Skip to main content

Domain Events

Built, released at v0.1.4, applied to k3s (reduced footprint); MCP and A2A built, not deployed

Built on develop (merged 2026-11-08) in IQVO/yard-management, released at v0.1.4 (first release v0.1.0 on 2026-11-09; applied to the k3s cluster on 2026-11-10 at v0.1.2 in a reduced footprint, and the image pinned to the v0.1.4 commit 44d605e in warehouse-infra since 2026-11-18, checked 2026-12-02): yard-management switches on its API and relay (at the check the relay was 1/1 and the API 0/1 Pending on the NotReady agent node k3s-agent2); dock-scheduling runs its API only (it relays inline). The MCP server (25 tools on develop 3bcfc22, 21 in v0.1.4) is registered in warehouse-infra but switched off until the cluster has room; the A2A agent (two skills) is built on develop (2026-12-02), not released and not deployed (the chart carries it off by default and warehouse-infra has no a2a block); the analytics projectors, report services and sweeps are registered but switched off, so the KPI reports of ADR 0011 are released, not yet served. The page still derives from yard/model/model.yaml; where the as-built service differs, the model and this page say so (see the as-built notes).

Every event this context publishes and consumes, from contexts[yard-management].publishes and .consumes. The envelope follows the yard CloudEvents standard. There are nineteen published events (nine integration, ten analytics only) and thirteen consumed events. 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); 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
subjectthe aggregate root id: visitId for yardvisit, trailerId for trailer, moveId for yardmove, yardCheckId for yardcheck
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, trailers, arrived_at, versionCheckInVisitdock-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 or SITE_REQUEST.

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, versionDepartoutbound-shipping

kind in TrailerDwellExceeded is the TrailerKind whose threshold was crossed. 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).

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 YardKpiReport 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, versionCheckOutVisit
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, versionPlaceHold (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. 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

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

Derived from: model.yaml → contexts[yard-management].consumes, .policies, .read_models, and the producers' publishes[*].data for dock-scheduling.

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).
  • VisitCheckedIn is also consumed by inbound-receiving (its ADR 0021): it stores the earliest arrived_at per appointment_id in a visit_arrivals local copy for the dock-to-stock KPI and ignores a visit without an appointment_id.
  • VisitRejected is consumed by dock-scheduling, which cancels the appointment with TURNED_AWAY (decision X2, YM-G17), and by exception-management.
  • The AsyncAPI description of TrailerDocked says inbound-receiving consumes it; on develop it does not (the optional confirm of the door on an open receipt was not built), while outbound-shipping does. The upstream spec text is to be corrected in the producer's repository.
  • The consumed lines of ASNRegistered is used by no rule on these pages (gap YM-G26, accepted).