Domain Message Flow
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.
Following ddd-crew Domain Message Flow Modelling.
Five key business scenarios. Participants are contexts and external
systems. Every arrow is a real message (port call, REST route, CloudEvents
type) and is prefixed cmd: (command), qry: (query) or evt: (event).
Kafka events always go through the transactional outbox (ADR 0025). Every event
goes to both warehouse.network-fulfillment.events and
warehouse.network-fulfillment.analytics; the diagrams show one "Kafka"
participant for both.
1. Network demand accepted, settled and shipped
Source: internal/application/usecases/receive_network_demand.go,
reconcile_submitted_orders.go, confirm_network_order_shipment.go;
internal/adapters/outbound/ordermanagement/planner.go;
internal/adapters/inbound/http/server.go.
Omitted: translation (local, no message); the poller's idempotency check;
the reconcile pass runs on its own POLL_INTERVAL ticker, minutes after
the submission; FAILURE and PENDING branches (see scenario 2 and
sequence-diagrams.md). Full types are
com.warehouse.wes.network-fulfillment.networkorder.<Event>; REST path
parameters {id} / {networkRef} are written without braces.
2. Network demand rejected
Source: internal/application/usecases/receive_network_demand.go
(rejectUntranslatable, reject), reconcile_submitted_orders.go (fail).
Omitted: the untranslatable path never calls order-management at all.
In the FAILURE path the network already knows its own refusal, so no
second SubmitAcknowledgement is sent. The analytics projector counts a
SUBMISSION_FAILED rejection in orders_rejected_submission_failed
(surfaced as ordersRejectedSubmissionFailed in the acknowledgement report).
3. Acknowledgement window missed
Source: internal/application/usecases/sweep_acknowledgement_deadlines.go,
reject_overdue_orders.go, internal/adapters/inbound/kafka/analytics_consumer.go,
internal/adapters/outbound/analyticsstore/postgres_projection.go.
Omitted: the two passes are independent tickers. Whichever runs first
decides whether an at-risk event fires before the rejection. No message is
sent to the network: the window is closed and the order is never
acknowledged late. The projector ignores AcknowledgementDeadlineAtRisk.
The hold is recorded on the order since the raise (ADR 0024), so the cancel
branch fires for a NEW order; if that cancel keeps failing, scenario 5 is the
backstop.
4. Capability offer recomputed
Source: internal/application/usecases/recompute_capability_offers.go,
internal/adapters/outbound/processpathcache/consumer.go,
internal/adapters/outbound/pathcapacitycache/consumer.go,
internal/adapters/outbound/inventoryclient/client.go,
internal/adapters/inbound/http/server.go, internal/adapters/inbound/mcp/tools.go.
Omitted: full CE types are
com.warehouse.wes.process-path-management.processpath.*,
com.warehouse.wes.process-path-management.cptschedule.CPTScheduleChanged
and com.warehouse.wes.work-planning.workpool.PathCapacityChanged. The
whole scenario always runs. No message
goes to the network from this scenario. In live mode the separate FeedInventory
worker later reads the persisted offers and feeds them (ADR 0027 part 2).
5. Orphaned hold freed
Source: internal/application/usecases/sweep_orphaned_holds.go,
internal/domain/networkorder/hold.go,
internal/adapters/outbound/ordermanagement/planner.go (CancelHeldOrder),
cmd/netfulfil/workers.go (runSweepOrphanedHolds).
Omitted: the sweep never changes the order's state and sends nothing to the
network; RejectOverdueOrders still rejects a NEW order (scenario 3) and, once
the outcome is recorded, skips its own cancel. The pass is off with
ORPHAN_HOLD_SWEEP_ENABLED=false. The event goes to both topics, and the
projector ignores it. Two netfulfil replicas can both cancel and both publish.