Skip to content

Commit 2420361

Browse files
Bill LeoutsakosBill Leoutsakos
authored andcommitted
feat(design): add design conformance checks
1 parent 6f33c06 commit 2420361

48 files changed

Lines changed: 15111 additions & 64 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎.agents/skills/babysit/SKILL.md‎

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,12 @@ All three must hold:
5757
reported yet, and treating "not failing" as "passing" reports the PR clean before CI has
5858
had its say. Wait for it — the step-10 stop condition covers a check that never settles.
5959

60+
A passing design-conformance CI step can still contain warnings. Read its latest report and
61+
triage findings using `/ship`'s [committed design check](../ship/SKILL.md#committed-design-check).
62+
Intentional system changes and justified exceptions may remain once explained in the PR;
63+
they do not prevent a clean review or require another fix loop. Honor decisions already made
64+
in this session. Operational failures must be resolved before reporting the PR clean.
65+
6066
Do not stop early on "no new comments this round" alone — a thread can be open from an earlier
6167
round, and cubic often lands its first threads a round after Greptile's. Always check all three
6268
conditions freshly after every push.
@@ -85,11 +91,14 @@ conditions freshly after every push.
8591
If `mergeable` is `CONFLICTING`, fix that first (step 2). If a check is failing, fix that too
8692
— treat it exactly like a review finding. If a check is still `pending`, do not evaluate
8793
"clean" at all: go to step 9 and wait for it. Otherwise, if Greptile is 5/5, every thread
88-
across all pages has `isResolved: true`, and every check has finished and passed, stop —
94+
across all pages has `isResolved: true`, every check has finished and passed, and any design
95+
warnings have been triaged as above, stop —
8996
report the outcome (see "Reporting" below) and skip the rest of this list.
9097

