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[linehaul-transportation].publishes and .consumes. The envelope follows the network's CloudEvents standard and ADR 0007.

Envelope​

AttributeValue
specversion1.0 (structured JSON mode)
ida UUID minted once, when the event is written to the outbox; a redelivery carries the same id
source/retailnetwork/linehaul-transportation
typecom.retailnetwork.logistics.linehaul-transportation.<entity>.<EventName>, entity departure or load
subjectthe aggregate root id: departureId for departure events, loadId for load events
timethe instant the fact happened, UTC
datacontenttypeapplication/json
dataschemaurn:retailnetwork:linehaul-transportation:events:<EventName>:v1
Kafka topicretailnetwork.linehaul-transportation.events
Kafka keythe same aggregate root id as subject, so one departure's (or one load's) events stay in order on one partition

Every event leaves through the transactional outbox, in the same transaction as the aggregate change.

Published​

Departure events (key departureId)​

EventFull typedata fieldsProducing command / use caseConsumers
DepartureScheduledcom.retailnetwork.logistics.linehaul-transportation.departure.DepartureScheduleddepartureId, laneId, kind, originNodeId, destinationNodeId, cutoffAt, departsAt, arrivesAt, capacityPackagesScheduleDeparture, via GenerateDepartures (HorizonRoll) or PickupFromCutoffsdelivery-promise (DepartureView), order-sourcing (NetworkGraphView)
DepartureCapacityChangedcom.retailnetwork.logistics.linehaul-transportation.departure.DepartureCapacityChangeddepartureId, capacityPackages, bookedPackages, remainingPackagesBookCapacity (policy BookOnLock), ReleaseCapacity (only in the rebooking of a cancelled departure)delivery-promise, order-sourcing
DepartureCancelledcom.retailnetwork.logistics.linehaul-transportation.departure.DepartureCancelleddepartureId, reason, cancelledAtCancelDeparture (planner, or PickupFromCutoffs on NodeSuspended / NodeRetired)delivery-promise (RepromiseOnRisk), order-sourcing
DepartureDepartedcom.retailnetwork.logistics.linehaul-transportation.departure.DepartureDeparteddepartureId, departedAtRecordDepartureanalytics only
DepartureArrivedcom.retailnetwork.logistics.linehaul-transportation.departure.DepartureArriveddepartureId, arrivedAtRecordArrivalanalytics only

Load events (key loadId)​

EventFull typedata fieldsProducing command / use caseConsumers
LoadClosedcom.retailnetwork.logistics.linehaul-transportation.load.LoadClosedloadId, departureId, packageCountCloseLoadanalytics only
LoadDepartedcom.retailnetwork.logistics.linehaul-transportation.load.LoadDepartedloadId, departureId, originNodeId, trackingNumbers, departedAt, departureKind, nodeType (the type of the origin node; policy NodeTypeSnapshot)DispatchLoadshipping-and-tracking (journey scans, HandoverOnFirstScan)
LoadArrivedcom.retailnetwork.logistics.linehaul-transportation.load.LoadArrivedloadId, departureId, destinationNodeId, trackingNumbers, arrivedAt, departureKind, nodeType (the type of the destination node; policy NodeTypeSnapshot)ReceiveLoadshipping-and-tracking (journey scans), last-mile-delivery (InductOnArrival, InboundPackagesView)

"Analytics only" means the model names no in-org consumer. The events are still published on the integration topic; no context may depend on them for a decision without a model change.

OpenLoad, AddPackage, CloseDeparture, DefineLaneSchedule, RetireLaneSchedule and GenerateDepartures (itself) raise no event.

Example: a pickup departure scheduled​

DepartureScheduled is the most important event: it is how a vendor's declared cutoff reaches the promise. Example for a PICKUP departure (ids and times are illustrative):

{
"specversion": "1.0",
"id": "6f1d2c4e-8a1b-4e8f-9b4a-2d5c7e9f1a30",
"source": "/retailnetwork/linehaul-transportation",
"type": "com.retailnetwork.logistics.linehaul-transportation.departure.DepartureScheduled",
"subject": "dep-20261023-ln-fc017-sc003-1800",
"time": "2026-10-22T01:00:04Z",
"datacontenttype": "application/json",
"dataschema": "urn:retailnetwork:linehaul-transportation:events:DepartureScheduled:v1",
"data": {
"departureId": "dep-20261023-ln-fc017-sc003-1800",
"laneId": "ln-fc017-sc003-ground",
"kind": "PICKUP",
"originNodeId": "node-fc017",
"destinationNodeId": "node-sc003",
"cutoffAt": "2026-10-23T21:00:00Z",
"departsAt": "2026-10-23T21:00:00Z",
"arrivesAt": "2026-10-23T23:15:00Z",
"capacityPackages": 1200
}
}

