Skip to content

fix(sandbox): skip identical skill installs and prune old snapshots - #2791

Merged
lyingbug merged 4 commits into
Tencent:mainfrom
lyingbug:fix/skill-snapshot-reuse-and-gc
Aug 25, 2026
Merged

fix(sandbox): skip identical skill installs and prune old snapshots#2791
lyingbug merged 4 commits into
Tencent:mainfrom
lyingbug:fix/skill-snapshot-reuse-and-gc

Conversation

@lyingbug

Copy link
Copy Markdown
Collaborator

Summary

  • Skip a billed sandbox + new snapshot when the uploaded archive matches a skill that is already ready (or still installing) and still present in the live image. Failed installs and skills that left the image still reinstall.
  • Have the skill reaper delete superseded provider snapshots after 24 hours. The live image, snapshots still inside the retention window, and extras not in the ledger are left untouched so shared provider accounts cannot lose another environment's image.

Test plan

  • go test ./internal/application/service/ ./internal/sandbox/ ./internal/types/
  • Re-upload the same zip of a ready skill and confirm no new generation / snapshot ID
  • Re-upload a previously failed skill with the same zip and confirm a retry starts
  • After 24h (or a test with shortened retention), confirm superseded snapshots are deleted on the provider while the current image stays

Re-uploading the same archive of a ready skill was still booting a billed sandbox and growing a new generation. Superceded snapshots also accumulated on the provider because the ledger never deleted them.

Skip the rebuild when the digest already matches a skill still in the live image, and let the reaper delete superseded provider snapshots after 24h while leaving extras not in the ledger untouched.
A re-upload of the same archive skipped every installing row, so a dead process could not recover until the reaper. Skip only recent in-flight runs, still refresh the stored bundle, and prune non-live active snapshots after retention.
A fixed window on the submission time cannot tell a slow install from a
dead one: a single agent command may take installCommandTimeout and an
install runs several of them, so a two-minute window called live runs
dead, reset their progress and pushed the reaper's own deadline out.
Stamp InstallingSince while the run works and read that instead, which
also stops the reaper from failing installs that are merely long.

Answer the skip question from the image only for a ready row. The ledger
records which skill a snapshot carries, not which archive, so a row
installing a new bundle would look finished from the previous bundle's
snapshot and report a success that never happened.

Prune now refuses to delete once the credentials no longer address the
account that built the image: the delete would come back not-found, and
the ledger would record another account's still-billed snapshots as
gone. It also waits for an eligible row before building a provider
client, since most configs have nothing to prune on most sweeps.
Keep the skip/heartbeat install tests and the tenantForStorage tests
that landed on main in the same file.
@lyingbug
lyingbug merged commit b412855 into Tencent:main Aug 25, 2026
4 checks 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