@reqvire-org/ads 0.3.23 → 0.3.25
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/behaviors.mjs +6 -4
- package/dist/config.mjs +2 -1
- package/dist/contract-migration.mjs +1 -1
- package/dist/contracts.d.mts +2 -2
- package/dist/declarative-flow.mjs +144 -0
- package/dist/mcp/catalog.mjs +4 -2
- package/dist/mcp/mutations.mjs +4 -4
- package/dist/mcp/preview-widget.bundle.js +5 -5
- package/dist/runtime-contracts.mjs +26 -37
- package/dist/scenario-trace.mjs +47 -18
- package/dist/scenarios.mjs +1 -1
- package/dist/showcase/client.bundle.js +15 -15
- package/dist/skills/ads-break-ui/SKILL.md +2 -1
- package/dist/skills/ads-break-ui/references/contracts.md +50 -3
- package/dist/skills/ads-break-ui/references/guarded-editing.md +10 -0
- package/dist/skills/ads-designer/SKILL.md +2 -1
- package/dist/skills/ads-designer/references/contracts.md +50 -3
- package/dist/skills/ads-designer/references/guarded-editing.md +10 -0
- package/dist/skills/ads-import/SKILL.md +2 -1
- package/dist/skills/ads-import/references/contracts.md +50 -3
- package/dist/skills/ads-import/references/guarded-editing.md +10 -0
- package/dist/skills/ads-migrate/SKILL.md +2 -1
- package/dist/skills/ads-migrate/references/contracts.md +50 -3
- package/dist/skills/ads-migrate/references/guarded-editing.md +10 -0
- package/dist/skills/ads-motion/SKILL.md +2 -1
- package/dist/skills/ads-motion/references/contracts.md +50 -3
- package/dist/skills/ads-motion/references/guarded-editing.md +10 -0
- package/dist/source-values.mjs +3 -3
- package/dist/unit-contracts.mjs +23 -4
- package/dist/verification/browser.mjs +2 -0
- package/docs/ARCHITECTURE.md +5 -0
- package/docs/BEHAVIORS.md +8 -0
- package/docs/CHANGELOG.md +21 -0
- package/docs/CONTRACTS.md +50 -3
- package/docs/GUIDE.md +3 -1
- package/docs/MCP.md +23 -4
- package/package.json +1 -1
package/dist/behaviors.mjs
CHANGED
|
@@ -15,7 +15,7 @@ const id = z.string().regex(/^[a-zA-Z0-9][\w.-]{0,99}$/);
|
|
|
15
15
|
const reference = z.string().min(1).max(500);
|
|
16
16
|
const subject = z.union([
|
|
17
17
|
z.object({ api: reference }).strict(),
|
|
18
|
-
z.object({ source: reference, symbol: reference.optional() }).strict(),
|
|
18
|
+
z.object({ source: reference, symbol: reference.optional(), role:z.enum(["controller","implementation"]).optional() }).strict(),
|
|
19
19
|
]);
|
|
20
20
|
export const behaviorSchema = z.object({
|
|
21
21
|
schemaVersion: z.literal(1),
|
|
@@ -92,7 +92,9 @@ export function inspectBehaviors(options, suppliedProgram, suppliedRegistry) {
|
|
|
92
92
|
for(const entry of [...Object.values(declaration?.bindings??{}),...(declaration?.declarativeParts??[])])for(const name of entry.checks) {
|
|
93
93
|
const check=value.checks[name],scenario=check&&scenarios.find(scenario=>scenario.id===check.scenario);
|
|
94
94
|
const parent=entry.parentName??entry.scope.apiName;
|
|
95
|
-
|
|
95
|
+
const roots=entry.rootNames??[parent];
|
|
96
|
+
const nested=declaration?.declarativeParts?.some(part=>part.apiName===parent);
|
|
97
|
+
if(!check||config.mcp.behaviorProfiles[check.profile]?.mode!=="browser"||!roots.some(root=>scenario?.covers.includes(root))||entry.parentName&&(!scenario?.exercises?.includes(entry.apiName)||nested&&!scenario?.exercises?.includes(parent)))report(`Required contract check ${name} must use a browser profile and a scenario covering a rendering root (${roots.join(", ")||parent})${entry.parentName?` and exercising ${entry.apiName}${nested?` through ${parent}`:""}`:""}. Source registration does not establish rendered behavior.`);
|
|
96
98
|
if(!value.guarantees.some(guarantee=>guarantee.checks.includes(name)))report(`Required contract check ${name} must back a named guarantee, not remain an unclaimed execution.`);
|
|
97
99
|
}
|
|
98
100
|
contracts.push({ ...value, unit, file: relative(file), demonstrations: Object.fromEntries(Object.entries(value.subjects).filter(([, item]) => item.api).map(([name, item]) => [name, scenarios.filter(scenario => scenario.exercises?.includes(item.api)).map(scenario => scenario.id)])) });
|
|
@@ -107,7 +109,7 @@ export function inspectControllers(options, program, report, contracts = []) {
|
|
|
107
109
|
const pkg = existsSync(path.join(root, "package.json")) ? JSON.parse(readFileSync(path.join(root, "package.json"), "utf8")) : {};
|
|
108
110
|
const declared = new Set(Object.keys({ ...pkg.dependencies, ...pkg.devDependencies, ...pkg.peerDependencies, ...pkg.optionalDependencies }));
|
|
109
111
|
const privateFiles = new Map();
|
|
110
|
-
for (const contract of contracts) for (const subject of Object.values(contract.subjects).filter(item => item.source)) {
|
|
112
|
+
for (const contract of contracts) for (const subject of Object.values(contract.subjects).filter(item => item.source&&item.role!=="implementation")) {
|
|
111
113
|
const file = path.resolve(root, path.dirname(contract.file), subject.source);
|
|
112
114
|
if (!privateFiles.has(file)) privateFiles.set(file, new Set());
|
|
113
115
|
privateFiles.get(file).add(subject.symbol ?? null);
|
|
@@ -119,7 +121,7 @@ export function inspectControllers(options, program, report, contracts = []) {
|
|
|
119
121
|
const wholeFile = isInside(path.join(dsRoot, "controllers"), file) || privateFiles.get(file)?.has(null);
|
|
120
122
|
const subjects = wholeFile ? [] : checker.getSymbolsInScope(source, ts.SymbolFlags.Value).filter(symbol => privateFiles.get(file)?.has(symbol.name)).flatMap(symbol => symbol.declarations ?? []);
|
|
121
123
|
const headless = node => wholeFile || subjects.some(subject => subject.getSourceFile() === source && node.pos >= subject.pos && node.end <= subject.end);
|
|
122
|
-
function emit(node, rule, message) { const p = source.getLineAndCharacterOfPosition(node.getStart()); report(file, rule, message, p.line + 1, p.character + 1); }
|
|
124
|
+
function emit(node, rule, message) { const p = source.getLineAndCharacterOfPosition(node.getStart()); report(file, rule, message+(rule==="controller-skin"&&!isInside(path.join(dsRoot,"controllers"),file)?' An intentional visual behavior subject can declare role: "implementation"; controller subjects remain headless.':""), p.line + 1, p.character + 1); }
|
|
123
125
|
function visit(node) {
|
|
124
126
|
let specifier;
|
|
125
127
|
if ((ts.isImportDeclaration(node) || ts.isExportDeclaration(node)) && node.moduleSpecifier && ts.isStringLiteralLike(node.moduleSpecifier)) specifier = node.moduleSpecifier.text;
|
package/dist/config.mjs
CHANGED
|
@@ -18,7 +18,7 @@ export const defaultConfig = {
|
|
|
18
18
|
boundaries: { styleWrites: [], componentVariables: [] },
|
|
19
19
|
assets: { publicDirs: ["public/assets"], generatedPaths: ["dist", "dist-showcase", ".vite", ".ds"], generatedFiles: [], iconSource: null },
|
|
20
20
|
oxlint: { plugins: [], rules: {}, overrides: [] },
|
|
21
|
-
mcp: { showcaseUrl: null, showcaseTitle: null, apps: [], previewWatch: null, previewManifest: null, mutationChecks: null, behaviorProfiles: {}, capture: {} },
|
|
21
|
+
mcp: { showcaseUrl: null, showcaseTitle: null, apps: [], previewWatch: null, previewManifest: null, mutationChecks: null, mutationCheckTimeoutMs: 60000, behaviorProfiles: {}, capture: {} },
|
|
22
22
|
};
|
|
23
23
|
|
|
24
24
|
export function isInside(parent, file) {
|
|
@@ -120,6 +120,7 @@ export function loadConfig(directory = process.cwd()) {
|
|
|
120
120
|
if (profile.mode === "strict" && config.framework !== "react") throw new Error(`Behavior profile ${name}: React StrictMode requires framework react; use the configured framework's lifecycle tests instead.`);
|
|
121
121
|
}
|
|
122
122
|
if (config.mcp.mutationChecks !== null && (!Array.isArray(config.mcp.mutationChecks) || config.mcp.mutationChecks.length > 12 || new Set(config.mcp.mutationChecks).size !== config.mcp.mutationChecks.length || config.mcp.mutationChecks.some(name => typeof name !== "string" || !/^[a-zA-Z0-9][\w:.-]*$/.test(name)))) throw new Error("mcp.mutationChecks must be null or up to 12 unique package script names.");
|
|
123
|
+
if (!Number.isInteger(config.mcp.mutationCheckTimeoutMs) || config.mcp.mutationCheckTimeoutMs < 100 || config.mcp.mutationCheckTimeoutMs > 300000) throw new Error("mcp.mutationCheckTimeoutMs must be an integer from 100 to 300000. This budget applies to each registered project script, separately from behavior profiles.");
|
|
123
124
|
if (config.mcp.previewManifest !== null) {
|
|
124
125
|
const manifest = projectPath(root, config.mcp.previewManifest, "mcp.previewManifest");
|
|
125
126
|
if (!isInside(path.join(root, ".ds"), manifest) || path.extname(manifest) !== ".json") throw new Error("mcp.previewManifest must name a generated JSON manifest inside .ds/.");
|
|
@@ -75,7 +75,7 @@ export function migrateContractDraft(options, prepared) {
|
|
|
75
75
|
const subjects={};
|
|
76
76
|
for(const [id,subject]of Object.entries(value.subjects??{})) {
|
|
77
77
|
if(subject.api) {const api=apis.find(api=>api.name===subject.api);if(!api)throw new Error(`Unknown API ${subject.api}`);subjects[id]={api:importReference(slash(path.relative(options.root,api.file)),api.declaration.name?.text??subject.api)};}
|
|
78
|
-
else if(subject.symbol)subjects[id]={implementation:importReference(slash(path.normalize(path.join(path.dirname(file),subject.source))),subject.symbol)};
|
|
78
|
+
else if(subject.symbol)subjects[id]={implementation:importReference(slash(path.normalize(path.join(path.dirname(file),subject.source))),subject.symbol),...(subject.role!==undefined?{role:subject.role}:{})};
|
|
79
79
|
else throw new Error(`Subject ${id} names a whole file. Select an actual implementation symbol before migrating this behavior section.`);
|
|
80
80
|
}
|
|
81
81
|
const {schemaVersion:_version,...behavior}=value;contract.behavior={...behavior,subjects};remove.push(file);
|
package/dist/contracts.d.mts
CHANGED
|
@@ -8,14 +8,14 @@ export interface UnitContract {
|
|
|
8
8
|
bindings?: Readonly<Record<string, {
|
|
9
9
|
input: { api: Implementation; property: string };
|
|
10
10
|
producer: Implementation;
|
|
11
|
-
valueFrom: string;
|
|
11
|
+
valueFrom: string | readonly string[];
|
|
12
12
|
variable: string;
|
|
13
13
|
scope: { api: Implementation; selector: string };
|
|
14
14
|
checks: readonly string[];
|
|
15
15
|
}>>;
|
|
16
16
|
declarativeParts?: readonly { api: Implementation; parent: Implementation; consumer: Implementation; checks: readonly string[] }[];
|
|
17
17
|
behavior?: {
|
|
18
|
-
subjects: Readonly<Record<string, { api: Implementation } | { implementation: Implementation }>>;
|
|
18
|
+
subjects: Readonly<Record<string, { api: Implementation } | { implementation: Implementation; role?: "controller" | "implementation" }>>;
|
|
19
19
|
guarantees: readonly { id: string; description: string; subjects: readonly string[]; checks: readonly string[] }[];
|
|
20
20
|
checks: Readonly<Record<string, BehaviorCheck>>;
|
|
21
21
|
};
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
import ts from "typescript";
|
|
2
|
+
import { unwrap } from "./source-values.mjs";
|
|
3
|
+
import { uiOperation } from "./ui-framework.mjs";
|
|
4
|
+
|
|
5
|
+
/** Bounded source provenance for children, selections and projected child props.
|
|
6
|
+
* Unknown transforms and escaped mutable arrays provide no consumption credit. */
|
|
7
|
+
export function createChildFlow({ consumer, calls, bodies, canonical, key, checker }) {
|
|
8
|
+
const merge=sets=>new Set(sets.flatMap(set=>[...set]));
|
|
9
|
+
const empty=()=>new Set();
|
|
10
|
+
function nodes(node,predicate) {const found=[];function visit(item){if(predicate(item))found.push(item);ts.forEachChild(item,visit);}if(node)visit(node);return found;}
|
|
11
|
+
function functionNode(node) {return ts.isVariableDeclaration(node??{})?unwrap(node.initializer):node;}
|
|
12
|
+
function outputs(callback) {
|
|
13
|
+
if(!callback?.body||callback.asteriskToken||callback.modifiers?.some(item=>item.kind===ts.SyntaxKind.AsyncKeyword))return [];
|
|
14
|
+
if(!ts.isBlock(callback.body))return [callback.body];
|
|
15
|
+
return nodes(callback.body,ts.isReturnStatement).filter(node=>{for(let parent=node.parent;parent&&parent!==callback;parent=parent.parent)if(ts.isFunctionLike(parent))return false;return true;}).map(node=>node.expression).filter(Boolean);
|
|
16
|
+
}
|
|
17
|
+
const fn=expression=>functionNode(unwrap(expression)&&canonical(unwrap(expression)))??unwrap(expression);
|
|
18
|
+
const uses=new Map(),cache=new Map();
|
|
19
|
+
const changed=new Set(),aliases=[];
|
|
20
|
+
function rootOf(expression) {
|
|
21
|
+
expression=unwrap(expression);const fields=[];
|
|
22
|
+
while(expression&&(ts.isPropertyAccessExpression(expression)||ts.isElementAccessExpression(expression))){fields.unshift(ts.isPropertyAccessExpression(expression)?expression.name.text:"*");expression=unwrap(expression.expression);}
|
|
23
|
+
return {declaration:expression&&canonical(expression),fields};
|
|
24
|
+
}
|
|
25
|
+
for(const body of bodies)for(const node of nodes(body,node=>ts.isBinaryExpression(node)||ts.isVariableDeclaration(node)||ts.isDeleteExpression(node))) {
|
|
26
|
+
if(ts.isVariableDeclaration(node)&&node.initializer){const root=rootOf(node.initializer);if(root.declaration)aliases.push([node,root.declaration]);}
|
|
27
|
+
else if(ts.isDeleteExpression(node)||ts.isBinaryExpression(node)) {
|
|
28
|
+
const target=ts.isDeleteExpression(node)?node.expression:node.operatorToken.kind>=ts.SyntaxKind.FirstAssignment&&node.operatorToken.kind<=ts.SyntaxKind.LastAssignment?node.left:null;
|
|
29
|
+
if(target){const root=rootOf(target);if(root.declaration&&(!root.fields.length||["*","type","props","map","filter","find","forEach"].includes(root.fields[0])))changed.add(root.declaration);}
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
for(const call of calls)if(ts.isPropertyAccessExpression(call.expression)&&["push","unshift","splice","fill","copyWithin"].includes(call.expression.name.text)) {
|
|
33
|
+
const root=rootOf(call.expression.expression),declaration=root.declaration;
|
|
34
|
+
const initial=declaration&&ts.isVariableDeclaration(declaration)&&unwrap(declaration.initializer);
|
|
35
|
+
if(declaration&&!(initial&&ts.isArrayLiteralExpression(initial)&&!initial.elements.length))changed.add(declaration);
|
|
36
|
+
}
|
|
37
|
+
for(let pass=0;pass<=aliases.length;pass++){const count=changed.size;for(const[alias,target]of aliases)if(changed.has(alias))changed.add(target);if(changed.size===count)break;}
|
|
38
|
+
const add=(target,entry)=>{if(!target?.parameters)return;if(!uses.has(target))uses.set(target,[]);uses.get(target).push(entry);};
|
|
39
|
+
for(const call of calls) {
|
|
40
|
+
add(fn(call.expression),{call,direct:true});
|
|
41
|
+
const operation=uiOperation(call.expression,checker);
|
|
42
|
+
if(["Children.map","Children.forEach"].includes(operation))add(fn(call.arguments[1]),{call,input:call.arguments[0]});
|
|
43
|
+
else if(ts.isPropertyAccessExpression(call.expression)&&["map","forEach","flatMap","filter","find"].includes(call.expression.name.text))add(fn(call.arguments[0]),{call,input:call.expression.expression});
|
|
44
|
+
}
|
|
45
|
+
let budget;
|
|
46
|
+
function selectedInput(expression,seen=new Set()) {
|
|
47
|
+
expression=unwrap(expression);if(!expression||seen.has(expression)||seen.size>32)return false;
|
|
48
|
+
seen=new Set([...seen,expression]);
|
|
49
|
+
if(ts.isCallExpression(expression)&&ts.isPropertyAccessExpression(expression.expression)&&["filter","find"].includes(expression.expression.name.text))return true;
|
|
50
|
+
const declaration=canonical(expression);
|
|
51
|
+
if(changed.has(declaration))return false;
|
|
52
|
+
return !!(declaration&&ts.isVariableDeclaration(declaration)&&declaration.initializer&&selectedInput(declaration.initializer,seen));
|
|
53
|
+
}
|
|
54
|
+
function projected(origins,fields) {
|
|
55
|
+
if(!fields.length||fields.length===1&&fields[0]==="props")return origins;
|
|
56
|
+
if(fields[0]==="props"&&fields[1]==="children")return projected(new Set([...origins].map(origin=>origin+"/children")),fields.slice(2));
|
|
57
|
+
return empty();
|
|
58
|
+
}
|
|
59
|
+
function trace(expression,fields=[],seen=new Set(),active=new Set()) {
|
|
60
|
+
expression=unwrap(expression);
|
|
61
|
+
if(!expression||seen.size>80)return empty();
|
|
62
|
+
if(++budget.steps>12000){budget.exhausted=true;return empty();}
|
|
63
|
+
const marker=key(expression)+":"+expression.kind+":"+expression.end+":"+fields.join(".");if(seen.has(marker))return empty();
|
|
64
|
+
seen=new Set([...seen,marker]);
|
|
65
|
+
if(ts.isPropertyAccessExpression(expression))return trace(expression.expression,[expression.name.text,...fields],seen,active);
|
|
66
|
+
if(ts.isElementAccessExpression(expression)) {
|
|
67
|
+
if(ts.isStringLiteralLike(expression.argumentExpression))return trace(expression.expression,[expression.argumentExpression.text,...fields],seen,active);
|
|
68
|
+
if(expression.argumentExpression&&checker.getTypeAtLocation(expression.argumentExpression).flags&ts.TypeFlags.NumberLike)return trace(expression.expression,fields,seen,active);
|
|
69
|
+
return empty(); // Only numeric array selection retains element provenance.
|
|
70
|
+
}
|
|
71
|
+
if(ts.isObjectLiteralExpression(expression)&&fields.length) {
|
|
72
|
+
const property=expression.properties.findLast(property=>!ts.isSpreadAssignment(property)&&(property.name?.text??property.name?.getText())===fields[0]);
|
|
73
|
+
if(!property||expression.properties.some(ts.isSpreadAssignment))return empty();
|
|
74
|
+
return trace(ts.isShorthandPropertyAssignment(property)?property.name:property.initializer,fields.slice(1),seen,active);
|
|
75
|
+
}
|
|
76
|
+
if(ts.isConditionalExpression(expression))return merge([trace(expression.whenTrue,fields,seen,active),trace(expression.whenFalse,fields,seen,active)]);
|
|
77
|
+
if(ts.isBinaryExpression(expression)&&[ts.SyntaxKind.QuestionQuestionToken,ts.SyntaxKind.BarBarToken,ts.SyntaxKind.AmpersandAmpersandToken].includes(expression.operatorToken.kind))return merge([trace(expression.left,fields,seen,active),trace(expression.right,fields,seen,active)]);
|
|
78
|
+
const declaration=canonical(expression);
|
|
79
|
+
if(changed.has(declaration))return empty();
|
|
80
|
+
if(declaration===consumer?.parameters?.[0]&&fields[0]==="children")return projected(new Set(["children-input"]),fields.slice(1));
|
|
81
|
+
if(declaration&&ts.isBindingElement(declaration)&&ts.isObjectBindingPattern(declaration.parent)&&declaration.parent.parent===consumer?.parameters?.[0]&&(declaration.propertyName??declaration.name).getText()==="children")return projected(new Set(["children-input"]),fields);
|
|
82
|
+
if(declaration&&ts.isVariableDeclaration(declaration)) {
|
|
83
|
+
if(declaration.initializer) {
|
|
84
|
+
const initial=unwrap(declaration.initializer);
|
|
85
|
+
if(ts.isArrayLiteralExpression(initial)&&!initial.elements.length) {
|
|
86
|
+
let owner=declaration.parent;while(owner&&!ts.isFunctionLike(owner))owner=owner.parent;
|
|
87
|
+
const pushes=nodes(owner,ts.isCallExpression).filter(call=>ts.isPropertyAccessExpression(call.expression)&&call.expression.name.text==="push"&&canonical(call.expression.expression)===declaration);
|
|
88
|
+
const escaped=nodes(owner,ts.isIdentifier).some(node=>canonical(node)===declaration&&node!==declaration.name&&!ts.isReturnStatement(node.parent)&&!(ts.isPropertyAccessExpression(node.parent)&&node.parent.expression===node&&pushes.some(call=>call.expression===node.parent)));
|
|
89
|
+
if(escaped||!pushes.length)return empty();
|
|
90
|
+
const values=pushes.flatMap(call=>call.arguments.map(argument=>trace(ts.isSpreadElement(argument)?argument.expression:argument,fields,seen,active)));
|
|
91
|
+
return values.every(value=>value.size)?merge(values):empty();
|
|
92
|
+
}
|
|
93
|
+
return trace(initial,fields,seen,active);
|
|
94
|
+
}
|
|
95
|
+
if(ts.isVariableDeclarationList(declaration.parent)&&ts.isForOfStatement(declaration.parent.parent))return trace(declaration.parent.parent.expression,fields,seen,active);
|
|
96
|
+
}
|
|
97
|
+
if(declaration&&ts.isParameter(declaration)) {
|
|
98
|
+
const callback=declaration.parent,index=callback.parameters.indexOf(declaration),origins=[];
|
|
99
|
+
for(const {call,input,direct}of uses.get(callback)??[]) {
|
|
100
|
+
if(direct){
|
|
101
|
+
let recursive=false;for(let parent=call.parent;parent;parent=parent.parent)if(parent===callback){recursive=true;break;}
|
|
102
|
+
if(!recursive&&call.arguments[index])origins.push(trace(call.arguments[index],fields,seen,active));continue;
|
|
103
|
+
}
|
|
104
|
+
if(index!==0)continue;
|
|
105
|
+
const arrayCall=ts.isPropertyAccessExpression(call.expression)&&["map","forEach","flatMap","filter","find"].includes(call.expression.name.text);
|
|
106
|
+
const source=trace(input,[],seen,active);
|
|
107
|
+
if(source.size) {
|
|
108
|
+
const selected=arrayCall&&["filter","find"].includes(call.expression.name.text);
|
|
109
|
+
const inherited=selectedInput(input);
|
|
110
|
+
const elements=selected||!inherited?new Set([...source].map(origin=>origin+"/"+key(call))):source;
|
|
111
|
+
origins.push(projected(elements,fields));
|
|
112
|
+
}else origins.push(trace(input,fields,seen,active));
|
|
113
|
+
}
|
|
114
|
+
return merge(origins);
|
|
115
|
+
}
|
|
116
|
+
if(ts.isCallExpression(expression)) {
|
|
117
|
+
const operation=uiOperation(expression.expression,checker);
|
|
118
|
+
if(["Children.toArray","toChildArray"].includes(operation))return trace(expression.arguments[0],fields,seen,active);
|
|
119
|
+
if(operation==="useMemo")return merge(outputs(fn(expression.arguments[0])).map(output=>trace(output,fields,seen,active)));
|
|
120
|
+
if(ts.isPropertyAccessExpression(expression.expression)) {
|
|
121
|
+
const method=expression.expression.name.text,input=expression.expression.expression,callback=fn(expression.arguments[0]);
|
|
122
|
+
if(["filter","find"].includes(method)) {
|
|
123
|
+
const source=trace(input,[],seen,active);
|
|
124
|
+
return source.size?projected(new Set([...source].map(origin=>origin+"/"+key(expression))),fields):trace(input,fields,seen,active);
|
|
125
|
+
}
|
|
126
|
+
if(method==="slice")return trace(input,fields,seen,active);
|
|
127
|
+
if(["map","flatMap"].includes(method))return merge(outputs(callback).map(output=>trace(output,fields,seen,active)));
|
|
128
|
+
}
|
|
129
|
+
const helper=fn(expression.expression);
|
|
130
|
+
if(helper?.body) {
|
|
131
|
+
// A recursive flattening call only receives descendants of its input.
|
|
132
|
+
// The outer returned-array proof still validates every push and escape.
|
|
133
|
+
if(active.has(helper))return trace(expression.arguments[0],fields,seen,active);
|
|
134
|
+
return merge(outputs(helper).map(output=>trace(output,fields,seen,new Set([...active,helper]))));
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
return empty();
|
|
138
|
+
}
|
|
139
|
+
return expression=>{
|
|
140
|
+
if(cache.has(expression))return cache.get(expression);
|
|
141
|
+
budget={steps:0,exhausted:false};const result=trace(expression);
|
|
142
|
+
const proven=budget.exhausted?empty():result;cache.set(expression,proven);return proven;
|
|
143
|
+
};
|
|
144
|
+
}
|
package/dist/mcp/catalog.mjs
CHANGED
|
@@ -57,10 +57,12 @@ export function inspectCatalog(options, scenarios = []) {
|
|
|
57
57
|
const line = declaration.getSourceFile().getLineAndCharacterOfPosition(declaration.getStart()).line + 1;
|
|
58
58
|
const guides = documents.filter((doc) => doc.file.endsWith(".md") && path.dirname(doc.file) === path.dirname(file)).map((doc) => doc.uri);
|
|
59
59
|
const contract=contracts.find(contract=>[...(contract.paintInputs??[]),...(contract.declarativeParts??[])].some(input=>input.apiName===exported.name)||Object.values(contract.bindings??{}).some(binding=>binding.apiName===exported.name));
|
|
60
|
-
const
|
|
60
|
+
const relationships=contract?.declarativeParts?.filter(part=>part.apiName===exported.name)??[];
|
|
61
|
+
const declarative=relationships[0];
|
|
62
|
+
const relationship=part=>({parent:part.parentName,roots:(part.rootNames??[part.parentName]).slice(0,8),rootCount:part.rootNames?.length??1,sourceUri:sourceUri(part.consumer.source),symbol:part.consumer.symbol,checks:part.checks.slice(0,8),checkCount:part.checks.length});
|
|
61
63
|
const bindings=Object.entries(contract?.bindings??{}).filter(([,binding])=>binding.apiName===exported.name);
|
|
62
64
|
items.push({ name: exported.name, kind, apiKind: declarative ? "declarative" : ui ? "ui" : "behavior", importFrom: config.publicAlias, file: relative, line, sourceUri: sourceUri(relative), guides,
|
|
63
|
-
...(contract?{contractUri:sourceUri(contract.file),paintInputCount:contract.paintInputs?.filter(input=>input.apiName===exported.name).length??0,paintInputs:contract.paintInputs?.filter(input=>input.apiName===exported.name).slice(0,8).map(input=>({property:input.property,kind:input.kind,bindings:input.bindings??[]})),...(declarative?{consumer:
|
|
65
|
+
...(contract?{contractUri:sourceUri(contract.file),paintInputCount:contract.paintInputs?.filter(input=>input.apiName===exported.name).length??0,paintInputs:contract.paintInputs?.filter(input=>input.apiName===exported.name).slice(0,8).map(input=>({property:input.property,kind:input.kind,bindings:input.bindings??[]})),...(declarative?{consumer:relationship(declarative),consumerCount:relationships.length,consumers:relationships.slice(0,4).map(relationship),evidence:"registered relationships; source and browser verification are separate"}:{})}:{}),
|
|
64
66
|
...(bindings.length?{bindingCount:bindings.length,bindings:bindings.slice(0,4).map(([id,binding])=>({id,variable:binding.variable,scope:binding.scope.selector,producer:{sourceUri:sourceUri(binding.producer.source),symbol:binding.producer.symbol},checks:binding.checks.slice(0,8),checkCount:binding.checks.length})),bindingEvidence:"registered; verify source diagnostics and current browser checks"}:{}),
|
|
65
67
|
previews: scenarios.filter(item => item.covers.includes(exported.name) || item.exercises?.includes(exported.name)).map(item => item.id) });
|
|
66
68
|
}
|
package/dist/mcp/mutations.mjs
CHANGED
|
@@ -109,7 +109,7 @@ function snapshot(options, destination) {
|
|
|
109
109
|
return JSON.stringify(entries);
|
|
110
110
|
}
|
|
111
111
|
|
|
112
|
-
function checkCommand(command, args, cwd, signal, input, gate = {category:"architecture",phase:"patch-preparation"}) {
|
|
112
|
+
function checkCommand(command, args, cwd, signal, input, gate = {category:"architecture",phase:"patch-preparation"}, timeoutMs = 60000) {
|
|
113
113
|
return new Promise((resolve, reject) => {
|
|
114
114
|
if (signal?.aborted) { reject(fail("mutation-cancelled", "Mutation cancelled before validation.",undefined,evidenceFailure("runner","mutation-execution","ADS_CANCELLED"))); return; }
|
|
115
115
|
const child = spawn(command, args, { cwd, shell: false, detached: process.platform !== "win32", windowsHide: true, stdio: [input === undefined ? "ignore" : "pipe", "pipe", "pipe"],
|
|
@@ -126,13 +126,13 @@ function checkCommand(command, args, cwd, signal, input, gate = {category:"archi
|
|
|
126
126
|
}
|
|
127
127
|
const abort = () => { failure = fail("mutation-cancelled", "Mutation cancelled during validation."); kill(); };
|
|
128
128
|
signal?.addEventListener("abort", abort, { once: true });
|
|
129
|
-
const timer = setTimeout(() => { failure = fail("mutation-check", "
|
|
129
|
+
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);
|
|
130
130
|
for (const stream of [child.stdout, child.stderr]) stream.on("data", chunk => { output = (output + chunk.toString()).slice(-12000); });
|
|
131
131
|
child.once("error", error => { failure = error; });
|
|
132
132
|
child.once("exit", kill); // Also clean up descendants of a finished launcher.
|
|
133
133
|
child.once("close", code => {
|
|
134
134
|
clearTimeout(timer); signal?.removeEventListener("abort", abort);
|
|
135
|
-
const detail={command:path.basename(command),args,elapsedMs:Date.now()-startedAt,exitCode:code};
|
|
135
|
+
const detail={command:path.basename(command),args,timeoutMs,elapsedMs:Date.now()-startedAt,exitCode:code};
|
|
136
136
|
if (failure || code !== 0) {
|
|
137
137
|
const error=failure??fail("mutation-check", `${path.basename(command)} ${args.join(" ")} failed (${code}).\n${output}`);
|
|
138
138
|
error.diagnostic={...(error.diagnostic??{rule:"mutation-check",message:error.message}),...detail,output:output.slice(-4000),failure:evidenceFailure(failure?"runner":gate.category,gate.phase,failure?.code??(failure?"ADS_COMMAND_INTERRUPTED":"ADS_COMMAND_EXIT"),{certainty:"observed-boundary"})};
|
|
@@ -297,7 +297,7 @@ export function createMutationController(directory, { captures = createCaptureCo
|
|
|
297
297
|
const brand = await generateBrandAssets(candidate);
|
|
298
298
|
verified.push({ name: "brand assets", passed: true, skipped: !!brand.skipped });
|
|
299
299
|
}
|
|
300
|
-
for (const check of extraChecks) verified.push(await checkCommand(check.command, check.args, candidate, signal, undefined, {category:"build",phase:`project-check:${check.args[1]}`}));
|
|
300
|
+
for (const check of extraChecks) verified.push(await checkCommand(check.command, check.args, candidate, signal, undefined, {category:"build",phase:`project-check:${check.args[1]}`}, candidateOptions.config.mcp.mutationCheckTimeoutMs));
|
|
301
301
|
boundary=evidenceFailure("runner","behavior-verification","ADS_BEHAVIOR_SETUP");
|
|
302
302
|
const behaviorUnits = affectedBehaviorUnits(candidateOptions, changes.map(change => change.path));
|
|
303
303
|
if (behaviorUnits.length) {
|