@reqvire-org/ads 0.4.5 → 0.4.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/capture.mjs +1 -1
- package/dist/input-scope.mjs +57 -0
- package/dist/mcp/build-status.mjs +12 -3
- package/dist/mcp/mutations.mjs +1 -1
- package/dist/mcp/preview-watch.mjs +14 -3
- package/dist/mcp/server.mjs +24 -8
- package/dist/mcp/showcase-host.mjs +2 -1
- package/dist/preview-inputs.mjs +7 -2
- package/dist/scenario-registry.mjs +2 -2
- package/dist/stage-timing.cjs +3 -2
- package/dist/validation-inputs.mjs +21 -3
- package/docs/ARCHITECTURE.md +8 -0
- package/docs/CHANGELOG.md +31 -76
- package/package.json +1 -1
package/dist/capture.mjs
CHANGED
|
@@ -112,7 +112,7 @@ export function createCaptureController(root) {
|
|
|
112
112
|
const project = projects[app.projectIndex];
|
|
113
113
|
images.set(`${app.projectIndex}:${app.selectionIndex}`, { mimeType: "image/png", blob: bytes.toString("base64"), digest: `sha256:${createHash("sha256").update(bytes).digest("hex")}`, width: metadata.width, height: metadata.height, bytes: bytes.length, capturedAt: value.images[index].capturedAt, sourceRevision: project.revision, buildRevision: hosts[app.projectIndex].previewRevision(), settings: { theme: app.theme, ...(app.brand ? { brand: app.brand } : {}), viewport: app.viewport, animations: app.animations, guides: app.guides, browser: settings.browser, ...(settings.channel ? { channel: settings.channel } : {}), scale: "css" }, scenarioFile: app.scenarioFile, fixtureFile: app.fixtureFile });
|
|
114
114
|
}
|
|
115
|
-
for (const project of projects) if ((await previewSourceRevision(loadConfig(project.options.root)))!==project.revision)throw new Error("Project inputs changed while capturing. No capture slots were replaced; retry against current source.");
|
|
115
|
+
for (const project of projects) if ((await previewSourceRevision(loadConfig(project.options.root),[],{fresh:true}))!==project.revision)throw new Error("Project inputs changed while capturing. No capture slots were replaced; retry against current source.");
|
|
116
116
|
if (signal.aborted) throw new Error("Screenshot capture cancelled before publication.");
|
|
117
117
|
update("publishing", apps.length, apps.length);
|
|
118
118
|
const records = selections.map((selection, index) =>( { schemaVersion: 1, key: captureKey(selection), scenario: selection.scenario, ...(selection.target ? { target: selection.target } : {}), current: images.get(`0:${index}`) ?? null, ...(!images.has(`0:${index}`) ? { proposedTarget: true } : {}), candidate: candidateRoot ? { ...images.get(`1:${index}`), baseRevision: projects[0].revision, proposal } : null }));
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { AsyncLocalStorage } from "node:async_hooks";
|
|
2
|
+
|
|
3
|
+
// One read-only request (tool call, resource read or preview wait) captures the
|
|
4
|
+
// project's inputs once. Digests stay content-based: the scope only removes
|
|
5
|
+
// repeated walks within that request and is discarded with it.
|
|
6
|
+
const scope = new AsyncLocalStorage();
|
|
7
|
+
|
|
8
|
+
/** Run read-only work in one input revision; nested calls join the outer request.
|
|
9
|
+
* `own` starts a separate revision even inside a request: background passes
|
|
10
|
+
* (polling, refresh loops) must not inherit the walk of the request that
|
|
11
|
+
* happened to start them. */
|
|
12
|
+
let scopes = 0;
|
|
13
|
+
export function withInputRequestScope(run, { own = false, label = "request" } = {}) {
|
|
14
|
+
return scope.getStore() && !own ? run() : scope.run({ inputs: new Map(), id: `${label}#${++scopes}` }, run);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
/** Profiling label of the current request scope, if any. */
|
|
18
|
+
export const inputRequestScopeId = () => scope.getStore()?.id;
|
|
19
|
+
|
|
20
|
+
/** Long-lived work (child processes, timers, shared tasks) started during a
|
|
21
|
+
* request must not keep that request's revision alive or answer from it later. */
|
|
22
|
+
export function outsideInputRequestScope(run) {
|
|
23
|
+
return scope.getStore() ? scope.exit(run) : run();
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
const omitted = new Set(["signal"]);
|
|
27
|
+
/** Every serializable option can affect membership; functions/signals cannot. */
|
|
28
|
+
export function inputScopeKey(options) {
|
|
29
|
+
return JSON.stringify(options, (key, value) => (omitted.has(key) || typeof value === "function" ? undefined : value));
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Reuse this request's walk for `key`. `fresh` re-walks and replaces it (a
|
|
34
|
+
* content fence after long work). `observed` names external evidence, such as
|
|
35
|
+
* the build report bytes: a different value than the walk was paired with means
|
|
36
|
+
* something changed since, so the inputs are walked again.
|
|
37
|
+
* `contents` asks for file bytes to replay to an onFile consumer.
|
|
38
|
+
*/
|
|
39
|
+
export function scopedInputs(key, walk, { fresh = false, observed, contents = false } = {}) {
|
|
40
|
+
const store = scope.getStore();
|
|
41
|
+
if (!store) return walk(contents);
|
|
42
|
+
let entry = store.inputs.get(key);
|
|
43
|
+
const changed = observed !== undefined && entry?.observed !== undefined && entry.observed !== observed;
|
|
44
|
+
if (!entry || fresh || changed || (contents && !entry.contents)) {
|
|
45
|
+
entry = { promise: walk(contents), contents };
|
|
46
|
+
store.inputs.set(key, entry);
|
|
47
|
+
// A failed walk must not answer later reads in the same request.
|
|
48
|
+
entry.promise.catch(() => {
|
|
49
|
+
if (store.inputs.get(key) === entry) store.inputs.delete(key);
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
if (observed !== undefined) entry.observed = observed;
|
|
53
|
+
return entry.promise;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/** Test/profiling hook: whether the caller runs inside a request scope. */
|
|
57
|
+
export const inInputRequestScope = () => scope.getStore() !== undefined;
|
|
@@ -5,6 +5,7 @@ import { z } from "zod";
|
|
|
5
5
|
import { isInside, projectPath, loadConfig } from "../config.mjs";
|
|
6
6
|
import { previewSourceRevision } from "../preview-inputs.mjs";
|
|
7
7
|
import { readPreviewManifest } from "../preview-resources.mjs";
|
|
8
|
+
import timing from "../stage-timing.cjs";
|
|
8
9
|
import { livePreviewOptions, previewArtifactPath, withPreviewSession } from "../preview-scope.mjs";
|
|
9
10
|
|
|
10
11
|
import { previewFailureTitle, previewDiagnosticText } from "../preview-failure.mjs";
|
|
@@ -255,15 +256,23 @@ export function createBuildReporter(
|
|
|
255
256
|
}
|
|
256
257
|
|
|
257
258
|
/** Read durable build events; a running process alone never means a fresh build. */
|
|
258
|
-
export
|
|
259
|
+
export function inspectBuildStatus(root, config, options) {
|
|
260
|
+
return timing.timeStage("build-status", () => readBuildStatus(root, config, options));
|
|
261
|
+
}
|
|
262
|
+
async function readBuildStatus(root, config, { session, previewSession, processState, file = buildStatusFile(root) } = {}) {
|
|
259
263
|
const options = withPreviewSession({ root, config: { mcp: config } }, previewSession);
|
|
260
264
|
let report;
|
|
261
265
|
let reportError;
|
|
266
|
+
// The report's exact bytes pair with the input walk: within one request the
|
|
267
|
+
// inputs are walked again only after the compiler reported something new.
|
|
268
|
+
let observed = "absent";
|
|
262
269
|
try {
|
|
263
270
|
if (!isInside(root, path.resolve(file))) throw new Error("Build status must stay inside the project.");
|
|
264
271
|
if (existsSync(file)) {
|
|
265
272
|
if (realpathSync(file) !== file || statSync(file).size > maxBytes) throw new Error("Build status must be a real project file under 256 KiB.");
|
|
266
|
-
|
|
273
|
+
const text = readFileSync(file, "utf8");
|
|
274
|
+
observed = createHash("sha256").update(text).digest("hex");
|
|
275
|
+
report = snapshot.parse(JSON.parse(text));
|
|
267
276
|
if (session && report.session !== session) report = undefined;
|
|
268
277
|
}
|
|
269
278
|
} catch (error) {
|
|
@@ -276,7 +285,7 @@ export async function inspectBuildStatus(root, config, { session, previewSession
|
|
|
276
285
|
let sourceRevision, sourceError;
|
|
277
286
|
if (report?.live || report?.previews.some((entry) => entry.state === "ready")) {
|
|
278
287
|
try {
|
|
279
|
-
sourceRevision = await previewSourceRevision(loadConfig(root), config.apps ?? []);
|
|
288
|
+
sourceRevision = await previewSourceRevision(loadConfig(root), config.apps ?? [], { observed });
|
|
280
289
|
} catch (error) {
|
|
281
290
|
sourceError = `Cannot verify preview inputs: ${error.message}`;
|
|
282
291
|
}
|
package/dist/mcp/mutations.mjs
CHANGED
|
@@ -832,7 +832,7 @@ export function createMutationController(directory, { captures = createCaptureCo
|
|
|
832
832
|
}
|
|
833
833
|
if (!dryRun && captures.store.fingerprint()) {
|
|
834
834
|
try {
|
|
835
|
-
captures.store.promote(await previewSourceRevision(loadConfig(root)), (await analyze(root, "registry")).scenarios);
|
|
835
|
+
captures.store.promote(await previewSourceRevision(loadConfig(root), [], { fresh: true }), (await analyze(root, "registry")).scenarios);
|
|
836
836
|
} catch (error) {
|
|
837
837
|
warnings.push({ rule: "mutation-capture", message: `Source was applied; capture promotion needs recovery: ${error.message}` });
|
|
838
838
|
}
|
|
@@ -10,6 +10,8 @@ import { developmentExecutable } from "../development-runtime.mjs";
|
|
|
10
10
|
import { readPreviewManifest } from "../preview-resources.mjs";
|
|
11
11
|
import { activeNow } from "../active-clock.mjs";
|
|
12
12
|
import { loadConfig } from "../config.mjs";
|
|
13
|
+
import timing from "../stage-timing.cjs";
|
|
14
|
+
import { outsideInputRequestScope, withInputRequestScope } from "../input-scope.mjs";
|
|
13
15
|
|
|
14
16
|
/** ADS's own preview compiler, the one way previews are built: Bun, watching the project. */
|
|
15
17
|
export function adsPreviewCompiler() {
|
|
@@ -123,8 +125,12 @@ export function createPreviewWatch(
|
|
|
123
125
|
if (failure.code !== "ESRCH") throw failure;
|
|
124
126
|
}
|
|
125
127
|
}
|
|
128
|
+
// The compiler child, its handlers and timers outlive any one request.
|
|
126
129
|
function start() {
|
|
127
130
|
if (disposed || suspended || state !== "idle") return;
|
|
131
|
+
outsideInputRequestScope(startChild);
|
|
132
|
+
}
|
|
133
|
+
function startChild() {
|
|
128
134
|
for (const app of config.apps) {
|
|
129
135
|
const file = path.resolve(root, app.file);
|
|
130
136
|
baselines.set(file, stamp(file));
|
|
@@ -219,7 +225,7 @@ export function createPreviewWatch(
|
|
|
219
225
|
}
|
|
220
226
|
|
|
221
227
|
async function restart() {
|
|
222
|
-
return (restarting ??= (async () => {
|
|
228
|
+
return (restarting ??= outsideInputRequestScope(async () => {
|
|
223
229
|
await stopChild();
|
|
224
230
|
if (disposed) return;
|
|
225
231
|
if (!delegate) rmSync(controlFile(), { force: true });
|
|
@@ -235,12 +241,17 @@ export function createPreviewWatch(
|
|
|
235
241
|
active = undefined;
|
|
236
242
|
stalled = false;
|
|
237
243
|
start();
|
|
238
|
-
})
|
|
244
|
+
}).finally(() => {
|
|
239
245
|
restarting = undefined;
|
|
240
246
|
}));
|
|
241
247
|
}
|
|
242
248
|
|
|
243
|
-
|
|
249
|
+
// One input revision for the whole wait: status reads walk the inputs again
|
|
250
|
+
// only when the compiler's report changed (a build, restart or failure).
|
|
251
|
+
function ensure(file, signal, options) {
|
|
252
|
+
return timing.timeStage("preview-ensure", () => withInputRequestScope(() => ensurePreview(file, signal, options), { label: "preview-ensure" }));
|
|
253
|
+
}
|
|
254
|
+
async function ensurePreview(file, signal, { waitFor = "verified" } = {}) {
|
|
244
255
|
if (signal?.aborted) throw new Error("Preview request cancelled.");
|
|
245
256
|
if (suspended) {
|
|
246
257
|
const current = (await buildStatus()).previews.find((entry) => config.apps.some((app) => path.resolve(root, app.file) === file && app.id === entry.id));
|
package/dist/mcp/server.mjs
CHANGED
|
@@ -37,6 +37,7 @@ import { createPreviewWork } from "./preview-work.mjs";
|
|
|
37
37
|
import { createCaptureController } from "../capture.mjs";
|
|
38
38
|
import { CAPTURES_URI, captureSpec } from "../capture-store.mjs";
|
|
39
39
|
import { previewSourceRevision } from "../preview-inputs.mjs";
|
|
40
|
+
import { outsideInputRequestScope, withInputRequestScope } from "../input-scope.mjs";
|
|
40
41
|
import { createExecutionResults, RESULTS_URI, resultSections } from "./execution-results.mjs";
|
|
41
42
|
import { behaviorSections } from "./behavior-pages.mjs";
|
|
42
43
|
import { compactProgress, resultBudgets } from "./result-pages.mjs";
|
|
@@ -270,10 +271,11 @@ export async function createAdsMcp(
|
|
|
270
271
|
return stored;
|
|
271
272
|
}
|
|
272
273
|
if (cache.registryTask?.revision !== revision) {
|
|
273
|
-
|
|
274
|
+
// Shared by later requests: start it outside this request's revision.
|
|
275
|
+
const inspector = (cache.registryInspector ??= outsideInputRequestScope(() => createScenarioInspector(root)));
|
|
274
276
|
const task = {
|
|
275
277
|
revision,
|
|
276
|
-
promise: inspector.inspect(),
|
|
278
|
+
promise: outsideInputRequestScope(() => inspector.inspect()),
|
|
277
279
|
};
|
|
278
280
|
cache.registryTask = task;
|
|
279
281
|
void task.promise
|
|
@@ -283,7 +285,7 @@ export async function createAdsMcp(
|
|
|
283
285
|
.catch(() => {});
|
|
284
286
|
}
|
|
285
287
|
const registry = await cache.registryTask.promise;
|
|
286
|
-
if ((await previewSourceRevision(loadConfig(root))) !== revision) continue;
|
|
288
|
+
if ((await previewSourceRevision(loadConfig(root), [], { fresh: true })) !== revision) continue;
|
|
287
289
|
cache.registry = cache.lastRegistry = registry;
|
|
288
290
|
cache.registryRevision = revision;
|
|
289
291
|
cache.catalog = undefined;
|
|
@@ -371,10 +373,10 @@ export async function createAdsMcp(
|
|
|
371
373
|
const revision = cache.registryRevision;
|
|
372
374
|
if (cache.catalog && cache.catalogRevision === revision) return cache.catalog;
|
|
373
375
|
if (cache.catalogTask?.revision !== revision) {
|
|
374
|
-
const inspector = (cache.registryInspector ??= createScenarioInspector(root));
|
|
376
|
+
const inspector = (cache.registryInspector ??= outsideInputRequestScope(() => createScenarioInspector(root)));
|
|
375
377
|
const task = {
|
|
376
378
|
revision,
|
|
377
|
-
promise: inspector.inspect(root, "catalog"),
|
|
379
|
+
promise: outsideInputRequestScope(() => inspector.inspect(root, "catalog")),
|
|
378
380
|
};
|
|
379
381
|
cache.catalogTask = task;
|
|
380
382
|
void task.promise
|
|
@@ -384,7 +386,7 @@ export async function createAdsMcp(
|
|
|
384
386
|
.catch(() => {});
|
|
385
387
|
}
|
|
386
388
|
const value = await cache.catalogTask.promise;
|
|
387
|
-
if ((await previewSourceRevision(loadConfig(root))) !== revision) continue;
|
|
389
|
+
if ((await previewSourceRevision(loadConfig(root), [], { fresh: true })) !== revision) continue;
|
|
388
390
|
cache.catalog = value.catalog;
|
|
389
391
|
cache.catalogRevision = revision;
|
|
390
392
|
cache.behaviorLibraries = {
|
|
@@ -828,7 +830,12 @@ export async function createAdsMcp(
|
|
|
828
830
|
signal?.throwIfAborted();
|
|
829
831
|
return { graph, readAsset: id => { signal?.throwIfAborted(); return readPreviewAsset(options, id, graph); } };
|
|
830
832
|
}
|
|
831
|
-
|
|
833
|
+
// Accepted-project reads share one input revision per request. Draft reads
|
|
834
|
+
// keep their own lifecycle (they may refresh the draft workspace first).
|
|
835
|
+
function read(uri, signal) {
|
|
836
|
+
return uri.startsWith("ads://drafts/") ? readResource(uri, signal) : withInputRequestScope(() => readResource(uri, signal), { label: `resource:${uri}` });
|
|
837
|
+
}
|
|
838
|
+
async function readResource(uri, signal) {
|
|
832
839
|
if (uri === `${PROJECT_URI}/explorer`)
|
|
833
840
|
return {
|
|
834
841
|
contents: [
|
|
@@ -1237,7 +1244,15 @@ export async function createAdsMcp(
|
|
|
1237
1244
|
} else await refresh();
|
|
1238
1245
|
return result;
|
|
1239
1246
|
}
|
|
1247
|
+
// Read-only accepted-project tools; mutations, validation, captures and
|
|
1248
|
+
// drafts keep fresh reads at every fence.
|
|
1249
|
+
const requestScopedTools = new Set(["ads_status", "ads_catalog", "ads_scenarios", "ads_show_scenario"]);
|
|
1240
1250
|
function tools() {
|
|
1251
|
+
return toolDefinitions().map((tool) =>
|
|
1252
|
+
requestScopedTools.has(tool.name) ? { ...tool, call: (...args) => withInputRequestScope(() => tool.call(...args), { label: `tool:${tool.name}` }) } : tool,
|
|
1253
|
+
);
|
|
1254
|
+
}
|
|
1255
|
+
function toolDefinitions() {
|
|
1241
1256
|
return [
|
|
1242
1257
|
{
|
|
1243
1258
|
name: "ads_drafts",
|
|
@@ -2213,7 +2228,8 @@ export async function createAdsMcp(
|
|
|
2213
2228
|
refreshAgain = false;
|
|
2214
2229
|
const forced = refreshForced;
|
|
2215
2230
|
refreshForced = false;
|
|
2216
|
-
|
|
2231
|
+
// One input revision per observation pass (each status read used to walk again).
|
|
2232
|
+
changed = (await withInputRequestScope(() => refreshOnce(forced), { own: true, label: "observe" })) || changed;
|
|
2217
2233
|
}
|
|
2218
2234
|
return changed;
|
|
2219
2235
|
})
|
|
@@ -6,6 +6,7 @@ import { Readable } from "node:stream";
|
|
|
6
6
|
import { createMcpHandler, isLegacyRequest, WebStandardStreamableHTTPServerTransport } from "@modelcontextprotocol/server";
|
|
7
7
|
import { serveShowcaseHttp, showcaseHttpEvents } from "./showcase-http.mjs";
|
|
8
8
|
import { startSandboxHost } from "./sandbox-host.mjs";
|
|
9
|
+
import timing from "../stage-timing.cjs";
|
|
9
10
|
|
|
10
11
|
const maxRequestBodySize = 2 * 1024 * 1024,
|
|
11
12
|
maxLegacySessions = 64;
|
|
@@ -147,7 +148,7 @@ export async function startShowcaseHost(factory, { port = 0, observe } = {}) {
|
|
|
147
148
|
if (!service) { res.writeHead(503); res.end("Showcase service unavailable."); return; }
|
|
148
149
|
const abort = new AbortController(); requests.add(abort);
|
|
149
150
|
res.once("close", () => { requests.delete(abort); abort.abort(); });
|
|
150
|
-
await serveShowcaseHttp(req, res, route.slice(5) + url.search, service, abort.signal);
|
|
151
|
+
await timing.timeStage(`showcase-api:${req.method} ${route.slice(5).replace(/^drafts\/[^/]+\//, "drafts/*/")}`, () => serveShowcaseHttp(req, res, route.slice(5) + url.search, service, abort.signal));
|
|
151
152
|
return;
|
|
152
153
|
}
|
|
153
154
|
const asset = assets.get(route);
|
package/dist/preview-inputs.mjs
CHANGED
|
@@ -3,14 +3,19 @@ import path from "node:path";
|
|
|
3
3
|
import { isScenarioFile } from "./config.mjs";
|
|
4
4
|
import { scenarioGroupFingerprint } from "./scenario-groups.mjs";
|
|
5
5
|
import { validationInputFiles } from "./validation-inputs.mjs";
|
|
6
|
+
import timing from "./stage-timing.cjs";
|
|
6
7
|
|
|
7
8
|
/** Shared source evidence for compilation, watch recovery and status reads. */
|
|
8
|
-
|
|
9
|
+
/** `fence`: { fresh } re-walks after long work; { observed } pairs the walk with external evidence. */
|
|
10
|
+
export function previewSourceRevision(options,apps=[],fence={}){
|
|
11
|
+
return timing.timeStage("preview-source-revision", () => sourceRevision(options,apps,fence));
|
|
12
|
+
}
|
|
13
|
+
async function sourceRevision(options,apps,fence){
|
|
9
14
|
const {root} = options;
|
|
10
15
|
const rows = [];
|
|
11
16
|
const scenarios = [];
|
|
12
17
|
const outputs = new Set(apps.map(app => path.resolve(root,app.file)));
|
|
13
|
-
for (const [relative,digest] of Object.entries(await validationInputFiles(options))){
|
|
18
|
+
for (const [relative,digest] of Object.entries(await validationInputFiles(options,[],fence))){
|
|
14
19
|
const file=path.resolve(root,relative);
|
|
15
20
|
if (outputs.has(file)) continue;
|
|
16
21
|
rows.push([relative,digest]);
|
|
@@ -121,7 +121,7 @@ export async function prepareScenarioRegistryTransfer(candidate, target) {
|
|
|
121
121
|
registry = read(candidate, revision);
|
|
122
122
|
if (!registry) return null;
|
|
123
123
|
return async () => {
|
|
124
|
-
if ((await previewSourceRevision(target)) !== revision || !validRegistry(registry, target)) return false;
|
|
124
|
+
if ((await previewSourceRevision(target, [], { fresh: true })) !== revision || !validRegistry(registry, target)) return false;
|
|
125
125
|
write(target, revision, registry);
|
|
126
126
|
return true;
|
|
127
127
|
};
|
|
@@ -140,7 +140,7 @@ export async function discoverScenarioRegistry(options) {
|
|
|
140
140
|
const cached = read(current, revision);
|
|
141
141
|
if (cached) return cached;
|
|
142
142
|
const registry = await inspectScenarios(current, await programFor(current.root).build(current));
|
|
143
|
-
if (revision !== (await previewSourceRevision(loadConfig(current.root)))) continue;
|
|
143
|
+
if (revision !== (await previewSourceRevision(loadConfig(current.root), [], { fresh: true }))) continue;
|
|
144
144
|
write(current, revision, registry);
|
|
145
145
|
return registry;
|
|
146
146
|
}
|
package/dist/stage-timing.cjs
CHANGED
|
@@ -2,11 +2,12 @@ const { appendFileSync } = require("node:fs");
|
|
|
2
2
|
const { performance } = require("node:perf_hooks");
|
|
3
3
|
|
|
4
4
|
/** Opt-in development tracing, inherited by compiler children. No output normally. */
|
|
5
|
-
function timeStage(stage, run) {
|
|
5
|
+
function timeStage(stage, run, detail) {
|
|
6
6
|
const output = process.env.ADS_PROFILE_STAGES;
|
|
7
7
|
if (!output) return run();
|
|
8
8
|
const started = performance.now();
|
|
9
|
-
const
|
|
9
|
+
const extra = typeof detail === "function" ? detail() : detail;
|
|
10
|
+
const record = () => appendFileSync(output, JSON.stringify({ stage, pid: process.pid, ms: performance.now() - started, ...extra }) + "\n");
|
|
10
11
|
let pending = false;
|
|
11
12
|
try {
|
|
12
13
|
const result = run();
|
|
@@ -11,6 +11,7 @@ import { configurationFiles } from "./units.mjs";
|
|
|
11
11
|
import { createPreviewFileFilter } from "./preview-files.mjs";
|
|
12
12
|
import { projectNoticeFiles } from "./project-documents.mjs";
|
|
13
13
|
import timing from "./stage-timing.cjs";
|
|
14
|
+
import { inInputRequestScope, inputRequestScopeId, inputScopeKey, scopedInputs } from "./input-scope.mjs";
|
|
14
15
|
|
|
15
16
|
const digest = (file) => `sha256:${createHash("sha256").update(readFileSync(file)).digest("hex")}`;
|
|
16
17
|
const ignored = new Set(["output", "test-results", "playwright-report", ".playwright-cli"]);
|
|
@@ -54,9 +55,26 @@ async function references(file, content, revision) {
|
|
|
54
55
|
return result;
|
|
55
56
|
}
|
|
56
57
|
|
|
57
|
-
/** Mandatory UI/guard inputs, real local dependencies and declared opaque inputs.
|
|
58
|
-
|
|
59
|
-
|
|
58
|
+
/** Mandatory UI/guard inputs, real local dependencies and declared opaque inputs.
|
|
59
|
+
* Inside a read-only request scope, unbounded captures share one walk; `fresh`
|
|
60
|
+
* re-walks (a content fence) and `observed` re-walks when paired evidence changed. */
|
|
61
|
+
export function validationInputFiles(options, extraFiles = [], { fresh, observed, ...limits } = {}) {
|
|
62
|
+
const capture = (bounds) =>
|
|
63
|
+
timing.timeStage("input-capture", () => withModuleResolutionScope(() => captureInputs(options, extraFiles, bounds)), () => ({ scope: inputRequestScopeId() }));
|
|
64
|
+
if (!inInputRequestScope() || extraFiles.length || limits.maxFiles !== undefined || limits.maxBytes !== undefined) return capture(limits);
|
|
65
|
+
const { onFile } = limits;
|
|
66
|
+
return scopedInputs(
|
|
67
|
+
inputScopeKey(options),
|
|
68
|
+
async (contents) => {
|
|
69
|
+
const files = contents ? new Map() : undefined;
|
|
70
|
+
const digests = await capture(files ? { onFile: (file, content, revision) => files.set(file, [content, revision]) } : {});
|
|
71
|
+
return { digests, files };
|
|
72
|
+
},
|
|
73
|
+
{ fresh, observed, contents: !!onFile },
|
|
74
|
+
).then(({ digests, files }) => {
|
|
75
|
+
if (onFile) for (const [file, [content, revision]] of files) onFile(file, content, revision);
|
|
76
|
+
return { ...digests };
|
|
77
|
+
});
|
|
60
78
|
}
|
|
61
79
|
async function captureInputs(options, extraFiles, { maxFiles = Infinity, maxBytes = Infinity, onFile }) {
|
|
62
80
|
const supplied = options.config;
|
package/docs/ARCHITECTURE.md
CHANGED
|
@@ -940,6 +940,14 @@ Standalone compilation writes `.ds/build-status.json`. Managed compilation uses
|
|
|
940
940
|
`ADS_MCP_BUILD_STATUS` and `ADS_MCP_BUILD_SESSION` launch variables. Session identity
|
|
941
941
|
separates revisions across restarts; source and artifact digests establish
|
|
942
942
|
freshness independently of process state.
|
|
943
|
+
Those source digests come from one content walk per read-only request: a tool
|
|
944
|
+
call such as `ads_show_scenario` or `ads_status`, an accepted-project resource read
|
|
945
|
+
(including the showcase's HTTP reads), one observation pass, or one preview wait.
|
|
946
|
+
Discovery, the registry and build status within that request share it. While a
|
|
947
|
+
request waits for a build, it walks again only after the compiler's status report
|
|
948
|
+
changes. Discovery and capture fence long work with a fresh walk. Mutations, acceptance,
|
|
949
|
+
validation, captures and draft resources keep their own fresh reads. Compiler
|
|
950
|
+
children, timers and shared discovery tasks start outside any request's revision.
|
|
943
951
|
Compilation remains necessary for TSX and Linaria;
|
|
944
952
|
there is one preview pipeline with automatic updates.
|
|
945
953
|
|
package/docs/CHANGELOG.md
CHANGED
|
@@ -2,23 +2,23 @@
|
|
|
2
2
|
|
|
3
3
|
## Unreleased
|
|
4
4
|
|
|
5
|
-
## 0.4.
|
|
5
|
+
## 0.4.6
|
|
6
6
|
|
|
7
7
|
<!-- ads-local-tests:start -->
|
|
8
|
-
Local verification: **
|
|
9
|
-
Tested commit: `
|
|
10
|
-
Completed 2026-11-
|
|
8
|
+
Local verification: **883/883 passed** with `bun run test`.
|
|
9
|
+
Tested commit: `bb29264bf42ad07748f8c70097d76715af87b113`; Bun 1.4.4.
|
|
10
|
+
Completed 2026-11-11T15:06:17.009Z (619 seconds).
|
|
11
11
|
|
|
12
12
|
<!-- ads-local-test-proof
|
|
13
13
|
{
|
|
14
14
|
"schema": 3,
|
|
15
|
-
"version": "0.4.
|
|
16
|
-
"commit": "
|
|
17
|
-
"sourceSha256": "
|
|
15
|
+
"version": "0.4.6",
|
|
16
|
+
"commit": "bb29264bf42ad07748f8c70097d76715af87b113",
|
|
17
|
+
"sourceSha256": "4a6b98cb086f3ede9f1986b9dece7e997a04c747dfc27a63d70c2af2b94c18a4",
|
|
18
18
|
"command": "bun run test",
|
|
19
19
|
"result": "pass",
|
|
20
|
-
"tests":
|
|
21
|
-
"pass":
|
|
20
|
+
"tests": 883,
|
|
21
|
+
"pass": 883,
|
|
22
22
|
"fail": 0,
|
|
23
23
|
"skipped": 0,
|
|
24
24
|
"groups": [
|
|
@@ -28,15 +28,15 @@ Completed 2026-11-11T07:40:07.975Z (1184 seconds).
|
|
|
28
28
|
"pass": 94,
|
|
29
29
|
"fail": 0,
|
|
30
30
|
"skipped": 0,
|
|
31
|
-
"reportSha256": "
|
|
31
|
+
"reportSha256": "6f9b3efeb096563dc697bf3205eb1900da7bbe7a19a57ba7cdd4b59aa8ab9664"
|
|
32
32
|
},
|
|
33
33
|
{
|
|
34
34
|
"name": "integration",
|
|
35
|
-
"tests":
|
|
36
|
-
"pass":
|
|
35
|
+
"tests": 628,
|
|
36
|
+
"pass": 628,
|
|
37
37
|
"fail": 0,
|
|
38
38
|
"skipped": 0,
|
|
39
|
-
"reportSha256": "
|
|
39
|
+
"reportSha256": "ebfd00b27d810cf0490cfb6f56001be00b04452cf3ed67ccf6c862f4102fe538"
|
|
40
40
|
},
|
|
41
41
|
{
|
|
42
42
|
"name": "browser",
|
|
@@ -44,21 +44,31 @@ Completed 2026-11-11T07:40:07.975Z (1184 seconds).
|
|
|
44
44
|
"pass": 161,
|
|
45
45
|
"fail": 0,
|
|
46
46
|
"skipped": 0,
|
|
47
|
-
"reportSha256": "
|
|
47
|
+
"reportSha256": "cd13d1dcd9d666e6f3e8121f91685413029d371f14ee07186067ef0e872f35e2"
|
|
48
48
|
}
|
|
49
49
|
],
|
|
50
|
-
"testOverrides": {
|
|
51
|
-
"ADS_INTEGRATION_WORKERS": "1",
|
|
52
|
-
"ADS_BROWSER_WORKERS": "1"
|
|
53
|
-
},
|
|
50
|
+
"testOverrides": {},
|
|
54
51
|
"bun": "1.4.4",
|
|
55
|
-
"completedAt": "2026-11-
|
|
56
|
-
"durationMs":
|
|
57
|
-
"logSha256": "
|
|
52
|
+
"completedAt": "2026-11-11T15:06:17.009Z",
|
|
53
|
+
"durationMs": 618512,
|
|
54
|
+
"logSha256": "a471ffb30a031272bca4f20fd6a919a77fd341ee6e721cd1e2b8b8dc5fdb8c29"
|
|
58
55
|
}
|
|
59
56
|
-->
|
|
60
57
|
<!-- ads-local-tests:end -->
|
|
61
58
|
|
|
59
|
+
- Preview and explorer requests reuse one content revision. A verified
|
|
60
|
+
`ads_show_scenario` (and the showcase's `/api/previews`) used to walk and hash
|
|
61
|
+
the project's inputs six to eight times; it now walks them once. Explorer and
|
|
62
|
+
build reads, and each one-second observation pass, also walk once. Freshness
|
|
63
|
+
stays content-based: a wait walks again when the compiler reports a new build,
|
|
64
|
+
and discovery/capture fence long work with a fresh walk.
|
|
65
|
+
- `ADS_PROFILE_STAGES` also records `build-status`, `preview-source-revision`,
|
|
66
|
+
`preview-ensure` and `showcase-api:*` stages, and labels each input walk with
|
|
67
|
+
its request scope.
|
|
68
|
+
- Projects need no migration: components, tokens, scenarios and configuration are unchanged.
|
|
69
|
+
|
|
70
|
+
## 0.4.5
|
|
71
|
+
|
|
62
72
|
- Make the local showcase use HTTP by default for discovery, scoped preview actions and checked assets. Keep MCP tools, resources and embedded Apps supported by the same engine; remove the experimental activation requirement.
|
|
63
73
|
- Deliver build reports through SSE, reconnect and reconcile missed updates, and refresh current state when a tab becomes visible. Retained previews show a stale-connection warning; no periodic HTTP browser status polling is required.
|
|
64
74
|
- Combine checked manifest preparation with bounded asset publication, reuse known revisions and pin asset reads to the authorized graph. Keep persistent opaque preview frames and verified Blob loading for worker dependencies.
|
|
@@ -69,61 +79,6 @@ Completed 2026-11-11T07:40:07.975Z (1184 seconds).
|
|
|
69
79
|
|
|
70
80
|
## 0.4.4
|
|
71
81
|
|
|
72
|
-
<!-- ads-local-tests:start -->
|
|
73
|
-
Local verification: **860/860 passed** with `bun run test`.
|
|
74
|
-
Tested commit: `d8d9b2d093ce26d140c037f90e5c9087b8fed46d`; Bun 1.4.4.
|
|
75
|
-
Completed 2026-11-10T14:37:34.287Z (1344 seconds).
|
|
76
|
-
|
|
77
|
-
<!-- ads-local-test-proof
|
|
78
|
-
{
|
|
79
|
-
"schema": 3,
|
|
80
|
-
"version": "0.4.4",
|
|
81
|
-
"commit": "d8d9b2d093ce26d140c037f90e5c9087b8fed46d",
|
|
82
|
-
"sourceSha256": "2ff7cc61caabd96b928581e79ddbc1c6df459145c0039023c2f3400947d46131",
|
|
83
|
-
"command": "bun run test",
|
|
84
|
-
"result": "pass",
|
|
85
|
-
"tests": 860,
|
|
86
|
-
"pass": 860,
|
|
87
|
-
"fail": 0,
|
|
88
|
-
"skipped": 0,
|
|
89
|
-
"groups": [
|
|
90
|
-
{
|
|
91
|
-
"name": "unit",
|
|
92
|
-
"tests": 91,
|
|
93
|
-
"pass": 91,
|
|
94
|
-
"fail": 0,
|
|
95
|
-
"skipped": 0,
|
|
96
|
-
"reportSha256": "896a8879bc0071d3bc822a9a5ee6b32ba78f47c69ac81045534c39bb2e9533c5"
|
|
97
|
-
},
|
|
98
|
-
{
|
|
99
|
-
"name": "integration",
|
|
100
|
-
"tests": 617,
|
|
101
|
-
"pass": 617,
|
|
102
|
-
"fail": 0,
|
|
103
|
-
"skipped": 0,
|
|
104
|
-
"reportSha256": "6ad851727bd92ee38143505e045d8cc7ee3624c0861510efde7beb8f7480d528"
|
|
105
|
-
},
|
|
106
|
-
{
|
|
107
|
-
"name": "browser",
|
|
108
|
-
"tests": 152,
|
|
109
|
-
"pass": 152,
|
|
110
|
-
"fail": 0,
|
|
111
|
-
"skipped": 0,
|
|
112
|
-
"reportSha256": "af3bcf2d9aeb6d80d073763ff346ec142c476c327c9e12b4827e3964c28b841d"
|
|
113
|
-
}
|
|
114
|
-
],
|
|
115
|
-
"testOverrides": {
|
|
116
|
-
"ADS_INTEGRATION_WORKERS": "1",
|
|
117
|
-
"ADS_BROWSER_WORKERS": "1"
|
|
118
|
-
},
|
|
119
|
-
"bun": "1.4.4",
|
|
120
|
-
"completedAt": "2026-11-10T14:37:34.287Z",
|
|
121
|
-
"durationMs": 1343621,
|
|
122
|
-
"logSha256": "dba1d323e6a2d4da20f000f86d75d8955c490d61c55f18765656f5d5bee8ae82"
|
|
123
|
-
}
|
|
124
|
-
-->
|
|
125
|
-
<!-- ads-local-tests:end -->
|
|
126
|
-
|
|
127
82
|
- Load the configured project stylesheet in generated Token and Brand previews. Track inlined CSS import dependencies by contents so same-size/same-time token edits refresh correctly; include Preact refresh helpers in the private compiler graph.
|
|
128
83
|
- Stop draft watcher reconciliation when its controller closes, and skip previews retired while another draft refreshes.
|
|
129
84
|
- Update watched previews through a private incremental module graph inside the existing isolated iframe. Preserve state and focus for compatible React/Preact edits, refresh styles and lazy branches, and reopen safely for incompatible updates or rejected revisions. Keep full Bun builds and native acceptance gates.
|