Skip to content

Keep a relaunched ship's credentials usable - #46

Merged
FireSquid6 merged 1 commit into
mainfrom
fix-relaunch-ship-credentials
Aug 13, 2026
Merged

Keep a relaunched ship's credentials usable#46
FireSquid6 merged 1 commit into
mainfrom
fix-relaunch-ship-credentials

Conversation

@FireSquid6

Copy link
Copy Markdown
Owner

Follow-up to #45, which merged before this fix was pushed. One commit.

The bug

A ship provisioned automatically by fleet launch was 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 no shipToken at all — and its armory pull was refused by the bridge.

Minting a fresh pair instead is worse, which is why the skip was there. ShipConnection captures the bridgeToken it 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_token in the clear because it has to present it, so it is recoverable; shipToken exists only as a hash and must be regenerated. So provisioning now reuses the stored bridgeToken and rotates only the shipToken. 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. createShipCredentials is replaced by provisionShipCredentials and removed; nothing needed a full rotation any more.

A ship's agent_token_hash now 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_at survives 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 bridgeToken rotated out from under it) and a guard against the skip being reintroduced.

Verification

bun test 1115 pass / 0 fail across 92 files, bun typecheck clean, bun run docs:build 34 pages. The fix was confirmed to be load-bearing by reverting it and watching the two key tests fail.

🤖 Generated with Claude Code

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>
@vercel

vercel Bot commented Aug 13, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
fleet-docs Ready Ready Preview Aug 13, 2026 6:08pm

@FireSquid6
FireSquid6 merged commit 4e6c26a into main Aug 13, 2026
2 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