@reqvire-org/ads 0.4.2 → 0.4.4

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 (78) hide show
  1. package/README.md +11 -2
  2. package/dist/a11y.mjs +71 -65
  3. package/dist/analysis/helpers.mjs +5 -3
  4. package/dist/analysis/inputs.mjs +13 -6
  5. package/dist/analysis/module-resolvers.mjs +46 -0
  6. package/dist/analysis/service.mjs +7 -0
  7. package/dist/analysis/syntax.mjs +20 -5
  8. package/dist/assets.mjs +1 -1
  9. package/dist/boundaries.mjs +6 -4
  10. package/dist/bun-compiler.mjs +6 -5
  11. package/dist/check-service.mjs +8 -5
  12. package/dist/check.mjs +11 -46
  13. package/dist/component-contrast.mjs +126 -8
  14. package/dist/contrast-composition.mjs +80 -0
  15. package/dist/contrast-styles.mjs +88 -0
  16. package/dist/finding-rules.mjs +2 -0
  17. package/dist/font-rules.mjs +20 -15
  18. package/dist/fonts-generated.mjs +21 -14
  19. package/dist/foundation-views.mjs +6 -2
  20. package/dist/image-attributes.mjs +96 -92
  21. package/dist/mcp/build-status.mjs +8 -3
  22. package/dist/mcp/drafts.mjs +12 -5
  23. package/dist/mcp/mutations.mjs +11 -8
  24. package/dist/mcp/preview-widget.bundle.js +45 -45
  25. package/dist/mcp/resource-loader.js +1 -201
  26. package/dist/mcp/server.mjs +19 -5
  27. package/dist/pictogram-model.mjs +59 -0
  28. package/dist/pictograms.mjs +52 -0
  29. package/dist/preview-bun.mjs +76 -60
  30. package/dist/preview-incremental.mjs +358 -0
  31. package/dist/preview-manifest-update.mjs +70 -0
  32. package/dist/preview-resources.mjs +33 -1
  33. package/dist/render-audit/image-shape.mjs +13 -3
  34. package/dist/render-audit/pictograms.mjs +88 -0
  35. package/dist/render-audit/worker.mjs +12 -0
  36. package/dist/render-audit.mjs +11 -1
  37. package/dist/render-composition.mjs +186 -0
  38. package/dist/scenario-registry.mjs +2 -2
  39. package/dist/scenarios-compiler.mjs +1 -1
  40. package/dist/showcase/client.bundle.js +23 -23
  41. package/dist/showcase/draft-navigation.js +5 -5
  42. package/dist/showcase/foundation-view.css +3 -0
  43. package/dist/showcase/foundation-view.mjs +3 -0
  44. package/dist/showcase/pictogram-view.mjs +53 -0
  45. package/dist/showcase/ui/ui.js +2 -0
  46. package/dist/skills/README.md +1 -1
  47. package/dist/skills/ads-designer/SKILL.md +18 -2
  48. package/dist/skills/ads-designer/references/accessibility.md +70 -2
  49. package/dist/skills/ads-designer/references/branding.md +5 -16
  50. package/dist/skills/ads-designer/references/performance.md +3 -2
  51. package/dist/skills/ads-designer/references/pictograms.md +131 -0
  52. package/dist/skills/ads-designer/references/runtimes.md +15 -0
  53. package/dist/skills/ads-import/references/runtimes.md +15 -0
  54. package/dist/skills/ads-migrate/SKILL.md +2 -1
  55. package/dist/skills/ads-migrate/references/0.4.1-to-0.4.2.md +2 -3
  56. package/dist/skills/ads-migrate/references/0.4.3-to-0.4.4.md +80 -0
  57. package/dist/skills/ads-port/SKILL.md +4 -1
  58. package/dist/skills/ads-port/references/runtimes.md +15 -0
  59. package/dist/source-values.mjs +4 -1
  60. package/dist/starters/react/design-system/assets/pictograms/catalog.ads.json +13 -0
  61. package/dist/starters/react/design-system/assets/pictograms/journey.dark.svg +7 -0
  62. package/dist/starters/react/design-system/assets/pictograms/journey.svg +7 -0
  63. package/dist/starters/react/design-system/components/Content/Pictogram/Pictogram.ads.exports.ts +1 -0
  64. package/dist/starters/react/design-system/components/Content/Pictogram/Pictogram.ads.fixture.ts +1 -0
  65. package/dist/starters/react/design-system/components/Content/Pictogram/Pictogram.ads.scenario.tsx +7 -0
  66. package/dist/starters/react/design-system/components/Content/Pictogram/Pictogram.tsx +26 -0
  67. package/dist/style-token-rules.mjs +51 -0
  68. package/dist/task-cache.mjs +2 -2
  69. package/dist/units.mjs +4 -4
  70. package/dist/validation-inputs.mjs +7 -3
  71. package/docs/ADS.md +6 -1
  72. package/docs/ARCHITECTURE.md +144 -16
  73. package/docs/CACHING.md +65 -1
  74. package/docs/CHANGELOG.md +86 -50
  75. package/docs/GUIDE.md +52 -7
  76. package/docs/MCP.md +47 -16
  77. package/docs/benchmarks/README.md +1 -1
  78. package/package.json +7 -4
@@ -111,7 +111,10 @@ part of the port; do not ask permission for each token substitution. Preserve
111
111
  promised interaction contracts and document changes that affect behavior. If
112
112
  exact upstream fidelity is explicitly required and conflicts with project policy,
113
113
  explain the conflict and resolve that requirement before adding duplicate roles
