fix(743): re-tense the third stale site, and pin the two surviving mutants
PR Gates / CI image pin matches docker/ci (pull_request) Successful in 35s
PR Gates / Docs update reminder (pull_request) Successful in 42s
Build ErsatzTV Image / API docs in sync (OpenAPI + endpoint index) (pull_request) Successful in 1m23s
PR Gates / decisions lifecycle (pull_request) Successful in 1m25s
PR Gates / Script tests (pytest) (pull_request) Successful in 1m58s
Review verdict / Set review-verdict status (pull_request_target) Successful in 7s
Build ErsatzTV Image / Formatting (changed .cs conform to .editorconfig) (pull_request) Successful in 27s
Build ErsatzTV Image / Build & test (.NET) (pull_request) Successful in 8m52s
Build ErsatzTV Image / Functional E2E (curl + UI contracts) (pull_request) Successful in 16m42s
Build ErsatzTV Image / EF migration integrity (SQLite + MySql) (pull_request) Successful in 20m0s
Build ErsatzTV Image / Build & push image (amd64) (pull_request) Skipped

Round 2 of review. One blocking finding, and it is the same defect class as
round 1's: a present-tense claim that this PR falsified.

`release.verdict-status-check` — the record ABOUT the h10 status check — still
said "direct pushes to `main` are server-side permitted, so the gate can be
skipped without forging anything". A reader resolving that key from the catalog
would conclude the control does not exist. Round 1 corrected `ci-cd.md` and
`ci.actions-credential-scoping` and I stopped at the two sites I had edited,
instead of sweeping the corpus by SUBJECT. Swept properly this time
(`server-side permitted`, `bypassable`, `without forging`, `push whitelist`,
`enable_push`): this was the only remaining stale site.

Test gaps the reviewer found by mutation testing, now closed. Both mutants
SURVIVED the suite as shipped — the round-1 fixes were correct but unpinned:

- dropping `|| [ -n "${_h11_local_ref:-}" ]` → an unterminated final line is
  dropped. Two directions, and the dangerous one is not the obvious one: a
  dropped *branch* line leaves only tag refs and grants the exemption to a push
  containing a branch. Both pinned.
- dropping `[ -t 0 ] ||` → the hook hangs forever on an interactive run. Pinned
  with a real pty and an explicit timeout, so a regression fails cleanly rather
  than hanging a CI job. Verified the mutant is killed by exactly that test
  (and that it dies via the timeout, 32s).

Also from review, non-blocking:

- `ci-cd.md:951` cited `enable_push: false` alone as what closed #743 — the
  precise thing the new record says never to do, since the force-merge route
  also skipped the gate with no forgery. Now cites both fields.
- `ci-cd.md` flattened measured and source-attested into one 403: only the
  contents API was probed; the web editor/upload/apply-patch paths share the
  predicate but were not. Separated.
- `format-as-you-touch-rebase` still said "the documented sequence" and
  "always" for the release-cut behind-ness. `docs/ci-cd.md` documents the tag
  step, not the release-notes-PR flow, and the frequency is attested by one
  observed cut. Attributed to #719 instead.
- Documented the operator recovery path. `block_admin_merge_override: true`
  removes the `force_merge` escape that used to unstick a wrongly-red required
  context — that escape WAS the bypass, so it is gone by design, and the
  recovery (fix the status; last resort PATCH the field, merge, set it back)
  needed to be written down rather than left implicit in a residual.

Verification: 441/441 script tests; decisions-validate OK; PyYAML parses all
193 records; both mutants confirmed killed and the hook restored byte-identical.

fixes #719

Decisions-Edit: yes
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-08-06 00:10:45 +02:00
co-authored by Claude Opus 5
parent 6d80343320
commit 6af65ba5c5
5 changed files with 86 additions and 14 deletions
@@ -130,3 +130,57 @@ def test_zero_ref_lines_of_only_blank_lines_does_not_exempt(behind_repo):
r = _run_hook(behind_repo, "\n\n\n")
assert r.returncode == 1, "stdin of only blank lines vacuously granted the tag exemption"
assert "H11" in r.stdout
# --- final line with NO trailing newline -------------------------------------------------------
# `read` returns non-zero on an unterminated final line, so a bare `while read` silently DROPS it.
# Both directions matter and they fail differently, which is why each is pinned:
# - tag-only, unterminated -> the line is dropped, no refs are seen, and H11 blocks the release
# tag push again, i.e. #719 quietly returns.
# - mixed, unterminated -> the BRANCH line is dropped, leaving only tag refs, and the
# exemption is granted for a push that includes a branch. That is the dangerous direction.
# Git always newline-terminates its ref lines and `.husky/pre-push` re-adds one via `printf '%s\n'`,
# so this is reachable only on a hand-piped run — but the guard is cheap and the failure is silent.
def test_unterminated_final_line_tag_only_is_still_exempt(behind_repo):
stdin = f"refs/tags/v1.0.0 {DUMMY_SHA_A} refs/tags/v1.0.0 {DUMMY_SHA_B}" # no trailing \n
r = _run_hook(behind_repo, stdin)
assert r.returncode == 0, f"unterminated tag-only line was dropped, reinstating #719: {r.stdout}"
def test_tty_stdin_does_not_hang_and_does_not_exempt(behind_repo):
"""The hook gained a stdin reader in #719; before that it read nothing, and its own docs call
'run by hand' a supported case. Without the `[ -t 0 ] ||` guard an interactive run blocks
forever waiting on the terminal. A pty gives it a real TTY on fd 0; the `timeout` turns a
regression into a clean failure instead of a hung CI job."""
primary, secondary = os.openpty()
try:
r = subprocess.run(
["bash", str(HOOK)],
cwd=str(behind_repo),
stdin=secondary,
capture_output=True,
text=True,
timeout=30,
)
except subprocess.TimeoutExpired:
pytest.fail("hook hung on TTY stdin — the `[ -t 0 ] ||` guard is missing or ineffective")
finally:
os.close(primary)
os.close(secondary)
# A TTY yields no ref lines, so this is the zero-line fall-through: H11 still applies.
assert r.returncode == 1, "TTY stdin vacuously granted the tag exemption"
assert "H11" in r.stdout
def test_unterminated_final_branch_line_is_not_swallowed_into_the_exemption(behind_repo):
"""The dangerous direction: if the unterminated BRANCH line is dropped, only tag refs remain
and a branch push wins the tag exemption."""
stdin = (
f"refs/tags/v1.0.0 {DUMMY_SHA_A} refs/tags/v1.0.0 {DUMMY_SHA_B}\n"
f"refs/heads/feature {DUMMY_SHA_A} refs/heads/feature {DUMMY_SHA_B}" # no trailing \n
)
r = _run_hook(behind_repo, stdin)
assert r.returncode == 1, "an unterminated branch ref was swallowed into the tag exemption"
assert "H11" in r.stdout