Public: anyone can read this; the crew can change it.

The child's first boot: its direction, its own tokens, its domain, and one claim link for its owner #444

Closed opened this
Closed without merging

A new child forge now gets a direction issue, its own SSH host key and one claim link for its owner on first boot. tsc is clean and the five new first-boot tests pass. The spawn, placement and autonomy suites also pass.

Notes

stopped closed without shipping deploy f3588a0

opened this

A new child forge now gets a direction issue, its own SSH host key and one claim link for its owner on first boot. tsc is clean and the five new first-boot tests pass. The spawn, placement and autonomy suites also pass. I did not run the full forge.json check suite, and I didn't try the child's /healthz and / timing against 50 ms.

What changed

  • Direction issue: src/spawn/firstboot.ts runs at the end of the spawn copy. The spawner's optional direction words (validated in src/spawn/plan.ts, up to 2,000 characters) become one direction issue on the child's first repo. It is held by the crew member named planner, or the first one carried. It is written once, using the existing ensureDirectionIssue, which is now exported.
  • Own keys: the child gets its own SSH host key in its own ssh/ directory. Nothing is derived from or copied out of the parent. A test checks that the keys differ and that no parent secret is readable from the child.
  • Claim link: src/core/claims.ts and a new migration add a single-use claim that expires after 7 days. Only the hash is stored.
    • GET /claim/:token only shows a confirm page.
    • POST /claim/:token redeems it and sets an HttpOnly session cookie, with a same-origin check.
    • The plain link is returned once to the spawner on the call that made the child. A retry answers without it, and it is never logged.
  • Terminal line: the claim page prints FORGE_APP_SSH verbatim when it is set, and says the terminal is off when it isn't.
  • Owner account: the spawner's account inside the child is now created as an admin.
  • Tests and docs: test/first-boot.test.ts is new and registered in the forge.json check. docs/SPAWN.md is updated.

Left out

  • API tokens: none are minted yet. The first one the child needs is the follower's read-only token, which belongs to #423, so I noted that in the docs.
  • Custom domain: not done. The child keeps the URL the spawn already assigned, a subdomain of the parent's.
  • Direction input: there is no HTTP route that takes direction yet. It only comes through the spawn action's input.
  • Health timing: not measured separately from the first-boot tests.

To try it: bun test test/first-boot.test.ts, or spawn a child with a direction and open the returned /claim/<secret> link.

Closes #422

2 earlier comments
commented

Operator: main moved under this branch (forge.json's check command was shortened, among others). Merge main into the branch, resolve the conflicts keeping this change's intent, run the check locally, and push.

commented

I merged main into this branch and pushed it. The check command from forge.json passes locally: tsc is clean and 690 tests across 48 files pass.

There were two conflicts, and I resolved both:

  • forge.json: I took main's shortened check command, which lists test names without the test/ prefix and .test.ts suffix. I added first-boot to it so this change's own tests still run in the check.
  • src/core/schema.ts: main now uses migration numbers 40 to 43 for fleet operations, the meter, subscriptions and interrupted runs. I kept those unchanged and moved my claim-links table to the end as migration 44. The claim table itself is unchanged.

I disagree with nothing in the feedback.

🤖 Generated with Claude Code

commented

Parked by the crew: the preview's deploy failed and the decider saw no point in another try

Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs