@reqvire-org/ads 0.5.1 → 0.5.2

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 (114) hide show
  1. package/dist/ads-errors.mjs +110 -25
  2. package/dist/analysis/composition-axes.mjs +48 -0
  3. package/dist/analysis/construction-memo.mjs +38 -0
  4. package/dist/analysis/context.mjs +19 -0
  5. package/dist/analysis/design-reads.mjs +177 -0
  6. package/dist/analysis/factored-classes.mjs +90 -0
  7. package/dist/analysis/helpers.mjs +5 -7
  8. package/dist/analysis/native-project.mjs +12 -0
  9. package/dist/analysis/owner-analysis-cache.mjs +86 -23
  10. package/dist/analysis/owner-analysis-key.mjs +42 -10
  11. package/dist/analysis/owner-choices.mjs +23 -4
  12. package/dist/analysis/owner-composition.mjs +118 -33
  13. package/dist/analysis/owner-reuse.mjs +8 -6
  14. package/dist/analysis/owner-source.mjs +253 -76
  15. package/dist/analysis/scenario-keys.mjs +10 -7
  16. package/dist/analysis/service.mjs +50 -3
  17. package/dist/analysis/standalone.mjs +7 -4
  18. package/dist/analysis/syntax.mjs +59 -1
  19. package/dist/analysis/worker-protocol.mjs +14 -2
  20. package/dist/analysis/worker.mjs +32 -10
  21. package/dist/architecture-report.mjs +26 -0
  22. package/dist/asset-view-facts.mjs +16 -2
  23. package/dist/boundaries.mjs +26 -10
  24. package/dist/bun-compiler.mjs +2 -2
  25. package/dist/check-service.mjs +29 -17
  26. package/dist/check.mjs +13 -6
  27. package/dist/cli.mjs +1 -1
  28. package/dist/composed-keyline.mjs +2 -2
  29. package/dist/config.mjs +2 -1
  30. package/dist/construction-output.mjs +3 -2
  31. package/dist/construction-spec.d.mts +111 -6
  32. package/dist/construction-spec.mjs +172 -30
  33. package/dist/corner-overpaint.mjs +16 -4
  34. package/dist/derived-states.mjs +182 -0
  35. package/dist/design-inputs.mjs +18 -3
  36. package/dist/design-system-closure.mjs +12 -7
  37. package/dist/emit/contract.mjs +24 -5
  38. package/dist/emit/emission.mjs +6 -4
  39. package/dist/emit/integrity.mjs +8 -2
  40. package/dist/emit/output-watch.mjs +120 -0
  41. package/dist/emit/owner-emission-cache.mjs +4 -4
  42. package/dist/emit/preview-emitter.mjs +4 -2
  43. package/dist/emit/preview-tree.mjs +1 -1
  44. package/dist/emit/service.mjs +8 -2
  45. package/dist/finding-rules.mjs +3 -0
  46. package/dist/form-states.mjs +8 -0
  47. package/dist/frame-regions.mjs +29 -9
  48. package/dist/hover-geometry.mjs +15 -0
  49. package/dist/input-digests.mjs +17 -10
  50. package/dist/linaria/delivery.mjs +2 -0
  51. package/dist/lowering-properties.mjs +5 -0
  52. package/dist/lowering-region-layout.mjs +7 -2
  53. package/dist/mcp/build-status.mjs +9 -1
  54. package/dist/mcp/compiler-channel.mjs +11 -4
  55. package/dist/mcp/mutations.mjs +1 -0
  56. package/dist/mcp/preview-http.bundle.js +1 -1
  57. package/dist/mcp/preview-watch.mjs +2 -1
  58. package/dist/mcp/preview-widget.bundle.js +1 -1
  59. package/dist/motion-model.mjs +1 -1
  60. package/dist/owner-analysis-check.mjs +19 -5
  61. package/dist/owner-errors.mjs +4 -2
  62. package/dist/owner-lowering.mjs +71 -12
  63. package/dist/owner-scenarios.mjs +4 -1
  64. package/dist/ownership-model.mjs +18 -4
  65. package/dist/placeholder-contrast.mjs +17 -1
  66. package/dist/platform-features.mjs +10 -1
  67. package/dist/profile-view-facts.mjs +1 -1
  68. package/dist/recipe-macro.d.mts +72 -13
  69. package/dist/recipe-model.mjs +9 -5
  70. package/dist/region-lowering.mjs +238 -40
  71. package/dist/render-audit/layout-shift.page.mjs +24 -0
  72. package/dist/render-audit/render-states.mjs +122 -1
  73. package/dist/render-audit/render-states.page.mjs +140 -0
  74. package/dist/render-audit/worker.mjs +18 -3
  75. package/dist/render-audit.mjs +114 -1
  76. package/dist/role-vocabulary.d.mts +5 -0
  77. package/dist/role-vocabulary.mjs +12 -1
  78. package/dist/scenarios-compiler.mjs +20 -6
  79. package/dist/showcase/assets-view.mjs +29 -13
  80. package/dist/showcase/client.bundle.js +32 -32
  81. package/dist/showcase/http-client.bundle.js +15 -15
  82. package/dist/showcase/ui/ui.css +1 -1
  83. package/dist/showcase/ui/ui.js +4 -4
  84. package/dist/skills/ads-designer/references/accessibility.md +7 -0
  85. package/dist/skills/ads-designer/references/branding.md +13 -3
  86. package/dist/skills/ads-designer/references/contracts.md +5 -2
  87. package/dist/skills/ads-designer/references/design-data.md +1 -1
  88. package/dist/skills/ads-designer/references/layout.md +5 -1
  89. package/dist/skills/ads-designer/references/motion.md +9 -1
  90. package/dist/skills/ads-designer/references/recipes.md +27 -3
  91. package/dist/skills/ads-import/references/contracts.md +5 -2
  92. package/dist/skills/ads-import/references/design-data.md +1 -1
  93. package/dist/skills/ads-import/references/layout.md +5 -1
  94. package/dist/skills/ads-import/references/recipes.md +27 -3
  95. package/dist/skills/ads-migrate/SKILL.md +1 -0
  96. package/dist/skills/ads-migrate/references/0.5.1-to-0.5.2.md +185 -0
  97. package/dist/skills/ads-port/references/contracts.md +5 -2
  98. package/dist/skills/ads-port/references/design-data.md +1 -1
  99. package/dist/skills/ads-port/references/layout.md +5 -1
  100. package/dist/skills/ads-port/references/recipes.md +27 -3
  101. package/dist/surface-contrast.mjs +1 -0
  102. package/dist/surface-effects.mjs +5 -3
  103. package/dist/task-cache.mjs +8 -18
  104. package/dist/validation-checks.mjs +1 -1
  105. package/docs/ARCHITECTURE.md +63 -7
  106. package/docs/CACHING.md +152 -24
  107. package/docs/CHANGELOG.md +200 -23
  108. package/docs/GUIDE.md +45 -1
  109. package/docs/LANGUAGE.md +146 -8
  110. package/docs/MOTION.md +10 -2
  111. package/docs/PROFILE-KINDS.md +9 -1
  112. package/docs/RULES.md +22 -14
  113. package/docs/TOKEN-ROLES.md +7 -1
  114. package/package.json +1 -1
