fix(803,664): round 8 — the continuation fold joined with a space, which is not what the shell does
Build ErsatzTV Image / CI toolchain image resolves (pull_request) Successful in 13s
Build ErsatzTV Image / Delimiter ban (release path) (pull_request) Successful in 22s
PR Gates / CI image pin matches docker/ci (pull_request) Successful in 15s
PR Gates / Docs update reminder (pull_request) Successful in 19s
PR Gates / decisions lifecycle (pull_request) Successful in 16s
PR Gates / Fix proofs (Proves trailers) (pull_request) Successful in 16s
review-verdict/h10 Awaiting review verdict for c1007d6
Review verdict / Set review-verdict status (pull_request_target) Successful in 21s
Build ErsatzTV Image / Build & test (.NET) (pull_request) Successful in 9m24s
PR Gates / Script lint and tests (ruff + pytest) (pull_request) Successful in 9m6s
Build ErsatzTV Image / EF migration integrity (SQLite + MySql) (pull_request) Successful in 6m28s
Build ErsatzTV Image / Build & push image (amd64) (pull_request) Skipped
Build ErsatzTV Image / Functional E2E (curl + UI contracts) (pull_request) Successful in 5m59s
Build ErsatzTV Image / API docs in sync (OpenAPI + endpoint index) (pull_request) Successful in 8s
Build ErsatzTV Image / Formatting (changed .cs conform to .editorconfig) (pull_request) Successful in 5s
Build ErsatzTV Image / CI toolchain image resolves (pull_request) Successful in 13s
Build ErsatzTV Image / Delimiter ban (release path) (pull_request) Successful in 22s
PR Gates / CI image pin matches docker/ci (pull_request) Successful in 15s
PR Gates / Docs update reminder (pull_request) Successful in 19s
PR Gates / decisions lifecycle (pull_request) Successful in 16s
PR Gates / Fix proofs (Proves trailers) (pull_request) Successful in 16s
review-verdict/h10 Awaiting review verdict for c1007d6
Review verdict / Set review-verdict status (pull_request_target) Successful in 21s
Build ErsatzTV Image / Build & test (.NET) (pull_request) Successful in 9m24s
PR Gates / Script lint and tests (ruff + pytest) (pull_request) Successful in 9m6s
Build ErsatzTV Image / EF migration integrity (SQLite + MySql) (pull_request) Successful in 6m28s
Build ErsatzTV Image / Build & push image (amd64) (pull_request) Skipped
Build ErsatzTV Image / Functional E2E (curl + UI contracts) (pull_request) Successful in 5m59s
Build ErsatzTV Image / API docs in sync (OpenAPI + endpoint index) (pull_request) Successful in 8s
Build ErsatzTV Image / Formatting (changed .cs conform to .editorconfig) (pull_request) Successful in 5s
Sixth cold review, scoped to round 7 and the rebase. It verified the rebase resolution independently (counting the guard-inventory table by hand rather than trusting the machine check), confirmed every one of round 7's re-measured claims true, found the tail sentinel sound, and ran the suite green at 1218. Two Lows, both real. THE FOLD JOINED WITH A SPACE. Round 7 folded backslash continuations before scanning, to close a `jq \` + `-e` split. It appended a space where bash appends nothing — and that is not cosmetic. `jq -\` + `e '.'` is `jq -e '.'` to the shell and `jq - e '.'` to a space-joining fold: two tokens, no flag, detector silent. Fixed by joining with nothing, which is a simplification toward real shell semantics rather than another layer of cleverness. BUT THE REVIEW'S THREE DEMONSTRATIONS WERE MIS-SPECIFIED, and checking that is what produced the useful part. All three used an INDENTED continuation, and bash does not strip the continuation line's leading whitespace: `echo -\` followed by an indented `e X` prints `- e X` — the token does not re-form — and `jq -\` + indented `e` exits 3, not as `-e`. Measured directly rather than argued. So those three were not evasions; the guard was right to stay silent on them. The reachable shape is a continuation whose NEXT LINE BEGINS AT COLUMN 0, and in this file that is ordinary rather than exotic: YAML strips the `run:` block's common indentation (10 spaces), so any line written at the block's base indent executes at column 0. My first attempt to construct it put the line at column 0 IN THE FILE, which simply broke the YAML — the mutant did not parse, which is not a measurement. The correct mutant parses, passes `bash -n`, forms a live `jq -e`, goes GREEN under the space-joining fold and RED under this one. So the review's conclusion was right and its mechanism was not, and the fold is now documented by the shape that actually reaches it. The fold is extracted to `_fold_continuations` and carries its own cases, including the indented split that must NOT be joined into a flag — the false-positive direction matters here too, since inventing a token bash never forms would redden the guard on innocent code. Also: "four spellings" appeared a second time in the test docstring, 55 lines below where round 7 corrected it (v1 catches `jq -er`; it missed three). That is the fourth time in this branch a retraction has stood at an adjacent site after being fixed at the first — the pattern being that correcting the sentence is not the same as sweeping the claim. Verification: 1223 passed, 2 skipped; ruff clean; decisions-validate OK; YAML + `bash -n` clean. M22 (revert the fold to space-joining) lets the reachable evasion through, so the separator is load-bearing and proved so.
This commit is contained in:
@@ -2828,6 +2828,38 @@ def test_positive_control_a_QUIET_run_still_posts_its_exemption(tmp_path):
|
||||
)
|
||||
|
||||
|
||||
def _fold_continuations(lines):
|
||||
r"""Join backslash-continued shell lines the way bash does: delete the backslash AND the newline,
|
||||
joining with NOTHING.
|
||||
|
||||
The exit-status detector is per-line, so a `jq \` whose flag sits on the next line would slip
|
||||
past it. Folding first closes that — but only if the fold matches the shell, and the separator is
|
||||
where it goes wrong. An earlier version joined with a SPACE, which is not cosmetic: it turns
|
||||
`jq -\` + `e '.'` into `jq - e '.'` (two tokens, no flag) where bash produces `jq -e '.'`.
|
||||
|
||||
WHICH SPLITS ARE ACTUALLY REACHABLE, measured rather than assumed, because the obvious
|
||||
construction is not one. Bash does NOT strip the continuation line's leading whitespace, so
|
||||
`echo -\` followed by an INDENTED `e X` prints `- e X` — three tokens, no flag re-formed, and
|
||||
`jq -\` + indented `e` exits 3 rather than acting as `-e`. The reachable case is a continuation
|
||||
whose next line begins at COLUMN 0, and in this file that is not exotic: YAML strips the `run:`
|
||||
block's common indentation (10 spaces here), so any line written at the block's base indent runs
|
||||
at column 0. Verified end to end: a mutant of that exact shape parses as YAML, passes `bash -n`,
|
||||
forms a live `jq -e` — and reddens the guard under this fold while passing under the space-joining
|
||||
one.
|
||||
"""
|
||||
joined, buf = [], ""
|
||||
for ln in lines:
|
||||
stripped = ln.rstrip()
|
||||
if stripped.endswith("\\"):
|
||||
buf += stripped[:-1]
|
||||
else:
|
||||
joined.append(buf + ln)
|
||||
buf = ""
|
||||
if buf:
|
||||
joined.append(buf)
|
||||
return joined
|
||||
|
||||
|
||||
def _uses_jq_exit_status(line: str) -> bool:
|
||||
"""True if `line` invokes jq with the exit-status flag, in any spelling of the FLAG.
|
||||
|
||||
@@ -2867,6 +2899,30 @@ def _uses_jq_exit_status(line: str) -> bool:
|
||||
return False
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"raw,folded",
|
||||
[
|
||||
# The reachable shape: the continuation's next line is at column 0, which is what a line
|
||||
# written at the `run:` block's base indent becomes once YAML strips it. Bash re-forms the
|
||||
# token; so must the fold, or the detector sees `jq - e` and reports nothing.
|
||||
([" x=$(... | jq -\\", "e 'length')"], [" x=$(... | jq -e 'length')"]),
|
||||
# An INDENTED continuation does NOT re-form the token — bash keeps the leading whitespace —
|
||||
# so the fold must not invent one either. Measured: `echo -\` + indented `e X` prints `- e X`.
|
||||
([" x=$(... | jq -\\", " e 'length')"], [" x=$(... | jq - e 'length')"]),
|
||||
(["a\\", "b\\", "c"], ["abc"]), # two consecutive continuations
|
||||
(["plain", "lines"], ["plain", "lines"]), # nothing to fold
|
||||
(["trailing\\"], ["trailing"]), # continuation with nothing after it
|
||||
],
|
||||
)
|
||||
def test_the_continuation_fold_matches_the_SHELL(raw, folded):
|
||||
r"""It joins with NOTHING, because that is what `\<newline>` removal does.
|
||||
|
||||
Joining with a space is the intuitive choice and it silently defeats the guard downstream: it
|
||||
turns `jq -\` + `e` into `jq - e`, two tokens carrying no flag, where bash produces `jq -e`.
|
||||
"""
|
||||
assert _fold_continuations(raw) == folded
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"line,expected",
|
||||
[
|
||||
@@ -2892,7 +2948,8 @@ def test_the_jq_exit_status_detector_reads_FLAGS_not_a_substring(line, expected)
|
||||
"""The detector is itself a string-matching predicate, so it gets its own cases.
|
||||
|
||||
`"jq -e" in line` was the first version. It misses `jq -re`, `jq -er`, `jq -e` and
|
||||
`jq --exit-status` — four spellings of the same request — and a guard a rename walks straight
|
||||
`jq --exit-status` — three spellings of the same request (it catches `jq -er`, since `jq -e`
|
||||
is a substring of it) — and a guard a rename walks straight
|
||||
through is not a guard. The false-positive rows matter as much: an `e` inside the jq PROGRAM is
|
||||
not a flag, and a detector that reddens on one would make the rule unusable and get waived.
|
||||
"""
|
||||
@@ -2946,18 +3003,7 @@ def test_count_pr_mutations_uses_NO_jq_e(tmp_path):
|
||||
f"of the function rather than the whole of it — this guard would be scanning only part of "
|
||||
f"what it claims to cover. Last captured line: {fn[-1]!r}"
|
||||
)
|
||||
# JOIN BACKSLASH CONTINUATIONS FIRST. The detector is per-line, so `jq \` on one line and
|
||||
# `-e '.'` on the next slips past it — constructible inside this very function, where the `bad=`
|
||||
# read is already long enough to invite exactly that wrap. Folding continuations before scanning
|
||||
# is what makes "any spelling" true rather than aspirational.
|
||||
joined, buf = [], ""
|
||||
for ln in fn:
|
||||
buf += ln[:-1] + " " if ln.rstrip().endswith("\\") else ln
|
||||
if not ln.rstrip().endswith("\\"):
|
||||
joined.append(buf)
|
||||
buf = ""
|
||||
if buf:
|
||||
joined.append(buf)
|
||||
joined = _fold_continuations(fn)
|
||||
offenders = [ln.strip() for ln in joined if _uses_jq_exit_status(ln)]
|
||||
assert not offenders, (
|
||||
"`jq -e` appeared inside `count_pr_mutations`, whose own comment bans it because the runner "
|
||||
|
||||
Reference in New Issue
Block a user