The agent shipped a clean pull request, and the metrics all agreed it was good.
Syntax: immaculate. Logic: sound. The tests ran green, every one of them. The diff was forty lines, readable, with a commit message a senior would sign their name to. The reviewer, three weeks behind and skimming, read the logic, found nothing to argue with, and approved.
One line in that diff did something the architecture explicitly forbids. A domain entity now imports infrastructure directly, reaching past the interface meant to sit between them, closing a dependency loop the design says must never exist. The code works. The behavior is correct. A unit test cannot tell the difference, because there is no difference to a unit test. There is only a difference to the structure.
Six months ago a senior would have caught it. Not because they were brilliant, but because they were reading forty lines at human pace, remembered the rule, and that one import line would have made them frown. They’d have sent it back with a one-word comment. Boundaries.
The agent doesn’t frown. It obeys exactly what it hits at execution time, and nothing it hit said no. Every check that runs went green. The one rule that mattered wasn’t a check. It was a decision somebody made years ago, written in a diagram, never put anywhere the generator could see it.
That gap, between the architecture you decided and the architecture your pipeline enforces, used to be held shut by a person. It has quietly become the place your system comes apart. And this is something you can encode, not just something you should fear.
One clarification first, because the word is about to do a lot of work. The dependency I mean here is internal: which of your own modules may call which, whether your domain may import your infrastructure, whether a cycle is forming between two of your layers. This is not the third-party-package problem, the npm-and-PyPI question of what your agent pulls in from outside. That’s a different control. This piece is about the boundaries you drew inside your own codebase, and whether anything stops the generator from erasing them.
Decisions Without Enforcement
For decades, your architecture was held by a senior and three things the generator cannot see: an ADR that recorded the decision, a diagram that drew the boundary, and the memory of an engineer who’d internalized the rule and caught the violation in review. The boundary lived in all three. It never lived in the one place that constrains what gets generated: the build.
That was survivable for a long time, and the reason is not flattering. It wasn’t that the reviewer was a genius. It was a ratio. One human could read roughly what one human could write. Authorship ran at human pace, slow enough that a single experienced reviewer could hold the line on structure. The org got correct boundaries more or less for free out of that ratio, never priced the subsidy, and so never built a mechanical replacement. Structure eroded slowly underneath all of that even then, but it was a managed decline, and management was a person.
Then AI broke the ratio.
Authorship is no longer human-paced. The reviewer who held the boundary is now outnumbered by arithmetic, reading the output of a system that writes faster than any human could and respects none of the artifacts that encoded the rule. The senior is still there. The senior is just underwater. And the boundary still lives only in the ADR, the diagram, and a head, all three invisible to the thing now doing most of the writing.
This is the org-design debt, stated plainly: you have architecture decisions but no architecture enforcement. You made the decisions and wrote them down. You never built the gate, because for thirty years a person was the gate and the person was free.
Look at what AI actually changed about the defects, because it’s sharper than “AI writes bad code.” When Apiiro studied the question across what their September 2025 report describes as tens of thousands of repositories and several thousand developers across Fortune 50 enterprises, the type of defect inverted. Trivial syntax errors dropped 76 percent. Logic bugs fell more than 60 percent. The surface got cleaner. At the same time, architectural design flaws spiked 153 percent, and privilege-escalation paths jumped 322 percent.
The defects that improved are the ones that were easy to see and never mattered much. The class that exploded is the one Apiiro describes as the flaws scanners miss and reviewers struggle to spot. Your dashboards look better than they ever have, and the structure underneath is coming apart. The code looks great, though.
This is vendor research, not peer-reviewed, so hold it as such. But the direction is unambiguous: AI fixes the typos and builds the timebombs.
The Violation Passes While the Tests Go Green
The natural question is how. How does a violation that obvious reach production with every check green?
A controlled study from December 2025 shows the mechanism cleanly. The author handed three different models the same task: implement one book-lending microservice under explicit hexagonal, ports-and-adapters constraints. Same spec, same rules. Then he measured whether each model’s output respected the boundaries it was told to respect. The results split by model. One violated the architecture on four of its five runs. Another violated it on zero. The violator did exactly what the opening agent did: created an illegal circular dependency between the domain and infrastructure layers, imported infrastructure directly into a domain entity, and inverted the dependency direction the architecture forbids.
Keep this in proportion. Five runs per model, fifteen total. This is not a measurement of how often models break architecture in the wild, and you should not walk away saying open-weights models violate boundaries eighty percent of the time. It’s a small, deliberate study, and what it proves is narrower and more useful: this failure is real, reproducible, and model-dependent. It can happen in your toolchain.
Here’s the part that matters for your pipeline. In every violating run, the code was functionally correct. The service worked. A functional test suite would have gone green, because the structure was wrong in a way that doesn’t change what the code does, only how it’s coupled. The test asks “does it work.” The architecture asks “is it built the way we decided.” Your tests only answer the first.
And you don’t control which agent runs against your codebase: which model your contractor used, which one the next tool defaults to, what next quarter’s upgrade quietly swaps in. Whichever one it is, if it inverts a dependency, your tests will tell you everything is fine.
Writing a Better Architecture Doc Makes It Worse
By now the intuitive fix has probably formed in your head. If the model doesn’t respect the architecture, tell it the architecture. Write a clearer ADR. Put the layering rules in the prompt. Spell out the boundaries in the context file. Make it understand.
The data says that makes it worse.
A May 2026 study named the effect: constraint decay. As you layer architectural requirements onto an LLM agent in prose, its correctness degrades. Agents are strongest at unconstrained generation and measurably weaker in convention-heavy environments. Imposing Clean Architecture specifically cost 9.1 percentage points, give or take 1.6. Stack the constraints up to a fully specified setup and capable configurations dropped roughly 30 points in assertion pass rate. The more architectural discipline you express as words, the less of it you get. It’s the confident junior who nods at every instruction and follows fewer of them the more you give.
This is an arXiv preprint, tested across eight web frameworks against fixed API specs, so hold the exact figures lightly.
The turn this forces is the whole point. Constraint decay isn’t only “the model gets worse under pressure.” It’s evidence that prose is the wrong instrument. You cannot describe a boundary into being binding, because the model treats your description as one more soft suggestion to weigh against everything else you asked for, and trade away when something has to give. The one instruction it cannot trade away, cannot soften, cannot decay, is a build that fails.
So if words make it worse and tests can’t see it, enforcement has to be mechanical, the same move you already made for code when you stopped hoping it was correct and started running tests that fail.
The Boundary That Fails the Build
There’s a name for a check like that, and it predates AI by years. In Building Evolutionary Architectures, Ford, Parsons, Kua, and Sadalage call it an architectural fitness function: an objective, automatable test that measures whether the system still satisfies a desired architectural characteristic, wired into the build so structure is enforced continuously instead of reviewed manually. The second edition’s subtitle says the quiet part out loud. Automated Software Governance.
This is not a novel reaction to AI. It’s an established practice, on the Thoughtworks technique radar since 2018 and reaffirmed by them in October 2024 specifically as a countermeasure to AI coding agents.
The property that answers “wait for a better model” is this: a fitness function is model-independent. It doesn’t care which agent wrote the code, how capable it was, or whether it was your team, a contractor, or a tool you haven’t bought yet. It checks the structure that landed. The domain imported infrastructure, the build goes red, regardless of who typed it. You maintain the gate, which means you control it. Betting on the model is betting on something you don’t own.
Now the honesty bound, because overselling this would cost you the room. A fitness function catches the structural, expressible rules. Who may depend on whom. No cycles. The domain may not import infrastructure. The class of thing you can state precisely and check mechanically. It does not catch design judgment. It can’t tell you whether the boundary is in the right place, whether the abstraction is sound, whether a service is quietly swelling into a god-object that violates no dependency rule at all. Those still need a human, and always will. The gate doesn’t replace architectural thinking. It stops the decisions you already made from silently eroding while you’re not looking.
Encode the Boundary
So here is the lever, and it was never “write a better architecture doc.” It’s three moves a leader can mandate.
Name the load-bearing architectural boundaries and give the ruleset an owner. Which layer or module may depend on which. Where the domain must not import infrastructure. Which cycles are forbidden. Not a paragraph of intent on a wiki. An explicit ruleset, with a name next to it. Everything else is secondary, by definition.
Encode those rules as a CI gate that fails the build. A fitness function, not a doc: ArchUnit, dependency-cruiser, import-linter, NetArchTest, whatever fits your stack. The boundary either breaks the build when crossed, or it does not effectively exist. And scope it tight, to the one or two boundaries a violation would actually hurt. A precise gate that fails ten times a year and is right every time is a control. A noisy one that flags legitimate refactors is training data for ignoring it.
Demote ADRs, diagrams, and review to intent, not enforcement. They record why the boundary exists. They do not hold it. The build holds it. This is the actual structural decision: a policy about where your architecture is allowed to live.
The general method for turning any rule into a check is a topic of its own, and I’ll come back to it. The point here is prior to that: decide your load-bearing architecture is going to live in the build at all.
The Diagnostic: Two Tiers
You can run this today. If you lead the org, you don’t read a config file. You ask four questions, and the ones nobody can answer with a name or a file path are your exposed debt.
If an agent inverted a layer dependency or imported infrastructure into the domain today, would anything in CI fail? Or would it merge green?
Where do our load-bearing architectural boundaries actually live: in a build gate, in a diagram, or in one senior’s head?
Who owns the architecture ruleset, by name?
And separately: are we still relying on review to catch boundary violations, when our reviewers are already buried under the volume?
That last one is the question nobody can answer cleanly. Every “I don’t know” and every “no” is exposed process debt with a price tag.
If you’re closer to the code, run the IC version. Take your most important boundary, the one a violation would hurt most. In a throwaway branch, violate it on purpose: import infrastructure into the domain, create a forbidden cycle. Push it. Then watch whether anything red appears before a human looks.
If nothing fails, your architecture isn’t enforced. It’s documented.
“But Our Architects Catch This in Review”
This is the objection that matters most, and the one the numbers were built to answer.
Your senior people catch boundary violations in review, the way they always have. The trouble is that the math that made that work is gone. Faros AI’s 2026 telemetry, drawn from two years across roughly 22,000 developers and 4,000 teams, found median review time up about 5x, and 31.3 percent more pull requests merging with no review at all, human or agentic. The report’s own framing is blunt: a gate only works if the gatekeeper isn’t buried under an avalanche.
This is a velocity and oversight measure, not a measurement of architecture drift, so take it for exactly that: evidence the human backstop is overwhelmed. And the architectural violation is the precise defect Apiiro found reviewers struggle to spot even when they’re looking. You’re asking an overwhelmed human to reliably catch the hardest class of defect to see, at the moment volume makes catching anything reliably impossible. That’s not a control. It’s a hope with a job title.
A few more objections, answered directly.
“ have ADRs. Our architecture is documented.” Documented is not enforced. An ADR records a decision and its reasoning. It does nothing to a diff, and the agent never reads it. A boundary that lives only in a decision record is invisible to the generator. And the obvious patch, writing the archiWetecture out more fully, is the move constraint decay shows backfires. A documented architecture is necessary intent and zero enforcement.
“Better models will respect architecture eventually.” Two problems. The controlled study is an existence proof that a model can wreck a clean task another model nailed, and you don’t control which agent runs against your code. And a fitness function is model-independent: it checks the structure regardless of who wrote it. You maintain the gate, which means you control it. Betting on the model is betting on something you don’t own.
“We’re not layered or hexagonal. We’re a monolith, or a pragmatic mess.” You don’t need a textbook architecture for this. If you have any rule you’d be unhappy to see violated, this module owns payments and nothing else writes that table, the billing service must not reach into auth’s internals, no cycles between these two packages, that rule is a fitness-function candidate. The question isn’t whether you’re “layered.” It’s whether you have boundaries you’d defend in review. If you would, encode them. If you genuinely have none, you have a different and larger problem.
The Boundary Was Never in the Build
Go back to the agent in the opening.
It shipped a clean pull request. Syntax immaculate, logic sound, tests green, the reviewer satisfied. And one line quietly inverted a dependency the architecture forbids, closed a cycle the design rules out, and nothing in your pipeline so much as blinked. The code wasn’t bad. The boundary was never in the build.
For decades a senior held that boundary in review, and it worked because of a ratio nobody priced: one human could read what one human could write. That ratio is gone. The fix isn’t a smarter model or a clearer diagram. It’s a check that runs and fails.
AI doesn’t break the rule it was told. It breaks the rule nobody encoded.
So ask it plainly, about the codebase shipping AI-generated changes this week. Does your CI enforce architectural boundaries, or do you rely on reviewers to catch violations?
And would you bet on the reviewer
?


