Maturity Matrix

Policy-based merge rules

Policy-based merge rules replace ad-hoc human judgment about when and how to merge with codified, machine-enforced criteria.

  • ·Policy-based merge rules are enforced (OPA, branch protection, or equivalent)
  • ·Deterministic merge ordering with conflict detection prevents concurrent merge failures
  • ·PRs require a maximum of 2 CI rounds before merge (Stripe benchmark)
  • ·Merge rules are versioned as code and reviewed when changed
  • ·PRs exceeding 2 CI rounds are flagged for investigation

Evidence

  • ·Policy-as-code configuration (OPA rules, branch protection API config)
  • ·CI round count per PR metrics showing 2-round maximum adherence
  • ·Merge ordering logs showing deterministic processing

What It Is

Policy-based merge rules replace ad-hoc human judgment about when and how to merge with codified, machine-enforced criteria. Instead of "reviewers decide what's ready to merge," the system defines: which checks must pass, how many reviews are required, which reviewers must approve for which file paths, what labels must be present or absent, and what happens automatically when all criteria are met. The policy is the source of truth, not the reviewer's memory of what the team's conventions are.

At L3 (Systematic), policy-based merge rules are implemented through tools like Mergify, GitHub's CODEOWNERS with branch protection, or Prow (used by Kubernetes). The key distinction from L2's basic merge queues is that the rules themselves are sophisticated: different types of changes have different merge criteria. A documentation change requires one approval. A database migration requires two approvals including one from a DBA. A change to the payments service requires a security review. An agent-generated change below a certain risk score can auto-merge. These distinctions are enforced by configuration, not by hoping reviewers remember the rules.

The codification process is itself valuable. Writing down "what does it mean for a PR to be ready to merge?" forces a team to make explicit the tacit knowledge that currently lives in senior engineers' heads. That knowledge becomes a configuration file in version control, reviewable, auditable, and improvable over time.

Policy-based merge rules are a prerequisite for the auto-merge and high-throughput patterns at L4. You can't safely auto-merge at 50 PRs/day unless you have codified criteria that define "safe to auto-merge." The policy is the safety mechanism.

Why It Matters

  • Eliminates inconsistent enforcement - when merge criteria live in policies rather than people's memories, every PR is evaluated against the same standard; a change that would be fine when reviewed by one engineer isn't blocked by a different engineer with different standards
  • Enables tiered review requirements - different change types genuinely require different scrutiny; policy lets you formalize this: security changes need security review, API changes need a second maintainer sign-off, test-only changes can merge with one approval
  • Scales to AI-generated code - at L4/L5, the majority of PRs are agent-generated; without policy-based rules, every agent PR requires a human to manually decide "is this safe to auto-merge?"; with policy, that decision is automated
  • Audit trail for compliance - merge policies are configuration-as-code; every change to the policy is tracked in git; every merge event records which policy criteria were satisfied; this is exactly what compliance auditors want
  • Reduces reviewer cognitive load - reviewers who know the policy don't have to make meta-decisions about "is this PR good enough to merge?"; they focus on correctness, the policy handles the rest

Getting Started

6 steps to get from here to the next level

Common Pitfalls

Mistakes teams actually make at this stage - and how to avoid them

How Different Roles See It

B
BobHead of Engineering

Bob has different standards for different change types but no way to enforce them consistently. Security-adjacent changes are supposed to require a security review, but sometimes they slip through without one because the reviewer didn't notice the change touched authentication code. Bob has no visibility into whether his team's merge policies are actually being followed.

What Bob should do - role-specific action plan

S
SarahProductivity Lead

Sarah wants to understand the variance in PR cycle time across the team. She sees that some PRs merge in 2 hours and others take 3 days, and can't explain the difference. Her hypothesis is that the variance comes from inconsistent application of review criteria.

What Sarah should do - role-specific action plan

V
VictorStaff Engineer - AI Champion

Victor has been writing Mergify configurations for his own repositories and knows the tool deeply. He wants to implement a tiered auto-merge policy: agent-generated PRs that touch only test files can auto-merge; agent-generated PRs touching source code require one human approval; agent-generated PRs touching infrastructure require two approvals. This would let his parallel agent setup ship more work without manual per-PR approval.

What Victor should do - role-specific action plan