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
contexts[linehaul-transportation].publishes and .consumes. The
envelope follows the network's
CloudEvents standard and
ADR 0007.
Envelope
| Attribute | Value |
|---|---|
specversion | 1.0 (structured JSON mode) |
id | a UUID minted once, when the event is written to the outbox; a redelivery carries the same id |
source | /retailnetwork/linehaul-transportation |
type | com.retailnetwork.logistics.linehaul-transportation.<entity>.<EventName>, entity departure or load |
subject | the aggregate root id: departureId for departure events, loadId for load events |
time | the instant the fact happened, UTC |
datacontenttype | application/json |
dataschema | urn:retailnetwork:linehaul-transportation:events:<EventName>:v1 |
| Kafka topic | retailnetwork.linehaul-transportation.events |
| Kafka key | the 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)
| Event | Full type | data fields | Producing command / use case | Consumers |
|---|---|---|---|---|
DepartureScheduled | com.retailnetwork.logistics.linehaul-transportation.departure.DepartureScheduled | departureId, laneId, kind, originNodeId, destinationNodeId, cutoffAt, departsAt, arrivesAt, capacityPackages | ScheduleDeparture, via GenerateDepartures (HorizonRoll) or PickupFromCutoffs | delivery-promise (DepartureView), order-sourcing (NetworkGraphView) |
DepartureCapacityChanged | com.retailnetwork.logistics.linehaul-transportation.departure.DepartureCapacityChanged | departureId, capacityPackages, bookedPackages, remainingPackages | BookCapacity (policy BookOnLock), ReleaseCapacity (only in the rebooking of a cancelled departure) | delivery-promise, order-sourcing |
DepartureCancelled | com.retailnetwork.logistics.linehaul-transportation.departure.DepartureCancelled | departureId, reason, cancelledAt | CancelDeparture (planner, or PickupFromCutoffs on NodeSuspended / NodeRetired) | delivery-promise (RepromiseOnRisk), order-sourcing |
DepartureDeparted | com.retailnetwork.logistics.linehaul-transportation.departure.DepartureDeparted | departureId, departedAt | RecordDeparture | analytics only |
DepartureArrived | com.retailnetwork.logistics.linehaul-transportation.departure.DepartureArrived | departureId, arrivedAt | RecordArrival | analytics only |
Load events (key loadId)
| Event | Full type | data fields | Producing command / use case | Consumers |
|---|---|---|---|---|
LoadClosed | com.retailnetwork.logistics.linehaul-transportation.load.LoadClosed | loadId, departureId, packageCount | CloseLoad | analytics only |
LoadDeparted | com.retailnetwork.logistics.linehaul-transportation.load.LoadDeparted | loadId, departureId, originNodeId, trackingNumbers, departedAt, departureKind, nodeType (the type of the origin node; policy NodeTypeSnapshot) | DispatchLoad | shipping-and-tracking (journey scans, HandoverOnFirstScan) |
LoadArrived | com.retailnetwork.logistics.linehaul-transportation.load.LoadArrived | loadId, departureId, destinationNodeId, trackingNumbers, arrivedAt, departureKind, nodeType (the type of the destination node; policy NodeTypeSnapshot) | ReceiveLoad | shipping-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.
| Producer | Full type | What this context does with it | Idempotency beyond the inbox |
|---|---|---|---|
node-topology | com.retailnetwork.logistics.node-topology.node.NodeRegistered | Inserts the node (type, operator, vendor, region, time zone) into NodeProfileView | Upsert on nodeId |
node-topology | com.retailnetwork.logistics.node-topology.node.NodeOperationalProfileDeclared | Stores 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-topology | com.retailnetwork.logistics.node-topology.node.NodeActivated | Marks the node ACTIVE in NodeProfileView (no further reaction is named in the model) | Status overwrite |
node-topology | com.retailnetwork.logistics.node-topology.node.NodeSuspended | Marks the node SUSPENDED; PickupFromCutoffs cancels its future pickups (CancelDeparture) | A departure already CANCELLED is skipped |
node-topology | com.retailnetwork.logistics.node-topology.node.NodeRetired | Marks the node RETIRED; PickupFromCutoffs cancels its future pickups | As above |
node-topology | com.retailnetwork.logistics.node-topology.lane.LaneOpened | Inserts the lane (origin, destination, mode, nominal transit) into LaneView as OPEN | Upsert on laneId |
node-topology | com.retailnetwork.logistics.node-topology.lane.LaneClosed | Marks the lane CLOSED; later ScheduleDeparture on it fails with ErrLaneClosed | Status overwrite |
order-sourcing | com.retailnetwork.commerce.order-sourcing.assignment.FulfillmentReleasedToNode | Records the assignment, node and pickupDepartureId in ExpectedVolumeView | Upsert on (assignmentId, releaseNo) |
order-sourcing | com.retailnetwork.commerce.order-sourcing.assignment.FulfillmentReassigned | Updates 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-sourcing | com.retailnetwork.commerce.order-sourcing.assignment.FulfillmentLocked | BookOnLock: 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 ignored | One booking per assignmentId; a follower lock before or after the carrier's gives the same result |
order-sourcing | com.retailnetwork.commerce.order-sourcing.assignment.FulfillmentCancelled | Updates 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-tracking | com.retailnetwork.logistics.shipping-and-tracking.label.LabelIssued | Adds trackingNumber and packageNo to the assignment in ExpectedVolumeView | Upsert on labelRef |
Derived from: model.yaml → contexts[linehaul-transportation].consumes,
.policies, .read_models, and the producers' publishes[*].data.
Notes and gaps
FulfillmentReassignedandFulfillmentCancelledare raised byorder-sourcingonly beforeLOCKED(ErrAssignmentLocked,ErrCancelAfterLockon its side), whileBookOnLockbooks only onFulfillmentLocked. The release branch was therefore removed (gap G15, ADR 0002 A16, A28): both events updateExpectedVolumeViewonly. Iforder-sourcingever cancels after the lock, the capacity stays booked until the departure leaves (reported model gap).DepartureCapacityChangedcarriescapacityPackages, 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.