Why Graph-Native PR Blocking Catches Layered Architecture Violations Static Analysis Misses
Checking full dependency paths, not single imports, exposes layer violations.
Sponsored by Graphide

CI enforcement of architectural constraints requires a dependency graph joined to explicit layer rules and a required PR check that fails when those rules are violated. Graph-native PR blocking catches forbidden paths through intermediate files that file-scoped checks cannot follow. Its reliability depends on analyzing the exact revision under test and reporting files that fall outside the layer model.
How AI agents create a review problem that grows faster than teams can absorb
An agent can change files across a codebase faster than a reviewer can reconstruct the architectural implications of those changes. Agent-started pull requests change multiple files the great majority of the time and wait far longer for review than unassisted work. The reviewer receives a completed implementation. Checking it requires understanding both the changed code and the dependencies it introduces beyond the diff.
Synthesia reports that coding agents are involved in the majority of code shipped, while the volume of changes has increased without a corresponding increase in human reading time. That creates a structural asymmetry. Developers increasingly review and approve work that agents have already planned and implemented, but their capacity to inspect each relationship has not expanded. Without an automatic boundary check, architectural compliance competes for the same limited attention as behavior and correctness.
A reviewer must recognize when individually reasonable edits combine into a forbidden dependency path. As review time per line compresses, that system-wide judgment becomes harder to make consistently. Agent-speed development makes an existing enforcement gap more urgent rather than creating an entirely new category of defect.
What architectural drift actually looks like as it accumulates
Architectural drift is the growing divergence between the intended layer structure and the actual dependency graph. It rarely starts with a clear choice to give up the design. A Friday afternoon shortcut bypasses the correct route through Core and Infrastructure in favor of a direct import. The compiler accepts it, and the tests pass. The local change looks complete even though the system has acquired a dependency the architecture was meant to prevent.
Each shortcut changes which parts can be changed on their own. Circular dependencies, or tangles, emerge between bounded contexts, while modules become entangled across domain lines. Tree-shaking breaks because bundlers cannot statically eliminate those modules. A single unit test can require the entire dependency graph to initialize. Work that looks small then takes days instead of hours because the structure around it no longer allows a small change.
AI agents speed up this pattern when they choose the nearest matching symbol without knowing the domain boundaries or layer constraints. A symbol can be suitable for the immediate task and still be wrong for the caller's layer. Passing tests does not settle that distinction. The debt lies in the relationship between otherwise working pieces of code.
What static analysis tools can and cannot see by design
File-, package-, and AST-scoped static analysis evaluates code within a defined scope. That scope determines which questions a check can answer. A linter can reject a known bad import pair, and a package-aware analyzer can inspect relationships beyond a single file. Neither capability alone establishes whether one part of the system can reach another through any possible dependency path.
Staticcheck illustrates the distinction between crossing a package boundary and traversing a complete call graph. It inspects code across package boundaries but does not build or traverse complete call graphs across large codebases. Architectural violations and cross-service side effects therefore fall outside that capability. Local analysis remains useful within that scope.
A syntactically valid import can enable a path that crosses a prohibited boundary. Intermediate files can make each adjacent pair look acceptable even when the path from one end to the other is forbidden. A rule that examines only those pairs cannot infer the missing path-level constraint.
False positives that demand significant manual triage consume the same reviewer attention needed for genuine violations. For a linter, an architecture test, or static analysis, the decisive distinction is the data available to the rule.
The class of violation that only becomes visible at the graph level

