Search docs

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

Aggregate boundary violation

Flags code that reaches across aggregate boundaries instead of using the owning boundary.

warningviolationNo auto-fix

How to fix

  1. Route changes through the aggregate that owns the invariant.
  2. Use domain events or application services for cross-aggregate coordination.
  3. Keep read models separate from write decisions.

What it means

One aggregate or module appears to modify or inspect another aggregate's internals.

Why it matters

Aggregate boundaries protect consistency rules and make ownership explicit.

Common causes

  • A service updates several aggregates directly.
  • ORM relations are traversed instead of using domain methods.
  • A read model is used for writes.

Example bad pattern

Billing code directly mutates organization invitation state.

Example good pattern

Billing publishes a domain event or calls an organization-owned service boundary.

Related files/config

  • apps/api/src/modules
  • packages

Related CLI commands

  • archpilot validate
  • archpilot validate --ci
AP-DOM-002 - Aggregate boundary violation | ArchPilot Docs