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 (contexts[delivery-promise].publishes) and consumes (.consumes), following the CloudEvents standard of this domain and ADR 0007.

Envelope​

AttributeValue
specversion1.0
ida UUID minted once when the outbox row is written; a redelivery carries the same id
source/retailnetwork/delivery-promise
typecom.retailnetwork.commerce.delivery-promise.<entity>.<EventName>; entity promise for the eight promise events, promisebook for PromiseBookExhausted
subjectthe aggregate root id: promiseId, or bookId for PromiseBookExhausted
timethe instant the aggregate change was committed, UTC
datacontenttypeapplication/json
dataschemaurn:retailnetwork:delivery-promise:events:<EventName>:v1
Kafka topicretailnetwork.delivery-promise.events
Kafka keysame 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​

EventFull typeSubject / keyProducing command (use case)Consumers
PromiseMadecom.retailnetwork.commerce.delivery-promise.promise.PromiseMadepromiseIdMakePromiseanalytics only
PromiseConfirmedcom.retailnetwork.commerce.delivery-promise.promise.PromiseConfirmedpromiseIdConfirmPromise (on CustomerOrderPlaced)analytics only
PromiseAtRiskcom.retailnetwork.commerce.delivery-promise.promise.PromiseAtRiskpromiseIdFlagPromiseAtRisk (RepromiseOnRisk)customer-ordering
PromiseRevisedcom.retailnetwork.commerce.delivery-promise.promise.PromiseRevisedpromiseIdRevisePromise (RepromiseOnRisk)customer-ordering, order-sourcing
PromiseKeptcom.retailnetwork.commerce.delivery-promise.promise.PromiseKeptpromiseIdJudgePromise (JudgeOnDelivery)node-performance, customer-ordering
PromiseBrokencom.retailnetwork.commerce.delivery-promise.promise.PromiseBrokenpromiseIdJudgePromise (JudgeOnDelivery)node-performance, customer-ordering
PromiseReleasedcom.retailnetwork.commerce.delivery-promise.promise.PromiseReleasedpromiseIdReleaseExpiredHoldsanalytics only
PromiseCancelledcom.retailnetwork.commerce.delivery-promise.promise.PromiseCancelledpromiseIdCancelPromise (on CustomerOrderCancelled)analytics only
PromiseBookExhaustedcom.retailnetwork.commerce.delivery-promise.promisebook.PromiseBookExhaustedbookIdHoldCapacity inside MakePromiseorder-sourcing

Data fields​

Field names are the model's. Types and meanings are this pack's proposal; timestamps are RFC 3339 UTC strings.

PromiseMade

FieldTypeMeaning
promiseIdstringthe new promise
offerIdstringthe DeliveryOffer it consumed
tierenumSAME_DAY, NEXT_DAY, TWO_DAY, STANDARD or CONSOLIDATED (opt-in: only on a quote that asked for it)
nodeIdstringwitness node
pickupDepartureIdstringwitness pickup departure (its book is nodeId:pickupDepartureId)
shipBytimestamppickup cutoff the package must be ready for
deliverByEarliesttimestampwindow start
deliverByLatesttimestampwindow end; the judgement line
basisenumSCHEDULED, MEASURED or NOMINAL
confidencenumber, optionalin [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)
consolidationEligibleboolean, optionalpresent 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
policyVersionstringversion of the promise policies used
holdExpiresAttimestampthe provisional hold is released after this instant
linesarray 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

FieldTypeMeaning
promiseIdstringthe revised promise
orderIdstringits customer order
revisionNointeger1 for the first revision, then +1
previousDeliverByLatesttimestampwindow end before this revision
deliverByEarliesttimestampnew window start
deliverByLatesttimestampnew window end, never earlier than previousDeliverByLatest (ErrRevisionMovesEarlier)
shipBytimestampnew ship-by at the new witness node
nodeIdstringnew witness node
reasonstringwhy 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.

