Skip to main content

Domain Events

Every event this context publishes and consumes, from contexts[yard-management].publishes and .consumes. The envelope follows the yard CloudEvents standard. There are twenty-three published events (thirteen integration, ten analytics only) and sixteen consumed events (nine from dock-scheduling, three from facility-layout, four from inbound-receiving). The split is as built (service ADR 0004, refined by ADR 0010 on 2026-11-09, which moved DoorWorkCompleted and TrailerDeparted to the integration topic; ADR 0013 added TrailerSecured and TrailerSecuringReleased; ADR 0015 added InspectionCompleted and InspectionFailed); the AsyncAPI is version 3.0.0 and the topic of each channel is in its address.

Envelope​

AttributeValue
specversion1.0 (structured JSON mode, mandatory on every Kafka message)
idunique per event; a redelivery carries the same id (the inbox dedupes on it)
source/warehouse/yard-management
typecom.warehouse.wms.yard-management.<entity>.<EventName>; entity is the lower-case aggregate that raises it: yardvisit, trailer, yardmove, yardcheck, inspection
subjectthe aggregate root id: visitId for yardvisit, trailerId for trailer, moveId for yardmove, yardCheckId for yardcheck, inspectionId for inspection
timethe instant the fact happened
datacontenttypeapplication/json, payload fields in snake_case
dataschemaurn:warehouse:yard-management:events:<EventName>:v1 on the integration topic, urn:warehouse:yard-management:analytics:<EventName>:v1 on its analytics twin
Kafka topicintegration events: warehouse.yard-management.events and, as a twin with the same id, type, key and byte-identical data, warehouse.yard-management.analytics; analytics-only events: warehouse.yard-management.analytics only
Kafka keythe same aggregate root id as subject, so one visit's (or trailer's, or move's) events stay in order on one partition
versionevery event on an aggregate with a version carries it in data (starts at 1, +1 per accepted change); readers apply only version greater than the stored one

Every event leaves through the transactional outbox, in the same transaction as the aggregate change, with an attempt cap; one outbox row becomes up to two Kafka messages, and a row that can never be encoded goes verbatim to warehouse.yard-management.events.dlq.

Because events are keyed by visit or trailer id and not by appointment, dock-scheduling can receive them in any order across partitions (its policy OutOfOrderYardFacts).

Published: integration events​

Topic warehouse.yard-management.events (each message also goes, as a twin, to the analytics topic).

Visit events (key visitId)​

EventFull typedata fieldsProducing command / use caseConsumers
VisitCheckedIncom.warehouse.wms.yard-management.yardvisit.VisitCheckedInvisit_id, site_id, carrier, carrier_scac, purpose, appointment_id, carrier_flag, trailers, arrived_at, version; optional x12_status, cbv_biz_stepCheckInVisitdock-scheduling, inbound-receiving
VisitRejectedcom.warehouse.wms.yard-management.yardvisit.VisitRejectedvisit_id, site_id, carrier_scac, appointment_id, reason, rejected_atRejectAtGate (also the REJECT outcome of SealCheckAtGate)dock-scheduling, exception-management

reason is a RejectionReason: APPOINTMENT_REQUIRED, UNKNOWN_APPOINTMENT, SEAL_MISMATCH, TRAILER_ALREADY_ON_SITE, SITE_REQUEST or CARRIER_SUSPENDED (ADR 0016).

Trailer events (key trailerId)​

EventFull typedata fieldsProducing command / use caseConsumers
TrailerDockedcom.warehouse.wms.yard-management.trailer.TrailerDockedtrailer_id, site_id, door_code, appointment_id, asn_numbers, visit_id, docked_at, versionArriveAt a door, via CompleteMove (the move and the trailer change in one unit of work)dock-scheduling, outbound-shipping
TrailerUndockedcom.warehouse.wms.yard-management.trailer.TrailerUndockedtrailer_id, site_id, door_code, appointment_id, undocked_at, versionthe trailer leaves a door: StartMoving or Depart from DOCKEDdock-scheduling
SealExceptionRaisedcom.warehouse.wms.yard-management.trailer.SealExceptionRaisedtrailer_id, site_id, appointment_id, expected_seal_number, found_seal_number, raised_atpolicy SealCheckAtGateexception-management
TrailerDwellExceededcom.warehouse.wms.yard-management.trailer.TrailerDwellExceededtrailer_id, site_id, kind, dwell_minutes, threshold_minutes, location_codeDwellSweepexception-management
DoorWorkCompletedcom.warehouse.wms.yard-management.trailer.DoorWorkCompletedtrailer_id, site_id, door_code, appointment_id, completed_at, load_state, versionCompleteDoorWork (also AutoCompleteUnload)outbound-shipping
TrailerDepartedcom.warehouse.wms.yard-management.trailer.TrailerDepartedtrailer_id, site_id, visit_id, departed_at, dwell_minutes, load_state, seal_number, version; optional x12_status, cbv_biz_stepDepartoutbound-shipping
TrailerSecuredcom.warehouse.wms.yard-management.trailer.TrailerSecuredtrailer_id, site_id, door_code, method, secured_at, versionSecureTrailer (not raised again for the same method)none yet
TrailerSecuringReleasedcom.warehouse.wms.yard-management.trailer.TrailerSecuringReleasedtrailer_id, site_id, door_code, released_at, versionReleaseTrailerSecuringnone yet

