Files
ersatztv/docs/decisions/records/release/verdict-status-check.md
T
timothy 07e1e8cfbc
review-verdict/h10 Awaiting review verdict for 07e1e8c
PR Gates / CI image pin matches docker/ci (pull_request) Successful in 12s
Review verdict / Set review-verdict status (pull_request) Successful in 10s
PR Gates / decisions lifecycle (pull_request) Successful in 21s
PR Gates / Docs update reminder (pull_request) Successful in 19s
Build ErsatzTV Image / Formatting (changed .cs conform to .editorconfig) (pull_request) Successful in 1m19s
Build ErsatzTV Image / API docs in sync (OpenAPI + endpoint index) (pull_request) Successful in 1m28s
Build ErsatzTV Image / Build & test (.NET) (pull_request) Successful in 8m5s
Build ErsatzTV Image / Functional E2E (curl + UI contracts) (pull_request) Successful in 15m31s
Build ErsatzTV Image / EF migration integrity (SQLite + MySql) (pull_request) Successful in 15m44s
Build ErsatzTV Image / Build & push image (amd64) (pull_request) Has been skipped
fix(622): validate rename rows too; name the real blocker when only the verdict is pending
Third BLOCKED verdict, third legitimate finding. The per-row guard validated the
DESTINATION only, so `{"filename":"docs/x.md","status":"renamed"}` with no
`previous_filename` passed while its source silently vanished — precisely the
path-hiding that collecting both sides exists to prevent. A rename row must now
carry a non-empty `previous_filename`.

Required for rename rows ONLY. Demanding it globally would reject every ordinary
modified/added row and make the gate refuse all exemptions — which every
"withholds the exemption" test would happily pass through, so that direction gets
its own positive control. Predicate checked against ten shapes before adopting;
mutation-verified in both directions (dropping the clause fails 2 tests, applying
it globally fails 3 including the controls).

Also fixes a wart this PR introduced. `review-verdict/h10` is itself folded into
the COMBINED status, so a PR awaiting its verdict reports combined 'pending' and
the hook's condition (a) reported it as a CI problem — sending a reader to build
logs when the missing thing is the review, and exiting before the H10 branch that
would have said so. The message now names the outstanding contexts, and says
plainly when the verdict is the only one left.

Scope boundary, stated in the record: real Gitea populates `previous_filename` on
renames and returns well-formed pages. Everything past this point defends against
shapes with no evidence of existing, so the guard's claim stays "any page we
cannot fully classify withholds the exemption" rather than growing to cover
unobserved responses.

Decisions-Edit: yes
2026-07-25 22:43:30 +02:00

13 KiB

