Skip to content

perf(cli): keep template discovery for component and template in projects with no integration - #12585

Merged
josephfarina merged 3 commits into
mainfrom
josephfarina/warm-miss-core-only-templates
Nov 18, 2026
Merged

josephfarina merged 3 commits into
mainfrom
josephfarina/warm-miss-core-only-templates

Conversation

@josephfarina

Copy link
Copy Markdown
Contributor

User need

An agent in a project that uses only Core often asks astryx component or astryx template for a name that does not exist. Each such miss read every one of the CLI's template docs again, so a warm miss cost as much as a cold one.

Problem and solution fit

component and template now record template discovery into the per-user catalogs folder once that folder exists (a lookup miss makes it), and they never make the folder themselves. Later misses read the kept summary instead of every template doc. Every answer is unchanged.

Stacked on #12538, which keeps the stored-list check and Core's match views; this pull request keeps template discovery for the same commands.

Testing

  • packages/cli/test/packed-gather-cache.records.test.mjs checks, on the packed CLI, that a warm miss in a Core-only project reads the kept summary and that the commands never create the catalogs folder.
  • Search, lookups, docs forms, build answers, the typo grid and the stale-cache cases are identical to the base.
  • Speed: a warm component or template lookup that misses in a project with only Core answers about 55–60 ms faster; the one call that first records the summary pays about 50 ms once. Projects with integrations are unchanged.

@vercel

vercel Bot commented Nov 18, 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 18, 2026 6:26am UTC

Request Review

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

astracat-bot Bot commented Nov 18, 2026 •

Copy link
Copy Markdown
Contributor

AI review status for this pull request.

Review status Updated
🟢 Reviewed (for maintainers only) Nov 18, 2026, 6:34 AM UTC

@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 caching change itself checks out (warm lookups hit, answers match fresh runs, and adding an integration later leaves no stale template list), but three small fixes are needed first.

  • packages/cli/test/packed-gather-cache.records.test.mjs:41-52 copies the fixture's exported templatesEntries, so delete the local templateEntries and assert templatesEntries(tmp).size instead.
  • packages/cli/foundation/integrations/may-have-integrations.mjs:17-20 still says component and template skip the recorder in a project with no integration, and packages/cli/foundation/fs/gather-cache.mjs:50-52 still says only doctor never makes the folder, so update both headers to the new rule.
  • The new bare-project case only counts template entries, so it proves neither the warm hit the description claims nor the "keeps only template discovery" in its title (a warm component Button also keeps a doc parse); run the warm asks through expectWarmHit and assert or reword what is kept.

The changeset's "about 55–60 ms" measured 20–31 ms at the median here, so consider saying what was measured. Repository CI has not run on this head yet.

Claims and files checked

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

  • Claim (changeset): a warm component or template miss in a Core-only project is about 55–60 ms faster. Direction verified (20–31 ms median faster here); magnitude not reproduced.
  • Claim (changeset): template discovery is now kept for those commands. Verified (gather-cache.mjs:320-338; test fails on the base at records.test.mjs:357, passes on the head).
  • Claim (changeset and description): every answer is unchanged. Verified: kept runs match fresh runs for four lookups and after the project gains an integration.
  • Claim: the two commands record into an existing catalogs folder and never create it. Verified (gather-cache.mjs:331, :334; test :351-353).
  • Claim: a lookup miss creates the folder. Verified (name index, name-index.mjs:110-136).
  • Claim: later misses read the kept summary instead of every template doc. Verified in code (template-adapter.mjs:1547) and by a warm-hit check.
  • Claim: the test checks that a warm miss reads the kept summary. False: it checks that one summary is kept, not that it is read.
  • Claim: the test checks that the commands never create the folder. Verified for template --list and component Button.
  • Claim: search, lookups, docs, build, typo and stale-cache cases match the base. Partly checked: the kept-catalog suite has identical results on base and head; the other comparisons are not in the repository.
  • Claim: the first recording call pays about 50 ms once. Consistent (about 45 ms in one sample).
  • Claim: projects with integrations are unchanged. Verified (same path when an integration can load).
  • Claim: stacked on #12538. Verified.
  • File .changeset/warm-miss-core-only-templates.md: clear (timing note above).
  • File packages/cli/foundation/fs/gather-cache.mjs: gate logic clear; header at :50-52 stale.
  • File packages/cli/test/packed-gather-cache.records.test.mjs: copied helper at :41-52; case at :344-357 proves less than claimed.

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.

Approved pending CI: CI has not run on this head yet; it runs once this pull request targets main.

The three earlier fixes are in: the bare-project case uses the fixture's templatesEntries, checks the warm hit with expectWarmHit and lists every kind of entry kept, and both headers describe the new recording rule. One optional point: the changeset's "about 55–60 ms" measured 20–31 ms at the median in our runs, so consider describing the saving without a fixed figure.

Claims and files checked