ProducerFull typeFields usedWhat this context doesExtra idempotency / ordering guard
customer-orderingcom.retailnetwork.commerce.customer-ordering.customerorder.CustomerOrderPlacedorderId, groups[].groupNo, groups[].promiseIdThe 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 promisea CONFIRMED promise with the same orderId and groupNo is a no-op
customer-orderingcom.retailnetwork.commerce.customer-ordering.customerorder.CustomerOrderCancelledorderId, groupNos, reasonCancelPromise for the promises of those groups, releasing confirmed capacity (this pack's reading; no policy named)a CANCELLED promise is a no-op
order-sourcingcom.retailnetwork.commerce.order-sourcing.assignment.FulfillmentUnsourceablepromiseId, orderId, groupNo, excludedNodes, reasonRepromiseOnRisk: FlagPromiseAtRisk, recompute (excluding excludedNodes, this pack's reading), RevisePromisean AT_RISK promise is not flagged twice
order-sourcingcom.retailnetwork.commerce.order-sourcing.assignment.FulfillmentLockedassignmentId, orderId, groupNo, nodeId, pickupDepartureIdThe 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-trackingcom.retailnetwork.logistics.shipping-and-tracking.journey.PackageDeliveredassignmentId, orderId, deliveredAtJudgeOnDelivery: 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-trackingcom.retailnetwork.logistics.shipping-and-tracking.journey.PackageExceptionRaisedassignmentId, orderId, reason, atRepromiseOnRisk for the group's promise; when the event carries a tracking number, every assignment that shares it is flagged AT_RISKas above
shipping-and-trackingcom.retailnetwork.logistics.shipping-and-tracking.journey.PackageLosttrackingNumber, declaredAtJudgeOnDelivery: 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 judgeda judged promise is terminal; the outcome row is one per tracking number and the first final fact wins
shipping-and-trackingcom.retailnetwork.logistics.shipping-and-tracking.journey.PackageReturnedtrackingNumber, returnedAtas PackageLost, with cause RETURNEDas above
linehaul-transportationcom.retailnetwork.logistics.linehaul-transportation.departure.DepartureScheduleddepartureId, laneId, kind, originNodeId, destinationNodeId, cutoffAt, departsAt, arrivesAt, capacityPackagesupsert DepartureViewinsert-if-absent on departureId
linehaul-transportationcom.retailnetwork.logistics.linehaul-transportation.departure.DepartureCapacityChangeddepartureId, capacityPackages, bookedPackages, remainingPackagesupdate DepartureView remaining capacityapplied only if the CloudEvents time is newer than the row's
linehaul-transportationcom.retailnetwork.logistics.linehaul-transportation.departure.DepartureCancelleddepartureId, reason, cancelledAtmark cancelled in DepartureView; RepromiseOnRisk for every open promise whose witness path uses the departurea cancelled row stays cancelled
last-mile-deliverycom.retailnetwork.logistics.last-mile-delivery.wave.DeliveryWaveScheduledwaveId, stationNodeId, serviceDate, inductCutoffAt, windowStart, windowEnd, stopCapacityupsert DeliveryWaveViewinsert-if-absent on waveId
last-mile-deliverycom.retailnetwork.logistics.last-mile-delivery.wave.DeliveryWaveCapacityChangedwaveId, stopCapacity, assignedStops, remainingStopsupdate DeliveryWaveViewnewer time wins
last-mile-deliverycom.retailnetwork.logistics.last-mile-delivery.wave.DeliveryWaveCancelledwaveId, reasonmark 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 herea cancelled row stays cancelled
node-topologycom.retailnetwork.logistics.node-topology.node.NodeRegisterednodeId, nodeType, subtype, operator, regionId, timezone, postalCode, countryCodeinsert NodeProfileViewinsert-if-absent
node-topologycom.retailnetwork.logistics.node-topology.node.NodeOperationalProfileDeclarednodeId, profileRevision, timezone, operatingHoursByDay, holidays, handlingTimeMinutes, cutoffs, throughputCap, sortDwellMinutesupdate the profile in NodeProfileViewapplied only if profileRevision is higher
node-topologycom.retailnetwork.logistics.node-topology.node.NodeActivatednodeId, activatedAtstatus ACTIVE: the node becomes a candidatenewer time wins
node-topologycom.retailnetwork.logistics.node-topology.node.NodeSuspendednodeId, reason, suspendedAtstatus SUSPENDED: no new offers from it (open promises are re-promised when linehaul-transportation cancels its pickups)newer time wins
node-topologycom.retailnetwork.logistics.node-topology.node.NodeRetirednodeId, retiredAtstatus RETIRED (terminal)terminal
node-topologycom.retailnetwork.logistics.node-topology.lane.LaneOpenedlaneId, originNodeId, destinationNodeId, mode, nominalTransitMinutesinsert LaneViewinsert-if-absent
node-topologycom.retailnetwork.logistics.node-topology.lane.LaneClosedlaneId, closedAtclose the lane in LaneViewterminal
node-topologycom.retailnetwork.logistics.node-topology.servicearea.ServiceAreaAssignedpostalPrefix, deliveryStationNodeId, regionId, assignmentVersionupsert RegionAndServiceAreaViewapplied only if assignmentVersion is higher
node-topologycom.retailnetwork.logistics.node-topology.region.RegionDefinedregionId, code, nameinsert into RegionAndServiceAreaViewinsert-if-absent
offer-availabilitycom.retailnetwork.commerce.offer-availability.catalogitem.CatalogItemCreatedcatalogItemIdinsert the item into AvailabilityViewinsert-if-absent
offer-availabilitycom.retailnetwork.commerce.offer-availability.catalogitem.CatalogItemDiscontinuedcatalogItemIdthe item is no longer quotableterminal
offer-availabilitycom.retailnetwork.commerce.offer-availability.listing.ListingCreatedlistingId, catalogItemId, nodeIdinsert the listing into AvailabilityViewinsert-if-absent
offer-availabilitycom.retailnetwork.commerce.offer-availability.listing.ListingAvailabilityChangedlistingId, availableQty, basis, asOfupdate quantity and basisapplied only if asOf is newer (the producer's own rule)
offer-availabilitycom.retailnetwork.commerce.offer-availability.listing.ListingSuppressedlistingId, nodeId, reasonthe listing is not a candidatenewer time wins
offer-availabilitycom.retailnetwork.commerce.offer-availability.listing.ListingRestoredlistingId, nodeIdthe listing is a candidate againnewer time wins
node-performancecom.retailnetwork.partner.node-performance.scorecard.NodeScorecardUpdatednodeId, window, grade, observations, computedAtupsert ScorecardView per (nodeId, window)applied only if computedAt is newer
node-performancecom.retailnetwork.partner.node-performance.scorecard.NodeTierEligibilityChangednodeId, tier, eligible, changedAtupsert 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-transportationcom.retailnetwork.logistics.linehaul-transportation.load.LoadArrivedloadId, arrivedAt, and the OPTIONAL departureIdpairs with LoadDeparted for TransitActualsView; with a departureId also records the arrival in DepartureArrival for the late-risk sweepa 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).