attocode 0.2.1 → 0.2.3
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/CHANGELOG.md +191 -1
- package/README.md +7 -0
- package/dist/src/adapters.d.ts +6 -1
- package/dist/src/adapters.d.ts.map +1 -1
- package/dist/src/adapters.js +8 -1
- package/dist/src/adapters.js.map +1 -1
- package/dist/src/agent.d.ts +41 -4
- package/dist/src/agent.d.ts.map +1 -1
- package/dist/src/agent.js +846 -75
- package/dist/src/agent.js.map +1 -1
- package/dist/src/cli.d.ts.map +1 -1
- package/dist/src/cli.js +23 -2
- package/dist/src/cli.js.map +1 -1
- package/dist/src/core/protocol/types.d.ts +8 -8
- package/dist/src/defaults.d.ts +7 -2
- package/dist/src/defaults.d.ts.map +1 -1
- package/dist/src/defaults.js +38 -2
- package/dist/src/defaults.js.map +1 -1
- package/dist/src/integrations/agent-registry.d.ts +13 -0
- package/dist/src/integrations/agent-registry.d.ts.map +1 -1
- package/dist/src/integrations/agent-registry.js.map +1 -1
- package/dist/src/integrations/async-subagent.d.ts +135 -0
- package/dist/src/integrations/async-subagent.d.ts.map +1 -0
- package/dist/src/integrations/async-subagent.js +213 -0
- package/dist/src/integrations/async-subagent.js.map +1 -0
- package/dist/src/integrations/auto-checkpoint.d.ts +98 -0
- package/dist/src/integrations/auto-checkpoint.d.ts.map +1 -0
- package/dist/src/integrations/auto-checkpoint.js +252 -0
- package/dist/src/integrations/auto-checkpoint.js.map +1 -0
- package/dist/src/integrations/auto-compaction.d.ts.map +1 -1
- package/dist/src/integrations/auto-compaction.js +5 -1
- package/dist/src/integrations/auto-compaction.js.map +1 -1
- package/dist/src/integrations/bash-policy.d.ts +33 -0
- package/dist/src/integrations/bash-policy.d.ts.map +1 -0
- package/dist/src/integrations/bash-policy.js +142 -0
- package/dist/src/integrations/bash-policy.js.map +1 -0
- package/dist/src/integrations/codebase-context.d.ts +5 -0
- package/dist/src/integrations/codebase-context.d.ts.map +1 -1
- package/dist/src/integrations/codebase-context.js +33 -0
- package/dist/src/integrations/codebase-context.js.map +1 -1
- package/dist/src/integrations/complexity-classifier.d.ts +86 -0
- package/dist/src/integrations/complexity-classifier.d.ts.map +1 -0
- package/dist/src/integrations/complexity-classifier.js +233 -0
- package/dist/src/integrations/complexity-classifier.js.map +1 -0
- package/dist/src/integrations/delegation-protocol.d.ts +86 -0
- package/dist/src/integrations/delegation-protocol.d.ts.map +1 -0
- package/dist/src/integrations/delegation-protocol.js +127 -0
- package/dist/src/integrations/delegation-protocol.js.map +1 -0
- package/dist/src/integrations/dynamic-budget.d.ts +81 -0
- package/dist/src/integrations/dynamic-budget.d.ts.map +1 -0
- package/dist/src/integrations/dynamic-budget.js +151 -0
- package/dist/src/integrations/dynamic-budget.js.map +1 -0
- package/dist/src/integrations/economics.d.ts +86 -1
- package/dist/src/integrations/economics.d.ts.map +1 -1
- package/dist/src/integrations/economics.js +306 -11
- package/dist/src/integrations/economics.js.map +1 -1
- package/dist/src/integrations/environment-facts.d.ts +52 -0
- package/dist/src/integrations/environment-facts.d.ts.map +1 -0
- package/dist/src/integrations/environment-facts.js +84 -0
- package/dist/src/integrations/environment-facts.js.map +1 -0
- package/dist/src/integrations/hierarchical-config.d.ts.map +1 -1
- package/dist/src/integrations/hierarchical-config.js +17 -0
- package/dist/src/integrations/hierarchical-config.js.map +1 -1
- package/dist/src/integrations/index.d.ts +19 -2
- package/dist/src/integrations/index.d.ts.map +1 -1
- package/dist/src/integrations/index.js +34 -2
- package/dist/src/integrations/index.js.map +1 -1
- package/dist/src/integrations/injection-budget.d.ts +71 -0
- package/dist/src/integrations/injection-budget.d.ts.map +1 -0
- package/dist/src/integrations/injection-budget.js +136 -0
- package/dist/src/integrations/injection-budget.js.map +1 -0
- package/dist/src/integrations/mcp-client.d.ts.map +1 -1
- package/dist/src/integrations/mcp-client.js +14 -0
- package/dist/src/integrations/mcp-client.js.map +1 -1
- package/dist/src/integrations/mcp-custom-tools.d.ts +102 -0
- package/dist/src/integrations/mcp-custom-tools.d.ts.map +1 -0
- package/dist/src/integrations/mcp-custom-tools.js +232 -0
- package/dist/src/integrations/mcp-custom-tools.js.map +1 -0
- package/dist/src/integrations/mcp-tool-validator.d.ts +60 -0
- package/dist/src/integrations/mcp-tool-validator.d.ts.map +1 -0
- package/dist/src/integrations/mcp-tool-validator.js +141 -0
- package/dist/src/integrations/mcp-tool-validator.js.map +1 -0
- package/dist/src/integrations/policy-engine.d.ts +55 -0
- package/dist/src/integrations/policy-engine.d.ts.map +1 -0
- package/dist/src/integrations/policy-engine.js +247 -0
- package/dist/src/integrations/policy-engine.js.map +1 -0
- package/dist/src/integrations/safety.d.ts +5 -4
- package/dist/src/integrations/safety.d.ts.map +1 -1
- package/dist/src/integrations/safety.js +32 -7
- package/dist/src/integrations/safety.js.map +1 -1
- package/dist/src/integrations/sandbox/basic.d.ts +7 -0
- package/dist/src/integrations/sandbox/basic.d.ts.map +1 -1
- package/dist/src/integrations/sandbox/basic.js +27 -2
- package/dist/src/integrations/sandbox/basic.js.map +1 -1
- package/dist/src/integrations/sandbox/index.d.ts +6 -0
- package/dist/src/integrations/sandbox/index.d.ts.map +1 -1
- package/dist/src/integrations/sandbox/index.js +3 -0
- package/dist/src/integrations/sandbox/index.js.map +1 -1
- package/dist/src/integrations/sandbox/landlock.d.ts.map +1 -1
- package/dist/src/integrations/sandbox/landlock.js +3 -0
- package/dist/src/integrations/sandbox/landlock.js.map +1 -1
- package/dist/src/integrations/self-improvement.d.ts +90 -0
- package/dist/src/integrations/self-improvement.d.ts.map +1 -0
- package/dist/src/integrations/self-improvement.js +229 -0
- package/dist/src/integrations/self-improvement.js.map +1 -0
- package/dist/src/integrations/smart-decomposer.d.ts +22 -1
- package/dist/src/integrations/smart-decomposer.d.ts.map +1 -1
- package/dist/src/integrations/smart-decomposer.js +127 -28
- package/dist/src/integrations/smart-decomposer.js.map +1 -1
- package/dist/src/integrations/subagent-output-store.d.ts +91 -0
- package/dist/src/integrations/subagent-output-store.d.ts.map +1 -0
- package/dist/src/integrations/subagent-output-store.js +257 -0
- package/dist/src/integrations/subagent-output-store.js.map +1 -0
- package/dist/src/integrations/swarm/index.d.ts +2 -2
- package/dist/src/integrations/swarm/index.d.ts.map +1 -1
- package/dist/src/integrations/swarm/index.js +1 -1
- package/dist/src/integrations/swarm/index.js.map +1 -1
- package/dist/src/integrations/swarm/model-selector.d.ts +16 -0
- package/dist/src/integrations/swarm/model-selector.d.ts.map +1 -1
- package/dist/src/integrations/swarm/model-selector.js +123 -10
- package/dist/src/integrations/swarm/model-selector.js.map +1 -1
- package/dist/src/integrations/swarm/swarm-budget.d.ts +4 -0
- package/dist/src/integrations/swarm/swarm-budget.d.ts.map +1 -1
- package/dist/src/integrations/swarm/swarm-budget.js +6 -0
- package/dist/src/integrations/swarm/swarm-budget.js.map +1 -1
- package/dist/src/integrations/swarm/swarm-config-loader.d.ts +10 -1
- package/dist/src/integrations/swarm/swarm-config-loader.d.ts.map +1 -1
- package/dist/src/integrations/swarm/swarm-config-loader.js +226 -13
- package/dist/src/integrations/swarm/swarm-config-loader.js.map +1 -1
- package/dist/src/integrations/swarm/swarm-event-bridge.d.ts +12 -1
- package/dist/src/integrations/swarm/swarm-event-bridge.d.ts.map +1 -1
- package/dist/src/integrations/swarm/swarm-event-bridge.js +178 -9
- package/dist/src/integrations/swarm/swarm-event-bridge.js.map +1 -1
- package/dist/src/integrations/swarm/swarm-events.d.ts +66 -1
- package/dist/src/integrations/swarm/swarm-events.d.ts.map +1 -1
- package/dist/src/integrations/swarm/swarm-events.js +26 -5
- package/dist/src/integrations/swarm/swarm-events.js.map +1 -1
- package/dist/src/integrations/swarm/swarm-orchestrator.d.ts +127 -0
- package/dist/src/integrations/swarm/swarm-orchestrator.d.ts.map +1 -1
- package/dist/src/integrations/swarm/swarm-orchestrator.js +1842 -47
- package/dist/src/integrations/swarm/swarm-orchestrator.js.map +1 -1
- package/dist/src/integrations/swarm/swarm-quality-gate.d.ts +91 -3
- package/dist/src/integrations/swarm/swarm-quality-gate.d.ts.map +1 -1
- package/dist/src/integrations/swarm/swarm-quality-gate.js +395 -19
- package/dist/src/integrations/swarm/swarm-quality-gate.js.map +1 -1
- package/dist/src/integrations/swarm/task-queue.d.ts +55 -1
- package/dist/src/integrations/swarm/task-queue.d.ts.map +1 -1
- package/dist/src/integrations/swarm/task-queue.js +389 -16
- package/dist/src/integrations/swarm/task-queue.js.map +1 -1
- package/dist/src/integrations/swarm/types.d.ts +247 -11
- package/dist/src/integrations/swarm/types.d.ts.map +1 -1
- package/dist/src/integrations/swarm/types.js +67 -9
- package/dist/src/integrations/swarm/types.js.map +1 -1
- package/dist/src/integrations/swarm/worker-pool.d.ts +18 -5
- package/dist/src/integrations/swarm/worker-pool.d.ts.map +1 -1
- package/dist/src/integrations/swarm/worker-pool.js +236 -34
- package/dist/src/integrations/swarm/worker-pool.js.map +1 -1
- package/dist/src/integrations/thinking-strategy.d.ts +52 -0
- package/dist/src/integrations/thinking-strategy.d.ts.map +1 -0
- package/dist/src/integrations/thinking-strategy.js +129 -0
- package/dist/src/integrations/thinking-strategy.js.map +1 -0
- package/dist/src/integrations/tool-recommendation.d.ts +61 -0
- package/dist/src/integrations/tool-recommendation.d.ts.map +1 -0
- package/dist/src/integrations/tool-recommendation.js +268 -0
- package/dist/src/integrations/tool-recommendation.js.map +1 -0
- package/dist/src/integrations/verification-gate.d.ts +80 -0
- package/dist/src/integrations/verification-gate.d.ts.map +1 -0
- package/dist/src/integrations/verification-gate.js +146 -0
- package/dist/src/integrations/verification-gate.js.map +1 -0
- package/dist/src/integrations/work-log.d.ts +87 -0
- package/dist/src/integrations/work-log.d.ts.map +1 -0
- package/dist/src/integrations/work-log.js +275 -0
- package/dist/src/integrations/work-log.js.map +1 -0
- package/dist/src/main.js +31 -5
- package/dist/src/main.js.map +1 -1
- package/dist/src/modes/repl.d.ts.map +1 -1
- package/dist/src/modes/repl.js +10 -4
- package/dist/src/modes/repl.js.map +1 -1
- package/dist/src/modes/tui.d.ts.map +1 -1
- package/dist/src/modes/tui.js +5 -0
- package/dist/src/modes/tui.js.map +1 -1
- package/dist/src/modes.d.ts +6 -0
- package/dist/src/modes.d.ts.map +1 -1
- package/dist/src/modes.js +69 -21
- package/dist/src/modes.js.map +1 -1
- package/dist/src/tools/agent.d.ts.map +1 -1
- package/dist/src/tools/agent.js +11 -2
- package/dist/src/tools/agent.js.map +1 -1
- package/dist/src/tools/bash.d.ts +9 -3
- package/dist/src/tools/bash.d.ts.map +1 -1
- package/dist/src/tools/bash.js +12 -0
- package/dist/src/tools/bash.js.map +1 -1
- package/dist/src/tools/coercion.d.ts +6 -0
- package/dist/src/tools/coercion.d.ts.map +1 -1
- package/dist/src/tools/coercion.js +13 -0
- package/dist/src/tools/coercion.js.map +1 -1
- package/dist/src/tools/file.d.ts +2 -2
- package/dist/src/tools/file.js +2 -2
- package/dist/src/tools/file.js.map +1 -1
- package/dist/src/tools/permission.d.ts.map +1 -1
- package/dist/src/tools/permission.js +4 -111
- package/dist/src/tools/permission.js.map +1 -1
- package/dist/src/tools/standard.d.ts +17 -1
- package/dist/src/tools/standard.d.ts.map +1 -1
- package/dist/src/tools/standard.js +64 -11
- package/dist/src/tools/standard.js.map +1 -1
- package/dist/src/tracing/trace-collector.d.ts +167 -0
- package/dist/src/tracing/trace-collector.d.ts.map +1 -1
- package/dist/src/tracing/trace-collector.js +137 -0
- package/dist/src/tracing/trace-collector.js.map +1 -1
- package/dist/src/tracing/types.d.ts +105 -1
- package/dist/src/tracing/types.d.ts.map +1 -1
- package/dist/src/tracing/types.js.map +1 -1
- package/dist/src/tui/app.d.ts.map +1 -1
- package/dist/src/tui/app.js +34 -5
- package/dist/src/tui/app.js.map +1 -1
- package/dist/src/types.d.ts +89 -0
- package/dist/src/types.d.ts.map +1 -1
- package/package.json +6 -2
|
@@ -3,46 +3,406 @@
|
|
|
3
3
|
*
|
|
4
4
|
* Uses the orchestrator model to validate worker outputs.
|
|
5
5
|
* Each completed task is scored 1-5; score < 3 triggers rejection/retry.
|
|
6
|
+
*
|
|
7
|
+
* V4: Artifact verification — checks whether target files actually exist
|
|
8
|
+
* and have non-trivial content, so judges can't rubber-stamp empty outputs.
|
|
9
|
+
* Also injects temporal grounding so judges catch stale/outdated content.
|
|
10
|
+
*/
|
|
11
|
+
import * as fs from 'node:fs';
|
|
12
|
+
import * as path from 'node:path';
|
|
13
|
+
import { getTaskTypeConfig } from './types.js';
|
|
14
|
+
import { formatFactsCompact, getEnvironmentFacts } from '../environment-facts.js';
|
|
15
|
+
/**
|
|
16
|
+
* Run cheap, synchronous pre-flight checks on a task result.
|
|
17
|
+
* Returns a failing QualityGateResult on the first check that trips, or null if all pass.
|
|
18
|
+
*
|
|
19
|
+
* Checks: V4 artifact verification, V9 zero-tool-call, V10 file-creation intent, V6 closure report.
|
|
6
20
|
*/
|
|
21
|
+
export function runPreFlightChecks(task, result, swarmConfig, cachedArtifacts) {
|
|
22
|
+
// V4: Pre-flight artifact check — if task has target files, verify they exist
|
|
23
|
+
// C1: Accept pre-computed artifacts to avoid double filesystem scan
|
|
24
|
+
const artifactReport = cachedArtifacts ?? checkArtifacts(task);
|
|
25
|
+
// If ALL target files are empty/missing, auto-fail without burning a judge call
|
|
26
|
+
if (artifactReport.allEmpty) {
|
|
27
|
+
return {
|
|
28
|
+
score: 1,
|
|
29
|
+
feedback: `Target files are empty or missing: ${artifactReport.summary}`,
|
|
30
|
+
passed: false,
|
|
31
|
+
artifactAutoFail: true,
|
|
32
|
+
preFlightReject: true,
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
// V7: Tool-call pre-check using configurable requiresToolCalls from TaskTypeConfig.
|
|
36
|
+
const typeConfig = getTaskTypeConfig(task.type, swarmConfig);
|
|
37
|
+
if (typeConfig.requiresToolCalls && (result.toolCalls ?? 0) === 0) {
|
|
38
|
+
return {
|
|
39
|
+
score: 0,
|
|
40
|
+
feedback: 'No tool calls made — no work was done.',
|
|
41
|
+
passed: false,
|
|
42
|
+
preFlightReject: true,
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
// V10: File-creation intent pre-check — if the task description strongly implies
|
|
46
|
+
// file creation (e.g., "Write to report/X.md") but the worker produced no files,
|
|
47
|
+
// auto-reject. This catches workers that lacked write tools but still produced
|
|
48
|
+
// rich text output (which would pass the hollow-completion check).
|
|
49
|
+
if ((result.filesModified ?? []).length === 0 && (result.toolCalls ?? 0) === 0) {
|
|
50
|
+
const hasWriteIntent = /\b(write|create|generate|produce|save)\b.*\b(file|report|document|output)\b/i.test(task.description)
|
|
51
|
+
|| /\b(write_file|write to|save to|output to)\b/i.test(task.description)
|
|
52
|
+
|| (task.targetFiles && task.targetFiles.length > 0);
|
|
53
|
+
if (hasWriteIntent) {
|
|
54
|
+
return {
|
|
55
|
+
score: 1,
|
|
56
|
+
feedback: `Task requires file creation but worker produced 0 files and made 0 tool calls — likely missing write_file tool.`,
|
|
57
|
+
passed: false,
|
|
58
|
+
artifactAutoFail: true,
|
|
59
|
+
preFlightReject: true,
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
// V6: Closure report pre-check — catch workers that did no actual work
|
|
64
|
+
// When there are no targetFiles (so artifact check can't catch it), use the
|
|
65
|
+
// closure report to detect workers that admit failure with budget excuses
|
|
66
|
+
if (!artifactReport.allEmpty && result.closureReport) {
|
|
67
|
+
const cr = result.closureReport;
|
|
68
|
+
const noRealFindings = cr.findings.length === 0 ||
|
|
69
|
+
cr.findings.every(f => /budget|unable|not completed|constraint/i.test(f));
|
|
70
|
+
const admitsFailure = cr.failures.length > 0 &&
|
|
71
|
+
cr.failures.some(f => /no.*search|no.*performed|not created/i.test(f));
|
|
72
|
+
if (noRealFindings && admitsFailure) {
|
|
73
|
+
return {
|
|
74
|
+
score: 1,
|
|
75
|
+
feedback: `Worker admitted failure in closure report: ${cr.failures[0]}`,
|
|
76
|
+
passed: false,
|
|
77
|
+
artifactAutoFail: false,
|
|
78
|
+
preFlightReject: true,
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
return null;
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* F2: Run concrete validation checks on task output.
|
|
86
|
+
*
|
|
87
|
+
* Validates that modified files are syntactically valid (parseable) and that
|
|
88
|
+
* claimed file modifications match actual filesystem state. This provides
|
|
89
|
+
* ground-truth validation that catches broken outputs before the LLM judge.
|
|
90
|
+
*
|
|
91
|
+
* Checks:
|
|
92
|
+
* 1. For implement/test/refactor tasks: verify modified .ts/.js/.json files parse
|
|
93
|
+
* 2. For test tasks: verify test file is syntactically valid
|
|
94
|
+
* 3. Verify filesModified in closure report matches actual filesystem changes
|
|
95
|
+
*/
|
|
96
|
+
export function runConcreteChecks(task, result) {
|
|
97
|
+
const issues = [];
|
|
98
|
+
const filesModified = result.filesModified ?? [];
|
|
99
|
+
const actionTypes = ['implement', 'test', 'refactor', 'fix', 'create', 'merge'];
|
|
100
|
+
const isCodeTask = actionTypes.includes(task.type);
|
|
101
|
+
// Check 1: Verify modified files exist and are syntactically valid
|
|
102
|
+
if (isCodeTask && filesModified.length > 0) {
|
|
103
|
+
for (const filePath of filesModified) {
|
|
104
|
+
const resolved = path.resolve(filePath);
|
|
105
|
+
try {
|
|
106
|
+
if (!fs.existsSync(resolved)) {
|
|
107
|
+
issues.push(`Modified file missing: ${filePath}`);
|
|
108
|
+
continue;
|
|
109
|
+
}
|
|
110
|
+
const stat = fs.statSync(resolved);
|
|
111
|
+
if (stat.size === 0) {
|
|
112
|
+
issues.push(`Modified file is empty: ${filePath}`);
|
|
113
|
+
continue;
|
|
114
|
+
}
|
|
115
|
+
// Syntax check for parseable file types
|
|
116
|
+
const ext = path.extname(filePath).toLowerCase();
|
|
117
|
+
if (ext === '.json') {
|
|
118
|
+
const content = fs.readFileSync(resolved, 'utf-8');
|
|
119
|
+
try {
|
|
120
|
+
JSON.parse(content);
|
|
121
|
+
}
|
|
122
|
+
catch {
|
|
123
|
+
issues.push(`Invalid JSON syntax: ${filePath}`);
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
// For .ts/.js files, check for obvious syntax issues
|
|
127
|
+
// (incomplete files, unmatched braces, etc.)
|
|
128
|
+
if (['.ts', '.tsx', '.js', '.jsx', '.mts', '.mjs'].includes(ext)) {
|
|
129
|
+
const content = fs.readFileSync(resolved, 'utf-8');
|
|
130
|
+
// Check for grossly unbalanced braces (indicates truncated/corrupt file)
|
|
131
|
+
const opens = (content.match(/\{/g) || []).length;
|
|
132
|
+
const closes = (content.match(/\}/g) || []).length;
|
|
133
|
+
if (Math.abs(opens - closes) > 3) {
|
|
134
|
+
issues.push(`Unbalanced braces (${opens} open, ${closes} close): ${filePath}`);
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
catch {
|
|
139
|
+
// Can't read file — not necessarily an issue
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
// Check 2: Verify closure report filesModified matches actual changes
|
|
144
|
+
if (result.closureReport && result.closureReport.actionsTaken.length > 0) {
|
|
145
|
+
const claimedFiles = filesModified;
|
|
146
|
+
const missingClaimed = claimedFiles.filter(f => {
|
|
147
|
+
try {
|
|
148
|
+
return !fs.existsSync(path.resolve(f));
|
|
149
|
+
}
|
|
150
|
+
catch {
|
|
151
|
+
return true;
|
|
152
|
+
}
|
|
153
|
+
});
|
|
154
|
+
if (missingClaimed.length > 0 && missingClaimed.length === claimedFiles.length) {
|
|
155
|
+
issues.push(`All claimed modified files are missing: ${missingClaimed.join(', ')}`);
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
return {
|
|
159
|
+
passed: issues.length === 0,
|
|
160
|
+
issues,
|
|
161
|
+
};
|
|
162
|
+
}
|
|
7
163
|
/**
|
|
8
164
|
* Evaluate a worker's output using the orchestrator model.
|
|
9
165
|
* V3: Accepts optional judgeConfig for hierarchy-based model/persona override.
|
|
166
|
+
* V4: Includes artifact verification and temporal grounding.
|
|
10
167
|
*/
|
|
11
|
-
export async function evaluateWorkerOutput(provider, orchestratorModel, task, result, judgeConfig) {
|
|
12
|
-
|
|
168
|
+
export async function evaluateWorkerOutput(provider, orchestratorModel, task, result, judgeConfig, qualityThreshold = 3, onUsage, fileArtifacts, swarmConfig, cachedArtifactReport) {
|
|
169
|
+
// C1: Use cached artifact report if provided, otherwise compute once
|
|
170
|
+
const artifactReport = cachedArtifactReport ?? checkArtifacts(task);
|
|
171
|
+
// Run synchronous pre-flight checks first
|
|
172
|
+
const preFlight = runPreFlightChecks(task, result, swarmConfig, artifactReport);
|
|
173
|
+
if (preFlight) {
|
|
174
|
+
return preFlight;
|
|
175
|
+
}
|
|
176
|
+
const prompt = buildQualityPrompt(task, result, artifactReport, fileArtifacts);
|
|
13
177
|
const model = judgeConfig?.model ?? orchestratorModel;
|
|
178
|
+
const facts = formatFactsCompact(getEnvironmentFacts());
|
|
14
179
|
const systemPrompt = judgeConfig?.persona
|
|
15
|
-
? `${judgeConfig.persona}\n\nYou are evaluating worker outputs. Score concisely.`
|
|
16
|
-
:
|
|
180
|
+
? `${judgeConfig.persona}\n\n${facts}\nYou are evaluating worker outputs. Score concisely.`
|
|
181
|
+
: `${facts}\nYou are a quality reviewer for AI worker outputs. Evaluate concisely.`;
|
|
17
182
|
try {
|
|
18
183
|
const response = await provider.chat([
|
|
19
184
|
{ role: 'system', content: systemPrompt },
|
|
20
185
|
{ role: 'user', content: prompt },
|
|
21
186
|
], {
|
|
22
187
|
model,
|
|
23
|
-
maxTokens:
|
|
188
|
+
maxTokens: 800,
|
|
24
189
|
temperature: 0.1,
|
|
25
190
|
});
|
|
26
|
-
|
|
191
|
+
// Track quality gate LLM usage for orchestrator stats
|
|
192
|
+
onUsage?.(response, 'quality-gate');
|
|
193
|
+
const parsed = parseQualityResponse(response.content);
|
|
194
|
+
// Apply configurable threshold
|
|
195
|
+
parsed.passed = parsed.score >= qualityThreshold;
|
|
196
|
+
return parsed;
|
|
27
197
|
}
|
|
28
|
-
catch {
|
|
29
|
-
//
|
|
198
|
+
catch (error) {
|
|
199
|
+
// F7: Quality gate error → fail by default (was: pass by default).
|
|
200
|
+
// The orchestrator checks gateError and falls back to concrete validation.
|
|
30
201
|
return {
|
|
31
202
|
score: 3,
|
|
32
|
-
feedback:
|
|
33
|
-
passed:
|
|
203
|
+
feedback: `Quality gate evaluation failed (${error.message?.slice(0, 100) ?? 'unknown error'})`,
|
|
204
|
+
passed: false,
|
|
205
|
+
gateError: true,
|
|
206
|
+
gateErrorMessage: error.message?.slice(0, 200) ?? 'unknown error',
|
|
34
207
|
};
|
|
35
208
|
}
|
|
36
209
|
}
|
|
210
|
+
/**
|
|
211
|
+
* Check whether target files actually exist and have content.
|
|
212
|
+
* Returns a report that gets injected into the judge prompt.
|
|
213
|
+
* Exported so callers can pre-compute and cache the result.
|
|
214
|
+
*/
|
|
215
|
+
export function checkArtifacts(task) {
|
|
216
|
+
if (!task.targetFiles || task.targetFiles.length === 0) {
|
|
217
|
+
return { allEmpty: false, summary: 'No target files specified.', files: [] };
|
|
218
|
+
}
|
|
219
|
+
const files = [];
|
|
220
|
+
let allEmpty = true;
|
|
221
|
+
for (const filePath of task.targetFiles) {
|
|
222
|
+
const resolved = path.resolve(filePath);
|
|
223
|
+
let exists = false;
|
|
224
|
+
let sizeBytes = 0;
|
|
225
|
+
let preview = '';
|
|
226
|
+
try {
|
|
227
|
+
if (fs.existsSync(resolved)) {
|
|
228
|
+
exists = true;
|
|
229
|
+
const stats = fs.statSync(resolved);
|
|
230
|
+
sizeBytes = stats.size;
|
|
231
|
+
if (sizeBytes > 0) {
|
|
232
|
+
allEmpty = false;
|
|
233
|
+
// Read first 2000 chars for the judge to evaluate content quality
|
|
234
|
+
const content = fs.readFileSync(resolved, 'utf-8');
|
|
235
|
+
preview = content.slice(0, 2000);
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
catch {
|
|
240
|
+
// File read error — treat as missing
|
|
241
|
+
}
|
|
242
|
+
files.push({ path: filePath, exists, sizeBytes, preview });
|
|
243
|
+
}
|
|
244
|
+
const lines = files.map(f => {
|
|
245
|
+
if (!f.exists)
|
|
246
|
+
return ` - ${f.path}: MISSING`;
|
|
247
|
+
if (f.sizeBytes === 0)
|
|
248
|
+
return ` - ${f.path}: EMPTY (0 bytes)`;
|
|
249
|
+
return ` - ${f.path}: ${f.sizeBytes} bytes`;
|
|
250
|
+
});
|
|
251
|
+
return {
|
|
252
|
+
allEmpty,
|
|
253
|
+
summary: lines.join('\n'),
|
|
254
|
+
files,
|
|
255
|
+
};
|
|
256
|
+
}
|
|
257
|
+
/**
|
|
258
|
+
* Enhanced artifact detection — searches beyond targetFiles.
|
|
259
|
+
* Used by resilience recovery and rescue pass to find work products
|
|
260
|
+
* that the standard checkArtifacts() would miss (e.g., when targetFiles is empty).
|
|
261
|
+
*
|
|
262
|
+
* Search order:
|
|
263
|
+
* 1. Standard checkArtifacts() for declared targetFiles
|
|
264
|
+
* 2. taskResult.filesModified — scan those paths on disk
|
|
265
|
+
* 3. taskResult.closureReport.actionsTaken — extract file path mentions
|
|
266
|
+
* 4. taskResult.output — regex for file paths
|
|
267
|
+
* 5. De-duplicate, return unified report
|
|
268
|
+
*/
|
|
269
|
+
export function checkArtifactsEnhanced(task, taskResult, baseDir) {
|
|
270
|
+
const cwd = baseDir ?? process.cwd();
|
|
271
|
+
const seenPaths = new Set();
|
|
272
|
+
const allFiles = [];
|
|
273
|
+
// 1. Standard check for declared targetFiles
|
|
274
|
+
const standard = checkArtifacts(task);
|
|
275
|
+
for (const f of standard.files) {
|
|
276
|
+
if (!seenPaths.has(f.path)) {
|
|
277
|
+
seenPaths.add(f.path);
|
|
278
|
+
allFiles.push(f);
|
|
279
|
+
}
|
|
280
|
+
}
|
|
281
|
+
// Helper to probe a file path on disk and add to report
|
|
282
|
+
const probeFile = (filePath) => {
|
|
283
|
+
if (seenPaths.has(filePath))
|
|
284
|
+
return;
|
|
285
|
+
seenPaths.add(filePath);
|
|
286
|
+
const resolved = path.isAbsolute(filePath) ? filePath : path.resolve(cwd, filePath);
|
|
287
|
+
try {
|
|
288
|
+
if (fs.existsSync(resolved)) {
|
|
289
|
+
const stats = fs.statSync(resolved);
|
|
290
|
+
if (stats.size > 0) {
|
|
291
|
+
const content = fs.readFileSync(resolved, 'utf-8');
|
|
292
|
+
allFiles.push({
|
|
293
|
+
path: filePath,
|
|
294
|
+
exists: true,
|
|
295
|
+
sizeBytes: stats.size,
|
|
296
|
+
preview: content.slice(0, 2000),
|
|
297
|
+
});
|
|
298
|
+
return;
|
|
299
|
+
}
|
|
300
|
+
allFiles.push({ path: filePath, exists: true, sizeBytes: 0, preview: '' });
|
|
301
|
+
return;
|
|
302
|
+
}
|
|
303
|
+
}
|
|
304
|
+
catch {
|
|
305
|
+
// File access error — treat as missing
|
|
306
|
+
}
|
|
307
|
+
allFiles.push({ path: filePath, exists: false, sizeBytes: 0, preview: '' });
|
|
308
|
+
};
|
|
309
|
+
if (taskResult) {
|
|
310
|
+
// 2. filesModified from the task result
|
|
311
|
+
if (taskResult.filesModified) {
|
|
312
|
+
for (const fp of taskResult.filesModified) {
|
|
313
|
+
probeFile(fp);
|
|
314
|
+
}
|
|
315
|
+
}
|
|
316
|
+
// 3. closureReport.actionsTaken — extract file paths
|
|
317
|
+
if (taskResult.closureReport?.actionsTaken) {
|
|
318
|
+
for (const action of taskResult.closureReport.actionsTaken) {
|
|
319
|
+
const matches = action.match(/(?:^|\s)([\w./-]+\.\w{1,10})\b/g);
|
|
320
|
+
if (matches) {
|
|
321
|
+
for (const m of matches) {
|
|
322
|
+
const fp = m.trim();
|
|
323
|
+
// Basic sanity: must have a path separator or start with a filename-like pattern
|
|
324
|
+
if (fp.includes('/') || fp.includes('.')) {
|
|
325
|
+
probeFile(fp);
|
|
326
|
+
}
|
|
327
|
+
}
|
|
328
|
+
}
|
|
329
|
+
}
|
|
330
|
+
}
|
|
331
|
+
// 4. output — regex for file paths (conservative: require path separator)
|
|
332
|
+
const outputPathRegex = /(?:^|\s)((?:[\w.-]+\/)+[\w.-]+\.\w{1,10})\b/g;
|
|
333
|
+
let match;
|
|
334
|
+
const outputSlice = taskResult.output.slice(0, 8000); // Limit scan length
|
|
335
|
+
while ((match = outputPathRegex.exec(outputSlice)) !== null) {
|
|
336
|
+
const fp = match[1];
|
|
337
|
+
if (fp && !seenPaths.has(fp)) {
|
|
338
|
+
probeFile(fp);
|
|
339
|
+
}
|
|
340
|
+
}
|
|
341
|
+
}
|
|
342
|
+
// Build unified report
|
|
343
|
+
const existingFiles = allFiles.filter(f => f.exists && f.sizeBytes > 0);
|
|
344
|
+
const allEmpty = allFiles.length > 0 && existingFiles.length === 0;
|
|
345
|
+
const lines = allFiles.map(f => {
|
|
346
|
+
if (!f.exists)
|
|
347
|
+
return ` - ${f.path}: MISSING`;
|
|
348
|
+
if (f.sizeBytes === 0)
|
|
349
|
+
return ` - ${f.path}: EMPTY (0 bytes)`;
|
|
350
|
+
return ` - ${f.path}: ${f.sizeBytes} bytes`;
|
|
351
|
+
});
|
|
352
|
+
return {
|
|
353
|
+
allEmpty: allFiles.length === 0 ? false : allEmpty,
|
|
354
|
+
summary: allFiles.length === 0 ? 'No artifacts found.' : lines.join('\n'),
|
|
355
|
+
files: allFiles,
|
|
356
|
+
};
|
|
357
|
+
}
|
|
358
|
+
// ─── Prompt Building ──────────────────────────────────────────────────────
|
|
37
359
|
/**
|
|
38
360
|
* Build the quality evaluation prompt.
|
|
361
|
+
* V4: Includes artifact verification data and temporal anchoring.
|
|
39
362
|
*/
|
|
40
|
-
function buildQualityPrompt(task, result) {
|
|
41
|
-
const output = result.output.slice(0,
|
|
363
|
+
function buildQualityPrompt(task, result, artifacts, fileArtifacts) {
|
|
364
|
+
const output = result.output.slice(0, 16000); // Truncate long outputs (16K gives judge enough evidence for multi-file tasks)
|
|
365
|
+
const facts = getEnvironmentFacts();
|
|
366
|
+
let artifactSection = '';
|
|
367
|
+
if (artifacts.files.length > 0) {
|
|
368
|
+
const fileDetails = artifacts.files.map(f => {
|
|
369
|
+
if (!f.exists)
|
|
370
|
+
return ` ${f.path}: MISSING — file was not created`;
|
|
371
|
+
if (f.sizeBytes === 0)
|
|
372
|
+
return ` ${f.path}: EMPTY (0 bytes) — file exists but has no content`;
|
|
373
|
+
let detail = ` ${f.path}: ${f.sizeBytes} bytes`;
|
|
374
|
+
if (f.preview) {
|
|
375
|
+
detail += `\n First 2000 chars: ${f.preview}`;
|
|
376
|
+
}
|
|
377
|
+
return detail;
|
|
378
|
+
}).join('\n');
|
|
379
|
+
artifactSection = `
|
|
380
|
+
ARTIFACT VERIFICATION (filesystem check — this is ground truth):
|
|
381
|
+
${fileDetails}
|
|
382
|
+
|
|
383
|
+
CRITICAL: If target files are EMPTY (0 bytes) or MISSING, the task FAILED regardless
|
|
384
|
+
of what the worker claims. An empty file is NOT an acceptable artifact. Score <= 2.`;
|
|
385
|
+
}
|
|
386
|
+
// Build file artifacts section from worker tool calls (write_file/edit_file results)
|
|
387
|
+
let fileArtifactsSection = '';
|
|
388
|
+
if (fileArtifacts && fileArtifacts.length > 0) {
|
|
389
|
+
const artifactDetails = fileArtifacts
|
|
390
|
+
.slice(0, 10) // Limit to 10 files
|
|
391
|
+
.map(f => ` ${f.path}:\n ${f.preview.slice(0, 1500)}`)
|
|
392
|
+
.join('\n');
|
|
393
|
+
fileArtifactsSection = `
|
|
394
|
+
FILES CREATED/MODIFIED BY WORKER (from tool call results — ground truth):
|
|
395
|
+
${artifactDetails}
|
|
396
|
+
|
|
397
|
+
NOTE: These are actual file contents extracted from write_file/edit_file tool calls.
|
|
398
|
+
They prove the worker did real work beyond just text claims.`;
|
|
399
|
+
}
|
|
42
400
|
return `Evaluate this worker's output for the given task.
|
|
43
401
|
|
|
44
402
|
TASK: ${task.description}
|
|
45
403
|
TASK TYPE: ${task.type}
|
|
404
|
+
WORKER METRICS: ${result.toolCalls ?? 0} tool calls, ${fileArtifacts?.length ?? 0} files created/modified, ${result.tokensUsed} tokens used
|
|
405
|
+
CURRENT DATE: ${facts.currentDate} (${facts.currentYear})
|
|
46
406
|
${task.targetFiles ? `TARGET FILES: ${task.targetFiles.join(', ')}` : ''}
|
|
47
407
|
|
|
48
408
|
WORKER OUTPUT:
|
|
@@ -53,17 +413,25 @@ ${result.closureReport ? `STRUCTURED REPORT:
|
|
|
53
413
|
- Actions: ${result.closureReport.actionsTaken.join('; ')}
|
|
54
414
|
- Failures: ${result.closureReport.failures.join('; ')}
|
|
55
415
|
- Remaining: ${result.closureReport.remainingWork.join('; ')}` : ''}
|
|
416
|
+
${artifactSection}
|
|
417
|
+
${fileArtifactsSection}
|
|
56
418
|
|
|
57
419
|
Rate the output 1-5:
|
|
58
|
-
1 = Completely wrong or
|
|
59
|
-
2 = Attempted but significantly incomplete/
|
|
60
|
-
3 = Acceptable — covers the core requirement with minor issues
|
|
61
|
-
4 = Good — thorough and
|
|
62
|
-
5 = Excellent — complete, clean, well-structured
|
|
420
|
+
1 = Completely wrong, empty artifacts, or no meaningful work done
|
|
421
|
+
2 = Attempted but significantly incomplete (empty/missing files, stale data, major gaps)
|
|
422
|
+
3 = Acceptable — covers the core requirement with minor issues, files have real content
|
|
423
|
+
4 = Good — thorough, correct, and files contain well-structured content
|
|
424
|
+
5 = Excellent — complete, clean, well-structured, temporally accurate (${facts.currentYear} data)
|
|
425
|
+
|
|
426
|
+
IMPORTANT SCORING RULES:
|
|
427
|
+
- If target files are EMPTY or MISSING: maximum score is 1
|
|
428
|
+
- If content references outdated years (e.g. "as of ${facts.currentYear - 2}") without current data: maximum score is 2
|
|
429
|
+
- Worker claims alone are NOT evidence — the ARTIFACT VERIFICATION section is ground truth
|
|
63
430
|
|
|
64
431
|
Respond in EXACTLY this format:
|
|
65
432
|
SCORE: <number>
|
|
66
|
-
FEEDBACK: <one-line explanation
|
|
433
|
+
FEEDBACK: <one-line explanation>
|
|
434
|
+
CONCRETE_FIXES: <If score < 3, list 1-3 specific fixes the worker must make. Reference exact file names, functions, or missing pieces. If score >= 3, write "N/A">`;
|
|
67
435
|
}
|
|
68
436
|
/**
|
|
69
437
|
* Parse the quality gate response.
|
|
@@ -75,7 +443,15 @@ function parseQualityResponse(content) {
|
|
|
75
443
|
const clampedScore = Math.max(1, Math.min(5, score));
|
|
76
444
|
// Extract feedback
|
|
77
445
|
const feedbackMatch = content.match(/FEEDBACK:\s*(.+)/i);
|
|
78
|
-
|
|
446
|
+
let feedback = feedbackMatch ? feedbackMatch[1].trim() : content.slice(0, 200);
|
|
447
|
+
// Extract concrete fixes (appended to feedback for retry context)
|
|
448
|
+
const fixesMatch = content.match(/CONCRETE_FIXES:\s*(.+)/i);
|
|
449
|
+
if (fixesMatch) {
|
|
450
|
+
const fixes = fixesMatch[1].trim();
|
|
451
|
+
if (fixes && fixes !== 'N/A') {
|
|
452
|
+
feedback = feedback + ' | Fixes: ' + fixes;
|
|
453
|
+
}
|
|
454
|
+
}
|
|
79
455
|
return {
|
|
80
456
|
score: clampedScore,
|
|
81
457
|
feedback,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"swarm-quality-gate.js","sourceRoot":"","sources":["../../../../src/integrations/swarm/swarm-quality-gate.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AA4BH;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,oBAAoB,CACxC,QAAqB,EACrB,iBAAyB,EACzB,IAAe,EACf,MAAuB,EACvB,WAA+B;IAE/B,MAAM,MAAM,GAAG,kBAAkB,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;IAChD,MAAM,KAAK,GAAG,WAAW,EAAE,KAAK,IAAI,iBAAiB,CAAC;IACtD,MAAM,YAAY,GAAG,WAAW,EAAE,OAAO;QACvC,CAAC,CAAC,GAAG,WAAW,CAAC,OAAO,yDAAyD;QACjF,CAAC,CAAC,uEAAuE,CAAC;IAE5E,IAAI,CAAC;QACH,MAAM,QAAQ,GAAG,MAAM,QAAQ,CAAC,IAAI,CAClC;YACE,EAAE,IAAI,EAAE,QAAQ,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AAC,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC,CAAC;IAErD,mBAAmB;IACnB,MAAM,aAAa,GAAG,OAAO,CAAC,KAAK,CAAC,mBAAmB,CAAC,CAAC;IACzD,IAAI,QAAQ,GAAG,aAAa,CAAC,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC;IAE/E,kEAAkE;IAClE,MAAM,UAAU,GAAG,OAAO,CAAC,KAAK,CAAC,yBAAyB,CAAC,CAAC;IAC5D,IAAI,UAAU,EAAE,CAAC;QACf,MAAM,KAAK,GAAG,UAAU,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC;QACnC,IAAI,KAAK,IAAI,KAAK,KAAK,KAAK,EAAE,CAAC;YAC7B,QAAQ,GAAG,QAAQ,GAAG,YAAY,GAAG,KAAK,CAAC;QAC7C,CAAC;IACH,CAAC;IAED,OAAO;QACL,KAAK,EAAE,YAAY;QACnB,QAAQ;QACR,MAAM,EAAE,YAAY,IAAI,CAAC;KAC1B,CAAC;AACJ,CAAC"}
|
|
@@ -12,6 +12,10 @@ export declare class SwarmTaskQueue {
|
|
|
12
12
|
private waves;
|
|
13
13
|
private conflicts;
|
|
14
14
|
private currentWave;
|
|
15
|
+
private onCascadeSkipCallback?;
|
|
16
|
+
private partialDependencyThreshold;
|
|
17
|
+
private artifactAwareSkip;
|
|
18
|
+
private workingDirectory;
|
|
15
19
|
/**
|
|
16
20
|
* Load tasks from a SmartDecompositionResult.
|
|
17
21
|
* Converts subtasks to SwarmTasks and organizes them into waves
|
|
@@ -24,10 +28,13 @@ export declare class SwarmTaskQueue {
|
|
|
24
28
|
private rebuildWaves;
|
|
25
29
|
/**
|
|
26
30
|
* Update task ready status based on dependency completion.
|
|
31
|
+
* Supports partial dependency tolerance: if enough deps succeeded (>= threshold),
|
|
32
|
+
* the task runs with partial context instead of being cascade-skipped.
|
|
27
33
|
*/
|
|
28
34
|
private updateReadyStatus;
|
|
29
35
|
/**
|
|
30
36
|
* Build context string from completed dependency outputs.
|
|
37
|
+
* Includes partial dependency warnings when some deps failed.
|
|
31
38
|
*/
|
|
32
39
|
private buildDependencyContext;
|
|
33
40
|
/**
|
|
@@ -44,6 +51,10 @@ export declare class SwarmTaskQueue {
|
|
|
44
51
|
* Set a non-blocking cooldown on a task before it can be re-dispatched.
|
|
45
52
|
*/
|
|
46
53
|
setRetryAfter(taskId: string, delayMs: number): void;
|
|
54
|
+
/**
|
|
55
|
+
* Register a callback invoked for each task cascade-skipped due to a dependency failure.
|
|
56
|
+
*/
|
|
57
|
+
setOnCascadeSkip(callback: (taskId: string, reason: string) => void): void;
|
|
47
58
|
/**
|
|
48
59
|
* Mark a task as dispatched.
|
|
49
60
|
*/
|
|
@@ -58,7 +69,24 @@ export declare class SwarmTaskQueue {
|
|
|
58
69
|
*/
|
|
59
70
|
markFailed(taskId: string, maxRetries: number): boolean;
|
|
60
71
|
/**
|
|
61
|
-
*
|
|
72
|
+
* Mark a task as failed WITHOUT triggering cascade skip.
|
|
73
|
+
* Returns true if the task can be retried (attempts < maxAttempts).
|
|
74
|
+
* Caller is responsible for calling triggerCascadeSkip() if recovery fails.
|
|
75
|
+
*/
|
|
76
|
+
markFailedWithoutCascade(taskId: string, maxRetries: number): boolean;
|
|
77
|
+
/**
|
|
78
|
+
* Manually trigger cascade skip for a failed task's dependents.
|
|
79
|
+
* Call this after resilience recovery has been attempted and failed.
|
|
80
|
+
*/
|
|
81
|
+
triggerCascadeSkip(taskId: string): void;
|
|
82
|
+
/**
|
|
83
|
+
* Un-skip dependents of a task that was recovered (e.g., via resilience recovery).
|
|
84
|
+
* Checks if all dependencies are now satisfied and restores skipped tasks to ready.
|
|
85
|
+
*/
|
|
86
|
+
unSkipDependents(taskId: string): void;
|
|
87
|
+
/**
|
|
88
|
+
* Cascade failure to dependent tasks, respecting partial dependency threshold.
|
|
89
|
+
* Tasks with enough successful deps are kept ready/pending rather than skipped.
|
|
62
90
|
*/
|
|
63
91
|
private cascadeSkip;
|
|
64
92
|
/**
|
|
@@ -77,6 +105,21 @@ export declare class SwarmTaskQueue {
|
|
|
77
105
|
* Check if all tasks are resolved (no more work to do).
|
|
78
106
|
*/
|
|
79
107
|
isComplete(): boolean;
|
|
108
|
+
/**
|
|
109
|
+
* Replace a task with subtasks from micro-decomposition.
|
|
110
|
+
* Marks original task as 'decomposed', inserts subtasks into its wave,
|
|
111
|
+
* and updates dependency graph so anything depending on the original
|
|
112
|
+
* now depends on ALL subtasks.
|
|
113
|
+
*/
|
|
114
|
+
replaceWithSubtasks(originalTaskId: string, subtasks: SwarmTask[]): void;
|
|
115
|
+
/**
|
|
116
|
+
* Get all tasks that were cascade-skipped.
|
|
117
|
+
*/
|
|
118
|
+
getSkippedTasks(): SwarmTask[];
|
|
119
|
+
/**
|
|
120
|
+
* Un-skip a task, setting it to 'ready' with rescue context.
|
|
121
|
+
*/
|
|
122
|
+
rescueTask(taskId: string, rescueContext: string): void;
|
|
80
123
|
/**
|
|
81
124
|
* Get a task by ID.
|
|
82
125
|
*/
|
|
@@ -116,6 +159,17 @@ export declare class SwarmTaskQueue {
|
|
|
116
159
|
* Restore state from a checkpoint. Merges checkpoint state into existing tasks.
|
|
117
160
|
*/
|
|
118
161
|
restoreFromCheckpoint(state: Pick<SwarmCheckpoint, 'taskStates' | 'waves' | 'currentWave'>): void;
|
|
162
|
+
/**
|
|
163
|
+
* Add re-planned tasks from mid-swarm re-planning.
|
|
164
|
+
* Inserts new tasks into the specified wave and marks them ready.
|
|
165
|
+
*/
|
|
166
|
+
addReplanTasks(subtasks: Array<{
|
|
167
|
+
description: string;
|
|
168
|
+
type: string;
|
|
169
|
+
complexity: number;
|
|
170
|
+
dependencies: string[];
|
|
171
|
+
relevantFiles?: string[];
|
|
172
|
+
}>, wave: number): SwarmTask[];
|
|
119
173
|
/**
|
|
120
174
|
* Add fix-up tasks from wave review. Inserted into the current wave.
|
|
121
175
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"task-queue.d.ts","sourceRoot":"","sources":["../../../../src/integrations/swarm/task-queue.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;
|
|
1
|
+
{"version":3,"file":"task-queue.d.ts","sourceRoot":"","sources":["../../../../src/integrations/swarm/task-queue.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAIH,OAAO,KAAK,EAAE,wBAAwB,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AACzF,OAAO,KAAK,EAAE,SAAS,EAAE,eAAe,EAAE,WAAW,EAAE,SAAS,EAAE,eAAe,EAAmB,MAAM,YAAY,CAAC;AA8BvH,qBAAa,cAAc;IACzB,OAAO,CAAC,KAAK,CAAqC;IAClD,OAAO,CAAC,KAAK,CAAkB;IAC/B,OAAO,CAAC,SAAS,CAA0B;IAC3C,OAAO,CAAC,WAAW,CAAK;IACxB,OAAO,CAAC,qBAAqB,CAAC,CAA2C;IACzE,OAAO,CAAC,0BAA0B,CAAO;IACzC,OAAO,CAAC,iBAAiB,CAAQ;IACjC,OAAO,CAAC,gBAAgB,CAAiB;IAEzC;;;;OAIG;IACH,qBAAqB,CAAC,MAAM,EAAE,wBAAwB,EAAE,MAAM,EAAE,WAAW,GAAG,IAAI;IAyDlF;;OAEG;IACH,OAAO,CAAC,YAAY;IAapB;;;;OAIG;IACH,OAAO,CAAC,iBAAiB;IAgEzB;;;OAGG;IACH,OAAO,CAAC,sBAAsB;IA6D9B;;;OAGG;IACH,aAAa,IAAI,SAAS,EAAE;IAU5B;;;OAGG;IACH,gBAAgB,IAAI,SAAS,EAAE;IAe/B;;OAEG;IACH,aAAa,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,IAAI;IAOpD;;OAEG;IACH,gBAAgB,CAAC,QAAQ,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EA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