Search docs

Docs search
Back to Rule Catalog
AP-TXN-004Transaction Boundaries

Long-running workflow inside transaction

Flags transactions that include slow external or asynchronous work.

warningviolationNo auto-fix

How to fix

  1. Commit database changes before external side effects.
  2. Use an outbox or job queue for post-commit work.
  3. 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/src
  • apps/web
  • packages

Related CLI commands

  • archpilot validate
  • archpilot validate --ci
AP-TXN-004 - Long-running workflow inside transaction | ArchPilot Docs