Architectural Constraint Enforcement Layer for AI-Generated Code

dev tool real project •• multiple requests

Linters catch style issues, SonarQube catches bugs, but zero tools enforce architectural constraints on AI-generated code. Developers report that AI output is syntactically perfect but architecturally wrong: duplicating caching layers, ignoring existing systems, violating GDPR patterns. A dev.to commenter nailed it: 'Most teams have CI that checks if code works but zero tooling that checks if code makes sense architecturally.'

builder note

The insight from the HN thread is that this should be DECLARATIVE, not analytical. Let architects write rules like 'all database access goes through the repository layer' or 'no direct HTTP calls outside the gateway service.' The tool then checks every PR against the ruleset. Think of it as ArchUnit but polyglot, CI-native, and with an LLM that can understand intent, not just import paths.

landscape (4 existing solutions)

Existing tools operate at the syntax/pattern level (Semgrep), the code smell level (SonarQube), or the evolutionary coupling level (CodeScene). None operate at the architectural constraint level: 'this system uses Service X for caching, do not introduce a competing cache.' The gap is a declarative constraint language that encodes architectural decisions and runs in CI.

ArchUnit Java-only architecture testing library. Requires manually writing constraint rules in code. No AI-awareness, no cross-language support, no CI-native integration for modern polyglot stacks.
SonarQube Detects code smells and bugs at the file/function level. Has no concept of system-level architectural patterns, existing service boundaries, or domain-specific constraints like GDPR compliance patterns.
CodeScene Closest to architectural analysis via hotspot detection and code health. But focused on evolutionary coupling metrics, not declarative architectural rules. Can't express 'no new caching layers without reviewing existing ones.'
Semgrep Powerful pattern matching for security and code patterns. Could theoretically encode architectural rules but requires custom rule writing for every constraint. No built-in architectural awareness.

sources (4)

other https://dev.to/alexcloudstar/ai-generated-code-is-creating-a... "Zero tooling that checks if the code makes sense architecturally" 2026-03-21
other https://dev.to/harsh2644/ai-is-quietly-destroying-code-revie... "A caching layer PR was technically sound but ignored existing systems and GDPR implications" 2026-03-15
hn https://news.ycombinator.com/item?id=47196582 "Reviewing PR feels implicit, I have to exert deliberate effort" 2026-03-28
other https://www.iqsource.ai/en/blog/ai-code-review-quality-gover... "41% of code is AI-generated, most ships without meaningful review" 2026-03-10
architectureAI-codecode-qualityCI-CDconstraints