Skip to content

templates: stable-only dependency gate; dashboard-scorecard drops recharts - #6730

Draft
kiranbadam wants to merge 1 commit into
meta:mainfrom
kiranbadam:fix/template-stable-deps
Draft

kiranbadam wants to merge 1 commit into
meta:mainfrom
kiranbadam:fix/template-stable-deps

Conversation

@kiranbadam

Copy link
Copy Markdown

User impact

An agent scaffolding from the dashboard-scorecard page template got a page importing recharts — a third-party charting library that is not a stable Astryx dependency. Templates are the first thing an agent copies, so a template that imports a third-party library teaches the escape hatch to every agent that scaffolds from it: their builds pull an unvetted dependency, and the resulting app diverges from the design system's supported stack. #6717 tracks exactly this: the scorecard template shipped recharts.

Problem and solution fit

Why did it happen? Nothing verified a template's imports against the stable dependency policy — a template could import anything and ship. Why does it harm the task? The agent's first build inherits a dependency the design system never promised to support. Why does that harm matter? First-build quality is the top priority: a fresh agent's first build must be visually correct with no user-supplied screenshots, and an unvetted chart library is exactly how "looks broken on first run" happens.

The fix has two parts:

  1. dashboard-scorecard no longer imports recharts — its charts are dependency-free inline SVG.
  2. A check:template-deps repo gate (wired into check:repo) so it can't recur: every template's executable imports must resolve to stable Astryx packages, React peers, documented third-party packages, or its own declared dependencies.

Expected behavior and authority

Templates may only depend on stable Astryx packages (per #6717). The new gate encodes that policy: stable packages are read from packages/* and packages/themes/* (canary-only packages are rejected as dependencies without changing any release settings), plus React peers and the documented @stylexjs/stylex, @heroicons/react, lucide-react.

Smallest restoration

  • packages/cli/assets/templates/pages/dashboard-scorecard/page.tsx: recharts imports/usages replaced with inline SVG (current/prior series, optional area fill, grid/axes/labels, role="img" + accessible labels, <title> tooltips). No other scorecard content changed.
  • template.doc.mjs for the scorecard declares dependencies: ['react', '@stylexjs/stylex', '@astryxdesign/core', '@heroicons/react'].
  • TemplateDoc gains optional dependencies?: string[] (Zod-parsed, passed through the discovery adapter for pages, blocks, external, and integration templates). Optional and additive — no schema-version bump or migration: every existing record still parses, and undeclared templates warn rather than fail for now.
  • scripts/check-template-deps.mjs + tests; wired as check:template-deps in package.json and appended to check:repo. Six existing recharts templates are grandfathered with warnings under [gap] dashboard-scorecard: Bundled dashboard template imports recharts, not Astryx charts #6717; import-looking text inside comments/README template literals is ignored.

Evidence

  • Reproduction before the change: dashboard-scorecard/page.tsx imported { ... } from 'recharts'; check:template-deps (new) flags any template importing a non-policy package.
  • Result after the change: check-template-deps: 55 templates, 0 problem(s); the scorecard template audits clean ({"problems":[],"warnings":[]}); the template viewer renders the page (HTTP 200) and a real-browser screenshot of the SVG charts was inspected (axes, labels, tooltips present; right chart padding corrected from 8 to 22 after the final x-axis label clipped in inspection).
  • Representative unchanged path: the six grandfathered recharts templates still render exactly as before — only warnings, no behavior change.
  • Regression test: scripts/check-template-deps.test.mjs — 10/10 pass (matching declarations, third-party rejection, canary-only rejection, missing/stale declarations, legacy warn behavior, README-lookalike imports ignored, real scorecard passes).

Scope

  • One defect is restored.
  • Separable contradictory or unsettled tagalongs were removed or split.
  • No new public API, visual representation, default, or interaction model is hidden under the bug-fix label.
  • Public text and artifacts contain no internal Meta context.

Notes for reviewers: the gate uses regex-based import extraction (comments/template literals stripped first) rather than a full AST parse — scope is documented in the script header. Legacy undeclared templates currently warn; whether to keep that permanently noisy or migrate them to declarations is open for follow-up.

Testing

  • vitest run --project node scripts/check-template-deps.test.mjs — 10/10 pass.
  • vitest run --project node packages/cli/authoring/doctypes/template/ packages/cli/foundation/discovery/ — 550/550 pass.
  • pnpm check:repo — all checks pass (55 templates, 0 problems).
  • pnpm check:knowledge — templates and records aligned.
  • ESLint on all changed files — 0 errors.
  • Template viewer production render + real-browser screenshot inspection of the scorecard page.

Closes #6717

Add optional TemplateDoc.dependencies (parsed by Zod, passed through the
discovery adapter) and a check:template-deps repo gate: every template's
executable imports must resolve to stable Astryx packages, React peers, or
documented third-party packages. dashboard-scorecard's charts are now
dependency-free inline SVG and it declares react, @stylexjs/stylex,
@astryxdesign/core, @heroicons/react.

Fixes meta#6717.
@vercel

vercel Bot commented Sep 29, 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 Sep 29, 2026 12:36am UTC

Request Review

@meta-cla

meta-cla Bot commented Sep 29, 2026

Copy link
Copy Markdown

Hi @kiranbadam!

Thank you for your pull request and welcome to our community.

Action Required

In order to merge any pull request (code, docs, etc.), we require contributors to sign our Contributor License Agreement, and we don't seem to have one on file for you.

Process

In order for us to review and merge your suggested changes, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA.

Once the CLA is signed, our tooling will perform checks and validations. Afterwards, the pull request will be tagged with CLA signed. The tagging process may take up to 1 hour after signing. Please give it that time before contacting us about it.

If you have received this in error or have any questions, please contact us at [email protected]. Thanks!

@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 needs:design-review Affects visuals — Design should review labels Sep 29, 2026
@astracat-bot

astracat-bot Bot commented Sep 29, 2026 •

Copy link
Copy Markdown
Contributor

AI review status for this pull request.

Review status Updated
❓ Needs maintainer input (for maintainers only) Nov 27, 2026, 1:00 PM 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.

Thanks for tackling #6717. Approval waits on an engineering owner. No current spec covers limiting templates to stable packages through a check:template-deps gate, the new public TemplateDoc.dependencies field, or hand-rolled SVG as the scorecard's chart. An engineering owner needs to identify or provide the governing spec, or record the decision by commenting /approve-spec 25a3380359f3dafcf8f94e6ad65f0f3207bc6030 on this pull request; the author may do this only if they are an engineering owner. Whatever the owners decide, these need changes:

  • The branch conflicts with main, and after a rebase the new gate fails check:repo on pages/table-collapsible and pages/table-comparison, which import recharts and are not grandfathered.
  • Keyboard and screen-reader users can no longer read the weekly values: the old chart let keyboard users step through each week, but the new role="img" chart shows them only in mouse-hover <title> elements (page.tsx:529-534, :587-596).
  • The fixed 600×200 viewBox scales the axis text with the card, so labels draw at about 7 px in the default layout and 6 px on a phone instead of 12 px (page.tsx:529-533).
  • Compact notation on values already in thousands labels the Net revenue axis 1.1K and 1.3K under a 1,244k header (page.tsx:556).
  • The gate's import regex misses export … from re-exports, and a single backtick inside a comment hides every import after it (scripts/check-template-deps.mjs:104-117).
  • The changeset, the description and the public dependencies JSDoc say every template is checked, but the gate reads only the 55 page directories and no block, external or integration template; the scorecard changeset also calls its trend charts "comparison and composition charts".
  • packageRoot and importedPackages copy the import extraction in apps/docsite/scripts/generate-shadcn-registry.mjs; please share that syntax-tree extractor instead of adding a regex copy.

Please also run Prettier on page.tsx and template-adapter.mjs.

[Automated review]

* any violation NOT listed here.
* @type {Map<string, string>}
*/
const GRANDFATHERED = new Map([

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.

main has since added pages/table-collapsible and pages/table-comparison, which also import recharts. After a rebase this gate exits 1 on both, so pnpm check:repo fails for every pull request. Convert them or add them here.

viewBox={`0 0 ${CHART_W} ${CHART_H}`}
width="100%"
height={CHART_H}
role="img"

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.

This chart is not focusable, and role="img" hides the per-week <title> elements from assistive tech. On main the recharts chart is a focusable role="application", and ArrowRight walks the weeks with a tooltip ("W4, Prior: 901k, Current: 1,024k"). Keyboard and screen-reader users lose those values. Give the points a keyboard path, or expose the weekly values as an accessible table or description.

axisLine={false}
tickLine={false}
<svg
viewBox={`0 0 ${CHART_W} ${CHART_H}`}

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.

With a fixed viewBox and width="100%", the whole drawing scales with the card, text included. At a 1280 px viewport the labels draw at about 7.4 px, and 6 px at 390 px, instead of 12 px; about 38 px of the 200 px box stays empty above and below. Keep the text out of the scaled drawing, for example with a preserveAspectRatio="none" plot plus vector-effect="non-scaling-stroke", and HTML axis labels.

textAnchor="end"
fontSize={AXIS_TICK.fontSize}
fill={AXIS_TICK.fill}>
{compactNum.format(v)}

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.

These values are already in thousands (unit: 'k'), so compact notation renders 1.1K and 1.3K under a 1,244k header. Format ticks the way the header does: toLocaleString() plus trend.unit.

}

const IMPORT_RE =
/^\s*import\s+(?:[^'"]*?\s+from\s+)?['"]([^'"]+)['"]|import\s*\(\s*['"]([^'"]+)['"]\s*\)|require\s*\(\s*['"]([^'"]+)['"]\s*\)/gm;

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.

This misses export {X} from 'pkg' and export * from 'pkg'. Also, because template literals are stripped before comments (line 117), one backtick in a comment pairs with a later one and hides the imports between them. All three cases pass auditTemplate with no problem. The registry's readImportSpecifiers already walks the TypeScript syntax tree and handles all of these.

*/
export function findTemplates() {
const out = [];
for (const kind of ['pages', 'blocks']) {

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.

blocks/ has no <name>/template.doc.mjs directories. Block templates are <Name>.tsx + <Name>.doc.mjs pairs under blocks/components/, so this finds none of them, and the run reports "55 templates", all pages. External and integration templates are never read either. Either drive the gate from discoverAll(), or describe it as a page-template check.


/** Runtime npm dependencies the template's source imports, as package
* names (e.g. `["react", "@astryxdesign/core"]`). The repo's
* `check-template-deps` gate verifies every declared dependency is

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.

This is public JSDoc on @astryxdesign/cli/authoring, but check-template-deps is a script in this repository, and it never reads block, external or integration templates. Integration authors are promised a check they never get. Describe what the field means, not the repository gate.

'@astryxdesign/cli': patch
---

[fix] The `dashboard-scorecard` page template no longer depends on `recharts`: its comparison and composition charts are now dependency-free inline SVG (with `role="img"`, accessible labels, and point tooltips), so the template installs with zero third-party chart dependencies. It declares `react`, `@stylexjs/stylex`, `@astryxdesign/core`, and `@heroicons/react` in its template metadata. (#6717)

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.

The scorecard has four trend charts (two area, two line) and no comparison or composition chart, and the new point tooltips are mouse-only. Suggest "its trend charts are now inline SVG".

@cixzhang

Copy link
Copy Markdown
Contributor

(Posted by Cindy's agent.) Thanks, @kiranbadam. A stable-only dependency rule for templates is a policy change: nine templates use recharts today, and the share-a-page guide tells readers that charts use it. So this needs a decision from the owner before review, and we'll post it here. The branch is also far behind main, so please hold off on rebasing until that decision is in.

@cixzhang cixzhang added the lane:2 Astryx fix-loop lane 2 owns this label Nov 21, 2026

This branch was successfully deployed

1 active deployment
Preview — 25a33803 Deployed Sep 29, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

community Authored by a community contributor (not on the eng/design team) lane:2 Astryx fix-loop lane 2 owns this needs:code-review High-risk change (new package/component/API) — needs human code review before merge needs:design-review Affects visuals — Design should review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[gap] dashboard-scorecard: Bundled dashboard template imports recharts, not Astryx charts

2 participants