Skip to content

chore(cli): split static descriptor reader from theme-discovery - #14161

Open
Rajratna-D wants to merge 4 commits into
meta:mainfrom
Rajratna-D:refactor/static-descriptor-split
Open

Rajratna-D wants to merge 4 commits into
meta:mainfrom
Rajratna-D:refactor/static-descriptor-split

Conversation

@Rajratna-D

Copy link
Copy Markdown

Follow-up to #14147 per @cixzhang's suggestion.

Maintainer impact

packages/cli/foundation/discovery/icon-set-discovery.mjs and packages/cli/foundation/discovery/icon-definition-discovery.mjs previously imported readStaticDescriptorValue and isIgnoredThemeEntry from theme-discovery.mjs, which pulled doc-compiler (compile.mjs → docs-discovery.mjs → doc-compiler/import.mjs → fs/import-url.mjs) into static icon-set discovery's module graph. Any bundler or static analyzer following icon-set-discovery.mjs (such as Webpack cache.buildDependencies) encountered import-url.mjs's dynamic import(url).

Intended invariant

No behavior change. All existing callers of theme-discovery.mjs, icon-set-discovery.mjs, and icon-definition-discovery.mjs keep the exact same exports, runtime behavior, and single discovery path (theme-discovery.mjs re-exports all moved symbols).

Change

Smallest mechanism-only refactor with no product behavior change:

  • Extracts readStaticDescriptorValue, isIgnoredThemeEntry, STATIC_DESCRIPTOR_TYPES, descriptorStoreKey, and readDescriptorSource from packages/cli/foundation/discovery/theme-discovery.mjs into packages/cli/foundation/discovery/static-descriptor.mjs (and removes the unused descriptorReads map from theme-discovery.mjs).
  • Re-exports those five symbols from packages/cli/foundation/discovery/theme-discovery.mjs for existing callers.
  • Updates packages/cli/foundation/discovery/icon-set-discovery.mjs and packages/cli/foundation/discovery/icon-definition-discovery.mjs to import directly from ./static-descriptor.mjs.
  • Adds .changeset/static-descriptor-split.md ([chore] Internal:).

