Sequence Diagrams
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).
Two parts. Part A has the four scenarios the pack must show, each as one story
across several use cases: inbound adapter → use cases → aggregates → outbox → relay →
Kafka → neighbour. Part B has one diagram per significant command use case of
Use Cases, in the hexagonal layout of the built service:
inbound adapter → use case → aggregate → repository → outbox (same transaction) → relay →
Kafka. The relay and Kafka share one lifeline ("relay to Kafka") to keep each diagram at
six participants or fewer. alt blocks show error branches, optimistic-concurrency
version checks and idempotency (REST Idempotency-Key, Kafka inbox on the CloudEvents
id). Error names are the model's; HTTP statuses of domain errors follow decision D-10: 409 conflicts, 422 value rules (see
Use Cases).
The MCP tools and the A2A skills call the same use cases through the same
transaction (their mapping is on Use Cases;
the delegated flow is on Domain Message Flow).
Route parameters are written without braces. The relay publishes integration events to
warehouse.yard-management.events and, as a twin, to warehouse.yard-management.analytics; analytics-only events
go to the analytics topic alone. Both are keyed by the aggregate root id.
Part A: the four scenarios
A1. Live unload
An inbound carrier with a booked door: check-in, the visiting driver's move to the door, docking, door work closed by the receipt, check-out.
Derived from: model.yaml → contexts[yard-management].policies[DirectOnCheckIn, VisitingDriverMove, AutoCompleteUnload], .aggregates[YardVisit, Trailer, YardMove],
.publishes; contexts[dock-scheduling].policies.
Omitted: the failure branches (Part B), the analytics events (VisitCheckedOut,
DoorWorkStarted, YardMove*; DoorWorkCompleted and TrailerDeparted also go to the integration topic since
2026-11-09), and inbound-receiving's own receipt flow. Depart from the door under CheckOutVisit raises
TrailerUndocked and TrailerDeparted (decisions Y-2, Y-6). The dock operator or gate clerk completes the
first move through the completion route (decision Y-3).
A2. Drop, then a later door call
A carrier drops a trailer whose door is busy; the trailer waits in a spot; when the door frees, a hostler moves it in; after unloading it is returned to a spot.
Derived from: model.yaml → contexts[yard-management].policies[DirectOnCheckIn, CallToDoor, ClearDoorAfterWork], .aggregates[Trailer, YardMove], .publishes[TrailerUndocked, TrailerDocked]; contexts[dock-scheduling].policies[CompleteOnDoorRelease].
Omitted: the door work commands (A1), YardMoveRequested, YardMoveClaimed,
YardMoveCompleted and TrailerParked (analytics only), the idempotency and inbox rows.
CallToDoor reacts to the own TrailerUndocked; this pack reads that as a consumer of
the own topic, as dock-scheduling consumes it. StartMoving from DOCKED (the claim of a FROM_DOOR move)
raises TrailerUndocked (decision Y-6); the trailer carries its appointment through appointment_id (decision X3);
the first move to a plain spot has the reason TO_SPOT (decision Y-4).
A3. Gate rejection
A walk-in at a site that requires appointments; then a seal mismatch under both policies.
Derived from: model.yaml → contexts[yard-management].aggregates[YardVisit]
(invariants, commands), .policies[SealCheckAtGate], .aggregates[YardPolicy],
.reasons[RejectionReason], .publishes[VisitRejected, SealExceptionRaised];
fleet_changes[exception-management].
Omitted: ErrTrailerAlreadyOnSite (reason TRAILER_ALREADY_ON_SITE), UNKNOWN_APPOINTMENT
and SITE_REQUEST rejections; the detail that dock-scheduling now receives VisitRejected and cancels the
appointment with TURNED_AWAY (decision X2). A refused CheckInVisit creates nothing and RejectAtGate records the
rejection (decision Y-5). The seal number arrives with the trailer at check-in, and a rejected visit's
SealExceptionRaised has a null trailer_id (decisions Y-5, Y-13).
A4. A hostler claims a move, the lease expires, another hostler completes it
Derived from: model.yaml → contexts[yard-management].aggregates[YardMove, Trailer]
(transitions, invariants, notes), .policies[LeaseExpirySweep], .inbound, .rest.
Omitted: the Idempotency-Key rows; ErrHostlerBusy when a hostler already holds a
CLAIMED move; the late completion after expiry when nobody has re-claimed the move,
which is ErrIllegalTransition (the move is REQUESTED). The expiry returns the move to
REQUESTED and ReturnToOrigin brings the trailer back (decision Y-1), raises YardMoveLeaseExpired (decision
Y-10) and has no lease renewal. A refusal at ArriveAt still happens when the hostler is already at the
location; the destination was also validated when the move was requested (decision Y-8).
Part B: one diagram per significant command
Commands not drawn follow a pattern shown here: RejectAtGate (A3); RecordArrival,
DirectOnCheckIn inside B1; StartMoving inside B4; ArriveAt inside B5; Depart
inside B2; RecordSeal, BreakSeal, RecordLoadState, ReleaseHold as B9 (load, check
state, mutate, version check, optional outbox row); OpenYardCheck, RecordObservation
and DeclareYardPolicy as B11 without the outbox.
B1. CheckInVisit
Derived from: model.yaml → contexts[yard-management].aggregates[YardVisit, Trailer]
(commands, invariants), .policies[DirectOnCheckIn, VisitingDriverMove, SealCheckAtGate], conventions.integration_rules.
Omitted: the REJECT seal outcome (A3); the choice of door, holding spot or parking spot
(A2); each domain error is answered 409 or 422 (decision D-10). The first move's events
(YardMoveRequested, YardMoveClaimed) go to the analytics topic; the move is created CLAIMED, so the
service raises both (decision Y-1).
B2. CheckOutVisit
Derived from: model.yaml → contexts[yard-management].aggregates[YardVisit, Trailer]
(invariants, transitions), .publishes[VisitCheckedOut, TrailerDeparted, TrailerUndocked].
Omitted: the idempotency-key check (as in B1). Depart is called from here for each trailer taken out
(decision Y-6). For a live visit the trailer leaves from the door: released means no open move and either
PARKED or DOCKED with door work DONE (decision Y-2).
B3. RequestMove
Derived from: model.yaml → contexts[yard-management].aggregates[YardMove]
(invariants, commands), .policies[CallToDoor, ClearDoorAfterWork].
Omitted: the idempotency-key check; the Kafka inbox row when a policy is the caller. The
destination is validated at the request (known slot, closure, flow, hold, ErrDestinationReserved,
ErrTrailerHasOpenMove) and again at arrival (decision Y-8).
B4. ClaimNextMove
Derived from: model.yaml → contexts[yard-management].aggregates[YardMove, Trailer]
(invariants, transitions, notes), .business_decisions.
Omitted: the idempotency-key check. The claim order is the lowest band, then due_by, then request time
(decision Y-11); with nothing to claim the answer is 404 no-claimable-move; a claim from a door raises
TrailerUndocked (decision Y-6).
B5. CompleteMove
Derived from: model.yaml → contexts[yard-management].aggregates[YardMove, Trailer]
(invariants, notes), .read_models[LocationView, DoorClosureView].
Omitted: the idempotency-key check. For a VISITING_DRIVER move there is no lease; the dock
operator or gate clerk completes it through the same route (decision Y-3). The partial unique index on active
occupancy is the race-safe backstop for ErrLocationOccupied.
B6. ExpireLease
Derived from: model.yaml → contexts[yard-management].policies[LeaseExpirySweep],
.aggregates[YardMove].transitions.
Omitted: the outbox row for YardMoveLeaseExpired (analytics only, decision Y-10) and the
ReturnToOrigin step on the trailer (decision Y-1), both in the same unit of work as the move. Each
move is its own transaction, so one conflict does not stop the sweep.
B7. CancelMove
Derived from: model.yaml → contexts[yard-management].aggregates[YardMove].transitions,
.policies[NoShowFreesHolding].
Omitted: the idempotency check and the inbox row. A cancelled CLAIMED hostler move runs ReturnToOrigin in the same
unit of work, so the trailer goes back where it was (decision Y-1); the policy finds the move through the
appointment_id that the move carries (decisions X3, Y-14).
B8. StartDoorWork and CompleteDoorWork
Derived from: model.yaml → contexts[yard-management].aggregates[Trailer]
(value_objects[DoorWork], commands), .policies[AutoCompleteUnload, ClearDoorAfterWork], .publishes[DoorWorkStarted, DoorWorkCompleted].
Omitted: the AutoCompleteUnload caller (a ReceiptClosed consumer: inbox row instead of
the idempotency key, joining ReceiptAtDoorView to the trailer through receipt_id, decision Y-7) and the
follow-up RequestMove of ClearDoorAfterWork for a DROP trailer (B3). AutoCompleteUnload completes from
WAITING or IN_PROGRESS; an operator's completion needs IN_PROGRESS (assumption A11).
B9. PlaceHold
Derived from: model.yaml → contexts[yard-management].aggregates[Trailer]
(invariants[ErrTrailerOnHold], commands), .reasons[HoldReason].
Omitted: the idempotency-key check. A hold on an already DOCKED trailer is allowed and door work waits for
the release (decision Y-13); a held trailer is refused docking at ArriveAt (B5).
B10. DwellSweep
Derived from: model.yaml → contexts[yard-management].policies[DwellSweep],
.aggregates[YardPolicy] (dwell_threshold_minutes), .publishes[TrailerDwellExceeded].
Omitted: a kind with no threshold (skipped). The marker that makes the sweep "once per
trailer and threshold crossing" is dwell_alerted_at on the trailer (decision Y-13); the sweep has no aggregate
command of its own.
B11. CloseYardCheck
Derived from: model.yaml → contexts[yard-management].aggregates[YardCheck],
.publishes[YardCheckClosed].
Omitted: the idempotency-key check. OpenYardCheck and RecordObservation are the same
shape without the outbox row (ErrYardCheckOpen and ErrLocationAlreadyObserved as the
guards). The discrepancy rules are decision Y-11 (a location not observed is MISSING when the model records a trailer
there) and nothing applies a discrepancy to a trailer: closing only reports; exception-management opens one case
per discrepancy.