# `_schema/` — design-system contracts This directory codifies the structural contracts for design systems. `tokens.schema.ts` re-exports the token contract that every tokenized brand under `design-systems//` must satisfy. The canonical runtime copy lives in `packages/contracts/src/design-systems/token-schema.ts` so daemon importers and repo guards consume one schema. `manifest.schema.ts` is the project contract for Design System Project packages. Every bundled catalog entry now ships `manifest.json`, `DESIGN.md`, and `tokens.css`; the daemon keeps `DESIGN.md`-only discovery solely as a compatibility path for older or user-installed folders. ``` _schema/ ├── manifest.schema.ts ← project manifest schema (TS, machine-enforced when present) ├── tokens.schema.ts ← token schema re-export (TS, machine-enforced) ├── defaults.css ← A2 fallback values (CSS, human reference) └── AGENTS.md ← this file ``` The TypeScript schemas are the source of truth. `defaults.css` is a human-readable mirror of the A2 `fallback` fields in the token schema and exists so that reviewers can scan real CSS without parsing a TS array — drift between the two is enforced by the `design-system: A2 defaults parity` guard. Manifest shape is enforced by `scripts/check-design-system-manifests.ts` for any `design-systems//manifest.json` that exists. ## Project manifest contract Design System Project folders use fixed v1 file names: - `manifest.json` — machine-readable project entry. - `DESIGN.md` — canonical design prose. - `tokens.css` — canonical compiled tokens. - `design-tokens.json` — optional Design Tokens JSON derived from `tokens.css` + `source/token-contract.report.json`. - `tailwind-v4.css` — optional Tailwind v4 `@theme` CSS derived from `tokens.css`; it must not redefine source values independently. - `components.html` — optional standalone component fixture. - `assets/` — optional brand assets. - `preview/` — optional static preview pages. - `USAGE.md` — optional agent-facing package guide. - `components.manifest.json` — optional rebuildable cache derived from `components.html` and `tokens.css`. - `fonts/` — optional webfont files. - `source/` — optional importer evidence (`scanned-files.json`, `evidence.md`, `tokens.source.json`, `token-contract.report.json`, and `snippets/INDEX.json`). The manifest guard validates every bundled package through its `manifest.json`. When rich fields are declared, paths must be safe and present, JSON indexes must parse, and committed `components.manifest.json` files must match a fresh derivation from `components.html` plus `tokens.css`. These fields are also runtime inputs: catalog discovery consumes manifest metadata; prompt composition consumes usage, tokens, component information, import mode, craft bindings, and the manifest-derived pull index; package/static-file routes expose only declared preview and source files. Legacy `DESIGN.md`-only folders remain outside this manifest guard because they have no manifest to validate. ## Four layers, two questions Every shared token answers two questions: 1. **Who decides the value?** — the brand author (Layer A) or the schema author (Layer B-slot, when the brand has no opinion). 2. **What happens if the brand omits it?** — required, fallback, or alias. The four layers fall out of those answers: | Layer | Who decides | If omitted | Examples | | --- | --- | --- | --- | | **A1-identity** | brand | guard fails | `--bg`, `--fg`, `--accent`, `--font-display` | | **A1-structure** | brand | guard fails | type scale, `--container-max`, `--section-y-*` | | **A2** | brand (with fallback) | guard fails today; derive script fills tomorrow | `--motion-fast`, `--success`, `--space-4`, `--font-mono` | | **B-slot** | brand or schema-suggested alias | guard fails — brand must declare, either as `var(--sibling)` (collapsed) or independent value (richer) | `--fg-2 → var(--fg)`, `--surface-warm → var(--surface)` | Brand-specific tokens that fall outside the shared schema are tracked as **C-extensions** in `BRAND_EXTENSIONS` (per-brand allowlist) or `BRAND_EXTENSION_PREFIXES` (global prefix allowlist for whole families like `--tag-bg-*`). ## Why A2 fails the guard today (and might not later) A2 conceptually means "optional with fallback" — but artifacts are generated by agents pasting one brand's `:root` block into a single `