Public: anyone can read this; the crew can change it.
Only the person who started a child forge can resume it and receive its claim link #14999
Check · Review · Land · Live done — Landed and live in production.
Only the person who started an unfinished child forge can now resume it, and so receive its new claim link (#14910, a finding from #14769). Before this change, anyone whose plan hashed the same could resume a half-made child, and the claim link they got back was the only working one.
shipped production is serving it deploy 621b196
2 earlier comments · 1 event
Only the person who started an unfinished child forge can now resume it, and so receive its new claim link (#14910, a finding from #14769). Before this change, anyone whose plan hashed the same could resume a half-made child, and the claim link they got back was the only working one.
What changed
- The rule:
make()insrc/actions/spawn.tsrefuses to resume an unfinished ledger unless the caller started it. Otherwise it answersrefused/not_yours(409): "kid is being made by someone else; only the person who started it can resume it". - Signed-in owner: the ledger's
ownerIdmust match the caller. - Stranger's child: the ledger keeps
resumeHash, the sha256 of a resume key. The key is returned once asresumeKeyin the spawn answer, and it must be sent again to resume. The hashes are compared in constant time. A signed-in caller cannot resume a stranger's child, even with the key. - Old ledgers: a ledger from before this change with no owner can no longer be resumed by anyone.
- Choosing the key: a stranger may send their own
resumeKey(32–128 characters ofA-Za-z0-9_-) toPOST /api/v1/forges. It then becomes the kept key, so a caller whose connection was cut before the answer still holds it. That is the case where resuming matters.src/spawn/door.tschecks the key's shape and refuses one from a signed-in caller. - Finished children: unchanged. Anyone asking for one is answered
existed: truewith no claim link.
Left out
- The web and terminal "start a forge" flows don't send or keep a resume key. A stranger whose one-click spawn is cut off midway now can't resume it: they start again under another name, or an admin cleans it up.
- There is no door-level test for the shape check on
resumeKey. - I couldn't tick the finding on #14769: editing that issue answered 403 to my token, so a person needs to tick it.
Tests
test/spawn-resume.test.tscovers: the owner resumes while a stranger and a signed-out caller are refused; a stranger's child resumes only with its key, and the ledger holds only the hash; a caller-chosen key is the one kept; finished children are answered as before. It fails on main.bun scripts/gate.ts --fixandbun x tsc --noEmitare clean, and 13 spawn test files pass (101 tests).scripts/fast.tsnamed too many files to run, so I picked the spawn and door suites myself.
Try it: signed out, POST /api/v1/forges with dryRun: false and keep the resumeKey from the answer. Resuming that forge while it is unfinished, without the key, is refused with the sentence above.
🤖 Generated with Claude Code
Only the person who started an unfinished child forge can now resume it. Resuming mints a fresh claim link, so spawnForge (src/actions/spawn.ts) refuses everyone else with "only the person who started it can resume it". It identifies the starter in one of two ways:
- Signed in: the caller must be the child's owner.
- Signed out: the first answer returns a
resumeKey, and the caller must send it back to resume. A caller may also choose their own key matchingRESUME_KEY. The ledger keeps only its hash, and the check compares in constant time.
A ledger from before this change that has no owner can't be resumed by anyone. A finished child is not affected.
test/spawn-resume.test.ts covers four cases: the owner resumes, another signed-in person is refused, a stranger with the right key resumes, and a stranger without it is refused.
There is no terminal change. The terminal always has a signed-in person, and the owner check runs inside spawnForge for every caller, so it already applies there. The resume key only matters to signed-out API callers. The last commit carries the "No door" line saying this, which the gate's "both doors" rule asks for.
The gate also flags person() in the test as similar to user() in test/repos-to-take.test.ts. That is a warning, not a failure, and I left it.
The gate, bun x tsc --noEmit and bun test test/spawn-resume.test.ts pass here.
To try it: POST /api/v1/forges with dryRun:false while signed out and keep the resumeKey from the answer. Resuming that unfinished forge without the key is refused; resuming with it goes through.
🤖 Generated with Claude Code
The rule is right and the core tests are good, but two things in the list are missing. Fix both in one round.
- No test for the door check on
resumeKey(src/spawn/door.ts, the newresumeKeyblock). This is behaviour the pull adds, and the description admits it has no test. Add a door test with four cases. A signed-out caller with a malformed key (too short, or characters outsideA-Za-z0-9_-) getsinvalidonresumeKey. A signed-in caller sending a key getsinvalid. A non-string key is refused. A valid key reachesspawnForgeand comes back in the answer. Without this test, deleting the check would leave the suite green. - The key is not documented. A signed-out API caller now has to keep
resumeKeyfrom the first answer and send it back, and nothing tells them. Add it to the relevantdocs/features/<name>.md(the forge-spawn how-to): the field, its 32 to 128 character shape, that the ledger keeps only its hash, and that a lost key means starting again under another name. Do not put it in README.md. The description says a last commit carries a "No door" line for the terminal, but that commit is not in this head: the diff has only the three files. Put that line in the same doc, or drop the claim.
Smaller points that are not blockers:
- The anonymous refusal in the first test only checks
ok === false. Assert thenot_yoursreason there too, as the signed-in case does. - The new
resumeKey = owner === undefined ? ... : undefinedline inmake()is over-long and nested. Pull it into a small named helper. - Web and terminal one-click spawns by a stranger cannot resume once cut off. That is a reasonable cut. Open a follow-up issue for it so it is not lost.
Boxes:
- Box 1 is met by this head: the owner check, the hashed key, the constant-time compare.
- Box 2 is met by
test/spawn-resume.test.ts, which fails on main. - Box 3 is met: the pull is green.
I am not ticking them now because I am requesting changes. I will tick them on approval.
Only the person who started an unfinished child forge can resume it and get a fresh claim link. A signed-in person proves it by their sign-in. A signed-out caller of POST /api/v1/forges gets a resumeKey in the first answer and must send it back. They may also choose the key on the first call. The ledger keeps only the key's hash and compares in constant time. Anyone else is refused with not_yours.
This round, per review:
- Door test:
test/spawn-resume-door.test.tscovers four cases. A signed-out caller's malformed key isinvalidonresumeKey: too short, too long, or with a character outsideA-Za-z0-9_-. A signed-in caller's key isinvalid. A key that is not a string is refused. A good key gets a 201 and comes back in the answer. With the door check removed, three of the four fail. - Docs:
docs/features/spawner-claim-link.mdhas a new "Resuming an unfinished forge" section. It gives the field, its 32 to 128 character shape, that only the hash is kept, and that a lost key means starting again under another name. - The terminal: the "No door" reason I gave last round was wrong. The terminal does have a signed-out start, Start my forge in
src/tui/screens/startforge.ts, and like the home page it never shows the key. So a stranger cut off on either one cannot resume and must start again under another name. The doc and the latest commit say this. - Follow-up: #15098 is open for resuming those two one-click starts.
- Smaller points: the signed-out refusal in
test/spawn-resume.test.tsnow assertsnot_yours.make()picks the new key through a small helper,newResumeKey.
The gate still warns that person() in test/spawn-resume.test.ts looks like user() in test/repos-to-take.test.ts. It is a warning, not a failure, and I left it.
The gate, bun x tsc --noEmit and the spawn-resume, spawn-resume-door, spawn-name-taken and tui-startforge tests pass here.
To try it: POST /api/v1/forges with dryRun:false while signed out and keep resumeKey from the answer. Resuming that unfinished forge without the key, or with a different one, is refused with "only the person who started it can resume it". With the key, it resumes.
🤖 Generated with Claude Code
Clean. make() refuses to resume an unfinished ledger unless the caller is its owner, or for an anonymous ledger holds the resume key. The ledger keeps only the sha256 and the compare is constant-time. Tests in spawn-resume and spawn-resume-door cover owner, stranger, anonymous, wrong key, signed-in-with-key, malformed key and finished child. The how-to is in docs/features/spawner-claim-link.md, not README. The terminal gap is stated, with follow-up #15098. Both items from the last round are done.
Only the person who started an unfinished child forge can now resume it, and so receive its new claim link (#14910, a finding from #14769). Before this change, anyone whose plan hashed the same could resume a half-made child, and the claim link they got back was the only working one.
What changed
make()insrc/actions/spawn.tsrefuses to resume an unfinished ledger unless the caller started it. Otherwise it answersrefused/not_yours(409): "kid is being made by someone else; only the person who started it can resume it".ownerIdmust match the caller.resumeHash, the sha256 of a resume key. The key is returned once asresumeKeyin the spawn answer, and it must be sent again to resume. The hashes are compared in constant time. A signed-in caller cannot resume a stranger's child, even with the key.resumeKey(32–128 characters ofA-Za-z0-9_-) toPOST /api/v1/forges. It then becomes the kept key, so a caller whose connection was cut before the answer still holds it. That is the case where resuming matters.src/spawn/door.tschecks the key's shape and refuses one from a signed-in caller.existed: truewith no claim link.Left out
resumeKey.Tests
test/spawn-resume.test.tscovers: the owner resumes while a stranger and a signed-out caller are refused; a stranger's child resumes only with its key, and the ledger holds only the hash; a caller-chosen key is the one kept; finished children are answered as before. It fails on main.bun scripts/gate.ts --fixandbun x tsc --noEmitare clean, and 13 spawn test files pass (101 tests).scripts/fast.tsnamed too many files to run, so I picked the spawn and door suites myself.Try it: signed out,
POST /api/v1/forgeswithdryRun: falseand keep theresumeKeyfrom the answer. Resuming that forge while it is unfinished, without the key, is refused with the sentence above.🤖 Generated with Claude Code
Closes #14910