114
- or changing policy. Do not silently copy upstream defects or change a promised
114
+ or changing policy. A reference color that fails ADS contrast is such a conflict:
115
+ offer the options in `ads://guides/accessibility` ("When a required color cannot reach
116
+ contrast": other text color, large text at 3:1, nearest passing color) with measured
117
+ ratios. Do not silently copy upstream defects or change a promised
115
118
  timer, focus, gesture or placement contract merely to simplify implementation.
116
119
 
117
120
  ## Implement and integrate
@@ -152,6 +152,21 @@ ADS resolves the public alias, extracts Linaria using the shared atomic tag
152
152
  resolver, and registers compiled modules, CSS, fonts, images and workers as
153
153
  immutable MCP resources. The selected ADS framework controls JSX compilation.
154
154
 
155
+ In ADS 0.4.4, watched previews use a private incremental module graph; complete
156
+ Bun builds remain the path for `ads compile` and production-mode verification.
157
+ This is internal tooling. Do not add a project Vite server, preview plugin or
158
+ new compiler process to enable it. Compatible React/Preact edits update the
159
+ existing isolated iframe and can preserve state, focus and selection. Incompatible
160
+ updates, changed hook signatures or rejected-revision recovery can reset state.
161
+ Preview-local state is not a persistence contract or verification evidence.
162
+
163
+ The preview UI reuses bounded, scope-specific manifest revisions and asks for
164
+ changed records internally. Tool results remain graph references. Full-resource
165
+ reads and older-server fallback remain supported. Restart the project's ADS
166
+ runtime and reconnect after upgrading; changing an installed package does not
167
+ replace the running compiler. HTTP asset delivery is a separate, unreleased
168
+ experiment and is not required for these improvements.
169
+
155
170
  `ads compile .` builds all production previews for project builds or CI.
156
171
  `ads compile . --watch` runs the same source scheduler continuously.
157
172
  Programmatic project setup can call `compilePreviews` from
@@ -307,7 +307,10 @@ export function createSourceValues(program, options, { preserveCall = () => fals
307
307
  if (key.kind === "literal") {
308
308
  const selected = await get(object, String(key.value), next(context));
309
309
  const owner = await declaration(node);
310
- if (selected.kind === "unknown" && owner && owned(owner)) {
310
+ // A property symbol identifies its original declaration, not the value
311
+ // after mutation, an accessor or an opaque override. Preserve that lack
312
+ // of proof instead of recovering the declaration's stale initializer.
313
+ if (selected.kind === "unknown" && !(strict && selected.reason) && owner && owned(owner)) {
311
314
  if (isFunction(owner)) return reference(owner, env, via);
312
315
  if (ts.isVariableDeclaration(owner) && owner.initializer && owner.parent.flags & ts.NodeFlags.Const)
313
316
  return resolve(reference(owner.initializer, env, via), next(context));
@@ -0,0 +1,13 @@
1
+ {
2
+ "schemaVersion": 1,
3
+ "pictograms": [
4
+ {
5
+ "id": "journey",
6
+ "title": "Journey",
7
+ "description": "A route connecting three destinations. Use for onboarding or an empty journey list; decorative beside equivalent text.",
8
+ "license": "Original ADS starter artwork, MIT",
9
+ "schemes": { "light": "journey.svg", "dark": "journey.dark.svg" },
10
+ "minHeight": 48
11
+ }
12
+ ]
13
+ }
@@ -0,0 +1,7 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 96 64">
2
+ <defs><linearGradient id="route" x1="12" y1="48" x2="84" y2="16" gradientUnits="userSpaceOnUse"><stop stop-color="#83beff"/><stop offset="1" stop-color="#e0a6fa"/></linearGradient></defs>
3
+ <path d="M12 48h20c9 0 8-32 20-32h32" fill="none" stroke="url(#route)" stroke-width="5" stroke-linecap="round"/>
4
+ <circle cx="12" cy="48" r="7" fill="#83beff"/>
5
+ <circle cx="48" cy="28" r="7" fill="#f9bd58" stroke="#ffe5b6" stroke-width="2"/>
6
+ <path d="m84 7 9 9-9 9-9-9z" fill="#e0a6fa"/>
7
+ </svg>
@@ -0,0 +1,7 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 96 64">
2
+ <defs><linearGradient id="route" x1="12" y1="48" x2="84" y2="16" gradientUnits="userSpaceOnUse"><stop stop-color="#216ac4"/><stop offset="1" stop-color="#9954b8"/></linearGradient></defs>
3
+ <path d="M12 48h20c9 0 8-32 20-32h32" fill="none" stroke="url(#route)" stroke-width="5" stroke-linecap="round"/>
4
+ <circle cx="12" cy="48" r="7" fill="#216ac4"/>
5
+ <circle cx="48" cy="28" r="7" fill="#f9bd58" stroke="#553b19" stroke-width="2"/>
6
+ <path d="m84 7 9 9-9 9-9-9z" fill="#9954b8"/>
7
+ </svg>
@@ -0,0 +1 @@
1
+ export { Pictogram, type PictogramProps } from "./Pictogram";
@@ -0,0 +1 @@
1
+ export const fixture = { title: "Pictogram", label: "A journey connecting three destinations" } as const;
@@ -0,0 +1,7 @@
1
+ import { Pictogram } from "@ds";
2
+ import { DemoFrame } from "@ds/review";
3
+ import { fixture } from "./Pictogram.ads.fixture";
4
+ export const scenario = { title: fixture.title, covers: ["Pictogram"] };
5
+ export default function Scenario() {
6
+ return <DemoFrame><Pictogram label={fixture.label} size="small" /><Pictogram label={fixture.label} /><Pictogram label={fixture.label} size="large" /></DemoFrame>;
7
+ }
@@ -0,0 +1,26 @@
1
+ import { css, cx } from "@linaria/atomic";
2
+ import journey from "../../../assets/pictograms/journey.svg";
3
+ import journeyDark from "../../../assets/pictograms/journey.dark.svg";
4
+
5
+ export interface PictogramProps {
6
+ /** Omit when adjacent text already conveys the same meaning. */
7
+ label?: string;
8
+ size?: "small" | "medium" | "large";
9
+ }
10
+ const base = css`display: inline-flex;`;
11
+ const sizes = {
12
+ small: css`height: var(--space-24);`,
13
+ medium: css`height: var(--space-32);`,
14
+ large: css`height: var(--space-48);`,
15
+ };
16
+ const image = css`height: 100%; width: auto; object-fit: contain;`;
17
+ const light = css`display: var(--display-light, block);`;
18
+ const dark = css`display: var(--display-dark, block);`;
19
+
20
+ /** Project-owned illustration; theme switches work without an ADS runtime. */
21
+ export function Pictogram({ label, size = "medium" }: PictogramProps) {
22
+ return <span className={cx("ds-pictogram", base, sizes[size])} role={label ? "img" : undefined} aria-label={label} aria-hidden={label ? undefined : true}>
23
+ <img data-ads-pictogram="journey" className={cx(image, light)} src={journey} width={96} height={64} loading="eager" alt="" />
24
+ <img data-ads-pictogram="journey" className={cx(image, dark)} src={journeyDark} width={96} height={64} loading="eager" alt="" />
25
+ </span>;
26
+ }
@@ -0,0 +1,51 @@
1
+ // The style-token rule: a CSS declaration's design values must come from tokens. Shared by
2
+ // `ads check` (owner, review and foundation CSS) and the consumer guard (application CSS).
3
+ import valueParser from "postcss-value-parser";
4
+ import { numericCssUnit, tokenLengthLiteral } from "./css-values.mjs";
5
+ import { isColorKeyword } from "./design-values.mjs";
6
+
7
+ /** Messages for one declaration. `review`: a development review file; `foundation`: a token sheet. */
8
+ export function styleTokenViolations(decl, { review = false, foundation = false } = {}) {
9
+ const violations = new Set();
10
+ if (decl.value.includes("__ds_expression__"))
11
+ violations.add(
12
+ "Cannot establish this interpolated design value from source. Use a source-resolvable shared token/mapping; unknown interpolation does not grant permission for private design values.",
13
+ );
14
+ valueParser(decl.value).walk((node) => {
15
+ if (node.type === "function" && node.value === "url") return false;
16
+ if (node.type === "word" && decl.prop.startsWith("--") && isColorKeyword(node.value))
17
+ violations.add("Component variables map shared Data; named colors also require shared tokens.");
18
+ if (
19
+ node.type === "word" &&
20
+ (/^#[\da-f]{3,8}$/i.test(node.value) ||
21
+ (tokenLengthLiteral(node.value) &&
22
+ !(
23
+ review &&
24
+ /^(?:(?:min-|max-)?(?:width|height|inline-size|block-size)|flex-basis|grid-template-columns|grid-template-rows)$/.test(decl.prop)
25
+ )) ||
26
+ ["s", "ms"].includes(numericCssUnit(node.value)))
27
+ )
28
+ violations.add(
29
+ "Use a token for colors, absolute/font-relative lengths (including ch), and durations. Unitless geometry and structural angle/viewport/container relationships remain valid.",
30
+ );
31
+ if (node.type === "function" && /^(?:rgb|rgba|hsl|hsla|hwb|lab|lch|oklab|oklch|color|color-mix|cubic-bezier)$/.test(node.value))
32
+ violations.add("Define color formulas and easing in tokens.");
33
+ if (node.type === "function" && /^(?:blur|brightness|contrast|drop-shadow|grayscale|hue-rotate|invert|saturate|sepia)$/.test(node.value))
34
+ violations.add("Define visual filter effects in tokens.");
35
+ if (node.type === "word" && /^ease(?:-in|-out|-in-out)?$/.test(node.value)) violations.add("Use a motion token for easing.");
36
+ if (
37
+ node.type === "word" &&
38
+ /^(?:color|background-color|(?:border|outline|caret|text-decoration|column-rule)(?:-[a-z]+)?-color|fill|stroke)$/.test(decl.prop) &&
39
+ /^[a-z]+$/i.test(node.value) &&
40
+ !/^(?:inherit|initial|unset|revert|currentcolor|transparent|none)$/i.test(node.value)
41
+ )
42
+ violations.add("Use a semantic color token.");
43
+ });
44
+ if (
45
+ /^(?:font-family|font-weight|z-index)$/.test(decl.prop) &&
46
+ !/^(?:var\(|inherit$|initial$|unset$|revert(?:-layer)?$|auto$)/.test(decl.value) &&
47
+ !(foundation && decl.prop === "font-weight" && /^(?:bolder|lighter)$/.test(decl.value))
48
+ )
49
+ violations.add("Use a semantic typography or layering token.");
50
+ return violations;
51
+ }
@@ -73,13 +73,13 @@ export function architectureExternalInputs(root, trackingRoot = root) {
73
73
  };
74
74
  return { dependencies, git, environment: Object.fromEntries(semanticEnv.map((name) => [name, process.env[name] ?? null])) };
75
75
  }
76
- export async function architectureTaskInputs(root, trackingRoot = root) {
76
+ export async function architectureTaskInputs(root, trackingRoot = root, { onFile } = {}) {
77
77
  return {
78
78
  schemaVersion: 1,
79
79
  kind: "architecture",
80
80
  runtime: previewRuntimeFingerprint(),
81
81
  tool: toolInputs(),
82
- files: await validationInputFiles(loadConfig(root)),
82
+ files: await validationInputFiles(loadConfig(root), [], { onFile }),
83
83
  ...architectureExternalInputs(root, trackingRoot),
84
84
  };
85
85
  }
package/dist/units.mjs CHANGED
@@ -15,7 +15,7 @@ function fail(message, file) {
15
15
  }
16
16
 
17
17
  /** Project setup and explicitly registered ADS extension/build entrypoints. */
18
- export async function configurationFiles(options) {
18
+ export async function configurationFiles(options, resolve) {
19
19
  const { root, config, sourceRoot, dsRoot } = options;
20
20
  const files = new Set(["ds.config.json", "package.json"]);
21
21
  for (const entry of readdirSync(root, { withFileTypes: true })) {
@@ -27,8 +27,8 @@ export async function configurationFiles(options) {
27
27
  )
28
28
  files.add(entry.name);
29
29
  }
30
- const resolve = await importResolver(options),
31
- visited = new Set();
30
+ resolve ??= await importResolver(options);
31
+ const visited = new Set();
32
32
  async function visit(file, entrypoint = false, typeConfig = false) {
33
33
  if (!isInside(root, file) || file === root || /(?:^|[\\/])(?:node_modules|\.git|\.ds|dist)(?:[\\/]|$)/.test(path.relative(root, file)) || visited.has(file))
34
34
  return;
@@ -258,7 +258,7 @@ async function discoverUnits(options) {
258
258
  }
259
259
  const units = new Map();
260
260
  units.set("configuration", { id: "configuration", kind: "configuration", files: [...setup].filter((file) => existsSync(path.join(root, file))).sort() });
261
- for (const id of ["foundation", "documentation", "tokens", "assets/brand", "assets/fonts"]) units.set(id, { id, kind: id.split("/")[0], files: [] });
261
+ for (const id of ["foundation", "documentation", "tokens", "assets/brand", "assets/fonts", "assets/pictograms"]) units.set(id, { id, kind: id.split("/")[0], files: [] });
262
262
  units.get("documentation").files = projectDocumentFiles(root).filter(
263
263
  (file) => owner(slash(path.relative(dsRoot, path.resolve(root, file)))) === "documentation",
264
264
  );
@@ -2,7 +2,7 @@ import { walkAsync, walkValuesAsync } from "./analysis/queries.mjs";
2
2
  import { createHash } from "node:crypto";
3
3
  import { existsSync, lstatSync, readFileSync, readdirSync, realpathSync } from "node:fs";
4
4
  import path from "node:path";
5
- import ts from "./analysis/syntax.mjs";
5
+ import ts, { withModuleResolutionScope } from "./analysis/syntax.mjs";
6
6
  import postcss from "postcss";
7
7
  import valueParser from "postcss-value-parser";
8
8
  import { defaultConfig, fixedLayout, isInside, isTestFile } from "./config.mjs";
@@ -10,6 +10,7 @@ import { importResolver } from "./boundaries.mjs";
10
10
  import { configurationFiles } from "./units.mjs";
11
11
  import { createPreviewFileFilter } from "./preview-files.mjs";
12
12
  import { projectNoticeFiles } from "./project-documents.mjs";
13
+ import timing from "./stage-timing.cjs";
13
14
 
14
15
  const digest = (file) => `sha256:${createHash("sha256").update(readFileSync(file)).digest("hex")}`;
15
16
  const ignored = new Set(["output", "test-results", "playwright-report", ".playwright-cli"]);
@@ -54,7 +55,10 @@ async function references(file, content, revision) {
54
55
  }
55
56
 
56
57
  /** Mandatory UI/guard inputs, real local dependencies and declared opaque inputs. */
57
- export async function validationInputFiles(options, extraFiles = [], { maxFiles = Infinity, maxBytes = Infinity, onFile } = {}) {
58
+ export function validationInputFiles(options, extraFiles = [], limits = {}) {
59
+ return timing.timeStage("input-capture", () => withModuleResolutionScope(() => captureInputs(options, extraFiles, limits)));
60
+ }
61
+ async function captureInputs(options, extraFiles, { maxFiles = Infinity, maxBytes = Infinity, onFile }) {
58
62
  const supplied = options.config;
59
63
  const normalized = {
60
64
  ...defaultConfig,
@@ -212,7 +216,7 @@ export async function validationInputFiles(options, extraFiles = [], { maxFiles
212
216
  options.dsRoot,
213
217
  options.sourceRoot,
214
218
  ...config.assets.publicDirs.map((file) => path.resolve(root, file)),
215
- ...(await configurationFiles(options)),
219
+ ...(await configurationFiles(options, resolve)),
216
220
  ].map((file) => path.resolve(root, file)))
217
221
  await visit(file);
218
222
  for (const file of projectNoticeFiles(root)) await visit(path.resolve(root, file));
package/docs/ADS.md CHANGED
@@ -285,7 +285,10 @@ stylesheet dependencies are injected into preview entries.
285
285
  screen, in every theme and brand, through aliases) and `token-rhythm` (`--space-N` = N × 2
286
286
  px) are errors; `token-overlap-review` (equal values within one token family) is a review
287
287
  item. The accessibility guards (`a11y-*`) read tokens and runtime component source;
288
- `component-contrast` checks the color pairs components set themselves, and
288
+ `component-contrast` checks declared color pairs and text/background relationships proved
289
+ through owned JSX composition, including backgrounds supplied by another component.
290
+ It needs 4.5:1, or 3:1 for a source-resolved large-text size; incomplete composition is an
291
+ informational finding requiring a rendered audit. No custom contrast-pair registration is needed, and
289
292
  `layout-fixed-width` rejects fixed minima without a supported sizing role or beyond the spatial bound. `ads audit` adds axe-core
290
293
  in the rendered scenarios (`a11y-axe`), non-text contrast (`a11y-non-text-contrast`) and
291
294
  overflow at 390, 768 and 1280 px and in a 240 px container (`layout-overflow`). `ads tokens
@@ -586,3 +589,5 @@ The repository playground initializes the shipped Preact starter under ignored
586
589
  Edit `starters/shared/` for design changes and restart the playground to regenerate
587
590
  its source snapshot. Native mount adapters live under `starters/react/` and
588
591
  `starters/preact/`; framework import/config differences are generated during packing.
592
+
593
+ Pictograms are a separate illustrative asset category in `assets/pictograms/`, with a project-owned `catalog.ads.json`, explicit theme variants and dedicated showcase views. Fixed colors and gradients are allowed. Source checks validate the catalogue and SVG geometry; the render audit checks identified images against their declared theme, minimum height, aspect ratio and text alternative. See [Pictograms](../skills/ads-designer/references/pictograms.md) for the exact contract and limits.
@@ -83,9 +83,35 @@ acceptance stages and retain their own source-freshness requirements.
83
83
  Rules must use `analysis/helpers.mjs` for `sourceAst`, `sourceText`, `symbolAt`,
84
84
  `valueSymbolAt`, `localValueDeclarations`, `walk`, `findNode`, `nodesOfKind`, `memoFact` and `memoProgram`. Program acquisition
85
85
  goes through `cachedProgram`; import resolution goes through `importResolver`.
86
+ With fixed compiler options, import resolution shares normalized specifiers by
87
+ importing directory, including pending queries from sibling files. Its cache
88
+ belongs to the current inventory/request; a new capture resolves against current
89
+ package/configuration bytes and cannot inherit an earlier resolution by path alone.
90
+ Input capture shares compiler options and the import resolver with configuration
91
+ discovery. `analysis/module-resolvers.mjs` owns native resolver leases for that
92
+ capture, including pending queries; cleanup drains them on success or failure.
93
+ The syntax client stays alive until the capture releases its leases. No resolver
94
+ that observes the live filesystem survives into the next capture.
95
+ Warm checks collect compiler source bytes while computing the task input key and
96
+ pass them through `analyzeCaptured`; registered draft branches remain authoritative.
97
+ The independent post-check input capture still verifies freshness before caching
98
+ the report. Draft preparation similarly shares one inventory between inspection
99
+ and workspace population, retaining its targeted live conflict/path checks.
100
+ `render-composition.mjs` reuses the captured native program and `createSourceValues`
101
+ for owned JSX, component calls, props and classes. Its pending/completed graph is weakly
102
+ memoized by immutable program, so sibling drafts and edited imports do not share mutable
103
+ render facts. It does not execute project code or open another compiler. The contrast
104
+ adapter consumes the CSS trees already parsed by the check, resolves ancestor backdrops
105
+ and caches identical token-pair calculations within the check. It reports incomplete
106
+ cascade/branch evidence explicitly; browser axe audits retain dynamic rendering coverage.
107
+ Class choices stay factored in the immutable render graph. The contrast adapter compares
108
+ all alternatives' paint facts without enumerating their Cartesian product; layout-only
109
+ choices can retain a known ancestor backdrop. Captured selector targets distinguish inert
110
+ class hooks from possible paint overrides. Native type queries identify string/number
111
+ text slots without treating arbitrary React/Preact children as plain text.
86
112
  Optional inputs and immediate directory membership use `optionalSourceText` and
87
113
  `sourceDirectoryFiles`; both observe the captured revision, including absence.
88
- `sourceCss` shares read-only PostCSS trees within a request; transforms clone
114
+ `sourceCss` shares read-only PostCSS trees across requests on the same captured revision; transforms clone
89
115
  before modifying them. Spatial guards and foundation discovery use
90
116
  `spatial.mjs` over these helpers. The pure `spatial-model.cjs` compiler does no
91
117
  filesystem I/O. `spatial-inputs.cjs` retains a bounded cache of immutable models
@@ -106,6 +132,15 @@ The spatial design and starter defaults draw on IBM Carbon's 2x Grid. The
106
132
  source revision, and attribution boundaries. ADS's compiler and analysis services
107
133
  are separate from Carbon's Sass/React grid packages; consumers own their definitions.
108
134
 
135
+ File-local accessibility and image-attribute checks consume the main check's source
136
+ inventory and captured native ASTs. Their findings are memoized by immutable source
137
+ tree; they create no separate syntax parser or filesystem scan. Font checking and
138
+ preload generation share captured CSS trees and parsed face facts. Token values,
139
+ current preload configuration and actual style uses are evaluated separately on
140
+ each operation, so changing a consumer or theme cannot reuse an unrelated result.
141
+ Optional text (including absence) and CSS trees have weak captured-revision ownership;
142
+ new revisions invalidate them, while repeated reads on the same revision share data.
143
+
109
144
  Do not create compiler programs, native clients, path-keyed semantic caches or
110
145
  independent AST parsers in new rules. `memoFact` lives for one fenced request;
111
146
  `memoProgram` is only for facts determined by an immutable program/tree or captured
@@ -496,6 +531,14 @@ Project JavaScript, styles, fonts and UI run only inside that App; the outer
496
531
  shell forwards resource bytes without applying project styles or executing its
497
532
  runtime. This keeps the host neutral while compositions retain their full skin.
498
533
 
534
+ Alternative HTTP preview asset delivery is deferred and excluded from this
535
+ release. Its bounded local proof improved first display, but showed no meaningful
536
+ verified-edit or acceptance gain and no clear process-memory improvement. Frame
537
+ cleanup needed an additional lifetime connection; broader framework, worker/Wasm,
538
+ resource-limit and capture/evidence coverage remains unfinished. External MCP
539
+ Apps still require the existing adapter. The released path therefore keeps MCP
540
+ resource delivery, with persistent-frame updates and bounded manifest reuse/deltas.
541
+
499
542
  The ADS host gives inline App documents an `about:srcdoc` base when the App
500
543
  provides no explicit base URL. Fragment links then stay inside their own document
501
544
  with native scrolling, history and events. The sandbox permits this local base;
@@ -647,14 +690,55 @@ no API visibility, render coverage, styling permission or runtime behavior.
647
690
 
648
691
  ### Incremental compilation and refresh
649
692
 
650
- `runScenarioCompiler` owns scheduling, validation, freshness and publication.
651
- ADS owns preview compilation with Bun, using the project's declared React or
652
- Preact framework and shared Linaria extraction. The application keeps its own
653
- production bundler. A single scheduler warms views sequentially with foreground
654
- priority, retains compiled output, and reuses per-file transforms and worker
655
- bundles. Native ADS gates run directly; project lint/build/test commands remain
656
- explicit integration checks. Explorer navigation and metadata are served
657
- independently of compilation and validation.
693
+ `runScenarioCompiler` remains the single scheduler for live feedback, source
694
+ validation, discovery, freshness and verified publication. Watched previews use
695
+ `createIncrementalPreviewBuilder`: a private Vite module graph with the same ADS
696
+ Linaria extraction, import optimization, spatial metadata and source identities
697
+ as complete builds. React Refresh and native Prefresh supply component signatures
698
+ and replacement. This is preview compilation, not a second analysis engine.
699
+ Unwatched builds and acceptance preparation retain the complete Bun builder.
700
+ The application retains its own production bundler.
701
+
702
+ Vite runs in middleware mode without a listening server, filesystem routes or
703
+ browser websocket. The builder snapshots transformed modules, CSS, local assets,
704
+ literal lazy imports and self-contained Bun worker output into the existing
705
+ immutable `ads://assets/…` graph. Module reads never compile live filesystem
706
+ contents. The existing scheduler fences the source revision before publishing;
707
+ project and draft roots own separate compiler sessions. The shared analysis
708
+ service continues to supply discovery and checking.
709
+
710
+ Watched manifests add optional `refresh: {version: 1, epoch}` and module metadata
711
+ `hot: {id, source}`. The ID is stable within that compiler session; `source` hashes
712
+ the lowered module before immutable dependency URI rewriting. This lets the
713
+ loader distinguish changed code from a changed dependency address. A bounded
714
+ rewrite cache avoids reparsing unchanged compiler output while still observing
715
+ output membership and worker content changes.
716
+
717
+ The existing sandboxed iframe remains alive for compatible updates. Its resource
718
+ loader evaluates changed framework boundaries, updates styles, and preserves
719
+ component state, input values, focus and selection where the framework permits.
720
+ It tracks already executed lazy modules and visited views too; unopened lazy
721
+ branches remain unloaded. Navigation still mounts the selected scenario normally.
722
+ Changed hook signatures follow the framework's reset semantics. Removed or
723
+ incompatible exports, compiler/configuration epoch changes, interrupted refresh,
724
+ and restoration of an already evaluated old revision require a clean frame.
725
+ A failed source check restores the last verified output and remains a failure;
726
+ state retention is never a substitute for validation or acceptance.
727
+
728
+ The internal graph is renewed when configuration/dependency manifests or the
729
+ captured original inputs of optimized dependencies change, on source-directory
730
+ membership changes that can alter resolution, or when
731
+ its retained input/module count exceeds 4096 or retained lowered source/code
732
+ exceeds 64 MiB. Browser retained module metadata is bounded at 4096 records and
733
+ materialized resource bodies at 64 MiB, with a clean-frame reopen at the next
734
+ mount. These are retention limits, not process RSS guarantees. Owned Vite,
735
+ extraction, worker and temporary-directory lifetimes end with their builder.
736
+ See [caching](CACHING.md#preview-restoration) for the content checks.
737
+
738
+ The [preview benchmark](../scripts/benchmarks/preview/README.md) records the
739
+ integrated measurement method and results. Frame removal, the V3/source-emission
740
+ proposal and HTTP delivery remain outside this release. This integration does
741
+ not claim to fix Chromium's raw corner pixels.
658
742
 
659
743
  New preview requests share one input-stamp capture per batch. After that
660
744
  asynchronous capture, scheduling reads the current candidate, publication and
@@ -663,7 +747,7 @@ lose a requested view or reuse coverage from a retired candidate.
663
747
 
664
748
  ```mermaid
665
749
  flowchart LR
666
- Edit[Source edit] --> Compile[Compile changes with Bun]
750
+ Edit[Source edit] --> Compile[Update private module graph]
667
751
  Compile --> Validate[Validate project and inspect registry in background]
668
752
  Compile --> Live[Unverified live resources]
669
753
  Live --> App[Compare selected dependency closure]
@@ -671,8 +755,8 @@ flowchart LR
671
755
  Compile --> Publish
672
756
  Publish --> App
673
757
  Validate -->|Failure| Revert[Restore last verified view]
674
- App --> Keep[Unchanged: keep mounted view]
675
- App --> Mount[Changed: remount selected view]
758
+ App --> Keep[Compatible: refresh within persistent frame]
759
+ App --> Mount[Incompatible or rollback: clean frame]
676
760
  ```
677
761
 
678
762
  Watched compilation provides immediate visual feedback while validation and
@@ -803,9 +887,14 @@ independent of background preparation, and resource integrity checks still apply
803
887
  A successful global revision does not require remounting an unchanged selected
804
888
  view. The App compares its static module/style/asset closure, retains DOM/form/
805
889
  scroll state when that closure matches, and reruns token/paint audits against the
806
- accepted manifest. A changed selected closure remounts through the project's
807
- adapter. Native ESM resources still obey digest checks and the existing bounded
808
- revision lifecycle; this is state-preserving refresh, not component-level HMR.
890
+ accepted manifest. Watched graphs refresh compatible framework boundaries when
891
+ the selected closure changes; complete bundled graphs remount through the
892
+ project's adapter. Native ESM resources still obey digest checks and the bounded
893
+ revision lifecycle described above.
894
+ The visible preview retains its framing while replacement resources load. Kind
895
+ and subject framing change only after a successful mount; structural padding is
896
+ resolved before paint, including delayed framework commits. Font readiness and
897
+ the later audits do not temporarily restore specimen padding during reloads.
809
898
 
810
899
  Incremental compilation is separate from test selection. Preview refresh runs the
811
900
  adapter's validation callback. Draft acceptance executes the draft owners' own
@@ -986,7 +1075,8 @@ instead of asking the browser to normalize a color per drawn item.
986
1075
  ADS findings are errors, review items or info items. An error is a rule ADS can decide: it
987
1076
  fails `ads check`, validation and acceptance, and no setting turns it off. Token, theme, brand,
988
1077
  glyph and accessibility rules read from tokens and source are errors: contrast between the
989
- roles that meet on screen and the color pairs components set themselves, in every theme and
1078
+ roles that meet on screen, declared component pairs and source-proven composed text/backdrop
1079
+ pairs, in every theme and
990
1080
  brand, the 2 px spacing rhythm, fixed widths built from spacing tokens, theme and brand
991
1081
  coverage, brand artwork that is undescribed, unlicensed or unpreviewed, glyphs off the
992
1082
  shared viewBox or with fixed colors, controls padded off their size, target size, focus,
@@ -1012,6 +1102,13 @@ image shape and horizontal overflow at 390, 768 and 1280 px, by resizing each re
1012
1102
  also narrows components and patterns to a 240 px container: a set width above the browser review threshold of 96 px
1013
1103
  that overflows it is a review item, since whether a part ever sits in a pane takes judgement.
1014
1104
 
1105
+ Audit previews retain the same subject framing and layout as showcase previews but disable
1106
+ the decorative grey surround and clipped canvas layer before mounting. The preview root
1107
+ therefore paints the project's theme/brand canvas directly, so axe and non-text contrast
1108
+ resolve the real ancestor background. Authored surfaces remain intact. Image shape uses
1109
+ untransformed CSS dimensions: explicit ratios respect `box-sizing`, while width/height
1110
+ attribute ratios compare the content box, excluding border and padding.
1111
+
1015
1112
  Each render waits, bounded, for its content to settle before anything is measured, and says so when it
1016
1113
  did not. The audit also renders what a scenario shows only after someone acts on it. It opens what
1017
1114
  `aria-haspopup` controls open, and hovers and focuses controls for contrast. Each worker lists what
@@ -1283,3 +1380,34 @@ custom outputs use `assets.generatedPaths`. Bundled binary assets are forwarded
1283
1380
  as resources: the built-in Apps sandbox permits blob reads and WebAssembly
1284
1381
  compilation without granting external network access, JavaScript eval or host
1285
1382
  DOM access. External MCP hosts retain their own CSP policy.
1383
+
1384
+ ### Pictogram ownership and evidence
1385
+
1386
+ Pictograms are project-owned illustrative SVGs in `assets/pictograms/`, separate
1387
+ from brand identity, glyphs and raster images. `catalog.ads.json` declares their
1388
+ meaning, license, minimum drawn height and exact-theme/scheme/shared source
1389
+ selection. See the [pictogram contract and examples](../skills/ads-designer/references/pictograms.md).
1390
+
1391
+ `src/pictogram-model.mjs` is the pure catalogue/XML/geometry model;
1392
+ `src/pictograms.mjs` is its captured-input adapter. Pictogram SVG text is retained during the
1393
+ existing analysis input read; unrelated image assets are not added to the source tree. The adapter shares immutable results per request
1394
+ and weakly per captured revision, including missing inputs; rules/discovery never
1395
+ fall back to disk for a missing snapshot. No TypeScript program or parser is
1396
+ created for asset metadata. The XML parser checks document structure without
1397
+ executing SVG. Artwork is embedded as image data, never injected into gallery DOM.
1398
+
1399
+ Discovery publishes tool-owned `pictograms/<id>` foundation views attached to the
1400
+ `assets/pictograms` draft owner. CLI checks, MCP discovery, validation and acceptance
1401
+ share the same diagnostics. The gallery resolves explicit theme variants, renders
1402
+ clean/actual-size samples and a separate construction-grid card. Components keep
1403
+ normal SVG imports and their own theme selection; no ADS runtime ships with them.
1404
+
1405
+ The render audit receives the registry's checked digests and geometry, without
1406
+ rereading sources. It identifies visible SVG images by digest, caches source
1407
+ identities across viewport samples, and checks the active variant, accessibility
1408
+ markup, drawn size and proportions. `data-ads-pictogram` disambiguates shared bytes
1409
+ and detects wrong source substitutions. Inline SVG/CSS backgrounds, arbitrary
1410
+ transformations, illustration meaning and optical quality remain outside this
1411
+ image guard. Assets remain shared inputs for change selection, so their edits
1412
+ widen verification to consuming UI. Browser measurements are not included in
1413
+ analysis/acceptance performance benchmarks.
package/docs/CACHING.md CHANGED
@@ -48,6 +48,8 @@ retains execution ownership, cancellation and cleanup.
48
48
  | Cache | Lifetime and invalidation |
49
49
  | --- | --- |
50
50
  | Request facts (`memoFact`) | One captured input revision/request; concurrent callers share pending work |
51
+ | Input-discovery resolvers | One input capture; shared compiler options and pending native leases, drained and disposed before returning |
52
+ | Owned JSX render relationships | Weakly owned by the immutable native program; pending graph work is shared and failed work is evicted |
51
53
  | Immutable program/tree facts (`memoProgram`) and native query results | Reused only with their owning immutable program/tree; rejected queries are evicted |
52
54
  | Native project and draft snapshots | Project session with bounded revisions/programs; source/import/configuration changes update the snapshot |
53
55
  | Relocated draft ASTs | Owned by that draft; releasing it drops the wrapper cache without changing sibling/live paths |
@@ -60,6 +62,29 @@ edits are changes. Dependency selection uses shared ASTs and before/current
60
62
  import closures; a cached parse alone cannot establish a passing check or render.
61
63
  See [analysis ownership and rule helpers](ARCHITECTURE.md#semantic-analysis).
62
64
 
65
+ Source accessibility and image-attribute checks reuse immutable native source facts.
66
+ They share the main check's inventory rather than scanning and parsing components
67
+ again. Optional source text and read-only CSS trees are cached by captured revision,
68
+ including missing files. Font rules and preload generation share the resulting CSS
69
+ and face definitions; current token values, configuration and consuming styles still
70
+ determine the result. An edited source/stylesheet, added or deleted input, or a sibling
71
+ draft receives its own revision. The cache cannot fall back to newer disk bytes.
72
+
73
+ Acceptance captures an unchanged original/candidate input scope once at each
74
+ freshness boundary; a configuration change retains both distinct scopes. Comparing
75
+ a reviewed preview's inputs is only needed when such a preview workspace exists.
76
+ Before/after validation captures and exact-byte publication checks remain required.
77
+ Browser-preview planning runs only when the accepted owners have selected behavior
78
+ checks and the project has a preview framework; an empty behavior selection needs
79
+ no additional discovery query. Render-audit planning remains independent.
80
+
81
+ A warm-check miss derives its key and compiler source bytes from one capture,
82
+ then captures again after checking. A hit still captures current inputs before
83
+ consuming the report. Draft preparation shares the inventory used in its inspected
84
+ revision with workspace population; targeted live conflict checks remain separate.
85
+ Neither optimization retains live input state across operations or removes an
86
+ acceptance/publication freshness boundary.
87
+
63
88
  ## Controls
64
89
 
65
90
  | Control | Behavior |
@@ -94,7 +119,7 @@ Only immutable archives share storage; live outputs and evidence stay isolated.
94
119
 
95
120
  ## Preview restoration
96
121
 
97
- The interactive Bun compiler keeps its incremental module/graph cache. Turbo is
122
+ The watched preview compiler keeps a private incremental module graph. Turbo is
98
123
  not launched on every edit. ADS reopens a matching complete graph without semantic
99
124
  scenario discovery or compiler startup: check cached registry/dependencies, verify
100
125
  immutable assets, match the successful guard evidence already attached to the
@@ -102,6 +127,45 @@ graph against current source/tool/runtime/Git/dependency state, fence inputs, an
102
127
  publish new session metadata. This native handoff does not invoke Turbo again. Missing, changed or corrupt artifacts fall back to compiling.
103
128
  Guard failures remain failures. Old live build evidence is never restored.
104
129
 
130
+ Each project/draft builder owns its Vite graph, lowered ADS modules, Linaria
131
+ extractions, worker bundles and resource-rewrite cache. No dev server is exposed.
132
+ Before reuse it compares recorded input **contents**, including evaluated style
133
+ imports, CSS imports inlined by PostCSS, public-barrel inputs and spatial token-sheet membership. Same size and
134
+ mtime are insufficient. Package/dependency manifests, configuration and tsconfig
135
+ changes replace the graph and its refresh epoch. Original optimized-dependency
136
+ inputs, including transitive CommonJS requires, are also content checked and
137
+ renew the graph when changed. Failed requests are not published;
138
+ restored or newly added inputs are evaluated on the next request.
139
+ Design-system directory membership and source dependency directories are observed
140
+ too. Additions/deletions renew the graph and frame: a new file can outrank an old
141
+ import resolution even when every previously imported file is unchanged.
142
+ Every preview entry loads the configured project stylesheet, including generated
143
+ Token and Brand views that do not use the project's scenario mount adapter.
144
+
145
+ The resource-rewrite cache retains one entry per current output file, keyed by
146
+ its bytes, dependency/style metadata and output membership. JavaScript worker
147
+ asset bytes participate so changing a worker into an unsupported module cannot
148
+ reuse an earlier successful rewrite. Immutable output graph hashes and the
149
+ scheduler's pre/post source fences still determine publication.
150
+
151
+ Retained graph/input count over 4096 or lowered source/code over 64 MiB renews the
152
+ compiler session on its next build. The iframe separately reopens at the next
153
+ mount if retained module metadata exceeds 4096 records or materialized bodies
154
+ exceed 64 MiB. These limits bound retained objects, not total process memory.
155
+ Closing a builder releases compiler/extraction workers and its temporary
156
+ `.ds/incremental/` directory. Complete Bun verification builds remain separate.
157
+
158
+ The App keeps up to six manifest revisions and 8 MiB of serialized graph metadata
159
+ per accepted/draft scope, sharing pending reads and discarding rejected requests.
160
+ Current build/tool status authorizes reuse; the cache itself never establishes
161
+ freshness. Live-to-verified handoff can reuse identical graph records. A changed
162
+ revision requests only differences from a known base, using the server's existing
163
+ retained graph history; unavailable history falls back to a full manifest.
164
+ Scope changes and teardown clear the cache, and late responses from an old scope
165
+ cannot populate the new one. Restarted compiler sessions require new metadata even
166
+ when graph bytes are unchanged. The original full-manifest resource remains
167
+ available to older clients, and older servers work through full-resource fallback.
168
+
105
169
  ## CI wiring
106
170
 
107
171
  Use the existing CLI and persist the artifact directory. No additional ADS cache