Consumed​

Every consumer is idempotent on the CloudEvents id (a row in processed_events written in the same transaction as the effect) and dispatches on the full type string, never on a suffix.

ProducerFull typeWhat this context does with itIdempotency beyond the inbox
node-topologycom.retailnetwork.logistics.node-topology.node.NodeRegisteredInserts the node (type, operator, vendor, region, time zone) into NodeProfileViewUpsert on nodeId
node-topologycom.retailnetwork.logistics.node-topology.node.NodeOperationalProfileDeclaredStores the profile in NodeProfileView; PickupFromCutoffs (re)generates PICKUP departures for every cutoff of the horizon (ScheduleDeparture)Ignore a profileRevision not above the stored one; one pickup per (node, cutoff, operating day)
node-topologycom.retailnetwork.logistics.node-topology.node.NodeActivatedMarks the node ACTIVE in NodeProfileView (no further reaction is named in the model)Status overwrite
node-topologycom.retailnetwork.logistics.node-topology.node.NodeSuspendedMarks the node SUSPENDED; PickupFromCutoffs cancels its future pickups (CancelDeparture)A departure already CANCELLED is skipped
node-topologycom.retailnetwork.logistics.node-topology.node.NodeRetiredMarks the node RETIRED; PickupFromCutoffs cancels its future pickupsAs above
node-topologycom.retailnetwork.logistics.node-topology.lane.LaneOpenedInserts the lane (origin, destination, mode, nominal transit) into LaneView as OPENUpsert on laneId
node-topologycom.retailnetwork.logistics.node-topology.lane.LaneClosedMarks the lane CLOSED; later ScheduleDeparture on it fails with ErrLaneClosedStatus overwrite
order-sourcingcom.retailnetwork.commerce.order-sourcing.assignment.FulfillmentReleasedToNodeRecords the assignment, node and pickupDepartureId in ExpectedVolumeViewUpsert on (assignmentId, releaseNo)
order-sourcingcom.retailnetwork.commerce.order-sourcing.assignment.FulfillmentReassignedUpdates the node of the assignment's ExpectedVolumeView row and forgets its planned departure; releases nothing (no booking exists before the lock; ADR 0002 A16)Reads only assignmentId and toNodeId: no version is consumed, so the last delivered event wins
order-sourcingcom.retailnetwork.commerce.order-sourcing.assignment.FulfillmentLockedBookOnLock: BookCapacity of one package on pickupDepartureId; marks the assignment booked in ExpectedVolumeView. When the optional consolidatedInto is set (a follower of a merged release) the event id is claimed in the inbox and nothing else happens: no row, no booking, no capacity event (FollowerLockBooksNothing); mergedAssignmentIds is ignoredOne booking per assignmentId; a follower lock before or after the carrier's gives the same result
order-sourcingcom.retailnetwork.commerce.order-sourcing.assignment.FulfillmentCancelledUpdates the assignment's ExpectedVolumeView row only; releases nothing (ADR 0002 A16, A28: the release branch of BookOnLock was removed)Inbox on the CloudEvents id
shipping-and-trackingcom.retailnetwork.logistics.shipping-and-tracking.label.LabelIssuedAdds trackingNumber and packageNo to the assignment in ExpectedVolumeViewUpsert on labelRef

Derived from: model.yaml → contexts[linehaul-transportation].consumes, .policies, .read_models, and the producers' publishes[*].data.

Notes and gaps​

  • FulfillmentReassigned and FulfillmentCancelled are raised by order-sourcing only before LOCKED (ErrAssignmentLocked, ErrCancelAfterLock on its side), while BookOnLock books only on FulfillmentLocked. The release branch was therefore removed (gap G15, ADR 0002 A16, A28): both events update ExpectedVolumeView only. If order-sourcing ever cancels after the lock, the capacity stays booked until the departure leaves (reported model gap).
  • DepartureCapacityChanged carries capacityPackages, which suggests the capacity itself can change; no command in the model changes it. Reported as a model gap.
  • The idempotency keys in the last column are proposals; the model requires only the inbox on the CloudEvents id.