Design compliance — how to run the canon guards
npm run design:check runs the ADSF source gate and all four existing guards.
CI runs this enforcement unconditionally, including participant-only changes and
policy-only edits. Dev deployment requires the design-system job to succeed.
Manual deployments with tests enabled use the same composite action.
The original four guards remain complementary: three read source text, and one reads a committed browser extract. A green extract check validates that recorded measurement; it is not a fresh browser run.
npx vitest run \
src/__tests__/paletteCanon.test.ts \
src/__tests__/cortexMonochrome.test.ts \
src/__tests__/canonPropagation.test.ts \
src/__tests__/designCompliance.test.ts
npm test runs all four. The commands below run one group at a time.
| Guard | Reads | Catches |
|---|---|---|
paletteCanon |
every .ts/.tsx/.css file under src/ |
a hex or a Tailwind palette class that a person typed |
cortexMonochrome |
the staff files only | brand warmth that creeps into the monochrome staff shell |
canonPropagation |
design/canon.json and both guard files |
a ban that claims a platform but wires no matcher |
designCompliance |
design/route-colors.json |
a colour or typeface that renders, whatever the source spells |
ADSF source enforcement
Use Node 24 and Python 3.11+. Install the exact reviewed adapter once per checkout:
npm ci
# .codex-cache is ignored. Use a new destination; do not overwrite another checkout.
git clone --no-checkout https://github.com/ashrocket/agent-design-system.git .codex-cache/adsf
git -C .codex-cache/adsf checkout --detach c598a71f37704ad61e5746eb0d699ed52b4a9635
npm ci --prefix .codex-cache/adsf/src/agent_design_system/adapters/tsx --ignore-scripts --no-audit --no-fund
npm run design:check
An existing clean, exact-pinned checkout can be selected with ADSF_ROOT.
If python3 selects Apple's old Python, set ADSF_PYTHON_BIN to an installed
Python 3.11+ executable. After setup, the gate needs no network or model. It
reads app source without importing or rewriting it. Setup or parser failures
stop the check; they are never converted to an advisory success.
design/canon.jsonis the web palette source for both the existing palette guard and ADSF. Staff grayscale keeps the existing staff-surface exemption.design/theme-contract.jsonlocks all 30 color bindings and both font stacks insrc/index.css. A semantic ink token cannot silently become warm gray, even though both values belong to the palette. Duplicate definitions, resets, and CSS overrides of protected tokens are rejected. The existing danger, brand-soft and report-footer exceptions are frozen with exact values and provenance; they are not new palette approvals. Overrides outside@themeare rejected even when CSS omits the final semicolon.design/adsf-baseline.jsonwas initialized with 384 static debt occurrences in 228 file/code/utility fingerprints at commitcf42faf08172f6c0d8f5f8bf57c43d7504e1efee. It is a debt ledger, not canon. A new file, color, utility, variant, or increased occurrence count fails. Moving a line within its file is harmless. A stale allowance also fails when debt shrinks or its utility or file disappears. The failure prints the exact fingerprint, allowed count, and current count. Manually set that fingerprint's count to the current count, or remove it when the current count is zero, in the same change so removed debt cannot return. The gate does not rewrite the baseline; reductions pass once the matching allowances are ratcheted down.- Unknown color tokens and unresolved arbitrary colors fail outright. Four
undefined badge utilities in
DashboardPulseListwere replaced with the existinglight-grayandorange-on-white-and-inversebindings; its action strings now use existing tokens too.
Do not increase debt allowances, widen exemptions, or alter the theme contract
just to silence a failure. Policy changes require design rationale and review.
Use npm run design:test for the enforcement regression tests. To retain the
location-bearing source inventory explicitly:
npm run design:source -- --report .codex-cache/design/tailwind-audit.json
Report output cannot overwrite tracked files or source/policy directories, and an existing symlink or hardlink is rejected. Use an untracked artifact path such as the one above. This check protects against accidental output-path mistakes; it is not a filesystem sandbox against concurrent changes.
At the initial scan the adapter inspected 178 TSX files and 23,409 static class tokens. It also reported 705 dynamic class expressions; these remain coverage gaps and do not fail solely because they are dynamic. Tests and customer-branding fixtures are excluded. This is not a full CSS, inline-style, runtime, typography, accessibility, or visual audit. The existing guards still cover their own broader source patterns and recorded browser evidence. Inspect real screens after visual changes, and retain the rendered guard's limits below.
The rendered guard
The first three guards read text. They cannot see a colour that arrives through
a Tailwind utility, a CSS variable, a gradient stop or a ::before, because
none of those spell the hex anywhere. The fourth guard closes that hole.
It runs in two steps, on purpose.
Extract. A script drives a real browser across every route and records what each one painted.
npm run design:extract # writes design/route-colors.jsonThe script starts its own Vite on port 5178. Set
DESIGN_SCAN_PORTto move it. Playwright must have a browser: runnpx playwright install chromiumone time.Assert and print. A test reads the committed extract. It needs no browser and no server.
npm run design:report # the full per-route printout
Rules
Use
npm run design:reportto see the colours. The default Vitest reporter hidesconsole.info. The printout is the point of the test, and the plainvitest runcommand does not show it.Do not add
--silent. The test writes the new baseline toconsole.info. The--silentflag removes the output that you must paste.Re-extract after you add a route. The test parses
src/App.tsxandsrc/apps/Cortex.tsxand compares the result to the extract. A new route fails the test until you runnpm run design:extractagain.Classify a new route in
ROUTE_PLAN. The plan lives inscripts/design/route-manifest.mjs. Give the route a session and any path params, or give it a skip reason. The extractor stops when a route has neither.Paste the printed baseline. When a count changes on purpose, the test prints a line that starts with
DESIGN_DEBT_JSON. Copy that JSON intodesign/design-debt.json. The test also prints after an improvement, so a ratchet-down leaves the file stale until you paste.A colour can reach fewer routes. A colour cannot reach more. The ratchet counts routes, not elements. Element counts move with fixture data. Route counts do not.
Add a fixture, not an allowance. A page that fails to render gives a handful of canon colours and looks clean. The test refuses that: it checks the final URL, an element floor and the error boundary for each route. Fix the mock in
GATE_MOCKS, and do not widenKNOWN_THINto silence a failure.Keep
design/canon.jsonand the guard files in step.canonPropagationlooks for the matcher text inside the guard source. The two strings must be identical. Edit one alone and the suite fails.Write a PR number without the number sign. The
paletteCanonhex rule matches a three-digit hex. A comment that contains#402reads as the colour#440022.
What the rendered guard does not cover
- iOS.
canonPropagationopensios/UserHappyTests/PaletteCanonTests.swiftand confirms the matcher text is present. It does not run Swift. A green web run does not prove the iOS palette is clean. Run the Xcode tests for that. - Embedded documents. The staff
/docspages wrap prebuilt HTML in an iframe. Those colours are recorded in the extract and printed, but they are not enforced. They are published artefacts with their own design authority. - Alpha. A canon hex at any opacity counts as canon. The printout shows the alpha so the drift is visible.
- Hover, focus and dark states. The scan reads the resting, light-scheme page at 1440×900.
- The routes named under
NOT SCANNEDin the printout. That list is the honest edge of the scan. Shrink it.