ADR 0004: CloudEvents envelope and type catalogue
Status
Accepted (2026-10-17).
Context
Every Kafka message in the fleet is a CloudEvents 1.0 event in structured mode
(fleet rule .claude/rules/fleet/cloudevents.md, warehouse-docs
docs/strategic-design/event-standard-cloudevents.md). This ADR is the
catalogue of every type pick-face-replenishment publishes or consumes;
TestEventCatalogueMatchesContract checks it against apis/asyncapi.yaml.
Decision
Envelope
specversion1.0;ida UUID persisted with the outbox row (stable across relay retries; consumers dedupe on it);source/warehouse/pick-face-replenishment;subjectthe request id (repl-<uuid>), or<site_id>/<sku>for the policy event;timethe occurred-at instant in UTC;datacontenttypeapplication/json;dataschemaurn:warehouse:pick-face-replenishment:<events|analytics>:<EventName>:v1.- Kafka value = the JSON event format; header
content-type: application/cloudevents+json; charset=UTF-8; Kafka key = the subject, so all events of one request stay ordered on one partition. datais snake_case; optional fields are omitted when unset; timestamps are RFC 3339 UTC.- Built and decoded only through
internal/adapters/kafka/cloudevents.
Published
<entity> is the raising aggregate, lowercase, no separators: replenishment
or policy. The stream column says where the type goes:
events is warehouse.pick-face-replenishment.events, analytics is
warehouse.pick-face-replenishment.analytics.
| type | stream | raised when | data |
|---|---|---|---|
com.warehouse.wms.pick-face-replenishment.replenishment.ReplenishmentRequested | (events + analytics) | detection (or a manual request) opens a request | {request_id, site_id, sku, forward_bin, source_bin, quantity, priority, policy_min, policy_max, requested_at} |
com.warehouse.wms.pick-face-replenishment.replenishment.ReplenishmentCompleted | (events + analytics) | a matching StockRelocated closes the request | {request_id, site_id, sku, forward_bin, source_bin, quantity, completed_at} |
com.warehouse.wms.pick-face-replenishment.replenishment.ReplenishmentCancelled | (events + analytics) | an open request is cancelled | {request_id, site_id, sku, reason, cancelled_at} |
com.warehouse.wms.pick-face-replenishment.policy.ReplenishmentPolicyDeclared | (analytics) | a min/max policy is declared or changed | {site_id, sku, min_qty, max_qty, multiple, version, declared_at} |
Payload rules:
priorityisNORMALorURGENT;URGENTwhenon_hand - reserved <= 0at detection.policy_minandpolicy_maxare the policy values the request was sized with.ReplenishmentCompleted.quantityis whatStockRelocatedmoved, which can be less than the requested quantity.ReplenishmentCancelled.reasonisOPERATOR,ASSIGNMENT_CHANGEDorPOLICY_REMOVED.ReplenishmentPolicyDeclaredis key and subject<site_id>/<sku>; removing a policy raises no event of its own (its open requests are cancelled withPOLICY_REMOVED).- Analytics copies carry the same
typeand the sameidper occurrence, withdataschemaurn:warehouse:pick-face-replenishment:analytics:<EventName>:v1. - A breaking payload change is a new
.v2type and dataschema, never a mutation of v1.
Consumed (ADR 0003)
| type | topic | consumer group env |
|---|---|---|
com.warehouse.wms.inventory-storage.stock.BinStockLevelChanged | warehouse.inventory.events | INVENTORY_CONSUMER_GROUP |
com.warehouse.wms.inventory-storage.stock.StockRelocated | warehouse.inventory.events | INVENTORY_CONSUMER_GROUP |
com.warehouse.wms.slotting-optimization.slotplan.SlotPlanApproved | warehouse.slotting-optimization.events | SLOTTING_CONSUMER_GROUP |
com.warehouse.wms.facility-layout.zone.ZoneRegistered | warehouse.facility.events | LAYOUT_CONSUMER_GROUP |
com.warehouse.wms.facility-layout.locationslot.LocationSlotRegistered | warehouse.facility.events | LAYOUT_CONSUMER_GROUP |
com.warehouse.wms.facility-layout.locationslot.LocationSlotDecommissioned | warehouse.facility.events | LAYOUT_CONSUMER_GROUP |
Every other type on those topics is ignored. A message that is not a valid CloudEvent is logged and skipped, never retried forever.
Consequences
- Consumers need nothing but this catalogue and
apis/asyncapi.yaml; there is no shared Go code. ReplenishmentRequestedis the only type that asks the floor to do something; wes-work-planning turns it intoREPLENISHwork (a planned edge, ADR 0001).BinStockLevelChangedis pinned consumer-first: inventory-storage does not publish it yet (producer change P1), andREPLENISHMENTas aStockRelocatedreason arrives with producer change P4.
Amendment 1: the analytics stream has a reader (ADR 0008)
The published catalogue above is unchanged. The analytics stream is consumed by
this service's own cmd/pfr-projector (ADR 0008),
so the consumed catalogue gains these lines (the same four types as the
published table, read from the analytics stream; dataschema
urn:warehouse:pick-face-replenishment:analytics:<EventName>:v1):
| type | topic | consumer group env |
|---|---|---|
com.warehouse.wms.pick-face-replenishment.replenishment.ReplenishmentRequested | warehouse.pick-face-replenishment.analytics | ANALYTICS_CONSUMER_GROUP |
com.warehouse.wms.pick-face-replenishment.replenishment.ReplenishmentCompleted | warehouse.pick-face-replenishment.analytics | ANALYTICS_CONSUMER_GROUP |
com.warehouse.wms.pick-face-replenishment.replenishment.ReplenishmentCancelled | warehouse.pick-face-replenishment.analytics | ANALYTICS_CONSUMER_GROUP |
com.warehouse.wms.pick-face-replenishment.policy.ReplenishmentPolicyDeclared | warehouse.pick-face-replenishment.analytics | ANALYTICS_CONSUMER_GROUP |
Its dead-letter topic is warehouse.pick-face-replenishment.analytics.dlq. The
analytics stream is not an integration contract: no other context consumes it.
Addendum 2026-11-13: current state
The edge to wes-work-planning is no longer planned: wes-work-planning consumes ReplenishmentRequested and ReplenishmentCancelled (internal/adapters/inbound/kafka/replenishment_consumer.go, its ADR 0042). inventory-storage publishes BinStockLevelChanged (its ADR 0040, producer change P1) and sets reason REPLENISHMENT on StockRelocated for a completed REPLENISH task (its ADR 0041, producer change P4). The published catalogue above is unchanged.