@cat-factory/orchestration 0.193.0 → 0.195.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.
Files changed (121) hide show
  1. package/dist/container/dependencies.d.ts +17 -1
  2. package/dist/container/dependencies.d.ts.map +1 -1
  3. package/dist/container/module-shapes.d.ts +5 -0
  4. package/dist/container/module-shapes.d.ts.map +1 -1
  5. package/dist/container/platform-modules.d.ts.map +1 -1
  6. package/dist/container/platform-modules.js +14 -1
  7. package/dist/container/platform-modules.js.map +1 -1
  8. package/dist/container.d.ts +20 -2
  9. package/dist/container.d.ts.map +1 -1
  10. package/dist/container.js +14 -0
  11. package/dist/container.js.map +1 -1
  12. package/dist/index.d.ts +2 -0
  13. package/dist/index.d.ts.map +1 -1
  14. package/dist/index.js +2 -0
  15. package/dist/index.js.map +1 -1
  16. package/dist/modules/board/BoardService.d.ts +2 -0
  17. package/dist/modules/board/BoardService.d.ts.map +1 -1
  18. package/dist/modules/board/BoardService.js +4 -0
  19. package/dist/modules/board/BoardService.js.map +1 -1
  20. package/dist/modules/board/publicBoardReads.d.ts +12 -0
  21. package/dist/modules/board/publicBoardReads.d.ts.map +1 -1
  22. package/dist/modules/board/publicBoardReads.js +19 -4
  23. package/dist/modules/board/publicBoardReads.js.map +1 -1
  24. package/dist/modules/debug/RunDebugService.d.ts +27 -1
  25. package/dist/modules/debug/RunDebugService.d.ts.map +1 -1
  26. package/dist/modules/debug/RunDebugService.js +24 -2
  27. package/dist/modules/debug/RunDebugService.js.map +1 -1
  28. package/dist/modules/debug/debug.logic.d.ts +3 -3
  29. package/dist/modules/debug/debug.logic.d.ts.map +1 -1
  30. package/dist/modules/debug/debug.logic.js +4 -1
  31. package/dist/modules/debug/debug.logic.js.map +1 -1
  32. package/dist/modules/execution/AgentDispatchController.d.ts +115 -0
  33. package/dist/modules/execution/AgentDispatchController.d.ts.map +1 -0
  34. package/dist/modules/execution/AgentDispatchController.js +307 -0
  35. package/dist/modules/execution/AgentDispatchController.js.map +1 -0
  36. package/dist/modules/execution/ExecutionService.d.ts +18 -105
  37. package/dist/modules/execution/ExecutionService.d.ts.map +1 -1
  38. package/dist/modules/execution/ExecutionService.js +77 -589
  39. package/dist/modules/execution/ExecutionService.js.map +1 -1
  40. package/dist/modules/execution/ExecutionServiceDependencies.d.ts +6 -0
  41. package/dist/modules/execution/ExecutionServiceDependencies.d.ts.map +1 -1
  42. package/dist/modules/execution/IterationCapController.d.ts +57 -0
  43. package/dist/modules/execution/IterationCapController.d.ts.map +1 -0
  44. package/dist/modules/execution/IterationCapController.js +141 -0
  45. package/dist/modules/execution/IterationCapController.js.map +1 -0
  46. package/dist/modules/execution/MergeResolver.d.ts +14 -2
  47. package/dist/modules/execution/MergeResolver.d.ts.map +1 -1
  48. package/dist/modules/execution/MergeResolver.js +83 -30
  49. package/dist/modules/execution/MergeResolver.js.map +1 -1
  50. package/dist/modules/execution/PrVerificationReportController.d.ts +23 -0
  51. package/dist/modules/execution/PrVerificationReportController.d.ts.map +1 -1
  52. package/dist/modules/execution/PrVerificationReportController.js +18 -0
  53. package/dist/modules/execution/PrVerificationReportController.js.map +1 -1
  54. package/dist/modules/execution/RunDispatcher.d.ts +31 -195
  55. package/dist/modules/execution/RunDispatcher.d.ts.map +1 -1
  56. package/dist/modules/execution/RunDispatcher.js +47 -313
  57. package/dist/modules/execution/RunDispatcher.js.map +1 -1
  58. package/dist/modules/execution/RunDispatcherDependencies.d.ts +142 -0
  59. package/dist/modules/execution/RunDispatcherDependencies.d.ts.map +1 -0
  60. package/dist/modules/execution/RunDispatcherDependencies.js +27 -0
  61. package/dist/modules/execution/RunDispatcherDependencies.js.map +1 -0
  62. package/dist/modules/execution/RunLifecycleController.d.ts +154 -0
  63. package/dist/modules/execution/RunLifecycleController.d.ts.map +1 -0
  64. package/dist/modules/execution/RunLifecycleController.js +507 -0
  65. package/dist/modules/execution/RunLifecycleController.js.map +1 -0
  66. package/dist/modules/execution/RunStateMachine.d.ts.map +1 -1
  67. package/dist/modules/execution/RunStateMachine.js +27 -14
  68. package/dist/modules/execution/RunStateMachine.js.map +1 -1
  69. package/dist/modules/execution/StepDecisionController.d.ts +20 -0
  70. package/dist/modules/execution/StepDecisionController.d.ts.map +1 -1
  71. package/dist/modules/execution/StepDecisionController.js +30 -0
  72. package/dist/modules/execution/StepDecisionController.js.map +1 -1
  73. package/dist/modules/execution/policy-types.d.ts +14 -1
  74. package/dist/modules/execution/policy-types.d.ts.map +1 -1
  75. package/dist/modules/execution/prReport.commands.d.ts +54 -0
  76. package/dist/modules/execution/prReport.commands.d.ts.map +1 -0
  77. package/dist/modules/execution/prReport.commands.js +316 -0
  78. package/dist/modules/execution/prReport.commands.js.map +1 -0
  79. package/dist/modules/execution/prReport.environments.d.ts +11 -0
  80. package/dist/modules/execution/prReport.environments.d.ts.map +1 -1
  81. package/dist/modules/execution/prReport.environments.js +9 -1
  82. package/dist/modules/execution/prReport.environments.js.map +1 -1
  83. package/dist/modules/execution/prReport.logic.d.ts.map +1 -1
  84. package/dist/modules/execution/prReport.logic.js +23 -2
  85. package/dist/modules/execution/prReport.logic.js.map +1 -1
  86. package/dist/modules/execution/reproductionProof.logic.js +1 -1
  87. package/dist/modules/execution/reproductionProof.logic.js.map +1 -1
  88. package/dist/modules/execution/retry.logic.d.ts +3 -2
  89. package/dist/modules/execution/retry.logic.d.ts.map +1 -1
  90. package/dist/modules/execution/retry.logic.js +14 -2
  91. package/dist/modules/execution/retry.logic.js.map +1 -1
  92. package/dist/modules/execution/run-action-controllers.d.ts +18 -0
  93. package/dist/modules/execution/run-action-controllers.d.ts.map +1 -0
  94. package/dist/modules/execution/run-action-controllers.js +19 -0
  95. package/dist/modules/execution/run-action-controllers.js.map +1 -0
  96. package/dist/modules/execution/runMode.logic.d.ts +78 -0
  97. package/dist/modules/execution/runMode.logic.d.ts.map +1 -0
  98. package/dist/modules/execution/runMode.logic.js +78 -0
  99. package/dist/modules/execution/runMode.logic.js.map +1 -0
  100. package/dist/modules/execution/runStartOptions.d.ts +16 -1
  101. package/dist/modules/execution/runStartOptions.d.ts.map +1 -1
  102. package/dist/modules/merge/RiskPolicyService.d.ts.map +1 -1
  103. package/dist/modules/merge/RiskPolicyService.js +4 -0
  104. package/dist/modules/merge/RiskPolicyService.js.map +1 -1
  105. package/dist/modules/observability/LlmObservabilityService.d.ts +35 -4
  106. package/dist/modules/observability/LlmObservabilityService.d.ts.map +1 -1
  107. package/dist/modules/observability/LlmObservabilityService.js +43 -7
  108. package/dist/modules/observability/LlmObservabilityService.js.map +1 -1
  109. package/dist/modules/observability/observability.logic.d.ts +12 -2
  110. package/dist/modules/observability/observability.logic.d.ts.map +1 -1
  111. package/dist/modules/observability/observability.logic.js +31 -2
  112. package/dist/modules/observability/observability.logic.js.map +1 -1
  113. package/dist/modules/tutorial/TutorialProgressService.d.ts +51 -0
  114. package/dist/modules/tutorial/TutorialProgressService.d.ts.map +1 -0
  115. package/dist/modules/tutorial/TutorialProgressService.js +111 -0
  116. package/dist/modules/tutorial/TutorialProgressService.js.map +1 -0
  117. package/dist/modules/tutorial/TutorialTelemetryService.d.ts +47 -0
  118. package/dist/modules/tutorial/TutorialTelemetryService.d.ts.map +1 -0
  119. package/dist/modules/tutorial/TutorialTelemetryService.js +67 -0
  120. package/dist/modules/tutorial/TutorialTelemetryService.js.map +1 -0
  121. package/package.json +11 -11
