Repository navigation
perf(cli): theme build keeps what its css-tree checks of a theme's keys find - #11961
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
AI review status for this pull request.
|
PR Analysis Report🔎 Preview ·
|
…'s code and data last changed before the process started
There was a problem hiding this comment.
The kept css-tree answers look correct: they are keyed on the sorted keys or names and the build id, checked again against css-tree's file stamps, and equal to fresh checks in the new tests.
Approval waits on a spec decision: the new per-user cache entry is not in spec:AST-081 FR7 or architecture:cli-surface INV10 on main, and this pull request amends both records. An engineering owner records the decision by commenting /approve-spec <full head SHA> on this pull request; the author may do so as an engineering owner.
Required fix:
- The description's Scope line says "No output, flag or JSON shape changes", but
doctor's kept-cache row now names the new entry (packages/cli/api/doctor/doctor.mjs:2341), so reword it, for example "Notheme buildoutput, flag or JSON shape changes;doctor's cache row names the new entry."
Optional: the loaded-files.mjs and css-tree.mjs headers lag the code, and the cache key could name where css-tree resolved (details inline).
Claims and files checked
Review mode: full; reason: no-earlier-review
- Claims:
- Changeset: a repeat build of a theme with pseudo-class keys or plain token names finishes about 25 to 35 ms sooner: verified by mechanism (css-tree's load is skipped; the read-back checks about 135 file stamps); end-to-end timing not repeated.
- Changeset: the answers are kept beside the kept gathers and read back while the keys and css-tree's files are unchanged, so such a build loads no css-tree: verified (
foundation/runtime/css-tree.mjs:67-112; the new tests; theme build reaches css-tree only through the two checks). - Changeset: warnings, errors and written files do not change: verified (kept answers equal fresh checks; the theme build test suite passes).
- Description: loading css-tree costs every build of such a theme: verified (the base loads it in both checks).
- Description: stamps are taken as the process first finds each file loaded, so a process that loaded css-tree before a reinstall keeps nothing: verified (
css-tree.mjs:79-84and its test). - Description: the pseudo-key checks read only the key, css-tree and its selector data: verified (
api/theme/build/style-keys.mjs:50-357). - Description: the token-name check reads only the name and css-tree's property data: verified (
api/theme/build/written-values.mjs:205-213). - Description: a theme with nothing to ask keeps nothing and loads no css-tree, and a check that throws keeps nothing: verified (tests).
- Description: the new helper lists the files of loaded CommonJS code: verified (
foundation/fs/loaded-files.mjs). - Description: FR7, INV10 and doctor's cache row name the new entry: verified.
- Description: timing table and command battery: author measurements, not repeated.
- Description: the listed tests exist and pass: verified.
- Description: no output, flag or JSON shape changes: false (
doctor's row text changes).
- Files:
.changeset/theme-build-css-checks-kept.md: cleardocs/architecture/cli-surface.md: waits on the spec decisiondocs/specs/AST-081-global-mode/spec.md: waits on the spec decisionpackages/cli/api/doctor/doctor.mjs: clearpackages/cli/api/theme/build/css-checks.kept.test.mjs: clearpackages/cli/api/theme/build/style-keys.mjs: clearpackages/cli/api/theme/build/written-values.mjs: clearpackages/cli/foundation/doc-compiler/doc-loads.test.mjs: clearpackages/cli/foundation/fs/gather-cache.mjs: clearpackages/cli/foundation/fs/loaded-files.mjs: optional header notepackages/cli/foundation/runtime/css-tree.mjs: optional header and key notespackages/cli/test/packed-gather-cache.records.test.mjs: clear
…s-kept # Conflicts: # packages/cli/api/theme/build/written-values.mjs
|
/approve-spec 078e394 |
|
/approve-spec c1dcd1f |
|
/approve-spec b481167 |
There was a problem hiding this comment.
Changes requested: the kept css-tree answers look correct, and the spec:AST-081 FR7 and architecture:cli-surface INV10 amendment is approved at this head, but two claims in the description are false and need correcting.
- The Scope line says "No output, flag or JSON shape changes", but
doctor's kept-cache row now names the new entry (packages/cli/api/doctor/doctor.mjs:2341), so reword it, for example "Notheme buildoutput, flag or JSON shape changes;doctor's cache row names the new entry." - The description says "The theme build's kept JavaScript uses the same file" about
foundation/fs/loaded-files.mjs, but onlyfoundation/runtime/css-tree.mjsimports it at this head, so drop that sentence or name css-tree's kept answers as its only user.
Optional: the start-time check in loaded-files.mjs could allow for coarse file times (inline), and the earlier header, cache-key and release-note notes still apply.
Claims and files checked
Review mode: incremental; reason: none
- Claims:
- Release note: a repeat build of such a theme finishes about 25 to 35 ms sooner: close to the author's 23 to 32 ms medians; "about 20 to 30 ms" fits better (optional).
- Release note: the answers are kept and read back while the keys and css-tree's files are unchanged, so such a build loads no css-tree: verified (
foundation/runtime/css-tree.mjs:66-100; the new tests). - Release note: warnings, errors and written files do not change: verified (kept answers equal fresh checks; the theme build tests pass).
- Description: css-tree loads on every build of such a theme today: verified (the base checks call it on every run).
- Description: a kept answer is read back while its inputs, the build id and every loaded css-tree code and data file keep their stamps: verified (
css-tree.mjs:66-100,foundation/fs/gather-cache.mjs:1175-1222). - Description: an answer is kept only when every such file last changed before the process started, so a process that loaded css-tree before a reinstall keeps nothing: verified (
foundation/fs/loaded-files.mjs:49-58and its tests), with the optional coarse-time note. - Description: the pseudo-key checks read only the key, css-tree and its selector data: verified (
api/theme/build/style-keys.mjs:57-400). - Description: the token-name check reads only the name and css-tree's property data, asks about exactly the names it judges, and skips Core's own surface tokens: verified (
api/theme/build/written-values.mjs:271-287,:385-410). - Description: unchanged keys load no css-tree; a theme with nothing to ask, or a check that throws, keeps nothing: verified (tests).
- Description: the new helper lists a module's loaded CommonJS files and their stamps: verified (
loaded-files.mjs). - Description: the theme build's kept JavaScript uses the same file: false (only
css-tree.mjsimports it). - Description: FR7, INV10 and doctor's cache row name the new entry, pending an engineering owner's approval: verified; the approval is recorded at this head.
- Description: timing table, output identity and command battery: author measurements, not repeated.
- Description: the listed tests exist and pass: verified.
- Description: writing rubric results: verified; the added phrase only states what the per-user cache holds.
- Description: no output, flag or JSON shape changes: false (
doctor's row text changes).
- Files:
.changeset/theme-build-css-checks-kept.md: optional wording notedocs/architecture/cli-surface.md: clear (approved amendment)docs/specs/AST-081-global-mode/spec.md: clear (approved amendment)packages/cli/api/doctor/doctor.mjs: clearpackages/cli/api/theme/build/css-checks.kept.test.mjs: clearpackages/cli/api/theme/build/style-keys.mjs: clearpackages/cli/api/theme/build/written-values.mjs: clearpackages/cli/foundation/doc-compiler/doc-loads.test.mjs: clearpackages/cli/foundation/fs/gather-cache.mjs: clearpackages/cli/foundation/fs/loaded-files.mjs: optional coarse-time and header notespackages/cli/foundation/runtime/css-tree.mjs: optional header and cache-key notespackages/cli/test/packed-gather-cache.records.test.mjs: clear
…holds where css-tree resolved; header + release note
|
/approve-spec 41978cd |
There was a problem hiding this comment.
Approved pending CI: some required checks have not finished on this head yet.
The kept css-tree answers are keyed on the inputs, css-tree's location and the build id, are served only while every loaded css-tree file keeps its stamp, and are stored only when those files changed more than 2 s before the process started; the spec:AST-081 FR7 and architecture:cli-surface INV10 amendment is approved at this head, and both description claims flagged earlier now match the code.
Optional: the test comment at css-checks.kept.test.mjs:54-55 still describes the reinstall stamps as after the process start, though line 61 now sets them 1 s before it (inline).
Claims and files checked
Review mode: incremental; reason: none
- Claims:
- Release note: a repeat build of such a theme finishes about 20 to 30 ms sooner: consistent with the author's 23 to 32 ms medians (author measurement, not repeated).
- Release note: the answers are kept and read back while the keys and css-tree's files are unchanged, so such a build loads no css-tree: verified (
css-tree.mjs:67-102;css-checks.kept.test.mjs:185-196). - Release note: warnings, errors and written files do not change: verified (kept answers equal fresh checks; the seven published themes build identical
theme.cssfrom base and head). - Description: css-tree loads on every build of such a theme today: verified on the base code path; the 30 ms figure is the author's.
- Description: a kept answer is read back while its inputs, css-tree's location, the build id and every loaded css-tree code and MDN data file keep their full stamps: verified (
css-tree.mjs:69-75,:93-102;gather-cache.mjs:1175-1208). - Description: an answer is kept only when those files last changed at least 2 s before the process started, so a process that loaded css-tree before a reinstall keeps nothing: verified (
loaded-files.mjs:53-59;css-checks.kept.test.mjs:248-267). - Description: the pseudo-key checks read only the key, css-tree and its selector data: verified (
style-keys.mjs:57-394). - Description: the token-name check reads only the name and css-tree's property data, asks about exactly the names it judges, and skips Core's own surface tokens: verified (
written-values.mjs:271-289,:388-393;css-checks.kept.test.mjs:361-370). - Description: unchanged keys load no css-tree; a theme with nothing to ask, or a check that throws, keeps nothing: verified (
css-checks.kept.test.mjs:185-273,:354-370). - Description: the new helper lists a module's loaded CommonJS files and their stamps: verified (
loaded-files.mjs:26-62). - Description: FR7, INV10 and doctor's cache row name the new entry, pending an engineering owner's approval: verified; the approval is recorded at this head.
- Description: timing table, output identity and command battery: author measurements, not repeated; output identity is consistent with the identical theme builds.
- Description: the listed tests exist and pass: verified (the new test file's 10 tests, the records, doc-loads, lazy-dependency and theme build tests).
- Description: writing rubric results: verified; the added phrase only states what the per-user cache holds.
- Description: no
theme buildoutput, flag or JSON shape changes, and doctor's cache row names the new entry: verified (doctor.mjs:2341).
- Files:
.changeset/theme-build-css-checks-kept.md: cleardocs/architecture/cli-surface.md: clear (approved amendment)docs/specs/AST-081-global-mode/spec.md: clear (approved amendment)packages/cli/api/doctor/doctor.mjs: clearpackages/cli/api/theme/build/css-checks.kept.test.mjs: optional stale-comment note (inline)packages/cli/api/theme/build/style-keys.mjs: clearpackages/cli/api/theme/build/written-values.mjs: clearpackages/cli/foundation/doc-compiler/doc-loads.test.mjs: clearpackages/cli/foundation/fs/gather-cache.mjs: clearpackages/cli/foundation/fs/loaded-files.mjs: clearpackages/cli/foundation/runtime/css-tree.mjs: clearpackages/cli/test/packed-gather-cache.records.test.mjs: clear
| // A reinstall rewrites css-tree's files: their times are after this | ||
| // process started. |
There was a problem hiding this comment.
Non-blocking: this comment says the reinstalled files' times are after this process started, but line 61 now sets them 1 s before the start, the coarse-time case the 2 s margin in loadedFileStamps covers. Suggested: // A reinstall rewrites css-tree's files; a coarse file system can record their times up to 2 s before this process started.
Summary
A theme build checks each pseudo-class key in a theme's part styles (
':hover','::before',':is(.a, .b)') and each token name that does not start with two dashes (color-scheme) with css-tree. Loading css-tree takes about 30 ms, on every build, even when no key changed since the last build.foundation/runtime/css-tree.mjs:keptCssTreeAnswer(kind, inputs, answer)keeps an answer worked out with css-tree as a summary beside the kept gathers (persistedSummary) and reads it back while all of these are unchanged:api/theme/build/style-keys.mjs: whatpseudoKeyProblemandpseudoKeyNotesgive each pseudo-class key of the theme. They read the key text, css-tree and its selector data, nothing else: no Core component docs, no build options, no environment.api/theme/build/written-values.mjs: which of the theme's token names without two dashes are CSS properties' (key in cssTree().lexer.properties). That reads the name and css-tree's property data, nothing else. The check first finds the names it asks about, with a pass that takes none for a property: when it asks about none, that pass is the answer; otherwise a second pass uses css-tree's kept answer. So it asks about exactly the names the check judges: Core's own surface tokens (color-schemeon onDark and onLight) are not judged and not asked about.foundation/fs/loaded-files.mjs(new):loadedFiles(roots), the files of the CommonJS code a module loaded, andloadedFileStamps(files), their stamps and whether each last changed before the process started.spec:AST-081FR7,architecture:cli-surfaceINV10 and doctor's cache row name the new entry.Evidence
Builds of two themes with pseudo-class keys or such token names in a project with one integration, a fresh process per call, warm, interleaved, n=15, median paired difference (95% CI):
--checkTests
api/theme/build/css-checks.kept.test.mjs(new):test/packed-gather-cache.records.test.mjs: doctor's cache row names the entry.foundation/doc-compiler/doc-loads.test.mjs: the newrequire.cachereads are listed.api/theme/build,foundation/runtime, the records, doc-loads and lazy-dependency tests pass.Spec changes
spec:AST-081FR7,architecture:cli-surfaceINV10 and doctor's cache row add "whattheme buildfinds when it checks a theme's pseudo-class keys and token names" to the per-user cache's entries. This needs an engineering owner's/approve-spec.Writing rubric results
For the FR7 and INV10 additions:
Scope
No
theme buildoutput, flag or JSON shape changes;doctor's cache row names the new entry.