Repository navigation
control-plane: a template build's lastUsedAt is its own, not its worker id's - #941
Merged
Merged
Conversation
… worker's Every build of a template from one image shares one worker id (sbx_<template>_<image tag12>), and lastUsedAt was keyed by worker, so a new build reported an earlier, retired build's last sandbox, and a retired build the newer one's. lastUsed is now kept per build id, which every sandbox record created on a build carries; a record from before build tracing (no buildId) still counts for every build of its worker, as before. Closes rossoctl#936 Assisted-By: Claude Code Signed-off-by: Rong Chang <[email protected]>
ingpaolodettori-dev
approved these changes
Nov 20, 2026
ingpaolodettori-dev
left a comment
There was a problem hiding this comment.
Review — control-plane: a template build's lastUsedAt is its own, not its worker id's
Right diagnosis and a small, exact fix. A build's worker id is sbx_<template>_<image tag12>, shared by every build of one template from one image, so the per-worker timestamp attributed a retired build's sandboxes to a fresh build and vice versa. The facts now keep the newest creation per build id, with a per-worker map that only receives records carrying no buildId — which is exactly the pre-tracing rule the openapi description now states ("A sandbox record from before build tracing counts for every build of its worker").
lastUsedAttakes the later of the build's own newest record and its worker's legacy ones;nullonly when neither exists, so a build with no use still reports null rather than the map's absence (:0handled by thet > 0guard).inUseis untouched and stays per worker, which is correct — capacity belongs to the worker, use belongs to the build.- The test builds the real shape: one worker, a retired old build and a registered new one, a record on the old build only (new build null), then a pre-tracing record that both inherit. It would have failed before the change (both would report 150).
- The openapi note about a superseded twin sharing its successor's build id (#818) is honest about the one case the id cannot separate.
CI 18/18. Author: webchang (MEMBER — maintainer). One commit, signed off.
webchang
added a commit
to webchang/moca
that referenced
this pull request
Nov 20, 2026
Carries rossoctl#941-rossoctl#946, rossoctl#948, rossoctl#950 and rossoctl#338's rossoctl#949/rossoctl#951 (API 1.33.0). One conflict: docs/operate/sandbox-service/install.md's settings table; upstream's table kept (its rossoctl#945 SBX_STORAGE_CLASS wording, the OIDC and proxy-hop rows) plus the fork's SBX_GATE_RECORD_SCHEMA row. The fork-only set is unchanged: the same 30 files. Assisted-By: Claude (Anthropic AI) <[email protected]> Signed-off-by: Rong Chang <[email protected]>
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.
Summary
A template build's
lastUsedAtreported when its worker id was last used, not when the build was. Every build of a template from one image shares one worker id (sbx_<template id>_<image tag12>), so a freshly registered build reported an earlier, retired build's last sandbox, and a retired build reported the newer one's.Closes #936
What changes
packages/control-plane/src/sandbox-handlers.ts: the readiness facts keep the newest sandbox creation per build id (every sandbox record created on a build carriesbuildId), and per worker only for records from before build tracing, which carry none. A build'slastUsedAtis the later of its own and its worker's untraced records, ornull. The fallback is transient: records without abuildIdpredate build tracing and expire afterSH_SANDBOX_RETENTION_SECONDS(14 days by default,sandbox-config.ts:270), after which every build's value is its own.docs/api/openapi.yaml:TemplateBuild.lastUsedAt's description says it is per build, that builds of one template from one image share a worker id, that a build superseded by a rebuild of the same snapshot (feat(control-plane): reuse a registered build only while a host holds its snapshot #818) shares its build id with its successor (so the retired twin reports its successor's use), and how an untraced record counts.No version bump and no changelog entry: the field, its type and its shape are unchanged, and this corrects what it reports to match its description, a fix that is neither additive nor breaking under the change policy. Happy to add one if you'd prefer.
Tests
test/template-catalog.test.ts: two builds of one template sharing a worker id, sandboxes only on the retired build → the retired build reports its sandbox's time and the registered onenull; with an untraced record added, it counts for both builds of that worker.tsc --noEmitis clean, and the docs link check finds 0 broken links.Assisted-By: Claude Code