ADR 0003: consumed contracts, the local node status read model and the relationships of offer-availability
Status
Accepted (2026-10-23). Design source: retail-network-docs model/model.yaml
(inbound, consumes, read_models, policies, sync_calls) and
contracts-delta.md.
Context
offer-availability consumes events from one context, node-topology, calls no
sibling synchronously (sync_calls is empty) and is called by two in-organization
clients. This ADR records the consumed contract, the local read model, the
relationships and the delivery guarantees that follow.
Decision
Relationships
| Counterpart | Direction | Channel | Relationship |
|---|---|---|---|
| node-topology | inbound events | Kafka retailnetwork.node-topology.events | Conformist: offer-availability adopts the producer's model of node status |
| vendor-connectivity | inbound command | REST POST /inventory-feeds | Customer/Supplier: vendor-connectivity supplies feeds, owns the Submission, the 202 to the vendor, rate limits and the vendor-owns-node check |
| network merchandising | inbound commands | REST /catalog-items, /listings | UI |
| shopper / storefront | inbound queries | REST GET /catalog, GET /catalog/{catalogItemId} | Open Host Service |
| delivery-promise, order-sourcing, vendor-connectivity, shipping-and-tracking, node-performance | outbound events | Kafka retailnetwork.offer-availability.events | published language of ADR 0004; they are the Conformists |
GET /listings and GET /inventory-feeds/{feedId} have no caller named by the
model; they are plain reads for merchandising and for vendor-connectivity's
diagnostics.
Consumed events
All four come from node-topology on retailnetwork.node-topology.events (type
prefix com.retailnetwork.logistics.node-topology.node.), keyed by nodeId.
node-topology's own apis/asyncapi.yaml (origin/feature/service) is the
producer contract; offer-availability vendors a tolerant copy of what it reads in
its own apis/asyncapi.yaml (no cross-repo import):
| Type | Fields read | Effect |
|---|---|---|
...node.NodeRegistered | nodeId (+ CloudEvents time) | NodeStatusView row PROPOSED if unknown, else no-op |
...node.NodeActivated | nodeId, activatedAt | status ACTIVE, then RestoreListing for listings suppressed for NODE_NOT_SELLABLE |
...node.NodeSuspended | nodeId, suspendedAt (reason is not stored) | status SUSPENDED, then SuppressListing for every LIVE listing |
...node.NodeRetired | nodeId, retiredAt | status RETIRED, then SuppressListing for every LIVE listing |
Every other field and every other type on the topic is ignored (decoding is
tolerant, unknown types are acknowledged). The consumer dispatches on the full
type string, never on a suffix. A record that cannot be decoded, or whose
nodeId is not a valid id, is sent to the dead-letter topic
retailnetwork.offer-availability.events.dlq with the failure reason in headers
and its offset is committed; it does not block the partition.
Local read model: NodeStatusView
Table node_status_view(node_id, status, status_at, version); written only by the
consumer; read by CreateListing (is the node sellable) and by nothing else. It is
an event-fed copy: the service never calls node-topology (hard rule 4). Ordering
and unknown-node rules are A13 of ADR 0002.
Delivery guarantees
- Inbox. The CloudEvents
idof each consumed message is inserted intoprocessed_events(event_id, event_type, processed_at)in the same transaction as the view update, the listing changes and their outbox rows. A redelivered id is skipped (the transaction is a no-op that commits only if nothing else is new). - Consumer group. Mandatory:
NODE_STATUS_CONSUMER_GROUP(chart value; proposedoffer-availability-node-status). A missing value is a boot error naming the variable. Offsets are committed after the transaction commits. - Outbox. Every published event is appended to
outbox_eventsin the transaction of the aggregate change; an always-on relay drains it to Kafka with an attempt cap (ADR 0004 for the envelope). - No synchronous calls.
sync_callsis empty. The shopper path reads the local database only.
Analytics
None. The model has no analytics-only event for this context.
Consequences
- offer-availability can answer every request while node-topology is down; a node's status can lag its true status by the consumer lag, which A5 and A13 tolerate.
- A new consumed type needs a message in
apis/asyncapi.yaml, a row here and a dispatch entry ininternal/adapters/inbound/kafka. - The per-node policy runs in one transaction, so a node with a very large number of listings produces a correspondingly large transaction (bulk saves keep it to a few statements).
Amendment 2026-11-08: seller-inbound (ADR 0013)
offer-availability now consumes a second context. The relationship and the contract below extend the tables above.
| Counterpart | Direction | Channel | Relationship |
|---|---|---|---|
| seller-inbound | inbound events | Kafka retailnetwork.seller-inbound.events | Conformist: offer-availability adopts the producer's model of seller status |
| Type | Fields read | Effect |
|---|---|---|
com.retailnetwork.partner.seller-inbound.seller.SellerSuspended | sellerId, suspendedAt (reason is not stored) | SellerStatusView SUSPENDED, then SuppressListing(OWNER_SUSPENDED) for every LIVE listing whose ownerRef is the seller |
com.retailnetwork.partner.seller-inbound.seller.SellerReinstated | sellerId, reinstatedAt | SellerStatusView ACTIVE, then every OWNER_SUSPENDED listing of the seller is restored, or handed to its remaining cause |
- Local read model: SellerStatusView. Table
seller_status_view(seller_id, status, as_of, version), written only by the seller consumer; read byCreateListing(rule 7) and by the node restore path (rule 6). An event older thanas_ofis ignored; an unknown seller isACTIVE. - Every other type on the topic is acknowledged and counted
(
availability.seller_events.ignored), never applied. A seller type that cannot be decoded, or lackssellerIdor its instant, goes toretailnetwork.seller-inbound.events.dlq. - Inbox and transaction. The same
processed_eventsinbox, in one transaction with the view and the listing changes. - Consumer group. Mandatory:
SELLER_INBOUND_CONSUMER_GROUP(chart valueconfig.sellerInboundConsumerGroup; proposedoffer-availability-seller-inbound). A missing value is a boot error naming the variable. InboundShipmentReceivedis on the same topic and is NOT consumed yet: its payload carries no received item lines (ADR 0013, "Rule 8 is blocked").
Amendment 2026-11-09: received stock (ADR 0014)
seller-inbound's InboundShipmentReceived now carries the received item lines,
so the seller-inbound consumer applies it (ADR 0013 rule 8). The last bullet of
the 2026-11-08 amendment ("NOT consumed yet") no longer holds.
| Type | Fields read | Effect |
|---|---|---|
com.retailnetwork.partner.seller-inbound.inboundshipment.InboundShipmentReceived | sellerId, nodeId, received[].{catalogItemId?, gtin, qtyEaches} (shipmentId for logs only; status, cartons, receivedAt not read) | For each line with qtyEaches > 0, the item from catalogItemId or else from gtin through the local GTIN/packaging index (ADR 0006); each resolved item without a listing of (item, nodeId, sellerId) gets one (ListingCreated at 0 / UNKNOWN, ListingSuppressed when a cause holds); an existing listing is untouched |
- Absent
received(an event published before seller-inbound's ADR 0014): UNKNOWN, nothing is created, countedavailability.seller_events.ignoredwithreason=received_unknown; the id still lands inprocessed_events. - Unresolvable lines are skipped with a WARN and counted (
gtin_unresolved,item_unknown), never errors. A payload that does not decode or lackssellerId/nodeIdgoes toretailnetwork.seller-inbound.events.dlq. - Same topic, group, inbox and transaction rule as the seller status events: no new consumer group, topic or environment variable.
Addendum 2026-11-13: current state
- The outbound-events row of the Relationships table names five Conformists. On 2026-11-13 the topic
retailnetwork.offer-availability.eventsis also read byseller-inbound,pricing,product-content,product-discoveryandshopping-cart(their inbound Kafka handlers atorigin/develop); the per-type list is indocs/docs/ddd/domain-events.md. - This service also consumes
retailnetwork.seller-inbound.events(internal/adapters/inbound/kafka/seller_consumer.go,received_consumer.go), added by ADR 0013 and ADR 0014.