UPDATED IN SEPTEMBER 2026

Policy-based merge rules

Policy-based merge rules replace ad-hoc human judgment about when and how to merge with codified, machine-enforced criteria, and they expect agent output to arrive as a stack of dependent, independently reviewable branches rather than one thousand-line pull request.

L3 · SYSTEMATICWhat this level takes
MUSTNot met, not at this level
  • Policy-based merge rules are enforced (OPA, branch protection, or equivalent)
  • Deterministic merge ordering with conflict detection prevents concurrent merge failures
  • PRs require a small, published maximum number of CI rounds before merge, and the team tracks it
SHOULDExpected in practice, not required
  • Merge rules are versioned as code and reviewed when changed
  • PRs exceeding 2 CI rounds are flagged for investigation
EVIDENCEHow you would check
  • 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
DEPENDS ON
  • Delivery L2 (Merge & Deploy) - merge queue and auto-rebase must be operational
  • Delivery L2 (Governance & Compliance) - official AI tool policy required for policy-based rules

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.

Two things changed the shape of this control in 2026. The first is that the policy now has a machine input as well as a human one: Zalando's platform team runs an LLM risk classifier over incoming pull requests and auto-approves the ones it classifies as low-risk, which was 33% of PRs, contributing to a 20-40% reduction in lead time. Crucially their risk rules were derived from analysis of their own incidents, not from a generic prompt. A classifier trained on someone else's failure modes is a random number generator with good manners.

The second is the shape of the artefact the policy evaluates. Julia Muiruri's August write-up for GitHub makes the case that the fix for the unreviewable 1,000-line agent PR is not a better reviewer but a different instruction: tell the agent to emit a stack of dependent branches - data model, then API, then integration, then UI - each one independently reviewable and each one able to satisfy a different tier of your merge policy. Your policy should reward that shape. A stack of four 150-line PRs with clean boundaries can route through four different approval paths; one 1,000-line PR can only route through the strictest one.

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
  • Stacked branches let the policy actually discriminate - a policy with six risk tiers is worthless against a single PR that touches all six; dependent branches give each tier something it can evaluate on its own
  • 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

  1. Document your current implicit merge criteria - interview your most experienced reviewers: what does a PR need before you'd merge it? List everything. This becomes your first policy draft. Common items: CI passes, one approval, no unresolved comments, branch is up to date, relevant CODEOWNERS have approved.
  2. Implement CODEOWNERS - create a .github/CODEOWNERS file that maps file paths to required reviewers. This is GitHub's native way to enforce "this file requires this person's approval." CODEOWNERS is the foundation of path-based review policy.
  3. Configure branch protection rules - in repository Settings > Branches, configure: required status checks (CI jobs that must pass), required reviews (how many approvals), CODEOWNERS review requirement, and dismissal of stale reviews when new commits push. These are your basic policy levers.
  4. Add Mergify for advanced policy - Mergify's .mergify.yml configuration supports conditional logic that branch protection rules can't express: "if the PR author is a bot AND the diff is under 200 lines AND all CI checks pass, auto-merge." This is where policy-based rules become genuinely powerful for AI-assisted workflows.
  5. Define your PR risk tiers - categorize change types: (1) documentation/comments, (2) test-only, (3) feature code, (4) infrastructure/configuration, (5) security-sensitive, (6) database schema. Assign review requirements to each tier. Implement the tier logic in your policy configuration.
  6. Instruct agents to emit a stack, and write the policy that rewards it - add the instruction to your agent configuration ("produce dependent branches: data model, API, integration, UI, each independently reviewable"), then make the policy consequences visible: small, single-tier PRs get the fast path, monoliths that span tiers get the strictest one.
  7. Derive risk rules from your own incident history - Zalando's classifier works because its rules came out of real incident analysis. Read your last two years of postmortems and write the rules from what actually broke, rather than from a generic sensitivity list.
  8. Version control your policy files - CODEOWNERS, .mergify.yml, and branch protection settings should all be in version control and require a review to change. Policy drift is the enemy of consistent enforcement.
TIP

Start simple and add complexity incrementally. A policy with 20 rules that people don't understand is worse than a policy with 5 rules that everyone knows. Ship your first policy as a minimum viable configuration covering your three highest-priority concerns (usually: CI must pass, required reviewers per path, no self-merge). Add rules as you observe gaps.

Common Pitfalls

Over-engineering the policy before you understand your patterns. Teams sometimes write a 50-rule Mergify configuration on day one and then spend weeks debugging unexpected behavior. Start with 5-10 rules covering the most important criteria, run them for 30 days, observe what edge cases emerge, and add rules to address them. Incremental policy development produces more reliable policies than big-bang design.

