Skip to main content

Domain Events

Every event this context publishes and consumes, from contexts[dock-scheduling].publishes and .consumes; the three carrier events (ADR 0012) are read from apis/asyncapi.yaml and internal/domain/carrier/events.go. The envelope follows conventions.cloudevents in the design model.

Envelope​

AttributeValue
specversion1.0 (structured JSON mode)
ida UUID minted once, when the event is written to the outbox; a redelivery carries the same id
source/warehouse/dock-scheduling
typecom.warehouse.wms.dock-scheduling.<entity>.<EventName>, entity dockappointment, dockcalendar or carrier
subjectthe aggregate root id: appointmentId for dockappointment events, siteId for dockcalendar events, the SCAC for carrier events
timethe instant the fact happened, UTC
datacontenttypeapplication/json
dataschemaurn:warehouse:dock-scheduling:events:<EventName>:v1 on the integration topic, urn:warehouse:dock-scheduling:analytics:<EventName>:v1 on its analytics twin
Kafka topicwarehouse.dock-scheduling.events for integration events, warehouse.dock-scheduling.analytics for events marked analytics only
Kafka keythe same id as subject, so one appointment's (or one site calendar's, or one carrier's) events stay in order on one partition
Payload casesnake_case
versionin data of every event except DockAppointmentAtRisk: the aggregate version (starts at 1, plus 1 per accepted change); a reader applies only a version greater than the stored one

