Skip to content

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: true with required_approving_review_count: 0, dismiss_stale_reviews_on_push: true, and bypass_actors: []). .github/CODEOWNERS lists only Tier 3 protected paths (PROTECTED_PATHS in scripts/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 @fderuiter approval on the latest commit (and enter the serialized auto-merge queue under automerge:approved when @fderuiter approves and applies automerge).
  • 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/main Ancestor Gate: Static Checks runs uv run python scripts/validate_ruleset.py --check-freshness --fetch so Static Checks and Required CI fail closed if a pull request branch lacks current origin/main.
  • Required Check Name: Required CI (durable aggregate GitHub Actions check run from .github/workflows/ci.yml, integration_id: 15368, triggered on push, pull_request, merge_group, and workflow_dispatch).
  • workflow_dispatch Orchestration & Fork Limits: Because GITHUB_TOKEN updates and merges do not trigger pull_request or push workflows, scripts/auto_merge_controller.py dispatches .github/workflows/ci.yml (workflow_dispatch) on updated in-repository PR branches (both unreviewed automerge:eligible PRs and owner-approved automerge:approved protected PRs) to post Required CI on the new head SHA, and after merging always dispatches .github/workflows/ci.yml on main while dispatching .github/workflows/docs.yml on main only when the merged PR modifies documentation inputs (skipping docs.yml for non-documentation merges such as tests/**-only changes) so main verification and GitHub Pages documentation deployment run independently without redundant builds (with ci.yml and docs.yml build-docs cancelling superseded runs via cancel-in-progress: true while deploy-docs serializes Pages deployments via cancel-in-progress: false). External fork branches that fall behind main cannot be dispatched via workflow_dispatch and 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:

  1. Navigate to Settings > Rules > Rulesets.
  2. Click New ruleset > Import a ruleset.
  3. Select .github/rulesets/main.json from the repository.
  4. Set Enforcement Status to Active.
  5. Save changes.
  6. Navigate to Settings > Pages and set Build and deployment > Source to GitHub Actions so .github/workflows/docs.yml publishes documentation via OIDC instead of a branch.