swarm-engine 1.3.0 → 1.38.0
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/README.md +45 -7
- package/dist/cli/commands/memory.js +117 -0
- package/dist/cli/commands/memory.js.map +1 -1
- package/dist/core/types.d.ts +30 -0
- package/dist/core/types.d.ts.map +1 -1
- package/dist/index.d.ts +46 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +32 -0
- package/dist/index.js.map +1 -1
- package/dist/memory/index.d.ts +37 -0
- package/dist/memory/index.d.ts.map +1 -1
- package/dist/memory/index.js +97 -0
- package/dist/memory/index.js.map +1 -1
- package/dist/runtime/agent-runner.d.ts +10 -0
- package/dist/runtime/agent-runner.d.ts.map +1 -1
- package/dist/runtime/agent-runner.js +71 -3
- package/dist/runtime/agent-runner.js.map +1 -1
- package/dist/runtime/engine.d.ts +18 -0
- package/dist/runtime/engine.d.ts.map +1 -1
- package/dist/runtime/engine.js +306 -2
- package/dist/runtime/engine.js.map +1 -1
- package/dist/runtime/execution-graph.d.ts +86 -0
- package/dist/runtime/execution-graph.d.ts.map +1 -0
- package/dist/runtime/execution-graph.js +441 -0
- package/dist/runtime/execution-graph.js.map +1 -0
- package/dist/runtime/graph-adversarial.d.ts +88 -0
- package/dist/runtime/graph-adversarial.d.ts.map +1 -0
- package/dist/runtime/graph-adversarial.js +378 -0
- package/dist/runtime/graph-adversarial.js.map +1 -0
- package/dist/runtime/graph-analyzer.d.ts +106 -0
- package/dist/runtime/graph-analyzer.d.ts.map +1 -0
- package/dist/runtime/graph-analyzer.js +321 -0
- package/dist/runtime/graph-analyzer.js.map +1 -0
- package/dist/runtime/graph-causal.d.ts +91 -0
- package/dist/runtime/graph-causal.d.ts.map +1 -0
- package/dist/runtime/graph-causal.js +292 -0
- package/dist/runtime/graph-causal.js.map +1 -0
- package/dist/runtime/graph-context-router.d.ts +73 -0
- package/dist/runtime/graph-context-router.d.ts.map +1 -0
- package/dist/runtime/graph-context-router.js +162 -0
- package/dist/runtime/graph-context-router.js.map +1 -0
- package/dist/runtime/graph-discovery.d.ts +71 -0
- package/dist/runtime/graph-discovery.d.ts.map +1 -0
- package/dist/runtime/graph-discovery.js +367 -0
- package/dist/runtime/graph-discovery.js.map +1 -0
- package/dist/runtime/graph-dropout.d.ts +59 -0
- package/dist/runtime/graph-dropout.d.ts.map +1 -0
- package/dist/runtime/graph-dropout.js +196 -0
- package/dist/runtime/graph-dropout.js.map +1 -0
- package/dist/runtime/graph-embeddings.d.ts +58 -0
- package/dist/runtime/graph-embeddings.d.ts.map +1 -0
- package/dist/runtime/graph-embeddings.js +301 -0
- package/dist/runtime/graph-embeddings.js.map +1 -0
- package/dist/runtime/graph-feedback.d.ts +30 -0
- package/dist/runtime/graph-feedback.d.ts.map +1 -0
- package/dist/runtime/graph-feedback.js +82 -0
- package/dist/runtime/graph-feedback.js.map +1 -0
- package/dist/runtime/graph-gnn.d.ts +120 -0
- package/dist/runtime/graph-gnn.d.ts.map +1 -0
- package/dist/runtime/graph-gnn.js +524 -0
- package/dist/runtime/graph-gnn.js.map +1 -0
- package/dist/runtime/graph-learner.d.ts +70 -0
- package/dist/runtime/graph-learner.d.ts.map +1 -0
- package/dist/runtime/graph-learner.js +265 -0
- package/dist/runtime/graph-learner.js.map +1 -0
- package/dist/runtime/graph-meta-adversarial.d.ts +113 -0
- package/dist/runtime/graph-meta-adversarial.d.ts.map +1 -0
- package/dist/runtime/graph-meta-adversarial.js +366 -0
- package/dist/runtime/graph-meta-adversarial.js.map +1 -0
- package/dist/runtime/graph-meta.d.ts +115 -0
- package/dist/runtime/graph-meta.d.ts.map +1 -0
- package/dist/runtime/graph-meta.js +437 -0
- package/dist/runtime/graph-meta.js.map +1 -0
- package/dist/runtime/graph-self-evolve.d.ts +92 -0
- package/dist/runtime/graph-self-evolve.d.ts.map +1 -0
- package/dist/runtime/graph-self-evolve.js +422 -0
- package/dist/runtime/graph-self-evolve.js.map +1 -0
- package/dist/runtime/graph-synthesis.d.ts +47 -0
- package/dist/runtime/graph-synthesis.d.ts.map +1 -0
- package/dist/runtime/graph-synthesis.js +232 -0
- package/dist/runtime/graph-synthesis.js.map +1 -0
- package/dist/runtime/graph-trajectory.d.ts +88 -0
- package/dist/runtime/graph-trajectory.d.ts.map +1 -0
- package/dist/runtime/graph-trajectory.js +339 -0
- package/dist/runtime/graph-trajectory.js.map +1 -0
- package/dist/runtime/learning-engine.d.ts +12 -0
- package/dist/runtime/learning-engine.d.ts.map +1 -1
- package/dist/runtime/learning-engine.js +64 -0
- package/dist/runtime/learning-engine.js.map +1 -1
- package/package.json +2 -2
- package/skills/swarm-output-style/SKILL.md +71 -33
|
@@ -0,0 +1,321 @@
|
|
|
1
|
+
// ─── Analyzer ─────────────────────────────────────────────────────
|
|
2
|
+
/**
|
|
3
|
+
* Pre-execution analysis (centrality, failure prediction) and post-execution
|
|
4
|
+
* insights (topology-driven suggestions) over the execution knowledge graph.
|
|
5
|
+
*
|
|
6
|
+
* All analysis is purely structural — no LLM calls, just graph topology.
|
|
7
|
+
*/
|
|
8
|
+
export class GraphAnalyzer {
|
|
9
|
+
graph;
|
|
10
|
+
constructor(graph) {
|
|
11
|
+
this.graph = graph;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Find "god nodes" — nodes with highest degree, excluding orchestration
|
|
15
|
+
* hubs (which are structurally central by definition, not interesting).
|
|
16
|
+
*/
|
|
17
|
+
findGodNodes(options) {
|
|
18
|
+
const limit = options?.limit ?? 10;
|
|
19
|
+
const typeFilter = options?.type;
|
|
20
|
+
let candidates;
|
|
21
|
+
if (typeFilter) {
|
|
22
|
+
candidates = this.graph.getNodesByType(typeFilter);
|
|
23
|
+
}
|
|
24
|
+
else {
|
|
25
|
+
// Default: phase + agent + file nodes (the interesting ones)
|
|
26
|
+
candidates = [
|
|
27
|
+
...this.graph.getNodesByType('phase'),
|
|
28
|
+
...this.graph.getNodesByType('agent'),
|
|
29
|
+
...this.graph.getNodesByType('file'),
|
|
30
|
+
];
|
|
31
|
+
}
|
|
32
|
+
// Orchestration nodes are hubs by definition — exclude unless explicitly requested
|
|
33
|
+
if (!typeFilter) {
|
|
34
|
+
candidates = candidates.filter((n) => n.type !== 'orchestration');
|
|
35
|
+
}
|
|
36
|
+
const godNodes = candidates.map((node) => {
|
|
37
|
+
const outEdges = this.graph.getEdges(node.id, 'outgoing');
|
|
38
|
+
const inEdges = this.graph.getEdges(node.id, 'incoming');
|
|
39
|
+
const fanOut = new Set(outEdges.map((e) => e.target)).size;
|
|
40
|
+
return {
|
|
41
|
+
node,
|
|
42
|
+
degree: outEdges.length + inEdges.length,
|
|
43
|
+
inDegree: inEdges.length,
|
|
44
|
+
outDegree: outEdges.length,
|
|
45
|
+
fanOut,
|
|
46
|
+
};
|
|
47
|
+
});
|
|
48
|
+
return godNodes.sort((a, b) => b.degree - a.degree).slice(0, limit);
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Sampling-based betweenness centrality approximation.
|
|
52
|
+
*
|
|
53
|
+
* Samples random node pairs, finds shortest paths between them, and counts
|
|
54
|
+
* how often each intermediate node appears on those paths. Nodes that
|
|
55
|
+
* frequently appear as bridges score highest.
|
|
56
|
+
*
|
|
57
|
+
* O(samples × avgPathLength) vs O(V×E) for exact Brandes algorithm.
|
|
58
|
+
* Normalizes by valid paths found (not total samples) for meaningful scores.
|
|
59
|
+
*/
|
|
60
|
+
computeCentrality(sampleSize) {
|
|
61
|
+
const samples = sampleSize ?? 50;
|
|
62
|
+
const centrality = new Map();
|
|
63
|
+
const nodes = [
|
|
64
|
+
...this.graph.getNodesByType('phase'),
|
|
65
|
+
...this.graph.getNodesByType('agent'),
|
|
66
|
+
...this.graph.getNodesByType('file'),
|
|
67
|
+
];
|
|
68
|
+
if (nodes.length < 3)
|
|
69
|
+
return centrality;
|
|
70
|
+
let validPaths = 0;
|
|
71
|
+
for (let i = 0; i < samples; i++) {
|
|
72
|
+
const source = nodes[Math.floor(Math.random() * nodes.length)];
|
|
73
|
+
const target = nodes[Math.floor(Math.random() * nodes.length)];
|
|
74
|
+
if (source.id === target.id)
|
|
75
|
+
continue;
|
|
76
|
+
const path = this.graph.shortestPath(source.id, target.id, 8);
|
|
77
|
+
if (!path || path.nodes.length <= 2)
|
|
78
|
+
continue; // need intermediates
|
|
79
|
+
validPaths++;
|
|
80
|
+
// Only count intermediate nodes (skip endpoints)
|
|
81
|
+
for (let j = 1; j < path.nodes.length - 1; j++) {
|
|
82
|
+
const nodeId = path.nodes[j].id;
|
|
83
|
+
centrality.set(nodeId, (centrality.get(nodeId) ?? 0) + 1);
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
// Normalize by valid path count for meaningful 0–1 scores
|
|
87
|
+
if (validPaths > 0) {
|
|
88
|
+
for (const [id, count] of centrality) {
|
|
89
|
+
centrality.set(id, count / validPaths);
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
return centrality;
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* Predict which agents are most likely to fail based on graph signals:
|
|
96
|
+
*
|
|
97
|
+
* - Historical fail rate for the agent type (min 3 samples)
|
|
98
|
+
* - Files with prior error associations (caused_by edges)
|
|
99
|
+
* - Ambiguous inbound dependencies
|
|
100
|
+
* - High fan-in (more dependencies = more that can go wrong)
|
|
101
|
+
*/
|
|
102
|
+
predictFailures(orchestrationId, files) {
|
|
103
|
+
const predictions = [];
|
|
104
|
+
// Scope agent nodes to orchestration, specific files, or all
|
|
105
|
+
let agentNodes;
|
|
106
|
+
if (files && files.length > 0) {
|
|
107
|
+
// Find agents that have previously touched any of the specified files
|
|
108
|
+
const agentIds = new Set();
|
|
109
|
+
for (const filePath of files) {
|
|
110
|
+
const fileId = filePath.startsWith('file:') ? filePath : `file:${filePath}`;
|
|
111
|
+
const touchEdges = this.graph.getEdges(fileId, 'incoming').filter((e) => e.type === 'touched_file');
|
|
112
|
+
for (const edge of touchEdges) {
|
|
113
|
+
agentIds.add(edge.source);
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
agentNodes = [...agentIds]
|
|
117
|
+
.map((id) => this.graph.getNode(id))
|
|
118
|
+
.filter((n) => n !== null && n.type === 'agent');
|
|
119
|
+
}
|
|
120
|
+
else if (orchestrationId) {
|
|
121
|
+
const subgraph = this.graph.bfs(orchestrationId, 2);
|
|
122
|
+
agentNodes = subgraph.nodes.filter((n) => n.type === 'agent');
|
|
123
|
+
}
|
|
124
|
+
else {
|
|
125
|
+
agentNodes = this.graph.getNodesByType('agent');
|
|
126
|
+
}
|
|
127
|
+
// Build historical fail rates per agent type across the full graph
|
|
128
|
+
const typeStats = new Map();
|
|
129
|
+
for (const agent of this.graph.getNodesByType('agent')) {
|
|
130
|
+
const aType = agent.properties.agentType || agent.label;
|
|
131
|
+
const stats = typeStats.get(aType) ?? { total: 0, failed: 0 };
|
|
132
|
+
stats.total++;
|
|
133
|
+
const status = agent.properties.status;
|
|
134
|
+
if (status === 'error' || status === 'timeout') {
|
|
135
|
+
stats.failed++;
|
|
136
|
+
}
|
|
137
|
+
typeStats.set(aType, stats);
|
|
138
|
+
}
|
|
139
|
+
for (const agent of agentNodes) {
|
|
140
|
+
const aType = agent.properties.agentType || agent.label;
|
|
141
|
+
const stats = typeStats.get(aType);
|
|
142
|
+
// Require minimum 3 samples for historical rate to be meaningful
|
|
143
|
+
const historicalFailRate = stats && stats.total >= 3 ? stats.failed / stats.total : 0;
|
|
144
|
+
const reasons = [];
|
|
145
|
+
let riskScore = historicalFailRate;
|
|
146
|
+
// Check files this agent touches for prior error associations
|
|
147
|
+
const files = this.graph.getNeighbors(agent.id, 'touched_file');
|
|
148
|
+
for (const file of files) {
|
|
149
|
+
const errorEdges = this.graph.getEdges(file.id, 'incoming').filter((e) => e.type === 'caused_by');
|
|
150
|
+
if (errorEdges.length > 0) {
|
|
151
|
+
riskScore += 0.2;
|
|
152
|
+
reasons.push(`File "${file.label}" has ${errorEdges.length} historical error(s)`);
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
// Ambiguous dependencies increase uncertainty
|
|
156
|
+
const ambiguousInEdges = this.graph.getEdges(agent.id, 'incoming').filter((e) => e.confidence === 'AMBIGUOUS');
|
|
157
|
+
if (ambiguousInEdges.length > 0) {
|
|
158
|
+
riskScore += 0.1 * ambiguousInEdges.length;
|
|
159
|
+
reasons.push(`${ambiguousInEdges.length} ambiguous dependency edge(s)`);
|
|
160
|
+
}
|
|
161
|
+
// High fan-in = more can go wrong
|
|
162
|
+
const allInEdges = this.graph.getEdges(agent.id, 'incoming');
|
|
163
|
+
if (allInEdges.length > 5) {
|
|
164
|
+
riskScore += 0.1;
|
|
165
|
+
reasons.push(`High fan-in: ${allInEdges.length} incoming edges`);
|
|
166
|
+
}
|
|
167
|
+
if (historicalFailRate > 0) {
|
|
168
|
+
reasons.push(`Historical fail rate: ${(historicalFailRate * 100).toFixed(0)}% ` + `(${stats.failed}/${stats.total})`);
|
|
169
|
+
}
|
|
170
|
+
if (riskScore > 0 || reasons.length > 0) {
|
|
171
|
+
predictions.push({
|
|
172
|
+
nodeId: agent.id,
|
|
173
|
+
label: agent.label,
|
|
174
|
+
riskScore: Math.min(riskScore, 1),
|
|
175
|
+
reasons,
|
|
176
|
+
historicalFailRate,
|
|
177
|
+
});
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
return predictions.sort((a, b) => b.riskScore - a.riskScore);
|
|
181
|
+
}
|
|
182
|
+
/**
|
|
183
|
+
* Post-execution topology-driven suggestions.
|
|
184
|
+
*
|
|
185
|
+
* Detects structural issues without any LLM:
|
|
186
|
+
* 1. Isolated outputs — agents whose work was never consumed
|
|
187
|
+
* 2. High-centrality bottlenecks — single points of failure
|
|
188
|
+
* 3. Ambiguous dependencies — edges that need verification
|
|
189
|
+
*/
|
|
190
|
+
suggestImprovements(orchestrationId) {
|
|
191
|
+
const suggestions = [];
|
|
192
|
+
let scopeNodes;
|
|
193
|
+
let scopeEdges;
|
|
194
|
+
if (orchestrationId) {
|
|
195
|
+
const subgraph = this.graph.bfs(orchestrationId, 3);
|
|
196
|
+
scopeNodes = subgraph.nodes;
|
|
197
|
+
// Deduplicate edges — BFS collects all edges of each visited node,
|
|
198
|
+
// so edge A→B appears when visiting both A and B
|
|
199
|
+
const seen = new Set();
|
|
200
|
+
scopeEdges = subgraph.edges.filter((e) => {
|
|
201
|
+
const key = `${e.source}:${e.target}:${e.type}`;
|
|
202
|
+
if (seen.has(key))
|
|
203
|
+
return false;
|
|
204
|
+
seen.add(key);
|
|
205
|
+
return true;
|
|
206
|
+
});
|
|
207
|
+
}
|
|
208
|
+
else {
|
|
209
|
+
scopeNodes = [...this.graph.getNodesByType('agent'), ...this.graph.getNodesByType('phase')];
|
|
210
|
+
// Collect relevant edges across all types (not just 'contains')
|
|
211
|
+
const edgeTypes = [
|
|
212
|
+
'contains',
|
|
213
|
+
'spawned',
|
|
214
|
+
'produced',
|
|
215
|
+
'consumed',
|
|
216
|
+
'touched_file',
|
|
217
|
+
'caused_by',
|
|
218
|
+
'learned_from',
|
|
219
|
+
];
|
|
220
|
+
const nodeIds = new Set(scopeNodes.map((n) => n.id));
|
|
221
|
+
const seen = new Set();
|
|
222
|
+
scopeEdges = [];
|
|
223
|
+
for (const edgeType of edgeTypes) {
|
|
224
|
+
for (const edge of this.graph.getEdgesByType(edgeType)) {
|
|
225
|
+
if (nodeIds.has(edge.source) || nodeIds.has(edge.target)) {
|
|
226
|
+
const key = `${edge.source}:${edge.target}:${edge.type}`;
|
|
227
|
+
if (!seen.has(key)) {
|
|
228
|
+
seen.add(key);
|
|
229
|
+
scopeEdges.push(edge);
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
// 1. Isolated outputs: agents that completed but whose output was never consumed
|
|
236
|
+
const agents = scopeNodes.filter((n) => n.type === 'agent');
|
|
237
|
+
for (const agent of agents) {
|
|
238
|
+
if (agent.properties.status !== 'idle')
|
|
239
|
+
continue;
|
|
240
|
+
const producedEdges = this.graph.getEdges(agent.id, 'outgoing').filter((e) => e.type === 'produced');
|
|
241
|
+
const consumedEdges = this.graph.getEdges(agent.id, 'outgoing').filter((e) => e.type === 'consumed');
|
|
242
|
+
if (producedEdges.length === 0 && consumedEdges.length === 0) {
|
|
243
|
+
suggestions.push({
|
|
244
|
+
type: 'isolated_output',
|
|
245
|
+
message: `Agent "${agent.label}" completed but its output was never consumed by downstream agents`,
|
|
246
|
+
nodeIds: [agent.id],
|
|
247
|
+
severity: 'warning',
|
|
248
|
+
});
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
// 2. High-centrality bottlenecks
|
|
252
|
+
const centrality = this.computeCentrality(30);
|
|
253
|
+
const centralityThreshold = 0.3;
|
|
254
|
+
for (const [nodeId, score] of centrality) {
|
|
255
|
+
if (score >= centralityThreshold) {
|
|
256
|
+
const node = this.graph.getNode(nodeId);
|
|
257
|
+
if (node) {
|
|
258
|
+
suggestions.push({
|
|
259
|
+
type: 'high_centrality',
|
|
260
|
+
message: `"${node.label}" is a structural bottleneck (centrality: ${score.toFixed(2)})` +
|
|
261
|
+
` — failure here affects many downstream nodes`,
|
|
262
|
+
nodeIds: [nodeId],
|
|
263
|
+
severity: score >= 0.5 ? 'critical' : 'warning',
|
|
264
|
+
});
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
// 3. Ambiguous dependencies that need human verification
|
|
269
|
+
const ambiguousEdges = scopeEdges.filter((e) => e.confidence === 'AMBIGUOUS');
|
|
270
|
+
if (ambiguousEdges.length > 0) {
|
|
271
|
+
suggestions.push({
|
|
272
|
+
type: 'ambiguous_dependency',
|
|
273
|
+
message: `${ambiguousEdges.length} edge(s) have AMBIGUOUS confidence — verify these dependencies are real`,
|
|
274
|
+
nodeIds: [...new Set(ambiguousEdges.map((e) => e.source))],
|
|
275
|
+
severity: ambiguousEdges.length >= 3 ? 'warning' : 'info',
|
|
276
|
+
});
|
|
277
|
+
}
|
|
278
|
+
return suggestions;
|
|
279
|
+
}
|
|
280
|
+
/**
|
|
281
|
+
* Evaluate whether a phase should proceed, warn, or halt based on
|
|
282
|
+
* reflection confidence and historical pattern success rates.
|
|
283
|
+
*/
|
|
284
|
+
evaluatePhaseConfidence(phase, reflection, patternStats, config) {
|
|
285
|
+
const minHistoricalSuccessRate = config?.minHistoricalSuccessRate ?? 0.3;
|
|
286
|
+
const mediumSuccessThreshold = config?.minHistoricalSuccessRate ? config.minHistoricalSuccessRate + 0.2 : 0.5;
|
|
287
|
+
const haltOnLow = config?.haltOnLowConfidence ?? true;
|
|
288
|
+
const warnOnMedium = config?.warnOnMediumConfidence ?? true;
|
|
289
|
+
if (reflection.confidence === 'low' && patternStats && patternStats.successRate < minHistoricalSuccessRate) {
|
|
290
|
+
return {
|
|
291
|
+
result: haltOnLow ? 'halt' : 'warn',
|
|
292
|
+
reason: `Low confidence reflection combined with poor historical success rate (${Math.round(patternStats.successRate * 100)}%)`,
|
|
293
|
+
confidence: reflection.confidence,
|
|
294
|
+
historicalSuccessRate: patternStats.successRate,
|
|
295
|
+
};
|
|
296
|
+
}
|
|
297
|
+
if (reflection.confidence === 'low') {
|
|
298
|
+
return {
|
|
299
|
+
result: 'warn',
|
|
300
|
+
reason: 'Low confidence reflection — consider re-running or reviewing outputs',
|
|
301
|
+
confidence: reflection.confidence,
|
|
302
|
+
historicalSuccessRate: patternStats?.successRate,
|
|
303
|
+
};
|
|
304
|
+
}
|
|
305
|
+
if (reflection.confidence === 'medium' && patternStats && patternStats.successRate < mediumSuccessThreshold) {
|
|
306
|
+
return {
|
|
307
|
+
result: warnOnMedium ? 'warn' : 'pass',
|
|
308
|
+
reason: `Medium confidence with below-average historical success rate (${Math.round(patternStats.successRate * 100)}%)`,
|
|
309
|
+
confidence: reflection.confidence,
|
|
310
|
+
historicalSuccessRate: patternStats.successRate,
|
|
311
|
+
};
|
|
312
|
+
}
|
|
313
|
+
return {
|
|
314
|
+
result: 'pass',
|
|
315
|
+
reason: 'Phase confidence is acceptable',
|
|
316
|
+
confidence: reflection.confidence,
|
|
317
|
+
historicalSuccessRate: patternStats?.successRate,
|
|
318
|
+
};
|
|
319
|
+
}
|
|
320
|
+
}
|
|
321
|
+
//# sourceMappingURL=graph-analyzer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"graph-analyzer.js","sourceRoot":"","sources":["../../src/runtime/graph-analyzer.ts"],"names":[],"mappings":"AA4CA,qEAAqE;AAErE;;;;;GAKG;AACH,MAAM,OAAO,aAAa;IACJ;IAApB,YAAoB,KAAsB;QAAtB,UAAK,GAAL,KAAK,CAAiB;IAAG,CAAC;IAE9C;;;OAGG;IACH,YAAY,CAAC,OAAkD;QAC7D,MAAM,KAAK,GAAG,OAAO,EAAE,KAAK,IAAI,EAAE,CAAC;QACnC,MAAM,UAAU,GAAG,OAAO,EAAE,IAAI,CAAC;QAEjC,IAAI,UAAuB,CAAC;QAC5B,IAAI,UAAU,EAAE,CAAC;YACf,UAAU,GAAG,IAAI,CAAC,KAAK,CAAC,cAAc,CAAC,UAAU,CAAC,CAAC;QACrD,CAAC;aAAM,CAAC;YACN,6DAA6D;YAC7D,UAAU,GAAG;gBACX,GAAG,IAAI,CAAC,KAAK,CAAC,cAAc,CAAC,OAAO,CAAC;gBACrC,GAAG,IAAI,CAAC,KAAK,CAAC,cAAc,CAAC,OAAO,CAAC;gBACrC,GAAG,IAAI,CAAC,KAAK,CAAC,cAAc,CAAC,MAAM,CAAC;aACrC,CAAC;QACJ,CAAC;QAED,mFAAmF;QACnF,IAAI,CAAC,UAAU,EAAE,CAAC;YAChB,UAAU,GAAG,UAAU,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,KAAK,eAAe,CAAC,CAAC;QACpE,CAAC;QAED,MAAM,QAAQ,GAAc,UAAU,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE;YAClD,MAAM,QAAQ,GAAG,IAAI,CA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CAAC,WAAW,GAAG,GAAG,CAAC,IAAI;gBACvH,UAAU,EAAE,UAAU,CAAC,UAAU;gBACjC,qBAAqB,EAAE,YAAY,CAAC,WAAW;aAChD,CAAC;QACJ,CAAC;QAED,OAAO;YACL,MAAM,EAAE,MAAM;YACd,MAAM,EAAE,gCAAgC;YACxC,UAAU,EAAE,UAAU,CAAC,UAAU;YACjC,qBAAqB,EAAE,YAAY,EAAE,WAAW;SACjD,CAAC;IACJ,CAAC;CACF"}
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import type { ExecutionGraph } from './execution-graph.js';
|
|
2
|
+
export type CausalVar = 'model' | 'agentType' | 'fileSetSize' | 'contextQuality' | 'outcome';
|
|
3
|
+
export interface Observation {
|
|
4
|
+
orchestrationId: string;
|
|
5
|
+
model: string;
|
|
6
|
+
agentType: string;
|
|
7
|
+
fileSetSize: 'small' | 'medium' | 'large';
|
|
8
|
+
contextQuality: 'low' | 'medium' | 'high';
|
|
9
|
+
outcome: 'success' | 'failure';
|
|
10
|
+
}
|
|
11
|
+
export interface CausalEstimate {
|
|
12
|
+
effect: number;
|
|
13
|
+
confidence: 'low' | 'medium' | 'high';
|
|
14
|
+
sampleCount: number;
|
|
15
|
+
adjustedFor: CausalVar[];
|
|
16
|
+
method: 'raw' | 'stratified' | 'backdoor';
|
|
17
|
+
}
|
|
18
|
+
export interface InterventionSuggestion {
|
|
19
|
+
intervention: {
|
|
20
|
+
variable: CausalVar;
|
|
21
|
+
from: string;
|
|
22
|
+
to: string;
|
|
23
|
+
};
|
|
24
|
+
estimatedEffect: number;
|
|
25
|
+
confidence: 'low' | 'medium' | 'high';
|
|
26
|
+
reasoning: string;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Causal inference engine that builds structural causal models from execution
|
|
30
|
+
* traces and estimates causal effects using backdoor adjustment.
|
|
31
|
+
*
|
|
32
|
+
* Extracts observations from the execution knowledge graph, computes normalized
|
|
33
|
+
* mutual information between variables, identifies confounders, and estimates
|
|
34
|
+
* average treatment effects using a tiered approach (raw → stratified → backdoor).
|
|
35
|
+
*/
|
|
36
|
+
export declare class CausalGraphEngine {
|
|
37
|
+
private graph;
|
|
38
|
+
constructor(graph: ExecutionGraph);
|
|
39
|
+
/**
|
|
40
|
+
* Extract observations from the execution graph.
|
|
41
|
+
*
|
|
42
|
+
* Walks orchestration → phase → agent subgraphs via BFS (depth 3),
|
|
43
|
+
* mapping each agent to an observation with model, agentType, fileSetSize,
|
|
44
|
+
* contextQuality, and outcome.
|
|
45
|
+
*/
|
|
46
|
+
extractObservations(orchestrationId?: string): Observation[];
|
|
47
|
+
/**
|
|
48
|
+
* Compute Normalized Mutual Information between two categorical variables.
|
|
49
|
+
*
|
|
50
|
+
* NMI = I(X;Y) / sqrt(H(X) * H(Y))
|
|
51
|
+
* where H(X) = -Σ p(x) log2(p(x))
|
|
52
|
+
* and I(X;Y) = Σ p(x,y) log2(p(x,y) / (p(x)*p(y)))
|
|
53
|
+
*
|
|
54
|
+
* Returns 0 when either variable has zero entropy (constant).
|
|
55
|
+
* Returns 1.0 when a variable is compared with itself.
|
|
56
|
+
*/
|
|
57
|
+
computeNMI(observations: Observation[], var1: CausalVar, var2: CausalVar): number;
|
|
58
|
+
/**
|
|
59
|
+
* Identify confounders for a treatment → outcome relationship.
|
|
60
|
+
*
|
|
61
|
+
* A variable C is a confounder if:
|
|
62
|
+
* NMI(C, treatment) > 0.05 AND NMI(C, outcome) > 0.05
|
|
63
|
+
*/
|
|
64
|
+
identifyConfounders(observations: Observation[], treatment: CausalVar): CausalVar[];
|
|
65
|
+
/**
|
|
66
|
+
* Estimate Average Treatment Effect using a tiered approach:
|
|
67
|
+
*
|
|
68
|
+
* - Tier 1 (N < 3): insufficient data → effect=0, low confidence
|
|
69
|
+
* - Tier 2 (3–9): raw comparison of success rates
|
|
70
|
+
* - Tier 3 (10–49): stratify by top 1 confounder, weighted average
|
|
71
|
+
* - Tier 4 (50+): full backdoor adjustment with all confounders
|
|
72
|
+
*
|
|
73
|
+
* Effect is always clamped to [-1, 1].
|
|
74
|
+
*/
|
|
75
|
+
estimateCausalEffect(treatment: CausalVar, treatmentValue: string, controlValue: string, orchestrationId?: string): CausalEstimate;
|
|
76
|
+
/**
|
|
77
|
+
* Suggest interventions for a failed orchestration by estimating the causal
|
|
78
|
+
* effect of switching each variable to an alternative value observed in
|
|
79
|
+
* historical data.
|
|
80
|
+
*
|
|
81
|
+
* Returns suggestions ranked by estimated effect (descending), filtered
|
|
82
|
+
* to only positive effects.
|
|
83
|
+
*/
|
|
84
|
+
suggestIntervention(failedOrchestrationId: string): InterventionSuggestion[];
|
|
85
|
+
/**
|
|
86
|
+
* Compute stratified ATE: partition observations by confounder strata,
|
|
87
|
+
* compute per-stratum ATE, then take a weighted average (weight = stratum size).
|
|
88
|
+
*/
|
|
89
|
+
private stratifiedATE;
|
|
90
|
+
}
|
|
91
|
+
//# sourceMappingURL=graph-causal.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"graph-causal.d.ts","sourceRoot":"","sources":["../../src/runtime/graph-causal.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAI3D,MAAM,MAAM,SAAS,GAAG,OAAO,GAAG,WAAW,GAAG,aAAa,GAAG,gBAAgB,GAAG,SAAS,CAAC;AAE7F,MAAM,WAAW,WAAW;IAC1B,eAAe,EAAE,MAAM,CAAC;IACxB,KAAK,EAAE,MAAM,CAAC;IACd,SAAS,EAAE,MAAM,CAAC;IAClB,WAAW,EAAE,OAAO,GAAG,QAAQ,GAAG,OAAO,CAAC;IAC1C,cAAc,EAAE,KAAK,GAAG,QAAQ,GAAG,MAAM,CAAC;IAC1C,OAAO,EAAE,SAAS,GAAG,SAAS,CAAC;CAChC;AAED,MAAM,WAAW,cAAc;IAC7B,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,EAAE,KAAK,GAAG,QAAQ,GAAG,MAAM,CAAC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