Review mode: incremental; reason: none

  • Claim: on the base, a warm component or template miss in a Core-only project re-read every template doc. Verified: the base recorder skipped both commands there, and the head's test fails on the base at packed-gather-cache.records.test.mjs:382.
  • Claim: the two commands now record template discovery into an existing catalogs folder and never create it. Verified (gather-cache.mjs:323-336; test :371-373, :382).
  • Claim: a lookup miss creates the folder. Verified: the not-found name index makes it, and the test exempts the miss at :371.
  • Claim: later misses read the kept records instead of every template doc. Verified: the warm reruns at :380 rewrite no entry.
  • Claim (changeset and description): every answer is unchanged. Verified: kept and warm answers equal fresh runs (:351-356, :374-376, :381).
  • Claim: stacked on #12538. Verified: its branch is the base, and the kept kinds include its summaries.
  • Claim: the test checks the warm miss and that the commands never create the folder. Verified (:371-373, :380).
  • Claim: search, lookups, docs forms, build answers, the typo grid and stale-cache cases match the base. Consistent: the kept-catalog suites give the same results on base and head; the full replay was not rerun.
  • Claim (changeset and description): about 55–60 ms faster, and about 50 ms once for the first record. Direction verified (20–31 ms faster at the median, about 45 ms once); magnitude not reproduced.
  • Claim: projects with integrations are unchanged. Verified: the gate takes the base path where an integration can load.
  • File .changeset/warm-miss-core-only-templates.md: clear (timing note above).
  • File packages/cli/foundation/fs/gather-cache.mjs: clear.
  • File packages/cli/foundation/integrations/may-have-integrations.mjs: clear.
  • File packages/cli/test/packed-gather-cache.records.test.mjs: clear.

Automated review (maintainer link)

@josephfarina
josephfarina changed the base branch from josephfarina/search-warm-miss-kept-core to main November 18, 2026 06:13
…ith no integration

A warm component or template miss in a project with only Core read each of
the CLI's template docs on every call: those commands recorded nothing there,
so template discovery was never kept. They now record into the per-user
catalogs folder once it exists (a lookup miss makes it), and never make it.
…egration

Use the fixture's templatesEntries, update the headers that still said
component and template skip the recorder there, and check the warm hit and
every kind of entry the bare project keeps.

@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 finished on this head yet.

component and template now keep template discovery in Core-only projects once the catalogs folder exists, which the global-mode spec's write rules allow, and the bare-project test proves it by failing on the base. One optional point: the changeset's "about 55–60 ms" measured 30–37 ms faster on warm misses in a side-by-side run, so consider describing the saving without a fixed figure.

Claims and files checked

Review mode: full; reason: rebase

  • Claim: on the base, a warm component or template miss in a Core-only project re-read every template doc. Verified: the base recorder skipped both commands there, and the head's test fails on the base at packed-gather-cache.records.test.mjs:382.
  • Claim: the two commands now record template discovery into an existing catalogs folder and never create it themselves. Verified (gather-cache.mjs:323-340; test :371-373, :382).
  • Claim: a lookup miss creates the folder. Verified: the not-found name index creates it on base and head alike; the test exempts the miss at :371.
  • Claim: later misses read the kept records instead of every template doc. Verified: the warm reruns at :380 rewrite no entry.
  • Claim (changeset and description): every answer is unchanged. Verified: kept and warm answers equal fresh runs (:351-356, :374-376, :381), and 15 timed rounds per command gave identical output on base and head.
  • Claim: stacked on #12538. Verified: #12538 is merged and is this pull request's base; the kept kinds at :386-393 include its summaries.
  • Claim: the test checks, on the packed CLI, the warm miss and that the commands never create the folder. Verified (:371-373, :380-393).
  • Claim: search, lookups, docs forms, build answers, the typo grid and the stale-cache cases match the base. Consistent: every kept-catalog suite passes on the head and compares kept answers with fresh ones; the full replay was not rerun.
  • Claim (changeset and description): about 55–60 ms faster, and about 50 ms once for the first record. Direction verified: 30–37 ms faster on warm misses and about 40–43 ms once, side by side.
  • Claim: projects with integrations are unchanged. Verified: where an integration can load, the gate takes the base path.
  • File .changeset/warm-miss-core-only-templates.md: clear (timing note above).
  • File packages/cli/foundation/fs/gather-cache.mjs: clear.
  • File packages/cli/foundation/integrations/may-have-integrations.mjs: clear.
  • File packages/cli/test/packed-gather-cache.records.test.mjs: clear.

Automated review (maintainer link)

@github-actions

Copy link
Copy Markdown
Contributor

PR Analysis Report

🔎 Preview · 8243a7c

Storybook · Sandbox · built from this PR's head

Package size: measured; main has no measurement of the merge base to compare yet.

API changes: unknown (base surface unavailable): richtext, theme-butter, theme-chocolate, theme-gothic, theme-matcha, theme-neutral, theme-stone, theme-y2k

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
josephfarina merged commit 23cfeb3 into main Nov 18, 2026
81 checks passed
@github-actions
github-actions Bot deleted the josephfarina/warm-miss-core-only-templates branch November 19, 2026 06:04

This branch was successfully deployed

1 active deployment
Preview — 8243a7cd Deployed Nov 18, 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