Skip to main content

Domain Events

As built

Derived from network/model/model.yaml. This context's service is built; the model carries its as-built contracts, and identifiers (Err... names, routes, CloudEvents types) are the names the service uses.

Every event this context publishes and consumes, from contexts[customer-ordering].publishes and .consumes, with the producer's entry for each consumed event. The network-wide rules are on Event standard: CloudEvents and ADR 0007.

Envelope​

Every Kafka message is a CloudEvents 1.0 event in structured JSON mode (conventions.cloudevents):

AttributeValue for this context
specversion1.0
ida UUID minted once when the event is written to the outbox; a redelivery carries the same id
source/retailnetwork/customer-ordering
typecom.retailnetwork.commerce.customer-ordering.customerorder.<EventName> (tier commerce, entity customerorder)
subjectthe orderId (the aggregate root id)
timethe instant the fact happened (placedAt, cancelledAt), UTC
datacontenttypeapplication/json
dataschemaurn:retailnetwork:customer-ordering:events:<EventName>:v1
Kafka topicretailnetwork.customer-ordering.events
Kafka keythe orderId, so one order's events stay on one partition and in order

Published​

Both events are written to outbox_events in the same transaction as the CustomerOrder save, and a relay publishes them. No published event carries ship-to PII. CustomerOrderPlaced carries destinationPostalPrefix only (ADR 0006).

CustomerOrderPlaced​

