Skip to content

feat(stardust): schemas and a validator for the design/ folder - #847

Merged
paolomoz merged 2 commits into
mainfrom
stardust/design-system-schemas
Dec 2, 2026
Merged

paolomoz merged 2 commits into
mainfrom
stardust/design-system-schemas

Conversation

@paolomoz

@paolomoz paolomoz commented Nov 30, 2026 •

Copy link
Copy Markdown
Collaborator

What and why

First of three pull requests that make stardust write and read one fixed design-system structure, design/, in place of DESIGN.json (tracking: #846). This one adds the contract only: the schemas and a validator. No skill reads or writes design/ yet, so nothing changes for a run.

Today's DESIGN.json has four different top-level shapes across seven project files, and no DESIGN.md produced by stardust passes the Stitch linter. The schemas fix the shape; the validator proves it.

New files (all under plugins/stardust/skills/stardust/scripts/):

  • schemas/context.schema.json: design/context.json holds only schemaVersion and pageTypes. Components, token sets, modes and breakpoints are derived from the folders, so they have no second home here.
  • schemas/component.schema.json: the block contract (anatomy, properties, looks, slots, related.uses, optional files, optional part on each property). No status (the reference document's lifecycle is its origin), no states (read from CSS and JS), no usedBy (derived from the others' uses).
  • schemas/reference-frontmatter.schema.json: the CRD front matter with upstream keys verbatim (masofon/crd-format@a0772c7: related_crds, the upstream lifecycle values).
  • New script design-validate.mjs [<dir>] [--json] [--blocks <dir>] [--new-blocks a,b] and --legacy [<dir>]. Exit 0 no errors, 1 errors, 2 usage. No network, no browser.
    • Schemas through a built-in checker that implements exactly the keywords the schemas use (the plugin ships no node_modules); the test fails if a schema uses any other keyword.
    • Cross-file rules: name = file stem; unique parts, looks, look classes and fields; uses, slots[].accepts, a field's part and page-type components resolve; <block>.md needs <block>.json with the same id; checks/<block>.spec.js needs a contract; unknown files and _provenance in design/ are errors.
    • CRD requirement lines: in section 1 (either heading form) any line that reads as a requirement must match ^[-*] (\[open\] |\[review\] ){0,2}[FSBCAI][1-9][0-9]*: \S, continuation lines allowed, IDs unique. It reports the [open] and [review] counts per block; "ready" is computed, never stored.
    • A look class declared by 3 or more contracts is a warning (likely a section style). A block folder without a contract is a warning; a block named in --new-blocks without one is an error.
    • DESIGN.md: front matter required, name required, only the Stitch 0.4.0 keys, then the Stitch lint from @google/design.md at exactly 0.4.0 when the project has it. Without it (or with another version) the lint is skipped with one stitch-lint-skipped warning, so the OF1 Labs image needs no new package; the front matter is then read with a built-in YAML subset reader (block maps, lists, flow collections, scalars). YAML comes from yaml or js-yaml when present.
    • --legacy validates an old root or stardust/current/ pair as layer 1, skips the unknown-file rule and prints the DESIGN.json shape.
  • test/design-validate.test.mjs (temp-dir fixtures, a stub linter module, no browser) and one scripts-index.md row.

Baseline

The validator on existing projects (linter 0.4.0, --legacy on the root and the stardust/current/ pair). None has a design/ folder, so every one fails the new structure outright (exit 2).

Project Pair Errors Warnings DESIGN.json shape
an energy utility root, current 1 (rounded.pill: 50%) 7 (missing primary, 6 orphaned colours) components, extensions, generatedAt, narrative, schemaVersion, title; 12 modules
a nutrition brand root, current 1 (rounded.circle: 50%) 12 (missing primary, 11 orphaned) front matter mirrored into JSON (colors, rounded, spacing, typography at top level); 10 modules
a travel company root, current 1 (no front matter) 1 _provenance, components, extensions, …; root and current differ (14 vs 17 extension keys)
a semiconductor maker root 2 (no name; _provenance is not a Stitch key) 0 _provenance, chrome, colors, container, extensions, fonts
a research-firm site (a 78-page lab run) root, current 1 (no front matter) 1 _provenance, components, extensions, …; 42 modules, 15 extension keys

Four distinct top-level shapes, and no file passes. The same checks run again on fresh extract output once the switch lands.

How I checked it

  • node plugins/stardust/skills/stardust/scripts/test/design-validate.test.mjs: 21 checks pass.
  • The real linter (@google/design.md@0.4.0, installed in a scratch project) on the projects above.
  • npm ci && npm run validate && node scripts/check-release-configs.mjs && npm run lint:stardust; scripts/test/layout.test.mjs; evals/golden/golden.test.mjs.
  • prose-delta: +1 lines, -2 words across skill docs (the index row; 12 other rows shortened to stay under the 12 KB cap, each dropped flag still documented in a reference or used only inside other scripts).

Checklist

  • The change is to one plugin, or to repository tooling
  • npm run validate passes
  • Paths, commands and skills that the change names exist
  • New scripts, hooks, MCP servers or network endpoints are called out above
  • The human label is set, if a person and not an agent wrote this

🤖 Generated with Claude Code

@paolomoz paolomoz changed the title feat(stardust): design/ schemas and validator (design context, 1 of 3) feat(stardust): schemas and a validator for the design/ folder Nov 30, 2026
@paolomoz
paolomoz marked this pull request as ready for review November 30, 2026 17:39
@github-actions

github-actions Bot commented Nov 30, 2026 •

Copy link
Copy Markdown
Contributor

claude: approved on bda482c

The head is still bda482c, the commit that earlier rounds approved. Nothing has been pushed since. The change adds design/ schemas, design-validate.mjs, its tests and one scripts-index.md row. To stay under the size cap, 12 other index rows were shortened. No skill calls the validator yet. The author answered every earlier line comment and updated the description to match: it now says 12 rows were shortened and no longer says a missing linter exits 2.

I re-ran the checks on this head. The validator test passes all its checks. npm run lint:stardust passes, and its manifests are in step. npm run validate and check-release-configs pass on both trees. All four clients load 16 of 16 stardust skills. The script makes no network call and starts no process.

The text an agent reads has not changed since the last review, so I probed nothing new and ran no eval.

Redundant lines: none. Probed 0, redundant 0, could not probe 0.

@github-actions

github-actions Bot commented Nov 30, 2026 •

Copy link
Copy Markdown
Contributor

codex: approved on bda482c

Adds design schemas and a standalone validator without changing existing skill workflows. The head is unchanged since the previous approvals; no new blocking defect confirmed. Base/head validation, 23 validator checks, 217 repository tests and Stardust lint pass. All four clients install the plugin and load 16/16 skills. No new eval was run because instructions are unchanged since the prior review.

Redundant lines
None. Lines probed: 0; redundant: 0; unable to probe: 0. Previously reviewed instructions were not re-probed.

- `spec/spec-rum.mjs` — S5 Optel: `[--days 90] [--key-env <NAME>]`
- `spec/spec-sheet.mjs` — contact sheet: `<component|row-shape>`
- `spec/spec-variants.mjs` — S8 variants: `[--cut 0.5]`
- `stardust/design-validate.mjs` — `design/` check — `[<dir>] [--new-blocks a,b] [--legacy]`; exit 1 = errors, 2 = setup

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.

codex: The Claude comparison loaded stardust but did not discover this validator when asked to validate design/ and require a new hero contract. Neither arm supplied the command, so the plugin added no benefit for this task. Non-blocking for this contract-only PR; when switching the workflows, add explicit routing and an eval that verifies discovery of this command.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks. Agreed, and it is planned that way: in this PR no skill calls the validator, so there is nothing to discover yet. The switch (PR 3 of 3 on #846) names it where the agent acts: extract runs it as its exit check on stardust/current/design/, and the skills that create a block pass --new-blocks. That PR also updates the extract-multipage eval to assert the validator ran and exited 0.

Adds the JSON schemas for the design context (context.json, the block
contract, the reference document's front matter) and design-validate.mjs,
which checks a design/ folder: the schemas through a built-in checker for
exactly the keywords they use, cross-file rules, CRD requirement lines, and
DESIGN.md through the Stitch linter pinned at 0.4.0. --legacy validates an
old DESIGN.md/DESIGN.json pair as layer 1. No skill reads or writes design/
yet.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@paolomoz
paolomoz force-pushed the stardust/design-system-schemas branch from 1989052 to debf0cc Compare December 1, 2026 00:02
- `spec/spec-rum.mjs` — S5 Optel: `[--days 90 --key-env <NAME>]`
- `spec/spec-sheet.mjs` — contact sheet: `<component|row-shape>`
- `spec/spec-variants.mjs` — S8 variants: `[--cut 0.5]`
- `stardust/design-validate.mjs` — `design/` check — `[<dir>] [--new-blocks a,b] [--legacy]`

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.

claude: Not blocking. To fit this row under the 12 KB cap, the rebased branch now cuts 12 existing rows, not the four the description mentions. It drops, for example, --token-env|--token-file from da-media-upload, exit 1 = failures from deploy-batch, --json from content-presence, --all-matches from measure, --new from update-coverage, and --freeze-baseline/--check-baseline from stitch-shot. I checked each one: it is still documented in a reference (da-source-api.md, handoff-contract.md, coverage-model.md) or used only inside other scripts. Still, an agent reading the index will now call --help for these flags. Please update the description to match ("12 rows shortened"). For the next index addition, consider shortening descriptions rather than dropping flags, since this index exists to avoid --help calls.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks. The description now says 12 rows were shortened, and why each dropped flag is still safe: documented in a reference or used only inside other scripts. Agreed on the next addition: shorten descriptions before dropping flags.

… project lacks it

When @google/design.md 0.4.0 is not in the project (or another version
is), the Stitch lint of DESIGN.md is skipped with one warning,
stitch-lint-skipped, and every other check still runs; with the pinned
linter present it runs as before. YAML falls back to a built-in reader for
the front-matter subset when neither yaml nor js-yaml resolves, so the
validator needs no package at all. Exit 2 is now usage only.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
}
}
}
if (!lint) { report.warn(file, 'stitch-lint-skipped', lintNote ?? 'the Stitch lint did not run'); return; }

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.

