Skip to content

fix(cli): the transpile cache names copies for their source text and trims one subfolder per write, so it stays small and no run reads all of it - #12385

Merged
josephfarina merged 3 commits into
mainfrom
fix/transpile-cache-bounded
Nov 18, 2026
Merged

josephfarina merged 3 commits into
mainfrom
fix/transpile-cache-bounded

Conversation

@josephfarina

Copy link
Copy Markdown
Contributor

Maintainer impact

The CLI keeps the code jiti transpiles from TypeScript (integration manifests, configs, codemods, TypeScript doc topics, theme sources) in a per-user cache folder. jiti named each copy for the source's path, and the folder's size check could not remove a copy used in the last two days, because jiti checks that a copy exists and then reads it with no fallback. So on a machine that runs many projects or test suites in fresh folders, every run added copies of the same files and none went away. When the check finally ran, it read the whole folder. One machine reached over a million copies, and theme build and the theme editor then hung for minutes in that check.

Intended invariant

  • Every command prints exactly what it printed: the same output, error output, exit code and JSON. The one exception is doctor's text about this cache: the kept-catalog row's last sentence, and a new info row where an older CLI's folder exists.
  • A kept copy is used only when it holds exactly what the transform would make now. Its name is a hash of the source text and every setting the transform reads. jiti writes a file's own path into the code for import.meta.url, .dirname and .filename, and import.meta cannot be written with escapes, so text that contains "meta" also names the copy for its file.
  • No run reads the whole cache: a write trims only its own subfolder.

Change

  • foundation/fs/jiti-cache.mjs: the CLI's jiti loaders turn jiti's disk cache off and pass a transform that keeps copies in astryx/transpiled.
    • Copies go in 256 subfolders by hash. Each is written whole under another name and renamed into place. A read that fails, or a copy that is not whole, is a miss, and the copy is made again.
    • After a write, only that subfolder is trimmed to its share of the size limit the cache shares with the kept catalogs, the copies made longest ago first, never the new one.
    • A copy larger than that share is used for the run but not kept. A failed transpile, or settings that are not plain data (such as a Babel plugin function), are never kept.
    • jiti still runs each module under its real file name, so errors name that file, whichever folder made the copy.
  • The single folder that earlier CLIs used (astryx/jiti) is never read, listed or written. Older installed CLIs keep their own behavior there; this change cannot reach them. doctor finds that folder with one stat and names it with the command that removes it.
  • doctor's kept-catalog row describes the new trimming.
  • AST-081's list of per-user folders describes the cache as it now works.

Evidence

  • Path-free code: jiti's transform gave byte-identical code for the same source under two different paths for every TypeScript file in the CLI, Core and the bundled themes whose text has no "meta" (3,581 files; 10,068 transforms across the async, JSX and TypeScript settings; 0 differ). Among texts that contain "meta", 160 transforms differed: the files that use import.meta, which get a copy per file.

  • Timing: the packed CLI before and after this change, both projects in sibling folders of the same path length, warm runs interleaved after a warm-up (11 each), first runs on a fresh cache folder (41 each); median difference after − before, 95% confidence interval:

case before after difference
warm battery, integration with a TypeScript manifest (every command) 296 ms weighted 295 ms −0.4%; every case's interval holds 0
warm battery, integration with a JavaScript manifest 247 ms weighted 247 ms +0.2%; every case's interval holds 0
warm battery, Core-only project 214 ms weighted 213 ms −0.5%; every case's interval holds 0
first component Button, TypeScript manifest (transpiles and keeps 7 copies) 1248 ms 1247 ms +15 ms [−23, +91]
first component Button, JavaScript manifest 852 ms 842 ms +3 ms [−11, +11]
first theme build of a theme with local TypeScript modules 1429 ms 1453 ms +20 ms [−53, +70]
first component Button, Core-only project 329 ms 349 ms +12 ms [−9, +23]

At the size limit, a subfolder holds a few hundred copies, so the trim after a write reads a few hundred entries.

  • Product/runtime behavior verified unchanged: every battery case's output, error output and exit code matched before and after, except doctor's kept-catalog row, whose last sentence now describes the trimming.
  • Failure before the change: a cache folder that grows without bound under fresh-folder runs, and a check that reads all of it (described above).
  • CI impact: none (no workflow, action or CI script changes).

