Skip to content

ci: keep the recorded Node test times fresh from main on a schedule, and never fail a pull request on them - #11900

Merged
josephfarina merged 6 commits into
mainfrom
ci/node-record-refresh
Nov 15, 2026
Merged

josephfarina merged 6 commits into
mainfrom
ci/node-record-refresh

Conversation

@josephfarina

@josephfarina josephfarina commented Nov 15, 2026 •

Copy link
Copy Markdown
Contributor

Maintainer impact

A merge that adds Node test files leaves scripts/vitest-node-durations.json behind. A per-pull-request guard in scripts/vitest-shard-sequencer.test.mjs failed when fewer than nine in ten of the Node project's test files had a recorded time, so the first Node leg failed on every open pull request until someone re-recorded by hand. The leg planner books an unrecorded file at the ninetieth percentile (about 10 s), so a missing entry never drops a file, but a missing or low entry costs leg balance and can make a leg run long until the next refresh. A contributor cannot produce a CI-comparable time, so the record is kept fresh from main's own runs instead of by pull requests.

Intended invariant

AST-030 FR22: Node legs split by recorded time; which files run never depends on the times. This adds: no pull-request check fails on the record's coverage or on a recorded time's drift, and after each successful full unit run of main (with a six-hour backstop) a job re-records when coverage drops below nine in ten or a recorded file drifted past its entry.

Change

  • scripts/vitest-shard-sequencer.test.mjs: the "nine in ten" coverage guard leaves the per-pull-request path. Every other sequencer test stays.
  • .github/scripts/node-time-drift.mjs: a drifted or unrecorded changed test file is a ::notice instead of an ::error, and the step always exits 0. It reports the same facts and the same suggested entry.
  • New .github/workflows/node-record-refresh.yml:
    • Triggers: workflow_run on the Main workflow (completed, branches: [main]), every six hours as a backstop, and by hand. A completed run counts only when it succeeded, was a full unit run (a dispatch; a push runs no Node leg), and is this repository's main.
    • It reads that run's log (the backstop reads main's latest successful full unit run) and runs .github/scripts/node-record-refresh.mjs check. A refresh is due when fewer than MIN_RECORDED_SHARE = 0.9 of the Node test files have a recorded time, or a recorded file ran far past its entry by the pull-request drift rule (drifted from node-time-drift.mjs, with DRIFT_MARGIN_S = MARGIN_S), each leg's slowdown taken out separately.
    • When due, it regenerates the record from that run with the existing node scripts/vitest-shard-sequencer.mjs record, force-pushes one commit to the fixed branch ci/node-durations-refresh as github-actions[bot] (skipped when the branch already carries that record), and opens the pull request or edits the open one. It never pushes to main.
    • Only this job has contents: write and pull-requests: write, plus actions: read to read main's run logs.
  • AST-030 FR22 states both triggers and that no pull-request check fails on the record's coverage or on a recorded time's drift; a verification row covers the refresh.

Evidence

  • Failure before the change: on main the record times 1240 of 1382 Node test files (89.7%), so the guard failed the first Node leg on every pull request.
  • Success after the change: no pull-request test reads the bar. Dry run of the check on a recent full unit run of main: refresh due for both reasons (89.7% coverage; packages/cli/api/theme-edit/theme-stress.test.mjs ran 103.1 s against its recorded 36.6 s). record on that log times 1262 files and brings the record over the bar.
  • Product/runtime behavior verified unchanged: CI-only change; no package code.
  • CI impact (for a change to workflows, actions or CI scripts): pull-request jobs keep their runner classes and job-minutes per update; the drift step in test-node and swizzle-proof does the same work and only changes its annotation level. New job on standard ubuntu-latest after each successful full unit run of main (about hourly) plus four backstop runs a day: about three minutes each (setup, one log read, one check), about one more on a run that regenerates the record; about 80 runner-minutes a day, under 0.06 average concurrent jobs. Time to green for pull requests improves when the record is stale, since the first Node leg no longer fails.

Scope

Components: none

  • No intended public API, product behavior, visual direction, or policy change.
  • Product changes discovered during the work were removed or split.
  • Public text and artifacts contain no internal Meta context.

A pull request opened or pushed with the workflow token starts no workflow, so CI on the refresh pull request starts when someone with write access reopens it.

Testing

  • pnpm exec vitest run --project node .github/scripts/: 143 files passed, 3 skipped (3390 tests).
  • pnpm exec vitest run --project node scripts/vitest-shard-sequencer.test.mjs: 23 passed.
  • node-record-refresh.test.mjs: workflow shape (the workflow_run trigger on Main, completed, main; success, full-unit-run and same-repository conditions; the backstop schedule; permissions; the fixed branch, force-push only to it, skipped when unchanged); the coverage bar at and below nine in ten; a drift-triggered refresh with full coverage (one recorded file far past its entry → refresh, and the pull request names it); no refresh within the drift rule; a leg that ran slow throughout; only Node-leg lines read; record over a fixture Main log lifting the share over the bar; one pull request across repeated runs; every Node file in exactly one leg with an empty record; the pull-request drift step exiting 0 for an unrecorded slow file and for a recorded file far past its entry.
  • node-time-drift.test.mjs: notice mode (notices, never errors; exit 0; exit 2 only for missing arguments).
  • Pre-commit coverage: the Lint workflow's lint job runs pnpm check:repo (step "Check repository guardrails", which includes check:cldr-weekdays and check:knowledge) and Prettier over the changed files (step "Check formatting of changed files"). The latest commit also passed the full local hook.
  • Prettier clean; ESLint ignores these paths by config; pnpm check:knowledge passes.

Writing rubric results

R1 narration: none; the new FR22 sentences state what the system does in the present tense. A draft sentence ("A missing or low recorded time never fails a pull-request check") overstated the rule, since a missing time still counts at the ninetieth percentile toward the over-eight-legs failure; it now reads "No pull-request check fails on the record's coverage or on a recorded time's drift", and the verification row's failure column matches.
R2 research: none in the record.
R3 evidence: the verification row names a test file and the states it covers, not a change.
R4 rejected alternatives: none added.
R5 change references: none.
R6 open questions: none added.
R7 project status: none.

@vercel

vercel Bot commented Nov 15, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
astryx Ready Ready Preview Nov 15, 2026 5:55pm UTC

Request Review

@astracat-bot

astracat-bot Bot commented Nov 15, 2026 •

Copy link
Copy Markdown
Contributor

AI review status for this pull request.

Review status Updated
🟢 Reviewed (for maintainers only) Nov 15, 2026, 6:10 PM UTC

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Meta Open Source bot. label Nov 15, 2026
@github-actions github-actions Bot added the needs:spec-owner-review Current knowledge records await owner approval label Nov 15, 2026
@josephfarina

Copy link
Copy Markdown
Contributor Author

/approve-spec e0cbd3b

@github-actions github-actions Bot removed the needs:spec-owner-review Current knowledge records await owner approval label Nov 15, 2026

@astracat-bot astracat-bot Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Requesting changes: the scheduled refresh matches the FR22 text an engineering owner approved for this head, but two points need fixing.

  • node-time-drift.mjs:199 and :254 no longer fail a pull request that makes a recorded test file much slower than its entry, yet the approved FR22 sentence exempts only a missing recorded time and the scheduled job re-records only when fewer than nine in ten files have a time (node-record-refresh.mjs:49), so a slowed file's low entry can land and stay and later legs planned from it can run past the fifteen-minute budget that FR22 and DEC-17 require; keep ::error and exit 1 for drifted changed files with notices only for unrecorded ones, or amend FR22 to cover drift and make the refresh also fire on drifted entries.
  • The claim that a stale record never breaks a leg's time budget (node-record-refresh.mjs:7-8, and node-time-drift.mjs:8-9, node-record-refresh.yml:5 and the description) does not hold, because the planner books an unrecorded file at about 10 s while vitest-node-legs.mjs:34-37 notes one that ran 290 s, and this head's slowest Node leg ended about 85 s before its watchdog; say instead that a stale record costs leg balance and can make a leg run long until it is refreshed.

