Skip to content

Call a hibernated sandbox hibernated - #75

Merged
vitramir merged 2 commits into
mainfrom
sandbox-hibernated-status
Nov 3, 2026
Merged

vitramir merged 2 commits into
mainfrom
sandbox-hibernated-status

Conversation

@vitramir

@vitramir vitramir commented Nov 3, 2026

Copy link
Copy Markdown
Contributor

agyn sandbox list printed unknown for a sandbox the Agents service reports as SANDBOX_STATUS_HIBERNATED (agynio/agents#109). This PR names it on every CLI surface that prints a sandbox status. It also pins the connect plugin, because without the pin the bindings cannot be generated into a build at all.

Pin the connect plugin

  • Unpinned, buf.build/connectrpc/go now resolves to v2, which generates code for connectrpc.com/connect/v2. As a result, buf generate followed by go build fails on main today. This pins v1.21.0, the newest v1 release on the BSR, as Forward ReportWorkloadIdle, and fix the build gateway#212 did.
  • I compared every exported symbol under gen/ against the same plugins at the API commit in the previous buf.lock, and none was removed.
    • agents/v1 gains SANDBOX_STATUS_HIBERNATED and the agent hibernate, hibernate_after and hibernation_ttl fields.
    • It also gains three unrelated RPCs: DeleteOrganizationResources, ResolveAgentExists and ResolveEnvironmentExists.
  • The tracked files under the gitignored gen/:
    • The gateway bindings regenerate byte for byte.
    • The egress, groups and networks bindings had fallen behind and now pick up only additions. main's own egress_test already calls GetUsername, which only the regenerated file has.
    • CI regenerates all of them before every build either way.
  • buf.lock moves to the API commit the bindings were generated from. Regenerating at that commit gives an identical gen/.

Status names

Surfaces that print a sandbox status:

  • sandboxStatusLabel now returns hibernated. It feeds:
    • sandbox list, stop and delete, in table, JSON and YAML output.
    • The "multiple sandboxes; pass a name" candidate list that connect, stop, delete, cp, tabs and sync print when given no name.
  • The sync session's pause note now says "the sandbox is hibernated" instead of "the sandbox is stopped". It shows in sandbox sync status (detail:), in sync list -o json|yaml (note) and in the session log. The pause itself was already right: sandbox-sync.md says automatic resumption never restarts or wakes a sandbox.
  • Checked and left alone: formatExposureStatus, which prints exposure statuses only.
  • Not applicable: hibernating and waking are workload statuses, and the CLI neither generates runners/v1 nor prints workloads.

connect and start need no behaviour change:

  • connect calls EnsureSandboxRunning, which wakes the sandbox by writing it starting and keeping its workload. The existing wait for running then covers it, and the attach follows.
  • start creates a fresh sandbox, so it never meets a hibernated one.
  • A connect that lands while the workload is still hibernating is the race the spec accepts: the attach fails, and the next connect wakes the sandbox.

Not changed: sandbox cp does not call EnsureSandboxRunning. On a hibernated sandbox it polls until the 5-minute timeout, as it already did on a stopped one.

Testing

  • TestEverySandboxStatusHasALabel walks SandboxStatus_name. Because CI generates from the API's main, this test also fails when the API gains a status the CLI has no name for.
  • TestSandboxAtRestPausesTheSession covers both the stopped and the hibernated pause.
  • Each test fails with its fix reverted.
  • CI's job on a fresh export, with Go 1.24.0, is green: buf generate, go vet ./cmd/... ./internal/..., go test, the smoke test and go build.
  • With Go 1.26.3, go test ./... and go build ./... are green. go vet ./... under 1.26 flags only composite literals in the vendored third_party/mutagen, which is pre-existing; CI vets only ./cmd/... and ./internal/....
  • On the local agyn-kvm VM, agyn sandbox list --all shows sandbox hibsb1314 as unknown with 0.18.0 and as hibernated with this branch.

The BSR's newest buf.build/connectrpc/go is v2, which generates for
connectrpc.com/connect/v2. Left unpinned, `buf generate` now writes code this
module cannot build -- "no required module provides package
connectrpc.com/connect/v2" -- so every CI run and every release fails at the
build. v1.21.0 is the newest v1 release the BSR serves, and the one the
gateway pinned for the same reason.

With it, the tracked bindings whose protos have not moved regenerate byte for
byte. The rest gain only what the API gained since they were last committed:
DeleteOrganizationResources on egress, groups and networks; upstream TLS,
private-resource targets and the basic-auth username on egress rules; and
private-resource mediation on networks. Nothing is removed. Those copies were
already behind main's own code -- egress_test calls GetUsername, which only the
regenerated file has -- and CI regenerates them before every build either way.

buf.lock moves to the API commit this was generated from, which carries the
hibernated sandbox status.
The Agents service reports SANDBOX_STATUS_HIBERNATED for a sandbox whose idle
timeout put it to sleep on a runner that can hibernate, and `agyn sandbox list`
printed it as "unknown" -- for the one state that says everything in the
sandbox is still there, a connect away. sandboxStatusLabel names it, which
covers list, stop and delete, and the candidates a command lists when it is
given no name and the caller has several sandboxes.

A sync session over a hibernated sandbox already paused, as it should:
automatic resumption no more wakes a sandbox than it restarts one. But it said
"the sandbox is stopped" -- in `sync status`, in the session's note and in its
log -- and now says hibernated.

connect needs nothing new. EnsureSandboxRunning wakes a hibernated sandbox by
writing it starting, and the wait for running that follows is the one a
restart already takes. start creates its sandbox and never meets a hibernated
one. Sandboxes have no hibernating or waking status; those belong to
workloads, which nothing in the CLI reads.

The label test walks SandboxStatus_name, so the first CI run after the API
gains a status the CLI has no name for fails, rather than leaving it to
someone reading "unknown" in a list.
@vitramir
vitramir merged commit a7ba431 into main Nov 3, 2026
1 check passed
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