@@ -0,0 +1,507 @@
1
+ import { assertFound, ConflictError, DEFAULT_RISK_POLICY, noopLogger, ValidationError, } from '@cat-factory/kernel';
2
+ import { companionFor } from '@cat-factory/agents';
3
+ import { DEFAULT_COMPANION_MAX_ATTEMPTS, pipelineHasVisualStep } from '@cat-factory/contracts';
4
+ import { assertPipelineLaunchable } from '../pipelines/pipelineShape.js';
5
+ import { isTesterKind } from './ci.logic.js';
6
+ import { DEFAULT_FOLLOW_UP_MAX_LOOPS, FOLLOW_UP_PRODUCER_KIND } from './followUp.logic.js';
7
+ import { isRalphKind, resolveRalphConfig, seedRalphState } from './ralph.logic.js';
8
+ import { buildResumedInstance, planResumedSteps, planRestartFromStep } from './retry.logic.js';
9
+ import { claimLiveRunOrConflict, handOffLiveRun } from './runStart.js';
10
+ import { settleRunModeForStart } from './runMode.logic.js';
11
+ import { descendantIds } from '../board/board.logic.js';
12
+ /**
13
+ * A run's LIFECYCLE surface: every entry point that launches one (`start`), re-launches one
14
+ * (`retry` / `restartFromStep`), lifts a spend pause (`resumePaused`), or ends one (`cancel` /
15
+ * `stopRun` / `teardownForBlockTree`).
16
+ *
17
+ * They belong together because all three launch paths write the SAME two things in the SAME order:
18
+ * the atomic live-run claim, then the durable/SPA/outbound hand-off (both owned by `runStart.ts`,
19
+ * reached through the one `runStartDeps` getter below). They differ only in the block patch written
20
+ * between the two and in what each tears down first. Keeping that order in one place is what stops
21
+ * a new entry point from claiming without handing off (a run nothing drives) or announcing before
22
+ * the claim commits.
23
+ *
24
+ * `ExecutionService` keeps thin delegates, so no HTTP call site changed. The per-step machine
25
+ * (`advanceInstance` / `stepInstance`) and the human decision surface (`StepDecisionController`)
26
+ * deliberately stay where they are: those act on a run that is already live.
27
+ */
28
+ export class RunLifecycleController {
29
+ deps;
30
+ constructor(deps) {
31
+ this.deps = deps;
32
+ }
33
+ /** Start a pipeline against a block, replacing any prior run on it. */
34
+ async start(workspaceId, blockId, pipelineId, options = {}) {
35
+ const { initiatedBy, activate, origin = 'manual', intakeOrigin, gatesOverride } = options;
36
+ await this.deps.requireWorkspace(workspaceId);
37
+ const block = await this.deps.requireBlock(workspaceId, blockId);
38
+ const pipeline = assertFound(await this.deps.pipelineRepository.get(workspaceId, pipelineId), 'Pipeline', pipelineId);
39
+ // Launch-constraint gate (start-only, NOT part of the shared retry re-validation): reject a
40
+ // manual start of a recurring-only pipeline (or a scheduled fire of a one-off-only one), and
41
+ // a bug-intake pipeline that isn't recurring. Before any side effects.
42
+ assertPipelineLaunchable(pipeline.agentKinds, pipeline.availability, origin, pipeline.enabled);
43
+ // Per-run gate override must be parallel to the pipeline's steps (one boolean per step,
44
+ // original-index-aligned like `pipeline.gates`). A mismatch means a preset's review mapping
45
+ // is out of step with the pipeline it targets — reject up front, before any side effects.
46
+ if (gatesOverride && gatesOverride.length !== pipeline.agentKinds.length) {
47
+ throw new ValidationError(`Gate override has ${gatesOverride.length} entr${gatesOverride.length === 1 ? 'y' : 'ies'} but pipeline '${pipeline.id}' has ${pipeline.agentKinds.length} step(s).`);
48
+ }
49
+ // Shared config/resource preconditions (pipeline shape, frame type, tester infra, binary
50
+ // storage, agent backend, provider/preset satisfiability, budget) — the SAME gate a retry
51
+ // runs, so the two can't drift. See assertRunnable.
52
+ await this.deps.admission.assertRunnable(workspaceId, block, pipeline, initiatedBy);
53
+ // A Ralph-loop step needs a programmatic completion command (its exit condition); refuse to
54
+ // start a misconfigured run rather than dispatch a validation-less coding pass that never
55
+ // gates. The command is a per-task agent-config value (the SPA also requires it at creation).
56
+ if (pipeline.agentKinds.some(isRalphKind) &&
57
+ !resolveRalphConfig(block.agentConfig).validationCommand) {
58
+ throw new ValidationError('A Ralph loop task needs a validation command (its completion criterion) before it can ' +
59
+ 'start. Set one in the task configuration.');
60
+ }
61
+ // START-ONLY gates below: a retry REPLACES the failed run rather than adding a new one, so
62
+ // the concurrency limit doesn't apply to it, and a re-drive of an already-started task isn't
63
+ // re-gated on its dependencies.
64
+ // Enforce the workspace's per-service running-task limit (off by default) — a clear,
65
+ // actionable error before any side effects, so the human knows why the start was refused.
66
+ await this.deps.admission.assertWithinTaskLimit(workspaceId, block);
67
+ // Hard dependency gate: a task cannot start while any block it `dependsOn` is unfinished
68
+ // (not yet `done`/merged). Enforced server-side so it holds for manual starts, recurring
69
+ // fires, auto-start propagation and direct API calls alike — the frontend's runnable
70
+ // check is only a hint. Before any side effects so nothing is torn down on a refusal.
71
+ await this.deps.admission.assertDependenciesMet(workspaceId, block);
72
+ // Mint the activation next: if the credential can't be unlocked, fail before
73
+ // tearing down the block's prior run or creating a new one.
74
+ const executionId = this.deps.idGenerator.next('exec');
75
+ await activate?.(executionId);
76
+ // Read the block's prior run once: a manual re-start of an already-running block REPLACES
77
+ // it (the board offers "start" on a live block), so we pass its id to `insertLive` as the
78
+ // `replaceId` it supersedes atomically. A genuinely-CONCURRENT second start reads the SAME
79
+ // prior (or none), so only one insert wins and the other is rejected 409 — the loser's
80
+ // `replaceId` deletes only what it read, never the winner's fresh row (see insertLive).
81
+ const prior = await this.deps.executionRepository.getByBlock(workspaceId, blockId);
82
+ // Replacing the block's prior run: clear its per-run activation now (it never reaches
83
+ // the terminal cleanup in emitInstance when it's still running), so a replaced run's
84
+ // system-encrypted token copy doesn't linger to its TTL. Keyed by the OLD run id, so
85
+ // the activation just minted for the new run is untouched.
86
+ if (this.deps.subscriptionActivations && prior && prior.id !== executionId) {
87
+ // Best-effort + idempotent, mirroring the terminal cleanup in RunStateMachine.emit: a
88
+ // failure here must never derail the start. In mothership mode this repo is remote and
89
+ // `deleteByExecution` is not yet allow-listed (it throws `unknown_method`), so an
90
+ // unguarded call would otherwise break re-running any block; the TTL sweep reclaims the
91
+ // stale activation row as the backstop.
92
+ try {
93
+ await this.deps.subscriptionActivations.deleteByExecution(prior.id);
94
+ }
95
+ catch {
96
+ // Swallow — see above.
97
+ }
98
+ }
99
+ // NB: do NOT `deleteByBlock` here — `claimLiveRunOrConflict` (below) atomically clears the
100
+ // block's terminal rows AND the `prior` run it replaces, then inserts the new live run, so a
101
+ // concurrent double-start is rejected by the live-run index instead of both wiping each
102
+ // other's row (see insertLive).
103
+ // Build the run only from the ENABLED steps. A step the pipeline marked
104
+ // `enabled[i] === false` is kept in the saved pipeline (so it can be toggled back
105
+ // on later) but skipped here entirely. Gates/thresholds are read by the kind's
106
+ // ORIGINAL index `i`, so they stay aligned to the kind even when earlier steps are
107
+ // skipped; the first SURVIVING step is the one that starts working.
108
+ const steps = pipeline.agentKinds
109
+ .map((kind, i) => ({ kind, i }))
110
+ .filter(({ i }) => pipeline.enabled?.[i] !== false)
111
+ .map(({ kind, i }, position) => {
112
+ const companionDef = companionFor(kind);
113
+ return {
114
+ agentKind: kind,
115
+ state: position === 0 ? 'working' : 'pending',
116
+ progress: 0,
117
+ decision: null,
118
+ // A gated step pauses for human approval once its proposal is ready (see
119
+ // recordStepResult). A per-run override (the initiative-preset seam) wins over the
120
+ // pipeline's own gate for this step; else the pipeline definition at run start. Both
121
+ // read by the step's ORIGINAL index `i`, so they stay aligned to the kind even when
122
+ // earlier steps are disabled.
123
+ requiresApproval: gatesOverride?.[i] ?? pipeline.gates?.[i] ?? false,
124
+ approval: null,
125
+ // A consensus-enabled step runs through the multi-model mechanism (the consensus
126
+ // executor reads this off the context). Copied from the pipeline at run start.
127
+ ...(pipeline.consensus?.[i] ? { consensus: pipeline.consensus[i] } : {}),
128
+ // Estimate gating: when set+enabled the step is skipped at runtime unless the
129
+ // block estimate (written by an earlier task-estimator step) meets the threshold.
130
+ ...(pipeline.gating?.[i] ? { gating: pipeline.gating[i] } : {}),
131
+ // The extensible per-step options bag (the new home for per-step parameters — see
132
+ // stepOptionsSchema). Copied from the pipeline at run start, keyed by the step's
133
+ // ORIGINAL index `i`, so it stays aligned to the kind even when earlier steps are
134
+ // disabled. Today it carries the requirements-review `autoRecommend` toggle.
135
+ ...(pipeline.stepOptions?.[i] ? { stepOptions: pipeline.stepOptions[i] } : {}),
136
+ // A companion step carries its quality bar + rework budget, seeded from the
137
+ // pipeline's per-step threshold (else the companion's default).
138
+ ...(companionDef
139
+ ? {
140
+ companion: {
141
+ threshold: pipeline.thresholds?.[i] ?? companionDef.defaultThreshold,
142
+ maxAttempts: DEFAULT_COMPANION_MAX_ATTEMPTS,
143
+ attempts: 0,
144
+ verdicts: [],
145
+ },
146
+ }
147
+ : {}),
148
+ // The Follow-up companion is on by default for a `coder` step; the pipeline's
149
+ // per-step `followUps[i] === false` toggle disables it. Seeded empty here; the
150
+ // harness streams items in as the Coder surfaces them (see pollAgentJob).
151
+ ...(kind === FOLLOW_UP_PRODUCER_KIND && pipeline.followUps?.[i] !== false
152
+ ? {
153
+ followUps: {
154
+ enabled: true,
155
+ items: [],
156
+ loops: 0,
157
+ maxLoops: DEFAULT_FOLLOW_UP_MAX_LOOPS,
158
+ },
159
+ }
160
+ : {}),
161
+ // The test quality-control companion is on by default for a Tester step; the
162
+ // pipeline's per-step `testerQuality[i].enabled === false` disables it. `maxAttempts`
163
+ // is seeded with the default ceiling here and refreshed from the task's resolved
164
+ // merge preset on the first report (TesterController). Optional estimate gating is
165
+ // carried through so it can be evaluated against the block estimate at gate time.
166
+ ...(isTesterKind(kind) && pipeline.testerQuality?.[i]?.enabled !== false
167
+ ? {
168
+ testerQuality: {
169
+ enabled: true,
170
+ attempts: 0,
171
+ maxAttempts: DEFAULT_RISK_POLICY.maxTesterQualityIterations,
172
+ verdicts: [],
173
+ ...(pipeline.testerQuality?.[i]?.gating
174
+ ? { gating: pipeline.testerQuality[i].gating }
175
+ : {}),
176
+ },
177
+ }
178
+ : {}),
179
+ // A `ralph` step carries its persistent-loop state — the iteration count, the budget,
180
+ // and the programmatic completion command — seeded from the block's per-task agent
181
+ // config. Riding the persisted step is what lets a mid-loop run survive a restart
182
+ // (both durable drivers + sweepers re-drive from it). See ralph.logic.ts.
183
+ ...(isRalphKind(kind)
184
+ ? { ralph: seedRalphState(resolveRalphConfig(block.agentConfig)) }
185
+ : {}),
186
+ };
187
+ });
188
+ if (steps.length === 0) {
189
+ throw new ValidationError('Pipeline has no enabled steps to run.');
190
+ }
191
+ // For a visual (UI-test) pipeline on a frontend frame, resolve its backend bindings ONCE at
192
+ // start and stamp both the resolved bindings and the non-fatal advisories (duplicate env vars,
193
+ // or a partial-live set of bound services) on the run. The bindings are a frozen snapshot so
194
+ // the SPA's run/step detail projects what the run ACTUALLY drove against (truthful after the
195
+ // envs are torn down). Only paid for a visual pipeline — the same condition the tester infra
196
+ // gate keys off — so a plain backend run does no extra env read. Absent → no notes/bindings.
197
+ const frontendRun = pipelineHasVisualStep({ agentKinds: pipeline.agentKinds })
198
+ ? await this.deps.contextBuilder.resolveFrontendRunInfo(workspaceId, block)
199
+ : undefined;
200
+ // Settle the run's MODE once and pin it below. Read at START, never at merge time: a run
201
+ // admitted as live must not become un-mergeable because the preset was edited while it
202
+ // worked, nor a sandboxed one escape because its role was un-listed mid-flight.
203
+ const { mode, notes } = await settleRunModeForStart({
204
+ requested: options.mode,
205
+ role: options.initiatedByRole,
206
+ loadDryRunRoles: async () => await this.deps.resolveDryRunRoles?.(workspaceId, block),
207
+ baseNotes: frontendRun?.notes ?? [],
208
+ logger: this.deps.logger ?? noopLogger,
209
+ fields: { workspaceId, executionId, blockId },
210
+ });
211
+ const instance = {
212
+ id: executionId,
213
+ blockId,
214
+ pipelineId: pipeline.id,
215
+ pipelineName: pipeline.name,
216
+ steps,
217
+ currentStep: 0,
218
+ status: 'running',
219
+ initiatedBy: initiatedBy ?? null,
220
+ // The authority this run is admitted under, pinned for the DURABLE merge path (which
221
+ // rebuilds the run from its stored row and has no request context to re-resolve a role
222
+ // from). Absent stays absent rather than being guessed onto a tier; `mode` is stored only
223
+ // when sandboxed, since `live` is the read-time default and what every legacy run was.
224
+ initiatedByRole: options.initiatedByRole ?? null,
225
+ ...(mode === 'dry_run' ? { mode } : {}),
226
+ // Only a headless start carries an explicit intake origin; `ui` is the read-time
227
+ // default, so an ordinary board/schedule start stores nothing extra.
228
+ ...(intakeOrigin != null ? { intakeOrigin } : {}),
229
+ createdAt: this.deps.clock.now(),
230
+ ...(notes.length ? { notes } : {}),
231
+ ...(frontendRun?.bindings.length ? { frontendBindings: frontendRun.bindings } : {}),
232
+ };
233
+ await claimLiveRunOrConflict(this.runStartDeps, workspaceId, instance, prior?.id);
234
+ await this.deps.blockRepository.update(workspaceId, blockId, {
235
+ status: 'in_progress',
236
+ progress: 0,
237
+ executionId: instance.id,
238
+ });
239
+ await handOffLiveRun(this.runStartDeps, workspaceId, instance, block);
240
+ return instance;
241
+ }
242
+ /**
243
+ * Retry a failed run: re-drive the same pipeline on the same block, **resuming
244
+ * from the step that actually failed** rather than restarting from step 0. The
245
+ * steps that already completed are preserved (so a `coder` failure in `pl_full`
246
+ * doesn't re-run the human-gated `requirements`/`architect` steps before it);
247
+ * the failed step and everything after it are reset to a clean, re-runnable
248
+ * state. Only a `failed` run can be retried.
249
+ *
250
+ * A fresh instance id is minted because the durable runner addresses one
251
+ * Workflows instance per execution id and the failed one is terminal — the new
252
+ * instance simply starts with `currentStep` pointed at the failed step, so the
253
+ * driver advances forward from there and never re-issues the completed steps'
254
+ * work. Mirrors {@link BootstrapService.retry}; both are reached via the unified
255
+ * `POST /agent-runs/:id/retry` endpoint.
256
+ */
257
+ async retry(workspaceId, executionId,
258
+ /** The retrying user (their personal subscription is used for individual-usage
259
+ * models). Falls back to the original initiator when omitted. */
260
+ initiatedBy,
261
+ /** Mint the per-run personal-credential activation (see {@link start}). */
262
+ activate) {
263
+ await this.deps.requireWorkspace(workspaceId);
264
+ const previous = assertFound(await this.deps.executionRepository.get(workspaceId, executionId), 'Execution', executionId);
265
+ if (previous.status !== 'failed') {
266
+ throw new ConflictError(`Only a failed run can be retried (run is '${previous.status}').`, 'run_not_retryable', { status: previous.status });
267
+ }
268
+ const block = await this.deps.requireBlock(workspaceId, previous.blockId);
269
+ // Run the SAME config/resource preconditions start() does (shape, frame type, tester infra,
270
+ // binary storage, agent backend, provider/preset satisfiability, budget), so a retry can't
271
+ // silently proceed on a config a fresh start would refuse — the drift that let a
272
+ // subscription-only preset fail mid-run against the routing default. Validated over the
273
+ // STORED steps (what the retry actually re-drives), not the current pipeline definition, so
274
+ // an out-of-band pipeline edit can't skew the gate and a deleted pipeline needs no special
275
+ // case. Before any side effects.
276
+ await this.deps.admission.assertRunnable(workspaceId, block, this.deps.admission.runnableShapeOf(previous.steps), initiatedBy ?? previous.initiatedBy);
277
+ const { steps, currentStep } = planResumedSteps(previous);
278
+ // Mint the activation before replacing the failed run, so a bad password aborts
279
+ // the retry without losing the retryable terminal run.
280
+ const newId = this.deps.idGenerator.next('exec');
281
+ const replaceId = previous.id;
282
+ await activate?.(newId);
283
+ // Replace the terminal failed run for this block with the resumed one (single run per
284
+ // block, matching the board's by-block projection). This mints a FRESH run id; the
285
+ // atomic `claimLiveRunOrConflict` below replaces `previous` (via `replaceId`) and clears
286
+ // any terminal rows in the SAME transaction, so a concurrent double-retry is serialised by
287
+ // the live-run index (the loser gets a 409) instead of both deleting-then-inserting.
288
+ const instance = buildResumedInstance({
289
+ previous,
290
+ id: newId,
291
+ plan: { steps, currentStep },
292
+ initiatedBy,
293
+ now: this.deps.clock.now(),
294
+ });
295
+ await claimLiveRunOrConflict(this.runStartDeps, workspaceId, instance, replaceId);
296
+ const done = steps.filter((s) => s.state === 'done').length;
297
+ await this.deps.blockRepository.update(workspaceId, previous.blockId, {
298
+ status: 'in_progress',
299
+ progress: steps.length > 0 ? done / steps.length : 0,
300
+ executionId: instance.id,
301
+ });
302
+ await handOffLiveRun(this.runStartDeps, workspaceId, instance, block);
303
+ return instance;
304
+ }
305
+ /**
306
+ * Restart a run from a human-chosen step: re-run from `fromStepIndex` onward,
307
+ * regardless of how far the run had progressed (a `done`, `failed`, `blocked`,
308
+ * `paused` or still-`running` run are all valid sources). Unlike {@link retry}
309
+ * (which resumes at the first FAILURE) this rewinds to an arbitrary step the user
310
+ * picked — so it can re-run steps that already completed.
311
+ *
312
+ * What is preserved vs reset:
313
+ * - Steps BEFORE `fromStepIndex` keep their `output`/approval/timing untouched, so
314
+ * the engine still hands the restarted step its predecessors' work as
315
+ * `priorOutputs` (and their resolved `decisions`) — a useful handoff.
316
+ * - The chosen step and every later one are reset to a clean, re-runnable state,
317
+ * dropping each step's iteration counters (companion attempts, gate/test attempts,
318
+ * eviction recoveries) so the restart starts those loops from zero.
319
+ * - A block's incorporated requirements are NOT touched: they live on the
320
+ * requirement-review record, so a restarted spec-writer/coder still receives the
321
+ * incorporated document (or the base description when none was generated). When the
322
+ * chosen step is the `requirements-review` gate ITSELF, re-running it mints a fresh
323
+ * iteration-1 review (the reviewer's `review()` replaces the prior one), which is
324
+ * exactly the "reset the iterations counter from this step" semantics.
325
+ *
326
+ * Like {@link retry} a fresh instance id is minted (the durable runner addresses one
327
+ * driver per execution id). Any still-live driver/container for the run being
328
+ * replaced is torn down first, so restarting a RUNNING run never orphans a container
329
+ * or a parked Workflows instance.
330
+ */
331
+ async restartFromStep(workspaceId, executionId, fromStepIndex,
332
+ /** The restarting user (their personal subscription is used for individual-usage
333
+ * models). Falls back to the original initiator when omitted. */
334
+ initiatedBy,
335
+ /** Mint the per-run personal-credential activation (see {@link start}). */
336
+ activate) {
337
+ await this.deps.requireWorkspace(workspaceId);
338
+ const previous = assertFound(await this.deps.executionRepository.get(workspaceId, executionId), 'Execution', executionId);
339
+ const block = await this.deps.requireBlock(workspaceId, previous.blockId);
340
+ if (!Number.isInteger(fromStepIndex) ||
341
+ fromStepIndex < 0 ||
342
+ fromStepIndex >= previous.steps.length) {
343
+ throw new ValidationError(`Step ${fromStepIndex} is out of range for this run (it has ${previous.steps.length} step(s)).`);
344
+ }
345
+ // Run the SAME config/resource preconditions start()/retry() do, over the STORED steps this
346
+ // restart re-drives (frame type, tester infra, binary storage, agent backend, provider/preset
347
+ // satisfiability, budget). A restart re-dispatches provider-bearing steps just like a retry,
348
+ // so it must be gated identically — otherwise a run whose preset can't run every step (e.g. a
349
+ // subscription-only model an inline reviewer can't drive) strands mid-run instead of being
350
+ // refused up front. Before any teardown/side effects.
351
+ await this.deps.admission.assertRunnable(workspaceId, block, this.deps.admission.runnableShapeOf(previous.steps), initiatedBy ?? previous.initiatedBy);
352
+ // Tear down whatever was driving the run we're about to replace — its per-run
353
+ // container AND its durable driver — before minting the restart. A `done`/`failed`
354
+ // run is already terminal (a no-op teardown), but a still-`running` run would
355
+ // otherwise leak a container and a live Workflows/pg-boss driver.
356
+ await this.deps.runStateMachine.stopRunContainer(workspaceId, previous);
357
+ await this.deps.workRunner.cancelRun(workspaceId, executionId);
358
+ const { steps, currentStep } = planRestartFromStep(previous, fromStepIndex);
359
+ // Mint the activation before replacing the prior run, so a bad password aborts the
360
+ // restart without losing the source run.
361
+ const newId = this.deps.idGenerator.next('exec');
362
+ const replaceId = previous.id;
363
+ await activate?.(newId);
364
+ // Like retry(), this mints a FRESH run id. `claimLiveRunOrConflict` atomically supersedes
365
+ // the torn-down source run (`replaceId`, which here may still be LIVE — running/paused/
366
+ // blocked) and clears terminal rows in one transaction, so a concurrent start that already
367
+ // created a NEW live run for the block loses (409) instead of being silently clobbered.
368
+ const instance = buildResumedInstance({
369
+ previous,
370
+ id: newId,
371
+ plan: { steps, currentStep },
372
+ initiatedBy,
373
+ now: this.deps.clock.now(),
374
+ });
375
+ await claimLiveRunOrConflict(this.runStartDeps, workspaceId, instance, replaceId);
376
+ const done = steps.filter((s) => s.state === 'done').length;
377
+ await this.deps.blockRepository.update(workspaceId, previous.blockId, {
378
+ status: 'in_progress',
379
+ progress: steps.length > 0 ? done / steps.length : 0,
380
+ executionId: instance.id,
381
+ });
382
+ await handOffLiveRun(this.runStartDeps, workspaceId, instance, block);
383
+ return instance;
384
+ }
385
+ /**
386
+ * The bound callbacks the two run-start funnels (`runStart.ts`) need, so they depend on no
387
+ * concrete repository or service. Those funnels own the ORDER between a run's atomic claim and
388
+ * its hand-off and are documented there; every start path calls both, writing the block state
389
+ * that path owns in between.
390
+ */
391
+ get runStartDeps() {
392
+ return {
393
+ insertLive: (ws, instance, options) => this.deps.executionRepository.insertLive(ws, instance, options),
394
+ startRun: (ws, id) => this.deps.workRunner.startRun(ws, id),
395
+ emitInstance: (ws, instance) => this.deps.runStateMachine.emitInstance(ws, instance),
396
+ publishRunStarted: (ws, instance, block) => this.deps.runStateMachine.publishRunStarted(ws, instance, block),
397
+ };
398
+ }
399
+ /**
400
+ * Resume every run paused by the spend safeguard in this workspace. Flips them
401
+ * back to `running` and re-drives the durable runner. If the budget is still
402
+ * exhausted the spend gate will simply pause them again on their next step.
403
+ */
404
+ async resumePaused(workspaceId) {
405
+ await this.deps.requireWorkspace(workspaceId);
406
+ // Lean projection: only the paused runs' ids are needed to re-drive them — no `detail` decode.
407
+ const live = await this.deps.executionRepository.listLive(workspaceId);
408
+ const paused = live.filter((e) => e.status === 'paused');
409
+ for (const p of paused) {
410
+ // Optimistic-concurrency write: only flip + re-drive a run that is STILL paused at
411
+ // write time, so a resume racing the driver (or a concurrent resume) can't clobber a
412
+ // run another writer already advanced. A vanished/contended run is skipped (the next
413
+ // sweep retries) rather than failing the whole batch.
414
+ let flipped = false;
415
+ const resumed = await this.deps.runStateMachine
416
+ .mutateInstance(workspaceId, p.id, (inst) => {
417
+ flipped = inst.status === 'paused';
418
+ if (flipped)
419
+ inst.status = 'running';
420
+ })
421
+ .catch(() => null);
422
+ if (resumed && flipped) {
423
+ // `startRun` re-drives runners that re-create the run from scratch (pg-boss re-enqueues
424
+ // the same id). On Cloudflare the paused run's Workflows instance is still ALIVE parked
425
+ // on a `waitForEvent`, so `startRun`'s `create` no-ops there; `signalResume` delivers the
426
+ // event that wakes it immediately instead of waiting out the periodic budget re-check.
427
+ await this.deps.workRunner.startRun(workspaceId, resumed.id);
428
+ await this.deps.workRunner.signalResume?.(workspaceId, resumed.id);
429
+ await this.deps.runStateMachine.emitInstance(workspaceId, resumed);
430
+ }
431
+ }
432
+ // Clear the workspace-scoped `budget_paused` card now the pause is being lifted (F3). If the
433
+ // budget is still exhausted a resumed run re-pauses and re-raises it on its next step.
434
+ await this.deps.runStateMachine.clearBudgetPaused(workspaceId);
435
+ return this.deps.executionRepository.listByWorkspace(workspaceId);
436
+ }
437
+ /** Cancel the run on a block, returning it to `planned`. */
438
+ async cancel(workspaceId, blockId) {
439
+ await this.deps.requireWorkspace(workspaceId);
440
+ await this.deps.requireBlock(workspaceId, blockId);
441
+ // Tear down the durable run (if any) AND its per-run container before removing
442
+ // the record, so a cancel never leaves a container running until its watchdog.
443
+ const existing = await this.deps.executionRepository.getByBlock(workspaceId, blockId);
444
+ if (existing) {
445
+ await this.deps.runStateMachine.stopRunContainer(workspaceId, existing);
446
+ await this.deps.workRunner.cancelRun(workspaceId, existing.id);
447
+ }
448
+ await this.deps.executionRepository.deleteByBlock(workspaceId, blockId);
449
+ await this.deps.blockRepository.update(workspaceId, blockId, {
450
+ status: 'planned',
451
+ progress: 0,
452
+ executionId: null,
453
+ });
454
+ // The run record is gone and the block is back to planned; the client can't
455
+ // reconstruct that from a per-instance event, so signal a coarse refresh. Name the block
456
+ // so the refresh fans out to every board mounting its shared service.
457
+ await this.deps.events.boardChanged(workspaceId, 'cancel', blockId);
458
+ return this.deps.requireBlock(workspaceId, blockId);
459
+ }
460
+ /**
461
+ * Explicitly stop a *running* run by id (the unified `POST /agent-runs/:id/stop`
462
+ * surface): kill its per-run container, tear down the durable driver, then record
463
+ * a terminal `cancelled` failure so the board shows the run stopped (with retry)
464
+ * rather than spinning forever. Idempotent — a run already terminal is returned
465
+ * as-is. `opts.reason`/`opts.kind` let the orphan sweep reuse this with its own
466
+ * wording instead of the user-facing default.
467
+ */
468
+ async stopRun(workspaceId, executionId, opts = {}) {
469
+ await this.deps.requireWorkspace(workspaceId);
470
+ const instance = assertFound(await this.deps.executionRepository.get(workspaceId, executionId), 'Execution', executionId);
471
+ if (instance.status === 'failed' || instance.status === 'done')
472
+ return instance;
473
+ await this.deps.runStateMachine.stopRunContainer(workspaceId, instance);
474
+ await this.deps.workRunner.cancelRun(workspaceId, executionId);
475
+ await this.deps.failRun(workspaceId, executionId, opts.reason ?? 'Stopped by the user.', opts.kind ?? 'cancelled');
476
+ return assertFound(await this.deps.executionRepository.get(workspaceId, executionId), 'Execution', executionId);
477
+ }
478
+ /**
479
+ * Tear down every run under a block subtree — kill each container, terminate each
480
+ * durable driver, and delete the run record — so deleting a service/module never
481
+ * orphans a container or a Workflows instance. Best-effort and silent: the board
482
+ * delete that follows emits the coarse refresh, so no per-run event is needed.
483
+ *
484
+ * Returns the workspace block list it loaded so the immediately-following `removeBlock`
485
+ * can reuse it instead of re-listing the whole board (this teardown deletes only run
486
+ * records, never blocks, so the list is still current) — see {@link PreloadedBlocks}.
487
+ */
488
+ async teardownForBlockTree(workspaceId, rootId) {
489
+ const blocks = await this.deps.blockRepository.listByWorkspace(workspaceId);
490
+ // Resolve every run in one query and index by block id, rather than a per-block
491
+ // getByBlock (N+1) over the whole subtree.
492
+ const runsByBlock = new Map((await this.deps.executionRepository.listByWorkspace(workspaceId)).map((run) => [
493
+ run.blockId,
494
+ run,
495
+ ]));
496
+ for (const blockId of descendantIds(blocks, rootId)) {
497
+ const run = runsByBlock.get(blockId);
498
+ if (!run)
499
+ continue;
500
+ await this.deps.runStateMachine.stopRunContainer(workspaceId, run);
501
+ await this.deps.workRunner.cancelRun(workspaceId, run.id);
502
+ await this.deps.executionRepository.deleteByBlock(workspaceId, blockId);
503
+ }
504
+ return { workspaceId, blocks };
505
+ }
506
+ }
507
+ //# sourceMappingURL=RunLifecycleController.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"RunLifecycleController.js","sourceRoot":"","sources":["../../../src/modules/execution/RunLifecycleController.ts"],"names":[],"mappings":"AAiBA,OAAO,EACL,WAAW,EACX,aAAa,EACb,mBAAmB,EACnB,UAAU,EACV,eAAe,GAChB,MAAM,qBAAqB,CAAA;AAC5B,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAA;AAClD,OAAO,EAAE,8BAA8B,EAAE,qBAAqB,EAAE,MAAM,wBAAwB,CAAA;AAC9F,OAAO,EAAE,wBAAwB,EAAE,MAAM,+BAA+B,CAAA;AACxE,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,CAAA;AAC5C,OAAO,EAAE,2BAA2B,EAAE,uBAAuB,EAAE,MAAM,qBAAqB,CAAA;AAC1F,OAAO,EAAE,WAAW,EAAE,kBAAkB,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAA;AAClF,OAAO,EAAE,oBAAoB,EAAE,gBAAgB,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAA;AAC9F,OAAO,EAAE,sBAAsB,EAAE,cAAc,EAAqB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AAW,GAAG,IAAI,GAAG,CACzB,CAAC,MAAM,IAAI,CAAC,IAAI,CAAC,mBAAmB,CAAC,eAAe,CAAC,WAAW,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC;YAC9E,GAAG,CAAC,OAAO;YACX,GAAG;SACJ,CAAC,CACH,CAAA;QACD,KAAK,MAAM,OAAO,IAAI,aAAa,CAAC,MAAM,EAAE,MAAM,CAAC,EAAE,CAAC;YACpD,MAAM,GAAG,GAAG,WAAW,CAAC,GAAG,CAAC,OAAO,CAAC,CAAA;YACpC,IAAI,CAAC,GAAG;gBAAE,SAAQ;YAClB,MAAM,IAAI,CAAC,IAAI,CAAC,eAAe,CAAC,gBAAgB,CAAC,WAAW,EAAE,GAAG,CAAC,CAAA;YAClE,MAAM,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,SAAS,CAAC,WAAW,EAAE,GAAG,CAAC,EAAE,CAAC,CAAA;YACzD,MAAM,IAAI,CAAC,IAAI,CAAC,mBAAmB,CAAC,aAAa,CAAC,WAAW,EAAE,OAAO,CAAC,CAAA;QACzE,CAAC;QACD,OAAO,EAAE,WAAW,EAAE,MAAM,EAAE,CAAA;IAChC,CAAC;CACF"}
@@ -1 +1 @@
1
- {"version":3,"file":"RunStateMachine.d.ts","sourceRoot":"","sources":["../../../src/modules/execution/RunStateMachine.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,aAAa,EAEb,gBAAgB,EAChB,KAAK,EACL,eAAe,EACf,KAAK,EACL,uBAAuB,EACvB,iBAAiB,EACjB,mBAAmB,EACnB,WAAW,EAEX,MAAM,EACN,YAAY,EACZ,qBAAqB,EACrB,gBAAgB,EAChB,gCAAgC,EAChC,UAAU,EACX,MAAM,qBAAqB,CAAA;AAe5B,OAAO,EAAE,KAAK,oBAAoB,EAAqB,MAAM,mCAAmC,CAAA;AAChG,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,qCAAqC,CAAA;AAClF,OAAO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AAC,IAAI,CAAC,CAO1D;CACF"}
@@ -315,6 +315,9 @@ export class RunStateMachine {
315
315
  const summaries = await this.llmObservability.summarizeByExecution(workspaceId, instance.id);
316
316
  if (summaries.length === 0)
317
317
  return;
318
+ // Labelled once per emit from the SAME service that priced the cells, so the amount and
319
+ // its currency can never come from different tables.
320
+ const costCurrency = this.llmObservability.rollupCurrency ?? undefined;
318
321
  const cellsByKind = new Map();
319
322
  for (const cell of summaries) {
320
323
  const bucket = cellsByKind.get(cell.agentKind);
@@ -328,6 +331,27 @@ export class RunStateMachine {
328
331
  if (!cells)
329
332
  continue;
330
333
  const s = foldRollupTotals(cells);
334
+ // Costliest phase first, so the board surface shows the slice worth attacking rather
335
+ // than whichever one the store happened to return first.
336
+ const byPhase = foldRollupsByPhase(cells)
337
+ .map((p) => ({
338
+ phase: p.phase,
339
+ calls: p.calls,
340
+ promptTokens: p.promptTokens,
341
+ cacheReadTokens: p.cacheReadTokens,
342
+ cacheWriteTokens: p.cacheWriteTokens,
343
+ completionTokens: p.completionTokens,
344
+ carryCostTokens: p.carryCostTokens,
345
+ errors: p.errors,
346
+ costEstimate: p.costEstimate,
347
+ }))
348
+ .sort((a, b) => b.carryCostTokens - a.carryCostTokens || b.calls - a.calls);
349
+ // The currency labels EVERY amount in this payload, so it is stated whenever any of
350
+ // them exists — the step's own total OR one of its phases. Keying it on the total
351
+ // alone withheld the label from exactly the mixed-model step whose total is null
352
+ // BECAUSE one phase ran unpriced, leaving its priced phases with money and no
353
+ // denomination. Absent still means there is nothing here to mislabel.
354
+ const priced = s.costEstimate != null || byPhase.some((p) => p.costEstimate != null);
331
355
  step.metrics = {
332
356
  calls: s.calls,
333
357
  promptTokens: s.promptTokens,
@@ -342,20 +366,9 @@ export class RunStateMachine {
342
366
  errors: s.errors,
343
367
  warnings: s.warnings,
344
368
  carryCostTokens: s.carryCostTokens,
345
- // Costliest phase first, so the board surface shows the slice worth attacking
346
- // rather than whichever one the store happened to return first.
347
- byPhase: foldRollupsByPhase(cells)
348
- .map((p) => ({
349
- phase: p.phase,
350
- calls: p.calls,
351
- promptTokens: p.promptTokens,
352
- cacheReadTokens: p.cacheReadTokens,
353
- cacheWriteTokens: p.cacheWriteTokens,
354
- completionTokens: p.completionTokens,
355
- carryCostTokens: p.carryCostTokens,
356
- errors: p.errors,
357
- }))
358
- .sort((a, b) => b.carryCostTokens - a.carryCostTokens || b.calls - a.calls),
369
+ costEstimate: s.costEstimate,
370
+ costCurrency: priced ? costCurrency : undefined,
371
+ byPhase,
359
372
  };
360
373
  }
361
374
  }