Lane schedules
Weekly templates that generate a lane's departures (aggregate LaneSchedule).
Introduction
REST contract of the linehaul-transportation bounded context of the retail network, derived from retail-network-docs apis/linehaul-transportation/openapi.yaml and model/model.yaml (contexts[linehaul-transportation].rest), adjusted by the Model Gap Register decisions G3, G9, G14, G15, G28 and G29 and by the cross-context decisions E3, E13, E14 and E16 (ADR 0002). The service runs the middle mile: it turns lane schedules and the declared cutoffs of vendor nodes into scheduled departures, keeps each departure's remaining capacity, builds loads of packages onto departures and reports when loads depart and arrive. The planner calls the lane-schedule routes, the departure cancellation and capacity routes; sort-centre and station operators call the load routes; any context may call the departure reads. Domain events are published on Kafka (apis/asyncapi.yaml), never over REST. No authentication, consistent with the fleet. Errors are RFC 9457 problem details; the shared problem types are not-found (404), illegal-transition (409), concurrent-update (409) and validation-failed (422), plus one type per model Err name. Every POST takes a required Idempotency-Key; PUT is idempotent by method.
Add a package to an open load (AddPackage)
Refused with 409 package-already-loaded (ErrPackageAlreadyLoaded) if the tracking number is on another OPEN or CLOSED load, and with 409 load-over-capacity (ErrLoadOverCapacity) if the load would exceed its capacity snapshot. On a LINEHAUL or AIR departure the package is also booked on the departure (gap G15): 409 departure-full or departure-closed when it cannot be. On a PICKUP departure the booking was made at FulfillmentLocked and booked does not change. Adding a tracking number that is already on this load changes nothing.
Cancel a scheduled departure (CancelDeparture)
Moves a SCHEDULED departure to CANCELLED and publishes DepartureCancelled, which delivery-promise and order-sourcing use to re-promise. Every assignment booked on the departure is rebooked onto the next departure from the same origin (BookingMoved) or reported as BookingFailed when none fits. Cancel before cutoffAt wherever possible. Cancelling a CANCELLED departure returns it unchanged.
Change the package capacity of a scheduled departure (ChangeDepartureCapacity)
Planner command added by gap G28. Allowed on a SCHEDULED departure; the new capacity may not be below the packages already booked (departure-full). Publishes DepartureCapacityChanged. A capacity equal to the current one changes nothing and publishes nothing. A load that is already open keeps the capacity snapshot it took at OpenLoad.
Close an open load (CloseLoad)
OPEN to CLOSED; closes the departure of the load (CloseDeparture) and publishes LoadClosed on the analytics stream. Closing a CLOSED load returns it unchanged.
Define the weekly schedule of a lane (DefineLaneSchedule)
Creates the ACTIVE weekly template of one lane, or replaces the slots of an ACTIVE template (201 on creation, 200 on replacement; a redefinition takes effect from the next horizon roll, departures that were already generated stay). The lane must be known (LaneView). Slots must not overlap on the same weekday (overlapping-slots). A RETIRED schedule cannot be redefined (illegal-transition). Raises no event. Departures are generated by GenerateDepartures (policy HorizonRoll).
Departures
Departures
Dispatch a closed load (DispatchLoad)
CLOSED to DEPARTED; records the departure of the trip (RecordDeparture) and publishes LoadDeparted (with departureKind and nodeType) and DepartureDeparted. Dispatching a DEPARTED load returns it unchanged.
Get one departure
Returns the departure with its capacity, booked and remaining packages and its state.
Lane schedules
Lane schedules
List departures by origin, destination and time window (ListDepartures)
Open Host Service read for any context. Filters are ANDed; from and to bound cutoffAt (from inclusive, to exclusive). Ordered by cutoffAt then departureId, keyset-paged: limit (1-500, default 100) and the opaque cursor from nextCursor; filters are repeated on every page request. Any other query parameter is 400 unknown-query-parameter.
Loads
Loads
Open a load on a departure (OpenLoad)
Opens the load of a SCHEDULED departure, copying the origin, destination, departure kind, node types and the capacity of the departure into the load. A departure has at most one load (load-already-exists). Raises no event.
Receive a load at its destination node (ReceiveLoad)
DEPARTED to ARRIVED; records the arrival of the trip (RecordArrival) and publishes LoadArrived (with departureKind and nodeType), which last-mile-delivery uses to induct the packages at a delivery station, and DepartureArrived. Receiving an ARRIVED load returns it unchanged.
Retire the schedule of a lane (RetireLaneSchedule)
Moves the schedule from ACTIVE to RETIRED; GenerateDepartures skips it from now on and the departures already generated stay. Retiring a RETIRED schedule returns it unchanged. Raises no event.