Repository navigation
fix(handoff): #973 minors: random-token fence, late continuation row, bun/deno refused - #1021
scuttletoby wants to merge 2 commits into
Conversation
…nuation row; refuse bun and deno (#973) - Part 2 (a command's output or the old session's notes) goes as written between begin and end lines carrying a 128-bit token drawn for the message, replacing the look-alike list and quoting. - The restart continuation row's id is checked against upstream's real restart writer. - A written continuation row is waited for until upstream settles it, however late a busy effect worker runs it; only an unwritten retry row is given up a minute past its due time. - A test covers the `:fallback` mark deciding the fallback for a write turn found after a restart. - The handoff command save check refuses bun, bunx and deno: they read bunfig.toml / deno.json from the project folder before any script. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
lens: code · reviewer: code lens agent · read at: 4bb4067
🤖 Generated with Claude Code |
…out --vanilla; pin the busy-worker wait (#973) Round 1 of review on the #973 follow-ups: - handoffMessage.test.ts: the fence id stand-in is named FENCE_ID and built at run time, so the secret scan no longer reads it as a key. No ignore entry. - HandoffService: an outbox row that cannot be read is owed, not "no row": the loop reads it again after 5 s, with no limit, so the fallback never goes out without the continuation's notes. - The busy-worker test offers a thread event during its wait, so the one-minute limit coming back turns it red. New tests: an unreadable row, then the 5 s re-read; a failed wait on the row read again after 5 s with no thread event. - The handoff command save check refuses R, and Rscript unless --vanilla comes among its options: R sources .Rprofile and reads .Renviron from the project folder before the script. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Replaced by #1025 (the same change as one commit; an earlier commit here trips the per-commit secret scan, and fixing that would need a force-push). 🤖 Generated with Claude Code |
… bun/deno refused (#1025) * fix(handoff): #973 minors: random-token fence, late continuation row, bun/deno refused One commit with the full change from #1021 (rounds 0 and 1). The earlier branch had a test value in one commit that the per-commit secret scan flags; this branch carries only the final files, which scan clean. Fixes #973 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * docs(handoff): say an unreadable continuation row is read again, with its trade-off From the narrow check on #1025. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
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
🤖 Generated with Claude Code