Scope

Components: cli (transpile cache, doctor), docs (AST-081)

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

Writing rubric results

R1 narration: one sentence names the folder earlier releases used; it states what this CLI does with it (never reads or lists it, and doctor names it), kept as a boundary.
R2 research: none in the record; the path check is in this description.
R3 evidence: none cited in the changed text.
R4 rejected alternatives: none.
R5 change references: none.
R6 open questions: none.
R7 project status: none.

Testing

  • foundation/fs/jiti-cache.test.mjs (19 rows):
    • the user's own 0700 folder, or nothing on disk, with JITI_FS_CACHE and systems without user ids left to jiti;
    • one copy for the same file in three folders; a copy per file for text with "meta", each module reading its own path;
    • an error thrown from a copy another folder made names its own file;
    • a copy cut short or removed is made again; a copy larger than its share is used but not kept; settings that are not plain data and failed transpiles are not kept;
    • the name follows every setting;
    • trimming removes the copies made longest ago first, never the new one, never another file, a link or a folder, and reads only its own subfolder;
    • the old folder is never read, listed or written;
    • six processes writing and trimming one subfolder at once always get whole copies.
  • api/doctor/old-transpile-cache.test.mjs: the row is absent without the folder; it names the folder under XDG_CACHE_HOME, in macOS's cache folder and in Windows' local app data, with the POSIX or PowerShell command; it finds the folder with one stat and never lists it.
  • The packed kept-catalog tests read the copies in their subfolders and doctor's new sentence.
  • The CLI suites for the cache, doctor, doc loading, kept catalogs, integrations, theme build, startup imports and lazy dependencies pass (117 files, 2,103 tests), as do the type checks and the command-structure check.

@vercel

vercel Bot commented Nov 17, 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 18, 2026 6:42am UTC

Request Review

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Meta Open Source bot. label Nov 17, 2026
@astracat-bot

astracat-bot Bot commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor

AI review status for this pull request.

Review status Updated
🟢 Reviewed (for maintainers only) Nov 18, 2026, 6:49 AM UTC

@github-actions github-actions Bot added the needs:spec-owner-review Current knowledge records await owner approval label Nov 17, 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.

Approval waits on an engineering owner deciding the rewritten spec:AST-081 FR7 transpile-cache bullet: copies named by source text and settings (per file when the text contains meta), 256 subfolders trimmed by creation time, oversize copies not kept, and the old astryx/jiti folder left in place. An engineering owner records that decision by commenting /approve-spec <full head SHA> on this pull request, and the author may do so as an engineering owner. These changes are needed either way:

  • packages/cli/clients/cli/commands/build-theme.transpile-cache.test.mjs still looks for copies in astryx/jiti with theme in their name, so all three of its cases fail with this change (they pass on main); point it at astryx/transpiled and list the copies recursively.
  • The changeset says the same file in many folders shares one copy, but text containing meta gets a copy per file (jiti-cache.mjs:179), so add "unless its text contains meta".
  • trimSubfolder (jiti-cache.mjs:286) re-implements evictOldest from cache-eviction.mjs (list, keep regular files, sort by mtime, unlink the oldest), so call or extend the shared helper and keep only the .tmp sweep here.
Claims and files checked

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

