Search docs
Docs searchValidation rule
Back to Rule CatalogAP-TXN-002Transaction BoundariesTransaction started in controller/API layer
Flags transactions initiated from transport-layer code.
warningviolationNo auto-fix
How to fix
- Move transaction orchestration into the application service.
- Keep controllers focused on request/response handling.
- Test transaction behavior at the service boundary.
What it means
A controller or API route appears to own transaction orchestration.
Why it matters
Transaction policy belongs near application workflows, not HTTP transport concerns.
Common causes
- A controller directly uses the ORM transaction API.
- A route handler grew into an orchestration method.
- Service boundaries were skipped for a mutation.
Example bad pattern
POST /billing/checkout starts prisma.$transaction in the controller method.Example good pattern
The controller calls BillingService.createCheckoutSession(...), which owns the transaction.Related files/config
apps/api/srcapps/webpackages
Related CLI commands
archpilot validatearchpilot validate --ci