Repository navigation
Description
Follow-up promised in #4205, which fixed ~20 shapes in scripts/check-detector-eval-coverage.sh's emit scanner but did not change its foundation.
The problem is the approach, not the remaining bugs
The scanner hand-parses shell in awk to find emit <severity> <ID> call sites. Its failure mode of record is a silent loss: a literal call site that yields neither an ID nor an UNRESOLVED line, with CANDIDATES not counting it, so the count-vs-resolved accounting has nothing to disagree about and the gate exits 0 on a detector with uncovered check ids.
#4205 is the evidence that patching shapes does not converge. Six rounds of adversarial review, and four of them found defects introduced by the previous round's fix:
| round | found | of which introduced by the prior fix |
|---|---|---|
| 1 | 4 regressions | 4 |
| 2 | 7 silent losses | 3 |
| 3 | 6 silent losses, plus refuted the structural claim | 0 |
| Codex | 1 (P1) | 0 |
| 4 | 2 silent losses | 2 |
| 5 (V1) | 3 silent losses | 2 |
| 6 (different model family) | 6 silent losses, none previously found | 0 |
Each fix was validated before shipping. The defects were found by the next round, not by the tests written alongside the fix.
The shapes still open, all verified executing under real bash
Round 6 ran on the merged b229834ae and is the sharpest evidence, because it came from a different model family and found the simplest shape of all — one that five same-model rounds never tried:
x="$(emit error P1)" # bash: EMIT:error P1 scanner: CANDIDATES 0A command substitution inside double quotes collapses to a single opaque token, so its call sites never reach the tokenizer. A detector that captures its emitter's output is wholly invisible to the gate.
The rest of the open set:
- the closing line of a multi-line quoted string, when it carries a call after the quote (
' ... )" || emit error P2) — per-line quote resolution inverts the state there; $'...'with an escaped apostrophe, whose tail arms a delimiter that a later genuine heredoc then closes;- a
)#comment carrying a<<WORD, which swallows to the next WORD line; - command positions the walk does not model:
coproc,time -p, a leading redirection, a+=or escaped-space assignment prefix, a quoted command name ("emit" error P8),trap '...' EXIT,eval; $[ 1 << N ]deprecated arithmetic armingN;- two heredocs on one line (
cat <<A <<B), where only A arms.
Every one needs parser state a line-based scanner does not have. #4223 records them in the header and corrects three header claims that asserted some of them were already safe; it does not fix them.
Proposal
Replace the extraction with shfmt -tojson, which emits a real AST.
- Already a dependency.
shfmtruns in this repo's lint lanes today, so this adds no new tool to CI. - Replaces the class. Call sites, quoting, heredoc spans and command substitutions come from a parser that agrees with bash by construction, so none of the shapes above — and none of the next ones — are the scanner's problem.
- Fits the contract.
shfmtabsent, or a file it cannot parse, is an environment answer: exit 2, which the check-script contract already requires of an input the gate cannot read.
What to carry over
The 104-check self-test is the valuable artifact and should be the acceptance criterion for any replacement — it encodes every shape the rounds found, in both directions. Three disciplines in it are worth preserving explicitly, because #4205 shipped eight checks that reported clean while observing nothing:
- Arm-and-close. An arming case must assert that a call site after the terminator is still seen. "The body's own emit is hidden" is also satisfied by a swallow-to-EOF, so it passes exactly when the scanner is most broken.
- Measured discrimination. Every guard should be run against the revision carrying the bug it names, and fail there. In fix: read heredoc openings off the quote-resolved line in the eval-coverage gate #4205 five guards never executed at all (a helper defined 24 lines later;
command not foundon stderr while the suite reported green), two were byte-identical duplicates, and two exercised the wrong line. - Cross-model verification. Round 6 found six shapes that five same-model rounds missed, including the simplest one. Same-model review appears to share blind spots with the author.
A mutation audit keeps the first two honest: #4205's found three uncovered invariants that 104 passing checks did not.
Scope note
The gate governs one registered pair today (claude-config:audit-permission-grants), which resolves identically at every revision and contains none of the open shapes — independently re-confirmed in round 6. So nothing here is urgent. It is the difference between a gate that is correct today and a gate that stays correct as detectors are added.
🤖 Generated with Claude Code
Activity
kyle-sexton commentedon Sep 23, 2026
This was generated by AI during triage.
Human-gated. Open decision: whether to invest in the shfmt -tojson rewrite now (issue's own scope note says "nothing here is urgent" — gate currently governs one registered pair that resolves identically today)
fix(scripts): read emit call sites with shfmt --to-json (#4222) (#5065)
fix(scripts): report wrapper-prefixed emit calls as UNRESOLVED and co…
fix(scripts): stop the eval-coverage walk losing calls and pin its rules
test(scripts): pin the eval-coverage walk over case patterns, offsets…
fix(scripts): count a call with a word after its forwarder as a site
kyle-sexton commentedon Sep 29, 2026
This was generated by AI during the 2026-09-29 audit of the Cursor run.
Reopened, not for the shfmt decision (that ratify stands and is unchanged), but because the follow-up evidence this issue's "What to carry over" asked for is incomplete. PR #5339 (draft,
Refs #4222) carries the code and test work.Done
git diff 02c87fb82~1 02c87fb82 -- scripts/check-detector-eval-coverage.test.shremoves theundecidable_casegroup (exit 2 became exit 1 naming P4, six shapes: the id now resolves and is reported as lacking an eval case) andunclosed_case(exit 2 became exit 1). Those are the only flipped assertions. Each was checked against real bash: all seven fixtures parse (bash -n), real bash executes both emit calls, the new scanner reports both IDs, and the pre-fix(scripts): read emit call sites with shfmt --to-json (#4222) #5065 scanner answered exit 2.command,builtin,exec,nohup,eval,env,xargs) with an emit name in a later word, and a forwarder with a word after it (emit error "$@" P1), are now counted and reported UNRESOLVED (exit 2, site named) instead of vanishing. The suite is 166 pass, 0 fail.codex execexit 0) returned 14 findings. Re-probing the final script: quoted command words and quoted arguments,emit-finding, bundled-pvlookups and later-argument false positives are fixed; concatenated, escaped and computed command words (e"mit",\emit,$(printf emit)) are stated in the header as invisible by design. Findings 9 (quoted array-subscript evaluation) and 14 (trailing newline in an ID) were not re-verified in this pass.Still missing
The 15 surviving mutants have no recorded disposition. The audit plan required each to be shown equivalent or killed by a new test. Survivors, by id:
st-qlit,pp-paramexp,st-arrguard,st-objguard,pp-objtype,pp-noindex,if-quoted-any,mn-id-caret,mn-restnull,mn-select-args-drop,mn-select-args,hw-opts-i2,sh-cmp-gt,sh-cand-head,sh-res-noanchor. Several are plausibly equivalent guards, butif-quoted-any,mn-id-caret,mn-select-args-drop,mn-select-argsandhw-opts-i2change behavior a test should pin.Next steps (owner or a follow-up run)
scripts/check-detector-eval-coverage.test.sh.bash scripts/check-detector-eval-coverage.test.sh), then close.Nothing here reverses the shfmt ratify.
test(scripts): pin the eval-coverage counts, id anchoring and subscri…
kyle-sexton commentedon Sep 29, 2026
This was generated by AI during the 2026-09-29 audit of the Cursor run.
Disposition of the 15 surviving mutants and Codex findings 9 and 14, recorded in PR #5339 (draft,
Refs: #4222). The issue stays open until that PR merges.Survivors
The unmutated control still passes the suite (171 pass, 0 fail). Each equivalence below was checked structurally and by running the original and mutated jq programs over 1,117 inputs (every tracked shell script plus edge shapes) with no output difference.
st-qlit.Value, so dropping theLitcheck still yields null.st-objguardstaticonly sees a Word or null; for null,.Partsis null andlengthis 0, so the array guard returns null anyway.st-arrguard.Partsis always an array.pp-objtypelength == 1guard, so it is always an object.pp-paramexp.Param; other nodes give null and fail the@/*test.pp-noindex${@[0]}and${*[1]}("cannot index a special parameter name"), so no such node reaches the walk.if-quoted-anySglQuotednode with.Valueand no.Parts; the.Parts[0].Partslength test fails for it either way, and the suite pins'$@'as not a forwarder.mn-id-caret^is\A("\nP1" | test("^(P1)\\z")is false; only(?m)changes that). The leading-newline case is added as a pin.mn-restnullmn-select-args-drophidden_wrapped_emitand the emit test with a null command word and changes nothing.mn-select-args$rest, any other word has an empty.Args[1:].hw-opts-i2emitand cannot match^-[pvV]*[vV][pvV]*$.sh-cmp-gtIDline makes resolved exceed candidates; the gate must exit 2.sh-cand-headCANDIDATES 7line must not replace the lastCANDIDATESline.sh-res-noanchorIDis not anIDline.The three killed mutants are reachable only through a row pattern that accepts whitespace, which the header's row-pattern contract excludes. The cases pin the counts rather than report a live defect.
Codex findings
[[ -v 'a[$(emit error P1)]' ]]): rejected as by design. It is text until bash evaluates it, the same class aseval '...', and the header's "any other string bash evaluates later" covers it. A not-a-site case now pins it.\A(...)\z, the existing trailing-newline case asserts it is UNRESOLVED, and a leading-newline case is added beside it.Left open
The issue's decision (the shfmt
-tojsonrewrite, human-gated) is unchanged. Nothing remains for the mutation audit or the Codex review once #5339 merges.test(scripts): cover the shfmt version floor in the eval-coverage gate
kyle-sexton commentedon Sep 29, 2026
This was generated by AI during the 2026-09-29 audit of the Cursor run.
Owner decision needed: confirm the shfmt rewrite (priority low)
What happened. PR #5029 parked the eval-coverage shell-parser rewrite as unpaid work. It was closed without merging at 2026-09-28 05:26 UTC. PR #5065 merged the rewrite (
shfmt --to-json) at 07:23 UTC the same day. Neither PR says why the park was reversed. The issue was triaged needs-human, so no owner decision covers the rewrite. Where the earlier audit comment says "that ratify stands", it means the audit recommended ratifying. The owner has not decided.What it costs.
scripts/check-detector-eval-coverage.shneedsshfmtv3.13.0 or later and exits 2 without it..claude/cloud-bootstrap.sh:73, theci.ymllint-2 install step (:774), and the test-linux install step (:1707). A pin bump has to touch all three. No check keeps them in parity.Options
Recommended: A (judgment). The rewrite is merged, tested (171 cases), and fixes shapes the old scanner dropped silently. The pin duplication is a maintenance cost; a small pin-parity check can cover it if the owner wants one.
Reply A or B here. Choosing A closes this item. Choosing B unblocks a revert PR.
kyle-sexton commentedon Sep 30, 2026
Owner decision (2026-09-29): accepted the recommendation: "A. Ratify the rewrite as merged. Nothing changes. The mutation dispositions in PR #5339 stand."
The owner accepted every standing recommendation on 2026-09-29.
Evidence, checked against origin/main: PR #5065 merged 2026-09-28T07:23:27Z, and
scripts/check-detector-eval-coverage.shon origin/main usesshfmt(16 references). No revert is needed.Next: closing as completed. The survivor and Codex dispositions stay recorded in PR #5339 (
Refs #4222, still open), which merges on its own review. The optional pin-parity check for the threeshfmtpin sites is not part of this decision; file it separately if wanted.fix(scripts): harden audit-flagged gates and the eval-coverage scanner (