baldart 4.64.0 → 4.66.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (32) hide show
  1. package/CHANGELOG.md +38 -0
  2. package/README.md +1 -1
  3. package/VERSION +1 -1
  4. package/bin/baldart.js +15 -0
  5. package/framework/.claude/agents/code-reviewer.md +25 -11
  6. package/framework/.claude/agents/codebase-architect.md +13 -5
  7. package/framework/.claude/agents/doc-reviewer.md +26 -12
  8. package/framework/.claude/agents/ui-expert.md +18 -10
  9. package/framework/.claude/skills/context-primer/SKILL.md +7 -0
  10. package/framework/.claude/skills/design-system-init/SKILL.md +164 -156
  11. package/framework/.claude/skills/design-system-init/scripts/component-spec.template.md +26 -3
  12. package/framework/.claude/skills/design-system-init/scripts/extract-manifest.mjs +151 -0
  13. package/framework/.claude/skills/new/references/final-review.md +12 -2
  14. package/framework/.claude/skills/new/references/team-mode.md +1 -1
  15. package/framework/.claude/workflows/new-card-review.js +67 -13
  16. package/framework/.claude/workflows/new-final-review.js +63 -7
  17. package/framework/agents/component-manifest-schema.md +145 -0
  18. package/framework/agents/design-system-protocol.md +63 -23
  19. package/framework/agents/index.md +2 -0
  20. package/framework/docs/COMPONENT-MANIFEST-LAYER.md +100 -0
  21. package/framework/routines/ds-drift.routine.yml +19 -12
  22. package/framework/templates/baldart.config.template.yml +22 -0
  23. package/package.json +1 -1
  24. package/src/commands/configure.js +54 -0
  25. package/src/commands/doctor.js +85 -0
  26. package/src/commands/tokens.js +80 -0
  27. package/src/commands/update.js +7 -0
  28. package/src/utils/token-emitters/README.md +36 -0
  29. package/src/utils/token-emitters/css.js +18 -0
  30. package/src/utils/token-emitters/index.js +47 -0
  31. package/src/utils/token-emitters/ts.js +32 -0
  32. package/src/utils/tokens-generator.js +165 -0
package/CHANGELOG.md CHANGED
@@ -5,6 +5,44 @@ All notable changes to BALDART will be documented in this file.
5
5
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6
6
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
7
 
