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.

The network's envelope rules are on Event standard (CloudEvents) and ADR 0007.

Envelope​

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

AttributeValue for this context
specversion1.0
ida UUID minted once per event and stored in the outbox row, so a re-delivery carries the same id
source/retailnetwork/order-sourcing
typecom.retailnetwork.commerce.order-sourcing.assignment.<EventName> (tier commerce; entity assignment for every event except SourcingPolicyPublished, whose entity is policy)
subjectthe assignmentId
timewhen the transition happened, UTC
datacontenttypeapplication/json
dataschemaurn:retailnetwork:order-sourcing:events:<EventName>:v1 (stream segment analytics for an analytics-only event)
Kafka topicretailnetwork.order-sourcing.events; retailnetwork.order-sourcing.analytics for an analytics-only event
Kafka keythe assignmentId, so one assignment's events stay in order on one partition

Every event leaves through the transactional outbox, written in the same transaction as the aggregate. An event marked "analytics only" below goes ONLY to retailnetwork.order-sourcing.analytics (never to the events topic) and has no domain consumer; a sibling cannot consume it. The three consolidation events and the policy event were added by wave 2.

Published​

EventFull typeProducing commandConsumers
FulfillmentQueuedcom.retailnetwork.commerce.order-sourcing.assignment.FulfillmentQueuedQueueAssignmentanalytics only
FulfillmentReleasedToNodecom.retailnetwork.commerce.order-sourcing.assignment.FulfillmentReleasedToNodeReleaseToNodevendor-connectivity, linehaul-transportation, seller-inbound, customer-returns
FulfillmentReleaseWithdrawncom.retailnetwork.commerce.order-sourcing.assignment.FulfillmentReleaseWithdrawnRequeue (a merge dissolved by a promise revision)vendor-connectivity
FulfillmentReassignedcom.retailnetwork.commerce.order-sourcing.assignment.FulfillmentReassignedReoptimiseAssignment, HandleNodeRefusal (node changed), Requeue (node changed)linehaul-transportation
FulfillmentLockedcom.retailnetwork.commerce.order-sourcing.assignment.FulfillmentLockedLockAssignmentdelivery-promise, customer-ordering, linehaul-transportation, customer-returns
FulfillmentShippedcom.retailnetwork.commerce.order-sourcing.assignment.FulfillmentShippedMarkShippedcustomer-ordering
FulfillmentDeliveredcom.retailnetwork.commerce.order-sourcing.assignment.FulfillmentDeliveredMarkDeliveredanalytics only
FulfillmentUnsourceablecom.retailnetwork.commerce.order-sourcing.assignment.FulfillmentUnsourceableReleaseToNode, HandleNodeRefusal (no candidate left)delivery-promise, customer-ordering
FulfillmentCancelledcom.retailnetwork.commerce.order-sourcing.assignment.FulfillmentCancelledCancelAssignmentvendor-connectivity, linehaul-transportation, customer-ordering, seller-inbound
FulfillmentCancelRefusedcom.retailnetwork.commerce.order-sourcing.assignment.FulfillmentCancelRefusedRefuseCancelcustomer-ordering
FulfillmentConstraintRevisedcom.retailnetwork.commerce.order-sourcing.assignment.FulfillmentConstraintRevisedApplyRevisedPromise (every non-terminal state, always)analytics only
FulfillmentSourcingDecidedcom.retailnetwork.commerce.order-sourcing.assignment.FulfillmentSourcingDecidedReleaseToNodeanalytics only (read by this context's own projector, service ADR 0013)
AssignmentsConsolidatedcom.retailnetwork.commerce.order-sourcing.assignment.AssignmentsConsolidatedReleaseConsolidatedanalytics only
AssignmentsDeconsolidatedcom.retailnetwork.commerce.order-sourcing.assignment.AssignmentsDeconsolidatedHandleNodeRefusal (a merged carrier refused), Requeueanalytics only
SourcingPolicyPublishedcom.retailnetwork.commerce.order-sourcing.policy.SourcingPolicyPublishedPublishSourcingPolicyanalytics only

The field lists below are the model's publishes[*].data, in order. Types are the proposed JSON types; the model gives names only.

FulfillmentQueued​

FieldTypeMeaning
assignmentIdstringThe new assignment
orderIdstringThe customer order
groupNointegerThe shipment group within the order
promiseIdstringThe promise this assignment must keep
deliverByLatestdate-timeThe binding deadline
linesarrayThe group's lines as received in CustomerOrderPlaced (lineNo, catalogItemId, quantity); no listingId yet, because no node is chosen

FulfillmentReleasedToNode​

FieldTypeMeaning
assignmentIdstringThe assignment
releaseNointeger1 for the first release, +1 for each later one; with assignmentId it is the purchase order's idempotency key
orderIdstringThe customer order
groupNointegerThe shipment group
nodeIdstringThe vendor node released to
pickupDepartureIdstringThe pickup departure the group must make
requiredShipBydate-timeThat departure's cutoff at this node
promisedDeliverByLatestdate-timeThe promise's deliverByLatest
tierstringSAME_DAY, NEXT_DAY, TWO_DAY or STANDARD: the FULFILMENT CLASS. A CONSOLIDATED group is released as STANDARD, so the fifth tier never reaches the vendor or linehaul
estimatedCostCentsintegerOptional; omitted when the estimate is incomplete (service ADR 0011)
policyVersionintegerOptional; the sourcing policy version the search read, present only when version 1 or more was in force (service ADR 0014)
effectiveCostCentsintegerOptional; the estimate plus the cross-region surcharge, present only when the surcharge changed the cost (service ADR 0014)
estimatedCo2eGramsintegerOptional; the carbon estimate of the released path in planner-declared grams of CO2e, omitted when the estimate is incomplete (service ADR 0017). Recorded only: the ranking never reads it
emissionCompletebooleanOptional; every emission component of the path was declared. Omitted exactly when estimatedCo2eGrams is omitted
linesarray of {catalogItemId, listingId, quantity, ownerRef?, assignmentId?}The whole group (fill-or-kill); listingId is this node's listing; ownerRef is the owner OwnerChoice picked, omitted when operator-owned (service ADR 0012). For a merged release the union of the members' lines in member order, each line naming its own assignmentId
membersarray of {assignmentId, orderId, groupNo, promiseId}Optional; present only on a merged release: the carrier first, then ascending assignmentId. Absent means a single-group release (service ADR 0015)

No ship-to data: the release carries no PII (ADR 0006).

FulfillmentReassigned​

FieldTypeMeaning
assignmentIdstringThe assignment
fromNodeIdstringThe node it leaves (the refusing node, or the previous best candidate)
toNodeIdstringThe new candidate node
reasonstringWhy it moved: REOPTIMISED, RELEASE_RECHECK, PURCHASE_ORDER_REJECTED, PURCHASE_ORDER_EXPIRED, PROMISE_REVISED or CONSOLIDATION_WITHDRAWN (a member of a dissolved merge, re-searched, landed on another node)
assignmentVersionintegerThe version after the change, so consumers can drop stale copies

FulfillmentLocked​

FieldTypeMeaning
assignmentIdstringThe assignment
orderIdstringThe customer order
groupNointegerThe shipment group
nodeIdstringThe node that accepted
pickupDepartureIdstringThe pickup departure the package will make
lockedAtdate-timeWhen the acceptance was applied
lockReasonstringWhy it locked; the only trigger the model names is PurchaseOrderAccepted
consolidatedIntostringOptional; the carrier a FOLLOWER of a merged release locks with. Omitted unless the assignment is a follower (service ADR 0015)
mergedAssignmentIdsarray of stringOptional; every merged assignment id, carrier included, ascending. Omitted when the assignment is not merged. A merge has one FulfillmentLocked per member

FulfillmentShipped​

FieldTypeMeaning
assignmentIdstringThe assignment
orderIdstringThe customer order
groupNointegerThe shipment group
nodeIdstringThe shipping node
trackingNumbersarray of stringOne per package
shippedAtdate-timeFrom VendorShipmentConfirmed

FulfillmentDelivered​

FieldTypeMeaning
assignmentIdstringThe assignment
orderIdstringThe customer order
groupNointegerThe shipment group
deliveredAtdate-timeFrom PackageDelivered

FulfillmentUnsourceable​

FieldTypeMeaning
assignmentIdstringThe assignment
orderIdstringThe customer order
groupNointegerThe shipment group
promiseIdstringThe promise to revise
excludedNodesarray of {nodeId, reason}Every node that refused, so the re-promise can avoid them
reasonstringWhy no candidate is left; values are not enumerated in the model

FulfillmentCancelled​

FieldTypeMeaning
assignmentIdstringThe assignment
orderIdstringThe customer order
groupNointegerThe shipment group
reasonstringFrom CustomerOrderCancelled.reason

FulfillmentCancelRefused​

FieldTypeMeaning
assignmentIdstringThe assignment
orderIdstringThe customer order
groupNointegerThe shipment group
reasonstringCANCEL_AFTER_LOCK (the cancel arrived after the lock) or CANCEL_WHILE_MERGED (the group is a member of a live merge that has not locked yet; the cancel can be retried)

FulfillmentReleaseWithdrawn​

Subject and key: the carrier's assignmentId. Raised when a promise revision dissolves a merged release; vendor-connectivity cancels the issued purchase order of that releaseNo.

FieldTypeMeaning
assignmentIdstringThe carrier
releaseNointegerThe withdrawn release
orderIdstringThe carrier's order
groupNointegerThe carrier's group
reasonstringPROMISE_REVISED only: a cancel of a merged member is refused, not withdrawn
withdrawnAtdate-timeWhen the release was taken back

AssignmentsConsolidated​

Analytics only. Raised when a release carries followers.

FieldTypeMeaning
carrierAssignmentIdstringThe carrier
releaseNointegerThe merged release
nodeIdstringThe node released to
memberCountintegerCarrier plus followers
unitsintegerThe sum of every member's line quantities
membersarrayassignmentId, orderId, groupNo, promiseId, units per member
consolidatedAtdate-timeWhen the merge was released

AssignmentsDeconsolidated​

Analytics only. Raised when a merge ends before the lock.

FieldTypeMeaning
carrierAssignmentIdstringThe carrier
releaseNointegerThe dissolved release
reasonstringPROMISE_REVISED, PURCHASE_ORDER_REJECTED or PURCHASE_ORDER_EXPIRED
triggerAssignmentIdstringOptional; the member whose promise revision broke the merged delivery; omitted for a purchase order refusal
memberAssignmentIdsarray of stringEvery member
deconsolidatedAtdate-timeWhen the merge was dissolved

SourcingPolicyPublished​

Analytics only. Subject and Kafka key policy, entity policy. Raised in the same transaction as the save of version n + 1.

FieldTypeMeaning
versionintegerThe published version
crossRegionSurchargeCentsinteger0 to 100000
maxCostDeviationPercentinteger0 to 200
consolidationMaxAssignmentsintegerOptional; 0 to 10, 0 and 1 mean consolidation is off
publishedAtdate-timeWhen it was published

Example envelope​

The most important event: the release that becomes a purchase order.

{
"specversion": "1.0",
"id": "0c9f7a52-6a1e-4b8e-9d3f-2f6b1f0e8a41",
"source": "/retailnetwork/order-sourcing",
"type": "com.retailnetwork.commerce.order-sourcing.assignment.FulfillmentReleasedToNode",
"subject": "asg-7f3c2d10",
"time": "2026-10-22T14:05:00Z",
"datacontenttype": "application/json",
"dataschema": "urn:retailnetwork:order-sourcing:events:FulfillmentReleasedToNode:v1",
"data": {
"assignmentId": "asg-7f3c2d10",
"releaseNo": 1,
"orderId": "ord-51a0c9",
"groupNo": 1,
"nodeId": "node-fc-ws-sor-01",
"pickupDepartureId": "dep-pk-20261022-1800-fc-ws-sor-01",
"requiredShipBy": "2026-10-22T21:00:00Z",
"promisedDeliverByLatest": "2026-10-24T23:00:00Z",
"tier": "TWO_DAY",
"lines": [
{"catalogItemId": "cat-000123", "listingId": "lst-000123-fc-ws-sor-01", "quantity": 2},
{"catalogItemId": "cat-000987", "listingId": "lst-000987-fc-ws-sor-01", "quantity": 1}
]
}
}

The identifiers are illustrative; the model fixes no id format.

Consumed​

Every consumer is idempotent on the CloudEvents id through the inbox table processed_events, written in the same transaction as the change it causes, and dispatches on the full type string, never on a suffix. Domain-level idempotency comes on top, per row below.

Events that drive the aggregate​

ProducerEventFull typeFields usedWhat this context doesDomain idempotency
customer-orderingCustomerOrderPlacedcom.retailnetwork.commerce.customer-ordering.customerorder.CustomerOrderPlacedorderId, destinationPostalPrefix, optional consolidationKey, groups(groupNo, promiseId, tier (five values, CONSOLIDATED included), witnessNodeId, optional deliverByEarliest, deliverByLatest, lines(lineNo, catalogItemId, quantity))QueueAssignment per group; SAME_DAY groups go straight to ReleaseToNodeone assignment per (orderId, groupNo); a repeat finds it and does nothing
customer-orderingCustomerOrderCancelledcom.retailnetwork.commerce.customer-ordering.customerorder.CustomerOrderCancelledorderId, groupNos, reasonCancelAssignment for each listed groupan already CANCELLED assignment is left as is
delivery-promisePromiseRevisedcom.retailnetwork.commerce.delivery-promise.promise.PromiseRevisedpromiseId, revisionNo, optional deliverByEarliest, deliverByLatest, nodeId (new witness)ApplyRevisedPromise on the assignment of that promise, in every non-terminal state (ADR 0002 A9)always raises FulfillmentConstraintRevised; an UNSOURCEABLE group is re-queued when a candidate exists; from RELEASED, where a revised window that excludes the merged eta dissolves a consolidation merge (PROMISE_REVISED); a lower or equal revisionNo than the last applied is ignored
vendor-connectivityPurchaseOrderAcceptedcom.retailnetwork.partner.vendor-connectivity.purchaseorder.PurchaseOrderAcceptedassignmentId, releaseNo, nodeId, acceptedAtLockAssignment (LockOnCommit)only if releaseNo is the current PENDING release; a repeat on a LOCKED assignment is a no-op
vendor-connectivityPurchaseOrderRejectedcom.retailnetwork.partner.vendor-connectivity.purchaseorder.PurchaseOrderRejectedassignmentId, releaseNo, nodeId, reasonCode, rejectedAtHandleNodeRefusal with outcome REJECTED (ReassignOnRefusal)only for the current PENDING release; an older releaseNo is ignored
vendor-connectivityPurchaseOrderExpiredcom.retailnetwork.partner.vendor-connectivity.purchaseorder.PurchaseOrderExpiredassignmentId, releaseNo, nodeId, ackByHandleNodeRefusal with outcome EXPIREDas above
vendor-connectivityVendorShipmentConfirmedcom.retailnetwork.partner.vendor-connectivity.purchaseorder.VendorShipmentConfirmedassignmentId, nodeId, trackingNumbers, shippedAtMarkShippeda repeat on a SHIPPED assignment is a no-op
shipping-and-trackingPackageDeliveredcom.retailnetwork.logistics.shipping-and-tracking.journey.PackageDeliveredassignmentId, trackingNumber, deliveredAtMarkDelivereda repeat on a DELIVERED assignment is a no-op; multi-package rule is an open question

Events that feed read models​

ProducerEvents (full type)Read modelIdempotency
delivery-promisecom.retailnetwork.commerce.delivery-promise.promisebook.PromiseBookExhaustedPromiseBookPressureView (bookId, nodeId, pickupDepartureId, share)upsert by bookId
node-topologycom.retailnetwork.logistics.node-topology.node.NodeRegistered, com.retailnetwork.logistics.node-topology.node.NodeOperationalProfileDeclared, com.retailnetwork.logistics.node-topology.node.NodeActivated, com.retailnetwork.logistics.node-topology.node.NodeSuspended, com.retailnetwork.logistics.node-topology.node.NodeRetiredNodeProfileViewupsert by nodeId; a profile with a lower profileRevision is ignored
node-topologycom.retailnetwork.logistics.node-topology.lane.LaneOpened, com.retailnetwork.logistics.node-topology.lane.LaneClosed, com.retailnetwork.logistics.node-topology.lane.LaneEmissionDeclared, com.retailnetwork.logistics.node-topology.servicearea.ServiceAreaAssigned, com.retailnetwork.logistics.node-topology.region.RegionDefinedNetworkGraphViewupsert by laneId, postalPrefix (newer assignmentVersion wins), regionId
linehaul-transportationcom.retailnetwork.logistics.linehaul-transportation.departure.DepartureScheduled, com.retailnetwork.logistics.linehaul-transportation.departure.DepartureCapacityChanged, com.retailnetwork.logistics.linehaul-transportation.departure.DepartureCancelledNetworkGraphViewupsert by departureId
last-mile-deliverycom.retailnetwork.logistics.last-mile-delivery.wave.DeliveryWaveScheduled, com.retailnetwork.logistics.last-mile-delivery.wave.DeliveryWaveCapacityChanged, com.retailnetwork.logistics.last-mile-delivery.wave.WaveEmissionDeclaredNetworkGraphViewupsert by waveId; a declared emission is kept by the newer declaredAt, also for a wave not known yet
offer-availabilitycom.retailnetwork.commerce.offer-availability.listing.ListingCreated, com.retailnetwork.commerce.offer-availability.listing.ListingAvailabilityChanged, com.retailnetwork.commerce.offer-availability.listing.ListingSuppressed, com.retailnetwork.commerce.offer-availability.listing.ListingRestored, com.retailnetwork.commerce.offer-availability.catalogitem.CatalogItemDiscontinuedAvailabilityViewupsert by listingId / catalogItemId; an availability with an older asOf is ignored
node-performancecom.retailnetwork.partner.node-performance.scorecard.NodeScorecardUpdatedScorecardViewupsert by (nodeId, window); an older computedAt is ignored

A read-model change does not itself move an assignment. Queued assignments pick it up at the next re-optimisation sweep (ReoptimiseAssignment).

Derived from: model.yaml → contexts[order-sourcing].publishes, .consumes, .read_models, .policies; the producers' publishes[*].data; conventions.cloudevents, conventions.integration_rules.