Reviewing Agent Pull Requests by Invariant Boundaries Instead of Line Counts
Machine-enforced architectural boundaries catch risky changes agents slip past line-count reviews.
Sponsored by Graphide

The alternative to line-by-line review of large AI-generated pull requests is review by architectural invariant. Line count measures the amount of change. When an agent changes forty files at once, the useful questions are which boundaries it crossed, whether those crossings are permitted, and which decisions still require human judgment. Machine-enforced constraints make those questions answerable without treating every changed line as equally important.
Why line count became the default review heuristic, and why agents break it
Line count felt like a reasonable review heuristic because it largely worked for human-authored contributions. A developer who touched many files usually had a reason, and a reviewer asking why the change was so broad could expect an answer grounded in intent. Larger changes needed more attention because the risk tended to grow with the work involved. Size was a useful shortcut. Its value depended on the relationship between the author’s work and the resulting diff.
Agents dissolve that relationship by producing changes whose structure does not necessarily reflect the decisions a human contributor would make. The MSR’26 large-scale study finds that agentic and human pull requests differ a lot in commit count and somewhat in files touched. Those structural signatures do not map cleanly to established review intuitions. A reviewer cannot infer the same planning or deliberation from an agent’s broad patch.
The loss of decision history makes that interpretation harder. Human authors can explain why they chose an approach, what else they ruled out, and which constraints they worked under, while agent pull requests come without that human decision history. Reconstructing intent from the diff therefore asks a size metric to answer a question it never could. Agents also make pull requests cheap to produce, so review becomes the bottleneck. A process cannot last if it needs people to spend more time reviewing as the amount of generated code grows.
The blast-radius problem — why a small diff can carry catastrophic risk
A small change can cross a security boundary that a large migration leaves untouched. The relevant property is the reach of the change. A migration may alter many files without changing a behavioral invariant, while a compact authorization patch can weaken a constraint on which the system depends.
Imagine a 180-line diff that breaks tenant authorization while passing the checks in place. The example is a failure pattern. Its significance is that authorization constrains access across a boundary, so a local edit can have consequences beyond the edited code. The patch is small. The exposure is not. Reviewing it as a modest change would confuse the effort needed to read it with the judgment needed to assess it.
Agent-generated code can compile, follow style guides, and pass baseline tests while remaining vulnerable under load, edge cases, or invalid inputs. The defect lies in logic. Agents can also drift beyond the original scope or introduce architectural patterns unsuited to the broader codebase. Passing checks does not establish that those changes preserve the boundaries the checks were intended to protect, particularly when the boundary itself is not tested.
The EASE’26 study finds that most AI-generated pull requests in real repositories have no record of review activity. That finding makes reliance on discretionary inspection a weak safeguard. A small boundary-breaking patch may receive little attention precisely because it looks manageable. In the 180-line authorization example, reviewers need to check whether tenant isolation still holds even if the patch is below their preferred size threshold.
What architectural invariants are and why they are the right unit of review
An architectural invariant is a short, precise, testable constraint on what may call what, cross a boundary, or depend on another part of a system. It captures a structural decision that must survive individual changes. The constraint is independent of patch size. A forbidden dependency remains forbidden whether an agent introduces it through a short edit or as part of a broad refactor.
This changes the unit of review from textual volume to permitted relationships. The reviewer asks which boundaries the diff crosses and whether those crossings are allowed. A crossing is a concrete event to assess. If the architecture prohibits one part of the system from depending on another, the presence of that dependency supplies a clearer review criterion than the number of lines used to introduce it.
The distinction also gives expected behavior a place in the review process before the reviewer opens individual files. System boundaries become benchmarks against which the implementation is evaluated, rather than assumptions the reviewer must rediscover while reading. That benchmark narrows the search for risk. It points reviewers toward changes to protected relationships, though a change inside an allowed boundary can still be wrong.
Invariants are useful because their application is scope-independent. For a declared dependency rule, the relationship is permitted or it is not, regardless of how many files the pull request touches. This makes the explicit structural constraint testable. That test must govern the merge instead of remaining in a document someone might read.
Why written-down invariants still fail when agents are the authors
An invariant recorded only in a document or diagram depends on a person consulting it before merging. The document describes a rule but cannot reject a violation. Enforcement still rests on the reviewer’s attention. When generated contributions outpace that attention, written architecture becomes detached from the process that admits new code.
The underlying mechanism is constraint decay. Agents are strongest at unconstrained generation and weaker in convention-heavy environments, where architectural requirements layered in prose can degrade correctness. A written instruction competes with the immediate task. The output can satisfy visible checks while violating an unstated or unenforced architectural expectation. More detailed documentation does not, by itself, close that gap.
The review activity reported by the EASE study shows how easily an approach that depends on documentation can fail. An absence of recorded review removes the recorded review step on which that approach relies. The safeguard becomes difficult to account for. As reviewers fall behind, rubber-stamping can replace the deliberate comparison between a proposed change and the system’s constraints.
This is a structural capacity problem. Asking reviewers to remember more rules adds work to the same step that is already under strain. Documentation still expresses the intended architecture, but enforcement requires an independent consequence for violating it. For machine-checkable invariants, that consequence belongs in CI. A forbidden boundary crossing must fail the build.
How do boundary checks review large AI-generated pull requests in practice?
The team declares the permitted relationships, the build checks the change against them, and a violation blocks the merge. The rule becomes an executable constraint. Tooling for this pattern is deployable on existing codebases, so enforcement need not wait for a new system designed around it.
The Blacwing open-source monorepo encoded an allowed dependency DAG between apps and packages in CI. Its rules included prohibiting packages/contracts from importing an app and preventing apps from reaching into another app’s internals. To keep the architecture from eroding as agent-authored domain epics land, the issue was merged October 20, 2026. The example shows how a declared dependency structure can govern generated changes.
Those rules also explain why a boundary check differs from another pass over the diff. A reviewer need not infer whether an import seems architecturally appropriate from surrounding code when the repository has already declared that relationship forbidden. The build can adjudicate the declared rule. Human judgment remains necessary if the proposal is to change the rule itself.
Existing architectural debt does not make this approach impractical. Dependency-cruiser provides a baseline/delta pattern in which CI fails on newly introduced violations without requiring every legacy violation to be fixed first. Enforcement can begin without halting delivery for a complete cleanup, while still preventing each new pull request from expanding the set of violations.
The distinction between these cases is useful for adoption. Blacwing demonstrates the content of enforceable rules through an allowed dependency graph, while dependency-cruiser addresses the transition from an imperfect codebase to active enforcement. The proposed change must be checked for relationships that the declared policy forbids.
Where human review still belongs in an invariant-enforced pipeline
Machine enforcement establishes which questions no longer need repeated human inspection. A static dependency rule can tell whether a forbidden relationship exists, but it cannot tell what every effect of an allowed change will be. The distinction prevents automation from claiming more authority than its checks provide.
A June 2026 arxiv paper on automated code review argues that only high-risk changes, new architecture choices, and regulated code paths where a named human must be legally accountable should need human approval. That is a serious argument for removing routine human approval, not merely making conventional review faster. It is partly compatible with invariant-based review. Explicit boundaries can define the triggers that send a change to a person instead of requiring identical treatment for every pull request.
The same paper identifies consequences for user privacy, algorithmic fairness, and environmental footprint as requiring values-based judgment that agents are not reliably equipped to provide. These questions cannot be resolved by a static graph rule. A change can preserve every declared dependency constraint and still demand a decision about its effects. Green CI therefore establishes a starting condition for the remaining review.
The person who prompted the agent prepares the pull request, and a different human approves it where human approval is required. Combining prompting, reviewing, and merging in one person recreates the self-review problem that review exists to prevent. Invariants make this division deliberate. They identify what automation has established and what a named reviewer must still decide, rather than relying on heroic inspection to discover both.
What changes for senior engineers when invariants are the unit of ownership
The senior engineer’s contribution shifts from reading more generated code to owning the constraints under which it can safely change. That ownership includes defining the architecture precisely enough for automated checks to apply it. Ambiguity becomes an enforcement problem. A boundary that everyone understands differently cannot provide a dependable basis for accepting an agent’s output.
Anthropic’s 2026 Agentic Coding Trends Report finds that developers report being able to fully delegate only a small fraction of tasks to agents, even as AI involvement in their work is widespread. Widespread use is not equivalent to delegation. Enforceable invariants support trust within a defined scope by making certain violations detectable, without claiming to establish correctness beyond that scope.
The practical workflow follows from that limit. Teams should map structural constraints explicitly, including what may call what, what may depend on what, and which boundary crossings are forbidden. They should encode the machine-checkable constraints and run them in CI before human review. Reviewers can then concentrate on flagged boundary decisions and the higher-risk questions that enforcement cannot answer. A planned change to the architecture calls for a clear choice about the constraints, which keeps it from slipping through as an accidental exception buried in a large patch.
This changes what architectural ownership produces. Instead of leaving the next reviewer a diagram and hoping it is remembered, the senior engineer leaves a rule that participates in every subsequent change. The rule makes drift across its declared boundary detectable, even when the agent’s output is too broad for line-by-line inspection to serve as the primary safeguard.


