From 0f44e6659277c29884214bab659447cc474f60ce Mon Sep 17 00:00:00 2001 From: "Craig C." Date: Fri, 6 Nov 2026 19:36:01 +0200 Subject: [PATCH 1/7] feat(canary): compare each calendar's years with native Temporal in the swap check (CORE-110, #468) The Node leg of the weekly temporal-polyfill swap check now runs a calendar sweep beside the offset sweep. For every calendar both implementations accept, and every calendar year that overlaps ISO years -3000 to 5000, it compares the first day of the year, the months in the year and the days in the year with Node's built-in Temporal. Any calendar that differs blocks the swap, and a sweep that did not run blocks too. On temporal-polyfill 1.0.8 against Node 26.12.1 it compares 16 calendars and 128,762 years in about 11 seconds. It reports Persian (fullcalendar/temporal-polyfill#127) and Chinese and Dangi (fullcalendar/temporal-polyfill#128). The other 13 calendars match. The upstream filings now list #127 and #128. --- .../dox/scripts/canary/calendar-sweep.test.ts | 223 ++++++++++++++++++ apps/dox/scripts/canary/canary-issues.test.ts | 123 +++++++--- apps/dox/scripts/canary/canary-report.test.ts | 13 + .../dox/scripts/canary/canary-summary.test.ts | 74 ++++++ .../dox/scripts/canary/canary-verdict.test.ts | 9 + apps/dox/scripts/canary/polyfill-swap.test.ts | 186 ++++++++++++++- apps/dox/src/data/upstream-filings.json | 52 +++- context/domination/issues/CORE-110.md | 73 ++++++ context/domination/issues/CORE-92.md | 3 +- context/domination/issues/index.md | 1 + context/domination/tracker.md | 1 + scripts/lib/calendar-sweep.mjs | 165 +++++++++++++ scripts/lib/canary-issues.mjs | 64 ++++- scripts/lib/canary-summary.mjs | 28 ++- scripts/lib/canary-verdict.mjs | 9 +- scripts/polyfill-swap.mjs | 60 ++++- 16 files changed, 1035 insertions(+), 49 deletions(-) create mode 100644 apps/dox/scripts/canary/calendar-sweep.test.ts create mode 100644 context/domination/issues/CORE-110.md create mode 100644 scripts/lib/calendar-sweep.mjs diff --git a/apps/dox/scripts/canary/calendar-sweep.test.ts b/apps/dox/scripts/canary/calendar-sweep.test.ts new file mode 100644 index 000000000..0b5d2274e --- /dev/null +++ b/apps/dox/scripts/canary/calendar-sweep.test.ts @@ -0,0 +1,223 @@ +import { describe, expect, it } from "vitest"; +import { + SPAN_FROM, + SPAN_THROUGH, + sweepCalendars, +} from "../../../../scripts/lib/calendar-sweep.mjs"; + +/** + * CORE-110: the calendar sweep. Unit rows use stand-in Temporal namespaces that model a calendar as + * a function of the year; the expected values are written out by hand, never read back from the + * module. The stand-in "iso" and "alt" calendars have years 1 to 3 for ISO -3000 to 5000 in this + * fake, so a row stays small. + */ + +type Facts = { iso: string; months: number; days: number }; +type Table = Record>; + +/** ISO year of the span's two ends, mapped to the stand-in calendars' years 1 and 3. */ +const YEAR_OF: Record = { [SPAN_FROM]: 1, [SPAN_THROUGH]: 3 }; + +const facts = (iso: string, months = 12, days = 365): Facts => ({ + iso, + months, + days, +}); + +/** A fake `Temporal`: `table[calendar][year]` is what a date's first day reads. */ +function fake(table: Table, refusing: string[] = []) { + return { + PlainDate: { + from(item: string | { calendar: string; year: number }) { + if (typeof item === "string") { + return { + year: 0, + monthsInYear: 0, + daysInYear: 0, + toString: () => item, + withCalendar: () => ({ + year: YEAR_OF[item] ?? 0, + toString: () => "", + }), + }; + } + if (refusing.includes(item.calendar)) throw new RangeError("no"); + const row = table[item.calendar]?.[item.year]; + if (row === undefined) { + // The accepts() probe reads year 2000, which every listed calendar answers. + if (item.year === 2000 && table[item.calendar]) { + return { + year: 2000, + monthsInYear: 12, + daysInYear: 365, + toString: () => "", + withCalendar: () => ({ + year: 2000, + toString: () => "2000-01-01", + }), + }; + } + throw new RangeError("out of range"); + } + if (row === "throws") throw new RangeError("bad year"); + return { + year: item.year, + monthsInYear: row.months, + daysInYear: row.days, + toString: () => "", + withCalendar: () => ({ year: item.year, toString: () => row.iso }), + }; + }, + }, + }; +} + +const same: Table = { + iso: { + 1: facts("-003000-01-01"), + 2: facts("0001-01-01"), + 3: facts("5000-01-01"), + }, +}; + +describe("sweepCalendars", () => { + it("reports a match: the fixed span, the compared calendars and the years read", () => { + expect( + sweepCalendars({ + candidate: fake(same), + reference: fake(same), + calendars: ["iso"], + }), + ).toEqual({ + status: "ran", + from: "-003000-01-01", + through: "+005000-12-31", + calendars: 1, + years: 3, + differingCalendars: 0, + differing: [], + differingTruncated: false, + }); + }); + + it("names a calendar whose first day differs, with the count, the first year and an example", () => { + const late: Table = { + iso: { + 1: facts("-003000-01-01"), + 2: facts("0001-01-02"), + 3: facts("5000-01-02"), + }, + }; + const result = sweepCalendars({ + candidate: fake(late), + reference: fake(same), + calendars: ["iso"], + }); + expect(result.differingCalendars).toBe(1); + expect(result.differing).toEqual([ + { + calendar: "iso", + years: 2, + first: 2, + example: + "year 2: candidate 0001-01-02, 12 months, 365 days; reference 0001-01-01, 12 months, 365 days", + }, + ]); + }); + + it.each` + label | candidate | reference + ${"months in year"} | ${facts("0001-01-01", 13)} | ${facts("0001-01-01", 12)} + ${"days in year"} | ${facts("0001-01-01", 12, 366)} | ${facts("0001-01-01", 12, 365)} + `("a difference in the $label alone counts", ({ candidate, reference }) => { + const result = sweepCalendars({ + candidate: fake({ iso: { ...same.iso, 2: candidate } }), + reference: fake({ iso: { ...same.iso, 2: reference } }), + calendars: ["iso"], + }); + expect(result.differing).toMatchObject([ + { calendar: "iso", years: 1, first: 2 }, + ]); + }); + + it("counts one side throwing as a difference and both throwing as a skip", () => { + const candidate = fake({ + iso: { ...same.iso, 2: "throws", 3: "throws" }, + }); + const reference = fake({ + iso: { ...same.iso, 2: facts("0001-01-01"), 3: "throws" }, + }); + const result = sweepCalendars({ + candidate, + reference, + calendars: ["iso"], + }); + expect(result.years).toBe(2); + expect(result.differing).toEqual([ + { + calendar: "iso", + years: 1, + first: 2, + example: + "year 2: candidate throws RangeError; reference 0001-01-01, 12 months, 365 days", + }, + ]); + }); + + it("reports a calendar only one side accepts, and skips one neither accepts", () => { + const result = sweepCalendars({ + candidate: fake({ ...same, alt: same.iso }, []), + reference: fake({ ...same, alt: same.iso }, ["alt", "none"]), + calendars: ["iso", "alt", "none"], + }); + expect(result.calendars).toBe(1); + expect(result.differingCalendars).toBe(1); + expect(result.differing).toEqual([ + { + calendar: "alt", + years: 0, + first: null, + example: "only the candidate accepts this calendar", + }, + ]); + }); + + it("says which side is missing the calendar", () => { + const result = sweepCalendars({ + candidate: fake({ ...same, alt: same.iso }, ["alt"]), + reference: fake({ ...same, alt: same.iso }), + calendars: ["alt"], + }); + expect(result.differing[0]?.example).toBe( + "only the reference accepts this calendar", + ); + }); + + it("lists at most 50 calendars and still counts them all", () => { + const names = Array.from({ length: 60 }, (_, i) => `c${i}`); + const table: Table = {}; + const other: Table = {}; + for (const name of names) { + table[name] = same.iso; + other[name] = { ...same.iso, 2: facts("0001-01-09") }; + } + const result = sweepCalendars({ + candidate: fake(table), + reference: fake(other), + calendars: names, + }); + expect(result.differingCalendars).toBe(60); + expect(result.differing).toHaveLength(50); + expect(result.differingTruncated).toBe(true); + }); + + it("throws when it is given no calendar", () => { + expect(() => + sweepCalendars({ + candidate: fake(same), + reference: fake(same), + calendars: [], + }), + ).toThrow('Intl.supportedValuesOf("calendar") returned no calendars'); + }); +}); diff --git a/apps/dox/scripts/canary/canary-issues.test.ts b/apps/dox/scripts/canary/canary-issues.test.ts index 0738effc8..f541aebe3 100644 --- a/apps/dox/scripts/canary/canary-issues.test.ts +++ b/apps/dox/scripts/canary/canary-issues.test.ts @@ -276,12 +276,30 @@ const swapSweep = (differingZones = 0) => ({ differingTruncated: differingZones > 50, }); +/** The calendar sweep: `differing` names calendars, each with its year count. */ +const calendarSweep = (differingCalendars = 0) => ({ + status: "ran" as const, + from: "-003000-01-01", + through: "+005000-12-31", + calendars: 16, + years: 128762, + differingCalendars, + differing: Array.from({ length: differingCalendars }, (_, i) => ({ + calendar: `cal${i + 1}`, + years: i + 1, + first: 1502, + example: "year 1502: candidate a; reference b", + })), + differingTruncated: false, +}); + interface SwapOptions { version?: string; failed?: number; both?: number; fixed?: number; sweep?: unknown; + calendarSweep?: unknown; entryLoaded?: unknown; } @@ -289,6 +307,8 @@ interface SwapOptions { const swapLeg = (leg: SwapLeg, options: SwapOptions = {}) => { const { version = "1.0.7", failed = 0, both = 0, fixed = 0 } = options; const sweep = "sweep" in options ? options.sweep : swapSweep(); + const calendars = + "calendarSweep" in options ? options.calendarSweep : calendarSweep(); return { source: `temporal-polyfill-swap-${leg}`, status: "ran" as const, @@ -314,6 +334,7 @@ const swapLeg = (leg: SwapLeg, options: SwapOptions = {}) => { failing: [], failingTruncated: false, sweep: leg === "node" ? sweep : null, + calendarSweep: leg === "node" ? calendars : null, }; }; @@ -2061,37 +2082,44 @@ describe("swapReady", () => { }; it.each` - label | verdicts | reason - ${"chromium entryLoaded is false"} | ${cleanSwap({ chromium: { entryLoaded: false } })} | ${"temporal-polyfill-swap-chromium: the swap pass did not load temporal-polyfill"} - ${"firefox entryLoaded is missing"} | ${changed("firefox", (v) => delete v.entryLoaded)} | ${"temporal-polyfill-swap-firefox: the swap pass did not load temporal-polyfill"} - ${"node entryLoaded is the string true"} | ${cleanSwap({ node: { entryLoaded: "true" } })} | ${"temporal-polyfill-swap-node: the swap pass did not load temporal-polyfill"} - ${"entry not loaded beats failing tests"} | ${cleanSwap({ webkit: { entryLoaded: false, failed: 5 } })} | ${"temporal-polyfill-swap-webkit: the swap pass did not load temporal-polyfill"} - ${"webkit failed count is missing"} | ${changed("webkit", (v) => delete v.counts.failed)} | ${"temporal-polyfill-swap-webkit: the failed count is missing"} - ${"node counts are missing"} | ${changed("node", (v) => delete v.counts)} | ${"temporal-polyfill-swap-node: the failed count is missing"} - ${"chromium failed count is the string 0"} | ${changed("chromium", (v) => (v.counts.failed = "0"))} | ${"temporal-polyfill-swap-chromium: the failed count is missing"} - ${"firefox failed count is null"} | ${changed("firefox", (v) => (v.counts.failed = null))} | ${"temporal-polyfill-swap-firefox: the failed count is missing"} - ${"sweep differingZones is missing"} | ${changed("node", (v) => delete v.sweep.differingZones)} | ${"offset sweep: the differing zone count is missing"} - ${"sweep differingZones is undefined"} | ${changed("node", (v) => (v.sweep.differingZones = undefined))} | ${"offset sweep: the differing zone count is missing"} - ${"sweep differingZones is the string 0"} | ${changed("node", (v) => (v.sweep.differingZones = "0"))} | ${"offset sweep: the differing zone count is missing"} + label | verdicts | reason + ${"chromium entryLoaded is false"} | ${cleanSwap({ chromium: { entryLoaded: false } })} | ${"temporal-polyfill-swap-chromium: the swap pass did not load temporal-polyfill"} + ${"firefox entryLoaded is missing"} | ${changed("firefox", (v) => delete v.entryLoaded)} | ${"temporal-polyfill-swap-firefox: the swap pass did not load temporal-polyfill"} + ${"node entryLoaded is the string true"} | ${cleanSwap({ node: { entryLoaded: "true" } })} | ${"temporal-polyfill-swap-node: the swap pass did not load temporal-polyfill"} + ${"entry not loaded beats failing tests"} | ${cleanSwap({ webkit: { entryLoaded: false, failed: 5 } })} | ${"temporal-polyfill-swap-webkit: the swap pass did not load temporal-polyfill"} + ${"webkit failed count is missing"} | ${changed("webkit", (v) => delete v.counts.failed)} | ${"temporal-polyfill-swap-webkit: the failed count is missing"} + ${"node counts are missing"} | ${changed("node", (v) => delete v.counts)} | ${"temporal-polyfill-swap-node: the failed count is missing"} + ${"chromium failed count is the string 0"} | ${changed("chromium", (v) => (v.counts.failed = "0"))} | ${"temporal-polyfill-swap-chromium: the failed count is missing"} + ${"firefox failed count is null"} | ${changed("firefox", (v) => (v.counts.failed = null))} | ${"temporal-polyfill-swap-firefox: the failed count is missing"} + ${"sweep differingZones is missing"} | ${changed("node", (v) => delete v.sweep.differingZones)} | ${"offset sweep: the differing zone count is missing"} + ${"sweep differingZones is undefined"} | ${changed("node", (v) => (v.sweep.differingZones = undefined))} | ${"offset sweep: the differing zone count is missing"} + ${"sweep differingZones is the string 0"} | ${changed("node", (v) => (v.sweep.differingZones = "0"))} | ${"offset sweep: the differing zone count is missing"} + ${"calendar count is missing"} | ${changed("node", (v) => delete v.calendarSweep.differingCalendars)} | ${"calendar sweep: the differing calendar count is missing"} + ${"calendar count is the string 0"} | ${changed("node", (v) => (v.calendarSweep.differingCalendars = "0"))} | ${"calendar sweep: the differing calendar count is missing"} `("is not ready when $label", ({ verdicts, reason }) => { expect(swapReady(verdicts)).toEqual({ ready: false, reason }); }); it.each` - label | verdicts | reason - ${"node verdict missing"} | ${{ ...cleanSwap(), "temporal-polyfill-swap-node": null }} | ${"temporal-polyfill-swap-node: did not run"} - ${"chromium could not run"} | ${{ ...cleanSwap(), "temporal-polyfill-swap-chromium": couldNotRun("temporal-polyfill-swap-chromium", "no browser") }} | ${"temporal-polyfill-swap-chromium: did not run"} - ${"webkit key absent"} | ${Object.fromEntries(Object.entries(cleanSwap()).filter(([k]) => !k.endsWith("webkit")))} | ${"temporal-polyfill-swap-webkit: did not run"} - ${"versions differ"} | ${cleanSwap({ firefox: { version: "1.0.8" } })} | ${"legs ran different versions: 1.0.7, 1.0.8"} - ${"three tests fail on webkit"} | ${cleanSwap({ webkit: { failed: 3 } })} | ${"temporal-polyfill-swap-webkit: 3 tests fail on the swap"} - ${"one test fails on node"} | ${cleanSwap({ node: { failed: 1 } })} | ${"temporal-polyfill-swap-node: 1 test fails on the swap"} - ${"sweep could not run"} | ${cleanSwap({ node: { sweep: { status: "could-not-run", message: "no Intl" } } })} | ${"offset sweep: did not run"} - ${"sweep is null on node"} | ${cleanSwap({ node: { sweep: null } })} | ${"offset sweep: did not run"} - ${"two zones differ"} | ${cleanSwap({ node: { sweep: swapSweep(2) } })} | ${"offset sweep: 2 zones differ"} - ${"one zone differs"} | ${cleanSwap({ node: { sweep: swapSweep(1) } })} | ${"offset sweep: 1 zone differs"} - ${"a missing leg beats a failing one"} | ${{ ...cleanSwap({ node: { failed: 4 } }), "temporal-polyfill-swap-webkit": null }} | ${"temporal-polyfill-swap-webkit: did not run"} - ${"versions beat failures"} | ${cleanSwap({ node: { failed: 4 }, webkit: { version: "1.0.9" } })} | ${"legs ran different versions: 1.0.7, 1.0.9"} - ${"failures beat the sweep"} | ${cleanSwap({ chromium: { failed: 2 }, node: { sweep: swapSweep(5) } })} | ${"temporal-polyfill-swap-chromium: 2 tests fail on the swap"} + label | verdicts | reason + ${"node verdict missing"} | ${{ ...cleanSwap(), "temporal-polyfill-swap-node": null }} | ${"temporal-polyfill-swap-node: did not run"} + ${"chromium could not run"} | ${{ ...cleanSwap(), "temporal-polyfill-swap-chromium": couldNotRun("temporal-polyfill-swap-chromium", "no browser") }} | ${"temporal-polyfill-swap-chromium: did not run"} + ${"webkit key absent"} | ${Object.fromEntries(Object.entries(cleanSwap()).filter(([k]) => !k.endsWith("webkit")))} | ${"temporal-polyfill-swap-webkit: did not run"} + ${"versions differ"} | ${cleanSwap({ firefox: { version: "1.0.8" } })} | ${"legs ran different versions: 1.0.7, 1.0.8"} + ${"three tests fail on webkit"} | ${cleanSwap({ webkit: { failed: 3 } })} | ${"temporal-polyfill-swap-webkit: 3 tests fail on the swap"} + ${"one test fails on node"} | ${cleanSwap({ node: { failed: 1 } })} | ${"temporal-polyfill-swap-node: 1 test fails on the swap"} + ${"sweep could not run"} | ${cleanSwap({ node: { sweep: { status: "could-not-run", message: "no Intl" } } })} | ${"offset sweep: did not run"} + ${"sweep is null on node"} | ${cleanSwap({ node: { sweep: null } })} | ${"offset sweep: did not run"} + ${"calendar sweep could not run"} | ${cleanSwap({ node: { calendarSweep: { status: "could-not-run", message: "no Temporal" } } })} | ${"calendar sweep: did not run"} + ${"calendar sweep is null on node"} | ${cleanSwap({ node: { calendarSweep: null } })} | ${"calendar sweep: did not run"} + ${"one calendar differs"} | ${cleanSwap({ node: { calendarSweep: calendarSweep(1) } })} | ${"calendar sweep: 1 calendar differs (cal1)"} + ${"two calendars differ"} | ${cleanSwap({ node: { calendarSweep: calendarSweep(2) } })} | ${"calendar sweep: 2 calendars differ (cal1, cal2)"} + ${"the offset sweep beats the calendar sweep"} | ${cleanSwap({ node: { sweep: swapSweep(1), calendarSweep: calendarSweep(1) } })} | ${"offset sweep: 1 zone differs"} + ${"two zones differ"} | ${cleanSwap({ node: { sweep: swapSweep(2) } })} | ${"offset sweep: 2 zones differ"} + ${"one zone differs"} | ${cleanSwap({ node: { sweep: swapSweep(1) } })} | ${"offset sweep: 1 zone differs"} + ${"a missing leg beats a failing one"} | ${{ ...cleanSwap({ node: { failed: 4 } }), "temporal-polyfill-swap-webkit": null }} | ${"temporal-polyfill-swap-webkit: did not run"} + ${"versions beat failures"} | ${cleanSwap({ node: { failed: 4 }, webkit: { version: "1.0.9" } })} | ${"legs ran different versions: 1.0.7, 1.0.9"} + ${"failures beat the sweep"} | ${cleanSwap({ chromium: { failed: 2 }, node: { sweep: swapSweep(5) } })} | ${"temporal-polyfill-swap-chromium: 2 tests fail on the swap"} `("is not ready when $label", ({ verdicts, reason }) => { expect(swapReady(verdicts)).toEqual({ ready: false, reason }); }); @@ -2099,7 +2127,7 @@ describe("swapReady", () => { describe("swap findings", () => { const READY_TITLE = - "Swap to temporal-polyfill 1.0.7: it passes the GMT suite and the offset sweep"; + "Swap to temporal-polyfill 1.0.7: it passes the GMT suite and both sweeps"; const READY_MARKER = ''; const swapPlan = (swap: unknown, open: ReturnType[] = []) => plan( @@ -2126,6 +2154,12 @@ describe("swap findings", () => { expect(swapPlan(cleanSwap({ webkit: { failed: 2 } }))).toEqual([]); }); + it("a differing calendar sweep files nothing", () => { + expect( + swapPlan(cleanSwap({ node: { calendarSweep: calendarSweep(1) } })), + ).toEqual([]); + }); + it("a differing sweep files nothing", () => { expect(swapPlan(cleanSwap({ node: { sweep: swapSweep(3) } }))).toEqual([]); }); @@ -2182,6 +2216,8 @@ describe("swap findings", () => { "", "Offset sweep: every one of 418 zones matches `Intl.DateTimeFormat` at 12:00 UTC each day from 1970-01-01 to 2036-11-04 (tz 2026e).", "", + "Calendar sweep: every one of 16 calendars matches the built-in Temporal on the first day, months and days of each year from -003000-01-01 to +005000-12-31.", + "", "What the swap involves is in [temporal-polyfill-swap.md § 5 and § 7](https://github.com/northguild/gmt/blob/main/context/domination/research/temporal-polyfill-swap.md). Type errors are not checked here; § 5 lists them.", "", "A person makes the swap. CI opens issues, never pull requests.", @@ -2251,6 +2287,25 @@ describe("swap could not run", () => { ); }); + it("a Node leg that ran but whose calendar sweep could not run lists the sweep, with no swap finding", () => { + const actions = plan({ + ...base(), + ...cleanSwap({ + node: { + calendarSweep: { status: "could-not-run", message: "no Temporal" }, + }, + }), + }); + expect(actions.map((a) => a.key)).toEqual([ + "temporal-oracle/could-not-run", + ]); + const [action] = actions; + if (action.kind !== "open") throw new Error("expected open"); + expect(action.body).toContain( + "- **temporal-polyfill-swap-node**: calendar sweep: no Temporal\n", + ); + }); + it("a Node leg that ran but whose sweep could not run lists the sweep, with no swap finding", () => { const actions = plan({ ...base(), @@ -2400,7 +2455,7 @@ describe("swap force", () => { const dry = actions[1]; if (dry.kind !== "open") throw new Error("expected open"); expect(dry.title).toBe( - "[dry run] Swap to temporal-polyfill 1.0.7: it passes the GMT suite and the offset sweep", + "[dry run] Swap to temporal-polyfill 1.0.7: it passes the GMT suite and both sweeps", ); expect(dry.labels).toEqual(["canary", "canary-dry-run"]); expect(dry.body).toContain( @@ -2429,6 +2484,18 @@ describe("swap force", () => { expect(dry.body).not.toContain("every one of 418 zones matches"); }); + it("a forced run with differing calendars does not claim the calendar sweep matched", () => { + const actions = forcedPlan( + cleanSwap({ node: { calendarSweep: calendarSweep(2) } }), + ); + const dry = actions.find((a) => a.key === DRY_KEY); + if (!dry || dry.kind !== "open") throw new Error("expected open"); + expect(dry.body).toContain( + "Calendar sweep: 2 of 16 calendars differ from the built-in Temporal in some year from -003000-01-01 to +005000-12-31.", + ); + expect(dry.body).not.toContain("every one of 16 calendars matches"); + }); + it("shows a leg that did not run as 'did not run' in the dry-run table", () => { const actions = forcedPlan({ ...cleanSwap(), diff --git a/apps/dox/scripts/canary/canary-report.test.ts b/apps/dox/scripts/canary/canary-report.test.ts index 96cd50f2c..52df4ade1 100644 --- a/apps/dox/scripts/canary/canary-report.test.ts +++ b/apps/dox/scripts/canary/canary-report.test.ts @@ -497,6 +497,19 @@ describe("main", () => { differingTruncated: false, } : null, + calendarSweep: + leg === "node" + ? { + status: "ran", + from: "-003000-01-01", + through: "+005000-12-31", + calendars: 16, + years: 128762, + differingCalendars: 0, + differing: [], + differingTruncated: false, + } + : null, ...over, }); /** The four swap files: every leg ran, one zone differs, so nothing is swap-ready. */ diff --git a/apps/dox/scripts/canary/canary-summary.test.ts b/apps/dox/scripts/canary/canary-summary.test.ts index f5bb88856..8ee0b2c99 100644 --- a/apps/dox/scripts/canary/canary-summary.test.ts +++ b/apps/dox/scripts/canary/canary-summary.test.ts @@ -191,6 +191,22 @@ const swapSweep = (differingZones = 0) => ({ differingTruncated: differingZones > 50, }); +const calendarSweep = (differingCalendars = 0) => ({ + status: "ran", + from: "-003000-01-01", + through: "+005000-12-31", + calendars: 16, + years: 128762, + differingCalendars, + differing: Array.from({ length: differingCalendars }, (_, i) => ({ + calendar: `cal${i + 1}`, + years: i + 1, + first: 1502, + example: "year 1502: candidate a;\nreference b", + })), + differingTruncated: false, +}); + const swap = (leg: string, over: Record = {}) => ({ source: `temporal-polyfill-swap-${leg}`, status: "ran", @@ -216,6 +232,7 @@ const swap = (leg: string, over: Record = {}) => ({ failing: [], failingTruncated: false, sweep: leg === "node" ? swapSweep() : null, + calendarSweep: leg === "node" ? calendarSweep() : null, ...over, }); @@ -247,6 +264,8 @@ const SWAP_BLOCK = [ "| webkit | 71337 | 0 | 0 |", "", "Offset sweep: 0 zones differ (418 zones, 1970-01-01 to 2036-11-04, tz 2026e).", + "", + "Calendar sweep: 0 calendars differ (16 calendars, 128762 years, -003000-01-01 to +005000-12-31).", ]; const CLEAN_SUMMARY = [ @@ -815,6 +834,61 @@ describe("summaryMarkdown: temporal polyfill swap", () => { "temporal-polyfill — Not ready: temporal-polyfill-swap-node: did not run", ); expect(text).toContain("Offset sweep: did not run."); + expect(text).toContain("Calendar sweep: did not run."); + }); + + it("differing calendars are counted and listed with years, first year and an example", () => { + const text = swapOnly({ + "temporal-polyfill-swap-node": swap("node", { + calendarSweep: calendarSweep(2), + }), + }); + expect(text).toContain( + "Calendar sweep: 2 calendars differ (16 calendars, 128762 years, -003000-01-01 to +005000-12-31).\n- cal1: 1 year, first 1502, e.g. year 1502: candidate a; reference b\n- cal2: 2 years, first 1502, e.g. year 1502: candidate a; reference b", + ); + expect(text).toContain( + "— Not ready: calendar sweep: 2 calendars differ (cal1, cal2)", + ); + }); + + it("a calendar only one side accepts prints 'first none'", () => { + const sweep = calendarSweep(1); + sweep.differing = [ + { + calendar: "x", + years: 0, + first: null as never, + example: "only the reference accepts this calendar", + }, + ]; + const text = swapOnly({ + "temporal-polyfill-swap-node": swap("node", { calendarSweep: sweep }), + }); + expect(text).toContain( + "- x: 0 years, first none, e.g. only the reference accepts this calendar", + ); + }); + + it("a calendar sweep that could not run says so", () => { + const text = swapOnly({ + "temporal-polyfill-swap-node": swap("node", { + calendarSweep: { status: "could-not-run", message: "no Temporal" }, + }), + }); + expect(text).toContain("Calendar sweep: could not run: no Temporal"); + }); + + it("a node leg that could not run still prints the calendar sweep it carries", () => { + const text = swapOnly({ + "temporal-polyfill-swap-node": { + source: "temporal-polyfill-swap-node", + status: "could-not-run", + message: "timeout", + calendarSweep: calendarSweep(1), + }, + }); + expect(text).toContain("Calendar sweep: 1 calendars differ"); + expect(text).not.toContain("Calendar sweep: did not run."); }); it("a differing sweep counts the zones and lists the first ten", () => { diff --git a/apps/dox/scripts/canary/canary-verdict.test.ts b/apps/dox/scripts/canary/canary-verdict.test.ts index 6e1e4476b..7109fbead 100644 --- a/apps/dox/scripts/canary/canary-verdict.test.ts +++ b/apps/dox/scripts/canary/canary-verdict.test.ts @@ -561,6 +561,7 @@ describe("polyfillSwapVerdict", () => { }, failing: [{ file: "a.test.ts", test: "t", message: "boom" }], sweep: null, + calendarSweep: null, }; it("has the shape and key order the reporter reads", () => { @@ -576,6 +577,7 @@ describe("polyfillSwapVerdict", () => { "failing", "failingTruncated", "sweep", + "calendarSweep", ]); expect(polyfillSwapVerdict(input)).toMatchObject({ source: "temporal-polyfill-swap-node", @@ -611,6 +613,13 @@ describe("polyfillSwapVerdict", () => { const a = formatJson(polyfillSwapVerdict({ ...input, sweep })); expect(formatJson(polyfillSwapVerdict({ ...input, sweep }))).toBe(a); expect(polyfillSwapVerdict({ ...input, sweep }).sweep).toEqual(sweep); + const calendarSweep = { + status: "could-not-run" as const, + message: "no Temporal", + }; + expect( + polyfillSwapVerdict({ ...input, calendarSweep }).calendarSweep, + ).toEqual(calendarSweep); }); }); diff --git a/apps/dox/scripts/canary/polyfill-swap.test.ts b/apps/dox/scripts/canary/polyfill-swap.test.ts index ac32c3a80..c1b3f957a 100644 --- a/apps/dox/scripts/canary/polyfill-swap.test.ts +++ b/apps/dox/scripts/canary/polyfill-swap.test.ts @@ -14,6 +14,7 @@ import { Temporal as PolyfillTemporal } from "@js-temporal/polyfill"; import { afterEach, describe, expect, it, vi } from "vitest"; import { + calendarSweep, ENTRY_CHECK, entryLoaded, main, @@ -99,6 +100,7 @@ function setup(installed: string | null = "1.0.7") { let err = ""; const calls: Call[] = []; let swept = 0; + let calendarSwept = 0; const io = (spec: Spec | null, extra: Record = {}) => ({ root, stdout: (t: string) => (out += t), @@ -147,6 +149,19 @@ function setup(installed: string | null = "1.0.7") { differingTruncated: false, }; }, + calendarSweep: () => { + calendarSwept += 1; + return { + status: "ran", + from: "-003000-01-01", + through: "+005000-12-31", + calendars: 16, + years: 128_762, + differingCalendars: 0, + differing: [], + differingTruncated: false, + }; + }, today: () => RUN_DATE, ...extra, }, @@ -158,6 +173,7 @@ function setup(installed: string | null = "1.0.7") { io, calls, swept: () => swept, + calendarSwept: () => calendarSwept, out: () => out, err: () => err, verdict: (leg: string) => @@ -283,7 +299,7 @@ describe("polyfill-swap judging", () => { failingTruncated: false, }); expect(s.out()).toBe( - "polyfill-swap: node temporal-polyfill 1.0.7: 0 swap-only failures of 2 tests; sweep: 0 zones differ\n", + "polyfill-swap: node temporal-polyfill 1.0.7: 0 swap-only failures of 2 tests; sweep: 0 zones differ; calendar sweep: 0 calendars differ\n", ); }); @@ -511,6 +527,167 @@ describe("polyfill-swap entry check", () => { }); }); +describe("polyfill-swap calendar sweep", () => { + const passing = { control: one("passed"), swap: one("passed") }; + + it("the verdict of a node leg carries the calendar sweep, and the line counts the calendars", async () => { + const s = setup(); + await main(["node", "--version=1.0.7"], s.io(passing)); + expect(s.verdict("node").calendarSweep).toMatchObject({ + status: "ran", + calendars: 16, + differingCalendars: 0, + }); + expect(s.calendarSwept()).toBe(1); + }); + + it("gets the swap entry", async () => { + const s = setup(); + const seen: unknown[][] = []; + await main( + ["node", "--version=1.0.7"], + s.io(passing, { + loadEntry: async () => ({ Temporal: { fake: "entry" } }), + calendarSweep: (...args: unknown[]) => { + seen.push(args); + return { status: "ran", differingCalendars: 0 }; + }, + }), + ); + expect(seen).toEqual([[{ Temporal: { fake: "entry" } }]]); + }); + + it("finds 3 calendars: the line and the verdict carry the number", async () => { + const s = setup(); + await main( + ["node", "--version=1.0.7"], + s.io(passing, { + calendarSweep: () => ({ status: "ran", differingCalendars: 3 }), + }), + ); + expect(s.out()).toContain("; calendar sweep: 3 calendars differ"); + expect(s.verdict("node").calendarSweep).toEqual({ + status: "ran", + differingCalendars: 3, + }); + }); + + it("throws on node: exit 0, calendar sweep could-not-run, both passes and the offset sweep still ran", async () => { + const s = setup(); + const code = await main( + ["node", "--version=1.0.7"], + s.io(passing, { + calendarSweep: () => { + throw new Error("this host has no built-in Temporal to compare with"); + }, + }), + ); + expect(code).toBe(0); + expect(s.verdict("node").calendarSweep).toEqual({ + status: "could-not-run", + message: "this host has no built-in Temporal to compare with", + }); + expect(s.verdict("node").sweep).toMatchObject({ status: "ran" }); + expect(s.calls.map((c) => c.pass)).toEqual(["control", "swap"]); + expect(s.out()).not.toContain("calendar sweep:"); + }); + + it("runs before either pass on node and is kept when a pass times out", async () => { + const s = setup(); + const code = await main( + ["node", "--version=1.0.7"], + s.io(null, { + runPass: () => { + throw new Error("the control pass ran past its 18-minute limit"); + }, + }), + ); + expect(code).toBe(2); + expect(s.verdict("node")).toMatchObject({ + status: "could-not-run", + calendarSweep: { status: "ran", differingCalendars: 0 }, + }); + let out = ""; + await main(["summary", "node"], { + root: s.root, + stdout: (t) => (out += t), + stderr: () => {}, + }); + expect(out).toContain( + "Calendar sweep: 0 calendars differ from Node's built-in Temporal, -003000-01-01 to +005000-12-31, 16 calendars.", + ); + }); + + it("a node leg that stops before the sweeps has no calendar sweep, and a browser leg none", async () => { + const s = setup(); + await main( + ["node", "--version=1.0.7"], + s.io(null, { + loadEntry: async () => { + throw new Error("cannot import temporal-polyfill"); + }, + }), + ); + expect(s.calendarSwept()).toBe(0); + expect(s.verdict("node")).not.toHaveProperty("calendarSweep"); + const b = setup(); + await main(["chromium", "--version=1.0.7"], b.io(passing)); + expect(b.calendarSwept()).toBe(0); + expect(b.verdict("chromium").calendarSweep).toBeNull(); + }); + + it("summary prints a calendar sweep that could not run", async () => { + const s = setup(); + await main( + ["node", "--version=1.0.7"], + s.io(passing, { + calendarSweep: () => { + throw new Error("no Temporal"); + }, + }), + ); + let out = ""; + await main(["summary", "node"], { + root: s.root, + stdout: (t) => (out += t), + stderr: () => {}, + }); + expect(out).toContain("Calendar sweep could not run: no Temporal"); + }); +}); + +describe("polyfill-swap calendar sweep, for real", () => { + const entry = { Temporal: PolyfillTemporal }; + + it("compares the entry with the host's Temporal over the fixed span", () => { + // The stand-in host Temporal is the same polyfill, so nothing differs. + vi.stubGlobal("Temporal", PolyfillTemporal); + try { + expect(calendarSweep(entry, ["iso8601"])).toMatchObject({ + status: "ran", + from: "-003000-01-01", + through: "+005000-12-31", + calendars: 1, + years: 8001, + differingCalendars: 0, + }); + } finally { + vi.unstubAllGlobals(); + } + }); + + it("cannot run on a host with no built-in Temporal", () => { + vi.stubGlobal("Temporal", undefined); + try { + expect(() => calendarSweep(entry, ["iso8601"])).toThrow( + "this host has no built-in Temporal to compare with", + ); + } finally { + vi.unstubAllGlobals(); + } + }); +}); + describe("polyfill-swap sweep and legs", () => { it("the sweep throws on node: exit 0, sweep could-not-run, both passes still ran", async () => { const s = setup(); @@ -533,7 +710,7 @@ describe("polyfill-swap sweep and legs", () => { message: 'Intl longOffset text for X is "?", which the sweep cannot read', }); expect(s.calls.map((c) => c.pass)).toEqual(["control", "swap"]); - expect(s.out()).not.toContain("sweep:"); + expect(s.out()).not.toContain("; sweep:"); }); it("a pass times out on node: exit 2, could-not-run, the sweep kept and printed by summary", async () => { @@ -557,6 +734,10 @@ describe("polyfill-swap sweep and legs", () => { zones: 418, differingZones: 0, }), + calendarSweep: expect.objectContaining({ + status: "ran", + differingCalendars: 0, + }), }); let out = ""; await main(["summary", "node"], { @@ -570,6 +751,7 @@ describe("polyfill-swap sweep and legs", () => { "", `could not run: ${limit}`, "Offset sweep: 0 zones differ from Intl, 1970-01-01 to 2036-11-04, 418 zones, tz 2026e.", + "Calendar sweep: 0 calendars differ from Node's built-in Temporal, -003000-01-01 to +005000-12-31, 16 calendars.", "", ].join("\n"), ); diff --git a/apps/dox/src/data/upstream-filings.json b/apps/dox/src/data/upstream-filings.json index c06bec7b4..6b1961211 100644 --- a/apps/dox/src/data/upstream-filings.json +++ b/apps/dox/src/data/upstream-filings.json @@ -1,5 +1,5 @@ { - "checked": "2026-11-04T17:46:15.22034635Z", + "checked": "2026-11-06T16:38:53.906110824Z", "filings": [ { "repo": "js-temporal/temporal-polyfill", @@ -446,10 +446,10 @@ "state": "closed", "draft": false, "reviewDecision": null, - "comments": 1, + "comments": 2, "maintainerComments": 1, "createdAt": "2026-10-25", - "updatedAt": "2026-11-04", + "updatedAt": "2026-11-05", "closedAt": "2026-11-04", "mergedAt": null }, @@ -500,6 +500,52 @@ "updatedAt": "2026-11-04", "closedAt": "2026-11-04", "mergedAt": null + }, + { + "repo": "fullcalendar/temporal-polyfill", + "number": 127, + "kind": "issue", + "work": "report", + "title": "Persian calendar: 78 years from 1502 to 2987 AP get the wrong leap year", + "url": "https://github.com/fullcalendar/temporal-polyfill/issues/127", + "summary": "The Persian calendar uses the plain 33-year leap rule, where ICU4X corrects 78 years from 1502 to 2987 AP. In the year after each one, every date reads one day early.", + "pairsWith": [], + "closes": [], + "dependsOn": [], + "gmtGuard": null, + "gmtNote": "GMT runs on `@js-temporal/polyfill`, which gets these Persian years right, so this can't affect GMT. GMT's weekly swap check compares each calendar's years with native Temporal on every new `temporal-polyfill` release.", + "state": "open", + "draft": false, + "reviewDecision": null, + "comments": 2, + "maintainerComments": 0, + "createdAt": "2026-11-06", + "updatedAt": "2026-11-06", + "closedAt": null, + "mergedAt": null + }, + { + "repo": "fullcalendar/temporal-polyfill", + "number": 128, + "kind": "issue", + "work": "report", + "title": "Chinese and Dangi: dates read from Intl differ from native Temporal (Chinese New Year 2027)", + "url": "https://github.com/fullcalendar/temporal-polyfill/issues/128", + "summary": "Chinese and Dangi dates are read from `Intl`, which on Node 26 (ICU 78.3) disagrees with native Temporal. Chinese New Year 2027 falls on 7 February instead of 6 February.", + "pairsWith": [], + "closes": [], + "dependsOn": [], + "gmtGuard": null, + "gmtNote": "GMT runs on `@js-temporal/polyfill`, which throws on Chinese and Dangi dates under ICU 78 instead (js-temporal/temporal-polyfill#360). GMT's weekly swap check compares each calendar's years with native Temporal on every new `temporal-polyfill` release.", + "state": "open", + "draft": false, + "reviewDecision": null, + "comments": 0, + "maintainerComments": 0, + "createdAt": "2026-11-06", + "updatedAt": "2026-11-06", + "closedAt": null, + "mergedAt": null } ], "listings": [ diff --git a/context/domination/issues/CORE-110.md b/context/domination/issues/CORE-110.md new file mode 100644 index 000000000..7747d8670 --- /dev/null +++ b/context/domination/issues/CORE-110.md @@ -0,0 +1,73 @@ +# CORE-110 — Core: The weekly upgrade check compares each calendar's years with native Temporal + +**Scope:** The Node leg of the weekly `temporal-polyfill` upgrade check ([CORE-92](CORE-92.md)) +gains a calendar sweep beside its offset sweep. It compares every calendar's years with Node's +built-in Temporal. A difference blocks the upgrade. Adds no function and raises no pin. Tracked as +#468. + +## Gap + +`temporal-polyfill` 1.0.8 uses the plain 33-year rule for Persian leap years +(`modFloor(25 * year + 11, 33) < 8`). ICU4X, which Node 26's built-in Temporal follows, corrects 78 +years from 1502 to 2987 AP. In the year after each one, every date reads one day early: 1503 AP +M01-01 is 2124-03-20 natively and 2124-03-21 on the polyfill, and the days in 1502 AP are 365 +natively and 366 on the polyfill. The report is +[fullcalendar/temporal-polyfill#127](https://github.com/fullcalendar/temporal-polyfill/issues/127). + +Chinese and Dangi differ too, because the polyfill reads them from `Intl` (Decision 5). + +The move onto `temporal-polyfill` ([CORE-108](CORE-108.md), #460) waits on releases that fix them. +The upgrade check compares offsets and runs the GMT suite, and neither sees a calendar year. Without +a sweep, nothing tells us when a release fixes it. + +## Scope + +1. **Calendar sweep.** `scripts/lib/calendar-sweep.mjs` is a pure module with no imports and no + I/O. For every calendar both implementations accept, and every calendar year that overlaps ISO + years -3000 to 5000, it compares the swap's value with Node's built-in `globalThis.Temporal` on + three facts: the ISO date of the year's first day, the months in the year and the days in the + year. The span is fixed. It does not depend on the run date. +2. **Node leg.** `scripts/polyfill-swap.mjs` runs it on the Node leg, beside the offset sweep and + before the suite passes, so a suite timeout cannot lose it. The result is the verdict's + `calendarSweep` field. A host with no built-in Temporal records + `{ status: "could-not-run", message }`. +3. **Readiness.** The swap is ready only when the calendar sweep ran and no calendar differs. A + sweep that did not run, or whose count is missing, blocks, as the offset sweep does. +4. **Report.** The job summary lists each differing calendar with the number of years, the first + year and one example. The ready issue says every calendar matched. When releases fix the + Persian report and the Chinese and Dangi report, and nothing else differs, the check opens that issue. That + is the signal to take #464 out of parked. + +Out of scope: any library function, raising any pin. + +## What gmt provides (do not re-implement) + +- The swap runner `scripts/polyfill-swap.mjs` and its verdict (`CORE-92`) +- The offset sweep `scripts/lib/offset-sweep.mjs`, whose shape the calendar sweep follows +- The verdict, summary and issue modules `canary-verdict.mjs`, `canary-summary.mjs` and + `canary-issues.mjs` + +## Verification + +- On `temporal-polyfill` 1.0.8 against Node 26.12.1, the sweep compares 16 calendars and 128,762 + years in about 11 seconds. It reports Persian (156 years, first 1502), Chinese (3,889 years) and + Dangi (3,858 years), and blocks the upgrade. The other 13 calendars match. +- Unit tests in `apps/dox/scripts/canary/calendar-sweep.test.ts` run the sweep against stand-in + implementations. The runner, verdict, summary and issue tests cover the wiring. + +## Decisions + +1. **The reference is the host's built-in Temporal.** Node 26 follows ICU4X for calendars, which is + what the polyfill must match. +2. **Both sides must agree on the calendar set.** A calendar only one side accepts is a difference + with zero years. A calendar neither accepts is skipped. +3. **A year where one side throws and the other does not is a difference.** A year where both + throw is skipped. +4. **The sweep fails closed.** Missing, malformed or could-not-run results all block, so a verdict + that lost a field never reports ready. +5. **Chinese and Dangi block too.** On 1.0.8 the polyfill reads both lunisolar calendars from + `Intl.DateTimeFormat`, and Node 26's `Intl` (ICU 78.3) disagrees with its built-in Temporal + (ICU4X). Chinese differs in 3,889 years and Dangi in 3,858. Six Chinese years fall within + 1900–2100: Chinese New Year 2027 is 6 February natively and in published calendars, and 7 + February on the polyfill. Any calendar that differs blocks, whatever the source of the + difference, so the upgrade waits for releases that fix both reports. diff --git a/context/domination/issues/CORE-92.md b/context/domination/issues/CORE-92.md index b5121381c..ed5037dfc 100644 --- a/context/domination/issues/CORE-92.md +++ b/context/domination/issues/CORE-92.md @@ -74,7 +74,8 @@ to, and checking by hand on every release is the kind of watch nobody keeps. Web for host reasons (`KNOWN_HOST_FAILURES` in `scripts/lib/native-suite-tags.mjs`). A leg passes when no test fails on the swap that passes on the control in the same runtime. - **One verdict per leg**, `temporal-polyfill-swap-`, as for `native-suite-`. Four legs: - Node 26, Playwright Chromium, Firefox and WebKit. The Node leg also runs the offset sweep. + Node 26, Playwright Chromium, Firefox and WebKit. The Node leg also runs the offset sweep and the + calendar sweep ([CORE-110](CORE-110.md)). - **Import `temporal-polyfill/full/implementation`, never `/full`.** `/full` returns the runtime's built-in `Temporal` where one exists, so the swap would test the engine, not the polyfill. - **The sweep is brute force on purpose.** One instant a day at 12:00 UTC, from 1970-01-01 to ten diff --git a/context/domination/issues/index.md b/context/domination/issues/index.md index 815a9c1f2..e5eae277e 100644 --- a/context/domination/issues/index.md +++ b/context/domination/issues/index.md @@ -60,3 +60,4 @@ generated by `pnpm deps:sync` from [the tracker](../tracker.md); do not edit it - [CORE-92](CORE-92.md) — Weekly check for a `temporal-polyfill` release GMT can swap to - [CORE-105](CORE-105.md) — One file per workaround in `zonedWallClockDifference.ts` - [CORE-107](CORE-107.md) — A changelog page in Dox, and the You-Dont-Need-Momentjs PR on `/upstream` +- [CORE-110](CORE-110.md) — The weekly upgrade check compares each calendar's years with native Temporal diff --git a/context/domination/tracker.md b/context/domination/tracker.md index 57fd95873..d3ac09393 100644 --- a/context/domination/tracker.md +++ b/context/domination/tracker.md @@ -130,6 +130,7 @@ ending with lengths of time counted from now, ahead of the remaining realms. | 55 | CORE-92 | Core | Weekly check for a `temporal-polyfill`
release GMT can swap to | — | #386 | — | Done | | 56 | CORE-105 | Core | One file per workaround in
`zonedWallClockDifference.ts` | — | #437 | — | Done | | 57 | CORE-107 | Core | A changelog page in Dox, and the
You-Dont-Need-Momentjs PR on `/upstream` | — | #451 | — | Done | +| 58 | CORE-110 | Core | The weekly upgrade check compares
each calendar's years with native Temporal | — | #468 | — | In progress | **`CORE-8` sits at slot 8, ahead of the realm work.** It gates everything after it: it is the standards and consistency pass over the whole public surface before 1.16.0 ships, and a realm diff --git a/scripts/lib/calendar-sweep.mjs b/scripts/lib/calendar-sweep.mjs new file mode 100644 index 000000000..ad89b18a5 --- /dev/null +++ b/scripts/lib/calendar-sweep.mjs @@ -0,0 +1,165 @@ +/** + * The calendar sweep (CORE-110): for every calendar both implementations support, and every + * calendar year that overlaps ISO years -3000 to 5000, compare a candidate Temporal implementation + * with a reference one on three facts. Those are the ISO date of the year's first day, the months in + * the year and the days in the year. + * + * Pure functions, no I/O, no imports, never `Date`. The caller supplies both Temporal namespaces and + * the calendar names, so this module never loads a polyfill. The span is fixed. It does not depend + * on the run date, so two runs on different days read the same years. + */ + +/** First day of the span, as an ISO 8601 extended-year date. */ +export const SPAN_FROM = "-003000-01-01"; +/** Last day of the span, as an ISO 8601 extended-year date. */ +export const SPAN_THROUGH = "+005000-12-31"; +/** Calendars listed in a result; `differingCalendars` still counts them all. */ +const MAX_CALENDARS_LISTED = 50; + +/** + * @typedef {{ year: number, toString(): string }} SweepDate + * @typedef {{ PlainDate: { + * from(item: string | { calendar: string, year: number, monthCode: string, day: number }): { + * year: number, monthsInYear: number, daysInYear: number, + * withCalendar(calendar: string): SweepDate } } }} TemporalLike the part of a `Temporal` + * namespace the sweep reads + * @typedef {{ calendar: string, years: number, first: number | null, example: string }} DifferingCalendar + */ + +/** + * The calendar years that overlap the span, read from the reference. + * + * @param {TemporalLike} reference + * @param {string} calendar + * @returns {{ first: number, last: number }} + */ +function yearRange(reference, calendar) { + const start = reference.PlainDate.from(SPAN_FROM).withCalendar(calendar); + const end = reference.PlainDate.from(SPAN_THROUGH).withCalendar(calendar); + return { + first: Math.min(start.year, end.year), + last: Math.max(start.year, end.year), + }; +} + +/** + * What one implementation says about one calendar year: three facts as one line, or the error + * class when it throws. Two lines are equal only when all three facts agree. + * + * @param {TemporalLike} temporal + * @param {string} calendar + * @param {number} year + * @returns {{ ok: true, text: string } | { ok: false, text: string }} + */ +function readYear(temporal, calendar, year) { + try { + const first = temporal.PlainDate.from({ + calendar, + year, + monthCode: "M01", + day: 1, + }); + const iso = first.withCalendar("iso8601").toString(); + return { + ok: true, + text: `${iso}, ${first.monthsInYear} months, ${first.daysInYear} days`, + }; + } catch (error) { + const name = error instanceof Error ? error.name : "Error"; + return { ok: false, text: `throws ${name}` }; + } +} + +/** + * Whether the implementation builds a date in the calendar at all. + * + * @param {TemporalLike} temporal + * @param {string} calendar + */ +function accepts(temporal, calendar) { + try { + temporal.PlainDate.from({ calendar, year: 2000, monthCode: "M01", day: 1 }); + return true; + } catch { + return false; + } +} + +/** + * Compare the candidate with the reference, per calendar and year. + * + * A year where one side throws and the other does not is a difference. A year where both throw is + * skipped. A calendar only one side accepts is a difference too, with `years: 0` and no first year. + * + * @param {{ candidate: TemporalLike, reference: TemporalLike, calendars: string[] }} input + * @returns {{ status: "ran", from: string, through: string, calendars: number, years: number, + * differingCalendars: number, differing: DifferingCalendar[], differingTruncated: boolean }} + */ +export function sweepCalendars({ candidate, reference, calendars }) { + if (calendars.length === 0) + throw new Error('Intl.supportedValuesOf("calendar") returned no calendars'); + + /** @type {DifferingCalendar[]} */ + const differing = []; + let differingCalendars = 0; + let compared = 0; + let years = 0; + + for (const calendar of calendars) { + const onCandidate = accepts(candidate, calendar); + const onReference = accepts(reference, calendar); + if (!onCandidate || !onReference) { + if (onCandidate !== onReference) { + differingCalendars++; + if (differing.length < MAX_CALENDARS_LISTED) { + differing.push({ + calendar, + years: 0, + first: null, + example: onCandidate + ? "only the candidate accepts this calendar" + : "only the reference accepts this calendar", + }); + } + } + continue; + } + + compared++; + const range = yearRange(reference, calendar); + let count = 0; + /** @type {DifferingCalendar | null} */ + let found = null; + for (let year = range.first; year <= range.last; year++) { + const c = readYear(candidate, calendar, year); + const r = readYear(reference, calendar, year); + if (!c.ok && !r.ok) continue; + years++; + if (c.text === r.text) continue; + count++; + found ??= { + calendar, + years: 0, + first: year, + example: `year ${year}: candidate ${c.text}; reference ${r.text}`, + }; + } + if (found) { + differingCalendars++; + if (differing.length < MAX_CALENDARS_LISTED) { + differing.push({ ...found, years: count }); + } + } + } + + return { + status: "ran", + from: SPAN_FROM, + through: SPAN_THROUGH, + calendars: compared, + years, + differingCalendars, + differing, + differingTruncated: differingCalendars > MAX_CALENDARS_LISTED, + }; +} diff --git a/scripts/lib/canary-issues.mjs b/scripts/lib/canary-issues.mjs index 13a00d90b..7915c44c2 100644 --- a/scripts/lib/canary-issues.mjs +++ b/scripts/lib/canary-issues.mjs @@ -161,8 +161,9 @@ const FORCED_ROW = { * forced?: { difference: true }, * }} LeapSecondsVerdict * @typedef {{ source: string, status: "could-not-run", message: string, - * sweep?: SwapVerdict["sweep"] }} CouldNotRunVerdict `sweep`: the offset sweep of a swap Node leg - * that stopped after it ran + * sweep?: SwapVerdict["sweep"], calendarSweep?: SwapVerdict["calendarSweep"] }} CouldNotRunVerdict + * `sweep` and `calendarSweep`: the offset and calendar sweeps of a swap Node leg that stopped + * after they ran * @typedef {{ file: string, test: string, message: string }} NativeFailure * @typedef {{ * source: string, status: "ran", leg: "node" | "chromium" | "firefox" | "webkit", engine: string, @@ -190,6 +191,12 @@ const FORCED_ROW = { * sweep: null | { status: "ran", tz: string, from: string, through: string, zones: number, * differingZones: number, [field: string]: unknown } * | { status: "could-not-run", message: string }, + * calendarSweep: null | { status: "ran", from: string, through: string, calendars: number, + * years: number, differingCalendars: number, + * differing: { calendar: string, years: number, first: number | null, + * example: string }[], + * [field: string]: unknown } + * | { status: "could-not-run", message: string }, * forced?: { swapReady: true }, * }} SwapVerdict * @typedef {{ removable?: string, mismatch?: boolean, nativeFailure?: boolean, @@ -1068,10 +1075,11 @@ function leapSecondsFindings(verdicts, runUrl) { /** * CORE-92: whether the `temporal-polyfill` swap passed on every runtime. Ready only when all four * legs ran, name one version, have no test that fails on the swap and passes on the control, and - * the Node leg's offset sweep ran and found no differing zone. Fail closed: each leg must say its - * swap pass loaded `temporal-polyfill` (`entryLoaded: true`), and `counts.failed` and - * `differingZones` must be the number 0, so a missing or malformed field blocks. Otherwise the - * reason names the first condition that failed, in that order. + * the Node leg's offset sweep ran and found no differing zone, and its calendar sweep ran and found + * no differing calendar. Fail closed: each leg must say its swap pass loaded `temporal-polyfill` + * (`entryLoaded: true`), and `counts.failed`, `differingZones` and `differingCalendars` must be the + * number 0, so a missing or malformed field blocks. Otherwise the reason names the first condition + * that failed, in that order. * @param {Record} verdicts * @returns {{ ready: true, version: string } | { ready: false, reason: string }} */ @@ -1132,6 +1140,24 @@ export function swapReady(verdicts) { : "offset sweep: the differing zone count is missing", }; } + const calendars = ran[0]?.calendarSweep; + if (calendars?.status !== "ran") { + return { ready: false, reason: "calendar sweep: did not run" }; + } + const c = calendars.differingCalendars; + if (c !== 0) { + return { + ready: false, + reason: + Number.isInteger(c) && c > 0 + ? `calendar sweep: ${c} ${c === 1 ? "calendar differs" : "calendars differ"} (${( + calendars.differing ?? [] + ) + .map((d) => d.calendar) + .join(", ")})` + : "calendar sweep: the differing calendar count is missing", + }; + } return { ready: true, version: /** @type {string} */ (versions[0]) }; } @@ -1181,6 +1207,18 @@ function swapParagraphs(verdicts, version, runUrl) { ? `Offset sweep: every one of ${sweep.zones} zones matches \`Intl.DateTimeFormat\` at 12:00 UTC each day ${span}.` : `Offset sweep: ${sweep.differingZones} of ${sweep.zones} zones differ from \`Intl.DateTimeFormat\` at 12:00 UTC on some day ${span}.`; } + const calendarSweep = + node?.status === "ran" + ? /** @type {SwapVerdict} */ (node).calendarSweep + : null; + let calendarLine = "Calendar sweep: did not run."; + if (calendarSweep?.status === "ran") { + const span = `from ${calendarSweep.from} to ${calendarSweep.through}`; + calendarLine = + calendarSweep.differingCalendars === 0 + ? `Calendar sweep: every one of ${calendarSweep.calendars} calendars matches the built-in Temporal on the first day, months and days of each year ${span}.` + : `Calendar sweep: ${calendarSweep.differingCalendars} of ${calendarSweep.calendars} calendars differ from the built-in Temporal in some year ${span}.`; + } return [ `temporal-polyfill ${version}, imported from \`temporal-polyfill/full/implementation\`, passed every check on this run: ${runUrl}`, table( @@ -1194,6 +1232,7 @@ function swapParagraphs(verdicts, version, runUrl) { rows, ), sweepLine, + calendarLine, `What the swap involves is in [temporal-polyfill-swap.md § 5 and § 7](${SWAP_RESEARCH_URL}). Type errors are not checked here; § 5 lists them.`, "A person makes the swap. CI opens issues, never pull requests.", ]; @@ -1223,7 +1262,7 @@ function swapFindings(verdicts, runUrl) { /** @type {Finding} */ const real = { key: "temporal-polyfill-swap/ready", - title: `Swap to temporal-polyfill ${version}: it passes the GMT suite and the offset sweep`, + title: `Swap to temporal-polyfill ${version}: it passes the GMT suite and both sweeps`, labels: [CANARY_LABEL], body: paragraphs.join("\n\n"), comment, @@ -1250,7 +1289,7 @@ function swapFindings(verdicts, runUrl) { /** * A swap leg that ran but whose swap pass did not load `temporal-polyfill` (`entryLoaded` is not * `true`) tested the wrong Temporal, so it counts as a leg that could not run. The Node leg's - * offset sweep that could not run is listed too: it is part of that leg's check. + * offset or calendar sweep that could not run is listed too: it is part of that leg's check. * @param {Record} verdicts * @returns {{ source: string, message: string }[]} */ @@ -1274,6 +1313,15 @@ function swapSweepFailures(verdicts) { message: `offset sweep: ${/** @type {{ message: string }} */ (node.sweep).message}`, }); } + if ( + node?.status === "ran" && + node.calendarSweep?.status === "could-not-run" + ) { + out.push({ + source: SWAP_NODE, + message: `calendar sweep: ${/** @type {{ message: string }} */ (node.calendarSweep).message}`, + }); + } return out; } diff --git a/scripts/lib/canary-summary.mjs b/scripts/lib/canary-summary.mjs index 9227bb513..d3ef04f9d 100644 --- a/scripts/lib/canary-summary.mjs +++ b/scripts/lib/canary-summary.mjs @@ -271,10 +271,12 @@ function nativeBlocks(verdicts) { /** How many differing zones the swap block names. */ const SWAP_ZONES_LISTED = 10; +/** How many differing calendars the swap block names. */ +const SWAP_CALENDARS_LISTED = 10; /** - * The `temporal-polyfill` swap (CORE-92): the verdict line, one table row per leg and the offset - * sweep. A leg that did not run keeps its row. + * The `temporal-polyfill` swap (CORE-92): the verdict line, one table row per leg, the offset + * sweep and the calendar sweep (CORE-110). A leg that did not run keeps its row. * @param {Record} verdicts * @returns {string[]} */ @@ -329,6 +331,28 @@ function swapBlocks(verdicts) { } else { sweepBlocks.push("Offset sweep: did not run."); } + const calendarSweep = + /** @type {import("./canary-issues.mjs").SwapVerdict | import("./canary-issues.mjs").CouldNotRunVerdict | null | undefined} */ ( + /** @type {unknown} */ (verdicts["temporal-polyfill-swap-node"]) + )?.calendarSweep ?? null; + if (calendarSweep?.status === "ran") { + const lines = [ + `Calendar sweep: ${calendarSweep.differingCalendars} calendars differ (${calendarSweep.calendars} calendars, ${calendarSweep.years} years, ${calendarSweep.from} to ${calendarSweep.through}).`, + ...calendarSweep.differing + .slice(0, SWAP_CALENDARS_LISTED) + .map( + (d) => + `- ${d.calendar}: ${d.years} ${d.years === 1 ? "year" : "years"}, first ${d.first ?? "none"}, e.g. ${oneLine(d.example)}`, + ), + ]; + sweepBlocks.push(lines.join("\n")); + } else if (calendarSweep?.status === "could-not-run") { + sweepBlocks.push( + `Calendar sweep: could not run: ${oneLine(calendarSweep.message)}`, + ); + } else { + sweepBlocks.push("Calendar sweep: did not run."); + } return [ "### Temporal polyfill swap", `${version} — ${state}`, diff --git a/scripts/lib/canary-verdict.mjs b/scripts/lib/canary-verdict.mjs index b102ae03f..e2980545c 100644 --- a/scripts/lib/canary-verdict.mjs +++ b/scripts/lib/canary-verdict.mjs @@ -233,7 +233,8 @@ export function nativeSuiteVerdict({ * The verdict of one `temporal-polyfill` swap leg (CORE-92). `failing` is what fails on the swap and * passes on the control in the same runtime; the verdict keeps the first 50, each message cut to 300 * characters, and says when it cut. `counts.failed` is the full number. `both` and `fixed` are - * counts only: their rows stay in the uploaded Vitest reports. `sweep` is `null` off Node. + * counts only: their rows stay in the uploaded Vitest reports. `sweep` (the offset sweep) and + * `calendarSweep` (the calendar sweep, CORE-110) are `null` off Node. * `entryLoaded` is whether the swap pass's own check passed: the seam's `Temporal` was the swap * entry's object. Without it the counts say nothing about `temporal-polyfill`. * @@ -245,6 +246,8 @@ export function nativeSuiteVerdict({ * failed: number, both: number, fixed: number }, * failing: NativeFailure[], * sweep: null | { status: "ran", [field: string]: unknown } + * | { status: "could-not-run", message: string }, + * calendarSweep: null | { status: "ran", [field: string]: unknown } * | { status: "could-not-run", message: string } }} input */ export function polyfillSwapVerdict({ @@ -256,6 +259,7 @@ export function polyfillSwapVerdict({ counts, failing, sweep, + calendarSweep, }) { return { source: `temporal-polyfill-swap-${leg}`, @@ -275,6 +279,7 @@ export function polyfillSwapVerdict({ })), failingTruncated: failing.length > UNTAGGED_ROWS_IN_VERDICT, sweep, + calendarSweep, }; } @@ -306,7 +311,7 @@ export function leapSecondsVerdict({ /** * What a command that exited 2 leaves behind: a canary that cannot run is a finding, not a silence. * - * The swap check adds `sweep` to a Node leg that stopped after its offset sweep ran. + * The swap check adds `sweep` and `calendarSweep` to a Node leg that stopped after those sweeps ran. * * @returns {{ source: string, status: "could-not-run", message: string }} */ diff --git a/scripts/polyfill-swap.mjs b/scripts/polyfill-swap.mjs index 44ed8c381..5e0b68602 100644 --- a/scripts/polyfill-swap.mjs +++ b/scripts/polyfill-swap.mjs @@ -11,7 +11,9 @@ * packages/gmt/vitest.swap.config.ts). A test that fails on the swap and passes on the control * blocks the swap; one that fails on both is the host's and does not. No tag excuses anything. * Type errors do not decide. The Node leg also compares the swap's UTC offsets with Intl's on - * every day from 1970 to ten years ahead (scripts/lib/offset-sweep.mjs). + * every day from 1970 to ten years ahead (scripts/lib/offset-sweep.mjs). It also compares each + * calendar's years from ISO -3000 to 5000 with Node's built-in Temporal + * (scripts/lib/calendar-sweep.mjs). * * The package must already be installed in packages/gmt (the swap job does it; it is never in a * manifest or lockfile). Exit 0 when both passes ran, whether the swap passed or not; 2 when the @@ -36,6 +38,7 @@ import { runPassAgainIfStopped, } from "./native-suite.mjs"; import { classify } from "./lib/native-suite-tags.mjs"; +import { sweepCalendars } from "./lib/calendar-sweep.mjs"; import { sweepOffsets, sweepSpan } from "./lib/offset-sweep.mjs"; const ROOT = fileURLToPath(new URL("..", import.meta.url)); @@ -70,6 +73,7 @@ const messageOf = (error) => * runtime: (leg: Leg) => Promise, * loadEntry: (root: string) => Promise<{ Temporal?: unknown }>, * sweep: (entry: any, today: SweepDate) => object, + * calendarSweep: (entry: any) => object, * today: () => SweepDate, * }} Deps */ @@ -143,6 +147,26 @@ export function sweep( }; } +/** + * Every calendar the runtime lists, the swap's years against the runtime's built-in Temporal + * (`globalThis.Temporal`, the reference). A host without a built-in Temporal cannot run it. + * @param {any} entry + * @param {string[]} [calendars] the calendars to compare (default: every one `Intl` lists) + */ +export function calendarSweep( + entry, + calendars = Intl.supportedValuesOf("calendar"), +) { + if (!globalThis.Temporal) { + throw new Error("this host has no built-in Temporal to compare with"); + } + return sweepCalendars({ + candidate: entry.Temporal, + reference: globalThis.Temporal, + calendars, + }); +} + /** @param {Leg} leg @returns {Promise} */ export async function runtime(leg) { const require = createRequire(import.meta.url); @@ -174,6 +198,7 @@ const realDeps = { runtime, loadEntry, sweep: (entry, today) => sweep(entry, today), + calendarSweep: (entry) => calendarSweep(entry), today: () => globalThis.Temporal.Now.plainDateISO("UTC"), }; @@ -234,6 +259,14 @@ function summary(root, leg, stdout) { } else if (v?.sweep) { lines.push(`Offset sweep could not run: ${v.sweep.message}`); } + const cal = v?.calendarSweep; + if (cal?.status === "ran") { + lines.push( + `Calendar sweep: ${cal.differingCalendars} calendars differ from Node's built-in Temporal, ${cal.from} to ${cal.through}, ${cal.calendars} calendars.`, + ); + } else if (cal) { + lines.push(`Calendar sweep could not run: ${cal.message}`); + } stdout(`${lines.join("\n")}\n`); } @@ -270,7 +303,13 @@ export async function main(argv, { root = ROOT, stdout, stderr, deps = {} }) { const verdict = couldNotRunVerdict(source, message); saveVerdict( root, - sweepResult === null ? verdict : { ...verdict, sweep: sweepResult }, + { + ...verdict, + ...(sweepResult === null ? {} : { sweep: sweepResult }), + ...(calendarSweepResult === null + ? {} + : { calendarSweep: calendarSweepResult }), + }, "polyfill-swap", ); stderr(`polyfill-swap: ${leg} could not run: ${message}\n`); @@ -281,6 +320,8 @@ export async function main(argv, { root = ROOT, stdout, stderr, deps = {} }) { let host; /** @type {object | null} */ let sweepResult = null; + /** @type {object | null} */ + let calendarSweepResult = null; /** @type {ReturnType} */ let passes; try { @@ -300,6 +341,14 @@ export async function main(argv, { root = ROOT, stdout, stderr, deps = {} }) { } catch (error) { sweepResult = { status: "could-not-run", message: messageOf(error) }; } + try { + calendarSweepResult = d.calendarSweep(entry); + } catch (error) { + calendarSweepResult = { + status: "could-not-run", + message: messageOf(error), + }; + } } host = await d.runtime(leg); passes = runBoth(leg, root, d, stderr); @@ -353,6 +402,7 @@ export async function main(argv, { root = ROOT, stdout, stderr, deps = {} }) { counts, failing, sweep: leg === "node" ? sweepResult : null, + calendarSweep: leg === "node" ? calendarSweepResult : null, }), "polyfill-swap", ); @@ -360,8 +410,12 @@ export async function main(argv, { root = ROOT, stdout, stderr, deps = {} }) { sweepResult && "differingZones" in sweepResult ? `; sweep: ${sweepResult.differingZones} zones differ` : ""; + const calendarNote = + calendarSweepResult && "differingCalendars" in calendarSweepResult + ? `; calendar sweep: ${calendarSweepResult.differingCalendars} calendars differ` + : ""; stdout( - `polyfill-swap: ${leg} temporal-polyfill ${version}: ${counts.failed} swap-only failures of ${counts.tests} tests${sweepNote}\n`, + `polyfill-swap: ${leg} temporal-polyfill ${version}: ${counts.failed} swap-only failures of ${counts.tests} tests${sweepNote}${calendarNote}\n`, ); return 0; } From 7df69e6f996ac9aa661968bf8235979b0b067c35 Mon Sep 17 00:00:00 2001 From: "Craig C." Date: Fri, 6 Nov 2026 19:48:47 +0200 Subject: [PATCH 2/7] docs(canary): say the weekly swap check sweeps calendars, with a blank changeset (CORE-110, #468) --- .changeset/temporal-polyfill-calendar-sweep.md | 5 +++++ .github/workflows/temporal-oracle.yml | 7 ++++--- apps/dox/src/content/docs/upstream.mdx | 5 +++-- 3 files changed, 12 insertions(+), 5 deletions(-) create mode 100644 .changeset/temporal-polyfill-calendar-sweep.md diff --git a/.changeset/temporal-polyfill-calendar-sweep.md b/.changeset/temporal-polyfill-calendar-sweep.md new file mode 100644 index 000000000..d7b39225c --- /dev/null +++ b/.changeset/temporal-polyfill-calendar-sweep.md @@ -0,0 +1,5 @@ +--- +--- + +No release. Only the weekly swap check changes: it now compares every calendar's years with +Node's built-in Temporal. No `@northguild/gmt` function, output or bundle size changes. diff --git a/.github/workflows/temporal-oracle.yml b/.github/workflows/temporal-oracle.yml index 60ca9b8c5..c87c79fb8 100644 --- a/.github/workflows/temporal-oracle.yml +++ b/.github/workflows/temporal-oracle.yml @@ -22,9 +22,10 @@ name: Temporal oracle # The polyfill-swap job (CORE-92) runs the same suite on the newest `temporal-polyfill` release, # through `temporal-polyfill/full/implementation`, beside a control pass on # `@js-temporal/polyfill` in the same runtime. The Node leg also compares every zone's offset with -# `Intl.DateTimeFormat`, once a day from 1970 to ten years ahead. When every leg passes and no zone -# differs, the report job opens one issue saying the swap is due. A failing swap leg never fails -# the workflow. +# `Intl.DateTimeFormat`, once a day from 1970 to ten years ahead, and every calendar's years from +# ISO -3000 to 5000 with Node's built-in Temporal (CORE-110). When every leg passes and no zone or +# calendar differs, the report job opens one issue saying the swap is due. A failing swap leg never +# fails the workflow. on: workflow_dispatch: diff --git a/apps/dox/src/content/docs/upstream.mdx b/apps/dox/src/content/docs/upstream.mdx index c5e3f7160..80e9c80f9 100644 --- a/apps/dox/src/content/docs/upstream.mdx +++ b/apps/dox/src/content/docs/upstream.mdx @@ -87,8 +87,9 @@ One bug is left, and the maintainers closed its report as a known limitation: limitation. GMT's own probe sees it in WebKit as `Etc/UTC` not equal to `UTC`. So for now GMT stays on `@js-temporal/polyfill`. Every week, GMT runs its whole test suite on the newest -`temporal-polyfill` release in Node and three browsers, and checks every zone's offsets against -`Intl.DateTimeFormat`. A release that passes both opens an issue in GMT's repository, and that +`temporal-polyfill` release in Node and three browsers. It checks every zone's offsets against +`Intl.DateTimeFormat` and every calendar's years against Node's built-in Temporal. A release that +passes all three opens an issue in GMT's repository, and that issue starts the switch. See the [weekly runs](https://github.com/northguild/gmt/actions/workflows/temporal-oracle.yml). The full comparison is in GMT's repository: From 8be009d2987bc2e0ffa4b3ca9799cc0c3d7173ca Mon Sep 17 00:00:00 2001 From: "Craig C." Date: Fri, 6 Nov 2026 19:49:26 +0200 Subject: [PATCH 3/7] docs(domination): mark CORE-110 Done in the tracker (CORE-110, #468) --- context/domination/tracker.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/context/domination/tracker.md b/context/domination/tracker.md index d3ac09393..dde78efb2 100644 --- a/context/domination/tracker.md +++ b/context/domination/tracker.md @@ -130,7 +130,7 @@ ending with lengths of time counted from now, ahead of the remaining realms. | 55 | CORE-92 | Core | Weekly check for a `temporal-polyfill`
release GMT can swap to | — | #386 | — | Done | | 56 | CORE-105 | Core | One file per workaround in
`zonedWallClockDifference.ts` | — | #437 | — | Done | | 57 | CORE-107 | Core | A changelog page in Dox, and the
You-Dont-Need-Momentjs PR on `/upstream` | — | #451 | — | Done | -| 58 | CORE-110 | Core | The weekly upgrade check compares
each calendar's years with native Temporal | — | #468 | — | In progress | +| 58 | CORE-110 | Core | The weekly upgrade check compares
each calendar's years with native Temporal | — | #468 | — | Done | **`CORE-8` sits at slot 8, ahead of the realm work.** It gates everything after it: it is the standards and consistency pass over the whole public surface before 1.16.0 ships, and a realm From 1c0de92850c273ecce8e99369642d1f85a6b3a24 Mon Sep 17 00:00:00 2001 From: "Craig C." Date: Fri, 6 Nov 2026 20:13:36 +0200 Subject: [PATCH 4/7] fix(canary): a sweep that compared nothing blocks the swap (CORE-110, #468) The calendar sweep throws when neither side accepts any listed calendar, so the Node leg records could-not-run. Readiness also needs a positive count of zones, calendars and years, so a verdict that lost one never reports ready. Raised in review. --- .../dox/scripts/canary/calendar-sweep.test.ts | 20 +++++++++++ apps/dox/scripts/canary/canary-issues.test.ts | 35 +++++++++++-------- context/domination/issues/CORE-110.md | 8 +++-- scripts/lib/calendar-sweep.mjs | 7 ++++ scripts/lib/canary-issues.mjs | 21 +++++++++++ 5 files changed, 74 insertions(+), 17 deletions(-) diff --git a/apps/dox/scripts/canary/calendar-sweep.test.ts b/apps/dox/scripts/canary/calendar-sweep.test.ts index 0b5d2274e..974167b37 100644 --- a/apps/dox/scripts/canary/calendar-sweep.test.ts +++ b/apps/dox/scripts/canary/calendar-sweep.test.ts @@ -220,4 +220,24 @@ describe("sweepCalendars", () => { }), ).toThrow('Intl.supportedValuesOf("calendar") returned no calendars'); }); + + it("throws when neither side accepts any listed calendar, so the leg records could-not-run", () => { + expect(() => + sweepCalendars({ + candidate: fake(same, ["iso"]), + reference: fake(same, ["iso"]), + calendars: ["iso", "gone"], + }), + ).toThrow("neither side accepts any of the 2 listed calendars"); + }); + + it("still reports a difference when only the reference accepts the calendars", () => { + const result = sweepCalendars({ + candidate: fake(same, ["iso"]), + reference: fake(same), + calendars: ["iso"], + }); + expect(result.calendars).toBe(0); + expect(result.differingCalendars).toBe(1); + }); }); diff --git a/apps/dox/scripts/canary/canary-issues.test.ts b/apps/dox/scripts/canary/canary-issues.test.ts index f541aebe3..d0f255285 100644 --- a/apps/dox/scripts/canary/canary-issues.test.ts +++ b/apps/dox/scripts/canary/canary-issues.test.ts @@ -2082,20 +2082,27 @@ describe("swapReady", () => { }; it.each` - label | verdicts | reason - ${"chromium entryLoaded is false"} | ${cleanSwap({ chromium: { entryLoaded: false } })} | ${"temporal-polyfill-swap-chromium: the swap pass did not load temporal-polyfill"} - ${"firefox entryLoaded is missing"} | ${changed("firefox", (v) => delete v.entryLoaded)} | ${"temporal-polyfill-swap-firefox: the swap pass did not load temporal-polyfill"} - ${"node entryLoaded is the string true"} | ${cleanSwap({ node: { entryLoaded: "true" } })} | ${"temporal-polyfill-swap-node: the swap pass did not load temporal-polyfill"} - ${"entry not loaded beats failing tests"} | ${cleanSwap({ webkit: { entryLoaded: false, failed: 5 } })} | ${"temporal-polyfill-swap-webkit: the swap pass did not load temporal-polyfill"} - ${"webkit failed count is missing"} | ${changed("webkit", (v) => delete v.counts.failed)} | ${"temporal-polyfill-swap-webkit: the failed count is missing"} - ${"node counts are missing"} | ${changed("node", (v) => delete v.counts)} | ${"temporal-polyfill-swap-node: the failed count is missing"} - ${"chromium failed count is the string 0"} | ${changed("chromium", (v) => (v.counts.failed = "0"))} | ${"temporal-polyfill-swap-chromium: the failed count is missing"} - ${"firefox failed count is null"} | ${changed("firefox", (v) => (v.counts.failed = null))} | ${"temporal-polyfill-swap-firefox: the failed count is missing"} - ${"sweep differingZones is missing"} | ${changed("node", (v) => delete v.sweep.differingZones)} | ${"offset sweep: the differing zone count is missing"} - ${"sweep differingZones is undefined"} | ${changed("node", (v) => (v.sweep.differingZones = undefined))} | ${"offset sweep: the differing zone count is missing"} - ${"sweep differingZones is the string 0"} | ${changed("node", (v) => (v.sweep.differingZones = "0"))} | ${"offset sweep: the differing zone count is missing"} - ${"calendar count is missing"} | ${changed("node", (v) => delete v.calendarSweep.differingCalendars)} | ${"calendar sweep: the differing calendar count is missing"} - ${"calendar count is the string 0"} | ${changed("node", (v) => (v.calendarSweep.differingCalendars = "0"))} | ${"calendar sweep: the differing calendar count is missing"} + label | verdicts | reason + ${"chromium entryLoaded is false"} | ${cleanSwap({ chromium: { entryLoaded: false } })} | ${"temporal-polyfill-swap-chromium: the swap pass did not load temporal-polyfill"} + ${"firefox entryLoaded is missing"} | ${changed("firefox", (v) => delete v.entryLoaded)} | ${"temporal-polyfill-swap-firefox: the swap pass did not load temporal-polyfill"} + ${"node entryLoaded is the string true"} | ${cleanSwap({ node: { entryLoaded: "true" } })} | ${"temporal-polyfill-swap-node: the swap pass did not load temporal-polyfill"} + ${"entry not loaded beats failing tests"} | ${cleanSwap({ webkit: { entryLoaded: false, failed: 5 } })} | ${"temporal-polyfill-swap-webkit: the swap pass did not load temporal-polyfill"} + ${"webkit failed count is missing"} | ${changed("webkit", (v) => delete v.counts.failed)} | ${"temporal-polyfill-swap-webkit: the failed count is missing"} + ${"node counts are missing"} | ${changed("node", (v) => delete v.counts)} | ${"temporal-polyfill-swap-node: the failed count is missing"} + ${"chromium failed count is the string 0"} | ${changed("chromium", (v) => (v.counts.failed = "0"))} | ${"temporal-polyfill-swap-chromium: the failed count is missing"} + ${"firefox failed count is null"} | ${changed("firefox", (v) => (v.counts.failed = null))} | ${"temporal-polyfill-swap-firefox: the failed count is missing"} + ${"sweep differingZones is missing"} | ${changed("node", (v) => delete v.sweep.differingZones)} | ${"offset sweep: the differing zone count is missing"} + ${"sweep differingZones is undefined"} | ${changed("node", (v) => (v.sweep.differingZones = undefined))} | ${"offset sweep: the differing zone count is missing"} + ${"sweep differingZones is the string 0"} | ${changed("node", (v) => (v.sweep.differingZones = "0"))} | ${"offset sweep: the differing zone count is missing"} + ${"calendar count is missing"} | ${changed("node", (v) => delete v.calendarSweep.differingCalendars)} | ${"calendar sweep: the differing calendar count is missing"} + ${"calendar count is the string 0"} | ${changed("node", (v) => (v.calendarSweep.differingCalendars = "0"))} | ${"calendar sweep: the differing calendar count is missing"} + ${"the sweep compared no zone"} | ${changed("node", (v) => (v.sweep.zones = 0))} | ${"offset sweep: it compared no zone"} + ${"the sweep lost its zone count"} | ${changed("node", (v) => delete v.sweep.zones)} | ${"offset sweep: the zone count is missing"} + ${"the sweep compared no calendar"} | ${changed("node", (v) => (v.calendarSweep.calendars = 0))} | ${"calendar sweep: it compared no calendar"} + ${"the sweep lost its calendar count"} | ${changed("node", (v) => delete v.calendarSweep.calendars)} | ${"calendar sweep: the calendar count is missing"} + ${"the sweep read no year"} | ${changed("node", (v) => (v.calendarSweep.years = 0))} | ${"calendar sweep: it compared no year"} + ${"the sweep lost its year count"} | ${changed("node", (v) => delete v.calendarSweep.years)} | ${"calendar sweep: the year count is missing"} + ${"no zone beats a differing zone count"} | ${changed("node", (v) => ((v.sweep.zones = 0), (v.sweep.differingZones = 3)))} | ${"offset sweep: it compared no zone"} `("is not ready when $label", ({ verdicts, reason }) => { expect(swapReady(verdicts)).toEqual({ ready: false, reason }); }); diff --git a/context/domination/issues/CORE-110.md b/context/domination/issues/CORE-110.md index 7747d8670..d25b4cd64 100644 --- a/context/domination/issues/CORE-110.md +++ b/context/domination/issues/CORE-110.md @@ -2,8 +2,8 @@ **Scope:** The Node leg of the weekly `temporal-polyfill` upgrade check ([CORE-92](CORE-92.md)) gains a calendar sweep beside its offset sweep. It compares every calendar's years with Node's -built-in Temporal. A difference blocks the upgrade. Adds no function and raises no pin. Tracked as -#468. +built-in Temporal. A difference blocks the upgrade. Adds no function and raises no pin. The issue +is #468. ## Gap @@ -64,7 +64,9 @@ Out of scope: any library function, raising any pin. 3. **A year where one side throws and the other does not is a difference.** A year where both throw is skipped. 4. **The sweep fails closed.** Missing, malformed or could-not-run results all block, so a verdict - that lost a field never reports ready. + that lost a field never reports ready. A sweep that compared nothing proves nothing: the + calendar sweep throws when neither side accepts any listed calendar, and readiness needs a + positive count of zones, calendars and years, so the offset sweep is held to the same rule. 5. **Chinese and Dangi block too.** On 1.0.8 the polyfill reads both lunisolar calendars from `Intl.DateTimeFormat`, and Node 26's `Intl` (ICU 78.3) disagrees with its built-in Temporal (ICU4X). Chinese differs in 3,889 years and Dangi in 3,858. Six Chinese years fall within diff --git a/scripts/lib/calendar-sweep.mjs b/scripts/lib/calendar-sweep.mjs index ad89b18a5..fb60c67c5 100644 --- a/scripts/lib/calendar-sweep.mjs +++ b/scripts/lib/calendar-sweep.mjs @@ -90,6 +90,7 @@ function accepts(temporal, calendar) { * * A year where one side throws and the other does not is a difference. A year where both throw is * skipped. A calendar only one side accepts is a difference too, with `years: 0` and no first year. + * It throws when it compared no calendar and found no difference, so the leg records could-not-run. * * @param {{ candidate: TemporalLike, reference: TemporalLike, calendars: string[] }} input * @returns {{ status: "ran", from: string, through: string, calendars: number, years: number, @@ -152,6 +153,12 @@ export function sweepCalendars({ candidate, reference, calendars }) { } } + // A sweep that compared nothing and found nothing proves nothing, so it must not read as a match. + if (compared === 0 && differingCalendars === 0) + throw new Error( + `neither side accepts any of the ${calendars.length} listed calendars`, + ); + return { status: "ran", from: SPAN_FROM, diff --git a/scripts/lib/canary-issues.mjs b/scripts/lib/canary-issues.mjs index 7915c44c2..55a7ae2d7 100644 --- a/scripts/lib/canary-issues.mjs +++ b/scripts/lib/canary-issues.mjs @@ -1130,6 +1130,9 @@ export function swapReady(verdicts) { if (sweep?.status !== "ran") { return { ready: false, reason: "offset sweep: did not run" }; } + // A sweep that compared nothing proves nothing: the counts of what it read must be positive. + const noZones = notCounted("offset sweep", sweep.zones, "zone"); + if (noZones) return { ready: false, reason: noZones }; const n = sweep.differingZones; if (n !== 0) { return { @@ -1144,6 +1147,10 @@ export function swapReady(verdicts) { if (calendars?.status !== "ran") { return { ready: false, reason: "calendar sweep: did not run" }; } + const noCalendars = + notCounted("calendar sweep", calendars.calendars, "calendar") ?? + notCounted("calendar sweep", calendars.years, "year"); + if (noCalendars) return { ready: false, reason: noCalendars }; const c = calendars.differingCalendars; if (c !== 0) { return { @@ -1161,6 +1168,20 @@ export function swapReady(verdicts) { return { ready: true, version: /** @type {string} */ (versions[0]) }; } +/** + * Why a sweep's count of what it read blocks the swap, or `null` when it is a positive integer. + * @param {string} sweep "offset sweep" or "calendar sweep" + * @param {unknown} count + * @param {string} noun what was counted, singular + * @returns {string | null} + */ +function notCounted(sweep, count, noun) { + if (Number.isInteger(count) && /** @type {number} */ (count) > 0) return null; + return count === 0 + ? `${sweep}: it compared no ${noun}` + : `${sweep}: the ${noun} count is missing`; +} + /** * "Chromium 153.0.8010.12" for a browser leg (Playwright's `chromium 153…` capitalised), "Node * 26.12.1" for the Node leg. From 65544c2a300ac8eacd6b8cdc96ebd726f077733a Mon Sep 17 00:00:00 2001 From: "Craig C." Date: Fri, 6 Nov 2026 20:13:37 +0200 Subject: [PATCH 5/7] fix(dox): make each stacked defect reference a 24 px target on /upstream/ (CORE-110, #468) axe target-size flagged the two references in the D1 row of the defects table. Each link is now 24 px tall, per WCAG 2.2 success criterion 2.5.8. --- apps/dox/src/components/UpstreamDefects.astro | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/apps/dox/src/components/UpstreamDefects.astro b/apps/dox/src/components/UpstreamDefects.astro index 54dbfe8f6..867f47b94 100644 --- a/apps/dox/src/components/UpstreamDefects.astro +++ b/apps/dox/src/components/UpstreamDefects.astro @@ -141,10 +141,20 @@ const filingsFor = (defects: readonly string[]) => * wider than the column. */ .sl-markdown-content .gmt-defects-refs li { - margin: 0 0 0.15rem; + margin: 0; padding-inline-start: 0; } +/* + * Stacked references are separate targets, so each one is 24 px tall (WCAG 2.2 § 2.5.8 Target + * Size (Minimum)). A reference that wraps at its space is two lines of 24 px. + */ +.sl-markdown-content .gmt-defects-refs a { + display: inline-block; + min-block-size: 1.5rem; + line-height: 1.5rem; +} + .sl-markdown-content .gmt-defects-refs li::before { display: none; content: none; From c94ddd4d8a2371403af5951eafe8705fc043b48b Mon Sep 17 00:00:00 2001 From: "Craig C." Date: Fri, 6 Nov 2026 20:27:02 +0200 Subject: [PATCH 6/7] fix(canary): a forced dry run no longer says the release passed every check (CORE-110, #468) The dry-run issue opened with passed every check on this run even when the run was not ready. It now says was checked on this run, and the real-result line says the run is not ready to swap before naming the first check that blocks it. --- apps/dox/scripts/canary/canary-issues.test.ts | 9 ++++++++- scripts/lib/canary-issues.mjs | 14 +++++++++----- 2 files changed, 17 insertions(+), 6 deletions(-) diff --git a/apps/dox/scripts/canary/canary-issues.test.ts b/apps/dox/scripts/canary/canary-issues.test.ts index d0f255285..e3c21c813 100644 --- a/apps/dox/scripts/canary/canary-issues.test.ts +++ b/apps/dox/scripts/canary/canary-issues.test.ts @@ -2468,6 +2468,9 @@ describe("swap force", () => { expect(dry.body).toContain( "Forced for a dry run. Real result on this run: every check passed.", ); + expect(dry.body).toContain( + `temporal-polyfill 1.0.7, imported from \`temporal-polyfill/full/implementation\`, passed every check on this run: ${RUN}`, + ); }); it("forced with webkit failing files only the dry run and states the real reason", () => { @@ -2476,8 +2479,12 @@ describe("swap force", () => { const [dry] = actions; if (dry.kind !== "open") throw new Error("expected open"); expect(dry.body).toContain( - "Forced for a dry run. Real result on this run: temporal-polyfill-swap-webkit: 2 tests fail on the swap.", + "Forced for a dry run. Real result on this run: not ready to swap. The first check that blocks it: temporal-polyfill-swap-webkit: 2 tests fail on the swap.", + ); + expect(dry.body).toContain( + `temporal-polyfill 1.0.7, imported from \`temporal-polyfill/full/implementation\`, was checked on this run: ${RUN}`, ); + expect(dry.body).not.toContain("passed every check"); expect(dry.body).toContain("| WebKit 26.6 | 71337 | 2 | 0 | 0 |"); }); diff --git a/scripts/lib/canary-issues.mjs b/scripts/lib/canary-issues.mjs index 55a7ae2d7..d71151cc6 100644 --- a/scripts/lib/canary-issues.mjs +++ b/scripts/lib/canary-issues.mjs @@ -1195,13 +1195,15 @@ function swapRuntimeName(leg, v) { } /** - * The swap issue's paragraphs, built from whichever legs ran. + * The swap issue's paragraphs, built from whichever legs ran. `ready` is false only in a forced dry + * run, whose text must not claim a pass the run did not have. * @param {Record} verdicts * @param {string} version * @param {string} runUrl + * @param {boolean} ready * @returns {string[]} */ -function swapParagraphs(verdicts, version, runUrl) { +function swapParagraphs(verdicts, version, runUrl, ready) { const rows = NATIVE_LEGS.map((leg) => { const v = verdictOf(verdicts, SWAP(leg)); if (v?.status !== "ran") { @@ -1241,7 +1243,7 @@ function swapParagraphs(verdicts, version, runUrl) { : `Calendar sweep: ${calendarSweep.differingCalendars} of ${calendarSweep.calendars} calendars differ from the built-in Temporal in some year ${span}.`; } return [ - `temporal-polyfill ${version}, imported from \`temporal-polyfill/full/implementation\`, passed every check on this run: ${runUrl}`, + `temporal-polyfill ${version}, imported from \`temporal-polyfill/full/implementation\`, ${ready ? "passed every check" : "was checked"} on this run: ${runUrl}`, table( [ "Runtime", @@ -1278,7 +1280,7 @@ function swapFindings(verdicts, runUrl) { ) ); const version = result.ready ? result.version : (firstRan?.version ?? ""); - const paragraphs = swapParagraphs(verdicts, version, runUrl); + const paragraphs = swapParagraphs(verdicts, version, runUrl, result.ready); const comment = `temporal-polyfill ${version} also passes (run ${runUrl}).\n\n${paragraphs.join("\n\n")}`; /** @type {Finding} */ const real = { @@ -1291,7 +1293,9 @@ function swapFindings(verdicts, runUrl) { /** @type {Finding[]} */ const out = result.ready ? [real] : []; if (forcedBy) { - const outcome = result.ready ? "every check passed" : result.reason; + const outcome = result.ready + ? "every check passed" + : `not ready to swap. The first check that blocks it: ${result.reason}`; out.push( dryRun( real, From 95be9c63a090a1c3a646824a149a1c53b7851210 Mon Sep 17 00:00:00 2001 From: "Craig C." Date: Fri, 6 Nov 2026 20:32:11 +0200 Subject: [PATCH 7/7] fix(canary): a forced swap run that is not ready never claims a pass in its title or comment (CORE-110, #468) The dry-run twin reused the ready issue title, and a second forced run commented with the ready comment, which opens also passes and has no real result line. A run that is not ready now titles its dry run not ready, forced to preview the ready issue, and every comment on an open dry run opens with the same real-result line as the body. --- apps/dox/scripts/canary/canary-issues.test.ts | 36 +++++++++++++++++-- scripts/lib/canary-issues.mjs | 27 ++++++++------ 2 files changed, 50 insertions(+), 13 deletions(-) diff --git a/apps/dox/scripts/canary/canary-issues.test.ts b/apps/dox/scripts/canary/canary-issues.test.ts index e3c21c813..91264cf7c 100644 --- a/apps/dox/scripts/canary/canary-issues.test.ts +++ b/apps/dox/scripts/canary/canary-issues.test.ts @@ -2406,13 +2406,15 @@ describe("swap force", () => { "temporal-compat-check": cleanCheck(), "temporal-oracle": oracle(), }); - const forcedPlan = (swap: unknown) => { + const forcedPlan = (swap: unknown, open: unknown[] = []) => { const { verdicts } = applyForce( withNative({ ...base(), ...(swap as object) }), { swapReady: true }, ); - return planIssueActions(verdicts as never, [], ORACLE_CONTEXT); + return planIssueActions(verdicts as never, open as never, ORACLE_CONTEXT); }; + const openDryRun = () => + issue(52, `\nold`); it("marks the first swap leg that ran", () => { const { verdicts, skipped } = applyForce( @@ -2486,6 +2488,36 @@ describe("swap force", () => { ); expect(dry.body).not.toContain("passed every check"); expect(dry.body).toContain("| WebKit 26.6 | 71337 | 2 | 0 | 0 |"); + expect(dry.title).toBe( + "[dry run] Swap to temporal-polyfill 1.0.7: not ready, forced to preview the ready issue", + ); + }); + + it("a forced run that is not ready comments on the open dry run with the real result", () => { + const actions = forcedPlan(cleanSwap({ webkit: { failed: 2 } }), [ + openDryRun(), + ]); + expect(actions.map((a) => a.key)).toEqual([DRY_KEY]); + const [dry] = actions; + if (dry.kind !== "comment") throw new Error("expected comment"); + expect(dry.issue).toBe(52); + expect(dry.body).toMatch( + /^Forced for a dry run\. Real result on this run: not ready to swap\. The first check that blocks it: temporal-polyfill-swap-webkit: 2 tests fail on the swap\.\n\n/, + ); + expect(dry.body).toContain( + `temporal-polyfill 1.0.7, imported from \`temporal-polyfill/full/implementation\`, was checked on this run: ${RUN}`, + ); + expect(dry.body).not.toContain("also passes"); + expect(dry.body).not.toContain("passed every check"); + }); + + it("a forced run that passes comments on the open dry run with the real result", () => { + const actions = forcedPlan(cleanSwap(), [openDryRun()]); + const dry = actions.find((a) => a.key === DRY_KEY); + if (!dry || dry.kind !== "comment") throw new Error("expected comment"); + expect(dry.body).toMatch( + /^Forced for a dry run\. Real result on this run: every check passed\.\n\n/, + ); }); it("a forced run with differing zones does not claim the sweep matched", () => { diff --git a/scripts/lib/canary-issues.mjs b/scripts/lib/canary-issues.mjs index d71151cc6..13e3e072c 100644 --- a/scripts/lib/canary-issues.mjs +++ b/scripts/lib/canary-issues.mjs @@ -1293,20 +1293,25 @@ function swapFindings(verdicts, runUrl) { /** @type {Finding[]} */ const out = result.ready ? [real] : []; if (forcedBy) { + // The dry run is built from the ready issue, so a run that is not ready takes its own title, + // and every comment on an open dry-run issue opens with the real result, as the body does. const outcome = result.ready ? "every check passed" : `not ready to swap. The first check that blocks it: ${result.reason}`; - out.push( - dryRun( - real, - "--force-swap-ready", - [ - `Forced for a dry run. Real result on this run: ${outcome}.`, - ...paragraphs, - ], - runUrl, - ), - ); + const dryParagraphs = [ + `Forced for a dry run. Real result on this run: ${outcome}.`, + ...paragraphs, + ]; + const twin = result.ready + ? real + : { + ...real, + title: `Swap to temporal-polyfill ${version}: not ready, forced to preview the ready issue`, + }; + out.push({ + ...dryRun(twin, "--force-swap-ready", dryParagraphs, runUrl), + comment: dryParagraphs.join("\n\n"), + }); } return out; }