test(scripts): read the vi.mock anti-exemption pin over the comment-blanked gate, and name the offending line - #8461
Conversation
…lanked gate, and name the offending line The pin in `scripts/__tests__/check-vi-mock-inherit.test.ts` matched `/\.test\.tsx?['"`]\s*[,\]]/` against the RAW text of `scripts/check-vi-mock-inherit.mjs`. That gate's leading docblock is the per-slice logbook objectui#6892 writes every sweep record into, and a record names test files: a backticked filename followed by a comma is byte-identical to one entry of the exemption array the pin exists to catch. It went red on running prose twice (objectui#8116 at 69 of 69, objectui#8207 at `e104c509d`), and both times the repair was to reword the sentence. Apply the gate's own rule -- only text the language would EXECUTE is judged -- to the gate's own source: run the ENTRY pattern over `maskComments(src)`. A real exemption array is a string literal, which the shared masker leaves intact, so the pin keeps every tooth; the header docblock becomes unreachable. The DECLARATION pattern still reads the raw source: `^\s*` stops at a docblock's ` * ` prefix, so it has no false red to narrow away. Report the offending LINES instead of `not.toMatch`, which printed the whole ~1850-line source as "received" and never said where the match was. A sibling case drives both directions with the raw match as its control: the array fixture must match before masking and still be reported after it, the header-record fixture must match before masking and be gone after it, and an array written below that prose is still reported. Census unmoved: `node scripts/check-vi-mock-inherit.mjs` exits 0 at 663 judged / 663 inherit / 0 auto-mocked / 0 other workspace before and after. Part of objectui#8117 Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01FhBNJcLRZLe8M87VcUgpKr
…ot to its start
Caught by the dispatch note's second positive control, which asked for the
ANCHORED carve-out shape (`const KNOWN_BAD = [...]`) alongside the unanchored
inline list. The pin went red as it must, but the line it named was
[ "1853: " ]
an EMPTY line, one above the declaration. `EXEMPTION_DECLARATION_RE` opens with
`^\s*` and `\s` matches a newline, so against a declaration with a blank line
above it the match STARTS on that blank line. Counting to `m.index` therefore
reported the blank line.
A failure message that names the wrong line is the defect this branch is about,
one level down, so the repair gets its own case rather than a comment.
Part of objectui#8117
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01FhBNJcLRZLe8M87VcUgpKr
|
LANDED —
⇒ The pin now reads code and keeps its teeth, and the two raw fixture checks are what will stop a future
|
Fixes #8117
Head
2a10ce4e1, base1706d8be4. Sessionsession_01FhBNJcLRZLe8M87VcUgpKr.The defect, re-derived on today's tree
scripts/__tests__/check-vi-mock-inherit.test.tscarries the assertion that keeps theexemption swamp out of
scripts/check-vi-mock-inherit.mjs. It read the gate's raw sourceand asserted it does not match the pattern below — one entry of a hand-written array of exempt
file paths (the character class holds a single quote, a double quote and a backtick):
That gate's leading docblock is 1128 lines and is, by construction, the per-slice logbook
objectui#6892 writes every sweep record into. Recording a sweep means naming test files, and a
backticked filename followed by a comma is byte-identical to one entry of the array the pin
exists to catch.
Measured on this branch's base (
1706d8be4), before any edit:The card's diagnosis reproduces exactly. Note row 3: the header already carries 13 backticked
test filenames and none is followed by a comma — that green reading is not evidence the pin
is sound, it is the tax the two previous repairs paid by rewording prose (objectui#8116 at 69
of 69, objectui#8207 at
caf312b93). Without the injected control, the zero would have meantnothing.
What changed
One file,
scripts/__tests__/check-vi-mock-inherit.test.ts, +99 / -4.maskComments(src)— the gate's own rule ("only text thelanguage would EXECUTE is judged") turned on the gate's own file. The shared masker leaves
string literals, templates and regex literals intact, so a real exemption array survives it
whole; only prose goes. The pin keeps every tooth and the docblock becomes unreachable.
^\s*anchor reaches a docblockline's
*prefix and stops, so that half has no false red to fix, and blanking it wouldnarrow an assertion for nothing. Leg 6 below measures that claim rather than asserting it.
not.toMatchprinted the whole ~1850-line gate asthe "received" value and never said where the match was; locating it needed a separate
grep -nPwith the pattern copied out of the test by hand. Both patterns are now namedconstants and both assertions go through one
offendingLines()helper reportingLINE NUMBER: source line. Measured below: 101417 bytes of failure report became 1336.zero-hit reading on a tree whose prose already dodges the comma would otherwise mean nothing.
⛔ No exemption was added, and none of
isCovered/coveredPrefixes/operandDenotes/COVERED_SPECIFIERSwas touched.scripts/check-vi-mock-inherit.mjsis not in this diff.A premise of the card is falsified
Both the card body and the triage comment prescribe "the masking helper the gate already
exports (
deJsxClosingTagsplus the sharedjs-comment-mask)".deJsxClosingTagswasretired by objectui#7883 and survives only as three lines of historical prose (gate line
1115, test lines 544 and 568). It is not a function, not an export, not callable. The other
half is live and is what the gate itself uses at
check-vi-mock-inherit.mjs:1603-1604, so therepair stands — but on
js-comment-maskalone.Two smaller corrections: the card describes the pin as one assertion, and it is two, only one
of which has the false red; and the dispatch brief quotes
660 judged / 660 inheritwhere thetree reads 663 / 663 today.
Ablation — six legs, every mutation proved on disk before any result was read
Each leg prints the HEAD blob hash, the on-disk blob hash and a marker count before the run
is read; an empty hash exits 9 rather than reading as "nothing to compare". Restore is proved
by state —
git diff HEADempty and both blobs equal to HEAD — never by an exit code. Bothscripts carry
trap RESTORE EXIT INT TERMwith absolute paths fromgit rev-parse --show-toplevel.origin/main(gate08a986a0af5ftobf2f4a5611c9, marker 1; pin3bd7dd19b060to650fd8eba6cb, marker 2)bf2f4a5611c9, pin identical to HEAD)673f3fab6ba4, marker 1)1854: const PER_FILE_CARVE_OUTS = [...]bf2f4a5611c9, marker 1)f84a6483cf9f, commas after that filename now 0)const KNOWN_BAD = [...]as CODE (adb4fbcdf8bb, marker 1)1854: const KNOWN_BAD = ['packages/x/src/A.test.tsx', 'packages/y/src/B.test.ts'];f29e3bf3762d, marker 1)Restore after each script: 0 paths differing from HEAD, gate blob and pin blob both equal to
their HEAD blobs.
Leg 5 found a defect in the repair, and it is fixed in
2a10ce4e1The anchored positive control is the reason the dispatch note asked for two positive shapes
rather than one. The pin went red as it must, but the line it named was
an empty line, one above the declaration.
EXEMPTION_DECLARATION_REopens with^\s*and\smatches a newline, so against a declaration with a blank line above it the match startson that blank line, and counting to the match offset reported the blank line. A failure message
that names the wrong line is the defect this branch is about, one level down.
offendingLinesnow counts to the first non-whitespace byte of the match, and a dedicated case pins it. Leg 5
re-run on the fix reports
1854:with the declaration's own text, as the table shows.Census unmoved
node scripts/check-vi-mock-inherit.mjs, exit 0, before and after — byte-identical lines:Commands, with real output
All heavy runs through the shared
os-verify-lock.sh(slotissue-8117-vi-mock), verdicts readfrom its own
VERDICTline rather than a bare exit status. Head2a10ce4e1, tree clean.vitest run scripts/__tests__/check-vi-mock-inherit.test.tsTest Files 1 passed (1),Tests 86 passed (86)(84 before this PR)node scripts/check-vi-mock-inherit.mjsnode scripts/check-vi-mock-specifiers.mjsnode scripts/check-control-bytes.mjsnode scripts/check-comment-mask-corpus.mjstsc -p tsconfig.scripts.json--listFilesconfirms the program contains the changed file (count 1), so this is a measurement, not a NOT MEASURED readingpnpm run lint:root--format json, 0 errors, 32 pre-existing warnings, 0 in the changed file (control: another file does appear in that output)node scripts/check-changeset-presence.mjsgrep -naPfor control bytes on the changed filenode scripts/check-governed-queue-guard.mjs --test …Bare objectui#8202 was filed for the second instance and a maintainer already marked it a
duplicate of this card. It is mentioned for history only and needs nothing from this PR.
🤖 Generated with Claude Code
https://claude.ai/code/session_01FhBNJcLRZLe8M87VcUgpKr