@cat-factory/orchestration 0.104.0 → 0.105.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/modules/execution/AgentContextBuilder.d.ts.map +1 -1
- package/dist/modules/execution/AgentContextBuilder.js +25 -2
- package/dist/modules/execution/AgentContextBuilder.js.map +1 -1
- package/dist/modules/execution/ExecutionService.d.ts +7 -1
- package/dist/modules/execution/ExecutionService.d.ts.map +1 -1
- package/dist/modules/execution/ExecutionService.js +22 -0
- package/dist/modules/execution/ExecutionService.js.map +1 -1
- package/dist/modules/execution/ForkDecisionController.d.ts +68 -0
- package/dist/modules/execution/ForkDecisionController.d.ts.map +1 -0
- package/dist/modules/execution/ForkDecisionController.js +169 -0
- package/dist/modules/execution/ForkDecisionController.js.map +1 -0
- package/dist/modules/execution/RunDispatcher.d.ts +18 -1
- package/dist/modules/execution/RunDispatcher.d.ts.map +1 -1
- package/dist/modules/execution/RunDispatcher.js +100 -5
- package/dist/modules/execution/RunDispatcher.js.map +1 -1
- package/dist/modules/execution/RunStateMachine.d.ts +3 -1
- package/dist/modules/execution/RunStateMachine.d.ts.map +1 -1
- package/dist/modules/execution/RunStateMachine.js +13 -3
- package/dist/modules/execution/RunStateMachine.js.map +1 -1
- package/dist/modules/execution/forkDecision.logic.d.ts +50 -0
- package/dist/modules/execution/forkDecision.logic.d.ts.map +1 -0
- package/dist/modules/execution/forkDecision.logic.js +108 -0
- package/dist/modules/execution/forkDecision.logic.js.map +1 -0
- package/dist/modules/merge/RiskPolicyService.d.ts.map +1 -1
- package/dist/modules/merge/RiskPolicyService.js +3 -0
- package/dist/modules/merge/RiskPolicyService.js.map +1 -1
- package/dist/modules/notifications/NotificationService.d.ts.map +1 -1
- package/dist/modules/notifications/NotificationService.js +5 -1
- package/dist/modules/notifications/NotificationService.js.map +1 -1
- package/package.json +11 -11
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ForkDecisionController.js","sourceR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AK,CAAC,wBAAwB,CACpC,WAAmB,EACnB,QAA2B,EAC3B,SAAiB;QAEjB,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,mBAAmB;YAAE,OAAM;QAC1C,MAAM,KAAK,GAAG,MAAM,IAAI,CAAC,IAAI,CAAC,eAAe,CAAC,GAAG,CAAC,WAAW,EAAE,QAAQ,CAAC,OAAO,CAAC,CAAA;QAChF,IAAI,CAAC,KAAK;YAAE,OAAM;QAClB,MAAM,IAAI,CAAC,IAAI,CAAC,mBAAmB,CAAC,KAAK,CAAC,WAAW,EAAE;YACrD,IAAI,EAAE,uBAAuB;YAC7B,OAAO,EAAE,KAAK,CAAC,EAAE;YACjB,WAAW,EAAE,QAAQ,CAAC,EAAE;YACxB,KAAK,EAAE,IAAI,KAAK,CAAC,KAAK,SAAS,SAAS,2CAA2C;YACnF,IAAI,EACF,mFAAmF;gBACnF,sFAAsF;gBACtF,kBAAkB;YACpB,OAAO,EAAE,EAAE,YAAY,EAAE,QAAQ,CAAC,YAAY,EAAE,SAAS,EAAE;SAC5D,CAAC,CAAA;IACJ,CAAC;CACF"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { AgentExecutor, AgentRunContext, AgentRunResult, Block, BlockRepository, BrainstormSession, ClarityReview, Clock, ExecutionEventPublisher, ExecutionInstance, ExecutionRepository, FollowUpsStepState, GateDefinition, IdGenerator, IssueWritebackProvider, PipelineStep, ProviderCapabilities, ProvisionContext, RequirementConcernLevel, RequirementReview, ResolveRunRepoContext, RunInitiatorScope, TicketTrackerProvider, WorkRunner } from '@cat-factory/kernel';
|
|
1
|
+
import type { AgentExecutor, AgentRunContext, AgentRunResult, Block, BlockRepository, BrainstormSession, ClarityReview, Clock, ExecutionEventPublisher, ExecutionInstance, ExecutionRepository, FollowUpsStepState, ForkDecisionStepState, ChooseForkInput, GateDefinition, IdGenerator, IssueWritebackProvider, PipelineStep, ProviderCapabilities, ProvisionContext, RequirementConcernLevel, StepGating, RequirementReview, ResolveRunRepoContext, RunInitiatorScope, TicketTrackerProvider, WorkRunner } from '@cat-factory/kernel';
|
|
2
2
|
import type { AgentKindRegistry } from '@cat-factory/agents';
|
|
3
3
|
import type { BugIntakeService, EnvironmentProvisioningService } from '@cat-factory/integrations';
|
|
4
4
|
import { AgentContextBuilder } from './AgentContextBuilder.js';
|
|
@@ -6,6 +6,7 @@ import { CompanionController } from './CompanionController.js';
|
|
|
6
6
|
import { HumanTestController } from './HumanTestController.js';
|
|
7
7
|
import { MergeResolver } from './MergeResolver.js';
|
|
8
8
|
import { ReviewGateController, type ReviewKind } from './ReviewGateController.js';
|
|
9
|
+
import { ForkDecisionController } from './ForkDecisionController.js';
|
|
9
10
|
import type { InterviewGateController } from './InterviewGateController.js';
|
|
10
11
|
import { RunStateMachine } from './RunStateMachine.js';
|
|
11
12
|
import { StepGraph } from './StepGraph.js';
|
|
@@ -32,6 +33,7 @@ type ResolvedRiskPolicy = {
|
|
|
32
33
|
releaseWatchWindowMinutes: number;
|
|
33
34
|
releaseMaxAttempts: number;
|
|
34
35
|
humanReviewGraceMinutes: number;
|
|
36
|
+
forkDecision?: StepGating | null;
|
|
35
37
|
};
|
|
36
38
|
/** Collaborators + leaf dependencies the {@link RunDispatcher} needs. */
|
|
37
39
|
export interface RunDispatcherDeps {
|
|
@@ -54,6 +56,7 @@ export interface RunDispatcherDeps {
|
|
|
54
56
|
humanTestController: HumanTestController;
|
|
55
57
|
visualConfirmationController: VisualConfirmationController;
|
|
56
58
|
reviewGate: ReviewGateController;
|
|
59
|
+
forkDecisionController: ForkDecisionController;
|
|
57
60
|
requirementsKind: ReviewKind<RequirementReview>;
|
|
58
61
|
clarityKind: ReviewKind<ClarityReview>;
|
|
59
62
|
requirementsBrainstormKind: ReviewKind<BrainstormSession>;
|
|
@@ -116,6 +119,7 @@ export declare class RunDispatcher {
|
|
|
116
119
|
private readonly humanTestController;
|
|
117
120
|
private readonly visualConfirmationController;
|
|
118
121
|
private readonly reviewGate;
|
|
122
|
+
private readonly forkDecisionController;
|
|
119
123
|
private readonly requirementsKind;
|
|
120
124
|
private readonly clarityKind;
|
|
121
125
|
private readonly requirementsBrainstormKind;
|
|
@@ -665,6 +669,19 @@ export declare class RunDispatcher {
|
|
|
665
669
|
private activeFollowUpStep;
|
|
666
670
|
/** Read a run's live follow-up companion state (the active Coder step's items), or null. */
|
|
667
671
|
getFollowUps(workspaceId: string, executionId: string): Promise<FollowUpsStepState | null>;
|
|
672
|
+
/**
|
|
673
|
+
* Run the fork-decision phase for a coder step. On fresh entry resolve whether to propose
|
|
674
|
+
* (tri-state `off` → skip; `always` → propose; `auto` → the risk-policy fork gate against the
|
|
675
|
+
* block's estimate). Not proposing → record `skipped` and `continue` so the driver re-enters
|
|
676
|
+
* and dispatches the Coder. Proposing → dispatch the read-only `fork-proposer` explore job on
|
|
677
|
+
* this step (Phase A) via {@link handleAgentStep} with a dispatch-kind override; its
|
|
678
|
+
* completion is intercepted. A re-drive while `proposing` re-attaches to the running job.
|
|
679
|
+
*/
|
|
680
|
+
private handleForkDecisionPhase;
|
|
681
|
+
/** Read a run's active implementation-fork decision state, or null. */
|
|
682
|
+
getForkDecision(workspaceId: string, executionId: string): Promise<ForkDecisionStepState | null>;
|
|
683
|
+
/** Resolve the human's implementation-fork choice, re-running the Coder with it folded in. */
|
|
684
|
+
chooseFork(workspaceId: string, executionId: string, input: ChooseForkInput): Promise<ForkDecisionStepState>;
|
|
668
685
|
/**
|
|
669
686
|
* Locate the run + the Coder step that OWNS the addressed item + the item, throwing 404
|
|
670
687
|
* when absent. Routes by item id (not "the first enabled step") so a pipeline carrying more
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RunDispatcher.d.ts","sourceRoot":"","sources":["../../../src/modules/execution/RunDispatcher.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,aAAa,EAEb,eAAe,EACf,cAAc,EAEd,KAAK,EACL,eAAe,EAEf,iBAAiB,EACjB,aAAa,EACb,KAAK,EAEL,uBAAuB,EACvB,iBAAiB,EACjB,mBAAmB,EAEnB,kBAAkB,EAElB,cAAc,EAEd,WAAW,EACX,sBAAsB,EACtB,YAAY,EACZ,oBAAoB,EACpB,gBAAgB,EAGhB,uBAAuB,EACvB,iBAAiB,EACjB,qBAAqB,EAErB,iBAAiB,EAMjB,qBAAqB,EACrB,UAAU,EACX,MAAM,qBAAqB,CAAA;
|
|
1
|
+
{"version":3,"file":"RunDispatcher.d.ts","sourceRoot":"","sources":["../../../src/modules/execution/RunDispatcher.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,aAAa,EAEb,eAAe,EACf,cAAc,EAEd,KAAK,EACL,eAAe,EAEf,iBAAiB,EACjB,aAAa,EACb,KAAK,EAEL,uBAAuB,EACvB,iBAAiB,EACjB,mBAAmB,EAEnB,kBAAkB,EAElB,qBAAqB,EACrB,eAAe,EAEf,cAAc,EAEd,WAAW,EACX,sBAAsB,EACtB,YAAY,EACZ,oBAAoB,EACpB,gBAAgB,EAGhB,uBAAuB,EACvB,UAAU,EACV,iBAAiB,EACjB,qBAAqB,EAErB,iBAAiB,EAMjB,qBAAqB,EACrB,UAAU,EACX,MAAM,qBAAqB,CAAA;AAuC5B,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAA;AAE5D,OAAO,KAAK,EAEV,gBAAgB,EAChB,8BAA8B,EAG/B,MAAM,2BAA2B,CAAA;AAyClC,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAA;AAC9D,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAA;AAC9D,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAA;AAC9D,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAA;AAClD,OAAO,EAAE,oBAAoB,EAAE,KAAK,UAAU,EAAE,MAAM,2BAA2B,CAAA;AACjF,OAAO,EAAE,sBAAsB,EAAE,MAAM,6BAA6B,CAAA;AAOpE,OAAO,KAAK,E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AAM,EACd,MAAM,EAAE,MAAM,GACb,OAAO,CAAC,kBAAkB,CAAC,CAU7B;IAED,gEAAgE;IAC1D,eAAe,CACnB,WAAW,EAAE,MAAM,EACnB,WAAW,EAAE,MAAM,EACnB,MAAM,EAAE,MAAM,GACb,OAAO,CAAC,kBAAkB,CAAC,CAK7B;IAED;;;;;;;;;;;;OAYG;YACW,qBAAqB;IAyEnC,gFAAgF;IAChF,YAAY,CAAC,KAAK,EAAE,KAAK,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAQjD;IAED;;;;;OAKG;IACH,aAAa,CAAC,KAAK,EAAE,KAAK,GAAG,gBAAgB,CAe5C;IAED;;;;;OAKG;IACG,QAAQ,CAAC,OAAO,EAAE,eAAe,EAAE,OAAO,GAAE,cAAmB,GAAG,OAAO,CAAC,cAAc,CAAC,CAY9F;IAED;;;;;;;OAOG;YACW,eAAe;IAsB7B;;;;;OAKG;YACW,UAAU;CAWzB"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ConflictError, DEFAULT_RISK_POLICY, getErrorMessage, getErrorReason, getProvider, INITIATIVE_ANALYST_AGENT_KIND, INITIATIVE_COMMITTER_AGENT_KIND, INITIATIVE_PLANNER_AGENT_KIND, isAsyncAgentExecutor, NotFoundError, parseLocalModelId, recordGateAttempt, registeredGateFactories, registeredStepResolverFactories, requireProvider, RunContendedError, sameSubtasks, } from '@cat-factory/kernel';
|
|
2
2
|
import { frontendOriginsForService, parseBlueprintService, parseSpecDoc, resolveAprioriWorkingBranch, } from '@cat-factory/contracts';
|
|
3
|
-
import { blueprintPostOp, commitInitiativeTracker, hasTrait, isCompanionKind, isContainerBackedCompanion, INTERVIEW_GATE_TRAIT, moduleSlug, runRepoOps, specPostOp, TASK_ESTIMATOR_AGENT_KIND, } from '@cat-factory/agents';
|
|
3
|
+
import { blueprintPostOp, commitInitiativeTracker, FORK_PROPOSER_KIND, hasTrait, isCompanionKind, isContainerBackedCompanion, INTERVIEW_GATE_TRAIT, moduleSlug, runRepoOps, specPostOp, TASK_ESTIMATOR_AGENT_KIND, } from '@cat-factory/agents';
|
|
4
4
|
import { DEPLOYER_AGENT_KIND, isDeployStep } from '@cat-factory/integrations';
|
|
5
5
|
import { BUG_INTAKE_AGENT_KIND } from '../pipelines/pipelineShape.js';
|
|
6
6
|
import { coerceTaskEstimate, summarizeEstimate } from '../estimation/estimate.logic.js';
|
|
@@ -17,6 +17,8 @@ import { CompanionController } from './CompanionController.js';
|
|
|
17
17
|
import { HumanTestController } from './HumanTestController.js';
|
|
18
18
|
import { MergeResolver } from './MergeResolver.js';
|
|
19
19
|
import { ReviewGateController } from './ReviewGateController.js';
|
|
20
|
+
import { ForkDecisionController } from './ForkDecisionController.js';
|
|
21
|
+
import { DEFAULT_FORK_MAX_CHAT_TURNS, forkPhasePending, resolveForkTriState, shouldProposeForkAuto, } from './forkDecision.logic.js';
|
|
20
22
|
import { RunStateMachine } from './RunStateMachine.js';
|
|
21
23
|
import { StepGraph } from './StepGraph.js';
|
|
22
24
|
import { TesterController } from './TesterController.js';
|
|
@@ -115,6 +117,7 @@ export class RunDispatcher {
|
|
|
115
117
|
humanTestController;
|
|
116
118
|
visualConfirmationController;
|
|
117
119
|
reviewGate;
|
|
120
|
+
forkDecisionController;
|
|
118
121
|
requirementsKind;
|
|
119
122
|
clarityKind;
|
|
120
123
|
requirementsBrainstormKind;
|
|
@@ -160,6 +163,7 @@ export class RunDispatcher {
|
|
|
160
163
|
this.humanTestController = deps.humanTestController;
|
|
161
164
|
this.visualConfirmationController = deps.visualConfirmationController;
|
|
162
165
|
this.reviewGate = deps.reviewGate;
|
|
166
|
+
this.forkDecisionController = deps.forkDecisionController;
|
|
163
167
|
this.requirementsKind = deps.requirementsKind;
|
|
164
168
|
this.clarityKind = deps.clarityKind;
|
|
165
169
|
this.requirementsBrainstormKind = deps.requirementsBrainstormKind;
|
|
@@ -208,14 +212,19 @@ export class RunDispatcher {
|
|
|
208
212
|
* what the dispatch chain falls through to; all the deterministic / gate / inline-review
|
|
209
213
|
* kinds are claimed earlier by their own handlers (see {@link buildStepHandlerRegistry}).
|
|
210
214
|
*/
|
|
211
|
-
async handleAgentStep(ctx) {
|
|
215
|
+
async handleAgentStep(ctx, dispatchKind) {
|
|
212
216
|
const { workspaceId, instance, step, block, isFinalStep, options } = ctx;
|
|
213
217
|
// Async (container) steps don't block: dispatch the job and park. The durable
|
|
214
218
|
// driver polls `pollAgentJob` between sleeps so the run can span far longer
|
|
215
219
|
// than a single durable step's timeout, while each step stays short. A set
|
|
216
220
|
// `jobId` means a prior (possibly replayed) dispatch already started the job,
|
|
217
221
|
// so we re-attach instead of starting a duplicate.
|
|
218
|
-
|
|
222
|
+
//
|
|
223
|
+
// `dispatchKind` overrides the dispatched agent kind WITHOUT changing `step.agentKind`
|
|
224
|
+
// — used by the fork-decision phase to dispatch the read-only `fork-proposer` explore
|
|
225
|
+
// job as a HELPER off the coder step (Phase A). The completion still records against the
|
|
226
|
+
// coder step, and the fork-proposal interceptor keys on `step.agentKind` + the fork state.
|
|
227
|
+
const context = await this.contextBuilder.buildContext(workspaceId, instance, step, isFinalStep, block, dispatchKind ? { agentKind: dispatchKind } : undefined);
|
|
219
228
|
// A registered custom kind's PRE-ops run deterministic backend repo work before the
|
|
220
229
|
// agent dispatches (e.g. read a baseline `spec/` shard into the prompt). Gated on the
|
|
221
230
|
// step not having dispatched yet so a Workflows replay (jobId already set) doesn't
|
|
@@ -497,7 +506,10 @@ export class RunDispatcher {
|
|
|
497
506
|
const persisted = await this.runStateMachine.mutateInstance(workspaceId, executionId, async (fresh) => {
|
|
498
507
|
await applyRunningFold(fresh);
|
|
499
508
|
});
|
|
500
|
-
|
|
509
|
+
// Progress-only fold (subtask ticks / streamed follow-ups): skip the per-run
|
|
510
|
+
// LLM-metrics GROUP BY so a live container's poll cadence doesn't re-aggregate
|
|
511
|
+
// the run on every tick. The rollup refreshes on the step-boundary/terminal emit.
|
|
512
|
+
await this.runStateMachine.emitInstance(workspaceId, persisted, { rollUpMetrics: false });
|
|
501
513
|
}
|
|
502
514
|
catch (error) {
|
|
503
515
|
// The run was cancelled/removed mid-poll (`NotFoundError`) or stayed hot-contended
|
|
@@ -1462,7 +1474,9 @@ export class RunDispatcher {
|
|
|
1462
1474
|
}
|
|
1463
1475
|
if (changed) {
|
|
1464
1476
|
await this.runStateMachine.casPersist(workspaceId, instance);
|
|
1465
|
-
|
|
1477
|
+
// Progress-only deploy-job fold: skip the LLM-metrics rollup (same reason as the
|
|
1478
|
+
// agent running fold above — a deploy job makes no LLM calls anyway).
|
|
1479
|
+
await this.runStateMachine.emitInstance(workspaceId, instance, { rollUpMetrics: false });
|
|
1466
1480
|
}
|
|
1467
1481
|
return { kind: 'awaiting_job', jobId: step.jobId, stepIndex: instance.currentStep };
|
|
1468
1482
|
}
|
|
@@ -2239,6 +2253,19 @@ export class RunDispatcher {
|
|
|
2239
2253
|
canHandle: ({ step }) => isCompanionKind(step.agentKind) && !isContainerBackedCompanion(step.agentKind),
|
|
2240
2254
|
handle: ({ workspaceId, instance, step, block, isFinalStep, options }) => this.companionController.evaluate(workspaceId, instance, step, block, isFinalStep, options),
|
|
2241
2255
|
},
|
|
2256
|
+
// The optional implementation-fork decision phase on a Coder step (Phase A): when the
|
|
2257
|
+
// per-task tri-state + the risk-policy gate call for it, dispatch the read-only
|
|
2258
|
+
// `fork-proposer` explore job as a helper off THIS coder step. Claims the step only
|
|
2259
|
+
// while the phase is pending (tri-state not `off`, not yet resolved); once resolved
|
|
2260
|
+
// (`chosen` / `single_path` / `skipped`) it falls through so the Coder dispatches
|
|
2261
|
+
// normally (Phase B). A parked `awaiting_choice` step is short-circuited by the
|
|
2262
|
+
// run-lifecycle re-entry guard before this handler runs. See {@link handleForkDecisionPhase}.
|
|
2263
|
+
{
|
|
2264
|
+
kind: 'fork-decision',
|
|
2265
|
+
order: 170,
|
|
2266
|
+
canHandle: ({ step, block }) => forkPhasePending(step, resolveForkTriState(block.agentConfig)),
|
|
2267
|
+
handle: (ctx) => this.handleForkDecisionPhase(ctx),
|
|
2268
|
+
},
|
|
2242
2269
|
// The generic container/inline-agent step — claims every step no more-specific handler
|
|
2243
2270
|
// did. Highest order so it always runs last. See {@link handleAgentStep}.
|
|
2244
2271
|
{
|
|
@@ -2293,6 +2320,22 @@ export class RunDispatcher {
|
|
|
2293
2320
|
return this.companionController.resolveContainerVerdict(workspaceId, instance, step, companionBlock, isFinalStep, result);
|
|
2294
2321
|
},
|
|
2295
2322
|
},
|
|
2323
|
+
// The `fork-proposer` explore job (Phase A of the fork decision) just finished on a
|
|
2324
|
+
// coder step. Its structured `result.custom` is the proposal; record it onto the step's
|
|
2325
|
+
// `forkDecision` and either park for the human to choose (≥2 usable forks) or auto-advance
|
|
2326
|
+
// a single path — never the normal output/PR/follow-up/approval completion (none applies
|
|
2327
|
+
// to the proposer). Keyed on the coder step carrying `forkDecision.status === 'proposing'`.
|
|
2328
|
+
{
|
|
2329
|
+
kind: 'fork-proposal',
|
|
2330
|
+
order: 105,
|
|
2331
|
+
canIntercept: ({ step }) => step.agentKind === 'coder' && step.forkDecision?.status === 'proposing',
|
|
2332
|
+
intercept: ({ workspaceId, instance, step, result }) => {
|
|
2333
|
+
const proposal = this.agentKindRegistry
|
|
2334
|
+
.structuredOutput(FORK_PROPOSER_KIND)
|
|
2335
|
+
?.safeParse(result.custom);
|
|
2336
|
+
return this.forkDecisionController.recordProposal(workspaceId, instance, step, proposal, step.model);
|
|
2337
|
+
},
|
|
2338
|
+
},
|
|
2296
2339
|
// A `tester` step returned a structured report. On a withheld greenlight we do NOT
|
|
2297
2340
|
// finish the step: loop the `fixer` (within the attempt budget) and re-test, mirroring
|
|
2298
2341
|
// the CI gate. A greenlight (or no provider) returns null and falls through to the
|
|
@@ -2778,6 +2821,58 @@ export class RunDispatcher {
|
|
|
2778
2821
|
throw new NotFoundError('Execution', executionId);
|
|
2779
2822
|
return this.activeFollowUpStep(instance)?.step.followUps ?? null;
|
|
2780
2823
|
}
|
|
2824
|
+
// ---- Implementation-fork decision phase (Phase A dispatch) --------------
|
|
2825
|
+
// The proposer explore job runs as a HELPER off the coder step; its completion is handled
|
|
2826
|
+
// by the `fork-proposal` interceptor + {@link ForkDecisionController.recordProposal}, and the
|
|
2827
|
+
// human's choice by {@link ForkDecisionController.choose}. This method only owns the FRESH
|
|
2828
|
+
// entry: resolve the tri-state + risk-policy gate, then either dispatch the proposer or fall
|
|
2829
|
+
// through by marking the phase skipped so the Coder dispatches on the next re-drive.
|
|
2830
|
+
/**
|
|
2831
|
+
* Run the fork-decision phase for a coder step. On fresh entry resolve whether to propose
|
|
2832
|
+
* (tri-state `off` → skip; `always` → propose; `auto` → the risk-policy fork gate against the
|
|
2833
|
+
* block's estimate). Not proposing → record `skipped` and `continue` so the driver re-enters
|
|
2834
|
+
* and dispatches the Coder. Proposing → dispatch the read-only `fork-proposer` explore job on
|
|
2835
|
+
* this step (Phase A) via {@link handleAgentStep} with a dispatch-kind override; its
|
|
2836
|
+
* completion is intercepted. A re-drive while `proposing` re-attaches to the running job.
|
|
2837
|
+
*/
|
|
2838
|
+
async handleForkDecisionPhase(ctx) {
|
|
2839
|
+
const { workspaceId, instance, step, block } = ctx;
|
|
2840
|
+
if (!step.forkDecision) {
|
|
2841
|
+
const tri = resolveForkTriState(block.agentConfig);
|
|
2842
|
+
let propose = tri === 'always';
|
|
2843
|
+
if (tri === 'auto') {
|
|
2844
|
+
const policy = await this.resolveRiskPolicy(workspaceId, block);
|
|
2845
|
+
propose = shouldProposeForkAuto(policy.forkDecision, block.estimate);
|
|
2846
|
+
}
|
|
2847
|
+
if (!propose) {
|
|
2848
|
+
step.forkDecision = {
|
|
2849
|
+
status: 'skipped',
|
|
2850
|
+
forks: [],
|
|
2851
|
+
chat: [],
|
|
2852
|
+
maxChatTurns: DEFAULT_FORK_MAX_CHAT_TURNS,
|
|
2853
|
+
};
|
|
2854
|
+
await this.runStateMachine.casPersist(workspaceId, instance);
|
|
2855
|
+
await this.runStateMachine.emitInstance(workspaceId, instance);
|
|
2856
|
+
return { kind: 'continue' };
|
|
2857
|
+
}
|
|
2858
|
+
step.forkDecision = {
|
|
2859
|
+
status: 'proposing',
|
|
2860
|
+
forks: [],
|
|
2861
|
+
chat: [],
|
|
2862
|
+
maxChatTurns: DEFAULT_FORK_MAX_CHAT_TURNS,
|
|
2863
|
+
};
|
|
2864
|
+
}
|
|
2865
|
+
// Dispatch (or re-attach to) the proposer as a helper off this coder step.
|
|
2866
|
+
return this.handleAgentStep(ctx, FORK_PROPOSER_KIND);
|
|
2867
|
+
}
|
|
2868
|
+
/** Read a run's active implementation-fork decision state, or null. */
|
|
2869
|
+
getForkDecision(workspaceId, executionId) {
|
|
2870
|
+
return this.forkDecisionController.getActive(workspaceId, executionId);
|
|
2871
|
+
}
|
|
2872
|
+
/** Resolve the human's implementation-fork choice, re-running the Coder with it folded in. */
|
|
2873
|
+
chooseFork(workspaceId, executionId, input) {
|
|
2874
|
+
return this.forkDecisionController.choose(workspaceId, executionId, input);
|
|
2875
|
+
}
|
|
2781
2876
|
/**
|
|
2782
2877
|
* Locate the run + the Coder step that OWNS the addressed item + the item, throwing 404
|
|
2783
2878
|
* when absent. Routes by item id (not "the first enabled step") so a pipeline carrying more
|