Test memo: record the Vitest setup/environment modules instead of hashing their 179-file static closure
Maintainers usually reply within 1 day
@atomantic is already working on this.
Since Oct 19, 2026.
Assessment
This issue has not been assessed yet.
Description
Problem
Every test memo key (scripts/lib/testMemo.js, WORKSPACE_BASE_INPUTS) includes the static closure of the workspace Vitest config, its setup files and the custom environment (server/test/mediaRegistryEnvironment.js). That closure is 179 files for the server workspace: the environment and vitest.setup.js pull in server/lib/mockPathsDataRoot.js, server/lib/fileWriteQueue.js, server/test/admissionSetup.js and what those import. A change anywhere in it invalidates all 3,095 server keys, although the setup phase loads only part of that graph at runtime. Vitest's recordDependencies depfile records globalSetup dependencies but not environment or setupFiles dependencies, so the memo has nothing better than the static walk today.
Measured on the last 12 merges on main (PR #12295): 11 merges invalidate 7–828 recorded keys each; the environment closure is the remaining whole-suite trigger.
Chosen approach
Record what the setup phase actually loads, the same way test files are recorded, and use that for the recorded key:
- Register a small custom reporter in both workspace configs (
scripts/vitestSetupDependencies.js). InonTestRunEndit reads each project's module graph (project.vite.environments.__vitest__.moduleGraph) for thesetupFilesandenvironmententries, collects the transitive imported modules that are local source files, and writes<cacheDir>/vitest/setup-dependencies.json(root-relative paths, same shape asdependencies.jsonmodules). scripts/lib/testMemoRunner.jsreads that file next todependencies.json;createTestMemoAnalyzer.workspaceBaseaccepts arecordedmodule list and, when present, the recorded key uses it in place of the static base closure. The floor key keeps the static walk.scripts/lib/testMemo.test.jspins that a change to a module the setup phase never loaded leaves the recorded key unchanged, and that a change to one it did load moves it.
Acceptance
- The server base input set for the recorded key drops from 179 files to the modules the setup phase loads (expected well under 60).
- A change to a leaf under
server/lib/that neither the setup phase nor a given test loads leaves that test's recorded key unchanged. - Floor-key behavior is unchanged.
- Dominant language
- JavaScript
- Stars
- 38
- Forks
- 32
- Avg merge
- 33m
- Merged PRs (30d)
- 988
Getting set up
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from atomantic/PortOS
-
Share the test-Chrome resolver with the client browser tests and ci-warm-test-chrome.shPossibly taken @atomantic claimed this today. Opencode-quality effort:medium in-progress model:light planner:sonnet-5-5 tests
atomantic/PortOS#12315 · 1 assignee ·
Maintainers usually reply within 1 day
-
backup.db.test restore older database schema fails in local pregate DB suitePossibly taken @atomantic claimed this today. Openbug in-progress
atomantic/PortOS#12306 · 1 comment · 1 assignee ·
Maintainers usually reply within 1 day
-
Follow-up fixes for pregate attestation (post-merge review of #12299)Possibly taken @atomantic claimed this today. Openbug effort:medium in-progress model:medium planner:sonnet-5-5
atomantic/PortOS#12302 · 1 assignee ·
Maintainers usually reply within 1 day
-
Test memo: key non-literal native require() sites and importlib imports instead of failing closedPossibly taken @atomantic claimed this today. Openeffort:medium enhancement in-progress model:medium plan tests
atomantic/PortOS#12300 · 1 assignee ·
Maintainers usually reply within 1 day
-
Diagnose composition browser Page.enable timeout during document renderingPossibly taken @atomantic claimed this today. Openarea:media bug effort:high in-progress model:heavy plan planner:gpt-6-1-sol tests
atomantic/PortOS#12294 · 1 assignee ·
Maintainers usually reply within 1 day
All issues in atomantic/PortOS
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
Maintainers usually reply within 1 day
-
[BUG] npm pkg delete removes the first array item for a nonexistent propertyPossibly taken A pull request linked to this issue is open or already merged. Open
Difficulty 2/5 1-3 hours Newbie friendliness 83/100
Maintainers usually reply within 2 days
-
feedback simulation workshop
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
githubnext/gh-aw-workshop#4755 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
videojs/video.js#9537 · 1 comment ·
Maintainers usually reply within 1 day
-
fix
Difficulty 1/5 Under an hour Newbie friendliness 72/100
idean3885/claude-ops-agent#728 ·
Maintainers usually reply within 1 day