Skip to main content

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​

CounterpartDirectionChannelRelationship
node-topologyinbound eventsKafka retailnetwork.node-topology.eventsConformist: offer-availability adopts the producer's model of node status
vendor-connectivityinbound commandREST POST /inventory-feedsCustomer/Supplier: vendor-connectivity supplies feeds, owns the Submission, the 202 to the vendor, rate limits and the vendor-owns-node check
network merchandisinginbound commandsREST /catalog-items, /listingsUI
shopper / storefrontinbound queriesREST GET /catalog, GET /catalog/{catalogItemId}Open Host Service
delivery-promise, order-sourcing, vendor-connectivity, shipping-and-tracking, node-performanceoutbound eventsKafka retailnetwork.offer-availability.eventspublished 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):

TypeFields readEffect
...node.NodeRegisterednodeId (+ CloudEvents time)NodeStatusView row PROPOSED if unknown, else no-op
...node.NodeActivatednodeId, activatedAtstatus ACTIVE, then RestoreListing for listings suppressed for NODE_NOT_SELLABLE
...node.NodeSuspendednodeId, suspendedAt (reason is not stored)status SUSPENDED, then SuppressListing for every LIVE listing
...node.NodeRetirednodeId, retiredAtstatus 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 id of each consumed message is inserted into processed_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; proposed offer-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_events in 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_calls is 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 in internal/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.

CounterpartDirectionChannelRelationship
seller-inboundinbound eventsKafka retailnetwork.seller-inbound.eventsConformist: offer-availability adopts the producer's model of seller status
TypeFields readEffect
com.retailnetwork.partner.seller-inbound.seller.SellerSuspendedsellerId, 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.SellerReinstatedsellerId, reinstatedAtSellerStatusView 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 by CreateListing (rule 7) and by the node restore path (rule 6). An event older than as_of is ignored; an unknown seller is ACTIVE.
  • Every other type on the topic is acknowledged and counted (availability.seller_events.ignored), never applied. A seller type that cannot be decoded, or lacks sellerId or its instant, goes to retailnetwork.seller-inbound.events.dlq.
  • Inbox and transaction. The same processed_events inbox, in one transaction with the view and the listing changes.
  • Consumer group. Mandatory: SELLER_INBOUND_CONSUMER_GROUP (chart value config.sellerInboundConsumerGroup; proposed offer-availability-seller-inbound). A missing value is a boot error naming the variable.
  • InboundShipmentReceived is 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.

TypeFields readEffect
com.retailnetwork.partner.seller-inbound.inboundshipment.InboundShipmentReceivedsellerId, 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, counted availability.seller_events.ignored with reason=received_unknown; the id still lands in processed_events.
  • Unresolvable lines are skipped with a WARN and counted (gtin_unresolved, item_unknown), never errors. A payload that does not decode or lacks sellerId/nodeId goes to retailnetwork.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.events is also read by seller-inbound, pricing, product-content, product-discovery and shopping-cart (their inbound Kafka handlers at origin/develop); the per-type list is in docs/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.