Repository navigation
fix(cli): a spawn whose version dir cannot be claimed runs the declaration, loudly (TASK-174) - #1970
Merged
Merged
Conversation
…ation, loudly (TASK-174)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Follow-up to the merged #1965 (
62d226c9), from Vera's second non-blocking note (74903).cli/src+ tests, so cli goes0.1.77→0.1.78.The defect.
claimInUseswallowed every failure and returnedfalse.prepareMcpSpawnignored the return, so a spawn whose claim could not be written exec'd from a version dir the pruner was free torm -rf— the exact hazard the claim exists for — and said nothing. Vera's framing of the uncovered case:currentand the grace window cover the pointed-at dir and the young one, so what is exposed is ano-pointerfallback onto a dir older than the window.The fix: report it, and do not exec unprotected. I took the second of Vera's two options, and said why rather than picking silently. A claim failure means the directory under this seat is one a prune may take, so the spawn returns the declared command — what the guard approved, and what no pruner owns — instead of the home bin, and writes one line to stderr carrying the errno:
claimInUsenow returns{ claimed, reason };reasonis the errno (EEXIST,EACCES,ENOTDIR…), ornot_claimablefor a junk home / non-version / non-pid. A boolean could not tell "the home is a duplicate" from "nobody can write here", and only one of those is worth a sentence that names it.prepareMcpSpawngained an injectablewarn(default: one line toprocess.stderr, itself failure-tolerant) so the arm can hold the text.Measured, not assumed (the failure mode the arm uses is a real one, reachable in the field):
mkdirSync('<version>/.inuse', {recursive:true})against an existing file throwsEEXIST, and the file write under it throwsENOTDIR.Tests.
mcp-home.test.mjs51/51; full five-suite baseline (home + pi ×2 + claude + codex) 170/170, 0 runtime errors. New arms:a claim that cannot be written is LOUD: the spawn runs the declaration, not an unprotected dir— asserts the returned command is the npx declaration, the warn fired exactly once, and the line carries the version, the errno, and the consequence.positive control: a usable marker dir takes the home path and warns about nothing— without it the loud arm would also pass if the spawn always fell back, which would undo TASK-174 entirely.not_claimable, and the success arm asserts{claimed: true}, so the shape is pinned in both directions.Ledger — 15 mutations, no survivors (
/tmp/kai-174d-ledger.py, whole 5-suite baseline asserted per run as a(suites, tests)pair, so a suite that fails to compile cannot read as a kill):reason: 'claim_failed') → the same pair, because the line has to name the failure; M31 call a junk input claimable → the junk arm.mcp-warm-child.mjs, and they were all killed on the merged base. They remain valid only because that file is byte-identical to main in this PR.Note on the line, for the gate: the message says "prune could delete the directory this seat would run from" rather than naming a code path, because the pruner that would do it is a different process — the warm child — and a log line claiming otherwise would be the kind of comment that drifts.