claude: Not blocking. A missing linter used to fail closed with exit 2; now it gives one warning and exit 0, so a design whose only problems are Stitch lint errors will pass when the project lacks the linter. That is fine for this PR, since no skill calls the validator yet. When PR 3 makes extract use exit 0 as its exit check, have the skill treat stitch-lint-skipped as "not fully checked" (or install the pinned linter first) so the run doesn't report the design as clean. Please also update the PR description, which still says a missing linter is "exit 2, never a silent skip".

@paolomoz paolomoz Dec 2, 2026 •

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks. The description no longer says exit 2. Running without the linter is a deliberate choice: the lab image does not carry @google/design.md, and we chose to proceed without it rather than change the image. The stitch-lint-skipped warning is printed in every validator run, so the report shows the lint did not run; installing the pinned linter in a project turns it back on with no other change.

@github-actions

github-actions Bot commented Dec 2, 2026

Copy link
Copy Markdown
Contributor

Closed: the AI review raised a finding more than 24 hours ago that nobody has answered.

  • claude on plugins/stardust/skills/stardust/reference/scripts-index.md:110

Push a fix, or reply where you disagree (on the line for a line comment, on the pull request for a denial), then reopen the pull request, or open a new one: that runs the review again. A pull request written by a person rather than an agent gets the human label, and this rule does not apply to it. See the merge policy.

@github-actions github-actions Bot closed this Dec 2, 2026
@paolomoz paolomoz reopened this Dec 2, 2026
@paolomoz
paolomoz merged commit 2f8941f into main Dec 2, 2026
66 checks passed
@paolomoz
paolomoz deleted the stardust/design-system-schemas branch December 2, 2026 05:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant