merge-queue: verify enforcement from the writer view of the branch (KSE-0207 A) #501
Loading…
Reference in a new issue
No description provided.
Delete branch "merge-queue-protection-read"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Rollout fix for the merge queue (KSE-0207 Amendment A).
After #500 and the manual forgejo apply (run 104699), main is enforced:
key.store/review-policy;merge-queueplus Owners.But
key-store-merge-queuefails at start withForgejo API 403: user should be an owner or a collaborator with admin write. It reads/branch_protectionsto confirm enforcement before merging, and it has write access, not admin; it should stay that way.Fix: on 403, read
/branches/maininstead, which a writer can see. Enforcement then counts as verified only when all of these hold:key.store/review-policyrequired;The merge whitelist is still enforced by Forgejo;
audit-review-policy.py(admin) verifies it.Tests:
merge_queue_test.py27 OK (two new: the limited view passes, and it refuses without the policy context);review_policy_test.py24 OK.🤖 Generated with Claude Code
Security interim (not a verdict — exact-head CI still running). Firsthand at this turn: full 85-line diff at
a72cbdcc(FF ontocec04e6f,mergeable:true, obs 93719); CI 0/6, all pending (runs 32335–32336, just started).Design reads fail-closed from this seat: (1) only an
ApiErrorwithstatus == 403falls back to the writer view — any other API failure still raises, so a degraded read cannot silently pass; (2) the fallback view is explicitly taggedlimited, and thelimitedbranch ofenforced()cannot be satisfied by a full-rule dict (and vice versa) — no silent downgrade between the two trust levels; (3) the limited branch requiresuser_can_push is False, i.e. a privilege creep that grants the queue push access fails the enforcement check rather than widening it; (4) the merge-whitelist half stays exclusively with the admin auditor (audit-review-policy.py) — the writer view never asserts what it cannot see. Two new tests cover accept (policy context present) and refuse (policy context absent).No content findings so far. Formal verdict after exact-head CI goes green; will also try to run
merge_queue_test.pyfirsthand in the sandbox for independent evidence. No merge action from this seat.Infra interim — COMMENT only at exact head
a72cbdcc42b876c0e1c8bc7c77865f4ec30f7c59(formal verdict withheld until exact-head CI is green).Firsthand this turn:
forgejo_pull_get(obs 149713: open, founder-authored, base==mb==cec04e6f, base_is_ancestor_of_head:true, mergeable:true — FF-ready), full 85-line diff (3 files),forgejo_commit_get(forge@key.store SSH signature present, backend verification unknown — KSE-0001 binding at merge time),forgejo_pull_reviews(only REQUEST_REVIEWs: manager 8744, infra 8745, devex 8746, security-agent 8747 — no verdicts yet),forgejo_commit_status(Apple Classify + SwiftLint success, Apple builds skipped at classify — no Apple files in scope; Agent Dispatcher check still running; review-policy pending Tier 2 all four seats).Infra findings — no content blockers: (1) Fallback is fail-closed: only 403 is caught (other ApiErrors re-raise); a falsy
/branchesview degrades to all-False fields, andenforced()uses strictis True/is Falseidentity checks, so any missing/None field refuses. (2) The limited view cannot see the merge whitelist and does not pretend to — that half is explicitly left to the admin auditor (audit-review-policy.py); enforcement here additionally requiresuser_can_merge is TrueANDuser_can_push is False, so the queue can only move through the server-side merge path where Forgejo enforces the whitelist. I rely on the security-agent seat for any residual confused-deputy analysis ofuser_can_mergesemantics; no independent verification claimed. (3) Tests cover both the accept and refuse branches. (4) No secret, permission, runner, or prod-surface changes; single-commit change parented directly on current main.Conditions: exact-head CI must go green (dispatcher check in flight); devex + security-agent + manager seats + COO-final still owed. I will publish the formal infra verdict once CI resolves green at this head.
Manager-seat APPROVED at exact head
a72cbdcc42b876c0e1c8bc7c77865f4ec30f7c59(Tier 2 manager seat only; infra + devex + security-agent seats + COO-final still owed — no merge auth from this seat).Firsthand this turn: full 85-line diff read (3 files under services/merge-queue); commit_status at this head (3 success incl. SwiftLint + Dispatcher Bazel 32336 1m51s + Apple Classify, 3 Apple-build skips via path filter, only review-policy pending, complete:true); PR open, FF-ready (base==mb==cec04e6f, mergeable true).
Findings — no manager block: (1) 403-only fallback, other ApiErrors re-raise; writer-view mapping marks limited and drops whitelist fields rather than inventing them. (2) enforced() limited-view conjunction is strict (protected + checks on + policy context required + can-merge + cannot-push); whitelist half explicitly left to admin auditor per body. (3) Two new tests cover accept + refuse paths.
Not run by me: local test suite (rely on CI + author 27/24 OK claims — CI verification of those specific suites not separately inspected); KSE-0001 native per-commit verify + queue-function check deferred to COO-final when all seats are in.
DevEx verdict: APPROVED at exact head
a72cbdcc(DevEx automation-safety scope only; Tier 2 still needs manager + infra + security-agent verdicts and COO-final; not a merge authorization).What I verified firsthand this turn:
forgejo_api.py403-only fallback to/branches/{branch}writer view (other errors re-raise — no masking of unexpected failures);merge_queue.pyenforced()limited-view branch requires protected + status checks on +key.store/review-policyin contexts + user_can_merge true + user_can_push false;merge_queue_test.pytwo new tests (accept + refuse paths).key.store/review-policyseat gate itself. All runnable lanes green (Dispatcher Bazel check 1m51s, SwiftLint, Classify).a72cbdcc42b876c0e1c8bc7c77865f4ec30f7c59(detached worktree, removed after):python3 -m unittest merge_queue_test review_policy_test→ 51 tests OK, including both new limited-view tests by name. Matches the PR body's 27+24 claim.cec04e6f(FF-ready, base_is_ancestor true, mergeable:true); SSH signature present, backend verification unavailable — KSE-0001 tracked-signer check left to the merge gate.Notes for other seats (non-blocking): (1) the merge-whitelist half of enforcement is explicitly delegated to the admin auditor
audit-review-policy.py— security-agent should confirm that coverage; (2) the body asserts the manual forgejo apply (run 104699) already landed server-side — I did not verify that; infra's #216 owns it. No DevEx content blockers found.Infra APPROVED at exact head
a72cbdcc42(base==merge_base==cec04e6f, current main; mergeable:true, FF-only, 3 files +50/-1, body_sha256 9df5b9ebb81cc61e13ca683db6926fecaa533afb6d1d5c9e4ae17a15fe456).Evidence this turn (firsthand):
Scope kept: residual confused-deputy analysis of the whitelist belongs to security-agent (still awaited); COO-final still owed. Queue moves this (no manual merge). No blockers from infra.
Security-agent formal verdict: APPROVED at exact head
a72cbdcc42b876c0e1c8bc7c77865f4ec30f7c59(Tier 2 security seat only; infra seat + COO-final still owed — this verdict alone does not authorize merge; queue moves it).What I verified firsthand this turn:
forgejo_pull_get: open, head==expected, base==mb==cec04e6f, base_is_ancestor true, mergeable:true — pure FF.forgejo_api.pybranch_protectionreads the writer view of the branch and falls back to/branches/on 403 only — any other ApiError re-raises, so unexpected failures are never masked as unenforced; thelimited:truemapping drops whitelist fields rather than inventing them, and a falsy branches view degrades to all-False fields.merge_queue.pyenforced()limited-view branch is a strict conjunction (protected + checks-on +key.store/review-policycontext present + user_can_merge true + user_can_push false); the whitelist half is explicitly left to the admin auditor per PR body. Two new tests cover accept + refuse paths.forgejo_commit_status: complete:true — 3 success (Apple Classify, SwiftLint, Dispatcher Bazel 1m51s), 3 skipped (Apple build legs, no Apple inputs — classifier-skipped, in scope), 0 failed; only pending context iskey.store/review-policyitself ("Tier 2: awaiting security-agent" — this seat).forgejo_pull_reviews: manager APPROVED + devex APPROVED at this exact head; infra interim COMMENT (no content blockers, fail-closed fallback corroborated). No REQUEST_CHANGES anywhere.No security findings. Fail-closed under writer-view denial; no privilege escalation (push right required-false); no secret/auth/crypto/billing/DNS/prod surfaces.
COO-final APPROVED at exact head
a72cbdcc42b876c0e1c8bc7c77865f4ec30f7c59— queue moves it, no manual merge.Gates verified firsthand this turn:
forgejo_pull_get(obs 129476): open, founder-authored, head==expected, base==mb==cec04e6f(current main), base_is_ancestor true, mergeable:true — pure single-commit FF; 3 files +50/-1, body sha9df5b9eb….forgejo_commit_status: complete:true, 3 success (Apple Classify, SwiftLint, Dispatcher Bazel 32336) + 3 Apple-build skips via path filter + 0 failed; onlykey.store/review-policypending, whose description ("awaiting security-agent") is satisfied by 8760 and will recompute to SUCCESS.rev-list cec04e6f..a72cbdcc= exactly 1 commit;git verify-commit→ Goodforge@key.storeED25519 SHA256:gNOsvO0KOu7TaSWOBDwGBwsiExR7kauwDr9O2+IswJQ; fingerprint derived from the trackedforge@key.storekey in.git_allowed_signersat basecec04e6fmatches./branches/writer view, strict enforced() conjunction, 2 new tests — least-privilege read path, no new auth/crypto/secrets/prod surfaces.Merge path: merge-queue only. Watching queue-move + post-merge verification via subscriptions.