fix(774,775): close the cold-review findings — including three the change inflicted on itself
Two independent cold reviews (Codex GPT-5.6 cross-family; Fable 5 on the patch) both returned BLOCKED. They agreed on the counts error and the extractor hole; each found things the other did not. Fixes, with what each was: THE INVENTORY DID NOT COVER ITS OWN NEW GUARDS. `_SCRIPT_REF` matched `scripts/name.py` but not `scripts/tests/*.py`, so the three guard files this change introduced had no rows and the completeness check stayed green. A completeness guard blind to its author's new guards is precisely the defect being legislated against. The population now globs `scripts/tests/test_*.py` — which is how they actually run, since pr-checks.yml invokes the directory. 32 rows -> 48. That forced a third Kind. Once test files are in the population, every mutation proof becomes a row wanting a proof of its own, forever. `PROOF` marks a file whose job is to prove another guard; a scripts/tests file enforcing a repo invariant with no separate guard behind it stays GUARD and may cite a mutation case in its own file. HOOK EXISTENCE WAS STANDING IN FOR HOOK WIRING. Deleting a hook's registration from .claude/settings.json left the population and the table unchanged, so the row went on describing a guard that no longer ran — #631's shape one level down. Now derived from settings.json plus the husky hooks. THE SUMMARY COUNTS WERE A HAND-KEPT MIRROR AND WERE WRONG ON ARRIVAL: "28 guards, 4 tooling ... 19 have none" against a table holding 27/5/6/3/18. Both reviewers found it independently. The prose is now parsed and asserted against the table. TWO FALSE MUTATION GRADES, each with a concrete disarm: - test_full_first_page_alone_does_not_end_enumeration sends 50 docs paths then one more docs path; disarm pagination to treat a full page as final and it is still all-docs, still exempt, still green. Re-pointed at test_protected_path_on_a_LATER_page_is_still_seen, which does go red under that mutation. - test_the_scan_job_runs_the_out_of_pytest_positive_control asserts only that the script exists, is executable, is referenced and is marked; replace its logic with `exit 0` and all four pass. ci-prove-ban-detects.sh regraded NONE. The MUTATION column was also being applied as a curve: three rows graded MUTATION fed the real script an input only that clause rejects, which is what the rows eight lines away are graded BEHAVIOUR-ONLY for. Definition sharpened to *witnessed* rather than plausible, and those regraded. 5 MUTATION / 6 BEHAVIOUR-ONLY / 21 NONE across 32 guards. THE VOCABULARY EXTRACTOR COULD RETURN A PARTIAL SET. `[A-Z|-]` cannot match `SHIP*)`, so adding that arm leaves the extracted set non-empty AND equal to the read side — parity green while the gate desyncs. Emptiness checks cannot see partial degradation. A loose counterpart now asserts the strict pattern consumed every arm; proven red on exactly that attack and green on a clean tree. Also: each verdict pattern must be assigned once, since the extractor unions assignments while the classifier runs the last. Also: docker-build.yml was itself an unchecked scope mirror (now asserted to be the only workflow with toolchain container jobs, by parsing container.image rather than grepping — ci-image.yml names the image because it builds it); the mutant floor is an equality; e2e-functional.sh reclassified GUARD (it exits 1 on a failed contract assertion); design-sync-reminder.sh does block the first Stop. The doc now states all six excluded classes instead of one. Not done here, filed instead: workflow-owned execution-class metadata to replace TOOLCHAIN_JOBS, a single shared verdict vocabulary, and an executable clause-level mutation harness. Each touches a CI-gating or merge-gate path and wants its own review. 580 script-tests pass. Refs #774 Refs #775 Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -32,6 +32,7 @@ stays with review, and the table is the thing review reads.
|
||||
from __future__ import annotations
|
||||
|
||||
import re
|
||||
from collections import Counter
|
||||
from pathlib import Path
|
||||
|
||||
REPO_ROOT = Path(__file__).resolve().parents[2]
|
||||
@@ -40,12 +41,27 @@ HOOKS_DIR = REPO_ROOT / ".claude" / "hooks"
|
||||
HUSKY_DIR = REPO_ROOT / ".husky"
|
||||
WORKFLOWS_DIR = REPO_ROOT / ".gitea" / "workflows"
|
||||
|
||||
KINDS = {"GUARD", "TOOLING"}
|
||||
KINDS = {"GUARD", "TOOLING", "PROOF"}
|
||||
PROOFS = {"MUTATION", "BEHAVIOUR-ONLY", "NONE"}
|
||||
|
||||
_SCRIPT_REF = re.compile(r"scripts/[a-z0-9_.-]+\.(?:sh|py)")
|
||||
# `scripts/x.sh` AND `scripts/tests/x.py`. The first version omitted the `/`, and the consequence was
|
||||
# not theoretical: the three guard files this inventory shipped with were themselves outside the
|
||||
# population it checked for completeness, so they acquired no rows and the guard stayed green. Cold
|
||||
# review found it. A completeness guard blind to its own author's new guards is the defect this
|
||||
# whole change is about, so the miss is recorded here rather than quietly corrected.
|
||||
_SCRIPT_REF = re.compile(r"scripts/(?:[a-z0-9_.-]+/)?[a-z0-9_.-]+\.(?:sh|py)")
|
||||
_ROW = re.compile(r"^\|\s*`([^`]+)`\s*\|([^|]*)\|\s*([A-Z-]+)\s*\|\s*([A-Z-]+)\s*\|([^|]*)\|\s*$", re.M)
|
||||
|
||||
# The prose summary, parsed so it cannot drift from the table it summarises. It already had:
|
||||
# shipped as "28 guards, 4 tooling … 6 … 3 … 19" against a table holding 27/5/6/3/18, because it was
|
||||
# a hand-maintained mirror with no equality check — #773's Family C inside the deliverable arguing
|
||||
# against it. Both reviewers caught it independently.
|
||||
_SUMMARY = re.compile(
|
||||
r"(\d+)\s+guards?,\s+(\d+)\s+tooling\s+scripts?,\s+(\d+)\s+proof\s+files?\.\s+"
|
||||
r"\*\*(\d+)\s+guards?\s+carry\s+a\s+mutation\s+proof;\s+(\d+)\s+(?:are|is)\s+behaviour-only;\s+"
|
||||
r"(\d+)\s+have\s+none\.\*\*"
|
||||
)
|
||||
|
||||
|
||||
def derived_guard_files() -> set[str]:
|
||||
"""THE AUTHORITATIVE POPULATION, from the filesystem and the call sites — never a list.
|
||||
@@ -60,6 +76,11 @@ def derived_guard_files() -> set[str]:
|
||||
str(p.relative_to(REPO_ROOT)) for p in HOOKS_DIR.glob("*.sh")
|
||||
} | {
|
||||
str(p.relative_to(REPO_ROOT)) for p in HUSKY_DIR.iterdir() if p.is_file()
|
||||
} | {
|
||||
# `pr-checks.yml` runs `pytest scripts/tests` as a directory, so every file in it is
|
||||
# invoked and none is individually named anywhere. Globbing is the only derivation that
|
||||
# matches how they actually run.
|
||||
str(p.relative_to(REPO_ROOT)) for p in (REPO_ROOT / "scripts" / "tests").glob("test_*.py")
|
||||
}
|
||||
|
||||
callers = list(WORKFLOWS_DIR.glob("*.yml")) + list(HOOKS_DIR.glob("*.sh"))
|
||||
@@ -71,6 +92,23 @@ def derived_guard_files() -> set[str]:
|
||||
return found
|
||||
|
||||
|
||||
def wired_hook_files() -> set[str]:
|
||||
"""Hooks reachable from `.claude/settings.json` or a husky hook — WIRING, not existence.
|
||||
|
||||
Directory membership is not execution. A hook whose settings.json registration is deleted keeps
|
||||
its file, keeps its inventory row, and stops running — and the table would go on describing a
|
||||
working guard. That is #631 and #719's shape ("wired is not running") one level down, and it was
|
||||
the derivation's blind spot until cold review named it.
|
||||
"""
|
||||
text = (REPO_ROOT / ".claude" / "settings.json").read_text()
|
||||
for husky in HUSKY_DIR.iterdir():
|
||||
if husky.is_file():
|
||||
text += husky.read_text()
|
||||
return {
|
||||
str(p.relative_to(REPO_ROOT)) for p in HOOKS_DIR.glob("*.sh") if p.name in text
|
||||
}
|
||||
|
||||
|
||||
def inventory_rows() -> list[tuple[str, str, str, str]]:
|
||||
"""(guard, kind, proof, proof_ref) for each table row."""
|
||||
rows = []
|
||||
@@ -161,6 +199,86 @@ def test_every_claimed_proof_names_a_test_that_exists():
|
||||
)
|
||||
|
||||
|
||||
def test_every_hook_file_is_actually_WIRED():
|
||||
"""A hook file nothing registers is dead code holding an inventory row that reads as coverage."""
|
||||
on_disk = {str(p.relative_to(REPO_ROOT)) for p in HOOKS_DIR.glob("*.sh")}
|
||||
unwired = sorted(on_disk - wired_hook_files())
|
||||
assert not unwired, (
|
||||
f"these hook files exist and have inventory rows but are referenced by neither "
|
||||
f".claude/settings.json nor any .husky/ hook: {unwired}. They do not run. Either wire them "
|
||||
"or delete them — a row for a hook that never fires is the coverage claim #631 paid for."
|
||||
)
|
||||
|
||||
|
||||
def test_proof_rows_do_not_themselves_claim_a_proof():
|
||||
"""`PROOF` exists to stop an infinite regress, and the regress is not hypothetical.
|
||||
|
||||
Once `scripts/tests/*.py` entered the population, every mutation proof became a row needing a
|
||||
proof of its own, and so on. `PROOF` marks a file whose job IS to prove another guard; grading
|
||||
it would ask what proves the prover, forever. Files under `scripts/tests/` that enforce a repo
|
||||
invariant with no separate guard file behind them are `GUARD`, not `PROOF`, and are graded
|
||||
normally — that is the honest place to draw the line.
|
||||
"""
|
||||
for guard, kind, proof, ref in inventory_rows():
|
||||
if kind == "PROOF":
|
||||
assert proof == "NONE", f"{guard} is PROOF but claims Proof {proof}"
|
||||
assert guard.startswith("scripts/tests/"), (
|
||||
f"{guard} is marked PROOF but does not live in scripts/tests/"
|
||||
)
|
||||
assert ref in ("—", "-", ""), f"{guard}: PROOF rows carry no proof ref"
|
||||
|
||||
|
||||
def test_every_proof_ref_points_at_a_row_marked_PROOF():
|
||||
"""Ties the two halves of the table together. A guard citing a test that the table does not
|
||||
classify as a PROOF means the population and the refs disagree about what that file is."""
|
||||
rows = inventory_rows()
|
||||
proof_files = {g for g, k, _, _ in rows if k == "PROOF"}
|
||||
for guard, _kind, proof, ref in rows:
|
||||
if proof == "NONE":
|
||||
continue
|
||||
filename = ref.strip("`").split("::", 1)[0]
|
||||
path = f"scripts/tests/{filename}"
|
||||
# A test-file GUARD may cite ITSELF: its mutation cases live in the same file, because the
|
||||
# thing it guards is a repo invariant rather than another script. Splitting those into a
|
||||
# separate file to satisfy the table would be bookkeeping driving the code.
|
||||
if path == guard:
|
||||
continue
|
||||
assert path in proof_files, (
|
||||
f"{guard} cites {filename} as its proof, but that file is not a PROOF row in this "
|
||||
"table. The citation and the classification must agree."
|
||||
)
|
||||
|
||||
|
||||
def test_the_summary_counts_match_the_table():
|
||||
"""The prose is DERIVED-checked, not hand-maintained.
|
||||
|
||||
It shipped wrong the first time — "28 guards, 4 tooling … 19 have none" against a table holding
|
||||
27/5/…/18 — because it was a mirror with no equality check. Both cold reviewers found it
|
||||
independently, which is the clearest possible evidence that a summary nobody checks is a summary
|
||||
nobody can trust.
|
||||
"""
|
||||
rows = inventory_rows()
|
||||
kinds = Counter(k for _, k, _, _ in rows)
|
||||
grades = Counter(p for _, k, p, _ in rows if k == "GUARD")
|
||||
|
||||
m = _SUMMARY.search(INVENTORY.read_text())
|
||||
assert m, (
|
||||
"could not find the summary sentence in the expected shape. It must read exactly like: "
|
||||
"`N guards, N tooling scripts, N proof files. **N guards carry a mutation proof; N are "
|
||||
"behaviour-only; N have none.**` — if you reword it, update `_SUMMARY` in the same commit, "
|
||||
"because an unparsed summary is an unchecked one."
|
||||
)
|
||||
claimed = tuple(int(g) for g in m.groups())
|
||||
actual = (
|
||||
kinds["GUARD"], kinds["TOOLING"], kinds["PROOF"],
|
||||
grades["MUTATION"], grades["BEHAVIOUR-ONLY"], grades["NONE"],
|
||||
)
|
||||
assert claimed == actual, (
|
||||
f"the summary claims (guards, tooling, proofs, mutation, behaviour-only, none) = {claimed} "
|
||||
f"but the table holds {actual}."
|
||||
)
|
||||
|
||||
|
||||
def test_tooling_rows_never_claim_a_proof():
|
||||
"""A TOOLING row asserting nothing cannot have a proof that it can go red, and letting one
|
||||
carry a ref would quietly inflate the coverage count at the bottom of the inventory."""
|
||||
|
||||
Reference in New Issue
Block a user