Repository navigation
perf(cli): store search's catalog at publish, used where the project adds nothing and the CLI and Core are unchanged - #11755
Conversation
…adds nothing and the CLI and Core are unchanged
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
AI review status for this pull request.
|
There was a problem hiding this comment.
Changes requested. Storing search's catalog at publish makes the first search and build calls clearly faster. Right now, though, the store also answers in a project that has a local theme, and astryx search then loses that theme.
- In a project with a theme in
src/themesand no integration,projectAddsToCatalog(packages/cli/foundation/discovery/stored-search-catalog.mjs:86-92) lets the store answer, so an openastryx search <slug>prints "No results" whiletheme listshows the theme and the live gather finds it (spec:AST-050FR14). Please count a local themes root that holds a theme as adding to the catalog (or merge local themes in live), correct the header comment that calls the current checks the only ways a project adds to a catalog, and add a packed test with an ejected theme. - The changeset says the store is used only "in a project that adds nothing to a catalog" and that "Output is the same", but a project with a local theme contradicts both today. Once the check above is in, add local themes to the changeset's list of cases that gather live.
Next: fix the project check and the changeset, then push for another review.
Claims and files checked
- Claim: the published CLI stores search's catalog at publish. Verified (
package.jsonprepack,scripts/generate-search-catalog.mjs, test "ships in the package"). - Claim: the store is used only where the project adds nothing and the CLI and Core files are unchanged. False for a local theme in
src/themes(finding 1). The input-state part is verified (stored-search-catalog.mjs:103-115, in-place edit test). - Claim: an integration, a docs or blocks package, another Core version or an edited file gathers live. Verified (
packed-search-catalog.test.mjs:222-288, Core input check). - Claim: output is the same, byte for byte, across the listed asks. Verified for the PR's 13 asks (test passes). False for a local-theme project (finding 2).
- Claim: the first
searchis about 350 ms faster and the firstbuildabout 290 ms faster. Same direction here: a coldsearch button --jsontook 283 ms instead of 547 ms.buildwas not re-measured. - Claim: a file counts by its content, a folder by its names and
package.jsonby its packer-kept fields. Verified (stored-self-audit.mjs:59-81). - Claim: the package manager is worked out live and picks the stored copy. Verified (
stored-search-catalog.mjs:113-114, lockfile test). - Claim: the generator runs after the other stores and before the build id, once per package manager in its own process. Verified (
package.jsonprepack,pack-cli.mjsstages,generate-search-catalog.mjs:83-109,:309-310). - Claim: npm's catalog is stored whole and the others store only differences (36 doc candidates). Verified: pnpm and bun differ in 36 candidates.
- Claim: references are used only where shorter and only into files checked by content, and the generator reads the store back and checks the probe and each lockfile. Verified (
generate-search-catalog.mjs:142-149,:188-200,:59,:314-325). - Claim: the kept gather keeps a reference, not a copy, and its warm read is the same. Verified (
api/search/_adapter.mjs:178-182,:218-226, test at:204-220). - Claim: the store is about 1.65 MB unpacked and the tarball grows about 6%. The store measures 1,655,594 bytes at this head. The tarball was not re-measured.
- Claim: no public API change. Verified (exports,
bin,api/index.mjsand command docs unchanged). - Claim: the new test and the CLI suites pass. Verified: 6 of 6 new tests, and 27 files and 369 tests across
api/search,doc-loadsand the kept-gather tests. - File
.changeset/stored-search-catalog.md: finding 2. - File
packages/cli/.gitignore: clear. - File
packages/cli/api/search/_adapter.mjs: answers from the store that finding 1 lets through, otherwise clear. - File
packages/cli/foundation/discovery/stored-search-catalog.mjs: finding 1. - File
packages/cli/foundation/doc-compiler/doc-loads.test.mjs: clear. - File
packages/cli/package.json: clear. - File
packages/cli/scripts/generate-search-catalog.mjs: its probe proves only an empty project (finding 1), otherwise clear. - File
packages/cli/test-utils/pack-cli.mjs: clear. - File
packages/cli/test/packed-search-catalog.test.mjs: no local-theme case (finding 1).
PR Analysis Report🔎 Preview ·
|
…oves every project path the gather reads is checked live
…atalog is checked live or misses the store, a packed case for each
There was a problem hiding this comment.
Changes requested. The local-theme fix holds: a project with a theme in src/themes now gathers live, and an open astryx search finds the theme. One problem remains, in the new prepack generator.
- Miss:
packages/cli/scripts/generate-search-catalog.mjscreates its probe project underos.tmpdir()without resolving it (:306-312) but compares it with the real paths the gather reads (:79-90), so wherever the temp folder sits behind a symlink, as macOS's default/var/folders/...does,prepackand every packed CLI test fail with "the gather reads paths outside the packages that the live check does not"; resolving the stage and home withfs.realpathSyncand testing containment withpath.relative(asselfAuditInputsdoes) fixes it and also covers Windows separators.
Next: fix the generator's temp-folder paths, then push for another review.
Claims and files checked
- Claim: the published CLI stores search's catalog at publish. Verified (
package.jsonprepack, packed case "ships in the package"). - Claim: the store is used only when the run is not hosted, no integration can load, no installed package declares docs or blocks, and the local themes root holds no theme folder, valid or broken. Verified (
stored-search-catalog.mjs:93-121, packed cases for each, and a broken-folder probe). - Claim: every CLI and Core file and folder the gather read must be unchanged, a file by content, a folder by its names and
package.jsonby packer-kept fields. Verified (stored-self-audit.mjsinputState, in-place edit case). - Claim: the package manager is worked out live and picks the stored copy. Verified (
stored-search-catalog.mjs:142-144, lockfile,packageManagerand user-agent cases). - Claim: the generator runs after the other stores and before the build id, once per package manager in its own process. Verified (
package.json,pack-cli.mjsstages,generate-search-catalog.mjs:106-132,:330-333). - Claim: npm's catalog is stored whole and the others store only differences (36 doc candidates). Verified: pnpm and bun differ in 36 candidates, yarn in 27 and yarn-classic in 33.
- Claim: references point into other stores only where shorter and are read only when that file is unchanged. Verified (only content-checked inputs are referenced, and the content check runs before the body is read).
- Claim: the generator reads the store back for every package manager, fails if the probe project adds to a catalog, and checks the catalog beside each lockfile. Verified (
generate-search-catalog.mjs:72,:212-222,:337-348). - Claim: the generator fails if the gather probes a project path the live steps do not read, and without the local-theme check it fails on
src/themes. Verified on a resolved temp folder: the gather's project probes are covered, and only the local-theme check readssrc/themes. Under a symlinked temp folder it also fails on every CLI and Core file (the finding above). - Claim: the store file is not committed. Verified (
.gitignore). - Claim:
storedSearchCatalogchecks before it reads the body, andkeptStoredCatalogreads without the check. Verified (stored-search-catalog.mjs:132-156). - Claim: the kept gather keeps one small reference instead of several large entries. Verified for the head: one 429 KB entry with no candidates. The "six entries of 6.6 MB" figure for the base was not reproduced: the base keeps two entries of 3.8 MB after the same first search here.
- Claim:
pack-cli.mjs,prepack/postpack,.gitignoreand the runner list include the generator. Verified (doc-loadspasses). - Claim: output is the same in every case. Verified for the 13 asks, each lockfile, a declared package manager, a user agent, integrations, a computer-wide integration, local and broken themes, and edited files.
- Claim: the store is 1,655,594 bytes and the tarball grows about 6%. The store size matches exactly; the tarball and gzip savings were not re-measured.
- Claim: the first
searchis about 350 ms faster and the firstbuildabout 290 ms faster. Same direction: 307 instead of 627 ms, and 781 instead of 1,045 ms here. - Claim: projects with an integration never use the store. Verified (
mayHaveIntegrationsgate). - Claim: a store hit content-checks 2,223 inputs. Verified (1,718 CLI and 505 Core inputs); the timings were not re-measured.
- Claim: no public API, product behavior, visual or policy change. Verified (exports,
binand command docs unchanged, output identical). - Claim: the new test fails on the base and passes here (11 cases). Verified: 11 of 11 pass, and the base ships no store.
- Claim: the CLI suites pass. Verified with a resolved temp folder (106 files, 1,977 tests). Under a symlinked temp folder the packed suites fail (the finding above).
- File
.changeset/stored-search-catalog.md: clear. - File
packages/cli/.gitignore: clear. - File
packages/cli/api/search/_adapter.mjs: clear. - File
packages/cli/foundation/discovery/stored-search-catalog.mjs: clear. - File
packages/cli/foundation/doc-compiler/doc-loads.test.mjs: clear. - File
packages/cli/package.json: clear. - File
packages/cli/scripts/generate-search-catalog.mjs: the finding above. - File
packages/cli/test-utils/pack-cli.mjs: clear; it runs the generator, so the finding reaches every packed test. - File
packages/cli/test/packed-search-catalog.test.mjs: clear.
… folder passes its guard
There was a problem hiding this comment.
Approved pending CI: the required checks have not finished on this head yet.
The temp-folder fix holds: where the temp folder sits behind a symlink, as on macOS, the prepack generator now writes the store and the packed CLI tests pass. Every earlier finding is resolved, and nothing else blocks. Next: the merge guard merges once the required checks pass.
Claims and files checked
- Claim: the published CLI stores search's catalog at publish and uses it where the project adds nothing and the CLI's and Core's files are unchanged. Verified (
package.jsonprepack,stored-search-catalog.mjs:132-145, packed case "ships in the package"). - Claim: a machine's first
searchanswers about 350 ms sooner and its firstbuildabout 290 ms sooner. Same direction, larger here on a slower machine: 496 instead of 908 ms, and 1,117 instead of 1,848 ms. - Claim: the catalog is gathered live with an integration, a package that adds docs or blocks, a local theme, another Core version, or after a change to any file or folder the catalog reads. Verified (
stored-search-catalog.mjs:93-121,:132-145, packed cases for each). - Claim: output is the same. Verified for the 13 asks, each lockfile, a declared package manager, a user agent, integrations, a computer-wide integration, a local theme and edited files.
- Claim: the store is used only when the run is not hosted, no integration can load, no installed package declares docs or blocks, and the local themes root holds no theme folder, checked live on every run. Verified (
stored-search-catalog.mjs:93-121). - Claim: every recorded CLI and Core file and folder must be unchanged: a file by content, a folder by its names,
package.jsonby packer-kept fields. Verified (stored-self-audit.mjsinputState, in-place edit case). - Claim: the package manager is worked out live and picks the stored copy. Verified (
stored-search-catalog.mjs:142-144, lockfile,packageManagerand user-agent cases). - Claim: the generator runs at
prepackafter the stores it reads and before the build id, installs exactly the published files and gathers once per package manager in its own process. Verified (package.json,pack-cli.mjsstages,generate-search-catalog.mjs:111-141,:341-342). - Claim: npm's catalog is stored whole and the other package managers store only differences (36 doc candidates). Verified: pnpm and bun differ in 36 candidates, yarn in 27 and yarn-classic in 33; the store's size is unchanged since the last reviewed revision.
- Claim: strings already held by another content-checked store are byte-range references, read only when that file is unchanged. Verified (
generate-search-catalog.mjs:153-233; the content check runs before the body is read). - Claim: the generator reads the store back for every package manager, fails if the probe project adds to a catalog, and checks the catalog beside each lockfile. Verified (
generate-search-catalog.mjs:64-72,:221-231,:346-357). - Claim: the generator fails if the gather probes a path outside the two packages that the live steps do not read. Verified (
:80-91), now also under a temp folder behind a symlink. - Claim: the store file is not committed. Verified (
packages/cli/.gitignore:47-50). - Claim:
storedSearchCatalogchecks before it reads the body, andkeptStoredCatalogreads without the check. Verified (stored-search-catalog.mjs:132-156). - Claim: the adapter uses the store before it gathers, and the kept gather keeps a reference instead of a copy. Verified (
api/search/_adapter.mjs:113-126,:178-182,:218-226, packed case). - Claim: a project with no integrations keeps one 380 KB entry after its first search instead of six entries of 6.6 MB. The head keeps one 429 KB entry here; the same first search on the live path keeps two entries of 3.8 MB here, so the saving holds but the base figure was not reproduced.
- Claim:
pack-cli.mjs,prepack/postpack,.gitignoreand the runner list include the generator. Verified (doc-loadspasses). - Claim: the store is 1,655,594 bytes unpacked and the tarball grows about 6%. The store size matches exactly; the tarball and gzip figures were not re-measured.
- Claim: warm runs are unchanged within a few milliseconds, and a store hit costs about 65 ms of checks. Not re-measured; the first-call gains above include those checks.
- Claim: output is byte-identical between the two packed CLIs for every ask, on the first and third call. Verified for the PR's 13 asks and the kept-reference case.
- Claim: no public API, product behavior, visual or policy change. Verified (exports,
binand command docs unchanged; output identical). - Claim: the new packed test fails on the base and passes here (11 cases). Verified: 11 of 11 pass, and the base ships no store.
- Claim: the CLI suites pass. Verified: 106 files and 1,977 tests here, and the packed suites also pass under a symlinked temp folder.
- File
.changeset/stored-search-catalog.md: clear. - File
packages/cli/.gitignore: clear. - File
packages/cli/api/search/_adapter.mjs: clear. - File
packages/cli/foundation/discovery/stored-search-catalog.mjs: clear. - File
packages/cli/foundation/doc-compiler/doc-loads.test.mjs: clear. - File
packages/cli/package.json: clear. - File
packages/cli/scripts/generate-search-catalog.mjs: clear; the temp-folder fix holds. - File
packages/cli/test-utils/pack-cli.mjs: clear. - File
packages/cli/test/packed-search-catalog.test.mjs: clear.
Maintainer impact
A machine's first
searchorbuildgathers search's whole catalog from the CLI's and Core's shipped files: every component, hook, doc topic and section, template and theme. In a project with no integrations that takes about 350 ms of work, and recording and keeping the gather costs about 100 ms more. A run on a fresh machine, such as a new container or CI job, pays all of it. Every input of that gather is a file the two packages ship, so the answer is known when the CLI is packed.Intended invariant
Every run prints the same output. The stored catalog is used only when all of these are true:
mayHaveIntegrations), no installed package declares Astryx docs or blocks (discoverExternalPackages), and the project's local themes root holds no theme folder, valid or not (discoverLocalThemes).package.jsonby the fields a packer keeps.Docs spell install commands for the project's package manager, so the package manager is worked out live and picks the stored copy for it. Any mismatch gathers live, as before: an edited, added or removed file, another Core version, a checkout, or a project with an integration or a local theme.
Change
scripts/generate-search-catalog.mjsruns atprepack, after the stores the gather reads and before the build id. It installs exactly the files the CLI and Core publish into a probe project, and gathers the catalog once for each package manager docs spell commands for, each in its own process. It writesassets/search-catalog.generated.jsonin two lines. The header holds the state of every CLI and Core file and folder the gather read. The body holds the catalog in the encoding search's kept gather already uses, stored once:src/themes. The file is not committed, like the other stores.foundation/discovery/stored-search-catalog.mjs:storedSearchCatalog(coreDir, cwd)does the live project check, checks every recorded input by content, then reads the body (references resolved in its text before one parse) and returns the catalog for the package manager.keptStoredCatalog(pm)reads it without the check.api/search/_adapter.mjs: the adapter uses the store before it gathers. No command handler reads a file. When the store answers a gather, the kept gather keeps a reference to the store, not a copy of the catalog. The run's stamps already hold every file the content check read, so a warm run that finds them unchanged reads the store back without checking it again. A project with no integrations then keeps one 380 KB entry after its first search instead of six entries of 6.6 MB.pack-cli.mjs,prepack/postpackand.gitignoreinclude the new generator.doc-loads.test.mjslists its spawn.Declared difference
None in output.
Package growth:
assets/search-catalog.generated.jsonis 1,655,594 bytes unpacked and 346,209 bytes with gzip -9. The CLI tarball grows from 5,705,949 to 6,059,755 bytes (+353,806, about 6%). A plain copy of the catalog would be 2,396,856 bytes (571,777 gzip). Storing only the values that differ per package manager saves 51 KB gzip, and referring to text the other stores already hold saves 175 KB gzip. Most of what is left is doc prose that no other store holds as is (it is derived from the docs' text), and the per-file content states (about 63 KB gzip).Evidence
Packed CLI and Core from this branch's base, and from this branch. Each sample is a new machine: its own HOME, cache, config and temp folders, with
CI=1. Median of 9, in ms. First is call 1, second is call 2, warm is the median of calls 3 to 5.search button --jsonbuild "<dashboard idea>" --jsoncomponent Buttondocstemplate --listsearch button --jsonbuild "<dashboard idea>" --jsoncomponent Buttondocstemplate --listnpx, Core only: a new npm cache and_npxfolder each time (dependencies served from a warmed cache copy), the CLI installed from its tarball, thensearch button --json. Median of 7: 4,424 → 4,111 ms. The output is the same.search button --json321.4 → 324.5 (60 runs),search "date picker"408.4 → 406.0 (60),build "<dashboard idea>" --json649.6 → 646.0 (30),component Button273.4 → 271.0,docs285.8 → 286.8,template --list264.2 → 264.4 (30 each). These are within ±3 ms.searchas text,--json,--detail compactand--dense, doc, template, theme, hook and component searches, andbuildas text,--jsonand--detail compact.Scope
Components: CLI search catalog (stored at publish)
Testing
New
test/packed-search-catalog.test.mjs, using the packed CLI and a project holding a copy of Core's published files. It fails on the base and passes here (11 cases):searchandbuildasks in every output form are byte-identical to the checkout CLI, which gathers live;search install --json(which shows install commands) matches the live gather;theme eject neutral src/themes/housewrote a local theme, the store is off, andsearch house --type theme --jsonfinds the theme and matches the live gather (this case fails with the local-theme check taken out);packageManagerfield, and annpm_config_user_agentfrom another package manager, each answer as the live gather does;The CLI suites for
api/search,api/build,foundation/fs,foundation/discovery, the packed kept-gather, component-list and self-audit tests, anddoc-loadspass (105 files, 1,955 tests).