@cat-factory/orchestration 0.177.0 → 0.178.1

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 (61) hide show
  1. package/dist/container/dependencies.d.ts +9 -1
  2. package/dist/container/dependencies.d.ts.map +1 -1
  3. package/dist/container.d.ts.map +1 -1
  4. package/dist/container.js +1 -0
  5. package/dist/container.js.map +1 -1
  6. package/dist/modules/execution/AgentContextBuilder.d.ts +5 -24
  7. package/dist/modules/execution/AgentContextBuilder.d.ts.map +1 -1
  8. package/dist/modules/execution/AgentContextBuilder.js +10 -42
  9. package/dist/modules/execution/AgentContextBuilder.js.map +1 -1
  10. package/dist/modules/execution/ExecutionService.d.ts +14 -72
  11. package/dist/modules/execution/ExecutionService.d.ts.map +1 -1
  12. package/dist/modules/execution/ExecutionService.js +70 -353
  13. package/dist/modules/execution/ExecutionService.js.map +1 -1
  14. package/dist/modules/execution/ExecutionServiceDependencies.d.ts +7 -1
  15. package/dist/modules/execution/ExecutionServiceDependencies.d.ts.map +1 -1
  16. package/dist/modules/execution/OneShotStepController.d.ts +92 -0
  17. package/dist/modules/execution/OneShotStepController.d.ts.map +1 -0
  18. package/dist/modules/execution/OneShotStepController.js +202 -0
  19. package/dist/modules/execution/OneShotStepController.js.map +1 -0
  20. package/dist/modules/execution/PollRunningController.d.ts +113 -0
  21. package/dist/modules/execution/PollRunningController.d.ts.map +1 -0
  22. package/dist/modules/execution/PollRunningController.js +298 -0
  23. package/dist/modules/execution/PollRunningController.js.map +1 -0
  24. package/dist/modules/execution/RunAdmission.d.ts.map +1 -1
  25. package/dist/modules/execution/RunAdmission.js +4 -2
  26. package/dist/modules/execution/RunAdmission.js.map +1 -1
  27. package/dist/modules/execution/RunDispatcher.d.ts +4 -108
  28. package/dist/modules/execution/RunDispatcher.d.ts.map +1 -1
  29. package/dist/modules/execution/RunDispatcher.js +51 -468
  30. package/dist/modules/execution/RunDispatcher.js.map +1 -1
  31. package/dist/modules/execution/RunStateMachine.d.ts +44 -1
  32. package/dist/modules/execution/RunStateMachine.d.ts.map +1 -1
  33. package/dist/modules/execution/RunStateMachine.js +92 -1
  34. package/dist/modules/execution/RunStateMachine.js.map +1 -1
  35. package/dist/modules/execution/StepDecisionController.d.ts +120 -0
  36. package/dist/modules/execution/StepDecisionController.d.ts.map +1 -0
  37. package/dist/modules/execution/StepDecisionController.js +347 -0
  38. package/dist/modules/execution/StepDecisionController.js.map +1 -0
  39. package/dist/modules/execution/dispatchPromptSettings.d.ts +43 -0
  40. package/dist/modules/execution/dispatchPromptSettings.d.ts.map +1 -0
  41. package/dist/modules/execution/dispatchPromptSettings.js +76 -0
  42. package/dist/modules/execution/dispatchPromptSettings.js.map +1 -0
  43. package/dist/modules/execution/runStart.d.ts +50 -0
  44. package/dist/modules/execution/runStart.d.ts.map +1 -0
  45. package/dist/modules/execution/runStart.js +53 -0
  46. package/dist/modules/execution/runStart.js.map +1 -0
  47. package/dist/modules/kaizen/KaizenService.d.ts.map +1 -1
  48. package/dist/modules/kaizen/KaizenService.js +7 -5
  49. package/dist/modules/kaizen/KaizenService.js.map +1 -1
  50. package/dist/modules/kaizen/kaizen.logic.d.ts +24 -9
  51. package/dist/modules/kaizen/kaizen.logic.d.ts.map +1 -1
  52. package/dist/modules/kaizen/kaizen.logic.js +25 -10
  53. package/dist/modules/kaizen/kaizen.logic.js.map +1 -1
  54. package/dist/modules/pipelines/pipelineShape.d.ts +27 -0
  55. package/dist/modules/pipelines/pipelineShape.d.ts.map +1 -1
  56. package/dist/modules/pipelines/pipelineShape.js +44 -1
  57. package/dist/modules/pipelines/pipelineShape.js.map +1 -1
  58. package/dist/validation/validateRegistrations.d.ts.map +1 -1
  59. package/dist/validation/validateRegistrations.js +92 -0
  60. package/dist/validation/validateRegistrations.js.map +1 -1
  61. package/package.json +11 -11
@@ -1 +1 @@
1
- {"version":3,"file":"ExecutionService.d.ts","sourceRoot":"","sources":["../../../src/modules/execution/ExecutionService.ts"],"names":[],"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,MAAM,CAAC,WAAW,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,KAAK,CAAC,CAqBjE;IAED;;;;;;;OAOG;IACG,OAAO,CACX,WAAW,EAAE,MAAM,EACnB,WAAW,EAAE,MAAM,EACnB,IAAI,GAAE;QAAE,MAAM,CAAC,EAAE,MAAM,CAAC;QAAC,IAAI,CAAC,EAAE,gBAAgB,CAAA;KAAO,GACtD,OAAO,CAAC,iBAAiB,CAAC,CAqB5B;IAED;;;;;;;;;OASG;IACG,oBAAoB,CAAC,WAAW,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,eAAe,CAAC,CAkBxF;CACF"}
1
+ {"version":3,"file":"ExecutionService.d.ts","sourceRoot":"","sources":["../../../src/modules/execution/ExecutionService.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,eAAe,EACf,cAAc,EACd,iBAAiB,EACjB,gBAAgB,EAChB,KAAK,EACL,iBAAiB,EACjB,kBAAkB,EAClB,qBAAqB,EACrB,eAAe,EACf,oBAAoB,EACpB,iBAAiB,EACjB,oBAAoB,EACpB,6BAA6B,EAG7B,iBAAiB,EAIlB,MAAM,qBAAqB,CAAA;AAS5B,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAA;AAE3D,OAAO,EAEL,KAAK,uBAAuB,EAC7B,MAAM,8BAA8B,CAAA;AACrC,OAAO,EAOL,KAAK,kBAAkB,EACxB,MAAM,qBAAqB,CAAA;AAsB5B,OAAO,EACL,iBAAiB,EACjB,oBAAoB,EACpB,KAAK,gBAAgB,EACrB,wBAAwB,EACxB,KAAK,oBAAoB,EAC1B,MAAM,0BAA0B,CAAA;AAOjC,OAAO,EAAE,6BAA6B,EAAE,MAAM,oCAAoC,CAAA;AAClF,OAAO,EAAE,sBAAsB,EAAE,MAAM,6BAA6B,CAAA;AAGpE,OAAO,KAAK,EACV,kBAAkB,EAKnB,MAAM,qBAAqB,CAAA;AAO5B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,CAAC,iBAAiB,CAAC,CAyD5B;IAED;;;;;;;;;;;;;;;;;;;;;;;;;OAyBG;IACG,eAAe,CACnB,WAAW,EAAE,MAAM,EACnB,WAAW,EAAE,MAAM,EACnB,aAAa,EAAE,MAAM;IACrB;sEACkE;IAClE,WAAW,CAAC,EAAE,MAAM,GAAG,IAAI;IAC3B,2EAA2E;IAC3E,QAAQ,CAAC,EAAE,CAAC,WAAW,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,GAChD,OAAO,CAAC,iBAAiB,CAAC,CAgE5B;IAED;;;;;OAKG;IACH,OAAO,KAAK,YAAY,GASvB;IAED;;;;OAIG;IACG,YAAY,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,iBAAiB,EAAE,CAAC,CA+BpE;IAED,4DAA4D;IACtD,MAAM,CAAC,WAAW,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,KAAK,CAAC,CAqBjE;IAED;;;;;;;OAOG;IACG,OAAO,CACX,WAAW,EAAE,MAAM,EACnB,WAAW,EAAE,MAAM,EACnB,IAAI,GAAE;QAAE,MAAM,CAAC,EAAE,MAAM,CAAC;QAAC,IAAI,CAAC,EAAE,gBAAgB,CAAA;KAAO,GACtD,OAAO,CAAC,iBAAiB,CAAC,CAqB5B;IAED;;;;;;;;;OASG;IACG,oBAAoB,CAAC,WAAW,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,eAAe,CAAC,CAkBxF;CACF"}
@@ -1,18 +1,20 @@
1
1
  import { allPullRequests, DEFAULT_COMPANION_MAX_ATTEMPTS, pipelineHasVisualStep, } from '@cat-factory/contracts';
2
- import { companionFor, companionTargets, hasTrait, INTERVIEW_GATE_TRAIT, isCompanionKind, } from '@cat-factory/agents';
2
+ import { companionFor } from '@cat-factory/agents';
3
3
  import { assertPipelineLaunchable } from '../pipelines/pipelineShape.js';
4
4
  import { producerWasSkipped, shouldRunGatedStep } from './stepGating.logic.js';
5
5
  import { resolveIndividualVendors, } from './individualVendors.logic.js';
6
6
  import { assertFound, ConflictError, NotFoundError, RunContendedError, ReviewContendedError, ValidationError, } from '@cat-factory/kernel';
7
7
  import { DEFAULT_RISK_POLICY, noopLogger, runBestEffort } from '@cat-factory/kernel';
8
- import { REQUIREMENTS_REVIEW_AGENT_KIND, CLARITY_REVIEW_AGENT_KIND, REQUIREMENTS_BRAINSTORM_AGENT_KIND, ARCHITECTURE_BRAINSTORM_AGENT_KIND, isTesterKind, HUMAN_TEST_AGENT_KIND, VISUAL_CONFIRM_AGENT_KIND, HUMAN_REVIEW_AGENT_KIND, } from './ci.logic.js';
8
+ import { isTesterKind } from './ci.logic.js';
9
9
  import { DEFAULT_FOLLOW_UP_MAX_LOOPS, FOLLOW_UP_PRODUCER_KIND } from './followUp.logic.js';
10
10
  import { AgentContextBuilder } from './AgentContextBuilder.js';
11
11
  import { CompanionController } from './CompanionController.js';
12
12
  import { StepGraph } from './StepGraph.js';
13
+ import { claimLiveRunOrConflict, handOffLiveRun } from './runStart.js';
13
14
  import { RunStateMachine } from './RunStateMachine.js';
14
15
  import { RunDispatcher } from './RunDispatcher.js';
15
16
  import { RunAdmission } from './RunAdmission.js';
17
+ import { StepDecisionController } from './StepDecisionController.js';
16
18
  import { inferTechnicalLabel } from './technical.logic.js';
17
19
  import { MergeResolver } from './MergeResolver.js';
18
20
  import { PostMergeBoardController } from './PostMergeBoardController.js';
@@ -32,7 +34,6 @@ import { InitiativeInterviewController } from './InitiativeInterviewController.j
32
34
  import { DocInterviewController } from './DocInterviewController.js';
33
35
  import { isReentrantDecisionResume } from './reentrancy.logic.js';
34
36
  import { RunMergePolicy } from './RunMergePolicy.js';
35
- import { isAsyncAgentExecutor } from '@cat-factory/kernel';
36
37
  import { descendantIds } from '../board/board.logic.js';
37
38
  import { requireWorkspace } from '@cat-factory/kernel';
38
39
  import { buildResumedInstance, planResumedSteps, planRestartFromStep } from './retry.logic.js';
@@ -148,6 +149,8 @@ export class ExecutionService {
148
149
  * / `resolveGatePollExhaustion` + the follow-up human-action API are thin pass-throughs.
149
150
  */
150
151
  runDispatcher;
152
+ /** The human decision surface on a parked run (approve / reject / merge / …). */
153
+ stepDecisions;
151
154
  constructor(dependencies) {
152
155
  // Bind the whole deps object, then destructure what this constructor itself reads. The
153
156
  // object is what the sibling factories below are handed, so a field they consume can never
@@ -159,7 +162,7 @@ export class ExecutionService {
159
162
  // the context builder reads — the prompt-override log and the consensus-group library —
160
163
  // both fail that way when unforwarded: nothing errors, the feature is just off. Nothing
161
164
  // below may go back to naming them one by one.
162
- const { workspaceRepository, blockRepository, pipelineRepository, executionRepository, idGenerator, clock, agentExecutor, workRunner, executionEventPublisher, boardService, spendService, taskRepository, requirementReviewService, docInterviewService, forkChatService, testerQualityReviewer, kaizenScheduler, clarityReviewService, brainstormServices, environmentProvisioning, environmentTeardown, branchUpdater, blueprintReconciler, initiativeService, initiativeInterviewService, notificationService, resolveBinaryArtifactStore, llmObservability, pullRequestMerger, riskPolicyRepository, mergeTrackRecord, riskPolicyCache, ticketTrackerProvider, issueWriteback, bugIntakeService, subscriptionActivationRepository, resolveWorkspaceModelDefault, resolveProviderCapabilities, resolveRunRepoContext, runInitiatorScope, pokeInitiativeLoop, agentKindRegistry, gateRegistry, judgeRegistry, judgeAssessor, stepResolverRegistry, providerRegistry, prVerificationReportPublisher, workspaceSettingsRepository, appBaseUrl, logger, } = dependencies;
165
+ const { workspaceRepository, blockRepository, pipelineRepository, executionRepository, idGenerator, clock, agentExecutor, workRunner, executionEventPublisher, boardService, spendService, taskRepository, requirementReviewService, docInterviewService, forkChatService, testerQualityReviewer, kaizenScheduler, clarityReviewService, brainstormServices, environmentProvisioning, environmentTeardown, branchUpdater, blueprintReconciler, initiativeService, initiativeInterviewService, notificationService, runLifecycleSink, resolveBinaryArtifactStore, llmObservability, pullRequestMerger, riskPolicyRepository, mergeTrackRecord, riskPolicyCache, ticketTrackerProvider, issueWriteback, bugIntakeService, subscriptionActivationRepository, resolveWorkspaceModelDefault, resolveProviderCapabilities, resolveRunRepoContext, runInitiatorScope, pokeInitiativeLoop, agentKindRegistry, gateRegistry, judgeRegistry, judgeAssessor, stepResolverRegistry, providerRegistry, prVerificationReportPublisher, workspaceSettingsRepository, appBaseUrl, logger, } = dependencies;
163
166
  // Forward-only: the run-initiator scope is consumed solely by RunDispatcher (below), so it
164
167
  // is hoisted to a local with its default applied rather than stored as a `this.` field.
165
168
  const runInitiatorScopeFn = runInitiatorScope ?? ((_initiatedBy, fn) => fn());
@@ -188,6 +191,8 @@ export class ExecutionService {
188
191
  clock,
189
192
  stepGraph: this.stepGraph,
190
193
  notificationService,
194
+ runLifecycleSink,
195
+ logger,
191
196
  mergeTrackRecord,
192
197
  kaizenScheduler,
193
198
  subscriptionActivations: subscriptionActivationRepository,
@@ -361,6 +366,22 @@ export class ExecutionService {
361
366
  this.subscriptionActivations = subscriptionActivationRepository;
362
367
  this.pokeInitiativeLoop = pokeInitiativeLoop;
363
368
  this.resolveWorkspaceModelDefault = resolveWorkspaceModelDefault;
369
+ this.stepDecisions = new StepDecisionController({
370
+ agentExecutor: this.agentExecutor,
371
+ agentKindRegistry: this.agentKindRegistry,
372
+ blockRepository: this.blockRepository,
373
+ clock: this.clock,
374
+ executionRepository: this.executionRepository,
375
+ mergePolicy: this.mergePolicy,
376
+ runDispatcher: this.runDispatcher,
377
+ runStateMachine: this.runStateMachine,
378
+ stepGraph: this.stepGraph,
379
+ workRunner: this.workRunner,
380
+ requireWorkspace: (ws) => this.requireWorkspace(ws),
381
+ requireBlock: (ws, id) => this.requireBlock(ws, id),
382
+ failRun: (ws, id, message, kind, detail, reason) => this.failRun(ws, id, message, kind, detail, reason),
383
+ finalizeMerge: (ws, blockId) => this.finalizeMerge(ws, blockId),
384
+ });
364
385
  }
365
386
  /**
366
387
  * Assemble the post-merge board controller. A method rather than a literal in the constructor
@@ -535,7 +556,7 @@ export class ExecutionService {
535
556
  // Swallow — see above.
536
557
  }
537
558
  }
538
- // NB: do NOT `deleteByBlock` here — `insertLiveRunOrConflict` (below) atomically clears the
559
+ // NB: do NOT `deleteByBlock` here — `claimLiveRunOrConflict` (below) atomically clears the
539
560
  // block's terminal rows AND the `prior` run it replaces, then inserts the new live run, so a
540
561
  // concurrent double-start is rejected by the live-run index instead of both wiping each
541
562
  // other's row (see insertLive).
@@ -652,17 +673,13 @@ export class ExecutionService {
652
673
  ...(frontendRun?.notes.length ? { notes: frontendRun.notes } : {}),
653
674
  ...(frontendRun?.bindings.length ? { frontendBindings: frontendRun.bindings } : {}),
654
675
  };
655
- await this.insertLiveRunOrConflict(workspaceId, instance, prior?.id);
676
+ await claimLiveRunOrConflict(this.runStartDeps, workspaceId, instance, prior?.id);
656
677
  await this.blockRepository.update(workspaceId, blockId, {
657
678
  status: 'in_progress',
658
679
  progress: 0,
659
680
  executionId: instance.id,
660
681
  });
661
- // Hand the run off to the durable runner so it progresses server-side without
662
- // a browser open. With the no-op runner (tests) this does nothing and the run
663
- // is advanced directly via advanceInstance.
664
- await this.workRunner.startRun(workspaceId, instance.id);
665
- await this.runStateMachine.emitInstance(workspaceId, instance);
682
+ await handOffLiveRun(this.runStartDeps, workspaceId, instance, block);
666
683
  return instance;
667
684
  }
668
685
  /**
@@ -907,50 +924,6 @@ export class ExecutionService {
907
924
  // the companion iteration-cap gate, so they have a single home: {@link parkStepOnDecision},
908
925
  // the `advanceRunPastGate`/`settleAdvancedGate` split (run under `mutateInstance`), and
909
926
  // {@link dispatchIterationCap}.
910
- /**
911
- * Several gates park on a `step.approval` but are NOT generic prose approvals — they are
912
- * driven by their own dedicated surface, never the generic
913
- * approve/request-changes/reject resolvers (which would advance the run bypassing the
914
- * loop). Guard those resolvers so a stray approve can't short-circuit any of them:
915
- * the requirements/clarity review gates, the brainstorms, the human-testing and
916
- * visual-confirmation gates, an interview-trait gate, a companion at its rework cap
917
- * (`companion.exceeded`), the follow-up companion with undecided items, and a coder
918
- * parked on the implementation-fork decision (whose approve would skip the build
919
- * dispatch entirely).
920
- */
921
- assertNotIterativeGate(step) {
922
- if (step.agentKind === REQUIREMENTS_REVIEW_AGENT_KIND) {
923
- throw new ConflictError('Resolve the requirements review through its review window, not the approval gate');
924
- }
925
- if (step.agentKind === CLARITY_REVIEW_AGENT_KIND) {
926
- throw new ConflictError('Resolve the clarity review through its review window, not the approval gate');
927
- }
928
- if (step.agentKind === REQUIREMENTS_BRAINSTORM_AGENT_KIND ||
929
- step.agentKind === ARCHITECTURE_BRAINSTORM_AGENT_KIND) {
930
- throw new ConflictError('Resolve the brainstorm through its brainstorm window, not the approval gate');
931
- }
932
- if (step.agentKind === HUMAN_TEST_AGENT_KIND) {
933
- throw new ConflictError('Resolve the human-testing gate through its window (confirm / request a fix), not the approval gate');
934
- }
935
- if (step.agentKind === VISUAL_CONFIRM_AGENT_KIND) {
936
- throw new ConflictError('Resolve the visual-confirmation gate through its window (approve / request a fix), not the approval gate');
937
- }
938
- if (hasTrait(step.agentKind, INTERVIEW_GATE_TRAIT, this.agentKindRegistry)) {
939
- throw new ConflictError('Resolve the interview through its interview window, not the approval gate');
940
- }
941
- if (step.companion?.exceeded) {
942
- throw new ConflictError('Resolve this companion review through its iteration-cap prompt, not the approval gate');
943
- }
944
- if (step.followUps?.enabled && step.followUps.items.some((i) => i.status === 'pending')) {
945
- throw new ConflictError('Resolve the follow-up companion through its window (file / send back / answer / dismiss), not the approval gate');
946
- }
947
- if (step.forkDecision?.status === 'awaiting_choice' ||
948
- step.forkDecision?.status === 'answering') {
949
- // Approving here would advance the run PAST the coder step with the build never run
950
- // (the park sits between the proposer and the Coder dispatch).
951
- throw new ConflictError('Resolve the implementation-fork decision through its fork window (choose an approach), not the approval gate');
952
- }
953
- }
954
927
  /** Pick the brainstorm kind for a stage (the dedicated window drives both via the same loop). */
955
928
  brainstormKindFor(stage) {
956
929
  return stage === 'architecture'
@@ -1081,55 +1054,6 @@ export class ExecutionService {
1081
1054
  // The clarity / human-testing / visual-confirmation gate-window actions now live on the
1082
1055
  // per-feature sub-facades (`clarityReview` / `humanTest` / `visualConfirm`); see the getters
1083
1056
  // above and {@link gate-window-facades}.
1084
- /**
1085
- * Dispatch the `fixer` against the human-review gate's PR branch from a human's freeform
1086
- * instructions — bypassing the precheck + grace window. Parks a `pendingFix` on the gate step,
1087
- * consumed on the gate's next poll (see {@link evaluateGate}) which dispatches the fixer with
1088
- * the instructions folded in. A second request before the first is consumed simply replaces the
1089
- * pending instructions. Throws when no human-review gate is currently parked.
1090
- *
1091
- * The run is re-driven via `workRunner.startRun` so the pending fix is picked up promptly even
1092
- * when the driver had died (e.g. its durable advance job expired/was evicted before the stale-
1093
- * run sweeper re-drove it) — `startRun` is idempotent for a live run (the exclusive advance
1094
- * queue no-ops a duplicate send), so this only has an effect when no driver is currently
1095
- * polling. A spend-paused run is left paused (it resumes through its own path).
1096
- */
1097
- async requestHumanReviewFix(workspaceId, blockId, instructions) {
1098
- const block = await this.blockRepository.get(workspaceId, blockId);
1099
- if (!block?.executionId) {
1100
- throw new ConflictError('No human-review gate is currently awaiting input');
1101
- }
1102
- // Optimistic-concurrency write: parking the `pendingFix` can race the gate's own poll
1103
- // (the durable driver advancing the run), so re-read + re-apply on fresh state instead
1104
- // of clobbering — the lost-update fix, same path as resolveDecision. The validation runs
1105
- // inside the mutation so it sees the run as it stands at write time.
1106
- const instance = await this.runStateMachine.mutateInstance(workspaceId, block.executionId, (inst) => {
1107
- const step = inst.steps[inst.currentStep];
1108
- if (!step || step.agentKind !== HUMAN_REVIEW_AGENT_KIND || !step.gate) {
1109
- throw new ConflictError('No human-review gate is currently awaiting input');
1110
- }
1111
- // The fix is consumed by evaluateGate's pendingFix branch, which dispatches the fixer
1112
- // ONLY when the gate's provider is wired AND there is an async executor to escalate to.
1113
- // Reject up front when neither holds, instead of silently parking a pendingFix the gate
1114
- // would discard on its pass-through (an unwired gate advances) — the caller must see the
1115
- // failure, not a 200.
1116
- const gate = this.runDispatcher.gateFor(step.agentKind);
1117
- if (!gate?.wired() || !isAsyncAgentExecutor(this.agentExecutor)) {
1118
- throw new ConflictError('The human-review gate cannot dispatch a fix on this deployment (no review provider or async executor configured)');
1119
- }
1120
- step.gate.pendingFix = { instructions, at: this.clock.now() };
1121
- // Re-arm a decision-parked run so the re-driven loop polls instead of no-oping; a spend-
1122
- // paused run stays paused.
1123
- if (inst.status === 'blocked')
1124
- inst.status = 'running';
1125
- });
1126
- await this.runStateMachine.emitInstance(workspaceId, instance);
1127
- // Ensure a driver is active to consume the pending fix (idempotent for a live run).
1128
- if (instance.status === 'running') {
1129
- await this.workRunner.startRun(workspaceId, instance.id);
1130
- }
1131
- return instance;
1132
- }
1133
1057
  /**
1134
1058
  * Merge a block's PR(s) for real, then mark it `done`. The remote merge happens FIRST (via
1135
1059
  * the {@link PullRequestMerger} port) and only on its success does the block flip to `done`
@@ -1255,237 +1179,38 @@ export class ExecutionService {
1255
1179
  applyModuleAssignment(workspaceId, taskId) {
1256
1180
  return this.postMergeBoard.applyModuleAssignment(workspaceId, taskId);
1257
1181
  }
1182
+ // ---- human decision surface (delegated) ---------------------------------
1183
+ // Resolve / approve / request-changes / reject / merge and the human-review fix request all
1184
+ // live on {@link StepDecisionController} — the decisions PEOPLE make about a parked run, as
1185
+ // opposed to the engine's own advance path. These stay here as thin delegates because the HTTP
1186
+ // + public-API controllers reach them through the engine facade.
1258
1187
  /** Resolve a pending decision; the run's next step lets the agent finish it. */
1259
- async resolveDecision(workspaceId, executionId, decisionId, choice) {
1260
- await this.requireWorkspace(workspaceId);
1261
- // Optimistic-concurrency write: a second resolve (double-click) or a racing driver
1262
- // poll can't clobber the chosen decision — the loser re-reads and re-applies.
1263
- const instance = await this.runStateMachine.mutateInstance(workspaceId, executionId, async (inst) => {
1264
- const step = inst.steps.find((s) => s.decision?.id === decisionId);
1265
- if (!step || !step.decision)
1266
- throw new NotFoundError('Decision', decisionId);
1267
- step.decision.chosen = choice;
1268
- this.stepGraph.startStep(step);
1269
- if (inst.status === 'blocked')
1270
- inst.status = 'running';
1271
- await this.runStateMachine.updateBlockProgress(workspaceId, inst, 'in_progress');
1272
- });
1273
- // Wake the parked durable run, if any. The DB write above remains the source
1274
- // of truth (so the backstop sweeper can still re-drive it); the signal is an
1275
- // optimisation that lets the workflow continue immediately.
1276
- await this.workRunner.signalDecision(workspaceId, instance.id, decisionId, choice);
1277
- await this.runStateMachine.emitInstance(workspaceId, instance);
1278
- return instance;
1188
+ resolveDecision(workspaceId, executionId, decisionId, choice) {
1189
+ return this.stepDecisions.resolveDecision(workspaceId, executionId, decisionId, choice);
1279
1190
  }
1280
- /**
1281
- * Approve a step's gated proposal: the run advances to the next step, carrying
1282
- * the (optionally human-edited) proposal forward as context. Mirrors
1283
- * {@link resolveDecision}'s durable-wake but *advances* the pipeline instead of
1284
- * re-running the step (the step is already done). Idempotent — re-approving an
1285
- * already-approved gate is a no-op.
1286
- */
1287
- async approveStep(workspaceId, executionId, approvalId, opts = {}) {
1288
- await this.requireWorkspace(workspaceId);
1289
- // Optimistic-concurrency write like resolveDecision/requestStepChanges: an approve
1290
- // holding a stale snapshot (a racing reject, a driver poll, a terminal transition)
1291
- // must re-read and re-validate rather than blind-write — otherwise it can resurrect
1292
- // a run another writer already failed. The advance's in-memory half runs inside the
1293
- // CAS; the non-idempotent side effects (block writes, driver signal, emit) run once
1294
- // after, on the winning state.
1295
- let stepIndex = -1;
1296
- let alreadyApproved = false;
1297
- const instance = await this.runStateMachine.mutateInstance(workspaceId, executionId, (inst) => {
1298
- alreadyApproved = false;
1299
- stepIndex = inst.steps.findIndex((s) => s.approval?.id === approvalId);
1300
- const step = inst.steps[stepIndex];
1301
- if (!step || !step.approval)
1302
- throw new NotFoundError('Approval', approvalId);
1303
- this.assertNotIterativeGate(step);
1304
- if (step.approval.status === 'approved') {
1305
- alreadyApproved = true;
1306
- return;
1307
- }
1308
- if (step.approval.status === 'rejected') {
1309
- throw new ConflictError(`Approval '${approvalId}' was rejected`);
1310
- }
1311
- if (inst.status === 'failed' || inst.status === 'done') {
1312
- throw new ConflictError(`Execution '${executionId}' is already ${inst.status}`);
1313
- }
1314
- // A human edit to the proposal replaces the agent's text, so the revised
1315
- // proposal is what downstream steps read (via priorOutputs). That only holds when the
1316
- // output IS the agent's work product: a step whose output is a RENDERING of an
1317
- // already-ingested artifact (the spec doc, the blueprint tree, the initiative plan —
1318
- // see `reviewableArtifactOutput`) would take the edit into `step.output` while the
1319
- // committed artifact stayed the ingested one, so the correction silently reaches
1320
- // nothing. Refuse rather than accept-and-drop; the reviewer's route is "request
1321
- // changes", which re-runs the producer with the correction as feedback.
1322
- if (opts.proposal !== undefined) {
1323
- if (step.outputIsRendered) {
1324
- throw new ValidationError("This step's output is a rendering of the artifact it already produced, so edits " +
1325
- 'to it cannot change that artifact. Request changes instead — the step re-runs ' +
1326
- 'with your feedback.', { reason: 'proposal_not_editable' });
1327
- }
1328
- step.output = opts.proposal;
1329
- step.approval.proposal = opts.proposal;
1330
- }
1331
- step.approval.status = 'approved';
1332
- // A gate is never raised on the final step, but the shared advance stays defensive.
1333
- this.runStateMachine.advanceRunPastGate(inst, stepIndex);
1334
- });
1335
- if (alreadyApproved)
1336
- return instance;
1337
- await this.runStateMachine.settleAdvancedGate(workspaceId, instance, stepIndex);
1338
- return instance;
1191
+ /** Approve a step's gated proposal (optionally replacing it with the human's edit). */
1192
+ approveStep(workspaceId, executionId, approvalId, opts = {}) {
1193
+ return this.stepDecisions.approveStep(workspaceId, executionId, approvalId, opts);
1339
1194
  }
1340
- /**
1341
- * Request changes on a step's gated proposal: the same step re-runs with the
1342
- * human's freeform feedback and/or per-block comments (and its prior proposal)
1343
- * folded into the agent's context (see {@link AgentContextBuilder}). The run is left
1344
- * `running` on the same step; on the re-run's completion the gate is raised
1345
- * afresh. At least one of `feedback`/`comments` is expected (the controller
1346
- * validates this), but an empty review is harmless — the agent simply re-runs.
1347
- */
1348
- async requestStepChanges(workspaceId, executionId, approvalId, review) {
1349
- await this.requireWorkspace(workspaceId);
1350
- // Optimistic-concurrency write: two concurrent change-requests on the same gate
1351
- // (the documented double-submit) can't both dispatch a re-run — the loser re-reads,
1352
- // sees `changes_requested`, and is rejected below instead of clobbering.
1353
- const instance = await this.runStateMachine.mutateInstance(workspaceId, executionId, (inst) => {
1354
- const step = inst.steps.find((s) => s.approval?.id === approvalId);
1355
- if (!step || !step.approval)
1356
- throw new NotFoundError('Approval', approvalId);
1357
- this.assertNotIterativeGate(step);
1358
- if (step.approval.status === 'approved') {
1359
- throw new ConflictError(`Approval '${approvalId}' is already approved`);
1360
- }
1361
- if (step.approval.status === 'rejected') {
1362
- throw new ConflictError(`Approval '${approvalId}' was rejected`);
1363
- }
1364
- // A re-run is already in flight (and will raise a fresh gate on completion);
1365
- // acting on this now-stale gate id would dispatch duplicate work.
1366
- if (step.approval.status === 'changes_requested') {
1367
- throw new ConflictError(`Approval '${approvalId}' is already being re-run`);
1368
- }
1369
- const stepIndex = inst.steps.findIndex((s) => s.approval?.id === approvalId);
1370
- step.approval.status = 'changes_requested';
1371
- step.approval.feedback = review.feedback;
1372
- step.approval.comments = review.comments?.length ? review.comments : undefined;
1373
- // A companion's gate reviews the PRODUCER's output, not the companion's own work:
1374
- // requesting changes here must re-run the producer (with the human's feedback
1375
- // folded in) and re-grade, NOT re-run the companion. Redirect the rework to the
1376
- // nearest preceding step of one of the companion's target kinds.
1377
- if (isCompanionKind(step.agentKind)) {
1378
- const targets = companionTargets(step.agentKind);
1379
- let producerIndex = -1;
1380
- for (let i = stepIndex - 1; i >= 0; i--) {
1381
- if (targets.includes(inst.steps[i].agentKind)) {
1382
- producerIndex = i;
1383
- break;
1384
- }
1385
- }
1386
- const producer = producerIndex >= 0 ? inst.steps[producerIndex] : undefined;
1387
- if (producer) {
1388
- // Re-run the producer (with the human's feedback) and every step up to and
1389
- // including the companion, then the companion re-grades. Does NOT touch the
1390
- // companion's automatic-rework budget — a human-driven iteration is unbounded.
1391
- const previousProposal = producer.output ?? step.approval.proposal;
1392
- this.stepGraph.rerunProducerThrough(inst, producerIndex, stepIndex, {
1393
- previousProposal,
1394
- feedback: review.feedback ?? '',
1395
- ...(review.comments?.length ? { comments: review.comments } : {}),
1396
- });
1397
- if (inst.status === 'blocked')
1398
- inst.status = 'running';
1399
- return;
1400
- }
1401
- }
1402
- // Drop the live job handle so the re-run dispatches fresh work rather than
1403
- // re-attaching to the finished job (async steps); inline steps ignore this.
1404
- step.jobId = undefined;
1405
- // A requested re-run is a fresh execution: clear the prior timing so the next
1406
- // start/finish times this attempt rather than spanning the human gate wait.
1407
- step.startedAt = null;
1408
- step.finishedAt = null;
1409
- this.stepGraph.startStep(step);
1410
- if (inst.status === 'blocked')
1411
- inst.status = 'running';
1412
- });
1413
- await this.workRunner.signalDecision(workspaceId, instance.id, approvalId, 'changes_requested');
1414
- await this.runStateMachine.emitInstance(workspaceId, instance);
1415
- return instance;
1195
+ /** Request changes on a step's gated proposal; the step re-runs with the feedback folded in. */
1196
+ requestStepChanges(workspaceId, executionId, approvalId, review) {
1197
+ return this.stepDecisions.requestStepChanges(workspaceId, executionId, approvalId, review);
1416
1198
  }
1417
- /**
1418
- * Reject a step's gated proposal: the run stops entirely. The gate is marked
1419
- * `rejected` and the run is failed with a dedicated `rejected` failure kind, so
1420
- * the board surfaces it via the shared failure banner (block → `blocked`) with a
1421
- * Retry affordance. The parked durable run is woken so it observes the now-terminal
1422
- * status and stops (the workflow's advance loop no-ops on a non-running run).
1423
- * Idempotent — rejecting an already-terminal gate is a no-op.
1424
- */
1425
- async rejectStep(workspaceId, executionId, approvalId, reason) {
1426
- await this.requireWorkspace(workspaceId);
1427
- // Optimistic-concurrency write: a reject racing the durable driver (or a concurrent
1428
- // resolve/request-changes on the same gate) re-reads and re-applies instead of
1429
- // clobbering the other writer — the lost-update fix, same as resolveDecision.
1430
- let alreadyRejected = false;
1431
- const instance = await this.runStateMachine.mutateInstance(workspaceId, executionId, (inst) => {
1432
- const step = inst.steps.find((s) => s.approval?.id === approvalId);
1433
- if (!step || !step.approval)
1434
- throw new NotFoundError('Approval', approvalId);
1435
- this.assertNotIterativeGate(step);
1436
- if (step.approval.status === 'approved') {
1437
- throw new ConflictError(`Approval '${approvalId}' is already approved`);
1438
- }
1439
- // A re-run is in flight; this gate id is stale (a fresh one is raised on its
1440
- // completion). Reject the current gate via that fresh id, not this one.
1441
- if (step.approval.status === 'changes_requested') {
1442
- throw new ConflictError(`Approval '${approvalId}' is being re-run`);
1443
- }
1444
- // Already rejected (and the run already failed): leave it as-is and skip failRun below.
1445
- if (step.approval.status === 'rejected') {
1446
- alreadyRejected = true;
1447
- return;
1448
- }
1449
- step.approval.status = 'rejected';
1450
- if (reason)
1451
- step.approval.feedback = reason;
1452
- });
1453
- if (alreadyRejected)
1454
- return instance;
1455
- const message = reason
1456
- ? `A reviewer rejected the proposal: ${reason}`
1457
- : 'A reviewer rejected the proposal, stopping the run.';
1458
- // failRun persists the terminal failure + flips the block to `blocked` and emits.
1459
- await this.failRun(workspaceId, executionId, message, 'rejected');
1460
- // Wake the parked durable run; it re-reads the now-terminal status and stops.
1461
- await this.workRunner.signalDecision(workspaceId, instance.id, approvalId, 'rejected');
1462
- return assertFound(await this.executionRepository.get(workspaceId, executionId), 'Execution', executionId);
1199
+ /** Reject a step's gated proposal; the run stops with a `rejected` failure. */
1200
+ rejectStep(workspaceId, executionId, approvalId, reason) {
1201
+ return this.stepDecisions.rejectStep(workspaceId, executionId, approvalId, reason);
1463
1202
  }
1464
- /**
1465
- * Merge an open PR: a block moves from `pr_ready` to `done`. This is the HUMAN merge path —
1466
- * a `merge_review` / `pipeline_complete` notification act, or the inspector's merge control.
1467
- *
1468
- * `reviewEffort` records, in the same call, how much review the PR actually needed. It is
1469
- * always optional: an untagged merge settles the track record with a null tag and nothing
1470
- * downstream breaks. The record settle runs AFTER the merge and is best-effort inside the
1471
- * service, so no part of this feature can fail or block a merge.
1472
- */
1473
- async mergePr(workspaceId, blockId, reviewEffort) {
1474
- await this.requireWorkspace(workspaceId);
1475
- const block = await this.requireBlock(workspaceId, blockId);
1476
- if (block.status !== 'pr_ready') {
1477
- throw new ConflictError(`Block '${blockId}' has no PR awaiting merge`, 'no_pr_to_merge');
1478
- }
1479
- await this.finalizeMerge(workspaceId, blockId);
1480
- await this.mergePolicy.recordHumanMerge(workspaceId, blockId, reviewEffort);
1481
- return this.requireBlock(workspaceId, blockId);
1203
+ /** Dispatch the human-review gate's fixer from a human's freeform instructions. */
1204
+ requestHumanReviewFix(workspaceId, blockId, instructions) {
1205
+ return this.stepDecisions.requestHumanReviewFix(workspaceId, blockId, instructions);
1482
1206
  }
1483
- /**
1484
- * Record that a human DECLINED to merge — they dismissed the review card rather than acting on
1485
- * it, so the class's rollup counts a rejection instead of a forever-`pending_review` row.
1486
- */
1207
+ /** Merge an open PR for real, moving the block from `pr_ready` to `done`. */
1208
+ mergePr(workspaceId, blockId, reviewEffort) {
1209
+ return this.stepDecisions.mergePr(workspaceId, blockId, reviewEffort);
1210
+ }
1211
+ /** Record that a human DECLINED to merge (the review card was dismissed, not acted on). */
1487
1212
  recordMergeRejection(workspaceId, executionId) {
1488
- return this.mergePolicy.recordRejection(workspaceId, executionId);
1213
+ return this.stepDecisions.recordMergeRejection(workspaceId, executionId);
1489
1214
  }
1490
1215
  /**
1491
1216
  * Record a terminal agent failure: persist a structured {@link AgentFailure},
@@ -1541,7 +1266,7 @@ export class ExecutionService {
1541
1266
  await activate?.(newId);
1542
1267
  // Replace the terminal failed run for this block with the resumed one (single run per
1543
1268
  // block, matching the board's by-block projection). This mints a FRESH run id; the
1544
- // atomic `insertLiveRunOrConflict` below replaces `previous` (via `replaceId`) and clears
1269
+ // atomic `claimLiveRunOrConflict` below replaces `previous` (via `replaceId`) and clears
1545
1270
  // any terminal rows in the SAME transaction, so a concurrent double-retry is serialised by
1546
1271
  // the live-run index (the loser gets a 409) instead of both deleting-then-inserting.
1547
1272
  const instance = buildResumedInstance({
@@ -1551,15 +1276,14 @@ export class ExecutionService {
1551
1276
  initiatedBy,
1552
1277
  now: this.clock.now(),
1553
1278
  });
1554
- await this.insertLiveRunOrConflict(workspaceId, instance, replaceId);
1279
+ await claimLiveRunOrConflict(this.runStartDeps, workspaceId, instance, replaceId);
1555
1280
  const done = steps.filter((s) => s.state === 'done').length;
1556
1281
  await this.blockRepository.update(workspaceId, previous.blockId, {
1557
1282
  status: 'in_progress',
1558
1283
  progress: steps.length > 0 ? done / steps.length : 0,
1559
1284
  executionId: instance.id,
1560
1285
  });
1561
- await this.workRunner.startRun(workspaceId, instance.id);
1562
- await this.runStateMachine.emitInstance(workspaceId, instance);
1286
+ await handOffLiveRun(this.runStartDeps, workspaceId, instance, block);
1563
1287
  return instance;
1564
1288
  }
1565
1289
  /**
@@ -1621,7 +1345,7 @@ export class ExecutionService {
1621
1345
  const newId = this.idGenerator.next('exec');
1622
1346
  const replaceId = previous.id;
1623
1347
  await activate?.(newId);
1624
- // Like retry(), this mints a FRESH run id. `insertLiveRunOrConflict` atomically supersedes
1348
+ // Like retry(), this mints a FRESH run id. `claimLiveRunOrConflict` atomically supersedes
1625
1349
  // the torn-down source run (`replaceId`, which here may still be LIVE — running/paused/
1626
1350
  // blocked) and clears terminal rows in one transaction, so a concurrent start that already
1627
1351
  // created a NEW live run for the block loses (409) instead of being silently clobbered.
@@ -1632,36 +1356,29 @@ export class ExecutionService {
1632
1356
  initiatedBy,
1633
1357
  now: this.clock.now(),
1634
1358
  });
1635
- await this.insertLiveRunOrConflict(workspaceId, instance, replaceId);
1359
+ await claimLiveRunOrConflict(this.runStartDeps, workspaceId, instance, replaceId);
1636
1360
  const done = steps.filter((s) => s.state === 'done').length;
1637
1361
  await this.blockRepository.update(workspaceId, previous.blockId, {
1638
1362
  status: 'in_progress',
1639
1363
  progress: steps.length > 0 ? done / steps.length : 0,
1640
1364
  executionId: instance.id,
1641
1365
  });
1642
- await this.workRunner.startRun(workspaceId, instance.id);
1643
- await this.runStateMachine.emitInstance(workspaceId, instance);
1366
+ await handOffLiveRun(this.runStartDeps, workspaceId, instance, block);
1644
1367
  return instance;
1645
1368
  }
1646
1369
  /**
1647
- * Insert a freshly-built run, enforcing the one-live-run-per-block invariant at the DB in a
1648
- * single atomic write (see `ExecutionRepository.insertLive`). Callers must NOT `deleteByBlock`
1649
- * first: `insertLive` itself clears the block's terminal rows (and `replaceId`, the specific
1650
- * prior run a `retry`/`restart` is knowingly superseding) in the SAME transaction as the
1651
- * insert. A `false` return means a genuinely-concurrent start (double click,
1652
- * recurring-vs-manual, notification-vs-human retry) already created the block's live run — so
1653
- * we REFUSE this duplicate rather than materialise a second driver + container on the same
1654
- * branch. The winning run is untouched (the losing transaction only deletes terminal rows /
1655
- * its own `replaceId`, never the winner). Surfaces as a 409 the SPA shows as a toast.
1370
+ * The bound callbacks the two run-start funnels (`runStart.ts`) need, so they depend on no
1371
+ * concrete repository or service. Those funnels own the ORDER between a run's atomic claim and
1372
+ * its hand-off and are documented there; every start path calls both, writing the block state
1373
+ * that path owns in between.
1656
1374
  */
1657
- async insertLiveRunOrConflict(workspaceId, instance, replaceId) {
1658
- const inserted = await this.executionRepository.insertLive(workspaceId, instance, { replaceId });
1659
- if (!inserted) {
1660
- // No machine `reason`: this is a rare double-start edge, not a distinct client-handled
1661
- // conflict, so the human message drives the SPA's generic 409 toast (no new
1662
- // ConflictReason + exhaustive-Record/i18n cascade for a transient race).
1663
- throw new ConflictError('A run is already active for this block.');
1664
- }
1375
+ get runStartDeps() {
1376
+ return {
1377
+ insertLive: (ws, instance, options) => this.executionRepository.insertLive(ws, instance, options),
1378
+ startRun: (ws, id) => this.workRunner.startRun(ws, id),
1379
+ emitInstance: (ws, instance) => this.runStateMachine.emitInstance(ws, instance),
1380
+ publishRunStarted: (ws, instance, block) => this.runStateMachine.publishRunStarted(ws, instance, block),
1381
+ };
1665
1382
  }
1666
1383
  /**
1667
1384
  * Resume every run paused by the spend safeguard in this workspace. Flips them