Claims:

  • jiti names each copy for its source's path: verified (jiti 2.7.0 cache naming hashes the file name).
  • The old size check could not remove a copy used in the last two days because jiti checks that a copy exists and then reads it with no fallback: verified (base two-day protection; jiti's exists-then-read).
  • When the old check ran it read the whole folder: verified (evictOldest lists every entry).
  • One machine reached over a million copies and theme commands hung for minutes: not checkable from the repository; consistent with the base code.
  • Every command prints what it printed except doctor's cache text: verified by reading; a kept copy returns jiti's own code (jiti-cache.test.mjs "reads a kept copy instead of transpiling").
  • A copy's name hashes the source text and every setting the transform reads: verified (copyName; jiti 2.7.0's transform reads the path only for import.meta and .tsx).
  • Text containing "meta" also names the copy for its file: verified (jiti-cache.mjs:179; test).
  • No run reads the whole cache; a write trims only its own subfolder: verified (test "reads only the subfolder it writes").
  • Copies sit in 256 subfolders, are written under another name and renamed, and a failed read or partial copy is a miss: verified (keepCopy, readCopy; tests).
  • The trim keeps each subfolder within its share, oldest made first, never the new copy: verified (test).
  • Oversize copies are used but not kept; failed transpiles and non-plain settings are never kept: verified (tests).
  • Errors name the real file: verified (test).
  • The old folder is never read, listed or written, and doctor finds it with one stat: verified (tests).
  • doctor's kept-catalog row describes the trimming: verified (packed records test).
  • The record describes the cache as it now works: verified as text; it awaits owner approval.
  • Code is path-free for files without "meta" (3,581 files): consistent; a sample of 968 repository TypeScript files showed no path difference without "meta".
  • Timing table: not re-measured.
  • No CI workflow, action or script changes: verified.
  • The new cache tests (19) and doctor tests (6) pass: verified.
  • The packed kept-catalog tests read the subfolder copies and doctor's new sentence: verified, they pass.
  • The CLI suites, theme build included, pass: false; build-theme.transpile-cache.test.mjs fails 3 of 3.
  • Changeset: the cache stays small and fast however many folders load the same files: verified (bounded trim).
  • Changeset: the same file in many folders shares one copy: false for text containing "meta".
  • Changeset: each new copy trims only its own subfolder, so no run reads the whole cache: verified.
  • Changeset: fresh-folder runs could fill the old folder and a theme command spent minutes reading it: consistent with the base code.
  • Changeset: doctor names the old folder and the command that removes it: verified (test; doctor run in a project).

Files:

  • .changeset/transpile-cache-bounded.md: finding (sharing overstated).
  • docs/specs/AST-081-global-mode/spec.md: awaits engineering-owner approval of the FR7 rewrite.
  • packages/cli/api/doctor/doctor.mjs: clear.
  • packages/cli/api/doctor/old-transpile-cache.test.mjs: clear.
  • packages/cli/foundation/doc-compiler/doc-loads.test.mjs: clear.
  • packages/cli/foundation/fs/cache-eviction.mjs: clear.
  • packages/cli/foundation/fs/gather-cache.mjs: clear.
  • packages/cli/foundation/fs/jiti-cache.mjs: finding (trimSubfolder duplicates evictOldest).
  • packages/cli/foundation/fs/jiti-cache.test.mjs: clear.
  • packages/cli/test/packed-gather-cache.fresh.test.mjs: clear.
  • packages/cli/test/packed-gather-cache.records.test.mjs: clear.
  • packages/cli/clients/cli/commands/build-theme.transpile-cache.test.mjs (not changed): finding (fails at this head).

Automated review (maintainer link)

Comment thread .changeset/transpile-cache-bounded.md Resolved
@github-actions

github-actions Bot commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor

PR Analysis Report

🔎 Preview · 02053a9

Storybook · Sandbox · built from this PR's head

Package size: measured; main has no measurement of the merge base to compare yet.

API changes: unknown (base surface unavailable): richtext, theme-butter, theme-chocolate, theme-gothic, theme-matcha, theme-neutral, theme-stone, theme-y2k

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


Generated by PR Enrichment workflow | View full report

@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.

Approval waits on an engineering owner deciding the rewritten spec:AST-081 FR7 transpile-cache clause: copies named by source text and settings (per file when the text contains meta), 256 subfolders trimmed by creation time, oversize copies not kept, and the old astryx/jiti folder left in place with project doctor naming it. An engineering owner records that decision by commenting /approve-spec <full head SHA> on this pull request, and the author may do so as an engineering owner. The three earlier findings are fixed at this head, and these changes are needed either way:

  • Miss: removeFolderCommand (packages/cli/api/doctor/doctor.mjs:2798) re-implements quoteCommandArgument from foundation/env/package-manager.mjs and already misses the typographic quotes PowerShell also treats as quote marks, so build both commands with quoteCommandArgument(dir, platform).
  • Miss: isPlain (packages/cli/foundation/fs/jiti-cache.mjs:197) re-implements the plain-data check in foundation/fs/exact-codec.mjs without its cycle and -0 guards, so name copies with that module's isPlain and exactText and delete the local copy.

