Search docs
Docs searchValidation rule
Back to Rule CatalogAP-APP-002Application LayeringRepository contains business logic
Flags repository/data-access code that contains domain or workflow decisions.
warningviolationNo auto-fix
How to fix
- Move workflow decisions into a service or domain object.
- Keep repository methods explicit about read/write behavior.
- Test business branching outside the repository layer.
What the rule validates
A repository appears to make business decisions while reading or writing data.
Why it matters
Repositories should expose persistence operations without hiding policy or workflow behavior in data access.
Common causes
- A data helper grew into a workflow.
- Conditional business rules were placed near database queries.
- Persistence code performs side effects beyond storage.
Typical violation example
OrderRepository decides whether a refund is allowed before updating payment rows.Typical compliant example
RefundService decides eligibility, then asks OrderRepository to persist the approved change.Related rules
AP-APP-001 - Controller contains business logicAP-APP-003 - Service bypasses repository layerAP-APP-004 - Package responsibility mismatchAP-APP-005 - Service has oversized responsibility
Adjacent categories
Related files/config
apps/api/srcapps/webpackages
Related CLI commands
archpilot validatearchpilot validate --ci