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 model.yaml → contexts[shipping-and-tracking].publishes and .consumes, and the convention in conventions.cloudevents. The domain-wide rules are on Event standard: CloudEvents.

Envelope​

Every Kafka message is a CloudEvents 1.0 event in structured JSON mode.

AttributeValue
specversion1.0
idA UUID minted once when the outbox row is written; a relay retry re-sends the same id
source/retailnetwork/shipping-and-tracking
typecom.retailnetwork.logistics.shipping-and-tracking.<entity>.<EventName>, entity label or journey
subjectThe aggregate root id: labelRef for label events, trackingNumber for journey events
timeThe instant the change was committed (the aggregate's own clock, OccurredAt()), UTC. It is the processing clock, not the instant the fact happened: that instant is a data field (deliveredAt, handedOverAt, returnedAt, the scan's at) and can be earlier than time (ADR 0004; internal/adapters/outbound/kafka/encoder.go)
datacontenttypeapplication/json
dataschemaurn:retailnetwork:shipping-and-tracking:events:<EventName>:v1
Kafka topicretailnetwork.shipping-and-tracking.events
Kafka keySame as subject, so one journey's events stay in order on one partition

Every event leaves through the transactional outbox, in the same transaction as the aggregate change. No event carries a ship-to address or any part of it.

Published​

EventFull typeSubject / keyProducing use caseConsumers
LabelIssuedcom.retailnetwork.logistics.shipping-and-tracking.label.LabelIssuedlabelRefIssueLabellinehaul-transportation, customer-ordering, last-mile-delivery
LabelVoidedcom.retailnetwork.logistics.shipping-and-tracking.label.LabelVoidedlabelRefVoidLabelcustomer-ordering, linehaul-transportation (ExpectedVolumeView)
PackageScannedcom.retailnetwork.logistics.shipping-and-tracking.journey.PackageScannedtrackingNumberRecordScan (every applied scan)customer-ordering
PackageHandedOvercom.retailnetwork.logistics.shipping-and-tracking.journey.PackageHandedOvertrackingNumberRecordScan (LABELLED -> HANDED_OVER)node-performance
PackageDeliveredcom.retailnetwork.logistics.shipping-and-tracking.journey.PackageDeliveredtrackingNumberRecordScan (OUT_FOR_DELIVERY -> DELIVERED)delivery-promise, order-sourcing, customer-ordering
PackageExceptionRaisedcom.retailnetwork.logistics.shipping-and-tracking.journey.PackageExceptionRaisedtrackingNumberRaiseException (ExceptionOnSilence)delivery-promise, customer-ordering
PackageReturnedcom.retailnetwork.logistics.shipping-and-tracking.journey.PackageReturnedtrackingNumberReturnToSender (on the consumed PackageReturnInitiated, AT_STATION to RETURNED)delivery-promise, customer-ordering
PackageLostcom.retailnetwork.logistics.shipping-and-tracking.journey.PackageLosttrackingNumberDeclareLost (the silence sweep, 48 h after an unanswered NO_SCAN)delivery-promise, customer-ordering
PackageEtaWindowAssignedcom.retailnetwork.logistics.shipping-and-tracking.journey.PackageEtaWindowAssignedtrackingNumberAssignEta (the consumer of StopEtaWindowAssigned)customer-ordering
PackageDeliveryPointFlaggedcom.retailnetwork.logistics.shipping-and-tracking.journey.PackageDeliveryPointFlaggedtrackingNumberFlagDeliveryPoint (the consumer of DeliveryPointFlagged)customer-ordering

No event of this context is analytics-only: LabelVoided, PackageReturned and PackageLost were promoted to integration events (contracts-delta E6, E16; shipping-and-tracking ADR 0004), so nothing is written to retailnetwork.shipping-and-tracking.analytics. Types in the data tables below are proposed; the field names are the model's.

LabelIssued​

FieldTypeMeaning
labelRefstringIdentity of the label
trackingNumberstringThe package's network-wide unique id
poNumberstringThe purchase order the package belongs to
assignmentIdstringThe fulfillment assignment behind the purchase order
packageNointegerPackage number within the purchase order
tierenum SAME_DAY, NEXT_DAY, TWO_DAY, STANDARDService tier printed on the label
carrierstringCarrier printed on the label
stopKeystringOpaque keyed hash of the normalized ship-to address; packages with the same value share a stop. The address itself never leaves this context
destinationPostalPrefixstringThe first 5 letters or digits of the normalized postal code