The changeset could also say "Project doctor", as FR7 now does.

Claims and files checked

Review mode: full; reason: spec-record

Claims:

  • jiti named each copy for its source's path: verified (jiti 2.7.0's cache naming hashes the file name).
  • The old size check could not remove a copy used in the last two days, because jiti checks that a copy exists and then reads it with no fallback: verified (the base's two-day protection; jiti's exists-then-read).
  • When the old check ran, it read the whole folder: verified (the base trim lists every entry).
  • One machine reached over a million copies and theme commands hung for minutes: not checkable from the repository; consistent with the base code.
  • Every command prints what it printed, except doctor's cache text: verified by reading and tests; a kept copy returns jiti's own code (jiti-cache.test.mjs "reads a kept copy instead of transpiling").
  • A copy's name hashes the source text and every setting the transform reads: verified (copyName; jiti 2.7.0's transform reads the path only for import.meta, .tsx and errors).
  • Text containing "meta" also names the copy for its file: verified (jiti-cache.mjs:182; test).
  • No run reads the whole cache, and a write trims only its own subfolder: verified (test "reads only the subfolder it writes").
  • Copies sit in 256 subfolders, are written under another name and renamed, and a failed read or partial copy is a miss: verified (keepCopy, readCopy; tests).
  • The trim keeps each subfolder within its share, oldest made first, never the new copy: verified (trimSubfolder through evictOldest with keep; tests).
  • Oversize copies are used but not kept, and failed transpiles and non-plain settings are never kept: verified (tests).
  • Errors name the real file: verified (test).
  • The old folder is never read, listed or written: verified (test).
  • doctor finds the old folder with one stat and names it with the command that removes it: verified (test; doctor run in a project).
  • doctor's kept-catalog row describes the trimming: verified (packed kept-catalog records test).
  • The record describes the cache as it now works: verified as text; it awaits owner approval.
  • Code is path-free for files without "meta": consistent; 1,500 of the 3,581 files gave identical code under two paths in every transform without "meta".
  • Timing table: not re-measured.
  • Every battery case's output matched before and after except doctor's row: not re-run as a battery; consistent with the tests.
  • No workflow, action or CI script changes: verified.
  • The cache tests (19), the doctor row tests (6) and the packed kept-catalog tests pass: verified.
  • The CLI suites, type checks and command-structure check pass: partly verified; 42 related test files pass (one failure is environmental and fails on the base too), the command-structure check passes, and the type check shows no error in a changed file.
  • Changeset: the cache stays small and fast however many folders load the same files: verified (bounded per-subfolder trim).
  • Changeset: the same file in many folders shares one copy, unless its text contains meta: verified.
  • Changeset: each new copy trims only its own subfolder, so no run reads the whole cache: verified.
  • Changeset: fresh-folder runs could fill the old folder and a theme command spent minutes reading it: consistent with the base code.
  • Changeset: doctor names the old folder and the command that removes it: verified inside a project; doctor outside a project does not show it.

