Skip to content

pool: root's by-id read serves a root-adopted claim's placeholder token, and the claim answers it - #682

Merged
CMGS merged 3 commits into
mainfrom
pool/serve-adopted-token
Dec 2, 2026
Merged

CMGS merged 3 commits into
mainfrom
pool/serve-adopted-token

Conversation

@tonicmuroq

@tonicmuroq tonicmuroq commented Dec 1, 2026 •

Copy link
Copy Markdown
Contributor

Problem

When the root adopts an archived claim, it keeps the hash of the claim's token and a random placeholder (e17eee8). The by-id read hides the placeholder, and authed refuses it. So root's GET /v1/sandboxes/{id} returns no token until someone presents the original token.

A control plane that keeps no copy of the token reads it back from that route, as docs/sandboxd-api.md describes. Once such a claim moves to another node through a root adoption, nothing the control plane holds works. The agent relay and the port relay refuse every call until the claim is released.

Change

  • Manager.Sandbox no longer blanks the token while the hash is set. Root's and the operator's by-id reads return the placeholder (the minted token), and the operator read is audited as before.
  • authed accepts the claim's current token first, the minted one included. Otherwise, while the hash is set, it accepts the original token and makes it the claim's token, as before. From then on the minted token is refused.
  • Unchanged:
    • The archive row carries only the hash of the original token, so the minted token does not adopt the claim on another node.
    • A hand-off (an evacuation, or a wake on a full node) still asks as the root while the hash is set, so the adopting peer mints a new token.
    • The listing, checkpoint reads and the archive row never carry either token.
  • A claim adopted before this change already has its placeholder in claims.json. It is served after the upgrade with no migration.

What a holder of the minted token sees

  • The minted token stays with the claim through a live move and a resize.
  • It answers 404, like a call on a released claim, once the claim's own token replaced it or the claim was adopted again by the root (an evacuation, a wake hand-off from a full node, or any other root adoption). Root's by-id read on the owner then serves the token that works; read it again.
  • The replacement by the claim's own token is saved at the claim's next record write or at a clean shutdown. A node that crashes before that serves and accepts the minted token again until the own token returns.

Authority

No caller gains authority. The minted token goes only to root's and the operator's by-id read; both already act on every claim, and the operator already reads every ordinary claim's token there, audited. A tenant token gets 403 on that read; the listing, checkpoints, usage events and audit records carry no token.

Mixed versions and rollback

  • A node on v0.1.26 to v0.1.39 that receives such a claim by a live move, or reads it after a rollback, hides the minted token and refuses it, as today; the claim's own token still works there. Roll every node before a control plane relies on the minted token.
  • Nothing persisted changes shape.

Hot path

authed costs one constant-time compare for an ordinary claim and for a minted-token caller, as before. A claim's own token on a root-adopted claim costs one compare and one SHA-256 once, then it is an ordinary claim. Manager.Sandbox lost a branch.

Docs

  • docs/sandboxd-api.md: the by-id read (what the minted token is, how long it lasts, the 404 and the re-read), the evacuation paragraph, the /owner section.
  • docs/cluster.md: a wake hand-off and an evacuation of a root-adopted claim mint a new token; a released row no node lists is adopted by root's /owner too, so a holder that reads the token back no longer loses the claim.

Tests

  • TestFailoverTheRootAdoptsWithoutTheToken: the placeholder now opens the agent socket.
  • TestFailoverARootAdoptedClaimAnswersOnlyItsOwnToken is renamed ...AnswersItsOwnTokenAndThePlaceholderRootReads:
    • The placeholder wakes the claim, and root's by-id read serves it.
    • After a restart, it still works and is still served.
    • After the original token arrives, root's read serves the original and the placeholder is refused.
    • An empty token, a wrong one, the hash and a tenant token are still refused. The listing and checkpoint reads still carry neither the hash nor the placeholder.
  • TestFailoverARowRewriteOfARootAdoptedClaimKeepsTheTokenHash: another node refuses to adopt the claim for the placeholder.
  • TestFailoverARootAdoptedClaimReadsAsAnUnknownTokenToAnOlderNode is deleted. It modelled a node without token_sha256 (before v0.1.26); the placeholder's shape and its place in claims.json are pinned by the two tests above.
  • On the old operator.go, the first two tests fail where the placeholder is presented.
  • Gates on main 10cd885 plus this change: golangci-lint 0 issues in all five modules on linux and darwin, asl clean, go test -race ./... green on darwin and in a linux container.
  • Not run on hardware: the change is the in-memory token check and one HTTP read.

…en, and the claim answers it

A root adoption from the archive keeps the claim token's hash and a random
placeholder. The by-id read hid the placeholder and authed refused it, so root's
GET /v1/sandboxes/{id} answered without a token until someone presented the
original. A control plane that keeps no copy of the token, and reads it back
from that route, could then not reach the claim on the agent or port relay.

The placeholder is now a token: root's by-id read serves it, and the claim
answers it as well as the original. The first call with the original still
replaces the placeholder. A claim adopted before this change kept its placeholder
in claims.json, so it is served after the upgrade with no migration. The archive
row still carries only the original token's hash, so the placeholder cannot adopt
the claim on another node, and a drain hand-off still asks as the root.
@tonicmuroq
tonicmuroq requested a review from CMGS December 1, 2026 16:15
CMGS added 2 commits December 2, 2026 06:44
…te what the minted token is good for

authed returns on a token match and refuses before the hash learn, so the switch needs no comment; same answer on every input.
The older-node test is renamed and compares with the placeholder: the placeholder is now a token root reads, so it pins that token, not an unknown one.
cluster.md: root's /owner adopts a released row with no owner, so a holder that reads the token back no longer loses the claim; sandboxd-api.md: the minted token survives a live move and a resize, adopts on no other node, and each root adoption mints a new one.
…one; tests pin the other-node refusal and drop the pre-v0.1.26 reader

The by-id read says a replaced minted token answers 404 like a released claim and that any hand-off mints a new one; two touched lines are rewrapped.
cluster.md says a wake hand-off or an evacuation of a root-adopted claim moves it as the root, so a minted-token holder reads the token again.
The /owner section says root's by-id read returns the minted token until the claim's own token arrives.
The row-rewrite test checks that the placeholder is refused when another node adopts the claim.
The older-node test is deleted: it modelled a node without token_sha256 (before v0.1.26, outside the supported mix); the placeholder's shape and its claims.json persistence are pinned by the root-adoption tests.
@CMGS
CMGS merged commit c6304c4 into main Dec 2, 2026
2 checks passed
@tonicmuroq
tonicmuroq deleted the pool/serve-adopted-token branch December 2, 2026 01:49
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.

2 participants