From 6d803433209d683e2ca38a33b738168cd382deb2 Mon Sep 17 00:00:00 2001 From: Timothy Date: Wed, 5 Aug 2026 23:52:28 +0200 Subject: [PATCH] fix(743): close the admin force-merge bypass; the push half alone was not enough MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Independent review found the record repeated on the merge path exactly the mistake it had just diagnosed on the push path. The push argument was: a whitelist naming `timothy` closes nothing, because `timothy` is the identity every credential already holds. The merge path had the identical shape and went unchecked — `block_admin_merge_override` defaults to `false`, so `CanBypassBranchProtection` returns true for a repo admin and `POST /pulls/{n}/merge` with `force_merge: true` merges straight past a missing or red `review-verdict/h10`. One API call, no forgery, no PATCH — cheaper than the push route this change had just removed. So `enable_push: false` alone did NOT make the gate load-bearing, which is what the record's headline sentence claimed. `main` now carries both fields; they are one control and neither is citable alone. An admin-shaped control that exempts the only admin exempts everybody. Other review findings addressed: - H11's owning record (`release.format-as-you-touch-rebase`) now documents the #719 tag-only carve-out. It is a narrowing of an existing convention, so it amends that record rather than adding a new one — including the two details that are easy to regress (the .husky/pre-push forwarding, without which the exemption is dead code the unit tests still pass over; and the at-least-one- ref guard against vacuous exemption). - The record now states which write surfaces were enumerated and how each was established — contents-API refusal is MEASURED here (403 `user cannot commit to repo`), apply-patch/revert/cherry-pick are source-attested only. The admin force-merge bypass is likewise marked source-attested, not probed: probing it means merging an unreviewed PR. - prepush-rebase-check.sh: process a final ref line with no trailing newline (previously dropped, which silently reinstated the #719 block), and skip the stdin read on a TTY so an interactive run does not hang. - Corrected a citation the review caught: docs/ci-cd.md documents the tag step, not a release-notes-PR flow. Cite #719 for the observed flow instead. Also fixed a frontmatter break this round introduced: a `: ` inside the unquoted `rule:` scalar. PyYAML rejected it while the dependency-free reader accepted it, so only `scripts/tests` caught it. Verification: 438/438 script tests pass; decisions-validate OK; PyYAML parses all three touched records. refs #743 #719 Decisions-Edit: yes Co-Authored-By: Claude Opus 5 (1M context) --- .claude/hooks/prepush-rebase-check.sh | 16 ++++++--- docs/ci-cd.md | 20 +++++++---- docs/decisions/README.md | 4 +-- .../release/format-as-you-touch-rebase.md | 20 +++++++++-- .../release/main-direct-push-disabled.md | 36 ++++++++++++++----- ...test_prepush_rebase_check_tag_exemption.py | 11 +++--- 6 files changed, 78 insertions(+), 29 deletions(-) diff --git a/.claude/hooks/prepush-rebase-check.sh b/.claude/hooks/prepush-rebase-check.sh index 3a65bdc95..4dfa00f45 100755 --- a/.claude/hooks/prepush-rebase-check.sh +++ b/.claude/hooks/prepush-rebase-check.sh @@ -12,11 +12,11 @@ set -uo pipefail [ "${ETV_SKIP_REBASE_CHECK:-}" = "1" ] && exit 0 git rev-parse --git-dir >/dev/null 2>&1 || exit 0 -# Tag-only push exemption (ersatztv#719): a release cut tags the merge commit of a just-merged -# release-notes PR (docs/ci-cd.md -> "Cutting a release"), so the local branch is ALWAYS 1 commit -# behind origin/main at tag time -- H11 blocked every release. A tag push cannot revert anyone's +# Tag-only push exemption (ersatztv#719): the release cut tags a commit on main while the local +# branch sits 1 commit behind origin/main, so H11 blocked EVERY release -- and its "rebase first" +# advice did not even apply, since no branch was being pushed. A tag push cannot revert anyone's # merged work, which is the failure mode H11 exists to prevent, so skip the freshness check when -# EVERY ref being pushed is under refs/tags/. +# EVERY ref being pushed is under refs/tags/. (See #719 for the observed flow.) # # Read pushed refs from stdin: git feeds pre-push hooks one line per ref, " # " (.husky/pre-push forwards the lines it already captured). Ignore blank @@ -24,15 +24,21 @@ git rev-parse --git-dir >/dev/null 2>&1 || exit 0 # (hook run manually, stdin not forwarded, etc.) -- that would silently disable H11 for every push. # Require at least one parsed ref line before granting the exemption; with zero lines, fall through # to the existing branch-freshness check below (current behavior preserved). +# +# `[ -t 0 ] ||` so an interactive run does not hang waiting on a terminal: this script had no stdin +# reader before #719, and its own docs call "run by hand" a supported case. A TTY yields no ref +# lines, which is exactly the zero-line fall-through. _h11_refs_seen=0 _h11_all_tags=1 -while IFS=' ' read -r _h11_local_ref _h11_local_sha _h11_remote_ref _h11_remote_sha; do +[ -t 0 ] || while IFS=' ' read -r _h11_local_ref _h11_local_sha _h11_remote_ref _h11_remote_sha \ + || [ -n "${_h11_local_ref:-}" ]; do # `|| [ -n ... ]` also processes a final line with no trailing newline [ -z "${_h11_local_ref:-}" ] && continue _h11_refs_seen=1 case "${_h11_remote_ref:-}" in refs/tags/*) ;; *) _h11_all_tags=0 ;; esac + _h11_local_ref='' done if [ "$_h11_refs_seen" = "1" ] && [ "$_h11_all_tags" = "1" ]; then exit 0 diff --git a/docs/ci-cd.md b/docs/ci-cd.md index b7e49e0de..a0e529161 100644 --- a/docs/ci-cd.md +++ b/docs/ci-cd.md @@ -773,12 +773,20 @@ from `Build ErsatzTV Image / …` to `PR Gates / …`) does not affect merges. T unreviewed commit from merging** (ersatztv#622). It is not produced by a job's success/failure; it is a commit status that `scripts/post-review-verdict.sh` POSTs onto one specific sha. -**`main` is PR-only, and that is what makes the check load-bearing** (ersatztv#743, -`release.main-direct-push-disabled`). Gitea evaluates `status_check_contexts` when it **merges a -PR** — a direct `git push origin HEAD:main` never consults them. So until 2026-08-05 the entire gate -was skippable with no forgery at all, which was cheaper than every route enumerated in #697. `main` -now carries `enable_push: false`: a direct push is refused server-side at pre-receive -(`Not allowed to push to protected branch main`), for every account including a site admin. +**`main` is PR-only AND admin-override-proof, and it takes both to make the check load-bearing** +(ersatztv#743, `release.main-direct-push-disabled`). Gitea evaluates `status_check_contexts` when it +**merges a PR** — a direct `git push origin HEAD:main` never consults them. So until 2026-08-05 the +entire gate was skippable with no forgery at all, which was cheaper than every route enumerated in +#697. `main` now carries **two** fields, and citing either alone is a mistake: + +- `enable_push: false` — a direct push is refused server-side at pre-receive (`Not allowed to push to + protected branch main`), for every account including a site admin. The contents API and web editor + are refused too (HTTP 403 `user cannot commit to repo`); they share the same predicate. +- `block_admin_merge_override: true` — without it (the default is `false`), a repo admin could + `POST /pulls/{n}/merge` with `force_merge: true` and merge straight past a missing or red + `review-verdict/h10`. Disabling push alone just moves the bypass from the push path to the merge + path, since `timothy` is admin and is the identity every session already uses. + Practical consequences: **every** change to `main` goes through a PR, including a one-line docs fix; and the client-side Husky guards (H6/H11/H13) remain useful friction but were never the control — they are fail-open and `--no-verify` bypasses them. Tag pushes are unaffected (separate mechanism; diff --git a/docs/decisions/README.md b/docs/decisions/README.md index a7231ae23..a394c1f4a 100644 --- a/docs/decisions/README.md +++ b/docs/decisions/README.md @@ -121,9 +121,9 @@ the link for rationale. Superseded/retired history lives in `archive/`. Regenera | `process.subagent-drop-resume` | Treat a subagent connection drop as laptop sleep or transient network and re-resume via SendMessage — the work survives. | 2026-07-21 | [link](records/process/subagent-drop-resume.md) | | `release.api-contract-ci-gate` | A PR touching `ErsatzTV/Controllers/Api/**` or `ErsatzTV.Core/Api/**` must ship regenerated OpenAPI artifacts (`v1.json`, `v1.d.ts`, `endpoint-index.md`) in the same diff, enforced by a blocking `api-docs` CI job that regenerates-and-diffs against a fresh build. | 2026-07-12 | [link](records/release/api-contract-ci-gate.md) | | `release.done-when-merge-consent` | A PR may merge only when its linked issue's `## Done-when` checklist is fully ticked and the PR's CI is green, enforced by a PreToolUse hook on the Gitea merge tool (deny/allow/ask) plus a pre-push backstop for direct pushes to main. | 2026-07-12 | [link](records/release/done-when-merge-consent.md) | -| `release.format-as-you-touch-rebase` | A blocking `format` CI job runs `dotnet format --verify-no-changes` scoped only to the PR's changed `.cs` files (never the legacy BOM backlog), and a PR branch must be kept current by rebasing on `origin/main` (never merging main in), enforced by `.husky/pre-push` → `prepush-rebase-check.sh`. | 2026-07-12 | [link](records/release/format-as-you-touch-rebase.md) | +| `release.format-as-you-touch-rebase` | A blocking `format` CI job runs `dotnet format --verify-no-changes` scoped only to the PR's changed `.cs` files (never the legacy BOM backlog), and a PR branch must be kept current by rebasing on `origin/main` (never merging main in), enforced by `.husky/pre-push` → `prepush-rebase-check.sh`. H11 has ONE always-on carve-out, #719 — a push in which EVERY ref is under `refs/tags/` skips the freshness check, because a tag push cannot revert merged work, which is the failure mode H11 exists to prevent, and the release cut always tags from a branch that is 1 behind `origin/main`. A push mixing branch and tag refs is still blocked, and so is a push with zero parsed ref lines (the exemption requires at least one, so empty stdin cannot vacuously disable H11). | 2026-07-12 | [link](records/release/format-as-you-touch-rebase.md) | | `release.live-e2e-required` | A PR that changes an API write-path handler must include a live-E2E pass (driving the real endpoint/screen and confirming the round-trip through a subsequent read), not only unit/characterization tests, and must state whether live-E2E ran or wasn't required. | 2026-07-12 | [link](records/release/live-e2e-required.md) | -| `release.main-direct-push-disabled` | Branch protection on `main` carries `enable_push: false`, so `main` is reachable ONLY through the PR merge path — the one path on which Gitea evaluates `status_check_contexts`, and therefore the only path on which `review-verdict/h10` is consulted at all. This is what makes merge-consent derived rather than merely conventional: before it, `git push origin HEAD:main` skipped the gate with no forgery, which was strictly cheaper than every route enumerated in #697. Do NOT "soften" this to a push WHITELIST: measured on this instance, a whitelist naming `timothy` still admits the push, and `timothy` is the identity every agent session, PAT and injected `GITEA_TOKEN` already acts as — so the whitelist form closes nothing while reading in review as a control. The block binds a site admin at pre-receive; it does NOT bind a credential that can first PATCH branch protection, which an admin token can (see the residual below). Tag pushes are unaffected — a separate mechanism (`tag_protections`) governs them, so the release cut still works. | 2026-08-05 | [link](records/release/main-direct-push-disabled.md) | +| `release.main-direct-push-disabled` | Branch protection on `main` carries `enable_push: false` AND `block_admin_merge_override: true`. Both halves are required and neither is sufficient. `enable_push: false` removes the direct-push path, leaving the PR merge path — the only path on which Gitea evaluates `status_check_contexts`, and therefore the only path on which `review-verdict/h10` is consulted at all. `block_admin_merge_override: true` then closes the force-merge bypass on that remaining path: with it false (the default), `CanBypassBranchProtection` returns true for a repo admin, so `POST /pulls/{n}/merge` with `force_merge: true` merges a PR whose `h10` is missing or red — one API call, no forgery, no PATCH. Do NOT "soften" the push half to a push WHITELIST: measured here, a whitelist naming `timothy` still admits the push, and `timothy` is the identity every agent session, PAT and injected `GITEA_TOKEN` already acts as, so the whitelist form closes nothing while reading in review as a control. Same reasoning is why the admin-override half is needed: an admin-shaped control that exempts the only admin exempts everybody. What remains open: a credential that can PATCH branch protection off can still undo either half — an accepted residual, not a closed route. Tag pushes are unaffected (`tag_protections` governs those separately), so the release cut still works. | 2026-08-05 | [link](records/release/main-direct-push-disabled.md) | | `release.merge-consent-autogrant` | When Done-when boxes are ticked, CI is green, and a fresh positive Review-verdict references head, the merge-consent hook emits `permissionDecision: allow` to actually suppress the redundant mechanical prompt — the derived state IS the consent, no separate conversational confirmation on that path. | 2026-07-12 | [link](records/release/merge-consent-autogrant.md) | | `release.migration-rehearsal-prodcopy` | Before promoting a migration-bearing release, rehearse the new image's migrations against a throwaway copy of the latest prod backup (`scripts/migration-smoke.sh`), gating PASS on the migrator's completion log line rather than HTTP readiness alone. | 2026-07-12 | [link](records/release/migration-rehearsal-prodcopy.md) | | `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) | diff --git a/docs/decisions/records/release/format-as-you-touch-rebase.md b/docs/decisions/records/release/format-as-you-touch-rebase.md index fdceb2dbf..130c0fbfb 100644 --- a/docs/decisions/records/release/format-as-you-touch-rebase.md +++ b/docs/decisions/records/release/format-as-you-touch-rebase.md @@ -5,8 +5,8 @@ status: active since: '2026-07-12' supersedes: none superseded-by: none -rule: A blocking `format` CI job runs `dotnet format --verify-no-changes` scoped only to the PR's changed `.cs` files (never the legacy BOM backlog), and a PR branch must be kept current by rebasing on `origin/main` (never merging main in), enforced by `.husky/pre-push` → `prepush-rebase-check.sh`. -signals: 'format-as-you-touch, rebase not merge, BOM backlog · paths: `.husky/pre-push`, `.claude/hooks/prepush-rebase-check.sh` · issues: #311 (H11), #309, #310, #269, #312' +rule: 'A blocking `format` CI job runs `dotnet format --verify-no-changes` scoped only to the PR''s changed `.cs` files (never the legacy BOM backlog), and a PR branch must be kept current by rebasing on `origin/main` (never merging main in), enforced by `.husky/pre-push` → `prepush-rebase-check.sh`. H11 has ONE always-on carve-out, #719 — a push in which EVERY ref is under `refs/tags/` skips the freshness check, because a tag push cannot revert merged work, which is the failure mode H11 exists to prevent, and the release cut always tags from a branch that is 1 behind `origin/main`. A push mixing branch and tag refs is still blocked, and so is a push with zero parsed ref lines (the exemption requires at least one, so empty stdin cannot vacuously disable H11).' +signals: 'format-as-you-touch, rebase not merge, BOM backlog, tag-only push exemption, H11 blocks release cut, refs/tags pre-push, vacuous-truth guard · paths: `.husky/pre-push`, `.claude/hooks/prepush-rebase-check.sh`, `scripts/tests/test_prepush_rebase_check_tag_exemption.py` · issues: #311 (H11), #719, #309, #310, #269, #312' mechanics: '`docs/contributing.md` §7; `.claude/hooks/prepush-rebase-check.sh`; `npm run check:api`' --- @@ -36,5 +36,21 @@ git hook has no "ask"); deliberate escape `ETV_SKIP_REBASE_CHECK=1`. This supers guidance to "merge main into your PR branch." (After a rebase that conflicts in *generated* artifacts — v1.json/v1.d.ts/endpoint-index — regenerate, don't hand-resolve; `npm run check:api` guards.) +**2a. The tag-only carve-out (#719).** H11 as originally written fired on *every* release cut: the +documented sequence tags the merge commit of a just-merged release-notes PR, so the local branch is +always 1 behind `origin/main` at tag time, and the rebase advice it printed did not even apply — no +branch was being pushed. The hook now reads git's pre-push ref lines (` + `) and exits 0 when every parsed line's *remote* ref is under `refs/tags/`. +Two details are load-bearing and easy to regress: +- `.husky/pre-push` consumes stdin into `$_prepush_refs` before any guard runs, so it must **forward** + those lines (`printf '%s\n' "$_prepush_refs" | …`). Without that the check receives EOF and the + exemption is dead code that silently never fires. The unit tests drive the hook directly and would + still pass, so this wiring is not covered by them. +- The exemption requires **at least one** parsed ref line. "All refs are tags" is vacuously true for + zero lines, which would disable H11 for every push; with no lines the hook falls through to the + normal freshness check. `scripts/tests/test_prepush_rebase_check_tag_exemption.py` pins both the + negative control (branch push from a behind branch still blocked), the mixed branch+tag case, and + the two zero-line cases. + Rationale, as with the whole hook program: make the process rule a derivation/hook, not prose to remember (#303 methodology review). Tracked: #311; sibling #312 (H12 issue-qualification audit). diff --git a/docs/decisions/records/release/main-direct-push-disabled.md b/docs/decisions/records/release/main-direct-push-disabled.md index b68f7ce50..8ace6099e 100644 --- a/docs/decisions/records/release/main-direct-push-disabled.md +++ b/docs/decisions/records/release/main-direct-push-disabled.md @@ -5,9 +5,9 @@ status: active since: '2026-08-05' supersedes: none superseded-by: none -rule: 'Branch protection on `main` carries `enable_push: false`, so `main` is reachable ONLY through the PR merge path — the one path on which Gitea evaluates `status_check_contexts`, and therefore the only path on which `review-verdict/h10` is consulted at all. This is what makes merge-consent derived rather than merely conventional: before it, `git push origin HEAD:main` skipped the gate with no forgery, which was strictly cheaper than every route enumerated in #697. Do NOT "soften" this to a push WHITELIST: measured on this instance, a whitelist naming `timothy` still admits the push, and `timothy` is the identity every agent session, PAT and injected `GITEA_TOKEN` already acts as — so the whitelist form closes nothing while reading in review as a control. The block binds a site admin at pre-receive; it does NOT bind a credential that can first PATCH branch protection, which an admin token can (see the residual below). Tag pushes are unaffected — a separate mechanism (`tag_protections`) governs them, so the release cut still works.' +rule: 'Branch protection on `main` carries `enable_push: false` AND `block_admin_merge_override: true`. Both halves are required and neither is sufficient. `enable_push: false` removes the direct-push path, leaving the PR merge path — the only path on which Gitea evaluates `status_check_contexts`, and therefore the only path on which `review-verdict/h10` is consulted at all. `block_admin_merge_override: true` then closes the force-merge bypass on that remaining path: with it false (the default), `CanBypassBranchProtection` returns true for a repo admin, so `POST /pulls/{n}/merge` with `force_merge: true` merges a PR whose `h10` is missing or red — one API call, no forgery, no PATCH. Do NOT "soften" the push half to a push WHITELIST: measured here, a whitelist naming `timothy` still admits the push, and `timothy` is the identity every agent session, PAT and injected `GITEA_TOKEN` already acts as, so the whitelist form closes nothing while reading in review as a control. Same reasoning is why the admin-override half is needed: an admin-shaped control that exempts the only admin exempts everybody. What remains open: a credential that can PATCH branch protection off can still undo either half — an accepted residual, not a closed route. Tag pushes are unaffected (`tag_protections` governs those separately), so the release cut still works.' signals: 'direct push to main, push whitelist, enable_push false, branch protection bypass, review-verdict/h10 bypassable without forging, merge consent derived not asserted, pre-receive hook declined, Not allowed to push to protected branch, protected branch, tag_protections, release tag push, GITEA_TOKEN repo write, RENOVATE_TOKEN, site admin bypass, PR-only flow · paths: `docs/ci-cd.md` · issues: #743, #697, #698, #622, #672, #706, #742, server-management#714' -mechanics: 'Gitea 1.27.1. `PATCH /api/v1/repos/timothy/ersatztv/branch_protections/main` with `{"enable_push": false}`; whitelist fields left off (`enable_push_whitelist: false`, empty arrays). Verified 2026-08-05 against a throwaway `probe-743-*` rule rather than against `main`: with `enable_push: false` a push by `timothy` (site admin) was REFUSED — `pre-receive hook declined`, `Not allowed to push to protected branch`; after PATCHing the same rule to `enable_push: true` + `enable_push_whitelist: true` + `push_whitelist_usernames: ["timothy"]` the identical push SUCCEEDED. Then on `main` itself: `git push origin HEAD:main` REFUSED, and a tag-only push SUCCEEDED in the same worktree. `GET .../tag_protections` returns `[]`. All probe artifacts (rule, branch, tag) deleted and confirmed gone; `origin/main` head unchanged at `08e95f9ec` throughout.' +mechanics: 'Gitea 1.27.1. `PATCH /api/v1/repos/timothy/ersatztv/branch_protections/main` with `{"enable_push": false, "block_admin_merge_override": true}`; whitelist fields left off (`enable_push_whitelist: false`, empty arrays), `enable_force_push: false`, `enable_merge_whitelist: false`, `required_approvals: 0`. MEASURED 2026-08-05 against a throwaway `probe-743-*` rule rather than against `main`: with `enable_push: false` a push by `timothy` (site admin) was REFUSED — `pre-receive hook declined`, `Not allowed to push to protected branch`; after PATCHing the same rule to `enable_push: true` + `enable_push_whitelist: true` + `push_whitelist_usernames: ["timothy"]` the identical push SUCCEEDED. Separately probed on a second throwaway rule: a contents-API write (`PUT /repos/{o}/{r}/contents/{path}` with `branch` set to the protected branch) was REFUSED HTTP 403 `user cannot commit to repo [user: timothy]` — so the web-editor/API file-write surface does not bypass it either. Then on `main` itself: `git push origin HEAD:main` REFUSED, and a tag-only push SUCCEEDED from the same worktree. `GET .../tag_protections` returns `[]`; repo is `fork: false`, `mirror: false`. NOT measured, source-attested only (Gitea 1.27 `CanBypassBranchProtection`, `services/pull/check.go`, `routers/private/hook_pre_receive.go`): that `block_admin_merge_override: false` would have let an admin `force_merge` past the required contexts — the field was set to true rather than probed, since probing it means merging an unreviewed PR. All probe artifacts (two rules, two branches, one tag) deleted and confirmed gone; `origin/main` head unchanged at `08e95f9ec` throughout.' --- **Why a whitelist was the wrong shape.** #743 proposed "a push whitelist on `main` (or disable direct @@ -20,19 +20,37 @@ the control is supposed to constrain. It would have ticked the issue's box while This was measured, not reasoned: the same push was refused under `enable_push: false` and accepted under a whitelist naming `timothy`. +**Disabling push alone was NOT enough, and the reason is the same argument twice.** The first draft of +this record disabled direct push and concluded that `review-verdict/h10` was therefore load-bearing. +An independent review caught that this repeated on the merge path exactly the mistake it had just +diagnosed on the push path. The push argument was: a whitelist naming `timothy` fails because +`timothy` is the identity every credential already holds. The merge path had the identical shape — +`block_admin_merge_override` defaulted to `false`, so `CanBypassBranchProtection` returned true for a +repo admin and `POST /pulls/{n}/merge` with `force_merge: true` merged straight past a missing or red +`h10`. One API call, cheaper than the push route it replaced. **An admin-shaped control that exempts +the only admin exempts everybody.** Both fields are now set; treat them as one control, and never +cite `enable_push: false` alone as the reason the gate holds. + **What this actually closes, and what it does not.** It closes the *write-only* credential routes, which is most of #743's own "who can do it" list: the injected `GITEA_TOKEN` (repo write, not admin), `RENOVATE_TOKEN`, and any non-admin collaborator PAT. Those can no longer reach `main` at all, by any path that skips the gate. It does **not** close the admin route. `timothy` is a site admin, so a credential holding that -identity can `PATCH` the branch protection off, push, and restore it — the exact sequence used to -*prove* the semantics above. Closing that requires agent sessions to run as a scoped non-admin -credential, which is a different change with its own cost (packages live in a user namespace; see the -"Admin ownership is a real residual" section of `ci.actions-credential-scoping`). Recorded as an -accepted residual rather than fixed here, so it is not mistaken for covered. The severity bound from -#697 and #743 is unchanged throughout: push access is required, so this is a compromised contributor -or a subverted automated session, never an anonymous attacker. +identity can `PATCH` either field off, act, and restore it — the exact sequence used to *prove* the +push semantics above. Closing that requires agent sessions to run as a scoped non-admin credential, +which is a different change with its own cost (packages live in a user namespace; see the "Admin +ownership is a real residual" section of `ci.actions-credential-scoping`). Recorded as an accepted +residual rather than fixed here, so it is not mistaken for covered. The severity bound from #697 and +#743 is unchanged throughout: push access is required, so this is a compromised contributor or a +subverted automated session, never an anonymous attacker. + +**Which write surfaces were enumerated.** `git push` (measured, refused), the contents API and by +extension the web editor / upload path (measured on a probe branch, refused HTTP 403 — they share the +`CanUserPush` predicate, which has no admin special-case and no `unprotected_file_patterns` carve-out +since that field is empty), apply-patch / revert / cherry-pick (source-attested, same predicate), +force push (`enable_force_push: false`), default-branch deletion (separately refused), and fork-sync / +mirror (not applicable: `fork: false`, `mirror: false`). Merge remains the one intended path. **Why the release cut does not deadlock.** #743 flagged that the tag path had to keep working, and #719 documents H11 blocking a tag-only push on every release cut. Branch protection is scoped to diff --git a/scripts/tests/test_prepush_rebase_check_tag_exemption.py b/scripts/tests/test_prepush_rebase_check_tag_exemption.py index 379e3c540..6f3c28088 100644 --- a/scripts/tests/test_prepush_rebase_check_tag_exemption.py +++ b/scripts/tests/test_prepush_rebase_check_tag_exemption.py @@ -1,11 +1,12 @@ """Tests for the tag-only-push exemption in `.claude/hooks/prepush-rebase-check.sh` (ersatztv#719). H11 refuses to push a branch that is behind `origin/main`, to force a rebase instead of a merge. -But the documented release flow (`docs/ci-cd.md` -> "Cutting a release") tags the merge commit of a -just-merged release-notes PR, so the local branch is *always* one commit behind `origin/main` at tag -time -- H11 blocked every release cut. A tag push cannot revert anyone's merged work (the failure -mode H11 exists to prevent), so the fix skips the freshness check when EVERY ref being pushed is -under `refs/tags/`. +But the release cut tags a commit on `main` from a branch that is behind `origin/main`, so H11 +blocked every release -- and its "rebase first" advice did not even apply, because no branch was +being pushed. (Observed while cutting v26.13.0; see #719. `docs/ci-cd.md` -> "Cutting a release" +documents the tag step itself, not the release-notes-PR flow that puts the branch behind.) A tag +push cannot revert anyone's merged work (the failure mode H11 exists to prevent), so the fix skips +the freshness check when EVERY ref being pushed is under `refs/tags/`. These tests use real local git repositories (a bare "origin" plus a work tree pushed one commit behind it) rather than stubbing `git`, because the hook's decision hinges on genuine