key, title, status, since, supersedes, superseded-by, rule, signals, mechanics
key title status since supersedes superseded-by rule signals mechanics
release.verdict-status-check 2026-07-25 — H10 is enforced server-side as a per-sha required status check, not only by the PreToolUse hook (#622) active 2026-07-25 none none The H10 review verdict is written as a `review-verdict/h10` Gitea **commit status** on the exact reviewed sha by `scripts/post-review-verdict.sh`, and that context is a REQUIRED status check on `main`. Because a status belongs to one sha, a later commit cannot inherit it, so Gitea's own `merge_when_checks_succeed` refuses to merge a head no one reviewed. The PreToolUse hook additionally refuses to SCHEDULE an auto-merge unless that status is already green on head. A `pull_request` workflow auto-passes the two exempt classes (Renovate-authored, docs-only) unless the PR touches a protected path (`.claude/`, `.gitea/`, `.husky/`, `scripts/`, `docker/ci/`). This extends — does not supersede — `release.review-verdict-gate` (#303 H10), whose comment convention remains the human-readable artifact and the hook's condition (c). merge_when_checks_succeed freezes consent, auto-merge merges an unreviewed head, verdict bound to sha, review-verdict/h10 required check, post-review-verdict.sh, Renovate platformAutomerge exemption · paths: `scripts/post-review-verdict.sh`, `.gitea/workflows/review-verdict.yml`, `.claude/hooks/pretooluse-merge-consent.sh` · issues: #622, #303 (H6/H10), #242, #619 `scripts/tests/test_post_review_verdict.py` (incl. a TOCTOU head-moved case and cross-checks against the hook's own condition-(c) regexes); branch protection `status_check_contexts` on `main`

pretooluse-merge-consent.sh evaluates all three consent conditions at the moment the merge tool is called. That is sound for an immediate merge and unsound for a scheduled one. When the call passes merge_when_checks_succeed=true, condition (a) is deliberately delegated to Gitea — but Gitea then merges whatever head is green at its merge time, while (b) Done-when and (c) the head-referencing verdict were proven against the head that existed at scheduling time. Any commit pushed in between merges with no verdict covering it. The gate is not bypassed; it is satisfied against a snapshot that stops being true.

This is the same shape as the failure H10 was created to fix (#242, "re-review the fix commit, not just the initial diff"), reintroduced through the scheduling path rather than through forgetfulness. It also interacted badly with a convention we actively encouraged: append-only files hit the conflict treadmill, and the documented remedy was "rebase, then schedule merge_when_checks_succeed" — steering exactly the high-churn PRs, the ones most likely to grow follow-up commits, onto the one path where H10 stopped applying.

Correction on the motivating anecdote. #622 was filed claiming PR #619 merged 263 insertions with no covering verdict. That is false, and the record is corrected here rather than repeated: #619 carries a second verdict comment, Review-verdict: MERGEABLE @ 02c82b35, posted at 20:36:02 — six seconds before the 20:36:08 merge — which explicitly re-reviewed the two follow-up commits ("the verdict on record was stale … so they got their own scoped review"). The original claim came from reading the comment list while the Gitea API lagged. So the incident is evidence of the convention working under diligence, not of it failing.

The hole is nevertheless real, and is structural rather than anecdotal: nothing forced that re-review. It happened because a human chose to, inside a 45-minute window in which Gitea would have merged whatever was green. That is exactly the distinction this record exists to close — turning a property that held by diligence into one that holds by construction. The justification below therefore rests on a controlled experiment, not on the anecdote (ci/fake stands in for a slow CI check, so Gitea waits, as it really does):

arm required contexts unreviewed commit pushed after scheduling
without this change ci/fake merged
with this change ci/fake, review-verdict/h10 refused
then review the new head and post its verdict merges — blocked, not deadlocked

The negative-control arm is what makes this meaningful: the fix changes the outcome, rather than the observation passing for an unrelated reason.

The fix is the sha, not a smarter check. A Gitea commit status is attached to exactly one commit, so a status written for a parent cannot be inherited by a child that did not exist yet. Making review-verdict/h10 a required status check on main therefore makes the invariant self-invalidating by construction: push a new head and the required context is simply absent, which Gitea's merge-requirement check treats as not-passing, and the scheduled auto-merge refuses to fire until that head is re-reviewed. No re-evaluation hook, no polling, no second snapshot to go stale. Three properties follow that no hook-side fix could deliver:

  • it covers every merge path — Gitea UI, raw API, auto-merge, another agent's session — not only calls that happen to route through the Claude PreToolUse hook;
  • it needs no event to re-fire, because absence-of-status is the block;
  • it cannot be satisfied by a workflow merely running successfully, since the required context is the status the workflow posts, never the workflow's own job status.

The comment convention of release.review-verdict-gate is unchanged and still load-bearing: it is what a human reads, and it remains the hook's condition (c). post-review-verdict.sh writes both from one command so they cannot drift, and re-reads the head after posting the comment — if a commit landed in between it writes no status and exits non-zero rather than retargeting the verdict at a commit nobody reviewed (#622 in miniature). Where the two ever disagree, the status wins, because it is the one a merge is actually gated on.

Exemptions, and why they are narrow. A required check applies to every PR, including Renovate's, which uses platformAutomerge: true — Gitea's own auto-merge — to land patch bumps unattended. So .gitea/workflows/review-verdict.yml posts the status as success for Renovate-authored PRs and for docs-only PRs, and pending for everything else (an explicit blocking reason beats a silently-missing check). Both exemptions are void when the PR touches a protected path — .claude/, .gitea/, .husky/, scripts/, docker/ci/ — because a PR that weakens the merge gate must never be able to exempt itself from the merge gate. This deliberately also means Renovate's docker/ci/Dockerfile base bumps need a real verdict; those already require the manual publish-then-pin two-step (docs/ci-cd.md → "CI toolchain image"), so unattended merge was never correct for them.

Two deliberate non-choices. The workflow lives in its own file rather than joining pr-checks.yml, whose cancel-in-progress: true would let a superseding push cancel the run that grants an exemption, stranding a Renovate PR with no status and no further push to re-trigger it. And the workflow's docs-only pattern is narrower than the merge-consent hook's: the hook also lets .claude//.gitea// .husky/ through, which is safe there only because that path falls through to a human prompt, whereas here it would post a green status with nobody in the loop.

Option (2) from #622 — "refuse to schedule when the branch can still move" — was rejected as close to a no-op on its own, since it cannot stop a later push. It survives only as the hook-side precondition described above, which is now meaningful precisely because the server-side status exists to check.

Known limits, stated rather than papered over. This raises the floor against accident, which is the failure mode we actually have; it is not a control against a determined author of a PR, and should not be described as one:

  1. A rename hides a path unless both sides are read. Gitea reports a git mv as ONE row whose filename is the destination, with the source only in previous_filename — so reading filename alone lets a PR move a protected file into docs/ and look docs-only. Verified live (.gitea/workflows/renovate.yml → docs/innocuous-note.md showed no protected path). Both the workflow and the hook now read both sides. Noting the near-miss: an initial check against #619 suggested Gitea exposed no rename data at all, which was a false negative — that PR simply contained no renames. A constructed positive case settled it; an arbitrary sample did not.

  2. The file list must be paged, and the paging must fail closed. The endpoint caps at 50 rows and silently ignores a larger limit (PR #619: 194 changed files, ?limit=100 returns 50). A single-page read is a silent false negative — on #619 it saw zero protected paths where the full enumeration finds ten. Both call sites now page to exhaustion. Critically, each page is validated before its rows are counted, and validated per row, not just at the top level: every row must carry a non-empty string filename. An errored page, a non-array body, an array of scalars, and an array of filename-less objects all yield zero usable paths, and any of them would otherwise read as "end of list" and complete the enumeration from a partial list — failing open at precisely the point the guard exists to fail closed. An empty array stays valid, because that is what a genuine end-of-pagination looks like.

    Rename rows carry one extra requirement: a row whose status is renamed must also carry a non-empty previous_filename, or the row validates while its SOURCE silently vanishes — which is exactly the path-hiding that collecting both sides exists to prevent. It is required only for rename rows; demanding it globally would reject every ordinary modified/added row and make the gate refuse all exemptions, a failure the "withholds the exemption" tests could not distinguish from working, so there is a positive control for that too.

    This whole class lives only on the failure path, so every happy-path run looked correct and the first test suite was green throughout. It took two rounds to close: the first fix validated only the top-level type, which left [{}] as a working bypass. The tests therefore error and malform pages mid-pagination rather than only returning data, and include positive controls (an empty final page must still exempt; an ordinary row without previous_filename must still be valid) so that an over-strict guard — which would make every "withholds the exemption" test pass for the wrong reason — is also caught.

    Where this hardening stops. Three review rounds closed: single-page truncation, renames, failure-path pages, top-level-only validation, and malformed rename rows. Real Gitea populates previous_filename on renames and returns well-formed pages; everything past this point defends against response shapes with no evidence of existing. The guard's contract is now "any page we cannot fully classify withholds the exemption", and it is worth keeping that claim narrow and true rather than extending it to shapes nobody has observed.

2b. Status reads use the combined endpoint. GET /statuses/{sha} returns one row per status post (not per context) and pages at 50, so a head with a few CI reruns can push an earlier verdict off the first page. In the hook that would be a confusing false deny; in the workflow it would be worse — it would post pending (or an exemption success) over a real human verdict. Both now read GET /commits/{sha}/status, which returns latest-per-context, and the workflow refuses to post anything at all when that read fails or is unparseable, rather than treating it as "no verdict yet". 3. Changing a PR's base does not change its head sha, so a verdict status keeps applying to a diff that has materially changed. Not currently handled; low exposure here because base changes are rare and manual. 4. A PR that edits review-verdict.yml is judged by its own edited copy. Gitea runs pull_request workflows from the PR head, not the base — confirmed on the very PR that introduced this workflow (#630): review-verdict.yml does not exist on main, yet its job ran and posted a status. So PROTECTED is a guardrail against accidental self-exemption, not a tamper-proof control: a PR that rewrote the workflow would be classified by the rewritten rules. Acceptable for a two-account repo (timothy, renovate) where the threat is a careless change rather than a hostile one; it would not be for an untrusted-contributor repo, which would need the classification moved somewhere the PR cannot edit (a base-branch-pinned workflow, or server-side policy).

The same head-execution behaviour is what makes the rollout self-hosting in the good case: #630's own run correctly identified it as touching .claude/ and scripts/, refused both exemptions, and posted review-verdict/h10=pending with an actionable description.