Files:

  • .changeset/transpile-cache-bounded.md: non-blocking wording note (project doctor).
  • docs/specs/AST-081-global-mode/spec.md: awaits engineering-owner approval of the FR7 rewrite.
  • packages/cli/api/doctor/doctor.mjs: finding (removeFolderCommand duplicates quoteCommandArgument).
  • packages/cli/api/doctor/old-transpile-cache.test.mjs: clear.
  • packages/cli/clients/cli/commands/build-theme.transpile-cache.test.mjs: clear (passes 3 of 3).
  • packages/cli/foundation/doc-compiler/doc-loads.test.mjs: clear.
  • packages/cli/foundation/fs/cache-eviction.mjs: clear.
  • packages/cli/foundation/fs/cache-eviction.test.mjs: clear.
  • packages/cli/foundation/fs/gather-cache.mjs: clear.
  • packages/cli/foundation/fs/jiti-cache.mjs: finding (isPlain duplicates the exact codec's check).
  • packages/cli/foundation/fs/jiti-cache.test.mjs: clear.
  • packages/cli/test/packed-gather-cache.fresh.test.mjs: clear.
  • packages/cli/test/packed-gather-cache.records.test.mjs: clear.

Automated review (maintainer link)

Comment thread packages/cli/api/doctor/doctor.mjs Resolved
Comment thread .changeset/transpile-cache-bounded.md Resolved

@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.

Approval waits on an engineering owner deciding the rewritten spec:AST-081 FR7 transpile-cache clause: copies named by source text and settings (per file when the text contains meta), 256 subfolders trimmed by creation time, oversize copies used but not kept, and the old astryx/jiti folder left in place with project doctor naming it. An engineering owner records that decision by commenting /approve-spec <full head SHA> on this pull request, and the author may do so as an engineering owner. The earlier findings are fixed at this head: the remove command uses the shared quoteCommandArgument, copy names use the shared exact codec, and the changeset says "Project doctor". No other change is needed.

Claims and files checked

Review mode: incremental; reason: none

Claims:

  • jiti named each copy for its source's path: verified (jiti 2.7.0 names each cached file by a hash of its path).
  • The old size check could not remove a copy used in the last two days, because jiti checks that a copy exists and then reads it with no fallback: verified (the base's two-day protection; jiti's exists-then-read).
  • When the old check ran, it read the whole folder: verified (the base trim lists every entry).
  • One machine reached over a million copies and theme commands hung for minutes: not checkable from the repository; consistent with the base code.
  • Every command prints what it printed, except doctor's cache text: verified by reading and tests; a kept copy returns jiti's own code (jiti-cache.test.mjs "reads a kept copy instead of transpiling").
  • A copy's name hashes the source text and every setting the transform reads: verified (copyName, jiti-cache.mjs:146); the same text under .ts, .mts and .cts, or .js, .jsx and .mjs, gets one name and identical code, and .tsx gets its own.
  • Text containing "meta" also names the copy for its file: verified (jiti-cache.mjs:152; test).
  • No run reads the whole cache, and a write trims only its own subfolder: verified (test "reads only the subfolder it writes").
  • Copies sit in 256 subfolders, are written under another name and renamed, and a failed read or partial copy is a miss: verified (keepCopy, readCopy; tests).
  • The trim keeps each subfolder within its share, oldest made first, never the new copy: verified (trimSubfolder through evictOldest with keep; tests).
  • Oversize copies are used but not kept, and failed transpiles and non-plain settings are never kept: verified (tests).
  • Errors name the real file: verified (test).
  • The old folder is never read, listed or written: verified (test).
  • doctor finds the old folder with one stat and names it with the command that removes it: verified (test; doctor run in a project).
  • doctor's kept-catalog row describes the trimming: verified (packed kept-catalog records test).
  • The record describes the cache as it now works: verified as text; it awaits owner approval.
  • Code is path-free for files without "meta": consistent; a 1,500-file sample gave identical code under two paths in every transform without "meta".
  • At the size limit a subfolder holds a few hundred copies: consistent with a 256 KB share; not measured.
  • Timing table: not re-measured.
  • Every battery case's output matched before and after except doctor's row: not re-run as a battery; consistent with the tests.
  • No workflow, action or CI script changes: verified.
  • The cache tests (19), the doctor row tests (6) and the packed kept-catalog tests pass: verified.
  • The CLI suites, type checks and command-structure check pass: partly verified; the related CLI suites pass, four unrelated tests that depend on the test environment fail the same way on the base, and the type checks and command-structure check were not re-run.
  • Changeset: the cache stays small and fast however many folders load the same files: verified (bounded per-subfolder trim).
  • Changeset: copies live in astryx/transpiled, and the same file in many folders shares one copy unless its text contains meta: verified.
  • Changeset: each new copy trims only its own subfolder, so no run reads the whole cache: verified.
  • Changeset: fresh-folder runs could fill the old folder and a theme command spent minutes reading it: consistent with the base code.
  • Changeset: project doctor names the old folder and the command that removes it: verified.

Files:

  • .changeset/transpile-cache-bounded.md: clear.
  • docs/specs/AST-081-global-mode/spec.md: awaits engineering-owner approval of the FR7 rewrite.
  • packages/cli/api/doctor/doctor.mjs: clear.
  • packages/cli/api/doctor/old-transpile-cache.test.mjs: clear.
  • packages/cli/clients/cli/commands/build-theme.transpile-cache.test.mjs: clear.
  • packages/cli/foundation/doc-compiler/doc-loads.test.mjs: clear.
  • packages/cli/foundation/env/user-dirs.mjs: clear.
  • packages/cli/foundation/fs/cache-eviction.mjs: clear.
  • packages/cli/foundation/fs/cache-eviction.test.mjs: clear.
  • packages/cli/foundation/fs/gather-cache.mjs: clear.
  • packages/cli/foundation/fs/jiti-cache.mjs: clear.
  • packages/cli/foundation/fs/jiti-cache.test.mjs: clear.
  • packages/cli/test/packed-gather-cache.fresh.test.mjs: clear.
  • packages/cli/test/packed-gather-cache.records.test.mjs: clear.

Automated review (maintainer link)

@josephfarina

Copy link
Copy Markdown
Contributor Author

Owner decision (engineering owner, covering this pull request): the CLI's transpile cache names each kept copy for a hash of its source text and of every setting the transform reads, so a kept copy is used only when it holds exactly what the transform would make now. Each write trims at most one subfolder, so the cache stays small and no run reads all of it. Every command prints exactly what it printed before, with one exception: doctor's text about this cache, where the kept-catalog row's last sentence changes and a new info row appears where an older CLI's cache folder exists.

@josephfarina

Copy link
Copy Markdown
Contributor Author

/approve-spec 6c0e221

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

Copy link
Copy Markdown
Contributor Author

/approve-spec 0de9d73

@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 run on this head yet; its jobs were cancelled because CI was full, so they need a re-run.

The transpile-cache rewrite of spec:AST-081 FR7 now has an engineering owner's approval for this exact head, and the code, unchanged since the last review, has no open finding. The earlier inline findings stay fixed, so nothing else is needed from you.

Claims and files checked

Review mode: incremental; reason: none

Claims:

  • jiti named each kept copy for its source's path: verified (jiti 2.7.0 hashes the file path into each copy's name).
  • The old size check could not remove a copy used in the last two days, because jiti checks that a copy exists and then reads it with no fallback: verified (the base's two-day protection; jiti's exists-then-read).
  • The old check read the whole folder when it ran: verified (the base trim listed every entry).
  • One machine reached over a million copies and theme commands hung for minutes: not checkable from the repository; consistent with the base code.
  • Every command prints what it printed, except doctor's text about this cache: verified (only doctor's strings change; a kept copy returns jiti's own code, test "reads a kept copy instead of transpiling").
  • A copy's name hashes the source text and every setting the transform reads: verified (copyName; the same text under .ts, .mts and .cts, or .js, .mjs and .cjs, gets one name and identical code).
  • Text containing "meta" also names the copy for its file: verified (test reading import.meta.url and .dirname in two folders).
  • No run reads the whole cache, and a write trims only its own subfolder: verified (test that watches folder listings).
  • The loaders turn jiti's disk cache off and pass a transform that keeps copies in astryx/transpiled: verified (jitiCacheOptions; test).
  • Copies sit in 256 subfolders, are written under another name and renamed, and a failed read or partial copy is a miss: verified (keepCopy, readCopy; tests, six-process run).
  • Each subfolder is trimmed to its share, made longest ago first, never the new copy: verified (trimSubfolder through evictOldest with keep; tests).
  • Oversize copies are used but not kept, and failed transpiles and non-plain settings are never kept: verified (tests).
  • Errors name the real file: verified (test).
  • The old folder is never read, listed or written: verified (test).
  • Doctor finds the old folder with one stat and names it with the command that removes it: verified (test; doctor run in a project).
  • Doctor's kept-catalog row describes the trimming: verified (packed kept-catalog records test).
  • The global-mode record describes the cache as it now works: verified; owner-approved for this head.
  • Code is path-free for files without "meta" (3,581 files): consistent; representative sources across extensions give identical code, the full run is not repeated.
  • At the size limit a subfolder holds a few hundred copies: consistent with a 256 KB share; not measured.
  • Timing table: not re-measured.
  • Every battery case's output matched before and after except doctor's row: not re-run as a battery; consistent with the diff and tests.
  • No workflow, action or CI script changes: verified.
  • The cache tests (19), the doctor row tests (6) and the packed kept-catalog tests pass: verified.
  • The CLI suites, type checks and command-structure check pass: partly verified; the related suites, startup imports and doctor suites pass, and the type checks and command-structure check were not re-run.
  • Changeset: the cache stays small and fast however many folders load the same files: verified (bounded per-subfolder trim, shared copies).
  • Changeset: copies live in astryx/transpiled, named for text and settings, and the same file in many folders shares one copy unless its text contains meta: verified.
  • Changeset: each new copy trims only its own subfolder, so no run reads the whole cache: verified.
  • Changeset: fresh-folder runs could fill the old folder and a theme command spent minutes reading it: consistent with the base code.
  • Changeset: project doctor names the old folder and the command that removes it: verified.