ItemValue
Full typecom.retailnetwork.commerce.customer-ordering.customerorder.CustomerOrderPlaced
Topicretailnetwork.customer-ordering.events
Subject / keyorderId
Dataschemaurn:retailnetwork:customer-ordering:events:CustomerOrderPlaced:v1
Producing command / use casePlaceOrder (REST POST /checkout)
Consumersorder-sourcing (queues one assignment per group, QueueAssignment), delivery-promise (confirms each group's provisional promise, ConfirmPromise)
FieldTypeMeaning
orderIdstringThe customer order.
shopperIdstringThe shopper who placed it. An id, not PII.
destinationPostalPrefixstringThe ship-to's postal prefix, the one every promise was quoted for.
placedAttimestampWhen the order was placed.
consolidationKeystring, optionalAn opaque keyed hash of the shopper and the normalised ship-to (64 lower-case hex characters), derived here so order-sourcing can merge the groups of one shopper and one address without seeing the address. It is omitted when no secret is configured, and an absent key means the order never merges (never an empty key). It carries no PII and is not in REST, MCP or A2A (customer-ordering ADR 0012).
groups[]arrayOne entry per shipment group.
groups[].groupNointegerGroup number inside the order.
groups[].promiseIdstringThe delivery-promise promise for this group (still PROVISIONAL when published).
groups[].tierenumSAME_DAY, NEXT_DAY, TWO_DAY, STANDARD or CONSOLIDATED: the REAL tier of the promise, never mapped (customer-ordering ADR 0013).
groups[].witnessNodeIdstringThe node of the promise's witness path. order-sourcing may choose another node.
groups[].shipBytimestampThe pickup cutoff the promise assumed.
groups[].deliverByEarliesttimestampStart of the window shown to the shopper.
groups[].deliverByLatesttimestampEnd of the window; the hard constraint for order-sourcing.
groups[].chosenDeliveryDaydate, optionalThe local calendar date the shopper chose for a CONSOLIDATED group, taken from deliverByLatest in the group's time zone at placement; omitted for every other tier and when unknown.
groups[].consolidationEligibleboolean, optionaldelivery-promise's answer for a CONSOLIDATED group; an absent value means unknown or not a CONSOLIDATED option, never false.
groups[].lines[]arrayThe lines of this group.
groups[].lines[].lineNointegerLine number inside the order.
groups[].lines[].catalogItemIdstringThe catalogue item.
groups[].lines[].quantityintegerUnits ordered.

Why the per-group snapshot. order-sourcing needs each group's promiseId, tier, deliverByLatest and witnessNodeId to build its PromiseConstraint. Carrying them here means it can queue the assignment from this one event. Otherwise it would have to wait for and correlate a second event from delivery-promise, and PromiseMade and PromiseConfirmed are analytics-only anyway.

CustomerOrderCancelled​

ItemValue
Full typecom.retailnetwork.commerce.customer-ordering.customerorder.CustomerOrderCancelled
Topicretailnetwork.customer-ordering.events
Subject / keyorderId
Dataschemaurn:retailnetwork:customer-ordering:events:CustomerOrderCancelled:v1
Producing command / use caseCancelOrder: from the shopper (REST POST /orders/{orderId}/cancellations), or CancelUnkeepableGroup from the CancelOnUnfulfillable policy on PromiseUnkeepable
Consumersorder-sourcing (CancelAssignment for each listed group), delivery-promise (CancelPromise for each listed group)
FieldTypeMeaning
orderIdstringThe customer order.
reasonstringWhy it was cancelled: the shopper's request text, or PROMISE_UNKEEPABLE: <reason> for a group cancelled by the policy. The model defines no code list.
cancelledAttimestampWhen the cancellation was recorded.
groupNosinteger[]The shipment groups concerned: for a shopper request exactly the groups that were still unlocked (now CANCELLATION_REQUESTED), for the policy the one cancelled group.

ShopperNoticeDecided​

As built (service ADR 0017). The third published event, on the same topic, subject and key the orderId.

AttributeValue
Full typecom.retailnetwork.commerce.customer-ordering.order.ShopperNoticeDecided (the order entity; the other two events keep customerorder)
FieldsorderId, groupNo, family, notifier, policyVersion, noticeKey, decidedAt, fact (deliverByLatest, etaStart, etaEnd, reason, status, each optional)
familyDELAY_EXPECTED, ETA_WINDOW_ASSIGNED, DELIVERY_POINT_ADVISORY, GROUP_SHIPPED, GROUP_DELIVERED, GROUP_LOST, GROUP_RETURNED
notifierMARKETPLACE, SELLER or NOBODY (the default of every family)
Consumerscustomer-returns (the four GROUP_ families, for its OrderGroupView). The notice itself is delivered outside the network.

One event per family occurrence, whatever the notifier, written in the same unit of work as the fact it is about (policy ShopperNoticeDecision).

Consumed​

Every consumer is idempotent on the CloudEvents id: the id is inserted into processed_events in the same transaction as the effect, and a duplicate is acknowledged without effect. Consumers dispatch on the full type string, never on a suffix. Proposed consumer groups: customer-ordering.order-sourcing, customer-ordering.delivery-promise, customer-ordering.shipping-and-tracking.

From order-sourcing (retailnetwork.order-sourcing.events, Conformist)​

EventFull typeFields usedWhat this context does
FulfillmentLockedcom.retailnetwork.commerce.order-sourcing.assignment.FulfillmentLockedassignmentId, orderId, groupNo, nodeId, lockedAtMarkInFulfillment: records the group as locked (which ends customer cancellation, ErrCancelAfterLock) and moves PLACED → IN_FULFILLMENT. Links assignmentId to the group. Updates OrderTrackingView.
FulfillmentShippedcom.retailnetwork.commerce.order-sourcing.assignment.FulfillmentShippedassignmentId, orderId, groupNo, trackingNumbers, shippedAtMarkGroupShipped: the group becomes SHIPPED from PROMISED, LOCKED or CANCELLATION_REQUESTED (a shipment on a PLACED order is accepted and wins over a pending cancel request); the order is PARTIALLY_SHIPPED or SHIPPED. Records the group's tracking numbers. Updates OrderTrackingView.
FulfillmentUnsourceablecom.retailnetwork.commerce.order-sourcing.assignment.FulfillmentUnsourceableorderId, groupNo, promiseId, reasonRecords the reason in OrderTrackingView only. It cancels nothing: delivery-promise consumes the same event and re-promises, and only its PromiseUnkeepable triggers CancelOnUnfulfillable.
FulfillmentCancelledcom.retailnetwork.commerce.order-sourcing.assignment.FulfillmentCancelledorderId, groupNoConfirmGroupCancelled: the group becomes CANCELLED; the order is CANCELLED when no group remains outside CANCELLED.
FulfillmentCancelRefusedcom.retailnetwork.commerce.order-sourcing.assignment.FulfillmentCancelRefusedorderId, groupNo, reasonRefuseGroupCancellation: the group returns from CANCELLATION_REQUESTED to LOCKED with the refusal reason; the vendor ships.

From delivery-promise (retailnetwork.delivery-promise.events, Customer/Supplier)​

EventFull typeFields usedWhat this context does
PromiseAtRiskcom.retailnetwork.commerce.delivery-promise.promise.PromiseAtRiskpromiseId, orderId, reason, detectedAtMarks the group at risk in OrderTrackingView. No command.
PromiseRevisedcom.retailnetwork.commerce.delivery-promise.promise.PromiseRevisedpromiseId, orderId, revisionNo, deliverByEarliest, deliverByLatest, shipBy, reasonUpdateGroupPromise: replaces the group's window (found by promiseId); a revisionNo not above the last applied is skipped. Updates OrderTrackingView.
PromiseKeptcom.retailnetwork.commerce.delivery-promise.promise.PromiseKeptpromiseId, orderId, deliveredAt, deliverByLatestShows the verdict in OrderTrackingView. No command.
PromiseBrokencom.retailnetwork.commerce.delivery-promise.promise.PromiseBrokenpromiseId, orderId, deliveredAt, deliverByLatest, lateByMinutes, causeShows the verdict in OrderTrackingView. No command.
PromiseUnkeepablecom.retailnetwork.commerce.delivery-promise.promise.PromiseUnkeepablepromiseId, orderId, groupNo, reasonCancelOnUnfulfillable (CancelUnkeepableGroup): a PROMISED group goes straight to CANCELLED and CustomerOrderCancelled is published; in any other group state the event is recorded and skipped.

From shipping-and-tracking (retailnetwork.shipping-and-tracking.events, Conformist)​

EventFull typeFields usedWhat this context does
LabelIssuedcom.retailnetwork.logistics.shipping-and-tracking.label.LabelIssuedtrackingNumber, assignmentId, packageNo, tier, carrierAdds the package to OrderTrackingView, linked to the group through assignmentId. No command.
PackageScannedcom.retailnetwork.logistics.shipping-and-tracking.journey.PackageScannedtrackingNumber, nodeId, scanType, at, stateAdvances the package line in OrderTrackingView (linked by trackingNumber). No command.
PackageDeliveredcom.retailnetwork.logistics.shipping-and-tracking.journey.PackageDeliveredtrackingNumber, assignmentId, orderId, deliveredAtMarkGroupDelivered once every tracking number of the group is delivered, for EVERY group that shares the package (a merged shipment carries several groups, often of several orders of one shopper), plus the group the event itself resolves; the order becomes DELIVERED when every group is. PackageLost and PackageReturned act the same way. Updates OrderTrackingView.
PackageExceptionRaisedcom.retailnetwork.logistics.shipping-and-tracking.journey.PackageExceptionRaisedtrackingNumber, orderId, reason, atShows the exception in OrderTrackingView. No command.
PackageEtaWindowAssignedcom.retailnetwork.logistics.shipping-and-tracking.journey.PackageEtaWindowAssignedtrackingNumber, assignmentId, orderId, etaStart, etaEnd, assignedAtApplyEta upserts the window on the tracking package row (newest assignedAt wins, migration 0009). No command: a read-model fact, shown on the tracking view only while the package is OUT_FOR_DELIVERY and the window is not older than the last scan; never clipped to the group's window, and the group promise is byte-identical before and after (customer-ordering ADR 0014).
PackageDeliveryPointFlaggedcom.retailnetwork.logistics.shipping-and-tracking.journey.PackageDeliveryPointFlaggedtrackingNumber, assignmentId, orderId, reason, flaggedAtApplyPointFlag upserts the flag on the tracking package row (newest flaggedAt wins, migration 0010). No command: the tracking view carries deliveryPointAdvisory{reason, flaggedAt} while the package has not ended (DELIVERED, RETURNED, LOST or VOIDED); codes only, and not an address change, not instructions, not a notification (customer-ordering ADR 0015).

Ordering. Producers key by their own root id (assignmentId, promiseId, trackingNumber), so there is no order guarantee across groups or across topics. A message that would move the status backwards raises ErrStatusRegression inside the aggregate. The consumer records it in the inbox, logs it and acknowledges it. A message that names an unknown orderId (for example, it arrived before the checkout commit was visible) is retried with backoff, then dead-lettered for an operator. The model names no dead-letter topic.

Example envelope​

The most important event, CustomerOrderPlaced, for a one-group NEXT_DAY order (all ids synthetic):

{
"specversion": "1.0",
"id": "4c1f7f0e-2d55-4c1a-9a7e-3f2b8e9d6a10",
"source": "/retailnetwork/customer-ordering",
"type": "com.retailnetwork.commerce.customer-ordering.customerorder.CustomerOrderPlaced",
"subject": "ord-20261022-000123",
"time": "2026-10-22T14:03:11Z",
"datacontenttype": "application/json",
"dataschema": "urn:retailnetwork:customer-ordering:events:CustomerOrderPlaced:v1",
"data": {
"orderId": "ord-20261022-000123",
"shopperId": "shp-000042",
"destinationPostalPrefix": "01310",
"placedAt": "2026-10-22T14:03:11Z",
"groups": [
{
"groupNo": 1,
"promiseId": "prm-8e21b7",
"tier": "NEXT_DAY",
"witnessNodeId": "node-fc-sp-01",
"shipBy": "2026-10-22T21:00:00Z",
"deliverByEarliest": "2026-10-23T12:00:00Z",
"deliverByLatest": "2026-10-23T22:00:00Z",
"lines": [
{"lineNo": 1, "catalogItemId": "cat-100234", "quantity": 2},
{"lineNo": 2, "catalogItemId": "cat-100877", "quantity": 1}
]
}
]
}
}

There is no address, name or phone anywhere in the envelope. The proposed analytics topic retailnetwork.customer-ordering.analytics exists by convention, but the model lists no analytics event for this context.