ADR 0004: CloudEvents envelope and type catalogue
Status
Accepted (2026-10-08). Per-key ordering amended by ADR 0007 (a row excluded by the relay attempt cap is overtaken). The four dockappointment types are retired (ADR 0019) and no longer declared in apis/asyncapi.yaml (ADR 0022); their rows below are kept, marked retired.
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 inbound-receiving publishes or consumes;
TestEventCatalogueMatchesContract checks it against apis/asyncapi.yaml.
Decision
Envelope
specversion1.0;ida UUID minted once per domain event and persisted with the outbox row (stable across relay retries; consumers dedupe on it);source/warehouse/inbound-receiving;subjectthe id of the aggregate instance;timethe occurred-at instant in UTC;datacontenttypeapplication/json;dataschemaurn:warehouse:inbound-receiving:events:<EventName>:v1.- Kafka value = the JSON event format; header
content-type: application/cloudevents+json; charset=UTF-8; message key as in the table below. - Built and decoded only through
internal/adapters/kafka/cloudevents. datais snake_case JSON; optional fields are omitted when unset; timestamps are RFC 3339 UTC.
Published on warehouse.inbound-receiving.events
<entity> is the raising aggregate, lowercase, no separators: asn,
dockappointment, policy (ADR 0026), receipt.
| type | subject | Kafka key | raised when |
|---|---|---|---|
com.warehouse.wms.inbound-receiving.asn.ASNRegistered | asn_number | asn_number | an ASN is registered |
com.warehouse.wms.inbound-receiving.asn.ASNCancelled | asn_number | asn_number | a Registered ASN is cancelled |
com.warehouse.wms.inbound-receiving.asn.AsnLateForArrival | asn_number | asn_number | at OpenReceipt, the ASN was registered after the visit it is received under had already arrived (ADR 0025) |
com.warehouse.wms.inbound-receiving.dockappointment.DockAppointmentBooked | appointment_id | appointment_id | (retired, ADR 0022) a door window is booked |
com.warehouse.wms.inbound-receiving.dockappointment.DockAppointmentCheckedIn | appointment_id | appointment_id | (retired, ADR 0022) the carrier checks in |
com.warehouse.wms.inbound-receiving.dockappointment.DockAppointmentCancelled | appointment_id | appointment_id | (retired, ADR 0022) a Booked appointment is cancelled |
com.warehouse.wms.inbound-receiving.dockappointment.DockAppointmentCompleted | appointment_id | appointment_id | (retired, ADR 0022) the receipt opened from the appointment closes |
com.warehouse.wms.inbound-receiving.receipt.ReceiptOpened | receipt_id | asn_number | receiving of an ASN starts |
com.warehouse.wms.inbound-receiving.receipt.ReceiptLineReceived | receipt_id | asn_number | a quantity is received against a line |
com.warehouse.wms.inbound-receiving.receipt.ReceiptCartonReceived | receipt_id | asn_number | a carton (or one case) is received: identity only, never quantity (ADR 0012) |
com.warehouse.wms.inbound-receiving.receipt.CartonDiscrepancyRaised | receipt_id | asn_number | a finding about a physical carton, one of the kinds of ADR 0012 and ADR 0014 |
com.warehouse.wms.inbound-receiving.receipt.ReceiptClosed | receipt_id | asn_number | receiving ends |
com.warehouse.wms.inbound-receiving.receipt.ReceiptStowCompleted | receipt_id | asn_number | the last Good carton of a closed receipt opened from an appointment is stowed: the dock-to-stock fact (ADR 0021) |
com.warehouse.wms.inbound-receiving.receipt.ReceivingAdviceIssued | receipt_id | asn_number | a receipt closes: the receiving advice for the supplier or depositor, with W13/CBV-coded discrepancies (ADR 0023) |
com.warehouse.wms.inbound-receiving.receipt.ReceivingAdviceOverdue | receipt_id | asn_number | an Open receipt passed the advice SLA since its last unit was received (ADR 0023) |
com.warehouse.wms.inbound-receiving.policy.ReceivingPolicyDeclared | supplier_ref | supplier_ref | a receiving tolerance policy is created or replaced (ADR 0026) |
The receipt events are keyed by asn_number, so everything that happens while
one ASN is received stays ordered on one partition. DockAppointmentCompleted
is keyed by appointment_id, so its order relative to ReceiptClosed is not
guaranteed; consumers must not depend on it.
Payloads (data)
| type (entity.Event) | fields |
|---|---|
asn.ASNRegistered | asn_number, supplier_ref, expected_arrival?, registered_at? (ADR 0025), lines[] = {line_no, sku, expected_qty} |
asn.ASNCancelled | asn_number, reason? |
asn.AsnLateForArrival | asn_number, supplier_ref, appointment_id, visit_id, asn_registered_at, arrived_at, lateness_seconds (ADR 0025) |
dockappointment.DockAppointmentBooked | appointment_id, door_code, carrier, window_start, window_end, asn_numbers[] |
dockappointment.DockAppointmentCheckedIn | appointment_id, door_code, checked_in_at |
dockappointment.DockAppointmentCancelled | appointment_id, door_code, reason? |
dockappointment.DockAppointmentCompleted | appointment_id, door_code, completed_at |
receipt.ReceiptOpened | receipt_id, asn_number, appointment_id?, door_code?, opened_at |
receipt.ReceiptLineReceived | receipt_id, asn_number, line_no, sku, quantity, condition (Good or Damaged), received_at |
receipt.ReceiptCartonReceived | receipt_id, asn_number, sscc?, parent_sscc?, sealed, lpn, contents[] (line_no, sku, gtin, qty, condition), received_at |
receipt.CartonDiscrepancyRaised | receipt_id, sscc?, kind, expected?, actual?, at |
receipt.ReceiptClosed | receipt_id, asn_number, closed_at, discrepancies[] = {line_no, sku, kind, expected_qty, received_qty, damaged_qty}, kind in Short, Over, Damaged, OverTolerance, UnderTolerance (ADR 0026), plus reason_code on the two tolerance kinds and an optional tolerance object {over_tolerance, under_tolerance, over_hard_stop, under_hard_stop} present when a policy was applied |
receipt.ReceiptStowCompleted | receipt_id, asn_number, appointment_id, arrived_at, closed_at, stowed_at, dock_to_stock_seconds, carton_count (ADR 0021) |
receipt.ReceivingAdviceIssued | receipt_id, asn_number, despatch_advice_ref, supplier_ref, owner_ref?, issued_at, last_carton_at, sla_seconds, within_sla, lines[], lines_total, carton_findings[], carton_findings_total (ADR 0023) |
receipt.ReceivingAdviceOverdue | receipt_id, asn_number, last_carton_at, due_at, sla_seconds, overdue_at (ADR 0023) |
policy.ReceivingPolicyDeclared | supplier_ref, owner_ref?, over_tolerance, under_tolerance, over_hard_stop, under_hard_stop, version, declared_at (ADR 0026) |
Payload rules:
ReceiptClosed.discrepanciesis present and empty ([]) when everything matched. A line can appear once per kind.received_qtyis good + damaged;damaged_qtyis the damaged part.ReceiptLineReceivedis the handover event (ADR 0003): inventory-storage bookscondition=Goodquantities only.- 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.product-master.product.ProductRegistered | warehouse.product-master.events | PRODUCT_CONSUMER_GROUP |
com.warehouse.wms.facility-layout.locationslot.LocationSlotRegistered | warehouse.facility.events | DOCK_DOOR_CONSUMER_GROUP |
com.warehouse.wms.facility-layout.locationslot.LocationSlotDecommissioned | warehouse.facility.events | DOCK_DOOR_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.
Analytics topic (ADR 0006)
Every published event above is ALSO written, in the same transaction and under
the same id, to warehouse.inbound-receiving.analytics (dead-letter topic
warehouse.inbound-receiving.analytics.dlq). The type, subject, Kafka key
and payload are identical to the integration message; only the dataschema
differs: urn:warehouse:inbound-receiving:analytics:<EventName>:v1. Only this
service's cmd/inbound-projector consumes it (consumer group from env
ANALYTICS_CONSUMER_GROUP); it is not an integration contract, and other
contexts keep reading warehouse.inbound-receiving.events. The projection and
its report are specified in ADR 0006.
Consequences
- Consumers need nothing but this catalogue and
apis/asyncapi.yaml; there is no shared Go code. - The nine types are pinned: the fleet plan and inventory-storage's consumer build against these exact strings.