Domain Events
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 (contexts[delivery-promise].publishes) and
consumes (.consumes), following
the CloudEvents standard of this domain
and ADR 0007.
Envelope
| Attribute | Value |
|---|---|
specversion | 1.0 |
id | a UUID minted once when the outbox row is written; a redelivery carries the same id |
source | /retailnetwork/delivery-promise |
type | com.retailnetwork.commerce.delivery-promise.<entity>.<EventName>; entity promise for the eight promise events, promisebook for PromiseBookExhausted |
subject | the aggregate root id: promiseId, or bookId for PromiseBookExhausted |
time | the instant the aggregate change was committed, UTC |
datacontenttype | application/json |
dataschema | urn:retailnetwork:delivery-promise:events:<EventName>:v1 |
| Kafka topic | retailnetwork.delivery-promise.events |
| Kafka key | same as subject, so all events of one promise (or one book) share a partition and keep their order |
Every event leaves through the transactional outbox (outbox_events), written
in the same Postgres transaction as the aggregate change.
Published
| Event | Full type | Subject / key | Producing command (use case) | Consumers |
|---|---|---|---|---|
PromiseMade | com.retailnetwork.commerce.delivery-promise.promise.PromiseMade | promiseId | MakePromise | analytics only |
PromiseConfirmed | com.retailnetwork.commerce.delivery-promise.promise.PromiseConfirmed | promiseId | ConfirmPromise (on CustomerOrderPlaced) | analytics only |
PromiseAtRisk | com.retailnetwork.commerce.delivery-promise.promise.PromiseAtRisk | promiseId | FlagPromiseAtRisk (RepromiseOnRisk) | customer-ordering |
PromiseRevised | com.retailnetwork.commerce.delivery-promise.promise.PromiseRevised | promiseId | RevisePromise (RepromiseOnRisk) | customer-ordering, order-sourcing |
PromiseKept | com.retailnetwork.commerce.delivery-promise.promise.PromiseKept | promiseId | JudgePromise (JudgeOnDelivery) | node-performance, customer-ordering |
PromiseBroken | com.retailnetwork.commerce.delivery-promise.promise.PromiseBroken | promiseId | JudgePromise (JudgeOnDelivery) | node-performance, customer-ordering |
PromiseReleased | com.retailnetwork.commerce.delivery-promise.promise.PromiseReleased | promiseId | ReleaseExpiredHolds | analytics only |
PromiseCancelled | com.retailnetwork.commerce.delivery-promise.promise.PromiseCancelled | promiseId | CancelPromise (on CustomerOrderCancelled) | analytics only |
PromiseBookExhausted | com.retailnetwork.commerce.delivery-promise.promisebook.PromiseBookExhausted | bookId | HoldCapacity inside MakePromise | order-sourcing |
Data fields
Field names are the model's. Types and meanings are this pack's proposal; timestamps are RFC 3339 UTC strings.
PromiseMade
| Field | Type | Meaning |
|---|---|---|
promiseId | string | the new promise |
offerId | string | the DeliveryOffer it consumed |
tier | enum | SAME_DAY, NEXT_DAY, TWO_DAY, STANDARD or CONSOLIDATED (opt-in: only on a quote that asked for it) |
nodeId | string | witness node |
pickupDepartureId | string | witness pickup departure (its book is nodeId:pickupDepartureId) |
shipBy | timestamp | pickup cutoff the package must be ready for |
deliverByEarliest | timestamp | window start |
deliverByLatest | timestamp | window end; the judgement line |
basis | enum | SCHEDULED, MEASURED or NOMINAL |
confidence | number, optional | in [0,1], three decimals: the calibration segment's observed share of judged promises within the quote's buffer; omitted when the segment has too few judgements (unknown, never zero) |
consolidationEligible | boolean, optional | present only for the tier CONSOLIDATED: true when the chosen day leaves the network at least one local day after the fastest window to merge the order with others, false when it is that window itself; never false by default and it never says another order exists |
policyVersion | string | version of the promise policies used |
holdExpiresAt | timestamp | the provisional hold is released after this instant |
lines | array of {catalogItemId, quantity} | the shipment group |
PromiseConfirmed: promiseId; orderId (the placed customer order);
groupNo (the group's number in that order).
PromiseAtRisk: promiseId; orderId; reason (string, what put it at
risk: NODE_UNSOURCEABLE, PACKAGE_EXCEPTION, INDUCTION_DEFERRED, DEPARTURE_CANCELLED, WAVE_CANCELLED, BOOKING_FAILED, BOOKING_MOVED or PREDICTED_LATE, the last raised by the clock-driven late-risk sweep); detectedAt (timestamp).
PromiseRevised
| Field | Type | Meaning |
|---|---|---|
promiseId | string | the revised promise |
orderId | string | its customer order |
revisionNo | integer | 1 for the first revision, then +1 |
previousDeliverByLatest | timestamp | window end before this revision |
deliverByEarliest | timestamp | new window start |
deliverByLatest | timestamp | new window end, never earlier than previousDeliverByLatest (ErrRevisionMovesEarlier) |
shipBy | timestamp | new ship-by at the new witness node |
nodeId | string | new witness node |
reason | string | why the promise was revised |
PromiseKept: promiseId; orderId; nodeId (the node judged);
deliveredAt (timestamp); deliverByLatest (timestamp).
PromiseBroken: as PromiseKept, plus lateByMinutes (integer,
deliveredAt - deliverByLatest in minutes) and cause (string; the model
gives no vocabulary).
PromiseReleased: promiseId; reason (string, for example the hold
expired).
PromiseCancelled: promiseId; orderId; reason (string, copied from
CustomerOrderCancelled.reason).
PromiseBookExhausted: bookId (nodeId:pickupDepartureId); nodeId;
pickupDepartureId; share (integer, the capacity just reached).
Analytics topic
DeliveryOfferQuoted is analytics-only, published on
retailnetwork.delivery-promise.analytics for every quote. Its data fields in the
model are offerId, tier, destinationPostalPrefix, nodeId,
deliverByEarliest, deliverByLatest, basis, confidence (optional),
consolidationEligible (optional, CONSOLIDATED only),
policyVersion, expiresAt and capacityBand (optional: AMPLE, TIGHT or
SCARCE, omitted when unknown, never an empty string). Consumers of the
analytics topic decode tolerantly and ignore what they do not use.
Example envelope: PromiseRevised
PromiseRevised is the event with the most consequence: the customer sees a new
date, and order-sourcing gets a new constraint.
{
"specversion": "1.0",
"id": "6f1d2c4a-9b7e-4f3a-a0c5-2e8d91b47c13",
"source": "/retailnetwork/delivery-promise",
"type": "com.retailnetwork.commerce.delivery-promise.promise.PromiseRevised",
"subject": "prm-01JC9X4T7QK2M8V5R3N6B1D0EA",
"time": "2026-11-24T15:42:07.318Z",
"datacontenttype": "application/json",
"dataschema": "urn:retailnetwork:delivery-promise:events:PromiseRevised:v1",
"data": {
"promiseId": "prm-01JC9X4T7QK2M8V5R3N6B1D0EA",
"orderId": "ord-01JC9X3ZP6W0H4F2K8S5T7Y9QB",
"revisionNo": 1,
"previousDeliverByLatest": "2026-11-25T21:00:00Z",
"deliverByEarliest": "2026-11-26T14:00:00Z",
"deliverByLatest": "2026-11-26T21:00:00Z",
"shipBy": "2026-11-25T02:00:00Z",
"nodeId": "node-fc-sp-07",
"reason": "departure on the witness path cancelled"
}
}
The identifiers and values are illustrative.
Consumed
Every consumer is idempotent on the CloudEvents id: the id is inserted into
processed_events (the inbox) in the same transaction as the read-model or
aggregate write; a duplicate id commits nothing. Consumers dispatch on the
full type string. On top of the inbox, each read model keeps a monotonic
guard where the producer gives one, so an out-of-order delivery never moves a
row backwards.
| Producer | Full type | Fields used | What this context does | Extra idempotency / ordering guard |
|---|---|---|---|---|
customer-ordering | com.retailnetwork.commerce.customer-ordering.customerorder.CustomerOrderPlaced | orderId, groups[].groupNo, groups[].promiseId | The reconciling ConfirmPromise for each group's promise (with ConfirmCapacity), all groups in one transaction with the inbox row. A group whose hold lapsed (ErrPromiseHoldExpired) or whose promise is closed is skipped with a warning log, never retried; the other groups are still confirmed and the ReleaseExpiredHolds sweeper releases the lapsed promise | a CONFIRMED promise with the same orderId and groupNo is a no-op |
customer-ordering | com.retailnetwork.commerce.customer-ordering.customerorder.CustomerOrderCancelled | orderId, groupNos, reason | CancelPromise for the promises of those groups, releasing confirmed capacity (this pack's reading; no policy named) | a CANCELLED promise is a no-op |
order-sourcing | com.retailnetwork.commerce.order-sourcing.assignment.FulfillmentUnsourceable | promiseId, orderId, groupNo, excludedNodes, reason | RepromiseOnRisk: FlagPromiseAtRisk, recompute (excluding excludedNodes, this pack's reading), RevisePromise | an AT_RISK promise is not flagged twice |
order-sourcing | com.retailnetwork.commerce.order-sourcing.assignment.FulfillmentLocked | assignmentId, orderId, groupNo, nodeId, pickupDepartureId | The model names no use. This pack records the assignmentId against the group's promise, so that PackageDelivered and PackageExceptionRaised can find it (open question) | last write wins; a lock happens once per assignment |
shipping-and-tracking | com.retailnetwork.logistics.shipping-and-tracking.journey.PackageDelivered | assignmentId, orderId, deliveredAt | JudgeOnDelivery: JudgePromise for the group's promise, and for every promise that shares the package's tracking number (SharedTrackingJudgement, each judged on its own window; PackageLost and PackageReturned break every sharing promise) | a judged promise is terminal (ErrPromiseClosed is swallowed as a duplicate) |
shipping-and-tracking | com.retailnetwork.logistics.shipping-and-tracking.journey.PackageExceptionRaised | assignmentId, orderId, reason, at | RepromiseOnRisk for the group's promise; when the event carries a tracking number, every assignment that shares it is flagged AT_RISK | as above |
shipping-and-tracking | com.retailnetwork.logistics.shipping-and-tracking.journey.PackageLost | trackingNumber, declaredAt | JudgeOnDelivery: the promise of every assignment that shares the tracking number is judged BROKEN with cause LOST (no deliveredAt), each on its own window (ADR 0025). A lost package's promise IS judged | a judged promise is terminal; the outcome row is one per tracking number and the first final fact wins |
shipping-and-tracking | com.retailnetwork.logistics.shipping-and-tracking.journey.PackageReturned | trackingNumber, returnedAt | as PackageLost, with cause RETURNED | as above |
linehaul-transportation | com.retailnetwork.logistics.linehaul-transportation.departure.DepartureScheduled | departureId, laneId, kind, originNodeId, destinationNodeId, cutoffAt, departsAt, arrivesAt, capacityPackages | upsert DepartureView | insert-if-absent on departureId |
linehaul-transportation | com.retailnetwork.logistics.linehaul-transportation.departure.DepartureCapacityChanged | departureId, capacityPackages, bookedPackages, remainingPackages | update DepartureView remaining capacity | applied only if the CloudEvents time is newer than the row's |
linehaul-transportation | com.retailnetwork.logistics.linehaul-transportation.departure.DepartureCancelled | departureId, reason, cancelledAt | mark cancelled in DepartureView; RepromiseOnRisk for every open promise whose witness path uses the departure | a cancelled row stays cancelled |
last-mile-delivery | com.retailnetwork.logistics.last-mile-delivery.wave.DeliveryWaveScheduled | waveId, stationNodeId, serviceDate, inductCutoffAt, windowStart, windowEnd, stopCapacity | upsert DeliveryWaveView | insert-if-absent on waveId |
last-mile-delivery | com.retailnetwork.logistics.last-mile-delivery.wave.DeliveryWaveCapacityChanged | waveId, stopCapacity, assignedStops, remainingStops | update DeliveryWaveView | newer time wins |
last-mile-delivery | com.retailnetwork.logistics.last-mile-delivery.wave.DeliveryWaveCancelled | waveId, reason | mark the wave cancelled in DeliveryWaveView and flag AT_RISK (reason WAVE_CANCELLED) every active promise whose witness wave it is, then RepromiseOnRisk. A cancelled wave is NOT invisible here | a cancelled row stays cancelled |
node-topology | com.retailnetwork.logistics.node-topology.node.NodeRegistered | nodeId, nodeType, subtype, operator, regionId, timezone, postalCode, countryCode | insert NodeProfileView | insert-if-absent |
node-topology | com.retailnetwork.logistics.node-topology.node.NodeOperationalProfileDeclared | nodeId, profileRevision, timezone, operatingHoursByDay, holidays, handlingTimeMinutes, cutoffs, throughputCap, sortDwellMinutes | update the profile in NodeProfileView | applied only if profileRevision is higher |
node-topology | com.retailnetwork.logistics.node-topology.node.NodeActivated | nodeId, activatedAt | status ACTIVE: the node becomes a candidate | newer time wins |
node-topology | com.retailnetwork.logistics.node-topology.node.NodeSuspended | nodeId, reason, suspendedAt | status SUSPENDED: no new offers from it (open promises are re-promised when linehaul-transportation cancels its pickups) | newer time wins |
node-topology | com.retailnetwork.logistics.node-topology.node.NodeRetired | nodeId, retiredAt | status RETIRED (terminal) | terminal |
node-topology | com.retailnetwork.logistics.node-topology.lane.LaneOpened | laneId, originNodeId, destinationNodeId, mode, nominalTransitMinutes | insert LaneView | insert-if-absent |
node-topology | com.retailnetwork.logistics.node-topology.lane.LaneClosed | laneId, closedAt | close the lane in LaneView | terminal |
node-topology | com.retailnetwork.logistics.node-topology.servicearea.ServiceAreaAssigned | postalPrefix, deliveryStationNodeId, regionId, assignmentVersion | upsert RegionAndServiceAreaView | applied only if assignmentVersion is higher |
node-topology | com.retailnetwork.logistics.node-topology.region.RegionDefined | regionId, code, name | insert into RegionAndServiceAreaView | insert-if-absent |
offer-availability | com.retailnetwork.commerce.offer-availability.catalogitem.CatalogItemCreated | catalogItemId | insert the item into AvailabilityView | insert-if-absent |
offer-availability | com.retailnetwork.commerce.offer-availability.catalogitem.CatalogItemDiscontinued | catalogItemId | the item is no longer quotable | terminal |
offer-availability | com.retailnetwork.commerce.offer-availability.listing.ListingCreated | listingId, catalogItemId, nodeId | insert the listing into AvailabilityView | insert-if-absent |
offer-availability | com.retailnetwork.commerce.offer-availability.listing.ListingAvailabilityChanged | listingId, availableQty, basis, asOf | update quantity and basis | applied only if asOf is newer (the producer's own rule) |
offer-availability | com.retailnetwork.commerce.offer-availability.listing.ListingSuppressed | listingId, nodeId, reason | the listing is not a candidate | newer time wins |
offer-availability | com.retailnetwork.commerce.offer-availability.listing.ListingRestored | listingId, nodeId | the listing is a candidate again | newer time wins |
node-performance | com.retailnetwork.partner.node-performance.scorecard.NodeScorecardUpdated | nodeId, window, grade, observations, computedAt | upsert ScorecardView per (nodeId, window) | applied only if computedAt is newer |
node-performance | com.retailnetwork.partner.node-performance.scorecard.NodeTierEligibilityChanged | nodeId, tier, eligible, changedAt | upsert NodeTierEligibility per (nodeId, tier); an ineligible node leaves the tier's candidates in future quotes and estimates (policy FastTierCandidateFilter) | applied only if changedAt is not older than the stored one; an unknown tier or a missing field is ignored and counted, never dead-lettered; a missing row means eligible |
linehaul-transportation | com.retailnetwork.logistics.linehaul-transportation.load.LoadArrived | loadId, arrivedAt, and the OPTIONAL departureId | pairs with LoadDeparted for TransitActualsView; with a departureId also records the arrival in DepartureArrival for the late-risk sweep | a first arrival is kept; an event without departureId writes no arrival row and is counted |
Consumer groups (proposed): one group per projector, named
delivery-promise-<read-model> (for example delivery-promise-departure-view),
plus delivery-promise-promise-lifecycle for the five events that drive a use
case (CustomerOrderPlaced, CustomerOrderCancelled, FulfillmentUnsourceable,
PackageDelivered, PackageExceptionRaised) and DepartureCancelled's
re-promise reaction.
A message that is not a valid CloudEvent, or whose type is unknown, is logged
and set aside so that it never blocks the partition. The model names no
dead-letter topic; choosing one is an implementation decision.
Omitted: the per-field JSON schemas (they belong in the AsyncAPI document, not
yet written), and the fields this context receives but ignores (for example
shopperId on CustomerOrderPlaced, vendorId on NodeRegistered).