Non-blocking: each scheduled run force-pushes a new commit to the refresh branch while main's record stays stale, even when the record already matches the open pull request, so a CI run started by reopening that pull request goes stale every six hours; comparing with the branch before pushing avoids that.

Claims and files checked

Review mode: full; reason: no-earlier-review

  • Claim: a per-pull-request guard failed when fewer than nine in ten Node test files had a recorded time. Verified: the removed test in scripts/vitest-shard-sequencer.test.mjs.
  • Claim: main's record times 1,240 of 1,381 Node test files (89.7%). Verified: the repository's own file list and record at the base give 1,240 of 1,381.
  • Claim: the leg planner books an unrecorded file at the ninetieth percentile. Verified: scripts/vitest-node-legs.mjs:34-38 and :85-90.
  • Claim: a stale record costs leg balance only, never correctness or the time budget. The correctness part is verified (every file runs in exactly one leg). The time-budget part is false; see above.
  • Claim: only the coverage guard leaves the pull-request path, and every other sequencer test stays. Verified: the diff removes one test and one import.
  • Claim: the new workflow runs every six hours and by hand, on main only, with write scopes only in its one job. Verified: node-record-refresh.yml:18-42.
  • Claim: below the bar it re-records from main's latest successful full unit run, force-pushes one commit to a fixed branch as the Actions bot, opens or edits one pull request, and never pushes to main. Verified: node-record-refresh.yml:52-84 and node-record-refresh.mjs:103-136.
  • Claim: the drift step reports the same facts and suggested entry, as notices, and always exits 0. Verified: node-time-drift.mjs:180-254.
  • Claim: re-recording a recent full run of main times 1,262 files. Not verified: that run's logs were not available to this review.
  • Claim: pull-request jobs keep their runner classes and job-minutes. Verified: the ci.yml edits are comments only.
  • Claim: the new job costs about ten to fifteen runner-minutes a day. Not measured.
  • Claim: CI on the refresh pull request starts when someone with write access reopens it. Verified: ci.yml:21 runs on reopened.
  • Claim: the listed test runs and formatting and knowledge checks pass. Verified: all seven Node legs and Lint passed at this head, including the sequencer test (23 tests), node-record-refresh.test.mjs (14) and node-time-drift.test.mjs (23).
  • .github/scripts/node-record-refresh.mjs: finding (lines 7-8; the trigger at line 49 ignores drift).
  • .github/scripts/node-record-refresh.test.mjs: clear.
  • .github/scripts/node-time-drift.mjs: finding (lines 199 and 254).
  • .github/scripts/node-time-drift.test.mjs: clear.
  • .github/workflows/ci.yml: clear.
  • .github/workflows/node-record-refresh.yml: non-blocking note (push churn) and the claim at line 5.
  • docs/specs/AST-030/spec.md: clear; an engineering owner approved it at this head.
  • scripts/vitest-shard-sequencer.test.mjs: clear.

Automated review (maintainer link)

Comment thread .github/scripts/node-time-drift.mjs Resolved
Comment thread .github/scripts/node-record-refresh.mjs Resolved
@github-actions

github-actions Bot commented Nov 15, 2026 •

Copy link
Copy Markdown
Contributor

PR Analysis Report

🔎 Preview · 3eb8e40

Storybook · Sandbox · built from this PR's head

Package size: no published package changed; no new dependencies.

Not run on this PR: add ci:run-visual for Visual, ci:run-a11y for Accessibility, ci:run-rtl for RTL.