TrailerDocked and each trailers entry of VisitCheckedIn carry the optional hazmat_class, un_number (null when not declared) and requires_temperature_control (false when not declared), additive since ADR 0014; no new type. method in TrailerSecured is RESTRAINT (a vehicle restraint engaged) or WHEEL_CHOCKS (ADR 0013). kind in TrailerDwellExceeded is the TrailerKind whose threshold the dwell reached (the alert fires when dwell equals the threshold). DoorWorkCompleted and TrailerDeparted reached this topic on 2026-11-09 (service ADR 0010) because outbound-shipping confirms a shipment when the trailer physically leaves; messages raised before that stayed on the analytics topic. SealExceptionRaised.trailer_id is null when the visit was rejected at the gate (the CloudEvents subject is then the visit id).

Inspection events (key inspectionId)​

EventFull typedata fieldsProducing command / use caseConsumers
InspectionCompletedcom.warehouse.wms.yard-management.inspection.InspectionCompletedinspection_id, site_id, trailer_id, visit_id, template_id, template_version, gate, outcome, condition_grade, completed_at, failed_item_codes; optional cbv_biz_step, cbv_dispositionCompleteInspectionnone yet (the audit record, ADR 0015)
InspectionFailedcom.warehouse.wms.yard-management.inspection.InspectionFailedinspection_id, site_id, trailer_id, template_id, gate, failed_items, failed_at, hold_placed; optional cbv_biz_step, cbv_dispositionCompleteInspection ending FAILED (the TrailerHeld of its hold follows)exception-management (planned)

Both are advisory (no version): an inspection is final once completed. visit_id, condition_grade and failed_items[].note are null when absent.

Yard check events (key yardCheckId)​

EventFull typedata fieldsProducing command / use caseConsumers
YardCheckClosedcom.warehouse.wms.yard-management.yardcheck.YardCheckClosedyard_check_id, site_id, closed_at, discrepanciesCloseYardCheckexception-management

discrepancies is a list of findings (kind MISSING, UNEXPECTED or WRONG_LOCATION, location, trailer), not a count.

Published: analytics-only events​

Topic warehouse.yard-management.analytics only. "Analytics only" means no other context reads the event and it does not go to the integration topic; no context may depend on it for a decision without a model change. The the analytics reports read model is built from them and from the twins of the integration events.

EventFull typedata fieldsProducing command / use case
VisitCheckedOutcom.warehouse.wms.yard-management.yardvisit.VisitCheckedOutvisit_id, site_id, trailers_out, departed_at, on_site_minutes, version; optional x12_status, cbv_biz_stepCheckOutVisit
TrailerParkedcom.warehouse.wms.yard-management.trailer.TrailerParkedtrailer_id, site_id, spot_code, versionArriveAt a spot, via CompleteMove; also ReturnToOrigin
DoorWorkStartedcom.warehouse.wms.yard-management.trailer.DoorWorkStartedtrailer_id, site_id, door_code, appointment_id, started_at, versionStartDoorWork
TrailerHeldcom.warehouse.wms.yard-management.trailer.TrailerHeldtrailer_id, site_id, reason, version; optional cbv_dispositionPlaceHold (also RecordSeal with state BROKEN)
TrailerHoldReleasedcom.warehouse.wms.yard-management.trailer.TrailerHoldReleasedtrailer_id, site_id, versionReleaseHold
YardMoveRequestedcom.warehouse.wms.yard-management.yardmove.YardMoveRequestedmove_id, site_id, trailer_id, appointment_id, performer, from_location, to_location, reason, due_by, versionRequestMove (also the first move at the gate, created CLAIMED)
YardMoveClaimedcom.warehouse.wms.yard-management.yardmove.YardMoveClaimedmove_id, site_id, hostler_ref, claimed_at, versionClaimNextMove
YardMoveLeaseExpiredcom.warehouse.wms.yard-management.yardmove.YardMoveLeaseExpiredmove_id, site_id, hostler_ref, versionExpireLease (the lease sweep)
YardMoveCompletedcom.warehouse.wms.yard-management.yardmove.YardMoveCompletedmove_id, site_id, trailer_id, performer, hostler_ref, from_location, to_location, actual_location, reason, completed_at, duration_seconds, versionCompleteMove
YardMoveCancelledcom.warehouse.wms.yard-management.yardmove.YardMoveCancelledmove_id, site_id, reason, versionCancelMove

