b9f031f52abb3d6f53e4551b045e839728fcf9ea
4
Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
b9f031f52a |
fix(776): a signal must not become consent
Round 3, from two independent re-reviews of the round-2 fix commit. The fix for the lost-output-on-SIGTERM defect introduced a worse one than the defect. The signal handler ended in `exit "$?"`, and `$?` at signal time is the status of whatever command was running — normally 0 for a guard still gathering evidence. Measured on the real guard, `prepush-donewhen.sh` SIGTERMed mid-curl with an unticked Done-when box: uninstrumented rc=-15 git ABORTS the push instrumented rc=0 git PUSHES to main That converts a killed guard into consent, in the permissive direction, in the hook that protects `main`. The handler now flushes, restores the default disposition and re-raises the signal, so the process dies the way it would have died. test_output_survives_a_SIGTERM could not see it: it asserts stdout content, never reads the return code, and drives a capture-mode hook so no exit-code guard is ever signalled. Also from this round: - The flush ran TWICE on the signal path (signal handler, then EXIT trap), writing two contradictory exit records for one invocation — a real decision then a phantom no-op — so the report mis-histogrammed the very case the trap was added for. It is idempotent now. - `exec 4<&- 2>/dev/null`: the round-1 blocker pattern again, eight lines below the comment forbidding it. Rather than fix the third instance and wait for a fourth, test_no_exec_in_the_sink_carries_a_STDERR_REDIRECT now enforces it. - The log write leaked `Operation not permitted` to stderr on an unwritable log, because `>> "$file" 2>/dev/null` opens the file BEFORE redirecting stderr. The fail-open test used a path that dies at mkdir and never reached this. - Classification: an unrecognised value is no longer lowercased into a valid decision, exit 2 now dominates a printed `allow` (it is the harness's block channel, and reporting a permit for a refused call is the one direction this log must never be wrong in), and a non-zero exit no longer annotates a real decision with an invented `+error`. - Classification and replay read the same bytes; they disagreed when a hook used fd 4, so the harness saw `deny` while the log recorded `no-op`. - The stderr normaliser rewrote `line N:` globally, collapsing genuinely different diagnostics; it is anchored to the script-path prefix now. - docs 5.4 claimed the two zero rows were "trigger did not fire", justified by unit tests that invoke the scripts directly and therefore prove nothing about harness dispatch. It now separates what is established from what is not, and stops contradicting its own decision record. Refs: #776 Decisions-Edit: yes Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> |
||
|
|
183df2bb3d |
fix(776): the instrumentation was silencing every hook's stderr
Round 2, from two independent cold reviews. The headline defect was found by
the test the reviews prompted rather than by the reviews themselves:
exec 0<"$sin" 2>/dev/null
reads as "suppress errors from this redirection". It is not. `exec` with
redirections and no command applies them to the shell PERMANENTLY, so this sent
each hook's ENTIRE stderr to /dev/null. Every husky guard's user-facing output
is stderr — the H6 "push to main BLOCKED" message, the BOM guard's remediation
text, the missing-trailer message — so the guards went on blocking correctly
while telling the human nothing about why. Invisible to the original A/B, which
compared only stdout and exit status.
The finding that exposed it was ranked Low ("the A/B ignores stderr").
Also fixed, each with an executed proof:
- The fd restore sat inside the same conditional as the replay, and the replay
read the PATH, so an unlinked-but-open scratch file meant a swallowed `deny`
at exit 0. Restore is now unconditional and the replay reads through a held
fd, which survives unlink.
- A SIGTERMed hook lost output it had already printed (52 bytes -> 0). Bash runs
no EXIT trap for an untrapped fatal signal; INT/TERM/HUP are trapped now.
- The classifier misreported an uppercase decision as prose, read the bare word
additionalContext in free text as a decision, and let a non-zero exit ERASE a
decision the hook really printed.
- The session id reached the log FILENAME unscrubbed. The first fix reused the
record scrubber, which deliberately keeps `/` and `.`, so `../../escaped` went
through untouched: passing a value through a scrub is not the same as passing
it through the right scrub.
- Preamble line 1 could abort a `set -e` hook, turning a fail-open guard
fail-closed; and a missing sink printed `command not found` to stderr.
The big one is test quality. `test_instrumentation_changes_NOTHING_the_harness_
can_see` was 160/165 empty-vs-empty and 165/165 exit-0-vs-exit-0, so deleting
the whole replay left it green for four hooks, two of which issue `deny`. Three
places claimed the matrix reached every deciding branch, including the decision
record. It now constructs the missing cases — a foreign worktree marker, a BOM
`.cs` in an *ersatztv*-named repo, stubbed memory_pressure, a real bare remote
for the three pre-push guards, a stub Gitea for prepush-donewhen — and
test_the_AB_is_not_VACUOUS_for_any_hook fails unless each hook has a case where
the control side actually says something.
Running pytest also wrote 115 synthetic fires into the production log, so the
report described the test suite while looking like a record of real sessions.
scripts/tests/conftest.py isolates every test; verified live, a full suite run
now leaves the real log untouched.
Refs: #776
Decisions-Edit: yes
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
|
||
|
|
fc65b5fbe3 |
docs(776,784): state the hazard, not the author's timeline
Applies ersatztv#784's who-benefits test to this change's own prose: if only the author's timeline explains why a sentence is there, it is narrative. Three comments said "the first version of this did X" where the reader only needs the hazard and the reason nothing downstream would catch it. One of the three turned into a real correction rather than a reword. The byte-exactness test was justified as "the A/B does not cover this", which is sharper and also true: the A/B compares the two halves against each other, so a wrapper that truncated BOTH would pass it. Only comparing against the literal expected bytes catches that. Refs: #776 Refs: #784 Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> |
||
|
|
56ed794ff7 |
feat(776): every hook reports that it fired, and the report is measured
In this harness version only `Stop` hooks emit a structured transcript record. `PreToolUse` and `PostToolUse` hooks leave no durable execution trace — which is every guard this repo relies on. #773 §5.4 could therefore only count filename mentions in settings dumps, i.e. inference, so a silently broken hook looked identical to a working one indefinitely. Each hook now sources one shared sink, `scripts/hook-fire-log.sh`, and records a `fire` record on entry and an `exit` record carrying its status and decision. The decision is parsed from the bytes the hook actually emitted rather than declared by the author: Claude hooks always exit 0 and decide by printing JSON, so stdout is diverted and replayed; git hooks decide by exit code and stream their output, so theirs is left alone. That avoided ~40 edits inside pretooluse-merge-consent and records what the harness sees rather than what the author meant. The instrumentation sits in the stdin/stdout path of the most authoritative guards in the repo, so transparency is the load-bearing claim, not coverage: test_instrumentation_changes_NOTHING_the_harness_can_see drives every hook with and without it over a payload matrix reaching each hook's deciding branch, and demands byte-equal stdout and equal exit status. It shipped with two defects that only that shape catches — `out=$(cat f)` stripping a trailing newline, and an unconditional stdin slurp that hangs on a TTY and would have frozen every interactive `git commit`. Both are now pinned, the second through a real pty. fixes #776 Decisions-Edit: yes Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> |