Skip to content

perf(cli): kept gathers leave the CLI's own files to its build id and folder - #11998

Merged
josephfarina merged 5 commits into
mainfrom
speed/gathers-cli-own-files
Nov 16, 2026
Merged

josephfarina merged 5 commits into
mainfrom
speed/gathers-cli-own-files

Conversation

@josephfarina

@josephfarina josephfarina commented Nov 16, 2026 •

Copy link
Copy Markdown
Contributor

Summary

In a project with an integration, most commands read back what earlier runs kept (the project's issues, the integration's themes and check results, component replacements). Checking such an entry stats every path its gather read, and most of those paths are the CLI's own files. In a project with one large integration, 2,625 of an entry's 3,953 paths are the CLI's templates, docs and code modules. That is about 10 ms of every such run spent proving the CLI is the CLI it was.

The per-user cache record already says the CLI's build id stands for the installed CLI's own files, with in-place edits to an installed CLI not supported. Summaries already work that way. Kept gathers now do too:

  • foundation/fs/gather-cache.mjs: an entry's check skips the CLI's own files, by the rule summaries already use (inCliBuild: under the CLI's folder, outside the node_modules folder inside it). A package placed in that node_modules folder is not part of the build and is checked as before, like every other path.
  • Every entry's key holds the real path of the folder the CLI runs from, beside the build id, resolved once per process. A copy of the same build installed in another folder, such as a package manager's patched copy, keeps its own entries. This holds for gathers, summaries and derived values.
  • Entries still store the CLI's own paths and states, so the code digest that derived values are keyed on (search's entry table, build's block vectors) is the same as before. Search's entry table still stamps its code inputs at each read, as before.
  • A source checkout keeps nothing, as before: it has no build id, which is written only at prepack and removed at postpack.

Evidence

Profile of a warm component Button in a project with one large integration, 10 runs each:

main change
entry check (staleReason) 18.8 ms 8.9 ms
confirmedEntry 21.8 ms 11.3 ms
the project's issues 28.1 ms 17.4 ms

A 51-case battery over every command in two projects (one with an integration, one with only Core) printed the same stdout and stderr, with the same exit code, as main for every case. The cases that read back kept entries were 10–30 ms faster in the integration project.

Tests

  • test/packed-gather-cache.changes.test.mjs: a copy of the same CLI installed in another folder keeps its own entries, with output equal to a fresh run. It fails when the key lacks the folder.
  • test/packed-gather-cache.installed.test.mjs, the CLI's own docs tree:
    • a patched copy installed beside the CLI sees its edit, while the CLI it came from is unchanged;
    • after an in-place edit to the installed CLI (same build id, same folder), the kept tree is still used, as the record says;
    • after a reinstall (another build id), the next run equals a fresh one.
    • It fails when the CLI's own paths are checked.
  • foundation/fs/gather-cache.deps.test.mjs:
    • an in-place edit to one of the CLI's own files is read back, and an edit to a package in the node_modules folder inside the CLI's is gathered again (fails when the whole folder is skipped);
    • the files the deps rows edit now sit outside the CLI's folder, so each edit still misses; the derived value is keyed by what it is worked out from, as search's entry table is.
  • test/packed-gather-cache.records.test.mjs: doctor's cache row states the policy.
  • The kept-gather, fs, doctor, search, component, docs, discovery and build suites pass.

Spec changes

spec:AST-081 FR7:

  • Before: "For the installed CLI's own files, the CLI's build id stands for their contents (an upgrade or reinstall changes it; in-place edits to an installed CLI aren't supported)."
  • After: "For the installed CLI's own files, the CLI's build id and the folder the CLI runs from stand for their contents (an upgrade, a reinstall or a copy installed in another folder, such as a patched one, changes them; in-place edits to an installed CLI aren't supported, and deleting the per-user astryx/catalogs folder clears what was kept)."

Doctor's cache row changes the same way. This needs an engineering owner's /approve-spec.

Writing rubric results

For the FR7 change:

  • R1 narration: none; the sentence states what stands for the CLI's own files and how to clear the cache.
  • R2 research: none in the record; the measurements stay in this description.
  • R3 evidence: none cited.
  • R4 rejected alternatives: none.
  • R5 change references: none.
  • R6 open questions: none.
  • R7 project status: none.

Scope

No output, flag or JSON shape changes, except doctor's cache-row text above. An in-place edit to an installed CLI, under the same build id and folder, is no longer seen by kept gathers, as the record already says. Deleting the per-user astryx/catalogs folder clears what was kept.

@vercel

vercel Bot commented Nov 16, 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 16, 2026 8:30am UTC

Request Review

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

astracat-bot Bot commented Nov 16, 2026 •

Copy link
Copy Markdown
Contributor

AI review status for this pull request.

Review status Updated
🟢 Reviewed (for maintainers only) Nov 16, 2026, 8:38 AM UTC

@github-actions github-actions Bot added the needs:spec-owner-review Current knowledge records await owner approval label Nov 16, 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's decision on the spec:AST-081 FR7 rewording, and two fixes are needed whatever that decision is.

  • The stale check at packages/cli/foundation/fs/gather-cache.mjs:665 skips every path under the CLI's folder, including packages inside the CLI's own node_modules that the build id does not hash, so a nested dependency updated or patched in place (after npm install -g or npm update, say) keeps serving old kept answers; if (inCliBuild(file)) continue;, the rule summaries use, keeps the speed-up and restores that check.
  • The changeset says "Output does not change.", but astryx doctor's cache row text changes, so the release note should say so.

At this head FR7 makes the CLI's real folder stand beside the build id for the CLI's own files, which needs an engineering owner's approval of the wording. An engineering owner records it by commenting /approve-spec with the full head commit SHA on this pull request, and the author may do so as an engineering owner.

Claims and files checked

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

  • Claim: kept checks spent most of their file checks on the CLI's own files (measured): unverified, measurement not reproduced.
  • Claim: the cache record already lets the build id stand for the CLI's own files: verified (FR7).
  • Claim: kept gathers now skip the CLI's own files as summaries do: false; summaries keep checking the CLI's node_modules (inCliBuild, gather-cache.mjs:1266) and the new skip does not (gather-cache.mjs:665).
  • Claim: every other path is checked as before: verified (gather-cache.mjs:661-669; unit suites pass).
  • Claim: the CLI's real folder joins every entry key for gathers, summaries and derived values: verified (entryKey, gather-cache.mjs:607-618).
  • Claim: entries still store the CLI's own states and search's entry table stamps its code inputs: verified (api/search/_entries.mjs:86).
  • Claim: a source checkout keeps nothing: verified (buildId, gather-cache.mjs:245-256; postpack removes the id).
  • Claim: profile table and the 51-case output battery: unverified, not reproduced.
  • Claim: the listed tests cover the copy, the patched copy, the in-place edit, the reinstall, the deps rows and doctor's row: verified by reading; the packed-CLI tests run in CI.
  • Claim: no output, flag or JSON change except doctor's row: verified.
  • Changeset: about 10 ms sooner: unverified (measurement); no per-file check of the CLI's own files, own entries for a copy in another folder, in-place edits unsupported, deleting the cache folder clears it: verified; "Output does not change": false (doctor's row).
  • File .changeset/kept-gathers-cli-own-files.md: finding (output claim).
  • File docs/specs/AST-081-global-mode/spec.md: FR7 wording awaits owner approval.
  • File packages/cli/api/doctor/doctor.mjs: clear.
  • File packages/cli/foundation/fs/gather-cache.mjs: finding (node_modules skip); two doc comments still describe the old behaviour (non-blocking).
  • File packages/cli/foundation/fs/gather-cache.deps.test.mjs: clear.
  • File packages/cli/test/packed-gather-cache.changes.test.mjs: clear.
  • File packages/cli/test/packed-gather-cache.installed.test.mjs: clear.
  • File packages/cli/test/packed-gather-cache.records.test.mjs: clear.