@@ -1,4 +1,4 @@
1
- import { outputIntegrityFingerprint, recordedOutputRevision } from "./emit/integrity.mjs";
1
+ import { recordedOutputRevision, withCurrentOutput } from "./emit/integrity.mjs";
2
2
  import { createHash } from "node:crypto";
3
3
  import { createRequire } from "node:module";
4
4
  import { spawnSync } from "node:child_process";
@@ -6,23 +6,13 @@ import { accessSync, constants, existsSync, mkdirSync, readFileSync, readdirSync
6
6
  import path from "node:path";
7
7
  import { fileURLToPath } from "node:url";
8
8
  import { isInside, loadConfig } from "./config.mjs";
9
+ import { parseArchitectureReport } from "./architecture-report.mjs";
10
+ export { parseArchitectureReport } from "./architecture-report.mjs";
9
11
  import { isRecord } from "./unknown.mjs";
10
12
  import { validationInputFiles } from "./validation-inputs.mjs";
11
13
  import { previewRuntimeFingerprint } from "./runtime-requirements.mjs";
12
14
  import { checkCommand } from "./validation-checks.mjs";
13
- const hash = (value) => createHash("sha256").update(value).digest("hex"), errorCode = (error) => isRecord(error) ? error.code : void 0, toolRoot = path.dirname(fileURLToPath(import.meta.url)), semanticEnv = ["NODE_ENV", "NODE_OPTIONS", "BUN_OPTIONS", "TZ", "LANG", "LC_ALL"], isStringArray = (value) => Array.isArray(value) && value.every((item) => typeof item === "string"), isDiagnostic = (value) => isRecord(value) && typeof value.rule === "string", isDiagnostics = (value) => Array.isArray(value) && value.every(isDiagnostic), isAcceptance = (value) => isRecord(value) && typeof value.scope === "string" && (value.status === "passed" || value.status === "not_established") && isStringArray(value.established) && isStringArray(value.unverified);
14
- export function parseArchitectureReport(value, source) {
15
- if (isRecord(value)) {
16
- const { ok, diagnostics, advisories, acceptance } = value;
17
- if (typeof ok === "boolean" && isDiagnostics(diagnostics) && isAcceptance(acceptance)) {
18
- if (advisories === void 0)
19
- return { ...value, ok, diagnostics, acceptance };
20
- if (isDiagnostics(advisories))
21
- return { ...value, ok, diagnostics, advisories, acceptance };
22
- }
23
- }
24
- throw TypeError(`${source} is not an ADS architecture report.`);
25
- }
15
+ const hash = (value) => createHash("sha256").update(value).digest("hex"), errorCode = (error) => isRecord(error) ? error.code : void 0, toolRoot = path.dirname(fileURLToPath(import.meta.url)), semanticEnv = ["NODE_ENV", "NODE_OPTIONS", "BUN_OPTIONS", "TZ", "LANG", "LC_ALL"];
26
16
  function turboBinary() {
27
17
  const platform = process.platform === "win32" ? "windows" : process.platform === "android" ? "linux" : process.platform, arch = process.arch === "x64" ? "64" : process.arch;
28
18
  try {
@@ -75,11 +65,10 @@ export function architectureExternalInputs(root, trackingRoot = root) {
75
65
  return {
76
66
  dependencies,
77
67
  git,
78
- environment: Object.fromEntries(semanticEnv.map((name) => [name, process.env[name] ?? null])),
79
- output: outputIntegrityFingerprint(options)
68
+ environment: Object.fromEntries(semanticEnv.map((name) => [name, process.env[name] ?? null]))
80
69
  };
81
70
  }
82
- export async function architectureTaskInputs(root, trackingRoot = root, { onFile } = {}) {
71
+ export async function architectureTaskInputs(root, trackingRoot = root, { onFile, environment } = {}) {
83
72
  return {
84
73
  schemaVersion: 1,
85
74
  kind: "architecture",
@@ -87,6 +76,7 @@ export async function architectureTaskInputs(root, trackingRoot = root, { onFile
87
76
  tool: toolInputs(),
88
77
  files: await validationInputFiles(loadConfig(root), [], { onFile }),
89
78
  ...architectureExternalInputs(root, trackingRoot),
79
+ ...environment === void 0 ? {} : { environment },
90
80
  outputRevision: recordedOutputRevision(loadConfig(root))
91
81
  };
92
82
  }
@@ -214,7 +204,7 @@ export async function runArchitectureTask(root, trackingRoot, directory, signal,
214
204
  throw failure ?? Error("ADS task did not produce an architecture report.");
215
205
  if (statSync(report).size > 16777216)
216
206
  throw Error("Architecture report exceeds 16 MiB.");
217
- const result = parseArchitectureReport(JSON.parse(readFileSync(report, "utf8")), "The ADS task report");
207
+ const result = withCurrentOutput(parseArchitectureReport(JSON.parse(readFileSync(report, "utf8")), "The ADS task report"), loadConfig(root));
218
208
  if (failure && result.ok !== !1)
219
209
  throw failure;
220
210
  let hit = !1;
@@ -16,7 +16,7 @@ function executionFresh() {
16
16
  }
17
17
  export async function checkCandidate(root, signal, trackingRoot = root, options = {}) {
18
18
  const service = await import("./check-service.mjs");
19
- if ((service.warmChecksFor(trackingRoot) || hasAnalysisRevision(root)) && existsSync(root)) {
19
+ if ((options.checked !== void 0 || options.environment !== void 0 || service.warmChecksFor(trackingRoot) || hasAnalysisRevision(root)) && existsSync(root)) {
20
20
  const { warmCheck } = service;
21
21
  return warmCheck(root, trackingRoot, signal, { fresh: executionFresh(), ...options });
22
22
  }
@@ -412,6 +412,16 @@ every token context through the shared paint mechanism
412
412
  subtree to that context only when the foundation declares `sections: true`;
413
413
  either way `foundation.css` repaints the element with the document surface.
414
414
 
415
+ **Composition facts.** Each text position and placement records the chains of
416
+ owned elements above it in every reachable choice, with the props that select
417
+ each chain (`src/analysis/owner-composition.mts`). Only the props that change
418
+ the chain are recorded (`src/analysis/composition-axes.mts`, exact: a prop that
419
+ decides whether another is read is kept), so a large variant matrix whose other
420
+ props style other elements keeps few leaves per position; more than 512 distinct
421
+ leaves at one position is a limit. Positions on the same path share one
422
+ enumeration, and each element's facts and each attribute read are reused across
423
+ choices that assign the inputs they read the same.
424
+
415
425
  **Boundaries.** A boundary is a placement above which neither paint is known.
416
426
  A pair that the elements below a boundary decide is checked; a side that
417
427
  reaches it is `component-contrast-unresolved` at the placement.
@@ -1202,6 +1212,16 @@ flowchart LR
1202
1212
  cache or `current`. Only validation and compilation that both pass against
1203
1213
  unchanged source publish the verified graph; a failure restores the last
1204
1214
  verified view.
1215
+ - **One check for a managed revision.** The MCP process's preview emitter checks
1216
+ in its analysis worker before emitting and sends a passing report over the
1217
+ private compiler channel, held in memory during that MCP process's lifetime.
1218
+ The Bun compiler's validation gate offers that report to the shared
1219
+ check service, which matches the full architecture-input key and refreshes
1220
+ output integrity before reuse. It still fences the build's inputs before
1221
+ publication. Missing or stale evidence checks normally; standalone compilation
1222
+ keeps its own gate. The emitter also seeds the live project's bounded saved
1223
+ reports, without eagerly storing acceptance candidates there. Native programs
1224
+ and owner facts remain in the worker that owns them; no worker cache is copied.
1205
1225
  - **Recovery.** Guarded publication invalidates the compiler explicitly.
1206
1226
  Content reconciliation recovers missed atomic file replacements, so OS watch
1207
1227
  delivery cannot establish freshness.
@@ -1414,7 +1434,9 @@ preview workspaces are full copies of that set.
1414
1434
  Neither set holds application source, public folders, the root `index.html` or
1415
1435
  tests outside `dsDir`. So an application, backend, native-toolchain or
1416
1436
  documentation edit never stales a validation, preview or acceptance revision.
1417
- The emitted output folder is never an input.
1437
+ The emitted output folder is never an input. Its integrity findings are read
1438
+ when a report is returned; the MCP server keeps them event-fed for its project
1439
+ ([caching](CACHING.md)).
1418
1440
 
1419
1441
  Compiled-preview cache keys need no read of application source or
1420
1442
  `node_modules`. The preview compiler's own inputs are the TypeScript
@@ -1493,12 +1515,38 @@ its analysis and emitted module
1493
1515
  ([caching](CACHING.md#owner-analysis-reuse)).
1494
1516
 
1495
1517
  The analysis service bounds active project and revision state. It closes after
1496
- idle time when no registered revision pins it. Direct library clients and
1497
- syntax-only clients have their own short idle cleanup. A one-shot CLI command
1498
- closes its clients when it has reported, so it exits without a wait for that
1499
- idle period. When one scenario inspector closes, its requests are canceled and
1500
- the shared compiler of other callers stays. Persisted registry metadata has
1501
- separate content checks.
1518
+ idle time when no registered revision pins it. Direct library clients keep
1519
+ their native sessions for 60 seconds after their last call, so spaced-out calls
1520
+ keep their programs and ASTs; while idle, a session's compiler process does not
1521
+ hold the event loop, so a finished caller exits at once. Syntax-only clients
1522
+ have their own short idle cleanup. A one-shot CLI command closes its clients
1523
+ when it has reported. When one scenario inspector closes, its requests are
1524
+ canceled and the shared compiler of other callers stays. Persisted registry
1525
+ metadata has separate content checks.
1526
+
1527
+ Cancelling an analysis request stops its work in the analysis worker, not only
1528
+ the caller's wait: the service sends a `cancel` message that the worker serves
1529
+ as it arrives, ahead of its queue. A queued request is answered without running;
1530
+ a running one stops at its next cancellation point (between owners, choices,
1531
+ scenarios, closure files and extracted constructions; `throwIfCancelled` in
1532
+ `src/analysis/context.mts`). Caches keep settled outcomes only, so a canceled
1533
+ analysis leaves nothing behind.
1534
+
1535
+ An unregistered analysis request sends the worker only the files that changed
1536
+ since the inventory the service last sent for that root, named by that
1537
+ inventory. The worker applies the changes only when it holds exactly that
1538
+ inventory (a registration or promotion of the project, or a restart, clears it);
1539
+ otherwise it refuses them and the complete inventory is sent. Stage tracing
1540
+ reports each request's `files` and whether they were `changes` on
1541
+ `analysis-inventory`.
1542
+
1543
+ Configuration read during an analysis is the captured revision's:
1544
+ `ds.config.json` (`loadConfig`) and the TypeScript configuration with its local
1545
+ `extends` chain (`projectCompilerOptions`) are read through the capture, never
1546
+ from newer bytes on disk: every `extends` target named by a path, relative or
1547
+ absolute, is read from the revision, and one the revision lacks or cannot parse
1548
+ is reported (`typescript-config-invalid`) instead of read from disk. A package
1549
+ configuration in `extends` is an installed dependency.
1502
1550
 
1503
1551
  ## On-demand visual evidence
1504
1552
 
@@ -1604,6 +1652,14 @@ and its exemptions.
1604
1652
  - Each render waits, bounded, for its content to settle, and the audit also
1605
1653
  renders interaction states (opened `aria-haspopup` overlays, hovered and
1606
1654
  focused controls).
1655
+ - Owner states are derived, not written (`src/derived-states.mts`): emission
1656
+ reads each construction's lowered CSS, whose selectors all start at its root,
1657
+ takes the compound after the root class as the state, and writes it with the
1658
+ construction's class string to the preview-only `ads-preview-audit.json`.
1659
+ The audit reads it once the previews are built and hands it to the page,
1660
+ which matches a construction by `data-ads-source` (the owner) and the element's
1661
+ classes; within one owner a class string is one construction. Nothing is added
1662
+ to rendered markup, and the facts never reach emitted output.
1607
1663
  - Each worker lists what every render could measure, then assigns targets in
1608
1664
  request order, so which render measures a shared control does not depend on
1609
1665
  page speed.
package/docs/CACHING.md CHANGED
@@ -31,16 +31,57 @@ The key includes:
31
31
  dependency inputs, configuration and lockfiles;
32
32
  - the installed package manifests of declared dependencies, and Git tracking of
33
33
  generated paths;
34
- - the emitted output folder, read by content: its `generated-modified` findings
35
- and the revision its contract records;
34
+ - the revision the emitted output folder's contract records (its contract file
35
+ alone);
36
36
  - the ADS implementation, the runtime and platform, and the check's semantic
37
37
  environment (`NODE_ENV`, `NODE_OPTIONS`, `BUN_OPTIONS`, `TZ`, `LANG`,
38
38
  `LC_ALL`).
39
39
 
40
+ The output folder's emitted files are not an input: a returned report, reused or
41
+ not, carries their `generated-modified` findings read by content when it is
42
+ returned (`withCurrentOutput`, `src/emit/integrity.mts`), once per check instead
43
+ of once per key calculation. A returned report is the evidence a fresh check
44
+ gives for those findings: failed, with acceptance not established, when the
45
+ folder was edited.
46
+
47
+ The MCP server's own project keeps those findings event-fed instead
48
+ (`src/emit/output-watch.mts`): a content-digest map of the output folder, like
49
+ the source inputs' (`src/input-digests.mts`), walked once and then re-reading
50
+ only the files its watcher reports, by content. These integrity findings read the
51
+ contract file again only when its digest changed, and no other emitted file unless
52
+ one was edited (the report-cache key still reads the contract's recorded revision);
53
+ a new, removed or replaced entry walks the folder again, as does the periodic
54
+ safety-net walk. Draft candidates and one-shot checks read the folder directly.
55
+ After a full walk, the shared watcher manager compares device and inode identities
56
+ and reopens handles for replaced directories, including descendants whose paths
57
+ are unchanged. Later edits in a tree replaced by `ads emit` therefore still reach
58
+ the digest map. This reconciliation adds no filesystem reads to unchanged hits.
59
+
40
60
  Inputs are fenced around execution and when a hit is consumed. Install from the
41
61
  lockfile; after hand-modifying installed packages without a lockfile change,
42
62
  request a fresh check.
43
63
 
64
+ The MCP preview emitter checks in the server's analysis worker. A successful,
65
+ fenced emission also stores that report in the server's saved-report shortcut,
66
+ so its first ordinary check can be a direct hit. Eager storage is limited to the
67
+ long-lived project: emitting an acceptance candidate does not add its report to
68
+ the live project's 16-entry list.
69
+
70
+ The emitter sends the passing report and its full task-input key over the existing
71
+ private compiler channel. The report stays in memory for the MCP process's
72
+ lifetime; it is not written to the preview tree or its disk state. The managed
73
+ compiler offers that evidence to its ordinary validation gate,
74
+ which reuses it only when current source membership and bytes, configuration,
75
+ dependencies, Git tracking, tool/runtime, environment and output revision match.
76
+ For the managed compiler, environment means its captured launch environment,
77
+ shared with its build-cache key; Bun's internal `NODE_ENV` change while preparing
78
+ a build does not create a different checking revision.
79
+ Output-integrity findings are refreshed when the report is consumed. Missing,
80
+ malformed or stale evidence runs a normal check; a fresh request bypasses it.
81
+ Standalone compilation retains its own check. An emission whose check reports
82
+ an output-modification finding supplies no passing evidence, so compilation
83
+ still rejects that finding.
84
+
44
85
  What a hit establishes:
45
86
 
46
87
  - A matching report skips rule execution; a changed key requires a new check.
@@ -69,7 +110,8 @@ What a hit establishes:
69
110
  | Relocated draft ASTs | Owned by that draft; releasing it drops the wrapper cache without changing sibling/live paths |
70
111
  | Warm reports and Turbo task artifacts | See [check paths](#check-paths); they hold no live compiler handles or acceptance state |
71
112
  | Construction extractions | Content-keyed, owner-independent compiled CSS; in memory per project, and [persisted](#persisted-extraction-cache) |
72
- | Owner analyses | [Content-keyed per owner](#owner-analysis-reuse); in memory per project (drafts share it, keyed by their own root), at most 512 owners × 3 token revisions; a released draft drops its entries |
113
+ | Owner analyses | [Content-keyed per owner](#owner-analysis-reuse), root-relative; in memory per project (drafts and acceptance candidates share it), at most 512 owners × 3 token revisions; an entry is dropped once every root that used it is released |
114
+ | Construction lowerings | [Content-keyed per construction](#construction-reuse), root-relative; in memory per project, at most 8192 constructions × 2 token revisions; released with owner analyses |
73
115
 
74
116
  Rules read source text from the captured revision.
75
117
  [Captured inputs](ARCHITECTURE.md#captured-inputs) covers warm-check captures,
@@ -104,10 +146,15 @@ inputs changed. The key
104
146
  graph), plus the public barrel when the closure imports the public alias;
105
147
  - every project source that may declare into the global scope (scripts such as
106
148
  `env.d.ts`, `declare global`, `declare module`);
107
- - the profile declarations, the asset records, and the public rows of owners in
108
- its closure analyzed before it;
109
- - the analysed root, `publicAlias`, themes, the compiler session's external
110
- inputs (installed declarations, compared by content) and the schema.
149
+ - the public rows of owners in its closure analyzed before it;
150
+ - `publicAlias`, themes, the compiler session's external inputs (installed
151
+ declarations, compared by content) and the schema.
152
+
153
+ The profile declarations and the asset records are not in the key: an outcome
154
+ records what it read of them and is reused only while those reads give the same
155
+ results ([design reads](#design-reads)). The key does not name where the design system is analysed: paths under the
156
+ analysed root are written root-relative, so a draft workspace or an acceptance
157
+ candidate and the live project share an unchanged owner's entry.
111
158
 
112
159
  A session closed while idle hands its observed external inputs to the next
113
160
  session of the same root, which keeps the environment identity only when every
@@ -126,17 +173,56 @@ the profile declarations already in its key. The composed contrast join over
126
173
  every owner's facts belongs to the revision's memoized check, not to an owner's
127
174
  entry: a token edit reuses every owner analysis and reruns only the join (stage
128
175
  `composed-contrast`), and an owner edit changes that owner's facts alone. The
129
- outcome schema is `ads-owner-analysis/9` (it carries each owner's closed props for the showcase's live controls); it includes the composition facts and
176
+ outcome schema is `ads-owner-analysis/11` (it carries each owner's closed props for the showcase's live controls, and the assets it draws with the size of each); it includes the composition facts and
130
177
  the profile/choice inventory `design`.
131
178
 
132
179
  - Settled outcomes (facts or a deterministic analysis failure) are reused;
133
180
  exceptions such as cancellation are never stored.
134
- - A draft never reuses or changes the base project's entries: outcomes carry
135
- absolute source paths, so the analysed root is part of the key.
136
- - `ADS_VERIFY_OWNER_REUSE=1` re-analyzes every reused owner and fails on any
137
- difference. Stage tracing reports `owners`, `reused` and `analyzed` on
181
+ - Drafts, acceptance candidates and the live project share entries. Outcomes
182
+ carry absolute source paths; one analysed under another root is relocated to
183
+ the requesting root (every path under that root, in file names and messages)
184
+ before it is returned. An entry records each root that analysed or reused it;
185
+ releasing a draft forgets its root and drops only the entries no other root
186
+ uses. An MCP edit, check or acceptance therefore analyzes only the owners
187
+ whose inputs it changed.
188
+ - `ADS_VERIFY_OWNER_REUSE=1` re-analyzes every reused owner, relocated ones
189
+ included, and fails on any difference. Stage tracing reports `owners`, `reused` and `analyzed` on
138
190
  `owner-facts` and `owner-analysis`.
139
191
 
192
+ ## Construction reuse
193
+
194
+ An owner whose inputs changed is analyzed again, but an edit rarely changes
195
+ every construction it can produce. Each construction's lowering and its checks
196
+ (state contrast, non-text contrast, inactive surfaces, corner overpaint,
197
+ runtime paints, hover geometry, surface uses) are a pure function of its
198
+ content, and are reused from the project's construction memo
199
+ (`src/analysis/construction-memo.mts`). The key is the digest of:
200
+
201
+ - the construction's identity, which also names its root class: its combined
202
+ spec and every fact that selects it (text, drawings, artwork state and theme,
203
+ hidden targets, inherited grids, aligned rows, decorative parts);
204
+ - the owner's private-name scope;
205
+ - the asset records it draws, by content (root-relative), and the declared
206
+ contexts;
207
+ - the schema (`ads-construction/2`: a placed drawing carries the size it is drawn at).
208
+
209
+ The profile declarations are not in the key: a lowering records the profiles it
210
+ read ([design reads](#design-reads)), and its outcome is reused only while they
211
+ read the same; reusing it replays those reads on the owner's own trace.
212
+
213
+ Token values are recorded the way owner analyses record them: a lowering that
214
+ read token values keeps one outcome per token-sheet digest, and reusing it
215
+ records the read on the owner's own evidence, so the owner stays
216
+ token-dependent. A failed construction is stored with its reviews and reproduces
217
+ the same finding. Reviews and failures are stored at their authored recipe path
218
+ and placed at the current revision's source when replayed; the analysis appends
219
+ an owner's further uses to a copy, never to the stored construction.
220
+
221
+ Choice enumeration, the owner's markup checks and its composition facts still
222
+ run for every analyzed owner. Stage tracing reports `reused` and `built` on
223
+ `construction-reuse`; `ADS_VERIFY_OWNER_REUSE=1` lowers every reused
224
+ construction again and fails on any difference.
225
+
140
226
  ## Import closure reuse
141
227
 
142
228
  The import closure rule (`src/design-system-closure.mts`) resolves every
@@ -149,14 +235,49 @@ and an owner edit resolves that owner's imports alone.
149
235
  - **Key.** The file's bytes and path, the closure's settings (compiler options
150
236
  and excluded folders), the revision's captured file membership (an added or
151
237
  removed file can change what a specifier resolves to), the compiler session's
152
- external inputs (installed packages) and the schema.
153
- - **Lifetime.** The analyzing process; entries of a discarded draft workspace
154
- are released with it.
238
+ external inputs (installed packages) and the schema
239
+ (`ads-design-system-closure/2`), all relative to the analysed project root.
240
+ - **Lifetime.** The analyzing process; a draft workspace or acceptance candidate
241
+ reuses the live project's entries, relocated to its own paths. An entry is
242
+ released once every root that used it is released.
155
243
  - **Bound.** 8192 files, least recently used first out.
156
244
 
245
+ Stage tracing reports `computed` and `reused` on `design-system-closure`;
246
+ `ADS_VERIFY_OWNER_REUSE=1` checks every reused file again.
247
+
248
+ The design inputs (foundation, asset and font records) are read once per
249
+ content: their key is the design files' bytes by design-system-relative name.
250
+ A read under another root is the same read with its asset and font paths moved,
251
+ and everything else (the foundation and its profiles) keeps its identity; each
252
+ entry keeps the moved reads of its last 4 roots.
253
+
157
254
  Without a compiler session's environment identity, every file is checked every
158
255
  revision.
159
256
 
257
+ ## Design reads
258
+
259
+ Owner analyses and construction lowerings record what they read of the profile
260
+ declarations and the asset catalog (`src/analysis/design-reads.mts`), so a
261
+ profile or asset edit invalidates only the results that read what changed:
262
+
263
+ - A read is recorded with its result: `profiles.get`/`has` and the catalog
264
+ maps' `get`/`has` by key, and the profile model's `compose`, `select` and
265
+ `variants` by their arguments (a composed or selected profile includes what it
266
+ extends and binds). Results are digested by content only when a replay
267
+ compares them; asset values are digested root-relative.
268
+ - Iterating a map or reading the foundation's `hash` reads its whole group
269
+ (profiles, or the catalog); the evidence then holds that group's digest by
270
+ content.
271
+ - The evidence also records the revision's whole profile and asset digests.
272
+ While a group's digest is unchanged (every token edit), its reads are not
273
+ replayed. Otherwise reuse replays them against the current revision: equal
274
+ digests mean the result is still valid; a result with no canonical form never
275
+ matches. A comment-only profile edit changes no digest,
276
+ and restoring an edit finds the earlier outcome (a slot keeps up to 3 outcomes
277
+ with different evidence).
278
+ - Profile validation (duplicates, unknown references, composition) still runs
279
+ for every revision in the design-input read.
280
+
160
281
  ## Scenario facts reuse
161
282
 
162
283
  `ads check` registers every scenario, traces what its specimens render
@@ -180,14 +301,18 @@ assembled from them for every revision.
180
301
  name);
181
302
  - the check program's global-scope declarations and the compiler session's
182
303
  external inputs;
183
- - the project and design-system roots, `publicAlias` and the schema.
304
+ - the design-system folder relative to the project root, `publicAlias` and
305
+ the schema (`ads-scenario-facts/4`). The key is written relative to the
306
+ project root.
184
307
  - **Lifetime.** The analyzing process; one cache per project, shared by its
185
- drafts, whose entries are released with the draft workspace.
308
+ drafts and acceptance candidates: a result is kept by the analysed project
309
+ root and relocated to the requesting one. An entry is released once every
310
+ root that used it is released.
186
311
  - **Bound.** 2048 results per project (a scenario's facts and its styling are
187
312
  one each, per key), least recently used first out; 8 projects per process. The
188
313
  resolved import edges of development modules (keyed by their bytes, the
189
- revision's file membership and the session's external inputs) share one bound
190
- of 4096 modules.
314
+ revision's file membership and the session's external inputs, relative to the
315
+ project root, so drafts share them) share one bound of 4096 modules.
191
316
 
192
317
  A token edit, an edit inside an owner no scenario reaches and a restored
193
318
  revision compute no scenario facts. An edit of a scenario, a fixture it reads, a
@@ -198,7 +323,9 @@ scenario: no second program).
198
323
  Without a module graph and check program (owner analysis rejected the revision),
199
324
  facts are read through the scenario program the registry uses. Without a known
200
325
  compiler environment, every scenario is computed. Stage tracing reports
201
- `computed` and `reused` on `owner-scenarios`. The scenarios' TypeScript
326
+ `computed` and `reused` on `owner-scenarios` (facts) and `scenario-styling`;
327
+ `ADS_VERIFY_OWNER_REUSE=1` computes every reused scenario result again and
328
+ fails on any difference. The scenarios' TypeScript
202
329
  diagnostics are part of the program-wide diagnostics.
203
330
 
204
331
  Framework identity (`src/analysis/framework-imports.mts`) reads every captured
@@ -242,10 +369,11 @@ it with the digest of the bytes it captured from the live project. When they
242
369
  differ, the captured revision is analysed instead; an analysis that does not
243
370
  match its own capture is reported as `source-changed`.
244
371
 
245
- The analysed root is part of the owner keys, so the candidate's owner analyses
246
- and emitted modules are keyed under the candidate root. The next emit or check
247
- of the live project in the same process analyzes its owners once under the live
248
- root's keys.
372
+ The acceptance's emit runs with the live project as its tracking root, as its
373
+ check does, so it uses the project's caches. Owner keys and emitted-module keys
374
+ are root-relative (the module text names its imports relative to itself): the
375
+ candidate reuses the modules of every owner the draft left unchanged, and the
376
+ next emit or check of the live project reuses the candidate's.
249
377
 
250
378
  ## Persisted extraction cache
251
379