Appearance
ADR-2282: Declarative Ruleset and Automerge Integration
Status
Accepted (Amended August 2026, November 2026)
Context
Developers push code modifications directly to the main branch because the repository lacks active branch protection rules. This lets untested changes bypass critical validation and automated quality gates. We need a system to ensure all repository modifications pass automated validation checks before entering the main branch, while allowing safe, non-code updates (such as markdown documentation) to merge seamlessly and automatically.
Furthermore, a misalignment was identified in the declarative branch protection configuration. The .github/rulesets/main.json originally mandated a required status check named "Test and Coverage". However, the actual continuous integration pipeline (configured in .github/workflows/ci.yml) executed and output different job check names, and a later decomposition into parallel validation jobs (actionlint, lint-and-static, dotnet-quality, native-aot-build, docs-build, security, container-security, unit-tests, dotnet-tests, and compliance) retired both "Frontend & Backend Unit Tests" and "Style and Lint Verification" while retiring Python operational scripts (scripts/sync_ruleset.py). That drift left .github/rulesets/main.json and .github/rulesets/release_branches.json requiring nonexistent checks with strict_required_status_checks_policy: false, deadlocking regular pull request merges and gh pr merge --auto --squash.
Decision
Store declarative repository ruleset definitions in .github/rulesets/ (main.json, release_branches.json, and version_tags.json), enforce parity continuously with a rulesets quality gate in packages/cli, reconcile rulesets via the Native AOT C# CLI command pnpm cadence rulesets, and gate branch merges and safe documentation automerges on one aggregated CI Gate status check plus Check for Merge Conflicts.
Amended August 2026: Realigned the required status check definitions in .github/rulesets/main.json from "Test and Coverage" to "Frontend & Backend Unit Tests" and "Style and Lint Verification".
Amended November 2026:
- Aggregated
CI Gate(ci-gate): Added anif: always()job namedCI Gatein.github/workflows/ci.ymlthat depends on all pull-request validation jobs (actionlint,lint-and-static,dotnet-quality,native-aot-build,docs-build,security,container-security,unit-tests,dotnet-tests,accessibility-e2e, andcompliance).CI Gatefails whenever any required validation job fails, cancels, or skips (including conditional downstream jobs such ascompliance), while allowingcontainer-securityto skip on pull requests that touch no container or dependency inputs. Push-only jobs (release-and-archive,deploy-docs) and pull-request orchestration jobs (classify,automerge) stay excluded from required branch status checks. - Strict branch rulesets pinned to GitHub Actions: Updated
.github/rulesets/main.json(refs/heads/main) and.github/rulesets/release_branches.json(refs/heads/release/*) to setstrict_required_status_checks_policy: trueand require onlyCI GateandCheck for Merge Conflicts(.github/workflows/conflict-check.yml), each pinned tointegration_id: 15368(GitHub Actions), while preservingrequired_approving_review_count: 1,require_code_owner_review: true, and immutablev*tag protections in.github/rulesets/version_tags.json. - Safe documentation automerge: Updated
Enable Automerge(automerge) in.github/workflows/ci.ymlto wait onClassify Change(is_safe == 'true') andCI Gate(needs.ci-gate.result == 'success') before callinggh pr merge --auto --squashwithGITHUB_TOKEN, unlocking native GitHub automerge once status checks and review requirements pass. - Native AOT C# sentinel and reconciliation (
cadence rulesets): Replaced the retiredscripts/sync_ruleset.pyscript withpnpm cadence check rulesets(QualityGates.cs, verifying JSON schema, strict policy,integration_id: 15368,CI Gatejob coverage, and workflow parity) andpnpm cadence rulesets(--dry-runpreview and fail-closedgh apireconciliation that exits non-zero on API or permission errors).
Alternatives Considered
Option 1: Classic manual GitHub branch protection setup
- Overview: Manually configure branch protection rules in the GitHub repository UI.
- Pros:
- Simple and does not require coding.
- Cons:
- Cannot version control branch rules inside the codebase.
- Changes to protections are not subject to pull request review.
Option 2: Require every individual CI job directly in branch rulesets
- Overview: List every decomposed job name in
.github/rulesets/main.jsonand.github/rulesets/release_branches.json. - Pros:
- Requires no aggregator job in
ci.yml.
- Requires no aggregator job in
- Cons:
- Splitting, renaming, or conditionally skipping a CI job (such as
container-security) immediately deadlocks merges and requires repository-admin API updates.
- Splitting, renaming, or conditionally skipping a CI job (such as
Option 3: Aggregated CI Gate, Declarative Rulesets, and Native AOT CLI Reconciliation
- Overview: Chosen option. Store rulesets in
.github/rulesets/*.json, gate branches onCI GateandCheck for Merge Conflicts(integration_id: 15368,strict_required_status_checks_policy: true), enforce parity inpnpm cadence check rulesets, and reconcile viapnpm cadence rulesets. - Pros:
- Rules are versioned, documented, and verified against workflow definitions in pre-commit and CI.
- Internal CI job refactors update
ci-gate.needswithout mutating GitHub Rulesets or deadlockinggh pr merge --auto. - Maintainers can preview (
--dry-run) and reconcile rulesets locally while hosted GitHub Actions runners are paused, with zero Python tooling.
- Cons:
- Adds a lightweight
ubuntu-latestaggregator job (CI Gate) at the end of pull-request validation runs.
- Adds a lightweight
Trade-offs
Positive Impact
Restores active GxP merge gates and up-to-date branch enforcement across main and release/*, prevents spoofed status contexts by pinning integration_id: 15368, unblocks native GitHub automerge for safe documentation changes, and catches workflow-to-ruleset drift locally in pnpm cadence check.
Negative Impact / Technical Debt
Applying ruleset updates with pnpm cadence rulesets requires a maintainer gh session with Administration: write permission on the repository; permission or API failures intentionally exit non-zero rather than silently skipping reconciliation.
This decision implements requirements under Trace-7.