The callstack/agent-device production case exposes the gap through an ordinary import chain. One hidden inversion ran from src/sdk/index.ts, at rank 4, through the root file src/agent-device-client.ts, to src/daemon-client/daemon-client-transport.ts, at rank 5. The same path existed from src/ai-sdk/index.ts. Zone-level checks said the structure was clean even though it had file-level cycles. The intermediate root file obscured the relationship between ranked layers.
Each hop could pass its local check. Traversing the chain revealed the inversion that those checks missed. This is why a rule against direct imports is not equivalent to a rule against reachability. The former describes an edge, while the latter constrains every path between the relevant parts of the system.
AutoBot-AI issue #13507, filed in August 2026, describes a related failure in the architectural model itself. Layer data was in one system and code-graph nodes were in another, with no shared identity to link them. As a result, the system could not produce the signal “this change crosses three architectural layers” even though both halves of the required information existed. Impact analysis instead returned a flat list of transitively affected nodes, leaving the reviewer to judge whether the change stayed contained or spanned the stack.
Graph interpretation also needs the right level of abstraction. A domain re-exporting its own internal modules can create file-level cycles without creating a circular dependency between bounded contexts. Collapsing files into domains before cycle detection separates those cases. A strongly connected component containing more than one domain identifies the architectural tangle, rather than treating every file cycle as equally significant.
What graph-native enforcement does that file-scoped tools cannot
Graph-native analysis uses the dependency graph as first-class data that rules can check. Files become nodes whose relationships can be traversed beyond the immediately adjacent import. Layer membership then joins to node identity, allowing the check to evaluate the path against the intended architecture. The graph supplies connectivity, and the layer model supplies meaning.
Accurate resolution is essential to that mechanism. The TypeScript Compiler API can build an import graph that respects path aliases and barrel re-exports, which regex-based scanning cannot reliably match. Otherwise, a check may evaluate a simplified relationship that fails to represent the dependency expressed by the code. Reachability is only useful when the graph preserves the edges relevant to the rule.
With that graph, a cross-layer rule can spot when presentation code reaches infrastructure through intermediate files that each look clean. An internal-access rule can find a path through re-exports into another domain's private internals. Domain-level cycle detection can collapse the file graph and check its strongly connected components. These are distinct constraints on the same connected model, rather than disconnected checks on individual imports.
The joined model also makes impact analysis more specific. It can identify the distinct layers touched by a change and the points where a forbidden boundary is crossed. However, structural reach is not authority over mutable runtime state. The hanmiyoo10-alt design issue #2215, from September 2026, states the useful boundary of the approach. The graph narrows where to look next before authoritative source verification, rather than deciding everything that is true about the running system.
How do teams block PRs that violate architecture rules?
The codesai.com team evaluated architecture tests, reviews with agents, and documentation or skills in April 2026. It chose architecture tests because integration into CI/CD makes a rule violation prevent the build from passing. That changes the enforcement mechanism. Documentation communicates a constraint, while a required failing check prevents code that violates the encoded constraint from proceeding.
1984Rakesh/SampleWebApp used dependency-cruiser to gate CI on clean architecture rules. Zero violations were reported across 237 client modules and 121 server modules, with CI gated on the check. The brianperry.dev monorepo wired architecture:check into ci:verify in 2026. A single violation among the dependencies checked stops the build, so an architectural failure rejects the PR without an additional reviewer action.
Xebia uncovered numerous incorrect imports and misplaced files when it activated dependency-cruiser rules in a high-quality, relatively new React codebase. The corrections were structural repairs, primarily involving relocating files and shifting code between modules. The case shows why an otherwise healthy codebase can still benefit from a check that evaluates where dependencies belong.
The agent-device team's October 2026 decision dealt with the cost of keeping enforcement working. It chose to replace 75 files of custom guardrail code with maintained graph tooling. Richer edge semantics, including dynamic imports, type-only imports, and reachability, reduced the reason to maintain custom graph analysis. These cases give teams choosing a tool a reason to check which rules and edge types it can express, since dependency checks that fail automatically do not all check the same things.
The limits of graph-native enforcement and how to handle them honestly
A stale graph is the strongest failure mode. If the graph was built from a different commit, it can silently answer questions about code that is no longer under test. A structurally accurate answer about the wrong revision is still an invalid enforcement result. Branch switches, pulls, merges, rebases, and exact-head changes can all invalidate remembered graph state.
The required response is to fail closed on freshness. If the indexed ref does not match the requested ref, enforcement must not reuse the graph. No graph query can silently substitute its remembered SHA for current authority, because doing so breaks the connection between the PR being evaluated and the structure being approved.
Granularity is a separate limit. Nx sees package-level edges, while Turborepo Boundaries checks file-level imports and was still experimental as of late 2026. Architectural zones are not necessarily packages. A team can therefore have monorepo boundary enforcement without having the granularity needed to express its layer constraints. The appropriate criterion is whether the model represents the boundaries the architecture actually defines.
Coverage is the third limit, and omission is not cleanliness. A file matching no layer must be reported as unlayered. Otherwise, an unranked intermediate zone can disappear from enforcement while still connecting layers in the code. The agent-device R5 guardrail gap shows how that can happen.
These limits also clarify the comparison with linters. Both kinds of check can automatically reject a change, so automatic rejection alone is not the differentiator. The distinction is whether the check evaluates a known bad import pair or reachability through intermediate nodes.
What the enforcement model means for teams shipping production code with AI agents
An effective AI code reviewer needs enough architectural understanding to recognize code that is locally correct but inconsistent with the system's design. Graph-native PR blocking automates the structural half of that judgment. Human review can then concentrate on intent and correctness rather than reconstructing layer compliance from every diff. A clean graph still does not prove that the implementation is correct.
In this model, the graph lives in the repository and versions with the code. Layer rules become enforceable constraints. Developers steer agents through a shared model of which layers exist and what each may import. The graph connects that intended structure to the dependencies the implementation actually creates.
The decisive check happens before merge. An enforcement result that exits non-zero makes an architectural violation as concrete as a failing test. Post-hoc review occurs after the violating code has entered the codebase, acquired dependents, and become harder to remove. For teams shipping agent-generated production code, that timing is the practical value of graph-native enforcement. It prevents a forbidden dependency from becoming the foundation of the next change.