Files:

  • .changeset/transpile-cache-bounded.md: clear.
  • docs/specs/AST-081-global-mode/spec.md: clear; the FR7 rewrite is owner-approved for this head.
  • packages/cli/api/doctor/doctor.mjs: clear.
  • packages/cli/api/doctor/old-transpile-cache.test.mjs: clear.
  • packages/cli/clients/cli/commands/build-theme.transpile-cache.test.mjs: clear.
  • packages/cli/foundation/doc-compiler/doc-loads.test.mjs: clear.
  • packages/cli/foundation/env/user-dirs.mjs: clear.
  • packages/cli/foundation/fs/cache-eviction.mjs: clear.
  • packages/cli/foundation/fs/cache-eviction.test.mjs: clear.
  • packages/cli/foundation/fs/gather-cache.mjs: clear.
  • packages/cli/foundation/fs/jiti-cache.mjs: clear.
  • packages/cli/foundation/fs/jiti-cache.test.mjs: clear.
  • packages/cli/test/packed-gather-cache.fresh.test.mjs: clear.
  • packages/cli/test/packed-gather-cache.records.test.mjs: clear.

Automated review (maintainer link)

…trims one subfolder per write, so it stays small and no run reads all of it
…r, writes a new subfolder's first copy with less work, and the theme build test reads the new folder
…c, doctor quotes the remove command with the shared quoting, and the cache's folder paths live with the other per-user folders
@josephfarina
josephfarina force-pushed the fix/transpile-cache-bounded branch from 0de9d73 to 02053a9 Compare November 18, 2026 06:30
@josephfarina

