@reqvire-org/ads 0.3.47 → 0.3.49

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.
Files changed (38) hide show
  1. package/dist/browser-audit/worker.mjs +8 -2
  2. package/dist/browser-audit.mjs +33 -3
  3. package/dist/finding-rules.mjs +2 -0
  4. package/dist/mcp/context.mjs +1 -1
  5. package/dist/mcp/mutations.mjs +23 -0
  6. package/dist/mcp/server.mjs +4 -4
  7. package/dist/palette-generated.mjs +6 -3
  8. package/dist/showcase/client.bundle.js +1 -1
  9. package/dist/showcase/icons.js +1 -1
  10. package/dist/showcase/style.css +1 -1
  11. package/dist/skills/ads-break-ui/references/design-data.md +8 -1
  12. package/dist/skills/ads-break-ui/references/drafts.md +3 -1
  13. package/dist/skills/ads-break-ui/references/guarded-editing.md +3 -2
  14. package/dist/skills/ads-break-ui/references/validation.md +6 -1
  15. package/dist/skills/ads-designer/references/accessibility.md +4 -2
  16. package/dist/skills/ads-designer/references/design-data.md +8 -1
  17. package/dist/skills/ads-designer/references/drafts.md +3 -1
  18. package/dist/skills/ads-designer/references/guarded-editing.md +3 -2
  19. package/dist/skills/ads-designer/references/validation.md +6 -1
  20. package/dist/skills/ads-import/references/design-data.md +8 -1
  21. package/dist/skills/ads-import/references/drafts.md +3 -1
  22. package/dist/skills/ads-import/references/guarded-editing.md +3 -2
  23. package/dist/skills/ads-import/references/validation.md +6 -1
  24. package/dist/skills/ads-motion/references/design-data.md +8 -1
  25. package/dist/skills/ads-motion/references/drafts.md +3 -1
  26. package/dist/skills/ads-motion/references/guarded-editing.md +3 -2
  27. package/dist/skills/ads-motion/references/validation.md +6 -1
  28. package/dist/skills/ads-port/references/design-data.md +8 -1
  29. package/dist/skills/ads-port/references/drafts.md +3 -1
  30. package/dist/skills/ads-port/references/guarded-editing.md +3 -2
  31. package/dist/skills/ads-port/references/validation.md +6 -1
  32. package/dist/token-quality.mjs +49 -22
  33. package/dist/validation.mjs +3 -4
  34. package/dist/verification.mjs +25 -4
  35. package/docs/CHANGELOG.md +51 -12
  36. package/docs/GUIDE.md +6 -2
  37. package/docs/MCP.md +15 -5
  38. package/package.json +1 -1
@@ -152,7 +152,9 @@ current rendered revision and complete acceptance before finishing the change.
152
152
  After rendered review, call `ads_accept({id,revision})` once. It checks that exact
153
153
  revision, runs mandatory ADS guards plus `acceptance.checks` and, when
154
154
  `acceptance.behaviorChecks` is enabled, affected registered behavior checks against an isolated candidate, and applies passing changes at
155
- their normal paths. Changes during checking or baseline conflicts prevent
155
+ their normal paths. When `acceptance.browserAudit` is enabled it also runs the axe-core
156
+ audit on the candidate's affected UI scenarios; an `a11y-axe` error rejects the draft.
157
+ Fix it in the component and accept the new revision. Changes during checking or baseline conflicts prevent
156
158
  application. Successful acceptance removes the proposal and records an event.
157
159
  There is no separate Apply or Iterate action. A failed attempt retains the draft;
158
160
  inspect its returned resultId with `ads_results` and fix the reported boundary.
@@ -23,8 +23,9 @@ ads_apply_patch({"unit":"components/Example","patchFile":"<returned patchFile>",
23
23
  The dry run validates the candidate in an isolated project copy using mandatory
24
24
  ADS guards, `acceptance.checks` and, when `acceptance.behaviorChecks` is enabled,
25
25
  affected registered behavior checks. Registration alone does not require a test
26
- at acceptance. See [validation policies](validation.md). Configured browser checks use that candidate's
27
- managed preview, not the live showcase. Read the summary, then page failing
26
+ at acceptance. With `acceptance.browserAudit`, axe-core also audits the candidate's
27
+ affected UI scenarios; `a11y-axe` errors reject the patch. See [validation policies](validation.md).
28
+ Configured browser checks use that candidate's managed preview, not the live showcase. Read the summary, then page failing
28
29
  `outcomes`, `diagnostics` or pipeline `checks` through `ads_results` with its
29
30
  `resultId`. Inspect one exact outcome with `ads_investigate({unit,check,runId})`;
30
31
  fix the draft and diff again. See [evidence.md](evidence.md) for page/range limits.
@@ -43,7 +43,12 @@ implicitly requiring them at acceptance.
43
43
  owners while project scripts and core gates retain full scope.
44
44
  - `browserAudit: true` in either policy adds the axe-core audit of every rendered
45
45
  UI scenario in every brand and theme (`browser-accessibility-audit`). Its `a11y-axe`
46
- findings are errors that fail the policy; draft and patch acceptance do not run it. See
46
+ findings are errors that fail the policy. With `acceptance.browserAudit`, draft
47
+ acceptance and guarded patches/transactions audit the candidate's affected UI
48
+ scenarios (all after configuration, foundation, token or asset changes) and reject
49
+ the change on any `a11y-axe` error or a `browser-audit` failure to run. Declare
50
+ `"sideEffects": ["**/*.css"]` in the project's `package.json`, as the starters do, so a
51
+ component change audits only the scenarios that import it. See
47
52
  ads://guides/accessibility.
48
53
  - Draft create, edit and show are preview-only; they trigger neither policy.
49
54
  `ads_verify` explicitly runs selected checks independently of either policy.
@@ -92,7 +92,7 @@ keeps independent component token definitions valid.
92
92
 
93
93
  ## Accessibility and rhythm checks
94
94
 
95
- `ads check` checks token values in every theme and brand. Each finding below is an error:
95
+ `ads check` checks token values in every theme and brand. Each finding below is an error unless marked info:
96
96
 
97
97
  - `token-contrast`: the roles that meet on screen fall below WCAG 2.2 AA: `--text-strong`,
98
98
  `--text-body`, `--text-muted`, `--text-link` and `--accent-text` on `--bg-canvas`,
@@ -100,6 +100,13 @@ keeps independent component token definitions valid.
100
100
  status's `-fg` on its solid and `-text` on its `-bg` (4.5:1); `--border-focus` and
101
101
  `--border-strong` on the canvas and surface (3:1). Fix it by choosing a different ramp
102
102
  step for the role, in the theme the message names, never with a one-off color.
103
+ Any CSS color is evaluated (hex, named, `rgb()`, `hsl()`, `hwb()`, `lab()`, `lch()`,
104
+ `oklab()`, `oklch()`, `color()`, `color-mix()`, `light-dark()`), through halves and
105
+ aliases. A translucent background counts as composited over `--bg-canvas`, a translucent
106
+ foreground as composited over its background.
107
+ - `token-contrast-unresolved` (info): a pair color ADS cannot resolve statically
108
+ (`currentColor`, relative color syntax, a system color), so that pair is not checked. Give
109
+ the role a color or a ramp step, or check the pages that use it with `ads audit`.
103
110
  - `token-rhythm`: a numbered spacing step leaves the scale `--space-N` = N × 2 px.
104
111
  - `control-padding`: pad a control with the token for its size. A block sized with
105
112
  `--control-height-<size>` pads its sides with `--control-padding-<size>`; the small gap
@@ -152,7 +152,9 @@ current rendered revision and complete acceptance before finishing the change.
152
152
  After rendered review, call `ads_accept({id,revision})` once. It checks that exact
153
153
  revision, runs mandatory ADS guards plus `acceptance.checks` and, when
154
154
  `acceptance.behaviorChecks` is enabled, affected registered behavior checks against an isolated candidate, and applies passing changes at
155
- their normal paths. Changes during checking or baseline conflicts prevent
155
+ their normal paths. When `acceptance.browserAudit` is enabled it also runs the axe-core
156
+ audit on the candidate's affected UI scenarios; an `a11y-axe` error rejects the draft.
157
+ Fix it in the component and accept the new revision. Changes during checking or baseline conflicts prevent
156
158
  application. Successful acceptance removes the proposal and records an event.
157
159
  There is no separate Apply or Iterate action. A failed attempt retains the draft;
158
160
  inspect its returned resultId with `ads_results` and fix the reported boundary.
@@ -23,8 +23,9 @@ ads_apply_patch({"unit":"components/Example","patchFile":"<returned patchFile>",
23
23
  The dry run validates the candidate in an isolated project copy using mandatory
24
24
  ADS guards, `acceptance.checks` and, when `acceptance.behaviorChecks` is enabled,
25
25
  affected registered behavior checks. Registration alone does not require a test
26
- at acceptance. See [validation policies](validation.md). Configured browser checks use that candidate's
27
- managed preview, not the live showcase. Read the summary, then page failing
26
+ at acceptance. With `acceptance.browserAudit`, axe-core also audits the candidate's
27
+ affected UI scenarios; `a11y-axe` errors reject the patch. See [validation policies](validation.md).
28
+ Configured browser checks use that candidate's managed preview, not the live showcase. Read the summary, then page failing
28
29
  `outcomes`, `diagnostics` or pipeline `checks` through `ads_results` with its
29
30
  `resultId`. Inspect one exact outcome with `ads_investigate({unit,check,runId})`;
30
31
  fix the draft and diff again. See [evidence.md](evidence.md) for page/range limits.
@@ -43,7 +43,12 @@ implicitly requiring them at acceptance.
43
43
  owners while project scripts and core gates retain full scope.
44
44
  - `browserAudit: true` in either policy adds the axe-core audit of every rendered
45
45
  UI scenario in every brand and theme (`browser-accessibility-audit`). Its `a11y-axe`
46
- findings are errors that fail the policy; draft and patch acceptance do not run it. See
46
+ findings are errors that fail the policy. With `acceptance.browserAudit`, draft
47
+ acceptance and guarded patches/transactions audit the candidate's affected UI
48
+ scenarios (all after configuration, foundation, token or asset changes) and reject
49
+ the change on any `a11y-axe` error or a `browser-audit` failure to run. Declare
50
+ `"sideEffects": ["**/*.css"]` in the project's `package.json`, as the starters do, so a
51
+ component change audits only the scenarios that import it. See
47
52
  ads://guides/accessibility.
48
53
  - Draft create, edit and show are preview-only; they trigger neither policy.
49
54
  `ads_verify` explicitly runs selected checks independently of either policy.
@@ -92,7 +92,7 @@ keeps independent component token definitions valid.
92
92
 
93
93
  ## Accessibility and rhythm checks
94
94
 
95
- `ads check` checks token values in every theme and brand. Each finding below is an error:
95
+ `ads check` checks token values in every theme and brand. Each finding below is an error unless marked info:
96
96
 
97
97
  - `token-contrast`: the roles that meet on screen fall below WCAG 2.2 AA: `--text-strong`,
98
98
  `--text-body`, `--text-muted`, `--text-link` and `--accent-text` on `--bg-canvas`,
@@ -100,6 +100,13 @@ keeps independent component token definitions valid.
100
100
  status's `-fg` on its solid and `-text` on its `-bg` (4.5:1); `--border-focus` and
101
101
  `--border-strong` on the canvas and surface (3:1). Fix it by choosing a different ramp
102
102
  step for the role, in the theme the message names, never with a one-off color.
103
+ Any CSS color is evaluated (hex, named, `rgb()`, `hsl()`, `hwb()`, `lab()`, `lch()`,
104
+ `oklab()`, `oklch()`, `color()`, `color-mix()`, `light-dark()`), through halves and
105
+ aliases. A translucent background counts as composited over `--bg-canvas`, a translucent
106
+ foreground as composited over its background.
107
+ - `token-contrast-unresolved` (info): a pair color ADS cannot resolve statically
108
+ (`currentColor`, relative color syntax, a system color), so that pair is not checked. Give
109
+ the role a color or a ramp step, or check the pages that use it with `ads audit`.
103
110
  - `token-rhythm`: a numbered spacing step leaves the scale `--space-N` = N × 2 px.
104
111
  - `control-padding`: pad a control with the token for its size. A block sized with
105
112
  `--control-height-<size>` pads its sides with `--control-padding-<size>`; the small gap
@@ -152,7 +152,9 @@ current rendered revision and complete acceptance before finishing the change.
152
152
  After rendered review, call `ads_accept({id,revision})` once. It checks that exact
153
153
  revision, runs mandatory ADS guards plus `acceptance.checks` and, when
154
154
  `acceptance.behaviorChecks` is enabled, affected registered behavior checks against an isolated candidate, and applies passing changes at
155
- their normal paths. Changes during checking or baseline conflicts prevent
155
+ their normal paths. When `acceptance.browserAudit` is enabled it also runs the axe-core
156
+ audit on the candidate's affected UI scenarios; an `a11y-axe` error rejects the draft.
157
+ Fix it in the component and accept the new revision. Changes during checking or baseline conflicts prevent
156
158
  application. Successful acceptance removes the proposal and records an event.
157
159
  There is no separate Apply or Iterate action. A failed attempt retains the draft;
158
160
  inspect its returned resultId with `ads_results` and fix the reported boundary.
@@ -23,8 +23,9 @@ ads_apply_patch({"unit":"components/Example","patchFile":"<returned patchFile>",
23
23
  The dry run validates the candidate in an isolated project copy using mandatory
24
24
  ADS guards, `acceptance.checks` and, when `acceptance.behaviorChecks` is enabled,
25
25
  affected registered behavior checks. Registration alone does not require a test
26
- at acceptance. See [validation policies](validation.md). Configured browser checks use that candidate's
27
- managed preview, not the live showcase. Read the summary, then page failing
26
+ at acceptance. With `acceptance.browserAudit`, axe-core also audits the candidate's
27
+ affected UI scenarios; `a11y-axe` errors reject the patch. See [validation policies](validation.md).
28
+ Configured browser checks use that candidate's managed preview, not the live showcase. Read the summary, then page failing
28
29
  `outcomes`, `diagnostics` or pipeline `checks` through `ads_results` with its
29
30
  `resultId`. Inspect one exact outcome with `ads_investigate({unit,check,runId})`;
30
31
  fix the draft and diff again. See [evidence.md](evidence.md) for page/range limits.
@@ -43,7 +43,12 @@ implicitly requiring them at acceptance.
43
43
  owners while project scripts and core gates retain full scope.
44
44
  - `browserAudit: true` in either policy adds the axe-core audit of every rendered
45
45
  UI scenario in every brand and theme (`browser-accessibility-audit`). Its `a11y-axe`
46
- findings are errors that fail the policy; draft and patch acceptance do not run it. See
46
+ findings are errors that fail the policy. With `acceptance.browserAudit`, draft
47
+ acceptance and guarded patches/transactions audit the candidate's affected UI
48
+ scenarios (all after configuration, foundation, token or asset changes) and reject
49
+ the change on any `a11y-axe` error or a `browser-audit` failure to run. Declare
50
+ `"sideEffects": ["**/*.css"]` in the project's `package.json`, as the starters do, so a
51
+ component change audits only the scenarios that import it. See
47
52
  ads://guides/accessibility.
48
53
  - Draft create, edit and show are preview-only; they trigger neither policy.
49
54
  `ads_verify` explicitly runs selected checks independently of either policy.
@@ -92,7 +92,7 @@ keeps independent component token definitions valid.
92
92
 
93
93
  ## Accessibility and rhythm checks
94
94
 
95
- `ads check` checks token values in every theme and brand. Each finding below is an error:
95
+ `ads check` checks token values in every theme and brand. Each finding below is an error unless marked info:
96
96
 
97
97
  - `token-contrast`: the roles that meet on screen fall below WCAG 2.2 AA: `--text-strong`,
98
98
  `--text-body`, `--text-muted`, `--text-link` and `--accent-text` on `--bg-canvas`,
@@ -100,6 +100,13 @@ keeps independent component token definitions valid.
100
100
  status's `-fg` on its solid and `-text` on its `-bg` (4.5:1); `--border-focus` and
101
101
  `--border-strong` on the canvas and surface (3:1). Fix it by choosing a different ramp
102
102
  step for the role, in the theme the message names, never with a one-off color.
103
+ Any CSS color is evaluated (hex, named, `rgb()`, `hsl()`, `hwb()`, `lab()`, `lch()`,
104
+ `oklab()`, `oklch()`, `color()`, `color-mix()`, `light-dark()`), through halves and
105
+ aliases. A translucent background counts as composited over `--bg-canvas`, a translucent
106
+ foreground as composited over its background.
107
+ - `token-contrast-unresolved` (info): a pair color ADS cannot resolve statically
108
+ (`currentColor`, relative color syntax, a system color), so that pair is not checked. Give
109
+ the role a color or a ramp step, or check the pages that use it with `ads audit`.
103
110
  - `token-rhythm`: a numbered spacing step leaves the scale `--space-N` = N × 2 px.
104
111
  - `control-padding`: pad a control with the token for its size. A block sized with
105
112
  `--control-height-<size>` pads its sides with `--control-padding-<size>`; the small gap
@@ -152,7 +152,9 @@ current rendered revision and complete acceptance before finishing the change.
152
152
  After rendered review, call `ads_accept({id,revision})` once. It checks that exact
153
153
  revision, runs mandatory ADS guards plus `acceptance.checks` and, when
154
154
  `acceptance.behaviorChecks` is enabled, affected registered behavior checks against an isolated candidate, and applies passing changes at
155
- their normal paths. Changes during checking or baseline conflicts prevent
155
+ their normal paths. When `acceptance.browserAudit` is enabled it also runs the axe-core
156
+ audit on the candidate's affected UI scenarios; an `a11y-axe` error rejects the draft.
157
+ Fix it in the component and accept the new revision. Changes during checking or baseline conflicts prevent
156
158
  application. Successful acceptance removes the proposal and records an event.
157
159
  There is no separate Apply or Iterate action. A failed attempt retains the draft;
158
160
  inspect its returned resultId with `ads_results` and fix the reported boundary.
@@ -23,8 +23,9 @@ ads_apply_patch({"unit":"components/Example","patchFile":"<returned patchFile>",
23
23
  The dry run validates the candidate in an isolated project copy using mandatory
24
24
  ADS guards, `acceptance.checks` and, when `acceptance.behaviorChecks` is enabled,
25
25
  affected registered behavior checks. Registration alone does not require a test
26
- at acceptance. See [validation policies](validation.md). Configured browser checks use that candidate's
27
- managed preview, not the live showcase. Read the summary, then page failing
26
+ at acceptance. With `acceptance.browserAudit`, axe-core also audits the candidate's
27
+ affected UI scenarios; `a11y-axe` errors reject the patch. See [validation policies](validation.md).
28
+ Configured browser checks use that candidate's managed preview, not the live showcase. Read the summary, then page failing
28
29
  `outcomes`, `diagnostics` or pipeline `checks` through `ads_results` with its
29
30
  `resultId`. Inspect one exact outcome with `ads_investigate({unit,check,runId})`;
30
31
  fix the draft and diff again. See [evidence.md](evidence.md) for page/range limits.
@@ -43,7 +43,12 @@ implicitly requiring them at acceptance.
43
43
  owners while project scripts and core gates retain full scope.
44
44
  - `browserAudit: true` in either policy adds the axe-core audit of every rendered
45
45
  UI scenario in every brand and theme (`browser-accessibility-audit`). Its `a11y-axe`
46
- findings are errors that fail the policy; draft and patch acceptance do not run it. See
46
+ findings are errors that fail the policy. With `acceptance.browserAudit`, draft
47
+ acceptance and guarded patches/transactions audit the candidate's affected UI
48
+ scenarios (all after configuration, foundation, token or asset changes) and reject
49
+ the change on any `a11y-axe` error or a `browser-audit` failure to run. Declare
50
+ `"sideEffects": ["**/*.css"]` in the project's `package.json`, as the starters do, so a
51
+ component change audits only the scenarios that import it. See
47
52
  ads://guides/accessibility.
48
53
  - Draft create, edit and show are preview-only; they trigger neither policy.
49
54
  `ads_verify` explicitly runs selected checks independently of either policy.
@@ -1,8 +1,10 @@
1
- import { contextValues, defaultThemes, resolveValue } from "./themes.mjs";
1
+ import { contextValues, defaultThemes } from "./themes.mjs";
2
+ import { paletteContexts, resolveColorToken } from "./palette-generated.mjs";
2
3
  import { findingSeverity } from "./finding-rules.mjs";
3
4
 
4
5
  /** Accessibility and rhythm reviews of token values: WCAG contrast between the roles that
5
- * meet on screen, in every theme, and spacing steps on the 2 px grid. Both are errors. */
6
+ * meet on screen, in every theme and brand, and spacing steps on the 2 px grid. Both are
7
+ * errors; a contrast pair ADS cannot resolve statically is an info item. */
6
8
 
7
9
  const named = { white: [255, 255, 255, 1], black: [0, 0, 0, 1] };
8
10
 
@@ -57,32 +59,57 @@ function contrastPairs(names) {
57
59
  return pairs.filter(([foreground, background]) => names.has(foreground) && names.has(background));
58
60
  }
59
61
 
62
+ const label = ({ theme, brand }) => brand === undefined ? `the ${theme.name} theme` : `the ${theme.name} theme of brand "${brand}"`;
63
+ const sameEntry = (first, second) => first?.color && second?.color ? first.color.every((value, index) => value === second.color[index]) : !first?.color && !second?.color && first?.value === second?.value;
64
+
65
+ /** WCAG contrast of every role pair in every theme of every brand. Colors resolve the way the
66
+ * generated palette resolves them (resolveColorToken: the per-theme halves, aliases and var()
67
+ * fallbacks, light-dark() by the theme's scheme, every CSS color syntax and color-mix(), clipped
68
+ * to sRGB). WCAG compares opaque colors, so alpha is composited as the page paints it: a
69
+ * translucent background over --bg-canvas (the canvas itself over white), then a translucent
70
+ * foreground over that background. A brand other than the default reports only the pairs whose
71
+ * colors it changes. A pair color that cannot be resolved statically (currentColor, relative
72
+ * color syntax, a system color, a non-color value) is reported once per token and value as a
73
+ * token-contrast-unresolved info item instead of being checked. */
60
74
  export function tokenContrastAdvisories(tokens, themes = defaultThemes, brands = []) {
61
75
  const names = new Set(tokens.map(token => token.name));
62
- const advisories = [];
76
+ const advisories = [], unresolved = new Map();
63
77
  const pairs = contrastPairs(names);
64
- // Every brand in every theme; a brand other than the default reports only the pairs it changes.
65
- for (const { name: scope } of themes) {
66
- const defaults = contextValues(tokens, { theme: scope, themes });
67
- for (const brand of brands.length ? brands.map(item => item.name) : [undefined]) {
68
- const own = brand === undefined || brand === brands[0].name;
69
- const values = own ? defaults : contextValues(tokens, { theme: scope, brand, themes });
70
- for (const [foreground, background, minimum] of pairs) {
71
- const fore = resolveValue(values, foreground), backValue = resolveValue(values, background);
72
- const front = parseColor(fore ?? ""), back = parseColor(backValue ?? "");
73
- if (!front || !back) continue;
74
- if (!own && fore === resolveValue(defaults, foreground) && backValue === resolveValue(defaults, background)) continue;
75
- const ratio = contrastRatio(front, back[3] < 1 ? over(back, [255, 255, 255, 1]) : back);
76
- if (ratio + 1e-9 >= minimum) continue;
77
- const at = values.get(foreground);
78
- if (!at) continue;
79
- const { file, line, column } = at;
80
- const where = own ? `the ${scope} theme` : `the ${scope} theme of brand "${brand}"`;
81
- advisories.push({ rule: "token-contrast", severity: findingSeverity("token-contrast"), file, line, column, tokens: [foreground, background], guidanceUri: "ads://guides/tokens",
82
- message: `${foreground} on ${background} is ${ratio.toFixed(2)}:1 in ${where}; ${minimum === 4.5 ? "text needs 4.5:1 (WCAG 1.4.3)" : "focus indicators and control borders need 3:1 (WCAG 1.4.11)"}.` });
78
+ const defaults = new Map(themes.map(theme => [theme.name, contextValues(tokens, { theme: theme.name, themes })]));
79
+ for (const context of paletteContexts({ themes, brands })) {
80
+ const { theme, brand } = context, scheme = theme.scheme;
81
+ const own = brand === undefined;
82
+ const values = own ? defaults.get(theme.name) : contextValues(tokens, { theme: theme.name, brand, themes });
83
+ const resolved = new Map(), base = new Map();
84
+ const color = (name, from = values, cache = resolved) => { if (!cache.has(name)) cache.set(name, resolveColorToken(from, name, scheme)); return cache.get(name); };
85
+ const canvasEntry = color("--bg-canvas");
86
+ const canvas = canvasEntry?.color ? over(canvasEntry.color, [255, 255, 255, 1]) : [255, 255, 255, 1];
87
+ for (const [foreground, background, minimum] of pairs) {
88
+ const front = color(foreground), back = color(background);
89
+ if (!front || !back) continue;
90
+ if (!own && sameEntry(front, color(foreground, defaults.get(theme.name), base)) && sameEntry(back, color(background, defaults.get(theme.name), base))) continue;
91
+ const missing = [[foreground, front, background], [background, back, foreground]].filter(([, entry]) => !entry.color);
92
+ for (const [name, entry, partner] of missing) {
93
+ const key = `${name}\u0000${entry.value}`;
94
+ const item = unresolved.get(key) ?? { name, value: entry.value, reason: entry.unresolved ?? "not a color", at: values.get(name), contexts: new Set(), partners: new Set() };
95
+ item.contexts.add(label(context)); item.partners.add(partner);
96
+ unresolved.set(key, item);
83
97
  }
98
+ if (missing.length) continue;
99
+ const opaqueBack = back.color[3] < 1 ? over(back.color, background === "--bg-canvas" ? [255, 255, 255, 1] : canvas) : back.color;
100
+ const ratio = contrastRatio(front.color, opaqueBack);
101
+ if (ratio + 1e-9 >= minimum) continue;
102
+ const at = values.get(foreground);
103
+ if (!at) continue;
104
+ const { file, line, column } = at;
105
+ advisories.push({ rule: "token-contrast", severity: findingSeverity("token-contrast"), file, line, column, tokens: [foreground, background], guidanceUri: "ads://guides/tokens",
106
+ message: `${foreground} on ${background} is ${ratio.toFixed(2)}:1 in ${label(context)}; ${minimum === 4.5 ? "text needs 4.5:1 (WCAG 1.4.3)" : "focus indicators and control borders need 3:1 (WCAG 1.4.11)"}.` });
84
107
  }
85
108
  }
109
+ for (const { name, value, reason, at, contexts, partners } of unresolved.values()) {
110
+ advisories.push({ rule: "token-contrast-unresolved", severity: findingSeverity("token-contrast-unresolved"), ...(at ? { file: at.file, line: at.line, column: at.column } : {}), tokens: [name, ...partners], guidanceUri: "ads://guides/tokens",
111
+ message: `${name} is ${value} in ${[...contexts].join(", ")}, which ADS cannot resolve to a color statically (${reason}), so its contrast with ${[...partners].join(", ")} is not checked. Set it to a color or a ramp step, or check the pages that use it with ads audit.` });
112
+ }
86
113
  return advisories;
87
114
  }
88
115
 
@@ -12,7 +12,6 @@ import { checkCandidate, checkCommand, projectChecks } from "./validation-checks
12
12
  import { acceptance } from "./evidence.mjs";
13
13
  import { inspectScenarios } from "./scenarios.mjs";
14
14
  import { inspectBuildStatus } from "./mcp/build-status.mjs";
15
- import { routeFindings } from "./finding-rules.mjs";
16
15
 
17
16
  const hash = value => createHash("sha256").update(value).digest("hex");
18
17
  function toolInputs() {
@@ -124,12 +123,12 @@ export function createValidationController(directory, { previewWork } = {}) {
124
123
  // Rendered axe-core audit per scenario, brand and theme. a11y-axe findings are errors:
125
124
  // they fail this policy.
126
125
  stage("browser-audit");
127
- const { runBrowserAudit } = await import("./browser-audit.mjs");
126
+ const { auditCheck, runBrowserAudit } = await import("./browser-audit.mjs");
128
127
  try {
129
128
  const audit = await runBrowserAudit(root, {previewHost,signal,onProgress:value=>{ progress={...value,completed:checks.length}; onProgress?.(progress); }});
130
- const routed=routeFindings([],audit.findings);
129
+ const {routed,check}=auditCheck(audit);
131
130
  diagnostics.push(...routed.diagnostics); advisories.push(...routed.advisories);
132
- checks.push({name:"browser-accessibility-audit",passed:!routed.diagnostics.length,engine:audit.engine,scenarios:audit.scenarios,themes:audit.themes,...(audit.brands?{brands:audit.brands}:{}),renders:audit.runs,errors:routed.diagnostics.length,reviews:routed.advisories.length});
131
+ checks.push(check);
133
132
  } catch (error) {
134
133
  if (signal.aborted) throw error;
135
134
  checks.push({name:"browser-accessibility-audit",passed:false});
@@ -55,7 +55,8 @@ function inputContext(options) {
55
55
  };
56
56
  }
57
57
 
58
- export function behaviorInputs(options, contract, check, context = inputContext(options)) {
58
+ /** Project files reachable from the given entry files through real imports, CSS imports and local assets. */
59
+ function inputClosure(options, context, entries) {
59
60
  const files = new Set(), demands = new Map(), effectsVisited = new Set();
60
61
  const resolve = context.resolve;
61
62
  function effects(file) {
@@ -120,10 +121,16 @@ export function behaviorInputs(options, contract, check, context = inputContext(
120
121
  }
121
122
  walk(ast);
122
123
  }
123
- for (const file of context.inventory.units.find(unit => unit.id === contract.unit)?.files ?? []) visit(path.join(options.root, file));
124
- for (const file of context.seeds) visit(file);
124
+ for (const file of entries) visit(file);
125
+ return files;
126
+ }
127
+
128
+ export function behaviorInputs(options, contract, check, context = inputContext(options)) {
125
129
  const scenario = check.scenario && context.scenarios.find(item => item.id === check.scenario);
126
- if (scenario) visit(path.join(options.root, scenario.file));
130
+ const files = inputClosure(options, context, [
131
+ ...(context.inventory.units.find(unit => unit.id === contract.unit)?.files ?? []).map(file => path.join(options.root, file)),
132
+ ...context.seeds, ...(scenario ? [path.join(options.root, scenario.file)] : []),
133
+ ]);
127
134
  const rows = [...files].sort().map(file => [slash(path.relative(options.root, file)), context.digest(file)]);
128
135
  for (const file of ["package-lock.json", "bun.lock", "bun.lockb", "pnpm-lock.yaml", "yarn.lock", "node_modules/.package-lock.json"]) rows.push([file, existsSync(path.join(options.root, file)) ? context.digest(path.join(options.root, file)) : null]);
129
136
  rows.push(["profile", JSON.stringify(options.config.mcp.behaviorProfiles[check.profile])], ["runtime", JSON.stringify(developmentRuntime())]);
@@ -172,6 +179,20 @@ export function affectedBehaviorUnits(options, changedFiles) {
172
179
  return contracts.filter(contract => Object.values(contract.checks).some(check => behaviorInputs(options, contract, check, context).files.some(file => changed.has(file)))).map(contract => contract.unit);
173
180
  }
174
181
 
182
+ /**
183
+ * Scenarios whose rendering a change can affect: those owned by a changed unit and those whose
184
+ * import closure (scenario file, its fixture/component imports, CSS and local assets) reaches a
185
+ * changed file. Shared configuration, foundation and token inputs are not traced here; callers
186
+ * treat changes to them as affecting every scenario.
187
+ */
188
+ export function affectedScenarios(options, changedFiles, scenarios = inspectScenarios(options).scenarios) {
189
+ const changed = new Set(changedFiles.map(file => slash(path.relative(options.root, path.resolve(options.root, file)))));
190
+ const context = inputContext(options), inventory = context.inventory;
191
+ const owners = new Set([...changed].map(file => inventory.owner(inventory.relative(file))).filter(Boolean));
192
+ return scenarios.filter(scenario => owners.has(inventory.owner(inventory.relative(scenario.file)))
193
+ || [...inputClosure(options, context, [path.join(options.root, scenario.file)])].some(file => changed.has(slash(path.relative(options.root, file))))).map(scenario => scenario.id);
194
+ }
195
+
175
196
  export function executeDevelopmentCommand(profile, args, root, env, signal) {
176
197
  return new Promise((resolve, reject) => {
177
198
  const label = profile.label ?? "Behavior verification";
package/docs/CHANGELOG.md CHANGED
@@ -1,34 +1,73 @@
1
1
  # Changelog
2
2
 
3
- ## 0.3.47
3
+ ## 0.3.49
4
4
 
5
5
  <!-- ads-local-tests:start -->
6
- Local verification: **703/703 passed** with `ADS_TEST_BUN=1 npm test`.
7
- Tested commit: `193a00129755b847a3b8cbdf54360828b2b5c9e3`; Node v24.13.0, Bun 1.4.1.
8
- Completed 2026-10-30T22:07:04.485Z (1059 seconds).
6
+ Local verification: **712/712 passed** with `ADS_TEST_BUN=1 npm test`.
7
+ Tested commit: `c199b06fd9762cd7f3e8d05a6fe5058d1388f756`; Node v24.13.0, Bun 1.4.1.
8
+ Completed 2026-10-31T13:25:26.100Z (1140 seconds).
9
9
 
10
10
  <!-- ads-local-test-proof
11
11
  {
12
12
  "schema": 1,
13
- "version": "0.3.47",
14
- "commit": "193a00129755b847a3b8cbdf54360828b2b5c9e3",
15
- "sourceSha256": "3d1e3ecff8be39ae212932e0d5e8060128b923b9b1c2c8ba6cbaf466d54e51f7",
13
+ "version": "0.3.49",
14
+ "commit": "c199b06fd9762cd7f3e8d05a6fe5058d1388f756",
15
+ "sourceSha256": "c4652f12ffca20ad8601857818923564305c0c805f9965d149d38682a858af10",
16
16
  "command": "ADS_TEST_BUN=1 npm test",
17
17
  "result": "pass",
18
- "tests": 703,
19
- "pass": 703,
18
+ "tests": 712,
19
+ "pass": 712,
20
20
  "fail": 0,
21
21
  "cancelled": 0,
22
22
  "skipped": 0,
23
23
  "node": "v24.13.0",
24
24
  "bun": "1.4.1",
25
- "completedAt": "2026-10-30T22:07:04.485Z",
26
- "durationMs": 1059305,
27
- "logSha256": "27baeaadeec20d80ff0aabbe9fbe3153158ef3ddfd45fe3e5dfed73f05a575db"
25
+ "completedAt": "2026-10-31T13:25:26.100Z",
26
+ "durationMs": 1140159,
27
+ "logSha256": "26b47125ed0f4cfdff35c87187f5ad40c9af5a231b06654cb466719a7eb19ce7"
28
28
  }
29
29
  -->
30
30
  <!-- ads-local-tests:end -->
31
31
 
32
+ - **`token-contrast` checks every CSS color syntax.** It used to read only hex, `rgb()` and
33
+ `hsl()` and skipped every other value without a word, so projects whose ramps are `oklch()`
34
+ got no static contrast checking. It now resolves each pair the way the generated palette
35
+ (`themes.generated.ts`) does, through one shared resolver: per-theme halves, aliases and
36
+ `var()` fallbacks, `light-dark()` by the theme's scheme, named colors, `rgb()`/`hsl()`/`hwb()`,
37
+ `lab()`/`lch()`/`oklab()`/`oklch()`, `color()` spaces and `color-mix()`, clipped to sRGB as a
38
+ canvas draws it, in every theme of every brand. Projects with such ramps can see new
39
+ `token-contrast` errors; fix each by choosing another ramp step for the role in the theme the
40
+ message names.
41
+ - **Alpha is composited as the page paints it.** A translucent background is composited over
42
+ `--bg-canvas` (the canvas itself over white), then a translucent foreground over that
43
+ background, and the ratio is taken between the opaque results.
44
+ - **Unresolvable pair colors are reported.** A pair color ADS cannot resolve statically
45
+ (`currentColor`, relative color syntax, a system color, a value that is not a color) is a
46
+ `token-contrast-unresolved` info item naming the token, its value, the themes and brands,
47
+ and the pairs that go unchecked, instead of being skipped.
48
+
49
+ ## 0.3.48
50
+
51
+ - **MCP acceptance runs the browser accessibility audit.** When the acceptance policy sets
52
+ `browserAudit: true`, `ads_accept`, `ads_apply_patch` and `ads_apply_transaction` run the
53
+ axe-core audit on the candidate before writing any source, in every declared brand and
54
+ theme. It audits only the UI scenarios the change can reach: those owned by a changed
55
+ unit and those whose import closure includes a changed file (the `@ds` barrel narrows to
56
+ the imported names when the project declares `sideEffects`). Configuration, foundation,
57
+ token and asset changes audit every UI scenario. The audit renders on the candidate
58
+ preview host that behavior checks or captures already built, or on a candidate host that
59
+ compiles only the selected scenarios. Any `a11y-axe` error rejects the change: nothing is
60
+ written, the result is `ok:false`, findings are in `diagnostics` (as in validation), and
61
+ the `browser-accessibility-audit` check records counts, scenarios, themes, brands, the
62
+ audited scenario IDs, the selection mode and `elapsedMs`. An audit that cannot run (no
63
+ project Playwright or browser) rejects acceptance with a `browser-audit` diagnostic.
64
+ Without `browserAudit`, acceptance is unchanged and starts no browser.
65
+ - The audit renders up to four scenario pages at once per theme.
66
+ - The Icons tab reserves the alias line on every glyph card, so the grids line up; a long
67
+ alias list is truncated with the full list as its tooltip.
68
+
69
+ ## 0.3.47
70
+
32
71
  - **Findings are errors, review items or info items.** Errors fail `ads check`,
33
72
  validation and acceptance; review items (`atomic-composition-review`, `token-overlap-review`,
34
73
  `pointer-capture-review`, `scenario-exercise-review`, `a11y-keyboard`, `brand-unused`,
package/docs/GUIDE.md CHANGED
@@ -444,7 +444,9 @@ can run `ads validate --policy acceptance`; ordinary `ads validate` selects the
444
444
  validation policy. See [policy guidance](../skills/ads-designer/references/validation.md).
445
445
  When the acceptance policy requires affected registered behavior checks (or
446
446
  a capture was requested), ADS builds and shares production previews with browser
447
- verification. Core-only acceptance does not build the whole graph. Remove `build:mcp-previews`
447
+ verification. `acceptance.browserAudit` renders the candidate's affected UI scenarios
448
+ for the axe-core audit on that host, or compiles only those scenarios when nothing
449
+ else needs previews. Core-only acceptance does not build the whole graph. Remove `build:mcp-previews`
448
450
  from `acceptance.checks`; keep that script in the ordinary project build.
449
451
  See the [editing contract](MCP.md#guarded-editing) for unit ownership,
450
452
  Git patches, bounded reads and preview review. Keep normal build gates enabled
@@ -753,7 +755,9 @@ and composition scenario, once per declared brand and theme (`--scenario`, `--th
753
755
  `--brand` narrow it). Each violation is an `a11y-axe` error naming the axe rule, WCAG
754
756
  criterion, themes and brands, failing elements and help link, and `ads audit` exits 1. It
755
757
  needs the project's Playwright and browser, as captures do; `browserAudit: true` in a
756
- validation or acceptance policy runs it there too.
758
+ validation or acceptance policy runs it there too. With `acceptance.browserAudit`, MCP
759
+ draft acceptance and guarded patches audit the candidate's affected scenarios before
760
+ writing source, and an `a11y-axe` error rejects the change.
757
761
  `ads tokens --format dtcg` exports the tokens as W3C Design Tokens JSON for design tools
758
762
  (`--theme <name>` and `--brand <name>` select one context).
759
763
 
package/docs/MCP.md CHANGED
@@ -96,7 +96,9 @@ is explicitly `previewOnly`, not behavioral or acceptance evidence.
96
96
 
97
97
  `ads_accept({id,revision})` validates and applies the exact reviewed revision in
98
98
  one operation. Architecture, configured project commands and affected
99
- behavior checks remain mandatory. Edits during checking and baseline conflicts
99
+ behavior checks remain mandatory. When `acceptance.browserAudit` is true, axe-core
100
+ also renders the candidate's affected UI scenarios in every declared brand and
101
+ theme; any `a11y-axe` error rejects acceptance. Edits during checking and baseline conflicts
100
102
  prevent application; failures retain the draft and return execution evidence.
101
103
  Successful acceptance removes draft source, records an event and resolves draft
102
104
  dependencies in remaining proposals. Accept dependencies first and review their
@@ -673,7 +675,8 @@ using the client's local file tools, then call
673
675
  freshness and owner paths and returns a `patchFile`; it changes no live source.
674
676
  Pass that `patchFile` to `ads_apply_patch` with `dryRun:true` to validate before
675
677
  applying. This runs the normal candidate gates, including affected registered
676
- behavior checks against an isolated candidate and its configured browser preview.
678
+ behavior checks against an isolated candidate and its configured browser preview
679
+ and, when `acceptance.browserAudit` is true, the candidate accessibility audit.
677
680
  It writes no live source and does not persist passing evidence for live inputs.
678
681
  Read the summary, then use its `resultId` with `ads_results` for failing
679
682
  `outcomes`, `diagnostics` or named pipeline `checks`; update the draft, diff again
@@ -706,8 +709,9 @@ For a coupled rename or upgrade, call `ads_apply_transaction`:
706
709
  It accepts 2–64 distinct owners, at most 256 distinct files and 16 MiB of combined
707
710
  Git diff text. Each patch obeys its own ownership/companion rules. Patches apply
708
711
  in order inside one candidate; shared-entry hunks in a later patch must match
709
- the earlier candidate's content. Core checks, configured project commands
710
- and all affected behavior checks run against the final candidate. No intermediate
712
+ the earlier candidate's content. Core checks, configured project commands,
713
+ all affected behavior checks and, when `acceptance.browserAudit` is true, the
714
+ accessibility audit run against the final candidate. No intermediate
711
715
  candidate is published. Dry runs, failures, conflicts and cancellation write no
712
716
  source; a publication failure rolls back prior writes. This coordinates owned
713
717
  source migrations, not dependency installation or arbitrary application files.
@@ -1421,7 +1425,13 @@ Validation and acceptance keep separate baselines; acceptance cannot establish
1421
1425
  full validation. Each policy chooses `checks`, `behaviorChecks` and `browserAudit` (the
1422
1426
  axe-core audit of every UI scenario in every brand and theme; its `a11y-axe` findings are
1423
1427
  errors); skipped tests are reported as skipped, without a passing label. Draft preview/edit triggers
1424
- neither policy. Explicit `ads_verify` remains independent of gating choices. The MCP tool
1428
+ neither policy. Draft acceptance, `ads_apply_patch` and `ads_apply_transaction` run
1429
+ the acceptance policy on their candidate: with `acceptance.browserAudit` they audit
1430
+ the candidate's affected UI scenarios (all of them after configuration, foundation,
1431
+ token or asset changes) before writing source. Any `a11y-axe` error, or an audit that
1432
+ cannot run (`browser-audit`), rejects the change; findings are in `diagnostics` and the
1433
+ `browser-accessibility-audit` check lists the audited scenarios, themes, brands and
1434
+ timing. Explicit `ads_verify` remains independent of gating choices. The MCP tool
1425
1435
  runs trusted configured project commands with cancellation and bounded output; it
1426
1436
  is available with source mutations disabled and writes only build/evidence output
1427
1437
  when project commands honor their checking contract. Summaries include policy, scope,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@reqvire-org/ads",
3
- "version": "0.3.47",
3
+ "version": "0.3.49",
4
4
  "type": "module",
5
5
  "description": "A design system your agent can see and shape. Your components. Your look. Your code.",
6
6
  "repository": {