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 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.
| Attribute | Value |
|---|---|
specversion | 1.0 |
id | A UUID minted once when the outbox row is written; a relay retry re-sends the same id |
source | /retailnetwork/shipping-and-tracking |
type | com.retailnetwork.logistics.shipping-and-tracking.<entity>.<EventName>, entity label or journey |
subject | The aggregate root id: labelRef for label events, trackingNumber for journey events |
time | The 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) |
datacontenttype | application/json |
dataschema | urn:retailnetwork:shipping-and-tracking:events:<EventName>:v1 |
| Kafka topic | retailnetwork.shipping-and-tracking.events |
| Kafka key | Same 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
| Event | Full type | Subject / key | Producing use case | Consumers |
|---|---|---|---|---|
LabelIssued | com.retailnetwork.logistics.shipping-and-tracking.label.LabelIssued | labelRef | IssueLabel | linehaul-transportation, customer-ordering, last-mile-delivery |
LabelVoided | com.retailnetwork.logistics.shipping-and-tracking.label.LabelVoided | labelRef | VoidLabel | customer-ordering, linehaul-transportation (ExpectedVolumeView) |
PackageScanned | com.retailnetwork.logistics.shipping-and-tracking.journey.PackageScanned | trackingNumber | RecordScan (every applied scan) | customer-ordering |
PackageHandedOver | com.retailnetwork.logistics.shipping-and-tracking.journey.PackageHandedOver | trackingNumber | RecordScan (LABELLED -> HANDED_OVER) | node-performance |
PackageDelivered | com.retailnetwork.logistics.shipping-and-tracking.journey.PackageDelivered | trackingNumber | RecordScan (OUT_FOR_DELIVERY -> DELIVERED) | delivery-promise, order-sourcing, customer-ordering |
PackageExceptionRaised | com.retailnetwork.logistics.shipping-and-tracking.journey.PackageExceptionRaised | trackingNumber | RaiseException (ExceptionOnSilence) | delivery-promise, customer-ordering |
PackageReturned | com.retailnetwork.logistics.shipping-and-tracking.journey.PackageReturned | trackingNumber | ReturnToSender (on the consumed PackageReturnInitiated, AT_STATION to RETURNED) | delivery-promise, customer-ordering |
PackageLost | com.retailnetwork.logistics.shipping-and-tracking.journey.PackageLost | trackingNumber | DeclareLost (the silence sweep, 48 h after an unanswered NO_SCAN) | delivery-promise, customer-ordering |
PackageEtaWindowAssigned | com.retailnetwork.logistics.shipping-and-tracking.journey.PackageEtaWindowAssigned | trackingNumber | AssignEta (the consumer of StopEtaWindowAssigned) | customer-ordering |
PackageDeliveryPointFlagged | com.retailnetwork.logistics.shipping-and-tracking.journey.PackageDeliveryPointFlagged | trackingNumber | FlagDeliveryPoint (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
| Field | Type | Meaning |
|---|---|---|
labelRef | string | Identity of the label |
trackingNumber | string | The package's network-wide unique id |
poNumber | string | The purchase order the package belongs to |
assignmentId | string | The fulfillment assignment behind the purchase order |
packageNo | integer | Package number within the purchase order |
tier | enum SAME_DAY, NEXT_DAY, TWO_DAY, STANDARD | Service tier printed on the label |
carrier | string | Carrier printed on the label |
stopKey | string | Opaque keyed hash of the normalized ship-to address; packages with the same value share a stop. The address itself never leaves this context |
destinationPostalPrefix | string | The first 5 letters or digits of the normalized postal code |
LabelVoided
| Field | Type | Meaning |
|---|---|---|
labelRef | string | Identity of the label |
trackingNumber | string | Tracking number of the voided label |
reason | string | Why it was voided |
PackageScanned
| Field | Type | Meaning |
|---|---|---|
trackingNumber | string | The package |
scanId | string | Identity of the applied scan |
nodeId | string | Where the package was observed |
scanType | string | Kind of observation (not enumerated in the model; these pages use the source fact name) |
at | timestamp | When it was observed |
state | enum, the journey states | Journey state after the scan |
PackageHandedOver
| Field | Type | Meaning |
|---|---|---|
trackingNumber | string | The package |
poNumber | string | The purchase order, so node-performance can compare with its requiredShipBy |
nodeId | string | The vendor node it left (origin of the pickup departure) |
handedOverAt | timestamp | The handover instant (HandoverOnFirstScan) |
PackageDelivered
| Field | Type | Meaning |
|---|---|---|
trackingNumber | string | The package |
assignmentId | string | The assignment, for order-sourcing |
orderId | string | The customer order, for customer-ordering and delivery-promise |
deliveredAt | timestamp | Time of the successful attempt |
PackageExceptionRaised
| Field | Type | Meaning |
|---|---|---|
trackingNumber | string | The package |
assignmentId | string | The assignment |
orderId | string | The customer order |
reason | string | Why; the model names NO_SCAN |
at | timestamp | When the exception was raised |
PackageReturned
| Field | Type | Meaning |
|---|---|---|
trackingNumber | string | The package |
orderId | string | The customer order |
returnedAt | timestamp | When the journey ended as RETURNED |
PackageLost
| Field | Type | Meaning |
|---|---|---|
trackingNumber | string | The package |
orderId | string | The customer order |
declaredAt | timestamp | When the package was declared lost |
PackageEtaWindowAssigned
| Field | Type | Meaning |
|---|---|---|
trackingNumber | string | The package |
assignmentId | string | The assignment |
orderId | string | The customer order, so customer-ordering can show the window |
etaStart | timestamp | Window start |
etaEnd | timestamp | Window end, after etaStart |
assignedAt | timestamp | The 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
| Field | Type | Meaning |
|---|---|---|
trackingNumber | string | The package |
assignmentId | string | The assignment |
orderId | string | The customer order of THIS journey |
reason | NOT_HOME | ACCESS_PROBLEM | A code the storefront words; never driver prose |
flaggedAt | timestamp | When 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
| Producer | Full type | Topic | Fields used | What this context does |
|---|---|---|---|---|
vendor-connectivity | com.retailnetwork.partner.vendor-connectivity.purchaseorder.VendorShipmentConfirmed | retailnetwork.vendor-connectivity.events | poNumber, nodeId, trackingNumbers, shippedAt | For 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-transportation | com.retailnetwork.logistics.linehaul-transportation.load.LoadDeparted | retailnetwork.linehaul-transportation.events | originNodeId, trackingNumbers, departedAt, departureKind | For 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-transportation | com.retailnetwork.logistics.linehaul-transportation.load.LoadArrived | retailnetwork.linehaul-transportation.events | destinationNodeId, trackingNumbers, arrivedAt, nodeType | For 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-delivery | com.retailnetwork.logistics.last-mile-delivery.route.PackageOutForDelivery | retailnetwork.last-mile-delivery.events | trackingNumber, stationNodeId, at | RecordScan at stationNodeId: OUT_FOR_DELIVERY |
last-mile-delivery | com.retailnetwork.logistics.last-mile-delivery.route.DeliveryAttempted | retailnetwork.last-mile-delivery.events | trackingNumber, outcome, failureReason, at | RecordScan: 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-delivery | com.retailnetwork.logistics.last-mile-delivery.route.StopEtaWindowAssigned | retailnetwork.last-mile-delivery.events | routeId, stopNo, stopKey (dropped), trackingNumbers, etaStart, etaEnd | AssignEta 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-delivery | com.retailnetwork.logistics.last-mile-delivery.deliverypointprofile.DeliveryPointFlagged | retailnetwork.last-mile-delivery.events | trackingNumbers, reason, flaggedAt; stopKey and failures read and dropped | FlagDeliveryPoint 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-delivery | com.retailnetwork.logistics.last-mile-delivery.packageattempthistory.PackageReturnInitiated (the route entity spelling is accepted) | retailnetwork.last-mile-delivery.events | trackingNumber, at | ReturnToSender on an AT_STATION journey: RETURNED, and PackageReturned with returnedAt = the event's CloudEvents time (ADR 0002 A8) |
offer-availability | com.retailnetwork.commerce.offer-availability.catalogitem.CatalogItemCreated | retailnetwork.offer-availability.events | all eight fields | Upsert CatalogDimensionsView |
Consumers dispatch on the full type string, never on a suffix.
Idempotency
- Inbox. Each consumer records the CloudEvents
idinprocessed_eventsin the same transaction as its last change. A message whoseidis 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
scanIdis<CloudEvents id>:<trackingNumber>, so a redelivery after a partial failure hitsErrDuplicateScanon the journeys already done and applies only the rest.ErrDuplicateScanandErrScanOutOfOrderare treated as success by consumers (no retry). - Closed journeys.
RecordScanchecks the journey is open first, then the scan id.ErrJourneyClosedon 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.
CatalogDimensionsViewis an upsert oncatalogItemIdand is naturally idempotent.