8
+ ## [4.66.0] - 2026-06-23
9
+
10
+ **Server-side reviewer death is no longer a silent drop in the `/new` review workflows — from a real `new-final-review` run where `qa-sentinel` died on `API Error: 529 Overloaded`.** When a reviewer agent inside `new-final-review.js` / `new-card-review.js` was killed by a transient server-side error (529 Overloaded, 429, 5xx, rate-limit — the org-level limit is SHARED across every terminal/session), the worker pool's `try/catch → null` + `.filter(Boolean)` **silently discarded it**. For `qa-sentinel` this was worst: a dead gate-runner produced an **empty `gateTable`**, which the fan-in read as "no mechanical gates ran ⇒ nothing to block" — so the batch's lint/tsc/test/build/i18n merge gate was lost without any FAIL signal. The two workflows had NO transient retry and NO degraded-coverage signal at all; the canonical handling already existed in `new2.js` (`agentSafe` + `noteDegraded`) and in the prose SSOT (`references/team-mode.md` § transient-vs-genuine) but had **never been propagated** to the other two workflows.
11
+
12
+ **MINOR** — reliability hardening of two distributed dynamic workflows; additive, backward-compatible (the return shape gains an additive `summary.degradedReviewers`), no new config key, schema-change propagation rule does NOT apply. Claude-only (workflows are Claude-only).
13
+
14
+ ### Fixed
15
+
16
+ - **`new-final-review.js` + `new-card-review.js` — transient-aware reviewer spawn (SSOT parity with `new2.js`).** Lifted the canonical `TRANSIENT`/`isTransient`/`agentSafe` helper (the same code `new2.js` already uses) into both workflows and routed every review thunk (codex / doc-reviewer / api-perf-cost-auditor / qa-sentinel / simplify / security) through a new `reviewSafe()` wrapper. A reviewer killed by a transient error is **retried in-workflow** (cap 3; honest about the lack of a reliable runtime sleep — this absorbs brief blips, it is NOT timed backoff). A sustained outage exhausts the cap and is **recorded**, never silently dropped.
17
+ - **A dead `qa-sentinel` now BLOCKS the merge instead of passing blind.** Both workflows inject a synthetic `{ gate: 'mechanical-gates (qa-sentinel)', status: 'FAIL', detail: … }` when qa-sentinel returns null after retries, so `summary.failingGates` (and the skill's F.5 / wave-boundary gate) treat the UNKNOWN mechanical gates as **non-PASS**. Verified deterministically: the synthetic FAIL flows into `failingGates` and does NOT read as a build PASS (so the O5(b) build-claim demotion stays suppressed). Also applied to `new-card-review.js`'s light-tier post-fix scoped qa-sentinel.
18
+ - **Degraded-coverage ledger.** Both workflows return an additive `summary.degradedReviewers: [{ reviewer, reason }]` listing reviewers that died after retries, and log it on completion — so the `/new` skill knows the batch ran with INCOMPLETE coverage rather than mistaking a thin `findings` set for "clean". `new2.js` was already correct (its authoritative mechanical gate is the owner-run Phase-2 `buildBlocked` path, transient-handled; the qa-sentinel reviewer death already triggers `noteDegraded`) — **left untouched** to avoid perturbing the A/B experiment.
19
+
20
+ ### Changed
21
+
22
+ - **`references/final-review.md`** — documents the non-silent reviewer-death contract in the delegated-workflow return-shape section + the F.3 qa-sentinel row (dead qa ⇒ synthetic FAIL ⇒ merge blocked; `summary.degradedReviewers` ⇒ surface terse / AUTONOMOUS materializes a re-run follow-up). Framed as the **per-agent twin of the F.1.5 whole-workflow-killed recovery**.
23
+ - **`references/team-mode.md`** — the transient-vs-genuine § now cross-links the workflow twin, making the SSOT relationship bidirectional (same discipline, two surfaces: prose for orchestrator-spawned teammates, workflow JS for in-workflow fan-out).
24
+
25
+ ## [4.65.0] - 2026-06-23
26
+
27
+ **Machine-readable component manifest + DTCG token SSOT — from a real slow-discovery diagnosis on a consumer (mayo).** UI component discovery was slow because the design-system `INDEX.md` had become a 33KB monolith read in full on every UI task, there was no token reference (tokens parsed from a 17KB `tokens.ts`), and 0/~135 components had a per-component spec — so every reuse lookup degraded to reading component source. The framework already prescribes per-component specs (owned by `doc-reviewer`, gated by `code-reviewer`, audited by `ds-drift`); this release **evolves that existing layer** (no twin) into a machine-readable, on-demand one, and gives tokens a real W3C DTCG source of truth.
28
+
29
+ **MINOR** — adds a CLI verb + a schema module + a util registry + config keys; additive, backward-compatible with existing prose specs, rides on `features.has_design_system` (NO new feature flag). The **schema-change propagation rule applies** to the new `paths.design_tokens` + `design_tokens:` block (template + configure + update detector + doctor + CHANGELOG).
30
+
31
+ ### Added
32
+
33
+ - **`framework/agents/component-manifest-schema.md`** — SSOT for the machine-readable frontmatter HEAD on each `components/<Name>.md`: deterministic fields (from TS/git — `name`/`source`/`source_sha`/`props`/`variants`/`composes`/`category`/`status`) vs agentic fields (curated by `doc-reviewer` — `purpose`/`token_bindings`/`a11y`/`related`/`must_rules`). Defines the on-demand read contract (INDEX router → frontmatter-first, prose only when modifying), the `source_sha`-anchored regeneration contract, and the **transition-leniency** rule (prose-only specs and empty deterministic fields stay valid — the HEAD is an upgrade target, not a new floor). Mirrors `card-schema.md`. Registered in `agents/index.md`.
34
+ - **DTCG token SSOT + generator (zero npm dependency)** — `src/utils/token-emitters/` (REGISTRY pattern: `ts` + `css` emitters, extensible) + `src/utils/tokens-generator.js` (parse `.tokens.json`, resolve `{aliases}` with cycle guard, `build()`/`isStale()`) + the **`baldart tokens build`** CLI verb (`src/commands/tokens.js`). Generated outputs carry a `baldart-generated from .tokens.json` banner.
35
+ - **Deterministic, Codex-portable extractor** — `framework/.claude/skills/design-system-init/scripts/extract-manifest.mjs` (pure Node, no deps): emits the deterministic HEAD from React+TS sources with **no subagent** (validated on mayo's real 73 components: 100% source_sha, ~73% props).
36
+ - **`framework/docs/COMPONENT-MANIFEST-LAYER.md`** — authoritative layer design / lifecycle / invariants (parallels `I18N-LAYER.md` / `CODE-GRAPH-LAYER.md`).
37
+ - **Config keys** `paths.design_tokens` (DTCG source) + `design_tokens.outputs[]` (generation targets) — propagated through template, `configure` (autodetect + prompt, gated on `has_design_system`), `update` detector (nested block + array), and `doctor`.
38
+
39
+ ### Changed
40
+
41
+ - **`/design-system-init`** — now bootstraps OR upgrades: a GREENFIELD mode and an UPGRADE mode (the mayo "prose-only / monolith / no DTCG" case) that regenerates the per-component HEAD from source, lifts prose into agentic fields, rebuilds the **thin INDEX router**, and bootstraps `.tokens.json` from the existing token file with a **round-trip verify**. No longer refuses on an existing registry. Spec template (`component-spec.template.md`) gains the frontmatter HEAD.
42
+ - **`design-system-protocol.md`** — canonical sources updated (INDEX = generated router; DTCG token SSOT inversion; `tokens-reference.md` demoted to a generated/narrative view); Authority Matrix made canonical in the protocol (out of the generated INDEX); Post-Intervention Check (b)/(c) require HEAD regeneration + DTCG edit-then-build; `DS_TOKENS_DRIFT` redefined as "generated output ≠ `baldart tokens build`".
43
+ - **Consumers wired** — `code-reviewer` Rule 8 (HEAD-first reads + transition leniency), `codebase-architect` Reuse Analysis (frontmatter-first discovery), `ui-expert` (read HEAD-first; write HEAD in the completion gate), `doc-reviewer` (owns the agentic HEAD fields; DTCG-aware token reconciliation), `context-primer` (UI fast-path), `ds-drift` routine (`source_sha` + DTCG output checks).
44
+ - **`baldart doctor`** — two backfills under `has_design_system`: `tokens-build` (regenerate drifted token outputs, autoOk) and `ds-manifest-nudge` (registry present but specs missing/prose-only → run `/design-system-init`) — the "default-on + nudge" behavior achieved without a new flag.
45
+
8
46
  ## [4.64.0] - 2026-06-23
9
47
 
10
48
  **Off-context final-merge conflict resolution — from a real heavy-drift `/mw` on `/new`.** On a long epic batch the trunk had drifted 45 commits while the batch ran; the final `/mw` (invoked via `Skill()`, so it runs IN the orchestrator's context) hit mixed conflicts and resolved them **inline** — Read/grep/sed/python churn re-reading the giant end-of-batch cache, exactly when tokens cost the most (the `~20M-token` hand-merge regression `merge-cleanup.md` already measured). This release moves the merge off that context the right way, without repeating the v4.46.0/v4.53.0 "model-in-the-loop for plumbing" mistake.
package/README.md CHANGED
@@ -82,7 +82,7 @@ No additional activation steps needed — once installed, Claude Code (and Codex
82
82
  ### Core Protocol
83
83
 
84
84
  - **AGENTS.md**: Mandatory coordination rules (MUST/SHOULD/OPTIONAL)
85
- - **agents/**: 25 domain modules (architecture, workflows, testing, security, card-schema, i18n-protocol, return-contract-protocol, etc.)
85
+ - **agents/**: 26 domain modules (architecture, workflows, testing, security, card-schema, i18n-protocol, return-contract-protocol, component-manifest-schema, etc.)
86
86
  - **Routing**: If you touch X, read Y - minimize context loading
87
87
 
88
88
  ### AI Agents (31 specialized agents)
package/VERSION CHANGED
@@ -1 +1 @@
1
- 4.64.0
1
+ 4.66.0
package/bin/baldart.js CHANGED
@@ -174,6 +174,21 @@ program
174
174
  await teardownCommand({ cwd: options.cwd, json: !!options.json });
175
175
  });
176
176
 
177
+ const tokensGroup = program
178
+ .command('tokens')
179
+ .description('Design-token operations. The DTCG `.tokens.json` (paths.design_tokens) is the SSOT; `tokens build` regenerates the stack-native artifacts (tokens.ts / CSS vars) from it.');
180
+
181
+ tokensGroup
182
+ .command('build')
183
+ .description('Regenerate design_tokens.outputs[] from the DTCG source. No source / no outputs → no-op. A malformed .tokens.json or write failure → exit 1.')
184
+ .option('--cwd <path>', 'Project root (defaults to the current directory).')
185
+ .option('--json', 'Machine-readable output: emit a single JSON result object on stdout')
186
+ .action(async (options) => {
187
+ const tokens = require('../src/commands/tokens');
188
+ const code = await tokens.build({ cwd: options.cwd, json: !!options.json });
189
+ if (typeof code === 'number' && code !== 0) process.exitCode = code;
190
+ });
191
+
177
192
  const overlayGroup = program
178
193
  .command('overlay')
179
194
  .description('Author and check .baldart/overlays/ — scaffolds, validates, and detects drift on skill/agent/command overlays');
@@ -51,14 +51,20 @@ this file).
51
51
  Concrete enforcement contract for the review pass:
52
52
 
53
53
  1. When `features.has_design_system: true`, read `${paths.design_system}/INDEX.md`
54
- (component index + Canonical Authority Matrix) before reviewing UI diffs.
55
- 2. For any component in the diff, cross-check against
56
- `${paths.design_system}/components/<Name>.md` — variants, states, required
57
- props, accessibility contract.
58
- 3. Enforce design-system MUST rules from the project's INDEX as HIGH-confidence
59
- findings. Typical rules include:
60
- - No hardcoded hex, shadow, radius, spacing literals only tokens from
61
- `${paths.design_system}/tokens-reference.md`.
54
+ (the thin router) before reviewing UI diffs, then read the **frontmatter HEAD**
55
+ of each in-scope `components/<Name>.md` (per
56
+ `framework/agents/component-manifest-schema.md`)not the whole monolith, not
57
+ the source. Read a spec's prose body only when the diff modifies that primitive.
58
+ 2. For any component in the diff, cross-check against its
59
+ `components/<Name>.md` HEAD variants, props, `token_bindings`, a11y,
60
+ `must_rules`. A `token_bindings` ID that does not resolve in the DTCG source
61
+ (`paths.design_tokens`) is `DS_TOKENS_DRIFT`.
62
+ 3. Enforce design-system MUST rules (the spec HEAD's `must_rules` + project INDEX)
63
+ as HIGH-confidence findings. Typical rules include:
64
+ - No hardcoded hex, shadow, radius, spacing literals — only tokens. When
65
+ `paths.design_tokens` is set, the SSOT is the DTCG `.tokens.json`; the
66
+ generated `tokens.ts`/CSS output must NOT be hand-edited (output ≠
67
+ `baldart tokens build` = `DS_TOKENS_DRIFT`). Otherwise the project token file.
62
68
  - Text/background pairing rules for themed surfaces (see the relevant
63
69
  pattern doc when `features.multi_tenant_theming: true`).
64
70
  - Overlay/z-index decisions follow the project's overlay decision tree.
@@ -76,15 +82,23 @@ Concrete enforcement contract for the review pass:
76
82
  conditions defined in [`design-system-protocol.md`](../../agents/design-system-protocol.md)
77
83
  § "Post-Intervention Coherence Check":
78
84
  (a) new primitive ⇒ `components/<Name>.md` spec present in the same diff,
79
- (b) modified primitive ⇒ spec updated in the same diff,
80
- (c) new/changed token `tokens-reference.md` updated in the same diff,
81
- (d) silently-existing primitive reused ⇒ INDEX entry added in the same diff.
85
+ (b) modified primitive ⇒ spec updated in the same diff, **including its
86
+ frontmatter HEAD** (deterministic `props`/`variants`/`composes`/`source_sha`
87
+ regenerated; agentic fields re-verified),
88
+ (c) new/changed token ⇒ DTCG `.tokens.json` updated + outputs regenerated
89
+ (`baldart tokens build`) when `paths.design_tokens` is set, else the
90
+ project token source/reference,
91
+ (d) silently-existing primitive reused ⇒ INDEX router entry added in the same diff.
82
92
  Each failing condition is a HIGH finding with the canonical code
83
93
  (`DS_INDEX_DRIFT` / `DS_COMPONENT_STALE` / `DS_TOKENS_DRIFT`). This is the
84
94
  third and final gate after `ui-design`/`ui-expert`'s own post-intervention
85
95
  check and the weekly `ds-drift` routine; if it trips here at review time,
86
96
  it means the upstream checks were skipped — flag the protocol violation
87
97
  alongside the drift.
98
+ **Transition leniency (do not raise the floor):** a prose-only spec lacking a
99
+ HEAD is NOT `DS_COMPONENT_STALE` merely for that; empty deterministic HEAD
100
+ fields (non-TS stack, unresolved prop) are advisory, never blocking. The HEAD
101
+ is an upgrade target — see `component-manifest-schema.md` § Transition leniency.
88
102
 
89
103
  When `features.has_design_system: false`, the registry reads are skipped but
90
104
  the review still flags hardcoded values and inconsistencies against
@@ -79,9 +79,13 @@ When analyzing a feature, resolve documentation authority in this order:
79
79
  **UI / design-system questions** follow a parallel resolution path (paths are
80
80
  project-specific; the convention below is recommended):
81
81
 
82
- 1. `${paths.design_system}/INDEX.md` — agentic-first component index + authority matrix
83
- 2. `${paths.design_system}/components/<Name>.md` — per-component spec (variants, props)
84
- 3. `${paths.design_system}/tokens-reference.md`token contract
82
+ 1. `${paths.design_system}/INDEX.md` — thin router (name source → purpose → spec)
83
+ 2. `${paths.design_system}/components/<Name>.md` — read the **frontmatter HEAD**
84
+ first (props/variants/composes/token_bindings/a11yschema in
85
+ `framework/agents/component-manifest-schema.md`); the prose body only if you
86
+ must understand rationale. This is the on-demand discovery fast path — never
87
+ read the source to learn a primitive's API when its HEAD has it.
88
+ 3. `${paths.design_tokens}` (DTCG `.tokens.json`) — token SSOT; `tokens-reference.md` is a generated view
85
89
  4. `${paths.design_system}/patterns/*` — theming, overlays, animations, platform quirks
86
90
  5. `${paths.references_dir}/ui-guidelines.md` — brand philosophy and aesthetic rules
87
91
  6. `${paths.references_dir}/component-registry.md` — inventory of shared components
@@ -226,8 +230,12 @@ component discovery.
226
230
 
227
231
  1. **Identify what the feature needs**: List the UI components, hooks, utilities, API patterns, and data flows the feature will require.
228
232
  2. **Search for existing matches**:
229
- - Check `${paths.references_dir}/component-registry.md` (read the
230
- relevant table section only, not the full file).
233
+ - When `features.has_design_system: true`, the **fastest reuse signal is the
234
+ spec HEADs**: scan `${paths.design_system}/INDEX.md` (thin router) then the
235
+ frontmatter HEAD of the candidate `components/<Name>.md` — structured
236
+ props/variants/purpose without reading source. Prefer this over Grep.
237
+ - Else check `${paths.references_dir}/component-registry.md` (relevant table
238
+ section only).
231
239
  - Grep only for 2-3 specific component names, not broad semantic sweeps.
232
240
  3. **Classify each candidate**:
233
241
  - **Direct reuse**: Component works as-is, just import it
@@ -60,21 +60,35 @@ When running in parallel with other agents (code-reviewer, security-reviewer):
60
60
 
61
61
  If your project ships a design-system SSOT (typically under `${paths.design_system}/**`
62
62
  with INDEX, per-component docs, tokens reference, pattern docs), include it in your
63
- documentation scope. Standard drift checks against this corpus:
64
-
65
- - **INDEX coverage**: compare the component index against the actual shared-component
66
- inventory (derive counts from a component registry doc). Flag mismatches as
67
- `DS_INDEX_DRIFT`.
68
- - **Per-component accuracy**: for each per-component doc, verify it lines up with
69
- the corresponding source file (variants, props, exported constants). If a doc has
70
- not been re-verified in more than 7 days and the source has changed in git, flag
71
- `DS_COMPONENT_STALE`.
63
+ documentation scope.
64
+
65
+ **You own the AGENTIC half of the per-component manifest HEAD** (schema:
66
+ `framework/agents/component-manifest-schema.md`): `purpose`, `a11y`,
67
+ `token_bindings`, `related`, `must_rules`, `last_verified`. You curate these —
68
+ you do NOT hand-write the deterministic half (`name`/`source`/`source_sha`/
69
+ `props`/`variants`/`composes`), which is regenerated from source by the extractor.
70
+ Never clobber a filled agentic field on a refresh. (This is the design-system twin
71
+ of your i18n-registry ownership: you curate context, tooling fills the mechanical part.)
72
+
73
+ Standard drift checks against this corpus:
74
+
75
+ - **INDEX coverage**: the `INDEX.md` router must list every primitive that has a
76
+ spec; flag mismatches as `DS_INDEX_DRIFT`. The router is generated — fix by
77
+ regenerating, not hand-editing.
78
+ - **Per-component accuracy**: for each spec, verify the HEAD lines up with the
79
+ source — `source_sha` matches the current blob, `props`/`variants` match the TS
80
+ types. If the source changed in git and the HEAD's `source_sha` is stale (or
81
+ `last_verified` >7 days with source change), flag `DS_COMPONENT_STALE`. A
82
+ prose-only spec with no HEAD is an upgrade candidate (`/design-system-init`), not
83
+ itself stale — see `component-manifest-schema.md` § Transition leniency.
72
84
  - **Animations reconciliation**: the animations pattern doc must match keyframes
73
85
  defined in the project's global styles. Flag `DS_ANIMATIONS_DRIFT` if a keyframe
74
86
  exists in code but not in the doc, or vice versa.
75
- - **Tokens reconciliation**: when token source files change, verify the
76
- tokens-reference doc is in sync and the relevant CSS custom properties still
77
- exist in the project's global styles. Flag `DS_TOKENS_DRIFT`.
87
+ - **Tokens reconciliation**: when `paths.design_tokens` is set, the DTCG
88
+ `.tokens.json` is the SSOT and the `tokens.ts`/CSS outputs + `tokens-reference.md`
89
+ are GENERATED verify they equal `baldart tokens build` (a hand-edit to a
90
+ generated file, or a dangling `token_bindings` ID, is `DS_TOKENS_DRIFT`). When it
91
+ is unset, fall back to checking the project token source vs its reference doc.
78
92
 
79
93
  Add a `## Design System Drift` section to the deliverables when any of these flags fire.
80
94
 
@@ -41,14 +41,17 @@ here.
41
41
 
42
42
  **BLOCKING pre-work when `features.has_design_system: true`:**
43
43
 
44
- 1. Read `${paths.design_system}/INDEX.md` (component index + Canonical
45
- Authority Matrix).
44
+ 1. Read `${paths.design_system}/INDEX.md` (the thin router). Authority Matrix
45
+ lives in `design-system-protocol.md`, not the INDEX.
46
46
  2. Read `${paths.ui_guidelines}` (visual language, typography, accessibility,
47
47
  brand voice).
48
- 3. Read `${paths.design_system}/tokens-reference.md` (token contract — SSOT
49
- for every color / spacing / shadow / radius / motion value).
50
- 4. For each primitive the task will create, modify, or visually depend on,
51
- read `${paths.design_system}/components/<Name>.md`.
48
+ 3. Read the token SSOT — the DTCG `.tokens.json` at `${paths.design_tokens}`
49
+ (or `tokens-reference.md`, its generated view) for every color / spacing /
50
+ shadow / radius / motion value.
51
+ 4. For each primitive the task will create, modify, or visually depend on, read
52
+ its `components/<Name>.md` — the **frontmatter HEAD** first (props/variants/
53
+ token_bindings/a11y, per `framework/agents/component-manifest-schema.md`);
54
+ the prose body when you need rationale.
52
55
  5. For each pattern in scope, read the relevant
53
56
  `${paths.design_system}/patterns/<topic>.md`.
54
57
 
@@ -347,10 +350,15 @@ project context layer at invocation time:
347
350
  the Post-Intervention Coherence Check defined in
348
351
  [`design-system-protocol.md`](../../agents/design-system-protocol.md)
349
352
  § "Post-Intervention Coherence Check":
350
- (a) every new primitive ships its `components/<Name>.md` spec,
351
- (b) every modified primitive has its spec updated to match,
352
- (c) every new/changed token is reflected in `tokens-reference.md`,
353
- (d) every silently-existing primitive you reused is now in `INDEX.md`.
353
+ (a) every new primitive ships its `components/<Name>.md` spec **with a
354
+ machine-readable frontmatter HEAD** (regenerate the deterministic fields
355
+ from source run the extractor / `baldart tokens build` as needed; fill
356
+ the agentic fields),
357
+ (b) every modified primitive has its spec + HEAD updated to match,
358
+ (c) every new/changed token is made in the DTCG `.tokens.json`
359
+ (`paths.design_tokens`) and outputs regenerated via `baldart tokens build`
360
+ — never hand-edit the generated `tokens.ts`/CSS,
361
+ (d) every silently-existing primitive you reused is now in the `INDEX.md` router.
354
362
  Report findings explicitly (`DS_INDEX_DRIFT` / `DS_COMPONENT_STALE` /
355
363
  `DS_TOKENS_DRIFT`) — never silent. **The design is not complete until
356
364
  this check passes**, regardless of how good it looks visually. Drift
@@ -89,6 +89,13 @@ SEARCH STRATEGY — canonical-router-first, verify-only-if-needed:
89
89
  relational → Graphify when `has_code_graph`); grep is the fallback for textual
90
90
  patterns. Follow those modules' tier order, budgets, and anti-flail rule —
91
91
  don't restate them here.
92
+ a-bis. **UI / component keywords when `has_design_system: true`**: route via the
93
+ design-system layer, NOT source scans — read `${paths.design_system}/INDEX.md`
94
+ (thin router) then the **frontmatter HEAD** of the matched
95
+ `components/<Name>.md` (props/variants/token_bindings; schema
96
+ `framework/agents/component-manifest-schema.md`). Read a spec's prose / the
97
+ source only to verify a runtime-sensitive claim. This is the cheap on-demand
98
+ path that replaces reading a monolithic INDEX or component sources.
92
99
  b. Read key file headers (first 50 lines) to identify structure.
93
100
  DO NOT read `${paths.prd_dir}/` or `${paths.references_dir}/` files in full —
94
101
  route via the registry and read only the specific section you need.