Every event leaves through the transactional outbox, in the same transaction as the aggregate change: one outbox row, up to two Kafka messages. Events the design model marks analytics only go only to warehouse.dock-scheduling.analytics; integration events go to warehouse.dock-scheduling.events and, as a twin with the same id, type, key and data, to warehouse.dock-scheduling.analytics (conventions.analytics_rule; the service's ADR 0004 and, for DockAppointmentDoorReassigned, ADR 0010). In the code the AsyncAPI is version 2.6.0 with one channel per topic: seven integration types on the events channel, all eleven on the analytics channel (ADR 0012 adds three carrier events to both: ten and fourteen). Since ADR 0013 every appointment fact (and every door closure) can also carry the optional x12_status, cbv_biz_step and read_point_gln fields, the standard meaning of the fact (ANSI X12 214 code, GS1 CBV business step, GS1 GLN of the door); the mapping is one table in internal/domain/standards, and an event with no honest mapping carries none of the first two.

Published​

Appointment events (key appointmentId)​

EventFull typeStreamdata fieldsProducing commandConsumers
DockAppointmentBookedcom.warehouse.wms.dock-scheduling.dockappointment.DockAppointmentBookedintegration + analytics twinappointment_id, site_id, direction, door_code, carrier, carrier_scac, window_start, window_end, asn_numbers, cpt_id, shipment_refs, expected_seal_number, arrival_tolerance_minutes, provenance, versionBookAppointmentyard-management, warehouse-planning, inbound-receiving, outbound-shipping
DockAppointmentRescheduledcom.warehouse.wms.dock-scheduling.dockappointment.DockAppointmentRescheduledintegration + analytics twinappointment_id, site_id, door_code, previous_door_code, window_start, window_end, previous_window_start, previous_window_end, arrival_tolerance_minutes, versionRescheduleAppointment (window and/or door; carries previous_door_code)yard-management, warehouse-planning, inbound-receiving
DockAppointmentCancelledcom.warehouse.wms.dock-scheduling.dockappointment.DockAppointmentCancelledintegration + analytics twinappointment_id, site_id, door_code, reason, versionCancelAppointment (carrier or planner request; policies CancelOnVisitRejected with TURNED_AWAY and CancelWhenAllAsnsCancelled with ASN_CANCELLED)yard-management, warehouse-planning, inbound-receiving
DockAppointmentNoShowcom.warehouse.wms.dock-scheduling.dockappointment.DockAppointmentNoShowintegration + analytics twinappointment_id, site_id, door_code, direction, carrier_scac, window_end, versionMarkNoShow (policy NoShowSweep)yard-management, warehouse-planning, exception-management
DockAppointmentDoorReassignedcom.warehouse.wms.dock-scheduling.dockappointment.DockAppointmentDoorReassignedintegration + analytics twinappointment_id, site_id, from_door_code, to_door_code, versionReassignDoor (policy ActualDoorWins)inbound-receiving
DockAppointmentCheckedIncom.warehouse.wms.dock-scheduling.dockappointment.DockAppointmentCheckedInanalytics onlyappointment_id, site_id, door_code, checked_in_at, arrival_status, visit_id, versionRecordArrival (policy ArrivalFromGate)analytics only
DockAppointmentCompletedcom.warehouse.wms.dock-scheduling.dockappointment.DockAppointmentCompletedanalytics onlyappointment_id, site_id, door_code, completed_at, versionRecordDoorRelease (policy CompleteOnDoorRelease)analytics only
DockAppointmentAtRiskcom.warehouse.wms.dock-scheduling.dockappointment.DockAppointmentAtRiskanalytics onlyappointment_id, site_id, door_code, eta_at, window_start, window_end, causeReportEta (policy EtaRisk), ReassignDoor (policy ActualDoorWins)analytics only

Calendar events (key siteId)​

EventFull typeStreamdata fieldsProducing commandConsumers
DoorClosureScheduledcom.warehouse.wms.dock-scheduling.dockcalendar.DoorClosureScheduledintegration + analytics twinsite_id, closure_id, door_code, from, to, reason, versionScheduleDoorClosureyard-management
DoorClosureLiftedcom.warehouse.wms.dock-scheduling.dockcalendar.DoorClosureLiftedintegration + analytics twinsite_id, closure_id, door_code, versionLiftDoorClosureyard-management
DoorOperatingHoursDeclaredcom.warehouse.wms.dock-scheduling.dockcalendar.DoorOperatingHoursDeclaredanalytics onlysite_id, door_code, operating_hours, versionDeclareOperatingHoursanalytics only

Carrier events (key scac, ADR 0012)​

EventFull typeStreamdata fieldsProducing commandConsumers
CarrierRegisteredcom.warehouse.wms.dock-scheduling.carrier.CarrierRegisteredintegration + analytics twinscac, name, usdot, mc, status, reason, suspended_at, version (the full snapshot after the change; absent optionals are null)RegisterCarrier (first registration), UpdateCarrier (only when the data changed)yard-management
CarrierSuspendedcom.warehouse.wms.dock-scheduling.carrier.CarrierSuspendedintegration + analytics twinscac, reason, suspended_at, versionSuspendCarrieryard-management
CarrierReinstatedcom.warehouse.wms.dock-scheduling.carrier.CarrierReinstatedintegration + analytics twinscac, reinstated_at, versionReinstateCarrieryard-management

A carrier fact raised by an MCP write also carries an optional initiated_by object in data (via mcp; proposal_id, approved_by and agent_id when supplied); a REST write carries none. yard-management folds the three into its CarrierView copy (its internal/adapters/inbound/kafka/dock_scheduling_consumer.go on origin/develop); no other context consumes them.

Stream: integration + analytics twin is warehouse.dock-scheduling.events plus the same message on warehouse.dock-scheduling.analytics; analytics only is the analytics topic alone.

Enumerations used in the payloads: direction is INBOUND or OUTBOUND; arrival_status is EARLY, ON_TIME or LATE; reason of DockAppointmentCancelled is a CancellationReason (CARRIER_REQUEST, SITE_REQUEST, ASN_CANCELLED, TURNED_AWAY); cause of DockAppointmentAtRisk is an AtRiskCause (LATE_ETA, DOOR_REASSIGNED_OVERLAP).

"Analytics only" means no other context reads the event; the service's projector folds it into the adherence report. No context may depend on those events for a decision without a model change. DockAppointmentDoorReassigned stopped being analytics only on 2026-11-09 (service ADR 0010): inbound-receiving keeps its copy of the appointment's door from it. Commands that raise no event: ReportEta (unless the ETA is late), DeclareCalendarSettings. DockAppointmentAtRisk carries no version; the REST appointment exposes atRisk and atRiskCause instead.

Example: a no-show​

DockAppointmentNoShow is one of the events with three consumers. Ids and times are illustrative; the data fields are exactly those in the design model and the AsyncAPI.

{
"specversion": "1.0",
"id": "6f1d2c4e-8a1b-4e8f-9b4a-2d5c7e9f1a30",
"source": "/warehouse/dock-scheduling",
"type": "com.warehouse.wms.dock-scheduling.dockappointment.DockAppointmentNoShow",
"subject": "appt-0001",
"time": "2026-11-06T14:40:00Z",
"datacontenttype": "application/json",
"dataschema": "urn:warehouse:dock-scheduling:events:DockAppointmentNoShow:v1",
"data": {
"appointment_id": "appt-0001",
"site_id": "SITE-A",
"door_code": "D07",
"direction": "INBOUND",
"carrier_scac": "ABCD",
"window_end": "2026-11-06T14:00:00Z",
"version": 2
}
}

Consumed​

Every consumer is idempotent on the CloudEvents id (a row in processed_events written in the same transaction as the effect) and dispatches on the full type string, never on a suffix (conventions.integration_rules). A fact that is valid but changes nothing (an unknown or terminal appointment, a site mismatch, an unknown door) is counted in dock_scheduling_ignored_facts_total and committed; a payload that can never be applied is dead-lettered to <topic>.dlq. The four consumers and their environment variables are in the service's ADR 0009. The full types: yard-management events are com.warehouse.wms.yard-management.<entity>.<EventName> (entity yardvisit or trailer), process-path-management is in the wes tier (com.warehouse.wes.process-path-management.cptschedule.CPTScheduleChanged), the others are read from each producer's AsyncAPI.

ProducerEvent and topicdata fields the design model relies onWhat this context does with itIdempotency beyond the inbox (in the code)
yard-managementVisitCheckedIn, warehouse.yard-management.eventsappointment_id, visit_id, arrived_atPolicy ArrivalFromGate: when it names an appointment_id, RecordArrival with arrival_status from the window and the arrival toleranceAn appointment already CHECKED_IN is left unchanged; unknown and terminal ones are ignored and counted; a blank appointment_id (walk-in, drop) applies nothing
yard-managementVisitRejected, warehouse.yard-management.eventsappointment_idPolicy CancelOnVisitRejected: a BOOKED appointment is cancelled with reason TURNED_AWAYAny other state, an unknown id or a site mismatch is ignored and counted
yard-managementTrailerDocked, warehouse.yard-management.eventsdoor_code, appointment_idPolicy ActualDoorWins: if the door differs from the booked door, ReassignDoor (the physical fact wins, the overlap refusal is skipped) and DockAppointmentDoorReassigned; later appointments now overlapping get DockAppointmentAtRiskSame door: no change
yard-managementTrailerUndocked, warehouse.yard-management.eventsdoor_code, appointment_idPolicy CompleteOnDoorRelease: when it names an appointment_id, RecordDoorRelease; OutOfOrderYardFacts covers a BOOKED appointment (implicit arrival)A COMPLETED appointment is not completed twice
facility-layoutLocationSlotRegistered, warehouse.facility.eventslocationCode, zoneId, role, dockFlowUpserts a Dock slot into DoorView (doors); a door whose zone has not arrived is held pending and cannot be bookedUpsert on the door code
facility-layoutLocationSlotDecommissioned, warehouse.facility.eventslocationCodeDeletes the door from DoorView: new bookings fail with ErrUnknownDoor, existing appointments are left untouched (D-7)Delete is naturally repeatable
facility-layoutZoneRegistered, warehouse.facility.eventszoneId, siteCodeMaps zoneId to siteCode, which gives every door its site_id (zones)Upsert on zoneId
inbound-receivingASNRegistered, warehouse.inbound-receiving.eventsasn_number, expected_arrival, linesInserts the ASN into AsnView (asns)Upsert on asn_number; a cancelled ASN stays cancelled
inbound-receivingASNCancelled, warehouse.inbound-receiving.eventsasn_numberMarks the ASN cancelled in AsnView; policy CancelWhenAllAsnsCancelled cancels an INBOUND BOOKED appointment whose ASNs are all cancelled, reason ASN_CANCELLEDA cancelled appointment is skipped
process-path-managementCPTScheduleChanged, warehouse.process-path-management.eventssite_id, timezone, cutoffsStores the schedule in CutoffView (cutoff_schedules, cutoffs). Phase 2, not built: policy PickupFromCutoffs would keep OUTBOUND appointments; today no appointment is created from it (D-3)The whole schedule of a site replaces the previous one; the event has no version, the inbox claim makes a replay a no-op

The legacy importer that once read this topic under its own group was removed in ADR 0011: this context consumes no inbound-receiving dockappointment.* type.

Source: internal/application/usecases/facts.go, internal/application/usecases/yard.go, internal/application/usecases/change.go, internal/adapters/inbound/kafka/yard_consumer.go, internal/adapters/inbound/kafka/facility_consumer.go, internal/adapters/inbound/kafka/asn_consumer.go, internal/adapters/inbound/kafka/cutoff_consumer.go, internal/adapters/outbound/kafka/encoder.go, apis/asyncapi.yaml, internal/application/ports/ports.go, migrations/0001_dock_scheduling.up.sql.

Notes​

The gaps this page used to list are closed by the service's decisions (see the Model Gap Register):

  • The arrival tolerance that yard-management needs reaches it on DockAppointmentBooked and DockAppointmentRescheduled as arrival_tolerance_minutes (X1, DS-G01).
  • VisitRejected is consumed here (policy CancelOnVisitRejected, X2, DS-G02), and also read by exception-management.
  • DockAppointmentAtRisk has no version; clients read atRisk and atRiskCause from the appointment, and GET /appointments takes an atRisk filter (D-6, DS-G11).
  • inbound-receiving keeps its appointments copy from DockAppointmentBooked, Rescheduled, Cancelled and, since ADR 0010, DockAppointmentDoorReassigned. It does not need NoShow (X7, DS-G14).
  • outbound-shipping also reads DockAppointmentBooked.