From 163522fb3aff991b4ed13d472f09c22f59671a71 Mon Sep 17 00:00:00 2001 From: Timothy Date: Sun, 16 Aug 2026 12:00:34 +0200 Subject: [PATCH] fix(794): an EMPTY Proves: trailer was skipped in silence MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cold review of the delta returned MERGEABLE with one MEDIUM it judged below the blocking bar but would fold in before merge. Folding it in, because it is the same script/CI asymmetry the previous commit set out to close. `%(trailers:key=Proves,valueonly)` renders a bare `Proves:` as an EMPTY line, so counting non-empty value lines missed a commit whose FIRST trailer is empty: the multi-trailer guard did not fire, `sel` came out empty, and `[ -n "$sel" ] || continue` dropped the commit without a word — with a real second selector never checked. If such a commit were a PR's only claim, the job would print "No commit in this PR carries a 'Proves:' trailer", which is then simply false. No false PROVEN, but a claim that reads as absent is still a claim that never ran. Counting trailer PRESENCE (`%(trailers:key=Proves)`) catches it, and a present-but-empty trailer is now refused loudly. Verified on both of the reviewer's scenarios: the empty-first case counts 1 by the old expression and 2 by the new one, and a lone bare trailer now errors instead of being skipped. Also from the same review: - docs/ci-cd.md had the direction backwards — a wobble DOES redden this job (exit 5 on a harness failure or signal); what the exit-code discipline buys is that a GREEN can never come from a cancelled or broken run. Reworded. - the PR-gates enumeration still said "four git-only gates"; there are five, and prove-fix is the one that is not merely checkout + git diff. - the last unqualified copy of the retracted SIGTERM claim now says "in the draft", and a 150-char comment line was rewrapped. Verified: scripts/tests 681 passed, 2 skipped; yaml parses; bash -n clean; no line over 100 chars in the script. Co-Authored-By: Claude Opus 5 (1M context) --- .gitea/workflows/pr-checks.yml | 16 +++++++++++++++- docs/ci-cd.md | 8 +++++--- scripts/prove-fix.sh | 5 +++-- 3 files changed, 23 insertions(+), 6 deletions(-) diff --git a/.gitea/workflows/pr-checks.yml b/.gitea/workflows/pr-checks.yml index 7c2366a11..45bd89954 100644 --- a/.gitea/workflows/pr-checks.yml +++ b/.gitea/workflows/pr-checks.yml @@ -271,7 +271,13 @@ jobs: # explicitly, so the guard was bypassed on the one path that actually enforces. # Measured: a commit with two trailers reported PROVEN while the second was never # run. Fixing the script and not its twin is how a guard reads as coverage. - if [ "$(printf '%s\n' "$raw" | grep -c .)" -gt 1 ]; then + # Count trailer PRESENCE, not non-empty values: `%(...valueonly)` renders a bare + # `Proves:` as an empty line, so counting non-empty lines misses a commit whose + # FIRST trailer is empty — `sel` then comes out empty and the commit is skipped + # in silence, with a real second selector never checked. Fail-open in CI while + # the script is fail-closed is the same asymmetry this guard exists to remove. + present="$(git show -s --format='%(trailers:key=Proves)' "$sha")" + if [ "$(printf '%s\n' "$present" | grep -c .)" -gt 1 ]; then claimed=$((claimed + 1)); failed=$((failed + 1)) echo "::error::commit $sha carries more than one 'Proves:' trailer; only the" \ "first would be checked, so the rest would read as proven without ever" \ @@ -279,6 +285,14 @@ jobs: continue fi sel="$(printf '%s\n' "$raw" | head -1 | sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//')" + # A trailer that is PRESENT but empty is a claim with no selector. Refuse it + # loudly; skipping it silently would let the job report "no claims" for a PR that + # made one. + if [ -n "$present" ] && [ -z "$sel" ]; then + claimed=$((claimed + 1)); failed=$((failed + 1)) + echo "::error::commit $sha carries a 'Proves:' trailer with no selector." + continue + fi [ -n "$sel" ] || continue claimed=$((claimed + 1)) diff --git a/docs/ci-cd.md b/docs/ci-cd.md index 6d2cf5d33..5ce0c456d 100644 --- a/docs/ci-cd.md +++ b/docs/ci-cd.md @@ -899,8 +899,10 @@ Three refusals worth knowing before you write a trailer: **Only pytest exit 1 counts as red.** 2 is an interrupted collection, 3 internal, 4 usage, 5 nothing collected, 143 a signal; `--continue-on-collection-errors` converts a genuine collection failure to -1 so add-a-file fixes stay provable. The job inherits that, so a red here means a claim failed, not -that the runner wobbled. +1 so add-a-file fixes stay provable. The job inherits that. Note the direction: a wobble DOES redden +this job (`prove-fix.sh` exits 5 on a harness/git failure or a signal, and the job turns that into an +error), so what the exit-code discipline buys is the other way round — a **green** here means a claim +was witnessed, never that a run was cancelled or broke. ### `script-tests` job (`Script tests (pytest)`, PR-only — in `pr-checks.yml`) @@ -995,7 +997,7 @@ assumed. **File:** `.gitea/workflows/pr-checks.yml` — `on: pull_request` only. -The four git-only PR gates — `ci-image-pin`, `docs-reminder`, `decisions-guard`, `script-tests` +The five PR gates — `ci-image-pin`, `docs-reminder`, `decisions-guard`, `script-tests`, and `prove-fix` (the one member that is NOT merely checkout + `git diff`: it installs pytest and creates worktrees) (all described above) — live here, **not** in `docker-build.yml`, and that separation is the fix for **ersatztv#535**. diff --git a/scripts/prove-fix.sh b/scripts/prove-fix.sh index aa1ab0c41..5106e2a24 100755 --- a/scripts/prove-fix.sh +++ b/scripts/prove-fix.sh @@ -17,7 +17,8 @@ # error, 5 nothing collected, and a killed run gives 143. Cold review measured a SIGTERM # being read as red in an early DRAFT — cancellation masquerading as evidence. On the first # COMMITTED version the reproducible false PROVEN is the marker case (a failed `cd` giving -# the subshell status 1), not the signal one; see the decision record. `--continue-on-collection-errors` is passed so a genuine collection failure +# the subshell status 1), not the signal one; see the decision record. +# `--continue-on-collection-errors` is passed so a genuine collection failure # (what happens when the fix ADDED the module the test imports) is reported as a test # error and exits 1 instead of vanishing into the ambiguous 2/3 band. Measured: pass 0, # fail 1, collection-error 2 (1 with the flag), SIGTERM 143. @@ -71,7 +72,7 @@ cleanup() { } # A signal must not look like a verdict: clean up, then exit non-zero EXPLICITLY. Without # that explicit exit the handler falls through and the previous status stands, which is -# how a cancelled run printed PROVEN. +# how a cancelled run printed PROVEN in the draft. on_signal() { cleanup; trap - EXIT; printf 'prove-fix: interrupted by signal\n' >&2; exit 5; } trap cleanup EXIT trap on_signal INT TERM