reason in TrailerHeld is a HoldReason: DAMAGED, SEAL_BROKEN, NOT_FOUND, QUALITY or SECURITY. Since ADR 0018 six events carry the optional standard-vocabulary fields x12_status (ANSI X12 214 status code), cbv_biz_step and cbv_disposition (GS1 CBV 2.0 URNs), listed in the data columns above and in Event catalogue; they are omitted, never null, when the mapping has no honest value, so every other payload is unchanged. YardMoveLeaseExpired is new as built (decision Y-10): ExpireLease used to raise nothing. DeclareYardPolicy raises no event; neither do OpenYardCheck, RecordObservation, RecordArrival, RecordSeal, BreakSeal, RecordLoadState, StartMoving or ArriveAt on their own account.

Example: a trailer docked​

TrailerDocked is the most important event: it is how the physical door reaches dock-scheduling (and, for ship-confirm, outbound-shipping). Ids and times are illustrative.

{
"specversion": "1.0",
"id": "0d3e7a52-5a63-4f0b-8f6e-1c2d9b7a4e11",
"source": "/warehouse/yard-management",
"type": "com.warehouse.wms.yard-management.trailer.TrailerDocked",
"subject": "trl-0001",
"time": "2026-11-12T14:07:31Z",
"datacontenttype": "application/json",
"dataschema": "urn:warehouse:yard-management:events:TrailerDocked:v1",
"data": {
"trailer_id": "trl-0001",
"site_id": "SITE-A",
"door_code": "D07",
"appointment_id": "apt-0042",
"asn_numbers": ["ASN-1001"],
"visit_id": "vis-0007",
"docked_at": "2026-11-12T14:07:31Z",
"version": 3
}
}

Example: a move completed​

YardMoveCompleted carries the actual_location next to the planned to_location and the move's reason. A location other than the destination needs a reason (ErrUnexplainedDestination); as built the payload has both fields (the model first lacked them, gap YM-G15). Ids and times are illustrative.

{
"specversion": "1.0",
"id": "5b8c1f90-2e47-4d36-a1c8-77e0a9d35b02",
"source": "/warehouse/yard-management",
"type": "com.warehouse.wms.yard-management.yardmove.YardMoveCompleted",
"subject": "mov-0105",
"time": "2026-11-12T14:07:30Z",
"datacontenttype": "application/json",
"dataschema": "urn:warehouse:yard-management:events:YardMoveCompleted:v1",
"data": {
"move_id": "mov-0105",
"site_id": "SITE-A",
"trailer_id": "trl-0001",
"performer": "HOSTLER",
"hostler_ref": "host-12",
"from_location": { "kind": "SPOT", "code": "P14" },
"to_location": { "kind": "DOOR", "code": "D07" },
"actual_location": { "kind": "DOOR", "code": "D07" },
"reason": "TO_DOOR",
"completed_at": "2026-11-12T14:07:30Z",
"duration_seconds": 214,
"version": 3
}
}

Consumed​

Every consumer is idempotent on the CloudEvents id (a processed_events row written in the same transaction as the effect) and dispatches on the full type string, never on a suffix. A policy refusal is logged and counted and the event is marked processed; an infrastructure failure rolls back and the message is redelivered. The three consumers (dock-scheduling, facility-layout, inbound-receiving) each run under a group named by an environment variable (DOCK_SCHEDULING_CONSUMER_GROUP, FACILITY_CONSUMER_GROUP, INBOUND_RECEIVING_CONSUMER_GROUP); the analytics consumer has its own (ANALYTICS_CONSUMER_GROUP).

From dock-scheduling (topic warehouse.dock-scheduling.events)​