Policy that blocks legitimate work. A policy that's too strict (requires 3 approvals for every change) creates its own bottleneck. Every policy rule should have a stated rationale: "we require 2 approvals for infrastructure changes because a bad infrastructure change can cause an outage." If the rationale is vague, the rule probably shouldn't exist. Review your policy rules quarterly and remove any that can't be justified.

Policy exceptions that proliferate. The value of policy is consistency. When teams add exception mechanisms ("add this label to bypass CODEOWNERS requirement"), those exceptions become the default path for urgent work. Track bypass rate. If more than 5% of merges bypass a policy rule, either the rule is wrong or the process creating urgency is wrong.

CODEOWNERS files that no one maintains. A CODEOWNERS file with owners who no longer work on the codebase blocks PRs indefinitely waiting for approval from people who aren't reviewing. Audit CODEOWNERS quarterly. Any path with owners who haven't reviewed a PR in 90 days should be reassigned or broadened.

Confusing a stack of branches with a split for the classifier. Zalando reported this as an honest harm: once auto-approval was tied to a risk classification, engineers learned to split pull requests so each fragment scored as low-risk. The difference between healthy stacking and classifier-gaming is whether each branch is independently meaningful and independently deployable. Track the ratio of stacked PRs that are merged as a set within a short window, and treat a rising number of tiny PRs whose fragments only make sense together as a signal your policy is being optimised against rather than followed. As Zalando put it, "AI amplifies the good and bad practices across our organization."

Policy that auto-merges PRs no human owns. LinearB's 2026 benchmarks, drawn from 8.1M pull requests across roughly 4,800 organisations, found agentic PRs merging at 79% in elite organisations and 37% at the fair tier, against overall 30-day merge rates of 90/86/81%. The variable that separated them was ownership: an agent-opened PR with no named human owner does not get rejected, it simply never merges. Assigning an owner belongs in the merge policy alongside the check requirements.

Not testing policy changes. Mergify and branch protection rules can be tested against existing PRs to see what behavior they would produce. Use this before shipping policy changes. A policy change that accidentally blocks all merges on Friday afternoon is a serious operational incident.

How Different Roles See It

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: Bob should start by auditing the last 90 days of merges for security-adjacent changes (any PR that touches src/auth/, src/payments/, or config/security.yml). How many were reviewed by someone with security expertise? How many were not? This audit converts "we probably have a policy gap" into "we have a measurable gap in N% of security changes." From there, Bob should commission a CODEOWNERS implementation for high-risk paths and a Mergify rule that blocks merge on those paths without the required reviewer. A one-sprint investment in policy infrastructure delivers ongoing audit compliance.

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: Sarah should tag the last 90 days of PRs by change type (documentation, feature, infrastructure, security) and compare cycle time by category. If security PRs take 3x longer than feature PRs, the question is: is that appropriate (security review takes longer) or wasteful (security reviewers don't know they're needed until someone asks)? Policy-based rules solve the second problem: CODEOWNERS automatically routes security PRs to the right reviewers at PR open time, eliminating the 24-hour lag between "PR opened" and "right reviewer notified." Sarah should quantify the notification lag and present it as the latency that policy automation eliminates.

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: Victor should implement the tiered auto-merge policy as a working prototype on a non-critical service, run it for 30 days, and measure: how many PRs auto-merged? How many auto-merged PRs caused issues? How much review time was saved? The data from the pilot is the proposal to the team. Victor should also add the branch-stacking instruction to the agent configuration before the pilot starts, so the tiered policy has something to discriminate on, and he should watch the PR size distribution for the split-to-game pattern Zalando reported. Victor should document the Mergify configuration as a template: other teams can adopt the same tiered policy for their agent workflows by copying the config and adjusting the path patterns. Making the pattern reusable is how a single prototype becomes a team-wide standard.

How This Guide Changed

What each edition changed in this guide, newest first.

  1. V1.6September 2026LATEST

    This edition added the artefact shape to the item, and the guide follows: a merge policy with six risk tiers cannot discriminate against a single pull request that touches all six, so the guide now asks teams to instruct agents to emit dependent, independently reviewable branches and to write policy that rewards that shape. Zalando's August snapshot supplied both the encouraging half - a risk classifier auto-approving 33% of PRs, with rules derived from their own incident history - and the warning, since their engineers promptly learned to split pull requests to score as low-risk. LinearB's 8.1M-PR benchmark added the finding that made ownership a policy requirement rather than a nicety.

  2. V1.0March 2026

    Original to the first edition. The idea it introduced was that merge criteria should vary with what is being changed - a documentation edit and a database migration have no business clearing the same bar - and that this differentiation belongs in configuration rather than in a reviewer's memory of team convention.

Where does your team actually sit on this?

This guide describes one level of one area. Run the assessment to place your team across all 16 areas, see which gates you have passed, and get a report you can take to your stakeholders.

Start the assessment