Search docs
Docs searchValidation rule
Back to Rule CatalogAP-DOM-004Domain Model QualityDomain logic scattered across layers
Flags business rules repeated across controllers, services, repositories, or UI code.
warningviolationNo auto-fix
How to fix
- Choose one domain or application boundary for the rule.
- Replace duplicated checks with calls to that boundary.
- Add tests that cover the centralized rule.
What it means
The same domain decision appears in several layers instead of one authoritative place.
Why it matters
Scattered logic creates inconsistent behavior and makes policy changes expensive.
Common causes
- A rule was copied into route and UI code.
- Repositories contain business branches.
- A domain service was never introduced.
Example bad pattern
Free-plan repository limits are checked separately in UI, API route, and database helper code.Example good pattern
A plan policy service owns the limit decision and all layers call it.Related files/config
apps/api/src/modulespackages
Related CLI commands
archpilot validatearchpilot validate --ci