Repository navigation
fix(handoff): #973 minors: random-token fence, late continuation row, bun/deno refused - #1025
Conversation
|
not a lens: narrow check after fix round 1 Read at 0. The move: OK. 1. Secret scan fix: OK. 2. Busy-worker test: OK. 3. Unreadable outbox row is owed: OK.
4. R and Rscript: OK. Runs on head, one file at a time: Non-blocking (none needs a new round):
CI at read ( 🤖 Generated with Claude Code |
… its trade-off From the narrow check on #1025. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Replaces #1021: the same change as one commit. The old branch had a test value in one commit that the per-commit secret scan flags (the value is a test placeholder, not a secret). Rewriting that branch would need a force-push, so the final files moved here;
gitleaks gitoverorigin/main..HEADfinds no leaks.All five follow-ups from the #958 round-2 lenses, each fixed at the root. Every change is in fork files (
apps/server/src/fork/handoff/,docs/fork/handoff.md), so no seam lines are added or announced.What changed, per item
handoffMessage.ts). Part 2 (a command's output or the old session's notes) now goes in exactly as written, between----- begin … <token> -----and----- end … <token> -----. The token is 128 random bits drawn for that message (randomFenceToken, Web Crypto), and the line before the fence says the notes end only at the end line with that token. The notes are written before the token exists, so no line in them can end the fence early, however it is disguised: Greek capitals, small capitals, Armenian, ǝ, Cherokee, an HTML tag, U+001C..1E, or a guessed token. If the notes happen to contain the token, a new one is drawn.CONFUSABLES,LOOKS_LIKE_OURSandneutraliseNotesare removed.handoffContinuationRow.test.tsruns upstream'sProviderRuntimeRecovery.reconcile("startup")on a write turn that a restart cut short. It checks that the onlyprovider-runtime.continuerow written has idcontinuationEffectId(writeRun)(now exported fromHandoffService.ts). The harness tests now use that helper instead of a copied string. Mutation check: renaming the id fails this test while every HandoffService test stays green.HandoffService.finishWrite). While upstream's continuation row ispending/running, the handoff waits for it to settle, however late a busy effect worker gets to it. The one-minute-past-due limit now applies only when no row is written yet (a retry row upstream writes right after the failure). If waiting on the row fails, the row is read again after 5 s. A row that cannot be read counts as owed, never as "no row": it is read again every 5 s (round 1).parsed.fallback. New test: after a restart, a failed write turn on a thread below the size backstop sends the fallback only when it is marked:fallback. Mutation check: removing theparsed.fallback ||term turns it red.PROJECT_CONFIG_RUNTIME), whatever script they are given. They readbunfig.toml(preload) ordeno.json(import map) from the project folder before the script runs. They are removed from the interpreter list, anddeno run/bun runno longer need special handling. Round 1 adds R:Ris refused whatever it is given, andRscriptunless--vanillacomes among its options (before its script or-e), as R sources.Rprofileand reads.Renvironfrom its working folder first.Failing first
Every new test was run against the unfixed code first:
handoffMessage.test.ts: red (fenceLine is not a function: the fence did not exist).HandoffService.test.ts: 4 red. The busy-worker test fails at the 10-minute check (expected 1 to be +0: the chain was judged after one minute). The fence tests are the other 3.handoffCommandSaveCheck.test.ts: the bun/deno test is red (the command was accepted).handoffContinuationRow.test.ts: red until the export.Items 2 and 4 add tests only, with no behaviour change; their mutation checks are above. After the fixes, each changed file passes on its own (17, 1, 10, 15 and 84 tests), and
vp run check:changedpasses (format, lint, knip, typecheck, tests).fork-seam-check.cjs origin/main HEADalso passes.State question
A handoff that runs again, stops half-way, or meets an old outbox row or an empty thread is still sent at most once, and never without its notes when they exist:
dispatchHandoffdrops a second send. A rebuilt text draws a new token; only the token differs, and the existing "second trigger" test now compares the texts with the token taken out. A failed handoff's retry resends the stored text, token included.restartContinuationOfRunId), and a new loop picks the chain up (continuedWrite→carriesOn), with the same ids. A pending row no longer runs into a time limit, so the continuation's notes are not dropped in favour of the fallback.pendingforever, or an outbox that can never be read, would keep this one handoff waiting, with nothing sent. That fits at most once. A newer turn end replaces the wait, as before.General vs project
R, andRscriptwithout--vanillarefused in a new handoff command. Such a command saved earlier is not checked again.:fallbackcoverage; and thedocs/fork/handoff.mdchanges.Round 1 (code lens)
generic-api-keyon the test constant athandoffMessage.test.ts:12FENCE_ID, value built at run time (Array.fromover 0..f twice); no ignore or allow-list entryhandoffMessage.test.ts17 pass. Local gitleaks 8.30.1 (checksum checked) with main's.gitleaks.toml/.gitleaksignore: the new commit and the files as they stand have no leaks. The repo's scan script itself cannot run on this Mac (it needs bash 4). The PR's Secret scan stays red: it reads every commit ofmain..head, and4bb4067a33still adds the line. Clearing it needs the owner's call (rewrite that commit, an exact-value allow on main, or a new branch); none was done here.HandoffService.ts:422-423)runUpdated(write)) after the first 10 minutes, then thetoBe(0)andsentchecksgiveUpMs = after.dueMs + stopWaitMsback: red (expected 1 to be +0); green with the fixHandoffService.ts:333-343,:451-456)continuationOfreturns owed (wait: "unread") for a failedget; the loop reads it again afterCONTINUATION_RECHECK(5 s) with no limit. The owed kinds are nowrow,retry,unreadRscriptreads.Rprofile/.Renvironfrom the project folder (handoffCommandSaveCheck.ts:19,docs/fork/handoff.md:166)Rrefused outright;Rscriptrefused unless--vanillacomes before its script or-e(after them it is the script's argument); with--vanillaits script is checked as before. Docs updatedRuns after round 1, one file at a time:
HandoffService.test.ts86 pass,handoffCommandSaveCheck.test.ts11 pass,handoffMessage.test.ts17 pass;vp run check:changedpasses (format, lint, knip, graphql, typecheck, 6 test files). The macOS-only__CF_USER_TEXT_ENCODINGfailure inhandoffCommand.test.tsdid not come up (that file is unchanged and was not run on its own).Fixes #973
After the narrow check (SAFE TO MERGE, comment 7085795419)
docs/fork/handoff.mdnow says an unreadable continuation row is read again every 5 s, with its trade-off.Rterm,Rcmd,Rscript-4.3andRscript --args --vanilla: other names are covered by the doc's existing "not named above, or under another name" rule (the check refuses known names; it is a safety net, not the wall). No test pins the-echeck: the code is right and the narrow check probed it by hand.🤖 Generated with Claude Code