ADR 0004: CloudEvents envelope and type catalogue
Status
Accepted (2026-10-23).
Context
Every Kafka message in the retail network is a CloudEvents 1.0 event in structured mode (retail-network-docs model/model.yaml conventions.cloudevents; the repo rule .claude/rules/fleet/cloudevents.md). This ADR is the catalogue of every type delivery-promise publishes. TestEventCatalogueMatchesContract checks it against apis/asyncapi.yaml. The types delivery-promise only consumes are listed in ADR 0003; the ones added after the first release are also named at the end of this ADR.
Decision
Envelope
specversion1.0;ida UUID persisted with the outbox row (stable across relay retries; consumers dedupe on it);source/retailnetwork/delivery-promise;subjectthe aggregate root id (promiseId,bookId,offerIdorpolicyVersion);timethe instant the change was committed, in UTC;datacontenttypeapplication/json;dataschemaurn:retailnetwork:delivery-promise:<stream>:<EventName>:v1where<stream>iseventsoranalytics.- Kafka value = the JSON event format; header
content-type: application/cloudevents+json; charset=UTF-8; Kafka key = the subject, so all events of one aggregate stay ordered on one partition. datais camelCase; optional fields are omitted when unset (never null); arrays are always present; timestamps are RFC 3339 UTC.- Built and decoded only through
internal/adapters/kafka/cloudevents. <entity>is the raising aggregate, lowercase, no separators:promise,promisebook,deliveryoffer,promisepolicy; the one non-aggregate fact,DeliveryRequestAnswered(ADR 0032), usesdeliveryrequestand its subject is a freshrequestId. Tier iscommerce.
Published types
Integration events (stream: events) go ONLY to retailnetwork.delivery-promise.events; analytics-only events (stream: analytics) go ONLY to retailnetwork.delivery-promise.analytics.
type: com.retailnetwork.commerce.delivery-promise.promise.PromiseMade stream: analytics
type: com.retailnetwork.commerce.delivery-promise.promise.PromiseConfirmed stream: analytics
type: com.retailnetwork.commerce.delivery-promise.promise.PromiseAtRisk stream: events
type: com.retailnetwork.commerce.delivery-promise.promise.PromiseRevised stream: events
type: com.retailnetwork.commerce.delivery-promise.promise.PromiseKept stream: events
type: com.retailnetwork.commerce.delivery-promise.promise.PromiseBroken stream: events
type: com.retailnetwork.commerce.delivery-promise.promise.PromiseReleased stream: analytics
type: com.retailnetwork.commerce.delivery-promise.promise.PromiseCancelled stream: analytics
type: com.retailnetwork.commerce.delivery-promise.promise.PromiseUnkeepable stream: events
type: com.retailnetwork.commerce.delivery-promise.promisebook.PromiseBookExhausted stream: events
type: com.retailnetwork.commerce.delivery-promise.deliveryoffer.DeliveryOfferQuoted stream: analytics
type: com.retailnetwork.commerce.delivery-promise.promisepolicy.PromisePolicyPublished stream: analytics
type: com.retailnetwork.commerce.delivery-promise.deliveryrequest.DeliveryRequestAnswered stream: analytics
| Event | Stream | Subject / key | Raised when | Consumers |
|---|---|---|---|---|
PromiseMade | analytics | promiseId | MakePromise is saved (PROVISIONAL, capacity held) | analytics only |
PromiseConfirmed | analytics | promiseId | ConfirmPromise is saved (the synchronous confirm of E7, or the reconciling consumer) | analytics only |
PromiseAtRisk | events | promiseId | FlagPromiseAtRisk is saved | customer-ordering |
PromiseRevised | events | promiseId | RevisePromise is saved | customer-ordering, order-sourcing |
PromiseKept | events | promiseId | JudgePromise: delivered on or before deliverByLatest | node-performance, customer-ordering |
PromiseBroken | events | promiseId | JudgePromise: late, lost or returned | node-performance, customer-ordering |
PromiseReleased | analytics | promiseId | ReleaseExpiredHolds released a hold | analytics only |
PromiseCancelled | analytics | promiseId | CancelPromise on CustomerOrderCancelled | analytics only |
PromiseUnkeepable | events | promiseId | RevisePromise found no path at any tier (E9) | customer-ordering |
PromiseBookExhausted | events | bookId | a hold made provisional + confirmed = share | order-sourcing |
DeliveryOfferQuoted | analytics | offerId | QuoteDeliveryOffers persisted an offer (one event per offer) | analytics only |
PromisePolicyPublished | analytics | policyVersion | PublishPromisePolicy is saved (G19) | analytics only |
DeliveryRequestAnswered | analytics | requestId | a quote or an estimate was answered with 200, best effort and only while DELIVERY_REQUEST_FACTS_ENABLED is true (ADR 0032) | analytics only |
Payload rules:
- The
datafield lists are exactly the model'spublishes[].datalists.PromiseUnkeepable(E9),DeliveryOfferQuotedandPromisePolicyPublishedare not in the model; their lists are defined inapis/asyncapi.yaml(ADR 0002, assumptions A19 and A20).pickupDepartureIdis omitted on a NOMINALPromiseMade(contracts-delta E8).deliveredAtis omitted on aPromiseBrokenof cause LOST or RETURNED. PromiseBroken.causeisLATE,LOSTorRETURNED.- A breaking change is a new
.v2type; a consumer ignores unknown fields. - The analytics-only events carry no PII (there is none in this context) and are not read by any integration consumer.
Consumed types added after the first release
These are NOT published by this service; they are listed so the full type string is in the catalogue (the dispatch table and apis/asyncapi.yaml receive operations must match it).
type: com.retailnetwork.partner.node-performance.scorecard.NodeTierEligibilityChanged stream: events
| Event | Stream | Subject / key | Raised when (by the producer) | Effect here |
|---|---|---|---|---|
NodeTierEligibilityChanged | events | <nodeId>:7d | node-performance flips a node's fast-tier eligibility (one event per tier, SAME_DAY and NEXT_DAY) | NodeTierEligibility read model; ineligible nodes are dropped from SAME_DAY and NEXT_DAY candidates (ADR 0022) |
Consequences
TestEventCatalogueMatchesContractfails whenapis/asyncapi.yamldeclares a type this table lacks.- Adding a published event needs: a line above, a message and schema in
apis/asyncapi.yaml, an encoder ininternal/adapters/outbound/kafka, and a golden JSON test.