ADR 0014: the day-of ETA window on the tracking view
Status
Accepted (2026-11-11). Part of the Wave 3 E3 design (a two-hour delivery window
on the day of delivery). Builds on
ADR 0003 (consumed
contracts and the tracking read model),
ADR 0004 (the catalogue; this
slice publishes nothing) and
ADR 0012 (a package
shared by merged groups is listed once per group). The provider of the window is
last-mile-delivery (its ADR 0013, StopEtaWindowAssigned); the relay is
shipping-and-tracking (its ADR 0013, PackageEtaWindowAssigned). This repo
builds against the WRITTEN event contract below, never against a sibling's code.
Context
Once a package is out for delivery the shopper wants to know WHEN, not only that it is on its way. last-mile-delivery spreads the stops of a route over the wave's delivery window and assigns each stop a window of at most two hours; shipping-and-tracking keeps the window on the package journey and republishes it per tracking number. customer-ordering holds the order and the tracking view, and is the context the shopper reads.
What customer-ordering has today: GET /orders/{orderId}/tracking joins the order
aggregate with the GroupSignals and Packages read models (ADR 0003). A package
row is tracking_packages, keyed by tracking_number and upserted by every
consumer in any arrival order. The group promise (deliverByEarliest,
deliverByLatest, status, verdict) is a coarse promise; the window is a finer,
later, day-of estimate and must never touch it.
Decision
- Consume the window. The shipping-and-tracking consumer handles the FULL type
com.retailnetwork.logistics.shipping-and-tracking.journey.PackageEtaWindowAssigned(topicretailnetwork.shipping-and-tracking.events, subject and key = the tracking number, dataschemaurn:retailnetwork:shipping-and-tracking:events:PackageEtaWindowAssigned:v1), datatrackingNumber,assignmentId,orderId,etaStart,etaEnd,assignedAt(RFC 3339 UTC). Decoding is tolerant (unknown fields are ignored). A blank tracking number, oretaStart >= etaEnd, is a bad payload and is dead-lettered. No new topic, consumer group or environment variable. - Apply it in the inbox unit.
Consumer.ApplyPackageEta(new fileconsume_eta.go) claims the CloudEvents id and callsTrackingRepository.ApplyEta(ctx, readmodel.Eta{TrackingNumber, AssignmentID, OrderID, Start, End, AssignedAt}).AssignedAtis the event'sassignedAt, falling back to the CloudEventstimewhen the payload lacks it. - Store it on the package row.
ApplyEtaupserts ontracking_number, creating the row when absent (the same arrival-order tolerance asApplyException:assignment_idandorder_idare coalesced, then the assignment link is applied). The three fields are stored only whenAssignedAtis not older than the storedeta_assigned_at(latest wins; an equal instant rewrites the same values). Migration0009_tracking_package_etaaddstracking_packages.eta_start,eta_end,eta_assigned_at(timestamptz NULL, a CHECK that the three are all null or all non-null andeta_start < eta_end).readmodel.PackagegainsEtaStart,EtaEnd,EtaAssignedAt. - One view rule, in one place (
views.TrackingFrom). A package showsetaStartandetaEndonly when itsstateisOUT_FOR_DELIVERY,etaAssignedAtis non-zero andetaAssignedAtis not beforelastScanAt. Otherwise both are omitted. This is the same definition asEtaCurrentin shipping-and-tracking (both compare the scanatand the window's event time, which last-mile-delivery sets to the same instant). Consequences of the one rule: yesterday's window is stale as soon as a newer scan exists, a failed attempt (state back toAT_STATION) hides it, and no terminal state shows it. A package shared by merged groups is listed once per group (ADR 0012) and shows the window in each. - No clipping. The window is shown as received, even when it ends after the
group's
deliverByLatest: hiding a late window would contradict the judgement the promise still uses. - The promise is never read or written by this path. The group's promise
snapshot, status and verdict are byte-identical before and after a window event
(a test asserts it).
UpdateGroupPromisestays the only way the snapshot moves. - REST, MCP, A2A (additive). The OpenAPI
TrackingPackageschema gains optionaletaStartandetaEnd(date-time) with the description of rule 4; the MCPget_order_trackingtool, the order-tracking resource and the A2Aget_order_trackingskill mirror them. The storefront BFF passes the tracking body through unchanged, so it needs no change. The generated REST reference is regenerated in the same commit as the OpenAPI edit. - Consumed-contract registration.
apis/asyncapi.yaml(consumed section), the consumed list of ADR 0003, the docs and the ADR index list the new type; the consumed count goes from seventeen to eighteen. This service still publishes the same two events.
Consequences
- With the producers silent nothing changes: no row gains a window, the view omits both fields. Rollback of the migration is additive-safe (the columns are nullable).
- The window is a read-model fact, not an order fact: no aggregate, no outbox event and no new state.
- A window that arrives before the package is
OUT_FOR_DELIVERY, or before the assignment link, is stored and stays hidden until the scan and the rule agree. - Deploy order: this service first, then shipping-and-tracking, then last-mile-delivery. A consumer ignores a type it has no handler for and commits past it, so an event published before its consumer is deployed is lost for that package, not queued.
- The wording shown to the shopper belongs to the storefront; the API carries instants only.