Search docs

Docs search
Back to Rule Catalog
AP-DOM-005Domain Model Quality

Cross-aggregate modification risk

Flags workflows that modify multiple aggregates without clear coordination.

warningviolationNo auto-fix

How to fix

  1. Move coordination into an application service.
  2. Use events/outbox for eventual consistency when appropriate.
  3. Keep each aggregate responsible for its own state changes.

What it means

A workflow writes across aggregate boundaries in a way that may bypass each aggregate's invariants.

Why it matters

Cross-aggregate writes need explicit orchestration, transaction, or event strategy.

Common causes

  • A service updates several model roots directly.
  • A migration path temporarily combines unrelated writes.
  • No event or application workflow owns the coordination.

Example bad pattern

One method directly updates organization, billing subscription, and invitation records with no coordination model.

Example good pattern

An onboarding workflow coordinates aggregate-owned operations and documents consistency expectations.

Related files/config

  • apps/api/src/modules
  • packages

Related CLI commands

  • archpilot validate
  • archpilot validate --ci
AP-DOM-005 - Cross-aggregate modification risk | ArchPilot Docs