diff --git a/.changeset/core-112-week-year.md b/.changeset/core-112-week-year.md new file mode 100644 index 000000000..40bb7dc6c --- /dev/null +++ b/.changeset/core-112-week-year.md @@ -0,0 +1,14 @@ +--- +"@northguild/gmt": patch +--- + +Formatting no longer stops Node with a crash, and prints the right year, in languages whose date patterns print the year a week belongs to instead of the calendar year. `formatZonedRange`, `formatCalendar` and the `…ToParts` functions stopped Node 22, 24 and 26 with a crash for some languages and calendars, for example Burmese with the Buddhist calendar, and Galician with the Hebrew, Buddhist or ROC calendar and a full date style. Every format function also printed the wrong year near the start or end of a year, or all year in the Buddhist, Japanese and ROC calendars: Scottish Gaelic printed `Dùbh 2025` for 30 December 2024, and now prints `Dùbh 2024`. + +Some calendars and languages printed a year or a range that the specifications do not give, and now print the specifications' text: + +- The Japanese calendar before 1873, when Japan adopted it, printed an era year: `Dec 31, 5 Meiji` for 31 December 1872 is now `Dec 31, 1872 AD`. +- An Islamic date before the Hijra printed a negative year such as `-23 AH`, and is now the empty value. +- Japanese with the Japanese calendar and a two-digit year printed `令和6年`, and now prints `令和06年`. The first year of an era stays `元年`. With another numbering system the era year printed Latin digits, and now prints that system's digits: `ja-u-ca-japanese-nu-arab` printed `令和6年` and now prints `令和٦年`. +- The Chinese and Dangi calendars with a two-digit year padded the related year, which has no two-digit form: `05(yi-chou)` for the year 5 is now `5(yi-chou)`. +- A range whose language's interval pattern drops or repeats a field, such as the year of a Chinese-calendar range across two years, prints both dates in full, joined by the language's own range separator. +- A language with the `islamic` calendar printed the astronomical Hijri date (`Muh. 5, 1446 AH` for 10 July 2024). It now prints the tabular `islamic-tbla` date (`Muh. 4, 1446 AH`), and `islamic-rgsa` prints the language's default calendar. diff --git a/.changeset/d6-cached-day-probe.md b/.changeset/d6-cached-day-probe.md new file mode 100644 index 000000000..8483c177e --- /dev/null +++ b/.changeset/d6-cached-day-probe.md @@ -0,0 +1,5 @@ +--- +"@northguild/gmt": patch +--- + +GMT checks the installed `@js-temporal/polyfill` for one more bug in counting months or years between two dates in a non-ISO calendar. The polyfill's unreleased `main` loses a day when a Hebrew or Islamic count starts on the 30th and crosses a 29-day month (tc39/proposal-temporal#3327). GMT already uses its own count while the polyfill has the older bugs in it. With this check, a later release that fixes those but has this one still gets GMT's count, so results stay correct. On 0.5.1, the release GMT depends on today, no result changes. diff --git a/.fallowrc.jsonc b/.fallowrc.jsonc index 3b78d86bb..19c6e99fc 100644 --- a/.fallowrc.jsonc +++ b/.fallowrc.jsonc @@ -6,6 +6,10 @@ "entry": [ "packages/gmt/src/test/nativeTemporal.ts", "scripts/lib/native-suite-reporter.mjs", + // The weekly D23/D24 locale sweep (CORE-112), run by hand or from a workflow. + "scripts/canary/weekYear.mjs", + // The weekly D29 range sweep (CORE-112); it starts itself as a child process. + "scripts/canary/rangeFields.mjs", "packages/gmt/bench/*.bench.ts", "packages/gmt/src/test/*.browser.ts", "packages/gmt/src/test/boundedWorker.ts", @@ -41,6 +45,54 @@ "maxCrap": 30, "maxUnitSize": 60, "thresholdOverrides": [ + { + "files": ["packages/gmt/src/internal/weekYearRange.ts"], + "functions": [ + "farRange", + "shiftYears", + "digitsMatch", + "computeShift", + "movedLikeYear", + "signOf", + ], + "maxCrap": 70, + "reason": "D24 range verdict: cyclomatic and cognitive are inside the limits; the CRAP figure is estimated from export references because these helpers are not exported, and weekYearRange.test.ts covers every branch through rangeYearVerdict", + }, + { + "files": ["packages/gmt/src/internal/rangeDetector.ts"], + "functions": [ + "judge", + "rangeVerdict", + "isAbsent", + "probeKind", + "", + ], + "maxCyclomatic": 30, + "maxCognitive": 30, + "maxCrap": 150, + "reason": "D29 range detector kernel: judge and the per-probe check branch once per field class (year, month, day, day period, hour, minute, era); rangeDetector.test.ts covers each verdict and its broken field class, and the three-engine sweep exercises every branch, while fallow estimates CRAP from export references because the helpers are not exported", + }, + { + "files": ["packages/gmt/src/internal/rangeFieldValues.ts"], + "functions": ["rowsOf"], + "maxCrap": 40, + "reason": "D29 field-value rows (ECMA-402 Table 6): cyclomatic 11 and cognitive 8 are inside the limits, and the CRAP figure is estimated from export references because rowsOf is unexported; rangeFields.test.ts and yearPrinting.test.ts reach every row through rangeFieldsEqual", + }, + { + "files": ["packages/gmt/src/internal/weekYearSynth.ts"], + "functions": ["textTwinOptions", "timeTwinOptions", "fits"], + "maxCrap": 40, + "reason": "D23 week-year parts synthesis: cyclomatic 10 and cognitive at most 13 are inside the limits, and the CRAP figure is estimated from export references because each helper is unexported; weekYearSingle.test.ts covers each branch through guardedDateTimeFormat", + }, + { + "files": [ + "packages/gmt/src/internal/yearPrinting.ts", + "packages/gmt/src/zoned/format/formatZonedRange.ts", + ], + "functions": ["formatRange", "zonedRangeText", "twinParts"], + "maxCrap": 70, + "reason": "CORE-112 range repairs: cyclomatic (at most 11) and cognitive (at most 11) are inside the limits; the CRAP figure is estimated from export references because each is a closure or an unexported helper, and yearPrinting.test.ts, rangeFields.test.ts and formatZonedRange*.test.ts cover each branch through the public range functions", + }, { "files": ["packages/gmt/src/internal/patternToken.ts"], "functions": [ diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index c5b9f7c1e..7d1244ab7 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -243,6 +243,10 @@ jobs: if: contains(fromJSON(env.CHECKS), 'upstream') run: node scripts/upstream.mjs check + - name: Pulse checks match the workflows + if: contains(fromJSON(env.CHECKS), 'pulse') + run: node apps/dox/scripts/build-pulse.mjs --check + # Some content pages are generated, not committed: `guides/concepts/dst-disambiguation.md` # (copied from the canonical `docs/dst-disambiguation.md`), the `changelog/` pages (built # from each package's CHANGELOG.md), `scenarios/index.mdx`, `tools/index.mdx` and the diff --git a/.github/workflows/cldr-sweep-weekly.yml b/.github/workflows/cldr-sweep-weekly.yml new file mode 100644 index 000000000..8045552f7 --- /dev/null +++ b/.github/workflows/cldr-sweep-weekly.yml @@ -0,0 +1,121 @@ +name: CLDR sweep weekly + +# Pulse check: cldr-sweep +# +# The week-year and range-field defects (D23, D24, D29 in packages/gmt/src/internal/temporalCompat) +# depend on the locale data inside each Node release, so no unit test can cover them. Once a week +# this sweep runs both detectors over every `cldr-dates-full` locale and every calendar, on Node 22, +# 24 and 26: scripts/canary/weekYear.mjs for week-of-year years and V8 aborts, and +# scripts/canary/rangeFields.mjs for a range that drops, repeats or garbles a field of one date. +# It is far too slow for ci.yml (about 160 CPU-minutes per Node), so it never runs there. +# +# A run fails only when a detector misses a defect the engine's own range parts confirm, or reports +# one they do not. A locale that is still broken does not fail it. Each leg writes a report and +# uploads it; the next run reads the report of the same leg from the previous run and lists, in the +# job summary, the locales that newly break and the ones that are fixed. No issue is filed and no +# token can write. +# +# Legs: rangeFields.mjs --shard i/n deals the sorted locales out round-robin, so the shards of one +# Node share the work. weekYear.mjs runs once per Node, on shard 1. Adding or removing a shard +# means changing the matrix. + +on: + workflow_dispatch: + schedule: + - cron: "23 3 * * 6" + +concurrency: + group: cldr-sweep-weekly + cancel-in-progress: false + +permissions: + actions: read + contents: read + +env: + # The job runs the Node it names, not the devEngines.runtime pin. + pnpm_config_verify_deps_before_run: "false" + +jobs: + sweep: + name: Sweep (${{ matrix.leg }}) + runs-on: ubuntu-latest + timeout-minutes: 90 + strategy: + fail-fast: false + matrix: + include: + - { leg: node22-1, node: 22, shard: "1/2" } + - { leg: node22-2, node: 22, shard: "2/2" } + - { leg: node24-1, node: 24, shard: "1/2" } + - { leg: node24-2, node: 24, shard: "2/2" } + - { leg: node26-1, node: 26, shard: "1/2" } + - { leg: node26-2, node: 26, shard: "2/2" } + steps: + - uses: actions/checkout@v7 + + - uses: pnpm/action-setup@v6 + + - uses: actions/setup-node@v7 + with: + node-version: ${{ matrix.node }} + check-latest: true + cache: pnpm + + - name: Install dependencies + run: pnpm install --frozen-lockfile --no-runtime + + - name: Build the library + run: pnpm --filter @northguild/gmt build + + # The week-year sweep covers every locale in one pass, so only the first shard of each Node + # runs it. + - name: Week-year sweep + if: ${{ startsWith(matrix.shard, '1/') }} + run: node scripts/canary/weekYear.mjs + + - name: Range-field sweep (shard ${{ matrix.shard }}) + if: ${{ !cancelled() }} + run: > + node scripts/canary/rangeFields.mjs --shard ${{ matrix.shard }} + --out "$RUNNER_TEMP/range-fields-${{ matrix.leg }}.json" + + - name: Upload the report + if: ${{ !cancelled() }} + uses: actions/upload-artifact@v7 + with: + name: cldr-sweep-${{ matrix.leg }}-${{ github.run_id }} + path: ${{ runner.temp }}/range-fields-${{ matrix.leg }}.json + if-no-files-found: ignore + retention-days: 35 + + # Finds the newest earlier run of this workflow that finished and kept a report for this leg, + # then lists what changed. No earlier report is a note, never a failure. + - name: Compare with the previous run + if: ${{ !cancelled() }} + env: + GH_TOKEN: ${{ github.token }} + LEG: ${{ matrix.leg }} + run: | + current="$RUNNER_TEMP/range-fields-$LEG.json" + { + echo "## Range fields, $LEG" + echo + } >> "$GITHUB_STEP_SUMMARY" + if [ ! -f "$current" ]; then + echo "This run wrote no report." >> "$GITHUB_STEP_SUMMARY" + exit 0 + fi + previous="" + for run in $(gh api "repos/$GITHUB_REPOSITORY/actions/workflows/cldr-sweep-weekly.yml/runs?status=completed&per_page=10" \ + --jq ".workflow_runs[] | select(.id != $GITHUB_RUN_ID and .conclusion != \"cancelled\") | .id" 2>/dev/null); do + if gh run download "$run" --repo "$GITHUB_REPOSITORY" --name "cldr-sweep-$LEG-$run" --dir "$RUNNER_TEMP/previous" 2>/dev/null; then + previous="$RUNNER_TEMP/previous/range-fields-$LEG.json" + break + fi + done + if [ -z "$previous" ] || [ ! -f "$previous" ]; then + echo "No earlier report for this leg, so there is nothing to compare." >> "$GITHUB_STEP_SUMMARY" + exit 0 + fi + node scripts/canary/rangeFields.mjs --diff "$previous" "$current" >> "$GITHUB_STEP_SUMMARY" diff --git a/.github/workflows/deploy-dox.yml b/.github/workflows/deploy-dox.yml index 2d8b9ace6..3e514a91d 100644 --- a/.github/workflows/deploy-dox.yml +++ b/.github/workflows/deploy-dox.yml @@ -1,5 +1,7 @@ name: Deploy Dox +# Pulse check: deploy-dox +# on: # After Release, never alongside it. Release runs on every push to main, so this # still deploys every merge. A push that publishes pushes its @@ -9,7 +11,7 @@ on: # or failure. # # Failure mode: if Release ever stops running on pushes to main (renamed, - # disabled, or given a path filter), merges stop deploying the docs. The daily + # disabled, or given a path filter), merges stop deploying the docs. The # schedule and workflow_dispatch below still deploy. workflow_run: workflows: [Release] diff --git a/.github/workflows/dox-gates-weekly.yml b/.github/workflows/dox-gates-weekly.yml index b80b7e113..c55b3ac79 100644 --- a/.github/workflows/dox-gates-weekly.yml +++ b/.github/workflows/dox-gates-weekly.yml @@ -1,5 +1,7 @@ name: Dox gates weekly +# Pulse check: dox-gates +# # The PR job (ci.yml, `dox-gates`) checks the changed pages in Chromium. This sweep checks every page # in three browsers and both themes, once a week, and files what fails as a `dox-gate` issue, one # open issue per finding (apps/dox/scripts/gates/issue-plan.mjs). A failing gate fails its leg; the @@ -26,7 +28,6 @@ on: required: false default: false schedule: - # Sundays 04:41 UTC. - cron: "41 4 * * 0" concurrency: diff --git a/.github/workflows/leap-seconds.yml b/.github/workflows/leap-seconds.yml index 5deff6566..5ee2ac2a3 100644 --- a/.github/workflows/leap-seconds.yml +++ b/.github/workflows/leap-seconds.yml @@ -1,8 +1,10 @@ name: Leap-second canary +# Pulse check: leap-seconds +# # Compares GMT's built-in leap-second table (packages/gmt/src/internal/leapSeconds.ts) with the # IERS Leap_Second.dat file, or with IANA's leap-seconds.list (the same IERS table) when IERS cannot -# be reached and the IANA file has not expired. Manual and weekly only: never part of ci.yml or +# be reached and the IANA file has not expired. Manual and scheduled only: never part of ci.yml or # `pnpm run validate`, because those runs have no network. A difference (IERS lists a row GMT does # not, or a row differs) opens or updates one `canary` issue carrying the IERS header line # ("Updated through IERS Bulletin …"); a run that cannot read either file opens or updates one @@ -10,9 +12,6 @@ name: Leap-second canary # plus a `patch` changeset. The dispatch input is a dry run: it files a clearly marked [dry run] # issue and changes no comparison or exit code. Issues are filed only from main: a run on another # branch lists what it would have filed in the job summary and files nothing. -# -# The table is closed (CGPM 2026 Resolution 5: continuous UTC from 20 May 2027). Retire this -# workflow and scripts/leap-seconds.mjs once IERS publishes its file format for continuous UTC. on: workflow_dispatch: @@ -23,7 +22,6 @@ on: required: false default: false schedule: - # Mondays 06:43 UTC - cron: "43 6 * * 1" concurrency: diff --git a/.github/workflows/temporal-oracle.yml b/.github/workflows/temporal-oracle.yml index 67f271553..defa4ba21 100644 --- a/.github/workflows/temporal-oracle.yml +++ b/.github/workflows/temporal-oracle.yml @@ -1,8 +1,13 @@ name: Temporal oracle +# Pulse check: workaround-node +# Pulse check: native-oracle +# Pulse check: native-suite +# Pulse check: polyfill-swap +# # Compares GMT's calendar results against Chromium's native Temporal (test262 is the final # authority where they disagree) and reports which @js-temporal/polyfill workarounds are still -# needed. Manual and weekly only: never part of ci.yml, because "upstream still broken" must +# needed. Manual and scheduled only: never part of ci.yml, because "upstream still broken" must # never fail a build. A failing oracle job means a GMT result differs from native Temporal on a # row that the script's tag list does not explain — a GMT bug to fix. # @@ -59,7 +64,6 @@ on: required: false default: false schedule: - # Mondays 06:17 UTC - cron: "17 6 * * 1" concurrency: diff --git a/.github/workflows/us-clock-watch.yml b/.github/workflows/us-clock-watch.yml index e20a8ef23..b77a804c1 100644 --- a/.github/workflows/us-clock-watch.yml +++ b/.github/workflows/us-clock-watch.yml @@ -1,5 +1,7 @@ name: US clock-change watch +# Pulse check: us-clock-watch +# # Compares three sources with the snapshot: the Congress.gov API, with a GovInfo title search, and # the Open States API for bills on the clock-change subject (new, or a changed latest action), and # the IANA tz database for any change to the rules of a zone in apps/dox/src/lib/us-region-zones.json. @@ -17,10 +19,6 @@ name: US clock-change watch # issue and changes no comparison or exit code. Issues are filed only from main: a run on another # branch lists what it would have filed in the job summary and files nothing, and its carried # snapshot is never read. -# -# Retirement (context/domination/issues/CORE-90.md, Decisions): the tz part when the US clock-change -# checker (CORE-90 phase 2) ships; the federal and state parts when the Proposals view's data is -# removed or replaced. on: workflow_dispatch: @@ -31,7 +29,6 @@ on: required: false default: false schedule: - # Mondays 07:17 UTC - cron: "17 7 * * 1" concurrency: diff --git a/apps/dox/package.json b/apps/dox/package.json index daa9832bf..2a38ff1e6 100644 --- a/apps/dox/package.json +++ b/apps/dox/package.json @@ -6,7 +6,7 @@ "license": "UNLICENSED", "type": "module", "scripts": { - "generate": "node ../../scripts/upstream.mjs refresh && node ./scripts/generate-version-map.mjs && node ../../scripts/syntax-floor.mjs --ts src/generated/syntax-floor.ts && tsx ./scripts/build-reference.ts && node ./scripts/build-guides.mjs && node ./scripts/build-changelog.mjs && node ./scripts/build-scenario-index.mjs && tsx ./scripts/build-tool-index.ts && tsx ./scripts/build-industry-pages.ts && tsx ./scripts/build-industry-sidebars.ts && node ./scripts/ensure-sidebar-order.mjs && node ../../scripts/bundle-size.mjs report --json src/generated/bundle-size.json && tsx ./scripts/build-corpus-counts.ts", + "generate": "node ../../scripts/upstream.mjs refresh && node ./scripts/build-pulse.mjs && node ./scripts/generate-version-map.mjs && node ../../scripts/syntax-floor.mjs --ts src/generated/syntax-floor.ts && tsx ./scripts/build-reference.ts && node ./scripts/build-guides.mjs && node ./scripts/build-changelog.mjs && node ./scripts/build-scenario-index.mjs && tsx ./scripts/build-tool-index.ts && tsx ./scripts/build-industry-pages.ts && tsx ./scripts/build-industry-sidebars.ts && node ./scripts/ensure-sidebar-order.mjs && node ../../scripts/bundle-size.mjs report --json src/generated/bundle-size.json && tsx ./scripts/build-corpus-counts.ts", "predev": "pnpm --filter @northguild/gmt build:dev", "dev": "pnpm run generate && node ./scripts/dev-all.mjs", "predev:site": "pnpm --filter @northguild/gmt build:dev", @@ -109,6 +109,7 @@ "oxlint": "^1.78.0", "pixelmatch": "7.2.0", "pngjs": "7.0.0", + "postcss": "8.5.31", "postcss-html": "1.8.1", "stylelint": "17.16.0", "stylelint-config-standard": "40.0.0", diff --git a/apps/dox/scripts/build-pulse.mjs b/apps/dox/scripts/build-pulse.mjs new file mode 100644 index 000000000..39f6d5dc1 --- /dev/null +++ b/apps/dox/scripts/build-pulse.mjs @@ -0,0 +1,452 @@ +#!/usr/bin/env node +/** + * Builds the data behind `/pulse/` and keeps the repo's list of checks honest. + * + * node scripts/build-pulse.mjs write src/generated/pulse.json, then read run history + * node scripts/build-pulse.mjs --check report drift between the list and the repo (`pnpm pulse:check`) + * node scripts/build-pulse.mjs --sync rewrite the table in context/canary/overview.md (`pnpm pulse:sync`) + * + * The one hand-written source is `scripts/lib/pulse.mjs`. This script reads each workflow with + * `yaml` (its name, its schedules, its jobs) and joins them to the list, so no cadence or job name + * is typed twice. The run history of every scheduled workflow is read from GitHub at build only, + * best effort, the way `scripts/upstream.mjs refresh` reads the filings: ten seconds in all, a six + * hour freshness window, no token or a 404 leaves the history empty, and the page says so. The + * history goes to the gitignored `src/generated/pulse-runs.live.json`. + * + * Nothing runs on import: the functions below take their inputs, so the tests use fixtures and an + * injected `gh`, clock and stamp. The stamp uses GMT when `packages/gmt` is built, and a build + * without it reads no history. + */ +import { execFile } from "node:child_process"; +import { + existsSync, + readdirSync, + readFileSync, + statSync, + writeFileSync, + mkdirSync, +} from "node:fs"; +import { dirname, join, relative } from "node:path"; +import { fileURLToPath } from "node:url"; +import { promisify } from "node:util"; +import { parseDocument } from "yaml"; +import { formatJson } from "../../../scripts/lib/format-json.mjs"; +import { tryLoadGmt } from "../../../scripts/lib/gmt.mjs"; +import { PULSE_AREAS, PULSE_CHECKS } from "../../../scripts/lib/pulse.mjs"; +import { WORKAROUNDS } from "../../../scripts/lib/workarounds.mjs"; + +const execFileAsync = promisify(execFile); + +const HERE = dirname(fileURLToPath(import.meta.url)); +export const REPO_ROOT = join(HERE, "../../.."); +const GENERATED = join(HERE, "../src/generated"); +export const PULSE_FILE = join(GENERATED, "pulse.json"); +export const RUNS_FILE = join(GENERATED, "pulse-runs.live.json"); + +export const OVERVIEW_PATH = "context/canary/overview.md"; +export const OVERVIEW_START = ""; +export const OVERVIEW_END = ""; + +const RUNS_BUDGET_MS = 10_000; +const RUNS_TTL_MS = 6 * 60 * 60 * 1000; +const RUNS_CALL_MS = 4_000; +const RUNS_PER_WORKFLOW = 12; + +/** The id a workaround group goes by: its defects joined, as the compat page labels it. */ +export const groupId = (group) => group.defects.join(" + "); + +/** Reads one workflow file: its name, every `schedule[].cron` and the id and name of every job. */ +export function readWorkflow(root, rel) { + const doc = parseDocument(readFileSync(join(root, rel), "utf8")); + if (doc.errors.length > 0) { + throw new Error(`${rel}: ${doc.errors[0].message}`); + } + const data = doc.toJS() ?? {}; + const on = data.on ?? {}; + const schedule = Array.isArray(on.schedule) ? on.schedule : []; + return { + name: typeof data.name === "string" ? data.name : rel, + crons: schedule.map((s) => s.cron).filter((c) => typeof c === "string"), + jobs: Object.entries(data.jobs ?? {}).map(([id, job]) => ({ + id, + name: typeof job?.name === "string" ? job.name : id, + })), + }; +} + +/** Every workflow file under `.github/workflows` that has an `on.schedule`, relative to the root. */ +export function scheduledWorkflows(root) { + const dir = join(root, ".github/workflows"); + if (!existsSync(dir)) return []; + return readdirSync(dir) + .filter((f) => /\.ya?ml$/.test(f)) + .sort() + .map((f) => `.github/workflows/${f}`) + .filter((rel) => readWorkflow(root, rel).crons.length > 0); +} + +const SKIP_DIRS = new Set(["node_modules", "dist", ".git", "generated"]); + +/** Files under `dir` (relative to `root`) whose name matches `test`, skipping dependency folders. */ +function findFiles(root, dir, test) { + const out = []; + const walk = (rel) => { + const abs = join(root, rel); + if (!existsSync(abs)) return; + for (const entry of readdirSync(abs, { withFileTypes: true })) { + if (entry.isDirectory()) { + if (!SKIP_DIRS.has(entry.name)) walk(`${rel}/${entry.name}`); + } else if (test(entry.name)) { + out.push(`${rel}/${entry.name}`); + } + } + }; + walk(dir); + return out.sort(); +} + +/** The workflow-or-test sources the list names, in list order, each once, with the checks it holds. */ +export function sourcesOf(checks) { + const map = new Map(); + for (const check of checks) { + if (!map.has(check.source)) map.set(check.source, []); + map.get(check.source).push(check); + } + return map; +} + +/** What `pulse.json` holds: the list joined with what the workflow files say. */ +export function buildPulse({ root = REPO_ROOT, checks = PULSE_CHECKS } = {}) { + const cards = []; + for (const [source, held] of sourcesOf(checks)) { + const isWorkflow = source.startsWith(".github/workflows/"); + const workflow = isWorkflow ? readWorkflow(root, source) : null; + cards.push({ + source, + file: source.split("/").at(-1), + kind: isWorkflow ? "workflow" : "test", + name: workflow?.name ?? held[0].name, + crons: workflow?.crons ?? [], + jobs: workflow?.jobs ?? [], + checkIds: held.map((c) => c.id), + }); + } + return { + areas: PULSE_AREAS, + checks: checks.map((c) => ({ ...c })), + cards, + workaroundGroups: WORKAROUNDS.map(groupId), + }; +} + +/** Whether a source file carries `Pulse check: ` in a comment. */ +const carriesTag = (text, id) => + new RegExp(`^\\s*(?:#|//|\\*)\\s*Pulse check:\\s*${id}\\s*$`, "m").test(text); + +/** A comment line that talks about retiring something: the list says it, not the source file. */ +const RETIRE_PROSE = + /^\s*(?:#|\/\/|\*)(?!\s*Pulse check:).*\bretire(?:s|d|ment)?\b/im; + +/** The plain-words cell for a check's life. */ +export function lifeText(life) { + switch (life.kind) { + case "permanent": + return `Stays. ${life.why}`; + case "workarounds": + return life.groups === "all" + ? "When the last workaround is gone." + : `When workarounds ${life.groups.join(", ")} are gone.`; + case "condition": + return `When ${life.until}.`; + } +} + +const cell = (text) => text.replaceAll("|", "\\|").replaceAll("\n", " "); + +const storyCell = (story) => + /^CORE-\d+$/.test(story) + ? `[${story}](../domination/issues/${story}.md)` + : `${story}: [../dox/built.md](../dox/built.md)`; + +/** The generated canary table, rows in list order. */ +export function overviewTable(checks = PULSE_CHECKS) { + const rows = checks.map((c) => { + const where = `\`${c.source.split("/").at(-1)}\`${c.job ? ` job \`${c.job}\`` : ""}`; + return `| ${[ + cell(c.name), + where, + cell(c.watches), + cell(c.finds), + cell(lifeText(c.life)), + c.story === "Dox epic" ? "Dox epic" : storyCell(c.story), + ].join(" | ")} |`; + }); + return [ + "| Canary | Where | Checks | Finds | Retires | Story |", + "| --- | --- | --- | --- | --- | --- |", + ...rows, + ].join("\n"); +} + +/** The overview text with the generated block replaced; `null` when the markers are missing. */ +export function syncedOverview(text, checks = PULSE_CHECKS) { + const start = text.indexOf(OVERVIEW_START); + const end = text.indexOf(OVERVIEW_END); + if (start === -1 || end === -1 || end < start) return null; + return `${text.slice(0, start + OVERVIEW_START.length)}\n\n${overviewTable(checks)}\n\n${text.slice(end)}`; +} + +/** Every way the list and the repo disagree, one sentence each. Empty means they agree. */ +export function checkDrift({ + root = REPO_ROOT, + checks = PULSE_CHECKS, + workarounds = WORKAROUNDS, +} = {}) { + const problems = []; + const ids = new Set(); + for (const c of checks) { + if (ids.has(c.id)) problems.push(`Two checks share the id ${c.id}.`); + ids.add(c.id); + } + + const scheduled = scheduledWorkflows(root); + const sources = new Set(checks.map((c) => c.source)); + for (const wf of scheduled) { + if (!sources.has(wf)) { + problems.push( + `${wf} runs on a schedule but no check in scripts/lib/pulse.mjs names it.`, + ); + } + } + + const canaryScripts = findFiles(root, "scripts/canary", (n) => + n.endsWith(".mjs"), + ); + const canaryTests = ["apps", "packages", "scripts"].flatMap((dir) => + findFiles(root, dir, (n) => n.endsWith("-canary.test.ts")), + ); + const namedScripts = new Set(checks.flatMap((c) => c.scripts ?? [])); + for (const s of canaryScripts) { + if (!namedScripts.has(s)) { + problems.push( + `${s} is a canary script but no check lists it under scripts.`, + ); + } + } + for (const t of canaryTests) { + if (!sources.has(t)) { + problems.push( + `${t} is a canary test but no check names it as its source.`, + ); + } + } + + const groupIds = new Set(workarounds.map(groupId)); + const claimed = new Set(); + for (const c of checks) { + const abs = join(root, c.source); + if (!existsSync(abs)) { + problems.push(`Check ${c.id}: ${c.source} does not exist.`); + continue; + } + const text = readFileSync(abs, "utf8"); + if (c.source.startsWith(".github/workflows/")) { + const wf = readWorkflow(root, c.source); + if (wf.crons.length === 0) { + problems.push(`Check ${c.id}: ${c.source} has no schedule.`); + } + if (c.job && !wf.jobs.some((j) => j.id === c.job)) { + problems.push(`Check ${c.id}: ${c.source} has no job ${c.job}.`); + } + } + for (const s of c.scripts ?? []) { + if (!existsSync(join(root, s))) { + problems.push(`Check ${c.id}: ${s} does not exist.`); + } + } + if (!carriesTag(text, c.id)) { + problems.push(`${c.source} has no "Pulse check: ${c.id}" line.`); + } + if (RETIRE_PROSE.test(text)) { + problems.push( + `${c.source} describes when it retires; that belongs in the check's life in scripts/lib/pulse.mjs.`, + ); + } + if (c.life.kind === "workarounds") { + const claims = c.life.groups === "all" ? [...groupIds] : c.life.groups; + for (const g of claims) { + if (!groupIds.has(g)) { + problems.push( + `Check ${c.id} claims workaround group ${g}, which does not exist.`, + ); + } + claimed.add(g); + } + } + } + for (const g of groupIds) { + if (!claimed.has(g)) { + problems.push(`Workaround group ${g} is claimed by no check's life.`); + } + } + + const overviewPath = join(root, OVERVIEW_PATH); + if (existsSync(overviewPath)) { + const text = readFileSync(overviewPath, "utf8"); + const next = syncedOverview(text, checks); + if (next === null) { + problems.push( + `${OVERVIEW_PATH} has no ${OVERVIEW_START} and ${OVERVIEW_END} markers.`, + ); + } else if (next !== text) { + problems.push( + `The table in ${OVERVIEW_PATH} is out of date: run pnpm pulse:sync.`, + ); + } + } + return problems; +} + +// --------------------------------------------------------------------------------------------- +// Run history + +/** What a workflow run is called on the page: only the fields it prints. */ +const RUN_JQ = `[.workflow_runs[] | select(.conclusion != null) | {startedAt: .run_started_at, conclusion: .conclusion, url: .html_url}]`; + +/** The default way to ask GitHub: the `gh` CLI, with a time limit. */ +export async function ghApi(path, timeoutMs) { + const { stdout } = await execFileAsync("gh", ["api", path, "--jq", RUN_JQ], { + timeout: Math.max(1, Math.floor(timeoutMs)), + maxBuffer: 4 * 1024 * 1024, + }); + return JSON.parse(stdout); +} + +/** + * Age in ms of the live file by its modified time; `Infinity` when there is none, or when + * `packages/gmt` is not built (the refresh then reads no history anyway). A test may answer + * synchronously. + * + * @param {string} file + * @returns {number | Promise} + */ +function liveFileAge(file) { + if (!existsSync(file)) return Infinity; + return tryLoadGmt().then((gmt) => + gmt === null + ? Infinity + : gmt.getUnixNow({ epochUnit: "milliseconds" }) - statSync(file).mtimeMs, + ); +} + +/** + * Reads the recent scheduled runs of every scheduled workflow and writes the live file. Returns + * what happened as a word for the log; never throws. Every input that touches the world is + * injectable. + */ +export async function refreshRuns({ + root = REPO_ROOT, + checks = PULSE_CHECKS, + file = RUNS_FILE, + env = process.env, + gh = ghApi, + stamp = async () => { + const gmt = await tryLoadGmt(); + return gmt === null ? null : gmt.getUtcNow(); + }, + ageOf = liveFileAge, + clock = () => performance.now(), + log = (line) => console.warn(line), +} = {}) { + if (env.CI === undefined && env.PULSE_REFRESH !== "force") { + if ((await ageOf(file)) < RUNS_TTL_MS) { + log( + `pulse: ${file} is under 6 h old, skipping (PULSE_REFRESH=force to refresh now)`, + ); + return "fresh"; + } + } + try { + const read = await stamp(); + if (read === null) { + log("pulse: packages/gmt is not built, so no run history was read"); + return "skipped"; + } + const sources = [...sourcesOf(checks).keys()].filter((s) => + scheduledWorkflows(root).includes(s), + ); + const deadline = clock() + RUNS_BUDGET_MS; + const workflows = {}; + for (const source of sources) { + const left = deadline - clock(); + if (left <= 0) throw new Error("the 10 s budget ran out"); + const name = source.split("/").at(-1); + try { + workflows[name] = await gh( + `repos/{owner}/{repo}/actions/workflows/${name}/runs?event=schedule&per_page=${RUNS_PER_WORKFLOW}`, + Math.min(left, RUNS_CALL_MS), + ); + } catch { + // A 404 (the workflow is not on main yet) or a failed call leaves this one without history. + workflows[name] = null; + } + } + mkdirSync(dirname(file), { recursive: true }); + writeFileSync(file, formatJson({ runsRead: read, workflows })); + return "read"; + } catch (error) { + log( + `pulse: run history not read: ${error instanceof Error ? error.message : String(error)}`, + ); + return "failed"; + } +} + +// --------------------------------------------------------------------------------------------- + +async function main(argv) { + const mode = argv.includes("--check") + ? "check" + : argv.includes("--sync") + ? "sync" + : "build"; + if (mode === "sync") { + const path = join(REPO_ROOT, OVERVIEW_PATH); + const text = readFileSync(path, "utf8"); + const next = syncedOverview(text); + if (next === null) { + console.error( + `${OVERVIEW_PATH} has no ${OVERVIEW_START} and ${OVERVIEW_END} markers.`, + ); + process.exit(1); + } + if (next !== text) writeFileSync(path, next); + console.log( + next === text + ? "pulse: overview already current" + : "pulse: overview table rewritten", + ); + return; + } + const problems = checkDrift(); + if (problems.length > 0) { + console.error( + `pulse: the list of checks and the repo disagree:\n- ${problems.join("\n- ")}`, + ); + process.exit(1); + } + if (mode === "check") { + console.log(`pulse: ${PULSE_CHECKS.length} checks match the repo`); + return; + } + mkdirSync(GENERATED, { recursive: true }); + writeFileSync(PULSE_FILE, formatJson(buildPulse())); + await refreshRuns(); +} + +if ( + process.argv[1] && + relative(process.argv[1], fileURLToPath(import.meta.url)) === "" +) { + await main(process.argv.slice(2)); +} diff --git a/apps/dox/scripts/build-pulse.test.ts b/apps/dox/scripts/build-pulse.test.ts new file mode 100644 index 000000000..341982973 --- /dev/null +++ b/apps/dox/scripts/build-pulse.test.ts @@ -0,0 +1,337 @@ +import { + mkdirSync, + mkdtempSync, + readFileSync, + rmSync, + writeFileSync, +} from "node:fs"; +import { tmpdir } from "node:os"; +import { dirname, join } from "node:path"; +import { + buildPulse, + checkDrift, + OVERVIEW_END, + OVERVIEW_PATH, + OVERVIEW_START, + overviewTable, + readWorkflow, + refreshRuns, + syncedOverview, +} from "./build-pulse.mjs"; + +type Check = Parameters[0] extends infer T + ? T extends readonly (infer C)[] + ? C + : never + : never; + +const WORKFLOW = `name: Fixture weekly + +# Pulse check: fixture + +on: + workflow_dispatch: + schedule: + - cron: "17 6 * * 1" + +jobs: + canary: + name: The canary + runs-on: ubuntu-latest +`; + +const CHECK = { + id: "fixture", + name: "Fixture", + area: "temporal", + source: ".github/workflows/fixture.yml", + job: "canary", + watches: "A thing.", + finds: "Opens an issue.", + life: { kind: "workarounds", groups: "all" }, + story: "CORE-1", +} as unknown as Check; + +const GROUPS = [{ defects: ["D1"] }, { defects: ["D2", "D3"] }]; + +const dirs: string[] = []; +afterEach(() => { + for (const dir of dirs.splice(0)) + rmSync(dir, { recursive: true, force: true }); +}); + +/** A repo-shaped folder with one scheduled workflow and the overview table in sync. */ +function fixtureRoot( + files: Record = {}, + checks: readonly Check[] = [CHECK], +): string { + const root = mkdtempSync(join(tmpdir(), "pulse-")); + dirs.push(root); + const all: Record = { + ".github/workflows/fixture.yml": WORKFLOW, + [OVERVIEW_PATH]: `# Overview\n\n${OVERVIEW_START}\n${OVERVIEW_END}\n`, + ...files, + }; + for (const [rel, text] of Object.entries(all)) { + mkdirSync(dirname(join(root, rel)), { recursive: true }); + writeFileSync(join(root, rel), text); + } + const overview = join(root, OVERVIEW_PATH); + const synced = syncedOverview(readFileSync(overview, "utf8"), checks); + if (synced !== null) writeFileSync(overview, synced); + return root; +} + +describe("pulse: the real list matches the repo", () => { + it("reports no drift", () => { + expect(checkDrift()).toEqual([]); + }); + + it("joins every check to a card, with the cron and jobs the workflow file says", () => { + const data = buildPulse(); + const ids = data.cards.flatMap((c: { checkIds: string[] }) => c.checkIds); + expect(ids.sort()).toEqual( + data.checks.map((c: { id: string }) => c.id).sort(), + ); + const oracle = data.cards.find( + (c: { file: string }) => c.file === "temporal-oracle.yml", + ); + expect(oracle?.crons).toHaveLength(1); + expect(oracle?.jobs.map((j: { id: string }) => j.id)).toContain("oracle"); + }); +}); + +describe("pulse: the drift check", () => { + it("passes on a fixture where list, workflow, tag and groups agree", () => { + const root = fixtureRoot(); + expect( + checkDrift({ root, checks: [CHECK], workarounds: GROUPS as never }), + ).toEqual([]); + }); + + it("fails when a scheduled workflow has no entry", () => { + const root = fixtureRoot({ + ".github/workflows/other.yml": WORKFLOW.replace("fixture", "other"), + }); + const problems = checkDrift({ + root, + checks: [CHECK], + workarounds: GROUPS as never, + }); + expect(problems.join("\n")).toMatch(/other\.yml runs on a schedule/); + }); + + it("fails when an entry is deleted from the list", () => { + const root = fixtureRoot(); + const problems = checkDrift({ + root, + checks: [], + workarounds: GROUPS as never, + }); + expect(problems.join("\n")).toMatch(/fixture\.yml runs on a schedule/); + }); + + it("fails when the source loses its Pulse check line", () => { + const root = fixtureRoot({ + ".github/workflows/fixture.yml": WORKFLOW.replace( + "# Pulse check: fixture\n", + "", + ), + }); + const problems = checkDrift({ + root, + checks: [CHECK], + workarounds: GROUPS as never, + }); + expect(problems.join("\n")).toMatch(/no "Pulse check: fixture" line/); + }); + + it("fails when a workaround group is claimed by no check", () => { + const root = fixtureRoot(); + const partial = { + ...CHECK, + life: { kind: "workarounds", groups: ["D1"] }, + } as Check; + const problems = checkDrift({ + root, + checks: [partial], + workarounds: GROUPS as never, + }); + expect(problems.join("\n")).toMatch( + /group D2 \+ D3 is claimed by no check/, + ); + }); + + it("fails when a check claims a group that does not exist", () => { + const root = fixtureRoot(); + const wrong = { + ...CHECK, + life: { kind: "workarounds", groups: ["D9"] }, + } as Check; + const problems = checkDrift({ + root, + checks: [wrong], + workarounds: GROUPS as never, + }); + expect(problems.join("\n")).toMatch(/claims workaround group D9/); + }); + + it("fails when a job named by an entry is not in the workflow", () => { + const root = fixtureRoot(); + const wrong = { ...CHECK, job: "missing" } as Check; + const problems = checkDrift({ + root, + checks: [wrong], + workarounds: GROUPS as never, + }); + expect(problems.join("\n")).toMatch(/has no job missing/); + }); + + it("fails on retirement prose left in a source file", () => { + const root = fixtureRoot({ + ".github/workflows/fixture.yml": WORKFLOW.replace( + "# Pulse check: fixture\n", + "# Pulse check: fixture\n# Retire this workflow when it is done.\n", + ), + }); + const problems = checkDrift({ + root, + checks: [CHECK], + workarounds: GROUPS as never, + }); + expect(problems.join("\n")).toMatch(/describes when it retires/); + }); + + it("fails on a canary script and a canary test no entry names", () => { + const root = fixtureRoot({ + "scripts/canary/extra.mjs": "// a canary\n", + "apps/dox/src/lib/extra-canary.test.ts": "// a canary\n", + }); + const text = checkDrift({ + root, + checks: [CHECK], + workarounds: GROUPS as never, + }).join("\n"); + expect(text).toMatch(/scripts\/canary\/extra\.mjs is a canary script/); + expect(text).toMatch(/extra-canary\.test\.ts is a canary test/); + }); + + it("fails when the overview table is stale", () => { + const root = fixtureRoot(); + writeFileSync( + join(root, OVERVIEW_PATH), + `# Overview\n\n${OVERVIEW_START}\nold\n${OVERVIEW_END}\n`, + ); + const problems = checkDrift({ + root, + checks: [CHECK], + workarounds: GROUPS as never, + }); + expect(problems.join("\n")).toMatch(/out of date: run pnpm pulse:sync/); + }); +}); + +describe("pulse: the workflow reader", () => { + it("reads the name, the schedules and the jobs", () => { + const root = fixtureRoot(); + expect(readWorkflow(root, ".github/workflows/fixture.yml")).toEqual({ + name: "Fixture weekly", + crons: ["17 6 * * 1"], + jobs: [{ id: "canary", name: "The canary" }], + }); + }); +}); + +describe("pulse: the overview table", () => { + it("writes one row per check between the markers and is stable", () => { + const once = syncedOverview(`a\n${OVERVIEW_START}\n${OVERVIEW_END}\nb\n`, [ + CHECK, + ]); + expect(once).toContain("| Fixture | `fixture.yml` job `canary` |"); + expect(syncedOverview(once as string, [CHECK])).toBe(once); + }); + + it("returns null when the markers are missing", () => { + expect(syncedOverview("no markers", [CHECK])).toBeNull(); + }); +}); + +describe("pulse: run history", () => { + const RUN = { + conclusion: "success", + startedAt: "2026-11-09T06:20:00Z", + url: "u", + }; + + /** Reads the history into a fixture folder with everything injected: no network, no clock. */ + async function read( + options: Partial[0]> = {}, + ): Promise<{ result: string; file: string; logs: string[] }> { + const root = fixtureRoot(); + const file = join(root, "runs.json"); + const logs: string[] = []; + const result = await refreshRuns({ + root, + checks: [CHECK], + file, + env: {}, + stamp: async () => "2026-11-14T10:00:00Z", + ageOf: () => Infinity, + clock: () => 0, + log: (line: string) => logs.push(line), + gh: async () => [RUN], + ...options, + }); + return { result, file, logs }; + } + + it("writes the runs of each scheduled workflow with the time they were read", async () => { + const { result, file } = await read(); + expect(result).toBe("read"); + expect(JSON.parse(readFileSync(file, "utf8"))).toEqual({ + runsRead: "2026-11-14T10:00:00Z", + workflows: { "fixture.yml": [RUN] }, + }); + }); + + it("leaves a workflow's runs null when the call fails", async () => { + const { file } = await read({ + gh: async () => { + throw new Error("HTTP 404"); + }, + }); + expect( + JSON.parse(readFileSync(file, "utf8")).workflows["fixture.yml"], + ).toBeNull(); + }); + + it("skips while the file is under six hours old, unless forced", async () => { + expect((await read({ ageOf: () => 1000 })).result).toBe("fresh"); + expect( + (await read({ ageOf: () => 1000, env: { PULSE_REFRESH: "force" } })) + .result, + ).toBe("read"); + expect( + (await read({ ageOf: () => 1000, env: { CI: "true" } })).result, + ).toBe("read"); + }); + + it("reads nothing, and says so, when the library is not built", async () => { + const { result, logs } = await read({ stamp: async () => null }); + expect(result).toBe("skipped"); + expect(logs.join()).toMatch(/not built/); + }); + + it("gives up with a warning when the budget is spent", async () => { + let now = 0; + const { result, logs } = await read({ + clock: () => { + const t = now; + now += 20_000; + return t; + }, + }); + expect(result).toBe("failed"); + expect(logs.join()).toMatch(/budget/); + }); +}); diff --git a/apps/dox/scripts/canary/native-suite-compat.test.ts b/apps/dox/scripts/canary/native-suite-compat.test.ts index 9002af6c4..a41eb9247 100644 --- a/apps/dox/scripts/canary/native-suite-compat.test.ts +++ b/apps/dox/scripts/canary/native-suite-compat.test.ts @@ -333,14 +333,18 @@ describe("runBrowserCompat with a fake browser", () => { expect(verdict.counts).toEqual({ workarounds: WORKAROUNDS.length, stillNeeded: 0, - removable: WORKAROUNDS.length - 2, + removable: WORKAROUNDS.length - 3, guard: 1, - outOfScope: 1, + outOfScope: 2, }); expect(verdict.workarounds.find((w) => w.id === "D17")).toMatchObject({ state: "out-of-scope", engines: ["firefox"], }); + expect(verdict.workarounds.find((w) => w.id === "D23")).toMatchObject({ + state: "out-of-scope", + engines: ["v8"], + }); expect(verdict.workarounds.find((w) => w.id === "D19")).toMatchObject({ state: "removable", engines: ["webkit"], diff --git a/apps/dox/scripts/llms.test.ts b/apps/dox/scripts/llms.test.ts index fdaa4980d..0beefa748 100644 --- a/apps/dox/scripts/llms.test.ts +++ b/apps/dox/scripts/llms.test.ts @@ -768,7 +768,7 @@ Body text here.`; expect(wrong).toEqual([]); }); - it("llms.txt lists Install first under Start here, and compare, bundle-size and upstream under Migrate", () => { + it("llms.txt lists Install first and upstream and pulse under Start here, and compare and bundle-size under Migrate", () => { const distDir = distDirOrSkip(); if (distDir === null) return; const llms = readFileSync(resolve(distDir, "llms.txt"), "utf8"); @@ -784,12 +784,18 @@ Body text here.`; const startHere = section("Start here"); expect(startHere[0]).toMatch(/\/install\.md\)/); const migrate = section("Migrate"); - for (const slug of [ - "compare", - "bundle-size", - "upstream", - "native-engines", - ]) { + for (const slug of ["upstream", "pulse"]) { + const link = new RegExp(`/${slug}\\.md\\)`); + expect( + startHere.some((line) => link.test(line)), + `${slug} is under Start here`, + ).toBe(true); + expect( + migrate.some((line) => link.test(line)), + `${slug} is not under Migrate`, + ).toBe(false); + } + for (const slug of ["compare", "bundle-size", "native-engines"]) { const link = new RegExp(`/${slug}\\.md\\)`); expect( migrate.some((line) => link.test(line)), @@ -809,7 +815,7 @@ Body text here.`; const urls = [...full.matchAll(/^> source: (\S+)$/gm)].map((m) => m[1]!); const path = (url: string) => url.replace(/^.*\/gmt\//, ""); expect(urls.length).toBeGreaterThan(0); - const lastStart = urls.findIndex((url) => path(url) === "why-gmt.md"); + const lastStart = urls.findIndex((url) => path(url) === "pulse.md"); expect(lastStart).toBeGreaterThanOrEqual(0); expect(path(urls[lastStart + 1]!)).toMatch(/^guides\//); const firstMigrate = urls.findIndex((url) => @@ -818,7 +824,7 @@ Body text here.`; expect(firstMigrate).toBeGreaterThan(lastStart); for (const url of urls.slice(firstMigrate)) { expect(path(url), url).toMatch( - /^(migrate\/|compare\/behaviour\.md$|compare\.md$|bundle-size\.md$|upstream\.md$|native-engines\.md$)/, + /^(migrate\/|compare\/behaviour\.md$|compare\.md$|bundle-size\.md$|native-engines\.md$)/, ); } }); diff --git a/apps/dox/src/components/UpstreamDefectRow.astro b/apps/dox/src/components/UpstreamDefectRow.astro index 5691449a0..7d439e1e8 100644 --- a/apps/dox/src/components/UpstreamDefectRow.astro +++ b/apps/dox/src/components/UpstreamDefectRow.astro @@ -14,10 +14,9 @@ import { groupLabel, groupWhatBreaks, reasonParts, - shortRef, stateLine, } from "../data/temporal-compat"; -import type { UpstreamFiling } from "../data/upstream-filings"; +import { filingRef, type UpstreamFiling } from "../data/upstream-filings"; import { chip, defectBadge } from "../lib/upstream-badges"; interface Props { @@ -55,7 +54,7 @@ const { count } = stateLine(group); diff --git a/apps/dox/src/components/UpstreamFilingRow.astro b/apps/dox/src/components/UpstreamFilingRow.astro index 891634c71..f974cc01e 100644 --- a/apps/dox/src/components/UpstreamFilingRow.astro +++ b/apps/dox/src/components/UpstreamFilingRow.astro @@ -8,8 +8,7 @@ * fields, so no status is typed by hand. The cells carry no `data-col`: the card is a header, a * body and a meta line, not label/value pairs. */ -import { shortRef } from "../data/temporal-compat"; -import type { UpstreamFiling } from "../data/upstream-filings"; +import { filingRef, type UpstreamFiling } from "../data/upstream-filings"; import { inlineCodeHtml } from "../lib/inline-code-html"; import { octicon } from "../lib/octicons"; import { @@ -52,9 +51,9 @@ const gmtNote = filing.gmtGuard ? null : filing.gmtNote; - {filing.kind === "pr" ? "Pull request:" : "Issue:"} + {filing.tracker === "github" && filing.kind === "pr" ? "Pull request:" : "Issue:"} - {shortRef(filing.repo, filing.number)} + {filingRef(filing)} @@ -74,8 +73,17 @@ const gmtNote = filing.gmtGuard ? null : filing.gmtNote; - {countLabel(filing.maintainerComments, "maintainer reply", "maintainer replies")} - + {filing.maintainerComments === null ? ( + <> + Maintainer replies are not tracked on this site + + + ) : ( + <> + {countLabel(filing.maintainerComments, "maintainer reply", "maintainer replies")} + + + )} diff --git a/apps/dox/src/components/UpstreamTracker.astro b/apps/dox/src/components/UpstreamTracker.astro index 41f0dafd7..b54d8d6f3 100644 --- a/apps/dox/src/components/UpstreamTracker.astro +++ b/apps/dox/src/components/UpstreamTracker.astro @@ -1,10 +1,10 @@ --- /** - * The /upstream/ tracker: one table per repository, built from `upstream-filings.ts` — the live + * The /upstream/ tracker: one table per repository or tracker, built from `upstream-filings.ts` — the live * refresh when GitHub is reachable, the committed snapshot otherwise. Nothing is fetched in the * browser. Sentences come from `lib/upstream-summary.ts`, styles in `gmt-content-tables.css`. */ -import { filingRepos, filingsForRepo } from "../data/upstream-filings"; +import { filingGroups, filingsForGroup } from "../data/upstream-filings"; import { UPSTREAM_COLUMNS as COLUMNS } from "../lib/upstream-status"; import { asDate } from "../lib/upstream-summary"; import UpstreamFilingRow from "./UpstreamFilingRow.astro"; @@ -16,18 +16,18 @@ import UpstreamTrackerSummary from "./UpstreamTrackerSummary.astro"; { - filingRepos.map((repo) => ( + filingGroups.map((group) => (

- {repo} + {group.name}

-
+
{COLUMNS.map((column) => )} - {filingsForRepo(repo).map((f) => ( + {filingsForGroup(group.id).map((f) => ( ))} diff --git a/apps/dox/src/components/UpstreamTrackerSummary.astro b/apps/dox/src/components/UpstreamTrackerSummary.astro index a26fcdf69..c4b41a8c6 100644 --- a/apps/dox/src/components/UpstreamTrackerSummary.astro +++ b/apps/dox/src/components/UpstreamTrackerSummary.astro @@ -17,7 +17,7 @@ import { contributionClause, coverageClause } from "../lib/upstream-summary";

- So far we have sent {filedByUs} reports and fixes to the Temporal projects, {filedPrs} of them as + So far we have sent {filedByUs} reports and fixes to Temporal and the projects it builds on, {filedPrs} of them as ready-to-merge code changes{contributionClause}. {coverageClause}: {handledInGmt} through its own built-in fix, and {unaffectingGmt} because the bug is in code GMT doesn't use. diff --git a/apps/dox/src/components/pulse/Pulse.astro b/apps/dox/src/components/pulse/Pulse.astro new file mode 100644 index 000000000..55112d403 --- /dev/null +++ b/apps/dox/src/components/pulse/Pulse.astro @@ -0,0 +1,37 @@ +--- +/** + * `/pulse/`: every scheduled check, what it watches, when it runs, its recent runs and what + * retires it. The markup is built in `widgets/families/pulse/pulse-template.ts`; the script below + * fills three reserved slots after first paint (`lib/pulse-mount.ts`). + */ +import { renderAreas, renderRead, renderRetire } from "../../widgets/families/pulse/pulse-template"; +import PulseSummary from "./PulseSummary.astro"; + +const areas = renderAreas().value; +const read = renderRead().value; +const retire = renderRetire().value; +--- + +

+ + +

GitHub may start a scheduled run hours late, so a run can sit well after its time.

+ +

How a check retires

+

+ A check watches until the fix it waits for ships upstream. Then its workaround is removed, and + the check goes with it. +

+ +
+ + diff --git a/apps/dox/src/components/pulse/PulseBeats.astro b/apps/dox/src/components/pulse/PulseBeats.astro new file mode 100644 index 000000000..39ae6bdc3 --- /dev/null +++ b/apps/dox/src/components/pulse/PulseBeats.astro @@ -0,0 +1,11 @@ +--- +/** The strip of a workflow'\''s last eight runs, or NO SIGNAL. The markup is built in `widgets/families/pulse/pulse-template.ts`. */ +import { cards } from "../../data/pulse"; +import { renderBeats } from "../../widgets/families/pulse/pulse-template"; +interface Props { file: string } +const card = cards.find((c) => c.file === Astro.props.file); +if (card === undefined) throw new Error(`pulse: no card for ${Astro.props.file}`); +const out = renderBeats(card, `pulse-${card.file.replace(/\.[^.]+$/, "")}`).value; +--- + + diff --git a/apps/dox/src/components/pulse/PulseCard.astro b/apps/dox/src/components/pulse/PulseCard.astro new file mode 100644 index 000000000..1828ca90f --- /dev/null +++ b/apps/dox/src/components/pulse/PulseCard.astro @@ -0,0 +1,11 @@ +--- +/** One workflow, or one unscheduled source, with its checks. The markup is built in `widgets/families/pulse/pulse-template.ts`. */ +import { cards } from "../../data/pulse"; +import { renderCard } from "../../widgets/families/pulse/pulse-template"; +interface Props { file: string } +const card = cards.find((c) => c.file === Astro.props.file); +if (card === undefined) throw new Error(`pulse: no card for ${Astro.props.file}`); +const out = renderCard(card).value; +--- + + diff --git a/apps/dox/src/components/pulse/PulseLife.astro b/apps/dox/src/components/pulse/PulseLife.astro new file mode 100644 index 000000000..f28be12b2 --- /dev/null +++ b/apps/dox/src/components/pulse/PulseLife.astro @@ -0,0 +1,10 @@ +--- +/** Watching, Fixed upstream, Retired, for one check. The markup is built in `widgets/families/pulse/pulse-template.ts`. */ +import { checkById } from "../../data/pulse"; +import { renderLife } from "../../widgets/families/pulse/pulse-template"; +interface Props { id: string } +const check = checkById(Astro.props.id); +const out = renderLife(check.life).value; +--- + + diff --git a/apps/dox/src/components/pulse/PulseSummary.astro b/apps/dox/src/components/pulse/PulseSummary.astro new file mode 100644 index 000000000..cdabb67e5 --- /dev/null +++ b/apps/dox/src/components/pulse/PulseSummary.astro @@ -0,0 +1,7 @@ +--- +/** The four readouts above the cards. The markup is built in `widgets/families/pulse/pulse-template.ts`. */ +import { renderSummary } from "../../widgets/families/pulse/pulse-template"; +const out = renderSummary().value; +--- + + diff --git a/apps/dox/src/content/docs/bundle-size.mdx b/apps/dox/src/content/docs/bundle-size.mdx index 1d0393cea..45a788a1a 100644 --- a/apps/dox/src/content/docs/bundle-size.mdx +++ b/apps/dox/src/content/docs/bundle-size.mdx @@ -15,4 +15,4 @@ The `@northguild/gmt` row is the whole package, all {formatCount(gmtStats.functi Sizes come from bundling `packages/gmt/src` with esbuild, minified, as ES modules for a neutral platform. 1 kB is 1,000 bytes. The minified size of each row is gated: the repository's check fails when it passes the budget in the last column, and a budget changes only by a reviewed edit. Gzipped sizes are reported and never gated, because they vary with the version of zlib. -The polyfill stays until a stable Safari ships `Temporal` and the weekly run against native `Temporal` passes on Node 26, Chromium, Firefox, WebKit on Linux and WebKit on macOS for 12 weeks running ([#316](https://github.com/northguild/gmt/issues/316)). +The polyfill stays until a stable Safari ships `Temporal` and the weekly run against native `Temporal` passes on Node 26, Chromium, Firefox, WebKit on Linux and WebKit on macOS for 12 weeks running ([#316](https://github.com/northguild/gmt/issues/316)). [Pulse](/pulse/) shows the checks that watch for it. diff --git a/apps/dox/src/content/docs/guides/core-date-operations/formatting.mdx b/apps/dox/src/content/docs/guides/core-date-operations/formatting.mdx index 0aa9c5ab3..de8e11625 100644 --- a/apps/dox/src/content/docs/guides/core-date-operations/formatting.mdx +++ b/apps/dox/src/content/docs/guides/core-date-operations/formatting.mdx @@ -35,6 +35,8 @@ For a birthday or a holiday with no year, see [Month-Day Values](/guides/core-da For a card expiry or a billing month, `formatYearMonth("2026-10", "fr-FR", { year: "numeric", month: "long" })` gives `"octobre 2026"`. A day or time field is dropped, and it formats through the Gregorian calendar. +Some languages' date patterns, such as Scottish Gaelic's month and year, print the year a week belongs to where the calendar year is meant, so 30 December 2024 shows 2025 in every browser, and asking Node for the parts of such a date stops the process. GMT checks each formatter once and prints the calendar year, as the ECMA-402 specification says. [Helping fix Temporal](/upstream/) lists the reports. + ## Locale-elided ranges `formatDateRange` and `formatDateTimeRange` are the plain counterparts of diff --git a/apps/dox/src/content/docs/native-engines.mdx b/apps/dox/src/content/docs/native-engines.mdx index 1cf23d349..3e5d30095 100644 --- a/apps/dox/src/content/docs/native-engines.mdx +++ b/apps/dox/src/content/docs/native-engines.mdx @@ -64,4 +64,4 @@ tests their engine or data yet. If GMT gives a wrong answer on one, we want the ## Where the results are -The [weekly workflow](https://github.com/northguild/gmt/actions/workflows/temporal-oracle.yml) lists every run. Each run's summary names the engine version it tested and, for `webkit-macos`, the macOS version. +The [weekly workflow](https://github.com/northguild/gmt/actions/workflows/temporal-oracle.yml) lists every run. Each run's summary names the engine version it tested and, for `webkit-macos`, the macOS version. [Pulse](/pulse/) shows the recent results next to the other checks GMT runs. diff --git a/apps/dox/src/content/docs/pulse.mdx b/apps/dox/src/content/docs/pulse.mdx new file mode 100644 index 000000000..e1ce64d5f --- /dev/null +++ b/apps/dox/src/content/docs/pulse.mdx @@ -0,0 +1,17 @@ +--- +title: Pulse +description: > + Every scheduled check GMT runs against the engines, the polyfill, the world's clocks and this + site: what it watches, when it runs, its recent runs, and what retires it. +slug: pulse +industries: [core] +--- + +import Pulse from "../../components/pulse/Pulse.astro"; + +GMT is a living, breathing project, and its code is never finished. Every week these checks run +against the JavaScript engines, the polyfill, the world's clocks and this site. They spot a clock +rule that changes, an engine defect that is new, and the day a fix ships upstream, so its +workaround can go. + + diff --git a/apps/dox/src/content/docs/upstream.mdx b/apps/dox/src/content/docs/upstream.mdx index 66dab94a9..92ead5e39 100644 --- a/apps/dox/src/content/docs/upstream.mdx +++ b/apps/dox/src/content/docs/upstream.mdx @@ -65,7 +65,8 @@ Until that release, GMT's own code covers every bug in the table above. There are two Temporal polyfills: [`@js-temporal/polyfill`](https://github.com/js-temporal/temporal-polyfill), which GMT uses, and [`temporal-polyfill`](https://github.com/fullcalendar/temporal-polyfill) from FullCalendar, which is smaller and publishes releases more often. We ran GMT's whole test suite on -`temporal-polyfill` to see whether GMT should switch. +`temporal-polyfill` to see whether GMT should switch. The check that watches for a fix is on +[Pulse](/pulse/). Release 1.0.8 fixes most of the bugs in the table above, and the five bugs we reported in `temporal-polyfill` 1.0.6 and 1.0.7. Its UTC offsets match `Intl.DateTimeFormat` in every time @@ -76,16 +77,23 @@ with no test failing that passes on `@js-temporal/polyfill`. Release 1.0.7 had t - **Looking back from far ahead.** Asked for the last clock change before a date more than about three years from today, 1.0.7 returned an older one. Asked on 4 November 2026 about June 2030 in `America/New_York`, it returned the change in November 2029, not the one in March 2030. Twelve of - GMT's tests failed on this. We reported it as #125. + GMT's tests failed on this. We reported it as [#125](https://github.com/fullcalendar/temporal-polyfill/issues/125). - **Before 1847.** 1.0.7 did not find clock changes before 1847, such as `Asia/Manila` on - 31 December 1844. We reported it as #126. GMT works around the same bug in + 31 December 1844. We reported it as [#126](https://github.com/fullcalendar/temporal-polyfill/issues/126). GMT works around the same bug in `@js-temporal/polyfill`. -One bug is left, and the maintainers closed its report as a known limitation: +Three bugs are left in 1.0.8. We found the first two by comparing every calendar's years with +Node's built-in Temporal, and sent a fix for each: +- **Persian leap years.** From 1502 AP (2123), 78 years are leap years where the built-in Temporal + makes the next year the leap year, so each next year starts a day late. We reported it as + [#127](https://github.com/fullcalendar/temporal-polyfill/issues/127) and sent the fix as [#131](https://github.com/fullcalendar/temporal-polyfill/pull/131). +- **Chinese and Dangi.** It reads these calendars from `Intl.DateTimeFormat`, which disagrees with + the built-in Temporal in some years. It puts Chinese New Year 2027 on 7 February, not 6 February. + We reported it as [#128](https://github.com/fullcalendar/temporal-polyfill/issues/128) and sent the fix as [#132](https://github.com/fullcalendar/temporal-polyfill/pull/132). - **Zone names that are links.** It treats a link name such as `Asia/Calcutta` as a different - zone from `Asia/Kolkata`. FullCalendar's report of this, #118 (not ours), was closed as a known - limitation. GMT's own probe sees it in WebKit as `Etc/UTC` not equal to `UTC`. + zone from `Asia/Kolkata`. FullCalendar's report of this, [#118](https://github.com/fullcalendar/temporal-polyfill/issues/118) (not ours), was + closed as a known 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. It checks every zone's offsets against @@ -130,7 +138,8 @@ found no differences. Every week, GMT runs its whole test suite on the Temporal built into Node 26, Chromium, Firefox, WebKit on Linux and WebKit on macOS, and expects the same answers it gets on the polyfill. A failure that no known bug explains opens an issue in GMT's repository. Each run lists the exact engine versions it used: -see the [weekly runs](https://github.com/northguild/gmt/actions/workflows/temporal-oracle.yml). +see the [weekly runs](https://github.com/northguild/gmt/actions/workflows/temporal-oracle.yml), +and [Pulse](/pulse/) for what each check watches and when it retires. The built-in engines have a few bugs of their own. We report each one we find. The list so far: @@ -140,6 +149,36 @@ The built-in engines have a few bugs of their own. We report each one we find. T accept the calendar `islamic`, which the standard says to reject. - Node 26 throws when it rounds to the day on a date that starts twice, such as 6 November 2010 in `America/Goose_Bay`. Chromium 153 already has the fix, so a later Node will have it too. +- [`nodejs/node#67457`](https://github.com/nodejs/node/issues/67457): Node 26 adds an extra month + or week when it rounds up a length that is a whole number of years, months or weeks. From + 1 January 2000 to 1 January 2001, rounded up to months, it gives one year and one month. The fix + is already in `temporal_rs`, the Temporal code that Node and Chromium share, and Chromium 153 + has it. The report asks Node 26 to take it. +- [`nodejs/node#67076`](https://github.com/nodejs/node/issues/67076): Node 22, 24 and 26 stop with + a crash when they split a date into parts in a few languages, such as Burmese with the Buddhist + calendar, or Galician with the Hebrew calendar and a full date. These languages' date patterns + print the year a week belongs to (see the next item). V8, the JavaScript engine in Node and + Chromium, has the fix, and Chromium 158 has it. The report asks Node to take it. +- In CLDR, the data every engine formats dates with, some languages' date patterns print the year + a week belongs to instead of the calendar year. Scottish Gaelic, for example, prints December + 2025 for 30 December 2024, and Telugu with the Buddhist calendar prints 2026 all year instead of + 2569. Node, Chromium and Safari all print it. Someone else reported two of these languages as + [CLDR-19873](https://unicode-org.atlassian.net/browse/CLDR-19873), and + [our comment there](https://unicode-org.atlassian.net/browse/CLDR-19873?focusedCommentId=213171) + adds the rest. +- Node, Chromium and Safari print a few other years wrong. Japanese calendar dates before 1873 + come out in a Japanese era such as Meiji 5, where the standard gives the Gregorian era; + [`ICU-23341`](https://unicode-org.atlassian.net/browse/ICU-23341) fixes the years before Meiji + in ICU 79.1. Node and Chromium print Islamic dates before the Hijra as a negative year + ([`ICU-23327`](https://unicode-org.atlassian.net/browse/ICU-23327)). In Japanese, a two-digit + year in the Japanese calendar prints as 令和6年 instead of 令和06年, and the Chinese and Korean + calendars pad the Gregorian year shown beside the cycle year, such as 05 for the year 5. We + reported these two as [`ICU-23620`](https://unicode-org.atlassian.net/browse/ICU-23620) and + [`ICU-23621`](https://unicode-org.atlassian.net/browse/ICU-23621), and Meiji 1 to 5 as + [`ICU-23619`](https://unicode-org.atlassian.net/browse/ICU-23619). +- [`tc39/ecma402#1116`](https://github.com/tc39/ecma402/issues/1116): the standard's rule for + years before 1 fits only calendars that count those years backwards in an era of their own, such + as BC. It asks to limit the rule to those calendars. - [`ICU-20548`](https://unicode-org.atlassian.net/browse/ICU-20548): Node, Chromium and Safari shorten a long zone name in a time range, and drop an offset name such as `GMT-5`. - [Bugzilla 1998020](https://bugzilla.mozilla.org/show_bug.cgi?id=1998020): Firefox accepts a diff --git a/apps/dox/src/data/gmt-stats.json b/apps/dox/src/data/gmt-stats.json index 4c5d77061..a1876de2d 100644 --- a/apps/dox/src/data/gmt-stats.json +++ b/apps/dox/src/data/gmt-stats.json @@ -1,8 +1,8 @@ { "suite": "packages/gmt", - "tests": 76522, - "files": 1006, - "executions": 2295660, + "tests": 76990, + "files": 1026, + "executions": 2309700, "nodes": ["22", "24", "26"], "timezones": 10, "timezoneList": [ diff --git a/apps/dox/src/data/pulse.ts b/apps/dox/src/data/pulse.ts new file mode 100644 index 000000000..9fe8292be --- /dev/null +++ b/apps/dox/src/data/pulse.ts @@ -0,0 +1,181 @@ +/** + * What `/pulse/` shows, joined from its sources. The one hand-written source is + * `scripts/lib/pulse.mjs`; `scripts/build-pulse.mjs` reads each workflow file (its name, its + * schedules, its jobs) and the recent runs, and writes `generated/pulse.json` and + * `generated/pulse-runs.live.json`. This module adds what the other pages already know: the + * workaround states from the compat snapshot and the filings. Counts come from those joins. + */ +import pulseData from "../generated/pulse.json"; +import { compatGroups, groupLabel, type CompatGroup } from "./temporal-compat"; +import { filingKey, filings, type UpstreamFiling } from "./upstream-filings"; + +export type PulseAreaId = "temporal" | "clocks" | "site"; + +export type PulseLife = + | { kind: "permanent"; why: string } + | { kind: "workarounds"; groups: "all" | readonly string[] } + | { + kind: "condition"; + until: string; + waitsOn?: readonly string[]; + waitsOnRepos?: readonly string[]; + }; + +export interface PulseCheck { + id: string; + name: string; + area: PulseAreaId; + source: string; + job?: string; + scripts?: readonly string[]; + watches: string; + finds: string; + life: PulseLife; + story: string; +} + +export interface PulseCard { + source: string; + file: string; + kind: "workflow" | "test"; + name: string; + crons: readonly string[]; + jobs: readonly { id: string; name: string }[]; + checkIds: readonly string[]; +} + +export interface PulseRun { + startedAt: string; + conclusion: string; + url: string; +} + +interface RunsFile { + runsRead: string; + workflows: Record; +} + +const isRunsFile = (value: unknown): value is RunsFile => + typeof value === "object" && + value !== null && + typeof (value as RunsFile).runsRead === "string" && + typeof (value as RunsFile).workflows === "object"; + +// The live file is optional and gitignored. Outside Vite `import.meta.glob` does not exist, and a +// missing file is the same as a failed read: every strip then says NO SIGNAL. The guard reads +// `import.meta.env`, which Vite replaces at build; `typeof import.meta.glob` would stay in the +// built code and be false there (`lib/import-meta-glob-guard.test.ts`). +const liveModules = ( + import.meta.env === undefined + ? {} + : import.meta.glob("../generated/pulse-runs.live.json", { + eager: true, + import: "default", + }) +) as Record; +const live = Object.values(liveModules)[0]; +const runsFile: RunsFile | null = isRunsFile(live) ? live : null; + +export const areas = pulseData.areas as readonly { + id: PulseAreaId; + heading: string; + blurb: string; +}[]; +export const checks = pulseData.checks as readonly PulseCheck[]; +export const cards = pulseData.cards as readonly PulseCard[]; + +/** When the run history was read (UTC), or `null` when this build read none. */ +export const runsRead: string | null = runsFile?.runsRead ?? null; + +/** The recent scheduled runs of a card's workflow, newest first, or `null` when none were read. */ +export const runsFor = (card: PulseCard): readonly PulseRun[] | null => + runsFile?.workflows[card.file] ?? null; + +export const checkById = (id: string): PulseCheck => { + const found = checks.find((c) => c.id === id); + if (found === undefined) throw new Error(`pulse: no check ${id}`); + return found; +}; + +export const cardsIn = (area: PulseAreaId): readonly PulseCard[] => + cards.filter((card) => checkById(card.checkIds[0]!).area === area); + +/** The workaround groups a life claims, as the compat snapshot has them. */ +export function groupsClaimed(life: PulseLife): readonly CompatGroup[] { + if (life.kind !== "workarounds") return []; + return life.groups === "all" + ? compatGroups + : compatGroups.filter((g) => + (life.groups as readonly string[]).includes(groupLabel(g)), + ); +} + +/** The filings a `condition` life waits on: the keys it names, and every open one in its repos. */ +export function filingsWaitedOn(life: PulseLife): readonly UpstreamFiling[] { + if (life.kind !== "condition") return []; + const keys = life.waitsOn ?? []; + const repos = life.waitsOnRepos ?? []; + return filings.filter( + (f) => + keys.includes(filingKey(f)) || + (f.tracker === "github" && repos.includes(f.repo) && f.state === "open"), + ); +} + +export type LifeStep = "watching" | "fixed" | "retired" | "permanent"; + +/** + * Where a check is on its way out. `fixed` means the thing it waits on has been fixed upstream and + * the check is due to go; `retired` never shows, because a retired check is gone from the list. + */ +export function lifeStep(life: PulseLife): LifeStep { + switch (life.kind) { + case "permanent": + return "permanent"; + case "workarounds": { + const claimed = groupsClaimed(life); + return claimed.length > 0 && claimed.every((g) => g.state === "removable") + ? "fixed" + : "watching"; + } + case "condition": { + const waited = filingsWaitedOn(life); + return waited.length > 0 && waited.every((f) => f.state === "closed") + ? "fixed" + : "watching"; + } + } +} + +/** The counts the summary row and a workaround life line print. */ +export interface WorkaroundCounts { + total: number; + stillNeeded: number; + removable: number; + guards: number; + other: number; +} + +export function countWorkarounds( + groups: readonly CompatGroup[], +): WorkaroundCounts { + const count = (state: CompatGroup["state"]) => + groups.filter((g) => g.state === state).length; + const stillNeeded = count("still-needed"); + const removable = count("removable"); + const guards = count("guard"); + return { + total: groups.length, + stillNeeded, + removable, + guards, + other: groups.length - stillNeeded - removable - guards, + }; +} + +export const summary = { + checks: checks.length, + scheduled: cards.filter((c) => c.crons.length > 0).length, + workarounds: countWorkarounds(compatGroups), + filingsOpen: filings.filter((f) => f.state === "open").length, +}; diff --git a/apps/dox/src/data/temporal-compat.json b/apps/dox/src/data/temporal-compat.json index c8194f2b8..242ca6304 100644 --- a/apps/dox/src/data/temporal-compat.json +++ b/apps/dox/src/data/temporal-compat.json @@ -35,8 +35,8 @@ { "defects": ["D6"], "title": "D6 — non-ISO until re-constrains the day while counting months", - "trigger": "a js-temporal release contains 10aeb98 (already on main)", - "probes": 11, + "trigger": "a js-temporal release contains 10aeb98 (already on main) and no longer writes the un-constrained day into its calendar cache (tc39/proposal-temporal#3327 problem 1, on main since 853fc8b)", + "probes": 13, "failing": 11, "state": "still-needed" }, @@ -72,7 +72,7 @@ { "defects": ["D11"], "title": "D11 — the calendar nudge window is never retried, so total, round and until with a calendar smallestUnit answer over the wrong bounds (relativeTo on the 29th-31st)", - "trigger": "a js-temporal release contains js-temporal/temporal-polyfill#361's 50d66d2, which ports proposal-temporal #3172 (5dd0b0d97ee1, the fix for tc39 #3168) and retries the nudge window; merged to main in PR #361 as 5af905f, so no new filing is needed", + "trigger": "a js-temporal release contains js-temporal/temporal-polyfill#361's 50d66d2, which ports proposal-temporal #3172 (17e12be0af42, the fix for tc39 #3168) and retries the nudge window; merged to main in PR #361 as 5af905f, so no new filing is needed", "probes": 6, "failing": 6, "state": "still-needed" @@ -104,7 +104,7 @@ { "defects": ["D15"], "title": "D15 — `Z` string read by wall clock under offset: \"ignore\" instead of as an exact instant (zonedWallClock.ts defect 6)", - "trigger": "a js-temporal release (and Node floor) whose ToTemporalZonedDateTime keeps a Z string's own instant under offset: \"ignore\", as InterpretISODateTimeOffset requires. Native V8 (Node 24.21 with --harmony-temporal) shares the defect; not filed upstream yet, and js-temporal main c55b211 and tc39 main e8cc03f both still have it (bug doc § O). The expected value is the specification's", + "trigger": "a js-temporal release (and Node floor) whose ToTemporalZonedDateTime keeps a Z string's own instant under offset: \"ignore\", as InterpretISODateTimeOffset requires. Native V8 (Node 24.21 with --harmony-temporal) shares the defect. Filed as tc39/proposal-temporal#3337; js-temporal main c55b211 and tc39 main b038883 both still have it (bug doc § O). The expected value is the specification's", "probes": 1, "failing": 1, "state": "still-needed" @@ -160,6 +160,71 @@ "failing": 6, "state": "still-needed" }, + { + "defects": ["D23"], + "title": "D23 — formatToParts and formatRangeToParts abort V8 on a week-of-year year field (nodejs/node#67076)", + "trigger": "every V8 the check reads (Node at the engines.node floor, and the temporal-compat-chromium verdict) passes the D23 repro: a gd formatter with year numeric and month short resolves a year, and the Node child-process confirmation of scripts/canary/weekYear.mjs exits 0 with a year part", + "probes": 1, + "failing": 1, + "state": "still-needed", + "engines": ["v8"] + }, + { + "defects": ["D24"], + "title": "D24 — CLDR date patterns print the week-of-year year where the calendar year is meant (internal/weekYearGuard.ts)", + "trigger": "every engine's compat verdict passes every D24 repro, and the weekly sweep of scripts/canary/weekYear.mjs flags no locale, calendar or option set", + "probes": 7, + "failing": 7, + "state": "still-needed" + }, + { + "defects": ["D25"], + "title": "D25 — the japanese calendar prints Japanese eras before 1873-01-01 (internal/yearPrinting.ts)", + "trigger": "every engine's compat verdict passes both D25 repros: en-u-ca-japanese prints 2 BC for ISO -0001-07-10 and 1872 AD for 1872-12-31 (tc39/proposal-intl-era-monthcode#86, tc39/test262#4877)", + "probes": 2, + "failing": 2, + "state": "still-needed" + }, + { + "defects": ["D26"], + "title": "D26 — an islamic calendar prints a negative year before the Hijra (internal/yearPrinting.ts)", + "trigger": "every engine's compat verdict passes the D26 repro: en-u-ca-islamic-civil prints a different era text for ISO 600-07-10 and 2025-07-10", + "probes": 1, + "failing": 1, + "state": "still-needed" + }, + { + "defects": ["D27"], + "title": "D27 — ja japanese leaves the era year unpadded under year 2-digit and in Latin digits under another numbering system (internal/yearPrinting.ts, internal/japaneseNumerals.ts)", + "trigger": "every engine's compat verdict passes both D27 repros: ja-u-ca-japanese with year 2-digit prints 令和06年 for 2024-07-10, and ja-u-ca-japanese-nu-arab with year numeric prints 令和٦年", + "probes": 2, + "failing": 2, + "state": "still-needed" + }, + { + "defects": ["D28"], + "title": "D28 — chinese and dangi pad the related year under year 2-digit (internal/yearPrinting.ts)", + "trigger": "every engine's compat verdict passes the D28 repro: en-u-ca-chinese with year 2-digit prints the related year 5 for ISO 0005-07-10", + "probes": 1, + "failing": 1, + "state": "still-needed" + }, + { + "defects": ["D29"], + "title": "D29 — a range drops, repeats or garbles a field of one date (internal/rangeFields.ts)", + "trigger": "every engine's compat verdict passes every D29 repro (rangeFieldRepros.ts, one range per upstream defect, so the gate stays on while any one fails), and the weekly sweep of scripts/canary/rangeFields.mjs flags no locale, calendar or option set", + "probes": 18, + "failing": 18, + "state": "still-needed" + }, + { + "defects": ["D30"], + "title": "D30 — islamic and islamic-rgsa resolve as written (internal/formatterCache.ts)", + "trigger": "every engine's compat verdict passes both D30 repros: en-u-ca-islamic resolves islamic-tbla and en-u-ca-islamic-rgsa resolves a calendar other than islamic-rgsa (tc39/proposal-intl-era-monthcode#99)", + "probes": 2, + "failing": 2, + "state": "still-needed" + }, { "defects": ["D9"], "title": "D9 — non-ISO months added and counted one month at a time (heap OOM for in-range amounts; temporalCompat/largeMonthSpan.ts)", diff --git a/apps/dox/src/data/temporal-compat.test.ts b/apps/dox/src/data/temporal-compat.test.ts index e525050b3..89f07657f 100644 --- a/apps/dox/src/data/temporal-compat.test.ts +++ b/apps/dox/src/data/temporal-compat.test.ts @@ -214,11 +214,13 @@ describe("temporal compat snapshot", () => { describe("shortRef", () => { it.each` - repo | number | label - ${"tc39/proposal-temporal"} | ${3292} | ${"tc39 #3292"} - ${"js-temporal/temporal-polyfill"} | ${369} | ${"polyfill #369"} - ${"fullcalendar/temporal-polyfill"} | ${126} | ${"fullcalendar #126"} - ${"whatwg/html"} | ${12} | ${"whatwg/html #12"} + repo | number | label + ${"tc39/proposal-temporal"} | ${3292} | ${"tc39 #3292"} + ${"js-temporal/temporal-polyfill"} | ${369} | ${"polyfill #369"} + ${"fullcalendar/temporal-polyfill"} | ${126} | ${"fullcalendar #126"} + ${"tc39/ecma402"} | ${1116} | ${"ecma402 #1116"} + ${"nodejs/node"} | ${67076} | ${"node #67076"} + ${"whatwg/html"} | ${12} | ${"whatwg/html #12"} `("labels $repo#$number as '$label'", ({ repo, number, label }) => { expect(shortRef(repo, number)).toBe(label); }); diff --git a/apps/dox/src/data/temporal-compat.ts b/apps/dox/src/data/temporal-compat.ts index 0a027150b..7ccc4d591 100644 --- a/apps/dox/src/data/temporal-compat.ts +++ b/apps/dox/src/data/temporal-compat.ts @@ -161,11 +161,13 @@ const KNOWN_REPOS: Readonly> = { "tc39/proposal-temporal": "tc39", "js-temporal/temporal-polyfill": "polyfill", "fullcalendar/temporal-polyfill": "fullcalendar", + "tc39/ecma402": "ecma402", + "nodejs/node": "node", }; /** * The short form the `/upstream/` tables print for a GitHub reference: `tc39 #3292`, - * `polyfill #369`, or `owner/repo #n` for any other repository. + * `polyfill #369`, `node #67076`, or `owner/repo #n` for any other repository. */ export const shortRef = (repo: string, number: number): string => `${KNOWN_REPOS[repo] ?? repo} #${number}`; @@ -264,6 +266,14 @@ const WHAT_BREAKS: Readonly> = { D19: "Two names for one zone, such as UTC and Etc/UTC or Asia/Kolkata and Asia/Calcutta, which the polyfill treats as different zones in Safari and WebKit", D21: "The current time when a test fakes a clock before 1970, which the polyfill reads one millisecond early, so a clock function can return the previous year, day or second at a boundary", D22: "A length in days or larger measured from a repeated hour, which the polyfill can measure from the wrong pass or refuse, so it can be an hour too long or missing. Where the specification has no value, which also happens after a skipped hour, GMT returns its sentinel", + D23: "Some languages and calendars, among them Scottish Gaelic, Galician, Burmese and Telugu, whose date patterns use the week-of-year year: asking Node or Chrome for the parts of such a date, or of a range, stopped the process with no error to catch", + D24: "Dates in the same languages near the start or end of a year, which every browser prints with the year the week belongs to rather than the calendar year, and with some calendars, such as Buddhist in Telugu, on every day of the year", + D25: "Japanese calendar dates before 1873, which every browser prints in a Japanese era such as Meiji 5 or Taika, where the calendar uses the Gregorian era until the end of 1872. A range across 1873 prints each date in its own era", + D26: "Islamic calendar dates before the Hijra (622 CE), which Node and Chrome print as a negative year. They have no name for the era before the Hijra, so GMT returns its empty value there", + D27: "Japanese calendar dates in Japanese with a two-digit year, which every browser prints as 令和6年 where 令和06年 is asked for, and with Arabic-Indic or other digits asked for, which Node, Chrome and Safari print in Latin digits. The first year of an era stays 元年", + D28: "Chinese and Korean calendar dates with a two-digit year, where the Gregorian year shown beside the cycle year was padded, such as 05 for the year 5", + D29: "Date ranges in some languages and calendars that leave out, repeat or mix up a part of one date, such as a Chinese calendar range a year apart without the Gregorian year, or a Yoruba range with the weekday twice. GMT prints both dates in full, joined the language's own way", + D30: "Dates in the calendars named islamic and islamic-rgsa, which Node and Chrome print with an astronomical Islamic calendar the standard no longer offers. GMT uses islamic-tbla for islamic, and the language's default calendar for islamic-rgsa", "zoned.A": "Zoned times within a day of the earliest or latest instant Temporal supports", "zoned.B": diff --git a/apps/dox/src/data/upstream-filings.json b/apps/dox/src/data/upstream-filings.json index 890fe7870..382cbc998 100644 --- a/apps/dox/src/data/upstream-filings.json +++ b/apps/dox/src/data/upstream-filings.json @@ -1,7 +1,8 @@ { - "checked": "2026-11-08T12:19:17.436335629Z", + "checked": "2026-11-15T10:35:51.923947826Z", "filings": [ { + "tracker": "github", "repo": "js-temporal/temporal-polyfill", "number": 361, "kind": "pr", @@ -22,11 +23,12 @@ "comments": 1, "maintainerComments": 0, "createdAt": "2026-04-22", - "updatedAt": "2026-09-21", + "updatedAt": "2026-11-13", "closedAt": "2026-09-21", "mergedAt": "2026-09-21" }, { + "tracker": "github", "repo": "js-temporal/temporal-polyfill", "number": 367, "kind": "pr", @@ -51,6 +53,7 @@ "mergedAt": null }, { + "tracker": "github", "repo": "js-temporal/temporal-polyfill", "number": 368, "kind": "pr", @@ -75,6 +78,7 @@ "mergedAt": null }, { + "tracker": "github", "repo": "js-temporal/temporal-polyfill", "number": 369, "kind": "pr", @@ -99,6 +103,7 @@ "mergedAt": null }, { + "tracker": "github", "repo": "js-temporal/temporal-polyfill", "number": 370, "kind": "pr", @@ -123,6 +128,7 @@ "mergedAt": null }, { + "tracker": "github", "repo": "js-temporal/temporal-polyfill", "number": 371, "kind": "pr", @@ -147,6 +153,7 @@ "mergedAt": null }, { + "tracker": "github", "repo": "js-temporal/temporal-polyfill", "number": 372, "kind": "pr", @@ -171,6 +178,7 @@ "mergedAt": null }, { + "tracker": "github", "repo": "js-temporal/temporal-polyfill", "number": 373, "kind": "issue", @@ -197,6 +205,33 @@ "mergedAt": null }, { + "tracker": "github", + "repo": "tc39/proposal-temporal", + "number": 3301, + "kind": "issue", + "role": "contributor", + "work": "report", + "title": "Removing time zone canonicalization in `Intl.DateTimeFormat` will change behavior of Temporal polyfills", + "url": "https://github.com/tc39/proposal-temporal/issues/3301", + "contributionUrl": "https://github.com/tc39/proposal-temporal/issues/3301#issuecomment-6892556793", + "summary": "When `Intl.DateTimeFormat` stops canonicalizing time zone ids, the polyfills compare zones wrongly. Our comment shows that in WebKit, which already works that way, `UTC` and `Etc/UTC` compare unequal and `until` throws, and that the `UTC` case can be fixed without time zone data.", + "pairsWith": [], + "closes": [], + "dependsOn": [], + "gmtGuard": "D19", + "gmtNote": null, + "state": "open", + "draft": false, + "reviewDecision": null, + "comments": 2, + "maintainerComments": 1, + "createdAt": "2026-04-04", + "updatedAt": "2026-11-15", + "closedAt": null, + "mergedAt": null + }, + { + "tracker": "github", "repo": "tc39/proposal-temporal", "number": 3327, "kind": "issue", @@ -215,11 +250,12 @@ "comments": 1, "maintainerComments": 0, "createdAt": "2026-09-18", - "updatedAt": "2026-09-18", + "updatedAt": "2026-11-13", "closedAt": null, "mergedAt": null }, { + "tracker": "github", "repo": "tc39/proposal-temporal", "number": 3328, "kind": "issue", @@ -238,11 +274,12 @@ "comments": 1, "maintainerComments": 0, "createdAt": "2026-09-18", - "updatedAt": "2026-09-18", + "updatedAt": "2026-11-13", "closedAt": null, "mergedAt": null }, { + "tracker": "github", "repo": "tc39/proposal-temporal", "number": 3329, "kind": "issue", @@ -261,11 +298,12 @@ "comments": 0, "maintainerComments": 0, "createdAt": "2026-09-18", - "updatedAt": "2026-09-18", + "updatedAt": "2026-11-13", "closedAt": null, "mergedAt": null }, { + "tracker": "github", "repo": "tc39/proposal-temporal", "number": 3330, "kind": "issue", @@ -289,6 +327,7 @@ "mergedAt": null }, { + "tracker": "github", "repo": "tc39/proposal-temporal", "number": 3331, "kind": "issue", @@ -308,11 +347,12 @@ "comments": 1, "maintainerComments": 0, "createdAt": "2026-10-21", - "updatedAt": "2026-10-24", + "updatedAt": "2026-11-13", "closedAt": "2026-10-24", "mergedAt": null }, { + "tracker": "github", "repo": "tc39/proposal-temporal", "number": 3332, "kind": "issue", @@ -336,13 +376,14 @@ "mergedAt": null }, { + "tracker": "github", "repo": "tc39/proposal-temporal", "number": 3335, "kind": "issue", "work": "report", "title": "Polyfill: Temporal.Now reads a millisecond before Date.now() after a pre-1970 clock reading", "url": "https://github.com/tc39/proposal-temporal/issues/3335", - "summary": "After the clock reads a date before 1970, the next Temporal.Now reading can land a millisecond before Date.now(), so a 2027 clock can read as the last millisecond of 2026. The polyfill carries the previous reading's milliseconds modulo a million as a sub-millisecond part, and the remainder keeps its minus sign. Fake timers in tests hit this whenever they set a pre-1970 date. The issue proposes a floor modulo.", + "summary": "After the clock reads a date before 1970, the next Temporal.Now reading can land a millisecond before Date.now(), so a 2027 clock can read as the last millisecond of 2026. The polyfill carries the previous reading's milliseconds modulo a million as a sub-millisecond part, and the remainder keeps its minus sign. In js-temporal's polyfill, fake timers in tests hit this whenever they set a pre-1970 date. The issue proposes a floor modulo.", "pairsWith": [], "closes": [], "dependsOn": [], @@ -354,11 +395,12 @@ "comments": 0, "maintainerComments": 0, "createdAt": "2026-10-31", - "updatedAt": "2026-10-31", + "updatedAt": "2026-11-13", "closedAt": null, "mergedAt": null }, { + "tracker": "github", "repo": "tc39/proposal-temporal", "number": 3336, "kind": "issue", @@ -382,6 +424,79 @@ "mergedAt": null }, { + "tracker": "github", + "repo": "tc39/proposal-temporal", + "number": 3337, + "kind": "issue", + "work": "report", + "title": "Polyfill: ZonedDateTime.from reads a `Z` string by wall clock when `offset` is `ignore`", + "url": "https://github.com/tc39/proposal-temporal/issues/3337", + "summary": "Reading a string that ends in `Z` with `offset: \"ignore\"` should keep the exact time the string names. The polyfill reads the string's wall-clock time in the target zone instead, so the result is off by that zone's offset.", + "pairsWith": [], + "closes": [], + "dependsOn": [], + "gmtGuard": "D15", + "gmtNote": null, + "state": "open", + "draft": false, + "reviewDecision": null, + "comments": 0, + "maintainerComments": 0, + "createdAt": "2026-11-15", + "updatedAt": "2026-11-15", + "closedAt": null, + "mergedAt": null + }, + { + "tracker": "github", + "repo": "tc39/proposal-temporal", + "number": 3338, + "kind": "issue", + "work": "report", + "title": "Polyfill: Islamic dates before 1 AH throw `Era before-hijra was not matched by any era` in WebKit", + "url": "https://github.com/tc39/proposal-temporal/issues/3338", + "summary": "In WebKit, the polyfill throws for Islamic dates before 1 AH, because WebKit's formatter prints those years in a `Before Hijra` era the polyfill does not recognise. V8 prints those dates as `AH` with a negative year, so the polyfill works there.", + "pairsWith": [], + "closes": [], + "dependsOn": [], + "gmtGuard": "D18", + "gmtNote": null, + "state": "open", + "draft": false, + "reviewDecision": null, + "comments": 0, + "maintainerComments": 0, + "createdAt": "2026-11-15", + "updatedAt": "2026-11-15", + "closedAt": null, + "mergedAt": null + }, + { + "tracker": "github", + "repo": "tc39/proposal-temporal", + "number": 3339, + "kind": "issue", + "work": "report", + "title": "Polyfill: `toLocaleString` takes Temporal formats from `resolvedOptions()`, so `month: 'long'` prints a numeric month in zh and ja", + "url": "https://github.com/tc39/proposal-temporal/issues/3339", + "summary": "`toLocaleString` builds its Temporal formats from `resolvedOptions()` rather than from the caller's options, so in Chinese and Japanese `month: \"long\"` or `\"short\"` prints a numeric month. V8 has the same problem (Chromium 553245554).", + "pairsWith": [], + "closes": [], + "dependsOn": [], + "gmtGuard": null, + "gmtNote": "GMT never calls `toLocaleString`: its formatters pass the caller's own options to `Intl.DateTimeFormat`, so the month width the caller asks for is kept.", + "state": "open", + "draft": false, + "reviewDecision": null, + "comments": 0, + "maintainerComments": 0, + "createdAt": "2026-11-15", + "updatedAt": "2026-11-15", + "closedAt": null, + "mergedAt": null + }, + { + "tracker": "github", "repo": "fullcalendar/temporal-polyfill", "number": 119, "kind": "issue", @@ -406,6 +521,7 @@ "mergedAt": null }, { + "tracker": "github", "repo": "fullcalendar/temporal-polyfill", "number": 120, "kind": "issue", @@ -430,6 +546,7 @@ "mergedAt": null }, { + "tracker": "github", "repo": "fullcalendar/temporal-polyfill", "number": 121, "kind": "issue", @@ -454,6 +571,7 @@ "mergedAt": null }, { + "tracker": "github", "repo": "fullcalendar/temporal-polyfill", "number": 125, "kind": "issue", @@ -478,6 +596,7 @@ "mergedAt": null }, { + "tracker": "github", "repo": "fullcalendar/temporal-polyfill", "number": 126, "kind": "issue", @@ -502,6 +621,7 @@ "mergedAt": null }, { + "tracker": "github", "repo": "fullcalendar/temporal-polyfill", "number": 127, "kind": "issue", @@ -520,11 +640,12 @@ "comments": 2, "maintainerComments": 0, "createdAt": "2026-11-06", - "updatedAt": "2026-11-06", + "updatedAt": "2026-11-13", "closedAt": null, "mergedAt": null }, { + "tracker": "github", "repo": "fullcalendar/temporal-polyfill", "number": 128, "kind": "issue", @@ -536,25 +657,26 @@ "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.", + "gmtNote": "GMT runs on `@js-temporal/polyfill`, whose 0.5.1 release throws on Chinese and Dangi dates under ICU 78 instead (js-temporal/temporal-polyfill#360, fixed on its `main` and not yet released). 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", + "updatedAt": "2026-11-13", "closedAt": null, "mergedAt": null }, { + "tracker": "github", "repo": "fullcalendar/temporal-polyfill", "number": 131, "kind": "pr", "work": "fix", "title": "Apply the ICU4X leap-year corrections to the Persian calendar", "url": "https://github.com/fullcalendar/temporal-polyfill/pull/131", - "summary": "Adds the 78 leap-year corrections that ICU4X, and so native Temporal, makes to the Persian calendar from 1502 to 2987 AP. Without them, every date in the year after each corrected year reads one day early, and the leap-year answers are wrong for both years.", + "summary": "The Persian calendar skips the corrections ICU4X makes to 78 leap years from 1502 to 2987 AP, so the first day of the year after each one reads as an extra 30th day of month 12, every other day of that year one day early, and the leap-year answers are wrong for both years. This applies the same corrections as ICU4X.", "pairsWith": [], "closes": ["fullcalendar/temporal-polyfill#127"], "dependsOn": [], @@ -571,6 +693,7 @@ "mergedAt": null }, { + "tracker": "github", "repo": "fullcalendar/temporal-polyfill", "number": 132, "kind": "pr", @@ -582,7 +705,7 @@ "closes": ["fullcalendar/temporal-polyfill#128"], "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.", + "gmtNote": "GMT runs on `@js-temporal/polyfill`, whose 0.5.1 release throws on Chinese and Dangi dates under ICU 78 instead (js-temporal/temporal-polyfill#360, fixed on its `main` and not yet released). 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, @@ -592,10 +715,545 @@ "updatedAt": "2026-11-13", "closedAt": null, "mergedAt": null + }, + { + "tracker": "github", + "repo": "tc39/ecma402", + "number": 1116, + "kind": "issue", + "work": "report", + "title": "FormatDateTimePattern: \"value ≤ 0, set value to 1 − value\" is wrong for calendars with a single era", + "url": "https://github.com/tc39/ecma402/issues/1116", + "summary": "ECMA-402 turns a year of 0 or below into 1 minus the year for every calendar, but only a calendar with an inverse era needs that. The indian and persian calendars have one signed era, so `-79 Śaka` and `-622 AP` are right, and native Temporal already gives those years.", + "pairsWith": [], + "closes": [], + "dependsOn": [], + "gmtGuard": null, + "gmtNote": "GMT prints the year the engine prints and keeps no year rule of its own, so this changes nothing in GMT.", + "state": "open", + "draft": false, + "reviewDecision": null, + "comments": 1, + "maintainerComments": 1, + "createdAt": "2026-11-14", + "updatedAt": "2026-11-14", + "closedAt": null, + "mergedAt": null + }, + { + "tracker": "github", + "repo": "nodejs/node", + "number": 67076, + "kind": "issue", + "work": "report", + "title": "Intl.DateTimeFormat formatToParts aborts the process (unreachable code) when the locale pattern has Y: please cherry-pick V8 0426b0d1045d into v22.x, v24.x and v26.x", + "url": "https://github.com/nodejs/node/issues/67076", + "summary": "Node stops the whole process when `formatToParts` or `formatRangeToParts` formats a date with a pattern that holds the week-of-year year, which some languages' patterns do. It asks Node 22, 24 and 26 to take the V8 fix that Chromium 158 already has.", + "pairsWith": [], + "closes": [], + "dependsOn": [], + "gmtGuard": "D23", + "gmtNote": null, + "state": "open", + "draft": false, + "reviewDecision": null, + "comments": 0, + "maintainerComments": 0, + "createdAt": "2026-10-28", + "updatedAt": "2026-10-28", + "closedAt": null, + "mergedAt": null + }, + { + "tracker": "github", + "repo": "nodejs/node", + "number": 67457, + "kind": "issue", + "work": "report", + "title": "Temporal on v26.x: until() and round() add one smallestUnit to a whole number of years, months or weeks (temporal_rs 0.2.3)", + "url": "https://github.com/nodejs/node/issues/67457", + "summary": "Node 26 adds one `smallestUnit` when it rounds a whole number of years, months or weeks. It asks Node 26 to move to `temporal_rs` 0.2.4 or later, or to take the one fix (boa-dev/temporal#723) on its own.", + "pairsWith": [], + "closes": [], + "dependsOn": [], + "gmtGuard": null, + "gmtNote": "GMT makes no change: it already follows the spec text, and `@js-temporal/polyfill` 0.5.1 is right.", + "state": "open", + "draft": false, + "reviewDecision": null, + "comments": 2, + "maintainerComments": 2, + "createdAt": "2026-11-13", + "updatedAt": "2026-11-14", + "closedAt": null, + "mergedAt": null + }, + { + "tracker": "github", + "repo": "nodejs/node", + "number": 67484, + "kind": "issue", + "work": "release", + "title": "v26.x: please backport two V8 Temporal formatting fixes (d785c2ad7a2c, 93603e3f07a9)", + "url": "https://github.com/nodejs/node/issues/67484", + "summary": "Asks Node 26 to take two V8 fixes for Temporal `toLocaleString`: an `era` option on its own drops the year and month, and a Chinese or Japanese full date loses its long month name.", + "pairsWith": [], + "closes": [], + "dependsOn": [], + "gmtGuard": null, + "gmtNote": "GMT is not affected: it never calls `toLocaleString`, and its formatters pass the caller's own options to `Intl.DateTimeFormat`.", + "state": "open", + "draft": false, + "reviewDecision": null, + "comments": 0, + "maintainerComments": 0, + "createdAt": "2026-11-15", + "updatedAt": "2026-11-15", + "closedAt": null, + "mergedAt": null + }, + { + "tracker": "jira", + "key": "CLDR-19873", + "role": "contributor", + "work": "report", + "title": "Incorrect use of week-based year (Y) in gl and kek date patterns", + "url": "https://unicode-org.atlassian.net/browse/CLDR-19873", + "contributionUrl": "https://unicode-org.atlassian.net/browse/CLDR-19873?focusedCommentId=213171", + "summary": "Some languages' date patterns print the week-of-year year where the calendar year belongs. The ticket names gl and kek, and our comment adds the other patterns on `main`, the gd and te repros and the Node crash.", + "pairsWith": [], + "closes": [], + "dependsOn": [], + "gmtGuard": "D24", + "gmtNote": null, + "state": "open", + "status": "New", + "resolution": null, + "fixVersions": [], + "comments": 1, + "maintainerComments": 0, + "createdAt": "2026-10-20", + "updatedAt": "2026-11-13", + "closedAt": null + }, + { + "tracker": "jira", + "key": "CLDR-19912", + "work": "report", + "title": "Interval formats that drop, repeat or misplace a field (yo, rw, sw, brx, dz, en_JP, kgp, yrl, ku, qu, rm, sv, th, wae, ta)", + "url": "https://unicode-org.atlassian.net/browse/CLDR-19912", + "summary": "Interval patterns in 15 languages drop, repeat or misplace a field when a range is formatted: yo, rw, sw, brx, dz, en-JP, kgp, yrl, ku, qu, rm, sv, th, wae and ta. It includes the rw `yMMMd` pattern that CLDR 49 adds and the ta `hmv` pattern.", + "pairsWith": [], + "closes": [], + "dependsOn": [], + "gmtGuard": "D29", + "gmtNote": null, + "state": "open", + "status": "New", + "resolution": null, + "fixVersions": [], + "comments": 1, + "maintainerComments": 0, + "createdAt": "2026-11-14", + "updatedAt": "2026-11-15", + "closedAt": null + }, + { + "tracker": "jira", + "key": "CLDR-19913", + "work": "report", + "title": "Interval formats that write a field in a different form from the single date, or run two fields together (fur, gsw, ksh, mn, brx, zh iso8601, root chinese)", + "url": "https://unicode-org.atlassian.net/browse/CLDR-19913", + "summary": "Interval patterns in fur, gsw, ksh and mn write the month in a different form from the single date. They also run two fields together in brx and in zh with the iso8601 calendar, and the root locale drops the chinese related year.", + "pairsWith": [], + "closes": [], + "dependsOn": [], + "gmtGuard": "D29", + "gmtNote": null, + "state": "open", + "status": "New", + "resolution": null, + "fixVersions": [], + "comments": 0, + "maintainerComments": 0, + "createdAt": "2026-11-14", + "updatedAt": "2026-11-14", + "closedAt": null + }, + { + "tracker": "jira", + "key": "ICU-23609", + "work": "report", + "title": "PersianCalendar::isLeapYear returns true for every year before 0 since ICU4C 75", + "url": "https://unicode-org.atlassian.net/browse/ICU-23609", + "summary": "ICU4C 75 and later counts every Persian year before year 0 as a leap year, because a C++ `%` rounds toward zero. WebKit on macOS shows it.", + "pairsWith": [], + "closes": [], + "dependsOn": [], + "gmtGuard": null, + "gmtNote": "Only GMT running on macOS WebKit's own `Temporal` sees it, where `addDate` and `subtractDate` return `\"\"` for the dates it breaks. GMT on the polyfill is right.", + "state": "open", + "status": "New", + "resolution": null, + "fixVersions": [], + "comments": 2, + "maintainerComments": 0, + "createdAt": "2026-11-11", + "updatedAt": "2026-11-11", + "closedAt": null + }, + { + "tracker": "jira", + "key": "ICU-23619", + "work": "report", + "title": "Japanese calendar: use the Gregorian era for 1868-10-23 to 1872-12-31 (Meiji 1–5)", + "url": "https://unicode-org.atlassian.net/browse/ICU-23619", + "summary": "The japanese calendar prints a date before 1873 in a Japanese era, where the standard asks for the Gregorian era up to the end of 1872. ICU 79 fixes most of it but still prints Meiji 1 to 5 for 1868-10-23 to 1872-12-31.", + "pairsWith": [], + "closes": [], + "dependsOn": [], + "gmtGuard": "D25", + "gmtNote": null, + "state": "open", + "status": "New", + "resolution": null, + "fixVersions": [], + "comments": 0, + "maintainerComments": 0, + "createdAt": "2026-11-14", + "updatedAt": "2026-11-14", + "closedAt": null + }, + { + "tracker": "jira", + "key": "ICU-23620", + "work": "report", + "title": "ja@calendar=japanese: a two-digit year (yy) prints one digit when the pattern contains 年", + "url": "https://unicode-org.atlassian.net/browse/ICU-23620", + "summary": "A `ja` date in the japanese calendar with `year: \"2-digit\"` prints `令和6年` where the standard asks for `令和06年`, because ICU's Japanese year numbering ignores the minimum digit count.", + "pairsWith": [], + "closes": [], + "dependsOn": [], + "gmtGuard": "D27", + "gmtNote": null, + "state": "open", + "status": "New", + "resolution": null, + "fixVersions": [], + "comments": 1, + "maintainerComments": 0, + "createdAt": "2026-11-14", + "updatedAt": "2026-11-14", + "closedAt": null + }, + { + "tracker": "jira", + "key": "ICU-23621", + "work": "report", + "title": "DateTimePatternGenerator turns a yy skeleton into a padded rr related year (Chinese, Dangi)", + "url": "https://unicode-org.atlassian.net/browse/ICU-23621", + "summary": "Under `year: \"2-digit\"` the chinese and dangi calendars print the related year padded to two digits, where ECMA-402 prints it at full width.", + "pairsWith": [], + "closes": [], + "dependsOn": [], + "gmtGuard": "D28", + "gmtNote": null, + "state": "open", + "status": "New", + "resolution": null, + "fixVersions": [], + "comments": 0, + "maintainerComments": 0, + "createdAt": "2026-11-14", + "updatedAt": "2026-11-14", + "closedAt": null + }, + { + "tracker": "jira", + "key": "ICU-23622", + "work": "report", + "title": "DateIntervalFormat: a flexible day period (B) is printed once for two periods, and a chinese or dangi skeleton with U falls back to a pattern that loses fields", + "url": "https://unicode-org.atlassian.net/browse/ICU-23622", + "summary": "ICU prints the flexible day period B once for two different periods, and the chinese and dangi U skeletons fall back to patterns that lose fields.", + "pairsWith": [], + "closes": [], + "dependsOn": [], + "gmtGuard": "D29", + "gmtNote": null, + "state": "open", + "status": "New", + "resolution": null, + "fixVersions": [], + "comments": 0, + "maintainerComments": 0, + "createdAt": "2026-11-14", + "updatedAt": "2026-11-14", + "closedAt": null + }, + { + "tracker": "jira", + "key": "ICU-23623", + "work": "report", + "title": "DateIntervalFormat: when only the era differs, the range uses the y entry and prints one era, so one date loses its era", + "url": "https://unicode-org.atlassian.net/browse/ICU-23623", + "summary": "When two dates differ only in their era, ICU takes the `y` interval pattern, which prints the era once, so one date loses its era: `scn` in the gregorian calendar, and ca, chr, fi, hr, it and ko in the ethiopic, japanese and roc calendars.", + "pairsWith": [], + "closes": [], + "dependsOn": [], + "gmtGuard": "D29", + "gmtNote": null, + "state": "open", + "status": "New", + "resolution": null, + "fixVersions": [], + "comments": 0, + "maintainerComments": 0, + "createdAt": "2026-11-15", + "updatedAt": "2026-11-15", + "closedAt": null + }, + { + "tracker": "jira", + "key": "ICU-23624", + "work": "report", + "title": "DateIntervalFormat: an hour cycle set by the caller is not applied when the interval pattern comes from CLDR with a different hour letter (ja hm)", + "url": "https://unicode-org.atlassian.net/browse/ICU-23624", + "summary": "A `ja` range with `hourCycle: \"h12\"` keeps the `K` hour of the CLDR interval pattern and prints `0時` where the single date prints 12.", + "pairsWith": [], + "closes": [], + "dependsOn": [], + "gmtGuard": "D29", + "gmtNote": null, + "state": "open", + "status": "New", + "resolution": null, + "fixVersions": [], + "comments": 0, + "maintainerComments": 0, + "createdAt": "2026-11-15", + "updatedAt": "2026-11-15", + "closedAt": null + }, + { + "tracker": "jira", + "key": "ICU-23625", + "work": "report", + "title": "DateIntervalFormat: the long flexible day period width is not applied to B, so a range prints AM or PM where the single date prints the wide period", + "url": "https://unicode-org.atlassian.net/browse/ICU-23625", + "summary": "Under `dayPeriod: \"long\"` a range keeps the stored `B` width, so in 22 locales such as bgc, to, sd and gaa it prints AM or PM where the single date prints the wide period.", + "pairsWith": [], + "closes": [], + "dependsOn": [], + "gmtGuard": "D29", + "gmtNote": null, + "state": "open", + "status": "New", + "resolution": null, + "fixVersions": [], + "comments": 0, + "maintainerComments": 0, + "createdAt": "2026-11-15", + "updatedAt": "2026-11-15", + "closedAt": null + }, + { + "tracker": "jira", + "key": "ICU-23626", + "work": "report", + "title": " IslamicCalendar: civilLeapYear makes every year before 1 AH a leap year", + "url": "https://unicode-org.atlassian.net/browse/ICU-23626", + "summary": "ICU's tabular Islamic calendar counts every year before 1 AH as a leap year, because its leap-year test uses a remainder that is negative for negative years. ICU4C and ICU4J share the line.", + "pairsWith": [], + "closes": [], + "dependsOn": [], + "gmtGuard": null, + "gmtNote": "GMT has no workaround for this: it shows only through engines that use this ICU code for Temporal, which today is WebKit (WebKit 331725).", + "state": "open", + "status": "New", + "resolution": null, + "fixVersions": [], + "comments": 0, + "maintainerComments": 0, + "createdAt": "2026-11-15", + "updatedAt": "2026-11-15", + "closedAt": null + }, + { + "tracker": "jira", + "key": "ICU-23627", + "work": "report", + "title": "IndianCalendar::handleComputeMonthStart truncates a negative Julian day, so months before Julian Day 0 start one day late", + "url": "https://unicode-org.atlassian.net/browse/ICU-23627", + "summary": "ICU starts every Indian-calendar month before Julian Day 0 one day late, because it truncates a negative day number instead of rounding it down. ICU4C and ICU4J share the bug.", + "pairsWith": [], + "closes": [], + "dependsOn": [], + "gmtGuard": null, + "gmtNote": "GMT has no workaround for this: it shows only through engines that use this ICU code for Temporal, which today is WebKit (WebKit 331726).", + "state": "open", + "status": "New", + "resolution": null, + "fixVersions": [], + "comments": 0, + "maintainerComments": 0, + "createdAt": "2026-11-15", + "updatedAt": "2026-11-15", + "closedAt": null + }, + { + "tracker": "chromium", + "id": 553245554, + "role": "contributor", + "work": "report", + "title": "Temporal’s Intl stringification for CJK is incorrect", + "url": "https://issues.chromium.org/issues/553245554", + "contributionUrl": "https://issues.chromium.org/issues/553245554#comment5", + "summary": "V8 prints a numeric month in Chinese and Japanese for Temporal `toLocaleString` with `month: \"long\"`. A V8 fix covers the full date; our comment shows the cases it misses, where the Temporal type drops a field such as the day.", + "pairsWith": [], + "closes": [], + "dependsOn": [], + "gmtGuard": null, + "gmtNote": "GMT never calls `toLocaleString`: its formatters pass the caller's own options to `Intl.DateTimeFormat`, so the month width the caller asks for is kept.", + "state": "open", + "comments": null, + "maintainerComments": null, + "createdAt": "2026-08-27", + "updatedAt": "2026-11-15", + "closedAt": null + }, + { + "tracker": "chromium", + "id": 585635918, + "work": "report", + "title": "Intl.DateTimeFormat keeps the \"islamic\" and \"islamic-rgsa\" calendars instead of the Intl era and monthCode fallbacks", + "url": "https://issues.chromium.org/issues/585635918", + "summary": "V8 keeps `islamic` and `islamic-rgsa` as the resolved calendar. ECMA-402 turns `islamic` into `islamic-tbla` and no longer has `islamic-rgsa`, and WebKit 26.6 does both.", + "pairsWith": [], + "closes": [], + "dependsOn": [], + "gmtGuard": "D30", + "gmtNote": null, + "state": "open", + "comments": null, + "maintainerComments": null, + "createdAt": "2026-11-14", + "updatedAt": "2026-11-14", + "closedAt": null + }, + { + "tracker": "bugzilla", + "host": "bugs.webkit.org", + "id": 330688, + "work": "report", + "title": "Temporal and Intl reject the time zone ids CST6CDT, EST5EDT, MST7MDT and PST8PDT", + "url": "https://bugs.webkit.org/show_bug.cgi?id=330688", + "summary": "WebKit 26.6 rejects the time zone ids `CST6CDT`, `EST5EDT`, `MST7MDT` and `PST8PDT` in `Intl` and `Temporal`, although the time zone database defines all four as zones. Chromium, Firefox and Node accept them.", + "pairsWith": [], + "closes": [], + "dependsOn": [], + "gmtGuard": null, + "gmtNote": "GMT has no workaround for this: it asks the engine about a time zone id, so these four read as invalid input on WebKit until the bug is fixed.", + "state": "open", + "status": "NEW", + "resolution": null, + "comments": 1, + "maintainerComments": 0, + "createdAt": "2026-11-09", + "updatedAt": "2026-11-10", + "closedAt": null + }, + { + "tracker": "bugzilla", + "host": "bugs.webkit.org", + "id": 331724, + "work": "report", + "title": "[JSC][Intl] Islamic era override ignores the formatter time zone, so 1 Muharram 1 AH formats as year 0 of Before Hijra", + "url": "https://bugs.webkit.org/show_bug.cgi?id=331724", + "summary": "WebKit switches Islamic dates from `Before Hijra` to `AH` at a fixed instant instead of at local midnight, so the first hours of 1 AH print as year 0 in UTC and in every zone east of −07:52:58.", + "pairsWith": [], + "closes": [], + "dependsOn": [], + "gmtGuard": "D18", + "gmtNote": null, + "state": "open", + "status": "NEW", + "resolution": null, + "comments": 0, + "maintainerComments": 0, + "createdAt": "2026-11-15", + "updatedAt": "2026-11-15", + "closedAt": null + }, + { + "tracker": "bugzilla", + "host": "bugs.webkit.org", + "id": 331725, + "work": "report", + "title": "[JSC][Temporal] islamic-civil, islamic-tbla and islamic-umalqura report every negative year as a leap year, so add({ years: 1 }) from M12 day 30 lands 13 months on", + "url": "https://bugs.webkit.org/show_bug.cgi?id=331725", + "summary": "WebKit's Temporal treats every Islamic year before 1 AH as a leap year, so adding a year to the 30th of Dhu al-Hijjah lands 13 months on. The cause is in ICU, filed as ICU-23626.", + "pairsWith": [], + "closes": [], + "dependsOn": [], + "gmtGuard": null, + "gmtNote": "GMT has no workaround for this: it shows only when GMT runs on WebKit's own Temporal, where the native-suite rows that hit it are tagged with this report until WebKit is fixed.", + "state": "open", + "status": "NEW", + "resolution": null, + "comments": 1, + "maintainerComments": 0, + "createdAt": "2026-11-15", + "updatedAt": "2026-11-15", + "closedAt": null + }, + { + "tracker": "bugzilla", + "host": "bugs.webkit.org", + "id": 331726, + "work": "report", + "title": "[JSC][Temporal] indian calendar add() and until() throw RangeError when the result is the last day of a month starting on or before ISO -004713-11-24", + "url": "https://bugs.webkit.org/show_bug.cgi?id=331726", + "summary": "WebKit's Temporal throws when adding years or months lands on the last day of an Indian month that starts before Julian Day 0. The cause is in ICU, filed as ICU-23627.", + "pairsWith": [], + "closes": [], + "dependsOn": [], + "gmtGuard": null, + "gmtNote": "GMT has no workaround for this: it shows only when GMT runs on WebKit's own Temporal, where the native-suite rows that hit it are tagged with this report until WebKit is fixed.", + "state": "open", + "status": "NEW", + "resolution": null, + "comments": 1, + "maintainerComments": 0, + "createdAt": "2026-11-15", + "updatedAt": "2026-11-15", + "closedAt": null + }, + { + "tracker": "bugzilla", + "host": "bugzilla.mozilla.org", + "id": 2085525, + "work": "report", + "title": "Intl.DateTimeFormat formatRange prints AM/PM instead of the dayPeriod when timeZoneName is set", + "url": "https://bugzilla.mozilla.org/show_bug.cgi?id=2085525", + "summary": "Firefox's `formatRange` prints AM/PM instead of the flexible day period when `timeZoneName` is set. A single `format` in Firefox, and `formatRange` in every other engine, print the day period.", + "pairsWith": [], + "closes": [], + "dependsOn": [], + "gmtGuard": "D17", + "gmtNote": null, + "state": "open", + "status": "UNCONFIRMED", + "resolution": null, + "comments": 0, + "maintainerComments": 0, + "createdAt": "2026-10-24", + "updatedAt": "2026-10-26", + "closedAt": null } ], "listings": [ { + "tracker": "github", "repo": "sindresorhus/awesome-nodejs", "number": 1402, "kind": "issue", @@ -613,6 +1271,7 @@ "mergedAt": null }, { + "tracker": "github", "repo": "sorrycc/awesome-javascript", "number": 1209, "kind": "pr", @@ -630,6 +1289,7 @@ "mergedAt": null }, { + "tracker": "github", "repo": "you-dont-need/You-Dont-Need-Momentjs", "number": 159, "kind": "pr", diff --git a/apps/dox/src/data/upstream-filings.test.ts b/apps/dox/src/data/upstream-filings.test.ts index d1102847c..14580e82d 100644 --- a/apps/dox/src/data/upstream-filings.test.ts +++ b/apps/dox/src/data/upstream-filings.test.ts @@ -5,6 +5,10 @@ import { resolve } from "node:path"; import { checked, contributions, + filingGroup, + filingGroups, + filingKey, + filingsForGroup, filedByUs, filedPrs, filings, @@ -19,14 +23,17 @@ import { listings, overlayLive, totalFilings, + TRACKERS, TRACKED_REPOS, unaffectingGmt, + type GitHubFiling, type UpstreamFiling, type UpstreamListing, } from "./upstream-filings"; +import { urlOf } from "../../../../scripts/lib/upstream-trackers.mjs"; import { getUtcNow, isAfterUtc, isValidUtc } from "@northguild/gmt"; -// The literal `DefectId` / `ZonedDefectId` / `BoundedWorkDefectId` union members +// The literal `DefectId` / `ZonedDefectId` / `BoundedWorkDefectId` / `CanaryDefectId` union members // `probeRepros.ts` and `repros.ts` declare — the same set `scripts/upstream.mjs check` parses out of // the same file, so a filing's `gmtGuard` can never name a group that doesn't exist. const reprosSrc = ["probeRepros.ts", "repros.ts"] @@ -43,7 +50,7 @@ const reprosSrc = ["probeRepros.ts", "repros.ts"] .join("\n"); const knownGuards = new Set(); for (const m of reprosSrc.matchAll( - /export type (?:DefectId|ZonedDefectId|BoundedWorkDefectId) =([^;]+);/g, + /export type (?:DefectId|ZonedDefectId|BoundedWorkDefectId|CanaryDefectId) =([^;]+);/g, )) { for (const lit of m[1].matchAll(/"([^"]+)"/g)) knownGuards.add(lit[1]); } @@ -59,18 +66,50 @@ describe("upstream filings", () => { expect(isAfterUtc(checked, getUtcNow())).toBe(false); }); - it("gives every filing a URL matching its own repo, kind and number", () => { + it("gives every filing a URL matching its own tracker and identity", () => { for (const f of filings) { - const expected = `https://github.com/${f.repo}/${f.kind === "pr" ? "pull" : "issues"}/${f.number}`; - expect(f.url).toBe(expected); + expect(f.url, filingKey(f)).toBe(urlOf(f)); } }); - it("has no duplicate repo+number", () => { - const keys = filings.map((f) => `${f.repo}#${f.number}`); + it("names a known tracker on every filing", () => { + for (const f of filings) + expect(TRACKERS, filingKey(f)).toContain(f.tracker); + }); + + it("has no duplicate identity", () => { + const keys = filings.map(filingKey); expect(new Set(keys).size).toBe(keys.length); }); + it("gives a filing only the members of its own tracker", () => { + // GitHub's `kind`, `draft`, `reviewDecision` and `mergedAt` mean nothing on the Jira, Chromium + // or Bugzilla trackers, so none of those carries them. + for (const f of filings) { + if (f.tracker === "github") continue; + for (const field of [ + "repo", + "number", + "kind", + "draft", + "reviewDecision", + "mergedAt", + ]) { + expect(f, `${filingKey(f)} ${field}`).not.toHaveProperty(field); + } + } + }); + + it("groups filings under one heading per repository or tracker", () => { + const grouped = filingGroups.reduce( + (n, g) => n + filingsForGroup(g.id).length, + 0, + ); + expect(grouped).toBe(totalFilings); + const headings = filingGroups.map((g) => g.name); + expect(new Set(headings).size).toBe(headings.length); + }); + it("sums repo counts to the total", () => { const sum = filingsByRepo.reduce((n, row) => n + row.count, 0); expect(sum).toBe(totalFilings); @@ -96,7 +135,7 @@ describe("upstream filings", () => { if (f.gmtGuard !== null) { expect( knownGuards.has(f.gmtGuard), - `${f.repo}#${f.number} gmtGuard "${f.gmtGuard}"`, + `${filingKey(f)} gmtGuard "${f.gmtGuard}"`, ).toBe(true); } } @@ -105,10 +144,9 @@ describe("upstream filings", () => { it("covers every filing in GMT: exactly one of gmtGuard or gmtNote", () => { // A filing with neither would be a defect GMT neither works around nor avoids. for (const f of filings) { - expect( - (f.gmtGuard === null) !== (f.gmtNote === null), - `${f.repo}#${f.number}`, - ).toBe(true); + expect((f.gmtGuard === null) !== (f.gmtNote === null), filingKey(f)).toBe( + true, + ); } expect(handledInGmt + unaffectingGmt).toBe(totalFilings); }); @@ -121,20 +159,18 @@ describe("upstream filings", () => { for (const f of filings) { if (f.role === undefined) continue; - expect(["author", "contributor"], `${f.repo}#${f.number}`).toContain( - f.role, - ); + expect(["author", "contributor"], filingKey(f)).toContain(f.role); } }); it("links our own comment on every filing we did not open", () => { // Without it the page would show a maintainer's PR with nothing saying what we did on it. - // `url` cannot carry the anchor: `scripts/upstream.mjs` rewrites it from repo, kind and number. + // `url` cannot carry the anchor: `scripts/upstream.mjs` rewrites it from the entry's identity. for (const f of filings) { - const label = `${f.repo}#${f.number}`; + const label = filingKey(f); if (f.role === "contributor") { expect(f.contributionUrl, label).toBeTruthy(); - expect(f.contributionUrl, label).toContain(`/${f.number}#`); + expect(f.contributionUrl, label).toContain(f.url); } else { expect(f.contributionUrl ?? null, label).toBeNull(); } @@ -169,9 +205,9 @@ describe("upstream filings", () => { }); it("pairs symmetrically: if A pairsWith B, B pairsWith A", () => { - const byKey = new Map(filings.map((f) => [`${f.repo}#${f.number}`, f])); + const byKey = new Map(filings.map((f) => [filingKey(f), f])); for (const f of filings) { - const key = `${f.repo}#${f.number}`; + const key = filingKey(f); for (const partnerKey of f.pairsWith) { const partner = byKey.get(partnerKey); expect( @@ -187,7 +223,7 @@ describe("upstream filings", () => { }); it("names only filings that exist in dependsOn and closes", () => { - const keys = new Set(filings.map((f) => `${f.repo}#${f.number}`)); + const keys = new Set(filings.map(filingKey)); for (const f of filings) { for (const dep of f.dependsOn) { // A dependency may be a filing tracked here, or an upstream number this @@ -218,8 +254,9 @@ describe("upstream filings", () => { describe("overlayLive", () => { const filing = ( number: number, - fields: Partial = {}, - ): UpstreamFiling => ({ + fields: Partial = {}, + ): GitHubFiling => ({ + tracker: "github", repo: "tc39/proposal-temporal", number, kind: "issue", @@ -251,7 +288,10 @@ describe("overlayLive", () => { { checked: committedAt, filings: [filing(3335), filing(3336)] }, { checked: liveAt, filings: [filing(3335)] }, ); - expect(result.filings.map((f) => f.number)).toEqual([3335, 3336]); + expect(result.filings.map(filingKey)).toEqual([ + "tc39/proposal-temporal#3335", + "tc39/proposal-temporal#3336", + ]); }); it("takes the hand-written fields from the committed file", () => { @@ -308,7 +348,7 @@ describe("overlayLive", () => { filings: [filing(3336), filing(3340, { new: true }), polyfill], }, ); - expect(result.filings.map((f) => `${f.repo}#${f.number}`)).toEqual([ + expect(result.filings.map(filingKey)).toEqual([ "js-temporal/temporal-polyfill#400", "tc39/proposal-temporal#3336", "tc39/proposal-temporal#3340", @@ -352,7 +392,8 @@ describe("overlayLive", () => { it("orders repositories as the tracker lists them, not alphabetically", () => { const at = "2026-11-02T10:00:00Z"; - const make = (repo: string, number: number): UpstreamFiling => ({ + const make = (repo: string, number: number): GitHubFiling => ({ + tracker: "github", repo, number, kind: "issue", @@ -387,7 +428,7 @@ describe("overlayLive", () => { ], }, ); - expect(result.filings.map((f) => `${f.repo}#${f.number}`)).toEqual([ + expect(result.filings.map(filingKey)).toEqual([ "js-temporal/temporal-polyfill#400", "tc39/proposal-temporal#3336", "fullcalendar/temporal-polyfill#130", @@ -397,9 +438,89 @@ describe("overlayLive", () => { it("names only tracked repositories in the committed data", () => { for (const f of filings) { - expect(TRACKED_REPOS).toContain(f.repo); + if (f.tracker === "github") expect(TRACKED_REPOS).toContain(f.repo); } }); + + it("orders every GitHub repository before the other trackers", () => { + const at = "2026-11-02T10:00:00Z"; + const jira = { + tracker: "jira", + key: "ICU-23619", + work: "report", + title: "t", + url: "https://unicode-org.atlassian.net/browse/ICU-23619", + summary: "s", + pairsWith: [], + closes: [], + dependsOn: [], + gmtGuard: "D25", + gmtNote: null, + state: "open", + status: "New", + resolution: null, + fixVersions: [], + comments: 0, + maintainerComments: 0, + createdAt: "2026-11-14", + updatedAt: "2026-11-14", + closedAt: null, + } satisfies UpstreamFiling; + const chromium = { + tracker: "chromium", + id: 585635918, + work: "report", + title: "t", + url: "https://issues.chromium.org/issues/585635918", + summary: "s", + pairsWith: [], + closes: [], + dependsOn: [], + gmtGuard: "D30", + gmtNote: null, + state: "open", + comments: null, + maintainerComments: null, + createdAt: "2026-11-14", + updatedAt: "2026-11-14", + closedAt: null, + } satisfies UpstreamFiling; + const github: GitHubFiling = { + tracker: "github", + repo: "nodejs/node", + number: 67076, + kind: "issue", + work: "report", + title: "t", + url: "https://github.com/nodejs/node/issues/67076", + summary: "s", + pairsWith: [], + closes: [], + dependsOn: [], + gmtGuard: "D23", + gmtNote: null, + state: "open", + draft: false, + reviewDecision: null, + comments: 0, + maintainerComments: 0, + createdAt: "2026-10-28", + updatedAt: "2026-10-28", + closedAt: null, + mergedAt: null, + }; + const result = overlayLive( + { checked: at, filings: [chromium, jira, github] }, + { checked: "2026-11-02T11:00:00Z", filings: [chromium, jira, github] }, + ); + expect(result.filings.map(filingKey)).toEqual([ + "nodejs/node#67076", + "ICU-23619", + "chromium#585635918", + ]); + expect(filingGroup(jira).name).toBe("Unicode Jira (ICU and CLDR)"); + expect(filingGroup(chromium).name).toBe("Chromium issue tracker"); + }); }); const TEMPORAL_REPOS = [ @@ -412,6 +533,7 @@ const listing = ( number: number, fields: Partial = {}, ): UpstreamListing => ({ + tracker: "github", repo: "example/comparison-list", number, kind: "issue", @@ -451,10 +573,10 @@ describe("upstream listings", () => { }); it("is on a project outside Temporal, and shares no key with a filing", () => { - const filingKeys = new Set(filings.map((f) => `${f.repo}#${f.number}`)); + const filingKeys = new Set(filings.map(filingKey)); for (const l of listings) { - expect(TEMPORAL_REPOS, `${l.repo}#${l.number}`).not.toContain(l.repo); - expect(filingKeys.has(`${l.repo}#${l.number}`)).toBe(false); + expect(TEMPORAL_REPOS, filingKey(l)).not.toContain(l.repo); + expect(filingKeys.has(filingKey(l))).toBe(false); } }); @@ -603,4 +725,94 @@ describe("scripts/upstream.mjs check", () => { expect(result.ok).toBe(false); expect(result.output).toContain("duplicate"); }); + + // Each tracker has its own members, and `check` rejects any that belongs to another. + const entry = (tracker: string, id?: Record) => { + const found = (committed.filings as Record[]).find( + (f) => + f.tracker === tracker && + (id === undefined || Object.entries(id).every(([k, v]) => f[k] === v)), + ); + expect(found, tracker).toBeDefined(); + return found!; + }; + const withFilings = (...changed: Record[]) => { + const keys = new Set( + changed.map((c) => + JSON.stringify([c.tracker, c.key, c.id, c.repo, c.number]), + ), + ); + return { + ...committed, + filings: [ + ...(committed.filings as Record[]).filter( + (f) => + !keys.has( + JSON.stringify([f.tracker, f.key, f.id, f.repo, f.number]), + ), + ), + ...changed, + ], + }; + }; + + it("fails on a Jira filing that carries a GitHub member", () => { + const bad = { ...entry("jira"), reviewDecision: null }; + const result = run(withFilings(bad)); + expect(result.ok).toBe(false); + expect(result.output).toContain("does not belong to a jira filing"); + }); + + it("fails on a Chromium filing that carries a Bugzilla status", () => { + const bad = { ...entry("chromium"), status: "NEW" }; + const result = run(withFilings(bad)); + expect(result.ok).toBe(false); + expect(result.output).toContain("does not belong to a chromium filing"); + }); + + it("fails on a GitHub filing without a kind", () => { + const { kind: _kind, ...bad } = entry("github"); + const result = run(withFilings(bad)); + expect(result.ok).toBe(false); + expect(result.output).toContain("kind"); + }); + + it("fails on a Jira key outside ICU and CLDR", () => { + const bad = { + ...entry("jira"), + key: "ABC-1", + url: "https://unicode-org.atlassian.net/browse/ABC-1", + }; + const result = run(withFilings(entry("jira"), bad)); + expect(result.ok).toBe(false); + expect(result.output).toContain("not an ICU or CLDR issue key"); + }); + + it("fails on a Chromium filing with comment counts", () => { + const bad = { ...entry("chromium"), comments: 2, maintainerComments: 1 }; + const result = run(withFilings(bad)); + expect(result.ok).toBe(false); + expect(result.output).toContain("null on a Chromium filing"); + }); + + it("fails on a Bugzilla filing on another host", () => { + const bad = { ...entry("bugzilla"), host: "bugzilla.example.test" }; + const result = run(withFilings(bad)); + expect(result.ok).toBe(false); + expect(result.output).toContain("host"); + }); + + it("fails on an unknown tracker", () => { + const bad = { ...entry("jira"), tracker: "linear" }; + const result = run(withFilings(bad)); + expect(result.ok).toBe(false); + expect(result.output).toContain("tracker"); + }); + + it("fails on an open Jira filing that has a resolution", () => { + const bad = { ...entry("jira"), state: "open", resolution: "Fixed" }; + const result = run(withFilings(bad)); + expect(result.ok).toBe(false); + expect(result.output).toContain("resolved as"); + }); }); diff --git a/apps/dox/src/data/upstream-filings.ts b/apps/dox/src/data/upstream-filings.ts index db72750d5..afa12d724 100644 --- a/apps/dox/src/data/upstream-filings.ts +++ b/apps/dox/src/data/upstream-filings.ts @@ -1,6 +1,9 @@ /** * The upstream filings GMT has reported against `@js-temporal/polyfill`, - * `tc39/proposal-temporal` and `fullcalendar/temporal-polyfill`. `/upstream/` and its `UpstreamTracker.astro` + * `tc39/proposal-temporal`, `fullcalendar/temporal-polyfill`, `tc39/ecma402` and `nodejs/node` on + * GitHub, and on the Unicode Jira, the Chromium issue tracker and two Bugzilla servers. Every entry + * names its tracker (`tracker`), and each tracker has its own identity fields, so no entry carries a + * member that belongs to another tracker. `/upstream/` and its `UpstreamTracker.astro` * import every figure from here, the same way `gmt-stats.ts` is the one place * a GMT number is typed. * @@ -23,6 +26,7 @@ * error, but a glob that matches nothing is just an empty object. */ import { isAfterUtc } from "@northguild/gmt"; +import { shortRef } from "./temporal-compat"; import committedData from "./upstream-filings.json"; /** `port` mirrors an already-merged upstream commit; `fix` and `report` are a @@ -30,10 +34,8 @@ import committedData from "./upstream-filings.json"; * publish of commits already on `main`. */ export type FilingWork = "port" | "fix" | "report" | "release"; -export interface UpstreamFiling { - repo: string; - number: number; - kind: "pr" | "issue"; +/** What every tracker's filing carries: our judgement, then what the tracker reports. */ +interface FilingBase { /** `null` only for a filing `sync` just discovered and nobody has classified yet. */ work: FilingWork | null; title: string; @@ -69,24 +71,79 @@ export interface UpstreamFiling { */ outcome?: string | null; /** A `"contributor"` row's link to our own comment. `url` cannot hold it: `sync` rewrites `url` - * from the repo, kind and number every run. */ + * from the tracker's own identity every run. */ contributionUrl?: string | null; state: "open" | "closed"; + createdAt: string; + updatedAt: string; + closedAt: string | null; + /** Live file only: discovery found this filing but the committed file doesn't have it + * yet, so its hand-written fields (`summary`, `gmtGuard`, ...) are still empty. */ + new?: boolean; +} + +/** A GitHub issue or pull request. */ +export interface GitHubFiling extends FilingBase { + tracker: "github"; + repo: string; + number: number; + kind: "pr" | "issue"; draft: boolean; reviewDecision: "APPROVED" | "CHANGES_REQUESTED" | "REVIEW_REQUIRED" | null; comments: number; /** Comments by anyone outside GMT (`AUTHORS` in `scripts/upstream.mjs`), so a * cross-link one of us posts never counts as a maintainer response. */ maintainerComments: number; - createdAt: string; - updatedAt: string; - closedAt: string | null; mergedAt: string | null; - /** Live file only: `gh` found this filing but the committed file doesn't have it - * yet, so its hand-written fields (`summary`, `gmtGuard`, ...) are still empty. */ - new?: boolean; } +/** An issue in the Unicode Jira (`ICU-…` or `CLDR-…`). */ +export interface JiraFiling extends FilingBase { + tracker: "jira"; + /** The Jira key, such as `"ICU-23619"`. */ + key: string; + /** Jira's own status name, such as `"Accepted"` or `"Done"`. */ + status: string; + /** Jira's resolution name once resolved, such as `"Fixed"`; `null` while unresolved. */ + resolution: string | null; + fixVersions: readonly string[]; + comments: number; + maintainerComments: number; +} + +/** + * An issue on the Chromium issue tracker. The tracker has no public API, so what is read is the + * state and the dates; the comment counts are `null` because the endpoint we can call without + * signing in does not return comments. + */ +export interface ChromiumFiling extends FilingBase { + tracker: "chromium"; + /** The numeric issue id. */ + id: number; + comments: null; + maintainerComments: null; +} + +/** A bug on a Bugzilla server (`bugzilla.mozilla.org` or `bugs.webkit.org`). */ +export interface BugzillaFiling extends FilingBase { + tracker: "bugzilla"; + host: string; + /** The numeric bug id. */ + id: number; + /** Bugzilla's status, such as `"NEW"` or `"RESOLVED"`. */ + status: string; + /** Bugzilla's resolution once resolved, such as `"FIXED"`; `null` while open. */ + resolution: string | null; + comments: number; + maintainerComments: number; +} + +export type UpstreamFiling = + | GitHubFiling + | JiraFiling + | ChromiumFiling + | BugzillaFiling; + /** * A pull request or an issue GMT opened on a project outside Temporal, such as a comparison list * that should include GMT. It fixes no Temporal defect, so it is not a filing: it has no `work`, @@ -94,6 +151,7 @@ export interface UpstreamFiling { * synced. */ export interface UpstreamListing { + tracker: "github"; repo: string; number: number; kind: "pr" | "issue"; @@ -140,8 +198,22 @@ export const HAND_WRITTEN_FIELDS = [ * `scripts/upstream.mjs`, which a test holds equal. */ export const LISTING_HAND_WRITTEN_FIELDS = ["summary"] as const; -const keyOf = (f: { repo: string; number: number }): string => - `${f.repo}#${f.number}`; +/** The stable identity of an entry: `owner/repo#n`, `ICU-23619`, `chromium#n`, `host#n`. */ +export const filingKey = (f: UpstreamFiling | UpstreamListing): string => { + switch (f.tracker) { + case "github": + return `${f.repo}#${f.number}`; + case "jira": + return f.key; + case "chromium": + return `chromium#${f.id}`; + case "bugzilla": + return `${f.host}#${f.id}`; + } +}; + +/** The trackers, in page order. Mirrors `TRACKERS` in `scripts/upstream.mjs`. */ +export const TRACKERS = ["github", "jira", "chromium", "bugzilla"] as const; /** * The repositories the tracker follows, in page order. Mirrors `REPOS` in `scripts/upstream.mjs`, @@ -151,20 +223,98 @@ export const TRACKED_REPOS = [ "js-temporal/temporal-polyfill", "tc39/proposal-temporal", "fullcalendar/temporal-polyfill", + "tc39/ecma402", + "nodejs/node", ] as const; -const repoRank = (repo: string): number => { - const i = (TRACKED_REPOS as readonly string[]).indexOf(repo); - return i === -1 ? TRACKED_REPOS.length : i; +/** A heading on the page: one GitHub repository, or one other tracker. */ +export interface FilingGroup { + /** Stable id, the page's grouping key. */ + id: string; + /** What the heading says. */ + name: string; + /** Where the heading links. */ + href: string; +} + +const JIRA_HOST = "unicode-org.atlassian.net"; + +/** Which heading a filing sits under. */ +export function filingGroup(f: UpstreamFiling): FilingGroup { + switch (f.tracker) { + case "github": + return { + id: f.repo, + name: f.repo, + href: `https://github.com/${f.repo}`, + }; + case "jira": + return { + id: JIRA_HOST, + name: "Unicode Jira (ICU and CLDR)", + href: `https://${JIRA_HOST}`, + }; + case "chromium": + return { + id: "issues.chromium.org", + name: "Chromium issue tracker", + href: "https://issues.chromium.org", + }; + case "bugzilla": + return { + id: f.host, + name: + f.host === "bugs.webkit.org" ? "WebKit Bugzilla" : "Mozilla Bugzilla", + href: `https://${f.host}`, + }; + } +} + +/** The short label a table prints for one filing: `tc39 #3292`, `ICU-23619`, `Chromium 585635918`. */ +export function filingRef(f: UpstreamFiling | UpstreamListing): string { + switch (f.tracker) { + case "github": + return shortRef(f.repo, f.number); + case "jira": + return f.key; + case "chromium": + return `Chromium ${f.id}`; + case "bugzilla": + return `${f.host === "bugs.webkit.org" ? "WebKit" : "Mozilla"} ${f.id}`; + } +} + +/** The page order of two entries: tracker, then repository or host, then number. */ +const orderKey = ( + f: UpstreamFiling | UpstreamListing, +): [number, string, number] => { + const rank = TRACKERS.indexOf(f.tracker); + switch (f.tracker) { + case "github": { + const i = (TRACKED_REPOS as readonly string[]).indexOf(f.repo); + return [ + rank, + String(i === -1 ? TRACKED_REPOS.length : i).padStart(3, "0") + f.repo, + f.number, + ]; + } + case "jira": + return [rank, f.key.split("-")[0], Number(f.key.split("-")[1])]; + case "chromium": + return [rank, "", f.id]; + case "bugzilla": + return [rank, f.host, f.id]; + } }; -const byRepoThenNumber = ( - a: { repo: string; number: number }, - b: { repo: string; number: number }, -): number => - repoRank(a.repo) - repoRank(b.repo) || - a.repo.localeCompare(b.repo) || - a.number - b.number; +const byPageOrder = ( + a: UpstreamFiling | UpstreamListing, + b: UpstreamFiling | UpstreamListing, +): number => { + const [ra, sa, na] = orderKey(a); + const [rb, sb, nb] = orderKey(b); + return ra - rb || sa.localeCompare(sb) || na - nb; +}; /** * The live file laid over the committed one. @@ -183,9 +333,9 @@ export function overlayLive( live: UpstreamFilings, ): UpstreamFilings { if (!isAfterUtc(live.checked, committed.checked)) return committed; - const liveByKey = new Map(live.filings.map((f) => [keyOf(f), f])); + const liveByKey = new Map(live.filings.map((f) => [filingKey(f), f])); const fromCommitted = committed.filings.map((own) => { - const fresh = liveByKey.get(keyOf(own)); + const fresh = liveByKey.get(filingKey(own)); if (fresh === undefined) return own; const merged: Record = { ...fresh }; for (const field of HAND_WRITTEN_FIELDS) { @@ -194,11 +344,11 @@ export function overlayLive( } return merged as unknown as UpstreamFiling; }); - const committedKeys = new Set(committed.filings.map(keyOf)); - const onlyLive = live.filings.filter((f) => !committedKeys.has(keyOf(f))); + const committedKeys = new Set(committed.filings.map(filingKey)); + const onlyLive = live.filings.filter((f) => !committedKeys.has(filingKey(f))); return { checked: live.checked, - filings: [...fromCommitted, ...onlyLive].sort(byRepoThenNumber), + filings: [...fromCommitted, ...onlyLive].sort(byPageOrder), listings: overlayListings(committed.listings ?? [], live.listings), }; } @@ -208,17 +358,17 @@ function overlayListings( live: readonly UpstreamListing[] | undefined, ): readonly UpstreamListing[] { if (live === undefined) return committed; - const liveByKey = new Map(live.map((l) => [keyOf(l), l])); + const liveByKey = new Map(live.map((l) => [filingKey(l), l])); return committed .map((own) => { - const fresh = liveByKey.get(keyOf(own)); + const fresh = liveByKey.get(filingKey(own)); if (fresh === undefined) return own; const merged: Record = { ...fresh }; for (const field of LISTING_HAND_WRITTEN_FIELDS) merged[field] = own[field]; return merged as unknown as UpstreamListing; }) - .sort(byRepoThenNumber); + .sort(byPageOrder); } function isUpstreamFilings(value: unknown): value is UpstreamFilings { @@ -226,7 +376,12 @@ function isUpstreamFilings(value: unknown): value is UpstreamFilings { typeof value === "object" && value !== null && typeof (value as UpstreamFilings).checked === "string" && - Array.isArray((value as UpstreamFilings).filings) + Array.isArray((value as UpstreamFilings).filings) && + // A live file written before the trackers were named holds GitHub entries without a + // `tracker`; it is ignored and the committed file stands. + (value as UpstreamFilings).filings.every((f) => + (TRACKERS as readonly string[]).includes(f?.tracker), + ) ); } @@ -239,13 +394,15 @@ function isUpstreamFilings(value: unknown): value is UpstreamFilings { // from `lib/mdx-jsx.ts` — which the `.md`, `llms-full.txt` and retrieval-chunk pipeline runs // outside Vite — dies on `glob is not a function`. Outside Vite it takes the committed snapshot, // which is the same fallback a missing live file already gets, and the one `upstream check` gates. +// The guard reads `import.meta.env`, which Vite replaces at build; `typeof import.meta.glob` +// would stay in the built code and be false there (`lib/import-meta-glob-guard.test.ts`). const liveModules = ( - typeof import.meta.glob === "function" - ? import.meta.glob("../generated/upstream-filings.live.json", { + import.meta.env === undefined + ? {} + : import.meta.glob("../generated/upstream-filings.live.json", { eager: true, import: "default", }) - : {} ) as Record; const liveData = Object.values(liveModules)[0]; @@ -269,14 +426,14 @@ export const checked: string = upstreamFilings.checked; export const listings: readonly UpstreamListing[] = upstreamFilings.listings ?? []; -/** Every distinct repository a filing names, in first-seen (JSON) order. */ -export const filingRepos: readonly string[] = [ - ...new Set(filings.map((f) => f.repo)), +/** Every distinct heading a filing sits under, in first-seen (JSON) order. */ +export const filingGroups: readonly FilingGroup[] = [ + ...new Map(filings.map((f) => [filingGroup(f).id, filingGroup(f)])).values(), ]; -/** Filings for one repository, in the order the JSON lists them (repo, then number). */ -export function filingsForRepo(repo: string): readonly UpstreamFiling[] { - return filings.filter((f) => f.repo === repo); +/** Filings under one heading, in the order the JSON lists them. */ +export function filingsForGroup(id: string): readonly UpstreamFiling[] { + return filings.filter((f) => filingGroup(f).id === id); } export interface CountRow { @@ -284,18 +441,20 @@ export interface CountRow { count: number; } -/** How many filings name each repository. */ -export const filingsByRepo: readonly CountRow[] = filingRepos.map((repo) => ({ - label: repo, - count: filingsForRepo(repo).length, +/** How many filings sit under each heading. */ +export const filingsByRepo: readonly CountRow[] = filingGroups.map((g) => ({ + label: g.id, + count: filingsForGroup(g.id).length, })); -/** How many filings are a PR versus an issue. */ +/** How many filings are a GitHub PR versus a GitHub issue; other trackers have issues only. */ export const filingsByKind: readonly CountRow[] = ( ["pr", "issue"] as const ).map((kind) => ({ label: kind, - count: filings.filter((f) => f.kind === kind).length, + count: filings.filter( + (f) => (f.tracker === "github" ? f.kind : "issue") === kind, + ).length, })); /** How many filings are open versus closed. */ @@ -308,7 +467,7 @@ export const filingsByState: readonly CountRow[] = ( /** Filings with at least one comment from someone other than the author. */ export const filingsWithMaintainerResponse: number = filings.filter( - (f) => f.maintainerComments > 0, + (f) => (f.maintainerComments ?? 0) > 0, ).length; /** Every distinct non-null `gmtGuard` a filing names — the GMT canary groups @@ -344,5 +503,5 @@ export const contributions: number = filings.filter((f) => !isOurs(f)).length; /** Our own pull requests — the filings that carry a ready-to-merge patch. A maintainer's PR we * only commented on is not one of these, which is why the page cannot count `kind === "pr"`. */ export const filedPrs: number = filings.filter( - (f) => isOurs(f) && f.kind === "pr", + (f) => isOurs(f) && f.tracker === "github" && f.kind === "pr", ).length; diff --git a/apps/dox/src/data/upstream-trackers.test.ts b/apps/dox/src/data/upstream-trackers.test.ts new file mode 100644 index 000000000..df3b3ac3a --- /dev/null +++ b/apps/dox/src/data/upstream-trackers.test.ts @@ -0,0 +1,337 @@ +import * as gmt from "@northguild/gmt"; +import { + bugzillaBugUrl, + bugzillaCommentsUrl, + chromiumIssueUrl, + identityOf, + isJiraKey, + jiraDiscoveryUrl, + jiraIssueUrl, + keyOf, + makeDays, + parseBugzilla, + parseChromium, + parseJira, + parseJiraDiscovery, + SYNCED_FIELDS, + urlOf, +} from "../../../../scripts/lib/upstream-trackers.mjs"; + +// The readers take a recorded response as text and know nothing of the network, so each test +// feeds one a trimmed copy of what the tracker returned (Jira on 2026-11-14, Chromium's page +// JSON, Bugzilla's REST API) and never calls out. +const days = makeDays(gmt); +const OURS = "712020:edbd7a30-b6e5-42d7-b938-06b19b5d87a9"; + +describe("makeDays", () => { + it("reads a time in the reporter's offset as the UTC day", () => { + // 21:53 in California on the 13th is the 14th in UTC; slicing the text would say the 13th. + expect(days.fromIso("2026-11-13T21:53:32.451-0800")).toBe("2026-11-14"); + expect(days.fromIso("2026-11-13T21:53:32.451-08:00")).toBe("2026-11-14"); + expect(days.fromIso("2026-11-14T01:00:00Z")).toBe("2026-11-14"); + }); + + it("answers null for anything that is not a time", () => { + expect(days.fromIso("")).toBeNull(); + expect(days.fromIso(undefined)).toBeNull(); + expect(days.fromEpochSeconds("x")).toBeNull(); + }); + + it("reads epoch seconds as a UTC day", () => { + expect(days.fromEpochSeconds(1794679042)).toBe("2026-11-14"); + }); +}); + +describe("tracker identities", () => { + it("names and links each tracker's entries", () => { + const refs = [ + { tracker: "github", repo: "nodejs/node", number: 67076, kind: "issue" }, + { tracker: "jira", key: "ICU-23619" }, + { tracker: "chromium", id: 585635918 }, + { tracker: "bugzilla", host: "bugs.webkit.org", id: 330688 }, + ]; + expect(refs.map(keyOf)).toEqual([ + "nodejs/node#67076", + "ICU-23619", + "chromium#585635918", + "bugs.webkit.org#330688", + ]); + expect(refs.map(urlOf)).toEqual([ + "https://github.com/nodejs/node/issues/67076", + "https://unicode-org.atlassian.net/browse/ICU-23619", + "https://issues.chromium.org/issues/585635918", + "https://bugs.webkit.org/show_bug.cgi?id=330688", + ]); + }); + + it("keeps only the identity members of an entry", () => { + expect( + identityOf({ tracker: "jira", key: "ICU-23619", status: "New" }), + ).toEqual({ key: "ICU-23619" }); + }); + + it("accepts keys of the projects we file in and no others", () => { + expect(isJiraKey("ICU-23619")).toBe(true); + expect(isJiraKey("CLDR-19912")).toBe(true); + expect(isJiraKey("ABC-1")).toBe(false); + expect(isJiraKey("ICU-0")).toBe(false); + }); + + it("gives GitHub-only fields to GitHub alone", () => { + for (const tracker of ["jira", "chromium", "bugzilla"] as const) { + for (const field of ["draft", "reviewDecision", "mergedAt"]) { + expect(SYNCED_FIELDS[tracker]).not.toContain(field); + } + } + expect(SYNCED_FIELDS.github).toContain("mergedAt"); + }); +}); + +const jiraIssue = (over: Record = {}) => + JSON.stringify({ + key: "ICU-23609", + fields: { + summary: "PersianCalendar::isLeapYear returns true for every year < 0", + status: { + name: "New", + statusCategory: { key: "new", name: "To Do" }, + }, + resolution: null, + resolutiondate: null, + fixVersions: [], + created: "2026-11-10T16:41:07.000-0800", + updated: "2026-11-10T17:02:44.118-0800", + comment: { + total: 3, + comments: [ + { author: { accountId: OURS }, body: "Adding the support thread." }, + { author: { accountId: OURS }, body: "More detail." }, + { author: { accountId: "557058:someone-else" }, body: "Thanks." }, + ], + }, + ...over, + }, + }); + +describe("Jira", () => { + it("searches by our reporter id in ICU and CLDR", () => { + const url = decodeURIComponent(jiraDiscoveryUrl()); + expect(url).toContain("/rest/api/3/search/jql?"); + expect(url).toContain(OURS); + expect(url).toContain("project in (ICU, CLDR)"); + expect(jiraIssueUrl("ICU-23609")).toContain("/rest/api/2/issue/ICU-23609?"); + }); + + it("lists the keys a search found and says whether the list is complete", () => { + const raw = JSON.stringify({ + issues: [{ key: "ICU-23609" }, { key: "CLDR-19912" }, { key: "XYZ-1" }], + isLast: true, + }); + expect(parseJiraDiscovery(raw)).toEqual({ + keys: ["ICU-23609", "CLDR-19912"], + complete: true, + }); + expect( + parseJiraDiscovery(JSON.stringify({ issues: [], isLast: false })) + .complete, + ).toBe(false); + }); + + it("refuses a search response without an issues list", () => { + expect(() => parseJiraDiscovery("{}")).toThrow(/no issues array/); + }); + + it("reads an open issue and counts only replies from others", () => { + expect(parseJira(jiraIssue(), "ICU-23609", days)).toEqual({ + title: "PersianCalendar::isLeapYear returns true for every year < 0", + url: "https://unicode-org.atlassian.net/browse/ICU-23609", + state: "open", + status: "New", + resolution: null, + fixVersions: [], + comments: 3, + maintainerComments: 1, + createdAt: "2026-11-11", + updatedAt: "2026-11-11", + closedAt: null, + }); + }); + + it("reads a resolved issue as closed, with its fix versions and day", () => { + const parsed = parseJira( + jiraIssue({ + status: { name: "Done", statusCategory: { key: "done" } }, + resolution: { name: "Fixed" }, + resolutiondate: "2026-11-20T09:00:00.000-0800", + fixVersions: [{ name: "79.1" }], + }), + "ICU-23609", + days, + ); + expect(parsed).toMatchObject({ + state: "closed", + status: "Done", + resolution: "Fixed", + fixVersions: ["79.1"], + closedAt: "2026-11-20", + }); + }); + + it("refuses a response for another issue or of another shape", () => { + expect(() => parseJira(jiraIssue(), "ICU-1", days)).toThrow(/unexpected/); + expect(() => parseJira("{}", "ICU-23609", days)).toThrow(/unexpected/); + }); +}); + +// A trimmed copy of the page JSON for an open issue: `)]}'`, then positional arrays, with the +// issue at response[0][1][22] as `[null, id, core, null, created, modified, resolved?, …]`. +const chromiumPage = (id: number, { resolved }: { resolved?: number } = {}) => { + const issue: unknown[] = [ + null, + id, + [1456516, 1, 2, 3, 3, "Intl.DateTimeFormat keeps the islamic calendar"], + null, + [1794679042, 304000000], + [1794679086, 219000000], + ]; + if (resolved !== undefined) issue[6] = [resolved]; + const slots: unknown[] = Array.from({ length: 22 }, () => null); + return `)]}'\n\n${JSON.stringify([["b.IssueFetchResponse", [...slots, issue]]])}`; +}; + +describe("Chromium", () => { + it("asks the tracker's own page endpoint", () => { + expect(chromiumIssueUrl(585635918)).toBe( + "https://issues.chromium.org/action/issues/585635918", + ); + }); + + it("reads an open issue, with comment counts it cannot know left null", () => { + expect(parseChromium(chromiumPage(585635918), 585635918, days)).toEqual({ + title: "Intl.DateTimeFormat keeps the islamic calendar", + url: "https://issues.chromium.org/issues/585635918", + state: "open", + comments: null, + maintainerComments: null, + createdAt: "2026-11-14", + updatedAt: "2026-11-14", + closedAt: null, + }); + }); + + it("reads an issue with a resolved time as closed", () => { + expect( + parseChromium( + chromiumPage(585635918, { resolved: 1794765442 }), + 585635918, + days, + ), + ).toMatchObject({ state: "closed", closedAt: "2026-11-15" }); + }); + + it("throws on a shape it does not recognise, so the caller keeps the last state", () => { + expect(() => parseChromium(")]}'\n[]", 585635918, days)).toThrow( + /unexpected response shape/, + ); + expect(() => parseChromium(chromiumPage(1), 585635918, days)).toThrow( + /unexpected response shape/, + ); + expect(() => + parseChromium("blocked", 585635918, days), + ).toThrow(); + }); +}); + +const bugzillaBug = (over: Record = {}) => + JSON.stringify({ + bugs: [ + { + id: 330688, + summary: "Temporal and Intl reject the time zone ids CST6CDT", + status: "NEW", + resolution: "", + is_open: true, + creator: "owner@example.test", + creation_time: "2026-11-09T20:15:00Z", + last_change_time: "2026-11-10T08:00:00Z", + ...over, + }, + ], + }); +const bugzillaComments = (creators: string[]) => + JSON.stringify({ + bugs: { + "330688": { + comments: creators.map((creator, count) => ({ count, creator })), + }, + }, + }); + +describe("Bugzilla", () => { + it("asks the host's REST API for the bug and its comments", () => { + expect(bugzillaBugUrl("bugs.webkit.org", 330688)).toContain( + "https://bugs.webkit.org/rest/bug/330688?include_fields=", + ); + expect(bugzillaCommentsUrl("bugzilla.mozilla.org", 2085525)).toBe( + "https://bugzilla.mozilla.org/rest/bug/2085525/comment", + ); + }); + + it("does not count the description, and counts replies by others as maintainers'", () => { + const parsed = parseBugzilla( + bugzillaBug(), + bugzillaComments([ + "owner@example.test", + "owner@example.test", + "triager@example.test", + ]), + "bugs.webkit.org", + 330688, + days, + ); + expect(parsed).toMatchObject({ + url: "https://bugs.webkit.org/show_bug.cgi?id=330688", + state: "open", + status: "NEW", + resolution: null, + comments: 2, + maintainerComments: 1, + createdAt: "2026-11-09", + updatedAt: "2026-11-10", + closedAt: null, + }); + }); + + it("reads a resolved bug as closed on the day it was resolved", () => { + const parsed = parseBugzilla( + bugzillaBug({ + status: "RESOLVED", + resolution: "FIXED", + is_open: false, + cf_last_resolved: "2026-11-12T10:00:00Z", + }), + bugzillaComments(["owner@example.test"]), + "bugs.webkit.org", + 330688, + days, + ); + expect(parsed).toMatchObject({ + state: "closed", + resolution: "FIXED", + closedAt: "2026-11-12", + comments: 0, + }); + }); + + it("refuses a response for another bug", () => { + expect(() => + parseBugzilla( + bugzillaBug({ id: 1 }), + bugzillaComments([]), + "bugs.webkit.org", + 330688, + days, + ), + ).toThrow(/unexpected response shape/); + }); +}); diff --git a/apps/dox/src/lib/bevel-border-widths.test.ts b/apps/dox/src/lib/bevel-border-widths.test.ts new file mode 100644 index 000000000..7c55f47be --- /dev/null +++ b/apps/dox/src/lib/bevel-border-widths.test.ts @@ -0,0 +1,305 @@ +/** + * Guard: a bevelled box never has border sides of different widths. + * + * Chromium paints `corner-shape: bevel` wrongly when the sides differ: the colour of the thick + * side runs along part of the opposite edge (a 3px series-coloured bottom bar showed as a + * partial line along the top). The house fix is one width on every side, the accent colour on + * the one side, and the extra thickness drawn as an inset `box-shadow` (with the same amount + * added to padding where the old border took layout room). + * + * A side of width 0 is ignored: it paints nothing, and a band with only side edges draws cleanly. + * + * The scan parses every stylesheet and every `"; + expect(findUnequalBevelBorders(css, "x.astro")).toHaveLength(1); + }); + + it("leaves an even border, and an uneven one with no bevel, alone", () => { + expect( + findUnequalBevelBorders( + ".a { border: 1px solid red; border-block-end-color: blue; corner-shape: bevel; }", + "x.css", + ), + ).toEqual([]); + expect( + findUnequalBevelBorders( + ".a { border: 1px solid red; border-block-end: 3px solid blue; }", + "x.css", + ), + ).toEqual([]); + }); + + it("has no bevelled rule with unequal border side widths", () => { + const report: string[] = []; + for (const file of files) { + const css = readFileSync(path.join(DOX, file), "utf8"); + for (const f of findUnequalBevelBorders(css, file)) { + report.push(`${file}:${f.line} ${f.selector} (${f.detail})`); + } + } + expect(report).toEqual([]); + }); +}); diff --git a/apps/dox/src/lib/canada-stored-times-mount.test.ts b/apps/dox/src/lib/canada-stored-times-mount.test.ts index 747ad1e9e..4d16e4bb3 100644 --- a/apps/dox/src/lib/canada-stored-times-mount.test.ts +++ b/apps/dox/src/lib/canada-stored-times-mount.test.ts @@ -180,6 +180,18 @@ describe("the stored-times section", () => { await expectNoAxeViolations(document.body); }); + it("opens the accepted formats by click and closes on Escape", async () => { + const { fetch } = fakeFetch(); + const { user } = await mounted(fetch); + const formats = screen.getByRole("button", { name: "Accepted formats" }); + await user.click(formats); + expect(formats).toHaveAttribute("aria-expanded", "true"); + expect(screen.getByText(/Up to \d+ lines and/)).toBeVisible(); + await user.keyboard("{Escape}"); + expect(formats).toHaveAttribute("aria-expanded", "false"); + expect(formats).toHaveFocus(); + }); + it("shows the zone picker only when a line has no zone", async () => { const { fetch } = fakeFetch(); const { user } = await mounted(fetch); diff --git a/apps/dox/src/lib/clock-change-stored.ts b/apps/dox/src/lib/clock-change-stored.ts index 45a024109..a862da3eb 100644 --- a/apps/dox/src/lib/clock-change-stored.ts +++ b/apps/dox/src/lib/clock-change-stored.ts @@ -290,6 +290,12 @@ export function wireStoredTimes( const none = w.part("stored-none"); const stale = w.part("stored-stale"); const summary = w.part("stored-summary"); + wireDisclosure( + w.part("stored-formats").closest("[data-disclosure]")!, + { + signal, + }, + ); const message = (text: string): void => { setHtml(results, html`

${text}

`); }; diff --git a/apps/dox/src/lib/import-meta-glob-guard.test.ts b/apps/dox/src/lib/import-meta-glob-guard.test.ts new file mode 100644 index 000000000..6cf19f14c --- /dev/null +++ b/apps/dox/src/lib/import-meta-glob-guard.test.ts @@ -0,0 +1,52 @@ +/** + * Guard: no module tests whether `import.meta.glob` exists. + * + * Vite rewrites each `import.meta.glob(…)` call at build, but leaves a test of the function + * itself, such as `typeof import.meta.glob === "function"`, in the built code, where it is false. + * A module guarded that way reads its optional file in dev and never in the built site: `/pulse/` + * said "Run history was not read in this build" on every deploy, though the file was there. + * + * A module that also runs in plain Node tests `import.meta.env` instead, which Vite replaces at + * build and plain Node leaves `undefined`. + */ +import { readdirSync, readFileSync, statSync } from "node:fs"; +import path from "node:path"; + +const SRC = path.resolve(import.meta.dirname, ".."); + +/** `typeof import.meta.glob`, or `import.meta.glob` tested as a value rather than called. */ +const PROBE = + /typeof\s+import\.meta\.glob\b|!\s*import\.meta\.glob\b|import\.meta\.glob\s*(?:[!=]==?|\?|&&|\|\|)/; + +function walk(dir: string): string[] { + return readdirSync(dir).flatMap((name) => { + const full = path.join(dir, name); + if (statSync(full).isDirectory()) return walk(full); + return /\.(?:[cm]?[jt]sx?|astro)$/.test(name) && !name.includes(".test.") + ? [full] + : []; + }); +} + +describe("import.meta.glob is never tested for existence", () => { + it("finds the probe it bans", () => { + expect(PROBE.test(`typeof import.meta.glob === "function"`)).toBe(true); + expect(PROBE.test(`import.meta.glob ? a : b`)).toBe(true); + expect(PROBE.test(`import.meta.glob("./x.json", { eager: true })`)).toBe( + false, + ); + }); + + it("has no module that tests it", () => { + const report = walk(SRC).flatMap((file) => + readFileSync(file, "utf8") + .split("\n") + .flatMap((line, i) => + PROBE.test(line) && !line.trimStart().startsWith("//") + ? [`${path.relative(SRC, file)}:${i + 1}`] + : [], + ), + ); + expect(report).toEqual([]); + }); +}); diff --git a/apps/dox/src/lib/mdx-jsx.ts b/apps/dox/src/lib/mdx-jsx.ts index 11ee4f0f7..62b69d020 100644 --- a/apps/dox/src/lib/mdx-jsx.ts +++ b/apps/dox/src/lib/mdx-jsx.ts @@ -9,6 +9,24 @@ * * Kept free of Astro globals so vitest can import it directly. */ +import { + areas as pulseAreas, + cardsIn as pulseCardsIn, + checkById as pulseCheck, + countWorkarounds, + filingsWaitedOn, + groupsClaimed, + runsFor as pulseRuns, + runsRead as pulseRunsRead, + type PulseLife, +} from "../data/pulse"; +import { filingRef as pulseFilingRef } from "../data/upstream-filings"; +import { + beats as pulseBeats, + beatsCaption, + cadenceText, + noSignal, +} from "./pulse-view"; import { BUNDLE_COLUMNS, bundleCells, bundleRows } from "./bundle-size"; import { KEY_POINTS } from "../data/canada-key-points"; import { keyPointsMarkdown } from "../data/clock-change-text"; @@ -28,12 +46,12 @@ import { compatGroups, groupLabel, groupWhatBreaks, - shortRef, stateLine, } from "../data/temporal-compat"; import { filedByUs, filedPrs, + filingRef, filings, handledInGmt, listings, @@ -341,9 +359,7 @@ function renderUpstreamDefects(): string { const rows = compatGroups.map((group) => { const sent = filings .filter((f) => f.gmtGuard && group.defects.includes(f.gmtGuard)) - .map( - (f) => `[${shortRef(f.repo, f.number)}](${f.contributionUrl ?? f.url})`, - ) + .map((f) => `[${filingRef(f)}](${f.contributionUrl ?? f.url})`) .join(", "); const { badge, count } = stateLine(group); // A guard row continues with why it is kept. The reason is free text, so it is escaped: a `|` @@ -468,7 +484,7 @@ function renderBehaviourMatrix(): string { * with it (CORE-8 review, #253). */ function renderUpstreamTracker(): string { - return `\n**So far we have sent ${filedByUs} reports and fixes to the Temporal projects, ${filedPrs} of them as ready-to-merge code changes${contributionClause}. ${coverageClause}: ${handledInGmt} through its own built-in fix, and ${unaffectingGmt} because the bug is in code GMT doesn't use.**\n`; + return `\n**So far we have sent ${filedByUs} reports and fixes to Temporal and the projects it builds on, ${filedPrs} of them as ready-to-merge code changes${contributionClause}. ${coverageClause}: ${handledInGmt} through its own built-in fix, and ${unaffectingGmt} because the bug is in code GMT doesn't use.**\n`; } /** @@ -488,6 +504,59 @@ function renderUpstreamListings(): string { ].join("\n"); } +/** A check's retirement, in words, for the text twin of `/pulse/`. */ +function pulseLife(life: PulseLife): string { + if (life.kind === "permanent") return `Stays. ${life.why}`; + if (life.kind === "condition") { + const waited = filingsWaitedOn(life).map( + (f) => `[${pulseFilingRef(f)}](${f.url})`, + ); + return `Retires when ${life.until}.${waited.length > 0 ? ` Waiting on ${waited.join(", ")}.` : ""}`; + } + const claimed = groupsClaimed(life); + if (claimed.length === 0) { + return "Retires with its workarounds, which are not in the compatibility snapshot yet."; + } + const c = countWorkarounds(claimed); + return `Retires with its workarounds: ${c.stillNeeded} still needed, ${c.removable} removable, ${c.guards} guards.`; +} + +/** + * `` as Markdown: each check's cadence, what it watches, its last results as words and + * what retires it. There is no next run: that is a live value the text cannot hold. + */ +function renderPulse(): string { + const out: string[] = [""]; + for (const area of pulseAreas) { + out.push(`## ${area.heading}`, "", area.blurb, ""); + for (const card of pulseCardsIn(area.id)) { + out.push(`### ${card.name}`, ""); + const cron = card.crons[0]; + if (cron === undefined) { + out.push("Runs with the Dox tests, never on a schedule.", ""); + } else { + out.push(card.crons.map(cadenceText).join(" and ") + ".", ""); + const runs = pulseRuns(card); + const lost = noSignal(runs, pulseRunsRead); + out.push( + lost !== null || runs === null || pulseRunsRead === null + ? `No signal: ${lost?.text ?? "Run history not read in this build"}.` + : beatsCaption(pulseBeats(cron, runs, pulseRunsRead)) + ".", + "", + ); + } + for (const id of card.checkIds) { + const check = pulseCheck(id); + out.push( + `- **${check.name}.** ${check.watches} ${check.finds} ${pulseLife(check.life)}`, + ); + } + out.push(""); + } + } + return out.join("\n"); +} + /** * Render the components that carry prose, and unwrap the ones that don't. * @@ -541,6 +610,7 @@ export function renderMdxComponents(body: string): string { out = replaceElements(out, "LibraryCompare", renderLibraryCompare); out = replaceElements(out, "UpstreamDefects", renderUpstreamDefects); out = replaceElements(out, "UpstreamTracker", renderUpstreamTracker); + out = replaceElements(out, "Pulse", renderPulse); out = replaceElements(out, "UpstreamListings", renderUpstreamListings); out = replaceElements(out, "BundleSize", renderBundleSize); out = replaceElements(out, "MigrationMap", renderMigrationMap); diff --git a/apps/dox/src/lib/native-engines.test.ts b/apps/dox/src/lib/native-engines.test.ts index f287c3dfb..9932b8b58 100644 --- a/apps/dox/src/lib/native-engines.test.ts +++ b/apps/dox/src/lib/native-engines.test.ts @@ -94,11 +94,15 @@ describe("the sidebar", () => { "install", "core-rules", "why-gmt", + "upstream", + "pulse", ]); }); - it("puts the engine page right after Helping fix Temporal", () => { + it("puts the engine page right after the bundle-size page", () => { const slugs = MIGRATE.map((p) => p.slug); - expect(slugs.indexOf("native-engines")).toBe(slugs.indexOf("upstream") + 1); + expect(slugs.indexOf("native-engines")).toBe( + slugs.indexOf("bundle-size") + 1, + ); }); }); diff --git a/apps/dox/src/lib/pulse-mount.test.ts b/apps/dox/src/lib/pulse-mount.test.ts new file mode 100644 index 000000000..42e70a513 --- /dev/null +++ b/apps/dox/src/lib/pulse-mount.test.ts @@ -0,0 +1,123 @@ +/** + * @vitest-environment jsdom + */ +import { afterEach, describe, expect, it } from "vitest"; +import { screen } from "@testing-library/dom"; +import userEvent from "@testing-library/user-event"; +import { disclosure, html, setHtml, raw } from "~/widgets/builders"; +import { mountPulse, type PulseLib } from "./pulse-mount"; + +const lib: PulseLib = { + getUtcNow: () => "2026-11-14T09:00:00Z", + parseCronExpression: (c) => (c === "bad" ? null : { c }), + cronRuns: (_e, _z, r) => [{ instant: r.after.replace("09:00", "21:00") }], + formatRelativeUtc: (v, _l, o) => (v === o.reference ? "now" : "in 12 hours"), + diffUtc: (a, b) => (a === "old" ? 9 : 0.1 + (b === "" ? 0 : 0)), +}; + +const aborts: AbortController[] = []; +afterEach(() => { + for (const a of aborts.splice(0)) a.abort(); + document.body.replaceChildren(); +}); + +function setup(read = "2026-11-14T06:00:00Z"): HTMLElement { + const root = document.createElement("div"); + setHtml( + root, + raw(`
+

Next run

+

read

+
+
strip
+ +
`), + ); + document.body.append(root); + return root; +} + +async function run(root: HTMLElement, now = lib.getUtcNow) { + const c = new AbortController(); + aborts.push(c); + await mountPulse(root, c.signal, { + lib: () => Promise.resolve({ ...lib, getUtcNow: now }), + }); + return c; +} + +describe("mountPulse", () => { + it("fills the next-run and read-ago slots", async () => { + await run(setup()); + expect(screen.getByLabelText("next run")).toHaveTextContent("in 12 hours"); + expect(screen.getByLabelText("read ago")).toHaveTextContent("in 12 hours"); + }); + + it("switches an old strip to NO SIGNAL with the days", async () => { + await run(setup("old")); + expect(screen.getByText(/NO SIGNAL/)).toBeVisible(); + expect(screen.getByText("Run history is 9 days old")).toBeInTheDocument(); + expect(screen.queryByText("strip")).not.toBeVisible(); + }); + + it("leaves a recent strip alone", async () => { + await run(setup()); + expect(screen.getByText("strip")).toBeVisible(); + expect(screen.getByText(/NO SIGNAL/)).not.toBeVisible(); + }); + + it("recomputes when the tab becomes visible, and stops after abort", async () => { + const root = setup(); + let at = "2026-11-14T09:00:00Z"; + const c = new AbortController(); + aborts.push(c); + await mountPulse(root, c.signal, { + now: () => at, + lib: () => Promise.resolve(lib), + }); + const slot = screen.getByLabelText("next run"); + expect(slot).toHaveTextContent("in 12 hours"); + at = "2026-11-14T21:00:00Z"; + // oxlint-disable-next-line dox-test/no-dispatch-event -- no user action changes visibility; the event is the input + document.dispatchEvent(new Event("visibilitychange")); + expect(slot).toHaveTextContent("now"); + c.abort(); + at = "2026-11-14T09:00:00Z"; + // oxlint-disable-next-line dox-test/no-dispatch-event -- no user action changes visibility; the event is the input + document.dispatchEvent(new Event("visibilitychange")); + expect(slot).toHaveTextContent("now"); + }); + + it("opens a workaround list by keyboard, before gmt loads", async () => { + const root = setup(); + setHtml( + root, + disclosure({ + id: "p-list", + label: "3 workarounds", + flow: true, + children: html`

AF

`, + }), + ); + const c = new AbortController(); + aborts.push(c); + void mountPulse(root, c.signal, { lib: () => new Promise(() => {}) }); + const user = userEvent.setup(); + const button = screen.getByRole("button", { name: "3 workarounds" }); + expect(screen.getByText("AF")).not.toBeVisible(); + button.focus(); + await user.keyboard("{Enter}"); + expect(button).toHaveAttribute("aria-expanded", "true"); + expect(screen.getByText("AF")).toBeVisible(); + await user.keyboard(" "); + expect(button).toHaveAttribute("aria-expanded", "false"); + }); + + it("does nothing when already aborted", async () => { + const c = new AbortController(); + c.abort(); + const root = setup(); + await mountPulse(root, c.signal, { lib: () => Promise.resolve(lib) }); + expect(screen.getByLabelText("next run")).toBeEmptyDOMElement(); + }); +}); diff --git a/apps/dox/src/lib/pulse-mount.ts b/apps/dox/src/lib/pulse-mount.ts new file mode 100644 index 000000000..36d4f78d9 --- /dev/null +++ b/apps/dox/src/lib/pulse-mount.ts @@ -0,0 +1,139 @@ +/** + * The wiring of `/pulse/`. The server renders every card; this wires each card's workaround + * list (a disclosure) at once, then fills three reserved slots after first paint and changes + * nothing else: each card's "Next run", the "read … ago" line, and a strip whose run history has + * grown too old (it switches to NO SIGNAL). + * + * Time is gmt's, loaded from subpaths after first paint, with a `deps.now` seam for tests. There + * is no timer and no polling: the slots are recomputed when the tab becomes visible again. + * Aborting the signal removes that listener. + */ +import { wireDisclosure } from "~/widgets/builders/disclosure"; +import { INERT_HANDLE, type WidgetHandle } from "./widget-mount"; + +/** A read older than this many days is too old to call "recent" (`pulse-view.ts`). */ +const STALE_AFTER_DAYS = 8; + +/** The gmt functions the mount uses, so a test supplies its own. */ +export interface PulseLib { + getUtcNow(): string; + parseCronExpression(cron: string): unknown; + cronRuns( + expr: never, + zone: string, + range: { after: string; count: number }, + mode: "crontabMatch", + ): readonly { instant: string }[]; + formatRelativeUtc( + value: string, + locale: string, + options: { reference: string }, + ): string; + diffUtc(from: string, to: string, unit: "days"): number; +} + +export interface PulseDeps { + /** The current instant. Defaults to gmt's `getUtcNow`. */ + now: () => string; + /** The gmt functions. Defaults to the subpath imports. */ + lib: () => Promise; +} + +async function loadLib(): Promise { + const [get, parse, calc, format, utcCalc] = await Promise.all([ + import("@northguild/gmt/utc/get"), + import("@northguild/gmt/recurrence/parse"), + import("@northguild/gmt/recurrence/calculate"), + import("@northguild/gmt/utc/format"), + import("@northguild/gmt/utc/calculate"), + ]); + return { + getUtcNow: get.getUtcNow, + parseCronExpression: parse.parseCronExpression, + cronRuns: calc.cronRuns as PulseLib["cronRuns"], + formatRelativeUtc: format.formatRelativeUtc, + diffUtc: utcCalc.diffUtc as PulseLib["diffUtc"], + }; +} + +export function mountPulse( + root: HTMLElement, + signal: AbortSignal, + deps: Partial = {}, +): Promise { + if (signal.aborted) return Promise.resolve(INERT_HANDLE); + const own = new AbortController(); + signal.addEventListener("abort", () => own.abort(), { once: true }); + const life = own.signal; + const doc = root.ownerDocument; + // The workaround lists open without gmt, so they work before (and if) it loads. + for (const el of root.querySelectorAll("[data-disclosure]")) + wireDisclosure(el, { signal: life }); + + return (deps.lib ?? loadLib)().then((lib) => { + if (life.aborted) return INERT_HANDLE; + const now = (): string => deps.now?.() ?? lib.getUtcNow(); + + const fill = (): void => { + if (life.aborted) return; + const at = now(); + for (const el of root.querySelectorAll( + "[data-pulse-next]", + )) { + const cron = el.getAttribute("data-pulse-next") ?? ""; + const expr = lib.parseCronExpression(cron); + if (expr === null) continue; + const next = lib.cronRuns( + expr as never, + "UTC", + { after: at, count: 1 }, + "crontabMatch", + )[0]; + if (next === undefined) continue; + el.textContent = lib.formatRelativeUtc(next.instant, "en", { + reference: at, + }); + el.closest("[data-pulse-card]")?.setAttribute("data-pulse-ready", ""); + } + for (const el of root.querySelectorAll( + "[data-pulse-read]", + )) { + const read = el.getAttribute("data-pulse-read") ?? ""; + const out = el.querySelector("[data-pulse-read-ago]"); + if (out !== null) + out.textContent = lib.formatRelativeUtc(read, "en", { + reference: at, + }); + } + for (const strip of root.querySelectorAll( + "[data-pulse-strip-read]", + )) { + const read = strip.getAttribute("data-pulse-strip-read") ?? ""; + const days = Math.floor(lib.diffUtc(read, at, "days")); + if (days <= STALE_AFTER_DAYS) continue; + strip.setAttribute("data-signal", "lost"); + const text = strip.querySelector( + "[data-pulse-signal-text]", + ); + if (text !== null) text.textContent = `Run history is ${days} days old`; + strip + .querySelector("[data-pulse-signal]") + ?.removeAttribute("hidden"); + strip + .querySelector("[data-pulse-beats]") + ?.setAttribute("hidden", ""); + } + }; + + const onVisible = (): void => { + if (doc.visibilityState === "visible") fill(); + }; + fill(); + doc.addEventListener("visibilitychange", onVisible, { signal: life }); + + return { + destroy: () => own.abort(), + getPermalinkState: () => null, + }; + }); +} diff --git a/apps/dox/src/lib/pulse-view.test.ts b/apps/dox/src/lib/pulse-view.test.ts new file mode 100644 index 000000000..d1ec27947 --- /dev/null +++ b/apps/dox/src/lib/pulse-view.test.ts @@ -0,0 +1,137 @@ +import { + beatLabel, + beats, + beatsCaption, + cadenceText, + nextRun, + noSignal, + resultOf, + type Run, +} from "./pulse-view"; + +const run = (startedAt: string, conclusion = "success"): Run => ({ + startedAt, + conclusion, + url: `https://example.test/${startedAt}`, +}); + +// A Saturday at 14:00 UTC; the Monday 06:17 runs before it are 2, 9, 16, 23 Nov ... counting back. +const READ = "2026-11-14T14:00:00Z"; + +describe("cadenceText", () => { + it.each([ + ["17 6 * * 1", "Every Monday at 06:17 UTC"], + ["23 3 * * 6", "Every Saturday at 03:23 UTC"], + ["43 6 * * 1", "Every Monday at 06:43 UTC"], + ["17 7 * * 1", "Every Monday at 07:17 UTC"], + ["41 4 * * 0", "Every Sunday at 04:41 UTC"], + ["0 6 * * *", "Every day at 06:00 UTC"], + ])("reads %s as %s", (cron, words) => { + expect(cadenceText(cron)).toBe(words); + }); + + it("throws on a schedule it cannot say in words", () => { + expect(() => cadenceText("*/5 * * * *")).toThrow(/cannot read/); + expect(() => cadenceText("0 6 * * 1,3")).toThrow(/cannot read/); + expect(() => cadenceText("0 6 1 * *")).toThrow(/cannot read/); + expect(() => cadenceText("nonsense")).toThrow(/cannot read/); + }); +}); + +describe("nextRun", () => { + it("is the first schedule time after the given instant", () => { + expect(nextRun("17 6 * * 1", READ)).toBe("2026-11-16T06:17:00Z"); + }); +}); + +describe("beats", () => { + it("answers each expected time with the run that started after it", () => { + const list = beats( + "17 6 * * 1", + [run("2026-11-09T06:30:00Z"), run("2026-11-02T06:25:00Z", "failure")], + READ, + ); + expect(list).toHaveLength(8); + expect(list.at(-1)).toMatchObject({ + expected: "2026-11-09T06:17:00Z", + result: "passed", + }); + expect(list.at(-2)).toMatchObject({ + expected: "2026-11-02T06:17:00Z", + result: "failed", + }); + }); + + it("marks a week with no run as No run", () => { + const list = beats("17 6 * * 1", [run("2026-11-09T06:30:00Z")], READ); + expect(list.at(-2)?.result).toBe("none"); + expect(list.at(-2)?.run).toBeNull(); + expect(beatLabel(list.at(-2)!)).toBe("No run, expected 2 November"); + }); + + it("counts a 13:00 start as the 06:17 run, because GitHub may start a run hours late", () => { + const list = beats("17 6 * * 1", [run("2026-11-09T13:00:00Z")], READ); + expect(list.at(-1)?.result).toBe("passed"); + }); + + it("does not give one run to the next week's expected time", () => { + const list = beats("17 6 * * 1", [run("2026-11-02T06:20:00Z")], READ); + expect(list.at(-2)?.result).toBe("passed"); + expect(list.at(-1)?.result).toBe("none"); + }); + + it("calls a cancelled run Did not finish", () => { + const list = beats( + "17 6 * * 1", + [run("2026-11-09T06:20:00Z", "cancelled")], + READ, + ); + expect(list.at(-1)?.result).toBe("unfinished"); + expect(beatsCaption(list)).toBe( + "Last 8 · latest Did not finish, 9 November", + ); + }); + + it("with no runs at all, every beat is No run", () => { + expect( + beats("17 6 * * 1", [], READ).every((b) => b.result === "none"), + ).toBe(true); + }); +}); + +describe("resultOf", () => { + it.each([ + ["success", "passed"], + ["failure", "failed"], + ["startup_failure", "failed"], + ["cancelled", "unfinished"], + ["timed_out", "unfinished"], + ["skipped", "unfinished"], + ])("%s is %s", (conclusion, result) => { + expect(resultOf(conclusion)).toBe(result); + }); +}); + +describe("noSignal", () => { + it("is no signal when no history was read", () => { + expect(noSignal(null, null)?.text).toBe( + "Run history not read in this build", + ); + expect(noSignal(null, READ)?.reason).toBe("not-read"); + }); + + it("trusts a read of a few days", () => { + expect(noSignal([], READ, "2026-11-20T14:00:00Z")).toBeNull(); + }); + + it("does not trust a 9-day-old read", () => { + expect(noSignal([], READ, "2026-11-23T14:00:00Z")).toEqual({ + reason: "stale", + text: "Run history is 9 days old", + }); + }); + + it("at build, with no now, only a missing history is no signal", () => { + expect(noSignal([], READ)).toBeNull(); + }); +}); diff --git a/apps/dox/src/lib/pulse-view.ts b/apps/dox/src/lib/pulse-view.ts new file mode 100644 index 000000000..3f2114879 --- /dev/null +++ b/apps/dox/src/lib/pulse-view.ts @@ -0,0 +1,223 @@ +/** + * The rules `/pulse/` applies to a schedule and its run history: how a cron reads in words, which + * of the last expected runs happened and how each ended, and when the history is too old to trust. + * + * Time is GMT's (`parseCronExpression`, `cronRuns`, `formatUtc`), never `Date`. Nothing here reads + * a clock: every function takes the instants it needs, so the same inputs give the same page at + * build and the same answer in a test. + */ +// The package root, not a subpath: see `upstream-summary.ts` for the dev-server alias trap. +import { + addUtc, + cronRuns, + diffUtc, + formatUtc, + isBeforeUtc, + parseCronExpression, +} from "@northguild/gmt"; + +/** How many expected runs a strip shows. */ +export const BEAT_COUNT = 8; + +/** A read older than this many days is not trusted: the strip says NO SIGNAL. */ +export const STALE_AFTER_DAYS = 8; + +/** How far back the expected runs are searched; wide enough for eight of any daily or weekly run. */ +const LOOKBACK_DAYS = 70; + +/** Any instant before the first run; the weekday of the next run after it names the weekday. */ +const ANCHOR = "2000-01-01T00:00:00Z"; + +const pad2 = (n: number): string => String(n).padStart(2, "0"); + +/** + * "Every Monday at 06:17 UTC" or "Every day at 06:00 UTC". Accepts a fixed minute and hour with the + * day of the week `*` or one weekday, and throws on anything else, so a new kind of schedule is a + * decision here and not a silently wrong sentence. + */ +export function cadenceText(cron: string): string { + const e = parseCronExpression(cron); + if ( + e === null || + e.minute.values.length !== 1 || + e.hour.values.length !== 1 || + !e.dayOfMonth.star || + !e.month.star + ) { + throw new Error(`pulse: cannot read the schedule "${cron}" in words`); + } + const time = `${pad2(e.hour.values[0]!)}:${pad2(e.minute.values[0]!)} UTC`; + if (e.dayOfWeek.star && e.dayOfWeek.values.length === 7) { + return `Every day at ${time}`; + } + if (e.dayOfWeek.values.length !== 1) { + throw new Error(`pulse: cannot read the schedule "${cron}" in words`); + } + const next = cronRuns( + e, + "UTC", + { after: ANCHOR, count: 1 }, + "crontabMatch", + )[0]; + if (next === undefined) { + throw new Error(`pulse: the schedule "${cron}" never runs`); + } + const weekday = formatUtc(next.instant, "en", { + timeZone: "UTC", + weekday: "long", + }); + return `Every ${weekday} at ${time}`; +} + +/** The first run after `after`, as an instant, or `null` when the schedule never fires again. */ +export function nextRun(cron: string, after: string): string | null { + const e = parseCronExpression(cron); + if (e === null) return null; + return ( + cronRuns(e, "UTC", { after, count: 1 }, "crontabMatch")[0]?.instant ?? null + ); +} + +/** A run as the run history file holds it. */ +export interface Run { + startedAt: string; + conclusion: string; + url: string; +} + +export type BeatResult = "passed" | "failed" | "unfinished" | "none"; + +/** The words a result is called, and how it is drawn. Never a colour word. */ +export const RESULT_WORD: Readonly> = { + passed: "Passed", + failed: "Failed", + unfinished: "Did not finish", + none: "No run", +}; + +export const RESULT_PATTERN: Readonly< + Record +> = { + passed: "solid", + failed: "cross", + unfinished: "outline", + none: "dotted", +}; + +export interface Beat { + /** The time the schedule said the run would start (UTC). */ + expected: string; + result: BeatResult; + /** The run that answered it, when there was one. */ + run: Run | null; +} + +/** How GitHub's conclusion reads as one of the four results. */ +export function resultOf(conclusion: string): BeatResult { + switch (conclusion) { + case "success": + case "neutral": + return "passed"; + case "failure": + case "startup_failure": + return "failed"; + default: + return "unfinished"; + } +} + +/** + * The last `BEAT_COUNT` expected runs up to `runsRead`, oldest first, each with the run that + * answered it. A run answers the expected time it started after and before the next one: GitHub may + * start a scheduled run hours late, so a 13:00 start answers a 06:17 schedule. An expected time + * with no run is `none`; a second run in the same gap is ignored in favour of the newest. + * `runs` is newest first, as the history file holds it. + */ +export function beats( + cron: string, + runs: readonly Run[], + runsRead: string, +): Beat[] { + const e = parseCronExpression(cron); + if (e === null) throw new Error(`pulse: cannot read the schedule "${cron}"`); + const expected = cronRuns( + e, + "UTC", + { start: addUtc(runsRead, { days: -LOOKBACK_DAYS }), end: runsRead }, + "crontabMatch", + ) + .map((r) => r.instant) + .slice(-BEAT_COUNT); + return expected.map((time, i) => { + const next = expected[i + 1]; + const answer = + runs.find( + (r) => + !isBeforeUtc(r.startedAt, time) && + (next === undefined || isBeforeUtc(r.startedAt, next)), + ) ?? null; + return { + expected: time, + result: answer === null ? "none" : resultOf(answer.conclusion), + run: answer, + }; + }); +} + +/** Why a strip cannot be read, in words, or `null` when it can. */ +export type NoSignal = + | { reason: "not-read"; text: string } + | { reason: "stale"; text: string }; + +/** + * Whether the strip can be shown. `runs: null` (no history was read in this build) is always no + * signal. With `now` given, a read more than `STALE_AFTER_DAYS` old is too: the page was built long + * ago and what it says about "recent" runs is not recent. Build time passes no `now`. + */ +export function noSignal( + runs: readonly Run[] | null, + runsRead: string | null, + now?: string, +): NoSignal | null { + if (runs === null || runsRead === null) { + return { reason: "not-read", text: "Run history not read in this build" }; + } + if (now !== undefined) { + const gap = diffUtc(runsRead, now, "days"); + const days = typeof gap === "number" ? Math.floor(gap) : 0; + if (days > STALE_AFTER_DAYS) { + return { reason: "stale", text: `Run history is ${days} days old` }; + } + } + return null; +} + +/** "9 November": the day of a run, in UTC. */ +export const dayOf = (instant: string): string => + formatUtc(instant, "en-GB", { + timeZone: "UTC", + day: "numeric", + month: "long", + }); + +/** "06:17 UTC". */ +export const timeOf = (instant: string): string => + `${formatUtc(instant, "en-GB", { timeZone: "UTC", hour: "2-digit", minute: "2-digit", hourCycle: "h23" })} UTC`; + +/** "14 November 2026, 06:02 UTC". */ +export const stampOf = (instant: string): string => + `${formatUtc(instant, "en-GB", { timeZone: "UTC", day: "numeric", month: "long", year: "numeric" })}, ${timeOf(instant)}`; + +/** What a beat says to a screen reader and in the text twin. */ +export const beatLabel = (b: Beat): string => + b.result === "none" + ? `${RESULT_WORD.none}, expected ${dayOf(b.expected)}` + : `${RESULT_WORD[b.result]}, ${dayOf(b.expected)}`; + +/** "Last 8 · latest Passed, 9 November". */ +export function beatsCaption(list: readonly Beat[]): string { + const latest = list.at(-1); + return latest === undefined + ? "No scheduled run is due yet" + : `Last ${list.length} · latest ${beatLabel(latest)}`; +} diff --git a/apps/dox/src/lib/runtime-tz-canary.test.ts b/apps/dox/src/lib/runtime-tz-canary.test.ts index 7d2974617..b35c1bcd5 100644 --- a/apps/dox/src/lib/runtime-tz-canary.test.ts +++ b/apps/dox/src/lib/runtime-tz-canary.test.ts @@ -2,6 +2,8 @@ import { getTimeZoneOffset } from "@northguild/gmt/zoned/get"; import { PROBE_INSTANT, PROBE_ZONES } from "./canada-clock-change"; import { MOROCCO_FACTS, MOROCCO_PROBE } from "./morocco-clock-change"; +// Pulse check: runtime-tz + /** * A canary for the machine running the tests. The page states what tzdb 2026e gives for each * probe zone; a runtime with older time zone data gives another offset, and the Canada checker's diff --git a/apps/dox/src/lib/section-order.ts b/apps/dox/src/lib/section-order.ts index 346e56b0f..cc972b41b 100644 --- a/apps/dox/src/lib/section-order.ts +++ b/apps/dox/src/lib/section-order.ts @@ -7,11 +7,13 @@ * `migrate/index`. A `label` is the short text the sidebar shows; the page title stays in full. */ -/** What a reader needs first, in reading order. */ +/** What a reader needs first, in reading order, then the proof that GMT is kept up: the fixes it sends back to Temporal, and the checks that keep running. */ export const START_HERE = [ { slug: "install" }, { slug: "core-rules" }, { slug: "why-gmt" }, + { slug: "upstream" }, + { slug: "pulse" }, ] as const satisfies readonly { slug: string; label?: string }[]; /** The Migrate group: the overview, the pages that weigh GMT against the others, the weekly engine runs, one page per library, then the behaviour matrix. */ @@ -19,7 +21,6 @@ export const MIGRATE = [ { slug: "migrate", label: "Overview" }, { slug: "compare", label: "GMT vs. the others" }, { slug: "bundle-size" }, - { slug: "upstream" }, { slug: "native-engines" }, { slug: "migrate/date-fns", label: "From date-fns" }, { slug: "migrate/luxon", label: "From Luxon" }, diff --git a/apps/dox/src/lib/top-level-pages.test.ts b/apps/dox/src/lib/top-level-pages.test.ts index 865ccacef..b2c8c84b9 100644 --- a/apps/dox/src/lib/top-level-pages.test.ts +++ b/apps/dox/src/lib/top-level-pages.test.ts @@ -27,6 +27,7 @@ describe("topLevelPages", () => { "../content/docs/guides/intro.mdx": "g", "../content/docs/alpha.mdx": "a", "../content/docs/upstream.mdx": "u", + "../content/docs/pulse.mdx": "p", "../content/docs/index.mdx": "x", "../content/docs/why-gmt.mdx": "w", "../content/docs/core-rules.mdx": "c", @@ -36,6 +37,8 @@ describe("topLevelPages", () => { { slug: "install", source: "i" }, { slug: "core-rules", source: "c" }, { slug: "why-gmt", source: "w" }, + { slug: "upstream", source: "u" }, + { slug: "pulse", source: "p" }, { slug: "alpha", source: "a" }, { slug: "zebra", source: "z" }, ]); @@ -45,7 +48,7 @@ describe("topLevelPages", () => { const raw = { "../content/docs/compare.mdx": "c", "../content/docs/bundle-size.mdx": "b", - "../content/docs/upstream.mdx": "u", + "../content/docs/native-engines.mdx": "n", "../content/docs/install.mdx": "i", }; const slugs = topLevelPages(raw).map((p) => p.slug); @@ -113,17 +116,16 @@ describe("migratePages", () => { ).toEqual([{ slug: "migrate/index", source: "index" }]); }); - it("names twelve pages, the overview keyed as a folder index", () => { - expect(MIGRATE_ORDER).toHaveLength(12); + it("names eleven pages, the overview keyed as a folder index", () => { + expect(MIGRATE_ORDER).toHaveLength(11); expect(MIGRATE_ORDER[0]).toBe("migrate/index"); }); - it("lists compare, bundle-size, upstream and native-engines after the overview", () => { - expect(MIGRATE_ORDER.slice(0, 5)).toEqual([ + it("lists compare, bundle-size and native-engines after the overview", () => { + expect(MIGRATE_ORDER.slice(0, 4)).toEqual([ "migrate/index", "compare", "bundle-size", - "upstream", "native-engines", ]); }); @@ -142,6 +144,8 @@ describe("the sidebar config", () => { "install", "core-rules", "why-gmt", + "upstream", + "pulse", ]) { expect(config, `the config writes out ${slug}`).not.toContain( `slug: "${slug}"`, diff --git a/apps/dox/src/lib/upstream-badges.test.ts b/apps/dox/src/lib/upstream-badges.test.ts index 9f5fafdda..164e9db2a 100644 --- a/apps/dox/src/lib/upstream-badges.test.ts +++ b/apps/dox/src/lib/upstream-badges.test.ts @@ -7,6 +7,7 @@ import { stateNote, workBadge, } from "./upstream-badges"; +import type { UpstreamFiling } from "../data/upstream-filings"; describe("stateBadge", () => { it.each` @@ -20,7 +21,16 @@ describe("stateBadge", () => { `( "$kind $state draft=$draft merged=$mergedAt is $text", ({ kind, state, draft, mergedAt, text, tone, icon }) => { - expect(stateBadge({ kind, state, draft, mergedAt })).toEqual({ + expect( + stateBadge({ + tracker: "github", + kind, + state, + draft, + mergedAt, + reviewDecision: null, + }), + ).toEqual({ text, tone, icon, @@ -31,6 +41,7 @@ describe("stateBadge", () => { describe("a listing that is an issue", () => { const issue = { + tracker: "github", kind: "issue", state: "open", draft: false, @@ -50,10 +61,48 @@ describe("a listing that is an issue", () => { describe("stateNote", () => { it("keeps what 'Merged' alone loses", () => { - expect(stateNote({ mergedAt: "2026-05-01" })).toBe( + const github = (mergedAt: string | null) => + ({ tracker: "github", mergedAt }) as UpstreamFiling; + expect(stateNote(github("2026-05-01"))).toBe( "Merged, not yet in a published release", ); - expect(stateNote({ mergedAt: null })).toBeNull(); + expect(stateNote(github(null))).toBeNull(); + }); + + it("gives a Jira or Bugzilla filing the tracker's own words", () => { + const jira = { + tracker: "jira", + status: "Done", + resolution: "Fixed", + fixVersions: ["79.1"], + } as unknown as UpstreamFiling; + expect(stateNote(jira)).toBe( + "Status Done, resolution Fixed, fix version 79.1", + ); + const open = { + tracker: "bugzilla", + status: "UNCONFIRMED", + resolution: null, + } as UpstreamFiling; + expect(stateNote(open)).toBe("Status UNCONFIRMED"); + }); + + it("has nothing to add for a Chromium filing", () => { + expect(stateNote({ tracker: "chromium" } as UpstreamFiling)).toBeNull(); + }); +}); + +describe("a filing on another tracker", () => { + it("reads as an issue with no review chip", () => { + for (const tracker of ["jira", "chromium", "bugzilla"] as const) { + const f = { tracker, state: "closed", closedAt: "2026-11-20" } as const; + expect(stateBadge(f)).toEqual({ + text: "Closed", + tone: "purple", + icon: "issue-closed", + }); + expect(reviewBadge(f)).toBeNull(); + } }); }); @@ -72,9 +121,16 @@ describe("reviewBadge", () => { `( "$kind $state draft=$draft $reviewDecision shows $text", ({ kind, state, draft, reviewDecision, text }) => { - expect(reviewBadge({ kind, state, draft, reviewDecision })?.text).toBe( - text, - ); + expect( + reviewBadge({ + tracker: "github", + kind, + state, + draft, + mergedAt: null, + reviewDecision, + })?.text, + ).toBe(text); }, ); }); diff --git a/apps/dox/src/lib/upstream-badges.ts b/apps/dox/src/lib/upstream-badges.ts index 80a67f29e..0408379e7 100644 --- a/apps/dox/src/lib/upstream-badges.ts +++ b/apps/dox/src/lib/upstream-badges.ts @@ -10,7 +10,7 @@ * `upstream-badges.test.ts`. */ import { stateLine, type CompatGroup } from "~/data/temporal-compat"; -import type { UpstreamFiling } from "~/data/upstream-filings"; +import type { GitHubFiling, UpstreamFiling } from "~/data/upstream-filings"; import { badge } from "../widgets/builders/badge"; import type { SafeHtml } from "../widgets/builders/html"; import type { OcticonName } from "./octicons"; @@ -25,22 +25,28 @@ export interface BadgeSpec { dim?: boolean; } -type StateFields = Pick< - UpstreamFiling, - "kind" | "state" | "draft" | "mergedAt" ->; -type ReviewFields = Pick< - UpstreamFiling, - "kind" | "state" | "draft" | "reviewDecision" +type GitHubFields = Pick< + GitHubFiling, + "tracker" | "kind" | "state" | "draft" | "mergedAt" | "reviewDecision" >; +/** The state fields every tracker has; the GitHub ones are read only when `tracker` is `"github"`. */ +type StateFields = + | GitHubFields + | Pick< + Exclude, + "tracker" | "state" | "closedAt" + >; +type ReviewFields = StateFields; type InGmtFields = Pick< UpstreamFiling, - "gmtGuard" | "gmtNote" | "kind" | "pairsWith" ->; + "gmtGuard" | "gmtNote" | "pairsWith" +> & { + kind?: "pr" | "issue"; +}; /** Where a filing stands on GitHub, with the icon GitHub draws for that state. */ export function stateBadge(f: StateFields): BadgeSpec & { icon: OcticonName } { - if (f.kind === "issue") { + if (f.tracker !== "github" || f.kind === "issue") { return f.state === "closed" ? { text: "Closed", tone: "purple", icon: "issue-closed" } : { text: "Open", tone: "spring", icon: "issue-opened" }; @@ -59,8 +65,22 @@ export function stateBadge(f: StateFields): BadgeSpec & { icon: OcticonName } { * The part of a filing's state that GitHub's one word loses. A merged pull request is not yet * in a published polyfill release, which is the fact that decides whether a user has the fix. */ -export function stateNote(f: Pick): string | null { - return f.mergedAt ? "Merged, not yet in a published release" : null; +export function stateNote(f: UpstreamFiling): string | null { + switch (f.tracker) { + case "github": + return f.mergedAt ? "Merged, not yet in a published release" : null; + case "jira": + case "bugzilla": { + const resolution = f.resolution ? `, resolution ${f.resolution}` : ""; + const fixed = + f.tracker === "jira" && f.fixVersions.length > 0 + ? `, fix version ${f.fixVersions.join(", ")}` + : ""; + return `Status ${f.status}${resolution}${fixed}`; + } + case "chromium": + return null; + } } /** @@ -69,6 +89,8 @@ export function stateNote(f: Pick): string | null { * GitHub leaves `reviewDecision` empty until somebody reviews. */ export function reviewBadge(f: ReviewFields): BadgeSpec | null { + // Reviews are a GitHub pull request's: no other tracker has a review verdict. + if (f.tracker !== "github") return null; if (f.reviewDecision === "APPROVED") { return { text: "Approved", tone: "spring", icon: "check", dim: true }; } diff --git a/apps/dox/src/widgets/builders/badge.module.css b/apps/dox/src/widgets/builders/badge.module.css index 6e0f7bd0f..5f82836df 100644 --- a/apps/dox/src/widgets/builders/badge.module.css +++ b/apps/dox/src/widgets/builders/badge.module.css @@ -7,7 +7,7 @@ box-sizing: border-box; padding: 0.125rem 0.5rem; border: 1px solid var(--gmt-badge-edge); - border-radius: var(--gmt-radius-sm); + border-radius: var(--gmt-bevel-sm); corner-shape: bevel; background: var(--gmt-surface-widget); color: var(--gmt-badge-ink); @@ -76,22 +76,25 @@ } } -/* A solid state pill, as GitHub draws Open, Merged and Closed: the tone fills the whole badge and - the page's void colour is the ink, so the word and icon stay readable on it. The fill is the - tone's `-ink` token, which is dark enough on the light page and light enough on the dark one for - the void ink to hold 4.5:1 either way. It is larger than the outline chips around it. */ +/* A solid state chip, as GitHub draws Open, Merged and Closed: the same bevelled box as the + outline chips beside it, filled with its tone, with the page's void colour as the ink. A + cyan chip is the selected one, filled ice as `--gmt-selected-fill`. Each fill is the tone's + `-ink` token, dark enough on the light page and light enough on the dark one for the void ink + to hold 4.5:1 either way. */ .fill { - --gmt-badge-solid: var(--gmt-ice-dim); + --gmt-badge-solid: var(--gmt-ice); - padding: 0.25rem 0.75rem; - border-color: transparent; - border-radius: 999px; - corner-shape: round; + border-color: var(--gmt-badge-solid); background: var(--gmt-badge-solid); color: var(--gmt-void); - font-size: var(--gmt-text-sm); font-weight: 600; + &[data-tone="cyan"] { + --gmt-badge-solid: var(--gmt-selected-fill); + + color: var(--gmt-selected-ink); + } + &[data-tone="spring"] { --gmt-badge-solid: var(--gmt-spring-ink); } @@ -99,4 +102,8 @@ &[data-tone="purple"] { --gmt-badge-solid: var(--gmt-purple-ink); } + + &[data-tone="danger"] { + --gmt-badge-solid: var(--gmt-danger-ink); + } } diff --git a/apps/dox/src/widgets/builders/disclosure.module.css b/apps/dox/src/widgets/builders/disclosure.module.css index 23d13b4a7..dfd2dd7d2 100644 --- a/apps/dox/src/widgets/builders/disclosure.module.css +++ b/apps/dox/src/widgets/builders/disclosure.module.css @@ -66,6 +66,18 @@ } } +/* A flow disclosure: the panel is a block under the button, as wide as the root, and takes its + room in the page. */ +.root[data-flow="true"] { + display: block; + + & > .panel { + position: static; + inline-size: auto; + max-inline-size: none; + } +} + @media (forced-colors: active) { .button, .panel { diff --git a/apps/dox/src/widgets/builders/disclosure.test.ts b/apps/dox/src/widgets/builders/disclosure.test.ts index a30b03bca..37dbf3f92 100644 --- a/apps/dox/src/widgets/builders/disclosure.test.ts +++ b/apps/dox/src/widgets/builders/disclosure.test.ts @@ -89,6 +89,33 @@ describe("disclosure", () => { }); }); +describe("disclosure flow", () => { + it("opens and shuts the same way, and keeps its name and panel", async () => { + const abort = new AbortController(); + const r = renderHtml( + disclosure({ + id: "f", + label: "31 workarounds", + flow: true, + children: html`

The list

`, + }), + ); + try { + wireDisclosure(r.first(), { + signal: abort.signal, + }); + const button = screen.getByRole("button", { name: "31 workarounds" }); + expect(button).toHaveAttribute("aria-expanded", "false"); + await userEvent.click(button); + expect(button).toHaveAttribute("aria-expanded", "true"); + expect(screen.getByText("The list")).toBeVisible(); + await expectNoAxeViolations(r.host); + } finally { + abort.abort(); + } + }); +}); + describe("disclosure panel width", () => { /* jsdom has no layout, so the rule that keeps the panel inside a clipping drawer is read from the stylesheet; the browser run measures the rectangle. */ diff --git a/apps/dox/src/widgets/builders/disclosure.ts b/apps/dox/src/widgets/builders/disclosure.ts index 1f226aa7b..186d9f14e 100644 --- a/apps/dox/src/widgets/builders/disclosure.ts +++ b/apps/dox/src/widgets/builders/disclosure.ts @@ -32,11 +32,16 @@ export interface DisclosureOptions extends GateOption { className?: string; /** Extra class on the button, from the caller's own module. */ buttonClassName?: string; + /** + * Open the panel in the page's flow, below the button and as wide as its container, so a long + * list pushes what follows down instead of floating over it. The behaviour is the same. + */ + flow?: boolean; } export function disclosure(o: DisclosureOptions): SafeHtml { const open = o.open === true; - return html`
{column}