Repository navigation
Description
Summary
T6 docs-parity's site scan is anchored with [^\n]* on both sides of --grep=, so it only matches when git log and --grep= sit on the same physical line. Shell line-continuation is invisible to it: a semantically identical derivation, wrapped across lines for readability, yields zero scan hits and the assertion passes.
The scan is shared by two different generations of the assertion, and the blind spot defeats both.
Affected code
tests/code-review-pipeline-regression.test.cjs#L1036 — the T6 docs-parity case:
for (const m of src.matchAll(/^\s*[A-Z_]+=\$\(git log[^\n]*--grep=[^\n]*$/gm)) {
grepSites.push(m[0]);
}On next (97ce61dee) that feeds an anti-revert ban:
assert.deepStrictEqual(
grepSites.filter((l) => l.includes('PHASE_SCOPE_NUM') || /phase-\)?\(/.test(l)),
[],
'no phase-scope message-grep derivation may remain — subjects carry no milestone bound (#3995)'
);Two independent reasons a continued assignment escapes:
- The scan never matches it.
[^\n]*cannot cross a newline and the pattern is$-anchored, sogit logand--grep=must share a line. - Even if it matched, the filter would miss.
PHASE_SCOPE_NUMnormally sits on the--grep=line — a different physical line from the[A-Z_]+=$(git logthe scan would have captured — sol.includes('PHASE_SCOPE_NUM')tests a string that does not contain it.
This is live in the release too, with a different consequence
Re-checked against v1.12.0 (published 2026-08-30). The scan there is byte-identical, but T6 is a different assertion — #3995 later inverted its polarity:
| ref | what T6 asserts | what a wrapped site does |
|---|---|---|
v1.12.0 |
every grep derivation uses the identical #3503 scope-anchored, POSIX-portable pattern, and grepLines.length >= 3 |
invisible to the count, and never reaches the per-site SCOPE_GREP / --extended-regexp conformance assertions |
next 97ce61dee |
no phase-scope message-grep derivation may remain | escapes the ban outright |
At the tag the failure mode is arguably worse than a missed ban: a wrapped site is silently exempted from the pattern-conformance checks that exist to catch the macOS \b-no-op class, so it could carry exactly the malformed pattern T6 was written to reject.
Reproduction
Driving the scan (copied verbatim from the shipped test) against two semantically identical fragments — same variable, same git log --extended-regexp --grep= with the same phase-scope pattern; the only difference is two backslashes and two newlines:
same-line scan-hits=1 after-filter=1 => T6 FAILS (caught)
backslash-continued scan-hits=0 after-filter=0 => T6 PASSES (missed)
Repeated with the regex extracted verbatim from the v1.12.0 file: same-line caught=1, continued caught=0 — identical.
Cross-checked against a real file rather than a fixture: running the shipped scan over a code-review.md carrying two such continued derivations, both containing PHASE_SCOPE_NUM, returns []; a multiline-tolerant pattern over the same bytes returns 2.
This is not hypothetical formatting. Wrapping is the natural shape for a git log invocation carrying a long ERE, and it is what a real candidate implementation did while working on #3926 — that change passed T6 and was caught only by later manual review, not by the guard.
Why it matters
T6's own comment records that the class it guards "failed five times: #2989/#3191/#3503/#3995". A guard for a five-time-recurring defect that under-detects on a common formatting choice is worth a line of repair.
Suggested fix
Fold continuations before matching, rather than widening the regex in place — the assertion's message and its filter both assume one site is one string, and a naive [\s\S]*? would let the scan run across unrelated statements:
// Join backslash-continued lines so a wrapped assignment presents as one
// logical line; the site scan below is otherwise unchanged.
const logical = src.replace(/\\\n\s*/g, ' ');…then scan logical instead of src. One line, and it repairs both generations of the assertion because it corrects the scan rather than what is built on it.
Verified across a matrix, including negative controls:
| input | before | after |
|---|---|---|
| same-line derivation (must stay caught) | caught 1 | caught 1 |
| backslash-continued derivation (the hole) | caught 0 | caught 1 |
benign non-phase-scope --grep (must stay clean) |
0 | 0 |
unrelated wrapped assignment near a --grep= string (must not glue) |
0 | 0 |
real code-review.md with two continued derivations |
caught 0 | caught 2 |
pristine next code-review.md (must stay clean) |
0 | 0 |
The last row is the one that matters for adoption: the fold introduces no false positive on the current tree, so it can land without touching any workflow file.
Worth pinning with a negative-control test asserting the continued form is caught, so the hole cannot silently reopen.
Happy to send this as a PR if useful.
Activity
trek-e commentedon Sep 4, 2026
Diagnosis
Reproduced and confirmed. Driving the shipped scan exactly as written against two semantically identical fragments — same variable, same extended-regexp grep with the same phase-scope pattern, differing only by two backslash-newlines — the single-line form is caught while the backslash-continued form produces zero scan hits and sails through the assertion. The cause is twofold: the site pattern cannot cross a newline (so a wrapped invocation is never captured at all), and the downstream filter inspects only the captured physical line, which would not contain the phase-scope token even if the first line matched. The same scanning code also underpins the earlier released generation of the assertion, where a wrapped site silently exempts itself from the pattern-conformance checks.
Two historical changes are relevant: the scan was introduced with the portability guard, and a later change inverted the assertion's polarity while keeping the byte-identical scan, so both generations share the hole. The current tree is clean — no grep-based derivations remain in the guarded workflow documents — so this is a latent blind spot in a regression guard, not a live violation. The reporter's suggested repair (fold continuations into logical lines before scanning) changes nothing on the pristine tree and closes the gap in both generations; pinning it with a negative control that asserts the continued form is caught would prevent the hole from silently reopening.
Classification: bug in tests, confirmed.
Agent Brief
Behavioral guidance: any guard that scans shell sources for dangerous command shapes must scan logical lines, not physical ones. Before adding or reviewing a source-scanning assertion: (1) normalize line continuations first so wrapped invocations present as one statement; (2) make sure the property being checked is actually inside the captured span, not on a neighboring line; (3) always pair such guards with a negative control asserting the dangerous wrapped form is caught, and a clean-tree control asserting zero false positives; (4) remember a widening lazy match across newlines is not a safe substitute — it can glue unrelated statements — folding continuations is the safer primitive.
github-actions commentedon Sep 4, 2026
Branch
fix/4259-bug-tests-t6-docs-parity-site-scan-requicreated.git fetch origin && git checkout fix/4259-bug-tests-t6-docs-parity-site-scan-requitrek-e commentedon Sep 11, 2026
Closing as a duplicate of #4631 — consolidating at the seam rather than fixing per-symptom.
This is not a dismissal of the report. Your specifics are preserved verbatim in that epic's Absorbed issues table, and its Done when checklist requires a failing-first regression test for this exact defect before the epic can close.
Why it is being consolidated: a scan of all 69 open
confirmed-bugissues (2026-09-11) found this one shares a single root cause with seven other open issues — a gate hand-rolls a narrow derivation of what it should evaluate, the derivation comes back empty, and "empty" is reported as "pass". Fixing each occurrence where it was found leaves the remaining call sites carrying the same bug, which is the pattern that produced this cluster in the first place.The epic delivers one
resolveEvaluationScope(), evidence read through the existing document seams instead of per-gate regex, and anEvidencetype that distinguishes "none" from "could not read" so a gate can no longer pass vacuously, plus a machine-enforced anti-divergence ratchet so a new hand-written copy cannot be introduced — the approach that worked for #1372 (markdown sectionizer), #2143 (table + bounded mutation) and #2121 (phase-id), each of which closed its bug class structurally.Track the fix at #4631.
fix(#4259): fold shell continuations before the T6 docs-parity site s…