Automated review (maintainer link)

@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's decision on the spec:AST-081 FR7 rewording; the code needs nothing more.

Both earlier findings are fixed: the stale check now skips only the CLI's own published files, so packages in the CLI's own node_modules stay checked, and the changeset names doctor's cache row. At this head FR7 makes the CLI's real folder stand beside the build id for the CLI's own files and adds copies in another folder and clearing astryx/catalogs; an engineering owner records approval of that wording by commenting /approve-spec with the full head commit SHA on this pull request, and the author may do so as an engineering owner. Non-blocking: two doc comments (gather-cache.mjs:174-178, :1042-1043) and the file header's @output (:9-13) still describe the old per-file check of the CLI's own files.

Claims and files checked

Review mode: incremental; reason: none

  • Changed rules (0): none.
  • Claim: most paths a kept entry checks are the CLI's own files, costing about 10 ms per read: unverified, measurement not reproduced.
  • Claim: the cache record already lets the build id stand for the CLI's own files, with in-place edits unsupported: verified (FR7).
  • Claim: summaries already skip the CLI's own files: verified (gather-cache.mjs:1287).
  • Claim: kept gathers now skip the CLI's own files by the summaries' rule and still check packages in the CLI's own node_modules: verified (gather-cache.mjs:666; gather-cache.deps.test.mjs:246-277).
  • Claim: every entry key holds the CLI's real folder, worked out once per process, for gathers, summaries and derived values: verified (gather-cache.mjs:596-618, :1063-1064, :1203-1204).
  • Claim: entries still store the CLI's own states, so derived values' code digest is unchanged, and search's entry table still stamps its code inputs: verified (gather-cache.mjs:980-984; api/search/_entries.mjs:80-87).
  • Claim: a source checkout keeps nothing, since only prepack writes the build id and postpack removes it: verified (gather-cache.mjs:245-256; packages/cli/package.json scripts).
  • Claim: the profile table and the 51-case output comparison: unverified, not reproduced.
  • Claim: the copy test fails when the key lacks the folder: verified (it fails at packed-gather-cache.changes.test.mjs:94 without the folder).
  • Claim: the installed-CLI test covers the patched copy, the in-place edit and the reinstall, and fails when the CLI's own paths are checked: verified (it fails at packed-gather-cache.installed.test.mjs:290 without the skip).
  • Claim: the cache unit test reads back an in-place edit to the CLI's files, gathers again after a nested-package edit, and fails when the whole folder is skipped: verified (it fails with the earlier prefix skip).
  • Claim: doctor's cache row states the policy: verified (doctor.mjs:2341; packed-gather-cache.records.test.mjs:78).
  • Claim: the listed suites pass: verified for the cache unit suites and the three changed packed-CLI suites; the doctor, search, component, docs, discovery and build suites were not run.
  • Claim: FR7's before and after text, and no output, flag or JSON change apart from doctor's row: verified.
  • Changeset: about 10 ms sooner: unverified (measurement); no per-file check of the CLI's own files, own entries for a copy in another folder, in-place edits unsupported, deleting the cache folder clears it, nested node_modules still checked, output unchanged apart from doctor's row: verified.
  • File .changeset/kept-gathers-cli-own-files.md: clear.
  • File docs/specs/AST-081-global-mode/spec.md: FR7 wording awaits an engineering owner's approval.
  • File packages/cli/api/doctor/doctor.mjs: clear.
  • File packages/cli/foundation/fs/gather-cache.mjs: non-blocking stale comments.
  • File packages/cli/foundation/fs/gather-cache.deps.test.mjs: clear.
  • File packages/cli/test/packed-gather-cache.changes.test.mjs: clear.
  • File packages/cli/test/packed-gather-cache.installed.test.mjs: clear.
  • File packages/cli/test/packed-gather-cache.records.test.mjs: clear.

