Repository navigation
perf(cli): keep each shipped doc's parse, and build doc schemas on first parse - #12166
Conversation
|
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.
This pull request needs an engineering owner's spec decision and two small additions before it can be approved.
An engineering owner records the decision on the spec:AST-081 FR7 change, which lets the per-user catalogs folder keep each stored doc's parse keyed by its text, by commenting /approve-spec <full head SHA> on this pull request; the author may do so as an engineering owner.
docs/architecture/cli-surface.mdINV10 (lines 285-289) still lists the per-user writes without the new doc-parse entry, so add the same item there that FR7 gains.- The description has no
## Writing rubric resultsfor the record edits, which the knowledge-record rules require before review.
The code checked out: output stayed byte-identical across fresh, keeping and reading runs, a failing parse is never kept, and the drift locks still catch schema drift inside the new builders.
Claims and files checked
Review mode: full; reason: no-earlier-review
- Changeset: commands that keep catalogs keep each shipped doc's parse by its text: verified, limited to plain-data shipped docs without a publish-time parse (
stored-docs.mjs:187-195) - Changeset: parsers build their schemas on first parse: verified (eight modules, whitespace-insensitive diff)
- Changeset and description: output, error output and exit codes unchanged: verified (packed round-trip test; byte-identical probe runs)
- Description: schemas used to be built at load, and Core docs were parsed again on every run: verified (base modules; publish-time parses cover only the CLI's own docs)
- Description: a failing parse is never kept: verified (
gather-cache.mjs:1173; value-store test) - Description: only docs read from the shipped store are kept: verified (
stored-docs.mjs:189-190) - Description: kept only in runs that keep catalogs, and a project with no integration keeps none: verified (
gather-cache.mjs:1144; Core-only probe) - Description: digest check, read-back rule, build and folder in the key: verified (
gather-cache.mjs:1143-1199,:626-637) - Description: stored, then kept, then fresh parse: verified (
parse-readable.mjs:32) - Description: the global-mode spec's catalogs list gains the item: verified (
spec.md:420-421) - Description: schemas, checks and messages unchanged: verified (whitespace-insensitive diff)
- Description: timing tables and the 14,616-parse comparison: not reproduced (measurements)
- Description: no CI change and no public API change: verified (no workflow files; exported modules keep their names)
- Description: the listed tests, including the two removal claims for the value store: verified (read, and all pass here)
- Description: typechecks pass with the drift locks: verified (authoring contract typecheck clean; a seeded drift still fails on head as on base)
- Description: 14 theme-edit test failures also occur on main: not reproduced
.changeset/doc-parses-kept-per-user.md: clear (claims checked above)docs/specs/AST-081-global-mode/spec.md: waits on the owner decision; its companion list indocs/architecture/cli-surface.mdINV10 is not updated; rubric results missingpackages/cli/authoring/doctypes/_schema.mjs: clear (wrap only; drift locks still checked)packages/cli/authoring/codemod/parse.mjs,packages/cli/authoring/config/parse.mjs: clear (wrap only)packages/cli/authoring/doctypes/{template,theme,icon-set,icon-definition}/parse.mjs: clear (wrap only)packages/cli/authoring/doctypes/{command,component,enum,hook,namespace,reference,schema}/parse.mjs,packages/cli/authoring/doctypes/legacy.mjs: clear (read schemas throughdocSchemas())packages/cli/foundation/doc-compiler/parse-readable.mjs: clearpackages/cli/foundation/doc-compiler/stored-docs.mjs: non-blocking note (installed zod version not in the key)packages/cli/foundation/fs/gather-cache.mjs: clearpackages/cli/foundation/fs/gather-cache.value.test.mjs,packages/cli/foundation/doc-compiler/parse-quiet.test.mjs,packages/cli/test/packed-gather-cache.doc-parses.test.mjs,packages/cli/test/packed-gather-cache.malformed.test.mjs: clear (pass)packages/cli/authoring/doctypes/load-contract.test.mjs,packages/cli/test/authoring-types.test.mjs,packages/cli/test-utils/kept-entry.mjs: clear
PR Analysis Report🔎 Preview ·
|
There was a problem hiding this comment.
This pull request needs an engineering owner's spec decision before it can be approved; the code itself checks out.
An engineering owner records the decision on the spec:AST-081 FR7 and architecture:cli-surface INV10 changes, which let the per-user catalogs folder keep each stored doc's parse keyed by its text, by commenting /approve-spec <full head SHA> on this pull request; the author may do so as an engineering owner.
- Regression (non-blocking): the header of
packages/cli/foundation/fs/gather-cache.mjs(lines 40-43) still says the doc's text and the build are all a kept parse depends on, so name the zod release the parsers load there too.
The INV10 list item, the writing rubric results and the zod version in the key are now in place, and output stayed identical across fresh, keeping and reading runs.
Claims and files checked
Review mode: full; reason: spec-record
- Changeset: commands that keep catalogs keep each shipped doc's parse by its text: verified, limited to stored docs without a publish-time parse (
stored-docs.mjs:220-231) - Changeset: parsers build their schemas on first parse: verified (seven builder modules; whitespace-insensitive diff)
- Changeset and description: output, error output and exit codes unchanged: verified (packed round-trip tests; string and regex literals identical)
- Description: schemas used to be built at load, and Core docs were parsed again on every run: verified (base modules; publish-time parses cover only the CLI's own docs)
- Description: a failing parse is never kept: verified (
gather-cache.mjs:1173; value-store test) - Description: only docs read from the shipped store are kept, and only in runs that keep catalogs, so a project with no integration keeps none: verified (
stored-docs.mjs:222-223,gather-cache.mjs:1144; records test) - Description: read-back rule, digest check, build and folder in the key: verified (
gather-cache.mjs:1143-1195,:626-637) - Description: the zod version the parsers load is in the key, read once per run, and nothing is kept when it cannot be read: verified (
stored-docs.mjs:189-206,:224-227) - Description: stored, then kept, then fresh parse: verified (
parse-readable.mjs:32) - Description: publish-time parses are served under any installed zod: verified (the stored parse is not keyed by zod)
- Description: both record lists gain the item, and each edit passes the writing rubric: verified (
spec.md:420-421,cli-surface.md:289; knowledge check clean) - Description: timing tables and the 14,616-parse comparison: not reproduced (measurements)
- Description: no CI change and no public API change: verified (no workflow files; exported entry points keep their names)
- Description: the listed tests and their removal claims (digest check, run check, zod key): verified (all pass; each removal fails its case)
- Description: typechecks pass with the drift locks: verified (authoring contract typecheck clean; a seeded drift still fails)
- Description: 14 theme-edit test failures also occur on main: not reproduced
.changeset/doc-parses-kept-per-user.md: cleardocs/specs/AST-081-global-mode/spec.md,docs/architecture/cli-surface.md: wait on the engineering-owner decision; the two lists now agreepackages/cli/foundation/fs/gather-cache.mjs: non-blocking note (header, lines 40-43)packages/cli/foundation/doc-compiler/stored-docs.mjs,packages/cli/foundation/doc-compiler/parse-readable.mjs: clearpackages/cli/authoring/doctypes/_schema.mjs,packages/cli/authoring/codemod/parse.mjs,packages/cli/authoring/config/parse.mjs: clear (wrap only; drift locks still checked)packages/cli/authoring/doctypes/{template,theme,icon-set,icon-definition}/parse.mjs: clear (wrap only)packages/cli/authoring/doctypes/{command,component,enum,hook,namespace,reference,schema}/parse.mjs,packages/cli/authoring/doctypes/legacy.mjs: clear (read schemas throughdocSchemas())packages/cli/foundation/fs/gather-cache.value.test.mjs,packages/cli/foundation/doc-compiler/parse-quiet.test.mjs,packages/cli/test/packed-gather-cache.doc-parses.test.mjs,packages/cli/test/packed-gather-cache.malformed.test.mjs: clear (pass)packages/cli/authoring/doctypes/load-contract.test.mjs,packages/cli/test/authoring-types.test.mjs,packages/cli/test-utils/kept-entry.mjs: clear
|
/approve-spec 78dbb91 |
|
/approve-spec c4db41b |
There was a problem hiding this comment.
Approved pending CI. The two per-user write list edits (spec:AST-081 FR7 and architecture:cli-surface INV10) carry an engineering owner's approval for this head, and the header comment now names the zod release, which resolves the last open note. Lint and the CLI smoke test pass, but the main CI run was cancelled because CI was full, so it needs a re-run on this head before merge.
Claims and files checked
Review mode: incremental; reason: none
- Changed rules (0): none.
- Claim: the doc parsers build their schemas on first parse, not at load. Verified in all seven builder modules.
- Claim: a run that keeps catalogs keeps each shipped doc's parse by the doc's text. Verified, for shipped docs with no publish-time parse; the key also holds the zod release and the CLI build.
- Claim: output, error output and exit codes are unchanged. Verified by the packed-CLI test across fresh, keeping and reading runs, in text and JSON.
- Claim: a failing parse is never kept. Verified by the value test.
- Claim: nothing is kept outside a run that keeps catalogs, or in a project with no integration. Verified by the value test and the records suite.
- Claim: the store writes only text that reads back equal, checks a digest, and keys by build and CLI folder. Verified in the store code and its tests.
- Claim: the zod release is read once per run from where the parsers resolve it, and nothing is kept when it cannot be read. Verified.
- Claim: the stored parse comes first, then the kept one, then a fresh parse. Verified.
- Claim: the publish-time parses rest on the same zod assumption. Accurate as stated.
- Claim: the two per-user write lists gain the new item. Verified.
- Claim: no public API change, no CI impact, no internal context. Verified.
- Claim: the new tests fail without the digest check, the run check and the zod release in the key. Verified by removing each.
- Claim: parsing every shipped doc prints nothing. Verified; the test watches the console and both output streams.
- Claim: the typechecks pass, the drift locks included. Verified for the authoring-contract, JSON API and declaration builds.
- Claim: the speed tables, the 14,616-parse comparison and the 14 failing theme-edit tests on main. These are the author's measurements and were not reproduced.
- Files, each clear:
.changeset/doc-parses-kept-per-user.md,docs/architecture/cli-surface.md,docs/specs/AST-081-global-mode/spec.md. - Files, each clear:
packages/cli/authoring/doctypes/_schema.mjs,packages/cli/authoring/codemod/parse.mjs,packages/cli/authoring/config/parse.mjs, and theicon-definition,icon-set,templateandthemeparsers underpackages/cli/authoring/doctypes/. - Files, each clear: the
command,component,enum,hook,namespace,referenceandschemaparsers underpackages/cli/authoring/doctypes/, andpackages/cli/authoring/doctypes/legacy.mjs. - Files, each clear:
packages/cli/foundation/doc-compiler/parse-readable.mjs,packages/cli/foundation/doc-compiler/stored-docs.mjs,packages/cli/foundation/fs/gather-cache.mjs. - Files, each clear:
packages/cli/foundation/doc-compiler/parse-quiet.test.mjs,packages/cli/foundation/fs/gather-cache.value.test.mjs,packages/cli/test/packed-gather-cache.doc-parses.test.mjs,packages/cli/test/packed-gather-cache.malformed.test.mjs,packages/cli/authoring/doctypes/load-contract.test.mjs,packages/cli/test/authoring-types.test.mjs,packages/cli/test-utils/kept-entry.mjs.
Maintainer impact
Every command that reads a doc paid twice for zod in each run. Each doc parser built all of its schemas when the CLI loaded it, and most runs never call most parsers.
componentthen parsed the same shipped Core doc again on every run, although its result depends only on the doc's text. In a project with an integration, a warmcomponentrun spent about 20 ms on this.Intended invariant
Every command prints exactly what it printed: the same output, error output, exit code and JSON. A doc parse that fails throws the same error in the same words on every run, because it is never kept. A kept parse is used only for a doc whose exports come from the shipped stored docs, so the doc's text and the CLI build decide it. It is kept only in a run that already keeps catalogs, so a project with no integration keeps nothing, as before.
Change
authoring/doctypes/_schema.mjs, the template, theme, icon-set and icon-definition parsers, and the config and codemod parsers) build their schemas the first time they parse, not when they load. Each module keeps one builder and reads its schemas through it. The schemas, their checks and their error messages are the same as before; they are only built later.persistedValueinfoundation/fs/gather-cache.mjskeeps a value that depends only on its key and the CLI build. It writes the value's text only when that text reads back as an equal value (the rule the stored parses already use), with a digest of the text, so an entry changed after it was written is a miss. The build id and the CLI folder are in its key, as in every kept entry.keptParseinfoundation/doc-compiler/stored-docs.mjskeeps the parse of a stored doc's export throughpersistedValue, keyed by the doc's text, the export name and the version of the zod copy the doc parsers load (read once per run, from where the parsers resolve it). The build id names the CLI's own code, not its dependencies, and a reinstall can put another zod beside the same build. When the zod version cannot be read, nothing is kept.parseReadableDocuses the stored parse first, then the kept one, then parses as before.spec:AST-081FR7 andarchitecture:cli-surfaceINV10: the lists of what the per-user catalogs folder keeps name each stored doc's checked contents, keyed by its text.Evidence
Same machine, the packed CLI before and after this change, both projects in sibling folders of the same path length, each case run interleaved after a warm-up, 11 runs each (95% confidence interval on the difference):
component, ten lookups, a project with an integrationtemplate(5),theme build(5),upgrade(2), with an integrationsearch, twelve requests, with an integrationbuild(6),docs(6),doctor(2),hook(2), with an integrationhook,theme build,doctor,templateandupgrade, a Core-only projectsearch(12) andbuild(6), a Core-only projectcomponent(10) anddocs(6), a Core-only projectWeighted over the battery's commands: 381 → 367 ms (−3.6%) with an integration, 270 → 262 ms (−2.9%) in a Core-only project.
First runs, on a fresh cache folder (the code compile cache warm), 41 each, interleaved:
component, integration with a JavaScript manifestcomponent, integration with a TypeScript manifestbuild, integration with a TypeScript manifestWith an older integration release that ships a TypeScript manifest, a first
componentrun costs about 9 ms more (interval +1 to +36 ms); with a compiled (JavaScript) manifest, which current integration releases ship, first runs are unchanged. Most runs are warm, so across typical use this change is net faster.Writing rubric results
The two record edits each add one item to a list of per-user writes:
spec:AST-081FR7 andarchitecture:cli-surfaceINV10.Scope
Components: cli (doc parsers, kept catalogs)
Testing
foundation/fs/gather-cache.value.test.mjs(new): a value is kept in a run that keeps catalogs and read back with its key order; outside such a run nothing is kept; a computation that throws keeps nothing and throws again; a value that does not read back exactly (an undefined property, a date, NaN, −0) is never kept; a changed entry is a miss and is stored over; another CLI build is a miss. Removing the digest check fails the changed-entry case; removing the run check fails the outside-a-run case.test/packed-gather-cache.doc-parses.test.mjs(new, packed CLI): a run that reads a kept parse prints the same output and error output as a fresh parse, in text and JSON, and keeps nothing new; with a zod copy that names another version, the run parses and keeps every doc again and prints the same (leaving zod out of the key fails this case); every module that imports zod loads one copy of it, in the run that keeps a parse and in the one that reads it back.foundation/doc-compiler/parse-quiet.test.mjs(new): parsing every doc the CLI and Core ship prints nothing, so a kept parse cannot hide a warning. A doc parse returns a value or throws (parseReadableDoc→parseDoc→ the kind's parser →safeParse, thenformatZodErrorandthrow); none of these modules writes to the console or an output stream. Adding a warning to the legacy parser fails this test.test/packed-gather-cache.malformed.test.mjs: the kept kinds include the doc parses, and every damaged entry is a miss that is stored over.test/packed-gather-cache.records.test.mjsstill holds: a project with no integration keeps nothing.api/theme-editfiles, which fail the same way onmainon the test machine.