Search docs
Docs searchValidation rule
Back to Rule CatalogAP-TXN-004Transaction BoundariesLong-running workflow inside transaction
Flags transactions that include slow external or asynchronous work.
warningviolationNo auto-fix
How to fix
- Commit database changes before external side effects.
- Use an outbox or job queue for post-commit work.
- Keep transaction scopes short and database-focused.
What it means
A transaction scope appears to include email, network calls, uploads, or other long-running behavior.
Why it matters
Long-running transactions hold locks while waiting for work that cannot be rolled back cleanly.
Common causes
- Email or webhook calls happen before commit.
- External API calls sit inside the transaction callback.
- A background workflow was implemented as one synchronous transaction.
Example bad pattern
A transaction writes invitation rows and sends every invitation email before commit.Example good pattern
The transaction writes invitation rows, then a post-commit workflow sends email.Related files/config
apps/api/srcapps/webpackages
Related CLI commands
archpilot validatearchpilot validate --ci