dsforge-harness 0.1.1 → 0.1.5

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.
package/README.md CHANGED
@@ -1,7 +1,143 @@
1
1
  # dsforge
2
2
 
3
- A verified **design → design-system → code** harness for Claude Code.
3
+ A verified **design → design-system → code** harness for Claude Code. / Claude Code용 검증형 **디자인 → 디자인시스템 → 코드** 하네스.
4
4
 
5
+ ## 목차 / Table of Contents
6
+ - **한국어**
7
+ - [개요](#개요)
8
+ - [설치 / 사용](#설치--사용)
9
+ - [무엇을 입력받나](#무엇을-입력받나)
10
+ - [구조](#구조)
11
+ - [한계](#한계)
12
+ - [포크 / 리브랜딩 메모](#포크--리브랜딩-메모)
13
+ - **English**
14
+ - [Overview](#overview)
15
+ - [Install / use](#install--use)
16
+ - [What it asks for](#what-it-asks-for)
17
+ - [Structure](#structure)
18
+ - [Limits](#limits)
19
+ - [Notes for forking / rebranding](#notes-for-forking--rebranding)
20
+
21
+ ---
22
+
23
+ # 한국어
24
+
25
+ ## 개요
26
+ 기능 명세와 Figma 디자인시스템(DS)을 주면 전체 파이프라인을 굴립니다 — Figma 시안, 토큰 바인딩 디자인시스템,
27
+ 토큰 충실 프론트엔드 코드 — **자동 검사 게이트**(DS 감사 · 시안-명세 대조 · 코드-DS 대조)와 **사람 리뷰 게이트
28
+ 2곳**과 함께. 원칙은 *추정하지 말고 측정하라*: 모든 단계를 빌드 보고서가 아니라 Figma 노드와 코드를 **직접 읽어**
29
+ 검증합니다. 두 화면(리스트·폼) × 두 도메인에서 단계별로 검증됐고, DS가 없을 때 토큰 바인딩 DS를 처음부터 도출하는
30
+ **Branch B** 도 검증됐습니다.
31
+
32
+ > 엔진은 Claude입니다(시안·코드는 Claude가 만들고, 리뷰어가 검증). 번들 스크립트는 **검사만** 자동화합니다 —
33
+ > dsforge는 화면을 혼자 찍어내는 정적 생성기가 아닙니다.
34
+
35
+ ## 설치 / 사용
36
+ **동작 모델:** dsforge 설치(`npx dsforge-harness init` 또는 아래 플러그인 경로)는 셸에서 실행하는 **유일한** 단계
37
+ 입니다. skill과 `CLAUDE.md` 진입점만 깔아줍니다. 이후는 전부 **Claude Code 세션 안에서** 일어납니다: Claude가
38
+ Figma 시안과 코드를 만들고, Figma-MCP 검사(Check 1/2)와 Node 검사(Check 3 / `verify`)를 돌리고, **사람 게이트 2곳**
39
+ 에서 멈춰 승인을 기다립니다. dsforge는 **터미널에서 호출하는 단독 생성기가 아니라** Claude Code가 따르는 하네스
40
+ 입니다. `npx dsforge-harness verify/check3`는 Node 쪽 검사만 다시 돌릴 뿐 화면을 만들지 않습니다.
41
+
42
+ **A — npm으로 프로젝트별 설치 (공개 기본):**
43
+ ```
44
+ npx dsforge-harness init
45
+ ```
46
+ skill을 `.claude/skills/dsforge/`에 설치하고 현재 프로젝트에 `CLAUDE.md` 진입점을 씁니다. 그 폴더에서 Claude Code를
47
+ 열면 읽고 시작합니다. "하네스를 한 리포에 떨궈서 바로 쓰는" 경로이며 누구나 됩니다(npm 패키지는 공개).
48
+ (`npx dsforge-harness verify <project> <screen>`로 검증기도 돌릴 수 있습니다.)
49
+ > npm 패키지명은 **`dsforge-harness`**, 설치되는 CLI 명령은 **`dsforge`** 입니다 — 전역 설치
50
+ > (`npm i -g dsforge-harness`) 후엔 `dsforge init` / `dsforge verify …`로 실행합니다.
51
+
52
+ **B — Claude Code 플러그인으로 (모든 프로젝트에서 사용):**
53
+ ```
54
+ /plugin marketplace add jsiksn/dsforge # 이 GitHub 리포
55
+ /plugin install dsforge@dsforge
56
+ ```
57
+ 설치 후 아무 프로젝트나 열고, `dsforge` skill이 깔려 있으므로 명세로 화면을 만들어 달라고 하면 하네스가 트리거됩니다.
58
+ 나중에 `/plugin marketplace update`로 갱신.
59
+ > **주의 — GitHub 리포는 현재 비공개입니다.** 마켓플레이스 경로(B)는 리포 소유자(또는 접근 허가된 계정)만 됩니다.
60
+ > 공개 전까지는 위 **npm 경로(A)** 를 쓰세요(공개 기본).
61
+
62
+ **C — 수동:** `plugins/dsforge/skills/dsforge/`를 `~/.claude/skills/`(모든 프로젝트) 또는 리포의
63
+ `.claude/skills/`(해당 프로젝트)로 복사.
64
+
65
+ **설치 후 Claude Code에 붙여넣어 하네스를 시작하는 프롬프트:**
66
+ ```
67
+ Run the dsforge harness for this project. Inputs:
68
+ - Design-system Figma file key: <DS_FILE_KEY> (or: "no DS yet — propose mockups first, then derive the DS")
69
+ - Functional spec: <paste the spec, or a path/link>
70
+ - Working Figma file key (for mockups): <WORK_FILE_KEY>
71
+ - Screens to build: <e.g. dataset list; model create/edit>
72
+ - Mockup options per screen: <default 2-3>
73
+
74
+ Follow the dsforge skill's pipeline exactly. First confirm whether a real DS exists
75
+ and how many mockup options per screen, then take the branch:
76
+ - Branch A (DS exists): audit the DS -> if it has gaps, ASK me augment-vs-mark-"(proposed)"
77
+ -> extract tokens -> per screen [ build 2-3 mockup OPTIONS -> run checks ->
78
+ STOP for my pick (GATE 1) -> build code -> run checks -> STOP for final review (GATE 2) ].
79
+ - Branch B (no DS): per screen build 2-3 mockup OPTIONS first -> STOP for my pick (GATE 1)
80
+ -> author a new token-bound DS in a new Figma file (variables, focus/disabled variants,
81
+ elevation) until check1 PASSes -> extract tokens -> build code -> run checks ->
82
+ STOP for final review (GATE 2).
83
+ Rules: tokens only (no hardcoded hex/px) once a DS exists; never fabricate spec content
84
+ (mark proposals "(제안)"/"(proposed)"); measure by reading Figma nodes and code, don't
85
+ trust build reports; hold at both human gates (exactly two) until I approve.
86
+ Craft: author every component with auto-layout (no clipped labels, no floating/detached
87
+ nodes, correctly-sized badges); keep the DS and the screens on SEPARATE pages
88
+ ("Design System" / "Screens"); and render + self-critique each screen to a clean image
89
+ BEFORE running the mechanical checks — GATE 1 is the visual judgment point, and a green
90
+ check is a floor, not the quality bar.
91
+ ```
92
+
93
+ ## 무엇을 입력받나
94
+ 트리거되면 Claude Code가 먼저 **진짜 DS가 이미 있는지**(Branch A) 없는지(Branch B)와 **화면당 시안 옵션 수**
95
+ (기본 2–3)를 확인한 뒤, ① 대상 **디자인시스템 Figma 파일 키**(Branch A) ② **기능 명세** ③ 시안용 **작업 Figma
96
+ 파일 키** 를 받습니다. 그다음 둘 중 하나를 굴립니다:
97
+ - **Branch A (DS 있음):** DS 감사(빈틈 있으면 *보강 vs "(제안)" 표시* 를 물음) → 토큰 추출 → 화면마다
98
+ [시안 2–3안 → 검사 → *하나 선택* → 코드 → 검사 → *최종 리뷰*].
99
+ - **Branch B (DS 없음):** 화면마다 [시안 2–3안 → *하나 선택*] → 새 Figma 파일에 토큰 바인딩 DS 작성(변수,
100
+ focus/disabled variant, elevation)해서 DS 감사 통과까지 → 토큰 추출 → 코드 → 검사 → *최종 리뷰*.
101
+
102
+ 어느 쪽이든 사람 게이트는 정확히 **둘**입니다.
103
+
104
+ ## 구조
105
+ ```
106
+ dsforge/
107
+ ├── .claude-plugin/marketplace.json # 이 리포는 CC 플러그인 마켓플레이스
108
+ ├── plugins/dsforge/
109
+ │ ├── .claude-plugin/plugin.json
110
+ │ └── skills/dsforge/
111
+ │ ├── SKILL.md # 하네스 skill (트리거 + 워크플로)
112
+ │ ├── validators/ # 검증기 + 토큰 추출기 (+ projects/_TEMPLATE.json, ezp.json)
113
+ │ ├── references/ # 방법론, 런북, 실제 실행 예시
114
+ │ └── assets/code-scaffold-reference-ezp/ # 참조 React 구현 (드롭인 아님, 패턴)
115
+ ├── templates/CLAUDE.md # `dsforge init`가 프로젝트에 써줌
116
+ ├── bin/dsforge.js # npm CLI (init / verify / check3)
117
+ └── package.json
118
+ ```
119
+ 제네릭·재사용: `validators/`(DS를 입력으로) 와 `references/`(방법). 프로젝트별 예시:
120
+ `code-scaffold-reference-ezp/` 와 `validators/projects/ezp.json` — `ezp`는 dsforge가 검증된 디자인시스템일 뿐,
121
+ 하네스의 일부가 아닙니다.
122
+
123
+ ## 한계
124
+ **DS 조합형 화면**(리스트 / 폼 / 상세)에서 증명됨. **캔버스 / 그래프 에디터형 화면은 미검증.** 검사는 기계적
125
+ 토큰/콘텐츠/구조 충실도만 검증하며, 시각적 판단과 디자인 의도는 사람 게이트의 몫입니다. 전제: Claude Code +
126
+ Figma MCP(당신 Figma에 인증), Node.js ≥ 18, 리뷰어.
127
+
128
+ ## 포크 / 리브랜딩 메모
129
+ - 이름 `dsforge`가 전반(package, plugin, skill, marketplace)에 쓰입니다. 리브랜딩하려면 `package.json`,
130
+ `.claude-plugin/marketplace.json`, `plugins/dsforge/.claude-plugin/plugin.json`에서 바꾸고
131
+ `plugins/dsforge/` + `plugins/dsforge/skills/dsforge/`를 리네임하세요.
132
+ - `npm publish` 전에 npm 이름 가용성 확인 — 선점됐으면 스코프(`@<you>/dsforge`).
133
+
134
+ 라이선스: MIT.
135
+
136
+ ---
137
+
138
+ # English
139
+
140
+ ## Overview
5
141
  Give it a functional spec and a Figma design system, and it drives the whole pipeline — Figma mockups,
6
142
  token-bound design system, token-faithful front-end code — with **automated check gates** (DS audit,
7
143
  mockup-vs-spec, code-vs-DS) and **two human review gates**. Its rule is *measure, don't estimate*:
@@ -13,7 +149,6 @@ a brand-new token-bound design system from scratch when no DS exists.
13
149
  > automate only the **checking** — dsforge is not a static generator that emits screens on its own.
14
150
 
15
151
  ## Install / use
16
-
17
152
  **How it runs (operating model):** installing dsforge — `npx dsforge-harness init` or the plugin path below — is the
18
153
  only step you run at a shell. It just places the skill and a `CLAUDE.md` entry point. Everything after that
19
154
  happens **inside a Claude Code session**: Claude builds the Figma mockups and the code, runs the Figma-MCP
@@ -31,8 +166,7 @@ project. Open Claude Code in that folder → it reads them and starts. This is t
31
166
  repo and go" path, and it works for anyone — the npm package is public. (You can also
32
167
  `npx dsforge-harness verify <project> <screen>` to run the verifier.)
33
168
  > The npm package is **`dsforge-harness`**, but the CLI command it installs is **`dsforge`** — so after a
34
- > global install (`npm i -g dsforge-harness`) you run `dsforge init` / `dsforge verify …`. The Claude Code
35
- > plugin, the `dsforge` skill, the repo `jsiksn/dsforge`, and the kickoff prompt are all unchanged.
169
+ > global install (`npm i -g dsforge-harness`) you run `dsforge init` / `dsforge verify …`.
36
170
 
37
171
  **B — As a Claude Code plugin (available in every project):**
38
172
  ```
@@ -97,11 +231,11 @@ dsforge/
97
231
  │ ├── .claude-plugin/plugin.json
98
232
  │ └── skills/dsforge/
99
233
  │ ├── SKILL.md # the harness skill (triggers + workflow)
100
- │ ├── validators/ # verifier + token extractor (+ projects/_TEMPLATE.json, ezp.json)
234
+ │ ├── validators/ # verifier + token extractor (+ projects/_TEMPLATE.json, ezp.json)
101
235
  │ ├── references/ # methodology, runbook, real-run examples
102
236
  │ └── assets/code-scaffold-reference-ezp/ # reference React impl (a pattern, not drop-in)
103
237
  ├── templates/CLAUDE.md # written into a project by `dsforge init`
104
- ├── bin/dsforge.js # the npm CLI (init / verify / check3)
238
+ ├── bin/dsforge.js # the npm CLI (init / verify / check3)
105
239
  └── package.json
106
240
  ```
107
241
  Generic & reusable: `validators/` (DS-as-input) and `references/` (method). Project-specific examples:
package/bin/dsforge.js CHANGED
@@ -52,6 +52,9 @@ Usage:
52
52
  npx dsforge-harness init Install the dsforge skill + CLAUDE.md into this project
53
53
  npx dsforge-harness verify <proj> <scr> Run the full verifier (node) for a project/screen
54
54
  npx dsforge-harness check3 <proj> <scr> Run only the code-vs-DS check (node)
55
+ npx dsforge-harness check-recall <proj> <cur> <prior>
56
+ From-scratch recall-leak check: compare a screen's non-spec
57
+ content against a prior screen (node)
55
58
  npx dsforge-harness help This message
56
59
 
57
60
  check1 / check2 / extract-tokens run inside Claude Code via the Figma MCP (see the skill).
@@ -62,6 +65,7 @@ switch (cmd) {
62
65
  case 'init': init(); break;
63
66
  case 'verify': runScript('verify.js', rest); break;
64
67
  case 'check3': runScript('check3.js', rest); break;
68
+ case 'check-recall': runScript('check-recall.js', rest); break;
65
69
  case undefined:
66
70
  case 'help':
67
71
  case '-h':
package/package.json CHANGED
@@ -1,9 +1,9 @@
1
1
  {
2
2
  "name": "dsforge-harness",
3
- "version": "0.1.1",
3
+ "version": "0.1.5",
4
4
  "description": "Verified design→design-system→code harness: a functional spec becomes Figma mockups, a token-bound design system, and token-faithful code, with automated check gates and two human review gates. Ships as a Claude Code plugin/skill.",
5
5
  "bin": { "dsforge": "bin/dsforge.js" },
6
- "scripts": { "test": "node plugins/dsforge/skills/dsforge/validators/test/check-layout.test.js" },
6
+ "scripts": { "test": "node plugins/dsforge/skills/dsforge/validators/test/run-all.js" },
7
7
  "files": ["bin/", "plugins/", "templates/", "README.md"],
8
8
  "keywords": ["design-to-code", "design-system", "figma", "design-tokens", "verification", "claude-code", "claude", "skill"],
9
9
  "license": "MIT",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsforge",
3
- "version": "0.1.1",
3
+ "version": "0.1.4",
4
4
  "description": "Verified design→design-system→code harness: a functional spec becomes Figma mockups, a token-bound design system, and token-faithful code, with automated check gates (DS audit, mockup-vs-spec, code-vs-DS) and two human review gates.",
5
5
  "author": { "name": "jsiksn" },
6
6
  "homepage": "https://github.com/jsiksn/dsforge",
@@ -76,6 +76,14 @@ appear *verbatim*) before building any mockup.
76
76
  - **[HUMAN GATE 2] final screen review.**
77
77
 
78
78
  ### Branch B — no DS yet (order reversed: mockups → DS → code)
79
+ > **From-scratch isolation (REQUIRED).** Branch B derives each screen from the **spec alone**. Do **not**
80
+ > look at, copy, or "carry over" any previous screen or its data — not an earlier Branch-A screen, not a
81
+ > sibling Branch-B screen. If a prior screen is in your context, a from-scratch build will *recall* it:
82
+ > colours/fonts change but the **layout/IA and the non-spec incidental content** (placeholder ids, dates,
83
+ > filter labels, footer text) come back identical, which is a leak, not a design. So: generate **fresh
84
+ > placeholders** for anything the spec doesn't define (and mark "(제안)/(proposed)"); the only inputs are the
85
+ > **spec + empty files**. Cross-check with `check-recall.js` (below). **Re-test in a session that has never
86
+ > seen the other screen** — a recall can't be ruled out in a context that already contains it.
79
87
  1. **Skip the audit** — there is no DS to audit. Go straight from the spec to visual proposals.
80
88
  2. **Per screen, build 2–3 mockup options** (the count from step 4) with `use_figma` — each a **full
81
89
  viewport + app shell**, **auto-layout, aligned, filling the viewport, realistic density, no floating
@@ -149,14 +157,42 @@ separate page** (`Screens`). Never pile the DS and the screens onto one page.
149
157
  exact invocation.
150
158
 
151
159
  ## How the validators run
152
- - `check3.js`, `verify.js` → **Node** (run via `npx dsforge check3 <project> <screen>` / `npx dsforge verify <project>`, or `node validators/check3.js <project> <screen>` from the app root).
160
+ - `check3.js`, `verify.js`, `check-recall.js` → **Node** (run via `npx dsforge check3 <project> <screen>` /
161
+ `npx dsforge verify <project>` / `npx dsforge check-recall <project> <cur> <prior>`, or `node validators/<x>.js …`
162
+ from the app root). `check3` also enforces **size-token dimension fidelity** when the descriptor declares
163
+ `sizeBindings` (each bound element's dimension must come from its size token + `box-sizing: border-box`).
164
+ `check-recall` is the **from-scratch recall guard** — for Branch B screens, compare each new screen's
165
+ non-spec content against any prior screen; a high overlap means the build recalled it instead of deriving
166
+ it from the spec.
153
167
  - `check1.js`, `check2.js`, `check-layout.js`, `extract-tokens.js` → **Figma MCP `use_figma`** (paste the
154
168
  script body, pass the descriptor as config). See each file's top comment. `check-layout.js` is the visual
155
- floor — run it (hardFails 0) before GATE 1.
169
+ floor — run it (hardFails 0) before GATE 1. `check2.js` also emits a `textFingerprint` that `check-recall`
170
+ consumes for the mockup-stage comparison.
156
171
 
157
172
  ## Disciplines (non-negotiable)
158
173
  - **Tokens only** — no hand-entered hex/px except the structural exceptions declared in the descriptor
159
174
  (`structuralPxAllow`: 1px hairlines, focus-ring width, etc.).
175
+ - **Size tokens bind dimensions** — when a DS size token exists for an element's dimension (row / input /
176
+ button / bar height, etc.), set that dimension *from the token* (`height: var(--…-size-…)`) with
177
+ `box-sizing: border-box`. Never let the rendered size fall out of padding+border arithmetic — that drifts
178
+ ~1px per element and accumulates. `check3` enforces this via the descriptor's `sizeBindings`.
179
+ - **From-scratch isolation** — in Branch B, derive each screen from the **spec + empty files only**; never
180
+ reference or copy a prior screen or its data, generate fresh placeholders, and guard with `check-recall.js`
181
+ (re-test in a session that never saw the other screen).
182
+ - **Surface fills** — only genuinely *raised* surfaces (card / panel / table / status-card) carry a background
183
+ token; **layout / auto-layout wrappers have no fill (transparent)**. Don't repaint a region in the same
184
+ colour as the surface beneath it (white-on-white). `check-layout` surfaces such **nested same-fill** as an
185
+ **advisory** (a review signal, not a gate) — it doesn't block, because some same-fill repaints (inset
186
+ full-area body bgs, surface-in-surface) are discipline-true yet visually harmless and no geometric rule
187
+ cleanly separates those from real defects. The discipline is the real lever here; the advisory just flags
188
+ candidates. Applies at mockup, DS, and code.
189
+ - **Icon & vector assets** — **Branch A only:** extract the DS's icon / logo / glyph **vector** nodes
190
+ (`node.exportAsync({ format: 'SVG_STRING' })`) and emit them as **inline SVG**, not placeholder boxes. Keep
191
+ the colour-token discipline: monochrome icons → `fill="currentColor"` (the colour comes from the consuming
192
+ slot's `color` token); multi-colour logos → map each colour to its brand token `var(--…)`. **Strip every
193
+ baked raw hex** (`fill="#…"`) — currentColor or token vars only. **Branch B (from-scratch):** there is no DS
194
+ to export from, so icons stay **manual placeholders** (boxes, marked "(제안)") until a DS exists. `check3`
195
+ (`iconAssets`) verifies declared icon slots carry real `<svg>` with zero raw hex.
160
196
  - **Zero fabrication** — anything not in the spec is marked "(제안)/(proposed)" with placeholder values.
161
197
  - **Measure, don't estimate** — verify by reading nodes/code, never by trusting a build report.
162
198
  Traverse **inside** component instances.
@@ -177,8 +213,9 @@ who independently re-derives the numbers. Don't collapse the two.
177
213
  intent are what the human gates are for.
178
214
 
179
215
  ## Bundled resources
180
- - `validators/` — the verifier + token extractor (`extract-tokens, check1, check2, check-layout, check3, verify`),
181
- plus `projects/_TEMPLATE.json` (fill per project) and `projects/ezp.json` (filled example).
216
+ - `validators/` — the verifier + token extractor (`extract-tokens, check1, check2, check-layout, check3,
217
+ check-recall, verify`), plus `projects/_TEMPLATE.json` (fill per project), `projects/ezp.json` (filled
218
+ example), and `test/` (node regression tests, run via `npm test`).
182
219
  - `references/` — methodology & runbook (`00`–`03`) and `examples/` (real runs).
183
220
  - `assets/code-scaffold-reference-ezp/` — reference React implementation (token-bound shell/forms/table
184
221
  + two screens). A *pattern* to regenerate for your DS, not a drop-in. The `ezp` name is the test DS.
@@ -0,0 +1,57 @@
1
+ /*
2
+ * DS icons extracted from the EZP design system (Branch A) — P3(a) icon/vector asset extraction.
3
+ * Source: working file pDz5W3pXk579bxcWPGkvwi, screen 2:6, rail icons exported via node.exportAsync({format:'SVG_STRING'}).
4
+ *
5
+ * Token discipline (no raw hex):
6
+ * - Monochrome icons use fill="currentColor" — the consuming slot's CSS `color` (a token) drives the colour.
7
+ * Baked fills from the export (fill="white", fill="#393F4C") were normalised to currentColor.
8
+ * - The brand logo's four colours map 1:1 to DS tokens: logo/yellow·red·green·blue → var(--ezp-logo-*).
9
+ * The remaining rail icons (ml, eco, finance, cs, …) extract by the identical pattern; this file carries the
10
+ * render-verified representative set (logo + home + material + member). This is the Branch A path only —
11
+ * from-scratch (Branch B) has no DS to export from, so icons stay manual placeholders (see SKILL.md).
12
+ */
13
+ import React from 'react';
14
+
15
+ type S = React.SVGProps<SVGSVGElement>;
16
+
17
+ export function LogoMark(props: S) {
18
+ return (
19
+ <svg viewBox="0 0 25 24" fill="none" xmlns="http://www.w3.org/2000/svg" {...props}>
20
+ <path d="M10.2498 1.31319V5.80044C8.01966 6.26697 6.26168 8.02525 5.80043 10.2498H1.3076C0.585887 10.2498 0 9.66387 0 8.94216V1.31319C0 0.586198 0.585887 0 1.3076 0H8.93656C9.66356 0 10.2498 0.585887 10.2498 1.31319Z" fill="var(--ezp-logo-yellow)" />
21
+ <path d="M23.756 5.75164C23.756 8.92599 21.184 11.4977 18.0097 11.4977C17.8089 11.4977 17.6137 11.4868 17.4182 11.4706C17.3911 11.1775 17.3423 10.89 17.2718 10.6078C17.4129 10.4179 17.5484 10.228 17.6786 10.0381C19.5886 7.33058 20.3917 5.05168 19.5507 4.21062C18.7043 3.36955 16.4198 4.17798 13.7123 6.07706C14.0325 6.18554 14.3417 6.32136 14.6348 6.47304C15.5029 6.16906 16.192 6.17466 16.5609 6.54359C16.8972 6.8799 16.9299 7.47138 16.7073 8.22013C16.6529 8.42092 16.5771 8.63258 16.4795 8.85513C15.861 7.93263 14.9873 7.20004 13.951 6.76054C13.6959 6.65207 13.4301 6.55976 13.1535 6.4892C12.8713 6.41865 12.5838 6.36456 12.2854 6.33721C12.2692 6.14731 12.2583 5.94652 12.2583 5.75133C12.2583 2.572 14.8303 0 18.01 0C21.1896 0 23.7563 2.572 23.7563 5.75164H23.756Z" fill="var(--ezp-logo-red)" />
22
+ <path d="M11.498 18.2484C11.498 21.4227 8.92071 24 5.74635 24C2.572 24 0 21.4227 0 18.2484C0 15.074 2.572 12.502 5.74604 12.502C5.94124 12.502 6.14202 12.5129 6.33193 12.5291C6.35897 12.8274 6.41336 13.1149 6.48392 13.3972C6.55447 13.6685 6.64679 13.929 6.75526 14.1838V14.1891C7.19475 15.2201 7.92735 16.0991 8.84984 16.7232C8.6329 16.8208 8.42123 16.8913 8.22044 16.951C7.4661 17.1736 6.87492 17.1409 6.53831 16.8046C6.16937 16.4357 6.16378 15.7466 6.46776 14.8785C6.31577 14.5854 6.18554 14.2817 6.07706 13.9616C4.1671 16.6691 3.36395 18.948 4.20502 19.7891C5.04609 20.6354 7.33027 19.827 10.0381 17.9226C10.2224 17.7924 10.4126 17.6566 10.6025 17.5102C10.8848 17.5807 11.1723 17.6348 11.4706 17.6622C11.4868 17.8521 11.4977 18.0476 11.4977 18.2481L11.498 18.2484Z" fill="var(--ezp-logo-green)" />
23
+ <path d="M23.7566 13.8152V21.4442C23.7566 22.1659 23.1707 22.7574 22.4434 22.7574H14.8198C14.0928 22.7574 13.5066 22.1659 13.5066 21.4442V16.9513C15.7367 16.4901 17.4946 14.7321 17.9506 12.502H22.4434C23.1704 12.502 23.7566 13.0935 23.7566 13.8152Z" fill="var(--ezp-logo-blue)" />
24
+ </svg>
25
+ );
26
+ }
27
+
28
+ export function IconHome(props: S) {
29
+ return (
30
+ <svg viewBox="0 0 18 18" fill="none" xmlns="http://www.w3.org/2000/svg" {...props}>
31
+ <path d="M7 17.3574V12.8529C7 12.538 7.34615 12.2167 7.69231 12.2167L10.3077 12.2103C10.6538 12.2103 11 12.5316 11 12.8529V17.351C11 17.5214 11.0729 17.6849 11.2028 17.8054C11.3326 17.9259 11.5087 17.9936 11.6923 17.9936H17.3077C17.4913 17.9936 17.6674 17.9259 17.7972 17.8054C17.9271 17.6849 18 17.5214 18 17.351V8.35477C18.0002 8.27033 17.9824 8.18669 17.9477 8.10862C17.913 8.03056 17.8621 7.95961 17.7978 7.89982L16 6.16098L16 1.64223C16 1.4718 15.9271 1.30836 15.7972 1.18785C15.6674 1.06734 15.4913 0.999643 15.3077 0.999643H13.6923C13.5087 0.999643 13.3326 1.06734 13.2028 1.18785C13.0729 1.30836 13 1.4718 13 1.64223L13 3.59064L9.49015 0.188784C9.42584 0.128942 9.34945 0.0814642 9.26534 0.0490695C9.18123 0.0166749 9.09106 0 9 0C8.90894 0 8.81877 0.0166749 8.73466 0.0490695C8.65055 0.0814642 8.57415 0.128942 8.50984 0.188784L0.202155 7.89982C0.137906 7.95961 0.0869827 8.03056 0.0522957 8.10862C0.0176088 8.18669 -0.000161376 8.27033 1.10422e-06 8.35477V17.351C1.10422e-06 17.5214 0.0729404 17.6849 0.202773 17.8054C0.332606 17.9259 0.508697 17.9936 0.692309 17.9936L6.30769 18C6.4913 18 6.66739 17.9323 6.79723 17.8118C6.92706 17.6913 7 17.5278 7 17.3574Z" fill="currentColor" />
32
+ </svg>
33
+ );
34
+ }
35
+
36
+ export function IconMaterial(props: S) {
37
+ return (
38
+ <svg viewBox="0 0 18 18" fill="none" xmlns="http://www.w3.org/2000/svg" {...props}>
39
+ <path d="M9 -0.000488281C7.16483 -0.000488281 5.47433 0.346313 4.22133 0.931915C3.02083 1.49352 2 2.39112 2 3.59953C2 4.80793 3.02083 5.70553 4.22133 6.26714C5.47433 6.85274 7.16483 7.19954 9 7.19954C10.8352 7.19954 12.5257 6.85274 13.7787 6.26714C14.9792 5.70553 16 4.80793 16 3.59953C16 2.39112 14.9792 1.49352 13.7787 0.931915C12.5257 0.346313 10.8352 -0.000488281 9 -0.000488281Z" fill="currentColor" />
40
+ <path d="M2 7.19947V6.19266C2.53317 6.71106 3.17133 7.09507 3.73833 7.35907C5.17567 8.03107 7.03767 8.39947 9 8.39947C10.9623 8.39947 12.8243 8.03107 14.2617 7.35907C14.8287 7.09387 15.4668 6.71106 16 6.19266V7.19947C16 8.40787 14.9792 9.30547 13.7787 9.86708C12.5257 10.4527 10.8352 10.7995 9 10.7995C7.16483 10.7995 5.47433 10.4515 4.22133 9.86708C3.02083 9.30547 2 8.40787 2 7.19947Z" fill="currentColor" />
41
+ <path d="M2 9.79268V10.7995C2 12.0079 3.02083 12.9055 4.22133 13.4671C5.47433 14.0527 7.16483 14.3995 9 14.3995C10.8352 14.3995 12.5257 14.0527 13.7787 13.4671C14.9792 12.9055 16 12.0079 16 10.7995V9.79268C15.4668 10.3111 14.8287 10.6939 14.2617 10.9591C12.8243 11.6311 10.9623 11.9995 9 11.9995C7.03767 11.9995 5.17567 11.6311 3.73833 10.9591C3.17133 10.6951 2.53317 10.3111 2 9.79268Z" fill="currentColor" />
42
+ <path d="M2 14.3995V13.3927C2.53317 13.9111 3.17133 14.2951 3.73833 14.5591C5.17567 15.2311 7.03767 15.5995 9 15.5995C10.9623 15.5995 12.8243 15.2311 14.2617 14.5591C14.8287 14.2939 15.4668 13.9111 16 13.3927V14.3995C16 15.6079 14.9792 16.5055 13.7787 17.0671C12.5257 17.6527 10.8352 17.9995 9 17.9995C7.16483 17.9995 5.47433 17.6527 4.22133 17.0671C3.02083 16.5055 2 15.6079 2 14.3995Z" fill="currentColor" />
43
+ </svg>
44
+ );
45
+ }
46
+
47
+ export function IconMember(props: S) {
48
+ return (
49
+ <svg viewBox="0 0 18 18" fill="none" xmlns="http://www.w3.org/2000/svg" {...props}>
50
+ <path d="M7.875 16C7.875 16 6.75 16 6.75 14.875C6.75 13.75 7.875 9.875 12.375 9.875C16.875 9.875 18 13.75 18 14.875C18 16 16.875 16 16.875 16H7.875ZM12.375 8.75C13.27 8.75 14.129 8.394 14.761 7.761C15.394 7.129 15.75 6.27 15.75 5.375C15.75 4.48 15.394 3.621 14.761 2.989C14.129 2.356 13.27 2 12.375 2C11.48 2 10.621 2.356 9.989 2.989C9.356 3.621 9 4.48 9 5.375C9 6.27 9.356 7.129 9.989 7.761C10.621 8.394 11.48 8.75 12.375 8.75ZM5.868 16C5.701 15.649 5.618 15.264 5.625 14.875C5.625 13.351 6.39 11.281 7.803 10.19C7.098 9.973 6.363 9.866 5.625 9.875C1.125 9.875 0 13.75 0 14.875C0 16 1.125 16 1.125 16H5.868ZM5.0625 8.75C5.808 8.75 6.524 8.454 7.051 7.926C7.579 7.399 7.875 6.683 7.875 5.9375C7.875 5.192 7.579 4.476 7.051 3.949C6.524 3.421 5.808 3.125 5.0625 3.125C4.317 3.125 3.601 3.421 3.074 3.949C2.546 4.476 2.25 5.192 2.25 5.9375C2.25 6.683 2.546 7.399 3.074 7.926C3.601 8.454 4.317 8.75 5.0625 8.75Z" fill="currentColor" />
51
+ </svg>
52
+ );
53
+ }
54
+
55
+ // Rail composition (active state via the slot, not the icon). Remaining icons extract identically.
56
+ export const RAIL_TOP = [{ key: 'home', Icon: IconHome }, { key: 'material', Icon: IconMaterial }];
57
+ export const RAIL_BOTTOM = [{ key: 'member', Icon: IconMember }];
@@ -4,6 +4,7 @@
4
4
  * AI Orchestration nav + breadcrumb. Sidebar gets a token-bound right border.
5
5
  */
6
6
  import React from 'react';
7
+ import { LogoMark, RAIL_TOP, RAIL_BOTTOM } from './icons';
7
8
 
8
9
  export type NavItem = { label: string; active?: boolean };
9
10
  export type NavGroup = { label: string; items?: NavItem[] };
@@ -11,17 +12,18 @@ export type NavGroup = { label: string; items?: NavItem[] };
11
12
  const DEFAULT_GROUPS: NavGroup[] = [{ label: 'Content' }, { label: 'Content' }, { label: 'Content' }];
12
13
 
13
14
  export function Sidebar({ section = 'Material', navGroups = DEFAULT_GROUPS }: { section?: string; navGroups?: NavGroup[] }) {
14
- const railIcons = [0, 1, 2, 3, 4];
15
15
  return (
16
16
  <aside className="ezp-sidebar">
17
17
  <div className="ezp-rail">
18
- <div className="ezp-rail-logo" aria-label="logo" />
19
- {railIcons.map((i) => (
20
- <div key={i} className={'ezp-rail-icon' + (i === 0 ? ' ezp-rail-icon--on' : '')} />
18
+ {/* real DS assets (P3(a)) — inline SVG, colour from the slot token via currentColor / brand-token vars */}
19
+ <span className="ezp-rail-logo" aria-label="logo"><LogoMark /></span>
20
+ {RAIL_TOP.map(({ key, Icon }, i) => (
21
+ <span key={key} className={'ezp-rail-icon' + (i === 0 ? ' ezp-rail-icon--on' : '')} aria-label={key}><Icon /></span>
21
22
  ))}
22
23
  <div className="ezp-rail-spacer" />
23
- <div className="ezp-rail-icon" />
24
- <div className="ezp-rail-icon" />
24
+ {RAIL_BOTTOM.map(({ key, Icon }) => (
25
+ <span key={key} className="ezp-rail-icon" aria-label={key}><Icon /></span>
26
+ ))}
25
27
  </div>
26
28
  <nav className="ezp-nav">
27
29
  <div className="ezp-user">
@@ -24,9 +24,12 @@
24
24
  .ezp-nav-sub--active { color: var(--ezp-logo-blue); }
25
25
  .ezp-nav-sub--active .ezp-nav-sub-dot { background: var(--ezp-logo-blue); }
26
26
  .ezp-rail { width: var(--ezp-size-sidebar-collapsed); background: var(--ezp-light-1100); display: flex; flex-direction: column; align-items: center; padding: var(--ezp-space-md) 0; gap: var(--ezp-space-sm); }
27
- .ezp-rail-logo { width: 24px; height: 24px; border-radius: var(--ezp-radius-sm); background: var(--ezp-logo-green); margin-bottom: var(--ezp-space-sm); }
28
- .ezp-rail-icon { width: 20px; height: 20px; border-radius: var(--ezp-radius-sm); background: var(--ezp-light-700); opacity: .55; }
29
- .ezp-rail-icon--on { opacity: 1; background: var(--ezp-white); }
27
+ /* real DS icons (P3(a)): inline SVG sized by the slot; monochrome colour comes from `color` (a token) via
28
+ currentColor, the brand logo from logo/* token vars baked into its SVG. No background boxes. */
29
+ .ezp-rail-logo { width: 24px; height: 24px; margin-bottom: var(--ezp-space-sm); }
30
+ .ezp-rail-icon { width: 20px; height: 20px; color: var(--ezp-white); opacity: .55; }
31
+ .ezp-rail-icon--on { opacity: 1; }
32
+ .ezp-rail-logo svg, .ezp-rail-icon svg { display: block; width: 100%; height: 100%; }
30
33
  .ezp-rail-spacer { flex: 1; }
31
34
  .ezp-nav { flex: 1; min-width: 0; display: flex; flex-direction: column; padding: var(--ezp-space-md); gap: var(--ezp-space-md); background: var(--ezp-white); }
32
35
  .ezp-user { display: flex; align-items: center; gap: var(--ezp-space-sm); }
@@ -67,7 +70,7 @@
67
70
  .ezp-table-wrap { border: 1px solid var(--ezp-light-200); border-radius: var(--ezp-radius-md); overflow: hidden; }
68
71
  .ezp-table { width: 100%; border-collapse: separate; border-spacing: 0; }
69
72
  .ezp-th { background: var(--ezp-light-50); color: var(--ezp-light-600); text-align: left; padding: var(--ezp-space-sm) var(--ezp-space-md); border-bottom: 1px solid var(--ezp-light-200); white-space: nowrap; }
70
- .ezp-td { padding: var(--ezp-space-sm) var(--ezp-space-md); border-bottom: 1px solid var(--ezp-light-200); color: var(--ezp-light-1100); vertical-align: middle; background: var(--ezp-white); }
73
+ .ezp-td { height: var(--ezp-size-table-row-height); box-sizing: border-box; padding: 0 var(--ezp-space-md); border-bottom: 1px solid var(--ezp-light-200); color: var(--ezp-light-1100); vertical-align: middle; background: var(--ezp-white); } /* row height bound to size/table-row-height (30px), not padding+border arithmetic; border-box so the 1px border doesn't drift the row ~1px/row (P4) */
71
74
  .ezp-tr:last-child .ezp-td { border-bottom: none; }
72
75
  .ezp-cell-name { color: var(--ezp-logo-blue); cursor: pointer; } /* 상세 진입 affordance (link) */
73
76
  .ezp-cell-action { text-align: right; }
@@ -1,7 +1,9 @@
1
1
  /*
2
2
  * Check-layout — objective layout-breakage audit (generic, run via Figma MCP use_figma on a mockup frame).
3
3
  * use_figma({ fileKey: <screen.mockup.fileKey>, skillNames: "figma-use", code: <this body> })
4
- * CFG (top) = { screenFrameId, spacingMax, overlayRe } — from the descriptor (shell.spacingMax + screen frame).
4
+ * CFG (top) — filled from the project descriptor (validators/projects/<project>.json), like check2:
5
+ * screenFrameId ← screens.<screen>.mockup.frameId · spacingMax ← shell · overlayRe ← shell.
6
+ * Replace the '0:0' placeholder with the screen's real frame id per run (don't hand-tune otherwise).
5
7
  * READ-ONLY. Returns { hardFails:[], advisories:[] }.
6
8
  *
7
9
  * This catches the FLOOR of visual quality — objective breakage only. It does NOT judge aesthetics
@@ -9,12 +11,13 @@
9
11
  * entering the visual gate, never a substitute for it.
10
12
  *
11
13
  * HARD FAIL (must be 0): textClip · outOfFrame · overlap · missingAutoLayout · junkFrame · textTruncateSetting
12
- * ADVISORY (review): largeGap · overlayAnchorUnclear
14
+ * ADVISORY (review): largeGap · overlayAnchorUnclear · nestedSameFill
13
15
  */
16
+ // Fill from the descriptor (validators/projects/<project>.json) — these are not constants to hand-tune:
14
17
  const CFG = {
15
- screenFrameId: '0:0',
16
- spacingMax: 64, // largest spacing token (px); largeGap advisory = gap > spacingMax*3
17
- overlayRe: '(^|[ _-])(action-menu|context-menu|row-action-menu|dropdown|popover|tooltip|overlay|modal|toast)',
18
+ screenFrameId: '0:0', // ← screens.<screen>.mockup.frameId (replace this placeholder per screen)
19
+ spacingMax: 64, // ← shell.spacingMax: largest spacing token (px); largeGap advisory = gap > spacingMax*3
20
+ overlayRe: '(^|[ _-])(action-menu|context-menu|row-action-menu|dropdown|popover|tooltip|overlay|modal|toast)', // ← shell overlay name pattern
18
21
  };
19
22
  figma.skipInvisibleInstanceChildren = true; // skip hidden interior layers — DS components park hidden internals off-frame (false outOfFrame); visible TEXT inside instances is still traversed (label clipping lives there too)
20
23
  const TOL = 2;
@@ -57,8 +60,12 @@ for (const n of authored) {
57
60
  const defName = /^Frame(\s*\d+)?$/i.test(n.name || '');
58
61
  if (defName || def100 || (kids.length === 0 && fillEmpty && !isFill)) hardFails.push({ type: 'junkFrame', node: n.name, id: n.id, w: Math.round(n.width), h: Math.round(n.height), children: kids.length });
59
62
  }
60
- // overlap among authored siblings (intended overlays / absolute excluded)
61
- for (const n of authored) {
63
+ // overlap among siblings — checked inside the screen frame itself (P2-1: its direct children are excluded from
64
+ // `all`/authored, so top-level region overlaps were a false-negative) and inside authored FRAMEs. INSTANCEs are
65
+ // treated as leaves (P1-2: their interiors are the DS's responsibility, audited by check1 — not a screen
66
+ // overlap). Intended overlays / absolute-positioned excluded.
67
+ const overlapParents = [screen, ...authored.filter((n) => n.type === 'FRAME')];
68
+ for (const n of overlapParents) {
62
69
  const kids = (n.children || []).filter((c) => !isOverlay(c));
63
70
  for (let i = 0; i < kids.length; i++) for (let j = i + 1; j < kids.length; j++) { const a = bb(kids[i]), b = bb(kids[j]); if (a && b && inter(a, b) > 4) hardFails.push({ type: 'overlap', a: kids[i].name, b: kids[j].name, parent: n.name }); }
64
71
  }
@@ -78,4 +85,40 @@ for (const n of all) {
78
85
  if (!near && ov.test(n.name || '')) advisories.push({ type: 'overlayAnchorUnclear', node: n.name, id: n.id });
79
86
  }
80
87
 
88
+ // nestedSameFill (P7) — ADVISORY (not a hardFail): an authored node re-painting the SAME opaque surface fill
89
+ // as its nearest ancestor surface (white-on-white). It's a redundant-surface signal for review, not a gate:
90
+ // some same-fill repaints (inset full-area body bgs, surface-in-surface) are discipline-true but visually
91
+ // harmless, and no geometric rule cleanly separates those from real defects — so it informs, never blocks.
92
+ // The full geometric carve-out below only TRIMS obvious noise (it is not, and need not be, complete):
93
+ // only same-colour repaint is considered; a *different* opaque fill (white block over an #EEF2FF card) is left
94
+ // to the discipline. EXEMPT from the advisory: real raised cards (border/shadow), and full-bleed background
95
+ // layers spanning at least one FULL axis of the surface beneath them (a body bg inset only by a sidebar/topbar
96
+ // still spans the other axis). Authored-only (instance interiors are check1's job); TEXT/overlays/hidden excluded.
97
+ const solidFillKey = (n) => {
98
+ if (!Array.isArray(n.fills)) return null;
99
+ if (n.opacity != null && n.opacity < 0.999) return null;
100
+ const f = n.fills.find((p) => p && p.visible !== false && p.type === 'SOLID' && (p.opacity == null || p.opacity >= 0.999) && p.color);
101
+ if (!f) return null; const c = f.color;
102
+ return Math.round(c.r * 255) + ',' + Math.round(c.g * 255) + ',' + Math.round(c.b * 255);
103
+ };
104
+ // a real raised surface is distinguished by a border or a shadow; if so it may legitimately share the page's
105
+ // fill, so it is NOT a redundant repaint. Only edgeless same-fill nodes (layout wrappers) are flagged.
106
+ const hasEdge = (n) => (Array.isArray(n.strokes) && n.strokes.some((s) => s && s.visible !== false)) ||
107
+ (Array.isArray(n.effects) && n.effects.some((e) => e && e.visible !== false && /SHADOW/.test(e.type || '')));
108
+ // a full-bleed background layer fills the same-coloured surface beneath it on at least one FULL axis
109
+ // (edge-to-edge within TOL) — it IS that surface's background (e.g. a body bg inset only by a sidebar/topbar
110
+ // still spans the other axis), not a stacked sub-region. A gap-making sub-region spans NEITHER axis → flag.
111
+ const spansFullAxis = (c, a) => !!c && !!a && (
112
+ (Math.abs(c.x - a.x) <= TOL && Math.abs((c.x + c.width) - (a.x + a.width)) <= TOL) ||
113
+ (Math.abs(c.y - a.y) <= TOL && Math.abs((c.y + c.height) - (a.y + a.height)) <= TOL));
114
+ for (const n of all) {
115
+ if (n.type === 'TEXT' || isOverlay(n) || hidden(n) || inInstance(n)) continue;
116
+ const key = solidFillKey(n); if (!key || hasEdge(n)) continue;
117
+ let p = n.parent, anc = null;
118
+ while (p) { const k = solidFillKey(p); if (k) { anc = { node: p, key: k }; break; } if (p.id === CFG.screenFrameId) break; p = p.parent; }
119
+ if (!anc || anc.key !== key) continue;
120
+ if (spansFullAxis(bb(n), bb(anc.node))) continue; // full-bleed background over the same surface — exempt
121
+ advisories.push({ type: 'nestedSameFill', node: n.name, id: n.id, fill: key, parentSurface: anc.node.name });
122
+ }
123
+
81
124
  return { screen: CFG.screenFrameId, hardFails, advisories, hardFailCount: hardFails.length, advisoryCount: advisories.length };
@@ -0,0 +1,76 @@
1
+ /*
2
+ * Check-recall — from-scratch (Branch B) recall-leak audit (generic, config-driven). Node.
3
+ * node validators/check-recall.js <project> <currentScreen> <priorScreen> (cwd = project root)
4
+ *
5
+ * Why: in from-scratch mode a screen must be derived from the SPEC alone. If the executor leaves a prior,
6
+ * in-context screen (e.g. a Branch-A screen) in view, the new one can *recall* it — color/font may change but
7
+ * the structure and the **non-spec incidental content** (placeholder ids, dates, filter labels, footer text)
8
+ * come back byte-for-byte. Those values are not derivable from the spec, so a high non-spec overlap with a
9
+ * prior screen is the fingerprint of recall. check2's fabrication pass can't see this (it only checks that
10
+ * spec anchors are present and no enumerable menu is invented); this compares two screens to each other.
11
+ *
12
+ * Source of each screen's text, in priority order:
13
+ * 1. validators/out/check2-<screen>.json `textFingerprint` (mockup-stage texts, emitted by check2.js), else
14
+ * 2. string/JSX-text literals extracted from screen.code.files (code-stage).
15
+ * Spec set = that screen's own anchors (designAnchors groups + code.anchors + code.orderedArray.items).
16
+ * non-spec = content text minus spec. nonSpecOverlap = |cur∩prior| / |cur|. FAIL if > threshold
17
+ * (descriptor `recall.maxNonSpecOverlap`, default 0.5). READ-ONLY; prints JSON, exit 0.
18
+ */
19
+ const fs = require('fs');
20
+ const path = require('path');
21
+ const ROOT = process.cwd();
22
+ const [project, curKey, priorKey] = process.argv.slice(2);
23
+ if (!project || !curKey || !priorKey) { console.error('usage: node validators/check-recall.js <project> <currentScreen> <priorScreen>'); process.exit(1); }
24
+ const cfg = JSON.parse(fs.readFileSync(path.join(ROOT, 'validators/projects', project + '.json'), 'utf8'));
25
+ const readOpt = (p) => { try { return fs.readFileSync(p, 'utf8'); } catch (e) { return null; } };
26
+ const norm = (s) => String(s).replace(/\s+/g, ' ').trim();
27
+ const meaningful = (s) => s.length >= 2 && /[\p{L}\p{N}]/u.test(s); // has a letter or digit, not pure punctuation
28
+
29
+ function specAnchors(screen) {
30
+ const out = [];
31
+ if (screen.designAnchors) for (const list of Object.values(screen.designAnchors)) if (Array.isArray(list)) out.push(...list);
32
+ if (screen.code && Array.isArray(screen.code.anchors)) out.push(...screen.code.anchors);
33
+ if (screen.code && screen.code.orderedArray && Array.isArray(screen.code.orderedArray.items)) out.push(...screen.code.orderedArray.items);
34
+ return new Set(out.map(norm).filter(meaningful));
35
+ }
36
+
37
+ function contentText(key, screen) {
38
+ // 1) mockup-stage fingerprint staged by check2
39
+ const c2 = readOpt(path.join(ROOT, 'validators/out', 'check2-' + key + '.json'));
40
+ if (c2) { try { const j = JSON.parse(c2); if (Array.isArray(j.textFingerprint)) return { source: 'check2.textFingerprint', items: j.textFingerprint.map(norm).filter(meaningful) }; } catch (e) {} }
41
+ // 2) code-stage: string + simple JSX-text literals
42
+ const items = [];
43
+ const codeDir = path.dirname(path.join(ROOT, cfg.codeTokensCss));
44
+ for (const rel of (screen.code && screen.code.files) || []) {
45
+ const src = readOpt(path.join(codeDir, rel)); if (!src) continue;
46
+ for (const m of src.matchAll(/'([^'\n]{2,})'|"([^"\n]{2,})"|`([^`\n]{2,})`/g)) items.push(m[1] || m[2] || m[3]);
47
+ for (const m of src.matchAll(/>\s*([^<>{}\n]{2,}?)\s*</g)) items.push(m[1]); // JSX text nodes
48
+ }
49
+ return { source: 'code.literals', items: items.map(norm).filter(meaningful) };
50
+ }
51
+
52
+ function nonSpec(key) {
53
+ const screen = cfg.screens[key];
54
+ if (!screen) { console.error('unknown screen: ' + key); process.exit(1); }
55
+ const spec = specAnchors(screen);
56
+ const isSpec = (s) => spec.has(s) || [...spec].some((a) => a.length >= 3 && (s.includes(a) || a.includes(s)));
57
+ const ct = contentText(key, screen);
58
+ const set = new Set(ct.items.filter((s) => !isSpec(s)));
59
+ return { source: ct.source, total: ct.items.length, nonSpec: set };
60
+ }
61
+
62
+ const cur = nonSpec(curKey);
63
+ const prior = nonSpec(priorKey);
64
+ const shared = [...cur.nonSpec].filter((s) => prior.nonSpec.has(s));
65
+ const denom = cur.nonSpec.size || 1;
66
+ const nonSpecOverlap = +(shared.length / denom).toFixed(3);
67
+ const threshold = (cfg.recall && typeof cfg.recall.maxNonSpecOverlap === 'number') ? cfg.recall.maxNonSpecOverlap : 0.5;
68
+ const pass = nonSpecOverlap <= threshold;
69
+
70
+ console.log(JSON.stringify({
71
+ project, current: curKey, prior: priorKey,
72
+ source: { current: cur.source, prior: prior.source },
73
+ curNonSpecCount: cur.nonSpec.size, priorNonSpecCount: prior.nonSpec.size,
74
+ sharedNonSpecCount: shared.length, sharedNonSpec: shared.slice(0, 40),
75
+ nonSpecOverlap, threshold, pass,
76
+ }, null, 2));
@@ -45,4 +45,6 @@ return {
45
45
  binding: { bound, authoredRaw, dsInternalRaw: internalRaw, ratioPct: +((bound / (bound + authoredRaw + internalRaw)) * 100).toFixed(1), authoredOffenders },
46
46
  viewport: { w: Math.round(screen.width), h: Math.round(screen.height), ok: Math.round(screen.width) === CFG.viewport.w && Math.round(screen.height) === CFG.viewport.h },
47
47
  shell,
48
+ // all mockup TEXT strings (deduped) — consumed by check-recall.js to detect from-scratch recall leaks across screens
49
+ textFingerprint: [...new Set(all.filter((n) => n.type === 'TEXT' && typeof n.characters === 'string').map((n) => n.characters.trim()).filter((s) => s.length >= 2))],
48
50
  };
@@ -56,9 +56,64 @@ if (screen.code.anchors) {
56
56
  content.anchors = { total: screen.code.anchors.length, present: screen.code.anchors.length - missing.length, missing, verbatim: missing.length === 0 };
57
57
  }
58
58
 
59
+ // ---- size-token dimension fidelity (P4) — opt-in via descriptor `sizeBindings` ----
60
+ // Each binding { selector, dim?, token } requires the element's dimension to be BOUND to the size token's var
61
+ // (not a literal) AND box-sizing:border-box (rule-level or via a global `*` reset), so border/padding cannot
62
+ // inflate the rendered dimension past the token value. Catches the "row height = padding+border ≈ token+1px"
63
+ // drift the hardcode scan misses (padding is a spacing token, the 1px border is in structuralPxAllow).
64
+ const sizeBindings = [...(cfg.sizeBindings || []), ...((screen.code && screen.code.sizeBindings) || [])];
65
+ let sizeFidelity = { applicable: false };
66
+ if (sizeBindings.length) {
67
+ const cssFiles = [...new Set([path.basename(cfg.codeTokensCss), ...(cfg.codeCssFiles || []), ...((screen.code.files) || []).filter((f) => f.endsWith('.css'))])];
68
+ const cssAll = cssFiles.map((f) => { try { return read(path.join(codeDir, f)); } catch (e) { return ''; } }).join('\n');
69
+ const rules = [...cssAll.matchAll(/([^{}]+)\{([^{}]*)\}/g)].map((m) => ({ sels: m[1].split(',').map((s) => s.trim()), body: m[2] }));
70
+ const findRule = (sel) => rules.find((r) => r.sels.includes(sel));
71
+ const globalBorderBox = rules.some((r) => r.sels.some((s) => s.includes('*')) && /box-sizing\s*:\s*border-box/.test(r.body));
72
+ const violations = [];
73
+ for (const bnd of sizeBindings) {
74
+ const dim = bnd.dim || 'height';
75
+ const expectVar = toVar(bnd.token);
76
+ const tokenVal = ds.float[bnd.token];
77
+ const rule = findRule(bnd.selector);
78
+ if (!rule) { violations.push({ selector: bnd.selector, dim, token: bnd.token, issue: 'selectorNotFound' }); continue; }
79
+ const decl = (rule.body.match(new RegExp('(?:^|[;{\\s])' + dim + '\\s*:\\s*([^;]+)')) || [])[1];
80
+ const val = decl ? decl.trim() : '';
81
+ const boundToToken = val.indexOf('var(' + expectVar + ')') !== -1;
82
+ const borderBox = globalBorderBox || /box-sizing\s*:\s*border-box/.test(rule.body);
83
+ if (!val) violations.push({ selector: bnd.selector, dim, token: bnd.token, issue: 'dimMissing', note: 'no ' + dim + ' set; height comes from padding+border (drift)' });
84
+ else if (!boundToToken) violations.push({ selector: bnd.selector, dim, token: bnd.token, issue: /\d+(?:\.\d+)?px/.test(val) ? 'literalNotToken' : 'notTokenBound', got: val, expected: 'var(' + expectVar + ')' + (tokenVal != null ? ' (' + tokenVal + 'px)' : '') });
85
+ else if (!borderBox) violations.push({ selector: bnd.selector, dim, token: bnd.token, issue: 'noBorderBox', note: 'border/padding can inflate ' + dim + ' past the token; add box-sizing:border-box' });
86
+ }
87
+ sizeFidelity = { applicable: true, total: sizeBindings.length, ok: sizeBindings.length - violations.length, violations };
88
+ }
89
+
90
+ // ---- icon/vector asset fidelity (P3a) — opt-in via descriptor `iconAssets` (Branch A only) ----
91
+ // Each declared icon slot selector must carry a real <svg> (not an empty placeholder box), and the inline SVG
92
+ // source files must contain no raw hex (currentColor / token var() only). Branch B has no DS to export from,
93
+ // so it declares no iconAssets and the pass stays inapplicable.
94
+ const ia = cfg.iconAssets;
95
+ let iconAssets = { applicable: false };
96
+ if (ia && Array.isArray(ia.selectors) && ia.selectors.length) {
97
+ const esc = (s) => s.replace(/[-/\\^$*+?.()|[\]{}]/g, '\\$&');
98
+ const codeBlob = (screen.code.files || []).map((f) => { try { return read(path.join(codeDir, f)); } catch (e) { return ''; } }).join('\n');
99
+ const placeholderSlots = [];
100
+ for (const sel of ia.selectors) {
101
+ const cls = sel.replace(/^\./, '');
102
+ // an empty self-closing element carrying the class = still a placeholder box (not replaced by an asset)
103
+ if (new RegExp('<(?:div|span)\\b[^>]*\\b' + esc(cls) + '\\b[^>]*/>', 'i').test(codeBlob)) placeholderSlots.push(sel);
104
+ }
105
+ const svgFiles = [...new Set([...(ia.files || []), ...((screen.code.files) || [])])];
106
+ const svgBlob = svgFiles.map((f) => { try { return read(path.join(codeDir, f)); } catch (e) { return ''; } }).join('\n');
107
+ const rawHexInSvg = [];
108
+ for (const m of svgBlob.matchAll(/<svg[\s\S]*?<\/svg>/gi)) for (const h of (m[0].match(/#[0-9a-fA-F]{3,8}\b/g) || [])) rawHexInSvg.push(h);
109
+ iconAssets = { applicable: true, selectors: ia.selectors.length, placeholderSlots, rawHexInSvg: [...new Set(rawHexInSvg)] };
110
+ }
111
+
59
112
  console.log(JSON.stringify({
60
113
  project, screen: screenKey,
61
114
  tokenCompare: { match: tok.match, total: tok.total, pct: +((tok.match / tok.total) * 100).toFixed(1), mismatch: tok.mismatch, missing: tok.missing },
62
115
  hardcode: { hexCount: hexHits.length, hexLiterals: hexHits, pxViolationCount: pxViolations.length, pxViolations, declaredColorLiterals: colorLiterals },
63
116
  content,
117
+ sizeFidelity,
118
+ iconAssets,
64
119
  }, null, 2));
@@ -31,11 +31,22 @@
31
31
  "2px": "focus ring width/offset",
32
32
  "<NNpx>": "<reason, e.g. control glyph / min-height / viewport>"
33
33
  },
34
+ "codeCssFiles": ["<component-css-file(s), e.g. app.css>"],
35
+ "_codeCssFiles_note": "OPTIONAL. CSS files (besides codeTokensCss) that hold the component rules check3's sizeBindings look up. Resolved next to codeTokensCss.",
36
+ "sizeBindings": [
37
+ { "selector": "<.css-selector>", "dim": "height", "token": "size/<token>" }
38
+ ],
39
+ "_sizeBindings_note": "OPTIONAL (P4). Each bound element's dim must be height: var(--<ds>-size-<token>) + box-sizing:border-box, else check3 flags drift. Omit to skip the check.",
40
+ "recall": { "maxNonSpecOverlap": 0.5 },
41
+ "_recall_note": "OPTIONAL (P5). Threshold for check-recall.js: fail when a from-scratch screen's non-spec content overlap with a prior screen exceeds this.",
42
+ "iconAssets": { "selectors": ["<.icon-slot-class>"], "files": ["<file(s) holding the inline SVG, e.g. components/icons.tsx>"] },
43
+ "_iconAssets_note": "OPTIONAL (P3a, Branch A only). check3 requires each icon slot to carry a real <svg> (not an empty placeholder box) with zero raw hex (currentColor / token var only). Omit for from-scratch (Branch B): icons stay manual placeholders.",
34
44
  "selfVerify": { "tokensTotal": "<total token count expected>", "dsRaw": 0 },
35
45
  "screens": {
36
46
  "<screenKey>": {
37
47
  "label": "<human label>",
38
48
  "mockup": { "fileKey": "<working figma file key>", "frameId": "<frame node id>" },
49
+ "_mockup_note": "mockup.frameId is the screen frame. Paste it into the use_figma CFG.screenFrameId for check2.js and check-layout.js (replacing their '0:0' placeholder); fileKey is the use_figma fileKey.",
39
50
  "designAnchors": {
40
51
  "_note": "Verbatim spec content that MUST appear in the mockup. Grouped freely.",
41
52
  "breadcrumb": ["..."], "title": ["..."]
@@ -13,6 +13,14 @@
13
13
  "weightMap": { "Bold": 700, "SemiBold": 600, "Medium": 500, "Regular": 400 }
14
14
  },
15
15
  "shell": { "viewport": { "w": 1920, "h": 1080 }, "componentNames": ["side-nav", "gnb"] },
16
+ "codeCssFiles": ["ezp.css"],
17
+ "sizeBindings": [
18
+ { "selector": ".ezp-td", "dim": "height", "token": "size/table-row-height" },
19
+ { "selector": ".ezp-input", "dim": "height", "token": "size/input-height" },
20
+ { "selector": ".ezp-btn-primary", "dim": "height", "token": "size/button-height" }
21
+ ],
22
+ "recall": { "maxNonSpecOverlap": 0.5 },
23
+ "iconAssets": { "selectors": [".ezp-rail-logo", ".ezp-rail-icon"], "files": ["components/icons.tsx"] },
16
24
  "check1": {
17
25
  "interactiveDetect": "btn|button|form-control|form-select|form-check|form-switch|input|tab|menu|nav|toggle|switch|link|chip|radio|checkbox",
18
26
  "requiredStatesForPass": ["focus", "disabled"],
@@ -14,6 +14,17 @@
14
14
  * FIXTURE B — guards against over-correction: real visible breakage is still caught (an authored clipped
15
15
  * title + a clipped VISIBLE label inside an instance), while a VISIBLE non-text interior layer that
16
16
  * extends past its parent is correctly ignored (DS internals are check1's job).
17
+ * FIXTURE C — nestedSameFill (P7) is an ADVISORY, never a hardFail: an edgeless layout wrapper repainting the
18
+ * page's own fill (white-on-white) is advised; a real raised card (same fill but with a border or a shadow)
19
+ * is exempt; a wrapper carrying a DIFFERENT fill from its parent (white block over an #EEF2FF card) is NOT a
20
+ * same-fill case (discipline, not this check). hardFails stay 0.
21
+ * FIXTURE D — nestedSameFill full-bleed precision (the approved-screen false positives): a full-bleed body
22
+ * background layer that spans a full axis of the surface beneath it is EXEMPT, while a same-fill SUB-REGION
23
+ * (a white table inside a white board) stays advised. hardFails stay 0.
24
+ * FIXTURE E — P2-1: the screen frame's OWN direct children are overlap-checked (real overlap → flag; mere
25
+ * adjacency → pass).
26
+ * FIXTURE F — P1-2: overlapping children INSIDE an instance are NOT flagged (instance = leaf); the same
27
+ * overlap inside an authored FRAME IS flagged.
17
28
  */
18
29
  'use strict';
19
30
  const fs = require('fs');
@@ -37,6 +48,9 @@ function buildFigma(rootSpec) {
37
48
  layoutSizingHorizontal: spec.layoutSizingHorizontal || 'FIXED',
38
49
  layoutSizingVertical: spec.layoutSizingVertical || 'FIXED',
39
50
  fills: spec.fills !== undefined ? spec.fills : [{ type: 'SOLID' }],
51
+ strokes: spec.strokes || [],
52
+ effects: spec.effects || [],
53
+ opacity: spec.opacity,
40
54
  width: spec.bbox ? spec.bbox.width : 0,
41
55
  height: spec.bbox ? spec.bbox.height : 0,
42
56
  textTruncation: spec.textTruncation || 'DISABLED',
@@ -94,13 +108,14 @@ const fixtureA = {
94
108
  { id: 'A:dash', name: 'Dashboard', type: 'TEXT', bbox: { x: 16, y: 16, width: 120, height: 20 }, characters: 'Dashboard' },
95
109
  ] },
96
110
  ] },
97
- { id: 'A:pag', name: 'pagination-wrap', type: 'INSTANCE', bbox: { x: 0, y: 860, width: 1440, height: 40 },
111
+ // content sits beside the nav (top-level siblings just touch at x=240 — no overlap). Pagination lives
112
+ // INSIDE content (not a screen-level sibling), with its hidden overflow row parked off-frame.
113
+ { id: 'A:content', name: 'content', type: 'FRAME', layoutMode: 'VERTICAL', bbox: { x: 240, y: 0, width: 1200, height: 900 },
98
114
  children: [
99
- // hidden overflow row parked far to the right
100
- { id: 'A:overflow', name: 'overflow-pages', type: 'FRAME', visible: false, layoutMode: 'HORIZONTAL', bbox: { x: 2200, y: 860, width: 300, height: 40 }, children: [] },
115
+ { id: 'A:title', name: 'Model Management', type: 'TEXT', bbox: { x: 272, y: 24, width: 300, height: 28 }, characters: 'Model Management' },
116
+ { id: 'A:pag', name: 'pagination-wrap', type: 'INSTANCE', bbox: { x: 264, y: 852, width: 1152, height: 32 },
117
+ children: [ { id: 'A:overflow', name: 'overflow-pages', type: 'FRAME', visible: false, layoutMode: 'HORIZONTAL', bbox: { x: 2200, y: 860, width: 300, height: 40 }, children: [] } ] },
101
118
  ] },
102
- { id: 'A:content', name: 'content', type: 'FRAME', layoutMode: 'VERTICAL', bbox: { x: 240, y: 0, width: 1200, height: 900 },
103
- children: [ { id: 'A:title', name: 'Model Management', type: 'TEXT', bbox: { x: 272, y: 24, width: 300, height: 28 }, characters: 'Model Management' } ] },
104
119
  ],
105
120
  };
106
121
 
@@ -124,6 +139,86 @@ const fixtureB = {
124
139
  ],
125
140
  };
126
141
 
142
+ const WHITE = { type: 'SOLID', color: { r: 1, g: 1, b: 1 } };
143
+ const EEF2FF = { type: 'SOLID', color: { r: 238 / 255, g: 242 / 255, b: 1 } };
144
+ const STROKE = [{ type: 'SOLID', visible: true }];
145
+ const SHADOW = [{ type: 'DROP_SHADOW', visible: true }];
146
+ const fixtureC = {
147
+ id: '0:0', name: 'C-screen', type: 'FRAME', layoutMode: 'VERTICAL', bbox: { x: 0, y: 0, width: 1000, height: 800 }, fills: [WHITE],
148
+ children: [
149
+ // edgeless white SUB-REGION wrapper on the white page (spans neither axis fully) → redundant repaint → flag
150
+ { id: 'C:wrap', name: 'section-wrap', type: 'FRAME', layoutMode: 'VERTICAL', bbox: { x: 40, y: 40, width: 920, height: 140 }, fills: [WHITE],
151
+ children: [ { id: 'C:wtext', name: 'Section', type: 'TEXT', bbox: { x: 64, y: 64, width: 120, height: 20 }, characters: 'Section' } ] },
152
+ // white card WITH a border → a real raised surface → exempt
153
+ { id: 'C:card', name: 'real-card', type: 'FRAME', bbox: { x: 20, y: 260, width: 300, height: 160 }, fills: [WHITE], strokes: STROKE, children: [] },
154
+ // selected card (#EEF2FF) with a white block inside → DIFFERENT fill → not a same-fill case (discipline)
155
+ { id: 'C:sel', name: 'selected-card', type: 'FRAME', bbox: { x: 20, y: 440, width: 300, height: 200 }, fills: [EEF2FF], strokes: STROKE,
156
+ children: [ { id: 'C:inner', name: 'inner-white-block', type: 'FRAME', bbox: { x: 30, y: 450, width: 280, height: 80 }, fills: [WHITE], children: [] } ] },
157
+ // white card WITH a shadow → a real raised surface → exempt
158
+ { id: 'C:shadow', name: 'shadow-card', type: 'FRAME', bbox: { x: 20, y: 660, width: 300, height: 100 }, fills: [WHITE], effects: SHADOW, children: [] },
159
+ ],
160
+ };
161
+
162
+ // FIXTURE D — full-bleed body-background layers (the false positives found on the approved screens: Branch B
163
+ // main-col/content #F1F5F9) must be EXEMPT even when inset by a sidebar/topbar (they still span one FULL axis
164
+ // of the surface beneath); a same-fill SUB-REGION (version-table inside a board, spanning neither axis) stays
165
+ // flagged. Mirrors the real 10:2 structure: page-bg → main-col (full height, inset left by sidebar) → content
166
+ // (full width, inset top by topbar) → bordered board (card) → white version-table (sub-region).
167
+ const SLATE = { type: 'SOLID', color: { r: 241 / 255, g: 245 / 255, b: 249 / 255 } }; // #F1F5F9
168
+ const fixtureD = {
169
+ id: '0:0', name: 'D-screen', type: 'FRAME', layoutMode: 'VERTICAL', bbox: { x: 0, y: 0, width: 1200, height: 800 }, fills: [SLATE],
170
+ children: [
171
+ { id: 'D:main', name: 'main-col', type: 'FRAME', bbox: { x: 220, y: 0, width: 980, height: 800 }, fills: [SLATE], // inset left by sidebar → spans full HEIGHT of page → exempt
172
+ children: [
173
+ { id: 'D:content', name: 'content', type: 'FRAME', bbox: { x: 220, y: 48, width: 980, height: 752 }, fills: [SLATE], // inset top by topbar → spans full WIDTH of main-col → exempt
174
+ children: [
175
+ { id: 'D:board', name: 'detail-board', type: 'FRAME', bbox: { x: 260, y: 100, width: 900, height: 560 }, fills: [WHITE], strokes: STROKE, // real card (border + different colour) → exempt
176
+ children: [
177
+ // white table, a SUB-REGION of the white board (spans neither axis) → flagged (white-on-white)
178
+ { id: 'D:vtable', name: 'version-table', type: 'FRAME', bbox: { x: 300, y: 160, width: 820, height: 200 }, fills: [WHITE], children: [] },
179
+ ] },
180
+ ] },
181
+ ] },
182
+ ],
183
+ };
184
+
185
+ // FIXTURE E (P2-1) — the screen frame's OWN direct children are now overlap-checked (previously excluded from
186
+ // `all`/authored → false-negative). E_overlap: two top-level regions that really overlap → flagged.
187
+ // E_ok: two adjacent top-level regions that only touch → pass.
188
+ const fixtureE_overlap = {
189
+ id: '0:0', name: 'E-overlap', type: 'FRAME', layoutMode: 'NONE', bbox: { x: 0, y: 0, width: 1000, height: 600 },
190
+ children: [
191
+ { id: 'E:a', name: 'region-a', type: 'FRAME', bbox: { x: 0, y: 0, width: 600, height: 400 }, fills: [WHITE], children: [] },
192
+ { id: 'E:b', name: 'region-b', type: 'FRAME', bbox: { x: 400, y: 0, width: 600, height: 400 }, fills: [WHITE], children: [] }, // x 400–1000 overlaps region-a's 0–600
193
+ ],
194
+ };
195
+ const fixtureE_ok = {
196
+ id: '0:0', name: 'E-ok', type: 'FRAME', layoutMode: 'NONE', bbox: { x: 0, y: 0, width: 1000, height: 600 },
197
+ children: [
198
+ { id: 'E:c', name: 'region-c', type: 'FRAME', bbox: { x: 0, y: 0, width: 500, height: 400 }, fills: [WHITE], children: [] },
199
+ { id: 'E:d', name: 'region-d', type: 'FRAME', bbox: { x: 500, y: 0, width: 500, height: 400 }, fills: [WHITE], children: [] }, // adjacent at x=500 — touches, no overlap
200
+ ],
201
+ };
202
+
203
+ // FIXTURE F (P1-2) — overlapping children INSIDE an instance are NOT flagged (an instance is a leaf for
204
+ // authored-layout; its interior is the DS's responsibility, audited by check1); the same overlap inside an
205
+ // authored FRAME IS flagged (control).
206
+ const fixtureF = {
207
+ id: '0:0', name: 'F-screen', type: 'FRAME', layoutMode: 'NONE', bbox: { x: 0, y: 0, width: 1000, height: 600 },
208
+ children: [
209
+ { id: 'F:inst', name: 'chip', type: 'INSTANCE', bbox: { x: 0, y: 0, width: 200, height: 100 }, fills: [WHITE],
210
+ children: [
211
+ { id: 'F:ia', name: 'icon', type: 'FRAME', bbox: { x: 0, y: 0, width: 120, height: 80 }, fills: [WHITE], children: [] },
212
+ { id: 'F:ib', name: 'label-bg', type: 'FRAME', bbox: { x: 60, y: 0, width: 120, height: 80 }, fills: [WHITE], children: [] }, // overlaps icon, but inside an INSTANCE → NOT flagged
213
+ ] },
214
+ { id: 'F:row', name: 'authored-row', type: 'FRAME', layoutMode: 'HORIZONTAL', bbox: { x: 0, y: 200, width: 400, height: 100 }, fills: [WHITE],
215
+ children: [
216
+ { id: 'F:c', name: 'col-a', type: 'FRAME', bbox: { x: 0, y: 200, width: 250, height: 80 }, fills: [WHITE], children: [] },
217
+ { id: 'F:d', name: 'col-b', type: 'FRAME', bbox: { x: 150, y: 200, width: 250, height: 80 }, fills: [WHITE], children: [] }, // overlaps col-a inside an authored FRAME → flagged
218
+ ] },
219
+ ],
220
+ };
221
+
127
222
  // ---- assertions ------------------------------------------------------------
128
223
  let failed = 0;
129
224
  function ok(cond, msg) { if (cond) { console.log(' PASS ' + msg); } else { console.log(' FAIL ' + msg); failed++; } }
@@ -144,6 +239,47 @@ function ok(cond, msg) { if (cond) { console.log(' PASS ' + msg); } else { con
144
239
  ok(!b.hardFails.some((f) => f.node === 'hidden-tooltip'), 'B: hidden interior NOT flagged');
145
240
  ok(b.hardFails.length === 2, 'B: exactly 2 hardFails (no spurious overlap/junk)');
146
241
 
242
+ // Fixture C — nestedSameFill (P7) is an ADVISORY (never a hardFail): edgeless same-fill advised;
243
+ // bordered/shadowed/different-fill exempt.
244
+ const c = await runCheckLayout(buildFigma(fixtureC));
245
+ const nsf = c.advisories.filter((f) => f.type === 'nestedSameFill').map((f) => f.node);
246
+ console.log('Fixture C (nestedSameFill advisories):', JSON.stringify(c.advisories.filter((f) => f.type === 'nestedSameFill')));
247
+ ok(c.hardFails.length === 0, 'C: nestedSameFill is NOT a hardFail (hardFails == 0)');
248
+ ok(nsf.includes('section-wrap'), 'C: edgeless white wrapper on white page advised (nestedSameFill)');
249
+ ok(!nsf.includes('real-card'), 'C: white card WITH border exempt');
250
+ ok(!nsf.includes('shadow-card'), 'C: white card WITH shadow exempt');
251
+ ok(!nsf.includes('inner-white-block'), 'C: white block over #EEF2FF (different fill) NOT advised');
252
+ ok(nsf.length === 1, 'C: exactly 1 nestedSameFill advisory (only the wrapper)');
253
+
254
+ // Fixture D — full-bleed precision: body-bg layers that span a full axis are exempt; a same-fill
255
+ // sub-region (white table in a white board) stays advised. hardFails stay 0.
256
+ const d = await runCheckLayout(buildFigma(fixtureD));
257
+ const dnsf = d.advisories.filter((f) => f.type === 'nestedSameFill').map((f) => f.node);
258
+ console.log('Fixture D (nestedSameFill advisories):', JSON.stringify(d.advisories.filter((f) => f.type === 'nestedSameFill')));
259
+ ok(d.hardFails.length === 0, 'D: nestedSameFill is NOT a hardFail (hardFails == 0)');
260
+ ok(!dnsf.includes('main-col'), 'D: main-col (spans full height, inset by sidebar) exempt');
261
+ ok(!dnsf.includes('content'), 'D: content (spans full width, inset by topbar) exempt');
262
+ ok(dnsf.includes('version-table'), 'D: same-fill sub-region (spans neither axis) advised');
263
+ ok(dnsf.length === 1, 'D: exactly 1 nestedSameFill advisory (only the sub-region)');
264
+
265
+ // Fixture E — P2-1: the screen frame's own children are overlap-checked now.
266
+ const eO = await runCheckLayout(buildFigma(fixtureE_overlap));
267
+ const eOv = eO.hardFails.filter((f) => f.type === 'overlap');
268
+ console.log('Fixture E_overlap:', JSON.stringify(eO.hardFails));
269
+ ok(eOv.length === 1 && eOv[0].parent === 'E-overlap', 'E: top-level region overlap flagged (parent = screen frame)');
270
+ ok(eO.hardFails.length === 1, 'E_overlap: exactly 1 hardFail (the overlap, no junk)');
271
+ const eK = await runCheckLayout(buildFigma(fixtureE_ok));
272
+ console.log('Fixture E_ok:', JSON.stringify(eK.hardFails));
273
+ ok(eK.hardFails.length === 0, 'E_ok: adjacent top-level regions (touch only) → 0 hardFails');
274
+
275
+ // Fixture F — P1-2: instance interior overlap NOT flagged; authored overlap flagged.
276
+ const f = await runCheckLayout(buildFigma(fixtureF));
277
+ const fOv = f.hardFails.filter((x) => x.type === 'overlap');
278
+ console.log('Fixture F (overlap):', JSON.stringify(fOv));
279
+ ok(fOv.length === 1, 'F: exactly 1 overlap (authored only)');
280
+ ok(fOv.some((o) => o.parent === 'authored-row'), 'F: authored FRAME overlap flagged');
281
+ ok(!fOv.some((o) => o.parent === 'chip'), 'F: INSTANCE interior overlap NOT flagged (instance = leaf)');
282
+
147
283
  console.log('');
148
284
  if (failed) { console.log('check-layout regression: ' + failed + ' assertion(s) FAILED'); process.exit(1); }
149
285
  console.log('check-layout regression: all assertions passed');
@@ -0,0 +1,59 @@
1
+ /*
2
+ * Regression test for check-recall.js (P5 from-scratch recall leak). Node, no Figma.
3
+ * node validators/test/check-recall.test.js
4
+ * Builds a temp project with a prior screen + three candidates, runs the real check-recall.js:
5
+ * leak same non-spec placeholders as prior (ids/dates/tags) -> nonSpecOverlap high -> FAIL
6
+ * fresh different placeholders -> nonSpecOverlap 0 -> PASS
7
+ * speconly only the shared SPEC anchors, no placeholders -> non-spec empty -> PASS
8
+ * The speconly case proves the check flags recalled *non-spec* content, not spec text that is meant to repeat.
9
+ */
10
+ 'use strict';
11
+ const fs = require('fs');
12
+ const path = require('path');
13
+ const os = require('os');
14
+ const cp = require('child_process');
15
+
16
+ const RECALL = path.join(__dirname, '..', 'check-recall.js');
17
+ const root = path.join(os.tmpdir(), 'dsforge-recall-test-' + process.pid);
18
+ const ANCHORS = ['Create dataset', 'Dataset List'];
19
+
20
+ function write(rel, content) { const p = path.join(root, rel); fs.mkdirSync(path.dirname(p), { recursive: true }); fs.writeFileSync(p, content); }
21
+ const lits = (arr) => 'export const D = [' + arr.map((s) => `'${s}'`).join(', ') + '];\n';
22
+
23
+ fs.rmSync(root, { recursive: true, force: true });
24
+ write('app/tokens.css', ':root {}\n');
25
+ write('app/prior.tsx', lits(['model-0001', 'model-0002', 'vision', '2026-06-10', ...ANCHORS]));
26
+ write('app/leak.tsx', lits(['model-0001', 'model-0002', 'vision', '2026-06-10', ...ANCHORS]));
27
+ write('app/fresh.tsx', lits(['alpha-77', 'beta-88', 'audio', '2025-01-02', ...ANCHORS]));
28
+ write('app/spec.tsx', lits([...ANCHORS]));
29
+ const screen = (file) => ({ label: file, code: { files: [file], anchors: ANCHORS } });
30
+ write('validators/projects/t.json', JSON.stringify({
31
+ project: 't', tokenRef: 'validators/out/t-tokens.json', codeTokensCss: 'app/tokens.css',
32
+ recall: { maxNonSpecOverlap: 0.5 },
33
+ screens: { prior: screen('prior.tsx'), leak: screen('leak.tsx'), fresh: screen('fresh.tsx'), speconly: screen('spec.tsx') },
34
+ }));
35
+
36
+ let failed = 0;
37
+ function ok(cond, msg) { console.log((cond ? ' PASS ' : ' FAIL ') + msg); if (!cond) failed++; }
38
+ const run = (cur, prior) => JSON.parse(cp.execSync(`node "${RECALL}" t ${cur} ${prior}`, { cwd: root }).toString());
39
+
40
+ const leak = run('leak', 'prior');
41
+ console.log('leak:', JSON.stringify({ overlap: leak.nonSpecOverlap, shared: leak.sharedNonSpec, pass: leak.pass }));
42
+ ok(leak.pass === false, 'leak: recalled non-spec content -> FAIL');
43
+ ok(leak.nonSpecOverlap > 0.5, 'leak: nonSpecOverlap above threshold');
44
+ ok(leak.sharedNonSpec.includes('model-0001') && leak.sharedNonSpec.includes('2026-06-10'), 'leak: shares ids/dates with prior');
45
+
46
+ const fresh = run('fresh', 'prior');
47
+ console.log('fresh:', JSON.stringify({ overlap: fresh.nonSpecOverlap, pass: fresh.pass }));
48
+ ok(fresh.pass === true, 'fresh: distinct placeholders -> PASS');
49
+ ok(fresh.nonSpecOverlap === 0, 'fresh: zero non-spec overlap');
50
+
51
+ const spec = run('speconly', 'prior');
52
+ console.log('speconly:', JSON.stringify({ curNonSpec: spec.curNonSpecCount, overlap: spec.nonSpecOverlap, pass: spec.pass }));
53
+ ok(spec.pass === true, 'speconly: identical SPEC text is not a leak -> PASS');
54
+ ok(spec.curNonSpecCount === 0, 'speconly: no non-spec content to compare');
55
+
56
+ fs.rmSync(root, { recursive: true, force: true });
57
+ console.log('');
58
+ if (failed) { console.log('check-recall: ' + failed + ' assertion(s) FAILED'); process.exit(1); }
59
+ console.log('check-recall: all assertions passed');
@@ -0,0 +1,61 @@
1
+ /*
2
+ * Regression test for check3.js icon/vector asset fidelity (P3a). Node, no Figma.
3
+ * node validators/test/check3-icons.test.js
4
+ * Builds a temp project with `iconAssets` declared, runs the real check3.js:
5
+ * good screen — icon slots wrap real <svg> with currentColor → 0 placeholderSlots, 0 rawHexInSvg
6
+ * bad screen — one slot left as an empty placeholder box + an <svg> with a raw hex fill → both flagged
7
+ */
8
+ 'use strict';
9
+ const fs = require('fs');
10
+ const path = require('path');
11
+ const os = require('os');
12
+ const cp = require('child_process');
13
+
14
+ const CHECK3 = path.join(__dirname, '..', 'check3.js');
15
+ const root = path.join(os.tmpdir(), 'dsforge-icons-test-' + process.pid);
16
+ const write = (rel, c) => { const p = path.join(root, rel); fs.mkdirSync(path.dirname(p), { recursive: true }); fs.writeFileSync(p, c); };
17
+
18
+ fs.rmSync(root, { recursive: true, force: true });
19
+ write('validators/out/t-tokens.json', JSON.stringify({ color: {}, float: {}, text: {} }));
20
+ write('app/tokens.css', ':root {}\n');
21
+ // GOOD: both slots carry a real inline SVG; fills are currentColor (no raw hex), slots are not empty boxes.
22
+ write('app/good.tsx', [
23
+ 'export const S = () => (<aside>',
24
+ ' <span className="rail-logo"><svg viewBox="0 0 1 1"><path d="M0 0h1v1H0z" fill="var(--logo-green)"/></svg></span>',
25
+ ' <span className="rail-icon"><svg viewBox="0 0 1 1"><path d="M0 0h1v1H0z" fill="currentColor"/></svg></span>',
26
+ '</aside>);',
27
+ ].join('\n'));
28
+ // BAD: rail-logo left as an empty placeholder box; rail-icon svg bakes a raw hex fill.
29
+ write('app/bad.tsx', [
30
+ 'export const S = () => (<aside>',
31
+ ' <div className="rail-logo" />',
32
+ ' <span className="rail-icon"><svg viewBox="0 0 1 1"><path d="M0 0h1v1H0z" fill="#3366FF"/></svg></span>',
33
+ '</aside>);',
34
+ ].join('\n'));
35
+ write('validators/projects/t.json', JSON.stringify({
36
+ project: 't', tokenRef: 'validators/out/t-tokens.json', codeTokensCss: 'app/tokens.css',
37
+ tokenCssNaming: { colorPrefix: '--c-', spaceFrom: 'space/', spaceTo: '--space-', sizeFrom: 'size/', sizeTo: '--size-', radiusFrom: 'radius/', radiusTo: '--radius-', textClass: {}, weightMap: {} },
38
+ structuralPxAllow: {},
39
+ iconAssets: { selectors: ['.rail-logo', '.rail-icon'] },
40
+ screens: { good: { label: 'good', code: { files: ['good.tsx'] } }, bad: { label: 'bad', code: { files: ['bad.tsx'] } } },
41
+ }));
42
+
43
+ let failed = 0;
44
+ const ok = (c, m) => { console.log((c ? ' PASS ' : ' FAIL ') + m); if (!c) failed++; };
45
+ const run = (scr) => JSON.parse(cp.execSync(`node "${CHECK3}" t ${scr}`, { cwd: root }).toString()).iconAssets;
46
+
47
+ const good = run('good');
48
+ console.log('good iconAssets:', JSON.stringify(good));
49
+ ok(good.applicable === true, 'applicable when iconAssets declared');
50
+ ok(good.placeholderSlots.length === 0, 'good: no placeholder slots (real <svg> in every slot)');
51
+ ok(good.rawHexInSvg.length === 0, 'good: no raw hex in SVG (currentColor / token var only)');
52
+
53
+ const bad = run('bad');
54
+ console.log('bad iconAssets:', JSON.stringify(bad));
55
+ ok(bad.placeholderSlots.includes('.rail-logo'), 'bad: empty placeholder box slot flagged');
56
+ ok(bad.rawHexInSvg.includes('#3366FF'), 'bad: raw hex in SVG flagged');
57
+
58
+ fs.rmSync(root, { recursive: true, force: true });
59
+ console.log('');
60
+ if (failed) { console.log('check3 icon-assets: ' + failed + ' assertion(s) FAILED'); process.exit(1); }
61
+ console.log('check3 icon-assets: all assertions passed');
@@ -0,0 +1,63 @@
1
+ /*
2
+ * Regression test for check3.js size-token dimension fidelity (P4). Node, no Figma.
3
+ * node validators/test/check3-size.test.js
4
+ * Builds a temp project tree, runs the real check3.js against it, asserts the sizeFidelity verdict:
5
+ * .good height bound to the size-token var + box-sizing:border-box -> OK
6
+ * .drift no height (row height = padding+border ≈ token+1px, the P4 bug) -> dimMissing
7
+ * .literal height: 30px literal (matches value but not token-bound) -> literalNotToken
8
+ * .nobox bound to token var but no box-sizing -> noBorderBox
9
+ */
10
+ 'use strict';
11
+ const fs = require('fs');
12
+ const path = require('path');
13
+ const os = require('os');
14
+ const cp = require('child_process');
15
+
16
+ const CHECK3 = path.join(__dirname, '..', 'check3.js');
17
+ const root = path.join(os.tmpdir(), 'dsforge-size-test-' + process.pid);
18
+
19
+ function write(rel, content) { const p = path.join(root, rel); fs.mkdirSync(path.dirname(p), { recursive: true }); fs.writeFileSync(p, content); }
20
+
21
+ fs.rmSync(root, { recursive: true, force: true });
22
+ write('validators/out/t-tokens.json', JSON.stringify({ color: {}, float: { 'size/row': 30 }, text: {} }));
23
+ write('app/tokens.css', ':root { --size-row: 30px; }\n');
24
+ write('app/screen.tsx', 'export const X = 1;\n');
25
+ write('app/comp.css', [
26
+ '.good { height: var(--size-row); box-sizing: border-box; padding: 0 12px; border-bottom: 1px solid var(--c-line); }',
27
+ '.drift { padding: 9px 12px; border-bottom: 1px solid var(--c-line); }',
28
+ '.literal { height: 30px; box-sizing: border-box; }',
29
+ '.nobox { height: var(--size-row); padding: 9px 0; border: 1px solid var(--c-line); }',
30
+ ].join('\n') + '\n');
31
+ write('validators/projects/t.json', JSON.stringify({
32
+ project: 't', tokenRef: 'validators/out/t-tokens.json', codeTokensCss: 'app/tokens.css', codeCssFiles: ['comp.css'],
33
+ tokenCssNaming: { colorPrefix: '--c-', spaceFrom: 'space/', spaceTo: '--space-', sizeFrom: 'size/', sizeTo: '--size-', radiusFrom: 'radius/', radiusTo: '--radius-', textClass: {}, weightMap: {} },
34
+ sizeBindings: [
35
+ { selector: '.good', dim: 'height', token: 'size/row' },
36
+ { selector: '.drift', dim: 'height', token: 'size/row' },
37
+ { selector: '.literal', dim: 'height', token: 'size/row' },
38
+ { selector: '.nobox', dim: 'height', token: 'size/row' },
39
+ ],
40
+ structuralPxAllow: {},
41
+ screens: { main: { label: 'm', code: { files: ['screen.tsx'] } } },
42
+ }));
43
+
44
+ let failed = 0;
45
+ function ok(cond, msg) { console.log((cond ? ' PASS ' : ' FAIL ') + msg); if (!cond) failed++; }
46
+
47
+ const out = JSON.parse(cp.execSync(`node "${CHECK3}" t main`, { cwd: root }).toString());
48
+ const sf = out.sizeFidelity;
49
+ console.log('sizeFidelity:', JSON.stringify(sf));
50
+ const bySel = {}; for (const v of sf.violations) bySel[v.selector] = v.issue;
51
+
52
+ ok(sf.applicable === true, 'applicable when sizeBindings declared');
53
+ ok(sf.total === 4, 'total == 4 bindings');
54
+ ok(!bySel['.good'], '.good (token-bound + border-box) -> no violation');
55
+ ok(bySel['.drift'] === 'dimMissing', '.drift (no height; padding+border) -> dimMissing');
56
+ ok(bySel['.literal'] === 'literalNotToken', '.literal (height: 30px literal) -> literalNotToken');
57
+ ok(bySel['.nobox'] === 'noBorderBox', '.nobox (token-bound, no box-sizing) -> noBorderBox');
58
+ ok(sf.violations.length === 3, 'exactly 3 violations (only .good passes)');
59
+
60
+ fs.rmSync(root, { recursive: true, force: true });
61
+ console.log('');
62
+ if (failed) { console.log('check3 size-fidelity: ' + failed + ' assertion(s) FAILED'); process.exit(1); }
63
+ console.log('check3 size-fidelity: all assertions passed');
@@ -0,0 +1,17 @@
1
+ /*
2
+ * Run all dsforge validator regression tests. Node.
3
+ * node validators/test/run-all.js (or `npm test` from the package root)
4
+ */
5
+ 'use strict';
6
+ const path = require('path');
7
+ const cp = require('child_process');
8
+
9
+ const tests = ['check-layout.test.js', 'check3-size.test.js', 'check3-icons.test.js', 'check-recall.test.js'];
10
+ let failed = 0;
11
+ for (const t of tests) {
12
+ console.log('\n=== ' + t + ' ===');
13
+ const r = cp.spawnSync('node', [path.join(__dirname, t)], { stdio: 'inherit' });
14
+ if (r.status !== 0) failed++;
15
+ }
16
+ console.log('\n' + (failed ? failed + ' test file(s) FAILED' : 'all ' + tests.length + ' test files passed'));
17
+ process.exit(failed ? 1 : 0);
@@ -34,7 +34,11 @@ for (const sk of Object.keys(cfg.screens)) {
34
34
  const shellOk = Object.values(c2.shell).every(Boolean);
35
35
  const c2pass = c2.coverage.pct === 100 && c2.fabrication.extra.length === 0 && c2.binding.authoredRaw === 0 && c2.viewport.ok && shellOk;
36
36
  const contentOk = c3.content.array ? c3.content.array.verbatimAndOrdered : (c3.content.anchors ? c3.content.anchors.verbatim : true);
37
- const c3pass = c3.tokenCompare.match === c3.tokenCompare.total && c3.hardcode.hexCount === 0 && c3.hardcode.pxViolationCount === 0 && contentOk;
37
+ // size-token dimension fidelity (P4) — only enforced when the descriptor declares sizeBindings (backward compatible)
38
+ const sizeOk = c3.sizeFidelity && c3.sizeFidelity.applicable ? c3.sizeFidelity.violations.length === 0 : true;
39
+ // icon/vector asset fidelity (P3a) — only enforced when the descriptor declares iconAssets (Branch A; backward compatible)
40
+ const iconOk = c3.iconAssets && c3.iconAssets.applicable ? (c3.iconAssets.placeholderSlots.length === 0 && c3.iconAssets.rawHexInSvg.length === 0) : true;
41
+ const c3pass = c3.tokenCompare.match === c3.tokenCompare.total && c3.hardcode.hexCount === 0 && c3.hardcode.pxViolationCount === 0 && contentOk && sizeOk && iconOk;
38
42
  // Layout floor (objective breakage) — staged in out/check-layout-<screen>.json by the use_figma run.
39
43
  // Optional: absent for projects that haven't run it, but hardFails 0 is the precondition to the visual gate.
40
44
  const cl = loadOpt('check-layout-' + sk + '.json');
@@ -54,6 +58,7 @@ for (const [sk, r] of Object.entries(screens)) {
54
58
  repro['anchorsVerbatim_' + sk] = r.contentOk;
55
59
  repro['fabrication0_' + sk] = r.c2.fabrication.extra.length === 0 && (!r.c3.content.array || r.c3.content.array.extra.length === 0);
56
60
  if (r.cl) repro['layoutClean_' + sk] = r.layoutPass === true; // only enforced when the layout floor was run
61
+ if (r.c3.sizeFidelity && r.c3.sizeFidelity.applicable) repro['sizeFidelity0_' + sk] = r.c3.sizeFidelity.violations.length === 0; // only when sizeBindings declared
57
62
  }
58
63
  const reproduced = Object.values(repro).every(Boolean);
59
64
 
@@ -62,7 +67,7 @@ const report = {
62
67
  check1_DS: { pass: c1pass, tokens: c1.tokens, raw: c1.binding.raw, instanceInteriorNodes: c1.binding.instanceInteriorNodes, states: c1.variants.withRequiredStates + '/' + c1.variants.interactiveSets },
63
68
  screens: Object.fromEntries(Object.entries(screens).map(([sk, r]) => [sk, {
64
69
  check2: { pass: r.c2pass, coverage: r.c2.coverage.total, fabricationExtra: r.c2.fabrication.extra.length, authoredRaw: r.c2.binding.authoredRaw, dsInternalRaw: r.c2.binding.dsInternalRaw, viewport: r.c2.viewport.ok, shell: r.shellOk },
65
- check3: { pass: r.c3pass, tokens: r.c3.tokenCompare.match + '/' + r.c3.tokenCompare.total, hex: r.c3.hardcode.hexCount, pxViol: r.c3.hardcode.pxViolationCount, content: r.contentOk },
70
+ check3: { pass: r.c3pass, tokens: r.c3.tokenCompare.match + '/' + r.c3.tokenCompare.total, hex: r.c3.hardcode.hexCount, pxViol: r.c3.hardcode.pxViolationCount, content: r.contentOk, sizeFidelity: r.c3.sizeFidelity && r.c3.sizeFidelity.applicable ? r.c3.sizeFidelity.ok + '/' + r.c3.sizeFidelity.total : 'n/a' },
66
71
  layout: r.cl ? { pass: r.layoutPass, hardFails: r.cl.hardFails.length, advisories: r.cl.advisories.length } : 'not run',
67
72
  }])),
68
73
  selfVerification: { baseline: sv, checks: repro, reproduced },