@kenkaiiii/ggcoder 4.3.232 → 4.3.234
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/README.md +1 -2
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +7 -89
- package/dist/cli.js.map +1 -1
- package/dist/core/agent-session.d.ts.map +1 -1
- package/dist/core/agent-session.js +2 -2
- package/dist/core/agent-session.js.map +1 -1
- package/dist/core/prompt-commands.d.ts.map +1 -1
- package/dist/core/prompt-commands.js +8 -16
- package/dist/core/prompt-commands.js.map +1 -1
- package/dist/core/prompt-commands.test.js +14 -44
- package/dist/core/prompt-commands.test.js.map +1 -1
- package/dist/core/runtime-mode.d.ts +0 -11
- package/dist/core/runtime-mode.d.ts.map +1 -1
- package/dist/core/runtime-mode.js +0 -9
- package/dist/core/runtime-mode.js.map +1 -1
- package/dist/core/session-restore-display.test.js +4 -110
- package/dist/core/session-restore-display.test.js.map +1 -1
- package/dist/interactive.d.ts.map +1 -1
- package/dist/interactive.js +1 -1
- package/dist/interactive.js.map +1 -1
- package/dist/system-prompt.d.ts +1 -2
- package/dist/system-prompt.d.ts.map +1 -1
- package/dist/system-prompt.js +11 -58
- package/dist/system-prompt.js.map +1 -1
- package/dist/system-prompt.test.js +3 -158
- package/dist/system-prompt.test.js.map +1 -1
- package/dist/tools/bash.d.ts +1 -4
- package/dist/tools/bash.d.ts.map +1 -1
- package/dist/tools/bash.js +3 -12
- package/dist/tools/bash.js.map +1 -1
- package/dist/tools/checkpoint-hook.test.js +3 -3
- package/dist/tools/checkpoint-hook.test.js.map +1 -1
- package/dist/tools/edit.d.ts +1 -4
- package/dist/tools/edit.d.ts.map +1 -1
- package/dist/tools/edit.js +5 -13
- package/dist/tools/edit.js.map +1 -1
- package/dist/tools/enter-plan.js +1 -1
- package/dist/tools/enter-plan.js.map +1 -1
- package/dist/tools/index.d.ts +0 -9
- package/dist/tools/index.d.ts.map +1 -1
- package/dist/tools/index.js +4 -8
- package/dist/tools/index.js.map +1 -1
- package/dist/tools/prompt-hints.d.ts.map +1 -1
- package/dist/tools/prompt-hints.js +0 -2
- package/dist/tools/prompt-hints.js.map +1 -1
- package/dist/tools/screenshot.d.ts +1 -1
- package/dist/tools/subagent.d.ts +1 -4
- package/dist/tools/subagent.d.ts.map +1 -1
- package/dist/tools/subagent.js +2 -5
- package/dist/tools/subagent.js.map +1 -1
- package/dist/tools/write.d.ts +1 -4
- package/dist/tools/write.d.ts.map +1 -1
- package/dist/tools/write.js +5 -13
- package/dist/tools/write.js.map +1 -1
- package/dist/ui/App.d.ts +5 -20
- package/dist/ui/App.d.ts.map +1 -1
- package/dist/ui/App.js +134 -309
- package/dist/ui/App.js.map +1 -1
- package/dist/ui/app-items.d.ts +23 -25
- package/dist/ui/app-items.d.ts.map +1 -1
- package/dist/ui/app-items.js +37 -0
- package/dist/ui/app-items.js.map +1 -1
- package/dist/ui/app-items.test.d.ts +2 -0
- package/dist/ui/app-items.test.d.ts.map +1 -0
- package/dist/ui/app-items.test.js +38 -0
- package/dist/ui/app-items.test.js.map +1 -0
- package/dist/ui/app-state-persistence.test.js +14 -318
- package/dist/ui/app-state-persistence.test.js.map +1 -1
- package/dist/ui/chat-layout-pinning.test.js +74 -4
- package/dist/ui/chat-layout-pinning.test.js.map +1 -1
- package/dist/ui/components/AssistantMessage.test.js +6 -9
- package/dist/ui/components/AssistantMessage.test.js.map +1 -1
- package/dist/ui/components/Banner.js +1 -1
- package/dist/ui/components/Banner.js.map +1 -1
- package/dist/ui/components/ChatFooterPane.d.ts +1 -5
- package/dist/ui/components/ChatFooterPane.d.ts.map +1 -1
- package/dist/ui/components/ChatFooterPane.js +3 -4
- package/dist/ui/components/ChatFooterPane.js.map +1 -1
- package/dist/ui/components/ChatInputStack.d.ts +3 -1
- package/dist/ui/components/ChatInputStack.d.ts.map +1 -1
- package/dist/ui/components/ChatInputStack.js +4 -3
- package/dist/ui/components/ChatInputStack.js.map +1 -1
- package/dist/ui/components/ChatScreen.d.ts +3 -16
- package/dist/ui/components/ChatScreen.d.ts.map +1 -1
- package/dist/ui/components/ChatScreen.js +2 -3
- package/dist/ui/components/ChatScreen.js.map +1 -1
- package/dist/ui/components/Footer.d.ts +3 -8
- package/dist/ui/components/Footer.d.ts.map +1 -1
- package/dist/ui/components/Footer.js +5 -25
- package/dist/ui/components/Footer.js.map +1 -1
- package/dist/ui/components/InputArea.d.ts +1 -9
- package/dist/ui/components/InputArea.d.ts.map +1 -1
- package/dist/ui/components/InputArea.js +2 -44
- package/dist/ui/components/InputArea.js.map +1 -1
- package/dist/ui/components/LiveToolPanel.d.ts +30 -0
- package/dist/ui/components/LiveToolPanel.d.ts.map +1 -0
- package/dist/ui/components/LiveToolPanel.js +66 -0
- package/dist/ui/components/LiveToolPanel.js.map +1 -0
- package/dist/ui/components/ToolExecution.js +0 -2
- package/dist/ui/components/ToolExecution.js.map +1 -1
- package/dist/ui/components/TranscriptViewport.d.ts +1 -1
- package/dist/ui/components/TranscriptViewport.js +1 -1
- package/dist/ui/footer-jump-regression.test.js +12 -2
- package/dist/ui/footer-jump-regression.test.js.map +1 -1
- package/dist/ui/footer-status-layout.test.js +4 -12
- package/dist/ui/footer-status-layout.test.js.map +1 -1
- package/dist/ui/hooks/useChatLayoutMeasurements.d.ts +3 -4
- package/dist/ui/hooks/useChatLayoutMeasurements.d.ts.map +1 -1
- package/dist/ui/hooks/useChatLayoutMeasurements.js +26 -4
- package/dist/ui/hooks/useChatLayoutMeasurements.js.map +1 -1
- package/dist/ui/hooks/useModeState.d.ts +4 -19
- package/dist/ui/hooks/useModeState.d.ts.map +1 -1
- package/dist/ui/hooks/useModeState.js +5 -45
- package/dist/ui/hooks/useModeState.js.map +1 -1
- package/dist/ui/hooks/usePixelFixFlow.js +2 -2
- package/dist/ui/layout-decisions.d.ts +11 -34
- package/dist/ui/layout-decisions.d.ts.map +1 -1
- package/dist/ui/layout-decisions.js +15 -42
- package/dist/ui/layout-decisions.js.map +1 -1
- package/dist/ui/live-area-height.d.ts.map +1 -1
- package/dist/ui/live-area-height.js +6 -1
- package/dist/ui/live-area-height.js.map +1 -1
- package/dist/ui/live-frame-height.test.js +26 -1
- package/dist/ui/live-frame-height.test.js.map +1 -1
- package/dist/ui/plan-overlay.test.js +1 -1
- package/dist/ui/plan-overlay.test.js.map +1 -1
- package/dist/ui/prompt-routing.d.ts +1 -19
- package/dist/ui/prompt-routing.d.ts.map +1 -1
- package/dist/ui/prompt-routing.js +1 -79
- package/dist/ui/prompt-routing.js.map +1 -1
- package/dist/ui/render.d.ts +3 -18
- package/dist/ui/render.d.ts.map +1 -1
- package/dist/ui/render.js +0 -10
- package/dist/ui/render.js.map +1 -1
- package/dist/ui/scroll-stabilization.test.js +1 -7
- package/dist/ui/scroll-stabilization.test.js.map +1 -1
- package/dist/ui/slash-command-images.test.js +11 -86
- package/dist/ui/slash-command-images.test.js.map +1 -1
- package/dist/ui/streaming-flush-bounce.test.d.ts +2 -0
- package/dist/ui/streaming-flush-bounce.test.d.ts.map +1 -0
- package/dist/ui/streaming-flush-bounce.test.js +156 -0
- package/dist/ui/streaming-flush-bounce.test.js.map +1 -0
- package/dist/ui/submit-prompt-command.d.ts +1 -16
- package/dist/ui/submit-prompt-command.d.ts.map +1 -1
- package/dist/ui/submit-prompt-command.js +4 -54
- package/dist/ui/submit-prompt-command.js.map +1 -1
- package/dist/ui/submit-slash-commands.d.ts +0 -1
- package/dist/ui/submit-slash-commands.d.ts.map +1 -1
- package/dist/ui/submit-slash-commands.js +0 -4
- package/dist/ui/submit-slash-commands.js.map +1 -1
- package/dist/ui/terminal-history-status-renderers.d.ts +0 -1
- package/dist/ui/terminal-history-status-renderers.d.ts.map +1 -1
- package/dist/ui/terminal-history-status-renderers.js +0 -3
- package/dist/ui/terminal-history-status-renderers.js.map +1 -1
- package/dist/ui/terminal-history.d.ts.map +1 -1
- package/dist/ui/terminal-history.js +11 -56
- package/dist/ui/terminal-history.js.map +1 -1
- package/dist/ui/terminal-history.test.js +6 -33
- package/dist/ui/terminal-history.test.js.map +1 -1
- package/dist/ui/tool-line-summary.d.ts +29 -0
- package/dist/ui/tool-line-summary.d.ts.map +1 -0
- package/dist/ui/tool-line-summary.js +153 -0
- package/dist/ui/tool-line-summary.js.map +1 -0
- package/dist/ui/transcript/TranscriptRenderer.d.ts +1 -1
- package/dist/ui/transcript/TranscriptRenderer.d.ts.map +1 -1
- package/dist/ui/transcript/TranscriptRenderer.js +18 -12
- package/dist/ui/transcript/TranscriptRenderer.js.map +1 -1
- package/dist/ui/transcript/presentation.d.ts +1 -17
- package/dist/ui/transcript/presentation.d.ts.map +1 -1
- package/dist/ui/transcript/presentation.js +0 -26
- package/dist/ui/transcript/presentation.js.map +1 -1
- package/dist/ui/transcript/spacing.d.ts +2 -2
- package/dist/ui/transcript/spacing.d.ts.map +1 -1
- package/dist/ui/transcript/spacing.js +14 -9
- package/dist/ui/transcript/spacing.js.map +1 -1
- package/dist/ui/transcript/spacing.test.js +5 -8
- package/dist/ui/transcript/spacing.test.js.map +1 -1
- package/dist/ui/transcript/tool-presentation.js +1 -1
- package/dist/ui/transcript/tool-presentation.js.map +1 -1
- package/dist/ui/transcript/transcript-lines.d.ts.map +1 -1
- package/dist/ui/transcript/transcript-lines.js +4 -0
- package/dist/ui/transcript/transcript-lines.js.map +1 -1
- package/dist/ui/tui-history-parity.test.js +0 -47
- package/dist/ui/tui-history-parity.test.js.map +1 -1
- package/dist/ui/tui-simulation.test.js +2 -1
- package/dist/ui/tui-simulation.test.js.map +1 -1
- package/package.json +3 -3
- package/dist/core/goal-controller.d.ts +0 -82
- package/dist/core/goal-controller.d.ts.map +0 -1
- package/dist/core/goal-controller.js +0 -838
- package/dist/core/goal-controller.js.map +0 -1
- package/dist/core/goal-controller.test.d.ts +0 -2
- package/dist/core/goal-controller.test.d.ts.map +0 -1
- package/dist/core/goal-controller.test.js +0 -1279
- package/dist/core/goal-controller.test.js.map +0 -1
- package/dist/core/goal-engine.d.ts +0 -61
- package/dist/core/goal-engine.d.ts.map +0 -1
- package/dist/core/goal-engine.js +0 -123
- package/dist/core/goal-engine.js.map +0 -1
- package/dist/core/goal-engine.test.d.ts +0 -2
- package/dist/core/goal-engine.test.d.ts.map +0 -1
- package/dist/core/goal-engine.test.js +0 -295
- package/dist/core/goal-engine.test.js.map +0 -1
- package/dist/core/goal-integration.d.ts +0 -80
- package/dist/core/goal-integration.d.ts.map +0 -1
- package/dist/core/goal-integration.js +0 -296
- package/dist/core/goal-integration.js.map +0 -1
- package/dist/core/goal-integration.test.d.ts +0 -2
- package/dist/core/goal-integration.test.d.ts.map +0 -1
- package/dist/core/goal-integration.test.js +0 -369
- package/dist/core/goal-integration.test.js.map +0 -1
- package/dist/core/goal-lifecycle-smoke.test.d.ts +0 -2
- package/dist/core/goal-lifecycle-smoke.test.d.ts.map +0 -1
- package/dist/core/goal-lifecycle-smoke.test.js +0 -248
- package/dist/core/goal-lifecycle-smoke.test.js.map +0 -1
- package/dist/core/goal-overhead-harness.d.ts +0 -33
- package/dist/core/goal-overhead-harness.d.ts.map +0 -1
- package/dist/core/goal-overhead-harness.js +0 -268
- package/dist/core/goal-overhead-harness.js.map +0 -1
- package/dist/core/goal-prerequisites.d.ts +0 -23
- package/dist/core/goal-prerequisites.d.ts.map +0 -1
- package/dist/core/goal-prerequisites.js +0 -114
- package/dist/core/goal-prerequisites.js.map +0 -1
- package/dist/core/goal-prerequisites.test.d.ts +0 -2
- package/dist/core/goal-prerequisites.test.d.ts.map +0 -1
- package/dist/core/goal-prerequisites.test.js +0 -154
- package/dist/core/goal-prerequisites.test.js.map +0 -1
- package/dist/core/goal-references.d.ts +0 -14
- package/dist/core/goal-references.d.ts.map +0 -1
- package/dist/core/goal-references.js +0 -153
- package/dist/core/goal-references.js.map +0 -1
- package/dist/core/goal-references.test.d.ts +0 -2
- package/dist/core/goal-references.test.d.ts.map +0 -1
- package/dist/core/goal-references.test.js +0 -77
- package/dist/core/goal-references.test.js.map +0 -1
- package/dist/core/goal-store.d.ts +0 -289
- package/dist/core/goal-store.d.ts.map +0 -1
- package/dist/core/goal-store.js +0 -1156
- package/dist/core/goal-store.js.map +0 -1
- package/dist/core/goal-store.test.d.ts +0 -2
- package/dist/core/goal-store.test.d.ts.map +0 -1
- package/dist/core/goal-store.test.js +0 -530
- package/dist/core/goal-store.test.js.map +0 -1
- package/dist/core/goal-verifier.d.ts +0 -17
- package/dist/core/goal-verifier.d.ts.map +0 -1
- package/dist/core/goal-verifier.js +0 -87
- package/dist/core/goal-verifier.js.map +0 -1
- package/dist/core/goal-verifier.test.d.ts +0 -2
- package/dist/core/goal-verifier.test.d.ts.map +0 -1
- package/dist/core/goal-verifier.test.js +0 -131
- package/dist/core/goal-verifier.test.js.map +0 -1
- package/dist/core/goal-worker-dev-server-lifecycle.test.d.ts +0 -2
- package/dist/core/goal-worker-dev-server-lifecycle.test.d.ts.map +0 -1
- package/dist/core/goal-worker-dev-server-lifecycle.test.js +0 -68
- package/dist/core/goal-worker-dev-server-lifecycle.test.js.map +0 -1
- package/dist/core/goal-worker.d.ts +0 -61
- package/dist/core/goal-worker.d.ts.map +0 -1
- package/dist/core/goal-worker.js +0 -467
- package/dist/core/goal-worker.js.map +0 -1
- package/dist/core/goal-worker.test.d.ts +0 -2
- package/dist/core/goal-worker.test.d.ts.map +0 -1
- package/dist/core/goal-worker.test.js +0 -493
- package/dist/core/goal-worker.test.js.map +0 -1
- package/dist/core/goal-worktree.d.ts +0 -108
- package/dist/core/goal-worktree.d.ts.map +0 -1
- package/dist/core/goal-worktree.js +0 -300
- package/dist/core/goal-worktree.js.map +0 -1
- package/dist/core/goal-worktree.test.d.ts +0 -2
- package/dist/core/goal-worktree.test.d.ts.map +0 -1
- package/dist/core/goal-worktree.test.js +0 -448
- package/dist/core/goal-worktree.test.js.map +0 -1
- package/dist/tools/goal-mode.test.d.ts +0 -2
- package/dist/tools/goal-mode.test.d.ts.map +0 -1
- package/dist/tools/goal-mode.test.js +0 -121
- package/dist/tools/goal-mode.test.js.map +0 -1
- package/dist/tools/goals.d.ts +0 -143
- package/dist/tools/goals.d.ts.map +0 -1
- package/dist/tools/goals.js +0 -1038
- package/dist/tools/goals.js.map +0 -1
- package/dist/tools/goals.test.d.ts +0 -2
- package/dist/tools/goals.test.d.ts.map +0 -1
- package/dist/tools/goals.test.js +0 -1444
- package/dist/tools/goals.test.js.map +0 -1
- package/dist/ui/components/GoalOverlay.d.ts +0 -83
- package/dist/ui/components/GoalOverlay.d.ts.map +0 -1
- package/dist/ui/components/GoalOverlay.js +0 -710
- package/dist/ui/components/GoalOverlay.js.map +0 -1
- package/dist/ui/components/GoalPickerMenu.d.ts +0 -9
- package/dist/ui/components/GoalPickerMenu.d.ts.map +0 -1
- package/dist/ui/components/GoalPickerMenu.js +0 -37
- package/dist/ui/components/GoalPickerMenu.js.map +0 -1
- package/dist/ui/components/GoalStatusBar.d.ts +0 -26
- package/dist/ui/components/GoalStatusBar.d.ts.map +0 -1
- package/dist/ui/components/GoalStatusBar.js +0 -130
- package/dist/ui/components/GoalStatusBar.js.map +0 -1
- package/dist/ui/components/GoalStatusBar.test.d.ts +0 -2
- package/dist/ui/components/GoalStatusBar.test.d.ts.map +0 -1
- package/dist/ui/components/GoalStatusBar.test.js +0 -17
- package/dist/ui/components/GoalStatusBar.test.js.map +0 -1
- package/dist/ui/goal-events.d.ts +0 -125
- package/dist/ui/goal-events.d.ts.map +0 -1
- package/dist/ui/goal-events.js +0 -407
- package/dist/ui/goal-events.js.map +0 -1
- package/dist/ui/goal-events.test.d.ts +0 -2
- package/dist/ui/goal-events.test.d.ts.map +0 -1
- package/dist/ui/goal-events.test.js +0 -416
- package/dist/ui/goal-events.test.js.map +0 -1
- package/dist/ui/goal-lifecycle-orchestration.test.d.ts +0 -2
- package/dist/ui/goal-lifecycle-orchestration.test.d.ts.map +0 -1
- package/dist/ui/goal-lifecycle-orchestration.test.js +0 -555
- package/dist/ui/goal-lifecycle-orchestration.test.js.map +0 -1
- package/dist/ui/goal-overlay.test.d.ts +0 -2
- package/dist/ui/goal-overlay.test.d.ts.map +0 -1
- package/dist/ui/goal-overlay.test.js +0 -384
- package/dist/ui/goal-overlay.test.js.map +0 -1
- package/dist/ui/goal-progress.d.ts +0 -31
- package/dist/ui/goal-progress.d.ts.map +0 -1
- package/dist/ui/goal-progress.js +0 -149
- package/dist/ui/goal-progress.js.map +0 -1
- package/dist/ui/goal-run-helpers.d.ts +0 -12
- package/dist/ui/goal-run-helpers.d.ts.map +0 -1
- package/dist/ui/goal-run-helpers.js +0 -42
- package/dist/ui/goal-run-helpers.js.map +0 -1
- package/dist/ui/goal-status-bar.test.d.ts +0 -2
- package/dist/ui/goal-status-bar.test.d.ts.map +0 -1
- package/dist/ui/goal-status-bar.test.js +0 -174
- package/dist/ui/goal-status-bar.test.js.map +0 -1
- package/dist/ui/goal-summary.d.ts +0 -14
- package/dist/ui/goal-summary.d.ts.map +0 -1
- package/dist/ui/goal-summary.js +0 -194
- package/dist/ui/goal-summary.js.map +0 -1
- package/dist/ui/hooks/useGoalOrchestration.d.ts +0 -82
- package/dist/ui/hooks/useGoalOrchestration.d.ts.map +0 -1
- package/dist/ui/hooks/useGoalOrchestration.js +0 -863
- package/dist/ui/hooks/useGoalOrchestration.js.map +0 -1
- package/dist/ui/hooks/useGoalPickerController.d.ts +0 -22
- package/dist/ui/hooks/useGoalPickerController.d.ts.map +0 -1
- package/dist/ui/hooks/useGoalPickerController.js +0 -35
- package/dist/ui/hooks/useGoalPickerController.js.map +0 -1
- package/dist/ui/prompt-routing.test.d.ts +0 -2
- package/dist/ui/prompt-routing.test.d.ts.map +0 -1
- package/dist/ui/prompt-routing.test.js +0 -48
- package/dist/ui/prompt-routing.test.js.map +0 -1
- package/dist/ui/transcript/GoalRows.d.ts +0 -10
- package/dist/ui/transcript/GoalRows.d.ts.map +0 -1
- package/dist/ui/transcript/GoalRows.js +0 -35
- package/dist/ui/transcript/GoalRows.js.map +0 -1
|
@@ -1,838 +0,0 @@
|
|
|
1
|
-
import { formatGoalBlockingPrerequisites, goalHasBlockingPrerequisites, goalHasUnmetLocalPrerequisites, unmetLocalGoalPrerequisites, } from "./goal-store.js";
|
|
2
|
-
import { formatGoalReferencesForPrompt, referencesRequiringAcknowledgement, } from "./goal-references.js";
|
|
3
|
-
export const DEFAULT_GOAL_TASK_ATTEMPT_LIMIT = 5;
|
|
4
|
-
export const DEFAULT_GOAL_VERIFIER_FIX_LIMIT = 5;
|
|
5
|
-
export const DEFAULT_GOAL_STRATEGY_LIMIT = 2;
|
|
6
|
-
/**
|
|
7
|
-
* Hard ceiling on total controller decisions per run. A safety net that
|
|
8
|
-
* guarantees termination even if some unforeseen state oscillates without
|
|
9
|
-
* tripping the per-dimension attempt/strategy/verifier/audit limits. Set high
|
|
10
|
-
* enough that legitimate large goals never hit it.
|
|
11
|
-
*/
|
|
12
|
-
export const DEFAULT_GOAL_DECISION_LIMIT = 300;
|
|
13
|
-
export const APPLY_INTEGRATION_TO_MAIN_TASK_TITLE = "Apply integrated worktree to main";
|
|
14
|
-
export const RESOLVE_LOCAL_PREREQUISITES_TASK_TITLE = "Resolve local Goal prerequisites";
|
|
15
|
-
export const RE_STRATEGIZE_GOAL_TASK_TITLE = "Re-strategize Goal approach";
|
|
16
|
-
export const FINAL_COMPLETION_AUDIT_TASK_TITLE = "Audit Goal completion evidence";
|
|
17
|
-
const BUILD_GOAL_EVIDENCE_PATH_TASK_TITLE = "Build Goal evidence path";
|
|
18
|
-
const BUILD_GOAL_VERIFICATION_HARNESS_TASK_TITLE = "Build Goal verification harness";
|
|
19
|
-
const DEFINE_GOAL_VERIFIER_TASK_TITLE = "Define Goal verifier";
|
|
20
|
-
const FIX_VERIFIER_FAILURE_TASK_TITLE = "Fix verifier failure";
|
|
21
|
-
const DEFAULT_GOAL_COMPLETION_AUDIT_LIMIT = 3;
|
|
22
|
-
/** Count of controller decisions already recorded as durable evidence. */
|
|
23
|
-
export function goalDecisionCount(run) {
|
|
24
|
-
return run.evidence.filter((item) => item.label.startsWith("Goal decision:")).length;
|
|
25
|
-
}
|
|
26
|
-
function needsHarnessInstrumentation(run) {
|
|
27
|
-
return run.harness.some((item) => !item.command && !item.path);
|
|
28
|
-
}
|
|
29
|
-
function referencePromptSection(references) {
|
|
30
|
-
const section = formatGoalReferencesForPrompt(references ?? []);
|
|
31
|
-
return section ? `${section}\n\n` : "";
|
|
32
|
-
}
|
|
33
|
-
function referenceMentionTokens(reference) {
|
|
34
|
-
return [reference.id, reference.label, reference.value, reference.path]
|
|
35
|
-
.filter((token) => !!token?.trim())
|
|
36
|
-
.map((token) => token.toLowerCase());
|
|
37
|
-
}
|
|
38
|
-
function requiresGoalReliabilityContract(run) {
|
|
39
|
-
const fields = [
|
|
40
|
-
run.goal,
|
|
41
|
-
...run.successCriteria,
|
|
42
|
-
...(run.references ?? []).map((reference) => `${reference.id} ${reference.label} ${reference.content ?? ""}`),
|
|
43
|
-
...run.evidence.map((item) => `${item.label}\n${item.path ?? ""}\n${item.content ?? ""}`),
|
|
44
|
-
].join("\n");
|
|
45
|
-
return /GOAL_PLAN/.test(fields);
|
|
46
|
-
}
|
|
47
|
-
function hasOriginalGoalPromptReference(run) {
|
|
48
|
-
return (run.references ?? []).some((reference) => reference.id === "original-goal-prompt" &&
|
|
49
|
-
reference.kind === "prompt" &&
|
|
50
|
-
reference.content?.trim());
|
|
51
|
-
}
|
|
52
|
-
function hasDurableGoalPlan(run) {
|
|
53
|
-
const fields = [
|
|
54
|
-
run.goal,
|
|
55
|
-
...run.evidence.map((item) => `${item.label}\n${item.path ?? ""}\n${item.content ?? ""}`),
|
|
56
|
-
].join("\n");
|
|
57
|
-
return /GOAL_PLAN/.test(fields) && /research=/.test(fields) && /success=/.test(fields);
|
|
58
|
-
}
|
|
59
|
-
function goalPromptDurabilityFailure(run) {
|
|
60
|
-
if (!requiresGoalReliabilityContract(run))
|
|
61
|
-
return undefined;
|
|
62
|
-
if (!hasOriginalGoalPromptReference(run)) {
|
|
63
|
-
return "Goal is missing durable [original-goal-prompt] reference content.";
|
|
64
|
-
}
|
|
65
|
-
if (!hasDurableGoalPlan(run)) {
|
|
66
|
-
return "Goal is missing durable planner GOAL_PLAN evidence/state.";
|
|
67
|
-
}
|
|
68
|
-
return undefined;
|
|
69
|
-
}
|
|
70
|
-
function fieldContainsReference(reference, fields) {
|
|
71
|
-
const haystack = fields.join("\n").toLowerCase();
|
|
72
|
-
return referenceMentionTokens(reference).some((token) => haystack.includes(token));
|
|
73
|
-
}
|
|
74
|
-
function unacknowledgedGoalReferences(run) {
|
|
75
|
-
const setupAndWorkFields = [
|
|
76
|
-
...run.successCriteria,
|
|
77
|
-
...run.evidencePlan.map((item) => `${item.id} ${item.label} ${item.description} ${item.command ?? ""} ${item.path ?? ""} ${item.evidence ?? ""}`),
|
|
78
|
-
...run.tasks.map((task) => `${task.title} ${task.prompt} ${task.lastSummary ?? ""}`),
|
|
79
|
-
...run.evidence.map((item) => `${item.label} ${item.path ?? ""} ${item.content ?? ""}`),
|
|
80
|
-
run.verifier?.description ?? "",
|
|
81
|
-
run.verifier?.command ?? "",
|
|
82
|
-
run.verifier?.lastResult?.summary ?? "",
|
|
83
|
-
run.completionAudit?.summary ?? "",
|
|
84
|
-
];
|
|
85
|
-
const completionFields = [
|
|
86
|
-
run.verifier?.description ?? "",
|
|
87
|
-
run.verifier?.command ?? "",
|
|
88
|
-
run.verifier?.lastResult?.summary ?? "",
|
|
89
|
-
run.verifier?.lastResult?.outputPath ?? "",
|
|
90
|
-
run.completionAudit?.summary ?? "",
|
|
91
|
-
run.completionAudit?.outputPath ?? "",
|
|
92
|
-
];
|
|
93
|
-
return (run.references ?? []).filter((reference) => {
|
|
94
|
-
if (reference.kind === "prompt") {
|
|
95
|
-
return (requiresGoalReliabilityContract(run) &&
|
|
96
|
-
reference.id === "original-goal-prompt" &&
|
|
97
|
-
!fieldContainsReference(reference, completionFields));
|
|
98
|
-
}
|
|
99
|
-
if (!referencesRequiringAcknowledgement([reference]).length)
|
|
100
|
-
return false;
|
|
101
|
-
return !fieldContainsReference(reference, setupAndWorkFields);
|
|
102
|
-
});
|
|
103
|
-
}
|
|
104
|
-
function buildHarnessTaskPrompt(run) {
|
|
105
|
-
const harnessItems = run.harness
|
|
106
|
-
.filter((item) => !item.command && !item.path)
|
|
107
|
-
.map((item) => `- ${item.label}: ${item.description ?? "Create local instrumentation."}`)
|
|
108
|
-
.join("\n");
|
|
109
|
-
return (`Goal: ${run.goal}\n\n` +
|
|
110
|
-
referencePromptSection(run.references) +
|
|
111
|
-
`Build only the missing local/free harness instrumentation needed before verification. Start by restating the intended experience, the relevant failure modes, and the senses/signals this harness must observe; do not default to generic tests, scripts, screenshots, benchmarks, or simulations unless that signal is required for this specific goal.\n` +
|
|
112
|
-
`${harnessItems}\n\n` +
|
|
113
|
-
`Inventory available local capabilities just deeply enough to choose a proportional instrument, then build it. Update the Goal harness/verifier metadata with the goals tool and record durable evidence showing the instrument exists and works. Do not require paid services or signups; block only with exact user instructions if a true external prerequisite is missing.`);
|
|
114
|
-
}
|
|
115
|
-
function blockedEvidencePlanReason(run) {
|
|
116
|
-
const blocked = run.evidencePlan.find((item) => item.status === "blocked");
|
|
117
|
-
if (!blocked)
|
|
118
|
-
return undefined;
|
|
119
|
-
return `${blocked.label}: ${blocked.instructions?.trim() || "User must provide this evidence prerequisite."}`;
|
|
120
|
-
}
|
|
121
|
-
function needsEvidenceInstrumentation(run) {
|
|
122
|
-
return unsatisfiedGoalEvidencePlanItems(run).some((item) => item.status === "planned");
|
|
123
|
-
}
|
|
124
|
-
export function unsatisfiedGoalEvidencePlanItems(run) {
|
|
125
|
-
return run.evidencePlan.filter((item) => !evidencePlanItemSatisfiedByDurableEvidence(run, item));
|
|
126
|
-
}
|
|
127
|
-
function unsatisfiedEvidencePlanItemReason(run, item) {
|
|
128
|
-
if (item.status === "ready" && !item.evidence?.trim() && !item.path && !item.command) {
|
|
129
|
-
return `${item.label} (ready but no durable evidence, path, or command recorded)`;
|
|
130
|
-
}
|
|
131
|
-
if (item.path && !run.evidence.some((evidence) => evidence.path === item.path)) {
|
|
132
|
-
return `${item.label} (missing durable evidence for path ${item.path})`;
|
|
133
|
-
}
|
|
134
|
-
if (item.command &&
|
|
135
|
-
!run.evidence.some((evidence) => exactTokenReferenced(evidence.content, item.command))) {
|
|
136
|
-
return `${item.label} (missing durable evidence for command ${item.command})`;
|
|
137
|
-
}
|
|
138
|
-
return item.label;
|
|
139
|
-
}
|
|
140
|
-
function exactTokenReferenced(content, token) {
|
|
141
|
-
return !!content?.trim() && !!token?.trim() && content.includes(token);
|
|
142
|
-
}
|
|
143
|
-
function evidencePlanItemSatisfiedByDurableEvidence(run, item) {
|
|
144
|
-
if (item.status === "ready" && item.evidence?.trim())
|
|
145
|
-
return true;
|
|
146
|
-
if (item.evidence?.trim())
|
|
147
|
-
return true;
|
|
148
|
-
const verifier = run.verifier?.lastResult;
|
|
149
|
-
if (verifier?.status === "pass") {
|
|
150
|
-
if (item.command && verifier.command === item.command)
|
|
151
|
-
return true;
|
|
152
|
-
if (item.path && verifier.outputPath === item.path)
|
|
153
|
-
return true;
|
|
154
|
-
}
|
|
155
|
-
return run.evidence.some((evidence) => {
|
|
156
|
-
if (item.path && evidence.path === item.path)
|
|
157
|
-
return true;
|
|
158
|
-
if (item.command && exactTokenReferenced(evidence.content, item.command))
|
|
159
|
-
return true;
|
|
160
|
-
if (item.path && exactTokenReferenced(evidence.content, item.path))
|
|
161
|
-
return true;
|
|
162
|
-
return false;
|
|
163
|
-
});
|
|
164
|
-
}
|
|
165
|
-
export function hasRequiredGoalEvidence(run) {
|
|
166
|
-
const missing = unsatisfiedGoalEvidencePlanItems(run);
|
|
167
|
-
if (missing.length > 0) {
|
|
168
|
-
return {
|
|
169
|
-
ok: false,
|
|
170
|
-
reason: `Goal evidence plan is not satisfied: ${missing.map((item) => unsatisfiedEvidencePlanItemReason(run, item)).join(", ")}.`,
|
|
171
|
-
};
|
|
172
|
-
}
|
|
173
|
-
return {
|
|
174
|
-
ok: true,
|
|
175
|
-
reason: "All required evidence-plan items are ready or proven by durable evidence.",
|
|
176
|
-
};
|
|
177
|
-
}
|
|
178
|
-
function finalAuditTaskCount(run) {
|
|
179
|
-
return run.tasks.filter((task) => task.title === FINAL_COMPLETION_AUDIT_TASK_TITLE).length;
|
|
180
|
-
}
|
|
181
|
-
function hasApplyIntegrationTask(run) {
|
|
182
|
-
return run.tasks.some((task) => task.title === APPLY_INTEGRATION_TO_MAIN_TASK_TITLE);
|
|
183
|
-
}
|
|
184
|
-
/**
|
|
185
|
-
* Done worktree tasks whose committed candidate changes must reach the main
|
|
186
|
-
* checkout. Ordering is expressed by dependsOn; this gate only excludes tasks
|
|
187
|
-
* explicitly marked integration="manual". Read-only tasks (audit, etc.)
|
|
188
|
-
* produce no candidate changes and are excluded.
|
|
189
|
-
*/
|
|
190
|
-
function pendingWorktreeIntegrationTasks(run) {
|
|
191
|
-
return run.tasks.filter((task) => task.status === "done" &&
|
|
192
|
-
!!task.worktree &&
|
|
193
|
-
task.integration !== "manual" &&
|
|
194
|
-
(task.candidate?.changedFiles?.length ?? 0) > 0);
|
|
195
|
-
}
|
|
196
|
-
/** Typed integration gate: candidates reached main (applied or committed). */
|
|
197
|
-
function integrationApplied(run) {
|
|
198
|
-
return run.integration?.status === "applied" || run.integration?.status === "committed";
|
|
199
|
-
}
|
|
200
|
-
/** Typed integration gate: integrated changes are committed in main. */
|
|
201
|
-
function integrationCommitted(run) {
|
|
202
|
-
return run.integration?.status === "committed";
|
|
203
|
-
}
|
|
204
|
-
function hasIntegratedWorktreeChanges(run) {
|
|
205
|
-
return (pendingWorktreeIntegrationTasks(run).length > 0 ||
|
|
206
|
-
(run.integration != null && run.integration.status !== "none"));
|
|
207
|
-
}
|
|
208
|
-
/**
|
|
209
|
-
* True when the latest verifier result predates the most recent substantive
|
|
210
|
-
* (non-audit, non-integration) worker completion, so the verifier evidence is
|
|
211
|
-
* stale and must be re-run before the audit/completion gates can trust it.
|
|
212
|
-
*/
|
|
213
|
-
function verifierStaleAfterWorker(run) {
|
|
214
|
-
return (!!run.verifier?.lastResult?.checkedAt &&
|
|
215
|
-
!!run.lastSubstantiveWorkerAt &&
|
|
216
|
-
run.lastSubstantiveWorkerAt > run.verifier.lastResult.checkedAt);
|
|
217
|
-
}
|
|
218
|
-
function needsMainIntegrationApplyTask(run) {
|
|
219
|
-
return (pendingWorktreeIntegrationTasks(run).length > 0 &&
|
|
220
|
-
!hasApplyIntegrationTask(run) &&
|
|
221
|
-
!integrationApplied(run));
|
|
222
|
-
}
|
|
223
|
-
function shouldCreateFinalAuditTask(run, limit = DEFAULT_GOAL_COMPLETION_AUDIT_LIMIT) {
|
|
224
|
-
return finalAuditTaskCount(run) < limit;
|
|
225
|
-
}
|
|
226
|
-
export function hasFreshGoalCompletionAudit(run) {
|
|
227
|
-
const verifierResult = run.verifier?.lastResult;
|
|
228
|
-
if (!verifierResult || verifierResult.status !== "pass") {
|
|
229
|
-
return { ok: false, reason: "Goal has no passing verifier result to audit." };
|
|
230
|
-
}
|
|
231
|
-
if (verifierStaleAfterWorker(run)) {
|
|
232
|
-
return {
|
|
233
|
-
ok: false,
|
|
234
|
-
reason: "Latest verifier result is stale after a later substantive Goal worker completion.",
|
|
235
|
-
};
|
|
236
|
-
}
|
|
237
|
-
const audit = run.completionAudit;
|
|
238
|
-
if (!audit) {
|
|
239
|
-
return { ok: false, reason: "Goal has no final completion audit." };
|
|
240
|
-
}
|
|
241
|
-
if (audit.status !== "pass") {
|
|
242
|
-
return { ok: false, reason: `Final completion audit status is ${audit.status}.` };
|
|
243
|
-
}
|
|
244
|
-
if (!audit.outputPath) {
|
|
245
|
-
return {
|
|
246
|
-
ok: false,
|
|
247
|
-
reason: "Final completion audit pass must reference verifier output or artifacts.",
|
|
248
|
-
};
|
|
249
|
-
}
|
|
250
|
-
if (audit.verifierCheckedAt !== verifierResult.checkedAt) {
|
|
251
|
-
return {
|
|
252
|
-
ok: false,
|
|
253
|
-
reason: "Final completion audit does not match the latest verifier result.",
|
|
254
|
-
};
|
|
255
|
-
}
|
|
256
|
-
if (audit.checkedAt < verifierResult.checkedAt) {
|
|
257
|
-
return {
|
|
258
|
-
ok: false,
|
|
259
|
-
reason: "Final completion audit is older than the latest verifier result.",
|
|
260
|
-
};
|
|
261
|
-
}
|
|
262
|
-
return { ok: true, reason: "Final completion audit passed after latest verifier evidence." };
|
|
263
|
-
}
|
|
264
|
-
function buildEvidencePlanTaskPrompt(run) {
|
|
265
|
-
const plannedItems = unsatisfiedGoalEvidencePlanItems(run)
|
|
266
|
-
.map((item) => `- ${item.label} (${item.mechanism}): ${item.description}${item.command ? `; candidate command: ${item.command}` : ""}${item.path ? `; artifact: ${item.path}` : ""}`)
|
|
267
|
-
.join("\n");
|
|
268
|
-
return (`Goal: ${run.goal}\n\n` +
|
|
269
|
-
referencePromptSection(run.references) +
|
|
270
|
-
`Turn the planned proof paths below into real local/free verification capability before the Goal verifier runs. For each path, preserve the orchestrator's goal-specific sensory intent: what experience is being observed, what failure it catches, and what signal proves it.\n` +
|
|
271
|
-
`${plannedItems}\n\n` +
|
|
272
|
-
`Inventory available local capabilities without anchoring on any fixed tool category. Build only the proportional instrument needed for this proof path, update the Goal evidence_plan/harness/verifier metadata with the goals tool, and persist concrete command/file/artifact/log evidence that the instrument works. If the verifier artifact exists only in your isolated worker worktree, set verifier_cwd to that worktree path when recording the verifier; otherwise copy/integrate the verifier artifact into the main checkout before using a main-checkout-relative command. Do not use narrative-only verification or human visual inspection as completion evidence. Only block with exact user instructions for inputs that cannot be generated or checked locally.`);
|
|
273
|
-
}
|
|
274
|
-
function buildVerifierTaskPrompt(run) {
|
|
275
|
-
return (`Goal: ${run.goal}\n\n` +
|
|
276
|
-
referencePromptSection(run.references) +
|
|
277
|
-
`Define and build a real end-to-end verifier for this Goal. Begin from the intended experience and required senses/signals already implied by the success criteria and evidence plan, including mandatory Goal references. Choose a proportional local/free verifier that observes those signals and catches the important goal-specific failures; do not add generic simulations, screenshots, benchmarks, or scripts unless they directly support that proof. Update the Goal with a verifier_command, verifier_description, and verifier_cwd when the command must run from an isolated worker worktree. The verifier must be runnable locally/free and produce durable command or file evidence, not narrative or human visual inspection. If an external prerequisite is missing, mark it missing with exact user instructions.`);
|
|
278
|
-
}
|
|
279
|
-
function buildApplyIntegrationToMainTaskPrompt(run) {
|
|
280
|
-
const integrationTasks = pendingWorktreeIntegrationTasks(run)
|
|
281
|
-
.map((task) => `- ${task.id} / ${task.title}: worktree=${task.worktree?.path ?? "unknown"}; branch=${task.worktree?.branchName ?? "unknown"}; base=${task.worktree?.baseRef ?? "unknown"}; summary=${task.lastSummary?.slice(0, 600) ?? "none"}`)
|
|
282
|
-
.join("\n");
|
|
283
|
-
return (`Goal: ${run.goal}\n\n` +
|
|
284
|
-
referencePromptSection(run.references) +
|
|
285
|
-
`Apply accepted integration worktree changes into the user's main checkout before any release, verifier, final audit, or completion. This task intentionally runs in the main checkout, not a new isolated worktree.\n\n` +
|
|
286
|
-
`Integrated candidate worker outputs to apply:\n${integrationTasks || "- none recorded"}\n\n` +
|
|
287
|
-
`For each integrated worktree, inspect its candidate packet, patch, diffstat, changed files, base SHA, verification logs, and risk notes. Apply or port only accepted changes to the main checkout; reject stale/risky/unrelated artifacts with durable evidence. Preserve user work. Run targeted checks in the main checkout after applying. Record durable evidence with label "Integrated worktree applied to main" containing the source worktree(s), accepted/rejected artifacts, changed files, diffstat, commands/results, and restart-needed note. The orchestrator will deterministically commit/confirm accepted changes after this worker exits. Do not mark the whole Goal complete.`);
|
|
288
|
-
}
|
|
289
|
-
function incompleteTasks(run) {
|
|
290
|
-
return run.tasks.filter((task) => task.status !== "done");
|
|
291
|
-
}
|
|
292
|
-
function activeTask(run) {
|
|
293
|
-
return run.tasks.find((task) => task.status === "running" || task.status === "verifying");
|
|
294
|
-
}
|
|
295
|
-
function recoverableTask(task) {
|
|
296
|
-
return task.status === "pending" || task.status === "failed";
|
|
297
|
-
}
|
|
298
|
-
function existingTaskWithTitle(run, title) {
|
|
299
|
-
return run.tasks.find((task) => task.title === title);
|
|
300
|
-
}
|
|
301
|
-
function existingBlockedTaskWithTitle(run, title) {
|
|
302
|
-
return run.tasks.find((task) => task.title === title && task.status === "blocked");
|
|
303
|
-
}
|
|
304
|
-
function reconcileExistingAutoTaskDecision(task, reason) {
|
|
305
|
-
if (task.status === "running" || task.status === "verifying") {
|
|
306
|
-
return {
|
|
307
|
-
kind: "wait",
|
|
308
|
-
reason: `Goal auto-task "${task.title}" already exists and is ${task.status}; ${reason}`,
|
|
309
|
-
...(task.workerId ? { workerId: task.workerId } : {}),
|
|
310
|
-
};
|
|
311
|
-
}
|
|
312
|
-
if (task.status === "pending" || task.status === "failed") {
|
|
313
|
-
return {
|
|
314
|
-
kind: "start_worker",
|
|
315
|
-
task,
|
|
316
|
-
attempts: task.attempts + 1,
|
|
317
|
-
reason: `Goal auto-task "${task.title}" already exists; reusing it instead of creating a duplicate. ${reason}`,
|
|
318
|
-
};
|
|
319
|
-
}
|
|
320
|
-
return {
|
|
321
|
-
kind: "blocked",
|
|
322
|
-
reason: `Goal auto-task "${task.title}" already exists with status ${task.status}; not creating a duplicate. Reconcile its evidence or update the existing task before continuing. ${reason}`,
|
|
323
|
-
};
|
|
324
|
-
}
|
|
325
|
-
function duplicateAutoTaskDecision(run, title, reason) {
|
|
326
|
-
const existingTask = existingTaskWithTitle(run, title);
|
|
327
|
-
return existingTask ? reconcileExistingAutoTaskDecision(existingTask, reason) : undefined;
|
|
328
|
-
}
|
|
329
|
-
function taskMatchesDependency(task, dependencyId) {
|
|
330
|
-
return task.id === dependencyId || task.id.startsWith(dependencyId);
|
|
331
|
-
}
|
|
332
|
-
function blockedTaskDependencies(run, task) {
|
|
333
|
-
return (task.dependsOn ?? []).filter((dependencyId) => {
|
|
334
|
-
const dependency = run.tasks.find((item) => taskMatchesDependency(item, dependencyId));
|
|
335
|
-
return dependency === undefined || dependency.status !== "done";
|
|
336
|
-
});
|
|
337
|
-
}
|
|
338
|
-
function nextRunnableTask(run) {
|
|
339
|
-
return run.tasks.find((task) => recoverableTask(task) && blockedTaskDependencies(run, task).length === 0);
|
|
340
|
-
}
|
|
341
|
-
function nextBlockedDependencyTask(run) {
|
|
342
|
-
for (const task of run.tasks) {
|
|
343
|
-
if (!recoverableTask(task))
|
|
344
|
-
continue;
|
|
345
|
-
const dependencies = blockedTaskDependencies(run, task);
|
|
346
|
-
if (dependencies.length > 0)
|
|
347
|
-
return { task, dependencies };
|
|
348
|
-
}
|
|
349
|
-
return undefined;
|
|
350
|
-
}
|
|
351
|
-
export function canCompleteGoalRun(run) {
|
|
352
|
-
if (run.status === "draft") {
|
|
353
|
-
return { ok: false, reason: "Goal setup is incomplete and remains draft." };
|
|
354
|
-
}
|
|
355
|
-
if (run.successCriteria.length === 0) {
|
|
356
|
-
return { ok: false, reason: "Goal setup is incomplete: success criteria are required." };
|
|
357
|
-
}
|
|
358
|
-
if (run.evidencePlan.length === 0) {
|
|
359
|
-
return { ok: false, reason: "Goal setup is incomplete: an evidence plan is required." };
|
|
360
|
-
}
|
|
361
|
-
if (!run.verifier?.command) {
|
|
362
|
-
return { ok: false, reason: "Goal setup is incomplete: verifier command is required." };
|
|
363
|
-
}
|
|
364
|
-
const promptDurabilityFailure = goalPromptDurabilityFailure(run);
|
|
365
|
-
if (promptDurabilityFailure)
|
|
366
|
-
return { ok: false, reason: promptDurabilityFailure };
|
|
367
|
-
const unacknowledgedReferences = unacknowledgedGoalReferences(run);
|
|
368
|
-
if (unacknowledgedReferences.length > 0) {
|
|
369
|
-
return {
|
|
370
|
-
ok: false,
|
|
371
|
-
reason: `Goal references are not covered by criteria/tasks/evidence/verifier/audit: ${unacknowledgedReferences.map((item) => item.label).join(", ")}.`,
|
|
372
|
-
};
|
|
373
|
-
}
|
|
374
|
-
if (goalHasBlockingPrerequisites(run)) {
|
|
375
|
-
return { ok: false, reason: formatGoalBlockingPrerequisites(run) };
|
|
376
|
-
}
|
|
377
|
-
const remainingTasks = incompleteTasks(run);
|
|
378
|
-
if (remainingTasks.length > 0) {
|
|
379
|
-
return {
|
|
380
|
-
ok: false,
|
|
381
|
-
reason: `${remainingTasks.length} Goal task${remainingTasks.length === 1 ? " is" : "s are"} not done.`,
|
|
382
|
-
};
|
|
383
|
-
}
|
|
384
|
-
const requiredEvidence = hasRequiredGoalEvidence(run);
|
|
385
|
-
if (!requiredEvidence.ok)
|
|
386
|
-
return requiredEvidence;
|
|
387
|
-
if (hasIntegratedWorktreeChanges(run) && !integrationCommitted(run)) {
|
|
388
|
-
return {
|
|
389
|
-
ok: false,
|
|
390
|
-
reason: "Integrated Goal changes have not been committed in the main checkout.",
|
|
391
|
-
};
|
|
392
|
-
}
|
|
393
|
-
const verifierResult = run.verifier?.lastResult;
|
|
394
|
-
if (!verifierResult) {
|
|
395
|
-
return { ok: false, reason: "Goal has no verifier evidence." };
|
|
396
|
-
}
|
|
397
|
-
if (verifierResult.status !== "pass") {
|
|
398
|
-
return { ok: false, reason: `Verifier status is ${verifierResult.status}.` };
|
|
399
|
-
}
|
|
400
|
-
const completionAudit = hasFreshGoalCompletionAudit(run);
|
|
401
|
-
if (!completionAudit.ok)
|
|
402
|
-
return completionAudit;
|
|
403
|
-
return {
|
|
404
|
-
ok: true,
|
|
405
|
-
reason: "All tasks are done, verifier evidence passed, and final completion audit passed.",
|
|
406
|
-
};
|
|
407
|
-
}
|
|
408
|
-
export function shouldClearGoalContinuation(decision) {
|
|
409
|
-
return decision.kind !== "wait";
|
|
410
|
-
}
|
|
411
|
-
export function shouldCreateVerifierFixTask(run, limit = DEFAULT_GOAL_VERIFIER_FIX_LIMIT) {
|
|
412
|
-
return run.tasks.filter((task) => task.title === "Fix verifier failure").length < limit;
|
|
413
|
-
}
|
|
414
|
-
export function verifierFixTaskCount(run) {
|
|
415
|
-
return run.tasks.filter((task) => task.title === "Fix verifier failure").length;
|
|
416
|
-
}
|
|
417
|
-
export function hasRepeatedVerifierFailure(run, repeatLimit = 2) {
|
|
418
|
-
const failures = run.evidence
|
|
419
|
-
.filter((item) => item.label === "Verifier fail" || item.label === "Verifier result")
|
|
420
|
-
.map((item) => (item.content ?? "").trim())
|
|
421
|
-
.filter(Boolean);
|
|
422
|
-
if (failures.length < repeatLimit)
|
|
423
|
-
return false;
|
|
424
|
-
const last = failures[failures.length - 1];
|
|
425
|
-
return failures.slice(-repeatLimit).every((item) => item === last);
|
|
426
|
-
}
|
|
427
|
-
function buildFinalCompletionAuditTaskPrompt(run) {
|
|
428
|
-
const verifier = run.verifier?.lastResult;
|
|
429
|
-
const evidencePlanItems = run.evidencePlan
|
|
430
|
-
.map((item) => `- ${item.id} / ${item.label} (${item.status}, ${item.mechanism}): ${item.description}${item.command ? `; command=${item.command}` : ""}${item.path ? `; path=${item.path}` : ""}${item.evidence ? `; evidence=${item.evidence}` : ""}`)
|
|
431
|
-
.join("\n");
|
|
432
|
-
const recentEvidence = run.evidence
|
|
433
|
-
.slice(-12)
|
|
434
|
-
.map((item) => `- ${item.createdAt} ${item.label}${item.path ? ` (${item.path})` : ""}: ${(item.content ?? "").slice(0, 320)}`)
|
|
435
|
-
.join("\n");
|
|
436
|
-
return (`Goal: ${run.goal}\n\n` +
|
|
437
|
-
referencePromptSection(run.references) +
|
|
438
|
-
`You are the final read-only Goal completion auditor. Do not edit files, do not run broad implementation work, do not mark the Goal complete, and do not trust worker summaries by themselves. Verify the original success criteria and every mandatory Goal reference against actual durable artifacts after the latest verifier pass.\n\n` +
|
|
439
|
-
`Success criteria:\n${run.successCriteria.map((item) => `- ${item}`).join("\n") || "- none recorded"}\n\n` +
|
|
440
|
-
`Latest verifier: status=${verifier?.status ?? "unknown"}; checkedAt=${verifier?.checkedAt ?? "unknown"}; command=${verifier?.command ?? run.verifier?.command ?? "not recorded"}; output=${verifier?.outputPath ?? "not recorded"}; summary=${verifier?.summary ?? "not recorded"}\n\n` +
|
|
441
|
-
`Evidence plan:\n${evidencePlanItems || "- none"}\n\n` +
|
|
442
|
-
`Recent durable evidence:\n${recentEvidence || "- none"}\n\n` +
|
|
443
|
-
`Read the referenced report/log/source artifacts and compare them with the latest verifier result. The coordinator schedules and records decisions/state; the verifier path/UI/controller executes the configured verifier command as the final pre-audit gate and records goals verify evidence; this final audit records goals audit only after comparing the latest verifier output and references, including [original-goal-prompt] and durable GOAL_PLAN evidence. If an evidence-plan item is still planned but already matched by durable verifier/source/file evidence, update that evidence_plan item to status=ready with a concise evidence summary before recording the audit; if proof is missing, create a new pending Goal task with exact fix instructions and do not pass the audit. If everything matches, record a passing completion audit with the goals tool using action=audit and verification_status=pass: write a plain-prose summary of which durable artifacts you compared and reference any mandatory non-prompt Goal references (and, when this Goal uses GOAL_PLAN planning, mention original-goal-prompt and GOAL_PLAN). The system auto-stamps FINAL_AUDIT_PASS and verifier_checked_at and fills output_path from the recorded verifier run, so do not transcribe the timestamp; any remaining contract gaps are returned all at once. If anything is missing, stale, contradictory, or unverified, create a new pending Goal task with exact instructions to fix it, record evidence describing the mismatch, and leave the audit failing or absent so the coordinator resumes a worker until fixed.`);
|
|
444
|
-
}
|
|
445
|
-
function buildVerifierFailureTaskPrompt(run) {
|
|
446
|
-
const result = run.verifier?.lastResult;
|
|
447
|
-
const priorSummaries = run.evidence
|
|
448
|
-
.filter((item) => item.label.startsWith("Verifier"))
|
|
449
|
-
.slice(-3)
|
|
450
|
-
.map((item) => `- ${item.label}${item.path ? ` (${item.path})` : ""}: ${(item.content ?? "").slice(0, 500)}`)
|
|
451
|
-
.join("\n") || "- none";
|
|
452
|
-
const attempt = verifierFixTaskCount(run) + 1;
|
|
453
|
-
return (`Original objective: ${run.goal}\n\n` +
|
|
454
|
-
referencePromptSection(run.references) +
|
|
455
|
-
`Success criteria:\n${run.successCriteria.map((item) => `- ${item}`).join("\n") || "- none recorded"}\n\n` +
|
|
456
|
-
`Verifier command: ${run.verifier?.command ?? "(missing)"}\n` +
|
|
457
|
-
`Exit code: ${result?.exitCode ?? "unknown"}\n` +
|
|
458
|
-
`Output path: ${result?.outputPath ?? "not recorded"}\n` +
|
|
459
|
-
`Fix attempt ${attempt}/${DEFAULT_GOAL_VERIFIER_FIX_LIMIT}.\n\n` +
|
|
460
|
-
`Prior verifier summaries:\n${priorSummaries}\n\n` +
|
|
461
|
-
`Run targeted diagnostics, fix the root cause, update durable Goal evidence with the goals tool, and rerun the exact verifier command. Do not mark the Goal complete.`);
|
|
462
|
-
}
|
|
463
|
-
function buildResolveLocalPrerequisitesTaskPrompt(run) {
|
|
464
|
-
const items = unmetLocalGoalPrerequisites(run)
|
|
465
|
-
.map((item) => `- ${item.label} (${item.status})${item.checkCommand ? `; check: ${item.checkCommand}` : ""}${item.instructions ? `; instructions: ${item.instructions}` : ""}`)
|
|
466
|
-
.join("\n");
|
|
467
|
-
return (`Goal: ${run.goal}\n\n` +
|
|
468
|
-
referencePromptSection(run.references) +
|
|
469
|
-
`Resolve the following local Goal prerequisites so the Goal can proceed unattended. These are not user-supplied external inputs; satisfy each one locally with free tools.\n\n` +
|
|
470
|
-
`${items || "- none recorded"}\n\n` +
|
|
471
|
-
`For each prerequisite, make its check pass locally (install/configure/build as needed using local/free tooling), then record durable evidence and update the prerequisite to status=met with the goals tool (action="prerequisite"). If a prerequisite turns out to genuinely require user-supplied external input, mark it kind=external with exact user instructions instead of guessing.`);
|
|
472
|
-
}
|
|
473
|
-
function isReStrategizeTask(task) {
|
|
474
|
-
return task.title.startsWith(RE_STRATEGIZE_GOAL_TASK_TITLE);
|
|
475
|
-
}
|
|
476
|
-
export function goalStrategyTaskCount(run) {
|
|
477
|
-
return run.tasks.filter(isReStrategizeTask).length;
|
|
478
|
-
}
|
|
479
|
-
function workerEvidenceContentsForTask(run, task) {
|
|
480
|
-
if (!task.workerId)
|
|
481
|
-
return [];
|
|
482
|
-
return run.evidence
|
|
483
|
-
.filter((item) => {
|
|
484
|
-
const match = /^Worker\s+(\S+)\s+/.exec(item.label);
|
|
485
|
-
return match?.[1] === task.workerId;
|
|
486
|
-
})
|
|
487
|
-
.map((item) => (item.content ?? "").trim())
|
|
488
|
-
.filter(Boolean);
|
|
489
|
-
}
|
|
490
|
-
/**
|
|
491
|
-
* No-progress signal for an implementation task: the latest two worker evidence
|
|
492
|
-
* contents for the task's worker are identical, so re-running the same approach
|
|
493
|
-
* is unlikely to make progress.
|
|
494
|
-
*/
|
|
495
|
-
export function taskFailureRepeatedWithoutProgress(run, task) {
|
|
496
|
-
const contents = workerEvidenceContentsForTask(run, task);
|
|
497
|
-
if (contents.length < 2)
|
|
498
|
-
return false;
|
|
499
|
-
return contents[contents.length - 1] === contents[contents.length - 2];
|
|
500
|
-
}
|
|
501
|
-
function buildReStrategizeTaskPrompt(run, focus) {
|
|
502
|
-
const priorContents = focus
|
|
503
|
-
? workerEvidenceContentsForTask(run, focus)
|
|
504
|
-
: run.evidence
|
|
505
|
-
.filter((item) => item.label.startsWith("Verifier"))
|
|
506
|
-
.map((item) => (item.content ?? "").trim())
|
|
507
|
-
.filter(Boolean);
|
|
508
|
-
const priorSummaries = priorContents
|
|
509
|
-
.slice(-3)
|
|
510
|
-
.map((content) => `- ${content.slice(0, 500)}`)
|
|
511
|
-
.join("\n");
|
|
512
|
-
const what = focus ? `task "${focus.title}" (${focus.id})` : "the configured verifier";
|
|
513
|
-
return (`Original objective: ${run.goal}\n\n` +
|
|
514
|
-
referencePromptSection(run.references) +
|
|
515
|
-
`Prior attempts at ${what} repeatedly failed without progress.\n\n` +
|
|
516
|
-
`Prior attempt summaries:\n${priorSummaries || "- none recorded"}\n\n` +
|
|
517
|
-
`Analyze why the prior attempts failed, then take a fundamentally different approach to accomplish the original objective. Do not repeat the same strategy. Use local/free tools, record durable evidence with the goals tool, and update task status.${focus ? ` When you accomplish the objective, also mark the original failing task ${focus.id} done with the goals tool so the Goal can proceed.` : ""} If the objective genuinely requires user-supplied external input, record it as an external prerequisite with exact instructions.`);
|
|
518
|
-
}
|
|
519
|
-
/**
|
|
520
|
-
* Bounded re-strategy escalation: run an existing recoverable re-strategy task,
|
|
521
|
-
* else create one (up to the strategy limit), else terminate the run in
|
|
522
|
-
* `failed` with a structured diagnosis brief. Replaces the former pause/block
|
|
523
|
-
* dead-ends so the loop always either changes state or resolves.
|
|
524
|
-
*/
|
|
525
|
-
function reStrategizeOrFailDecision(run, options, context) {
|
|
526
|
-
const attemptLimit = options.taskAttemptLimit ?? DEFAULT_GOAL_TASK_ATTEMPT_LIMIT;
|
|
527
|
-
// Run an existing recoverable re-strategy task, but only while it still has
|
|
528
|
-
// attempt budget left, so a perpetually-failing strategy task cannot loop.
|
|
529
|
-
const recoverableStrategy = run.tasks.find((item) => isReStrategizeTask(item) && recoverableTask(item) && item.attempts < attemptLimit);
|
|
530
|
-
if (recoverableStrategy) {
|
|
531
|
-
return {
|
|
532
|
-
kind: "start_worker",
|
|
533
|
-
task: recoverableStrategy,
|
|
534
|
-
attempts: recoverableStrategy.attempts + 1,
|
|
535
|
-
reason: context.startReason,
|
|
536
|
-
};
|
|
537
|
-
}
|
|
538
|
-
const strategyLimit = options.strategyLimit ?? DEFAULT_GOAL_STRATEGY_LIMIT;
|
|
539
|
-
const strategyCount = goalStrategyTaskCount(run);
|
|
540
|
-
if (strategyCount < strategyLimit) {
|
|
541
|
-
// Distinct titles per attempt so the orchestrator creates a fresh task
|
|
542
|
-
// instead of reusing an exhausted same-title one.
|
|
543
|
-
const title = strategyCount === 0
|
|
544
|
-
? RE_STRATEGIZE_GOAL_TASK_TITLE
|
|
545
|
-
: `${RE_STRATEGIZE_GOAL_TASK_TITLE} (${strategyCount + 1})`;
|
|
546
|
-
return {
|
|
547
|
-
kind: "create_task",
|
|
548
|
-
title,
|
|
549
|
-
prompt: buildReStrategizeTaskPrompt(run, context.focus),
|
|
550
|
-
reason: `${context.startReason} (${strategyCount + 1}/${strategyLimit})`,
|
|
551
|
-
};
|
|
552
|
-
}
|
|
553
|
-
return {
|
|
554
|
-
kind: "terminal",
|
|
555
|
-
status: "failed",
|
|
556
|
-
reason: buildGoalFailureDiagnosis(run, context.failReason),
|
|
557
|
-
};
|
|
558
|
-
}
|
|
559
|
-
/**
|
|
560
|
-
* Structured diagnosis brief recorded when a Goal terminates in `failed` so the
|
|
561
|
-
* run ends resolved (not spinning, not silently paused) with an honest verdict.
|
|
562
|
-
*/
|
|
563
|
-
export function buildGoalFailureDiagnosis(run, reason) {
|
|
564
|
-
const attempts = run.tasks
|
|
565
|
-
.map((task) => `- ${task.title} (${task.id}): status=${task.status}; attempts=${task.attempts}${task.lastSummary ? `; last=${task.lastSummary.slice(0, 240)}` : ""}`)
|
|
566
|
-
.join("\n");
|
|
567
|
-
const failureSignatures = Array.from(new Set(run.evidence
|
|
568
|
-
.filter((item) => item.label === "Verifier fail" || item.label === "Verifier result")
|
|
569
|
-
.map((item) => (item.content ?? "").trim())
|
|
570
|
-
.filter(Boolean)))
|
|
571
|
-
.slice(-5)
|
|
572
|
-
.map((signature) => `- ${signature.slice(0, 240)}`)
|
|
573
|
-
.join("\n");
|
|
574
|
-
const verifier = run.verifier?.lastResult;
|
|
575
|
-
const externalNeeds = run.prerequisites
|
|
576
|
-
.filter((item) => (item.status !== "met" || !item.evidence?.trim()) && item.kind === "external")
|
|
577
|
-
.map((item) => `- ${item.label}: ${item.instructions ?? "user-supplied input required"}`)
|
|
578
|
-
.join("\n");
|
|
579
|
-
return [
|
|
580
|
-
"GOAL_FAILURE_DIAGNOSIS",
|
|
581
|
-
`objective=${run.goal}`,
|
|
582
|
-
`reason=${reason}`,
|
|
583
|
-
`tasks:\n${attempts || "- none"}`,
|
|
584
|
-
`distinct_failure_signatures:\n${failureSignatures || "- none"}`,
|
|
585
|
-
`latest_verifier=${verifier ? `${verifier.status} (exit ${verifier.exitCode ?? "unknown"}): ${verifier.summary?.slice(0, 240) ?? ""}` : "none"}`,
|
|
586
|
-
`human_decision_needed:\n${externalNeeds || "- none"}`,
|
|
587
|
-
].join("\n");
|
|
588
|
-
}
|
|
589
|
-
export function formatGoalControllerDecision(decision) {
|
|
590
|
-
const parts = [`kind=${decision.kind}`];
|
|
591
|
-
if ("reason" in decision)
|
|
592
|
-
parts.push(`reason=${decision.reason}`);
|
|
593
|
-
if (decision.kind === "start_worker") {
|
|
594
|
-
parts.push(`task=${decision.task.id}`, `title=${decision.task.title}`, `attempts=${decision.attempts}`);
|
|
595
|
-
if (decision.task.workerId)
|
|
596
|
-
parts.push(`worker=${decision.task.workerId}`);
|
|
597
|
-
if (decision.task.dependsOn?.length)
|
|
598
|
-
parts.push(`depends_on=${decision.task.dependsOn.join(",")}`);
|
|
599
|
-
if (decision.task.parallelGroup)
|
|
600
|
-
parts.push(`parallel_group=${decision.task.parallelGroup}`);
|
|
601
|
-
if (decision.task.expectedChangedScope?.length) {
|
|
602
|
-
parts.push(`expected_changed_scope=${decision.task.expectedChangedScope.join(",")}`);
|
|
603
|
-
}
|
|
604
|
-
if (decision.task.integration)
|
|
605
|
-
parts.push(`integration=${decision.task.integration}`);
|
|
606
|
-
}
|
|
607
|
-
if (decision.kind === "wait" && decision.workerId)
|
|
608
|
-
parts.push(`worker=${decision.workerId}`);
|
|
609
|
-
if (decision.kind === "run_verifier")
|
|
610
|
-
parts.push(`verifier=${decision.command}`);
|
|
611
|
-
if (decision.kind === "terminal")
|
|
612
|
-
parts.push(`status=${decision.status}`);
|
|
613
|
-
if (decision.kind === "create_task")
|
|
614
|
-
parts.push(`title=${decision.title}`);
|
|
615
|
-
return { label: `Goal decision: ${decision.kind}`, content: parts.join("; ") };
|
|
616
|
-
}
|
|
617
|
-
export function decideGoalNextAction(run, options = {}) {
|
|
618
|
-
const completion = canCompleteGoalRun(run);
|
|
619
|
-
if (completion.ok) {
|
|
620
|
-
if (run.continueRequestedAt && run.verifier?.command) {
|
|
621
|
-
return {
|
|
622
|
-
kind: "run_verifier",
|
|
623
|
-
command: run.verifier.command,
|
|
624
|
-
reason: "Goal rerun requested; rerunning configured verifier before any new final audit.",
|
|
625
|
-
};
|
|
626
|
-
}
|
|
627
|
-
return { kind: "complete", reason: completion.reason };
|
|
628
|
-
}
|
|
629
|
-
// Hard termination guarantee: if a run somehow keeps making decisions without
|
|
630
|
-
// completing or hitting a narrower limit, fail with a diagnosis rather than
|
|
631
|
-
// loop forever.
|
|
632
|
-
const decisionLimit = options.decisionLimit ?? DEFAULT_GOAL_DECISION_LIMIT;
|
|
633
|
-
if (goalDecisionCount(run) > decisionLimit) {
|
|
634
|
-
return {
|
|
635
|
-
kind: "terminal",
|
|
636
|
-
status: "failed",
|
|
637
|
-
reason: buildGoalFailureDiagnosis(run, `Goal exceeded the maximum of ${decisionLimit} controller decisions without completing; stopping to avoid an unbounded loop.`),
|
|
638
|
-
};
|
|
639
|
-
}
|
|
640
|
-
if (goalHasBlockingPrerequisites(run)) {
|
|
641
|
-
return { kind: "blocked", reason: formatGoalBlockingPrerequisites(run) };
|
|
642
|
-
}
|
|
643
|
-
if ((run.status === "blocked" && run.verifier?.lastResult?.status !== "pass") ||
|
|
644
|
-
run.status === "failed" ||
|
|
645
|
-
(run.status === "passed" && run.verifier?.lastResult?.status !== "pass") ||
|
|
646
|
-
(run.status === "paused" && !run.continueRequestedAt)) {
|
|
647
|
-
return { kind: "terminal", status: run.status, reason: `Goal is ${run.status}.` };
|
|
648
|
-
}
|
|
649
|
-
if (run.activeWorkerId) {
|
|
650
|
-
return {
|
|
651
|
-
kind: "wait",
|
|
652
|
-
reason: "Goal already has an active worker.",
|
|
653
|
-
workerId: run.activeWorkerId,
|
|
654
|
-
};
|
|
655
|
-
}
|
|
656
|
-
const runningTask = activeTask(run);
|
|
657
|
-
if (runningTask) {
|
|
658
|
-
return {
|
|
659
|
-
kind: "wait",
|
|
660
|
-
reason: `Goal task "${runningTask.title}" is already ${runningTask.status}.`,
|
|
661
|
-
...(runningTask.workerId ? { workerId: runningTask.workerId } : {}),
|
|
662
|
-
};
|
|
663
|
-
}
|
|
664
|
-
if (goalHasUnmetLocalPrerequisites(run)) {
|
|
665
|
-
const duplicateDecision = duplicateAutoTaskDecision(run, RESOLVE_LOCAL_PREREQUISITES_TASK_TITLE, "Local Goal prerequisites must be satisfied locally before implementation.");
|
|
666
|
-
if (duplicateDecision)
|
|
667
|
-
return duplicateDecision;
|
|
668
|
-
return {
|
|
669
|
-
kind: "create_task",
|
|
670
|
-
title: RESOLVE_LOCAL_PREREQUISITES_TASK_TITLE,
|
|
671
|
-
prompt: buildResolveLocalPrerequisitesTaskPrompt(run),
|
|
672
|
-
reason: `Resolving ${unmetLocalGoalPrerequisites(run).length} local Goal prerequisite(s) locally instead of blocking.`,
|
|
673
|
-
};
|
|
674
|
-
}
|
|
675
|
-
const task = nextRunnableTask(run);
|
|
676
|
-
if (task) {
|
|
677
|
-
const attempts = task.attempts + 1;
|
|
678
|
-
const limit = options.taskAttemptLimit ?? DEFAULT_GOAL_TASK_ATTEMPT_LIMIT;
|
|
679
|
-
if (attempts > limit) {
|
|
680
|
-
// Past the soft attempt limit: keep retrying while the failure signature
|
|
681
|
-
// keeps changing (still making progress); on a no-progress repeat,
|
|
682
|
-
// re-strategize a bounded number of times, then fail with a diagnosis.
|
|
683
|
-
if (!isReStrategizeTask(task) && !taskFailureRepeatedWithoutProgress(run, task)) {
|
|
684
|
-
return {
|
|
685
|
-
kind: "start_worker",
|
|
686
|
-
task,
|
|
687
|
-
attempts,
|
|
688
|
-
reason: `Goal task "${task.title}" passed the soft attempt limit but is still making progress; continuing attempt ${attempts}.`,
|
|
689
|
-
};
|
|
690
|
-
}
|
|
691
|
-
return reStrategizeOrFailDecision(run, options, {
|
|
692
|
-
focus: task,
|
|
693
|
-
startReason: `Re-strategizing "${task.title}" with a fundamentally different approach.`,
|
|
694
|
-
failReason: `Task "${task.title}" could not be completed after ${task.attempts} attempt(s) and the bounded re-strategy limit.`,
|
|
695
|
-
});
|
|
696
|
-
}
|
|
697
|
-
return {
|
|
698
|
-
kind: "start_worker",
|
|
699
|
-
task,
|
|
700
|
-
attempts,
|
|
701
|
-
reason: `Goal task "${task.title}" is ready for worker attempt ${attempts}.`,
|
|
702
|
-
};
|
|
703
|
-
}
|
|
704
|
-
const dependencyBlockedTask = nextBlockedDependencyTask(run);
|
|
705
|
-
if (dependencyBlockedTask) {
|
|
706
|
-
const missingDependencies = dependencyBlockedTask.dependencies.filter((dependencyId) => !run.tasks.some((item) => taskMatchesDependency(item, dependencyId)));
|
|
707
|
-
if (missingDependencies.length > 0) {
|
|
708
|
-
return {
|
|
709
|
-
kind: "terminal",
|
|
710
|
-
status: "failed",
|
|
711
|
-
reason: buildGoalFailureDiagnosis(run, `Goal task "${dependencyBlockedTask.task.title}" depends on missing task(s) that cannot be synthesized: ${missingDependencies.join(", ")}.`),
|
|
712
|
-
};
|
|
713
|
-
}
|
|
714
|
-
return {
|
|
715
|
-
kind: "wait",
|
|
716
|
-
reason: `Goal task "${dependencyBlockedTask.task.title}" is waiting for dependency task(s): ${dependencyBlockedTask.dependencies.join(", ")}.`,
|
|
717
|
-
};
|
|
718
|
-
}
|
|
719
|
-
const blockedEvidence = blockedEvidencePlanReason(run);
|
|
720
|
-
if (blockedEvidence) {
|
|
721
|
-
return { kind: "blocked", reason: blockedEvidence };
|
|
722
|
-
}
|
|
723
|
-
if (needsMainIntegrationApplyTask(run)) {
|
|
724
|
-
return {
|
|
725
|
-
kind: "create_task",
|
|
726
|
-
title: APPLY_INTEGRATION_TO_MAIN_TASK_TITLE,
|
|
727
|
-
prompt: buildApplyIntegrationToMainTaskPrompt(run),
|
|
728
|
-
reason: "Accepted integration worktree changes must be applied to the user's main checkout before verifier, final audit, release, commit, or completion.",
|
|
729
|
-
};
|
|
730
|
-
}
|
|
731
|
-
if (run.verifier?.lastResult?.status === "pass" &&
|
|
732
|
-
verifierStaleAfterWorker(run) &&
|
|
733
|
-
run.verifier?.command) {
|
|
734
|
-
return {
|
|
735
|
-
kind: "run_verifier",
|
|
736
|
-
command: run.verifier.command,
|
|
737
|
-
reason: "Latest verifier result is stale after later Goal worker evidence; rerunning configured verifier as the final pre-audit gate.",
|
|
738
|
-
};
|
|
739
|
-
}
|
|
740
|
-
if (needsEvidenceInstrumentation(run)) {
|
|
741
|
-
if (run.verifier?.lastResult?.status === "pass") {
|
|
742
|
-
if (shouldCreateFinalAuditTask(run)) {
|
|
743
|
-
return {
|
|
744
|
-
kind: "create_task",
|
|
745
|
-
title: FINAL_COMPLETION_AUDIT_TASK_TITLE,
|
|
746
|
-
prompt: buildFinalCompletionAuditTaskPrompt(run),
|
|
747
|
-
reason: `Verifier passed; final read-only audit must reconcile ${unsatisfiedGoalEvidencePlanItems(run).length} evidence-plan item(s) before the Goal can pass (${finalAuditTaskCount(run) + 1}/${DEFAULT_GOAL_COMPLETION_AUDIT_LIMIT}).`,
|
|
748
|
-
};
|
|
749
|
-
}
|
|
750
|
-
return {
|
|
751
|
-
kind: "terminal",
|
|
752
|
-
status: "failed",
|
|
753
|
-
reason: buildGoalFailureDiagnosis(run, "Verifier passed, but the final completion audit could not reconcile the Goal evidence plan after bounded attempts."),
|
|
754
|
-
};
|
|
755
|
-
}
|
|
756
|
-
const duplicateDecision = duplicateAutoTaskDecision(run, BUILD_GOAL_EVIDENCE_PATH_TASK_TITLE, "Goal evidence plan still requires local instrumentation or exact prerequisite handling before verification.");
|
|
757
|
-
if (duplicateDecision)
|
|
758
|
-
return duplicateDecision;
|
|
759
|
-
return {
|
|
760
|
-
kind: "create_task",
|
|
761
|
-
title: BUILD_GOAL_EVIDENCE_PATH_TASK_TITLE,
|
|
762
|
-
prompt: buildEvidencePlanTaskPrompt(run),
|
|
763
|
-
reason: "Goal evidence plan requires local instrumentation or exact prerequisite handling before verification.",
|
|
764
|
-
};
|
|
765
|
-
}
|
|
766
|
-
if (needsHarnessInstrumentation(run)) {
|
|
767
|
-
const duplicateDecision = duplicateAutoTaskDecision(run, BUILD_GOAL_VERIFICATION_HARNESS_TASK_TITLE, "Goal harness still requires local instrumentation before verification.");
|
|
768
|
-
if (duplicateDecision)
|
|
769
|
-
return duplicateDecision;
|
|
770
|
-
return {
|
|
771
|
-
kind: "create_task",
|
|
772
|
-
title: BUILD_GOAL_VERIFICATION_HARNESS_TASK_TITLE,
|
|
773
|
-
prompt: buildHarnessTaskPrompt(run),
|
|
774
|
-
reason: "Goal harness requires local instrumentation before verification.",
|
|
775
|
-
};
|
|
776
|
-
}
|
|
777
|
-
if (run.verifier?.lastResult?.status === "fail") {
|
|
778
|
-
if (hasRepeatedVerifierFailure(run)) {
|
|
779
|
-
return reStrategizeOrFailDecision(run, options, {
|
|
780
|
-
startReason: "Verifier produced the same failure repeatedly; re-strategizing with a fundamentally different approach.",
|
|
781
|
-
failReason: "Verifier produced the same failure repeatedly and bounded re-strategy attempts were exhausted.",
|
|
782
|
-
});
|
|
783
|
-
}
|
|
784
|
-
const limit = options.verifierFixLimit ?? DEFAULT_GOAL_VERIFIER_FIX_LIMIT;
|
|
785
|
-
const blockedFixTask = existingBlockedTaskWithTitle(run, FIX_VERIFIER_FAILURE_TASK_TITLE);
|
|
786
|
-
if (blockedFixTask) {
|
|
787
|
-
return reStrategizeOrFailDecision(run, options, {
|
|
788
|
-
startReason: "A blocked verifier-fix task exists; re-strategizing the verifier fix with a different approach.",
|
|
789
|
-
failReason: "A verifier-fix task was blocked and bounded re-strategy attempts were exhausted.",
|
|
790
|
-
});
|
|
791
|
-
}
|
|
792
|
-
if (shouldCreateVerifierFixTask(run, limit)) {
|
|
793
|
-
return {
|
|
794
|
-
kind: "create_task",
|
|
795
|
-
title: FIX_VERIFIER_FAILURE_TASK_TITLE,
|
|
796
|
-
prompt: buildVerifierFailureTaskPrompt(run),
|
|
797
|
-
reason: `Verifier failed; creating bounded fix task ${verifierFixTaskCount(run) + 1}/${limit}.`,
|
|
798
|
-
};
|
|
799
|
-
}
|
|
800
|
-
return {
|
|
801
|
-
kind: "terminal",
|
|
802
|
-
status: "failed",
|
|
803
|
-
reason: buildGoalFailureDiagnosis(run, `Verifier failed and the bounded verifier-fix limit (${limit}) was reached without a pass.`),
|
|
804
|
-
};
|
|
805
|
-
}
|
|
806
|
-
if (run.verifier?.lastResult?.status === "pass") {
|
|
807
|
-
if (shouldCreateFinalAuditTask(run)) {
|
|
808
|
-
return {
|
|
809
|
-
kind: "create_task",
|
|
810
|
-
title: FINAL_COMPLETION_AUDIT_TASK_TITLE,
|
|
811
|
-
prompt: buildFinalCompletionAuditTaskPrompt(run),
|
|
812
|
-
reason: `Verifier passed; creating final read-only completion audit before the Goal can pass (${finalAuditTaskCount(run) + 1}/${DEFAULT_GOAL_COMPLETION_AUDIT_LIMIT}).`,
|
|
813
|
-
};
|
|
814
|
-
}
|
|
815
|
-
return {
|
|
816
|
-
kind: "terminal",
|
|
817
|
-
status: "failed",
|
|
818
|
-
reason: buildGoalFailureDiagnosis(run, "Verifier passed, but the final completion audit did not pass after bounded attempts."),
|
|
819
|
-
};
|
|
820
|
-
}
|
|
821
|
-
if (run.verifier?.command) {
|
|
822
|
-
return {
|
|
823
|
-
kind: "run_verifier",
|
|
824
|
-
command: run.verifier.command,
|
|
825
|
-
reason: "All Goal tasks are done; running configured verifier for real completion evidence.",
|
|
826
|
-
};
|
|
827
|
-
}
|
|
828
|
-
const duplicateDecision = duplicateAutoTaskDecision(run, DEFINE_GOAL_VERIFIER_TASK_TITLE, "No verifier command is configured yet.");
|
|
829
|
-
if (duplicateDecision)
|
|
830
|
-
return duplicateDecision;
|
|
831
|
-
return {
|
|
832
|
-
kind: "create_task",
|
|
833
|
-
title: DEFINE_GOAL_VERIFIER_TASK_TITLE,
|
|
834
|
-
prompt: buildVerifierTaskPrompt(run),
|
|
835
|
-
reason: "No pending Goal task or verifier command is configured.",
|
|
836
|
-
};
|
|
837
|
-
}
|
|
838
|
-
//# sourceMappingURL=goal-controller.js.map
|