protect-main: own the merge and approval whitelists (WR-56) #33
No reviewers
Labels
No labels
needs-info
needs-triage
ready-for-agent
ready-for-human
review
merge-ready
review
needs-fix
review
needs-human
review
needs-operator
review
needs-review
review
waiting
wayfinder:grilling
wayfinder:map
wayfinder:prototype
wayfinder:research
wayfinder:task
wontfix
No milestone
No project
No assignees
3 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
olympus/workshop!33
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "hermes/WR-56-the-rule-the-script-applies-includes-the"
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?
Implements WR-56
Summary
The rule
scripts/protect-main.shapplies now states who may merge and whose approval counts, so arepository the script has converged is not one it merely has not looked at.
A removal prints in the table's own shape, so a whitelist difference reads like every other one:
The two team names are a single constant pair (
MERGE_TEAMS,APPROVAL_TEAMS) read by both thepre-write check and the target, rather than a literal in the payload and a second copy in the check.
The ADR is untouched: it states the standard mechanism-free and names no team.
Evidence
Before — the new cases against the script as it was on
main:After —
mise exec --, the repository's own entry points (README):The new cases: no rule → all six sent (28); a drifted team corrected, the old one printed (29); a
hand-added username removed and printed, both lists (30); a converged repository reports
no changeand sends no write (31); the before-state carries all six as they were (32); an unknown team refuses
with field, team and repository named, nothing written and no before-state (33); a repository under a
user refuses naming that as the reason, with nothing written and no before-state (34). The stand-in
forge gained
/orgs/<owner>/teams; it still answers 404 for/orgs/<owner>itself —onboard-repo.test.shcase 6 (the label repair) is the check that dependency is intact, and itpasses — and it now answers the instance's own 404 for an owner that is a user, which is what case
34 drives.
The measurement the ticket asks for
Run against the live forge, read-only, with the bot's token:
GET /api/v1/orgs/olympus/teams200—['Implementers', 'Owners', 'Reviewers']: both constants exist on the instance, and this is the route the run now readsGET /api/v1/repos/olympus/workshop/branch_protections/main403—user should be an owner or a collaborator with admin write of a repositoryNot measured: whether Forgejo accepts a whitelist naming a team it does not have, silently or with
an error. Showing that needs a write to a live protection rule, and the bot's token is refused
admin write on every repository here — so the run's refusal is a guard whose opposite case is unread
on this instance, not a guard that has been observed to matter. Every route to it was tried and
refused:
GET /repos/olympus/workshop/branch_protections/mainanswers403 user should be an owner or a collaborator with admin write of a repository;POST /user/repos, a throwaway repository ofthe bot's own to measure against, answers
403 token does not have at least one of required scope(s): [write:user]; andpermissions.adminreadsfalseon all sixolympus/repositories.Two pieces of it are within reach and were taken: the team list is real and reachable, and a write
the forge accepts without applying is already caught by the read-back (case 6 of the suite,
the forge did not keep …). Whoever holds an admin token can settle it in onePATCHof a throwawayrepository's whitelist: set a name no team carries, read the rule back, and report whether the
forge kept the name, dropped the field, or answered an error.
What else changed, and what a reader should weigh
/orgs/<owner>/teamsbefore writing, so a user-owned repository has no teams to name and stops with that reason instead
of writing a whitelist that matches nobody. Every olympus repository is under the organisation; the
script's usage line says
<owner>/<repo>and no longer quietly accepts any owner.the price of the refusal ordering the ticket asks for: no write and no before-state without the
names being real.
--protect-mainrun against each — which needs the Operator's admin token — is what moves them, and each will print
its own removals.
Merge Danger
Door: two-way. The script is run by hand, one repository at a time, and every write it makes is
preceded by a before-state file whose
beforeobject is the rollback — now including the whitelistsit changed.
Blast Radius: local to
scripts/— the script, its two suites and the stand-in forge. Nothingruns it automatically: no workflow calls
scripts/protect-main.sh, and the merge of this PR changesno live protection rule. The merge does arm the next manual run to rewrite whitelists on whichever
repository it is pointed at, which is why that run prints every name it takes away.
Review started (round 1/5) on
c276813cb0— reading the diff now.repo: olympus/workshop | PR: #33 | head:
c276813cb0| round: 1/5 | verdict: APPROVERecommendation: merge
Spec source: WR-56 (Vikunja #183, "The rule the script applies includes the merge and approval whitelists, so drift in them is caught too"), linked from the PR body; the PR's own Evidence and Merge Danger sections used as the stated contract.
Standards sources:
AGENTS.md(org-wide ADRs read first),GLOSSARY.md(vocabulary — "Protected main", not "branch rules"),docs/agents/domain.md,README.md(the script's contract, run viamise exec),docs/adr/0002(mechanism-free record, names no team), plus the Fowler smell baseline as judgement calls.Verified independently: both affected suites pass on my run against the head SHA —
protect-main.test.shall 175 checks pass,onboard-repo.test.shall 45 checks pass (including case 6, the label repair that pins the/orgs/<owner>404 the stand-in must keep). Local diff of28b90a5..c276813matches the forge PR diff exactly (4 files, 228 insertions).Standards
No BLOCKERs. No documented-standard breaches found: the ADR is untouched (✓ WR-56 "The record is not edited"), the glossary vocabulary is used correctly ("Protected main", "record"), and the script runs through
mise execperREADME.md. Three judgement calls from the smell baseline:scripts/protect-main.sh:417-422(the target dict),scripts/protect-main.sh:465-466(theWHITELISTStuple in the removals printer), and twice more in the test loops atscripts/tests/protect-main.test.sh:577and:605(read-back check, before-state check — two shell loops 30 lines apart that could share one list variable). The target and the removals tuple serve different purposes and the tests deliberately restate expected state, so this is a wash in the script itself; the two test loops are the duplication worth one shared variable. Judgement call, not a violation.scripts/protect-main.sh:175says "fix the constant beside required_approvals in this script", but the constantsMERGE_TEAMS/APPROVAL_TEAMSsit atscripts/protect-main.sh:46-47besideBRANCH/RULE, whilerequired_approvalslives inside the target dict at:409. A reader following the signpost lands in the python heredoc, not on the constant. The header comment at:59-62states the kinship correctly ("the org's standard in the same way required_approvals is"); only the die message points to the wrong place. Cheap fix: "fixMERGE_TEAMS/APPROVAL_TEAMSat the top of this script".scripts/protect-main.sh:170dies on any non-200 fromGET /orgs/$OWNER/teams. For a user-owned repository (404) the message says "a team this run cannot check is one the rule may name for nobody" — true, but never the actual reason: the owner is not an organisation. The PR body discloses this behaviour change honestly ("a user-owned repository has no teams to name and stops with that reason"), but the on-the-wire message leaves the reader to guess why. Naming the 404 branch ("$OWNER is not an organisation on this instance") would make the refusal self-explanatory. Judgement call.Spec
No BLOCKERs. All eight implementation decisions and all six new test cases the ticket lists are present and pass: the six whitelist fields join the target (
protect-main.sh:417-422), the team names are one constant pair read by both the pre-write check and the target (✓ user story 12 — no literal copied twice), removals are printed not refused in the table's own shape (:457-471, tests 29–30), the before-state carries all six as they were (test 32), team verification happens before any write with no write and no before-state on refusal (test 33), the doors stay doors (test 6 extended, still asserts them), the payload is confirmed against the read-back (test 6's "the forge did not keep approvals_whitelist_teams" proves a dropped field is caught), and the suite output is quoted in the PR. Two advisories:GET /orgs/olympus/teams→ 200 with the real team list — and states plainly that the write side was not measured, because the bot's token is refused admin write on every repository, and hands over the one-PATCH recipe for whoever holds an admin token. So the failure mode the ticket designs against ("a merge nobody can perform") remains unobserved on this instance. Mitigations in place: the read-back catches a forge that accepts without applying, and the pre-write refusal stops a typo'd constant before anything is written. Disclosed, not silent — but the ticket's letter is unmet until someone with an admin token runs that probe.Summary
Standards: 3 findings (0 BLOCKER, 3 ADVISORY). Worst: the refusal at
protect-main.sh:175points the fixer at "the constant beside required_approvals", which is not where the constant lives.Spec: 2 findings (0 BLOCKER, 2 ADVISORY). Worst: the ticket's measured-not-assumed probe of how the live forge treats an unknown team was not — and could not be — performed; the PR discloses this and hands off the recipe.
The change does exactly what WR-56 asks, the one behaviour change it adds beyond the ticket (user-owned repositories now refuse) is disclosed and weighed in the PR body, both suites pass on an independent run, and no blocker stands. merge-ready.
5 advisories should've been a Reject for the PR. Please fix.
Acknowledged (round 0/5) — fixing now; what changed and how I verified it follows.
New commits pushed, approval review dismissed automatically according to repository settings
Round 1/5 of the standing review (
bot-minos, APPROVED with 0 blockers, 5 advisories), re-armed by the Operator's comment "5 advisories should've been a Reject for the PR. Please fix." No argument with the grade: I worked all five. Three are fixed and verified on9154987; two cannot be fixed from this identity and are named below with the exact commands that settle them. The header names the review round I read; the dispatch's own counter read0/5, which is the re-arm's reset, not the loop's spent rounds.Per finding
9154987—whitelist_fieldsstated once inprotect-main.test.sh; both loops read it:175says "fix the constant beside required_approvals", which points into the payload heredoc, not at the constants9154987— the message namesMERGE_TEAMS/APPROVAL_TEAMSand their place; case 33 pins itGET /orgs/<owner>/teamsgot one message, so a user-owned repository reported a status code and no reason9154987— the 404 is its own branch and says why; case 34 drives itS1 — the four enumerations the finding counted stayed as they were where they earn it (the target dict states values; the removals tuple lists fields for the printed removals; the two serve different purposes and the finding called that a wash). The one it named — two hand-written list loops 30 lines apart, one for the read-back and one for the before-state — is now one variable, so a field added to the standard cannot move one loop and not the other.
S2 — the constants sit at
:46-47, besideBRANCH/RULE;required_approvalslives inside the target's python heredoc. The message now readsfix MERGE_TEAMS/APPROVAL_TEAMS at the top of this script. Case 33 asserts that sentence, so the signpost cannot drift back. (I left the backticks off the message — inside a double-quoteddiethey would need escaping, and an unescaped pair would run the constant as a command.)S3 — a 404 on that route is not a failed read: the repository was read a step earlier, so the owner exists, and the org route says it is not an organisation. The refusal now says so:
The stand-in forge answers that 404 the way the instance does (
GetOrgByName,user redirect does not exist— measured live at/orgs/pit/teamsand/orgs/bot-efesto/teams), and case 34 drives a user-owned repository through it: rc 1, the reason named, the whitelists named, no write, no before-state.Verification
Red first, then green. The red proof is the reviewed head's script driven by the new suites, from a
git archive c276813copy (the suite copies the script out of the tree, so the swap is a tree, not a working file):Case 34's other two checks (no write, no before-state) pass at both heads — they guard a property the old code also held, and I am not claiming them as proof of the fix.
Green, on the pushed tree (
git archive HEAD | tar -x, i.e. byte-identical to9154987), every suite this repo names, unpiped:CI at the new head agrees — run 31, both contexts read from the run's own logs, not from the aggregate:
The pushed files were read back from the forge at
9154987(GET /repos/olympus/workshop/raw/<path>?ref=9154987): the 404 branch is present, the old signpost string is absent,USER_OWNERSand the instance's 404 body are present,whitelist_fieldsis present and neither hand-written loop survives.What I could not fix, and what settles it
P1 — the write-side measurement. The finding is right that only a write can answer it. Every route from the bot's identity was tried and refused this round:
So there is no repository where this identity can read or write a protection rule, and no way to make one. The one command that settles it, for whoever holds an admin token:
P2 — user story 15. Unchanged and honestly stated in the body: the six repositories still hold what they held, and each convergence needs the same admin token (
mise exec -- scripts/protect-main.sh <owner>/<repo>, run once per repository, each printing its own removals). I did not touch a live rule and will not.Neither is a code change I can make, so the round lands
review/needs-humanrather thanneeds-review: the three code findings are verified and CI-green, and the two that remain are two commands only you can run. Once they are done, moving the label back toreview/needs-reviewre-arms the reviewer; the code half is ready for it now.Edits that are not in the commit
PATCH, stored body read back byte-identical): theprotect-main.test.shtally 175 → 181, the new-cases enumeration gained case 34 and the stand-in's user-owned 404, and "The measurement the ticket asks for" now carries the three refused routes above instead of only "the bot's token is refused admin write".28–33→28–34, and the red pairing now records this round's3 of 181 checks failedat the reviewed head. Read back byte-identical.claude/codex/agentCLI exists on this host (command -vprints nothing), so the Standards and Spec passes ran in sequence in one context.workspace/held no otherworkshop-pr33*tree, and the live ref wasc276813immediately before the push).I'm going to close this. If we need to we'll tackle it again in the future
Pull request closed