ADR 0008: Requoted delivery dates in the destination's time zone
Status
Accepted (2026-10-30).
Context
A definitive 409 from customer-ordering's POST /checkout (offer-not-quotable,
promise-capacity-exhausted, book-closed) carries requotedOffers, each with a delivery
window as two instants (deliverByEarliest, deliverByLatest). The anti-corruption layer
(internal/adapters/outbound/customerordering/gateway.go) turns them into calendar dates
(cs.RequotedOffer) that checkout returns on the session, publishes on
CheckoutRequoteRequired and posts to shopping-cart /carts/{id}/delivery-requote-acceptances.
It formatted both instants in UTC. A shopper reads a window as days of the DESTINATION's
calendar: a Saturday 09:00-21:00 window in Chicago is 2026-10-31T14:00:00Z ..
2026-11-01T02:00:00Z, which UTC shows as Oct 31 - Nov 1, a day the window does not
touch locally.
delivery-promise (its ADR 0011) now names the destination's IANA zone as an optional
timeZone on every window, and customer-ordering relays it on each requoted offer
(requotedOffers[].timeZone, additive). It is absent for rows stored before the change.
shopping-cart already reads quoted windows in that zone (its ADR 0007); the requote path
must agree with it, or the cart flips its dates when checkout requotes.
Weighed alternatives:
- Send the instants and the zone to shopping-cart and let it format. Rejected: the cart's
requoted endpoint takes dates, the session and the
CheckoutRequoteRequiredevent expose dates, and changing three contracts for a formatting rule is more than the fix needs. - Keep UTC. Rejected: it is the bug.
- Use the server's local zone. Rejected: it is the cluster's zone, never the destination's.
Decision
- The gateway reads the optional
timeZoneof each requoted offer and formats both window bounds astime.DateOnlyin that zone. Each offer uses its own zone. - A missing zone, the name
Local(the process zone), or a name the zone database does not know falls back to UTC, the dates checkout sent before. Each such name is logged at WARN the first time the gateway sees it (zonesininternal/adapters/outbound/customerordering/zone.go, the same shape as shopping-cart's resolver), so a provider that never sends the zone, or sends a bad one, is visible without flooding the log. At most 64 names are cached; past that a name is still resolved, only not cached or warned about. cmd/api/tzdata.goembeds the zone database (time/tzdata), so names resolve on a base image without tzdata. Onlycmd/apiplaces orders;cmd/mcpandcmd/a2ado not need it.- Checkout's own contracts are unchanged in shape:
deliverByEarliest/deliverByLateststayformat: date; their descriptions now say they are the destination's calendar days (apis/openapi.yamlRequotedOffer,apis/asyncapi.yamlCheckoutRequoteRequired). No new field, no new event version.
docs/adr has no index file (see ADR 0006), so none is edited.
Consequences
- A requoted window that is one local day shows as one day, in the session, in the event and in the cart, matching what shopping-cart shows for the original quote.
- Until customer-ordering relays
timeZone, every requote logs one WARN (the empty name) per process and keeps UTC dates: nothing breaks, the gap is visible. - The binary grows by the embedded zone database (about 450 KB).
- Tests:
internal/adapters/outbound/customerordering/zone_test.go(Chicago 14:00Z..02:00Z is 2026-10-31 for both bounds; a missing zone reads as UTC; unusable names warn once; the cache is bounded).