Copy link
Copy Markdown
Contributor Author

/approve-spec 02053a9

@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 is still running on this head; the merge waits for its required checks.

The transpile-cache rewrite of spec:AST-081 FR7 has an engineering owner's approval for this exact head, the code matches it, and the cache, doctor and packed kept-catalog tests pass. One optional wording point for the next edit of the record: FR7 says a file "whose text contains the word meta" gets a copy per location, while copyName matches any meta substring (so metadata also splits copies); "contains meta" would match the code.

Claims and files checked

Review mode: full; reason: rebase

Claims:

  • jiti named each kept copy for its source's path: verified (jiti 2.7.0 hashes the file path into each copy's name).
  • The old size check could not remove a copy used in the last two days, because jiti checks that a copy exists and then reads it with no fallback: verified (the base's two-day protection; jiti's exists-then-read).
  • The old check read the whole folder when it ran: verified (the base trim listed every entry).
  • One machine reached over a million copies and theme commands hung for minutes: not checkable from the repository; consistent with the base code.
  • Every command prints what it printed, except doctor's text about this cache: verified (only doctor's strings change; a kept copy returns jiti's own code).
  • A copy's name hashes the source text and every setting the transform reads: verified (copyName; jiti's transform reads the path only for import.meta and the .tsx test).
  • Text containing "meta" also names the copy for its file: verified (test reading import.meta.url and .dirname from two folders).
  • No run reads the whole cache, and a write trims only its own subfolder: verified (test that watches folder listings).
  • The loaders turn jiti's disk cache off and pass a transform that keeps copies in astryx/transpiled: verified (jitiCacheOptions; test).
  • Copies sit in 256 subfolders, are written under another name and renamed, and a failed read or partial copy is a miss: verified (keepCopy, readCopy; tests, six-process run).
  • Each subfolder is trimmed to its share, made longest ago first, never the new copy: verified (trimSubfolder through evictOldest with keep; tests).
  • Oversize copies are used but not kept, and failed transpiles and non-plain settings are never kept: verified (tests).
  • Errors name the real file: verified (test).
  • The old folder is never read, listed or written, and older CLIs keep their own behavior there: verified (test watching file-system calls).
  • Doctor finds the old folder with one stat and names it with the command that removes it: verified (test; a doctor run prints the row).
  • Doctor's kept-catalog row describes the trimming: verified (packed kept-catalog test; only the last sentence changes).
  • The global-mode record describes the cache as it now works: verified, owner-approved for this head; its "the word meta" is narrower than the code's substring test (optional wording point above).
  • Code is path-free for files without "meta" (3,581 files): consistent; 968 CLI and theme files under two paths give identical code, the full run is not repeated.
  • At the size limit a subfolder holds a few hundred copies: consistent with a 256 KB share; not measured.
  • Timing table: not re-measured.
  • Every battery case's output matched before and after except doctor's row: not re-run as a battery; consistent with the diff and tests.
  • No workflow, action or CI script changes: verified.
  • The cache tests (19), the doctor row tests and the packed kept-catalog tests pass: verified.
  • The CLI suites, type checks and command-structure check pass: partly verified; the related suites pass here and CI's typecheck and lint pass, and the command-structure check was not re-run.
  • Changeset: the per-user cache stays small and fast however many folders load the same files: verified (shared copies, bounded per-subfolder trim).
  • Changeset: copies live in astryx/transpiled, named for text and settings, shared across folders unless the text contains meta: verified.
  • Changeset: each new copy trims only its own subfolder, so no run reads the whole cache: verified.
  • Changeset: fresh-folder runs could fill the old folder and a theme command spent minutes reading it: consistent with the base code.
  • Changeset: project doctor names the old folder and the command that removes it: verified.

