|
| 1 | +--- |
| 2 | +title: "Sweep — Local & Federated Design System for Fidelity" |
| 3 | +lede: "The repeatable procedure for checking a member's CSS against the federal contract. The one sanctioned exception to the two-file rule." |
| 4 | +date_created: 2026-08-01 |
| 5 | +date_modified: 2026-08-01 |
| 6 | +semantic_version: 0.0.1.0 |
| 7 | +status: Active |
| 8 | +tags: |
| 9 | + - Loop |
| 10 | + - Design-System |
| 11 | + - Fidelity |
| 12 | + - Enforcement |
| 13 | +--- |
| 14 | + |
| 15 | +# Sweep — Local & Federated Design System for Fidelity |
| 16 | + |
| 17 | +## Purpose |
| 18 | + |
| 19 | +This loop checks a single member's CSS surface against the federal token |
| 20 | +contract. It catches what the drift script cannot: visual fidelity, token |
| 21 | +appropriateness (right token for the right job), and undocumented deviations. |
| 22 | + |
| 23 | +## When to run |
| 24 | + |
| 25 | +**By a developer:** after finishing a feature that touches CSS or adds a |
| 26 | +component. After changing a token's value in `packages/theme`. Before a release. |
| 27 | + |
| 28 | +**By an AI coding agent, self-directed:** when the diff touches CSS, Svelte |
| 29 | +style blocks, or token references. When the task description mentions colour, |
| 30 | +spacing, or typography. When the agent changes a member's `DESIGN.md`. The agent |
| 31 | +runs this loop as a *task*, not as a preamble before every edit. |
| 32 | + |
| 33 | +## Procedure |
| 34 | + |
| 35 | +### 1. Read the federal contract |
| 36 | + |
| 37 | +Read `packages/theme/theme.css` — the Tier 1 and Tier 2 blocks only. Note the |
| 38 | +tokens available. Read `DESIGN.md` §The federation contract — F1 through F11. |
| 39 | + |
| 40 | +### 2. Read the member's design surface |
| 41 | + |
| 42 | +Read every `.css` and `.svelte` file in the member's `src/` directory. Also |
| 43 | +read the member's `DESIGN.md`, including *Deviations* — deviations are declared |
| 44 | +exceptions, not bugs to "fix." |
| 45 | + |
| 46 | +### 3. Check each rule |
| 47 | + |
| 48 | +For each federal rule F1–F11, answer: does this member violate it? |
| 49 | + |
| 50 | +Key checks: |
| 51 | +- **F1 + F1a:** Grep for `--color__`, `--font__`, `--color-` (member declaring |
| 52 | + federal tokens or consuming Tier 1 directly). |
| 53 | +- **F3:** Does every selector descend from the member's root class? |
| 54 | +- **F4:** Any raw `z-index` number? Should be `var(--z-*)`. |
| 55 | +- **F8:** Any `#hex` or raw `box-shadow`? Should be a token. |
| 56 | +- **F10:** Does `mount.ts` import `theme.css`? It should not. |
| 57 | + |
| 58 | +### 4. Check token appropriateness |
| 59 | + |
| 60 | +For each token reference, ask: is this the right token for the job? |
| 61 | + |
| 62 | +- `--color-text` for body text, `--color-text-muted` for secondary. |
| 63 | +- `--color-accent` for the brand accent, `--color-accent-warm` for emphasis. |
| 64 | +- `--color-border` for decorative dividers, `--color-border-strong` for control |
| 65 | + boundaries. |
| 66 | +- `--color-error-text` for error states, `--color-warn-text` for warnings. |
| 67 | + |
| 68 | +### 5. Record findings |
| 69 | + |
| 70 | +Record every violation with file, line, and rule reference. A deviation already |
| 71 | +declared in the member's `DESIGN.md` is not a finding — it is a known exception. |
| 72 | + |
| 73 | +## Hard rules for agents |
| 74 | + |
| 75 | +1. **This loop is a task, not a preamble.** An agent that sweeps before every |
| 76 | + small edit has spent its context window on ceremony. |
| 77 | + |
| 78 | +2. **Never self-authorise implement mode.** An agent that finds a violation |
| 79 | + *reports* it. Fixing it is a separate task with its own scope. |
| 80 | + |
| 81 | +3. **Diff-scoped, not member-scoped.** When running on a code change, sweep |
| 82 | + only the files the change touches plus any files that reference the changed |
| 83 | + tokens. |
| 84 | + |
| 85 | +4. **Read the member's Deviations before reporting.** A declared deviation is |
| 86 | + not a finding. |
0 commit comments