Skip to main content

ADR 0004: CloudEvents envelope and type catalogue

Status​

Accepted (2026-11-05); stream split refined by ADR 0010 (DoorWorkCompleted and TrailerDeparted also on the integration topic) and ADR 0013 (TrailerSecured and TrailerSecuringReleased, both integration) and ADR 0015 (InspectionCompleted and InspectionFailed, both integration).

Context​

Every Kafka message in the fleet is a CloudEvents 1.0 event in structured mode (fleet rule .claude/rules/fleet/cloudevents.md). This ADR is the catalogue of every type yard-management publishes or consumes; TestEventCatalogueMatchesContract checks it against apis/asyncapi.yaml.

Decision​

Envelope​

  • specversion 1.0; id a UUID persisted with the outbox row (stable across relay retries; consumers dedupe on it); source /warehouse/yard-management; subject the aggregate root id; time the occurred-at instant in UTC; datacontenttype application/json; dataschema urn:warehouse:yard-management:<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 aggregate stay ordered on one partition.
  • data is snake_case; nullable fields are null (never omitted); timestamps are RFC 3339 UTC; version is the aggregate version after the change (the advisory events VisitRejected, SealExceptionRaised, TrailerDwellExceeded and YardCheckClosed carry none).
  • Built and decoded only through internal/adapters/kafka/cloudevents.

Streams​

Thirteen types are integration events on warehouse.yard-management.events (the original seven plus DoorWorkCompleted and TrailerDeparted, ADR 0010, TrailerSecured and TrailerSecuringReleased, ADR 0013, and InspectionCompleted and InspectionFailed, ADR 0015) and are mirrored on warehouse.yard-management.analytics (same id, same type, byte-identical data, analytics dataschema). The other ten are analytics-only: they go ONLY to warehouse.yard-management.analytics. A row the encoder cannot encode is written verbatim to warehouse.yard-management.events.dlq. Both topics have 8 partitions.

Published​

<entity> is the raising aggregate, lowercase: yardvisit, trailer, yardmove, yardcheck or inspection (ADR 0015).

typestreamraised whenkey
com.warehouse.wms.yard-management.yardvisit.VisitCheckedInevents + analyticsa visit passes the gate (consumed by dock-scheduling)visit_id
com.warehouse.wms.yard-management.yardvisit.VisitRejectedevents + analyticsa visit is turned away (dock-scheduling, exception-management)visit_id
com.warehouse.wms.yard-management.yardvisit.VisitCheckedOutanalyticsthe visit leavesvisit_id
com.warehouse.wms.yard-management.trailer.TrailerDockedevents + analyticsa trailer arrives at a door (dock-scheduling, inbound-receiving)trailer_id
com.warehouse.wms.yard-management.trailer.TrailerUndockedevents + analyticsa trailer leaves a door (dock-scheduling)trailer_id
com.warehouse.wms.yard-management.trailer.TrailerParkedanalyticsa trailer comes to rest on a spottrailer_id
com.warehouse.wms.yard-management.trailer.DoorWorkStartedanalyticsunloading or loading beginstrailer_id
com.warehouse.wms.yard-management.trailer.DoorWorkCompletedevents + analyticsdoor work is done (outbound-shipping, ADR 0010)trailer_id
com.warehouse.wms.yard-management.trailer.TrailerDepartedevents + analyticsa trailer leaves the site (outbound-shipping, ADR 0010)trailer_id
com.warehouse.wms.yard-management.trailer.TrailerSecuredevents + analyticsa docked trailer is secured by a restraint or wheel chocks (no consumer yet, ADR 0013)trailer_id
com.warehouse.wms.yard-management.trailer.TrailerSecuringReleasedevents + analyticsthe securing is released (no consumer yet, ADR 0013)trailer_id
com.warehouse.wms.yard-management.trailer.SealExceptionRaisedevents + analyticsgate seal differs from the expected one (exception-management)trailer_id (visit id when no trailer)
com.warehouse.wms.yard-management.trailer.TrailerDwellExceededevents + analyticsdwell crossed the kind's threshold (exception-management)trailer_id
com.warehouse.wms.yard-management.trailer.TrailerHeldanalyticsa hold is placedtrailer_id
com.warehouse.wms.yard-management.trailer.TrailerHoldReleasedanalyticsa hold is releasedtrailer_id
com.warehouse.wms.yard-management.inspection.InspectionCompletedevents + analyticsa compliance inspection ends, PASSED or FAILED (no consumer yet: the audit record, ADR 0015)inspection_id
com.warehouse.wms.yard-management.inspection.InspectionFailedevents + analyticsan inspection ends FAILED on a required item (exception-management, ADR 0015)inspection_id
com.warehouse.wms.yard-management.yardmove.YardMoveRequestedanalyticsa move is requestedmove_id
com.warehouse.wms.yard-management.yardmove.YardMoveClaimedanalyticsa hostler claims a movemove_id
com.warehouse.wms.yard-management.yardmove.YardMoveLeaseExpiredanalyticsa lease ran outmove_id
com.warehouse.wms.yard-management.yardmove.YardMoveCompletedanalyticsa move is completedmove_id
com.warehouse.wms.yard-management.yardmove.YardMoveCancelledanalyticsa move is cancelledmove_id
com.warehouse.wms.yard-management.yardcheck.YardCheckClosedevents + analyticsan audit closes (exception-management)yard_check_id

