Commit Graph
5 Commits
Author SHA1 Message Date
timothyandClaude Opus 5 b2b651779a fix(785): close the re-review's BLOCKER — the leak guard pinned the FIX, not the property
Third cold review, this one scoped to the previous two fix commits. Its central finding is
the one worth reading, because the guard it faults is the guard I added to stop exactly
this class of thing.

BLOCKER — `test_the_subprocess_env_CARRIES_the_isolated_hook_fire_log_dir` asserted on
`_env()`'s RETURN VALUE. `_env()` can be perfectly correct while a call site passes
something else, and that is the reintroduction a future tidy-up actually produces.
Demonstrated: leave `_env()` exactly as shipped, restore a module-level snapshot and point
one `env=` at it — 13 tests pass and 58 records leak. I reproduced it before acting.

The guard was pinned to the SHAPE OF THE FIX rather than to the property, which is
`verify-against-the-REAL-predecessor`: it was witnessed red against a hand-written revert,
so "pins it" and #809's "witnessed red by reintroducing the snapshot" were both overclaims.

`test_driving_a_hook_LANDS_its_records_in_the_ISOLATED_dir` asserts the EFFECT instead —
drive a real hook through the real `_run()`, records must land in the fixture's dir — with
an anti-vacuity check that the hook reached a decision first. Measured: green at head, RED
under the call-site reintroduction that the old guard passed.

MEDIUM x3 — the workflow extractor was a text scanner and review broke it three ways in
one pass. A `run: |` block scalar was invisible, so reformatting the step to the form its
own sibling in that job already uses produced a FALSE RED whose message asserts a CI
regression that has not happened. A job or step switched off with `if: false` or
`continue-on-error: true` still read as wired — 7 green with the guard not gating at all.
And `run:` inside block-scalar TEXT was extracted and executed, so an `echo we no longer
run: PYTHONPATH=. python3 ... --check` left the subprocess proof green while the real step
was deleted. Two of the three are false greens.

`fixing-a-parser-bug-introduces-the-next-one` says the second round of a string predicate
is not the last. The structure is available — pyyaml is installed by the `script-tests` job
and four sibling suites already parse this workflow with it — so the scanner is replaced by
`yaml.safe_load`, and "would actually execute" is now three explicit conditions: the job
exists, the job is not disabled, the step is neither disabled nor allowed to fail. The six
ways it can stop gating are a parametrised test, and the block-scalar REFORMAT is a
negative control, because a detector that cannot tell a reformat from a removal trains its
readers to ignore it.

LOW — `_hook_calls` skipped whole-line comments but not inline ones, and broadening the
marker in the previous commit is what made that reachable: a trailing
`# ... .claude/hooks/removed-helper.sh` reddened a correct `pre-push`. The fix for one
over-match introduced another. Verified both directions.

NIT — a section header still said "three clauses" after the fourth mutation was added.

Docs. Two accuracy fixes, both verified against the files rather than reasoned about:
`test_hook_fire_log.py` proves THREE clauses (coverage, transparency, placement), not two,
and its row's Blocks column already claims two of them — the single `Proof ref` is a column
limit, not a coverage statement. And the "1,488 stray records" figure was unreproducible in
a durable doc, the same commit having deleted the evidence. Replaced with the reproduction
and a figure that survives it: 58 records per run, measured identically on macOS/git 2.55
and Linux/git 2.47.3.

Also corrects a count in 88832047b's own message: it says the inversion reddens "8 of 12";
that file had 13 tests at that commit. Third mislabelled figure in this branch, all three
in messages about mislabelled figures.

Refs: #785
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-21 21:29:00 +02:00
timothyandClaude Opus 5 a01def3f10 fix(785): the new leak guard's third assertion was a tautology
`test_the_subprocess_env_CARRIES_the_isolated_hook_fire_log_dir` shipped with

    assert "hook-fire" not in str(Path.home() / ".cache") or isolated != str(...)

Evaluated: `str(Path.home() / ".cache")` is `/Users/timothy/.cache`, which never contains
"hook-fire", so the left operand is always True and the `or` never reaches the comparison.
The assertion could not fail. It was decoration inside a guard added specifically to stop
vacuous checks — the recurring shape this milestone exists to close, committed by its own
fix.

The first two assertions in that test were doing the real work throughout, so nothing that
was proved is now unproved. The third now compares the resolved paths, with the production
path DERIVED the way `hook-fire-log.sh` derives it (`${HOME:-/tmp}/.cache/ersatztv/
hook-fire`) rather than restated as a literal that would drift from it.

Verified reachable: with `isolated` set to the production path the comparison evaluates
False, i.e. the assertion fires. Previously that same input passed.

Found by re-reading the fix commit rather than by the reviews — which is the argument for
re-reviewing the FIX and not only the original diff.

Refs: #785
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-21 21:29:00 +02:00
timothyandClaude Opus 5 4822003004 fix(785): stop the tests writing to the PRODUCTION hook-fire log, and correct a mislabelled count
Two independent cold reviews, both against the real subjects rather than the diff. Five
findings; the first is the serious one.

HIGH — `test_worktree_ownership_guard.py` was defeating conftest's isolation. `_ENV` was a
module-level `{**os.environ, ...}` snapshot, taken at IMPORT time, which is before the
autouse `isolate_hook_fire_log` fixture monkeypatches `ETV_HOOK_FIRE_LOG_DIR`. So every
hook subprocess logged to the real `$HOME/.cache/ersatztv/hook-fire/`. Measured: 1,488
records for the two synthetic session ids, and one further run added 28 more.