CI impact: 0 job-min per update · pool 0% · standard runners · 1 other workflow changed (not measured) · 4 CI action or script files changed (not measured)
Before After Change
Job-minutes per PR update 173.3 173.3 0
Runner pool, runner-minutes a day 69,333 69,333 0 (0%)
Average concurrent jobs 48.1 48.1 0
Time to green (median → this run) — 9.8 min —
Runs a day 400 400 0

Other workflows: node-record-refresh.yml added: runs on workflow_run, schedule (41 */6 * * *), workflow_dispatch; standard runners; its minutes are not measured here

Not measured (the jobs that use these keep their recent minutes above): .github/scripts/node-record-refresh.mjs, .github/scripts/node-record-refresh.test.mjs, .github/scripts/node-time-drift.mjs, .github/scripts/node-time-drift.test.mjs.

Assumptions: before is each job's average over the last 20 pull-request runs; after keeps that for unchanged jobs and uses this run's minutes for added or changed ones, weighted by how often each changed job ran in those runs; runs a day averages the seven whole days before today; time to green compares this run with the median of those runs that ran the same jobs.


Generated by PR Enrichment workflow | View full report

@josephfarina

Copy link
Copy Markdown
Contributor Author

Thanks, all three points are addressed in 74a155c:

  1. Drift fails again. node-time-drift.mjs keeps ::error and exit 1 for a recorded changed file that runs far past its entry, as before. Only a changed file with no recorded time gets a ::notice, which never fails. That matches the FR22 sentence: only a missing recorded time is exempt. Tests cover both exits.
  2. The budget claim is corrected. The script headers, the workflow header, the refresh pull request body and this description now say that a missing entry never drops a file, but it costs leg balance and can make a leg run long until the record is refreshed.
  3. No push when nothing changed. The scheduled job fetches the refresh branch first. If the branch already carries the regenerated record, the job does not push. It still opens the pull request if none is open. The workflow-shape test checks this.

The FR22 text is unchanged.

…main, on low coverage or drift; drift stays a notice on pull requests
@github-actions github-actions Bot added the needs:spec-owner-review Current knowledge records await owner approval label Nov 15, 2026
@josephfarina

Copy link
Copy Markdown
Contributor Author

/approve-spec 3eb8e40

@github-actions github-actions Bot removed the needs:spec-owner-review Current knowledge records await owner approval label Nov 15, 2026

@astracat-bot astracat-bot Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved pending CI: CI has not finished on this head yet.

The scheduled refresh, the notice-only drift step and the removed coverage guard match FR22 as an engineering owner approved it for this head, and both earlier points are fixed: the refresh now also fires when a recorded file drifts in main's run, and the comments no longer say a stale record cannot break a leg's time budget.

Non-blocking:

  • While a refresh is due, each successful full unit run of main (about hourly) commits a new record to ci/node-durations-refresh, because each new run's times differ from the branch's, so a CI run started by reopening the bot pull request goes stale within the hour; checking the branch's record first and skipping the commit when it is already fresh would keep that run current.
  • The checkout keeps the job's write-scoped token in .git/config while setup runs pnpm install with lifecycle scripts; persist-credentials: false, with the token given only to the fetch and push, keeps it out of the install.
Claims and files checked

Review mode: full; reason: spec-record

