Compare commits

..
1 Commits
Author SHA1 Message Date
jakman85andClaude Opus 5 7b9f733c97 fix(ci): let an administrator merge their own green PR
gate / gate (pull_request) Failing after 1m44s
gate / conformance (pull_request) Has been skipped
`required_approvals: 1` on `main` was a lock-out, not a protection. Gitea
refuses to let a PR's author approve their own PR, and `jakman85` is the only
collaborator — so no account in existence could approve a PR the operator
opened, including the PR that would fix that. Measured 2026-10-01 on PR #35:
gate green in 1m41s, reviews `[]`, `required_approvals: 1`, unmergeable.

It was never the documented design either: `ci/approval-policy.sh`'s header and
`ci/gate.sh:194` both already describe the model as "required_approvals drops
to 0 and the GATE decides", and `require-gate.sh`'s own closing note named this
failure and prescribed this remedy. 2026-09-30's entry flagged the 1-vs-0
disagreement as unresolved; this settles it at 0.

Layer 1 — branch protection. required_approvals 1 -> 0 in the declaration, plus
infra/gitea/allow-admin-self-merge.sh to apply it live (target read FROM the
declaration, so the script cannot drift from what the gate checks).
require-gate.sh moves to 0 too; left at 1 it would re-impose the lock-out on its
next run. The narrow choice is deliberate: the other way to unblock an owner is
block_admin_merge_override: false, which would re-open what
block-admin-override.sh was written to close (PRs #5-#9, zero approvals). This
drops the approval COUNT only — block_admin_merge_override and
enable_status_check stay true and are asserted after the PATCH, so a red gate
stays unmergeable by everyone, administrators included.

Layer 2 — ci/approval-policy.sh. Sensitive paths still need a non-author
approval the sole admin cannot get, so an administrator may waive it with an
`/approve-override <reason>` comment: directive must start a line, reason
mandatory, permission re-checked LIVE, invalidated by a new commit, and the
overrider + reason printed in the gate log and job summary. Candidate selection
is the pure, offline ci/approval-override.py (23 unit assertions, all passing);
authorisation stays in the fail-closed stage. Every new failure mode blocks.

The cost, stated not buried: for an administrator, "a change to the gate cannot
be gated by the gate" is now advisory rather than structural. Unavoidable with
one human; what is bought back is an attributed, commit-scoped record instead of
a silent bypass. And the uncomfortable part, accepted as an operator decision:
authorisation is by live permission alone, and the AGENT account `gitea-admin`
also holds `owner` — so an agent can clear its own PR this way. Documented in
approval-policy.json, the stage header, and CLAUDE.md (which tells agents not
to). Narrowing needs no code change: add `override_admins` and the stage already
requires membership.

Adjacent fix, in scope because `make -C ci test` is the only runner for the
suite added here: ci/tests/gate-decision.test.sh hand-maintained a stub list
that "must name EVERY stage gate.sh runs" and omitted `approval-policy` (added
to gate.sh by PR #17), so run_stage hit exit 127 and 15 of 50 assertions failed.
Verified pre-existing on pristine origin/main @ 0c7e8dd. The list is now derived
from gate.sh's own run_stage lines, so the omission cannot recur; the suite goes
15-failed -> 50 passing and `make -C ci test` goes FAILED -> all suites passed.

Toolbox gate: rc 3 UNDETERMINED — every stage green except `gitea-settings`
(no SETTINGS_API_TOKEN locally) and `conformance` (no cluster). NOT a green run.

The live rule is UNCHANGED and still reads 1 — mutating it is an operator
action. Until allow-admin-self-merge.sh is run, ci/gitea-settings.sh will
correctly report DRIFT and this PR will be red.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
2026-10-01 23:54:51 -05:00
@@ -144,18 +144,15 @@ missing from its test. `make -C ci test` goes from **FAILED to all suites passed
- **The live Gitea rule still says `required_approvals: 1`. I did not change it.** Mutating live
platform settings is an operator action; `infra/gitea/allow-admin-self-merge.sh` is written,
syntax-checked, and **unrun**. The declaration and the live rule must move together.
*Now measured, not predicted:* PR #38's CI run (run 202, job 0) fails at **1m44s** with
`required_approvals: DECLARED 0 but LIVE is 1` → `gitea-settings: FAIL`. Correct behaviour, and
the PR stays red until the script is run.
- **The override has never been ACCEPTED by a real run** — only offered. Measured in the same CI
log: the stage reached `approval-policy: FAIL` on the sensitive paths and printed the *new*
code's guidance, `Or, if you hold admin/owner on this repository, comment on the PR:
/approve-override <reason> ... NEWER than head commit 7b9f733c`. So the new stage **is** what
runs on this PR (self-bootstrapping confirmed by measurement, not by reasoning), and the
authorising branch — comment parse → live permission lookup → exit 0 — is still **unexercised**.
Posting the comment on PR #38 is its first real test. If it does not work, the recovery is to
PATCH `required_approvals` and read run 202's successor log.
syntax-checked, and **unrun**. Until it runs, `ci/gitea-settings.sh` will report **DRIFT** on
this branch (declared 0, live 1) and the PR will be **red** — correctly. The declaration and
the live rule must move together.
- **I have not seen the override accepted by a real CI run.** The code path has never executed
against live Gitea. The first proof will be this PR itself: it touches `ci/**`,
`infra/gitea/**` and `CLAUDE.md`, so it needs an override to pass its own new stage.
Because CI checks out the PR's merged tree, the *new* `approval-policy.sh` is what runs — it is
self-bootstrapping — but that is reasoning, not a measurement. **If the override does not work,
this PR cannot merge**, and the recovery is to PATCH `required_approvals` and read the job log.
- **I have not seen the gate still REFUSE a merge** now that approvals are 0. The claim that
`block_admin_merge_override: true` keeps a red gate unmergeable rests on Gitea's documented
behaviour and on the 2026-09-29 session, **not** on a provoked refusal in this one. That probe