Repository navigation
fix: code-graph --api-policy: an unexpected error may exit 1, the same code as a ratchet miss - #628
Conversation
#625) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
review-code: FAIL @ 6f4907a content:d3965bda7ae1 — required CI is red at head: the crash path prints two stderr lines What has to changeThe required check
The second gate run with the bad The first run of the same command printed only the Where to look (my reading, not proven): Per criterion
Standing checks
Deviations
Nothing undisclosed that this gate could see. Verdict-written: 2026-10-11T02:38:41Z |
|
review-doc: FAIL @ 6f4907a content:d3965bda7ae1 — the docs promise one stderr line; CI at this head measured two What has to changeThree doc files state the same runtime fact: a crash prints one stderr line. At this head that is measured false. Both CI runs (38105398220, 38105394142) show the real command line printing The wording is what the issue asks for, so I expect the text to stand as written once the code makes it true. It cannot pass at a head where the only measurement contradicts it. Criterion 4[PASS on the text] Criterion 5, changeset half[PASS] Hygiene
Verdict-written: 2026-10-11T02:38:58Z |
…ng on stderr (#625) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Repair round 1, answering the two FAIL verdicts at 6f4907a. The fix is commit b695a2a, already the PR head; this run changed no file and pushed nothing. How this note comes late: the builder that made b695a2a died after its push and before its note. Two more spawns died too. This run adopted the last one's stranded claim (the lane ledger records it as Findings, each one answered:
Look at first:
Run in this tree at b695a2a: — at b695a2a |
|
review-code: PASS @ b695a2a content:c081a2a0e7b8 — crash exits 3 with one line; required CI green at head What changed since the last roundThe round-1 FAIL was a second stderr line, Per criterion
Behaviour claims I traced
Things to know, not blocking
Standing checks
Deviations
Nothing undisclosed that this gate could see. Verdict-written: 2026-10-11T02:59:03Z |
|
review-doc: PASS @ b695a2a content:c081a2a0e7b8 — docs name exit 3 and CI now measures the one-line claim true What changed since the last roundThe round-1 FAIL was the one-line claim, measured false in CI. The code now makes it true: Criterion 4[PASS] Criterion 5, changeset half[PASS] Hygiene
One thing to know: on a package with type errors a crash prints two Verdict-written: 2026-10-11T02:59:21Z |
code-graph --api(alone, with--api-base, or with--api-policy) used to end a crash with a Node stack and exit 1, the same code the ratchet uses for a miss. A CI job reading only the exit code could not tell the two apart.Now any error in the run that is not a refused input prints one line,
code-graph: unexpected error: <message>, with no stack and nothing on stdout, and exits 3. An--outfile that cannot be written is one of these, so it exits 3, not 2. Exits 0, 1 and 2 are unchanged.packages/code-graph/src/api/cli.ts:runApiViewno longer rethrows; it reports the line and resolves toAPI_CRASH_EXIT(3).packages/code-graph/src/api/crash.test.ts: the real command line on all 11 fixture branches (plain exit kept, then twice with a bad--out), the view and the diff with a bad--out, andrunApiViewwith a throwingemiton view, diff and ratchet.packages/code-graph/src/engine/tsgo.ts: closing a tsgo session now releases its open snapshots and sends the server SIGKILL before the API's own close. The server shares this process's stderr, and the API's close (stdin closed, then SIGTERM) could let it printcontext canceledthere, which is the second line CI saw.src/engine/tsgo.test.tspins the order.packages/code-graph/SPEC.md§13.6 and the "Published API" section ofdocs/reference/cli.mdname exit 3, and say the emit's diagnostics warning stays its own line.@demlik/code-graph.The exit code changes for the
--apimode only. The other modes (--tree --outand the--cigates) still crash with exit 1, as the issue leaves out of scope.Run here:
pnpm typecheckandpnpm lintfrom the root, and the wholepackages/code-graphsuite (75 files, 1075 tests), all passing. I did not run the rootpnpm test; CI answers that.The stray line did not reproduce on this machine: 160 runs of the real command line at the old head, on macOS, printed nothing extra. The fix rests on what SIGKILL is, a signal the server cannot handle, and on the order test.
Fixes #625
Deviations
--apirun inpackages/code-graph/src/index.ts. Did: caught the error one level down, inrunApiViewinsrc/api/cli.ts, and leftindex.tsas it was. Why:runApiViewalready maps a refused input to exit 2 there, and itsemitis injected, so one place owns every exit of the mode and a unit test can reach it. Disposition: stated here.fabrika build checkmust be green before a push. Did: pushed withbuild checkred on thecodeowners-cpguard alone, on both the code and prose surfaces, in both rounds. Why: the guard lists paths this repo does not have (packages/fabrika-cli/src/ci/,biome-plugins/and four more) and this diff does not touch.github/CODEOWNERS; it is the known upstream fault in build check's codeowners-cp step fails on paths demlik doesn't have #289. Disposition: stated here; the repo's typecheck and lint and the code-graph tests were run by hand and pass.--apimode only. Did: changed how every tsgo session closes, insrc/engine/tsgo.ts, so the modes that read types through it (--edges,--find,--blastand the rest) end the server the same way. Why: the stray stderr line comes from the server every mode shares, andsrc/engine/tsgo.tsis the one module that owns it; a fix inside--apialone would leave the same line in the other modes. Disposition: stated here; the changeset names it.killServerreads the server's child process off two private fields of the pinned tsgo build (client.channel.child). Why: the build spawns the server with stderr inherited and offers no option for it and no handle on the process. Disposition: stated here; a pin that moves those fields throws at close, so every test that reads types fails rather than the line coming back.code-graph:stderr line. Did: left the emit's diagnostics warning (code-graph: warning: tsgo reported N diagnostic(s)) in place, so a crash on a package with type errors prints that line and then the crash line. Why: the warning is §13.3's own documented line and is true whether or not the run then crashes; the fixture has no diagnostics, so the first criterion's run prints one line. Disposition: stated here and in SPEC §13.6 and the CLI reference.🤖 Generated with Claude Code