Files:

  • .changeset/transpile-cache-bounded.md: clear.
  • docs/specs/AST-081-global-mode/spec.md: clear; owner-approved for this head; optional wording point on "the word meta".
  • packages/cli/api/doctor/doctor.mjs: clear; the rebase keeps every phrase the base added to the kept-catalog row.
  • packages/cli/api/doctor/old-transpile-cache.test.mjs: clear.
  • packages/cli/clients/cli/commands/build-theme.transpile-cache.test.mjs: clear.
  • packages/cli/foundation/doc-compiler/doc-loads.test.mjs: clear.
  • packages/cli/foundation/env/user-dirs.mjs: clear.
  • packages/cli/foundation/fs/cache-eviction.mjs: clear.
  • packages/cli/foundation/fs/cache-eviction.test.mjs: clear.
  • packages/cli/foundation/fs/gather-cache.mjs: clear.
  • packages/cli/foundation/fs/jiti-cache.mjs: clear.
  • packages/cli/foundation/fs/jiti-cache.test.mjs: clear.
  • packages/cli/test/packed-gather-cache.fresh.test.mjs: clear.
  • packages/cli/test/packed-gather-cache.records.test.mjs: clear.

Automated review (maintainer link)

owns and others cannot open; otherwise nothing is cached on disk. Each
copy is named for its source text and transpile settings, not its
location, so the same file in many folders shares one copy; a file whose
text contains the word `meta`, as every use of `import.meta` must, also

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: copyName tests a substring (source.includes('meta'), packages/cli/foundation/fs/jiti-cache.mjs:152), so a file that only mentions metadata also gets a copy per location, while this line says "the word meta". The changeset already says "contains meta"; the same words here, at the next edit of this record, would match the code.

@josephfarina
josephfarina merged commit 286e4db into main Nov 18, 2026
80 checks passed
@github-actions
github-actions Bot deleted the fix/transpile-cache-bounded branch November 19, 2026 06:05

This branch was successfully deployed

1 active deployment
Preview — 02053a9f Deployed Nov 18, 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