Repository navigation
Description
Summary
Check AX's repository rulesets into the repo, and use that to add the protection that main already has to release tags and release branches, and to enforce branch and tag naming. Ruleset changes are then proposed, reviewed and audited as PRs instead of being edited only in the GitHub UI.
This issue combines four items from the epic (#546): rulesets as code, protecting release tags, protecting release branches, and branching and tagging rules. They are one unit of work: each protection lands as a JSON file in .github/rulesets/ and is applied with the same script.
Current state (checked 2026-11-12)
- Two rulesets exist, both on
~DEFAULT_BRANCH:mainandmain: require PR review and CI(merged into one by Combine the main rulesets into a single protect-main ruleset #548). - No ruleset targets tags or
release-*branches. Anyone with write access can create, move or delete av*tag. - Tags
v0.1.0…v0.3.1were created by hand. All of them followvX.Y.Z; there are no stray tags. - There are 62 branches on upstream. Most (32) were last updated in July 2026. Common prefixes:
readme-*,fix-*,antigravity-*,agy-*. Because PRs are squash-merged,git branch --mergedfinds only 1 of them, so cleanup has to check PR state instead. delete_branch_on_mergeisfalse.- There is no
.github/rulesets/directory and norelease-*branch yet.
Proposal
1. Rulesets as code
- Export each active ruleset to
.github/rulesets/<name>.jsonwithgh api repos/google/ax/rulesets/<id>. Remove server-managed fields such asid,node_id,_links,created_at,updated_atandsource*, so the files contain only the policy:name,target,enforcement,conditions,rules,bypass_actors. - Apply with
hack/apply-rulesets.sh, which a repo admin runs:- Match local files to live rulesets by
name. PUT /repos/google/ax/rulesets/<id>for existing rulesets, andPOST /repos/google/ax/rulesetsfor new ones.- Support
--dry-run, which shows the differences without changing anything. - Never delete live rulesets that have no file. List them instead.
- Match local files to live rulesets by
- Detect drift with a scheduled workflow, or a step in an existing one, that compares
.github/rulesets/*.jsonwith the live rulesets and fails or opens an issue when they differ.- Reading
bypass_actorsneeds admin. Decide whether this check uses a GitHub App or token with admin read, or compares everything exceptbypass_actors.
- Reading
- Document the flow in CONTRIBUTING.md or
docs/dev/rulesets.md: open a PR that edits the JSON, get it reviewed, and after merge an admin runshack/apply-rulesets.sh.
2. Protect release tags (protect-tags.json)
- Target tags matching
refs/tags/v*. - Rules: block creation, update, deletion and non-fast-forward, and require names to match
^v\d+\.\d+\.\d+(-[0-9A-Za-z.-]+)?$. - Bypass list: release managers only, or the release workflow's identity once the tag-driven release workflow (Epic 5) lands.
- This must be in place before releases publish images from tags, following Substrate's
docs/dev/releasing.md.
3. Protect release branches (protect-release-branches.json)
- Target
refs/heads/release-*. - Rules: block deletion and force-push, require a PR, and require the same status checks as
main. - Open: how many approvals release-branch PRs need. Substrate uses 0 because its cherry-picks are bot-driven.
- Open: whether release branches also use the merge queue. Substrate's don't.
4. Branching and tagging rules
- Branches: only
mainandrelease-X.Yare long-lived on upstream. The format for any other upstream branch depends on the fork RFC in Epic: Establish rulesets for branching, tagging, and merging #546 (require forks, allow only prefixes such asuser/<ldap>/…orbot/…, or keep the current setup). If that RFC adds a branch-name ruleset, it lands here too. - Tags: semantic-version
vX.Y.Z[-pre]only, with no ad-hoc tags on upstream. Enforced byprotect-tags. - Cleanup: turn on
delete_branch_on_merge. For the 62 existing branches, delete those whose PR is merged or closed, and contact the owners of the rest. - Write the rules down in CONTRIBUTING.md (with the Epic 3 docs update).
Acceptance criteria
- Every active ruleset on
google/axhas a matching file in.github/rulesets/ -
hack/apply-rulesets.sh --dry-runreports no differences against the live configuration right after export -
hack/apply-rulesets.shcreates or updates rulesets from the files, matched by name - Drift between the files and the live rulesets is reported automatically
- A user who isn't a release manager can't create, move or delete a
v*tag, and tags that don't match the semver pattern are rejected - A
release-X.Ybranch can only change through PRs that pass CI, and can't be deleted or force-pushed -
delete_branch_on_mergeis on, and stale upstream branches are cleaned up - The ruleset change process and the branch and tag naming rules are documented
Rollout
New rulesets start in evaluate mode. Once the rule insights show they wouldn't block legitimate work, they switch to active. Suggested order: rulesets as code first, then protect-tags, then protect-release-branches, then branch cleanup.
Open questions
- Who are the admins who can run the apply script, and who are the release managers on the tag bypass list?
- Should applying stay a manual admin step, or eventually run automatically after merge using a GitHub App with admin rights on rulesets?
- How many approvals do release-branch PRs need, and do release branches use the merge queue?
Notes
- Later rulesets changes in this epic (Combine the main rulesets into a single protect-main ruleset #548, clearing approvals on fresh commits, the merge queue) should each land as a JSON change in this directory.
- Reference: GitHub REST API: repository rulesets.
Activity
[-]Manage repository rulesets as code[/-][+]Manage rulesets as code and protect release tags and branches[/+]ci: manage repository rulesets as code and combine the main rulesets (#…
ci: protect release tags and release branches (#574)