Skip to content

feat(agents): add an explicit stop op for Sandbox sessions - #16

Draft
tee8z wants to merge 1 commit into
dev-2884-resumable-bindingfrom
dev-2884-explicit-stop
Draft

tee8z wants to merge 1 commit into
dev-2884-resumable-bindingfrom
dev-2884-explicit-stop

Conversation

@tee8z

@tee8z tee8z commented Oct 19, 2026 •

Copy link
Copy Markdown
Collaborator

A wedged Agent Sandbox session can ignore !shutdown, and the provider had no op to end it.
This PR adds a provider stop op. It suspends the Sandbox, so the controller deletes the Pod with SIGTERM.
The harness still gets its checkpoint window. The normal stop stays !shutdown.

The stop request is the deploy request with "op": "stop".
Before any cluster contact, stop_session() requires provider_config.sandbox, an approved identity_policy, and a verified launch owner.

Observed Sandbox Response state Action
None absent None
Different agent, owner, or thread Error None
lifecycle=ended ended None
lifecycle=ending ending None
Unknown lifecycle value Error None
Live ending One merge patch

The merge patch carries the observed metadata.resourceVersion. It sets buzz.block.xyz/lifecycle=ending, buzz.block.xyz/ended-reason=stopped, and spec.operatingMode: Suspended.
On 409 Conflict, stop() reads the Sandbox again, for at most 5 attempts. Then it returns Sandbox kept changing while stopping; retry.

info now returns ops: ["info", "deploy", "stop"]. The field is additive within protocol version 1, so the desktop can gate session controls on stop.

Stack

Position 10 of 20 in the DEV-2884 Buzz stack. Base: #15. Next: #2.

Validation

  • cargo fmt --check -p buzz-backend-kubernetes: pass.
  • cargo clippy -p buzz-backend-kubernetes --all-targets -- -D warnings: pass.
  • cargo test -p buzz-backend-kubernetes: lib 12 passed; bin 177 passed, 1 ignored; wire_fixtures 5 passed.
  • New tests:
    • stop_suspends_with_a_cas_patch_and_retries_conflicts
    • stop_requires_sandbox_scope_and_identity_policy_before_cluster_contact
    • parses_stop_with_the_deploy_payload, stop_response_serializes_flat, info_advertises_stop
    • The stop-no-identity-policy wire fixture.

Limits

  • The ignored test live_controller_reuses_scopes_and_refuses_lost_workspaces needs the kind-remote-agent-check cluster. It was not run. Its new stop steps were compiled only.
  • Temporary glue, removed by the recovery PR:
    • A stop request with sandbox.recovery fails options parsing (deny_unknown_fields). The recovery PR adds the explicit refusal stop does not accept a recovery mode.
    • The live test patches the tombstone with lifecycle::CHECKPOINT and skips the recovery steps.
    • The fixture README does not mention deploy-sandbox-bad-recovery.
  • Buzz AGENTS.md requires a human to test the change before it leaves draft.

Add a provider `stop` op for a wedged Agent Sandbox session. It takes
the deploy payload, requires provider_config.sandbox and an approved
identity_policy before any cluster contact, and sets lifecycle=ending,
reason stopped, and operatingMode Suspended in one resourceVersion CAS
merge patch (retried on conflict). The controller then deletes the Pod
with SIGTERM, so the harness keeps its checkpoint window; the normal
stop remains !shutdown.

`info` now advertises `ops`, additive within protocol version 1, so the
desktop can gate its session controls on `stop`. Adds wire tests, a
refusal fixture, and fake-apiserver coverage for the CAS patch.

Signed-off-by: Tee8z <tee8z@protonmail.com>
@tee8z
tee8z force-pushed the dev-2884-explicit-stop branch from 77ea3f1 to a6f2aec Compare October 19, 2026 23:28
@coderabbitai

coderabbitai Bot commented Oct 19, 2026

Copy link
Copy Markdown

Important

Draft PR not reviewed

Draft PRs are not automatically reviewed by default.

  • Trigger a manual review

To automatically review draft PRs, update your CodeRabbit configuration:

reviews:
  auto_review:
    drafts: true
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Comment @coderabbitai help to get the list of available commands.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant