@reqvire-org/ads 0.3.34 → 0.3.36

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 (37) hide show
  1. package/dist/check-runner.mjs +7 -0
  2. package/dist/mcp/drafts.mjs +5 -2
  3. package/dist/mcp/mutation-limits.mjs +2 -0
  4. package/dist/mcp/mutations.mjs +20 -11
  5. package/dist/mcp/patch.mjs +5 -3
  6. package/dist/mcp/preview-owner-guard.mjs +36 -1
  7. package/dist/mcp/preview-watch.mjs +88 -13
  8. package/dist/mcp/preview-work.mjs +41 -0
  9. package/dist/mcp/server.mjs +29 -16
  10. package/dist/preview-builder.mjs +1 -0
  11. package/dist/scenario-inspector.mjs +11 -5
  12. package/dist/scenario-registry.mjs +16 -0
  13. package/dist/scenarios-compiler.mjs +90 -23
  14. package/dist/skills/ads-break-ui/references/drafts.md +6 -0
  15. package/dist/skills/ads-break-ui/references/guarded-editing.md +2 -2
  16. package/dist/skills/ads-break-ui/references/runtimes.md +9 -0
  17. package/dist/skills/ads-designer/references/drafts.md +6 -0
  18. package/dist/skills/ads-designer/references/guarded-editing.md +2 -2
  19. package/dist/skills/ads-designer/references/runtimes.md +9 -0
  20. package/dist/skills/ads-import/references/drafts.md +6 -0
  21. package/dist/skills/ads-import/references/guarded-editing.md +2 -2
  22. package/dist/skills/ads-import/references/runtimes.md +9 -0
  23. package/dist/skills/ads-motion/references/drafts.md +6 -0
  24. package/dist/skills/ads-motion/references/guarded-editing.md +2 -2
  25. package/dist/skills/ads-motion/references/runtimes.md +9 -0
  26. package/dist/skills/ads-port/references/drafts.md +6 -0
  27. package/dist/skills/ads-port/references/guarded-editing.md +2 -2
  28. package/dist/skills/ads-port/references/runtimes.md +9 -0
  29. package/dist/validation-checks.mjs +23 -3
  30. package/dist/validation.mjs +19 -10
  31. package/dist/verification.mjs +5 -4
  32. package/docs/ARCHITECTURE.md +28 -0
  33. package/docs/CHANGELOG.md +41 -12
  34. package/docs/GUIDE.md +5 -1
  35. package/docs/MCP.md +12 -7
  36. package/docs/benchmarks/gidi-preview-memory.md +141 -0
  37. package/package.json +1 -1
@@ -103,6 +103,15 @@ compiler. Existing custom adapters still work; they must adopt the helper to gai
103
103
  incremental transforms. Upgrade the project dependency and restart the builder.
104
104
  Keep the full validation callback and production build behavior.
105
105
 
106
+ Managed acceptance builds every scenario in production mode and shares the
107
+ candidate compiler/checked output with browser verification. Remove
108
+ `build:mcp-previews` from `mcp.mutationChecks` after upgrading ADS; keep that script
109
+ in normal builds. Explicit project commands still run as configured. During
110
+ acceptance ADS parks accepted/draft compilers but retains their publications;
111
+ an old view remains visible while verified preview requests wait. Do not launch
112
+ a second compiler to work around that wait. Semantic workers retire after five
113
+ idle seconds and rediscover from revision-fenced metadata when needed.
114
+
106
115
  The shared watched builder reuses completed self-contained IIFE worker bundles
107
116
  for constructor URLs and standard `?worker`/`?worker&url` imports. It uses Vite's
108
117
  configured worker plugins, deduplicates pending requests, tracks real worker and
@@ -24,6 +24,12 @@ For example, `Button.tsx.ads` maps to the normal `Button.tsx` target. The final
24
24
  `.ads` extension keeps proposed code out of default TypeScript/lint discovery,
25
25
  without editing project tsconfig files. The manifest remains
26
26
  `proposal.ads.draft.json`. These are ordinary tracked project files: commit them and review them in a PR.
27
+
28
+ A draft may group up to 64 owners and 256 tracked files. For related changes,
29
+ use one multi-owner draft: its previews share a compiler workspace and acceptance
30
+ validates the combined candidate once, then applies all changes together. The
31
+ existing source and patch byte budgets still apply.
32
+
27
33
  Git is not required to create or recover a draft. Restarting ADS or cloning the
28
34
  project discovers the same source. Generated compiler workspaces and execution
29
35
  events remain under ignored `.ds/`; an interrupted check is never a pass.
@@ -104,8 +104,8 @@ of duplicating them across units. Do not create an asset group or bypass a guard
104
104
  to add these documents. Code/configuration and hidden/generated paths remain
105
105
  outside documentation ownership.
106
106
 
107
- For genuinely coupled changes, `ads_apply_transaction` accepts 2–8 distinct owner
108
- patches (32 distinct files and 16 MiB combined). Each patch keeps its ownership and
107
+ For genuinely coupled changes, `ads_apply_transaction` accepts 2–64 distinct owner
108
+ patches (256 distinct files and 16 MiB combined). Each patch keeps its ownership and
109
109
  companion restrictions. Patches apply in order; later shared-entry hunks match the
110
110
  earlier candidate. All guards, registered checks and affected behavior checks run
111
111
  on the final candidate before live source is written. Dry-run first. Rejection,
@@ -103,6 +103,15 @@ compiler. Existing custom adapters still work; they must adopt the helper to gai
103
103
  incremental transforms. Upgrade the project dependency and restart the builder.
104
104
  Keep the full validation callback and production build behavior.
105
105
 
106
+ Managed acceptance builds every scenario in production mode and shares the
107
+ candidate compiler/checked output with browser verification. Remove
108
+ `build:mcp-previews` from `mcp.mutationChecks` after upgrading ADS; keep that script
109
+ in normal builds. Explicit project commands still run as configured. During
110
+ acceptance ADS parks accepted/draft compilers but retains their publications;
111
+ an old view remains visible while verified preview requests wait. Do not launch
112
+ a second compiler to work around that wait. Semantic workers retire after five
113
+ idle seconds and rediscover from revision-fenced metadata when needed.
114
+
106
115
  The shared watched builder reuses completed self-contained IIFE worker bundles
107
116
  for constructor URLs and standard `?worker`/`?worker&url` imports. It uses Vite's
108
117
  configured worker plugins, deduplicates pending requests, tracks real worker and
@@ -24,6 +24,12 @@ For example, `Button.tsx.ads` maps to the normal `Button.tsx` target. The final
24
24
  `.ads` extension keeps proposed code out of default TypeScript/lint discovery,
25
25
  without editing project tsconfig files. The manifest remains
26
26
  `proposal.ads.draft.json`. These are ordinary tracked project files: commit them and review them in a PR.
27
+
28
+ A draft may group up to 64 owners and 256 tracked files. For related changes,
29
+ use one multi-owner draft: its previews share a compiler workspace and acceptance
30
+ validates the combined candidate once, then applies all changes together. The
31
+ existing source and patch byte budgets still apply.
32
+
27
33
  Git is not required to create or recover a draft. Restarting ADS or cloning the
28
34
  project discovers the same source. Generated compiler workspaces and execution
29
35
  events remain under ignored `.ds/`; an interrupted check is never a pass.
@@ -104,8 +104,8 @@ of duplicating them across units. Do not create an asset group or bypass a guard
104
104
  to add these documents. Code/configuration and hidden/generated paths remain
105
105
  outside documentation ownership.
106
106
 
107
- For genuinely coupled changes, `ads_apply_transaction` accepts 2–8 distinct owner
108
- patches (32 distinct files and 16 MiB combined). Each patch keeps its ownership and
107
+ For genuinely coupled changes, `ads_apply_transaction` accepts 2–64 distinct owner
108
+ patches (256 distinct files and 16 MiB combined). Each patch keeps its ownership and
109
109
  companion restrictions. Patches apply in order; later shared-entry hunks match the
110
110
  earlier candidate. All guards, registered checks and affected behavior checks run
111
111
  on the final candidate before live source is written. Dry-run first. Rejection,
@@ -103,6 +103,15 @@ compiler. Existing custom adapters still work; they must adopt the helper to gai
103
103
  incremental transforms. Upgrade the project dependency and restart the builder.
104
104
  Keep the full validation callback and production build behavior.
105
105
 
106
+ Managed acceptance builds every scenario in production mode and shares the
107
+ candidate compiler/checked output with browser verification. Remove
108
+ `build:mcp-previews` from `mcp.mutationChecks` after upgrading ADS; keep that script
109
+ in normal builds. Explicit project commands still run as configured. During
110
+ acceptance ADS parks accepted/draft compilers but retains their publications;
111
+ an old view remains visible while verified preview requests wait. Do not launch
112
+ a second compiler to work around that wait. Semantic workers retire after five
113
+ idle seconds and rediscover from revision-fenced metadata when needed.
114
+
106
115
  The shared watched builder reuses completed self-contained IIFE worker bundles
107
116
  for constructor URLs and standard `?worker`/`?worker&url` imports. It uses Vite's
108
117
  configured worker plugins, deduplicates pending requests, tracks real worker and
@@ -1,17 +1,29 @@
1
1
  import { spawn } from "node:child_process";
2
- import { readFileSync } from "node:fs";
2
+ import { mkdtempSync, readFileSync, rmSync, statSync } from "node:fs";
3
+ import { tmpdir } from "node:os";
4
+ import { fileURLToPath } from "node:url";
3
5
  import path from "node:path";
4
6
  import { projectContext } from "./mcp/context.mjs";
5
7
  import { packageScriptCommand } from "./development-runtime.mjs";
6
8
  import { failure as evidenceFailure } from "./evidence.mjs";
7
9
  const fail = (rule, message, file, failure) => Object.assign(new Error(message), { diagnostic: {rule, message, ...(file ? {file} : {}), ...(failure ? {failure} : {})} });
8
10
 
11
+ export async function checkCandidate(root, signal, trackingRoot = root) {
12
+ const directory = mkdtempSync(path.join(tmpdir(), "ads-architecture-"));
13
+ const report = path.join(directory, "report.json");
14
+ try {
15
+ await checkCommand(process.execPath, [fileURLToPath(new URL("./check-runner.mjs", import.meta.url)), root, report, trackingRoot], root, signal, undefined, {category:"architecture",phase:"ads-check"});
16
+ if (statSync(report).size > 16 * 1024 * 1024) throw new Error("Architecture report exceeds 16 MiB.");
17
+ return JSON.parse(readFileSync(report, "utf8"));
18
+ } finally { rmSync(directory, { recursive:true, force:true }); }
19
+ }
20
+
9
21
  export function checkCommand(command, args, cwd, signal, input, gate = {category:"architecture",phase:"patch-preparation"}, timeoutMs = 60000) {
10
22
  return new Promise((resolve, reject) => {
11
23
  if (signal?.aborted) { reject(fail("mutation-cancelled", "Mutation cancelled before validation.",undefined,evidenceFailure("runner","mutation-execution","ADS_CANCELLED"))); return; }
12
24
  const child = spawn(command, args, { cwd, shell: false, detached: process.platform !== "win32", windowsHide: true, stdio: [input === undefined ? "ignore" : "pipe", "pipe", "pipe"],
13
25
  env: { ...process.env, PATH: [path.join(cwd, "node_modules/.bin"), path.dirname(process.execPath), process.env.PATH ?? ""].join(path.delimiter) } });
14
- let output = "", failure;
26
+ let output = "", failure, guard, done = false;
15
27
  const startedAt=Date.now();
16
28
  if (input !== undefined) { child.stdin.on("error", () => {}); child.stdin.end(input); }
17
29
  function kill() {
@@ -21,6 +33,12 @@ export function checkCommand(command, args, cwd, signal, input, gate = {category
21
33
  stop.on("error", () => child.kill("SIGKILL"));
22
34
  } else { try { process.kill(-child.pid, "SIGKILL"); } catch (error) { if (error.code !== "ESRCH") failure ??= error; } }
23
35
  }
36
+ if (child.pid) {
37
+ guard = spawn(process.execPath, [fileURLToPath(new URL("./mcp/preview-owner-guard.mjs", import.meta.url)), String(child.pid), "--tree"], {stdio:["pipe","ignore","ignore"],windowsHide:true});
38
+ guard.stdin.on("error",()=>{});
39
+ const guardFailed = () => { if (!done) { failure ??= new Error("Validation ownership guard exited."); kill(); } };
40
+ guard.once("error",guardFailed);guard.once("exit",guardFailed);
41
+ }
24
42
  const abort = () => { failure = fail("mutation-cancelled", "Mutation cancelled during validation."); kill(); };
25
43
  signal?.addEventListener("abort", abort, { once: true });
26
44
  const timer = setTimeout(() => { failure = fail("mutation-check", `${path.basename(command)} ${args.join(" ")} exceeded its ${timeoutMs} ms command budget.`); failure.code="ADS_COMMAND_TIMEOUT"; kill(); }, timeoutMs);
@@ -28,6 +46,7 @@ export function checkCommand(command, args, cwd, signal, input, gate = {category
28
46
  child.once("error", error => { failure = error; });
29
47
  child.once("exit", kill); // Also clean up descendants of a finished launcher.
30
48
  child.once("close", code => {
49
+ done = true; guard?.stdin.end("cleanup\n");
31
50
  clearTimeout(timer); signal?.removeEventListener("abort", abort);
32
51
  const detail={command:path.basename(command),args,timeoutMs,elapsedMs:Date.now()-startedAt,exitCode:code};
33
52
  if (failure || code !== 0) {
@@ -43,7 +62,8 @@ export function checkCommand(command, args, cwd, signal, input, gate = {category
43
62
  export function projectChecks(options) {
44
63
  const context = projectContext(options);
45
64
  const pkg = JSON.parse(readFileSync(path.join(options.root, "package.json"), "utf8"));
46
- const scripts = options.config.mcp.mutationChecks ?? [pkg.scripts?.["lint:project"] ? "lint:project" : "lint", "typecheck", "build:mcp-previews"].filter(name => typeof pkg.scripts?.[name] === "string");
65
+ const managed = options.config.mcp.previewManifest && options.config.mcp.previewWatch;
66
+ const scripts = options.config.mcp.mutationChecks ?? [pkg.scripts?.["lint:project"] ? "lint:project" : "lint", "typecheck", ...(managed ? [] : ["build:mcp-previews"])].filter(name => typeof pkg.scripts?.[name] === "string");
47
67
  if (scripts.some(name => typeof pkg.scripts?.[name] !== "string")) throw fail("mutation-check", "Every configured mcp.mutationChecks script must exist in package.json.");
48
68
  if (scripts.length && !["npm", "bun"].includes(context.packageManager)) throw fail("mutation-check", "Declare packageManager as npm or bun to run mutation checks.");
49
69
  return scripts.map(script => packageScriptCommand(context.packageManager, script));
@@ -3,14 +3,13 @@ import { existsSync, lstatSync, mkdirSync, readFileSync, readdirSync, realpathSy
3
3
  import { createRequire } from "node:module";
4
4
  import path from "node:path";
5
5
  import { fileURLToPath } from "node:url";
6
- import { checkProject } from "./check.mjs";
7
6
  import { loadConfig, isInside } from "./config.mjs";
8
7
  import { createLintConfig } from "./lint-config.mjs";
9
8
  import { inspectUnits } from "./units.mjs";
10
9
  import { inspectBehaviors } from "./behaviors.mjs";
11
10
  import { affectedBehaviorUnits, createVerificationController } from "./verification.mjs";
12
11
  import { validationInputFiles } from "./validation-inputs.mjs";
13
- import { checkCommand, projectChecks } from "./validation-checks.mjs";
12
+ import { checkCandidate, checkCommand, projectChecks } from "./validation-checks.mjs";
14
13
  import { projectContext } from "./mcp/context.mjs";
15
14
  import { packageScriptCommand } from "./development-runtime.mjs";
16
15
  import { acceptance } from "./evidence.mjs";
@@ -37,7 +36,7 @@ function outputFile(root, name) {
37
36
  return path.join(folder,name);
38
37
  }
39
38
 
40
- export function createValidationController(directory) {
39
+ export function createValidationController(directory, { previewWork } = {}) {
41
40
  const root = path.resolve(directory);
42
41
  let active, progress;
43
42
  return {
@@ -52,7 +51,7 @@ export function createValidationController(directory) {
52
51
  let finish; controller.completion = new Promise(resolve => { finish = resolve; });
53
52
  const startedAt = Date.now(), checks = [], diagnostics = [], advisories = [], results = [];
54
53
  const requestedScope = scope;
55
- let inputs, changed = [], units = [], fallback;
54
+ let inputs, changed = [], units = [], fallback, releasePreview, previewHost;
56
55
  function stage(name) { signal.throwIfAborted(); progress = {stage:name,elapsedMs:Date.now()-startedAt,completed:checks.length}; onProgress?.(progress); }
57
56
  async function command(name, launch, options) {
58
57
  stage(name);
@@ -60,6 +59,7 @@ export function createValidationController(directory) {
60
59
  catch (error) { checks.push({name,passed:false}); throw error; }
61
60
  }
62
61
  try {
62
+ if (previewWork) releasePreview = await previewWork.acquire(signal);
63
63
  const options = loadConfig(root);
64
64
  inputs = validationInputs(options);
65
65
  const baselineFile = outputFile(root,"validation-baseline.json");
@@ -78,7 +78,7 @@ export function createValidationController(directory) {
78
78
  if (fallback) scope = "all";
79
79
  }
80
80
  stage("architecture");
81
- const core = checkProject(root);
81
+ const core = await checkCandidate(root, signal);
82
82
  diagnostics.push(...core.diagnostics); advisories.push(...(core.advisories ?? []));
83
83
  checks.push({name:"architecture",passed:core.ok});
84
84
  if (!core.ok) return complete();
@@ -109,10 +109,21 @@ export function createValidationController(directory) {
109
109
  await command("registered-oxlint",{command:process.execPath,args:[path.resolve(path.dirname(oxlintPackage),typeof bin === "string" ? bin : bin.oxlint),"--deny-warnings","--config",lintConfig,...paths]},options);
110
110
  } finally { rmSync(lintConfig,{force:true}); }
111
111
  for (const launch of scripts) await command(`project:${launch.args.at(-1)}`,launch,options);
112
+ if (options.config.mcp.previewManifest && options.config.mcp.previewWatch) {
113
+ stage("preview-build");
114
+ const { startAdsMcp } = await import("./mcp/server.mjs");
115
+ previewHost = await startAdsMcp(root, { stdio:false });
116
+ await previewHost.buildAll(signal, {timeoutMs:options.config.mcp.mutationCheckTimeoutMs});
117
+ checks.push({name:"managed production previews",passed:true});
118
+ }
112
119
  if (options.config.mcp.previewManifest || options.config.mcp.apps.length) {
113
120
  stage("verified-previews");
114
121
  const apps=[...options.config.mcp.apps,...inspectScenarios(options).scenarios.map(entry=>({id:entry.id,file:entry.artifact}))];
115
- const build=inspectBuildStatus(root,{...options.config.mcp,apps});
122
+ const build=previewHost ? previewHost.buildStatus() : inspectBuildStatus(root,{...options.config.mcp,apps});
123
+ if (previewHost && options.config.mcp.apps.length) build.previews = [
124
+ ...build.previews.filter(entry=>entry.id.includes("/")),
125
+ ...inspectBuildStatus(root,{...options.config.mcp,apps:options.config.mcp.apps}).previews,
126
+ ];
116
127
  const pending=build.previews.filter(entry=>!entry.current);
117
128
  checks.push({name:"verified-previews",passed:!pending.length,previewCount:apps.length});
118
129
  if (pending.length) {
@@ -124,7 +135,7 @@ export function createValidationController(directory) {
124
135
  units = scope === "all" ? behaviors.contracts.map(contract=>contract.unit) : affectedBehaviorUnits(options,changed);
125
136
  if (units.length) {
126
137
  stage("behavior");
127
- const verification = createVerificationController(root);
138
+ const verification = createVerificationController(root, {previewHost});
128
139
  let result;
129
140
  try { result = await verification.run({units},signal,value=>{ progress={stage:"behavior",...value}; onProgress?.(progress); }); }
130
141
  finally { await verification.close(); }
@@ -133,11 +144,10 @@ export function createValidationController(directory) {
133
144
  if (!result.ok && !result.diagnostics.length) diagnostics.push({rule:"validation-behavior",message:"Registered behavior checks did not all pass. Inspect the recorded outcomes."});
134
145
  } else checks.push({name:"registered-behavior",passed:true,skipped:true,reason:scope === "all" ? "No registered behavior contracts." : "No affected behavior contracts."});
135
146
  } catch (error) { diagnostics.push(error.diagnostic ?? {rule:signal.aborted ? "validation-cancelled" : "validation-execution",message:error.message}); }
136
- finally { /* Completion also runs for early architecture failures. */ }
147
+ finally { try { await previewHost?.close(); } finally { releasePreview?.();active=undefined;progress=undefined;finish(); } }
137
148
  return complete();
138
149
 
139
150
  function complete() {
140
- try {
141
151
  let current = false;
142
152
  try { current = !!inputs && validationInputs(loadConfig(root)).revision === inputs.revision; } catch (error) { diagnostics.push({rule:"validation-inputs",message:error.message}); }
143
153
  if (inputs && !current) diagnostics.push({rule:"validation-stale",message:"Project inputs changed during validation. Rerun against current source."});
@@ -151,7 +161,6 @@ export function createValidationController(directory) {
151
161
  }
152
162
  return {ok,scope,requestedScope,...(fallback?{fallback}:{}),sourceRevision:inputs?.revision,current,elapsedMs:Date.now()-startedAt,selection:{files:changed,units},checks,diagnostics,advisories,results,
153
163
  acceptance:acceptance(scope === "all" ? "full-project-validation" : "affected-project-validation",ok,checks.filter(check=>check.passed&&!check.skipped).map(check=>check.name),["unconfigured-project-checks","unasserted-behavior","visual-parity","accessibility-audit"])};
154
- } finally { active=undefined;progress=undefined;finish(); }
155
164
  }
156
165
  },
157
166
  };
@@ -223,7 +223,7 @@ function runProgress(group, report, startedAt, profile, timeoutMs) {
223
223
  }
224
224
 
225
225
  /** Registered development commands are trusted project code, never model-supplied commands. */
226
- export function createVerificationController(root, { reportRoot = root, onProgress } = {}) {
226
+ export function createVerificationController(root, { reportRoot = root, onProgress, previewWork, previewHost } = {}) {
227
227
  root = path.resolve(root);
228
228
  reportRoot = path.resolve(reportRoot);
229
229
  let active, progress;
@@ -236,9 +236,10 @@ export function createVerificationController(root, { reportRoot = root, onProgre
236
236
  const controller = active;
237
237
  signal = signal ? AbortSignal.any([signal, active.signal]) : active.signal;
238
238
  let finish; controller.completion = new Promise(resolve => { finish = resolve; });
239
- let host;
239
+ let host, releasePreview;
240
240
  const results = [], diagnostics = [];
241
241
  try {
242
+ if (previewWork) releasePreview = await previewWork.acquire(signal);
242
243
  const options = loadConfig(root), inventory = inspectBehaviors(options);
243
244
  if (inventory.diagnostics.length) return verificationResult(inventory.diagnostics.map(diagnostic=>({...diagnostic,failure:failure("architecture","behavior-contract",diagnostic.rule)})),results);
244
245
  const selectedUnits = new Set(units ?? (unit ? [unit] : inventory.contracts.map(item => item.unit)));
@@ -257,7 +258,7 @@ export function createVerificationController(root, { reportRoot = root, onProgre
257
258
  const scenarios = {};
258
259
  if (profile.mode === "browser" && group.some(check => check.scenario)) {
259
260
  const { startAdsMcp } = await import("./mcp/server.mjs");
260
- host ??= await startAdsMcp(root, { stdio: false, showcase: true });
261
+ host ??= previewHost ?? await startAdsMcp(root, { stdio: false, showcase: true });
261
262
  // Queue all selected roots before parallel browser workers open. A
262
263
  // single graph avoids repeated compilation and startup handovers.
263
264
  await host.warmScenarios([...new Set(group.map(check => check.scenario).filter(Boolean))], signal);
@@ -354,7 +355,7 @@ export function createVerificationController(root, { reportRoot = root, onProgre
354
355
  }
355
356
  return verificationResult(diagnostics,results);
356
357
  } catch (error) { return verificationResult([{ rule: "behavior-verification", message: error.message }],results); }
357
- finally { try { await host?.close(); } finally { if (active === controller) { active = undefined; progress = undefined; } finish(); } }
358
+ finally { try { if (host !== previewHost) await host?.close(); } finally { releasePreview?.(); if (active === controller) { active = undefined; progress = undefined; } finish(); } }
358
359
  },
359
360
  };
360
361
  }
@@ -564,6 +564,34 @@ dependencies. An edit racing publication cannot associate previous output with
564
564
  newer inputs; it leaves the previous cache intact and requires the next build.
565
565
  A transferred checked graph can refresh older watcher metadata without recompiling
566
566
  it, while a partial watched graph cannot replace the complete catalogue.
567
+ Its full semantic registry snapshot transfers only when source revisions match,
568
+ so restarting a parked compiler need not repeat discovery of accepted source.
569
+ Shared dependency maps are stored once, with a fresh validation memo for each
570
+ reuse operation. No file hash is retained across operations. Configuration input
571
+ ordering is canonical across Node and Bun; complete caches stay within the
572
+ existing 8 MiB budget rather than silently writing an unreadable large file.
573
+
574
+ Guarded acceptance and MCP validation park the project's accepted and draft
575
+ compiler processes while the isolated candidate runs. Parking retains the same
576
+ publication session and immutable assets, so mounted Apps keep their view and
577
+ resource reads continue. Requests requiring a verified build queue until validation releases the
578
+ compiler budget; cancellation removes the waiter. Resumption starts a compiler
579
+ only when requested, reusing checked artifacts for unchanged inputs.
580
+
581
+ For managed resource previews, ADS requests all scenarios in production mode
582
+ through that candidate's compiler. It closes an incremental Rollup graph before
583
+ starting production compilation. The same candidate host then serves registered
584
+ browser verification; warm selections reuse the checked production graph.
585
+ Production reuse requires a successful production build of the exact inputs,
586
+ not merely a previously compiled development graph. Project-owned additional
587
+ commands still run as configured. Remove the standalone preview-build command
588
+ from `mcp.mutationChecks`; keep it in the ordinary project build.
589
+
590
+ Candidate architecture inspection runs in a short-lived owned process, releasing
591
+ its TypeScript heap after completion or cancellation. Semantic preview workers
592
+ retire after five idle seconds, while revision-fenced metadata remains on disk.
593
+ Closing a temporary host releases its semantic program cache. These lifecycle
594
+ bounds do not change source checks, behavior selection or publication fences.
567
595
 
568
596
  After the selected view paints, a connected showcase can prefetch changed peers'
569
597
  static resources into the App's existing byte cache. This bounded, opportunistic
package/docs/CHANGELOG.md CHANGED
@@ -1,34 +1,63 @@
1
1
  # Changelog
2
2
 
3
- ## 0.3.34
3
+ ## 0.3.36
4
4
 
5
5
  <!-- ads-local-tests:start -->
6
- Local verification: **535/535 passed** with `ADS_TEST_BUN=1 npm test`.
7
- Tested commit: `7e1573d7c1d210b5955cf41778ac3886b515d6af`; Node v24.13.0, Bun 1.3.13.
8
- Completed 2026-10-22T20:53:31.087Z (614 seconds).
6
+ Local verification: **550/550 passed** with `ADS_TEST_BUN=1 npm test`.
7
+ Tested commit: `bd323b5bca2899bfe0693cbe18d847e7117363ff`; Node v24.13.0, Bun 1.3.13.
8
+ Completed 2026-10-23T08:15:20.531Z (755 seconds).
9
9
 
10
10
  <!-- ads-local-test-proof
11
11
  {
12
12
  "schema": 1,
13
- "version": "0.3.34",
14
- "commit": "7e1573d7c1d210b5955cf41778ac3886b515d6af",
15
- "sourceSha256": "c020f82b1ceab0b30bb61722b26e8bba44c72e115687032fc7a5377487896c96",
13
+ "version": "0.3.36",
14
+ "commit": "bd323b5bca2899bfe0693cbe18d847e7117363ff",
15
+ "sourceSha256": "071702f9a64c119b33cd06b348cb995ccfe6c97de7f8d624a05d75b57f15eec7",
16
16
  "command": "ADS_TEST_BUN=1 npm test",
17
17
  "result": "pass",
18
- "tests": 535,
19
- "pass": 535,
18
+ "tests": 550,
19
+ "pass": 550,
20
20
  "fail": 0,
21
21
  "cancelled": 0,
22
22
  "skipped": 0,
23
23
  "node": "v24.13.0",
24
24
  "bun": "1.3.13",
25
- "completedAt": "2026-10-22T20:53:31.087Z",
26
- "durationMs": 613940,
27
- "logSha256": "d66e7ddc9334e67567af1c47644e23c82348ab03e0297589301f7f5f00e72005"
25
+ "completedAt": "2026-10-23T08:15:20.531Z",
26
+ "durationMs": 754603,
27
+ "logSha256": "9c04003e1d68049541f855f2d3909f8f1569737f2b978fb828889a2f5ff13da8"
28
28
  }
29
29
  -->
30
30
  <!-- ads-local-tests:end -->
31
31
 
32
+ - Allow up to 64 owners in one tracked draft or guarded transaction, with up to
33
+ 256 changed files. Related changes share the draft compiler and one final
34
+ acceptance validation; source/patch byte budgets and publication checks remain
35
+ enforced. Share these limits across draft manifests, MCP schemas and patch parsing.
36
+
37
+ ## 0.3.35
38
+
39
+ - Bound acceptance memory by parking accepted/draft compilers while retaining
40
+ published views, running candidate architecture checks in a short-lived
41
+ process, and retiring idle semantic workers and temporary program caches.
42
+ - Deduplicate shared preview dependency maps so large full graphs remain below
43
+ the cache reader's size limit. Hash shared dependencies once per operation and
44
+ sort configuration inputs for stable reuse under Bun as well as Node.
45
+ - Build all candidate previews in production mode through the managed compiler;
46
+ reuse that checked graph and host for browser verification. Remove
47
+ `build:mcp-previews` from `mcp.mutationChecks` after upgrading; normal builds
48
+ retain the standalone script. Development graphs cannot satisfy a production
49
+ build check.
50
+ - Preserve current preview reads while compilers are parked, exclude queue time
51
+ from build budgets, and keep configuration replacements parked until validation
52
+ completes. Fail malformed full-build catalogs promptly and recover complete
53
+ catalogs after repair. Keep read-only architecture reports outside the project.
54
+ - In the frozen Gidi acceptance workload, peak process-tree PSS fell from
55
+ 7.99 to 4.56 GiB and two complete draft/accept cycles fell from 355.7 to
56
+ 270.3 seconds, retaining all validation gates. See the
57
+ [benchmark report](https://github.com/reqvire-org/ads/blob/v0.3.35/docs/benchmarks/gidi-preview-memory.md).
58
+
59
+ ## 0.3.34
60
+
32
61
  - Ship typed browser verification helpers so strict project typechecks retain
33
62
  Playwright's DOM callback inference. Recognize explicitly configured nested
34
63
  Vite/Playwright build files as tooling rather than ADS runtime imports.
package/docs/GUIDE.md CHANGED
@@ -433,7 +433,11 @@ Guarded MCP editing is opt-in. Its mandatory checks and optional project
433
433
  `mcp.mutationChecks` scripts run in a temporary project copy with installed
434
434
  dependencies. Project scripts default to 60 seconds each; use the explicit
435
435
  `mcp.mutationCheckTimeoutMs` budget (100–300000 ms) for measured slower builds.
436
- Behavior profiles have a separate whole-run budget. See the [editing contract](MCP.md#guarded-editing) for unit ownership,
436
+ Behavior profiles have a separate whole-run budget.
437
+ For managed resource previews, ADS builds the complete production graph during
438
+ acceptance and shares it with browser verification. Remove `build:mcp-previews`
439
+ from `mcp.mutationChecks`; keep that script in the ordinary project build.
440
+ See the [editing contract](MCP.md#guarded-editing) for unit ownership,
437
441
  Git patches, bounded reads and preview review. Keep normal build gates enabled
438
442
  for edits made by other tools.
439
443
 
package/docs/MCP.md CHANGED
@@ -31,7 +31,7 @@ exercised conditions alongside normal application integration checks.
31
31
  ### Auto-mode tracked drafts
32
32
 
33
33
  Use the [draft workflow](../skills/ads-designer/references/drafts.md) for iterative
34
- design. With `--mutations`, `ads_create_draft` creates a tracked proposal for 1–8
34
+ design. With `--mutations`, `ads_create_draft` creates a tracked proposal for 1–64
35
35
  owners; ordinary file edits or `ads_update_draft` continue it. `ads_show_draft`
36
36
  reuses an isolated compiler workspace and returns both an MCP App preview and
37
37
  browser URLs without running acceptance checks. `ads_drafts` lists only pending
@@ -638,7 +638,7 @@ For a coupled rename or upgrade, call `ads_apply_transaction`:
638
638
  }
639
639
  ```
640
640
 
641
- It accepts 2–8 distinct owners, at most 32 distinct files and 16 MiB of combined
641
+ It accepts 2–64 distinct owners, at most 256 distinct files and 16 MiB of combined
642
642
  Git diff text. Each patch obeys its own ownership/companion rules. Patches apply
643
643
  in order inside one candidate; shared-entry hunks in a later patch must match
644
644
  the earlier candidate's content. Core checks, registered Oxlint, project commands
@@ -671,15 +671,20 @@ requires correcting its owner/policy, never a direct-write bypass.
671
671
  Set `dryRun` to `false` to apply. ADS reconstructs complete candidate files locally
672
672
  and validates a temporary project copy with core guards and registered Oxlint
673
673
  rules, including warnings. By default it also runs available `lint:project`
674
- (or `lint`), `typecheck` and `build:mcp-previews` scripts. Override only that
675
- additional list through project-owned configuration:
674
+ (or `lint`) and `typecheck` scripts. For resource projects with `mcp.previewWatch`,
675
+ ADS also requests a full production preview build from the managed compiler and
676
+ uses that same host and checked graph for registered browser verification. Keep
677
+ `build:mcp-previews` for standalone builds; remove it from `mutationChecks` to
678
+ avoid a redundant command. Explicit scripts still run exactly as configured.
679
+ Projects without managed resource previews retain the standalone script default.
680
+ Override the additional script list through project-owned configuration:
676
681
 
677
682
  ```json
678
- { "mcp": { "mutationChecks": ["lint", "typecheck", "build:mcp-previews"], "mutationCheckTimeoutMs": 120000 } }
683
+ { "mcp": { "mutationChecks": ["lint", "typecheck"], "mutationCheckTimeoutMs": 120000 } }
679
684
  ```
680
685
 
681
- Every listed script must exist. An empty list still runs mandatory ADS and Oxlint
682
- checks. Scripts use the project's npm/Bun runner; installed dependencies are
686
+ Every listed script must exist. An empty list still runs mandatory ADS, Oxlint
687
+ and configured managed preview checks. Scripts use the project's npm/Bun runner; installed dependencies are
683
688
  shared with the validation copy. These are trusted project commands, not an OS
684
689
  sandbox. An explicit `configuration` patch can change project commands, registered
685
690
  rules and reviewed exceptions; validation runs the proposed configuration and
@@ -0,0 +1,141 @@
1
+ # Gidi draft acceptance: memory and compiler reuse
2
+
3
+ Measured on 23 October 2026 using a frozen Gidi source snapshot and real MCP
4
+ Apps in headless Chrome. The installed Gidi package and working source were not
5
+ patched. The baseline distribution matched published ADS 0.3.34 byte for byte.
6
+
7
+ | Measurement | ADS 0.3.34 | Changed implementation |
8
+ | --- | ---: | ---: |
9
+ | Peak process-tree PSS | 7.99 GiB | 4.56 GiB |
10
+ | Peak process-tree RSS | 8.82 GiB | 5.50 GiB |
11
+ | Main Bun process peak PSS, including benchmark driver | 3.71 GiB | 2.11 GiB |
12
+ | Idle PSS after acceptance 1 | 3.30 GiB | 1.49 GiB |
13
+ | Idle PSS after acceptance 2 | 4.70 GiB | 1.71 GiB |
14
+ | Acceptance 1, including all configured gates | 101.0 s | 81.3 s |
15
+ | Acceptance 2, including all configured gates | 116.3 s | 81.8 s |
16
+ | Reopen accepted preview after acceptance 1 | 14.3 s | 8.0 s |
17
+ | Reopen accepted preview after acceptance 2 | 14.0 s | 7.4 s |
18
+ | Complete two-cycle workflow | 355.7 s | 270.3 s |
19
+
20
+ Peak proportional memory fell by 43%; the complete workload took 24% less time.
21
+ These are local observations from this workload, not a latency or memory limit
22
+ for every design system. Two cycles demonstrate substantially lower retention;
23
+ they do not establish the absence of every long-session leak.
24
+
25
+ ## Workload and controls
26
+
27
+ Each cycle creates a Popover owner draft, adds a comment to its owned fixture,
28
+ opens the actual draft App, accepts the reviewed revision, reopens the accepted
29
+ App, and observes a two-second idle window. This exercises source revision
30
+ changes without changing the rendered UI. The full catalog contains 151
31
+ scenarios. Both cycles passed all nine acceptance gates and the selected
32
+ registered Popover behavior check, with zero diagnostics or warnings.
33
+
34
+ Both versions run the project's architecture checks, registered Oxlint rules,
35
+ `lint:ds`, typecheck, native app build/audit, frontend tests, application browser
36
+ tests and the affected registered behavior checks. The candidate configuration
37
+ removes `build:mcp-previews` from `mutationChecks`; ADS performs that complete
38
+ production preview build itself and shares its host/graph with verification.
39
+ The adapter's validation callback still runs. No configured check was bypassed.
40
+
41
+ Node v24.13.0 and Bun 1.3.13 were used. Both comparison runs had an 8 GiB systemd
42
+ scope limit, no additional swap, one Playwright worker in each Gidi runner, and
43
+ `NODE_OPTIONS=--max-old-space-size=1536`. Bun's `--smol` flag was not used. PSS and
44
+ RSS were sampled from `/proc` every approximately 200 ms across the MCP process,
45
+ compiler, validators, browser and descendants. Idle values are medians over the
46
+ two-second windows. The main-process measurement includes the same benchmark
47
+ driver in both runs. Filesystem caches were not forcibly cleared.
48
+
49
+ The frozen source contains 865 files. Its SHA-256 inventory identity is
50
+ `b1c4de874e303f6c8a1eb976f5014fcb2589b773cc62fb9b08db8e21d99c0094`.
51
+ The 286-file baseline distribution identity is
52
+ `2f6f81127d585941c70b1bfd2829fdb19b9c89ba4719df08a2d8207d4f11c3e8`.
53
+ Local raw results are `output/memory-benchmark/baseline-5-metrics.json`,
54
+ `candidate-6-metrics.json`, `final-comparison.json` and `identities.json`.
55
+
56
+ ## Findings and changes
57
+
58
+ Accepted and draft compilers previously remained warm during isolated candidate
59
+ validation. The main MCP process also performed candidate architecture analysis
60
+ and retained semantic program state. Acceptance now parks preview compilers
61
+ while keeping their published resources readable. Analysis uses a short-lived
62
+ owned process; idle semantic workers retire after five seconds. Compilers resume
63
+ lazily and preserve the publication session. Current accepted previews remain
64
+ readable; requests requiring a new verified build wait or cancel.
65
+
66
+ Production compilation now happens once in the candidate's managed compiler.
67
+ The same checked graph serves its registered browser verification. Development
68
+ output cannot satisfy a production-build check. Candidate source, outputs and
69
+ reviewed draft revisions retain their existing publication fences.
70
+
71
+ The initial lifecycle change roughly halved memory but made accepted-preview
72
+ reopening slower. A real Gidi probe explained the remaining rebuild: its full
73
+ cache was 10,003,007 bytes, above the reader's 8,388,608-byte limit. It repeated
74
+ the same 520 dependency hashes separately for 151 scenarios. Small fixtures
75
+ had not exposed this size boundary.
76
+
77
+ The cache now stores shared dependency sets once and checks shared hashes once
78
+ per operation. Gidi's complete cache is 252,861 bytes, with 151 entries and one
79
+ dependency set. Metadata transfers with matching accepted source so parked
80
+ compiler restarts can reuse it. Compiler fingerprints use the same declared
81
+ configuration and opaque-input boundary as guarded copies, with canonical
82
+ ordering under Node and Bun. Unrelated local MCP launcher JSON is not a compiler
83
+ input. Hash memos do not survive an operation or hide later edits.
84
+
85
+ Validation subprocesses also have ownership guards. On Linux these retain
86
+ descendant identities so detached browser web servers are cleaned up after a
87
+ launcher exits or its owner is forcibly killed. A timed-out calibration exposed
88
+ one such orphan in the old pipeline; the owned calibration processes were
89
+ removed.
90
+
91
+ ## Reproduction
92
+
93
+ Use Linux, Node, Bun, Chrome and a Gidi checkout with its dependencies installed.
94
+ Build ADS first. Preparing a series freezes source and the installed baseline
95
+ distribution under `output/memory-benchmark`; use a fresh `ADS_BENCH_OUTPUT`
96
+ directory for a new source/dependency baseline. Preparation changes only the
97
+ generated copies. It gives the application tests port 43087 and adjusts the
98
+ candidate's mutation-check list for managed production compilation.
99
+
100
+ ```sh
101
+ node scripts/build-ads-tool.mjs
102
+ node scripts/benchmarks/gidi-preview-memory/prepare.mjs /path/to/gidi baseline 1
103
+ node scripts/benchmarks/gidi-preview-memory/prepare.mjs /path/to/gidi candidate 1
104
+ ```
105
+
106
+ Run the following separately for `baseline-1` and `candidate-1`, with Node and
107
+ Bun on PATH. Do not run the two workloads simultaneously.
108
+
109
+ ```sh
110
+ systemd-run --user --scope -p MemoryMax=8G -p MemorySwapMax=0 \
111
+ timeout --kill-after=5s 900s env NODE_OPTIONS=--max-old-space-size=1536 \
112
+ node scripts/benchmarks/gidi-preview-memory/monitor.mjs \
113
+ output/memory-benchmark/baseline-1
114
+ ```
115
+
116
+ ```sh
117
+ node scripts/benchmarks/gidi-preview-memory/report.mjs \
118
+ output/memory-benchmark/baseline-1-metrics.json \
119
+ output/memory-benchmark/candidate-1-metrics.json
120
+ ```
121
+
122
+ The monitor writes checkpoints during the run so an enforced memory limit does
123
+ not erase the samples. `ADS_BENCH_CYCLES` controls repetitions. Set
124
+ `ADS_BENCH_RUNTIME_SOURCE=1` to edit runtime Popover source instead; in this
125
+ snapshot that selects 74 registered behavior checks and is a much longer
126
+ workload. All selected checks remain mandatory.
127
+
128
+ ## Final verification
129
+
130
+ `ADS_TEST_BUN=1 npm test` passed **547/547 tests**, with zero failures,
131
+ cancellations or skips, on the final source (644 seconds). Tool lint and
132
+ benchmark-helper lint passed. The suite includes oversized-cache restart reuse,
133
+ fresh dependency checks, Bun portability, production-versus-development reuse,
134
+ catalog failure/recovery, current-view reads while parked, cancellation,
135
+ configuration replacement, process ownership and read-only architecture checks.
136
+
137
+ The performance samples identify their measured runtime separately from the
138
+ final distribution in `output/memory-benchmark/identities.json`. Subsequent
139
+ recovery and read-only hardening was included in the final full suite. These
140
+ changes ship in ADS 0.3.35. Upgrade consumers before removing the standalone
141
+ preview-build script from `mcp.mutationChecks`; keep it in the normal build.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@reqvire-org/ads",
3
- "version": "0.3.34",
3
+ "version": "0.3.36",
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": {