9198
2. **If the PR has a merge conflict**, merge `origin/staging`, resolve the conflicts, run the
92-
usual pre-push checks, push, and go to step 8 to re-trigger review.
99+
usual pre-commit checks and commit the resolution. Run `/ship`'s
100+
[committed design check](../ship/SKILL.md#committed-design-check) against the resulting HEAD
101+
before pushing, then go to step 8 to re-trigger review.
93102

94103
3. **If no review has run yet** (fresh PR, no bot comments): both run automatically on PR open —
95104
confirm via `gh pr checks <n>` (look for `Greptile Review` and `cubic · AI code reviewer`) and
@@ -129,7 +138,11 @@ conditions freshly after every push.
129138
migration safety, and the regenerate + audit phases. A review-fix round is still a code change
130139
and can trip any of them just as easily as the original commit did.
131140

132-
7. **Commit and push** the round's fixes as one commit — `--force-with-lease` whenever step 6's
141+
7. **Commit, check and push** the round's fixes as one commit. After committing and before
142+
every push, follow `/ship`'s [committed design check](../ship/SKILL.md#committed-design-check),
143+
including warning triage and committing/rechecking any resulting fixes. Push only the
144+
checked HEAD; rerun after a rebase or any other change to the comparison.
145+
Use `--force-with-lease` whenever step 6's
133146
sync check rewrote history, which includes a plain `git rebase origin/staging` that completed
134147
with no conflicts, not only the cherry-pick rebuild path; both rewrite commits already
135148
published to the remote, so a plain `git push` can be rejected either way — then run `/ship`

‎.agents/skills/emcn-design-review/SKILL.md‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,14 @@ User arguments: $ARGUMENTS
1616

1717
This codebase uses **emcn**, a custom component library built on Radix UI primitives with CVA variants and CSS variable design tokens. All UI must use emcn components and tokens.
1818

19+
## Deterministic conformance and fixes
20+
21+
For committed product UI changes, run `bun run check:design --base <actual-target-branch> --head HEAD`. This checks central derivation, component ownership and system changes; it does not judge whether an approved red variant or monospace font is a good product choice. The style review advice below may inform suggestions, but must not be presented as additional deterministic linter rules.
22+
23+
With fixes enabled, correct straightforward local violations using the cited central token, recipe or component prop. For a small gray adjustment, choose the approved token that fits its role (body, muted, icon or surface); do not hardcode the nearest hex. Ask the engineer when a correction has broad impact or ambiguous intent, especially before changing shared definitions or adding variants. An intentional change or justified artwork exception can proceed with an explanation in the PR; retain the warning. New shared standards should involve the designer. Do not enlarge this task into a whole-codebase cleanup or invent a central token just to pass.
24+
25+
Untouched debt stays quiet. Bringing noncompliant styling into a new file or component is an opportunity to fix it, even when its value is unchanged. Product artwork should use the registered central libraries; central asset changes notify. Landing pages, user media and sanctioned provider branding are separate scope. Unknown HTML illustrations may still receive normal styling warnings. Unresolved inputs are not proof of conformance. Only committed blobs are checked, and exit 2 means an operational failure; CI findings currently warn without blocking. See `scripts/design-conformance/README.md` for exact coverage.
26+
1927
## Steps
2028

2129
1. Read the emcn public barrel at `packages/emcn/src/index.ts` (re-exports components, Calendar, Table*, and icons) to know what's available; for the full icon set read `packages/emcn/src/icons/index.ts`

‎.agents/skills/ship/SKILL.md‎

Lines changed: 28 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
name: ship
3-
description: Commit, push, and open a PR to staging in one shot — runs the cleanup pass and, when migrations changed, the db-migrate safety review first
3+
description: Commit, check design conformance, push, and open a PR to staging — runs cleanup and the applicable migration safety review first
44
argument-hint: "[optional context or scope notes]"
55
---
66

@@ -82,7 +82,7 @@ When the user runs `/ship`:
8282
bun run docs-manifest:check || { echo "❌ docs manifest out of sync — do not ship"; exit 1; }
8383
```
8484
If Phase A regenerated a file, its matching `:check` in Phase B now passes trivially — that parity is the point. Do not ship with any generator or audit failing; fix the cause (never silence it) and re-run. `check:migrations` and `type-check` are covered by steps 5 and CI respectively and are not repeated here.
85-
7. **Stage and commit** the changes with the generated message — including any files Phase A regenerated in step 6
85+
7. **Stage and commit** the changes with the generated message — including any files Phase A regenerated in step 6. Then run the [committed design check](#committed-design-check) below and resolve or explain its findings before step 8.
8686
8. **Push to origin** using the current branch name — `--force-with-lease` if step 2's sync
8787
check did any history rewrite (a clean rebase or a cherry-pick rebuild) on a branch that had
8888
already been pushed once; a plain push would be rejected in exactly the polluted-remote case
@@ -98,7 +98,31 @@ When the user runs `/ship`:
9898
positional/line-by-line comparison against the PR's oldest-first list can spuriously fail on
9999
any multi-commit branch. These two lists must describe the same commits in the same order
100100
(same subjects, the last one being the commit from step 7). If they don't match, the branch
101-
still has a problem — redo step 2's fix and `git push --force-with-lease`.
101+
still has a problem — redo step 2's fix, repeat the committed design check for the resulting HEAD, and `git push --force-with-lease`.
102+
103+
## Committed design check
104+
105+
After committing and before **every push**, run this from the repository root with Bun 1.4.1:
106+
107+
```bash
108+
bun run check:design --base origin/staging --head HEAD
109+
```
110+
111+
Run it for every `/ship`; let the checker apply its own scope. A `.tsx`-only condition would miss CSS, Tailwind configuration, artwork and contract-registry changes. `check:audits` deliberately excludes this base-dependent command. It reads committed merge-base → HEAD blobs, so a run before committing cannot validate the pending changes.
112+
113+
Interpret both the exit status and the report:
114+
115+
- **0 with a completed report:** no findings; continue to push.
116+
- **1 with a completed report:** read the usage violations and central-system notifications. Triage them before pushing; findings are warnings, not an automatic shipping failure.
117+
- **2, unexpected termination, or no completed report:** the check did not complete. Fix the operational problem and rerun before pushing. A startup failure with exit 1 is not a findings report. Do not hide failures with `|| true` or treat missing output as a pass.
118+
119+
Fix straightforward usage violations through the cited central component, prop, recipe or token. For a small local gray correction, choose the approved token appropriate to its role. Do not invent a new token or loosen a contract just to remove the warning. Keep fixes within the work being shipped; unchanged debt elsewhere can wait for its own cleanup.
120+
121+
When a change has broad shared impact or ambiguous intent, explain the finding and ask the engineer how to proceed. Intentional central-system changes and justified exceptions can proceed with an explanation in the PR; involve the designer for new standards or ambiguous broad changes. Honor decisions already given in this session. Retain the warning rather than weakening the linter or requiring every intended system change to produce a clean report.
122+
123+
If this review produces edits, rerun the affected generation/lint/audit checks from step 6, commit the fixes, then repeat the design check against the new HEAD. Also rerun after a rebase, conflict resolution or other change to the comparison. Push only the checked commit; uncommitted fixes are not covered by an earlier result.
124+
125+
In the PR's **Testing** section, record the design-check outcome and explain any retained warnings. Leave **No new warnings introduced** unchecked when warnings remain. This review is about central design-system conformance; approved component variants, colours and fonts remain available for the engineer's product decisions. See `scripts/design-conformance/README.md` for scope and known unchecked inputs.
102126
103127
## Commit Message Format
104128
@@ -154,7 +178,7 @@ Describe the checks, tests, and E2E artifacts run
154178
- [x] Code follows project style guidelines
155179
- [x] Self-reviewed my changes
156180
- [ ] Tests added/updated and passing (new tests pass the `test-audit` authoring gate)
157-
- [x] No new warnings introduced
181+
- [ ] No new warnings introduced
158182
- [x] I confirm that I have read and agree to the terms outlined in the [Contributor License Agreement (CLA)](./CONTRIBUTING.md#contributor-license-agreement-cla)
159183
```
160184

‎.github/workflows/test-build.yml‎

Lines changed: 13 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -195,18 +195,11 @@ jobs:
195195
timeout-minutes: 15
196196

197197
steps:
198-
# The diff-based audits below need a base commit to read, and the default
199-
# depth of 1 clones a single commit with no parent. They normally fetch
200-
# their base by SHA (see "Resolve base ref"), so this depth only covers the
201-
# `HEAD~1` fallback — but without it that fallback resolves to nothing.
202-
#
203-
# Worth stating because the failure was invisible for so long: the migration
204-
# audit read the resulting `git diff` failure as "no migrations changed" and
205-
# exited 0, so it had never actually run on a push build.
198+
# Design conformance compares immutable merge-base sources and requires full history.
206199
- name: Checkout code
207200
uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6
208201
with:
209-
fetch-depth: 2
202+
fetch-depth: 0
210203

211204
- name: Setup Bun
212205
uses: oven-sh/setup-bun@0c5077e51419868618aeaa5fe8019c62421857d6 # v2
@@ -295,37 +288,11 @@ jobs:
295288
296289
echo "✅ All env flags are properly configured"
297290
298-
# One fetch for both base-ref audits, and no `|| true`: a swallowed fetch leaves
299-
# the base ref absent, which neither audit can tell apart from a branch that
300-
# changed nothing. The block-registry check at least degrades to a visible
301-
# `⚠ … skipping` line; the migration audit printed `✓ No new migrations to
302-
# check` and exited 0, clearing the only guard on production DDL.
303-
#
304-
# Depth stays at 1 — without a merge-base the migration audit diffs the two
305-
# tips, which under `--diff-filter=AM` is exactly the migrations new here.
306-
# Resolved once for both diff-based audits, and never with `|| true`: a
307-
# swallowed fetch leaves the base absent, which neither audit can tell apart
308-
# from a branch that changed nothing.
309-
#
310-
# On push the base is `github.event.before`, the tip the branch had before
311-
# this push — not `HEAD~1`, which names only the last commit and would let a
312-
# multi-commit push slip every earlier commit's migrations past the audit.
313-
# It is fetched by SHA at depth 1; the audits diff two tips and need no
314-
# common ancestry. An all-zero `before` means the branch is new and has no
315-
# predecessor to diff, so `HEAD~1` remains the fallback there.
291+
# Resolve immutable event revisions without making the checkout shallow again.
292+
# The same base covers the complete push for migration and block-registry checks.
316293
- name: Resolve base ref for diff-based audits
317294
id: audit_base
318-
run: |
319-
if [ "${{ github.event_name }}" = "pull_request" ]; then
320-
git fetch --depth=1 origin "${{ github.base_ref }}"
321-
echo "ref=origin/${{ github.base_ref }}" >> "$GITHUB_OUTPUT"
322-
elif [ -n "${{ github.event.before }}" ] &&
323-
[ "${{ github.event.before }}" != "0000000000000000000000000000000000000000" ]; then
324-
git fetch --depth=1 origin "${{ github.event.before }}"
325-
echo "ref=${{ github.event.before }}" >> "$GITHUB_OUTPUT"
326-
else
327-
echo "ref=HEAD~1" >> "$GITHUB_OUTPUT"
328-
fi
295+
run: bun --no-env-file scripts/design-conformance/ci.ts --resolve-refs
329296

330297
- name: Check block registry invariants
331298
run: bun run apps/sim/scripts/check-block-registry.ts "${{ steps.audit_base.outputs.ref }}"
@@ -342,6 +309,13 @@ jobs:
342309
- name: Verify docs manifest is in sync
343310
run: bun run docs-manifest:check
344311

312+
# Only findings (exit 1) are non-blocking; operational errors still fail CI.
313+
- name: Design conformance (warnings)
314+
env:
315+
DESIGN_BASE: ${{ steps.audit_base.outputs.ref }}
316+
DESIGN_HEAD: ${{ steps.audit_base.outputs.head }}
317+
run: bun --no-env-file scripts/design-conformance/ci.ts --base "$DESIGN_BASE" --head "$DESIGN_HEAD"
318+
345319
- name: Migration safety (zero-downtime) audit
346320
run: bun run check:migrations "${{ steps.audit_base.outputs.ref }}"
347321

@@ -352,7 +326,7 @@ jobs:
352326
# excludes *.test.ts(x), and including them today surfaces ~2.2k errors,
353327
# so that is its own cleanup rather than a gate to switch on here.
354328
- name: Type-check all workspaces
355-
run: bunx turbo run type-check
329+
run: bun run type-check
356330

357331
# cloud-review-tools.test.ts runs the real helper on the runner, which shells
358332
# out to rg. Blacksmith's image ships it, GitHub's doesn't.

‎CLAUDE.md‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ This file (also `AGENTS.md`) holds the repo-wide rules. Area detail lives in `.c
1111
- **Comments**: TSDoc for documentation. An inline `//` only for a terse, non-obvious why, or for a script-enforced `// <tag>: <reason>` annotation (`boundary-raw-fetch`, `double-cast-allowed`, `boundary-raw-json`, `untyped-response`, `rq-lint-allow`, `client-boundary-allow`, …). No `====` separators.
1212
- **ID generation**: `generateId()` (UUID v4, the default) or `generateShortId(size?)` (URL-safe, 21 chars by default) from `@sim/utils/id` — never `crypto.randomUUID()`, `nanoid`, or `uuid`. Both use `crypto.getRandomValues()`, so they also work in non-secure (HTTP) browsers.
1313
- **Common utilities**: use the shared helpers from `@sim/utils` instead of inline implementations:
14+
- **Design conformance**: Run `bun run check:design --base origin/staging --working-tree` while editing product UI. Reuse suitable EMCN components and global tokens; explain intentional Extras in the PR. Design findings are advisory, while an incomplete check is an error. See `scripts/design-conformance/README.md`.
15+
- **Styling**: Derive product styling from central tokens, component props and recipes where they fit. Keep product composition local. Explain intentional changes to shared standards. Landing and docs are outside the product design check.
1416
- `sleep(ms)` from `@sim/utils/helpers` — never `new Promise(resolve => setTimeout(resolve, ms))`
1517
- `toError(e)` from `@sim/utils/errors` — normalize caught values to `Error`; never `e instanceof Error ? e : new Error(String(e))`
1618
- `getErrorMessage(e, fallback?)` from `@sim/utils/errors` — never `e instanceof Error ? e.message : 'fallback'`

‎biome.json‎

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
{
22
"$schema": "https://biomejs.dev/schemas/2.0.6/schema.json",
3-
"vcs": { "enabled": true, "clientKind": "git", "useIgnoreFile": false },
3+
"vcs": {
4+
"enabled": true,
5+
"clientKind": "git",
6+
"useIgnoreFile": false
7+
},
48
"files": {
59
"ignoreUnknown": false,
610
"includes": [
@@ -144,8 +148,12 @@
144148
"overrides": [
145149
{
146150
"includes": ["apps/sim/app/_styles/tailwind.css"],
147-
"linter": { "enabled": false },
148-
"formatter": { "enabled": false }
151+
"linter": {
152+
"enabled": false
153+
},
154+
"formatter": {
155+
"enabled": false
156+
}
149157
},
150158
{
151159
"includes": ["packages/**"],
@@ -157,6 +165,15 @@
157165
}
158166
}
159167
}
168+
},
169+
{
170+
"includes": [
171+
"scripts/design-conformance/catalogue.json",
172+
"scripts/design-conformance/contracts.json"
173+
],
174+
"formatter": {
175+
"enabled": false
176+
}
160177
}
161178
],
162179
"javascript": {

0 commit comments

Comments
 (0)