Full typedata fields (producer's contract)What this context does with itIdempotency beyond the inbox
com.warehouse.wms.dock-scheduling.dockappointment.DockAppointmentBookedappointment_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, versionInserts the appointment into AppointmentView (door, window, expected seal, tolerance), status BOOKEDApply only version above the stored one
com.warehouse.wms.dock-scheduling.dockappointment.DockAppointmentRescheduledappointment_id, site_id, door_code, previous_door_code, window_start, window_end, previous_window_start, previous_window_end, arrival_tolerance_minutes, versionUpdates door, window and tolerance in AppointmentViewAs above
com.warehouse.wms.dock-scheduling.dockappointment.DockAppointmentCancelledappointment_id, site_id, door_code, reason, versionMarks it CANCELLED; NoShowFreesHolding cancels an open TO_DOOR move for itAs above; cancel a move only if one is open
com.warehouse.wms.dock-scheduling.dockappointment.DockAppointmentNoShowappointment_id, site_id, door_code, direction, carrier_scac, window_end, versionMarks it NO_SHOW; NoShowFreesHolding as aboveAs above
com.warehouse.wms.dock-scheduling.dockcalendar.DoorClosureScheduledsite_id, closure_id, door_code, from, to, reason, versionInserts the closure into DoorClosureView (ErrDoorClosed)Upsert on closure_id
com.warehouse.wms.dock-scheduling.dockcalendar.DoorClosureLiftedsite_id, closure_id, door_code, versionRemoves the closure from DoorClosureViewAs above
com.warehouse.wms.dock-scheduling.carrier.CarrierRegisteredscac, name, usdot, mc, status, versionReplaces the carrier in the carriers copy (the whole snapshot; service ADR 0016)Apply only version above the stored one
com.warehouse.wms.dock-scheduling.carrier.CarrierSuspendedscac, reason, versionSets the carrier SUSPENDED with the reason; keeps its name and identifiersAs above
com.warehouse.wms.dock-scheduling.carrier.CarrierReinstatedscac, versionSets the carrier ACTIVE and clears the reasonAs above

From facility-layout (topic warehouse.facility.events)​

Full typedata fields usedWhat this context does with itIdempotency beyond the inbox
com.warehouse.wms.facility-layout.locationslot.LocationSlotRegisteredlocationCode, zoneId, role, dockFlowAdds a Yard or Dock slot to LocationView (locations); a slot whose zone has not arrived is held pending and is unknown-location until it doesUpsert on locationCode
com.warehouse.wms.facility-layout.locationslot.LocationSlotDecommissionedlocationCodeRemoves or deactivates the slot in LocationView (ErrUnknownLocation for new arrivals)Repeatable
com.warehouse.wms.facility-layout.zone.ZoneRegisteredzoneId, siteCodeMaps zoneId to siteCode so a slot has a site; never by parsing a location codeUpsert on zoneId

From inbound-receiving (topic warehouse.inbound-receiving.events)​

Full typedata fields usedWhat this context does with itIdempotency beyond the inbox
com.warehouse.wms.inbound-receiving.asn.ASNRegisteredasn_number, linesAdds the ASN to AsnContentView (what an inbound trailer holds)Upsert on asn_number
com.warehouse.wms.inbound-receiving.asn.ASNCancelledasn_numberMarks it cancelled in AsnContentViewStatus overwrite
com.warehouse.wms.inbound-receiving.receipt.ReceiptOpenedreceipt_id, asn_number, appointment_id, door_codeRecords the receipt at the door in ReceiptAtDoorViewUpsert on receipt_id
com.warehouse.wms.inbound-receiving.receipt.ReceiptClosedreceipt_id, asn_number, closed_atAutoCompleteUnload: CompleteDoorWork and load_state EMPTY if the trailer is DOCKEDComplete door work once

Source: internal/domain/trailer/events.go, internal/adapters/outbound/kafka/encoder.go, internal/adapters/inbound/kafka/consumer.go, internal/application/views/views.go, apis/asyncapi.yaml.

The type strings of all three producers are read from their AsyncAPI (the dock-scheduling copy is under yard/apis/dock-scheduling/, the others under apis/). The "idempotency beyond the inbox" column is as built where the service's ADR 0009 states it and otherwise this page's reading: versioned dock-scheduling facts are guarded by version, a replay of an older version never overwrites a newer row.

Notes​

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

  • VisitRejected, SealExceptionRaised, TrailerDwellExceeded and YardCheckClosed carry no version, as modelled (decision Y-10 documents the exemptions); the trailers array of VisitCheckedIn and discrepancies are spelled out in the AsyncAPI.
  • ExpireLease now raises YardMoveLeaseExpired (analytics only, decision Y-10, YM-G14).
  • StartMoving and ArriveAt run inside the move's use cases and raise TrailerParked, TrailerDocked and TrailerUndocked; a live visit that leaves from the door raises TrailerUndocked then TrailerDeparted (decision Y-6, YM-G8).
  • VisitRejected is consumed by dock-scheduling, which cancels the appointment with TURNED_AWAY (decision X2, YM-G17), and by exception-management.
  • inbound-receiving consumes VisitCheckedIn (its ADR 0021, visit_arrival_consumer.go) and no other type of this context; it does not consume TrailerDocked (the optional confirm of the door on an open receipt was not built), while outbound-shipping does. The AsyncAPI descriptions that named inbound-receiving as a consumer of TrailerDocked were corrected on 2026-11-13.
  • The consumed lines of ASNRegistered is used by no rule on these pages (gap YM-G26, accepted).