fix(672): review round 2 -- correct a stale rule: field, document the self-test gap
PR Gates / Docs update reminder (pull_request) Successful in 16s
PR Gates / CI image pin matches docker/ci (pull_request) Successful in 19s
PR Gates / decisions lifecycle (pull_request) Successful in 26s
PR Gates / Script tests (pytest) (pull_request) Successful in 52s
Build ErsatzTV Image / API docs in sync (OpenAPI + endpoint index) (pull_request) Successful in 20s
Build ErsatzTV Image / Formatting (changed .cs conform to .editorconfig) (pull_request) Successful in 14s
Build ErsatzTV Image / EF migration integrity (SQLite + MySql) (pull_request) Successful in 6m22s
Build ErsatzTV Image / Functional E2E (curl + UI contracts) (pull_request) Successful in 16m17s
Build ErsatzTV Image / Build & test (.NET) (pull_request) Successful in 21m49s
Build ErsatzTV Image / Build & push image (amd64) (pull_request) Has been skipped

Re-review of the fix commits returned MERGEABLE (nine trigger mutations all
caught, every prior finding verified against independent sources) with four
low-severity findings. All four are addressed here.

F1: `release.verdict-status-check`'s `rule:` frontmatter still said "A
`pull_request` workflow auto-passes the two exempt classes". Round 1 past-tensed
that record's BODY and left its `rule:` stale -- which is the exact failure mode
the previous commit cites as the reason to put limitations in `rule:` in the
first place. The catalog row mirrors this field verbatim and it mirrors again
per-`key:` into MemPalace, so a stale `rule:` propagates further than a stale
paragraph.

F2: same record, "is what makes the rollout self-hosting" -> past tense. It
described #630 and now reads as a live property.

F3, the one that matters operationally: base resolution cuts BOTH ways. A change
to `review-verdict.yml` is no longer exercised by its own PR -- the PR runs the
version already on `main` -- so an edit goes live only ON MERGE, repo-wide,
having never run. A broken edit merges green and then breaks the gate for every
subsequent PR, and the PR that would repair it is gated by the same broken
workflow. The recipe for verifying one safely (scratch base + throwaway PR +
probe-named context) now lives in docs/ci-cd.md, which is where an operator
looks, rather than in the record.

F4: the sibling-workflow guard globbed `*.yml`, so a workflow added as `.yaml`
would be silently unscanned. Latent today, which is when it is cheap.

The record lost its meta-justification paragraph to the 60-line prose ceiling.
Fifth trim this session; the operational recipe moving to ci-cd.md is better
placement anyway, but it was forced rather than chosen. ersatztv#688.