LabelVoided​

FieldTypeMeaning
labelRefstringIdentity of the label
trackingNumberstringTracking number of the voided label
reasonstringWhy it was voided

PackageScanned​

FieldTypeMeaning
trackingNumberstringThe package
scanIdstringIdentity of the applied scan
nodeIdstringWhere the package was observed
scanTypestringKind of observation (not enumerated in the model; these pages use the source fact name)
attimestampWhen it was observed
stateenum, the journey statesJourney state after the scan

PackageHandedOver​

FieldTypeMeaning
trackingNumberstringThe package
poNumberstringThe purchase order, so node-performance can compare with its requiredShipBy
nodeIdstringThe vendor node it left (origin of the pickup departure)
handedOverAttimestampThe handover instant (HandoverOnFirstScan)

PackageDelivered​

FieldTypeMeaning
trackingNumberstringThe package
assignmentIdstringThe assignment, for order-sourcing
orderIdstringThe customer order, for customer-ordering and delivery-promise
deliveredAttimestampTime of the successful attempt

PackageExceptionRaised​

FieldTypeMeaning
trackingNumberstringThe package
assignmentIdstringThe assignment
orderIdstringThe customer order
reasonstringWhy; the model names NO_SCAN
attimestampWhen the exception was raised

PackageReturned​

FieldTypeMeaning
trackingNumberstringThe package
orderIdstringThe customer order
returnedAttimestampWhen the journey ended as RETURNED

PackageLost​

FieldTypeMeaning
trackingNumberstringThe package
orderIdstringThe customer order
declaredAttimestampWhen the package was declared lost

PackageEtaWindowAssigned​

FieldTypeMeaning
trackingNumberstringThe package
assignmentIdstringThe assignment
orderIdstringThe customer order, so customer-ordering can show the window
etaStarttimestampWindow start
etaEndtimestampWindow end, after etaStart
assignedAttimestampThe route start instant: the CloudEvents time of the consumed StopEtaWindowAssigned

One event per journey of the stop, raised by AssignEta in the same unit of work as the stored window (shipping-and-tracking ADR 0013). Under one key the OUT_FOR_DELIVERY PackageScanned precedes it, because last-mile-delivery writes PackageOutForDelivery first; the currency rule (EtaCurrent) tolerates any order.

PackageDeliveryPointFlagged​

FieldTypeMeaning
trackingNumberstringThe package
assignmentIdstringThe assignment
orderIdstringThe customer order of THIS journey
reasonNOT_HOME | ACCESS_PROBLEMA code the storefront words; never driver prose
flaggedAttimestampWhen the flag was raised

One event per journey of the flagged stop, raised by FlagDeliveryPoint (shipping-and-tracking ADR 0014). The stopKey and the failure count are read and dropped: no address-derived value of a stop is kept here. There is no cleared event — customer-ordering ends the advisory when the package ends.

Example envelope: PackageDelivered​

PackageDelivered is the most important event: it closes the journey, closes the assignment in order-sourcing and lets delivery-promise judge the promise. Values are synthetic.

{
"specversion": "1.0",
"id": "5b6f2a0e-8d1c-4f7a-9c3e-2a41d7e9b0c4",
"source": "/retailnetwork/shipping-and-tracking",
"type": "com.retailnetwork.logistics.shipping-and-tracking.journey.PackageDelivered",
"subject": "RN1000000042",
"time": "2026-10-22T17:42:10Z",
"datacontenttype": "application/json",
"dataschema": "urn:retailnetwork:shipping-and-tracking:events:PackageDelivered:v1",
"data": {
"trackingNumber": "RN1000000042",
"assignmentId": "asg-7f3c21",
"orderId": "ord-20261021-0091",
"deliveredAt": "2026-10-22T17:42:10Z"
}
}

Consumed​

