Repository navigation
fix(timezones): SUPPORTED_TIMEZONES order is not reproducible, so the contract step emits a 111 KB no-op migration - #728
Conversation
…nt one `@vvo/tzdb`'s `getTimeZones()` returns its zones sorted by `currentTimeOffsetInMinutes`, and `SUPPORTED_TIMEZONES` inherited that order. That value moves at every DST boundary in any zone the list covers, so the order of five Postgres enums was a function of the date the migration was generated: a clean checkout of `main` produced a 111 KB migration that dropped and recreated all five `*_tz` types with no schema change (#722). Confirmed rather than assumed. `Pacific/Easter` reports `rawOffsetInMinutes: -360` and `currentTimeOffsetInMinutes: -300` today, because Chile entered DST on 2026-09-06 — one day after the committed snapshot was written. Regenerating moved exactly the three Chilean zones. `rawOffsetInMinutes` is fixed for a zone, so sorting on it is stable on any machine and on any date. It also agrees with the label: we render `zone.rawFormat`, so before this fix `Pacific/Easter` read `(-06:00)` while sitting in the `-05:00` group for half the year. The tie-break compares code units rather than calling `localeCompare`. Collation depends on the host's ICU version, which is the same class of non-determinism this module already avoids by not using `Intl.supportedValuesOf('timeZone')`. The list is now pinned by digest in `tests/unit/timezone-options.spec.ts`, so a `@vvo/tzdb` bump or a clock change fails a unit test instead of surfacing as a migration diff nobody reads. Three assertions, each confirmed failing at the site that causes it and each for its own reason: - the sort removed entirely -> all three red - sorted, but on `currentTimeOffsetInMinutes` -> digest and ordering red, the input-order case green, since that defect is order-independent but wrong `src/migrations/AGENTS.md` recorded this as an undiagnosed false positive. The set-comparison rule there still stands, because a widening still looks like a reorder, but a reorder now means a red spec first. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_011WhkKoQTCGvJymk1XySE9r
The one-time cost of the fix in the previous commit. Generated by the contract step, not written by hand. `src/payload-types.ts` and the five enum types are a pure reorder: the line multiset of the regenerated file is identical to the committed one, so no member is added or removed. Each column is cast to `text` and back with a `USING` clause, and `down()` mirrors `up()`, so every stored value survives. Re-running `pnpm db:migrations:create --skip-empty` after this commit creates nothing, which is the acceptance criterion this migration exists to satisfy. Deployment note: the five `ALTER COLUMN ... SET DATA TYPE` pairs rewrite `events`, `_events_v`, `app_cards`, `_app_cards_v` and `registrations` under an ACCESS EXCLUSIVE lock. Migrations apply in-process on boot. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_011WhkKoQTCGvJymk1XySE9r
…ost ICU Adversarial review found the order was only half the problem. `getTimeZones()` resolves every zone through `Intl` and silently drops any the host cannot format — `dist/getTimeZones.js` returns the accumulator unchanged when the offset lookup throws. So the enum's MEMBERSHIP was a function of the runtime's ICU version, which is precisely the dependency this module's own doc comment disclaims. An older runtime would have generated a shorter enum. `rawTimeZones` is the static export behind that call and carries all four fields used here (`name`, `group`, `rawFormat`, `rawOffsetInMinutes`), so this costs nothing: `pnpm generate:types` produces a byte-identical `src/payload-types.ts`, the pinned digest does not move, and no extra migration is needed. It is invisible on this box, where 0 of 315 zones drop. Three specs cover it, each confirmed failing at its own site. The matrix now separates four defect classes: | reintroduced | pin | ordering | input-order | mock-wired | no-ICU | | --------------------- | --- | -------- | ----------- | ---------- | ------ | | no sort | red | pass | red | pass | red | | sorted on current off | red | red | red | red | red | | right key, ICU source | ok | pass | red | red | red | | tie-break removed | red | pass | red | pass | red | Row 3 is why the new cases exist: the previous specs passed it outright. Also from review: the reversal case could have gone vacuous if the mock ever stopped applying, so a second case proves the stub is wired by truncating it. The comparator moves to a named `byName` helper, which puts the sort back under Prettier's 100-column width — the branch was failing `prettier --check`, which neither `pnpm lint` nor CI would have caught. `src/migrations/AGENTS.md` said a green spec beside a reorder migration means the pin was edited. That is not exhaustive, and this PR is the counter-example: a stale committed snapshot produces the same pair and must be committed. Both cases are now named, with how to tell them apart. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_011WhkKoQTCGvJymk1XySE9r
|
🚅 Deployed to the SahajCloud-pr-728 environment in sahajcloud
1 service not affected by this PR
|
Brings #727 onto this branch after its squash-merge. The one conflict was `src/payload-types.ts`, the generated file this PR exists to stabilize. Resolved by regenerating with `pnpm generate:types` rather than by hand — which reproduced this branch's version byte for byte, the property the PR adds. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01XmzSzbuPBtmPwBnsFuaoPk
Review asked for both. Neither changes behaviour — the unit lane is unchanged at 1618 passing. `src/lib/timezones/index.ts` — the docblock's 24-line #722 section becomes 7, and the sort comparator's 6-line note becomes 2. Every imperative survives: sort on `rawOffsetInMinutes`, read the static `rawTimeZones`, compare code units rather than `localeCompare`, and the pointer to the spec that pins both membership and order. What went was the narrative — the 111 KB migration, the `Pacific/Easter` label example, and the walk through `getTimeZones.js`'s accumulator. That story is on #722 and in the PR body. `src/migrations/AGENTS.md` — the "read the DDL first" section described a diagnosis that was open when it was written. With the cause fixed, the two paragraphs about telling an ambiguous reorder from a real change are stale, and the "commit it, the snapshot is stale" case describes only this PR's own one-time catch-up. Cut to the check that stays live: a widening still looks exactly like a reorder, so compare the member lists as sets. The surviving default on a reorder is now the safe one — do not commit it until you know why the list moved. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01XmzSzbuPBtmPwBnsFuaoPk
|
Both comments applied in
The merge's one conflict was Lean gate green (1618 unit tests). Threads resolved, re-requested. 🤖 Written by the sydevs autonomous loop — see what this is Generated by Claude Code |
|
CI is red on the e2e lane only, and the cause is not this PR. All 8 failures are A 404 is not the credential case the assertion's message suggests. A wrong password returns 401. The whole preview host 404s,
#714 carries an unrelated diff. Its run failed at 19:22 and its preview host 404s the same way. Production answers. Railway's own commit status for No re-run spent — it fails identically while the host 404s. Re-run the job once previews serve again. The other three checks are green. 🤖 Written by the sydevs autonomous loop — see what this is Generated by Claude Code |
Summary
SUPPORTED_TIMEZONESnow sorts onrawOffsetInMinutesinstead of inheritinggetTimeZones()'s current-offset order, which moved at every DST boundary.rawTimeZones, so membership no longer depends on the host's ICU version.@vvo/tzdbbump or a clock change fails CI instead of surfacing as a migration diff.Changes
src/lib/timezones/index.ts— impose the order, read the static export, rewrite the doc commenttests/unit/timezone-options.spec.ts— pin the list; three new casessrc/migrations/AGENTS.md— trim the "false positive" section to the check that stays livesrc/payload-types.ts,src/migrations/20260907_181403_reorder_timezone_enums.*— generatedPreview
firstDate_tzpicker) — https://sahajcloud-sahajcloud-pr-728.up.railway.app/admin/collections/eventsContract impact
src/payload-types.tschanges, andpnpm types:cmscopies it into WeMeditateWeb. The change is a pure reorder of theSupportedTimezonesunion — the line multiset of the regenerated file is identical to the committed one, so no consumer loses a member. Nothing downstream depends on the order.Migration
src/migrations/20260907_181403_reorder_timezone_enums.ts*_tzenum types (events,_events_v,app_cards,_app_cards_v,registrations) are dropped and recreated to reorder their members. No table, no column, no data change. Each column is cast totextand back with aUSINGclause, and the member set is unchanged, so no stored value can be orphaned.down()mirrorsup()and restores the previous order.⚠ This is the one-time catch-up the fix makes necessary. The five
ALTER COLUMNpairs rewrite those tables under an ACCESS EXCLUSIVE lock, and migrations apply in-process on boot.Test results
pnpm lint,pnpm typecheck,pnpm typecheck:tests,pnpm test:unit(125 files, 1618 tests)events,session-reminders,registrations-fullnesspnpm db:migrations:create --skip-emptynow creates nothing on a clean tree — acceptance criterion 4Every new assertion was confirmed failing first, at the site that causes it. Four defect classes, and each column is a different spec:
currentTimeOffsetInMinutesgetTimeZones()nametie-break removedRow 3 is why the last three cases exist — the first version of this PR passed it outright.
Manual verification
Notes for reviewer
Etc/GMT*labels are sign-inverted (index.ts, pre-existing).Etc/GMT-3is really UTC+03:00 but is labelled(UTC-03:00), and the comment directly above claims the opposite. Confirmed againstIntlfor all 27. It is label-only, needs no migration, and fix(timezones): SUPPORTED_TIMEZONES order is not reproducible, so the contract step emits a 111 KB no-op migration #722 puts "which timezones are supported" out of scope — so it is filed as fix(timezones): the 27 Etc/GMT* picker labels show the inverted offset, and the comment above them claims otherwise #729 rather than widened into this PR.AGENTS.mdguidance). The fifth is fix(timezones): the 27 Etc/GMT* picker labels show the inverted offset, and the comment above them claims otherwise #729 above.securityReview.triggerPattern.Detail
Review round
7abcb10. Both comments applied, andorigin/mainmerged in after #727 landed. The docblock's #722 section is down from 24 lines to 7, and the sort comparator's note from 6 to 2 — every imperative kept, the narrative dropped to #722 and to this body. Insrc/migrations/AGENTS.md, the paragraphs describing the diagnosis while it was still open are gone, along with the "the snapshot is stale, commit it" case, which only ever described this PR's own catch-up. What stays is the check that outlives the fix: a widening still looks exactly like a reorder, so compare the member lists as sets. Its default on a reorder is now the safe one — do not commit until you know why the list moved.The merge's one conflict was
src/payload-types.tsitself. It was resolved by runningpnpm generate:types, which reproduced this branch's file byte for byte — the property the PR adds, exercised against a moving base rather than asserted.Root cause, confirmed rather than assumed.
Pacific/EasterreportsrawOffsetInMinutes: -360andcurrentTimeOffsetInMinutes: -300today, because Chile entered DST on 2026-09-06 — one day after the committed snapshot was written.getTimeZones()sorts on the latter, so regenerating moved exactly the three Chilean zones. The reorder is date-driven, not machine-driven, and would return at every DST boundary in any zone the list covers.Why the tie-break does not call
localeCompare. Collation depends on the host's ICU version, which is the same class of non-determinism the module already avoids by not usingIntl.supportedValuesOf('timeZone'). IANA names are ASCII, so a code-unit compare is total: every(rawOffsetInMinutes, name)pair is unique, so no tie ever falls through tosort's own stability and the input order cannot leak.Why
rawTimeZonescosts nothing.getTimeZones()israwTimeZonesplus per-zoneIntlresolution, and it silently drops any zone the host cannot format — so it decided membership, not just order. The builder reads only the four fields present on the raw records, so switching produced a byte-identicalpayload-types.tsand left the pinned digest unmoved. It adds no migration of its own, and is invisible on a current runtime, where 0 of 315 zones drop.Ordering is only asserted where it is imposed.
UTCand Payload's curateddefaultTimezonesare seeded ahead of the tzdb loop to keep their friendlier labels, so the monotonic case excludes them rather than asserting them out of order. TheEtc/GMT*range is appended last and is not in the tzdb map at all.Closes #722
🤖 Written by the sydevs autonomous loop — see what this is
🤖 Generated with Claude Code
https://claude.ai/code/session_011WhkKoQTCGvJymk1XySE9r