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