feat(pool): lifecycle auto-archive for idle sandboxes#1
Merged
Conversation
Add an archived state after hibernation: a hibernated claim idle past archive_after_seconds is checkpointed to the store and its local VM is dropped; the next access wakes it from the store keeping the same id/token/tenant and guest state, and archive_delete_after_seconds bounds retention. The archive image is hidden from the checkpoint API and cannot be listed or deleted while its claim is live. A persist failure on any transition (archive, wake, release, reap) rolls back so a durable claim never diverges from the store. Archived count is surfaced on /info, /metrics, and the SDK NodeInfo.
Post-review /simplify pass: - archive.go: extract deleteOrphanArchiveCk (two identical abort-path ck deletes) and compress the archive*For doc comment. - pool.go: extract benignSweepErr - the released/woke-mid-sweep error set was inlined in idleOnce/archiveOnce/reapOnce. - e2e/lifecycle: rename waitArchived's max param (shadowed the builtin).
Layout-only: the shared validation helper was wedged between the PoolSpec and StoreConfig type declarations, breaking the config-type cluster. Move it to the bottom with the other validate* funcs (standalone funcs below the type+method blocks).
CMGS
added a commit
that referenced
this pull request
Jul 9, 2026
Four comment em-dashes in pool.go were double-UTF-8-encoded (rendered as mojibake) by a scripted edit and merged in #1. Byte-restore only, no code change.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
M7-E lifecycle auto-archive
Adds an
archivedlifecycle state after hibernation so idle sandboxes stop consuming local compute while staying instantly resumable under the same identity.Behaviour
archive_after_secondsis checkpointed to the store and its local VM dropped (ArchiveCkset;VMName/VsockSocket/HibernateSnapcleared).archive_delete_after_secondsbounds retention (0 = keep forever).DeleteCheckpointwhile its claim is live, so a sandbox cannot be bricked through the checkpoint API.GET /v1/info,/metrics(sandboxd_archivedgauge +archives_total/unarchives_total/archive_deletes_total), and the Go SDKNodeInfo.Archived.Hot-path cost
Zero on the warm-claim and data-plane paths — archiving runs on the reap tick, off the claim path.
LastActivitymoved to a lock-freeatomic.Int64(benchmarked intypes/bench_test.go).Tests
archive_test.go): full lifecycle round-trip, retention purge, keep-forever, the checkpoint-API brick guard, idle/in-flight dedup, and all four persist-failure rollback paths; 4 verified by reintroducing the bug and confirming the test fails.go test -race ./...green;golangci-lint0 issues on linux and darwin.scripts/archive-e2e.sh+e2e/cmd/lifecycle): claim -> idle-hibernate -> archive (local VM dropped) -> wake in ~115ms with the same id and guest state intact; full regression harness green.