Domain events
The model view of the events. The wire format, topics, key and payload fields are on the Event catalogue; how a neighbour reacts is on Integration. Event names are past tense, raised by an aggregate command and appended to the outbox in the same transaction (internal/domain/*/events.go, internal/adapters/outbound/kafka/encoder.go).
Source: aggregates internal/domain/{offer,promise,book,policy}; consumers verified in customer-ordering, order-sourcing and node-performance (origin/develop, internal/adapters/inbound/kafka/handlers.go). The analytics events have no consumer and are left out of the arrows.
Published
| Event | Aggregate | Meaning | Raised by | Recipients |
|---|---|---|---|---|
DeliveryOfferQuoted | DeliveryOffer | An offer was persisted with its window and witness, the optional capacityBand of its book at quote time (ADR 0023) and, for a CONSOLIDATED offer, consolidationEligible (ADR 0024). One per offer, so one quote can raise several. | QuoteDeliveryOffers | none (analytics: quote-to-order conversion per tier and node; promise coverage per region from destinationPostalPrefix, deliverByLatest and timeZone, ADR 0030) |
PromiseMade | Promise | A provisional promise holds capacity; the offer is consumed. A CONSOLIDATED promise also carries consolidationEligible (ADR 0024). | MakePromise | none (analytics) |
PromiseConfirmed | Promise | The order was placed; the hold became confirmed. A repeated confirm raises nothing. | ConfirmPromise | none (analytics) |
PromiseReleased | Promise | A provisional promise's hold expired and was returned (reason: HOLD_EXPIRED). | ReleaseExpiredHolds | none (analytics: hold leakage) |
PromiseCancelled | Promise | A confirmed or at-risk promise was cancelled and its confirmed hold returned. | CancelPromise, OnCustomerOrderCancelled | none (analytics) |
PromiseAtRisk | Promise | The witness path is no longer feasible (reason names why). A signal, not a verdict. | FlagAtRisk in OnDepartureCancelled, OnWaveCancelled, OnBookingFailed, OnBookingMoved, OnPackageExceptionRaised, OnPackageInductionDeferred, OnFulfillmentUnsourceable; also FlagPredictedLate, the clock-driven late-risk sweep, with reason PREDICTED_LATE (ADR 0021) | customer-ordering |
PromiseRevised | Promise | The window moved later because the old path broke; carries the previous latest bound and the new terms, node and reason. | ReviseAtRisk | customer-ordering, order-sourcing |
PromiseUnkeepable | Promise | Re-promising found no path at any tier. At most once per promise. | ReviseAtRisk | customer-ordering |
PromiseKept | Promise | Delivered on or before deliverByLatest. | JudgePromise | customer-ordering, node-performance |
PromiseBroken | Promise | Delivered late, lost or returned, with cause LATE, LOST or RETURNED and minutes late. | JudgePromise | customer-ordering, node-performance |
PromiseBookExhausted | PromiseBook | A hold brought the node's cutoff to its share; later quotes find no room there. | MakePromise | order-sourcing |
PromisePolicyPublished | PromisePolicy | A new immutable policy version is current. | PublishPromisePolicy | none (analytics) |
DeliveryRequestAnswered | none (a best-effort fact, not an aggregate; entity deliveryrequest) | A quote or an estimate was answered with 200, with or without a promise: kind, the destination region (first two characters of the postal prefix only), item count, whether a promise came back and the shortest promised day count. Handed over AFTER the response through a bounded queue, dropped and counted when it is full or the write fails, and raised only while DELIVERY_REQUEST_FACTS_ENABLED=true (ADR 0032). | the REST adapter of QuoteDeliveryOffers and EstimateDeliveries, after the response | none (analytics) |
Every state change of a promise raises exactly one event, with the single exception of the idempotent repeat of a confirm. The state machine is on Aggregate design canvas.
Consumed
Each consumed event updates a read model (never an aggregate directly) or runs a policy. Idempotent on the CloudEvents id.
| Event (producer) | Reaction | Policy or projection |
|---|---|---|
NodeRegistered, NodeOperationalProfileDeclared, NodeActivated, NodeSuspended, NodeRetired (node-topology) | upsert the node and profile; a suspended or retired node leaves the candidate set; NodeActivated / NodeSuspended older than the stored StateAt is dropped and an equal instant applies; RETIRED is terminal: no later status fact revives the node (ADR 0029) | projection rm_nodes |
LaneOpened, LaneClosed, ServiceAreaAssigned, RegionDefined (node-topology) | upsert lane, service area, region | projections |
CatalogItemCreated, CatalogItemDiscontinued, ListingCreated, ListingAvailabilityChanged, ListingSuppressed, ListingRestored (offer-availability) | upsert item and listing; ListingSuppressed / ListingRestored older than the stored SuppressedAt is dropped, an equal instant applies (ADR 0029) | projections |
DepartureScheduled, DepartureCapacityChanged (linehaul) | upsert the departure and its remaining packages; a capacity event older than the stored CapacityAt is dropped, an equal instant applies (ADR 0028) | projection rm_departures |
LoadDeparted, LoadArrived (linehaul) | LoadDeparted opens the load's pairing row and LoadArrived pairs it into one measured-transit observation; LoadArrived also records the arrival of the load's departure (needs a departureId) | projections rm_load_transit_open, rm_transit_actuals (ADR 0014), rm_departure_arrival for the late-risk sweep (ADR 0021) |
DepartureCancelled (linehaul) | mark the departure unscheduled; flag promises whose witness uses it | RepromiseOnRisk |
BookingMoved, BookingFailed (linehaul) | flag promises that rode the booking | RepromiseOnRisk |
DeliveryWaveScheduled, DeliveryWaveCapacityChanged (last-mile) | upsert the wave; a capacity event older than the stored CapacityAt is dropped, an equal instant applies (ADR 0028) | projection rm_waves |
DeliveryWaveCancelled (last-mile) | mark cancelled; flag promises whose witness wave it is | RepromiseOnRisk |
PackageInductionDeferred (last-mile) | flag the promise | RepromiseOnRisk |
NodeScorecardUpdated (node-performance) | upsert the grade when computedAt is not older than the stored one (ADR 0028) | projection rm_scorecards |
NodeTierEligibilityChanged (node-performance) | upsert the (node, tier) fact when changedAt is not older than the stored one; unknown tier or missing field is ignored and counted | projection rm_node_tier_eligibility |
FulfillmentLocked, FulfillmentShipped (order-sourcing) | record the assignment, then the packages; may complete the facts for judging | JudgeOnDelivery |
FulfillmentUnsourceable (order-sourcing) | flag the promise at risk and re-promise excluding the listed nodes | RepromiseOnRisk |
PackageDelivered, PackageLost, PackageReturned (shipping-and-tracking) | record the outcome; judge when complete | JudgeOnDelivery |
PackageExceptionRaised (shipping-and-tracking) | flag the promise at risk | RepromiseOnRisk |
CustomerOrderPlaced (customer-ordering) | confirm each group's promise if still provisional | reconciling ConfirmPromise |
CustomerOrderCancelled (customer-ordering) | cancel the listed groups' promises, or all of them | CancelPromise |
Source: internal/adapters/inbound/kafka/dispatch.go (Handlers), internal/application/usecases/projections.go. A payload that cannot be applied is dead-lettered, never blocks the partition.
Ordering and delivery guarantees
- At-least-once, key = aggregate root id; the relay sends rows in
outbox_events.idorder. - A promise's events share a partition, so a consumer sees
PromiseAtRiskbefore thePromiseRevisedthat follows it. - Producers are not ordered across topics: the read model keeps what it knows, and a late schedule event never undoes a later cancel (
scheduledflag handling inprojections.go). - No event carries personal data: the destination is a postal prefix and ids only.