Payload fields are in apis/asyncapi.yaml (one message per type with schema and example) and equal contracts-delta.md / model.yaml publishes, plus the final gap decisions: appointment_id on YardMoveRequested, to_location and reason on YardMoveCompleted, trailer_id nullable on SealExceptionRaised, and YardMoveLeaseExpired. A breaking payload change is a new .v2 type and dataschema, never a mutation of v1.

Consumed (ADR 0003)​

typetopicconsumer group env
com.warehouse.wms.dock-scheduling.dockappointment.DockAppointmentBookedwarehouse.dock-scheduling.eventsDOCK_SCHEDULING_CONSUMER_GROUP
com.warehouse.wms.dock-scheduling.dockappointment.DockAppointmentRescheduledwarehouse.dock-scheduling.eventsDOCK_SCHEDULING_CONSUMER_GROUP
com.warehouse.wms.dock-scheduling.dockappointment.DockAppointmentCancelledwarehouse.dock-scheduling.eventsDOCK_SCHEDULING_CONSUMER_GROUP
com.warehouse.wms.dock-scheduling.dockappointment.DockAppointmentNoShowwarehouse.dock-scheduling.eventsDOCK_SCHEDULING_CONSUMER_GROUP
com.warehouse.wms.dock-scheduling.dockcalendar.DoorClosureScheduledwarehouse.dock-scheduling.eventsDOCK_SCHEDULING_CONSUMER_GROUP
com.warehouse.wms.dock-scheduling.dockcalendar.DoorClosureLiftedwarehouse.dock-scheduling.eventsDOCK_SCHEDULING_CONSUMER_GROUP
com.warehouse.wms.facility-layout.zone.ZoneRegisteredwarehouse.facility.eventsFACILITY_CONSUMER_GROUP
com.warehouse.wms.facility-layout.locationslot.LocationSlotRegisteredwarehouse.facility.eventsFACILITY_CONSUMER_GROUP
com.warehouse.wms.facility-layout.locationslot.LocationSlotDecommissionedwarehouse.facility.eventsFACILITY_CONSUMER_GROUP
com.warehouse.wms.inbound-receiving.asn.ASNRegisteredwarehouse.inbound-receiving.eventsINBOUND_RECEIVING_CONSUMER_GROUP
com.warehouse.wms.inbound-receiving.asn.ASNCancelledwarehouse.inbound-receiving.eventsINBOUND_RECEIVING_CONSUMER_GROUP
com.warehouse.wms.inbound-receiving.receipt.ReceiptOpenedwarehouse.inbound-receiving.eventsINBOUND_RECEIVING_CONSUMER_GROUP
com.warehouse.wms.inbound-receiving.receipt.ReceiptClosedwarehouse.inbound-receiving.eventsINBOUND_RECEIVING_CONSUMER_GROUP

The projector reads this service's own analytics topic with ANALYTICS_CONSUMER_GROUP.

Consequences​

  • Consumers need nothing but this catalogue and apis/asyncapi.yaml; there is no shared Go code.
  • The analytics stream is the only source of the KPI reports; the integration topic stays small.

Addendum 2026-11-13: current state​

  • The Published table lists inbound-receiving as a consumer of TrailerDocked and only dock-scheduling for VisitCheckedIn. As built, TrailerDocked is read by dock-scheduling and outbound-shipping, and VisitCheckedIn by dock-scheduling and inbound-receiving (inbound-receiving internal/adapters/inbound/kafka/visit_arrival_consumer.go, its ADR 0021).
  • The Consumed table lists thirteen types; ADR 0016 added CarrierRegistered, CarrierSuspended and CarrierReinstated on warehouse.dock-scheduling.events, sixteen in all (internal/adapters/inbound/kafka/dock_scheduling_consumer.go).

Addendum 2026-11-17: standard vocabulary fields (ADR 0018)​

  • No type is added or renamed; the catalogue above is unchanged. Six payloads gain up to three OPTIONAL fields, x12_status (the ANSI X12 214 shipment status code), cbv_biz_step and cbv_disposition (GS1 CBV 2.0 URNs): VisitCheckedIn, VisitCheckedOut and TrailerDeparted (x12_status, cbv_biz_step), InspectionCompleted and InspectionFailed (cbv_biz_step, cbv_disposition) and TrailerHeld (cbv_disposition, for the reasons DAMAGED and SEAL_BROKEN). They are the exception to "nullable fields are null": a field with no honest value is OMITTED, so every other payload, and these six when nothing is mapped, are byte-identical to before. The integration and analytics twins still carry identical data.