ProducerFull typeTopicFields usedWhat this context does
vendor-connectivitycom.retailnetwork.partner.vendor-connectivity.purchaseorder.VendorShipmentConfirmedretailnetwork.vendor-connectivity.eventspoNumber, nodeId, trackingNumbers, shippedAtFor each tracking number, RecordScan of type SHIPMENT_CONFIRMED at nodeId, time shippedAt. It is an applied scan that moves no state (LABELLED stays LABELLED) and raises PackageScanned (ADR 0002 A5); handover still comes from the pickup scan
linehaul-transportationcom.retailnetwork.logistics.linehaul-transportation.load.LoadDepartedretailnetwork.linehaul-transportation.eventsoriginNodeId, trackingNumbers, departedAt, departureKindFor each tracking number, RecordScan at originNodeId. Kind PICKUP (or no kind on a LABELLED journey) is the pickup: HANDED_OVER and PackageHandedOver; any other kind is a departure scan
linehaul-transportationcom.retailnetwork.logistics.linehaul-transportation.load.LoadArrivedretailnetwork.linehaul-transportation.eventsdestinationNodeId, trackingNumbers, arrivedAt, nodeTypeFor each tracking number, RecordScan at destinationNodeId: AT_STATION when nodeType is DELIVERY_STATION (from IN_TRANSIT, or from HANDED_OVER on direct injection), otherwise IN_TRANSIT
last-mile-deliverycom.retailnetwork.logistics.last-mile-delivery.route.PackageOutForDeliveryretailnetwork.last-mile-delivery.eventstrackingNumber, stationNodeId, atRecordScan at stationNodeId: OUT_FOR_DELIVERY
last-mile-deliverycom.retailnetwork.logistics.last-mile-delivery.route.DeliveryAttemptedretailnetwork.last-mile-delivery.eventstrackingNumber, outcome, failureReason, atRecordScan: DELIVERED and PackageDelivered on DELIVERED; back to AT_STATION on FAILED. The event has no node id; the scan takes the station of the journey's last out-for-delivery scan. The optional outcomeDetail is ignored here (tolerant decoding); the delivery-point profile that counts it stays in last-mile-delivery
last-mile-deliverycom.retailnetwork.logistics.last-mile-delivery.route.StopEtaWindowAssignedretailnetwork.last-mile-delivery.eventsrouteId, stopNo, stopKey (dropped), trackingNumbers, etaStart, etaEndAssignEta per tracking number (not a scan): a terminal journey is counted and acknowledged, an assignedAt not strictly newer than the stored one is counted (ErrEtaStale), otherwise the window is stored and PackageEtaWindowAssigned published with the journey's orderId. The stopKey is dropped: this context keeps no address-derived value of a stop (ADR 0013)
last-mile-deliverycom.retailnetwork.logistics.last-mile-delivery.deliverypointprofile.DeliveryPointFlaggedretailnetwork.last-mile-delivery.eventstrackingNumbers, reason, flaggedAt; stopKey and failures read and droppedFlagDeliveryPoint per journey (not a scan): a terminal journey is counted and acknowledged, a flaggedAt not strictly newer is counted (ErrPointFlagStale), otherwise pointFlagReason and pointFlaggedAt are stored and PackageDeliveryPointFlagged published with the journey's own orderId (ADR 0014)
last-mile-deliverycom.retailnetwork.logistics.last-mile-delivery.packageattempthistory.PackageReturnInitiated (the route entity spelling is accepted)retailnetwork.last-mile-delivery.eventstrackingNumber, atReturnToSender on an AT_STATION journey: RETURNED, and PackageReturned with returnedAt = the event's CloudEvents time (ADR 0002 A8)
offer-availabilitycom.retailnetwork.commerce.offer-availability.catalogitem.CatalogItemCreatedretailnetwork.offer-availability.eventsall eight fieldsUpsert CatalogDimensionsView

Consumers dispatch on the full type string, never on a suffix.

Idempotency​

  • Inbox. Each consumer records the CloudEvents id in processed_events in the same transaction as its last change. A message whose id is already there is acknowledged and skipped.
  • Per-scan dedupe. One load event names many tracking numbers and is applied as one transaction per journey. The proposed scanId is <CloudEvents id>:<trackingNumber>, so a redelivery after a partial failure hits ErrDuplicateScan on the journeys already done and applies only the rest. ErrDuplicateScan and ErrScanOutOfOrder are treated as success by consumers (no retry).
  • Closed journeys. RecordScan checks the journey is open first, then the scan id. ErrJourneyClosed on a consumed event is logged and acknowledged, even for a redelivered scan; a scan after delivery is a producer-side anomaly, not a retry case.
  • Unknown tracking number. A tracking number this context never issued is logged, counted and acknowledged (proposed). The model has no dead-letter convention for it.
  • Read model. CatalogDimensionsView is an upsert on catalogItemId and is naturally idempotent.