Refs: #672
Decisions-Edit: yes
This commit is contained in:
2026-07-28 23:03:15 +02:00
parent b2a5c72bfe
commit 20b7171fba
5 changed files with 50 additions and 32 deletions
+16
View File
@@ -836,6 +836,22 @@ as establishing that the gate cannot be forged (see the residual below, and ersa
A PR whose base predates ersatztv#658 has no such script on its base ref; that case posts `pending`
with the reason rather than dying with no status at all.
⚠️ **Changing `review-verdict.yml` itself: it is not exercised by its own PR.** Base resolution cuts
both ways — the PR editing this workflow runs the version already on `main`, so an edit goes live
**only on merge**, repo-wide, having never run. A broken edit merges green and then breaks the gate
for every subsequent PR, and the PR that would repair it is gated by the same broken workflow. Do not
trust the editing PR's own checks. Verify the way ersatztv#672 did:
1. Push a scratch **base** branch carrying the candidate workflow.
2. Open a throwaway PR from a scratch head *into that base*, so the candidate is the definition that
runs. Have it post a **probe-named** context (e.g. `review-verdict/h10-PROBE`), never the real
`review-verdict/h10` — a probe must not be able to forge the gate it is testing.
3. Read the resulting commit statuses to see which definition actually ran, then delete both
branches.
The same shape is what makes a `branches:`/`types:` change verifiable at all, since neither can be
observed from the editing PR.
It lives in its **own workflow file** on purpose: `pr-checks.yml` sets `cancel-in-progress: true`,
and a cancelled run there would leave an exempt PR with no status and no further push to
re-trigger it. Its own job context (`Review verdict / Set review-verdict status`) is **not** the
+1 -1
View File
@@ -122,7 +122,7 @@ the link for rationale. Superseded/retired history lives in `archive/`. Regenera
| `release.prepush-clean-worktree-guard` | A fail-open pre-push hook blocks a push when any file in the branch's diff vs `origin/main` also has uncommitted working-tree or index changes, since a stale-index commit (e.g. `git reset --soft` + `git add` over an edited-but-unstaged fix) can silently push, CI-test, and get reviewed a different tree than the one on disk. Scope is precise to pushed-diff files; escape hatch `ETV_ALLOW_DIRTY_PUSH=1`. | 2026-07-17 | [link](records/release/prepush-clean-worktree-guard.md) |
| `release.promotion-floating-prod` | Prod tracks the floating `:prod` image reference; a tag build's immutable `:<version>` image is scanned first, then promotion happens via a separate manual `DeployStack`, with daily auto-update only as a fallback — tag with enough runway before 03:00 to avoid an unscanned promotion. | 2026-07-13 | [link](records/release/promotion-floating-prod.md) |
| `release.review-verdict-gate` | A PR may not merge until a `Review-verdict: <MERGEABLE\|APPROVED\|BLOCKED\|NOT-MERGEABLE> @ <head-sha>` comment references the PR's current head sha (short-sha prefix match against the verdict's OWN `@ <sha>` field, marker at COLUMN 0 (no indent, so indented code blocks cannot self-approve), whole-word verdict token, fenced code blocks stripped with markdown fence-length semantics, negative wins over positive on the same head); folds into the H6 merge-consent hook as condition (c). The grammar lives in ONE tested place, `scripts/check-review-verdict.sh` — #629 found three false-opens that survived because it was implemented inline and untested while this record described stricter behaviour than the code had. | 2026-07-12 | [link](records/release/review-verdict-gate.md) |
| `release.verdict-status-check` | 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). | 2026-07-25 | [link](records/release/verdict-status-check.md) |
| `release.verdict-status-check` | 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_target` 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). | 2026-07-25 | [link](records/release/verdict-status-check.md) |
| `rulebuilder.relative-date-macros` | The visual rule builder's `inLast`/`notInLast` date operators compile to/parse from the pre-existing `CustomMultiFieldQueryParser` macros `released_inthelast`/`released_notinthelast` and `added_inthelast`/`added_notinthelast`, value form `"<n> day\|week\|month\|year"`; there is no backend change. | 2026-07-23 | [link](records/rulebuilder/relative-date-macros.md) |
| `scan.collections-scan-status` | `GET /api/v1/media-sources/collections-scan-status` reports a family-global (not per-source), boolean-only active-scan set read from `IEntityLocker`; the SPA reconciles authoritatively against it (with a grace-tick helper) instead of a fixed client-side timeout. | 2026-07-12 | [link](records/scan/collections-scan-status.md) |
| `scan.getoraddfolder-db-lookup` | `ILibraryRepository.GetOrAddFolder` resolves the existing folder via a DB query on `(LibraryPathId, Path)`, not the caller's `LibraryPath.LibraryFolders` in-memory navigation, since that navigation is only eager-loaded on the local scan path and is null on remote (Jellyfin) callers. | 2026-07-20 | [link](records/scan/getoraddfolder-db-lookup.md) |
@@ -21,31 +21,29 @@ Two things that look preventive were not: `PROTECTED` is defined by the same rew
branch protection requires the *context*, not an author, while carrying `required_approvals: 0`.
**Measured, not inferred.** The premise is a claim about someone else's software, so it was settled
on this instance (Gitea 1.25.4) with **four** scratch PRs, not by analogy to GitHub. A PR rewriting
the workflow posted its own probe context and the real `review-verdict/h10` was never written — the
base definition never ran. Under `pull_request_target` the identical rewrite was ignored: the base
definition ran and posted `h10=pending`, on `opened` and `synchronize` alike, with `secrets` still
available. With `branches: [main]`, a PR into a non-`main` base produced no run and no status at all.
The fourth probe is the negative one that established the residual below; it is counted because
omitting it is what turns an honest partial into an overclaim. The probes posted only probe-named
contexts, never a forged `h10`. Not measured: whether `reopened`/`ready_for_review` fire here.
on this instance (Gitea 1.25.4) with **four** scratch PRs, not by analogy to GitHub: `pull_request` ran
the head's rewrite and never wrote the real `h10`; `pull_request_target` ignored the identical rewrite
and the base definition posted `h10=pending` on `opened` and `synchronize` alike, secrets available;
`branches: [main]` produced no run at all from a non-`main` base; and the fourth — the negative one
that established the residual below — is counted because omitting it turns an honest partial into an
overclaim. Probes posted only probe-named contexts, never a forged `h10`. Full results in #699. Not
measured: whether `reopened`/`ready_for_review` fire here.
**Why `branches: [main]` is load-bearing rather than tidy.** Base resolution means the *base branch*
supplies the definition, and anyone who can push a branch can make it a base — so dropping the filter
trades a head-supplied gate for a base-supplied one and closes nothing. Worse than lateral: a commit
status is repo-global per sha (`#663`), so a `success` forged against a scratch base is **inherited**
by a later genuine PR into `main` with the same head. The filter keeps "the base" and "`main`" the
same thing.
**Why `branches: [main]` is load-bearing rather than tidy.** The *base branch* supplies the
definition, and anyone who can push a branch can make it a base — so dropping the filter trades a
head-supplied gate for a base-supplied one and closes nothing. Worse than lateral: a commit status is
repo-global per sha (`#663`), so a `success` forged against a scratch base is **inherited** by a later
genuine PR into `main` with the same head.
**Why `pull_request_target` is not the footgun it usually is.** Its standard danger is executing
untrusted head code with a privileged token; this job executes none, checking out `base.sha` with
`persist-credentials: false` and running only that tree's scripts. Trigger and checkout are one
decision — under this trigger a head checkout would be strictly worse than #672 was.
**Options not taken.** `required_approvals: 1` was the cheapest mechanical fix and is unusable here:
Gitea forbids approving your own PR and this is effectively a single-maintainer repo, so it would
deadlock every PR rather than gate the dangerous ones. Verifying the status *author* needs an actor
the PR cannot control, and the tampered workflow holds the same `GITEA_TOKEN`.
**Options not taken.** `required_approvals: 1`, the cheapest mechanical fix, is unusable here: Gitea
forbids approving your own PR and this is effectively a single-maintainer repo, so it deadlocks every
PR instead of gating the dangerous ones. Verifying the status *author* needs an actor the PR cannot
control, and the tampered workflow holds the same `GITEA_TOKEN`.
**Severity, stated plainly.** Never remotely exploitable — pushing a branch requires write access, so
the threat model is a compromised contributor, who has other paths. Fixed because a gate whose
@@ -56,17 +54,19 @@ instance of "a ref-resolved workflow can obtain credentials that POST a commit s
inventory is not a short list: Gitea injects `GITEA_TOKEN` into **every** job, defaulting to
read/**write**, so head-resolved, `push`-triggered and `workflow_dispatch` workflows alike are routes
(1.24+ loads a dispatched definition from the selected branch). A collaborator's own API token is a
route with no workflow at all — branch protection binds the *context*, not its issuer. Full
inventory in `#697`; the exemption path's own defects are `#698`. No in-repository test can establish
status-authority isolation: the sibling-workflow guard added here catches only plain-text naming of
the context. Spelled out because the predecessor record's documented failure was a reassuring
sentence exactly where a catalog reader stops.
route with no workflow at all — branch protection binds the *context*, not its issuer. Full inventory
in `#697`; the exemption path's own defects are `#698`. No in-repository test can establish
status-authority isolation: the sibling guard added here catches only plain-text naming of the
context.
**The gate is no longer exercised by its own PR** — base resolution cuts both ways, so an edit here
goes live only on merge, repo-wide, untested. How to verify one safely is in `docs/ci-cd.md`.
**Residual.** The job's own context is renamed to `... (pull_request_target)`, safe only because it
was never one of branch protection's required contexts (the two `docker-build.yml` contexts plus
`review-verdict/h10`); adding it would let the workflow satisfy the gate by merely running. **A trap
for #697:** those two carry the literal suffix `(pull_request)`, so giving `docker-build.yml` the
same treatment renames them and deadlocks every merge unless branch protection is edited in the same
operation. A PR based off a non-`main` branch now gets no status where it previously got one —
fail-closed, and it removes a `#663` inheritance hazard — but `edited` is absent from `types:`, so a
PR retargeted onto `main` stays statusless until its next `synchronize`.
for #697:** those two carry the literal `(pull_request)` suffix, so giving `docker-build.yml` the same
treatment renames them and deadlocks merges unless branch protection is edited in the same operation.
A non-`main` base now yields no status where it previously got one — fail-closed, and it removes a
`#663` hazard — but `edited` is absent from `types:`, so a PR retargeted onto `main` stays statusless
until its next `synchronize`.
@@ -5,7 +5,7 @@ status: active
since: '2026-07-25'
supersedes: none
superseded-by: none
rule: '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).'
rule: '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_target` 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).'
signals: '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'
mechanics: '`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`'
---
@@ -188,6 +188,6 @@ described as one:
An untrusted-contributor repo would still need the classification moved somewhere no PR can
reach (server-side policy), not merely a base-pinned definition.
The same head-execution behaviour is what makes the rollout self-hosting in the good case: #630's
The same head-execution behaviour was what made 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.
+3 -1
View File
@@ -562,7 +562,9 @@ def test_no_OTHER_workflow_writes_the_review_verdict_status():
plainly so nobody reads a green here as "only one writer is possible".
"""
offenders = []
for wf in sorted((REPO_ROOT / ".gitea" / "workflows").glob("*.yml")):
# `*.y*ml`, not `*.yml` — a workflow added as `.yaml` is just as executable and would otherwise
# be silently unscanned. Latent today (no `.yaml` exists), which is exactly when it is cheap.
for wf in sorted((REPO_ROOT / ".gitea" / "workflows").glob("*.y*ml")):
if wf.name == WORKFLOW.name:
continue
# CODE lines only — `docs`-style commentary in a workflow header legitimately discusses the