Keep a relaunched ship's credentials usable - #46
Merged
Conversation
A ship provisioned by `fleet launch` was left unusable the second time you launched it: already in the roster, it was skipped for registration and spawned with no credentials at all, so its armory pull was refused. Minting a fresh pair instead is worse — a ShipConnection captures the bridge token it was built with, so rotating that half leaves the bridge presenting a token the restarted ship no longer accepts, and the ship goes offline rather than merely losing its armory. Provisioning now reuses the stored bridge token, which the bridge keeps in the clear because it has to present it, and rotates only the ship token, of which it keeps a hash. The live connection stays valid and the restarted ship gets a working pair, so the skip is no longer needed. A ship's agent token survives provisioning: it is a third credential the bridge re-mints on every connect, and may be in flight in a workspace. This survived until now because nothing ever launched twice. The test that covers it inits the second manager before provisioning, the way a real relaunch does, so the token it asserts against is the one a live connection would be holding. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
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.
Follow-up to #45, which merged before this fix was pushed. One commit.
The bug
A ship provisioned automatically by
fleet launchwas left unusable the second time you launched it. Already in the persisted roster, it was skipped for registration, so no credential pair was minted, so it spawned with noshipTokenat all — and its armory pull was refused by the bridge.Minting a fresh pair instead is worse, which is why the skip was there.
ShipConnectioncaptures thebridgeTokenit was built with and cannot be told a new one, so rotating that half leaves the bridge presenting a token the restarted ship no longer accepts: the ship goes fully offline rather than merely losing its armory.The fix
The two secrets are stored differently, and that asymmetry is the way out. The bridge keeps
bridge_tokenin the clear because it has to present it, so it is recoverable;shipTokenexists only as a hash and must be regenerated. So provisioning now reuses the storedbridgeTokenand rotates only theshipToken. The live connection stays valid because the value it holds never changes, and the restarted ship gets a pair whose hash the bridge has just updated.With the hazard gone, the skip is no longer needed and is deleted — it only ever existed to dodge the rotation, so it was pure downside once the rotation was safe.
createShipCredentialsis replaced byprovisionShipCredentialsand removed; nothing needed a full rotation any more.A ship's
agent_token_hashnow survives provisioning. It is a third credential that the bridge re-mints and re-pushes on every connect, and it may be in flight inside a workspace; nulling it served nothing this operation cares about.created_atsurvives too, which it did not before.Why it survived review
Nothing ever launched twice. The regression test does, and the ordering matters: it inits the second manager before provisioning, the way a real relaunch does, so the token it asserts against is the one a live connection would actually be holding. An earlier draft that restarted the ship after provisioning passed even with the bug present — a test that cannot fail is worse than no test.
Ten tests added, none removed or weakened, including a negative control (a ship refuses a
bridgeTokenrotated out from under it) and a guard against the skip being reintroduced.Verification
bun test1115 pass / 0 fail across 92 files,bun typecheckclean,bun run docs:build34 pages. The fix was confirmed to be load-bearing by reverting it and watching the two key tests fail.🤖 Generated with Claude Code