Skip to main content

ADR 0003: consumed contracts, local read models and relationships

Status​

Accepted (2026-10-23).

Context​

The promise sits on the shopper's critical path and makes NO synchronous call (model sync_calls: []). Every input is a local read model kept from events. The consumed contracts are the producers' CloudEvents; apis/asyncapi.yaml restates, as receive operations, only the fields this service relies on (tolerant decoding: unknown fields and unknown types are ignored).

Decision​

Consumed events (dispatch on the FULL type; consumer group mandatory)​

Producer topicTypes (com.retailnetwork.<tier>.<producer>.<entity>.<Event>)Effect
retailnetwork.node-topology.eventsnode.NodeRegistered, node.NodeOperationalProfileDeclared, node.NodeActivated, node.NodeSuspended, node.NodeRetired, lane.LaneOpened, lane.LaneClosed, servicearea.ServiceAreaAssigned, region.RegionDefinedNodeProfileView, LaneView, RegionAndServiceAreaView
retailnetwork.offer-availability.eventscatalogitem.CatalogItemCreated, catalogitem.CatalogItemDiscontinued, listing.ListingCreated, listing.ListingAvailabilityChanged, listing.ListingSuppressed, listing.ListingRestoredAvailabilityView
retailnetwork.linehaul-transportation.eventsdeparture.DepartureScheduled, departure.DepartureCapacityChanged, departure.DepartureCancelled, departure.BookingMoved, departure.BookingFailed, load.LoadDeparted, load.LoadArrivedDepartureView; RepromiseOnRisk (E13); TransitActuals (ADR 0014)
retailnetwork.last-mile-delivery.eventswave.DeliveryWaveScheduled, wave.DeliveryWaveCapacityChanged, wave.DeliveryWaveCancelled, packageattempthistory.PackageInductionDeferredDeliveryWaveView; RepromiseOnRisk (E5, E15)
retailnetwork.node-performance.eventsscorecard.NodeScorecardUpdated, scorecard.NodeTierEligibilityChangedScorecardView (30d window only, E18); NodeTierEligibility (ADR 0022: SAME_DAY and NEXT_DAY candidates of an ineligible node are removed)
retailnetwork.order-sourcing.eventsassignment.FulfillmentLocked, assignment.FulfillmentShipped, assignment.FulfillmentUnsourceableassignment map and package set (E1); RepromiseOnRisk
retailnetwork.shipping-and-tracking.eventsjourney.PackageDelivered, journey.PackageHandedToCarrier, journey.PackageReadyForCollection, journey.PackageExceptionRaised, journey.PackageLost, journey.PackageReturnedJudgeOnDelivery, RepromiseOnRisk (E6); carrier transit pairing (ADR 0026); pickup promises judged on readiness (ADR 0027)
retailnetwork.customer-ordering.eventscustomerorder.CustomerOrderPlaced, customerorder.CustomerOrderCancelledreconciling ConfirmPromise (E7); CancelPromise (G21)

One consumer reads the eight topics under ONE stable group, DELIVERY_PROMISE_CONSUMER_GROUP (a chart value, never derived from the pod name). A missing group is a boot error naming the variable, raised before the listener binds. A transient failure is retried with capped backoff, then the message goes to <topic>.dlq; a deterministic problem (not a CloudEvent, unknown type, malformed payload) is logged and skipped. Every handler runs in a unit of work that also inserts the CloudEvents id into processed_events (inbox), so a redelivery commits nothing.

Local read models (Postgres tables, rebuilt from events)​

rm_nodes (type, subtype, operator, region, time zone, state, profile revision and profile), rm_lanes, rm_regions, rm_service_areas, rm_catalog_items, rm_listings, rm_departures, rm_waves, rm_scorecards, rm_assignments (assignmentId to promiseId, orderId, groupNo, locked node), rm_shipments (trackingNumber to assignmentId), rm_package_outcomes, rm_load_transit_open, rm_carrier_transit_open and rm_transit_actuals (the measured-transit read model of ADR 0014: one open row per departed load, pairing by arrival into a per (origin, dest) ring of the latest 200 observed transits; since ADR 0026 also one open row per package handed to a carrier, keyed by tracking number, pairing by delivery into the same ring under (handoffNodeID, "area:"+prefix)), rm_node_tier_eligibility (ADR 0022: (node_id, tier) to eligible and changed_at; a missing row is ELIGIBLE) and rm_promise_calibration (ADR 0020: not fed by any event, but by this service's own judgements, in the transaction that records them; per (tier, basis, node grade) a ring of the latest 500 lateBy observations). Version guards make every projection idempotent and order-tolerant: a profileRevision, assignmentVersion or asOf not above the stored value is ignored (A25).

Relationships​

Customer/Supplier with customer-ordering (it calls POST /delivery-quotes, POST /promises, POST /promises/{promiseId}/confirmations and, to compensate a failed multi-group checkout, POST /promises/{promiseId}/cancellations; it consumes PromiseAtRisk, PromiseRevised, PromiseKept, PromiseBroken, PromiseUnkeepable) and with order-sourcing (consumes PromiseRevised, PromiseBookExhausted); node-performance consumes PromiseKept and PromiseBroken. Open Host Service for the storefront (quote). Conformist to node-topology, offer-availability, linehaul-transportation, last-mile-delivery, node-performance and shipping-and-tracking.

Sync calls​

None. No client of a sibling service exists in this repository.

Consequences​

  • A cold or stale read model yields fewer offers, never a false one: fast tiers need every input, only STANDARD falls back to nominal (A1).
  • Every consumed type was re-read against the producers' origin/feature/service AsyncAPI (2026-10-23); the two mismatches found (A26) were fixed on the consuming side. PromiseBroken.cause is LATE, LOST or RETURNED (A18).
  • The receive messages of apis/asyncapi.yaml stay tolerant copies: they list only the fields this service reads.