Domain message flow
Synced from exception-management
This page is a copy of docs/docs/ddd/domain-message-flow.md on develop, derived from that repository's code. Edit it there, then re-sync.
One page, end to end: how an anomaly fact becomes a resolved case. Every box below is a real package in this repo.
The flow in words:
- A fact lands on one of the six consumed topics; the consumer under
its pinned group id decodes the CloudEvents envelope
(
internal/adapters/kafka/cloudevents) and dispatches on the FULL type; unknown types are ignored; a non-CloudEvent message is WARN + skip. - Id claim first. The CloudEvents
idis claimed in the SAME Postgres transaction as the effect; a replayed id is a no-op that still commits the Kafka offset (FetchMessage+CommitMessages— offset only after a durable effect). - Open or touch by the dedup key (source type, source subject, site),
under the policy version current for the source type. Open freezes the
payload, computes the SLA clock and writes
ExceptionOpenedto the outbox; touch bumps occurrence andlastSeenAtonly. - Correlation. An
OrderRepromisedreverses the open case's sourceorder_refto an order id, compares (order level), checks the inclusive window againstlastSeenAt, and auto-resolves on match. - Operators triage, assign and resolve over REST behind the
Idempotency-Keymiddleware; the ops-agent only reads (REST + MCP). - Everything leaves through the outbox: the relay drains due rows,
encodes to CloudEvents, deletes on publish, backs off exponentially,
caps attempts (
OUTBOX_MAX_ATTEMPTS) and dead-letters deterministic poison (ADR 0005).