@cat-factory/orchestration 0.37.1 → 0.37.2
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/modules/execution/CompanionController.d.ts +6 -11
- package/dist/modules/execution/CompanionController.d.ts.map +1 -1
- package/dist/modules/execution/CompanionController.js +20 -20
- package/dist/modules/execution/CompanionController.js.map +1 -1
- package/dist/modules/execution/ExecutionService.d.ts +3 -100
- package/dist/modules/execution/ExecutionService.d.ts.map +1 -1
- package/dist/modules/execution/ExecutionService.js +84 -460
- package/dist/modules/execution/ExecutionService.js.map +1 -1
- package/dist/modules/execution/HumanTestController.d.ts +6 -8
- package/dist/modules/execution/HumanTestController.d.ts.map +1 -1
- package/dist/modules/execution/HumanTestController.js +26 -26
- package/dist/modules/execution/HumanTestController.js.map +1 -1
- package/dist/modules/execution/ReviewGateController.d.ts +11 -19
- package/dist/modules/execution/ReviewGateController.d.ts.map +1 -1
- package/dist/modules/execution/ReviewGateController.js +19 -19
- package/dist/modules/execution/ReviewGateController.js.map +1 -1
- package/dist/modules/execution/RunStateMachine.d.ts +131 -0
- package/dist/modules/execution/RunStateMachine.d.ts.map +1 -0
- package/dist/modules/execution/RunStateMachine.js +389 -0
- package/dist/modules/execution/RunStateMachine.js.map +1 -0
- package/dist/modules/execution/TesterController.d.ts +3 -4
- package/dist/modules/execution/TesterController.d.ts.map +1 -1
- package/dist/modules/execution/TesterController.js +6 -6
- package/dist/modules/execution/TesterController.js.map +1 -1
- package/dist/modules/execution/VisualConfirmationController.d.ts +6 -8
- package/dist/modules/execution/VisualConfirmationController.d.ts.map +1 -1
- package/dist/modules/execution/VisualConfirmationController.js +18 -18
- package/dist/modules/execution/VisualConfirmationController.js.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,389 @@
|
|
|
1
|
+
import { isAsyncAgentExecutor } from '@cat-factory/kernel';
|
|
2
|
+
import { MERGER_AGENT_KIND } from './ci.logic.js';
|
|
3
|
+
/**
|
|
4
|
+
* "What to do next" guidance per failure kind a pipeline run can produce, shown
|
|
5
|
+
* under the failure banner on the board (mirrors bootstrap's FAILURE_HINTS). Only
|
|
6
|
+
* the execution-relevant subset of {@link AgentFailureKind} is keyed.
|
|
7
|
+
*/
|
|
8
|
+
const EXECUTION_FAILURE_HINTS = {
|
|
9
|
+
agent: 'An agent step failed after its automatic retries. Review the run, then retry to re-run the pipeline.',
|
|
10
|
+
job_failed: 'The implementation container reported a failure. Inspect its logs (Cloudflare Workers Observability, filtered by the run id), then retry to spin a fresh container.',
|
|
11
|
+
evicted: 'The implementation container kept vanishing mid-run even after automatic fresh-container restarts. Most often this is transient: a deploy / new-version rollout draining the container, in which case simply retrying once the rollout has finished succeeds. If it persists, it points at a memory or crash issue on the run — inspect its logs (Cloudflare Workers Observability, filtered by the run id) and consider a heavier container instance type. Retry to try again.',
|
|
12
|
+
timeout: 'The run exceeded its time budget — a step or the implementation job did not finish in time. Retry to start it again.',
|
|
13
|
+
rejected: 'You rejected this step’s proposal, stopping the run. Retry to re-run the pipeline from the rejected step.',
|
|
14
|
+
companion_rejected: 'A companion agent could not return a usable quality assessment (its reply was truncated or malformed) even after a repair retry. Review the companion’s raw output on the run, then retry.',
|
|
15
|
+
cancelled: 'You stopped this run; its container was killed. Retry to start it again.',
|
|
16
|
+
dispatch: 'The agent’s container could not be started — the run never began executing. The provider/runtime’s verbatim response is shown below. Most often this is transient (a capacity blip or a new-version rollout); retrying spins a fresh container. If it persists it points at a misconfigured container binding/image or runner pool. Retry to try again.',
|
|
17
|
+
unknown: 'The run failed for an unclassified reason. Review the run, then retry.',
|
|
18
|
+
};
|
|
19
|
+
/**
|
|
20
|
+
* The async instance/block state-machine spine of the execution engine — the outer layer
|
|
21
|
+
* over {@link StepGraph}. It owns everything the engine and every gate controller share
|
|
22
|
+
* about MOVING a run: persisting the instance, pushing the live event (with the metrics
|
|
23
|
+
* rollup + terminal-state cleanup), the block status/progress writes, parking on a decision
|
|
24
|
+
* and advancing past a resolved one, finalizing a finished pipeline, failing a run, and
|
|
25
|
+
* reclaiming the per-run container.
|
|
26
|
+
*
|
|
27
|
+
* Lifted verbatim out of `ExecutionService` so these primitives have ONE cohesive home
|
|
28
|
+
* instead of being scattered as private methods and handed to each controller as a fat
|
|
29
|
+
* callback bag. The merge/auto-start subgraph (`finalizeMerge` / `applyModuleAssignment` /
|
|
30
|
+
* `autoStartDependents`) deliberately stays on the engine — `finalizeBlock` here only flips
|
|
31
|
+
* status and raises the no-merger notification, so this layer carries no merge collaborators.
|
|
32
|
+
*/
|
|
33
|
+
export class RunStateMachine {
|
|
34
|
+
executionRepository;
|
|
35
|
+
blockRepository;
|
|
36
|
+
events;
|
|
37
|
+
workRunner;
|
|
38
|
+
agentExecutor;
|
|
39
|
+
idGenerator;
|
|
40
|
+
clock;
|
|
41
|
+
stepGraph;
|
|
42
|
+
notificationService;
|
|
43
|
+
kaizenScheduler;
|
|
44
|
+
subscriptionActivations;
|
|
45
|
+
llmObservability;
|
|
46
|
+
constructor(deps) {
|
|
47
|
+
this.executionRepository = deps.executionRepository;
|
|
48
|
+
this.blockRepository = deps.blockRepository;
|
|
49
|
+
this.events = deps.events;
|
|
50
|
+
this.workRunner = deps.workRunner;
|
|
51
|
+
this.agentExecutor = deps.agentExecutor;
|
|
52
|
+
this.idGenerator = deps.idGenerator;
|
|
53
|
+
this.clock = deps.clock;
|
|
54
|
+
this.stepGraph = deps.stepGraph;
|
|
55
|
+
this.notificationService = deps.notificationService;
|
|
56
|
+
this.kaizenScheduler = deps.kaizenScheduler;
|
|
57
|
+
this.subscriptionActivations = deps.subscriptionActivations;
|
|
58
|
+
this.llmObservability = deps.llmObservability;
|
|
59
|
+
}
|
|
60
|
+
/** Persist the instance (the single write seam shared by the engine + controllers). */
|
|
61
|
+
persistInstance(workspaceId, instance) {
|
|
62
|
+
return this.executionRepository.upsert(workspaceId, instance);
|
|
63
|
+
}
|
|
64
|
+
async emitInstance(workspaceId, instance) {
|
|
65
|
+
// Stamp each step with the run id so a lone step (in a pushed event, a log line, a
|
|
66
|
+
// detail view) is self-describing for debugging; the value always equals the run id.
|
|
67
|
+
for (const step of instance.steps)
|
|
68
|
+
step.runId = instance.id;
|
|
69
|
+
// The metrics rollup and the block fetch are independent, so run them concurrently
|
|
70
|
+
// — the rollup adds no serial latency to the (frequent) emit path.
|
|
71
|
+
const [, block] = await Promise.all([
|
|
72
|
+
this.attachStepMetrics(workspaceId, instance),
|
|
73
|
+
this.blockRepository.get(workspaceId, instance.blockId),
|
|
74
|
+
]);
|
|
75
|
+
await this.events.executionChanged(workspaceId, instance, block);
|
|
76
|
+
// When a run reaches a terminal state, schedule a post-run Kaizen grading for each
|
|
77
|
+
// completed agent step (the scheduler skips verified combos + already-graded steps).
|
|
78
|
+
// Best-effort + idempotent: a failure here must never derail the emit, and a re-emit
|
|
79
|
+
// of an already-scheduled run is a no-op. The actual LLM grading runs later in the
|
|
80
|
+
// background sweep, so this only does cheap inserts.
|
|
81
|
+
if (this.kaizenScheduler && (instance.status === 'done' || instance.status === 'failed')) {
|
|
82
|
+
try {
|
|
83
|
+
await this.kaizenScheduler.scheduleForRun(workspaceId, instance);
|
|
84
|
+
}
|
|
85
|
+
catch {
|
|
86
|
+
// Swallow — grading is an observability concern and must never break a run.
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
// When a run reaches a terminal state, delete its per-run personal-credential
|
|
90
|
+
// activation immediately (individual-usage subscriptions) so the system-encrypted
|
|
91
|
+
// token copy doesn't linger to its TTL. Best-effort + idempotent — a missing repo or
|
|
92
|
+
// a re-emit of an already-cleared run is a no-op, and a failure here must never
|
|
93
|
+
// derail the emit.
|
|
94
|
+
if (this.subscriptionActivations &&
|
|
95
|
+
(instance.status === 'done' || instance.status === 'failed')) {
|
|
96
|
+
try {
|
|
97
|
+
await this.subscriptionActivations.deleteByExecution(instance.id);
|
|
98
|
+
}
|
|
99
|
+
catch {
|
|
100
|
+
// Swallow — a failure here must never derail the emit. This is not a silent
|
|
101
|
+
// data-loss path: the TTL sweep reclaims the row as a backstop, and the sweep
|
|
102
|
+
// (Worker cron / Node retention timer) logs its own errors, so a *systemic*
|
|
103
|
+
// cleanup failure surfaces there rather than being lost here.
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* Roll the run's recorded LLM calls into per-step `metrics` for the board, in
|
|
109
|
+
* place on the emitted instance. The proxy keys calls by execution + agentKind
|
|
110
|
+
* (not step index), so the aggregate is per-agent-kind within the run; steps
|
|
111
|
+
* sharing a kind get the same rollup. Best-effort and a no-op when the sink is
|
|
112
|
+
* not wired, so it never blocks an emit.
|
|
113
|
+
*/
|
|
114
|
+
async attachStepMetrics(workspaceId, instance) {
|
|
115
|
+
if (!this.llmObservability)
|
|
116
|
+
return;
|
|
117
|
+
try {
|
|
118
|
+
const summaries = await this.llmObservability.summarizeByExecution(workspaceId, instance.id);
|
|
119
|
+
if (summaries.length === 0)
|
|
120
|
+
return;
|
|
121
|
+
const byKind = new Map(summaries.map((s) => [s.agentKind, s]));
|
|
122
|
+
for (const step of instance.steps) {
|
|
123
|
+
const s = byKind.get(step.agentKind);
|
|
124
|
+
if (!s)
|
|
125
|
+
continue;
|
|
126
|
+
step.metrics = {
|
|
127
|
+
calls: s.calls,
|
|
128
|
+
promptTokens: s.promptTokens,
|
|
129
|
+
cachedPromptTokens: s.cachedPromptTokens,
|
|
130
|
+
completionTokens: s.completionTokens,
|
|
131
|
+
peakCompletionTokens: s.peakCompletionTokens,
|
|
132
|
+
maxOutputTokens: s.maxOutputTokens,
|
|
133
|
+
truncatedCalls: s.truncatedCalls,
|
|
134
|
+
upstreamMs: s.upstreamMs,
|
|
135
|
+
overheadMs: s.overheadMs,
|
|
136
|
+
errors: s.errors,
|
|
137
|
+
warnings: s.warnings,
|
|
138
|
+
};
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
catch (error) {
|
|
142
|
+
// Observability is best-effort; never block an emit on a metrics read.
|
|
143
|
+
void error;
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
/** Set the block's in-progress/blocked status and step-completion progress. */
|
|
147
|
+
async updateBlockProgress(workspaceId, instance, status) {
|
|
148
|
+
const total = instance.steps.length || 1;
|
|
149
|
+
const done = instance.steps.filter((s) => s.state === 'done').length;
|
|
150
|
+
await this.blockRepository.update(workspaceId, instance.blockId, {
|
|
151
|
+
status,
|
|
152
|
+
progress: Math.min(1, done / total),
|
|
153
|
+
});
|
|
154
|
+
}
|
|
155
|
+
/**
|
|
156
|
+
* Advance the block's step PROGRESS without touching its status — used when a step
|
|
157
|
+
* resolver already owns the block's terminal status (the merger set `done`/`pr_ready`)
|
|
158
|
+
* and a trailing step still follows, so the bar moves on without downgrading that status.
|
|
159
|
+
*/
|
|
160
|
+
async refreshBlockProgress(workspaceId, instance) {
|
|
161
|
+
const total = instance.steps.length || 1;
|
|
162
|
+
const done = instance.steps.filter((s) => s.state === 'done').length;
|
|
163
|
+
await this.blockRepository.update(workspaceId, instance.blockId, {
|
|
164
|
+
progress: Math.min(1, done / total),
|
|
165
|
+
});
|
|
166
|
+
}
|
|
167
|
+
/**
|
|
168
|
+
* Park a step on a human approval decision: mint the approval id, freeze the step's
|
|
169
|
+
* duration clock, flip the run `blocked`, persist + emit, and return the durable
|
|
170
|
+
* `awaiting_decision` outcome the driver parks on.
|
|
171
|
+
*/
|
|
172
|
+
async parkStepOnDecision(workspaceId, instance, step, proposal = '') {
|
|
173
|
+
step.approval = { id: this.idGenerator.next('appr'), status: 'pending', proposal };
|
|
174
|
+
this.stepGraph.pauseStepForInput(step);
|
|
175
|
+
instance.status = 'blocked';
|
|
176
|
+
await this.updateBlockProgress(workspaceId, instance, 'blocked');
|
|
177
|
+
await this.executionRepository.upsert(workspaceId, instance);
|
|
178
|
+
await this.emitInstance(workspaceId, instance);
|
|
179
|
+
return { kind: 'awaiting_decision', decisionId: step.approval.id };
|
|
180
|
+
}
|
|
181
|
+
/**
|
|
182
|
+
* Finish a gate step whose decision a human resolved and advance the run: stamp the step
|
|
183
|
+
* done, finalize the block (final step) or start the next, persist, signal the durable
|
|
184
|
+
* driver that the decision is `approved`, and emit.
|
|
185
|
+
*/
|
|
186
|
+
async advancePastResolvedGate(workspaceId, instance, stepIndex) {
|
|
187
|
+
const step = instance.steps[stepIndex];
|
|
188
|
+
const decisionId = step.approval.id;
|
|
189
|
+
this.stepGraph.finishStep(step);
|
|
190
|
+
step.progress = 1;
|
|
191
|
+
const isFinalStep = stepIndex === instance.steps.length - 1;
|
|
192
|
+
if (isFinalStep) {
|
|
193
|
+
instance.status = 'done';
|
|
194
|
+
await this.finalizeBlock(workspaceId, instance, undefined);
|
|
195
|
+
await this.stopRunContainer(workspaceId, instance);
|
|
196
|
+
}
|
|
197
|
+
else {
|
|
198
|
+
instance.currentStep = stepIndex + 1;
|
|
199
|
+
const next = instance.steps[instance.currentStep];
|
|
200
|
+
if (next)
|
|
201
|
+
this.stepGraph.startStep(next);
|
|
202
|
+
if (instance.status === 'blocked')
|
|
203
|
+
instance.status = 'running';
|
|
204
|
+
await this.updateBlockProgress(workspaceId, instance, 'in_progress');
|
|
205
|
+
}
|
|
206
|
+
await this.executionRepository.upsert(workspaceId, instance);
|
|
207
|
+
await this.workRunner.signalDecision(workspaceId, instance.id, decisionId, 'approved');
|
|
208
|
+
await this.emitInstance(workspaceId, instance);
|
|
209
|
+
}
|
|
210
|
+
/**
|
|
211
|
+
* A pipeline finished. A frame becomes `done` (a mapping-only run leaves it
|
|
212
|
+
* `ready`). A *task* never auto-`done`s from a confidence score any more — that
|
|
213
|
+
* looked merged when the PR was still open with red CI. Instead:
|
|
214
|
+
* - if the pipeline has a `merger` step, it already owned the merge/notify
|
|
215
|
+
* decision (see `resolveMergerStep`); we only backstop a missing one;
|
|
216
|
+
* - otherwise the work is complete but unmerged: leave the PR open (`pr_ready`)
|
|
217
|
+
* and raise a `pipeline_complete` notification for a human to confirm + merge.
|
|
218
|
+
* `done` now strictly means the PR was merged (see the engine's `finalizeMerge`).
|
|
219
|
+
*/
|
|
220
|
+
async finalizeBlock(workspaceId, instance, confidence) {
|
|
221
|
+
const block = await this.blockRepository.get(workspaceId, instance.blockId);
|
|
222
|
+
if (!block || block.status === 'done')
|
|
223
|
+
return;
|
|
224
|
+
if ((block.level ?? 'frame') !== 'task') {
|
|
225
|
+
// A mapping-only run (just the `blueprints` step, e.g. kicked off after a
|
|
226
|
+
// bootstrap) leaves the service frame `ready` and droppable rather than
|
|
227
|
+
// marking the whole service "done".
|
|
228
|
+
const mappingOnly = instance.steps.every((s) => s.agentKind === 'blueprints');
|
|
229
|
+
await this.blockRepository.update(workspaceId, block.id, {
|
|
230
|
+
status: mappingOnly ? 'ready' : 'done',
|
|
231
|
+
progress: 1,
|
|
232
|
+
});
|
|
233
|
+
return;
|
|
234
|
+
}
|
|
235
|
+
// Confidence is recorded by the caller (recordStepResult) before any merge, so
|
|
236
|
+
// it persists on both the merge and review paths; `confidence` is unused here.
|
|
237
|
+
void confidence;
|
|
238
|
+
const hasMerger = instance.steps.some((s) => s.agentKind === MERGER_AGENT_KIND);
|
|
239
|
+
if (hasMerger) {
|
|
240
|
+
// The `merger` step already merged (→ `done`) or raised a review (→ `pr_ready`).
|
|
241
|
+
// Only backstop the case where it produced no decision at all.
|
|
242
|
+
const fresh = await this.blockRepository.get(workspaceId, block.id);
|
|
243
|
+
if (fresh && fresh.status !== 'done' && fresh.status !== 'pr_ready') {
|
|
244
|
+
await this.blockRepository.update(workspaceId, block.id, {
|
|
245
|
+
status: 'pr_ready',
|
|
246
|
+
progress: 1,
|
|
247
|
+
});
|
|
248
|
+
}
|
|
249
|
+
return;
|
|
250
|
+
}
|
|
251
|
+
// No merger in this pipeline: complete but unmerged — ask a human to confirm.
|
|
252
|
+
await this.blockRepository.update(workspaceId, block.id, { status: 'pr_ready', progress: 1 });
|
|
253
|
+
await this.raisePipelineComplete(workspaceId, instance, block);
|
|
254
|
+
}
|
|
255
|
+
async raisePipelineComplete(workspaceId, instance, block) {
|
|
256
|
+
if (!this.notificationService)
|
|
257
|
+
return;
|
|
258
|
+
await this.notificationService.raise(workspaceId, {
|
|
259
|
+
type: 'pipeline_complete',
|
|
260
|
+
blockId: block.id,
|
|
261
|
+
executionId: instance.id,
|
|
262
|
+
title: `Confirm "${block.title}" is complete`,
|
|
263
|
+
body: `The "${instance.pipelineName}" pipeline finished and opened a PR, but it has no ` +
|
|
264
|
+
`merger step. Review the work and confirm it as complete (this merges the PR).`,
|
|
265
|
+
payload: {
|
|
266
|
+
...(block.pullRequest?.url ? { prUrl: block.pullRequest.url } : {}),
|
|
267
|
+
pipelineName: instance.pipelineName,
|
|
268
|
+
},
|
|
269
|
+
});
|
|
270
|
+
}
|
|
271
|
+
/**
|
|
272
|
+
* Record a terminal failure on a run: reclaim its container, mark it `failed` with the
|
|
273
|
+
* richest failure record (first write wins), drop the block to `blocked` with the
|
|
274
|
+
* progress it reached, and emit. The single funnel for every failure kind.
|
|
275
|
+
*/
|
|
276
|
+
async failRun(workspaceId, executionId, message, kind = 'agent', detail = null) {
|
|
277
|
+
const instance = await this.executionRepository.get(workspaceId, executionId);
|
|
278
|
+
if (!instance)
|
|
279
|
+
return;
|
|
280
|
+
// Reclaim the per-run container on the failure path too: a failed run otherwise
|
|
281
|
+
// leaves its container to idle out sleepAfter. This is the single funnel for
|
|
282
|
+
// every failure kind (job_failed from the driver, the spend/decision timeouts,
|
|
283
|
+
// and the user-facing stopRun, which already reclaimed — the call is idempotent).
|
|
284
|
+
await this.stopRunContainer(workspaceId, instance);
|
|
285
|
+
// The FIRST recorded failure wins: a run already in a terminal `failed` state keeps
|
|
286
|
+
// its existing (richest) failure rather than being overwritten. An inline gate that
|
|
287
|
+
// knows the precise kind/detail returns a `job_failed` result the driver funnels here,
|
|
288
|
+
// so there should only ever be one write — but this guards against a future path that
|
|
289
|
+
// both records a failure and returns `job_failed`, which would otherwise clobber the
|
|
290
|
+
// good record with a generic one (the companion-rejected regression).
|
|
291
|
+
if (instance.status === 'failed')
|
|
292
|
+
return;
|
|
293
|
+
const failure = {
|
|
294
|
+
kind,
|
|
295
|
+
message,
|
|
296
|
+
detail,
|
|
297
|
+
hint: EXECUTION_FAILURE_HINTS[kind] ?? null,
|
|
298
|
+
occurredAt: this.clock.now(),
|
|
299
|
+
lastSubtasks: instance.steps[instance.currentStep]?.subtasks ?? null,
|
|
300
|
+
};
|
|
301
|
+
await this.executionRepository.markFailed(workspaceId, executionId, failure);
|
|
302
|
+
// Progress reflects how far the pipeline got before failing.
|
|
303
|
+
const done = instance.steps.filter((s) => s.state === 'done').length;
|
|
304
|
+
const progress = instance.steps.length > 0 ? done / instance.steps.length : 0;
|
|
305
|
+
await this.blockRepository.update(workspaceId, instance.blockId, {
|
|
306
|
+
status: 'blocked',
|
|
307
|
+
progress,
|
|
308
|
+
});
|
|
309
|
+
const failed = await this.executionRepository.get(workspaceId, executionId);
|
|
310
|
+
if (failed)
|
|
311
|
+
await this.emitInstance(workspaceId, failed);
|
|
312
|
+
}
|
|
313
|
+
/** Reclaim the per-run container (per-job backends cancel the parked job; run-container
|
|
314
|
+
* backends use the run id). Best-effort: a vanished container is nothing to reclaim. */
|
|
315
|
+
async stopRunContainer(workspaceId, instance) {
|
|
316
|
+
const executor = this.agentExecutor;
|
|
317
|
+
if (!isAsyncAgentExecutor(executor) || !executor.stopJob)
|
|
318
|
+
return;
|
|
319
|
+
// The in-flight step's job id (when a job is parked), so a per-job backend can
|
|
320
|
+
// cancel exactly it; the run-container backends ignore it and use the run id.
|
|
321
|
+
const jobId = instance.steps[instance.currentStep]?.jobId ?? instance.id;
|
|
322
|
+
try {
|
|
323
|
+
await executor.stopJob({ jobId, runId: instance.id, workspaceId });
|
|
324
|
+
}
|
|
325
|
+
catch {
|
|
326
|
+
// The container may already be gone (eviction/completion) — nothing to reclaim.
|
|
327
|
+
}
|
|
328
|
+
}
|
|
329
|
+
/** Raise the iteration-cap `decision_required` card when a review loop parks at its cap. */
|
|
330
|
+
async raiseDecisionRequired(workspaceId, instance) {
|
|
331
|
+
if (!this.notificationService)
|
|
332
|
+
return;
|
|
333
|
+
const block = await this.blockRepository.get(workspaceId, instance.blockId);
|
|
334
|
+
if (!block)
|
|
335
|
+
return;
|
|
336
|
+
await this.notificationService.raise(workspaceId, {
|
|
337
|
+
type: 'decision_required',
|
|
338
|
+
blockId: block.id,
|
|
339
|
+
executionId: instance.id,
|
|
340
|
+
title: `"${block.title}" ran out of automatic iterations and needs your decision`,
|
|
341
|
+
body: 'An automatic review loop reached its iteration cap without converging. Open the ' +
|
|
342
|
+
'task to choose: one more round, proceed with the current result, or stop and reset.',
|
|
343
|
+
payload: { pipelineName: instance.pipelineName },
|
|
344
|
+
});
|
|
345
|
+
}
|
|
346
|
+
/**
|
|
347
|
+
* Ensure an open notification exists for a run that has just parked waiting for a human
|
|
348
|
+
* (an agent-raised decision, an approval gate, or an iterative review gate). Without
|
|
349
|
+
* the old decision timeout the run waits indefinitely, so the inbox card — which the
|
|
350
|
+
* periodic sweep escalates yellow → red — is the only signal a human is needed.
|
|
351
|
+
*
|
|
352
|
+
* Non-clobbering: if ANY open notification is already on the block (a more specific
|
|
353
|
+
* `merge_review`, iteration-cap `decision_required`, etc.), it is left untouched and we
|
|
354
|
+
* raise nothing — so the richer message wins. Best-effort: no notification service
|
|
355
|
+
* (tests) or a missing block is a no-op.
|
|
356
|
+
*/
|
|
357
|
+
async ensureWaitingNotification(workspaceId, instance) {
|
|
358
|
+
const svc = this.notificationService;
|
|
359
|
+
if (!svc)
|
|
360
|
+
return;
|
|
361
|
+
const open = await svc.listOpen(workspaceId);
|
|
362
|
+
if (open.some((n) => n.blockId === instance.blockId))
|
|
363
|
+
return;
|
|
364
|
+
const block = await this.blockRepository.get(workspaceId, instance.blockId);
|
|
365
|
+
if (!block)
|
|
366
|
+
return;
|
|
367
|
+
await svc.raise(workspaceId, {
|
|
368
|
+
type: 'decision_required',
|
|
369
|
+
blockId: block.id,
|
|
370
|
+
executionId: instance.id,
|
|
371
|
+
title: `"${block.title}" is waiting for your input`,
|
|
372
|
+
body: 'A pipeline step is parked awaiting a human decision. Open the task to respond.',
|
|
373
|
+
payload: { pipelineName: instance.pipelineName },
|
|
374
|
+
});
|
|
375
|
+
}
|
|
376
|
+
/**
|
|
377
|
+
* Clear the auto-raised "waiting for a human decision" card once a run advances past
|
|
378
|
+
* the decision it was parked on (so the escalation sweep can't flip a settled decision
|
|
379
|
+
* red). Scoped to the `decision_required` type, so the human-actionable cards a stopped
|
|
380
|
+
* run leaves behind are untouched. Best-effort: no notification service (tests) is a no-op.
|
|
381
|
+
*/
|
|
382
|
+
async clearWaitingNotification(workspaceId, instance) {
|
|
383
|
+
const svc = this.notificationService;
|
|
384
|
+
if (!svc)
|
|
385
|
+
return;
|
|
386
|
+
await svc.clearWaitingDecision(workspaceId, instance.blockId);
|
|
387
|
+
}
|
|
388
|
+
}
|
|
389
|
+
//# sourceMappingURL=RunStateMachine.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RunStateMachine.js","sourceRoot":"","sources":["../../../src/modules/execution/RunStateMachine.ts"],"names":[],"mappings":"AAeA,OAAO,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAA;AAC1D,OAAO,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAA;AAcjD;;;;GAIG;AACH,MAAM,uBAAuB,GAA8C;IACzE,KAAK,EACH,sGAAsG;IACxG,UAAU,EACR,qKAAqK;IACvK,OAAO,EACL,idAAid;IACnd,OAAO,EACL,sHAAsH;IACxH,QAAQ,EACN,2GAA2G;IAC7G,kBAAkB,EAChB,4LAA4L;IAC9L,SAAS,EAAE,0EAA0E;IACrF,QAAQ,EACN,yVAAyV;IAC3V,OAAO,EAAE,wEAAwE;CAClF,CAAA;AAmBD;;;;;;;;;;;;;GAaG;AACH,MAAM,OAAO,eAAe;IACT,mBAAmB,CAAqB;IACxC,eAAe,CAAiB;IAChC,MAAM,CAAyB;IAC/B,UAAU,CAAY;IACtB,aAAa,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K,6BAA6B;YACnD,IAAI,EAAE,gFAAgF;YACtF,OAAO,EAAE,EAAE,YAAY,EAAE,QAAQ,CAAC,YAAY,EAAE;SACjD,CAAC,CAAA;IACJ,CAAC;IAED;;;;;OAKG;IACH,KAAK,CAAC,wBAAwB,CAAC,WAAmB,EAAE,QAA2B;QAC7E,MAAM,GAAG,GAAG,IAAI,CAAC,mBAAmB,CAAA;QACpC,IAAI,CAAC,GAAG;YAAE,OAAM;QAChB,MAAM,GAAG,CAAC,oBAAoB,CAAC,WAAW,EAAE,QAAQ,CAAC,OAAO,CAAC,CAAA;IAC/D,CAAC;CACF"}
|
|
@@ -2,6 +2,7 @@ import type { AgentExecutor, AgentRunResult, Block, BlockRepository, ExecutionIn
|
|
|
2
2
|
import type { NotificationService } from '../notifications/NotificationService.js';
|
|
3
3
|
import type { AdvanceResult } from './advance.js';
|
|
4
4
|
import type { AgentContextBuilder } from './AgentContextBuilder.js';
|
|
5
|
+
import type { RunStateMachine } from './RunStateMachine.js';
|
|
5
6
|
/** The engine collaborators the Tester gate drives (kept on the engine, injected here). */
|
|
6
7
|
export interface TesterControllerDeps {
|
|
7
8
|
blockRepository: BlockRepository;
|
|
@@ -12,10 +13,8 @@ export interface TesterControllerDeps {
|
|
|
12
13
|
resolveMergePreset: (workspaceId: string, block: Block) => Promise<{
|
|
13
14
|
ciMaxAttempts: number;
|
|
14
15
|
}>;
|
|
15
|
-
/**
|
|
16
|
-
|
|
17
|
-
persistInstance: (workspaceId: string, instance: ExecutionInstance) => Promise<void>;
|
|
18
|
-
emitInstance: (workspaceId: string, instance: ExecutionInstance) => Promise<void>;
|
|
16
|
+
/** The async instance/block spine (container reclaim, instance persist + emit). */
|
|
17
|
+
stateMachine: RunStateMachine;
|
|
19
18
|
}
|
|
20
19
|
/**
|
|
21
20
|
* Drives the Tester gate's fix loop: apply a Tester report to its step (greenlight →
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TesterController.d.ts","sourceRoot":"","sources":["../../../src/modules/execution/TesterController.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,aAAa,EAEb,cAAc,EACd,KAAK,EACL,eAAe,EACf,iBAAiB,EACjB,YAAY,EACb,MAAM,qBAAqB,CAAA;AAI5B,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,yCAAyC,CAAA;AAClF,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,cAAc,CAAA;AACjD,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAA;
|
|
1
|
+
{"version":3,"file":"TesterController.d.ts","sourceRoot":"","sources":["../../../src/modules/execution/TesterController.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,aAAa,EAEb,cAAc,EACd,KAAK,EACL,eAAe,EACf,iBAAiB,EACjB,YAAY,EACb,MAAM,qBAAqB,CAAA;AAI5B,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,yCAAyC,CAAA;AAClF,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,cAAc,CAAA;AACjD,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAA;AACnE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAA;AA4C3D,2FAA2F;AAC3F,MAAM,WAAW,oBAAoB;IACnC,eAAe,EAAE,eAAe,CAAA;IAChC,mBAAmB,CAAC,EAAE,mBAAmB,CAAA;IACzC,aAAa,EAAE,aAAa,CAAA;IAC5B,cAAc,EAAE,mBAAmB,CAAA;IACnC,0EAA0E;IAC1E,kBAAkB,EAAE,CAAC,WAAW,EAAE,MAAM,EAAE,KAAK,EAAE,KAAK,KAAK,OAAO,CAAC;QAAE,aAAa,EAAE,MAAM,CAAA;KAAE,CAAC,CAAA;IAC7F,mFAAmF;IACnF,YAAY,EAAE,eAAe,CAAA;CAC9B;AAED;;;;;;;GAOG;AACH,qBAAa,gBAAgB;IACf,OAAO,CAAC,QAAQ,CAAC,IAAI;IAAjC,YAA6B,IAAI,EAAE,oBAAoB,EAAI;IAE3D;;;;;;OAMG;IACG,mBAAmB,CACvB,WAAW,EAAE,MAAM,EACnB,QAAQ,EAAE,iBAAiB,EAC3B,IAAI,EAAE,YAAY,EAClB,MAAM,EAAE,cAAc,GACrB,OAAO,CAAC,aAAa,GAAG,IAAI,CAAC,CA+D/B;IAED;;;OAGG;IACG,cAAc,CAClB,WAAW,EAAE,MAAM,EACnB,QAAQ,EAAE,iBAAiB,EAC3B,IAAI,EAAE,YAAY,EAClB,KAAK,EAAE,KAAK,GACX,OAAO,CAAC,aAAa,CAAC,CAsBxB;IAED;;;;;OAKG;YACW,UAAU;IAkBxB,wEAAwE;YAC1D,eAAe;IAuB7B;;;;;OAKG;YACW,aAAa;CA0D5B"}
|
|
@@ -105,7 +105,7 @@ export class TesterController {
|
|
|
105
105
|
// Reclaim the finished Tester container before dispatching the Fixer so the
|
|
106
106
|
// next job boots fresh — the per-run container would otherwise re-attach to the
|
|
107
107
|
// completed Tester job (idempotent dispatch by run id), replaying its result.
|
|
108
|
-
await this.deps.stopRunContainer(workspaceId, instance);
|
|
108
|
+
await this.deps.stateMachine.stopRunContainer(workspaceId, instance);
|
|
109
109
|
return this.dispatchFixer(workspaceId, instance, step, block, report);
|
|
110
110
|
}
|
|
111
111
|
// Budget spent (or no async executor to fix with): give up for human attention.
|
|
@@ -130,8 +130,8 @@ export class TesterController {
|
|
|
130
130
|
step.subtasks = undefined;
|
|
131
131
|
if (step.test)
|
|
132
132
|
step.test.phase = 'testing';
|
|
133
|
-
await this.deps.persistInstance(workspaceId, instance);
|
|
134
|
-
await this.deps.emitInstance(workspaceId, instance);
|
|
133
|
+
await this.deps.stateMachine.persistInstance(workspaceId, instance);
|
|
134
|
+
await this.deps.stateMachine.emitInstance(workspaceId, instance);
|
|
135
135
|
return { kind: 'awaiting_job', jobId: step.jobId, stepIndex: instance.currentStep };
|
|
136
136
|
}
|
|
137
137
|
/**
|
|
@@ -142,7 +142,7 @@ export class TesterController {
|
|
|
142
142
|
*/
|
|
143
143
|
async failTester(workspaceId, instance, step, block, output, error, attempts) {
|
|
144
144
|
step.output = output;
|
|
145
|
-
await this.deps.persistInstance(workspaceId, instance);
|
|
145
|
+
await this.deps.stateMachine.persistInstance(workspaceId, instance);
|
|
146
146
|
await this.raiseTestFailed(workspaceId, instance, block, error, attempts);
|
|
147
147
|
// Carry the precise classification (`agent`, not the generic container `job_failed`)
|
|
148
148
|
// and the Tester's own summary to the driver's single `failRun` funnel; failing the
|
|
@@ -207,8 +207,8 @@ export class TesterController {
|
|
|
207
207
|
maxAttempts: step.test?.maxAttempts ?? DEFAULT_MERGE_PRESET.ciMaxAttempts,
|
|
208
208
|
lastReport: report,
|
|
209
209
|
};
|
|
210
|
-
await this.deps.persistInstance(workspaceId, instance);
|
|
211
|
-
await this.deps.emitInstance(workspaceId, instance);
|
|
210
|
+
await this.deps.stateMachine.persistInstance(workspaceId, instance);
|
|
211
|
+
await this.deps.stateMachine.emitInstance(workspaceId, instance);
|
|
212
212
|
return { kind: 'awaiting_job', jobId: step.jobId, stepIndex: instance.currentStep };
|
|
213
213
|
}
|
|
214
214
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TesterController.js","sourceRoot":"","sources":["../../../src/modules/execution/TesterController.ts"],"names":[],"mappings":"AASA,OAAO,EAAE,oBAAoB,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAA;AAChF,OAAO,EAAmB,eAAe,EAAE,MAAM,wBAAwB,CAAA;AACzE,OAAO,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAA;
|
|
1
|
+
{"version":3,"file":"TesterController.js","sourceRoot":"","sources":["../../../src/modules/execution/TesterController.ts"],"names":[],"mappings":"AASA,OAAO,EAAE,oBAAoB,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAA;AAChF,OAAO,EAAmB,eAAe,EAAE,MAAM,wBAAwB,CAAA;AACzE,OAAO,EAAE,gBAAgB,EAAE,iB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,CAAC,aAAa;YACzE,UAAU,EAAE,MAAM;SACnB,CAAA;QACD,MAAM,IAAI,CAAC,IAAI,CAAC,YAAY,CAAC,eAAe,CAAC,WAAW,EAAE,QAAQ,CAAC,CAAA;QACnE,MAAM,IAAI,CAAC,IAAI,CAAC,YAAY,CAAC,YAAY,CAAC,WAAW,EAAE,QAAQ,CAAC,CAAA;QAChE,OAAO,EAAE,IAAI,EAAE,cAAc,EAAE,KAAK,EAAE,IAAI,CAAC,KAAK,EAAE,SAAS,EAAE,QAAQ,CAAC,WAAW,EAAE,CAAA;IACrF,CAAC;CACF"}
|
|
@@ -2,6 +2,8 @@ import type { AgentExecutor, ResolveBinaryArtifactStore, Block, BlockRepository,
|
|
|
2
2
|
import type { NotificationService } from '../notifications/NotificationService.js';
|
|
3
3
|
import type { AdvanceResult } from './advance.js';
|
|
4
4
|
import type { AgentContextBuilder } from './AgentContextBuilder.js';
|
|
5
|
+
import type { RunStateMachine } from './RunStateMachine.js';
|
|
6
|
+
import type { StepGraph } from './StepGraph.js';
|
|
5
7
|
/**
|
|
6
8
|
* The engine collaborators the visual-confirmation gate drives (kept on the engine, injected
|
|
7
9
|
* here). The binary-artifact store + notification channel are optional — absent ones put the
|
|
@@ -23,14 +25,10 @@ export interface VisualConfirmationControllerDeps {
|
|
|
23
25
|
resolveMergePreset: (workspaceId: string, block: Block) => Promise<{
|
|
24
26
|
ciMaxAttempts: number;
|
|
25
27
|
}>;
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
finalizeBlock: (workspaceId: string, instance: ExecutionInstance, confidence: number | undefined) => Promise<void>;
|
|
31
|
-
stopRunContainer: (workspaceId: string, instance: ExecutionInstance) => Promise<void>;
|
|
32
|
-
persistInstance: (workspaceId: string, instance: ExecutionInstance) => Promise<void>;
|
|
33
|
-
emitInstance: (workspaceId: string, instance: ExecutionInstance) => Promise<void>;
|
|
28
|
+
/** The async instance/block spine (park/advance/finalize/persist/emit/progress/stop). */
|
|
29
|
+
stateMachine: RunStateMachine;
|
|
30
|
+
/** The pure step mutators (start/finish a step). */
|
|
31
|
+
stepGraph: StepGraph;
|
|
34
32
|
clockNow: () => number;
|
|
35
33
|
}
|
|
36
34
|
/** The settle outcome of a helper (fixer) job, as seen by the gate. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"VisualConfirmationController.d.ts","sourceRoot":"","sources":["../../../src/modules/execution/VisualConfirmationController.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,aAAa,EAGb,0BAA0B,EAC1B,KAAK,EACL,eAAe,EACf,iBAAiB,EACjB,mBAAmB,EACnB,YAAY,EAGZ,UAAU,EACX,MAAM,qBAAqB,CAAA;AAG5B,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,yCAAyC,CAAA;AAClF,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,cAAc,CAAA;AACjD,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAA;
|
|
1
|
+
{"version":3,"file":"VisualConfirmationController.d.ts","sourceRoot":"","sources":["../../../src/modules/execution/VisualConfirmationController.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,aAAa,EAGb,0BAA0B,EAC1B,KAAK,EACL,eAAe,EACf,iBAAiB,EACjB,mBAAmB,EACnB,YAAY,EAGZ,UAAU,EACX,MAAM,qBAAqB,CAAA;AAG5B,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,yCAAyC,CAAA;AAClF,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,cAAc,CAAA;AACjD,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAA;AACnE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAA;AAC3D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAA;AAc/C;;;;GAIG;AACH,MAAM,WAAW,gCAAgC;IAC/C,eAAe,EAAE,eAAe,CAAA;IA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