Main Branch Protection & Repository Ruleset Configuration
This document specifies the required branch protection ruleset for main in Sortify.
Ruleset Definition
The canonical ruleset export is stored at .github/rulesets/main.json and validated in CI (Static Checks) and locally via scripts/validate_ruleset.py.
Settings Overview
- Target Branch:
refs/heads/main(enforcement: active,bypass_actors: []so zero users, roles, or apps bypass branch protection). - Restrict Deletions: Enabled (prevents deleting
main). - Block Force Pushes: Enabled (prevents non-fast-forward updates).
- Require Pull Request Before Merging:
- Code Owner Reviews: Required (
require_code_owner_review: truewithrequired_approving_review_count: 0,dismiss_stale_reviews_on_push: true, andbypass_actors: [])..github/CODEOWNERSlists only Tier 3 protected paths (PROTECTED_PATHSinscripts/classify_pr.py) and snapshot/type-check baselines (tests/snapshots/api/,tests/snapshots/tui_svg/,tests/ty_baseline.json) with no*catch-all rule, so Tier 1 and maintainer-labelled Tier 2 PRs can auto-merge while Tier 3 changes require@fderuiterapproval on the latest commit (and enter the serialized auto-merge queue underautomerge:approvedwhen@fderuiterapproves and appliesautomerge). - Require Conversation Resolution: All review threads must be resolved before merge.
- Required Status Checks:
- Require branches to be up to date before merging (
strict_required_status_checks_policy: true,do_not_enforce_on_create: false). - Explicit
origin/mainAncestor Gate:Static Checksrunsuv run python scripts/validate_ruleset.py --check-freshness --fetchsoStatic ChecksandRequired CIfail closed if a pull request branch lacks currentorigin/main. - Required Check Name:
Required CI(durable aggregate GitHub Actions check run from.github/workflows/ci.yml,integration_id: 15368, triggered onpush,pull_request,merge_group, andworkflow_dispatch). workflow_dispatchOrchestration & Fork Limits: BecauseGITHUB_TOKENupdates and merges do not triggerpull_requestorpushworkflows,scripts/auto_merge_controller.pydispatches.github/workflows/ci.yml(workflow_dispatch) on updated in-repository PR branches (both unreviewedautomerge:eligiblePRs and owner-approvedautomerge:approvedprotected PRs) to postRequired CIon the new head SHA, and after merging always dispatches.github/workflows/ci.ymlonmainwhile dispatching.github/workflows/docs.ymlonmainonly when the merged PR modifies documentation inputs (skippingdocs.ymlfor non-documentation merges such astests/**-only changes) somainverification and GitHub Pages documentation deployment run independently without redundant builds (withci.ymlanddocs.ymlbuild-docscancelling superseded runs viacancel-in-progress: truewhiledeploy-docsserializes Pages deployments viacancel-in-progress: false). External fork branches that fall behindmaincannot be dispatched viaworkflow_dispatchand are skipped until the contributor updates or rebases the fork branch.- Linear History: Required (Squash merge strategy).
Verification Commands
uv run python scripts/validate_ruleset.py --check # verify .github/rulesets/main.json schema and zero bypass_actors
uv run python scripts/validate_ruleset.py --check-freshness # verify current branch contains origin/main (--fetch to refresh remote)
uv run python scripts/validate_ruleset.py --live # verify active live GitHub ruleset enforcement via REST API (uses GITHUB_TOKEN / GH_TOKEN)
Manual Configuration Instructions (GitHub UI)
If rulesets and GitHub Pages publishing are configured via the GitHub web UI:
- Navigate to Settings > Rules > Rulesets.
- Click New ruleset > Import a ruleset.
- Select
.github/rulesets/main.jsonfrom the repository. - Set Enforcement Status to Active.
- Save changes.
- Navigate to Settings > Pages and set Build and deployment > Source to GitHub Actions so
.github/workflows/docs.ymlpublishes documentation via OIDC instead of a branch.