That is #776's defect reintroduced inside the file meant to prove #776's hooks, and it
corrupts the surface `docs/guard-inventory.md` cites as the observability claim for every
guard still graded NONE. Nothing surfaced it because the fire-log library is fail-open by
design — a logging failure must leave the hook behaving exactly as an uninstrumented one.

The env is now built per call. Measured after: a full run of the file adds 0 records. The
stray records were deleted; `s1`/`unknown-session` were left alone, not being ours.

`test_the_subprocess_env_CARRIES_the_isolated_hook_fire_log_dir` pins it, witnessed red by
reintroducing the snapshot. It is per-file, which is the same narrowness as the guard that
should have caught this: `test_hook_fire_log.py::test_the_suite_does_not_write_to_the_
PRODUCTION_log` says conftest "must isolate every test, not just this file's" but checks
only the running test and its own sandbox. Recorded in the inventory and tracked in #809,
including why the obvious general check (diff the log dir per test) is racy against a real
session's hooks firing concurrently.

MEDIUM — a9433d5cb's commit message mislabels a measurement. It reports the ownership
comparison mutation as "2 failed, 8 passed (inverted)". Reproduced both: INVERTING the
clause reddens 8 of 12 at today's head; 2 failed / 8 passed is what DELETING it produces
(2 of 10 at that commit's head). The number is real but belongs to the mutation the
parenthetical says was rejected. The shipped test is unaffected — inversion genuinely
reddens `test_MUTATION_inverting_the_OWNERSHIP_COMPARISON_blocks_the_owner`. Corrected
here rather than by amending, since the history is the record.

LOW — `docs/guard-inventory.md` described the unproven set as "every PreToolUse hook
except ..." two paragraphs above a standing list of eight hooks spanning four events. Both
sentences named the same set. `design-sync-reminder.sh` is registered on BOTH PreToolUse
and Stop in `.claude/settings.json`, so any "every X hook" phrasing double-counts it; the
set is now named by enumeration.

LOW — a truncated sentence ("`test_hook_fire_log.py` asserts TWO clauses", no verb, no
closing bold) orphaned the following paragraph's "That unproven set". Completed with both
clauses and their proofs.

NIT — `_hook_calls` matched comment lines and only the `./` invocation form. A commented
ghost hook would have reddened a correct tree; a `bash .claude/hooks/x.sh` form would have
gone unstubbed and exited 127, which two tests read as "drift caught". Both verified.

Refs: #785
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-21 21:29:00 +02:00
timothyandClaude Opus 5 fe01982a97 test(785): close two findings from the independent cold review
Both are the same species the milestone is about — a coverage claim resting on source-text
presence rather than on the guard actually running or the clause actually being reached.

MEDIUM, `test_build_catalog_check_path.py`. `_ci_check_command()` grepped the whole
workflow for the command text. So it matched a step that had been COMMENTED OUT, and it
was not scoped to the `decisions-guard` job at all — a match anywhere in the file would
do. Commenting out a step is the ordinary way a check gets switched off during an incident
and never switched back, and the subprocess proof would have stayed green over a guard CI
no longer runs. `guard-ships-with-mutation-proof`: the guard being WIRED is not the guard
RUNNING.

Now the extractor finds the job by key, stops at the next top-level job, strips comment
lines before matching, and asserts exactly one active step. `test_the_extractor_rejects_a_
COMMENTED_OUT_step` pins it. Witnessed against the real workflow: commenting the step out
reddens 2 of 7, deleting it reddens the same 2.

LOW, `test_worktree_ownership_guard.py`. The docstring claimed the three mutations covered
every clause the pair hangs on. They did not: the detection clause is `(commit|merge)`, and
every payload in the file used `commit`, so `merge` could be dropped and the file stayed
green. That is the more damaging half to lose — the mechanism exists for the
plumbing-merge path (`process.foreign-worktree-plumbing-merge`).

Adds a merge deny case and a fourth mutation, narrow by construction: the mutant must stop
denying a merge WHILE STILL denying a commit, so a mutation that merely broke the regex
cannot pass for it. Witnessed: dropping `merge` from the real hook reddens exactly those 2.

The docstring now also states which clauses are NOT mutated (the `git -C`/`cd` redirection
extraction, the marker hook's argument parsing) rather than implying the file is exhaustive.

The review's third finding — the inventory calling both husky files thin dispatchers — was
raised against ad0bed458..7bd7b4c8 and had already been corrected in fdc91056f.

Refs: #785
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-21 21:29:00 +02:00
timothyandClaude Opus 5 629ab0b173 test(785): prove the worktree-ownership PAIR, including the cross-file seam
`pretooluse-worktree-guard.sh` and `posttooluse-worktree-marker.sh` are one mechanism in
two files and neither had a test. #785 ranks them second because a regression in either
half is invisible: both hooks are deliberately fail-open, so a marker hook that writes
nothing and a guard that reads nothing both produce "the commit is allowed" — identical
to a correct fail-open.

Three clauses are disarmed and each was witnessed red against the REAL hooks in place,
not only against the isolated copies the tests build:

  * the guard's marker read           -> 5 failed, 5 passed
  * the guard's ownership comparison  -> 2 failed, 8 passed (inverted, because disarming
    it the other way only makes the guard deny MORE and every deny assertion stays green)
  * the marker hook's write           -> 6 failed, 4 passed

The third is the one that could not exist while the halves were tested apart: the clause
is in the marker hook, the assertion is about the guard's decision.

The first attempt at that third demonstration used a `sed` that silently matched nothing
and reported 10 passed. Re-run with an asserted replacement, hence the numbers above.

Refs: #785
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-21 21:29:00 +02:00