Graph-Based Change Decomposition for Forty-File Agent Pull Requests
Dependency graphs order forty-file agent diffs by architecture, not file sequence, to guide review.
Sponsored by Graphide

Graph-based change decomposition is a code review alternative for large AI-generated diffs that uses dependencies, rather than file order, to organize review. When an agent changes forty files, a dependency graph separates the work into bounded subgraphs, orders foundational changes before their consumers, and identifies new coupling. The diff remains evidence of the edits, but the graph becomes the unit of review.
Why forty-file agent PRs broke the review contract
A single prompt changes many files, and the reviewer gets a wall of hunks. Shared types, behavioral logic, tests, and generated output arrive together, although they demand different kinds of attention. The submission has no useful internal review boundary. The reviewer must reconstruct its scope while also deciding whether the implementation is correct, retaining relationships that the interface does not display.
Ogenrwot and Businge's MSR '26 study analyzed 24,014 merged agentic PRs and found a large difference from human PRs in commit count, with Cliff's δ = 0.54, and moderate differences in files touched. Watanabe et al.'s TOSEM study identified “too large” among the top reasons agentic PRs were rejected, with submissions combining multiple tasks. Size becomes a structural obstacle when one review must resolve several decisions whose dependencies remain implicit.
The root mechanism is a mismatch in throughput. Agents write code much faster, but review, validation, and integration have not sped up at the same rate. The reviewer inherits work that no human paced. Scope drift compounds that burden when an agent changes files beyond the original task or introduces patterns unsuited to the broader codebase, even where the local implementation appears plausible.
What a diff actually fails to show across forty files
A diff answers what changed line by line, but it does not represent what those changes mean for the system. The order of its files does not show the order of their dependencies. An early file might define an interface used throughout the submission, or it might contain incidental formatting. The reviewer cannot distinguish those roles from position, line count, or the apparent complexity of an individual hunk.
A layer violation exists between modules, a cycle spans dependencies, and a placement error concerns a file's role in the architecture. Each edited file can look reasonable in isolation while the combined change violates those relationships. Passing tests does not establish that a new implementation respects assumptions held by downstream consumers elsewhere in the repository.
A reviewer can recover this context, but only by looking beyond the diff and rebuilding the relevant dependency structure. Shared libraries and their consumers must be understood together. So must an interface change and the handlers that rely on it, even if file ordering separates them. The failure is therefore not insufficient reviewer effort, but an interface that withholds the relationships needed to direct that effort. Across forty files, review needs a representation of dependence as well as a record of edits.
How a dependency graph represents a codebase as a reviewable structure
A dependency graph makes those relationships explicit and queryable. Nodes stand for modules or files, and edges stand for imports and function calls. With an import edge directed from a consumer to its dependency, incoming edges identify the modules that depend on a file.
Depth shows where a node sits in the dependency order. Under a dependency-first convention, depth-0 nodes are foundations such as shared types and utilities, while higher-depth nodes are consumers and orchestrators. For an acyclic graph, topological sorting produces an order in which dependencies precede their consumers. That order provides the basis for reading an interface before evaluating the logic built on it.
PageRank-style centrality finds structural hubs in the import graph, while boundary rules set out which modules may depend on which others. A boundary crossing appears as an edge between layers or domains. Together, depth, centrality, and boundaries describe sequence, structural importance, and architectural permission.
Decomposing a forty-file PR into bounded, reviewable subgraphs
Suppose an agent changes a shared auth module, three API handlers that call it, a middleware layer, and fifteen generated client stubs as part of a forty-file PR. The other edits may be part of a different architectural decision. File count alone cannot establish the grouping. Decomposition begins by intersecting the changed-file set with the repository's dependency graph, retaining the edges between changed nodes to produce a change subgraph.
Connected components then show which groups are linked by dependencies. In the hypothetical, the auth module and its calling handlers would belong together, while the middleware's placement would follow its actual edges. Generated stubs would not automatically form a separate component merely because they are generated. Their relationships determine the grouping, while their role determines how they are reviewed. Components with no dependency edges between them can be reviewed on their own and, if they are independent, submitted on their own.
A topological sort places foundational changed files before the consumers whose correctness depends on them. The reviewer can therefore evaluate the auth contract before examining how the handlers use it. Centrality then ranks changes within that component, distinguishing a shared hub from peripheral edits without substituting alphabetical order for architectural sequence.
A propagated rename can appear as a broad, shallow fan with no added dependency depth, while a new abstraction layer can increase depth. These patterns make the architectural decision legible before every hunk is read. A team already using dependency-cruiser to encode a dependency DAG has a machine-readable basis for this work, so decomposition becomes a query against existing structure.
Separating load-bearing changes from cosmetic ones using graph signals
Once components define review units, graph signals help allocate attention within them. In-degree counts how many modules import a changed file and provides a direct signal of its potential blast radius. A heavily imported file exposes many consumers to a change, while a leaf imported by nothing external has a more bounded reach. Line count does not express that distinction.
Depth supplies a different signal from connectivity. A three-line change to a base schema can propagate further than a three-hundred-line addition to an orchestrator because the schema establishes assumptions that consumers inherit. Depth-0 changes to shared utilities, interfaces, and schemas therefore warrant scrutiny even when their diffs are small. Centrality complements this view by identifying hubs whose structural role would be easy to overlook in a file-by-file review.
New edges should come first in an architectural review. A module importing something it did not previously import introduces coupling, potentially crosses a layer boundary, and may reveal architectural drift. This is different from editing logic along an existing dependency. Tracking dependency movement distinguishes a refactor that preserves relationships from one that quietly changes them, even when both produce plausible implementations.
Renames, formatting, and generated updates can produce wide, shallow patterns with no new edges or dependencies. When the edits are established as mechanical, that structure supports batching or automated verification. The graph makes structural importance computable, but a shallow pattern alone does not prove that an edit is cosmetic. File function and the actual change still determine what verification is appropriate.
Enforcing decomposition automatically: CI as the architectural checkpoint
Graph-based review becomes enforceable when architectural constraints run in CI. Allowed dependencies can be expressed as rules, including packages importing contracts, apps not importing another app's internals, and layer N not importing layer N+2. These rules set out which edges are allowed, so reviewers no longer have to keep those preferences in mind. Import-graph traversal tests the code against them.
Deterministic violations do not require executing the application. File-path validation and graph traversal can detect specified module placement errors, prohibited layer crossings, and new cyclic dependencies early in the pipeline. The check can then exit non-zero, reporting failure to CI. When configured as a required merge check, that failure blocks the merge regardless of manual review approval. Approval does not override the architectural checkpoint.
The practical JavaScript and TypeScript toolchain includes eslint-plugin-boundaries and dependency-cruiser. The former supports architectural boundary enforcement, while the latter validates and visualizes dependencies using defined rules. The principle extends to languages with parseable import graphs. In each case, the critical distinction is enforcement rather than presentation, because an advisory finding still depends on someone noticing and acting on it.
CI constraints also tie decomposition to an architectural model that the team has agreed to. Reviewers assess bounded changes within that model, while the automated check rejects relationships that the model forbids. This division makes one claim verifiable, namely that the proposed dependency structure respects the encoded rules.
Where automated graph analysis currently has limits
The graph's usefulness depends partly on its granularity. Instruction-level program dependence graphs do not scale with large programs, so the depth of analysis must be weighed against how fast CI needs to run. Module-level, file-level, and function-level analysis offer different review surfaces and costs. A team must choose the level that fits its pipeline latency budget, since more detail is not always better.
Decomposition also remains bounded by the relationships represented. Components disconnected in a changed-file subgraph are independent only with respect to its retained edges. Likewise, topological sorting requires an acyclic dependency structure. A cycle is a structural finding to address before sorting can produce a valid sequence.
Structural correctness does not establish behavioral correctness or contextual fit. Watanabe et al.'s study found that nearly half of merged agentic PRs required additional human revisions, particularly for bug fixes, documentation, and project-specific standards. A March 2026 empirical study of code-review conversations found more review rounds for AI-generated code and lower adoption of AI-agent suggestions than human suggestions. Graph decomposition supplies a reviewable structure, but it cannot supply the judgment used to assess behavior within it.
Putting graph decomposition into practice on an existing codebase
Extract the import graph from the build system or a static analysis tool as structured data. The aim is to expose dependencies already present in the codebase.
For each agent PR, intersect the changed-file set with the graph to produce the change subgraph. An existing dependency-cruiser configuration used for linting can also support graph generation. Use connected components to group the changed files, then review each group in dependency-first topological order. Foundational changes should appear before consumers, with peripheral files separated from the core behavioral work.
Next, encode allowed dependencies as machine-readable constraints in CI. The rules begin with obvious boundaries, including no app-to-app internal imports and no upward layer imports, and expand incrementally as the team understands its violations. Keep generated changes apart from behavioral edits, and submit independent changes on their own where that makes sense. These practices turn graph structure into both a review sequence and an enforceable limit on architectural drift.
The graph should live in the repository and version with the code, so agent PRs are evaluated against the architectural model the team agreed to. That does not mean maintaining another diagram by hand. The dependency structure is already present in every import statement, and graph decomposition makes it explicit, queryable, and enforceable. The operational lift is in the tooling.