Automated review (maintainer link)

@github-actions

github-actions Bot commented Nov 16, 2026 •

Copy link
Copy Markdown
Contributor

PR Analysis Report

🔎 Preview · 23228e8

Storybook · Sandbox · built from this PR's head

Package size: @astryxdesign/cli 5.12 MB packed (+245 B); no new dependencies.

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

@josephfarina

Copy link
Copy Markdown
Contributor Author

/approve-spec 47cd639

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

Copy link
Copy Markdown
Contributor Author

/approve-spec c3ad841

@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: the heavy test jobs have not run on this head yet.

An engineering owner approved the spec:AST-081 FR7 rewording for this exact head, so every change now has spec authority, and nothing blocks. One non-blocking cleanup remains in packages/cli/foundation/fs/gather-cache.mjs: the header's @output (lines 9-13) and the comments at lines 174-178 and 1041-1046 still say an edit to the CLI's own files misses the kept gather, while the build id and folder now stand for those files.

Claims and files checked

Review mode: incremental; reason: none

  • Changed rules (0): none.
  • Claims (description):
    • Verified: the cache record already lets the build id stand for the CLI's own files, and summaries already skip them (gather-cache.mjs:1287).
    • Verified: an entry's check skips the CLI's own files by the summaries' inCliBuild rule (gather-cache.mjs:666, :1267-1272).
    • Verified: a package in the node_modules folder inside the CLI's is still checked (gather-cache.deps.test.mjs:246-277).
    • Verified: every entry key holds the CLI's real folder beside the build id, resolved once per process, for gathers, summaries and derived values (gather-cache.mjs:588-618).
    • Verified: entries still store the CLI's own states, so derived-value digests are unchanged, and search's entry table stamps its code inputs at each read (gather-cache.mjs:983-984, :1414-1415; api/search/_entries.mjs:80-87).
    • Verified: a source checkout keeps nothing, since the build id exists only between prepack and postpack (gather-cache.mjs:249; packages/cli/package.json:123-124).
    • Not reproduced (author's measurements): the profile table, the 10 ms saving and the 51-case output comparison.
    • Verified: the copy-in-another-folder test passes, and it fails when the key lacks the folder (packed-gather-cache.changes.test.mjs:83-97).
    • Verified: the docs-tree test covers a patched copy, an in-place edit and a new build id, and it fails when the CLI's own paths are checked (packed-gather-cache.installed.test.mjs:267-301).
    • Verified: the deps tests cover the in-place edit and the nested package and fail when the whole folder is skipped; their edited files now sit outside the CLI's folder (gather-cache.deps.test.mjs:50, :246-277, :353).
    • Verified: doctor's cache row states the policy (packed-gather-cache.records.test.mjs:78).
    • Verified: the kept-gather, fs, doctor, search, component, docs, discovery and build suites pass on this head.
    • Verified: FR7's before and after text and doctor's row change as described (spec.md:415, doctor.mjs:2341).
    • Verified: no output, flag or JSON shape changes beyond doctor's row, and deleting the per-user astryx/catalogs folder clears what was kept (gather-cache.mjs:263-265).
  • Claims (changeset):
    • Not reproduced (author's measurement): kept commands finish about 10 ms sooner in a project with an integration.
    • Verified: a kept gather no longer checks the CLI's own files one by one, and a copy in another folder keeps its own entries.
    • Verified: in-place edits stay unsupported, deleting astryx/catalogs clears what was kept, and a package in the CLI's own node_modules is still checked.
    • Verified: output changes only in doctor's cache row, which now names the folder.
  • Files:
    • .changeset/kept-gathers-cli-own-files.md: clear.
    • docs/specs/AST-081-global-mode/spec.md: clear (owner-approved FR7).
    • packages/cli/api/doctor/doctor.mjs: clear.
    • packages/cli/foundation/fs/gather-cache.mjs: non-blocking stale comments.
    • packages/cli/foundation/fs/gather-cache.deps.test.mjs: clear.
    • packages/cli/test/packed-gather-cache.changes.test.mjs: clear.
    • packages/cli/test/packed-gather-cache.installed.test.mjs: clear.
    • packages/cli/test/packed-gather-cache.records.test.mjs: clear.

Automated review (maintainer link)

…-files

# Conflicts:
#	packages/cli/api/doctor/doctor.mjs
#	packages/cli/foundation/fs/gather-cache.mjs
@github-actions github-actions Bot added the needs:spec-owner-review Current knowledge records await owner approval label Nov 16, 2026
@josephfarina

Copy link
Copy Markdown
Contributor Author

/approve-spec 23228e8

@github-actions github-actions Bot removed the needs:spec-owner-review Current knowledge records await owner approval label Nov 16, 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: the CI workflow's test jobs were cancelled at this head because CI was full, so they need a re-run before merge.

An engineering owner approved the spec:AST-081 FR7 rewording for this exact head, and the merge of main keeps both sides of its two conflicts (doctor's cache row and the gather-cache.mjs header).

Optional: the doc comments at gather-cache.mjs lines 174-180 and 1043-1047, and the file header's @output, still say an edit to the CLI's own files misses a kept gather; rewording them to say the build id and folder stand for those files would keep them accurate.

Claims and files checked

Review mode: incremental; reason: none

  • Changed rules (0).
  • Claims:
    • The entry check skips the CLI's own files by the rule summaries already use (under its folder, outside the node_modules inside it): verified, gather-cache.mjs:667, :1268-1273.
    • A package in the node_modules folder inside the CLI's is still checked: verified, gather-cache.deps.test.mjs:276.
    • Every entry key holds the CLI's real folder beside the build id, resolved once per process, for gathers, summaries and derived values: verified, gather-cache.mjs:597-599, :612, :931, :1065, :1205.
    • Entries still store the CLI's own states, so the code digest derived values key on is unchanged: verified, gather-cache.mjs:985, :1030-1036.
    • Search's entry table still stamps its code inputs at each read: verified, api/search/_entries.mjs:80-87.
    • A source checkout keeps nothing, since the build id exists only in an installed package and is written at prepack and removed at postpack: verified, gather-cache.mjs:246-257, scripts/generate-build-id.mjs:74-76.
    • Most of an entry's paths are the CLI's own files, and warm reads are about 10 ms faster: not reproduced; the author's profile.
    • A battery over every command printed the same output as main: not reproduced; the author's run.
    • A copy installed in another folder keeps its own entries, and the test fails without the folder in the key: verified, packed-gather-cache.changes.test.mjs:83-97, fails at :94 without it.
    • A patched copy sees its edit, an in-place edit keeps the kept docs tree, and a new build id gathers again; the test fails when the CLI's own paths are checked: verified, packed-gather-cache.installed.test.mjs:270-301, fails at :290 with the skip removed.
    • An in-place edit to a CLI file is read back, a nested package edit gathers again, the rows' files sit outside the CLI's folder, and the derived value is keyed by its source: verified, gather-cache.deps.test.mjs:50, :246-277, :353.
    • Doctor's cache row states the policy: verified, packed-gather-cache.records.test.mjs:80-82, doctor.mjs:2346.
    • The kept-gather, fs, doctor, search, component, docs, discovery and build suites pass: partly verified; the kept-gather, packed-catalog and doctor suites pass at this head, and CI's test jobs did not run.
    • The FR7 before and after text matches the record edit and needs an engineering owner's approval: verified, docs/specs/AST-081-global-mode/spec.md:422; approved for this head.
    • No output, flag or JSON shape changes beyond doctor's row, in-place edits are no longer seen, and deleting astryx/catalogs clears what was kept: verified, doctor.mjs:2346, gather-cache.mjs:264-266.
    • The writing rubric reports nothing for the FR7 sentence: verified; it carries no narration, research, evidence, alternatives, references, questions or status.
    • Changeset: kept commands in an integration project finish about 10 ms sooner: not reproduced; the author's measurement.
    • Changeset: a kept gather no longer checks the CLI's own files one by one, the build id and folder stand for them, and a copy in another folder keeps its own entries: verified, as above.
    • Changeset: in-place edits stay unsupported, deleting the catalogs folder clears what was kept, and nested packages are still checked: verified, as above.
    • Changeset: output is unchanged except doctor's row, which now names the folder: verified, doctor.mjs:2346.
  • Files:
    • .changeset/kept-gathers-cli-own-files.md: clear.
    • docs/specs/AST-081-global-mode/spec.md: clear; owner-approved for this head, no approval line changed.
    • packages/cli/api/doctor/doctor.mjs: clear; the merge keeps both phrases.
    • packages/cli/foundation/fs/gather-cache.mjs: code clear; non-blocking stale comments at lines 9-13, 174-180 and 1043-1047.
    • packages/cli/foundation/fs/gather-cache.deps.test.mjs: clear.
    • packages/cli/test/packed-gather-cache.changes.test.mjs: clear.
    • packages/cli/test/packed-gather-cache.installed.test.mjs: clear.
    • packages/cli/test/packed-gather-cache.records.test.mjs: clear.

Automated review (maintainer link)

@josephfarina
josephfarina merged commit f80af63 into main Nov 16, 2026
155 of 192 checks passed
@github-actions
github-actions Bot deleted the speed/gathers-cli-own-files branch November 17, 2026 06:03

This branch was successfully deployed

1 active deployment
Preview — 23228e81 Deployed Nov 16, 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