Evidence

  • Failure before the change: Static import tracing of packages/cli/foundation/discovery/icon-set-discovery.mjs reached packages/cli/foundation/fs/import-url.mjs via theme-discovery.mjs → doc-compiler/compile.mjs → discovery/docs-discovery.mjs → doc-compiler/import.mjs → fs/import-url.mjs.
  • Success after the change: icon-set-discovery.mjs and icon-definition-discovery.mjs import from static-descriptor.mjs, which only imports node:fs, doc-compiler/stored-docs.mjs, fs/read-record.mjs, and runtime/lazy-dependencies.mjs (no doc-compiler/import.mjs or fs/import-url.mjs).
  • Product/runtime behavior verified unchanged: theme-discovery.mjs re-exports all moved symbols unchanged; pnpm -F @astryxdesign/cli typecheck:strict reports 0 errors in the 4 touched CLI discovery files (the only 2 errors are pre-existing in unbuilt assets/templates/pages/*/page.tsx importing @astryxdesign/theme-neutral/built).
  • CI impact (for a change to workflows, actions or CI scripts): Not applicable (no workflows, actions, or CI scripts changed).

Scope

Components: packages/cli

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

Testing

  • pnpm review:pre --base main (0 findings)
  • pnpm -F @astryxdesign/cli typecheck:strict (0 errors in the 4 touched CLI discovery files)
  • Husky pre-commit checks (check:changesets, check:cli-structure, check:package-boundaries, prettier): passed

@vercel

vercel Bot commented Dec 1, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
astryx Building Building Preview Dec 3, 2026 4:12pm UTC

Request Review

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

astracat-bot Bot commented Dec 1, 2026 •

Copy link
Copy Markdown
Contributor

AI review status for this pull request.

Review status Updated
🔄 In progress (for maintainers only) Dec 3, 2026, 4:12 PM UTC

@github-actions github-actions Bot added community Authored by a community contributor (not on the eng/design team) needs:code-review High-risk change (new package/component/API) — needs human code review before merge labels Dec 1, 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.

Changes requested: the split itself checks out, and one changeset line needs to say what actually leaves the import graph.

  • The changeset says icon-set-discovery.mjs and icon-definition-discovery.mjs "do not pull doc-compiler into their import graph", but static-descriptor.mjs still imports ../doc-compiler/stored-docs.mjs; please name what drops out instead, for example "…no longer import doc-compiler/compile.mjs, whose graph reaches the dynamic import(url) in fs/import-url.mjs."

  • Non-blocking: please carry the reason comments that explained the cache and the JSDoc type check into static-descriptor.mjs verbatim, and give its header the @input, @output and @position lines its sibling modules have.

Reproduced locally, the seven test files that import these modules pass, the moved code is identical to the old block apart from its comments, theme-discovery.mjs keeps its exports, and the icon modules no longer reach fs/import-url.mjs. CI has not run on this head yet; a maintainer adds the ci:run label so it runs.

Claims and files checked

Review mode: same-head; reason: none

  • Live title: "chore(cli): split static descriptor reader from theme-discovery". Verified: the reader moves out of theme discovery.
  • Changed rules since the last review (0): none.
  • Claim: a follow-up to the earlier pull request, at the maintainer's suggestion. Verified in that pull request's comments.
  • Claim: the icon modules used to import the reader (and, for icon sets, the ignore filter) from theme discovery, which pulled the doc compiler and the URL importer into their graph. Verified on the base import graph.
  • Claim: bundlers that follow icon discovery met that dynamic import. Reported.
  • Claim: no behavior change; every caller keeps the same exports, runtime behavior and single discovery path through theme discovery's re-exports. Verified: every importer of the moved names found by a repository-wide search, identical executable code, the same export lists, and the related tests pass locally.
  • Claim: five symbols are extracted, re-exported, and imported directly by the icon modules, with a changeset. Verified.
  • Claim: the cache map is removed from theme discovery. Verified; it moved with the reader rather than being dropped.
  • Claim: the new module imports only the file system, the stored-docs store, the read recorder and the lazy dependency loader, and reaches neither the doc importer nor the URL importer. Verified, directly and through every module it reaches.
  • Claim: the strict typecheck has no errors in the touched files, with two pre-existing template errors. Verified locally: the same two errors, none in the touched files.
  • Claim: the pre-review checklist reports no findings. Reported.
  • Claim: the pre-commit checks (changesets, CLI structure, package boundaries, formatting) pass. Verified locally.
  • Claim: no workflow, action or CI script changes. Verified.
  • Claim: no public API, product behavior, visual or policy change, and no internal context in public text. Verified.
  • Claim (changeset): the icon modules do not pull the doc compiler into their import graph. False: the stored-docs module stays.
  • File .changeset/static-descriptor-split.md: finding (the claim above).
  • File packages/cli/foundation/discovery/icon-definition-discovery.mjs: clear.
  • File packages/cli/foundation/discovery/icon-set-discovery.mjs: clear.
  • File packages/cli/foundation/discovery/static-descriptor.mjs: clear, apart from the non-blocking comment and header notes.
  • File packages/cli/foundation/discovery/theme-discovery.mjs: clear.

Automated review (maintainer link)

Comment thread .changeset/static-descriptor-split.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.

Approved pending CI: CI has not run on this head yet; a maintainer adds the ci:run label so it runs.

The changeset now names exactly what leaves the icon modules' import graph, and the split keeps one reader and one cache behind the re-exports in theme-discovery.mjs. Reproduced locally, 18 related test files pass, and a static trace shows neither icon module reaches doc-compiler/compile.mjs or fs/import-url.mjs any more.

  • Non-blocking: static-descriptor.mjs still lacks two reason comments from the old location, on staticThemeValue (the synchronous-API constraint) and on the options parameter of readStaticDescriptorValue (what data accepts), and scripts/generate-stored-docs.mjs:186 still names theme-discovery.mjs as where the published package reads the stored value.
Claims and files checked

Review mode: full; reason: author-not-engowner

  • Live title: "chore(cli): split static descriptor reader from theme-discovery". Verified: the reader moves out of theme discovery into its own module.
  • Claim: a follow-up to the earlier pull request, at the maintainer's suggestion. Verified in that pull request's comments.
  • Claim: the icon modules used to take the reader (and, for icon sets, the ignore filter) from theme discovery, whose imports reach the doc compiler and, through it, the URL importer. Verified on the base import graph, along the exact chain the description gives.
  • Claim: bundlers that follow icon-set discovery met the URL importer's dynamic import. Reported.
  • Claim: no behavior change; every caller of the three modules keeps the same exports, runtime behavior and single discovery path through the re-exports. Verified: identical export lists on both trees, every importer of the moved names found by a repository-wide search either imports the new module directly (the two icon modules) or goes through the re-export, the same module instance, identical executable code apart from imports, no top-level side effects in the modules the icon code no longer loads, and the related tests pass locally.
  • Claim: five symbols move to the new module and theme discovery re-exports them. Verified.
  • Claim: the cache map is removed from theme discovery. Verified: it moved with the reader, and theme discovery no longer references it.
  • Claim: the icon modules import the new module directly. Verified.
  • Claim: a chore changeset is added. Verified; the changeset check passes locally.
  • Claim: the new module imports only the file system, the stored-docs store, the read recorder and the lazy dependency loader, and reaches neither the doc importer nor the URL importer. Verified, directly and through every module it reaches.
  • Claim: the strict typecheck reports no errors in the touched files and two existing errors in template pages. Verified locally: the same two errors, in untouched pages.
  • Claim: no workflow, action or CI script changes. Verified.
  • Claim: no public API, product behavior, visual or policy change, and no internal context in public text. Verified.
  • Claim: the pre-review checklist reports no findings. Reported.
  • Claim: the pre-commit checks (changesets, CLI structure, package boundaries, formatting) pass. Verified locally.
  • Claim (changeset): the icon modules no longer import the doc compiler's compile module, whose graph reaches the URL importer's dynamic import. Verified on the head import graph.
  • File .changeset/static-descriptor-split.md: clear.
  • File packages/cli/foundation/discovery/icon-definition-discovery.mjs: clear.
  • File packages/cli/foundation/discovery/icon-set-discovery.mjs: clear.
  • File packages/cli/foundation/discovery/static-descriptor.mjs: clear, apart from the non-blocking comment note.
  • File packages/cli/foundation/discovery/theme-discovery.mjs: clear.

Automated review (maintainer link)

@cixzhang

cixzhang commented Dec 3, 2026

Copy link
Copy Markdown
Contributor

🤖 (Posted by Cindy's agent.) Welcome, @Rajratna-D, and thank you for this clean split! The automated review approved it, and we'll start CI now. Three small leftovers from the move, to get it to a completely clean review: static-descriptor.mjs still needs the two reason comments from the old location (on staticThemeValue, the synchronous-API constraint, and on the options parameter of readStaticDescriptorValue, what data accepts), and scripts/generate-stored-docs.mjs:186 still names theme-discovery.mjs as where the published package reads the stored value.

@cixzhang cixzhang closed this Dec 3, 2026
@cixzhang cixzhang reopened this Dec 3, 2026
@Rajratna-D

Copy link
Copy Markdown
Author

🤖 (Posted by Cindy's agent.) Welcome, @Rajratna-D, and thank you for this clean split! The automated review approved it, and we'll start CI now. Three small leftovers from the move, to get it to a completely clean review: static-descriptor.mjs still needs the two reason comments from the old location (on staticThemeValue, the synchronous-API constraint, and on the options parameter of readStaticDescriptorValue, what data accepts), and scripts/generate-stored-docs.mjs:186 still names theme-discovery.mjs as where the published package reads the stored value.

Thank you @cixzhang! Pushed 47e7b50e2f to restore the two JSDoc reason comments in static-descriptor.mjs (staticThemeValue and readStaticDescriptorValue's options) and update packages/cli/scripts/generate-stored-docs.mjs to reference static-descriptor.mjs.

@cixzhang cixzhang added the ci:run A maintainer lets this outside contributor's pull request run CI (AST-030 FR17) label Dec 3, 2026
@cixzhang cixzhang closed this Dec 3, 2026
@cixzhang cixzhang reopened this Dec 3, 2026
@github-actions

github-actions Bot commented Dec 3, 2026 •

Copy link
Copy Markdown
Contributor

PR Analysis Report

🔎 Preview · 47e7b50

Storybook · Sandbox · built from this PR's head

Package size: @astryxdesign/cli 6.33 MB packed (+511 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

@cixzhang

cixzhang commented Dec 3, 2026

Copy link
Copy Markdown
Contributor

/approve-spec 47e7b50

@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, Lint and CLI smoke-test runs pass on this head, and the CI pass that follows a review has not run yet.

The split is clean: the moved code is identical, theme-discovery.mjs keeps every export, and neither icon module's import graph reaches doc-compiler/compile.mjs or fs/import-url.mjs any more (traced locally, and the related tests pass locally).

  • Non-blocking: four doc lines did not move: the tails of the descriptorStoreKey and readDescriptorSource JSDoc and the summaries of authoringTypeRe and jsdocAliases (static-descriptor.mjs:192, :203, :255, :437); carrying them over verbatim from theme-discovery.mjs keeps the contract and constraints they state.
Claims and files checked

Review mode: full; reason: author-not-engowner

  • Claim, title: the static descriptor reader is split out of theme discovery. Verified (static-descriptor.mjs:131-178, theme-discovery.mjs:35-48).
  • Claim: this follows up #14147 at a maintainer's suggestion. Verified (the maintainer's comment there invites the split if it keeps one discovery path).
  • Claim: before, the icon modules pulled compile.mjs, docs-discovery.mjs, doc-compiler/import.mjs and fs/import-url.mjs in through theme-discovery.mjs. Verified (static import trace of the base).
  • Claim: a bundler following icon-set-discovery.mjs met the dynamic import(url). Reported; the trace confirms the path.
  • Claim: no behavior change; callers keep the same exports, runtime behavior and single discovery path. Verified (23 exports before and after, 21 moved declarations code-identical, one shared module, related tests pass locally).
  • Claim: the five exports move to static-descriptor.mjs, and the descriptor cache leaves theme-discovery.mjs. Verified; the cache moved with its only reader (static-descriptor.mjs:28).
  • Claim: theme-discovery.mjs re-exports the five. Verified (:35-48).
  • Claim: the icon modules import from static-descriptor.mjs. Verified (icon-set-discovery.mjs:36-39, icon-definition-discovery.mjs:22).
  • Claim: a [chore] Internal: changeset is added. Verified; the changeset check passes locally.
  • Claim: static-descriptor.mjs imports only node:fs, stored-docs.mjs, read-record.mjs and lazy-dependencies.mjs, with no path to doc-compiler/import.mjs or fs/import-url.mjs. Verified directly (:14-21) and over the full static import graph of both icon modules.
  • Claim: the strict typecheck has no errors in the touched files and two existing template errors. Reported; reproduced locally (exactly those two).
  • Claim: no workflow, action or CI script changes. Verified.
  • Claim: no public API, behavior, visual or policy change, and no internal context. Verified.
  • Claim: the pre-review checklist and pre-commit checks pass. Reported; the changeset, CLI structure, package boundary and Prettier checks pass locally.
  • Claim, changeset: the icon modules no longer import doc-compiler/compile.mjs, whose graph reaches import(url) in fs/import-url.mjs. Verified (static import trace).
  • File .changeset/static-descriptor-split.md: clear.
  • File packages/cli/foundation/discovery/icon-definition-discovery.mjs: clear.
  • File packages/cli/foundation/discovery/icon-set-discovery.mjs: clear.
  • File packages/cli/foundation/discovery/static-descriptor.mjs: the non-blocking note above.
  • File packages/cli/foundation/discovery/theme-discovery.mjs: clear.
  • File packages/cli/scripts/generate-stored-docs.mjs: clear.

Automated review (maintainer link)

];

/**
* Where a descriptor's statically read value is stored at publish.

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: four doc lines did not move from theme-discovery.mjs, and each states a contract or a constraint. Please carry them over verbatim.

Here, descriptorStoreKey:

 * Where a descriptor's statically read value is stored at publish: by the
 * hash of its text, the type it is read as, and whether plain data counts.

Line 203, readDescriptorSource:

 * The static value a descriptor's source default-exports (see
 * {@link readStaticDescriptorValue}); throws when it is not one.

Line 255, authoringTypeRe (the regex matches only a type with its whitespace removed):

/**
 * `import('@astryxdesign/cli/authoring').<typeName>`, without whitespace.
 * @param {string} typeName
 */

Line 437, jsdocAliases:

 * The type names the file's JSDoc binds with `@typedef` or `@import`, from any
 * JSDoc comment in the module, as TypeScript reads them.

@cixzhang

cixzhang commented Dec 3, 2026

Copy link
Copy Markdown
Contributor

🤖 (Posted by Cindy's agent.) Thanks for restoring the JSDoc, @Rajratna-D! One small leftover from the split, to keep the review completely clean: two importers still import through theme-discovery.mjs's re-export path. Pointing them straight at static-descriptor.mjs finishes the move.

@cixzhang

cixzhang commented Dec 3, 2026

Copy link
Copy Markdown
Contributor

🤖 (Posted by Cindy's agent.) A correction to my earlier note, @Rajratna-D: the re-export paths are fine as they are. What the latest review actually lists is four doc lines that didn't move with the code. Please carry these over verbatim from theme-discovery.mjs into static-descriptor.mjs: the tails of the descriptorStoreKey and readDescriptorSource JSDoc, and the summaries of authoringTypeRe and jsdocAliases (around lines 192, 203, 255 and 437). That's the last item before this can merge. If you'd rather we make that edit on your branch with you credited, just say so. Thank you!

@Rajratna-D

Copy link
Copy Markdown
Author

@cixzhang Restored those four JSDoc blocks verbatim in static-descriptor.mjs (descriptorStoreKey, readDescriptorSource, authoringTypeRe, and jsdocAliases) and pushed a68dbf4a7f. Ready for ci:run and merge!

@cixzhang

cixzhang commented Dec 3, 2026

Copy link
Copy Markdown
Contributor

/approve-spec a68dbf4

This branch was successfully deployed

1 active (outdated) deployment
Preview — 47e7b50e Deployed Dec 3, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci:run A maintainer lets this outside contributor's pull request run CI (AST-030 FR17) CLA Signed This label is managed by the Meta Open Source bot. community Authored by a community contributor (not on the eng/design team) needs:code-review High-risk change (new package/component/API) — needs human code review before merge

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants