ADR 0020: The appointment copy follows reschedules and door reassignments
Status
Accepted (2026-11-09). Amends ADR 0019
point 2 (the types the DockAppointmentConsumer acts on) and the Consequences
bullet on rescheduled appointments. Does not edit ADR 0019's body.
Context
ADR 0019 made appointments a read-only copy of dock-scheduling's
appointments and fed it from two types only, DockAppointmentBooked and
DockAppointmentCancelled; it reasoned that "reschedules do not change ASN
coverage and are not needed".
They are needed for the door. dock-scheduling reschedules an appointment (a new
window and possibly a new door) and the yard reassigns its door when the booked
one is busy or closed. The copy kept the door of the booking, and OpenReceipt
stamps the receipt with the door on the copy, so a receipt could name a door the
truck is not at. Receipts, yard-management's door occupation and the door
figures of the receiving-performance report then disagree.
Decision
-
Two more types. The
DockAppointmentConsumer(consumer namedock-appointment-copy, topicwarehouse.dock-scheduling.events) also acts on:com.warehouse.wms.dock-scheduling.dockappointment.DockAppointmentRescheduled. Payload (snake_case):appointment_id,site_id,door_code,previous_door_code,window_start,window_end,previous_window_start,previous_window_end,arrival_tolerance_minutes,version. The copy takesdoor_code,window_startandwindow_endatversion.com.warehouse.wms.dock-scheduling.dockappointment.DockAppointmentDoorReassigned. Payload:appointment_id,site_id,from_door_code,to_door_code,version. The copy takesto_door_codeatversion;from_door_codeis informational (logged, not checked). dock-scheduling is moving this type onto its integration topic in a separate change; until that is deployed it simply never arrives, and nothing here depends on it.
The payloads are restated in
apis/asyncapi.yaml, never imported. Every other type on the topic (NoShow, check-in, door closures, ...) is still committed past. -
Same rules as Booked and Cancelled (use cases
ApplyDockAppointmentRescheduledandApplyDockAppointmentDoorReassigned, store methodsApplyRescheduledandApplyDoorReassigned):- Version guard: applied only when
versionis greater than the stored one. Reschedules, reassignments, bookings and cancellations share one version line, dock-scheduling's aggregate version. - The CloudEvents
idclaim inprocessed_eventsand the update commit in one unit of work; the offset is committed afterwards. - No loop: nothing is written to the outbox; unit, BDD and real-Postgres tests pin it, as for the other two types.
- Version guard: applied only when
-
Unknown appointment. A reschedule or reassignment of an appointment the copy does not hold (an
OUTBOUNDappointment is never copied, or one not seen yet) isIgnored: the claim commits, no row is created, and the consumer logs it at DEBUG, not WARN, because it is the normal case. A cancelled appointment is never revived: a newer reschedule or reassignment refreshes its door (and window) and the state staysCancelled, as ADR 0019 already does for a later Booked. -
Open receipts keep their door. The door on a receipt that is already
Openis a physical fact (where the truck was unloaded) and does not follow the appointment. Only receipts opened after the change take the new door from the copy. -
Invalid payloads. An empty or malformed
appointment_id,version < 1, an empty or invalid door, orwindow_end <= window_startisErrInvalidEvent: WARN and commit past, nothing claimed, as for the other types. A transient failure rolls back and is retried.
Consequences
- The copy's door and window are dock-scheduling's current ones, so a receipt opened after a reschedule or a door reassignment names the door the truck is at, and receipts agree with yard door occupation for new receipts. This replaces ADR 0019's Consequences statement that "the door on the receipt is the one on the copy, which a Rescheduled event does not refresh".
- A receipt opened before the change keeps the old door. Correcting the door of an open receipt is out of scope: it would need a receipt event and an operator decision, not a copy update.
- No-show and completion are still not consumed; a receipt can still be opened on a no-showed or completed appointment, and only a cancellation blocks one.
- ASN coverage is unchanged by both types; the ASN list still comes from
DockAppointmentBookedonly. - Until dock-scheduling publishes
DockAppointmentDoorReassignedon its integration topic, door reassignments reach the copy only through a reschedule that carries the new door. - No migration: the update touches existing columns of
appointments.