Claims:

  • The per-pull-request guard failed when fewer than nine in ten Node test files had a recorded time: verified, the removed test in scripts/vitest-shard-sequencer.test.mjs.
  • main's record timed 1,240 of 1,382 Node test files (89.7%): verified at the merge base with this head's file list; main has since been re-recorded by hand to 99.1%.
  • The planner books an unrecorded file at the ninetieth percentile, so a missing entry never drops a file but costs leg balance and can make a leg run long: verified, scripts/vitest-node-legs.mjs:34-38 and :85-90, and the "exactly one leg with no record" test.
  • Only the coverage guard leaves the pull-request path and every other sequencer test stays: verified, one test and one import removed; 23 sequencer tests pass.
  • A drifted or unrecorded changed test file is a notice, the step always exits 0, and it reports the same facts and suggested entry: verified, node-time-drift.mjs:198-212 and :255, and the notice-mode tests.
  • The job runs after a completed Main run on main, every six hours and by hand, and counts only a successful, dispatched, same-repository run of main: verified, node-record-refresh.yml:19-28 and :41-47.
  • A refresh is due under nine in ten coverage or when a recorded file drifts by the pull-request rule with the same margin, each leg's slowdown taken out separately: verified, node-record-refresh.mjs:35-41 and :77-110.
  • When due, it regenerates with the existing recorder, force-pushes one commit to the fixed branch as the Actions bot, skips the push when the branch already carries that record, opens or edits one pull request, and never pushes to main: verified, node-record-refresh.yml:84-111 and openOrRefresh; the skip fires only on a re-read of the same run (see the note above).
  • Only this job has contents: write and pull-requests: write, plus actions: read: verified, node-record-refresh.yml:30 and :50-54.
  • FR22 states both triggers and that no pull-request check fails on the record's coverage or a recorded time's drift, with a verification row: verified, docs/specs/AST-030/spec.md:532-540 and the new FR22 row.
  • A dry run on a recent full unit run found both reasons and record timed 1,262 files: not checked, since that run's log was not available to this review; the merge base does record theme-stress.test.mjs at 36.6 s.
  • Pull-request jobs keep their runner classes and minutes, and the drift step does the same work: verified, the ci.yml edits are comments only; the new job's minutes a day are an estimate.
  • A pull request opened or pushed with the workflow token starts no workflow, so CI on it starts on reopen: verified, ci.yml:21 runs on reopened.
  • The .github/scripts and sequencer test runs, Prettier, the ESLint ignore and the knowledge check: verified, 146 files under .github/scripts, the refresh, drift and sequencer suites pass (22, 23, 23), Prettier is clean, eslint.config.js:209 ignores .github/scripts/**, and the knowledge check passes.

Files:

  • .github/scripts/node-record-refresh.mjs: clear.
  • .github/scripts/node-record-refresh.test.mjs: clear.
  • .github/scripts/node-time-drift.mjs: clear.
  • .github/scripts/node-time-drift.test.mjs: clear.
  • .github/workflows/ci.yml: clear; the comments match the notice-only step.
  • .github/workflows/node-record-refresh.yml: two non-blocking notes above.
  • docs/specs/AST-030/spec.md: clear; the FR22 text and row match the code.
  • scripts/vitest-shard-sequencer.test.mjs: clear.

Automated review (maintainer link)

run: |
# A branch that already carries this record keeps its commit, so a
# CI run on the open pull request stays current.
if git fetch --quiet origin refs/heads/ci/node-durations-refresh &&

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Non-blocking: while a refresh is due, check compares each run with main's record, so every successful full unit run (about hourly) regenerates, and record gives each measured file that run's time, so this comparison with the branch matches only when the six-hour backstop re-reads a run already recorded. A CI run started by reopening the bot pull request then goes stale at the next Main run. Running check against the branch's record too, and skipping the commit when that record is already fresh with no drift against this run, would keep it current.

contents: write
pull-requests: write
steps:
- uses: actions/checkout@v7

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Non-blocking: this checkout keeps the job's contents: write token in .git/config while ./.github/actions/setup runs pnpm install --frozen-lockfile with lifecycle scripts. persist-credentials: false, with the token given only to the fetch and push below, keeps it out of the install.

@josephfarina
josephfarina merged commit 82246df into main Nov 15, 2026
196 of 204 checks passed
@github-actions
github-actions Bot deleted the ci/node-record-refresh branch November 16, 2026 06:04

This branch was successfully deployed

1 active deployment
Preview — 3eb8e404 Deployed Nov 15, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Meta Open Source bot.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant