agentic-orchestrator 0.1.28 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.claude/settings.local.json +46 -1
- package/.cortexrc +28 -0
- package/.github/agents/copilot-instructions.md +29 -0
- package/.github/copilot-instructions.md +93 -0
- package/.vscode/settings.json +13 -0
- package/.vscode/tms.code-snippets +223 -0
- package/AGENTS.md +72 -1
- package/Agentic-Orchestrator.iml +12 -11
- package/CLAUDE.md +72 -1
- package/CONSTITUTION.md +504 -0
- package/FUTURE-ENHANCEMENTS.md +85 -0
- package/NEXT-TASKS.md +25 -0
- package/PROMPTS.md +161 -0
- package/README.md +126 -29
- package/agentic/orchestrator/agents.yaml +4 -3
- package/agentic/orchestrator/defaults/policy.defaults.yaml +39 -3
- package/agentic/orchestrator/gates.yaml +15 -3
- package/agentic/orchestrator/policy.yaml +47 -3
- package/agentic/orchestrator/prompts/builder.system.md +69 -20
- package/agentic/orchestrator/prompts/planner-intake.system.md +149 -0
- package/agentic/orchestrator/prompts/planner.system.md +113 -40
- package/agentic/orchestrator/prompts/qa.system.md +73 -18
- package/agentic/orchestrator/prompts/reconciler.system.md +119 -0
- package/agentic/orchestrator/schemas/agents.schema.json +89 -1
- package/agentic/orchestrator/schemas/execution-control.schema.json +242 -0
- package/agentic/orchestrator/schemas/index.schema.json +234 -0
- package/agentic/orchestrator/schemas/intake.review.schema.json +82 -0
- package/agentic/orchestrator/schemas/organizer-ordering-artifact.schema.json +75 -0
- package/agentic/orchestrator/schemas/plan.schema.json +44 -0
- package/agentic/orchestrator/schemas/policy.schema.json +238 -9
- package/agentic/orchestrator/schemas/policy.user.schema.json +129 -1
- package/agentic/orchestrator/schemas/spec.manifest.bootstrap.schema.json +101 -0
- package/agentic/orchestrator/schemas/spec.manifest.verified.schema.json +80 -0
- package/agentic/orchestrator/schemas/state.schema.json +298 -3
- package/agentic/orchestrator/tools/catalog.json +145 -15
- package/agentic/orchestrator/tools/schemas/input/doctor.run.input.schema.json +18 -0
- package/agentic/orchestrator/tools/schemas/input/evidence.latest.input.schema.json +4 -0
- package/agentic/orchestrator/tools/schemas/input/evidence.verify_chain.input.schema.json +13 -0
- package/agentic/orchestrator/tools/schemas/input/feature.intake_submit.input.schema.json +11 -0
- package/agentic/orchestrator/tools/schemas/input/feature.question_answer.input.schema.json +15 -0
- package/agentic/orchestrator/tools/schemas/input/feature.question_create.input.schema.json +21 -0
- package/agentic/orchestrator/tools/schemas/input/feature.question_list.input.schema.json +13 -0
- package/agentic/orchestrator/tools/schemas/input/feature.ready_to_merge.input.schema.json +5 -0
- package/agentic/orchestrator/tools/schemas/input/feature.send_message.input.schema.json +1 -1
- package/agentic/orchestrator/tools/schemas/input/replay.timeline_get.input.schema.json +32 -0
- package/agentic/orchestrator/tools/schemas/input/repo.conflict_abort.input.schema.json +16 -0
- package/agentic/orchestrator/tools/schemas/input/repo.conflict_files.input.schema.json +16 -0
- package/agentic/orchestrator/tools/schemas/input/repo.reconcile_mainline.input.schema.json +37 -0
- package/agentic/orchestrator/tools/schemas/input/repo.resolve_conflict.input.schema.json +40 -0
- package/agentic/orchestrator/tools/schemas/input/runtime.execution_request_list.input.schema.json +7 -0
- package/agentic/orchestrator/tools/schemas/input/runtime.execution_request_submit.input.schema.json +25 -0
- package/agentic/orchestrator/tools/schemas/output/doctor.run.output.schema.json +34 -0
- package/agentic/orchestrator/tools/schemas/output/evidence.verify_chain.output.schema.json +23 -0
- package/agentic/orchestrator/tools/schemas/output/feature.get_context.output.schema.json +62 -2
- package/agentic/orchestrator/tools/schemas/output/feature.intake_submit.output.schema.json +24 -0
- package/agentic/orchestrator/tools/schemas/output/feature.question_answer.output.schema.json +21 -0
- package/agentic/orchestrator/tools/schemas/output/feature.question_create.output.schema.json +12 -0
- package/agentic/orchestrator/tools/schemas/output/feature.question_list.output.schema.json +14 -0
- package/agentic/orchestrator/tools/schemas/output/feature.ready_to_merge.output.schema.json +31 -0
- package/agentic/orchestrator/tools/schemas/output/feature.send_message.output.schema.json +8 -18
- package/agentic/orchestrator/tools/schemas/output/replay.timeline_get.output.schema.json +64 -0
- package/agentic/orchestrator/tools/schemas/output/repo.conflict_abort.output.schema.json +16 -0
- package/agentic/orchestrator/tools/schemas/output/repo.conflict_files.output.schema.json +22 -0
- package/agentic/orchestrator/tools/schemas/output/repo.reconcile_mainline.output.schema.json +61 -0
- package/agentic/orchestrator/tools/schemas/output/repo.resolve_conflict.output.schema.json +19 -0
- package/agentic/orchestrator/tools/schemas/output/report.dashboard.output.schema.json +26 -0
- package/agentic/orchestrator/tools/schemas/output/runtime.execution_request_list.output.schema.json +17 -0
- package/agentic/orchestrator/tools/schemas/output/runtime.execution_request_submit.output.schema.json +24 -0
- package/agentic/orchestrator/tools.md +13 -0
- package/apps/control-plane/scripts/validate-mcp-contracts.ts +1 -1
- package/apps/control-plane/src/application/kernel-tool-wiring.ts +140 -2
- package/apps/control-plane/src/application/services/activity-monitor-service.ts +44 -1
- package/apps/control-plane/src/application/services/bootstrap-manifest-generator-service.ts +251 -0
- package/apps/control-plane/src/application/services/checkpoint-service.ts +87 -27
- package/apps/control-plane/src/application/services/collision-override-service.ts +906 -0
- package/apps/control-plane/src/application/services/collision-queue-service.ts +129 -38
- package/apps/control-plane/src/application/services/cost-tracking-service.ts +94 -0
- package/apps/control-plane/src/application/services/execution-control-service.ts +599 -0
- package/apps/control-plane/src/application/services/feature-deletion-service.ts +37 -1
- package/apps/control-plane/src/application/services/feature-lifecycle-service.ts +182 -4
- package/apps/control-plane/src/application/services/feature-send-message-service.ts +17 -8
- package/apps/control-plane/src/application/services/feature-state-service.ts +191 -6
- package/apps/control-plane/src/application/services/gate-service.ts +121 -2
- package/apps/control-plane/src/application/services/git-reconciliation-service.ts +1591 -0
- package/apps/control-plane/src/application/services/intake-service.ts +1468 -0
- package/apps/control-plane/src/application/services/merge-service.ts +308 -17
- package/apps/control-plane/src/application/services/notifier-service.ts +3 -1
- package/apps/control-plane/src/application/services/performance-analytics-service.ts +75 -0
- package/apps/control-plane/src/application/services/plan-service.ts +336 -20
- package/apps/control-plane/src/application/services/question-service.ts +693 -0
- package/apps/control-plane/src/application/services/reactions-service.ts +73 -17
- package/apps/control-plane/src/application/services/replay-timeline-service.ts +295 -0
- package/apps/control-plane/src/application/services/reporting-service.ts +194 -10
- package/apps/control-plane/src/application/services/run-lease-service.ts +121 -5
- package/apps/control-plane/src/application/services/worktree-watchdog-service.ts +95 -8
- package/apps/control-plane/src/application/tools/tool-metadata.ts +7 -0
- package/apps/control-plane/src/application/usage-types.ts +138 -0
- package/apps/control-plane/src/cli/add-command-handler.ts +162 -0
- package/apps/control-plane/src/cli/answer-command-handler.ts +113 -0
- package/apps/control-plane/src/cli/attach-command-handler.ts +12 -3
- package/apps/control-plane/src/cli/cli-argument-parser.ts +133 -11
- package/apps/control-plane/src/cli/collision-command-handler.ts +113 -0
- package/apps/control-plane/src/cli/command-catalog.ts +479 -0
- package/apps/control-plane/src/cli/complete-command-handler.ts +23 -0
- package/apps/control-plane/src/cli/completion-command-handler.ts +25 -0
- package/apps/control-plane/src/cli/completion-resolver.ts +319 -0
- package/apps/control-plane/src/cli/completion-shell-renderer.ts +58 -0
- package/apps/control-plane/src/cli/dashboard-command-handler.ts +110 -1
- package/apps/control-plane/src/cli/dashboard-runtime-runner.ts +1036 -0
- package/apps/control-plane/src/cli/dashboard-runtime.ts +31 -0
- package/apps/control-plane/src/cli/help-command-handler.ts +17 -185
- package/apps/control-plane/src/cli/init-command-handler.ts +51 -6
- package/apps/control-plane/src/cli/merge-command-handler.ts +200 -0
- package/apps/control-plane/src/cli/questions-command-handler.ts +70 -0
- package/apps/control-plane/src/cli/replay-command-handler.ts +98 -0
- package/apps/control-plane/src/cli/resume-command-handler.ts +231 -16
- package/apps/control-plane/src/cli/retry-command-handler.ts +229 -17
- package/apps/control-plane/src/cli/retry-resume-decision.ts +75 -0
- package/apps/control-plane/src/cli/rollback-command-handler.ts +4 -2
- package/apps/control-plane/src/cli/run-command-handler.ts +35 -1
- package/apps/control-plane/src/cli/spec-ingestion-service.ts +45 -55
- package/apps/control-plane/src/cli/spec-preparation.ts +114 -0
- package/apps/control-plane/src/cli/spec-utils.ts +90 -11
- package/apps/control-plane/src/cli/status-command-handler.ts +122 -0
- package/apps/control-plane/src/cli/types.ts +41 -3
- package/apps/control-plane/src/core/collisions.ts +150 -31
- package/apps/control-plane/src/core/constants.ts +18 -1
- package/apps/control-plane/src/core/error-codes.ts +39 -0
- package/apps/control-plane/src/core/execution-control.ts +56 -0
- package/apps/control-plane/src/core/feature-resume-phase.ts +118 -0
- package/apps/control-plane/src/core/gate-freshness.ts +359 -0
- package/apps/control-plane/src/core/gate-log-extractor.ts +97 -0
- package/apps/control-plane/src/core/gates.ts +90 -1
- package/apps/control-plane/src/core/intake-artifacts.ts +295 -0
- package/apps/control-plane/src/core/kernel-types.ts +11 -0
- package/apps/control-plane/src/core/kernel.ts +604 -16
- package/apps/control-plane/src/core/mainline-conflict.ts +22 -0
- package/apps/control-plane/src/core/merge-repair.ts +149 -0
- package/apps/control-plane/src/core/path-layout.ts +46 -2
- package/apps/control-plane/src/core/path-rules.ts +11 -3
- package/apps/control-plane/src/core/plan-submit-recovery.ts +130 -0
- package/apps/control-plane/src/core/questions.ts +49 -0
- package/apps/control-plane/src/core/runtime-sessions.ts +4 -0
- package/apps/control-plane/src/core/schemas.ts +40 -1
- package/apps/control-plane/src/core/tool-caller.ts +25 -1
- package/apps/control-plane/src/core/utils/index-normalizer.ts +25 -4
- package/apps/control-plane/src/core/worktree-diff.ts +66 -0
- package/apps/control-plane/src/index.ts +29 -1
- package/apps/control-plane/src/interfaces/cli/bootstrap.ts +300 -6
- package/apps/control-plane/src/mcp/kernel-tool-executor.ts +17 -0
- package/apps/control-plane/src/mcp/tool-runtime.ts +63 -4
- package/apps/control-plane/src/providers/api-worker-provider.ts +62 -15
- package/apps/control-plane/src/providers/cli-worker-provider.ts +1037 -61
- package/apps/control-plane/src/providers/output-parsers/generic-output-parser.ts +99 -1
- package/apps/control-plane/src/providers/output-parsers/types.ts +2 -0
- package/apps/control-plane/src/providers/provider-defaults.ts +116 -7
- package/apps/control-plane/src/providers/providers.ts +225 -21
- package/apps/control-plane/src/providers/worker-provider-factory.ts +26 -2
- package/apps/control-plane/src/supervisor/artifact-stager.ts +52 -0
- package/apps/control-plane/src/supervisor/build-wave-executor.ts +477 -166
- package/apps/control-plane/src/supervisor/execution-enrollment-service.ts +408 -0
- package/apps/control-plane/src/supervisor/organizer-enrollment-scheduler.ts +117 -0
- package/apps/control-plane/src/supervisor/organizer-sidecar-service.ts +394 -0
- package/apps/control-plane/src/supervisor/plan-conformance-scorer.ts +2 -5
- package/apps/control-plane/src/supervisor/planner-phase.ts +85 -0
- package/apps/control-plane/src/supervisor/planning-wave-executor.ts +993 -64
- package/apps/control-plane/src/supervisor/prompt-bundle-loader.ts +20 -1
- package/apps/control-plane/src/supervisor/qa-wave-executor.ts +384 -177
- package/apps/control-plane/src/supervisor/run-coordinator.ts +723 -20
- package/apps/control-plane/src/supervisor/runtime.ts +485 -9
- package/apps/control-plane/src/supervisor/session-orchestrator.ts +220 -1
- package/apps/control-plane/src/supervisor/types.ts +152 -1
- package/apps/control-plane/src/supervisor/worker-decision-loop.ts +1030 -92
- package/apps/control-plane/test/activity-monitor.spec.ts +76 -0
- package/apps/control-plane/test/add-command-handler.spec.ts +189 -0
- package/apps/control-plane/test/application/services/feature-state-service.spec.ts +208 -0
- package/apps/control-plane/test/artifact-stager.spec.ts +93 -0
- package/apps/control-plane/test/batch-operations.spec.ts +58 -0
- package/apps/control-plane/test/bootstrap-edge-cases.spec.ts +50 -2
- package/apps/control-plane/test/bootstrap-manifest-generator-service.spec.ts +99 -0
- package/apps/control-plane/test/bootstrap.spec.ts +177 -4
- package/apps/control-plane/test/checkpoint-service.spec.ts +977 -29
- package/apps/control-plane/test/cli-argument-parser.spec.ts +119 -0
- package/apps/control-plane/test/cli-helpers.spec.ts +1202 -12
- package/apps/control-plane/test/cli.unit.spec.ts +797 -16
- package/apps/control-plane/test/collision-command-handler.spec.ts +182 -0
- package/apps/control-plane/test/collision-override-service.spec.ts +878 -0
- package/apps/control-plane/test/collision-queue.spec.ts +430 -2
- package/apps/control-plane/test/collisions.spec.ts +209 -1
- package/apps/control-plane/test/core-utils.spec.ts +61 -0
- package/apps/control-plane/test/cost-tracking.spec.ts +224 -0
- package/apps/control-plane/test/dashboard-api.integration.spec.ts +185 -5
- package/apps/control-plane/test/dashboard-client.spec.ts +948 -0
- package/apps/control-plane/test/dashboard-command.spec.ts +138 -6
- package/apps/control-plane/test/dashboard-runtime-runner.spec.ts +1550 -0
- package/apps/control-plane/test/dashboard-runtime.spec.ts +138 -0
- package/apps/control-plane/test/dashboard-ui-utils.spec.ts +56 -12
- package/apps/control-plane/test/dependency-scheduler.spec.ts +7 -1
- package/apps/control-plane/test/env-file.spec.ts +76 -0
- package/apps/control-plane/test/execution-control-service.spec.ts +535 -0
- package/apps/control-plane/test/execution-enrollment-service.spec.ts +648 -0
- package/apps/control-plane/test/feature-lifecycle.spec.ts +126 -0
- package/apps/control-plane/test/feature-resume-phase.spec.ts +164 -0
- package/apps/control-plane/test/feature-send-message-service.spec.ts +161 -0
- package/apps/control-plane/test/feature-state-service.spec.ts +295 -0
- package/apps/control-plane/test/fs.spec.ts +80 -0
- package/apps/control-plane/test/gate-freshness.spec.ts +590 -0
- package/apps/control-plane/test/gate-log-extractor.spec.ts +170 -0
- package/apps/control-plane/test/gates.spec.ts +108 -0
- package/apps/control-plane/test/git-reconciliation-service.spec.ts +2307 -0
- package/apps/control-plane/test/helpers.ts +65 -0
- package/apps/control-plane/test/incremental-gates.spec.ts +271 -0
- package/apps/control-plane/test/index-normalizer.spec.ts +98 -0
- package/apps/control-plane/test/init-wizard.spec.ts +17 -0
- package/apps/control-plane/test/intake-artifacts.spec.ts +203 -0
- package/apps/control-plane/test/intake-service.spec.ts +3176 -0
- package/apps/control-plane/test/kernel-collision-replay.spec.ts +3 -2
- package/apps/control-plane/test/kernel-tool-executor.spec.ts +77 -0
- package/apps/control-plane/test/kernel-tool-wiring.spec.ts +279 -0
- package/apps/control-plane/test/kernel.branches.spec.ts +15 -2
- package/apps/control-plane/test/kernel.coverage.spec.ts +7 -3
- package/apps/control-plane/test/kernel.coverage2.spec.ts +731 -2
- package/apps/control-plane/test/kernel.spec.ts +464 -2
- package/apps/control-plane/test/mainline-conflict.spec.ts +66 -0
- package/apps/control-plane/test/mcp-helpers.spec.ts +79 -0
- package/apps/control-plane/test/mcp.spec.ts +177 -13
- package/apps/control-plane/test/merge-command-handler.spec.ts +531 -0
- package/apps/control-plane/test/merge-service.spec.ts +570 -4
- package/apps/control-plane/test/notifier-service.spec.ts +26 -0
- package/apps/control-plane/test/organizer-enrollment-scheduler.spec.ts +340 -0
- package/apps/control-plane/test/organizer-ordering-artifact.spec.ts +95 -0
- package/apps/control-plane/test/organizer-sidecar-service.spec.ts +468 -0
- package/apps/control-plane/test/output-loop-detector.spec.ts +6 -0
- package/apps/control-plane/test/path-layout.spec.ts +70 -0
- package/apps/control-plane/test/performance-analytics.spec.ts +124 -0
- package/apps/control-plane/test/plan-conformance-scorer.spec.ts +53 -0
- package/apps/control-plane/test/plan-service.spec.ts +686 -4
- package/apps/control-plane/test/planning-wave-executor.spec.ts +3272 -86
- package/apps/control-plane/test/policy-loader-service.spec.ts +5 -0
- package/apps/control-plane/test/prompt-overlay.spec.ts +65 -0
- package/apps/control-plane/test/provider-command-runner-epipe.spec.ts +64 -0
- package/apps/control-plane/test/providers/api-worker-provider.spec.ts +129 -0
- package/apps/control-plane/test/providers/cli-worker-provider.spec.ts +148 -0
- package/apps/control-plane/test/providers/usage-types.spec.ts +98 -0
- package/apps/control-plane/test/providers.spec.ts +293 -16
- package/apps/control-plane/test/question-command-handlers.spec.ts +156 -0
- package/apps/control-plane/test/question-service.spec.ts +1119 -0
- package/apps/control-plane/test/reactions.spec.ts +114 -0
- package/apps/control-plane/test/replay-command-handler.spec.ts +144 -0
- package/apps/control-plane/test/replay-timeline-service.spec.ts +459 -0
- package/apps/control-plane/test/response.spec.ts +31 -0
- package/apps/control-plane/test/resume-command.spec.ts +757 -9
- package/apps/control-plane/test/retry-resume-decision.spec.ts +133 -0
- package/apps/control-plane/test/rollback-command-handler.spec.ts +334 -0
- package/apps/control-plane/test/rollback-command.spec.ts +120 -0
- package/apps/control-plane/test/run-coordinator.spec.ts +3062 -404
- package/apps/control-plane/test/schemas/state.schema.spec.ts +71 -0
- package/apps/control-plane/test/service-retry-paths.spec.ts +112 -0
- package/apps/control-plane/test/services.spec.ts +472 -2
- package/apps/control-plane/test/session-management.spec.ts +346 -1
- package/apps/control-plane/test/spec-ingestion.spec.ts +102 -28
- package/apps/control-plane/test/spec-preparation.spec.ts +182 -0
- package/apps/control-plane/test/supervisor-collaborators.spec.ts +191 -3
- package/apps/control-plane/test/supervisor.calltool.spec.ts +198 -0
- package/apps/control-plane/test/supervisor.spec.ts +95 -16
- package/apps/control-plane/test/supervisor.unit.spec.ts +385 -18
- package/apps/control-plane/test/tool-runtime.spec.ts +122 -0
- package/apps/control-plane/test/worker-decision-loop.spec.ts +3479 -476
- package/apps/control-plane/test/worker-execution-policy.spec.ts +1416 -6
- package/apps/control-plane/test/worker-provider-adapters.spec.ts +1894 -37
- package/apps/control-plane/test/worker-provider-factory.spec.ts +81 -0
- package/apps/control-plane/test/worktree-watchdog-service.spec.ts +125 -0
- package/apps/control-plane/vitest.config.ts +5 -0
- package/config/agentic/orchestrator/agents.yaml +22 -1
- package/config/agentic/orchestrator/gates.yaml +24 -7
- package/config/agentic/orchestrator/policy.yaml +23 -1
- package/config/agentic/orchestrator/prompts/builder.system.md +69 -20
- package/config/agentic/orchestrator/prompts/organizer.system.md +85 -0
- package/config/agentic/orchestrator/prompts/overrides/builder.claude.md +28 -0
- package/config/agentic/orchestrator/prompts/overrides/builder.codex.md +28 -0
- package/config/agentic/orchestrator/prompts/overrides/planner.claude.md +20 -0
- package/config/agentic/orchestrator/prompts/overrides/planner.codex.md +20 -0
- package/config/agentic/orchestrator/prompts/planner-intake.system.md +149 -0
- package/config/agentic/orchestrator/prompts/planner.system.md +113 -40
- package/config/agentic/orchestrator/prompts/qa.system.md +75 -18
- package/config/agentic/orchestrator/prompts/reconciler.system.md +119 -0
- package/dist/apps/control-plane/application/kernel-tool-wiring.d.ts +26 -2
- package/dist/apps/control-plane/application/kernel-tool-wiring.js +40 -2
- package/dist/apps/control-plane/application/kernel-tool-wiring.js.map +1 -1
- package/dist/apps/control-plane/application/services/activity-monitor-service.js +37 -1
- package/dist/apps/control-plane/application/services/activity-monitor-service.js.map +1 -1
- package/dist/apps/control-plane/application/services/bootstrap-manifest-generator-service.d.ts +4 -0
- package/dist/apps/control-plane/application/services/bootstrap-manifest-generator-service.js +188 -0
- package/dist/apps/control-plane/application/services/bootstrap-manifest-generator-service.js.map +1 -0
- package/dist/apps/control-plane/application/services/checkpoint-service.d.ts +5 -0
- package/dist/apps/control-plane/application/services/checkpoint-service.js +69 -24
- package/dist/apps/control-plane/application/services/checkpoint-service.js.map +1 -1
- package/dist/apps/control-plane/application/services/collision-override-service.d.ts +139 -0
- package/dist/apps/control-plane/application/services/collision-override-service.js +568 -0
- package/dist/apps/control-plane/application/services/collision-override-service.js.map +1 -0
- package/dist/apps/control-plane/application/services/collision-queue-service.d.ts +15 -0
- package/dist/apps/control-plane/application/services/collision-queue-service.js +92 -33
- package/dist/apps/control-plane/application/services/collision-queue-service.js.map +1 -1
- package/dist/apps/control-plane/application/services/cost-tracking-service.d.ts +11 -0
- package/dist/apps/control-plane/application/services/cost-tracking-service.js +75 -0
- package/dist/apps/control-plane/application/services/cost-tracking-service.js.map +1 -1
- package/dist/apps/control-plane/application/services/execution-control-service.d.ts +75 -0
- package/dist/apps/control-plane/application/services/execution-control-service.js +421 -0
- package/dist/apps/control-plane/application/services/execution-control-service.js.map +1 -0
- package/dist/apps/control-plane/application/services/feature-deletion-service.d.ts +1 -0
- package/dist/apps/control-plane/application/services/feature-deletion-service.js +23 -1
- package/dist/apps/control-plane/application/services/feature-deletion-service.js.map +1 -1
- package/dist/apps/control-plane/application/services/feature-lifecycle-service.d.ts +24 -1
- package/dist/apps/control-plane/application/services/feature-lifecycle-service.js +132 -3
- package/dist/apps/control-plane/application/services/feature-lifecycle-service.js.map +1 -1
- package/dist/apps/control-plane/application/services/feature-send-message-service.js +16 -8
- package/dist/apps/control-plane/application/services/feature-send-message-service.js.map +1 -1
- package/dist/apps/control-plane/application/services/feature-state-service.d.ts +36 -0
- package/dist/apps/control-plane/application/services/feature-state-service.js +163 -6
- package/dist/apps/control-plane/application/services/feature-state-service.js.map +1 -1
- package/dist/apps/control-plane/application/services/gate-service.d.ts +2 -1
- package/dist/apps/control-plane/application/services/gate-service.js +95 -5
- package/dist/apps/control-plane/application/services/gate-service.js.map +1 -1
- package/dist/apps/control-plane/application/services/git-reconciliation-service.d.ts +92 -0
- package/dist/apps/control-plane/application/services/git-reconciliation-service.js +1097 -0
- package/dist/apps/control-plane/application/services/git-reconciliation-service.js.map +1 -0
- package/dist/apps/control-plane/application/services/intake-service.d.ts +63 -0
- package/dist/apps/control-plane/application/services/intake-service.js +1050 -0
- package/dist/apps/control-plane/application/services/intake-service.js.map +1 -0
- package/dist/apps/control-plane/application/services/merge-service.d.ts +5 -1
- package/dist/apps/control-plane/application/services/merge-service.js +233 -18
- package/dist/apps/control-plane/application/services/merge-service.js.map +1 -1
- package/dist/apps/control-plane/application/services/notifier-service.d.ts +1 -1
- package/dist/apps/control-plane/application/services/notifier-service.js +1 -0
- package/dist/apps/control-plane/application/services/notifier-service.js.map +1 -1
- package/dist/apps/control-plane/application/services/performance-analytics-service.d.ts +11 -0
- package/dist/apps/control-plane/application/services/performance-analytics-service.js +59 -0
- package/dist/apps/control-plane/application/services/performance-analytics-service.js.map +1 -1
- package/dist/apps/control-plane/application/services/plan-service.d.ts +5 -0
- package/dist/apps/control-plane/application/services/plan-service.js +254 -15
- package/dist/apps/control-plane/application/services/plan-service.js.map +1 -1
- package/dist/apps/control-plane/application/services/question-service.d.ts +72 -0
- package/dist/apps/control-plane/application/services/question-service.js +507 -0
- package/dist/apps/control-plane/application/services/question-service.js.map +1 -0
- package/dist/apps/control-plane/application/services/reactions-service.d.ts +2 -0
- package/dist/apps/control-plane/application/services/reactions-service.js +60 -17
- package/dist/apps/control-plane/application/services/reactions-service.js.map +1 -1
- package/dist/apps/control-plane/application/services/replay-timeline-service.d.ts +39 -0
- package/dist/apps/control-plane/application/services/replay-timeline-service.js +205 -0
- package/dist/apps/control-plane/application/services/replay-timeline-service.js.map +1 -0
- package/dist/apps/control-plane/application/services/reporting-service.d.ts +59 -0
- package/dist/apps/control-plane/application/services/reporting-service.js +121 -9
- package/dist/apps/control-plane/application/services/reporting-service.js.map +1 -1
- package/dist/apps/control-plane/application/services/run-lease-service.d.ts +20 -0
- package/dist/apps/control-plane/application/services/run-lease-service.js +81 -4
- package/dist/apps/control-plane/application/services/run-lease-service.js.map +1 -1
- package/dist/apps/control-plane/application/services/worktree-watchdog-service.d.ts +10 -0
- package/dist/apps/control-plane/application/services/worktree-watchdog-service.js +65 -8
- package/dist/apps/control-plane/application/services/worktree-watchdog-service.js.map +1 -1
- package/dist/apps/control-plane/application/tools/tool-metadata.js +7 -0
- package/dist/apps/control-plane/application/tools/tool-metadata.js.map +1 -1
- package/dist/apps/control-plane/application/usage-types.d.ts +65 -0
- package/dist/apps/control-plane/application/usage-types.js +75 -0
- package/dist/apps/control-plane/application/usage-types.js.map +1 -0
- package/dist/apps/control-plane/cli/add-command-handler.d.ts +18 -0
- package/dist/apps/control-plane/cli/add-command-handler.js +110 -0
- package/dist/apps/control-plane/cli/add-command-handler.js.map +1 -0
- package/dist/apps/control-plane/cli/answer-command-handler.d.ts +8 -0
- package/dist/apps/control-plane/cli/answer-command-handler.js +96 -0
- package/dist/apps/control-plane/cli/answer-command-handler.js.map +1 -0
- package/dist/apps/control-plane/cli/attach-command-handler.js +8 -3
- package/dist/apps/control-plane/cli/attach-command-handler.js.map +1 -1
- package/dist/apps/control-plane/cli/cli-argument-parser.js +131 -11
- package/dist/apps/control-plane/cli/cli-argument-parser.js.map +1 -1
- package/dist/apps/control-plane/cli/collision-command-handler.d.ts +8 -0
- package/dist/apps/control-plane/cli/collision-command-handler.js +90 -0
- package/dist/apps/control-plane/cli/collision-command-handler.js.map +1 -0
- package/dist/apps/control-plane/cli/command-catalog.d.ts +21 -0
- package/dist/apps/control-plane/cli/command-catalog.js +416 -0
- package/dist/apps/control-plane/cli/command-catalog.js.map +1 -0
- package/dist/apps/control-plane/cli/complete-command-handler.d.ts +15 -0
- package/dist/apps/control-plane/cli/complete-command-handler.js +26 -0
- package/dist/apps/control-plane/cli/complete-command-handler.js.map +1 -0
- package/dist/apps/control-plane/cli/completion-command-handler.d.ts +8 -0
- package/dist/apps/control-plane/cli/completion-command-handler.js +20 -0
- package/dist/apps/control-plane/cli/completion-command-handler.js.map +1 -0
- package/dist/apps/control-plane/cli/completion-resolver.d.ts +1 -0
- package/dist/apps/control-plane/cli/completion-resolver.js +250 -0
- package/dist/apps/control-plane/cli/completion-resolver.js.map +1 -0
- package/dist/apps/control-plane/cli/completion-shell-renderer.d.ts +3 -0
- package/dist/apps/control-plane/cli/completion-shell-renderer.js +53 -0
- package/dist/apps/control-plane/cli/completion-shell-renderer.js.map +1 -0
- package/dist/apps/control-plane/cli/dashboard-command-handler.d.ts +1 -0
- package/dist/apps/control-plane/cli/dashboard-command-handler.js +83 -1
- package/dist/apps/control-plane/cli/dashboard-command-handler.js.map +1 -1
- package/dist/apps/control-plane/cli/dashboard-runtime-runner.d.ts +81 -0
- package/dist/apps/control-plane/cli/dashboard-runtime-runner.js +724 -0
- package/dist/apps/control-plane/cli/dashboard-runtime-runner.js.map +1 -0
- package/dist/apps/control-plane/cli/dashboard-runtime.d.ts +1 -0
- package/dist/apps/control-plane/cli/dashboard-runtime.js +26 -0
- package/dist/apps/control-plane/cli/dashboard-runtime.js.map +1 -0
- package/dist/apps/control-plane/cli/help-command-handler.js +13 -172
- package/dist/apps/control-plane/cli/help-command-handler.js.map +1 -1
- package/dist/apps/control-plane/cli/init-command-handler.js +51 -6
- package/dist/apps/control-plane/cli/init-command-handler.js.map +1 -1
- package/dist/apps/control-plane/cli/merge-command-handler.d.ts +8 -0
- package/dist/apps/control-plane/cli/merge-command-handler.js +139 -0
- package/dist/apps/control-plane/cli/merge-command-handler.js.map +1 -0
- package/dist/apps/control-plane/cli/questions-command-handler.d.ts +8 -0
- package/dist/apps/control-plane/cli/questions-command-handler.js +59 -0
- package/dist/apps/control-plane/cli/questions-command-handler.js.map +1 -0
- package/dist/apps/control-plane/cli/replay-command-handler.d.ts +15 -0
- package/dist/apps/control-plane/cli/replay-command-handler.js +55 -0
- package/dist/apps/control-plane/cli/replay-command-handler.js.map +1 -0
- package/dist/apps/control-plane/cli/resume-command-handler.d.ts +2 -0
- package/dist/apps/control-plane/cli/resume-command-handler.js +180 -17
- package/dist/apps/control-plane/cli/resume-command-handler.js.map +1 -1
- package/dist/apps/control-plane/cli/retry-command-handler.js +202 -16
- package/dist/apps/control-plane/cli/retry-command-handler.js.map +1 -1
- package/dist/apps/control-plane/cli/retry-resume-decision.d.ts +26 -0
- package/dist/apps/control-plane/cli/retry-resume-decision.js +61 -0
- package/dist/apps/control-plane/cli/retry-resume-decision.js.map +1 -0
- package/dist/apps/control-plane/cli/rollback-command-handler.js +3 -2
- package/dist/apps/control-plane/cli/rollback-command-handler.js.map +1 -1
- package/dist/apps/control-plane/cli/run-command-handler.js +26 -2
- package/dist/apps/control-plane/cli/run-command-handler.js.map +1 -1
- package/dist/apps/control-plane/cli/spec-ingestion-service.d.ts +2 -0
- package/dist/apps/control-plane/cli/spec-ingestion-service.js +37 -48
- package/dist/apps/control-plane/cli/spec-ingestion-service.js.map +1 -1
- package/dist/apps/control-plane/cli/spec-preparation.d.ts +14 -0
- package/dist/apps/control-plane/cli/spec-preparation.js +81 -0
- package/dist/apps/control-plane/cli/spec-preparation.js.map +1 -0
- package/dist/apps/control-plane/cli/spec-utils.d.ts +4 -0
- package/dist/apps/control-plane/cli/spec-utils.js +70 -11
- package/dist/apps/control-plane/cli/spec-utils.js.map +1 -1
- package/dist/apps/control-plane/cli/status-command-handler.js +69 -0
- package/dist/apps/control-plane/cli/status-command-handler.js.map +1 -1
- package/dist/apps/control-plane/cli/types.d.ts +41 -4
- package/dist/apps/control-plane/cli/types.js +9 -1
- package/dist/apps/control-plane/cli/types.js.map +1 -1
- package/dist/apps/control-plane/core/collisions.d.ts +37 -19
- package/dist/apps/control-plane/core/collisions.js +87 -12
- package/dist/apps/control-plane/core/collisions.js.map +1 -1
- package/dist/apps/control-plane/core/constants.d.ts +17 -1
- package/dist/apps/control-plane/core/constants.js +18 -1
- package/dist/apps/control-plane/core/constants.js.map +1 -1
- package/dist/apps/control-plane/core/error-codes.d.ts +39 -0
- package/dist/apps/control-plane/core/error-codes.js +39 -0
- package/dist/apps/control-plane/core/error-codes.js.map +1 -1
- package/dist/apps/control-plane/core/execution-control.d.ts +45 -0
- package/dist/apps/control-plane/core/execution-control.js +2 -0
- package/dist/apps/control-plane/core/execution-control.js.map +1 -0
- package/dist/apps/control-plane/core/feature-resume-phase.d.ts +3 -0
- package/dist/apps/control-plane/core/feature-resume-phase.js +88 -0
- package/dist/apps/control-plane/core/feature-resume-phase.js.map +1 -0
- package/dist/apps/control-plane/core/gate-freshness.d.ts +48 -0
- package/dist/apps/control-plane/core/gate-freshness.js +267 -0
- package/dist/apps/control-plane/core/gate-freshness.js.map +1 -0
- package/dist/apps/control-plane/core/gate-log-extractor.d.ts +22 -0
- package/dist/apps/control-plane/core/gate-log-extractor.js +66 -0
- package/dist/apps/control-plane/core/gate-log-extractor.js.map +1 -0
- package/dist/apps/control-plane/core/gates.d.ts +11 -2
- package/dist/apps/control-plane/core/gates.js +67 -3
- package/dist/apps/control-plane/core/gates.js.map +1 -1
- package/dist/apps/control-plane/core/intake-artifacts.d.ts +109 -0
- package/dist/apps/control-plane/core/intake-artifacts.js +143 -0
- package/dist/apps/control-plane/core/intake-artifacts.js.map +1 -0
- package/dist/apps/control-plane/core/kernel-types.d.ts +8 -0
- package/dist/apps/control-plane/core/kernel.d.ts +256 -8
- package/dist/apps/control-plane/core/kernel.js +400 -14
- package/dist/apps/control-plane/core/kernel.js.map +1 -1
- package/dist/apps/control-plane/core/mainline-conflict.d.ts +7 -0
- package/dist/apps/control-plane/core/mainline-conflict.js +20 -0
- package/dist/apps/control-plane/core/mainline-conflict.js.map +1 -0
- package/dist/apps/control-plane/core/merge-repair.d.ts +35 -0
- package/dist/apps/control-plane/core/merge-repair.js +99 -0
- package/dist/apps/control-plane/core/merge-repair.js.map +1 -0
- package/dist/apps/control-plane/core/path-layout.d.ts +10 -0
- package/dist/apps/control-plane/core/path-layout.js +32 -2
- package/dist/apps/control-plane/core/path-layout.js.map +1 -1
- package/dist/apps/control-plane/core/path-rules.js +9 -3
- package/dist/apps/control-plane/core/path-rules.js.map +1 -1
- package/dist/apps/control-plane/core/plan-submit-recovery.d.ts +22 -0
- package/dist/apps/control-plane/core/plan-submit-recovery.js +78 -0
- package/dist/apps/control-plane/core/plan-submit-recovery.js.map +1 -0
- package/dist/apps/control-plane/core/questions.d.ts +40 -0
- package/dist/apps/control-plane/core/questions.js +2 -0
- package/dist/apps/control-plane/core/questions.js.map +1 -0
- package/dist/apps/control-plane/core/runtime-sessions.d.ts +4 -0
- package/dist/apps/control-plane/core/schemas.d.ts +2 -0
- package/dist/apps/control-plane/core/schemas.js +31 -1
- package/dist/apps/control-plane/core/schemas.js.map +1 -1
- package/dist/apps/control-plane/core/tool-caller.d.ts +18 -1
- package/dist/apps/control-plane/core/utils/index-normalizer.js +17 -4
- package/dist/apps/control-plane/core/utils/index-normalizer.js.map +1 -1
- package/dist/apps/control-plane/core/worktree-diff.d.ts +4 -0
- package/dist/apps/control-plane/core/worktree-diff.js +52 -0
- package/dist/apps/control-plane/core/worktree-diff.js.map +1 -0
- package/dist/apps/control-plane/index.d.ts +10 -2
- package/dist/apps/control-plane/index.js +9 -2
- package/dist/apps/control-plane/index.js.map +1 -1
- package/dist/apps/control-plane/interfaces/cli/bootstrap.js +236 -6
- package/dist/apps/control-plane/interfaces/cli/bootstrap.js.map +1 -1
- package/dist/apps/control-plane/mcp/kernel-tool-executor.js +16 -0
- package/dist/apps/control-plane/mcp/kernel-tool-executor.js.map +1 -1
- package/dist/apps/control-plane/mcp/tool-runtime.d.ts +5 -0
- package/dist/apps/control-plane/mcp/tool-runtime.js +40 -5
- package/dist/apps/control-plane/mcp/tool-runtime.js.map +1 -1
- package/dist/apps/control-plane/providers/api-worker-provider.d.ts +2 -2
- package/dist/apps/control-plane/providers/api-worker-provider.js +40 -9
- package/dist/apps/control-plane/providers/api-worker-provider.js.map +1 -1
- package/dist/apps/control-plane/providers/cli-worker-provider.d.ts +59 -3
- package/dist/apps/control-plane/providers/cli-worker-provider.js +758 -46
- package/dist/apps/control-plane/providers/cli-worker-provider.js.map +1 -1
- package/dist/apps/control-plane/providers/output-parsers/generic-output-parser.js +91 -1
- package/dist/apps/control-plane/providers/output-parsers/generic-output-parser.js.map +1 -1
- package/dist/apps/control-plane/providers/output-parsers/types.d.ts +2 -0
- package/dist/apps/control-plane/providers/provider-defaults.d.ts +12 -0
- package/dist/apps/control-plane/providers/provider-defaults.js +103 -7
- package/dist/apps/control-plane/providers/provider-defaults.js.map +1 -1
- package/dist/apps/control-plane/providers/providers.d.ts +50 -4
- package/dist/apps/control-plane/providers/providers.js +145 -14
- package/dist/apps/control-plane/providers/providers.js.map +1 -1
- package/dist/apps/control-plane/providers/worker-provider-factory.d.ts +2 -0
- package/dist/apps/control-plane/providers/worker-provider-factory.js +8 -1
- package/dist/apps/control-plane/providers/worker-provider-factory.js.map +1 -1
- package/dist/apps/control-plane/supervisor/artifact-stager.d.ts +5 -0
- package/dist/apps/control-plane/supervisor/artifact-stager.js +45 -0
- package/dist/apps/control-plane/supervisor/artifact-stager.js.map +1 -0
- package/dist/apps/control-plane/supervisor/build-wave-executor.d.ts +24 -1
- package/dist/apps/control-plane/supervisor/build-wave-executor.js +362 -150
- package/dist/apps/control-plane/supervisor/build-wave-executor.js.map +1 -1
- package/dist/apps/control-plane/supervisor/execution-enrollment-service.d.ts +41 -0
- package/dist/apps/control-plane/supervisor/execution-enrollment-service.js +311 -0
- package/dist/apps/control-plane/supervisor/execution-enrollment-service.js.map +1 -0
- package/dist/apps/control-plane/supervisor/organizer-enrollment-scheduler.d.ts +15 -0
- package/dist/apps/control-plane/supervisor/organizer-enrollment-scheduler.js +93 -0
- package/dist/apps/control-plane/supervisor/organizer-enrollment-scheduler.js.map +1 -0
- package/dist/apps/control-plane/supervisor/organizer-sidecar-service.d.ts +44 -0
- package/dist/apps/control-plane/supervisor/organizer-sidecar-service.js +311 -0
- package/dist/apps/control-plane/supervisor/organizer-sidecar-service.js.map +1 -0
- package/dist/apps/control-plane/supervisor/plan-conformance-scorer.js +2 -5
- package/dist/apps/control-plane/supervisor/plan-conformance-scorer.js.map +1 -1
- package/dist/apps/control-plane/supervisor/planner-phase.d.ts +3 -0
- package/dist/apps/control-plane/supervisor/planner-phase.js +70 -0
- package/dist/apps/control-plane/supervisor/planner-phase.js.map +1 -0
- package/dist/apps/control-plane/supervisor/planning-wave-executor.d.ts +42 -0
- package/dist/apps/control-plane/supervisor/planning-wave-executor.js +753 -55
- package/dist/apps/control-plane/supervisor/planning-wave-executor.js.map +1 -1
- package/dist/apps/control-plane/supervisor/prompt-bundle-loader.js +19 -1
- package/dist/apps/control-plane/supervisor/prompt-bundle-loader.js.map +1 -1
- package/dist/apps/control-plane/supervisor/qa-wave-executor.d.ts +21 -0
- package/dist/apps/control-plane/supervisor/qa-wave-executor.js +287 -156
- package/dist/apps/control-plane/supervisor/qa-wave-executor.js.map +1 -1
- package/dist/apps/control-plane/supervisor/run-coordinator.d.ts +30 -1
- package/dist/apps/control-plane/supervisor/run-coordinator.js +561 -17
- package/dist/apps/control-plane/supervisor/run-coordinator.js.map +1 -1
- package/dist/apps/control-plane/supervisor/runtime.d.ts +84 -0
- package/dist/apps/control-plane/supervisor/runtime.js +393 -3
- package/dist/apps/control-plane/supervisor/runtime.js.map +1 -1
- package/dist/apps/control-plane/supervisor/session-orchestrator.d.ts +54 -0
- package/dist/apps/control-plane/supervisor/session-orchestrator.js +176 -1
- package/dist/apps/control-plane/supervisor/session-orchestrator.js.map +1 -1
- package/dist/apps/control-plane/supervisor/types.d.ts +142 -1
- package/dist/apps/control-plane/supervisor/types.js.map +1 -1
- package/dist/apps/control-plane/supervisor/worker-decision-loop.d.ts +68 -2
- package/dist/apps/control-plane/supervisor/worker-decision-loop.js +723 -89
- package/dist/apps/control-plane/supervisor/worker-decision-loop.js.map +1 -1
- package/docs/core/ARCHITECTURE.md +227 -0
- package/docs/core/DECISIONS.md +94 -0
- package/docs/core/DOMAIN-LOGIC.md +60 -0
- package/docs/core/PATTERNS.md +201 -0
- package/docs/core/TROUBLESHOOTING.md +347 -0
- package/docs/core/intentgraph-dependencies.json +39860 -0
- package/docs/core/intentgraph.index.json +46580 -0
- package/docs/plans/2026-03-10-gate-failure-targeted-repair-design.md +224 -0
- package/docs/plans/2026-03-10-gate-failure-targeted-repair.md +1032 -0
- package/docs/superpowers/plans/2026-03-16-provider-cli-config.md +743 -0
- package/docs/superpowers/plans/2026-03-23-reconcile-divergence-fix.md +777 -0
- package/docs/superpowers/plans/2026-03-28-ordering-agent-implementation.md +1754 -0
- package/docs/superpowers/plans/2026-03-29-drop-zone-and-provider-optimization.md +1108 -0
- package/docs/superpowers/plans/2026-03-29-merge-target-feature-branch.md +685 -0
- package/docs/superpowers/plans/2026-03-29-organizer-sidecar-runtime-loop.md +1289 -0
- package/docs/superpowers/specs/2026-03-23-reconcile-divergence-fix-design.md +118 -0
- package/docs/superpowers/specs/2026-03-28-ordering-agent-spec-audit-design.md +50 -0
- package/docs/superpowers/specs/2026-03-29-drop-zone-and-provider-optimization-design.md +254 -0
- package/docs/superpowers/specs/2026-03-29-merge-target-feature-branch-design.md +152 -0
- package/docs/superpowers/specs/2026-03-29-organizer-sidecar-runtime-loop-design.md +225 -0
- package/package.json +3 -2
- package/packages/web-dashboard/package.json +2 -1
- package/packages/web-dashboard/src/app/analytics/page.tsx +36 -2
- package/packages/web-dashboard/src/app/api/actions/route.ts +274 -63
- package/packages/web-dashboard/src/app/api/actions/status/route.ts +35 -0
- package/packages/web-dashboard/src/app/api/analytics/provider/route.ts +18 -0
- package/packages/web-dashboard/src/app/api/collisions/approve/route.ts +58 -0
- package/packages/web-dashboard/src/app/api/features/[id]/checkpoint-diff/route.ts +36 -0
- package/packages/web-dashboard/src/app/api/features/[id]/checkpoints/route.ts +29 -0
- package/packages/web-dashboard/src/app/api/features/[id]/conflicts/abort/route.ts +29 -0
- package/packages/web-dashboard/src/app/api/features/[id]/conflicts/files/route.ts +30 -0
- package/packages/web-dashboard/src/app/api/features/[id]/conflicts/resolve/route.ts +51 -0
- package/packages/web-dashboard/src/app/api/features/[id]/conflicts/route.ts +75 -0
- package/packages/web-dashboard/src/app/api/features/[id]/diff/route.ts +16 -2
- package/packages/web-dashboard/src/app/api/features/[id]/files/route.ts +26 -0
- package/packages/web-dashboard/src/app/api/features/[id]/gate-history/route.ts +27 -0
- package/packages/web-dashboard/src/app/api/features/[id]/genealogy/route.ts +26 -0
- package/packages/web-dashboard/src/app/api/features/[id]/history/run/[runId]/route.ts +20 -0
- package/packages/web-dashboard/src/app/api/features/[id]/history/runs/route.ts +34 -0
- package/packages/web-dashboard/src/app/api/features/[id]/intake-workspace/route.ts +20 -0
- package/packages/web-dashboard/src/app/api/features/[id]/live-output/route.ts +74 -0
- package/packages/web-dashboard/src/app/api/features/[id]/plan/amend/route.ts +21 -0
- package/packages/web-dashboard/src/app/api/features/[id]/plan-progress/route.ts +20 -0
- package/packages/web-dashboard/src/app/api/features/[id]/planner-artifacts/[artifact]/route.ts +78 -0
- package/packages/web-dashboard/src/app/api/features/[id]/planner-lifecycle/route.ts +20 -0
- package/packages/web-dashboard/src/app/api/features/[id]/planning-workspace/route.ts +20 -0
- package/packages/web-dashboard/src/app/api/features/[id]/questions/[questionId]/answer/route.ts +27 -0
- package/packages/web-dashboard/src/app/api/features/[id]/questions/route.ts +18 -0
- package/packages/web-dashboard/src/app/api/features/[id]/review/route.ts +14 -7
- package/packages/web-dashboard/src/app/api/features/[id]/route.ts +57 -2
- package/packages/web-dashboard/src/app/api/features/[id]/spec/route.ts +30 -0
- package/packages/web-dashboard/src/app/api/features/[id]/triage/route.ts +83 -0
- package/packages/web-dashboard/src/app/api/features/[id]/worker-events/route.ts +40 -0
- package/packages/web-dashboard/src/app/api/launch/preview/route.ts +86 -0
- package/packages/web-dashboard/src/app/api/launch/submit/route.ts +180 -0
- package/packages/web-dashboard/src/app/api/mainline/status/route.ts +74 -0
- package/packages/web-dashboard/src/app/api/merge-queue/route.ts +13 -0
- package/packages/web-dashboard/src/app/api/policy/budget/route.ts +14 -0
- package/packages/web-dashboard/src/app/api/projects/route.ts +11 -7
- package/packages/web-dashboard/src/app/api/reconciler/queue/route.ts +47 -0
- package/packages/web-dashboard/src/app/api/run/route.ts +26 -2
- package/packages/web-dashboard/src/app/api/runtime/events/route.ts +227 -0
- package/packages/web-dashboard/src/app/api/runtime/operations/route.ts +269 -0
- package/packages/web-dashboard/src/app/api/runtime/questions/route.ts +11 -0
- package/packages/web-dashboard/src/app/api/runtime/runs/route.ts +80 -0
- package/packages/web-dashboard/src/app/api/status/route.ts +4 -2
- package/packages/web-dashboard/src/app/feature/[id]/page.tsx +32 -42
- package/packages/web-dashboard/src/app/globals.css +34 -3
- package/packages/web-dashboard/src/app/launch/page.tsx +357 -0
- package/packages/web-dashboard/src/app/layout.tsx +23 -1
- package/packages/web-dashboard/src/app/page.tsx +263 -272
- package/packages/web-dashboard/src/components/dashboard/attention-strip.tsx +52 -0
- package/packages/web-dashboard/src/components/dashboard/collision-approval-drawer.tsx +185 -0
- package/packages/web-dashboard/src/components/dashboard/command-center-header.tsx +102 -0
- package/packages/web-dashboard/src/components/dashboard/mainline-status-banner.tsx +84 -0
- package/packages/web-dashboard/src/components/dashboard/merged-archive.tsx +36 -0
- package/packages/web-dashboard/src/components/dashboard/prioritized-queues.tsx +98 -0
- package/packages/web-dashboard/src/components/dashboard/reconciler-queue-card.tsx +115 -0
- package/packages/web-dashboard/src/components/dashboard/secondary-diagnostics-rail.tsx +48 -0
- package/packages/web-dashboard/src/components/dashboard/task-filter-bar.tsx +74 -0
- package/packages/web-dashboard/src/components/dashboard/triage-drawer.tsx +455 -0
- package/packages/web-dashboard/src/components/diff-viewer.tsx +19 -3
- package/packages/web-dashboard/src/components/evidence-viewer.tsx +65 -51
- package/packages/web-dashboard/src/components/feature-card.tsx +90 -7
- package/packages/web-dashboard/src/components/feature-cost-panel.tsx +112 -11
- package/packages/web-dashboard/src/components/feature-list-view.tsx +25 -4
- package/packages/web-dashboard/src/components/features/runtime-inspector/EventsTimelineView.tsx +260 -0
- package/packages/web-dashboard/src/components/features/runtime-inspector/OperationsListView.tsx +172 -0
- package/packages/web-dashboard/src/components/features/runtime-inspector/RuntimeInspectorPanel.tsx +896 -0
- package/packages/web-dashboard/src/components/filter-bar.tsx +7 -39
- package/packages/web-dashboard/src/components/focus/ActionableRiskList.tsx +46 -0
- package/packages/web-dashboard/src/components/focus/AgentRolePerformanceCard.tsx +200 -0
- package/packages/web-dashboard/src/components/focus/BlockedGuidanceBanner.tsx +149 -0
- package/packages/web-dashboard/src/components/focus/CheckpointInspector.tsx +123 -0
- package/packages/web-dashboard/src/components/focus/CheckpointRail.tsx +118 -0
- package/packages/web-dashboard/src/components/focus/CheckpointScrubber.tsx +249 -0
- package/packages/web-dashboard/src/components/focus/CollisionApprovalBanner.tsx +192 -0
- package/packages/web-dashboard/src/components/focus/CollisionRadar.tsx +136 -0
- package/packages/web-dashboard/src/components/focus/ConflictStatusCard.tsx +52 -0
- package/packages/web-dashboard/src/components/focus/ContextSidebar.tsx +108 -0
- package/packages/web-dashboard/src/components/focus/DiagnosisPanel.tsx +68 -0
- package/packages/web-dashboard/src/components/focus/FeatureDecisionBanner.tsx +68 -0
- package/packages/web-dashboard/src/components/focus/FeatureQuestionAnswerPanel.tsx +167 -0
- package/packages/web-dashboard/src/components/focus/FocusHeader.tsx +54 -0
- package/packages/web-dashboard/src/components/focus/FocusLayout.tsx +283 -0
- package/packages/web-dashboard/src/components/focus/GateFlakinessSummary.tsx +144 -0
- package/packages/web-dashboard/src/components/focus/GenealogyTree.tsx +34 -0
- package/packages/web-dashboard/src/components/focus/HeroBlock.tsx +67 -0
- package/packages/web-dashboard/src/components/focus/LiveAgentConsole.tsx +277 -0
- package/packages/web-dashboard/src/components/focus/MergeQueueCard.tsx +78 -0
- package/packages/web-dashboard/src/components/focus/OperationalSummaryCard.tsx +227 -0
- package/packages/web-dashboard/src/components/focus/PinnedActions.tsx +96 -0
- package/packages/web-dashboard/src/components/focus/PlanAmendmentPanel.tsx +250 -0
- package/packages/web-dashboard/src/components/focus/PlanProgressPanel.tsx +133 -0
- package/packages/web-dashboard/src/components/focus/PlannerArtifactViewer.tsx +158 -0
- package/packages/web-dashboard/src/components/focus/PlannerLifecycleHeader.tsx +141 -0
- package/packages/web-dashboard/src/components/focus/ProgressSnapshotCard.tsx +113 -0
- package/packages/web-dashboard/src/components/focus/RecentMaterialChanges.tsx +69 -0
- package/packages/web-dashboard/src/components/focus/RoleLogViewer.tsx +436 -0
- package/packages/web-dashboard/src/components/focus/RunHistoryBrowser.tsx +62 -0
- package/packages/web-dashboard/src/components/focus/SpecViewer.tsx +172 -0
- package/packages/web-dashboard/src/components/focus/TabBar.tsx +33 -0
- package/packages/web-dashboard/src/components/focus/UsageBurnChart.tsx +212 -0
- package/packages/web-dashboard/src/components/focus/VerificationSummaryCard.tsx +122 -0
- package/packages/web-dashboard/src/components/focus/tabs/ChangesTab.tsx +325 -0
- package/packages/web-dashboard/src/components/focus/tabs/ConflictsTab.tsx +395 -0
- package/packages/web-dashboard/src/components/focus/tabs/GatesQaTab.tsx +38 -0
- package/packages/web-dashboard/src/components/focus/tabs/HistoryTab.tsx +213 -0
- package/packages/web-dashboard/src/components/focus/tabs/IntakeTab.tsx +429 -0
- package/packages/web-dashboard/src/components/focus/tabs/OverviewTab.tsx +217 -0
- package/packages/web-dashboard/src/components/focus/tabs/PlanningTab.tsx +390 -0
- package/packages/web-dashboard/src/components/focus/tabs/ReviewTab.tsx +497 -0
- package/packages/web-dashboard/src/components/focus/tabs/RuntimeTab.tsx +213 -0
- package/packages/web-dashboard/src/components/focus/tabs/TranscriptTab.tsx +315 -0
- package/packages/web-dashboard/src/components/gate-results.tsx +2 -2
- package/packages/web-dashboard/src/components/human-input-panel.tsx +33 -57
- package/packages/web-dashboard/src/components/kanban-board.tsx +4 -0
- package/packages/web-dashboard/src/components/launch/launch-draft-card.tsx +131 -0
- package/packages/web-dashboard/src/components/plan-viewer.tsx +147 -69
- package/packages/web-dashboard/src/components/quick-launch-panel.tsx +20 -47
- package/packages/web-dashboard/src/components/summary-bar.tsx +30 -76
- package/packages/web-dashboard/src/lib/aop-client.ts +2484 -36
- package/packages/web-dashboard/src/lib/blocked-state-guidance.ts +475 -0
- package/packages/web-dashboard/src/lib/collision-radar.ts +136 -0
- package/packages/web-dashboard/src/lib/dashboard-action-states.ts +204 -0
- package/packages/web-dashboard/src/lib/dashboard-runtime-client.ts +439 -0
- package/packages/web-dashboard/src/lib/dashboard-utils.ts +179 -18
- package/packages/web-dashboard/src/lib/drop-zone-utils.ts +92 -0
- package/packages/web-dashboard/src/lib/focus-detail-derivations.ts +958 -0
- package/packages/web-dashboard/src/lib/focus-view.ts +300 -0
- package/packages/web-dashboard/src/lib/health-diagnosis.ts +356 -0
- package/packages/web-dashboard/src/lib/launch-contracts.ts +77 -0
- package/packages/web-dashboard/src/lib/launch-markdown.ts +107 -0
- package/packages/web-dashboard/src/lib/launch-page-preview.ts +89 -0
- package/packages/web-dashboard/src/lib/live-feed.ts +1 -1
- package/packages/web-dashboard/src/lib/multi-project-config.ts +33 -0
- package/packages/web-dashboard/src/lib/orchestrator-tools.ts +845 -59
- package/packages/web-dashboard/src/lib/planner-workspace.ts +1285 -0
- package/packages/web-dashboard/src/lib/review-contracts.ts +5 -3
- package/packages/web-dashboard/src/lib/runtime-files.ts +285 -0
- package/packages/web-dashboard/src/lib/tool-catalog.ts +51 -0
- package/packages/web-dashboard/src/lib/types.ts +731 -3
- package/packages/web-dashboard/src/lib/usage-burn.ts +175 -0
- package/packages/web-dashboard/src/lib/worktree-diff.ts +128 -0
- package/packages/web-dashboard/src/styles/dashboard.module.css +1742 -459
- package/packages/web-dashboard/test/api/actions/route.spec.ts +675 -0
- package/packages/web-dashboard/test/api/features/diff.route.spec.ts +57 -0
- package/packages/web-dashboard/test/api/features/feature.route.spec.ts +99 -0
- package/packages/web-dashboard/test/api/features/live-output.route.spec.ts +123 -0
- package/packages/web-dashboard/test/api/features/plan-amend.route.spec.ts +95 -0
- package/packages/web-dashboard/test/api/features/planner-workspaces.route.spec.ts +162 -0
- package/packages/web-dashboard/test/api/features/question-answer.route.spec.ts +99 -0
- package/packages/web-dashboard/test/api/features/triage.route.spec.ts +195 -0
- package/packages/web-dashboard/test/api/launch/preview.route.spec.ts +149 -0
- package/packages/web-dashboard/test/api/launch/submit.route.spec.ts +382 -0
- package/packages/web-dashboard/test/api/runtime/events/route.spec.ts +164 -0
- package/packages/web-dashboard/test/api/runtime/operations/route.spec.ts +156 -0
- package/packages/web-dashboard/test/api/runtime/runs/route.spec.ts +112 -0
- package/packages/web-dashboard/test/components/changes-tab.spec.tsx +76 -0
- package/packages/web-dashboard/test/components/command-center-root.spec.tsx +87 -0
- package/packages/web-dashboard/test/components/diagnosis-panel.spec.tsx +59 -0
- package/packages/web-dashboard/test/components/feature-card.spec.tsx +45 -0
- package/packages/web-dashboard/test/components/focus-layout.spec.tsx +299 -0
- package/packages/web-dashboard/test/components/gate-results.spec.tsx +39 -0
- package/packages/web-dashboard/test/components/gates-qa-tab.spec.tsx +118 -0
- package/packages/web-dashboard/test/components/human-input-panel.spec.tsx +54 -0
- package/packages/web-dashboard/test/components/intake-tab.spec.tsx +210 -0
- package/packages/web-dashboard/test/components/kanban-board.spec.tsx +35 -0
- package/packages/web-dashboard/test/components/launch-draft-card.spec.tsx +54 -0
- package/packages/web-dashboard/test/components/launch-page.spec.tsx +79 -0
- package/packages/web-dashboard/test/components/overview-tab.spec.tsx +236 -0
- package/packages/web-dashboard/test/components/planning-tab.spec.tsx +202 -0
- package/packages/web-dashboard/test/components/review-tab.spec.tsx +169 -0
- package/packages/web-dashboard/test/components/role-log-viewer.spec.ts +42 -0
- package/packages/web-dashboard/test/components/runtime-inspector.spec.tsx +22 -0
- package/packages/web-dashboard/test/components/runtime-tab.spec.tsx +133 -0
- package/packages/web-dashboard/test/components/transcript-tab.spec.tsx +46 -0
- package/packages/web-dashboard/test/components/triage-drawer.spec.tsx +159 -0
- package/packages/web-dashboard/test/lib/aop-client.spec.ts +235 -0
- package/packages/web-dashboard/test/lib/dashboard-runtime-client.spec.ts +144 -0
- package/packages/web-dashboard/test/lib/focus-detail-derivations.spec.ts +314 -0
- package/packages/web-dashboard/test/lib/focus-view.spec.ts +248 -0
- package/packages/web-dashboard/test/lib/health-diagnosis.spec.ts +277 -0
- package/packages/web-dashboard/test/lib/launch-markdown.spec.ts +36 -0
- package/packages/web-dashboard/test/lib/multi-project-config.spec.ts +54 -0
- package/packages/web-dashboard/test/lib/orchestrator-tools.spec.ts +352 -0
- package/packages/web-dashboard/test/lib/planner-workspace.spec.ts +289 -0
- package/packages/web-dashboard/test/lib/worktree-diff.spec.ts +119 -0
- package/packages/web-dashboard/vitest.config.ts +2 -0
- package/spec-files/completed/agentic_orchestrator_add_feature_to_active_execution_spec.md +557 -0
- package/spec-files/completed/agentic_orchestrator_dashboard_command_center_redesign_spec.md +1147 -0
- package/spec-files/completed/agentic_orchestrator_execution_mode_spec.md +18 -16
- package/spec-files/completed/agentic_orchestrator_feature_focus_view_track_a_spec.md +672 -0
- package/spec-files/completed/agentic_orchestrator_feature_focus_view_track_b_spec.md +794 -0
- package/spec-files/completed/agentic_orchestrator_feature_focus_view_track_c_decision_centric_remediation_spec.md +1037 -0
- package/spec-files/completed/agentic_orchestrator_feature_focus_view_ux_redesign_spec.md +1432 -0
- package/spec-files/completed/agentic_orchestrator_focus_plan_tab_intake_planning_workspace_spec.md +921 -0
- package/spec-files/completed/agentic_orchestrator_intentional_collision_override_spec.md +584 -0
- package/spec-files/completed/agentic_orchestrator_interactive_planning_intake_and_requirements_verification_spec.md +1185 -0
- package/spec-files/completed/agentic_orchestrator_reactive_execution_enrollment_spec.md +864 -0
- package/spec-files/{outstanding → completed}/agentic_orchestrator_runtime_inspection_spec.md +92 -19
- package/spec-files/completed/agentic_orchestrator_scope_aware_run_lease_spec.md +408 -0
- package/spec-files/completed/git-reconciliation-engine.md +827 -0
- package/spec-files/outstanding/agentic_orchestrator_dashboard_quick_launch_and_control_surface_spec.md +331 -0
- package/spec-files/outstanding/agentic_orchestrator_enterprise_governance_dashboard_spec.md +16 -6
- package/spec-files/outstanding/agentic_orchestrator_evidence_integrity_doctor_spec.md +60 -9
- package/spec-files/outstanding/agentic_orchestrator_focus_plan_tab_execution_contract_workspace_spec.md +616 -0
- package/spec-files/outstanding/agentic_orchestrator_headless_standby_dashboard_runtime_spec.md +310 -0
- package/spec-files/outstanding/agentic_orchestrator_human_input_interaction_protocol_spec.md +175 -72
- package/spec-files/outstanding/agentic_orchestrator_interactive_rename_cleanup_spec.md +197 -0
- package/spec-files/outstanding/agentic_orchestrator_interactive_resume_and_reconciliation_disposition_spec.md +412 -0
- package/spec-files/outstanding/agentic_orchestrator_knowledge_canary_spec.md +166 -137
- package/spec-files/outstanding/agentic_orchestrator_observability_replay_spec.md +3 -3
- package/spec-files/outstanding/agentic_orchestrator_phase_specific_agent_profiles_and_token_telemetry_spec.md +303 -0
- package/spec-files/outstanding/agentic_orchestrator_planning_review_quality_spec.md +18 -5
- package/spec-files/outstanding/agentic_orchestrator_policy_stratification_spec.md +225 -0
- package/spec-files/outstanding/agentic_orchestrator_quality_adoption_execution_spec.md +77 -50
- package/spec-files/outstanding/agentic_orchestrator_ready_to_merge_branch_handoff_spec.md +724 -0
- package/spec-files/outstanding/agentic_orchestrator_remove_deterministic_mode_spec.md +263 -0
- package/spec-files/outstanding/agentic_orchestrator_request_more_context_and_dashboard_human_input_spec.md +456 -0
- package/spec-files/outstanding/agentic_orchestrator_spec_coverage_and_reconciliation_enforcement_spec.md +1411 -0
- package/spec-files/outstanding/agentic_orchestrator_spec_ordering_agent_spec.md +370 -0
- package/spec-files/outstanding/shadow_workspace_implementation_spec.md +1 -1
- package/spec-files/progress.md +2026 -120
- package/specs/001-runtime-inspection/checklists/requirements.md +35 -0
- package/specs/001-runtime-inspection/design.md +338 -0
- package/specs/001-runtime-inspection/spec.md +95 -0
- package/specs/002-scope-aware-lease/checklists/requirements.md +35 -0
- package/specs/002-scope-aware-lease/contracts/lease-registry.schema.json +101 -0
- package/specs/002-scope-aware-lease/data-model.md +236 -0
- package/specs/002-scope-aware-lease/plan.md +766 -0
- package/specs/002-scope-aware-lease/quickstart.md +150 -0
- package/specs/002-scope-aware-lease/research.md +135 -0
- package/specs/002-scope-aware-lease/spec.md +128 -0
- package/specs/002-scope-aware-lease/tasks.md +767 -0
- package/tsconfig.json +1 -1
- package/vitest.config.ts +28 -0
- package/ARCHITECTURE_ADHERENCE_ANALYSIS.md +0 -871
- package/packages/web-dashboard/next-env.d.ts +0 -6
- package/packages/web-dashboard/src/components/detail-panel.tsx +0 -1124
- package/packages/web-dashboard/src/components/review-workspace.tsx +0 -1162
- /package/spec-files/{outstanding → completed}/agentic_orchestrator_artifact_database_publishing_spec.md +0 -0
- /package/spec-files/{outstanding → completed}/agentic_orchestrator_cli_shell_tab_completion_spec.md +0 -0
- /package/spec-files/{outstanding → completed}/agentic_orchestrator_dashboard_diff_and_agent_console_spec.md +0 -0
- /package/spec-files/{outstanding → completed}/agentic_orchestrator_performance_improvements_spec.md +0 -0
- /package/spec-files/{outstanding → completed}/agentic_orchestrator_persistent_worker_runtime_spec.md +0 -0
- /package/spec-files/{outstanding → completed}/agentic_orchestrator_provider_auth_bootstrap_spec.md +0 -0
- /package/spec-files/{outstanding → completed}/agentic_orchestrator_real_worker_provider_execution_spec.md +0 -0
|
@@ -1,8 +1,13 @@
|
|
|
1
|
+
import fs from 'node:fs/promises';
|
|
2
|
+
import os from 'node:os';
|
|
3
|
+
import path from 'node:path';
|
|
1
4
|
import { describe, expect, it, vi } from 'vitest';
|
|
2
5
|
import { STATUS, TOOLS } from '../src/core/constants.js';
|
|
3
6
|
import { ERROR_CODES } from '../src/core/error-codes.js';
|
|
4
7
|
import { PlanningWaveExecutor } from '../src/supervisor/planning-wave-executor.js';
|
|
5
8
|
|
|
9
|
+
type ToolCall = [role: string, toolName: string, args?: Record<string, unknown>];
|
|
10
|
+
|
|
6
11
|
function basePlan(featureId: string) {
|
|
7
12
|
return {
|
|
8
13
|
feature_id: featureId,
|
|
@@ -26,9 +31,22 @@ function basePlan(featureId: string) {
|
|
|
26
31
|
};
|
|
27
32
|
}
|
|
28
33
|
|
|
34
|
+
function readLoggedNote(toolCaller: {
|
|
35
|
+
callTool: ReturnType<typeof vi.fn>;
|
|
36
|
+
}): Record<string, unknown> {
|
|
37
|
+
const logCall = toolCaller.callTool.mock.calls.find(
|
|
38
|
+
(call) => call[1] === TOOLS.FEATURE_LOG_APPEND,
|
|
39
|
+
) as ToolCall | undefined;
|
|
40
|
+
expect(logCall).toBeDefined();
|
|
41
|
+
return JSON.parse(String(logCall?.[2]?.note ?? '{}')) as Record<string, unknown>;
|
|
42
|
+
}
|
|
43
|
+
|
|
29
44
|
describe('PlanningWaveExecutor post-QA reconciliation', () => {
|
|
30
45
|
it('GIVEN_worker_emits_plan_submission_WHEN_running_planning_wave_THEN_skips_fallback_plan_generation', async () => {
|
|
31
46
|
const featureId = 'feature_worker_plan';
|
|
47
|
+
const plannerSessionSync = {
|
|
48
|
+
syncPlannerSessions: vi.fn(async () => undefined),
|
|
49
|
+
};
|
|
32
50
|
const toolCaller = {
|
|
33
51
|
callTool: vi.fn(async (_role: string, toolName: string) => {
|
|
34
52
|
if (toolName === TOOLS.FEATURE_GET_CONTEXT) {
|
|
@@ -58,19 +76,33 @@ describe('PlanningWaveExecutor post-QA reconciliation', () => {
|
|
|
58
76
|
patchApplied: false,
|
|
59
77
|
noteLogged: true,
|
|
60
78
|
requestHandled: false,
|
|
79
|
+
questionRequested: false,
|
|
80
|
+
contextStall: false,
|
|
81
|
+
contextRequestCount: 0,
|
|
82
|
+
lastContextRequestAt: null,
|
|
83
|
+
lastContextRequestRole: null,
|
|
84
|
+
invalidOutput: false,
|
|
85
|
+
noProgress: false,
|
|
86
|
+
outputTypes: [],
|
|
87
|
+
rawOutputs: [],
|
|
61
88
|
priorityOrder: [],
|
|
62
89
|
toolResults: [],
|
|
90
|
+
errorCode: null,
|
|
91
|
+
interactiveOutcome: null,
|
|
92
|
+
checkpoint: null,
|
|
63
93
|
})),
|
|
64
94
|
};
|
|
65
95
|
|
|
66
96
|
const executor = new PlanningWaveExecutor({
|
|
67
97
|
toolCaller: toolCaller as never,
|
|
68
98
|
planGenerator: planGenerator as never,
|
|
99
|
+
plannerSessionSync,
|
|
69
100
|
workerDecisionRunner: workerDecisionRunner as never,
|
|
70
101
|
});
|
|
71
102
|
|
|
72
103
|
await executor.run([featureId]);
|
|
73
104
|
|
|
105
|
+
expect(plannerSessionSync.syncPlannerSessions).toHaveBeenCalledWith([featureId]);
|
|
74
106
|
expect(workerDecisionRunner.execute).toHaveBeenCalledWith(
|
|
75
107
|
expect.objectContaining({
|
|
76
108
|
role: 'planner',
|
|
@@ -84,6 +116,281 @@ describe('PlanningWaveExecutor post-QA reconciliation', () => {
|
|
|
84
116
|
expect(planSubmitCalls).toHaveLength(0);
|
|
85
117
|
});
|
|
86
118
|
|
|
119
|
+
it('uses the verified manifest instead of raw spec prose for post-QA reconciliation edge-case guidance', async () => {
|
|
120
|
+
const featureId = 'feature_verified_manifest_reconciliation';
|
|
121
|
+
const plannerSessionSync = {
|
|
122
|
+
syncPlannerSessions: vi.fn(async () => undefined),
|
|
123
|
+
};
|
|
124
|
+
const toolCaller = {
|
|
125
|
+
callTool: vi.fn(async (_role: string, toolName: string, args?: Record<string, unknown>) => {
|
|
126
|
+
if (toolName === TOOLS.FEATURE_GET_CONTEXT) {
|
|
127
|
+
return {
|
|
128
|
+
ok: true,
|
|
129
|
+
data: {
|
|
130
|
+
feature_id: featureId,
|
|
131
|
+
spec: 'Handle missing inputs and timeout retries under concurrent requests.',
|
|
132
|
+
state: {
|
|
133
|
+
front_matter: {
|
|
134
|
+
status: STATUS.BLOCKED,
|
|
135
|
+
},
|
|
136
|
+
},
|
|
137
|
+
plan: {
|
|
138
|
+
...basePlan(featureId),
|
|
139
|
+
plan_trace: [
|
|
140
|
+
{
|
|
141
|
+
obligation_id: 'OBL-001',
|
|
142
|
+
disposition: 'in_scope',
|
|
143
|
+
planned_paths: ['apps/control-plane/src/file.ts'],
|
|
144
|
+
notes: 'mapped',
|
|
145
|
+
},
|
|
146
|
+
],
|
|
147
|
+
},
|
|
148
|
+
intake: {
|
|
149
|
+
verified_manifest: {
|
|
150
|
+
obligations: [
|
|
151
|
+
{
|
|
152
|
+
obligation_id: 'OBL-001',
|
|
153
|
+
kind: 'endpoint',
|
|
154
|
+
verification_hint: 'required',
|
|
155
|
+
},
|
|
156
|
+
],
|
|
157
|
+
},
|
|
158
|
+
},
|
|
159
|
+
qa_test_index: {
|
|
160
|
+
summary: {
|
|
161
|
+
pending: 0,
|
|
162
|
+
failed: 0,
|
|
163
|
+
running: 0,
|
|
164
|
+
},
|
|
165
|
+
},
|
|
166
|
+
latest_evidence: {
|
|
167
|
+
overall: 'pass',
|
|
168
|
+
},
|
|
169
|
+
},
|
|
170
|
+
};
|
|
171
|
+
}
|
|
172
|
+
if (toolName === TOOLS.PLAN_UPDATE) {
|
|
173
|
+
return { ok: true, data: { accepted: true, plan_version: 3 } };
|
|
174
|
+
}
|
|
175
|
+
if (toolName === TOOLS.FEATURE_LOG_APPEND) {
|
|
176
|
+
return { ok: true, data: { appended: true } };
|
|
177
|
+
}
|
|
178
|
+
throw new Error(`unexpected_tool:${toolName}:${String(args?.feature_id ?? '')}`);
|
|
179
|
+
}),
|
|
180
|
+
};
|
|
181
|
+
|
|
182
|
+
const executor = new PlanningWaveExecutor({
|
|
183
|
+
toolCaller: toolCaller as never,
|
|
184
|
+
plannerSessionSync,
|
|
185
|
+
planGenerator: { generateInitialPlan: vi.fn(async () => ({ feature_id: featureId })) },
|
|
186
|
+
});
|
|
187
|
+
|
|
188
|
+
await executor.runPostQaReconciliation([featureId], 1);
|
|
189
|
+
|
|
190
|
+
expect(plannerSessionSync.syncPlannerSessions).toHaveBeenCalledWith([featureId]);
|
|
191
|
+
const updateCall = toolCaller.callTool.mock.calls.find((call) => call[1] === TOOLS.PLAN_UPDATE);
|
|
192
|
+
expect(updateCall).toBeTruthy();
|
|
193
|
+
const updatedPlan = updateCall?.[2].plan_json as Record<string, unknown>;
|
|
194
|
+
const riskItems = Array.isArray(updatedPlan.risk) ? updatedPlan.risk : [];
|
|
195
|
+
expect(riskItems).toEqual(
|
|
196
|
+
expect.arrayContaining([
|
|
197
|
+
'Verified endpoint and contract obligations cover payload validation and negative-path handling.',
|
|
198
|
+
'Required verified-manifest obligations have explicit verification coverage.',
|
|
199
|
+
]),
|
|
200
|
+
);
|
|
201
|
+
expect(riskItems).not.toEqual(
|
|
202
|
+
expect.arrayContaining([
|
|
203
|
+
'Edge-case: timeout, retry, and latency behavior is covered.',
|
|
204
|
+
'Edge-case: concurrent access and race-condition behavior are covered.',
|
|
205
|
+
]),
|
|
206
|
+
);
|
|
207
|
+
});
|
|
208
|
+
|
|
209
|
+
it('GIVEN_blocked_feature_with_accepted_plan_WHEN_running_planning_wave_THEN_skips_regular_planner_turn', async () => {
|
|
210
|
+
const featureId = 'feature_blocked_with_plan';
|
|
211
|
+
const toolCaller = {
|
|
212
|
+
callTool: vi.fn(async (_role: string, toolName: string) => {
|
|
213
|
+
if (toolName === TOOLS.FEATURE_GET_CONTEXT) {
|
|
214
|
+
return {
|
|
215
|
+
ok: true,
|
|
216
|
+
data: {
|
|
217
|
+
feature_id: featureId,
|
|
218
|
+
state: {
|
|
219
|
+
front_matter: {
|
|
220
|
+
status: STATUS.BLOCKED,
|
|
221
|
+
},
|
|
222
|
+
},
|
|
223
|
+
plan: basePlan(featureId),
|
|
224
|
+
},
|
|
225
|
+
};
|
|
226
|
+
}
|
|
227
|
+
return { ok: true, data: {} };
|
|
228
|
+
}),
|
|
229
|
+
};
|
|
230
|
+
const planGenerator = {
|
|
231
|
+
generateInitialPlan: vi.fn(async () => ({ feature_id: featureId })),
|
|
232
|
+
};
|
|
233
|
+
const workerDecisionRunner = {
|
|
234
|
+
execute: vi.fn(),
|
|
235
|
+
};
|
|
236
|
+
|
|
237
|
+
const executor = new PlanningWaveExecutor({
|
|
238
|
+
toolCaller: toolCaller as never,
|
|
239
|
+
planGenerator: planGenerator as never,
|
|
240
|
+
workerDecisionRunner: workerDecisionRunner as never,
|
|
241
|
+
});
|
|
242
|
+
|
|
243
|
+
await executor.run([featureId]);
|
|
244
|
+
|
|
245
|
+
expect(workerDecisionRunner.execute).not.toHaveBeenCalled();
|
|
246
|
+
expect(planGenerator.generateInitialPlan).not.toHaveBeenCalled();
|
|
247
|
+
});
|
|
248
|
+
|
|
249
|
+
it('GIVEN_blocked_feature_in_intake_with_existing_plan_WHEN_running_planning_wave_THEN_still_executes_planner_intake_turn', async () => {
|
|
250
|
+
const featureId = 'feature_blocked_intake_with_plan';
|
|
251
|
+
const toolCaller = {
|
|
252
|
+
callTool: vi.fn(async (_role: string, toolName: string) => {
|
|
253
|
+
if (toolName === TOOLS.FEATURE_GET_CONTEXT) {
|
|
254
|
+
return {
|
|
255
|
+
ok: true,
|
|
256
|
+
data: {
|
|
257
|
+
feature_id: featureId,
|
|
258
|
+
state: {
|
|
259
|
+
front_matter: {
|
|
260
|
+
status: STATUS.BLOCKED,
|
|
261
|
+
intake: {
|
|
262
|
+
status: 'in_progress',
|
|
263
|
+
verified_manifest_version: null,
|
|
264
|
+
},
|
|
265
|
+
},
|
|
266
|
+
},
|
|
267
|
+
intake: {
|
|
268
|
+
summary: {
|
|
269
|
+
status: 'in_progress',
|
|
270
|
+
verified_manifest_version: null,
|
|
271
|
+
},
|
|
272
|
+
verified_manifest: null,
|
|
273
|
+
review: {
|
|
274
|
+
ambiguities: [
|
|
275
|
+
{
|
|
276
|
+
id: 'AMB-001',
|
|
277
|
+
status: 'open',
|
|
278
|
+
summary: 'Clarify the intake contract before planning.',
|
|
279
|
+
obligation_ids: ['OBL-001'],
|
|
280
|
+
},
|
|
281
|
+
],
|
|
282
|
+
},
|
|
283
|
+
},
|
|
284
|
+
plan: basePlan(featureId),
|
|
285
|
+
},
|
|
286
|
+
};
|
|
287
|
+
}
|
|
288
|
+
return { ok: true, data: {} };
|
|
289
|
+
}),
|
|
290
|
+
};
|
|
291
|
+
const planGenerator = {
|
|
292
|
+
generateInitialPlan: vi.fn(async () => ({ feature_id: featureId })),
|
|
293
|
+
};
|
|
294
|
+
const workerDecisionRunner = {
|
|
295
|
+
execute: vi.fn(async () => ({
|
|
296
|
+
planSubmission: false,
|
|
297
|
+
intakeSubmission: false,
|
|
298
|
+
patchApplied: false,
|
|
299
|
+
noteLogged: false,
|
|
300
|
+
requestHandled: false,
|
|
301
|
+
questionRequested: true,
|
|
302
|
+
contextStall: false,
|
|
303
|
+
contextRequestCount: 0,
|
|
304
|
+
lastContextRequestAt: null,
|
|
305
|
+
lastContextRequestRole: null,
|
|
306
|
+
invalidOutput: false,
|
|
307
|
+
errorCode: null,
|
|
308
|
+
noProgress: false,
|
|
309
|
+
outputTypes: ['REQUEST'],
|
|
310
|
+
rawOutputs: [],
|
|
311
|
+
priorityOrder: [],
|
|
312
|
+
toolResults: [],
|
|
313
|
+
interactiveOutcome: null,
|
|
314
|
+
checkpoint: null,
|
|
315
|
+
})),
|
|
316
|
+
};
|
|
317
|
+
|
|
318
|
+
const executor = new PlanningWaveExecutor({
|
|
319
|
+
toolCaller: toolCaller as never,
|
|
320
|
+
planGenerator: planGenerator as never,
|
|
321
|
+
workerDecisionRunner: workerDecisionRunner as never,
|
|
322
|
+
});
|
|
323
|
+
|
|
324
|
+
await executor.run([featureId]);
|
|
325
|
+
|
|
326
|
+
expect(workerDecisionRunner.execute).toHaveBeenCalledWith(
|
|
327
|
+
expect.objectContaining({
|
|
328
|
+
role: 'planner',
|
|
329
|
+
featureId,
|
|
330
|
+
}),
|
|
331
|
+
);
|
|
332
|
+
expect(planGenerator.generateInitialPlan).not.toHaveBeenCalled();
|
|
333
|
+
});
|
|
334
|
+
|
|
335
|
+
it('GIVEN_legacy_planning_state_with_accepted_plan_WHEN_running_planning_wave_THEN_normalizes_state_and_skips_planner', async () => {
|
|
336
|
+
const featureId = 'feature_legacy_planning_with_plan';
|
|
337
|
+
const toolCaller = {
|
|
338
|
+
callTool: vi.fn(async (_role: string, toolName: string) => {
|
|
339
|
+
if (toolName === TOOLS.FEATURE_GET_CONTEXT) {
|
|
340
|
+
return {
|
|
341
|
+
ok: true,
|
|
342
|
+
data: {
|
|
343
|
+
feature_id: featureId,
|
|
344
|
+
state: {
|
|
345
|
+
front_matter: {
|
|
346
|
+
version: 6,
|
|
347
|
+
status: STATUS.PLANNING,
|
|
348
|
+
gates: {
|
|
349
|
+
plan: 'na',
|
|
350
|
+
},
|
|
351
|
+
},
|
|
352
|
+
},
|
|
353
|
+
plan: basePlan(featureId),
|
|
354
|
+
},
|
|
355
|
+
};
|
|
356
|
+
}
|
|
357
|
+
if (toolName === TOOLS.FEATURE_STATE_PATCH) {
|
|
358
|
+
return { ok: true, data: { updated: true } };
|
|
359
|
+
}
|
|
360
|
+
return { ok: true, data: {} };
|
|
361
|
+
}),
|
|
362
|
+
};
|
|
363
|
+
const planGenerator = {
|
|
364
|
+
generateInitialPlan: vi.fn(async () => ({ feature_id: featureId })),
|
|
365
|
+
};
|
|
366
|
+
const workerDecisionRunner = {
|
|
367
|
+
execute: vi.fn(),
|
|
368
|
+
};
|
|
369
|
+
|
|
370
|
+
const executor = new PlanningWaveExecutor({
|
|
371
|
+
toolCaller: toolCaller as never,
|
|
372
|
+
planGenerator: planGenerator as never,
|
|
373
|
+
workerDecisionRunner: workerDecisionRunner as never,
|
|
374
|
+
});
|
|
375
|
+
|
|
376
|
+
await executor.run([featureId]);
|
|
377
|
+
|
|
378
|
+
expect(workerDecisionRunner.execute).not.toHaveBeenCalled();
|
|
379
|
+
expect(planGenerator.generateInitialPlan).not.toHaveBeenCalled();
|
|
380
|
+
expect(toolCaller.callTool).toHaveBeenCalledWith('orchestrator', TOOLS.FEATURE_STATE_PATCH, {
|
|
381
|
+
feature_id: featureId,
|
|
382
|
+
expected_version: 6,
|
|
383
|
+
patch: {
|
|
384
|
+
front_matter: {
|
|
385
|
+
status: STATUS.BUILDING,
|
|
386
|
+
gates: {
|
|
387
|
+
plan: 'pass',
|
|
388
|
+
},
|
|
389
|
+
},
|
|
390
|
+
},
|
|
391
|
+
});
|
|
392
|
+
});
|
|
393
|
+
|
|
87
394
|
it('GIVEN_post_qa_gaps_WHEN_reconciling_THEN_emits_plan_update_with_edge_case_hardening', async () => {
|
|
88
395
|
const featureId = 'feature_gap';
|
|
89
396
|
const toolCaller = {
|
|
@@ -165,7 +472,77 @@ describe('PlanningWaveExecutor post-QA reconciliation', () => {
|
|
|
165
472
|
);
|
|
166
473
|
expect(logCall?.[0]).toBe('orchestrator');
|
|
167
474
|
const note = JSON.parse(String(logCall?.[2].note)) as Record<string, unknown>;
|
|
168
|
-
expect(note.
|
|
475
|
+
expect(note.plan_decision).toBe('update_required');
|
|
476
|
+
expect(note.execution_disposition).toBe('blocked_other');
|
|
477
|
+
});
|
|
478
|
+
|
|
479
|
+
it('GIVEN_blocked_feature_still_in_intake_WHEN_running_post_qa_reconciliation_THEN_skips_plan_update', async () => {
|
|
480
|
+
const featureId = 'feature_blocked_intake_reconciliation_skip';
|
|
481
|
+
const toolCaller = {
|
|
482
|
+
callTool: vi.fn(async (_role: string, toolName: string, _args?: Record<string, unknown>) => {
|
|
483
|
+
if (toolName === TOOLS.FEATURE_GET_CONTEXT) {
|
|
484
|
+
return {
|
|
485
|
+
ok: true,
|
|
486
|
+
data: {
|
|
487
|
+
feature_id: featureId,
|
|
488
|
+
state: {
|
|
489
|
+
front_matter: {
|
|
490
|
+
status: STATUS.BLOCKED,
|
|
491
|
+
intake: {
|
|
492
|
+
status: 'in_progress',
|
|
493
|
+
verified_manifest_version: null,
|
|
494
|
+
},
|
|
495
|
+
},
|
|
496
|
+
},
|
|
497
|
+
intake: {
|
|
498
|
+
summary: {
|
|
499
|
+
status: 'in_progress',
|
|
500
|
+
verified_manifest_version: null,
|
|
501
|
+
},
|
|
502
|
+
verified_manifest: null,
|
|
503
|
+
review: {
|
|
504
|
+
ambiguities: [
|
|
505
|
+
{
|
|
506
|
+
id: 'AMB-001',
|
|
507
|
+
status: 'open',
|
|
508
|
+
summary: 'Still unresolved.',
|
|
509
|
+
},
|
|
510
|
+
],
|
|
511
|
+
},
|
|
512
|
+
},
|
|
513
|
+
plan: basePlan(featureId),
|
|
514
|
+
qa_test_index: {
|
|
515
|
+
summary: {
|
|
516
|
+
pending: 1,
|
|
517
|
+
failed: 1,
|
|
518
|
+
running: 0,
|
|
519
|
+
},
|
|
520
|
+
},
|
|
521
|
+
latest_evidence: {
|
|
522
|
+
overall: 'fail',
|
|
523
|
+
},
|
|
524
|
+
},
|
|
525
|
+
};
|
|
526
|
+
}
|
|
527
|
+
if (toolName === TOOLS.FEATURE_LOG_APPEND) {
|
|
528
|
+
return { ok: true, data: { appended: true } };
|
|
529
|
+
}
|
|
530
|
+
return { ok: true, data: {} };
|
|
531
|
+
}),
|
|
532
|
+
};
|
|
533
|
+
|
|
534
|
+
const executor = new PlanningWaveExecutor({
|
|
535
|
+
toolCaller: toolCaller as never,
|
|
536
|
+
planGenerator: { generateInitialPlan: vi.fn(async () => ({ feature_id: featureId })) },
|
|
537
|
+
});
|
|
538
|
+
|
|
539
|
+
await executor.runPostQaReconciliation([featureId], 1);
|
|
540
|
+
|
|
541
|
+
expect(toolCaller.callTool).not.toHaveBeenCalledWith(
|
|
542
|
+
'planner',
|
|
543
|
+
TOOLS.PLAN_UPDATE,
|
|
544
|
+
expect.any(Object),
|
|
545
|
+
);
|
|
169
546
|
});
|
|
170
547
|
|
|
171
548
|
it('GIVEN_reconciled_post_qa_context_WHEN_reconciling_THEN_logs_no_update_and_skips_plan_update', async () => {
|
|
@@ -232,8 +609,9 @@ describe('PlanningWaveExecutor post-QA reconciliation', () => {
|
|
|
232
609
|
expect(logCall).toBeTruthy();
|
|
233
610
|
const logArgs = logCall?.[2] ?? {};
|
|
234
611
|
const note = JSON.parse(String(logArgs.note));
|
|
235
|
-
expect(note.
|
|
236
|
-
expect(note.
|
|
612
|
+
expect(note.plan_decision).toBe('unchanged');
|
|
613
|
+
expect(note.execution_disposition).toBe('blocked_stale_evidence');
|
|
614
|
+
expect(note.reasons).toEqual(['checkpoint_missing']);
|
|
237
615
|
});
|
|
238
616
|
|
|
239
617
|
it('GIVEN_plan_null_WHEN_reconciling_THEN_logs_no_update_missing_plan', async () => {
|
|
@@ -278,7 +656,8 @@ describe('PlanningWaveExecutor post-QA reconciliation', () => {
|
|
|
278
656
|
expect(logCall).toBeTruthy();
|
|
279
657
|
const logPayload = (logCall as unknown[] | undefined)?.[2] as { note?: string } | undefined;
|
|
280
658
|
const note = JSON.parse(String(logPayload?.note));
|
|
281
|
-
expect(note.
|
|
659
|
+
expect(note.plan_decision).toBe('unchanged');
|
|
660
|
+
expect(note.execution_disposition).toBe('blocked_other');
|
|
282
661
|
expect(note.reasons).toContain('missing_plan');
|
|
283
662
|
});
|
|
284
663
|
|
|
@@ -328,7 +707,8 @@ describe('PlanningWaveExecutor post-QA reconciliation', () => {
|
|
|
328
707
|
expect(logCall).toBeTruthy();
|
|
329
708
|
const logPayload = (logCall as unknown[] | undefined)?.[2] as { note?: string } | undefined;
|
|
330
709
|
const note = JSON.parse(String(logPayload?.note));
|
|
331
|
-
expect(note.
|
|
710
|
+
expect(note.plan_decision).toBe('unchanged');
|
|
711
|
+
expect(note.execution_disposition).toBe('blocked_other');
|
|
332
712
|
expect(note.reasons).toContain('existing_plan_version_invalid');
|
|
333
713
|
});
|
|
334
714
|
|
|
@@ -419,119 +799,2093 @@ describe('PlanningWaveExecutor post-QA reconciliation', () => {
|
|
|
419
799
|
expect(planUpdateCalls).toHaveLength(0);
|
|
420
800
|
expect(logCalls).toHaveLength(0);
|
|
421
801
|
});
|
|
422
|
-
});
|
|
423
802
|
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
803
|
+
it('GIVEN_blocked_provider_output_invalid_WHEN_reconciling_THEN_logs_blocked_provider_failure', async () => {
|
|
804
|
+
const featureId = 'feature_provider_invalid';
|
|
805
|
+
const edgeChecklist = [
|
|
806
|
+
'Edge-case: boundary values and size limits are covered.',
|
|
807
|
+
'Edge-case: negative-path input validation and error handling are covered.',
|
|
808
|
+
'Edge-case: dependency failure and retry behavior are covered.',
|
|
809
|
+
];
|
|
810
|
+
const toolCaller = {
|
|
811
|
+
callTool: vi.fn(async (_role: string, toolName: string) => {
|
|
812
|
+
if (toolName === TOOLS.FEATURE_GET_CONTEXT) {
|
|
813
|
+
return {
|
|
814
|
+
ok: true,
|
|
815
|
+
data: {
|
|
816
|
+
feature_id: featureId,
|
|
817
|
+
spec: 'Simple feature flow.',
|
|
818
|
+
state: {
|
|
819
|
+
front_matter: {
|
|
820
|
+
status: STATUS.BLOCKED,
|
|
821
|
+
status_reason: `blocked:${ERROR_CODES.PROVIDER_OUTPUT_INVALID}`,
|
|
822
|
+
checkpoints: [
|
|
823
|
+
{
|
|
824
|
+
checkpoint_id: 'checkpoint-1',
|
|
825
|
+
timestamp: '2026-03-12T16:00:00.000Z',
|
|
826
|
+
validation_status: 'valid',
|
|
827
|
+
diff_snapshot:
|
|
828
|
+
'.aop/features/feature_provider_invalid/checkpoints/checkpoint-1.diff',
|
|
829
|
+
diff_hash: 'diff-1',
|
|
830
|
+
},
|
|
831
|
+
],
|
|
832
|
+
evidence: {
|
|
833
|
+
last_gate_mode: 'fast',
|
|
834
|
+
},
|
|
835
|
+
},
|
|
836
|
+
},
|
|
837
|
+
plan: {
|
|
838
|
+
...basePlan(featureId),
|
|
839
|
+
risk: edgeChecklist,
|
|
840
|
+
},
|
|
841
|
+
qa_test_index: {
|
|
842
|
+
summary: { pending: 0, failed: 0, running: 0, passed: 1, waived: 0 },
|
|
843
|
+
},
|
|
844
|
+
latest_evidence: {
|
|
845
|
+
overall: 'fail',
|
|
846
|
+
mode: 'fast',
|
|
847
|
+
input_diff_hash: 'diff-1',
|
|
848
|
+
},
|
|
849
|
+
gate_evidence_by_mode: {
|
|
850
|
+
fast: {
|
|
851
|
+
mode: 'fast',
|
|
852
|
+
overall: 'fail',
|
|
853
|
+
input_diff_hash: 'diff-1',
|
|
854
|
+
input_checkpoint_id: 'checkpoint-1',
|
|
855
|
+
input_worktree_validity: 'valid',
|
|
856
|
+
},
|
|
857
|
+
full: {
|
|
858
|
+
mode: 'full',
|
|
859
|
+
overall: 'pass',
|
|
860
|
+
input_diff_hash: 'diff-1',
|
|
861
|
+
input_checkpoint_id: 'checkpoint-1',
|
|
862
|
+
input_worktree_validity: 'valid',
|
|
863
|
+
},
|
|
864
|
+
},
|
|
865
|
+
},
|
|
866
|
+
};
|
|
867
|
+
}
|
|
868
|
+
if (toolName === TOOLS.PLAN_UPDATE) {
|
|
869
|
+
return { ok: true, data: { accepted: true, plan_version: 3 } };
|
|
870
|
+
}
|
|
871
|
+
if (toolName === TOOLS.FEATURE_LOG_APPEND) {
|
|
872
|
+
return { ok: true, data: { appended: true } };
|
|
873
|
+
}
|
|
874
|
+
return { ok: true, data: {} };
|
|
875
|
+
}),
|
|
876
|
+
};
|
|
877
|
+
|
|
878
|
+
const executor = new PlanningWaveExecutor({
|
|
879
|
+
toolCaller: toolCaller as never,
|
|
880
|
+
planGenerator: { generateInitialPlan: vi.fn() },
|
|
881
|
+
});
|
|
882
|
+
|
|
883
|
+
await executor.runPostQaReconciliation([featureId], 1);
|
|
884
|
+
|
|
885
|
+
const note = readLoggedNote(toolCaller);
|
|
886
|
+
expect(note.execution_disposition).toBe('blocked_provider_failure');
|
|
887
|
+
expect(note.checkpoint_validity).toBe('valid');
|
|
888
|
+
});
|
|
889
|
+
|
|
890
|
+
it('GIVEN_invalid_checkpoint_WHEN_reconciling_THEN_logs_nonblocking_stale_evidence', async () => {
|
|
891
|
+
const featureId = 'feature_checkpoint_invalid';
|
|
892
|
+
const edgeChecklist = [
|
|
893
|
+
'Edge-case: boundary values and size limits are covered.',
|
|
894
|
+
'Edge-case: negative-path input validation and error handling are covered.',
|
|
895
|
+
'Edge-case: dependency failure and retry behavior are covered.',
|
|
896
|
+
];
|
|
897
|
+
const toolCaller = {
|
|
898
|
+
callTool: vi.fn(async (_role: string, toolName: string) => {
|
|
899
|
+
if (toolName === TOOLS.FEATURE_GET_CONTEXT) {
|
|
900
|
+
return {
|
|
901
|
+
ok: true,
|
|
902
|
+
data: {
|
|
903
|
+
feature_id: featureId,
|
|
904
|
+
spec: 'Simple feature flow.',
|
|
905
|
+
state: {
|
|
906
|
+
front_matter: {
|
|
907
|
+
status: STATUS.BLOCKED,
|
|
908
|
+
checkpoints: [
|
|
909
|
+
{
|
|
910
|
+
checkpoint_id: 'checkpoint-1',
|
|
911
|
+
timestamp: '2026-03-12T16:00:00.000Z',
|
|
912
|
+
validation_status: 'invalid',
|
|
913
|
+
diff_snapshot:
|
|
914
|
+
'.aop/features/feature_checkpoint_invalid/checkpoints/checkpoint-1.diff',
|
|
915
|
+
diff_hash: 'diff-1',
|
|
916
|
+
},
|
|
917
|
+
],
|
|
918
|
+
},
|
|
919
|
+
},
|
|
920
|
+
plan: {
|
|
921
|
+
...basePlan(featureId),
|
|
922
|
+
risk: edgeChecklist,
|
|
923
|
+
},
|
|
924
|
+
qa_test_index: {
|
|
925
|
+
summary: { pending: 0, failed: 0, running: 0, passed: 1, waived: 0 },
|
|
926
|
+
},
|
|
927
|
+
latest_evidence: {
|
|
928
|
+
overall: 'fail',
|
|
929
|
+
},
|
|
930
|
+
},
|
|
931
|
+
};
|
|
932
|
+
}
|
|
933
|
+
if (toolName === TOOLS.PLAN_UPDATE) {
|
|
934
|
+
return { ok: true, data: { accepted: true, plan_version: 3 } };
|
|
935
|
+
}
|
|
936
|
+
if (toolName === TOOLS.FEATURE_LOG_APPEND) {
|
|
937
|
+
return { ok: true, data: { appended: true } };
|
|
938
|
+
}
|
|
939
|
+
return { ok: true, data: {} };
|
|
940
|
+
}),
|
|
941
|
+
};
|
|
942
|
+
|
|
943
|
+
const executor = new PlanningWaveExecutor({
|
|
944
|
+
toolCaller: toolCaller as never,
|
|
945
|
+
planGenerator: { generateInitialPlan: vi.fn() },
|
|
946
|
+
});
|
|
947
|
+
|
|
948
|
+
await executor.runPostQaReconciliation([featureId], 1);
|
|
949
|
+
|
|
950
|
+
const note = readLoggedNote(toolCaller);
|
|
951
|
+
expect(note.execution_disposition).toBe('blocked_stale_evidence');
|
|
952
|
+
expect(note.checkpoint_validity).toBe('skipped');
|
|
953
|
+
});
|
|
954
|
+
|
|
955
|
+
it('GIVEN_warning_only_invalid_checkpoint_WHEN_reconciling_THEN_reruns_full_gate_instead_of_blocking', async () => {
|
|
956
|
+
const featureId = 'feature_checkpoint_warning';
|
|
957
|
+
const edgeChecklist = [
|
|
958
|
+
'Edge-case: boundary values and size limits are covered.',
|
|
959
|
+
'Edge-case: negative-path input validation and error handling are covered.',
|
|
960
|
+
'Edge-case: dependency failure and retry behavior are covered.',
|
|
961
|
+
];
|
|
962
|
+
const toolCaller = {
|
|
963
|
+
callTool: vi.fn(async (_role: string, toolName: string) => {
|
|
964
|
+
if (toolName === TOOLS.FEATURE_GET_CONTEXT) {
|
|
965
|
+
return {
|
|
966
|
+
ok: true,
|
|
967
|
+
data: {
|
|
968
|
+
feature_id: featureId,
|
|
969
|
+
spec: 'Simple feature flow.',
|
|
970
|
+
state: {
|
|
971
|
+
front_matter: {
|
|
972
|
+
status: STATUS.QA,
|
|
973
|
+
checkpoints: [
|
|
974
|
+
{
|
|
975
|
+
checkpoint_id: 'checkpoint-warning',
|
|
976
|
+
timestamp: '2026-03-12T16:00:00.000Z',
|
|
977
|
+
validation_status: 'invalid',
|
|
978
|
+
severity: 'warning',
|
|
979
|
+
diff_snapshot:
|
|
980
|
+
'.aop/features/feature_checkpoint_warning/checkpoints/checkpoint-warning.diff',
|
|
981
|
+
diff_hash: 'diff-new',
|
|
982
|
+
},
|
|
983
|
+
],
|
|
984
|
+
evidence: {
|
|
985
|
+
last_gate_mode: 'full',
|
|
986
|
+
},
|
|
987
|
+
},
|
|
988
|
+
},
|
|
989
|
+
plan: {
|
|
990
|
+
...basePlan(featureId),
|
|
991
|
+
risk: edgeChecklist,
|
|
992
|
+
},
|
|
993
|
+
qa_test_index: {
|
|
994
|
+
summary: { pending: 0, failed: 0, running: 0, passed: 1, waived: 0 },
|
|
995
|
+
},
|
|
996
|
+
latest_evidence: {
|
|
997
|
+
overall: 'pass',
|
|
998
|
+
mode: 'full',
|
|
999
|
+
input_diff_hash: 'diff-old',
|
|
1000
|
+
},
|
|
1001
|
+
gate_evidence_by_mode: {
|
|
1002
|
+
full: {
|
|
1003
|
+
mode: 'full',
|
|
1004
|
+
overall: 'pass',
|
|
1005
|
+
input_diff_hash: 'diff-old',
|
|
1006
|
+
input_checkpoint_id: 'checkpoint-old',
|
|
1007
|
+
input_worktree_validity: 'valid',
|
|
1008
|
+
},
|
|
1009
|
+
},
|
|
1010
|
+
},
|
|
1011
|
+
};
|
|
1012
|
+
}
|
|
1013
|
+
if (toolName === TOOLS.PLAN_UPDATE) {
|
|
1014
|
+
return { ok: true, data: { accepted: true, plan_version: 3 } };
|
|
1015
|
+
}
|
|
1016
|
+
if (toolName === TOOLS.FEATURE_LOG_APPEND) {
|
|
1017
|
+
return { ok: true, data: { appended: true } };
|
|
1018
|
+
}
|
|
1019
|
+
return { ok: true, data: {} };
|
|
1020
|
+
}),
|
|
1021
|
+
};
|
|
1022
|
+
|
|
1023
|
+
const executor = new PlanningWaveExecutor({
|
|
1024
|
+
toolCaller: toolCaller as never,
|
|
1025
|
+
planGenerator: { generateInitialPlan: vi.fn() },
|
|
1026
|
+
});
|
|
1027
|
+
|
|
1028
|
+
await executor.runPostQaReconciliation([featureId], 1);
|
|
1029
|
+
|
|
1030
|
+
const note = readLoggedNote(toolCaller);
|
|
1031
|
+
expect(note.execution_disposition).toBe('rerun_full_gate');
|
|
1032
|
+
expect(note.checkpoint_validity).toBe('skipped');
|
|
1033
|
+
expect(note.reasons).toEqual(
|
|
1034
|
+
expect.arrayContaining(['checkpoint_invalid_nonblocking', 'gate_evidence_stale:full']),
|
|
1035
|
+
);
|
|
1036
|
+
});
|
|
1037
|
+
|
|
1038
|
+
it('GIVEN_qa_with_stale_full_evidence_WHEN_reconciling_THEN_logs_rerun_full_gate', async () => {
|
|
1039
|
+
const featureId = 'feature_rerun_full_gate';
|
|
1040
|
+
const edgeChecklist = [
|
|
1041
|
+
'Edge-case: boundary values and size limits are covered.',
|
|
1042
|
+
'Edge-case: negative-path input validation and error handling are covered.',
|
|
1043
|
+
'Edge-case: dependency failure and retry behavior are covered.',
|
|
1044
|
+
];
|
|
1045
|
+
const toolCaller = {
|
|
1046
|
+
callTool: vi.fn(async (_role: string, toolName: string) => {
|
|
1047
|
+
if (toolName === TOOLS.FEATURE_GET_CONTEXT) {
|
|
1048
|
+
return {
|
|
1049
|
+
ok: true,
|
|
1050
|
+
data: {
|
|
1051
|
+
feature_id: featureId,
|
|
1052
|
+
spec: 'Simple feature flow.',
|
|
1053
|
+
state: {
|
|
1054
|
+
front_matter: {
|
|
1055
|
+
status: STATUS.QA,
|
|
1056
|
+
checkpoints: [
|
|
1057
|
+
{
|
|
1058
|
+
checkpoint_id: 'checkpoint-1',
|
|
1059
|
+
timestamp: '2026-03-12T16:00:00.000Z',
|
|
1060
|
+
validation_status: 'valid',
|
|
1061
|
+
diff_snapshot:
|
|
1062
|
+
'.aop/features/feature_rerun_full_gate/checkpoints/checkpoint-1.diff',
|
|
1063
|
+
diff_hash: 'diff-new',
|
|
1064
|
+
},
|
|
1065
|
+
],
|
|
1066
|
+
evidence: {
|
|
1067
|
+
last_gate_mode: 'full',
|
|
1068
|
+
},
|
|
1069
|
+
},
|
|
1070
|
+
},
|
|
1071
|
+
plan: {
|
|
1072
|
+
...basePlan(featureId),
|
|
1073
|
+
risk: edgeChecklist,
|
|
1074
|
+
},
|
|
1075
|
+
qa_test_index: {
|
|
1076
|
+
summary: { pending: 0, failed: 0, running: 0, passed: 1, waived: 0 },
|
|
1077
|
+
},
|
|
1078
|
+
latest_evidence: {
|
|
1079
|
+
overall: 'pass',
|
|
1080
|
+
mode: 'full',
|
|
1081
|
+
input_diff_hash: 'diff-old',
|
|
1082
|
+
},
|
|
1083
|
+
gate_evidence_by_mode: {
|
|
1084
|
+
full: {
|
|
1085
|
+
mode: 'full',
|
|
1086
|
+
overall: 'pass',
|
|
1087
|
+
input_diff_hash: 'diff-old',
|
|
1088
|
+
input_checkpoint_id: 'checkpoint-old',
|
|
1089
|
+
input_worktree_validity: 'valid',
|
|
1090
|
+
},
|
|
1091
|
+
},
|
|
1092
|
+
},
|
|
1093
|
+
};
|
|
1094
|
+
}
|
|
1095
|
+
if (toolName === TOOLS.PLAN_UPDATE) {
|
|
1096
|
+
return { ok: true, data: { accepted: true, plan_version: 3 } };
|
|
1097
|
+
}
|
|
1098
|
+
if (toolName === TOOLS.FEATURE_LOG_APPEND) {
|
|
1099
|
+
return { ok: true, data: { appended: true } };
|
|
1100
|
+
}
|
|
1101
|
+
return { ok: true, data: {} };
|
|
1102
|
+
}),
|
|
1103
|
+
};
|
|
1104
|
+
|
|
1105
|
+
const executor = new PlanningWaveExecutor({
|
|
1106
|
+
toolCaller: toolCaller as never,
|
|
1107
|
+
planGenerator: { generateInitialPlan: vi.fn() },
|
|
1108
|
+
});
|
|
1109
|
+
|
|
1110
|
+
await executor.runPostQaReconciliation([featureId], 1);
|
|
1111
|
+
|
|
1112
|
+
const note = readLoggedNote(toolCaller);
|
|
1113
|
+
expect(note.execution_disposition).toBe('rerun_full_gate');
|
|
1114
|
+
expect(note.gate_evidence_freshness).toBe('stale');
|
|
1115
|
+
});
|
|
1116
|
+
|
|
1117
|
+
it('GIVEN_ready_to_merge_with_current_full_evidence_WHEN_reconciling_THEN_logs_converged', async () => {
|
|
1118
|
+
const featureId = 'feature_converged';
|
|
1119
|
+
const edgeChecklist = [
|
|
1120
|
+
'Edge-case: boundary values and size limits are covered.',
|
|
1121
|
+
'Edge-case: negative-path input validation and error handling are covered.',
|
|
1122
|
+
'Edge-case: dependency failure and retry behavior are covered.',
|
|
1123
|
+
];
|
|
1124
|
+
const toolCaller = {
|
|
1125
|
+
callTool: vi.fn(async (_role: string, toolName: string) => {
|
|
1126
|
+
if (toolName === TOOLS.FEATURE_GET_CONTEXT) {
|
|
1127
|
+
return {
|
|
1128
|
+
ok: true,
|
|
1129
|
+
data: {
|
|
1130
|
+
feature_id: featureId,
|
|
1131
|
+
spec: 'Simple feature flow.',
|
|
1132
|
+
state: {
|
|
1133
|
+
front_matter: {
|
|
1134
|
+
status: STATUS.READY_TO_MERGE,
|
|
1135
|
+
checkpoints: [
|
|
1136
|
+
{
|
|
1137
|
+
checkpoint_id: 'checkpoint-1',
|
|
1138
|
+
timestamp: '2026-03-12T16:00:00.000Z',
|
|
1139
|
+
validation_status: 'valid',
|
|
1140
|
+
diff_snapshot:
|
|
1141
|
+
'.aop/features/feature_converged/checkpoints/checkpoint-1.diff',
|
|
1142
|
+
diff_hash: 'diff-1',
|
|
1143
|
+
},
|
|
1144
|
+
],
|
|
1145
|
+
evidence: {
|
|
1146
|
+
last_gate_mode: 'full',
|
|
1147
|
+
},
|
|
1148
|
+
},
|
|
1149
|
+
},
|
|
1150
|
+
plan: {
|
|
1151
|
+
...basePlan(featureId),
|
|
1152
|
+
risk: edgeChecklist,
|
|
1153
|
+
},
|
|
1154
|
+
qa_test_index: {
|
|
1155
|
+
summary: { pending: 0, failed: 0, running: 0, passed: 2, waived: 0 },
|
|
1156
|
+
},
|
|
1157
|
+
latest_evidence: {
|
|
1158
|
+
overall: 'pass',
|
|
1159
|
+
mode: 'full',
|
|
1160
|
+
input_diff_hash: 'diff-1',
|
|
1161
|
+
},
|
|
1162
|
+
gate_evidence_by_mode: {
|
|
1163
|
+
full: {
|
|
1164
|
+
mode: 'full',
|
|
1165
|
+
overall: 'pass',
|
|
1166
|
+
input_diff_hash: 'diff-1',
|
|
1167
|
+
input_checkpoint_id: 'checkpoint-1',
|
|
1168
|
+
input_worktree_validity: 'valid',
|
|
1169
|
+
},
|
|
1170
|
+
},
|
|
1171
|
+
},
|
|
1172
|
+
};
|
|
1173
|
+
}
|
|
1174
|
+
if (toolName === TOOLS.FEATURE_LOG_APPEND) {
|
|
1175
|
+
return { ok: true, data: { appended: true } };
|
|
1176
|
+
}
|
|
1177
|
+
return { ok: true, data: {} };
|
|
1178
|
+
}),
|
|
1179
|
+
};
|
|
1180
|
+
|
|
1181
|
+
const executor = new PlanningWaveExecutor({
|
|
1182
|
+
toolCaller: toolCaller as never,
|
|
1183
|
+
planGenerator: { generateInitialPlan: vi.fn() },
|
|
1184
|
+
});
|
|
1185
|
+
|
|
1186
|
+
await executor.runPostQaReconciliation([featureId], 1);
|
|
1187
|
+
|
|
1188
|
+
const note = readLoggedNote(toolCaller);
|
|
1189
|
+
expect(note.plan_decision).toBe('unchanged');
|
|
1190
|
+
expect(note.execution_disposition).toBe('converged');
|
|
1191
|
+
expect(note.gate_evidence_freshness).toBe('current');
|
|
1192
|
+
});
|
|
1193
|
+
|
|
1194
|
+
it('GIVEN_blocked_feature_with_stale_failed_full_gate_evidence_WHEN_reconciling_THEN_logs_blocked_stale_evidence', async () => {
|
|
1195
|
+
const featureId = 'feature_blocked_stale_full';
|
|
1196
|
+
const edgeChecklist = [
|
|
1197
|
+
'Edge-case: boundary values and size limits are covered.',
|
|
1198
|
+
'Edge-case: negative-path input validation and error handling are covered.',
|
|
1199
|
+
'Edge-case: dependency failure and retry behavior are covered.',
|
|
1200
|
+
];
|
|
1201
|
+
const toolCaller = {
|
|
1202
|
+
callTool: vi.fn(async (_role: string, toolName: string) => {
|
|
1203
|
+
if (toolName === TOOLS.FEATURE_GET_CONTEXT) {
|
|
1204
|
+
return {
|
|
1205
|
+
ok: true,
|
|
1206
|
+
data: {
|
|
1207
|
+
feature_id: featureId,
|
|
1208
|
+
spec: 'Simple feature flow.',
|
|
1209
|
+
state: {
|
|
1210
|
+
front_matter: {
|
|
1211
|
+
status: STATUS.BLOCKED,
|
|
1212
|
+
checkpoints: [
|
|
1213
|
+
{
|
|
1214
|
+
checkpoint_id: 'checkpoint-1',
|
|
1215
|
+
timestamp: '2026-03-12T16:00:00.000Z',
|
|
1216
|
+
validation_status: 'valid',
|
|
1217
|
+
diff_snapshot:
|
|
1218
|
+
'.aop/features/feature_blocked_stale_full/checkpoints/checkpoint-1.diff',
|
|
1219
|
+
diff_hash: 'diff-new',
|
|
1220
|
+
},
|
|
1221
|
+
],
|
|
1222
|
+
evidence: {
|
|
1223
|
+
last_gate_mode: 'full',
|
|
1224
|
+
},
|
|
1225
|
+
},
|
|
1226
|
+
},
|
|
1227
|
+
plan: {
|
|
1228
|
+
...basePlan(featureId),
|
|
1229
|
+
risk: edgeChecklist,
|
|
1230
|
+
},
|
|
1231
|
+
qa_test_index: {
|
|
1232
|
+
summary: { pending: 0, failed: 0, running: 0, passed: 1, waived: 0 },
|
|
1233
|
+
},
|
|
1234
|
+
latest_evidence: {
|
|
1235
|
+
overall: 'fail',
|
|
1236
|
+
mode: 'full',
|
|
1237
|
+
input_diff_hash: 'diff-old',
|
|
1238
|
+
},
|
|
1239
|
+
gate_evidence_by_mode: {
|
|
1240
|
+
full: {
|
|
1241
|
+
mode: 'full',
|
|
1242
|
+
overall: 'fail',
|
|
1243
|
+
input_diff_hash: 'diff-old',
|
|
1244
|
+
input_checkpoint_id: 'checkpoint-old',
|
|
1245
|
+
input_worktree_validity: 'valid',
|
|
1246
|
+
},
|
|
1247
|
+
},
|
|
1248
|
+
},
|
|
1249
|
+
};
|
|
1250
|
+
}
|
|
1251
|
+
if (toolName === TOOLS.PLAN_UPDATE) {
|
|
1252
|
+
return { ok: true, data: { accepted: true, plan_version: 3 } };
|
|
1253
|
+
}
|
|
1254
|
+
if (toolName === TOOLS.FEATURE_LOG_APPEND) {
|
|
1255
|
+
return { ok: true, data: { appended: true } };
|
|
1256
|
+
}
|
|
1257
|
+
return { ok: true, data: {} };
|
|
1258
|
+
}),
|
|
1259
|
+
};
|
|
1260
|
+
|
|
1261
|
+
const executor = new PlanningWaveExecutor({
|
|
1262
|
+
toolCaller: toolCaller as never,
|
|
1263
|
+
planGenerator: { generateInitialPlan: vi.fn() },
|
|
1264
|
+
});
|
|
1265
|
+
|
|
1266
|
+
await executor.runPostQaReconciliation([featureId], 1);
|
|
1267
|
+
|
|
1268
|
+
const note = readLoggedNote(toolCaller);
|
|
1269
|
+
expect(note.execution_disposition).toBe('blocked_stale_evidence');
|
|
1270
|
+
expect(note.gate_evidence_freshness).toBe('stale');
|
|
1271
|
+
});
|
|
1272
|
+
|
|
1273
|
+
it('GIVEN_blocked_feature_with_current_failed_gate_WHEN_reconciling_THEN_logs_blocked_other', async () => {
|
|
1274
|
+
const featureId = 'feature_blocked_current_fail';
|
|
1275
|
+
const edgeChecklist = [
|
|
1276
|
+
'Edge-case: boundary values and size limits are covered.',
|
|
1277
|
+
'Edge-case: negative-path input validation and error handling are covered.',
|
|
1278
|
+
'Edge-case: dependency failure and retry behavior are covered.',
|
|
1279
|
+
];
|
|
1280
|
+
const toolCaller = {
|
|
1281
|
+
callTool: vi.fn(async (_role: string, toolName: string) => {
|
|
1282
|
+
if (toolName === TOOLS.FEATURE_GET_CONTEXT) {
|
|
1283
|
+
return {
|
|
1284
|
+
ok: true,
|
|
1285
|
+
data: {
|
|
1286
|
+
feature_id: featureId,
|
|
1287
|
+
spec: 'Simple feature flow.',
|
|
1288
|
+
state: {
|
|
1289
|
+
front_matter: {
|
|
1290
|
+
status: STATUS.BLOCKED,
|
|
1291
|
+
checkpoints: [
|
|
1292
|
+
{
|
|
1293
|
+
checkpoint_id: 'checkpoint-1',
|
|
1294
|
+
timestamp: '2026-03-12T16:00:00.000Z',
|
|
1295
|
+
validation_status: 'valid',
|
|
1296
|
+
diff_snapshot:
|
|
1297
|
+
'.aop/features/feature_blocked_current_fail/checkpoints/checkpoint-1.diff',
|
|
1298
|
+
},
|
|
1299
|
+
],
|
|
1300
|
+
evidence: {
|
|
1301
|
+
last_gate_mode: 'fast',
|
|
1302
|
+
},
|
|
1303
|
+
},
|
|
1304
|
+
},
|
|
1305
|
+
plan: {
|
|
1306
|
+
...basePlan(featureId),
|
|
1307
|
+
risk: edgeChecklist,
|
|
1308
|
+
},
|
|
1309
|
+
qa_test_index: {
|
|
1310
|
+
summary: { pending: 0, failed: 0, running: 0, passed: 1, waived: 0 },
|
|
1311
|
+
},
|
|
1312
|
+
latest_evidence: {
|
|
1313
|
+
overall: 'fail',
|
|
1314
|
+
mode: 'fast',
|
|
1315
|
+
input_diff_hash: 'diff-1',
|
|
1316
|
+
},
|
|
1317
|
+
gate_evidence_by_mode: {
|
|
1318
|
+
fast: {
|
|
1319
|
+
mode: 'fast',
|
|
1320
|
+
overall: 'fail',
|
|
1321
|
+
input_diff_hash: 'diff-1',
|
|
1322
|
+
input_checkpoint_id: 'checkpoint-1',
|
|
1323
|
+
input_worktree_validity: 'valid',
|
|
1324
|
+
},
|
|
1325
|
+
},
|
|
1326
|
+
},
|
|
1327
|
+
};
|
|
1328
|
+
}
|
|
1329
|
+
if (toolName === TOOLS.PLAN_UPDATE) {
|
|
1330
|
+
return { ok: true, data: { accepted: true, plan_version: 3 } };
|
|
1331
|
+
}
|
|
1332
|
+
if (toolName === TOOLS.FEATURE_LOG_APPEND) {
|
|
1333
|
+
return { ok: true, data: { appended: true } };
|
|
1334
|
+
}
|
|
1335
|
+
return { ok: true, data: {} };
|
|
1336
|
+
}),
|
|
1337
|
+
};
|
|
1338
|
+
|
|
1339
|
+
const executor = new PlanningWaveExecutor({
|
|
1340
|
+
toolCaller: toolCaller as never,
|
|
1341
|
+
planGenerator: { generateInitialPlan: vi.fn() },
|
|
1342
|
+
});
|
|
1343
|
+
|
|
1344
|
+
await executor.runPostQaReconciliation([featureId], 1);
|
|
1345
|
+
|
|
1346
|
+
const note = readLoggedNote(toolCaller);
|
|
1347
|
+
expect(note.execution_disposition).toBe('blocked_other');
|
|
1348
|
+
expect(note.gate_evidence_freshness).toBe('unknown');
|
|
1349
|
+
});
|
|
1350
|
+
|
|
1351
|
+
it('GIVEN_fresh_required_gate_failure_WHEN_reconciling_THEN_invokes_planner_with_gate_failure_context', async () => {
|
|
1352
|
+
const featureId = 'feature_scope_gap';
|
|
1353
|
+
const logPath = path.join(os.tmpdir(), `planning-wave-${Date.now()}.log`);
|
|
1354
|
+
await fs.writeFile(
|
|
1355
|
+
logPath,
|
|
1356
|
+
[
|
|
1357
|
+
'# feature=feature_scope_gap mode=full step=validate_all attempt=1',
|
|
1358
|
+
'# cmd=["npm","run","validate:all"]',
|
|
1359
|
+
'# exit=1 timeout=false',
|
|
1360
|
+
'',
|
|
1361
|
+
'## stdout',
|
|
1362
|
+
'',
|
|
1363
|
+
'## stderr',
|
|
1364
|
+
'validate failed',
|
|
1365
|
+
'apps/control-plane/src/example.ts:12:3: example failure',
|
|
1366
|
+
].join('\n'),
|
|
1367
|
+
'utf8',
|
|
1368
|
+
);
|
|
1369
|
+
const workerDecisionRunner = {
|
|
1370
|
+
execute: vi.fn(async () => ({
|
|
1371
|
+
planSubmission: true,
|
|
1372
|
+
patchApplied: false,
|
|
1373
|
+
noteLogged: false,
|
|
1374
|
+
requestHandled: false,
|
|
1375
|
+
questionRequested: false,
|
|
1376
|
+
contextStall: false,
|
|
1377
|
+
contextRequestCount: 0,
|
|
1378
|
+
lastContextRequestAt: null,
|
|
1379
|
+
lastContextRequestRole: null,
|
|
1380
|
+
invalidOutput: false,
|
|
1381
|
+
noProgress: false,
|
|
1382
|
+
outputTypes: ['PLAN_SUBMISSION'],
|
|
1383
|
+
rawOutputs: [],
|
|
1384
|
+
priorityOrder: [],
|
|
1385
|
+
toolResults: [],
|
|
1386
|
+
errorCode: null,
|
|
1387
|
+
interactiveOutcome: null,
|
|
1388
|
+
checkpoint: null,
|
|
1389
|
+
})),
|
|
1390
|
+
};
|
|
1391
|
+
const toolCaller = {
|
|
1392
|
+
callTool: vi.fn(async (_role: string, toolName: string, _args?: Record<string, unknown>) => {
|
|
1393
|
+
if (toolName === TOOLS.FEATURE_GET_CONTEXT) {
|
|
1394
|
+
return {
|
|
1395
|
+
ok: true,
|
|
1396
|
+
data: {
|
|
1397
|
+
feature_id: featureId,
|
|
1398
|
+
spec: 'CLI feature with a gate failure outside current plan scope.',
|
|
1399
|
+
state: {
|
|
1400
|
+
front_matter: {
|
|
1401
|
+
status: STATUS.BLOCKED,
|
|
1402
|
+
checkpoints: [
|
|
1403
|
+
{
|
|
1404
|
+
checkpoint_id: 'checkpoint-1',
|
|
1405
|
+
timestamp: '2026-03-12T16:00:00.000Z',
|
|
1406
|
+
validation_status: 'valid',
|
|
1407
|
+
diff_snapshot:
|
|
1408
|
+
'.aop/features/feature_scope_gap/checkpoints/checkpoint-1.diff',
|
|
1409
|
+
diff_hash: 'diff-1',
|
|
1410
|
+
},
|
|
1411
|
+
],
|
|
1412
|
+
evidence: {
|
|
1413
|
+
last_gate_mode: 'full',
|
|
1414
|
+
},
|
|
1415
|
+
},
|
|
1416
|
+
},
|
|
1417
|
+
plan: {
|
|
1418
|
+
...basePlan(featureId),
|
|
1419
|
+
allowed_areas: ['apps/control-plane/src/cli/', 'apps/control-plane/test/'],
|
|
1420
|
+
forbidden_areas: [
|
|
1421
|
+
'apps/control-plane/src/application/',
|
|
1422
|
+
'apps/control-plane/src/supervisor/',
|
|
1423
|
+
],
|
|
1424
|
+
files: {
|
|
1425
|
+
create: [],
|
|
1426
|
+
modify: ['apps/control-plane/src/cli/example.ts'],
|
|
1427
|
+
delete: [],
|
|
1428
|
+
},
|
|
1429
|
+
},
|
|
1430
|
+
qa_test_index: {
|
|
1431
|
+
summary: { pending: 0, failed: 0, running: 0, passed: 1, waived: 0 },
|
|
1432
|
+
},
|
|
1433
|
+
latest_evidence: {
|
|
1434
|
+
overall: 'fail',
|
|
1435
|
+
mode: 'full',
|
|
1436
|
+
step_results: [
|
|
1437
|
+
{
|
|
1438
|
+
name: 'validate_all',
|
|
1439
|
+
cmd: ['npm', 'run', 'validate:all'],
|
|
1440
|
+
exit_code: 1,
|
|
1441
|
+
log_path: logPath,
|
|
1442
|
+
timeout: false,
|
|
1443
|
+
},
|
|
1444
|
+
],
|
|
1445
|
+
notes: ['npm run validate:all failed because the required gate is still red.'],
|
|
1446
|
+
},
|
|
1447
|
+
gate_evidence_by_mode: {
|
|
1448
|
+
full: {
|
|
1449
|
+
mode: 'full',
|
|
1450
|
+
overall: 'fail',
|
|
1451
|
+
input_diff_hash: 'diff-1',
|
|
1452
|
+
input_checkpoint_id: 'checkpoint-1',
|
|
1453
|
+
input_worktree_validity: 'valid',
|
|
1454
|
+
},
|
|
1455
|
+
},
|
|
1456
|
+
},
|
|
1457
|
+
};
|
|
1458
|
+
}
|
|
1459
|
+
if (toolName === TOOLS.FEATURE_LOG_APPEND) {
|
|
1460
|
+
return { ok: true, data: { appended: true } };
|
|
1461
|
+
}
|
|
1462
|
+
return { ok: true, data: {} };
|
|
1463
|
+
}),
|
|
1464
|
+
};
|
|
1465
|
+
|
|
1466
|
+
const executor = new PlanningWaveExecutor({
|
|
1467
|
+
toolCaller: toolCaller as never,
|
|
1468
|
+
planGenerator: { generateInitialPlan: vi.fn() },
|
|
1469
|
+
workerDecisionRunner: workerDecisionRunner as never,
|
|
1470
|
+
});
|
|
1471
|
+
|
|
1472
|
+
await executor.runPostQaReconciliation([featureId], 1);
|
|
1473
|
+
|
|
1474
|
+
expect(workerDecisionRunner.execute).toHaveBeenCalledWith(
|
|
1475
|
+
expect.objectContaining({
|
|
1476
|
+
role: 'planner',
|
|
1477
|
+
featureId,
|
|
1478
|
+
contextBundle: expect.objectContaining({
|
|
1479
|
+
gate_failure_context: expect.objectContaining({
|
|
1480
|
+
gate_name: 'full',
|
|
1481
|
+
step_name: 'validate_all',
|
|
1482
|
+
cmd: ['npm', 'run', 'validate:all'],
|
|
1483
|
+
exit_code: 1,
|
|
1484
|
+
affected_files: [
|
|
1485
|
+
expect.objectContaining({
|
|
1486
|
+
path: 'apps/control-plane/src/example.ts',
|
|
1487
|
+
line: 12,
|
|
1488
|
+
}),
|
|
1489
|
+
],
|
|
1490
|
+
error_lines: expect.arrayContaining(['validate failed']),
|
|
1491
|
+
notes: ['npm run validate:all failed because the required gate is still red.'],
|
|
1492
|
+
}),
|
|
1493
|
+
}),
|
|
1494
|
+
}),
|
|
1495
|
+
);
|
|
1496
|
+
|
|
1497
|
+
const note = readLoggedNote(toolCaller);
|
|
1498
|
+
expect(note.plan_decision).toBe('update_required');
|
|
1499
|
+
expect(note.execution_disposition).toBe('retry_build');
|
|
1500
|
+
expect(note.reasons).toEqual(
|
|
1501
|
+
expect.arrayContaining(['planner_gate_failure_revision_requested']),
|
|
1502
|
+
);
|
|
1503
|
+
expect(note.gate_failure_context).toEqual(
|
|
1504
|
+
expect.objectContaining({
|
|
1505
|
+
step_name: 'validate_all',
|
|
1506
|
+
exit_code: 1,
|
|
1507
|
+
cmd: ['npm', 'run', 'validate:all'],
|
|
1508
|
+
notes: ['npm run validate:all failed because the required gate is still red.'],
|
|
1509
|
+
}),
|
|
1510
|
+
);
|
|
1511
|
+
});
|
|
1512
|
+
|
|
1513
|
+
it('GIVEN_qa_with_pending_work_and_current_evidence_WHEN_reconciling_THEN_logs_retry_qa', async () => {
|
|
1514
|
+
const featureId = 'feature_retry_qa';
|
|
1515
|
+
const edgeChecklist = [
|
|
1516
|
+
'Edge-case: boundary values and size limits are covered.',
|
|
1517
|
+
'Edge-case: negative-path input validation and error handling are covered.',
|
|
1518
|
+
'Edge-case: dependency failure and retry behavior are covered.',
|
|
1519
|
+
];
|
|
1520
|
+
const toolCaller = {
|
|
1521
|
+
callTool: vi.fn(async (_role: string, toolName: string) => {
|
|
1522
|
+
if (toolName === TOOLS.FEATURE_GET_CONTEXT) {
|
|
1523
|
+
return {
|
|
1524
|
+
ok: true,
|
|
1525
|
+
data: {
|
|
1526
|
+
feature_id: featureId,
|
|
1527
|
+
spec: 'Simple feature flow.',
|
|
1528
|
+
state: {
|
|
1529
|
+
front_matter: {
|
|
1530
|
+
status: STATUS.QA,
|
|
1531
|
+
checkpoints: [
|
|
1532
|
+
{
|
|
1533
|
+
checkpoint_id: 'checkpoint-1',
|
|
1534
|
+
timestamp: '2026-03-12T16:00:00.000Z',
|
|
1535
|
+
validation_status: 'valid',
|
|
1536
|
+
diff_snapshot: '.aop/features/feature_retry_qa/checkpoints/checkpoint-1.diff',
|
|
1537
|
+
diff_hash: 'diff-1',
|
|
1538
|
+
},
|
|
1539
|
+
],
|
|
1540
|
+
evidence: {
|
|
1541
|
+
last_gate_mode: 'full',
|
|
1542
|
+
},
|
|
1543
|
+
},
|
|
1544
|
+
},
|
|
1545
|
+
plan: {
|
|
1546
|
+
...basePlan(featureId),
|
|
1547
|
+
risk: edgeChecklist,
|
|
1548
|
+
},
|
|
1549
|
+
qa_test_index: {
|
|
1550
|
+
summary: { pending: 1, failed: 0, running: 0, passed: 0, waived: 0 },
|
|
1551
|
+
},
|
|
1552
|
+
latest_evidence: {
|
|
1553
|
+
overall: 'pass',
|
|
1554
|
+
mode: 'full',
|
|
1555
|
+
input_diff_hash: 'diff-1',
|
|
1556
|
+
},
|
|
1557
|
+
gate_evidence_by_mode: {
|
|
1558
|
+
full: {
|
|
1559
|
+
mode: 'full',
|
|
1560
|
+
overall: 'pass',
|
|
1561
|
+
input_diff_hash: 'diff-1',
|
|
1562
|
+
input_checkpoint_id: 'checkpoint-1',
|
|
1563
|
+
input_worktree_validity: 'valid',
|
|
1564
|
+
},
|
|
1565
|
+
},
|
|
1566
|
+
},
|
|
1567
|
+
};
|
|
1568
|
+
}
|
|
1569
|
+
if (toolName === TOOLS.PLAN_UPDATE) {
|
|
1570
|
+
return { ok: true, data: { accepted: true, plan_version: 3 } };
|
|
1571
|
+
}
|
|
1572
|
+
if (toolName === TOOLS.FEATURE_LOG_APPEND) {
|
|
1573
|
+
return { ok: true, data: { appended: true } };
|
|
1574
|
+
}
|
|
1575
|
+
return { ok: true, data: {} };
|
|
1576
|
+
}),
|
|
1577
|
+
};
|
|
1578
|
+
|
|
1579
|
+
const executor = new PlanningWaveExecutor({
|
|
1580
|
+
toolCaller: toolCaller as never,
|
|
1581
|
+
planGenerator: { generateInitialPlan: vi.fn() },
|
|
1582
|
+
});
|
|
1583
|
+
|
|
1584
|
+
await executor.runPostQaReconciliation([featureId], 1);
|
|
1585
|
+
|
|
1586
|
+
const note = readLoggedNote(toolCaller);
|
|
1587
|
+
expect(note.execution_disposition).toBe('retry_qa');
|
|
1588
|
+
expect(note.gate_evidence_freshness).toBe('current');
|
|
1589
|
+
});
|
|
1590
|
+
|
|
1591
|
+
it('GIVEN_ready_to_merge_with_non_current_full_evidence_WHEN_reconciling_THEN_logs_blocked_stale_evidence', async () => {
|
|
1592
|
+
const featureId = 'feature_merge_blocked_stale';
|
|
1593
|
+
const edgeChecklist = [
|
|
1594
|
+
'Edge-case: boundary values and size limits are covered.',
|
|
1595
|
+
'Edge-case: negative-path input validation and error handling are covered.',
|
|
1596
|
+
'Edge-case: dependency failure and retry behavior are covered.',
|
|
1597
|
+
];
|
|
1598
|
+
const toolCaller = {
|
|
1599
|
+
callTool: vi.fn(async (_role: string, toolName: string) => {
|
|
1600
|
+
if (toolName === TOOLS.FEATURE_GET_CONTEXT) {
|
|
1601
|
+
return {
|
|
1602
|
+
ok: true,
|
|
1603
|
+
data: {
|
|
1604
|
+
feature_id: featureId,
|
|
1605
|
+
spec: 'Simple feature flow.',
|
|
1606
|
+
state: {
|
|
1607
|
+
front_matter: {
|
|
1608
|
+
status: STATUS.READY_TO_MERGE,
|
|
1609
|
+
checkpoints: [
|
|
1610
|
+
{
|
|
1611
|
+
checkpoint_id: 'checkpoint-1',
|
|
1612
|
+
timestamp: '2026-03-12T16:00:00.000Z',
|
|
1613
|
+
validation_status: 'valid',
|
|
1614
|
+
diff_snapshot:
|
|
1615
|
+
'.aop/features/feature_merge_blocked_stale/checkpoints/checkpoint-1.diff',
|
|
1616
|
+
diff_hash: 'diff-new',
|
|
1617
|
+
},
|
|
1618
|
+
],
|
|
1619
|
+
evidence: {
|
|
1620
|
+
last_gate_mode: 'full',
|
|
1621
|
+
},
|
|
1622
|
+
},
|
|
1623
|
+
},
|
|
1624
|
+
plan: {
|
|
1625
|
+
...basePlan(featureId),
|
|
1626
|
+
risk: edgeChecklist,
|
|
1627
|
+
},
|
|
1628
|
+
qa_test_index: {
|
|
1629
|
+
summary: { pending: 0, failed: 0, running: 0, passed: 2, waived: 0 },
|
|
1630
|
+
},
|
|
1631
|
+
latest_evidence: {
|
|
1632
|
+
overall: 'pass',
|
|
1633
|
+
mode: 'full',
|
|
1634
|
+
input_diff_hash: 'diff-old',
|
|
1635
|
+
},
|
|
1636
|
+
gate_evidence_by_mode: {
|
|
1637
|
+
full: {
|
|
1638
|
+
mode: 'full',
|
|
1639
|
+
overall: 'pass',
|
|
1640
|
+
input_diff_hash: 'diff-old',
|
|
1641
|
+
input_checkpoint_id: 'checkpoint-old',
|
|
1642
|
+
input_worktree_validity: 'valid',
|
|
1643
|
+
},
|
|
1644
|
+
},
|
|
1645
|
+
},
|
|
1646
|
+
};
|
|
1647
|
+
}
|
|
1648
|
+
if (toolName === TOOLS.FEATURE_LOG_APPEND) {
|
|
1649
|
+
return { ok: true, data: { appended: true } };
|
|
1650
|
+
}
|
|
1651
|
+
return { ok: true, data: {} };
|
|
1652
|
+
}),
|
|
1653
|
+
};
|
|
1654
|
+
|
|
1655
|
+
const executor = new PlanningWaveExecutor({
|
|
1656
|
+
toolCaller: toolCaller as never,
|
|
1657
|
+
planGenerator: { generateInitialPlan: vi.fn() },
|
|
1658
|
+
});
|
|
1659
|
+
|
|
1660
|
+
await executor.runPostQaReconciliation([featureId], 1);
|
|
1661
|
+
|
|
1662
|
+
const note = readLoggedNote(toolCaller);
|
|
1663
|
+
expect(note.plan_decision).toBe('unchanged');
|
|
1664
|
+
expect(note.execution_disposition).toBe('rerun_full_gate');
|
|
1665
|
+
expect(note.gate_evidence_freshness).toBe('stale');
|
|
1666
|
+
});
|
|
1667
|
+
|
|
1668
|
+
it('GIVEN_qa_with_skipped_checkpoint_and_missing_full_evidence_WHEN_reconciling_THEN_logs_rerun_full_gate', async () => {
|
|
1669
|
+
const featureId = 'feature_qa_skipped_checkpoint';
|
|
1670
|
+
const edgeChecklist = [
|
|
1671
|
+
'Edge-case: boundary values and size limits are covered.',
|
|
1672
|
+
'Edge-case: negative-path input validation and error handling are covered.',
|
|
1673
|
+
'Edge-case: dependency failure and retry behavior are covered.',
|
|
1674
|
+
];
|
|
1675
|
+
const toolCaller = {
|
|
1676
|
+
callTool: vi.fn(async (_role: string, toolName: string) => {
|
|
1677
|
+
if (toolName === TOOLS.FEATURE_GET_CONTEXT) {
|
|
1678
|
+
return {
|
|
1679
|
+
ok: true,
|
|
1680
|
+
data: {
|
|
1681
|
+
feature_id: featureId,
|
|
1682
|
+
spec: 'Simple feature flow.',
|
|
1683
|
+
state: {
|
|
1684
|
+
front_matter: {
|
|
1685
|
+
status: STATUS.QA,
|
|
1686
|
+
checkpoints: [
|
|
1687
|
+
{
|
|
1688
|
+
checkpoint_id: 'checkpoint-1',
|
|
1689
|
+
timestamp: '2026-03-12T16:00:00.000Z',
|
|
1690
|
+
validation_status: 'skipped',
|
|
1691
|
+
diff_snapshot: `.aop/features/${featureId}/checkpoints/checkpoint-1.diff`,
|
|
1692
|
+
diff_hash: 'diff-1',
|
|
1693
|
+
},
|
|
1694
|
+
],
|
|
1695
|
+
evidence: {
|
|
1696
|
+
last_gate_mode: 'fast',
|
|
1697
|
+
},
|
|
1698
|
+
},
|
|
1699
|
+
},
|
|
1700
|
+
plan: {
|
|
1701
|
+
...basePlan(featureId),
|
|
1702
|
+
risk: edgeChecklist,
|
|
1703
|
+
},
|
|
1704
|
+
qa_test_index: {
|
|
1705
|
+
summary: { pending: 0, failed: 0, running: 0, passed: 5, waived: 0 },
|
|
1706
|
+
},
|
|
1707
|
+
latest_evidence: {
|
|
1708
|
+
overall: 'pass',
|
|
1709
|
+
mode: 'fast',
|
|
1710
|
+
input_diff_hash: 'diff-1',
|
|
1711
|
+
},
|
|
1712
|
+
gate_evidence_by_mode: {},
|
|
1713
|
+
},
|
|
1714
|
+
};
|
|
1715
|
+
}
|
|
1716
|
+
if (toolName === TOOLS.FEATURE_LOG_APPEND) {
|
|
1717
|
+
return { ok: true, data: { appended: true } };
|
|
1718
|
+
}
|
|
1719
|
+
return { ok: true, data: {} };
|
|
1720
|
+
}),
|
|
1721
|
+
};
|
|
1722
|
+
|
|
1723
|
+
const executor = new PlanningWaveExecutor({
|
|
1724
|
+
toolCaller: toolCaller as never,
|
|
1725
|
+
planGenerator: { generateInitialPlan: vi.fn() },
|
|
1726
|
+
});
|
|
1727
|
+
|
|
1728
|
+
await executor.runPostQaReconciliation([featureId], 1);
|
|
1729
|
+
|
|
1730
|
+
const note = readLoggedNote(toolCaller);
|
|
1731
|
+
expect(note.plan_decision).toBe('unchanged');
|
|
1732
|
+
expect(note.execution_disposition).toBe('rerun_full_gate');
|
|
1733
|
+
expect(note.gate_evidence_freshness).toBe('missing');
|
|
1734
|
+
expect(note.checkpoint_validity).toBe('skipped');
|
|
1735
|
+
});
|
|
1736
|
+
});
|
|
1737
|
+
|
|
1738
|
+
describe('PlanningWaveExecutor live watchdog and semantic policies', () => {
|
|
1739
|
+
function workerDecision(overrides: Record<string, unknown> = {}) {
|
|
1740
|
+
return {
|
|
1741
|
+
planSubmission: false,
|
|
1742
|
+
intakeSubmission: false,
|
|
1743
|
+
patchApplied: false,
|
|
1744
|
+
noteLogged: false,
|
|
1745
|
+
requestHandled: false,
|
|
1746
|
+
questionRequested: false,
|
|
1747
|
+
contextStall: false,
|
|
1748
|
+
contextRequestCount: 0,
|
|
1749
|
+
lastContextRequestAt: null,
|
|
1750
|
+
lastContextRequestRole: null,
|
|
1751
|
+
invalidOutput: false,
|
|
1752
|
+
noProgress: false,
|
|
1753
|
+
outputTypes: [],
|
|
1754
|
+
rawOutputs: [],
|
|
1755
|
+
priorityOrder: [],
|
|
1756
|
+
toolResults: [],
|
|
1757
|
+
...overrides,
|
|
1758
|
+
};
|
|
1759
|
+
}
|
|
1760
|
+
|
|
1761
|
+
function createPlanningToolCaller(statuses: string[]) {
|
|
1762
|
+
let statusIndex = 0;
|
|
1763
|
+
return {
|
|
1764
|
+
callTool: vi.fn(async (_role: string, toolName: string, args?: Record<string, unknown>) => {
|
|
1765
|
+
if (toolName === TOOLS.FEATURE_GET_CONTEXT) {
|
|
1766
|
+
const status = statuses[Math.min(statusIndex, statuses.length - 1)] ?? STATUS.PLANNING;
|
|
1767
|
+
statusIndex += 1;
|
|
1768
|
+
return {
|
|
1769
|
+
ok: true,
|
|
1770
|
+
data: {
|
|
1771
|
+
feature_id: String(args?.feature_id ?? 'feature-a'),
|
|
1772
|
+
state: { front_matter: { status } },
|
|
1773
|
+
plan: null,
|
|
1774
|
+
},
|
|
1775
|
+
};
|
|
1776
|
+
}
|
|
1777
|
+
if (toolName === TOOLS.FEATURE_STATE_GET) {
|
|
1778
|
+
return { ok: true, data: { front_matter: { version: 3 } } };
|
|
1779
|
+
}
|
|
1780
|
+
return { ok: true, data: {} };
|
|
1781
|
+
}),
|
|
1782
|
+
};
|
|
439
1783
|
}
|
|
440
1784
|
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
1785
|
+
it('generates and submits fallback plan in stub mode when worker does not submit a plan', async () => {
|
|
1786
|
+
const toolCaller = createPlanningToolCaller([STATUS.PLANNING]);
|
|
1787
|
+
const planGenerator = {
|
|
1788
|
+
generateInitialPlan: vi.fn(async () => ({ feature_id: 'feature-a', plan_version: 1 })),
|
|
1789
|
+
};
|
|
1790
|
+
const executor = new PlanningWaveExecutor({
|
|
1791
|
+
toolCaller: toolCaller as never,
|
|
1792
|
+
planGenerator: planGenerator as never,
|
|
1793
|
+
providerMode: 'stub',
|
|
1794
|
+
workerDecisionRunner: {
|
|
1795
|
+
execute: vi.fn(async () => workerDecision()),
|
|
1796
|
+
},
|
|
1797
|
+
});
|
|
1798
|
+
|
|
1799
|
+
await executor.run(['feature-a']);
|
|
1800
|
+
|
|
1801
|
+
expect(planGenerator.generateInitialPlan).toHaveBeenCalledWith('feature-a');
|
|
1802
|
+
expect(toolCaller.callTool).toHaveBeenCalledWith(
|
|
1803
|
+
'planner',
|
|
1804
|
+
TOOLS.PLAN_SUBMIT,
|
|
1805
|
+
expect.objectContaining({
|
|
1806
|
+
feature_id: 'feature-a',
|
|
1807
|
+
}),
|
|
1808
|
+
);
|
|
1809
|
+
});
|
|
1810
|
+
|
|
1811
|
+
it('auto-promotes the bootstrap manifest in stub mode for intake features before planning', async () => {
|
|
1812
|
+
const toolCaller = {
|
|
1813
|
+
callTool: vi.fn(async (_role: string, toolName: string, _args?: Record<string, unknown>) => {
|
|
1814
|
+
if (toolName === TOOLS.FEATURE_GET_CONTEXT) {
|
|
1815
|
+
return {
|
|
1816
|
+
ok: true,
|
|
1817
|
+
data: {
|
|
1818
|
+
feature_id: 'feature-a',
|
|
1819
|
+
state: { front_matter: { status: STATUS.INTAKE } },
|
|
1820
|
+
plan: null,
|
|
1821
|
+
intake: {
|
|
1822
|
+
bootstrap_manifest: {
|
|
1823
|
+
artifact_type: 'bootstrap',
|
|
1824
|
+
feature_id: 'feature-a',
|
|
1825
|
+
manifest_version: 2,
|
|
1826
|
+
obligations: [{ obligation_id: 'OBL-001', confidence: 'high' }],
|
|
1827
|
+
ambiguities: [],
|
|
1828
|
+
},
|
|
1829
|
+
},
|
|
1830
|
+
},
|
|
1831
|
+
};
|
|
1832
|
+
}
|
|
1833
|
+
if (toolName === TOOLS.FEATURE_INTAKE_SUBMIT) {
|
|
1834
|
+
return {
|
|
1835
|
+
ok: true,
|
|
1836
|
+
data: {
|
|
1837
|
+
feature_id: 'feature-a',
|
|
1838
|
+
accepted: true,
|
|
1839
|
+
feature_status: STATUS.PLANNING,
|
|
1840
|
+
verified_manifest_version: 2,
|
|
1841
|
+
},
|
|
1842
|
+
};
|
|
1843
|
+
}
|
|
1844
|
+
if (toolName === TOOLS.FEATURE_STATE_GET) {
|
|
1845
|
+
return { ok: true, data: { front_matter: { version: 3 } } };
|
|
1846
|
+
}
|
|
1847
|
+
return { ok: true, data: {} };
|
|
1848
|
+
}),
|
|
1849
|
+
};
|
|
1850
|
+
const planGenerator = {
|
|
1851
|
+
generateInitialPlan: vi.fn(async () => ({ feature_id: 'feature-a', plan_version: 1 })),
|
|
1852
|
+
};
|
|
1853
|
+
const executor = new PlanningWaveExecutor({
|
|
1854
|
+
toolCaller: toolCaller as never,
|
|
1855
|
+
planGenerator: planGenerator as never,
|
|
1856
|
+
providerMode: 'stub',
|
|
1857
|
+
workerDecisionRunner: {
|
|
1858
|
+
execute: vi.fn(async () => workerDecision()),
|
|
1859
|
+
},
|
|
1860
|
+
getPolicySnapshot: () => ({
|
|
1861
|
+
planning: {
|
|
1862
|
+
intake: {
|
|
1863
|
+
allow_auto_promotion: true,
|
|
1864
|
+
auto_promotion_min_confidence: 'high',
|
|
1865
|
+
},
|
|
1866
|
+
},
|
|
1867
|
+
}),
|
|
1868
|
+
});
|
|
1869
|
+
|
|
1870
|
+
await executor.run(['feature-a']);
|
|
1871
|
+
|
|
1872
|
+
expect(toolCaller.callTool).toHaveBeenCalledWith(
|
|
1873
|
+
'planner',
|
|
1874
|
+
TOOLS.FEATURE_INTAKE_SUBMIT,
|
|
1875
|
+
expect.objectContaining({
|
|
1876
|
+
feature_id: 'feature-a',
|
|
1877
|
+
intake_submission: expect.objectContaining({
|
|
1878
|
+
verified_manifest: expect.objectContaining({
|
|
1879
|
+
artifact_type: 'verified',
|
|
1880
|
+
feature_id: 'feature-a',
|
|
1881
|
+
manifest_version: 2,
|
|
1882
|
+
verification_basis: 'policy_approved_auto_promotion',
|
|
1883
|
+
source_bootstrap_version: 2,
|
|
1884
|
+
}),
|
|
1885
|
+
}),
|
|
1886
|
+
}),
|
|
1887
|
+
);
|
|
1888
|
+
expect(planGenerator.generateInitialPlan).not.toHaveBeenCalled();
|
|
1889
|
+
});
|
|
1890
|
+
|
|
1891
|
+
it('blocks feature on provider stall timeout when block policy is configured', async () => {
|
|
1892
|
+
const toolCaller = createPlanningToolCaller([STATUS.PLANNING]);
|
|
1893
|
+
const stallError = new Error('stall timeout') as Error & { code?: string };
|
|
1894
|
+
stallError.code = ERROR_CODES.PROVIDER_STALL_TIMEOUT;
|
|
1895
|
+
const executor = new PlanningWaveExecutor({
|
|
1896
|
+
toolCaller: toolCaller as never,
|
|
1897
|
+
planGenerator: { generateInitialPlan: vi.fn() } as never,
|
|
1898
|
+
providerMode: 'live',
|
|
1899
|
+
providerStallAction: 'block_feature',
|
|
1900
|
+
workerDecisionRunner: {
|
|
1901
|
+
execute: vi.fn(async () => {
|
|
1902
|
+
throw stallError;
|
|
1903
|
+
}),
|
|
1904
|
+
},
|
|
1905
|
+
});
|
|
1906
|
+
|
|
1907
|
+
await executor.run(['feature-a']);
|
|
1908
|
+
|
|
1909
|
+
expect(toolCaller.callTool).toHaveBeenCalledWith(
|
|
1910
|
+
'orchestrator',
|
|
1911
|
+
TOOLS.FEATURE_STATE_PATCH,
|
|
1912
|
+
expect.objectContaining({
|
|
1913
|
+
feature_id: 'feature-a',
|
|
1914
|
+
patch: expect.objectContaining({
|
|
1915
|
+
front_matter: expect.objectContaining({
|
|
1916
|
+
status: STATUS.BLOCKED,
|
|
1917
|
+
}),
|
|
1918
|
+
}),
|
|
1919
|
+
}),
|
|
1920
|
+
);
|
|
1921
|
+
});
|
|
1922
|
+
|
|
1923
|
+
it('blocks feature on provider spawn failure when block policy is configured', async () => {
|
|
1924
|
+
const toolCaller = createPlanningToolCaller([STATUS.PLANNING]);
|
|
1925
|
+
const runtimeError = new Error('spawn timeout') as Error & { code?: string };
|
|
1926
|
+
runtimeError.code = ERROR_CODES.PROVIDER_SPAWN_TIMEOUT;
|
|
1927
|
+
const executor = new PlanningWaveExecutor({
|
|
1928
|
+
toolCaller: toolCaller as never,
|
|
1929
|
+
planGenerator: { generateInitialPlan: vi.fn() } as never,
|
|
1930
|
+
providerMode: 'live',
|
|
1931
|
+
providerSpawnFailureAction: 'block_feature',
|
|
1932
|
+
workerDecisionRunner: {
|
|
1933
|
+
execute: vi.fn(async () => {
|
|
1934
|
+
throw runtimeError;
|
|
1935
|
+
}),
|
|
1936
|
+
},
|
|
1937
|
+
});
|
|
1938
|
+
|
|
1939
|
+
await executor.run(['feature-a']);
|
|
1940
|
+
|
|
1941
|
+
expect(toolCaller.callTool).toHaveBeenCalledWith(
|
|
1942
|
+
'orchestrator',
|
|
1943
|
+
TOOLS.FEATURE_STATE_PATCH,
|
|
1944
|
+
expect.objectContaining({
|
|
1945
|
+
feature_id: 'feature-a',
|
|
1946
|
+
patch: expect.objectContaining({
|
|
1947
|
+
front_matter: expect.objectContaining({
|
|
1948
|
+
status: STATUS.BLOCKED,
|
|
1949
|
+
}),
|
|
1950
|
+
}),
|
|
1951
|
+
}),
|
|
1952
|
+
);
|
|
1953
|
+
});
|
|
1954
|
+
|
|
1955
|
+
it('blocks feature on provider hard timeout when timeout block policy is configured', async () => {
|
|
1956
|
+
const toolCaller = createPlanningToolCaller([STATUS.PLANNING]);
|
|
1957
|
+
const runtimeError = new Error('hard timeout') as Error & { code?: string };
|
|
1958
|
+
runtimeError.code = ERROR_CODES.PROVIDER_HARD_TIMEOUT;
|
|
1959
|
+
const executor = new PlanningWaveExecutor({
|
|
1960
|
+
toolCaller: toolCaller as never,
|
|
1961
|
+
planGenerator: { generateInitialPlan: vi.fn() } as never,
|
|
1962
|
+
providerMode: 'live',
|
|
1963
|
+
providerTimeoutAction: 'block_feature',
|
|
1964
|
+
workerDecisionRunner: {
|
|
1965
|
+
execute: vi.fn(async () => {
|
|
1966
|
+
throw runtimeError;
|
|
1967
|
+
}),
|
|
1968
|
+
},
|
|
1969
|
+
});
|
|
1970
|
+
|
|
1971
|
+
await executor.run(['feature-a']);
|
|
1972
|
+
|
|
1973
|
+
expect(toolCaller.callTool).toHaveBeenCalledWith(
|
|
1974
|
+
'orchestrator',
|
|
1975
|
+
TOOLS.FEATURE_STATE_PATCH,
|
|
1976
|
+
expect.objectContaining({
|
|
1977
|
+
feature_id: 'feature-a',
|
|
1978
|
+
patch: expect.objectContaining({
|
|
1979
|
+
front_matter: expect.objectContaining({
|
|
1980
|
+
status: STATUS.BLOCKED,
|
|
1981
|
+
}),
|
|
1982
|
+
}),
|
|
1983
|
+
}),
|
|
1984
|
+
);
|
|
1985
|
+
});
|
|
1986
|
+
|
|
1987
|
+
it('throws runtime errors that have no runtime-failure policy mapping', async () => {
|
|
1988
|
+
const toolCaller = createPlanningToolCaller([STATUS.PLANNING]);
|
|
1989
|
+
const nonMappedError = new Error('bad output') as Error & { code?: string };
|
|
1990
|
+
nonMappedError.code = ERROR_CODES.PROVIDER_OUTPUT_INVALID;
|
|
1991
|
+
const executor = new PlanningWaveExecutor({
|
|
1992
|
+
toolCaller: toolCaller as never,
|
|
1993
|
+
planGenerator: { generateInitialPlan: vi.fn() } as never,
|
|
1994
|
+
providerMode: 'live',
|
|
1995
|
+
workerDecisionRunner: {
|
|
1996
|
+
execute: vi.fn(async () => {
|
|
1997
|
+
throw nonMappedError;
|
|
1998
|
+
}),
|
|
1999
|
+
},
|
|
2000
|
+
});
|
|
2001
|
+
|
|
2002
|
+
await expect(executor.run(['feature-a'])).rejects.toMatchObject({
|
|
2003
|
+
code: ERROR_CODES.PROVIDER_OUTPUT_INVALID,
|
|
2004
|
+
});
|
|
2005
|
+
});
|
|
2006
|
+
|
|
2007
|
+
it('throws provider spawn failure when fail-run policy is configured', async () => {
|
|
2008
|
+
const toolCaller = createPlanningToolCaller([STATUS.PLANNING]);
|
|
2009
|
+
const runtimeError = new Error('runtime unavailable') as Error & { code?: string };
|
|
2010
|
+
runtimeError.code = ERROR_CODES.PROVIDER_RUNTIME_UNAVAILABLE;
|
|
2011
|
+
const executor = new PlanningWaveExecutor({
|
|
2012
|
+
toolCaller: toolCaller as never,
|
|
2013
|
+
planGenerator: { generateInitialPlan: vi.fn() } as never,
|
|
2014
|
+
providerMode: 'live',
|
|
2015
|
+
providerSpawnFailureAction: 'fail_run',
|
|
2016
|
+
workerDecisionRunner: {
|
|
2017
|
+
execute: vi.fn(async () => {
|
|
2018
|
+
throw runtimeError;
|
|
2019
|
+
}),
|
|
2020
|
+
},
|
|
2021
|
+
});
|
|
2022
|
+
|
|
2023
|
+
await expect(executor.run(['feature-a'])).rejects.toMatchObject({
|
|
2024
|
+
code: ERROR_CODES.PROVIDER_RUNTIME_UNAVAILABLE,
|
|
2025
|
+
});
|
|
2026
|
+
});
|
|
2027
|
+
|
|
2028
|
+
it('applies output-loop block policy and skips plan submission for that cycle', async () => {
|
|
2029
|
+
const toolCaller = createPlanningToolCaller([STATUS.PLANNING]);
|
|
2030
|
+
const executor = new PlanningWaveExecutor({
|
|
2031
|
+
toolCaller: toolCaller as never,
|
|
2032
|
+
planGenerator: { generateInitialPlan: vi.fn() } as never,
|
|
2033
|
+
providerMode: 'live',
|
|
2034
|
+
outputLoopStallAction: 'block_feature',
|
|
2035
|
+
outputLoopDetector: {
|
|
2036
|
+
threshold: 2,
|
|
2037
|
+
check: () => ({
|
|
2038
|
+
fingerprint: 'sha256:loop',
|
|
2039
|
+
isLoop: true,
|
|
2040
|
+
consecutiveIdentical: 1,
|
|
2041
|
+
lastUniqueIteration: 1,
|
|
2042
|
+
}),
|
|
2043
|
+
reset: vi.fn(),
|
|
2044
|
+
} as never,
|
|
2045
|
+
workerDecisionRunner: {
|
|
2046
|
+
execute: vi.fn(async () =>
|
|
2047
|
+
workerDecision({ rawOutputs: [{ type: 'NOTE', content: 'same' }] }),
|
|
2048
|
+
),
|
|
2049
|
+
},
|
|
2050
|
+
});
|
|
2051
|
+
|
|
2052
|
+
await executor.run(['feature-a']);
|
|
2053
|
+
|
|
2054
|
+
const statePatchCalls = toolCaller.callTool.mock.calls.filter(
|
|
2055
|
+
(call) => call[1] === TOOLS.FEATURE_STATE_PATCH,
|
|
2056
|
+
);
|
|
2057
|
+
expect(statePatchCalls).toHaveLength(1);
|
|
2058
|
+
const planSubmitCalls = toolCaller.callTool.mock.calls.filter(
|
|
2059
|
+
(call) => call[1] === TOOLS.PLAN_SUBMIT,
|
|
2060
|
+
);
|
|
2061
|
+
expect(planSubmitCalls).toHaveLength(0);
|
|
2062
|
+
});
|
|
2063
|
+
|
|
2064
|
+
it('throws on output-loop detection when fail-run policy is configured', async () => {
|
|
2065
|
+
const toolCaller = createPlanningToolCaller([STATUS.PLANNING]);
|
|
2066
|
+
const executor = new PlanningWaveExecutor({
|
|
2067
|
+
toolCaller: toolCaller as never,
|
|
2068
|
+
planGenerator: { generateInitialPlan: vi.fn() } as never,
|
|
2069
|
+
providerMode: 'live',
|
|
2070
|
+
outputLoopStallAction: 'fail_run',
|
|
2071
|
+
outputLoopDetector: {
|
|
2072
|
+
threshold: 2,
|
|
2073
|
+
check: () => ({
|
|
2074
|
+
fingerprint: 'sha256:loop',
|
|
2075
|
+
isLoop: true,
|
|
2076
|
+
consecutiveIdentical: 1,
|
|
2077
|
+
lastUniqueIteration: 1,
|
|
2078
|
+
}),
|
|
2079
|
+
reset: vi.fn(),
|
|
2080
|
+
} as never,
|
|
2081
|
+
workerDecisionRunner: {
|
|
2082
|
+
execute: vi.fn(async () =>
|
|
2083
|
+
workerDecision({ rawOutputs: [{ type: 'NOTE', content: 'same' }] }),
|
|
2084
|
+
),
|
|
2085
|
+
},
|
|
2086
|
+
});
|
|
2087
|
+
|
|
2088
|
+
await expect(executor.run(['feature-a'])).rejects.toMatchObject({
|
|
2089
|
+
code: ERROR_CODES.PROVIDER_OUTPUT_LOOP,
|
|
2090
|
+
});
|
|
2091
|
+
});
|
|
2092
|
+
|
|
2093
|
+
it('blocks malformed planner output in live mode and skips plan submission', async () => {
|
|
2094
|
+
const toolCaller = createPlanningToolCaller([STATUS.PLANNING]);
|
|
2095
|
+
const executor = new PlanningWaveExecutor({
|
|
2096
|
+
toolCaller: toolCaller as never,
|
|
2097
|
+
planGenerator: { generateInitialPlan: vi.fn() } as never,
|
|
2098
|
+
providerMode: 'live',
|
|
2099
|
+
malformedOutputAction: 'block_feature',
|
|
2100
|
+
workerDecisionRunner: {
|
|
2101
|
+
execute: vi.fn(async () => workerDecision({ invalidOutput: true })),
|
|
2102
|
+
},
|
|
2103
|
+
});
|
|
2104
|
+
|
|
2105
|
+
await executor.run(['feature-a']);
|
|
2106
|
+
|
|
2107
|
+
const statePatchCalls = toolCaller.callTool.mock.calls.filter(
|
|
2108
|
+
(call) => call[1] === TOOLS.FEATURE_STATE_PATCH,
|
|
2109
|
+
);
|
|
2110
|
+
expect(statePatchCalls).toHaveLength(1);
|
|
2111
|
+
expect(statePatchCalls[0]?.[2]).toEqual(
|
|
2112
|
+
expect.objectContaining({
|
|
2113
|
+
patch: {
|
|
2114
|
+
front_matter: expect.objectContaining({
|
|
2115
|
+
status: STATUS.BLOCKED,
|
|
2116
|
+
status_reason: `${ERROR_CODES.PROVIDER_OUTPUT_INVALID}: Planner emitted malformed worker outputs`,
|
|
2117
|
+
recovery: expect.objectContaining({
|
|
2118
|
+
state: 'retrying',
|
|
2119
|
+
cause: ERROR_CODES.PROVIDER_OUTPUT_INVALID,
|
|
2120
|
+
role: 'planner',
|
|
2121
|
+
resume_phase: 'planning',
|
|
2122
|
+
attempt: 1,
|
|
2123
|
+
}),
|
|
2124
|
+
}),
|
|
2125
|
+
},
|
|
2126
|
+
}),
|
|
2127
|
+
);
|
|
2128
|
+
const planSubmitCalls = toolCaller.callTool.mock.calls.filter(
|
|
2129
|
+
(call) => call[1] === TOOLS.PLAN_SUBMIT,
|
|
2130
|
+
);
|
|
2131
|
+
expect(planSubmitCalls).toHaveLength(0);
|
|
2132
|
+
});
|
|
2133
|
+
|
|
2134
|
+
it('routes malformed intake planner output into a blocking clarification question instead of blocked state', async () => {
|
|
2135
|
+
const featureId = 'feature_intake_recovery';
|
|
2136
|
+
const toolCaller = {
|
|
2137
|
+
callTool: vi.fn(async (_role: string, toolName: string) => {
|
|
2138
|
+
if (toolName === TOOLS.FEATURE_GET_CONTEXT) {
|
|
2139
|
+
return {
|
|
2140
|
+
ok: true,
|
|
2141
|
+
data: {
|
|
2142
|
+
feature_id: featureId,
|
|
2143
|
+
state: {
|
|
2144
|
+
front_matter: {
|
|
2145
|
+
status: STATUS.BLOCKED,
|
|
2146
|
+
intake: {
|
|
2147
|
+
status: 'in_progress',
|
|
2148
|
+
bootstrap_manifest_version: 1,
|
|
2149
|
+
verified_manifest_version: null,
|
|
2150
|
+
},
|
|
2151
|
+
cluster: {
|
|
2152
|
+
planner_session_id: 'planner-session-1',
|
|
2153
|
+
},
|
|
2154
|
+
},
|
|
2155
|
+
},
|
|
2156
|
+
plan: null,
|
|
2157
|
+
human_input: {
|
|
2158
|
+
open_questions: [],
|
|
2159
|
+
latest_answer: null,
|
|
2160
|
+
},
|
|
2161
|
+
intake: {
|
|
2162
|
+
verified_manifest: null,
|
|
2163
|
+
summary: {
|
|
2164
|
+
status: 'in_progress',
|
|
2165
|
+
verified_manifest_version: null,
|
|
2166
|
+
},
|
|
2167
|
+
review: {
|
|
2168
|
+
ambiguities: [
|
|
2169
|
+
{
|
|
2170
|
+
id: 'AMB-002',
|
|
2171
|
+
status: 'open',
|
|
2172
|
+
summary: 'Clarify the provider contract.',
|
|
2173
|
+
obligation_ids: ['OBL-002'],
|
|
2174
|
+
},
|
|
2175
|
+
{
|
|
2176
|
+
id: 'AMB-003',
|
|
2177
|
+
status: 'open',
|
|
2178
|
+
summary: 'Clarify the cost labeling behavior.',
|
|
2179
|
+
obligation_ids: ['OBL-003'],
|
|
2180
|
+
},
|
|
2181
|
+
],
|
|
2182
|
+
},
|
|
2183
|
+
},
|
|
2184
|
+
},
|
|
2185
|
+
};
|
|
2186
|
+
}
|
|
2187
|
+
if (toolName === TOOLS.FEATURE_QUESTION_LIST) {
|
|
2188
|
+
return {
|
|
2189
|
+
ok: true,
|
|
2190
|
+
data: {
|
|
2191
|
+
items: [
|
|
2192
|
+
{
|
|
2193
|
+
status: 'answered',
|
|
2194
|
+
phase: STATUS.INTAKE,
|
|
2195
|
+
resume_status: STATUS.INTAKE,
|
|
2196
|
+
details: {
|
|
2197
|
+
ambiguity_ids: ['AMB-002'],
|
|
2198
|
+
},
|
|
2199
|
+
},
|
|
2200
|
+
],
|
|
2201
|
+
},
|
|
2202
|
+
};
|
|
2203
|
+
}
|
|
2204
|
+
if (toolName === TOOLS.FEATURE_QUESTION_CREATE) {
|
|
2205
|
+
return {
|
|
2206
|
+
ok: true,
|
|
2207
|
+
data: {
|
|
2208
|
+
question_id: 'q_intake_recovery',
|
|
2209
|
+
},
|
|
2210
|
+
};
|
|
2211
|
+
}
|
|
2212
|
+
return { ok: true, data: { accepted: true } };
|
|
2213
|
+
}),
|
|
2214
|
+
};
|
|
2215
|
+
const executor = new PlanningWaveExecutor({
|
|
2216
|
+
toolCaller: toolCaller as never,
|
|
2217
|
+
planGenerator: { generateInitialPlan: vi.fn() } as never,
|
|
2218
|
+
providerMode: 'live',
|
|
2219
|
+
malformedOutputAction: 'block_feature',
|
|
2220
|
+
workerDecisionRunner: {
|
|
2221
|
+
execute: vi.fn(async () => workerDecision({ invalidOutput: true })),
|
|
2222
|
+
},
|
|
2223
|
+
});
|
|
2224
|
+
|
|
2225
|
+
await executor.run([featureId]);
|
|
2226
|
+
|
|
2227
|
+
expect(toolCaller.callTool).toHaveBeenCalledWith(
|
|
2228
|
+
'orchestrator',
|
|
2229
|
+
TOOLS.FEATURE_QUESTION_CREATE,
|
|
2230
|
+
expect.objectContaining({
|
|
2231
|
+
feature_id: featureId,
|
|
2232
|
+
session_id: 'planner-session-1',
|
|
2233
|
+
phase: STATUS.INTAKE,
|
|
2234
|
+
resume_status: STATUS.INTAKE,
|
|
2235
|
+
resume_phase: STATUS.INTAKE,
|
|
2236
|
+
details: expect.objectContaining({
|
|
2237
|
+
ambiguity_ids: ['AMB-002', 'AMB-003'],
|
|
2238
|
+
obligation_ids: ['OBL-002', 'OBL-003'],
|
|
2239
|
+
prior_answered_ambiguity_ids: ['AMB-002'],
|
|
2240
|
+
recovery_reason: ERROR_CODES.PROVIDER_OUTPUT_INVALID,
|
|
2241
|
+
}),
|
|
2242
|
+
}),
|
|
2243
|
+
);
|
|
2244
|
+
const statePatchCalls = toolCaller.callTool.mock.calls.filter(
|
|
2245
|
+
(call) => call[1] === TOOLS.FEATURE_STATE_PATCH,
|
|
2246
|
+
);
|
|
2247
|
+
expect(statePatchCalls).toHaveLength(0);
|
|
2248
|
+
});
|
|
2249
|
+
|
|
2250
|
+
it('routes no-progress intake planner turns into a blocking clarification question before the retry limit', async () => {
|
|
2251
|
+
const featureId = 'feature_intake_no_progress';
|
|
2252
|
+
const toolCaller = {
|
|
2253
|
+
callTool: vi.fn(async (_role: string, toolName: string) => {
|
|
2254
|
+
if (toolName === TOOLS.FEATURE_GET_CONTEXT) {
|
|
2255
|
+
return {
|
|
2256
|
+
ok: true,
|
|
2257
|
+
data: {
|
|
2258
|
+
feature_id: featureId,
|
|
2259
|
+
state: {
|
|
2260
|
+
front_matter: {
|
|
2261
|
+
status: STATUS.INTAKE,
|
|
2262
|
+
intake: {
|
|
2263
|
+
status: 'in_progress',
|
|
2264
|
+
bootstrap_manifest_version: 1,
|
|
2265
|
+
verified_manifest_version: null,
|
|
2266
|
+
},
|
|
2267
|
+
},
|
|
2268
|
+
},
|
|
2269
|
+
plan: null,
|
|
2270
|
+
human_input: {
|
|
2271
|
+
open_questions: [],
|
|
2272
|
+
latest_answer: null,
|
|
2273
|
+
},
|
|
2274
|
+
intake: {
|
|
2275
|
+
verified_manifest: null,
|
|
2276
|
+
summary: {
|
|
2277
|
+
status: 'in_progress',
|
|
2278
|
+
verified_manifest_version: null,
|
|
2279
|
+
},
|
|
2280
|
+
review: {
|
|
2281
|
+
ambiguities: [
|
|
2282
|
+
{
|
|
2283
|
+
id: 'AMB-010',
|
|
2284
|
+
status: 'open',
|
|
2285
|
+
summary: 'Clarify the telemetry rollout behavior.',
|
|
2286
|
+
obligation_ids: ['OBL-010'],
|
|
2287
|
+
},
|
|
2288
|
+
],
|
|
2289
|
+
},
|
|
2290
|
+
},
|
|
2291
|
+
},
|
|
2292
|
+
};
|
|
2293
|
+
}
|
|
2294
|
+
if (toolName === TOOLS.FEATURE_QUESTION_LIST) {
|
|
2295
|
+
return { ok: true, data: { items: [] } };
|
|
2296
|
+
}
|
|
2297
|
+
if (toolName === TOOLS.FEATURE_QUESTION_CREATE) {
|
|
2298
|
+
return { ok: true, data: { question_id: 'q_no_progress' } };
|
|
2299
|
+
}
|
|
2300
|
+
return { ok: true, data: { accepted: true } };
|
|
2301
|
+
}),
|
|
2302
|
+
};
|
|
2303
|
+
const executor = new PlanningWaveExecutor({
|
|
2304
|
+
toolCaller: toolCaller as never,
|
|
2305
|
+
planGenerator: { generateInitialPlan: vi.fn() } as never,
|
|
2306
|
+
providerMode: 'live',
|
|
2307
|
+
noProgressLimit: 2,
|
|
2308
|
+
workerDecisionRunner: {
|
|
2309
|
+
execute: vi.fn(async () => workerDecision({ noProgress: true })),
|
|
2310
|
+
},
|
|
2311
|
+
});
|
|
2312
|
+
|
|
2313
|
+
await executor.run([featureId]);
|
|
2314
|
+
|
|
2315
|
+
expect(toolCaller.callTool).toHaveBeenCalledWith(
|
|
2316
|
+
'orchestrator',
|
|
2317
|
+
TOOLS.FEATURE_QUESTION_CREATE,
|
|
2318
|
+
expect.objectContaining({
|
|
2319
|
+
feature_id: featureId,
|
|
2320
|
+
details: expect.objectContaining({
|
|
2321
|
+
ambiguity_ids: ['AMB-010'],
|
|
2322
|
+
recovery_reason: ERROR_CODES.PROVIDER_NO_PROGRESS,
|
|
2323
|
+
}),
|
|
2324
|
+
}),
|
|
2325
|
+
);
|
|
2326
|
+
const statePatchCalls = toolCaller.callTool.mock.calls.filter(
|
|
2327
|
+
(call) => call[1] === TOOLS.FEATURE_STATE_PATCH,
|
|
2328
|
+
);
|
|
2329
|
+
expect(statePatchCalls).toHaveLength(0);
|
|
2330
|
+
});
|
|
2331
|
+
|
|
2332
|
+
it('blocks planning context stalls when intake recovery does not apply', async () => {
|
|
2333
|
+
const toolCaller = createPlanningToolCaller([STATUS.PLANNING]);
|
|
2334
|
+
const executor = new PlanningWaveExecutor({
|
|
2335
|
+
toolCaller: toolCaller as never,
|
|
2336
|
+
planGenerator: { generateInitialPlan: vi.fn() } as never,
|
|
2337
|
+
providerMode: 'live',
|
|
2338
|
+
workerDecisionRunner: {
|
|
2339
|
+
execute: vi.fn(async () =>
|
|
2340
|
+
workerDecision({
|
|
2341
|
+
contextStall: true,
|
|
2342
|
+
contextRequestCount: 3,
|
|
2343
|
+
lastContextRequestAt: '2026-03-18T08:00:00.000Z',
|
|
2344
|
+
lastContextRequestRole: 'planner',
|
|
2345
|
+
}),
|
|
2346
|
+
),
|
|
2347
|
+
},
|
|
2348
|
+
});
|
|
2349
|
+
|
|
2350
|
+
await executor.run(['feature-a']);
|
|
2351
|
+
|
|
2352
|
+
expect(toolCaller.callTool).toHaveBeenCalledWith(
|
|
2353
|
+
'orchestrator',
|
|
2354
|
+
TOOLS.FEATURE_STATE_PATCH,
|
|
2355
|
+
expect.objectContaining({
|
|
2356
|
+
feature_id: 'feature-a',
|
|
2357
|
+
patch: {
|
|
2358
|
+
front_matter: expect.objectContaining({
|
|
2359
|
+
status: STATUS.BLOCKED,
|
|
2360
|
+
status_reason: expect.stringContaining(ERROR_CODES.PROVIDER_CONTEXT_STALL),
|
|
2361
|
+
}),
|
|
2362
|
+
},
|
|
2363
|
+
}),
|
|
2364
|
+
);
|
|
2365
|
+
expect(toolCaller.callTool).not.toHaveBeenCalledWith(
|
|
2366
|
+
'orchestrator',
|
|
2367
|
+
TOOLS.FEATURE_QUESTION_CREATE,
|
|
2368
|
+
expect.any(Object),
|
|
2369
|
+
);
|
|
2370
|
+
});
|
|
2371
|
+
|
|
2372
|
+
it('routes intake context stalls into a blocking clarification question instead of blocked state', async () => {
|
|
2373
|
+
const featureId = 'feature_intake_context_stall';
|
|
2374
|
+
const toolCaller = {
|
|
2375
|
+
callTool: vi.fn(async (_role: string, toolName: string) => {
|
|
2376
|
+
if (toolName === TOOLS.FEATURE_GET_CONTEXT) {
|
|
2377
|
+
return {
|
|
2378
|
+
ok: true,
|
|
2379
|
+
data: {
|
|
2380
|
+
feature_id: featureId,
|
|
2381
|
+
state: {
|
|
2382
|
+
front_matter: {
|
|
2383
|
+
status: STATUS.BLOCKED,
|
|
2384
|
+
intake: {
|
|
2385
|
+
status: 'in_progress',
|
|
2386
|
+
bootstrap_manifest_version: 1,
|
|
2387
|
+
verified_manifest_version: null,
|
|
2388
|
+
},
|
|
2389
|
+
},
|
|
2390
|
+
},
|
|
2391
|
+
plan: null,
|
|
2392
|
+
human_input: {
|
|
2393
|
+
open_questions: [],
|
|
2394
|
+
},
|
|
2395
|
+
intake: {
|
|
2396
|
+
verified_manifest: null,
|
|
2397
|
+
summary: {
|
|
2398
|
+
status: 'in_progress',
|
|
2399
|
+
verified_manifest_version: null,
|
|
2400
|
+
},
|
|
2401
|
+
review: {
|
|
2402
|
+
ambiguities: [
|
|
2403
|
+
{
|
|
2404
|
+
id: 'AMB-011',
|
|
2405
|
+
status: 'open',
|
|
2406
|
+
summary: 'Clarify the telemetry aggregation granularity.',
|
|
2407
|
+
obligation_ids: ['OBL-011'],
|
|
2408
|
+
},
|
|
2409
|
+
],
|
|
2410
|
+
},
|
|
2411
|
+
},
|
|
2412
|
+
},
|
|
2413
|
+
};
|
|
2414
|
+
}
|
|
2415
|
+
if (toolName === TOOLS.FEATURE_QUESTION_LIST) {
|
|
2416
|
+
return { ok: true, data: { items: [] } };
|
|
2417
|
+
}
|
|
2418
|
+
if (toolName === TOOLS.FEATURE_QUESTION_CREATE) {
|
|
2419
|
+
return { ok: true, data: { question_id: 'q_context_stall' } };
|
|
2420
|
+
}
|
|
2421
|
+
return { ok: true, data: { accepted: true } };
|
|
2422
|
+
}),
|
|
2423
|
+
};
|
|
2424
|
+
const executor = new PlanningWaveExecutor({
|
|
2425
|
+
toolCaller: toolCaller as never,
|
|
2426
|
+
planGenerator: { generateInitialPlan: vi.fn() } as never,
|
|
2427
|
+
providerMode: 'live',
|
|
2428
|
+
workerDecisionRunner: {
|
|
2429
|
+
execute: vi.fn(async () => workerDecision({ contextStall: true })),
|
|
2430
|
+
},
|
|
2431
|
+
});
|
|
2432
|
+
|
|
2433
|
+
await executor.run([featureId]);
|
|
2434
|
+
|
|
2435
|
+
expect(toolCaller.callTool).toHaveBeenCalledWith(
|
|
2436
|
+
'orchestrator',
|
|
2437
|
+
TOOLS.FEATURE_QUESTION_CREATE,
|
|
2438
|
+
expect.objectContaining({
|
|
2439
|
+
feature_id: featureId,
|
|
2440
|
+
details: expect.objectContaining({
|
|
2441
|
+
ambiguity_ids: ['AMB-011'],
|
|
2442
|
+
recovery_reason: ERROR_CODES.PROVIDER_CONTEXT_STALL,
|
|
2443
|
+
}),
|
|
2444
|
+
}),
|
|
2445
|
+
);
|
|
2446
|
+
expect(toolCaller.callTool).not.toHaveBeenCalledWith(
|
|
2447
|
+
'orchestrator',
|
|
2448
|
+
TOOLS.FEATURE_STATE_PATCH,
|
|
2449
|
+
expect.objectContaining({
|
|
2450
|
+
feature_id: featureId,
|
|
2451
|
+
}),
|
|
2452
|
+
);
|
|
2453
|
+
});
|
|
2454
|
+
|
|
2455
|
+
it('keeps intake malformed output blocked when verified-manifest data already exists in an inconsistent intake context', async () => {
|
|
2456
|
+
const featureId = 'feature_intake_verified_manifest_present';
|
|
2457
|
+
const toolCaller = {
|
|
2458
|
+
callTool: vi.fn(async (_role: string, toolName: string) => {
|
|
2459
|
+
if (toolName === TOOLS.FEATURE_GET_CONTEXT) {
|
|
2460
|
+
return {
|
|
2461
|
+
ok: true,
|
|
2462
|
+
data: {
|
|
2463
|
+
feature_id: featureId,
|
|
2464
|
+
state: {
|
|
2465
|
+
front_matter: {
|
|
2466
|
+
status: STATUS.BLOCKED,
|
|
2467
|
+
intake: {
|
|
2468
|
+
status: 'in_progress',
|
|
2469
|
+
bootstrap_manifest_version: 1,
|
|
2470
|
+
verified_manifest_version: null,
|
|
2471
|
+
},
|
|
2472
|
+
},
|
|
2473
|
+
},
|
|
2474
|
+
plan: null,
|
|
2475
|
+
human_input: {
|
|
2476
|
+
open_questions: [],
|
|
2477
|
+
},
|
|
2478
|
+
intake: {
|
|
2479
|
+
verified_manifest: {
|
|
2480
|
+
manifest_version: 2,
|
|
2481
|
+
obligations: [{ obligation_id: 'OBL-030' }],
|
|
2482
|
+
},
|
|
2483
|
+
summary: {
|
|
2484
|
+
status: 'in_progress',
|
|
2485
|
+
verified_manifest_version: null,
|
|
2486
|
+
},
|
|
2487
|
+
review: {
|
|
2488
|
+
ambiguities: [
|
|
2489
|
+
{
|
|
2490
|
+
id: 'AMB-030',
|
|
2491
|
+
status: 'open',
|
|
2492
|
+
summary: 'Should not be asked again.',
|
|
2493
|
+
obligation_ids: ['OBL-030'],
|
|
2494
|
+
},
|
|
2495
|
+
],
|
|
2496
|
+
},
|
|
2497
|
+
},
|
|
2498
|
+
},
|
|
2499
|
+
};
|
|
2500
|
+
}
|
|
2501
|
+
if (toolName === TOOLS.FEATURE_STATE_GET) {
|
|
2502
|
+
return { ok: true, data: { front_matter: { version: 7 } } };
|
|
2503
|
+
}
|
|
2504
|
+
return { ok: true, data: { accepted: true } };
|
|
2505
|
+
}),
|
|
2506
|
+
};
|
|
2507
|
+
const executor = new PlanningWaveExecutor({
|
|
2508
|
+
toolCaller: toolCaller as never,
|
|
2509
|
+
planGenerator: { generateInitialPlan: vi.fn() } as never,
|
|
2510
|
+
providerMode: 'live',
|
|
2511
|
+
malformedOutputAction: 'block_feature',
|
|
2512
|
+
workerDecisionRunner: {
|
|
2513
|
+
execute: vi.fn(async () => workerDecision({ invalidOutput: true })),
|
|
2514
|
+
},
|
|
2515
|
+
});
|
|
2516
|
+
|
|
2517
|
+
await executor.run([featureId]);
|
|
2518
|
+
|
|
2519
|
+
expect(toolCaller.callTool).not.toHaveBeenCalledWith(
|
|
2520
|
+
'orchestrator',
|
|
2521
|
+
TOOLS.FEATURE_QUESTION_CREATE,
|
|
2522
|
+
expect.any(Object),
|
|
2523
|
+
);
|
|
2524
|
+
expect(toolCaller.callTool).toHaveBeenCalledWith(
|
|
2525
|
+
'orchestrator',
|
|
2526
|
+
TOOLS.FEATURE_STATE_PATCH,
|
|
2527
|
+
expect.objectContaining({
|
|
2528
|
+
feature_id: featureId,
|
|
2529
|
+
}),
|
|
2530
|
+
);
|
|
2531
|
+
});
|
|
2532
|
+
|
|
2533
|
+
it('keeps intake malformed output blocked when a clarification question is already open', async () => {
|
|
2534
|
+
const featureId = 'feature_intake_open_question_present';
|
|
2535
|
+
const toolCaller = {
|
|
2536
|
+
callTool: vi.fn(async (_role: string, toolName: string) => {
|
|
445
2537
|
if (toolName === TOOLS.FEATURE_GET_CONTEXT) {
|
|
446
|
-
const status = statuses[Math.min(statusIndex, statuses.length - 1)] ?? STATUS.PLANNING;
|
|
447
|
-
statusIndex += 1;
|
|
448
2538
|
return {
|
|
449
2539
|
ok: true,
|
|
450
2540
|
data: {
|
|
451
|
-
feature_id:
|
|
452
|
-
state: {
|
|
2541
|
+
feature_id: featureId,
|
|
2542
|
+
state: {
|
|
2543
|
+
front_matter: {
|
|
2544
|
+
status: STATUS.BLOCKED,
|
|
2545
|
+
intake: {
|
|
2546
|
+
status: 'awaiting_input',
|
|
2547
|
+
bootstrap_manifest_version: 1,
|
|
2548
|
+
verified_manifest_version: null,
|
|
2549
|
+
},
|
|
2550
|
+
},
|
|
2551
|
+
},
|
|
453
2552
|
plan: null,
|
|
2553
|
+
human_input: {
|
|
2554
|
+
open_questions: [{ question_id: 'q_existing' }],
|
|
2555
|
+
},
|
|
2556
|
+
intake: {
|
|
2557
|
+
verified_manifest: null,
|
|
2558
|
+
summary: {
|
|
2559
|
+
status: 'awaiting_input',
|
|
2560
|
+
verified_manifest_version: null,
|
|
2561
|
+
},
|
|
2562
|
+
review: {
|
|
2563
|
+
ambiguities: [
|
|
2564
|
+
{
|
|
2565
|
+
id: 'AMB-040',
|
|
2566
|
+
status: 'open',
|
|
2567
|
+
summary: 'Clarify the warning-label copy.',
|
|
2568
|
+
obligation_ids: ['OBL-040'],
|
|
2569
|
+
},
|
|
2570
|
+
],
|
|
2571
|
+
},
|
|
2572
|
+
},
|
|
454
2573
|
},
|
|
455
2574
|
};
|
|
456
2575
|
}
|
|
457
2576
|
if (toolName === TOOLS.FEATURE_STATE_GET) {
|
|
458
|
-
return { ok: true, data: { front_matter: { version:
|
|
2577
|
+
return { ok: true, data: { front_matter: { version: 8 } } };
|
|
459
2578
|
}
|
|
460
|
-
return { ok: true, data: {} };
|
|
2579
|
+
return { ok: true, data: { accepted: true } };
|
|
461
2580
|
}),
|
|
462
2581
|
};
|
|
463
|
-
|
|
2582
|
+
const executor = new PlanningWaveExecutor({
|
|
2583
|
+
toolCaller: toolCaller as never,
|
|
2584
|
+
planGenerator: { generateInitialPlan: vi.fn() } as never,
|
|
2585
|
+
providerMode: 'live',
|
|
2586
|
+
malformedOutputAction: 'block_feature',
|
|
2587
|
+
workerDecisionRunner: {
|
|
2588
|
+
execute: vi.fn(async () => workerDecision({ invalidOutput: true })),
|
|
2589
|
+
},
|
|
2590
|
+
});
|
|
464
2591
|
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
2592
|
+
await executor.run([featureId]);
|
|
2593
|
+
|
|
2594
|
+
expect(toolCaller.callTool).not.toHaveBeenCalledWith(
|
|
2595
|
+
'orchestrator',
|
|
2596
|
+
TOOLS.FEATURE_QUESTION_CREATE,
|
|
2597
|
+
expect.any(Object),
|
|
2598
|
+
);
|
|
2599
|
+
expect(toolCaller.callTool).toHaveBeenCalledWith(
|
|
2600
|
+
'orchestrator',
|
|
2601
|
+
TOOLS.FEATURE_STATE_PATCH,
|
|
2602
|
+
expect.objectContaining({
|
|
2603
|
+
feature_id: featureId,
|
|
2604
|
+
}),
|
|
2605
|
+
);
|
|
2606
|
+
});
|
|
2607
|
+
|
|
2608
|
+
it('routes malformed intake planner output into a follow-up clarification question when every open ambiguity already has answered evidence', async () => {
|
|
2609
|
+
const featureId = 'feature_intake_all_answered';
|
|
2610
|
+
const toolCaller = {
|
|
2611
|
+
callTool: vi.fn(async (_role: string, toolName: string) => {
|
|
2612
|
+
if (toolName === TOOLS.FEATURE_GET_CONTEXT) {
|
|
2613
|
+
return {
|
|
2614
|
+
ok: true,
|
|
2615
|
+
data: {
|
|
2616
|
+
feature_id: featureId,
|
|
2617
|
+
state: {
|
|
2618
|
+
front_matter: {
|
|
2619
|
+
status: STATUS.BLOCKED,
|
|
2620
|
+
intake: {
|
|
2621
|
+
status: 'in_progress',
|
|
2622
|
+
bootstrap_manifest_version: 1,
|
|
2623
|
+
verified_manifest_version: null,
|
|
2624
|
+
},
|
|
2625
|
+
},
|
|
2626
|
+
},
|
|
2627
|
+
plan: null,
|
|
2628
|
+
human_input: {
|
|
2629
|
+
open_questions: [],
|
|
2630
|
+
latest_answer: null,
|
|
2631
|
+
},
|
|
2632
|
+
intake: {
|
|
2633
|
+
verified_manifest: null,
|
|
2634
|
+
summary: {
|
|
2635
|
+
status: 'in_progress',
|
|
2636
|
+
verified_manifest_version: null,
|
|
2637
|
+
},
|
|
2638
|
+
review: {
|
|
2639
|
+
ambiguities: [
|
|
2640
|
+
{
|
|
2641
|
+
id: 'AMB-020',
|
|
2642
|
+
status: 'open',
|
|
2643
|
+
summary: 'Clarify the usage estimate labels.',
|
|
2644
|
+
obligation_ids: ['OBL-020'],
|
|
2645
|
+
},
|
|
2646
|
+
],
|
|
2647
|
+
},
|
|
2648
|
+
},
|
|
2649
|
+
},
|
|
2650
|
+
};
|
|
2651
|
+
}
|
|
2652
|
+
if (toolName === TOOLS.FEATURE_QUESTION_LIST) {
|
|
2653
|
+
return {
|
|
2654
|
+
ok: true,
|
|
2655
|
+
data: {
|
|
2656
|
+
items: [
|
|
2657
|
+
{
|
|
2658
|
+
status: 'answered',
|
|
2659
|
+
phase: STATUS.INTAKE,
|
|
2660
|
+
resume_status: STATUS.INTAKE,
|
|
2661
|
+
details: {
|
|
2662
|
+
ambiguity_ids: ['AMB-020'],
|
|
2663
|
+
},
|
|
2664
|
+
},
|
|
2665
|
+
],
|
|
2666
|
+
},
|
|
2667
|
+
};
|
|
2668
|
+
}
|
|
2669
|
+
if (toolName === TOOLS.FEATURE_QUESTION_CREATE) {
|
|
2670
|
+
return { ok: true, data: { question_id: 'q_follow_up' } };
|
|
2671
|
+
}
|
|
2672
|
+
return { ok: true, data: { accepted: true } };
|
|
2673
|
+
}),
|
|
469
2674
|
};
|
|
470
2675
|
const executor = new PlanningWaveExecutor({
|
|
471
2676
|
toolCaller: toolCaller as never,
|
|
472
|
-
planGenerator:
|
|
473
|
-
providerMode: '
|
|
2677
|
+
planGenerator: { generateInitialPlan: vi.fn() } as never,
|
|
2678
|
+
providerMode: 'live',
|
|
2679
|
+
malformedOutputAction: 'block_feature',
|
|
474
2680
|
workerDecisionRunner: {
|
|
475
|
-
execute: vi.fn(async () => workerDecision()),
|
|
2681
|
+
execute: vi.fn(async () => workerDecision({ invalidOutput: true })),
|
|
476
2682
|
},
|
|
477
2683
|
});
|
|
478
2684
|
|
|
479
|
-
await executor.run([
|
|
2685
|
+
await executor.run([featureId]);
|
|
480
2686
|
|
|
481
|
-
expect(planGenerator.generateInitialPlan).toHaveBeenCalledWith('feature-a');
|
|
482
2687
|
expect(toolCaller.callTool).toHaveBeenCalledWith(
|
|
483
|
-
'
|
|
484
|
-
TOOLS.
|
|
2688
|
+
'orchestrator',
|
|
2689
|
+
TOOLS.FEATURE_QUESTION_CREATE,
|
|
485
2690
|
expect.objectContaining({
|
|
486
|
-
feature_id:
|
|
2691
|
+
feature_id: featureId,
|
|
2692
|
+
details: expect.objectContaining({
|
|
2693
|
+
ambiguity_ids: ['AMB-020'],
|
|
2694
|
+
obligation_ids: ['OBL-020'],
|
|
2695
|
+
prior_answered_ambiguity_ids: ['AMB-020'],
|
|
2696
|
+
recovery_reason: ERROR_CODES.PROVIDER_OUTPUT_INVALID,
|
|
2697
|
+
}),
|
|
487
2698
|
}),
|
|
488
2699
|
);
|
|
2700
|
+
const statePatchCalls = toolCaller.callTool.mock.calls.filter(
|
|
2701
|
+
(call) => call[1] === TOOLS.FEATURE_STATE_PATCH,
|
|
2702
|
+
);
|
|
2703
|
+
expect(statePatchCalls).toHaveLength(0);
|
|
489
2704
|
});
|
|
490
2705
|
|
|
491
|
-
it('
|
|
492
|
-
const
|
|
493
|
-
const
|
|
494
|
-
|
|
2706
|
+
it('includes prior clarification answers in the recovery question prompt for unresolved intake ambiguities', async () => {
|
|
2707
|
+
const featureId = 'feature_intake_prior_answer_prompt';
|
|
2708
|
+
const toolCaller = {
|
|
2709
|
+
callTool: vi.fn(async (_role: string, toolName: string) => {
|
|
2710
|
+
if (toolName === TOOLS.FEATURE_GET_CONTEXT) {
|
|
2711
|
+
return {
|
|
2712
|
+
ok: true,
|
|
2713
|
+
data: {
|
|
2714
|
+
feature_id: featureId,
|
|
2715
|
+
state: {
|
|
2716
|
+
front_matter: {
|
|
2717
|
+
status: STATUS.BLOCKED,
|
|
2718
|
+
intake: {
|
|
2719
|
+
status: 'in_progress',
|
|
2720
|
+
bootstrap_manifest_version: 1,
|
|
2721
|
+
verified_manifest_version: null,
|
|
2722
|
+
},
|
|
2723
|
+
},
|
|
2724
|
+
},
|
|
2725
|
+
plan: null,
|
|
2726
|
+
human_input: {
|
|
2727
|
+
open_questions: [],
|
|
2728
|
+
latest_answer: null,
|
|
2729
|
+
},
|
|
2730
|
+
intake: {
|
|
2731
|
+
verified_manifest: null,
|
|
2732
|
+
summary: {
|
|
2733
|
+
status: 'in_progress',
|
|
2734
|
+
verified_manifest_version: null,
|
|
2735
|
+
},
|
|
2736
|
+
review: {
|
|
2737
|
+
ambiguities: [
|
|
2738
|
+
{
|
|
2739
|
+
id: 'AMB-020',
|
|
2740
|
+
status: 'open',
|
|
2741
|
+
summary: 'Clarify the usage estimate labels.',
|
|
2742
|
+
obligation_ids: ['OBL-020'],
|
|
2743
|
+
},
|
|
2744
|
+
],
|
|
2745
|
+
clarification_answers: [
|
|
2746
|
+
{
|
|
2747
|
+
question_id: 'q_prior',
|
|
2748
|
+
ambiguity_ids: ['AMB-020'],
|
|
2749
|
+
answer: {
|
|
2750
|
+
label_policy: 'always_show_estimated',
|
|
2751
|
+
},
|
|
2752
|
+
answered_at: '2026-01-01T00:05:00.000Z',
|
|
2753
|
+
},
|
|
2754
|
+
],
|
|
2755
|
+
},
|
|
2756
|
+
},
|
|
2757
|
+
},
|
|
2758
|
+
};
|
|
2759
|
+
}
|
|
2760
|
+
if (toolName === TOOLS.FEATURE_QUESTION_LIST) {
|
|
2761
|
+
return {
|
|
2762
|
+
ok: true,
|
|
2763
|
+
data: {
|
|
2764
|
+
items: [
|
|
2765
|
+
{
|
|
2766
|
+
status: 'answered',
|
|
2767
|
+
phase: STATUS.INTAKE,
|
|
2768
|
+
resume_status: STATUS.INTAKE,
|
|
2769
|
+
details: {
|
|
2770
|
+
ambiguity_ids: ['AMB-020'],
|
|
2771
|
+
},
|
|
2772
|
+
},
|
|
2773
|
+
],
|
|
2774
|
+
},
|
|
2775
|
+
};
|
|
2776
|
+
}
|
|
2777
|
+
if (toolName === TOOLS.FEATURE_QUESTION_CREATE) {
|
|
2778
|
+
return { ok: true, data: { question_id: 'q_follow_up' } };
|
|
2779
|
+
}
|
|
2780
|
+
return { ok: true, data: { accepted: true } };
|
|
2781
|
+
}),
|
|
2782
|
+
};
|
|
495
2783
|
const executor = new PlanningWaveExecutor({
|
|
496
2784
|
toolCaller: toolCaller as never,
|
|
497
2785
|
planGenerator: { generateInitialPlan: vi.fn() } as never,
|
|
498
2786
|
providerMode: 'live',
|
|
499
|
-
|
|
2787
|
+
malformedOutputAction: 'block_feature',
|
|
500
2788
|
workerDecisionRunner: {
|
|
501
|
-
execute: vi.fn(async () => {
|
|
502
|
-
throw stallError;
|
|
503
|
-
}),
|
|
2789
|
+
execute: vi.fn(async () => workerDecision({ invalidOutput: true })),
|
|
504
2790
|
},
|
|
505
2791
|
});
|
|
506
2792
|
|
|
507
|
-
await executor.run([
|
|
2793
|
+
await executor.run([featureId]);
|
|
508
2794
|
|
|
509
2795
|
expect(toolCaller.callTool).toHaveBeenCalledWith(
|
|
510
2796
|
'orchestrator',
|
|
511
|
-
TOOLS.
|
|
2797
|
+
TOOLS.FEATURE_QUESTION_CREATE,
|
|
512
2798
|
expect.objectContaining({
|
|
513
|
-
feature_id:
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
2799
|
+
feature_id: featureId,
|
|
2800
|
+
prompt: expect.stringContaining('Prior answered clarification evidence:'),
|
|
2801
|
+
}),
|
|
2802
|
+
);
|
|
2803
|
+
expect(toolCaller.callTool).toHaveBeenCalledWith(
|
|
2804
|
+
'orchestrator',
|
|
2805
|
+
TOOLS.FEATURE_QUESTION_CREATE,
|
|
2806
|
+
expect.objectContaining({
|
|
2807
|
+
prompt: expect.stringContaining('"label_policy": "always_show_estimated"'),
|
|
519
2808
|
}),
|
|
520
2809
|
);
|
|
521
2810
|
});
|
|
522
2811
|
|
|
523
|
-
it('
|
|
2812
|
+
it('keeps malformed intake planner output blocked when no open ambiguities remain to ask about', async () => {
|
|
2813
|
+
const featureId = 'feature_intake_no_open_ambiguities';
|
|
2814
|
+
const toolCaller = {
|
|
2815
|
+
callTool: vi.fn(async (_role: string, toolName: string) => {
|
|
2816
|
+
if (toolName === TOOLS.FEATURE_GET_CONTEXT) {
|
|
2817
|
+
return {
|
|
2818
|
+
ok: true,
|
|
2819
|
+
data: {
|
|
2820
|
+
feature_id: featureId,
|
|
2821
|
+
state: {
|
|
2822
|
+
front_matter: {
|
|
2823
|
+
status: STATUS.BLOCKED,
|
|
2824
|
+
intake: {
|
|
2825
|
+
status: 'in_progress',
|
|
2826
|
+
bootstrap_manifest_version: 1,
|
|
2827
|
+
verified_manifest_version: null,
|
|
2828
|
+
},
|
|
2829
|
+
},
|
|
2830
|
+
},
|
|
2831
|
+
plan: null,
|
|
2832
|
+
human_input: {
|
|
2833
|
+
open_questions: [],
|
|
2834
|
+
},
|
|
2835
|
+
intake: {
|
|
2836
|
+
verified_manifest: null,
|
|
2837
|
+
summary: {
|
|
2838
|
+
status: 'in_progress',
|
|
2839
|
+
verified_manifest_version: null,
|
|
2840
|
+
},
|
|
2841
|
+
review: {
|
|
2842
|
+
ambiguities: [],
|
|
2843
|
+
},
|
|
2844
|
+
},
|
|
2845
|
+
},
|
|
2846
|
+
};
|
|
2847
|
+
}
|
|
2848
|
+
if (toolName === TOOLS.FEATURE_QUESTION_LIST) {
|
|
2849
|
+
return { ok: true, data: { items: [] } };
|
|
2850
|
+
}
|
|
2851
|
+
if (toolName === TOOLS.FEATURE_STATE_GET) {
|
|
2852
|
+
return { ok: true, data: { front_matter: { version: 5 } } };
|
|
2853
|
+
}
|
|
2854
|
+
return { ok: true, data: { accepted: true } };
|
|
2855
|
+
}),
|
|
2856
|
+
};
|
|
2857
|
+
const executor = new PlanningWaveExecutor({
|
|
2858
|
+
toolCaller: toolCaller as never,
|
|
2859
|
+
planGenerator: { generateInitialPlan: vi.fn() } as never,
|
|
2860
|
+
providerMode: 'live',
|
|
2861
|
+
malformedOutputAction: 'block_feature',
|
|
2862
|
+
workerDecisionRunner: {
|
|
2863
|
+
execute: vi.fn(async () => workerDecision({ invalidOutput: true })),
|
|
2864
|
+
},
|
|
2865
|
+
});
|
|
2866
|
+
|
|
2867
|
+
await executor.run([featureId]);
|
|
2868
|
+
|
|
2869
|
+
expect(toolCaller.callTool).not.toHaveBeenCalledWith(
|
|
2870
|
+
'orchestrator',
|
|
2871
|
+
TOOLS.FEATURE_QUESTION_CREATE,
|
|
2872
|
+
expect.anything(),
|
|
2873
|
+
);
|
|
2874
|
+
const statePatchCalls = toolCaller.callTool.mock.calls.filter(
|
|
2875
|
+
(call) => call[1] === TOOLS.FEATURE_STATE_PATCH,
|
|
2876
|
+
);
|
|
2877
|
+
expect(statePatchCalls).toHaveLength(1);
|
|
2878
|
+
});
|
|
2879
|
+
|
|
2880
|
+
it('throws on malformed planner output when fail-run policy is configured', async () => {
|
|
524
2881
|
const toolCaller = createPlanningToolCaller([STATUS.PLANNING]);
|
|
525
|
-
const nonMappedError = new Error('bad output') as Error & { code?: string };
|
|
526
|
-
nonMappedError.code = ERROR_CODES.PROVIDER_OUTPUT_INVALID;
|
|
527
2882
|
const executor = new PlanningWaveExecutor({
|
|
528
2883
|
toolCaller: toolCaller as never,
|
|
529
2884
|
planGenerator: { generateInitialPlan: vi.fn() } as never,
|
|
530
2885
|
providerMode: 'live',
|
|
2886
|
+
malformedOutputAction: 'fail_run',
|
|
531
2887
|
workerDecisionRunner: {
|
|
532
|
-
execute: vi.fn(async () => {
|
|
533
|
-
throw nonMappedError;
|
|
534
|
-
}),
|
|
2888
|
+
execute: vi.fn(async () => workerDecision({ invalidOutput: true })),
|
|
535
2889
|
},
|
|
536
2890
|
});
|
|
537
2891
|
|
|
@@ -540,40 +2894,144 @@ describe('PlanningWaveExecutor live watchdog and semantic policies', () => {
|
|
|
540
2894
|
});
|
|
541
2895
|
});
|
|
542
2896
|
|
|
543
|
-
it('
|
|
2897
|
+
it('tracks no-progress iterations and blocks on the configured limit', async () => {
|
|
2898
|
+
const toolCaller = createPlanningToolCaller([STATUS.PLANNING, STATUS.PLANNING]);
|
|
2899
|
+
const executor = new PlanningWaveExecutor({
|
|
2900
|
+
toolCaller: toolCaller as never,
|
|
2901
|
+
planGenerator: { generateInitialPlan: vi.fn() } as never,
|
|
2902
|
+
providerMode: 'live',
|
|
2903
|
+
noProgressLimit: 2,
|
|
2904
|
+
noProgressAction: 'block_feature',
|
|
2905
|
+
workerDecisionRunner: {
|
|
2906
|
+
execute: vi.fn(async () => workerDecision({ noProgress: true })),
|
|
2907
|
+
},
|
|
2908
|
+
});
|
|
2909
|
+
|
|
2910
|
+
await executor.run(['feature-a']);
|
|
2911
|
+
await executor.run(['feature-a']);
|
|
2912
|
+
|
|
2913
|
+
const statePatchCalls = toolCaller.callTool.mock.calls.filter(
|
|
2914
|
+
(call) => call[1] === TOOLS.FEATURE_STATE_PATCH,
|
|
2915
|
+
);
|
|
2916
|
+
expect(statePatchCalls).toHaveLength(1);
|
|
2917
|
+
});
|
|
2918
|
+
|
|
2919
|
+
it('throws on no-progress limit when fail-run policy is configured', async () => {
|
|
2920
|
+
const toolCaller = createPlanningToolCaller([STATUS.PLANNING]);
|
|
2921
|
+
const executor = new PlanningWaveExecutor({
|
|
2922
|
+
toolCaller: toolCaller as never,
|
|
2923
|
+
planGenerator: { generateInitialPlan: vi.fn() } as never,
|
|
2924
|
+
providerMode: 'live',
|
|
2925
|
+
noProgressLimit: 1,
|
|
2926
|
+
noProgressAction: 'fail_run',
|
|
2927
|
+
workerDecisionRunner: {
|
|
2928
|
+
execute: vi.fn(async () => workerDecision({ noProgress: true })),
|
|
2929
|
+
},
|
|
2930
|
+
});
|
|
2931
|
+
|
|
2932
|
+
await expect(executor.run(['feature-a'])).rejects.toMatchObject({
|
|
2933
|
+
code: ERROR_CODES.PROVIDER_NO_PROGRESS,
|
|
2934
|
+
});
|
|
2935
|
+
});
|
|
2936
|
+
|
|
2937
|
+
it('ignores no-progress policy in stub mode and still submits fallback plans', async () => {
|
|
2938
|
+
const toolCaller = createPlanningToolCaller([STATUS.PLANNING]);
|
|
2939
|
+
const planGenerator = {
|
|
2940
|
+
generateInitialPlan: vi.fn(async () => ({ feature_id: 'feature-a', plan_version: 1 })),
|
|
2941
|
+
};
|
|
2942
|
+
const executor = new PlanningWaveExecutor({
|
|
2943
|
+
toolCaller: toolCaller as never,
|
|
2944
|
+
planGenerator: planGenerator as never,
|
|
2945
|
+
providerMode: 'stub',
|
|
2946
|
+
workerDecisionRunner: {
|
|
2947
|
+
execute: vi.fn(async () => workerDecision({ noProgress: true })),
|
|
2948
|
+
},
|
|
2949
|
+
});
|
|
2950
|
+
|
|
2951
|
+
await executor.run(['feature-a']);
|
|
2952
|
+
|
|
2953
|
+
expect(planGenerator.generateInitialPlan).toHaveBeenCalledWith('feature-a');
|
|
2954
|
+
expect(toolCaller.callTool).toHaveBeenCalledWith(
|
|
2955
|
+
'planner',
|
|
2956
|
+
TOOLS.PLAN_SUBMIT,
|
|
2957
|
+
expect.objectContaining({ feature_id: 'feature-a' }),
|
|
2958
|
+
);
|
|
2959
|
+
});
|
|
2960
|
+
|
|
2961
|
+
it('skips fallback plan generation when the planner requested human input', async () => {
|
|
2962
|
+
const toolCaller = createPlanningToolCaller([STATUS.PLANNING]);
|
|
2963
|
+
const planGenerator = {
|
|
2964
|
+
generateInitialPlan: vi.fn(async () => ({ feature_id: 'feature-a', plan_version: 1 })),
|
|
2965
|
+
};
|
|
2966
|
+
const executor = new PlanningWaveExecutor({
|
|
2967
|
+
toolCaller: toolCaller as never,
|
|
2968
|
+
planGenerator: planGenerator as never,
|
|
2969
|
+
providerMode: 'live',
|
|
2970
|
+
workerDecisionRunner: {
|
|
2971
|
+
execute: vi.fn(async () => workerDecision({ questionRequested: true })),
|
|
2972
|
+
},
|
|
2973
|
+
});
|
|
2974
|
+
|
|
2975
|
+
await executor.run(['feature-a']);
|
|
2976
|
+
|
|
2977
|
+
expect(planGenerator.generateInitialPlan).not.toHaveBeenCalled();
|
|
2978
|
+
const planSubmitCalls = toolCaller.callTool.mock.calls.filter(
|
|
2979
|
+
(call) => call[1] === TOOLS.PLAN_SUBMIT,
|
|
2980
|
+
);
|
|
2981
|
+
expect(planSubmitCalls).toHaveLength(0);
|
|
2982
|
+
});
|
|
2983
|
+
|
|
2984
|
+
it('blocks planner execution on repeated context refresh with no progress', async () => {
|
|
544
2985
|
const toolCaller = createPlanningToolCaller([STATUS.PLANNING]);
|
|
545
2986
|
const executor = new PlanningWaveExecutor({
|
|
546
2987
|
toolCaller: toolCaller as never,
|
|
547
2988
|
planGenerator: { generateInitialPlan: vi.fn() } as never,
|
|
548
2989
|
providerMode: 'live',
|
|
549
|
-
outputLoopStallAction: 'block_feature',
|
|
550
|
-
outputLoopDetector: {
|
|
551
|
-
threshold: 2,
|
|
552
|
-
check: () => ({
|
|
553
|
-
fingerprint: 'sha256:loop',
|
|
554
|
-
isLoop: true,
|
|
555
|
-
consecutiveIdentical: 1,
|
|
556
|
-
lastUniqueIteration: 1,
|
|
557
|
-
}),
|
|
558
|
-
reset: vi.fn(),
|
|
559
|
-
} as never,
|
|
560
2990
|
workerDecisionRunner: {
|
|
561
2991
|
execute: vi.fn(async () =>
|
|
562
|
-
workerDecision({
|
|
2992
|
+
workerDecision({
|
|
2993
|
+
contextStall: true,
|
|
2994
|
+
contextRequestCount: 2,
|
|
2995
|
+
lastContextRequestAt: '2026-03-16T09:30:00.000Z',
|
|
2996
|
+
lastContextRequestRole: 'planner',
|
|
2997
|
+
}),
|
|
563
2998
|
),
|
|
564
2999
|
},
|
|
565
3000
|
});
|
|
566
3001
|
|
|
567
3002
|
await executor.run(['feature-a']);
|
|
568
3003
|
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
3004
|
+
expect(toolCaller.callTool).toHaveBeenCalledWith(
|
|
3005
|
+
'orchestrator',
|
|
3006
|
+
TOOLS.FEATURE_STATE_PATCH,
|
|
3007
|
+
expect.objectContaining({
|
|
3008
|
+
feature_id: 'feature-a',
|
|
3009
|
+
expected_version: 3,
|
|
3010
|
+
patch: {
|
|
3011
|
+
front_matter: expect.objectContaining({
|
|
3012
|
+
status: STATUS.BLOCKED,
|
|
3013
|
+
status_reason: `${ERROR_CODES.PROVIDER_CONTEXT_STALL}: repeated context refresh with no progress`,
|
|
3014
|
+
context_request_count: 2,
|
|
3015
|
+
last_context_request_at: '2026-03-16T09:30:00.000Z',
|
|
3016
|
+
last_context_request_role: 'planner',
|
|
3017
|
+
recovery: expect.objectContaining({
|
|
3018
|
+
state: 'retrying',
|
|
3019
|
+
cause: ERROR_CODES.PROVIDER_CONTEXT_STALL,
|
|
3020
|
+
role: 'planner',
|
|
3021
|
+
resume_phase: 'planning',
|
|
3022
|
+
attempt: 1,
|
|
3023
|
+
}),
|
|
3024
|
+
}),
|
|
3025
|
+
},
|
|
3026
|
+
}),
|
|
575
3027
|
);
|
|
576
|
-
|
|
3028
|
+
const logged = readLoggedNote(toolCaller);
|
|
3029
|
+
expect(logged).toMatchObject({
|
|
3030
|
+
phase: 'planning',
|
|
3031
|
+
error_code: ERROR_CODES.PROVIDER_CONTEXT_STALL,
|
|
3032
|
+
context_request_count: 2,
|
|
3033
|
+
last_context_request_role: 'planner',
|
|
3034
|
+
});
|
|
577
3035
|
});
|
|
578
3036
|
|
|
579
3037
|
it('resets planner loop state after blocked-to-planning transition', async () => {
|
|
@@ -606,4 +3064,732 @@ describe('PlanningWaveExecutor live watchdog and semantic policies', () => {
|
|
|
606
3064
|
expect(loopDetector.reset).toHaveBeenCalledTimes(1);
|
|
607
3065
|
expect(loopDetector.reset).toHaveBeenCalledWith('feature-a');
|
|
608
3066
|
});
|
|
3067
|
+
|
|
3068
|
+
it('returns the configured run id when a non-empty string run id is provided', () => {
|
|
3069
|
+
const executor = new PlanningWaveExecutor({
|
|
3070
|
+
toolCaller: { callTool: vi.fn() } as never,
|
|
3071
|
+
planGenerator: { generateInitialPlan: vi.fn() } as never,
|
|
3072
|
+
runId: 'run:planning:test',
|
|
3073
|
+
});
|
|
3074
|
+
|
|
3075
|
+
expect((executor as unknown as { resolveRunId: () => string }).resolveRunId()).toBe(
|
|
3076
|
+
'run:planning:test',
|
|
3077
|
+
);
|
|
3078
|
+
});
|
|
3079
|
+
|
|
3080
|
+
it('falls back to an unknown run id when a run-id callback returns an empty string', () => {
|
|
3081
|
+
const executor = new PlanningWaveExecutor({
|
|
3082
|
+
toolCaller: { callTool: vi.fn() } as never,
|
|
3083
|
+
planGenerator: { generateInitialPlan: vi.fn() } as never,
|
|
3084
|
+
runId: () => '',
|
|
3085
|
+
});
|
|
3086
|
+
|
|
3087
|
+
expect((executor as unknown as { resolveRunId: () => string }).resolveRunId()).toMatch(
|
|
3088
|
+
/^run:unknown:/,
|
|
3089
|
+
);
|
|
3090
|
+
});
|
|
3091
|
+
|
|
3092
|
+
it('rethrows runtime failures immediately when the planner is not running in live mode', async () => {
|
|
3093
|
+
const executor = new PlanningWaveExecutor({
|
|
3094
|
+
toolCaller: { callTool: vi.fn() } as never,
|
|
3095
|
+
planGenerator: { generateInitialPlan: vi.fn() } as never,
|
|
3096
|
+
providerMode: 'stub',
|
|
3097
|
+
});
|
|
3098
|
+
const error = new Error('stub failure');
|
|
3099
|
+
|
|
3100
|
+
await expect(
|
|
3101
|
+
(
|
|
3102
|
+
executor as unknown as {
|
|
3103
|
+
handleRuntimeFailure: (error: Error, featureId: string) => Promise<boolean>;
|
|
3104
|
+
}
|
|
3105
|
+
).handleRuntimeFailure(error, 'feature-a'),
|
|
3106
|
+
).rejects.toBe(error);
|
|
3107
|
+
});
|
|
3108
|
+
|
|
3109
|
+
it('marks blocked features as stale when only full gate evidence is stale', async () => {
|
|
3110
|
+
const executor = new PlanningWaveExecutor({
|
|
3111
|
+
toolCaller: { callTool: vi.fn() } as never,
|
|
3112
|
+
planGenerator: { generateInitialPlan: vi.fn() } as never,
|
|
3113
|
+
});
|
|
3114
|
+
|
|
3115
|
+
const decision = await (
|
|
3116
|
+
executor as unknown as {
|
|
3117
|
+
evaluateReconciliationDecision: (
|
|
3118
|
+
context: Record<string, unknown>,
|
|
3119
|
+
plan: Record<string, unknown>,
|
|
3120
|
+
status: string,
|
|
3121
|
+
) => Promise<{ executionDisposition: string; reasons: string[] }>;
|
|
3122
|
+
}
|
|
3123
|
+
).evaluateReconciliationDecision(
|
|
3124
|
+
{
|
|
3125
|
+
state: {
|
|
3126
|
+
front_matter: {
|
|
3127
|
+
evidence: {
|
|
3128
|
+
last_gate_mode: 'fast',
|
|
3129
|
+
},
|
|
3130
|
+
checkpoints: [
|
|
3131
|
+
{
|
|
3132
|
+
checkpoint_id: 'cp-1',
|
|
3133
|
+
validation_status: 'valid',
|
|
3134
|
+
diff_hash: 'hash-current',
|
|
3135
|
+
},
|
|
3136
|
+
],
|
|
3137
|
+
},
|
|
3138
|
+
},
|
|
3139
|
+
gate_evidence_by_mode: {
|
|
3140
|
+
fast: {
|
|
3141
|
+
mode: 'fast',
|
|
3142
|
+
overall: 'pass',
|
|
3143
|
+
input_diff_hash: 'hash-current',
|
|
3144
|
+
input_checkpoint_id: 'cp-1',
|
|
3145
|
+
input_worktree_validity: 'valid',
|
|
3146
|
+
finished_at: '2026-01-01T00:00:00.000Z',
|
|
3147
|
+
},
|
|
3148
|
+
full: {
|
|
3149
|
+
mode: 'full',
|
|
3150
|
+
overall: 'pass',
|
|
3151
|
+
input_diff_hash: 'hash-stale',
|
|
3152
|
+
input_checkpoint_id: 'cp-0',
|
|
3153
|
+
input_worktree_validity: 'valid',
|
|
3154
|
+
finished_at: '2025-12-31T00:00:00.000Z',
|
|
3155
|
+
},
|
|
3156
|
+
},
|
|
3157
|
+
latest_evidence: {
|
|
3158
|
+
mode: 'fast',
|
|
3159
|
+
overall: 'pass',
|
|
3160
|
+
},
|
|
3161
|
+
qa_test_index: {
|
|
3162
|
+
summary: { pending: 0, failed: 0, running: 0 },
|
|
3163
|
+
},
|
|
3164
|
+
},
|
|
3165
|
+
basePlan('feature-a'),
|
|
3166
|
+
STATUS.BLOCKED,
|
|
3167
|
+
);
|
|
3168
|
+
|
|
3169
|
+
expect(decision.executionDisposition).toBe('rerun_full_gate');
|
|
3170
|
+
expect(decision.reasons).toEqual(expect.arrayContaining(['gate_evidence_stale:full']));
|
|
3171
|
+
});
|
|
3172
|
+
|
|
3173
|
+
it('marks QA features as converged when full gate evidence is current and no work remains', async () => {
|
|
3174
|
+
const executor = new PlanningWaveExecutor({
|
|
3175
|
+
toolCaller: { callTool: vi.fn() } as never,
|
|
3176
|
+
planGenerator: { generateInitialPlan: vi.fn() } as never,
|
|
3177
|
+
});
|
|
3178
|
+
|
|
3179
|
+
const decision = await (
|
|
3180
|
+
executor as unknown as {
|
|
3181
|
+
evaluateReconciliationDecision: (
|
|
3182
|
+
context: Record<string, unknown>,
|
|
3183
|
+
plan: Record<string, unknown>,
|
|
3184
|
+
status: string,
|
|
3185
|
+
) => Promise<{ executionDisposition: string }>;
|
|
3186
|
+
}
|
|
3187
|
+
).evaluateReconciliationDecision(
|
|
3188
|
+
{
|
|
3189
|
+
state: {
|
|
3190
|
+
front_matter: {
|
|
3191
|
+
checkpoints: [
|
|
3192
|
+
{
|
|
3193
|
+
checkpoint_id: 'cp-1',
|
|
3194
|
+
validation_status: 'valid',
|
|
3195
|
+
diff_hash: 'hash-current',
|
|
3196
|
+
},
|
|
3197
|
+
],
|
|
3198
|
+
},
|
|
3199
|
+
},
|
|
3200
|
+
gate_evidence_by_mode: {
|
|
3201
|
+
full: {
|
|
3202
|
+
mode: 'full',
|
|
3203
|
+
overall: 'pass',
|
|
3204
|
+
input_diff_hash: 'hash-current',
|
|
3205
|
+
input_checkpoint_id: 'cp-1',
|
|
3206
|
+
input_worktree_validity: 'valid',
|
|
3207
|
+
finished_at: '2026-01-01T00:00:00.000Z',
|
|
3208
|
+
},
|
|
3209
|
+
},
|
|
3210
|
+
latest_evidence: {
|
|
3211
|
+
mode: 'full',
|
|
3212
|
+
overall: 'pass',
|
|
3213
|
+
},
|
|
3214
|
+
qa_test_index: {
|
|
3215
|
+
summary: { pending: 0, failed: 0, running: 0 },
|
|
3216
|
+
},
|
|
3217
|
+
},
|
|
3218
|
+
basePlan('feature-a'),
|
|
3219
|
+
STATUS.QA,
|
|
3220
|
+
);
|
|
3221
|
+
|
|
3222
|
+
expect(decision.executionDisposition).toBe('converged');
|
|
3223
|
+
});
|
|
3224
|
+
|
|
3225
|
+
it('returns gate failure context without log analysis when the log file cannot be read', async () => {
|
|
3226
|
+
const executor = new PlanningWaveExecutor({
|
|
3227
|
+
toolCaller: { callTool: vi.fn() } as never,
|
|
3228
|
+
planGenerator: { generateInitialPlan: vi.fn() } as never,
|
|
3229
|
+
repoRoot: '/tmp/aop-missing-log-root',
|
|
3230
|
+
});
|
|
3231
|
+
|
|
3232
|
+
const failureContext = await (
|
|
3233
|
+
executor as unknown as {
|
|
3234
|
+
extractGateFailureContext: (
|
|
3235
|
+
context: Record<string, unknown>,
|
|
3236
|
+
) => Promise<Record<string, unknown> | null>;
|
|
3237
|
+
}
|
|
3238
|
+
).extractGateFailureContext({
|
|
3239
|
+
latest_evidence: {
|
|
3240
|
+
mode: 'full',
|
|
3241
|
+
overall: 'fail',
|
|
3242
|
+
notes: ['gate failed'],
|
|
3243
|
+
step_results: [
|
|
3244
|
+
{
|
|
3245
|
+
name: 'full-check',
|
|
3246
|
+
cmd: ['npm', 'test'],
|
|
3247
|
+
exit_code: 1,
|
|
3248
|
+
log_path: 'missing.log',
|
|
3249
|
+
},
|
|
3250
|
+
],
|
|
3251
|
+
},
|
|
3252
|
+
});
|
|
3253
|
+
|
|
3254
|
+
expect(failureContext).toMatchObject({
|
|
3255
|
+
gate_name: 'full',
|
|
3256
|
+
step_name: 'full-check',
|
|
3257
|
+
exit_code: 1,
|
|
3258
|
+
affected_files: [],
|
|
3259
|
+
error_lines: [],
|
|
3260
|
+
summary_lines: [],
|
|
3261
|
+
notes: ['gate failed'],
|
|
3262
|
+
});
|
|
3263
|
+
});
|
|
3264
|
+
|
|
3265
|
+
it('marks blocked reconciliation as provider failure when status_reason carries provider_output_invalid', async () => {
|
|
3266
|
+
const executor = new PlanningWaveExecutor({
|
|
3267
|
+
toolCaller: { callTool: vi.fn() } as never,
|
|
3268
|
+
planGenerator: { generateInitialPlan: vi.fn() } as never,
|
|
3269
|
+
});
|
|
3270
|
+
|
|
3271
|
+
const decision = await (
|
|
3272
|
+
executor as unknown as {
|
|
3273
|
+
evaluateReconciliationDecision: (
|
|
3274
|
+
context: Record<string, unknown>,
|
|
3275
|
+
plan: Record<string, unknown>,
|
|
3276
|
+
status: string,
|
|
3277
|
+
) => Promise<{ executionDisposition: string; reasons: string[] }>;
|
|
3278
|
+
}
|
|
3279
|
+
).evaluateReconciliationDecision(
|
|
3280
|
+
{
|
|
3281
|
+
state: {
|
|
3282
|
+
front_matter: {
|
|
3283
|
+
status: STATUS.BLOCKED,
|
|
3284
|
+
status_reason: `blocked:${ERROR_CODES.PROVIDER_OUTPUT_INVALID}`,
|
|
3285
|
+
evidence: {
|
|
3286
|
+
last_gate_mode: 'fast',
|
|
3287
|
+
},
|
|
3288
|
+
checkpoints: [
|
|
3289
|
+
{
|
|
3290
|
+
checkpoint_id: 'cp-1',
|
|
3291
|
+
validation_status: 'valid',
|
|
3292
|
+
diff_hash: 'hash-current',
|
|
3293
|
+
},
|
|
3294
|
+
],
|
|
3295
|
+
},
|
|
3296
|
+
},
|
|
3297
|
+
latest_evidence: {
|
|
3298
|
+
mode: 'fast',
|
|
3299
|
+
overall: 'fail',
|
|
3300
|
+
input_diff_hash: 'hash-current',
|
|
3301
|
+
input_checkpoint_id: 'cp-1',
|
|
3302
|
+
input_worktree_validity: 'valid',
|
|
3303
|
+
},
|
|
3304
|
+
gate_evidence_by_mode: {
|
|
3305
|
+
fast: {
|
|
3306
|
+
mode: 'fast',
|
|
3307
|
+
overall: 'fail',
|
|
3308
|
+
input_diff_hash: 'hash-current',
|
|
3309
|
+
input_checkpoint_id: 'cp-1',
|
|
3310
|
+
input_worktree_validity: 'valid',
|
|
3311
|
+
},
|
|
3312
|
+
},
|
|
3313
|
+
qa_test_index: {
|
|
3314
|
+
summary: { pending: 0, failed: 0, running: 0 },
|
|
3315
|
+
},
|
|
3316
|
+
},
|
|
3317
|
+
basePlan('feature-provider-invalid-direct'),
|
|
3318
|
+
STATUS.BLOCKED,
|
|
3319
|
+
);
|
|
3320
|
+
|
|
3321
|
+
expect(decision.executionDisposition).toBe('blocked_provider_failure');
|
|
3322
|
+
expect(decision.reasons).toEqual(expect.arrayContaining(['provider_output_invalid']));
|
|
3323
|
+
});
|
|
3324
|
+
|
|
3325
|
+
it('requests a plan update when verified manifest obligations are missing from plan_trace', async () => {
|
|
3326
|
+
const executor = new PlanningWaveExecutor({
|
|
3327
|
+
toolCaller: { callTool: vi.fn() } as never,
|
|
3328
|
+
planGenerator: { generateInitialPlan: vi.fn() } as never,
|
|
3329
|
+
});
|
|
3330
|
+
|
|
3331
|
+
const decision = await (
|
|
3332
|
+
executor as unknown as {
|
|
3333
|
+
evaluateReconciliationDecision: (
|
|
3334
|
+
context: Record<string, unknown>,
|
|
3335
|
+
plan: Record<string, unknown>,
|
|
3336
|
+
status: string,
|
|
3337
|
+
) => Promise<{
|
|
3338
|
+
planDecision: string;
|
|
3339
|
+
reasons: string[];
|
|
3340
|
+
acceptanceCriteriaAdditions: string[];
|
|
3341
|
+
}>;
|
|
3342
|
+
}
|
|
3343
|
+
).evaluateReconciliationDecision(
|
|
3344
|
+
{
|
|
3345
|
+
state: {
|
|
3346
|
+
front_matter: {
|
|
3347
|
+
status: STATUS.BLOCKED,
|
|
3348
|
+
checkpoints: [
|
|
3349
|
+
{
|
|
3350
|
+
checkpoint_id: 'cp-1',
|
|
3351
|
+
validation_status: 'valid',
|
|
3352
|
+
diff_hash: 'hash-current',
|
|
3353
|
+
},
|
|
3354
|
+
],
|
|
3355
|
+
},
|
|
3356
|
+
},
|
|
3357
|
+
intake: {
|
|
3358
|
+
verified_manifest: {
|
|
3359
|
+
obligations: [
|
|
3360
|
+
{
|
|
3361
|
+
obligation_id: 'OBL-MISSING-TRACE',
|
|
3362
|
+
kind: 'contract',
|
|
3363
|
+
verification_hint: 'required',
|
|
3364
|
+
},
|
|
3365
|
+
],
|
|
3366
|
+
},
|
|
3367
|
+
},
|
|
3368
|
+
latest_evidence: {
|
|
3369
|
+
mode: 'full',
|
|
3370
|
+
overall: 'pass',
|
|
3371
|
+
input_diff_hash: 'hash-current',
|
|
3372
|
+
input_checkpoint_id: 'cp-1',
|
|
3373
|
+
input_worktree_validity: 'valid',
|
|
3374
|
+
},
|
|
3375
|
+
gate_evidence_by_mode: {
|
|
3376
|
+
full: {
|
|
3377
|
+
mode: 'full',
|
|
3378
|
+
overall: 'pass',
|
|
3379
|
+
input_diff_hash: 'hash-current',
|
|
3380
|
+
input_checkpoint_id: 'cp-1',
|
|
3381
|
+
input_worktree_validity: 'valid',
|
|
3382
|
+
},
|
|
3383
|
+
},
|
|
3384
|
+
qa_test_index: {
|
|
3385
|
+
summary: { pending: 0, failed: 0, running: 0 },
|
|
3386
|
+
},
|
|
3387
|
+
},
|
|
3388
|
+
{
|
|
3389
|
+
...basePlan('feature-missing-trace-direct'),
|
|
3390
|
+
plan_trace: [],
|
|
3391
|
+
},
|
|
3392
|
+
STATUS.BLOCKED,
|
|
3393
|
+
);
|
|
3394
|
+
|
|
3395
|
+
expect(decision.planDecision).toBe('update_required');
|
|
3396
|
+
expect(decision.reasons).toEqual(expect.arrayContaining(['verified_manifest_trace_missing:1']));
|
|
3397
|
+
expect(decision.acceptanceCriteriaAdditions).toEqual(
|
|
3398
|
+
expect.arrayContaining([
|
|
3399
|
+
'plan_trace maps every verified manifest obligation_id into planned implementation and verification work.',
|
|
3400
|
+
]),
|
|
3401
|
+
);
|
|
3402
|
+
});
|
|
3403
|
+
|
|
3404
|
+
it('marks blocked reconciliation as blocked_other when fast failure evidence is current', async () => {
|
|
3405
|
+
const executor = new PlanningWaveExecutor({
|
|
3406
|
+
toolCaller: { callTool: vi.fn() } as never,
|
|
3407
|
+
planGenerator: { generateInitialPlan: vi.fn() } as never,
|
|
3408
|
+
});
|
|
3409
|
+
|
|
3410
|
+
const decision = await (
|
|
3411
|
+
executor as unknown as {
|
|
3412
|
+
evaluateReconciliationDecision: (
|
|
3413
|
+
context: Record<string, unknown>,
|
|
3414
|
+
plan: Record<string, unknown>,
|
|
3415
|
+
status: string,
|
|
3416
|
+
) => Promise<{ executionDisposition: string }>;
|
|
3417
|
+
}
|
|
3418
|
+
).evaluateReconciliationDecision(
|
|
3419
|
+
{
|
|
3420
|
+
state: {
|
|
3421
|
+
front_matter: {
|
|
3422
|
+
status: STATUS.BLOCKED,
|
|
3423
|
+
evidence: {
|
|
3424
|
+
last_gate_mode: 'fast',
|
|
3425
|
+
},
|
|
3426
|
+
checkpoints: [
|
|
3427
|
+
{
|
|
3428
|
+
checkpoint_id: 'cp-1',
|
|
3429
|
+
validation_status: 'valid',
|
|
3430
|
+
diff_hash: 'hash-current',
|
|
3431
|
+
},
|
|
3432
|
+
],
|
|
3433
|
+
},
|
|
3434
|
+
},
|
|
3435
|
+
latest_evidence: {
|
|
3436
|
+
mode: 'fast',
|
|
3437
|
+
overall: 'fail',
|
|
3438
|
+
input_diff_hash: 'hash-current',
|
|
3439
|
+
input_checkpoint_id: 'cp-1',
|
|
3440
|
+
input_worktree_validity: 'valid',
|
|
3441
|
+
},
|
|
3442
|
+
gate_evidence_by_mode: {
|
|
3443
|
+
fast: {
|
|
3444
|
+
mode: 'fast',
|
|
3445
|
+
overall: 'fail',
|
|
3446
|
+
input_diff_hash: 'hash-current',
|
|
3447
|
+
input_checkpoint_id: 'cp-1',
|
|
3448
|
+
input_worktree_validity: 'valid',
|
|
3449
|
+
},
|
|
3450
|
+
},
|
|
3451
|
+
qa_test_index: {
|
|
3452
|
+
summary: { pending: 0, failed: 0, running: 0 },
|
|
3453
|
+
},
|
|
3454
|
+
},
|
|
3455
|
+
basePlan('feature-fast-fail-direct'),
|
|
3456
|
+
STATUS.BLOCKED,
|
|
3457
|
+
);
|
|
3458
|
+
|
|
3459
|
+
expect(decision.executionDisposition).toBe('blocked_other');
|
|
3460
|
+
});
|
|
3461
|
+
|
|
3462
|
+
it('marks blocked reconciliation as stale evidence when the last full gate is stale', async () => {
|
|
3463
|
+
const executor = new PlanningWaveExecutor({
|
|
3464
|
+
toolCaller: { callTool: vi.fn() } as never,
|
|
3465
|
+
planGenerator: { generateInitialPlan: vi.fn() } as never,
|
|
3466
|
+
});
|
|
3467
|
+
|
|
3468
|
+
const decision = await (
|
|
3469
|
+
executor as unknown as {
|
|
3470
|
+
evaluateReconciliationDecision: (
|
|
3471
|
+
context: Record<string, unknown>,
|
|
3472
|
+
plan: Record<string, unknown>,
|
|
3473
|
+
status: string,
|
|
3474
|
+
) => Promise<{ executionDisposition: string; reasons: string[] }>;
|
|
3475
|
+
}
|
|
3476
|
+
).evaluateReconciliationDecision(
|
|
3477
|
+
{
|
|
3478
|
+
state: {
|
|
3479
|
+
front_matter: {
|
|
3480
|
+
status: STATUS.BLOCKED,
|
|
3481
|
+
evidence: {
|
|
3482
|
+
last_gate_mode: 'full',
|
|
3483
|
+
},
|
|
3484
|
+
checkpoints: [
|
|
3485
|
+
{
|
|
3486
|
+
checkpoint_id: 'cp-1',
|
|
3487
|
+
validation_status: 'valid',
|
|
3488
|
+
diff_hash: 'hash-current',
|
|
3489
|
+
},
|
|
3490
|
+
],
|
|
3491
|
+
},
|
|
3492
|
+
},
|
|
3493
|
+
latest_evidence: {
|
|
3494
|
+
mode: 'full',
|
|
3495
|
+
overall: 'fail',
|
|
3496
|
+
input_diff_hash: 'hash-stale',
|
|
3497
|
+
input_checkpoint_id: 'cp-0',
|
|
3498
|
+
input_worktree_validity: 'valid',
|
|
3499
|
+
},
|
|
3500
|
+
gate_evidence_by_mode: {
|
|
3501
|
+
full: {
|
|
3502
|
+
mode: 'full',
|
|
3503
|
+
overall: 'fail',
|
|
3504
|
+
input_diff_hash: 'hash-stale',
|
|
3505
|
+
input_checkpoint_id: 'cp-0',
|
|
3506
|
+
input_worktree_validity: 'valid',
|
|
3507
|
+
},
|
|
3508
|
+
},
|
|
3509
|
+
qa_test_index: {
|
|
3510
|
+
summary: { pending: 0, failed: 0, running: 0 },
|
|
3511
|
+
},
|
|
3512
|
+
},
|
|
3513
|
+
basePlan('feature-full-stale-direct'),
|
|
3514
|
+
STATUS.BLOCKED,
|
|
3515
|
+
);
|
|
3516
|
+
|
|
3517
|
+
expect(decision.executionDisposition).toBe('blocked_stale_evidence');
|
|
3518
|
+
expect(decision.reasons).toEqual(expect.arrayContaining(['gate_evidence_stale:full']));
|
|
3519
|
+
});
|
|
3520
|
+
|
|
3521
|
+
it('returns false for stub auto-promotion when the bootstrap manifest is empty', () => {
|
|
3522
|
+
const executor = new PlanningWaveExecutor({
|
|
3523
|
+
toolCaller: { callTool: vi.fn() } as never,
|
|
3524
|
+
planGenerator: { generateInitialPlan: vi.fn() } as never,
|
|
3525
|
+
});
|
|
3526
|
+
|
|
3527
|
+
const allowed = (
|
|
3528
|
+
executor as unknown as {
|
|
3529
|
+
policyAllowsStubAutoPromotion: (bootstrapManifest: Record<string, unknown>) => boolean;
|
|
3530
|
+
}
|
|
3531
|
+
).policyAllowsStubAutoPromotion({});
|
|
3532
|
+
|
|
3533
|
+
expect(allowed).toBe(false);
|
|
3534
|
+
});
|
|
3535
|
+
|
|
3536
|
+
it('returns false for stub auto-promotion when policy disables it', () => {
|
|
3537
|
+
const executor = new PlanningWaveExecutor({
|
|
3538
|
+
toolCaller: { callTool: vi.fn() } as never,
|
|
3539
|
+
planGenerator: { generateInitialPlan: vi.fn() } as never,
|
|
3540
|
+
getPolicySnapshot: () => ({
|
|
3541
|
+
planning: {
|
|
3542
|
+
intake: {
|
|
3543
|
+
allow_auto_promotion: false,
|
|
3544
|
+
},
|
|
3545
|
+
},
|
|
3546
|
+
}),
|
|
3547
|
+
});
|
|
3548
|
+
|
|
3549
|
+
const allowed = (
|
|
3550
|
+
executor as unknown as {
|
|
3551
|
+
policyAllowsStubAutoPromotion: (bootstrapManifest: Record<string, unknown>) => boolean;
|
|
3552
|
+
}
|
|
3553
|
+
).policyAllowsStubAutoPromotion({
|
|
3554
|
+
obligations: [{ obligation_id: 'OBL-001', confidence: 'high' }],
|
|
3555
|
+
ambiguities: [],
|
|
3556
|
+
});
|
|
3557
|
+
|
|
3558
|
+
expect(allowed).toBe(false);
|
|
3559
|
+
});
|
|
3560
|
+
|
|
3561
|
+
it('returns false for stub auto-promotion when bootstrap ambiguities remain', () => {
|
|
3562
|
+
const executor = new PlanningWaveExecutor({
|
|
3563
|
+
toolCaller: { callTool: vi.fn() } as never,
|
|
3564
|
+
planGenerator: { generateInitialPlan: vi.fn() } as never,
|
|
3565
|
+
getPolicySnapshot: () => ({
|
|
3566
|
+
planning: {
|
|
3567
|
+
intake: {
|
|
3568
|
+
allow_auto_promotion: true,
|
|
3569
|
+
},
|
|
3570
|
+
},
|
|
3571
|
+
}),
|
|
3572
|
+
});
|
|
3573
|
+
|
|
3574
|
+
const allowed = (
|
|
3575
|
+
executor as unknown as {
|
|
3576
|
+
policyAllowsStubAutoPromotion: (bootstrapManifest: Record<string, unknown>) => boolean;
|
|
3577
|
+
}
|
|
3578
|
+
).policyAllowsStubAutoPromotion({
|
|
3579
|
+
obligations: [{ obligation_id: 'OBL-001', confidence: 'high' }],
|
|
3580
|
+
ambiguities: [{ ambiguity_id: 'AMB-001' }],
|
|
3581
|
+
});
|
|
3582
|
+
|
|
3583
|
+
expect(allowed).toBe(false);
|
|
3584
|
+
});
|
|
3585
|
+
|
|
3586
|
+
it('returns false when accepted plan state is already normalized', async () => {
|
|
3587
|
+
const executor = new PlanningWaveExecutor({
|
|
3588
|
+
toolCaller: { callTool: vi.fn() } as never,
|
|
3589
|
+
planGenerator: { generateInitialPlan: vi.fn() } as never,
|
|
3590
|
+
});
|
|
3591
|
+
|
|
3592
|
+
const changed = await (
|
|
3593
|
+
executor as unknown as {
|
|
3594
|
+
normalizeAcceptedPlanState: (
|
|
3595
|
+
featureId: string,
|
|
3596
|
+
frontMatter: Record<string, unknown>,
|
|
3597
|
+
plan: Record<string, unknown>,
|
|
3598
|
+
) => Promise<boolean>;
|
|
3599
|
+
}
|
|
3600
|
+
).normalizeAcceptedPlanState(
|
|
3601
|
+
'feature_accepted_plan_healthy',
|
|
3602
|
+
{
|
|
3603
|
+
status: STATUS.BUILDING,
|
|
3604
|
+
state_version: 3,
|
|
3605
|
+
gates: {
|
|
3606
|
+
plan: 'pass',
|
|
3607
|
+
},
|
|
3608
|
+
},
|
|
3609
|
+
basePlan('feature_accepted_plan_healthy'),
|
|
3610
|
+
);
|
|
3611
|
+
|
|
3612
|
+
expect(changed).toBe(false);
|
|
3613
|
+
});
|
|
3614
|
+
|
|
3615
|
+
it('does not auto-heal planning into building when the accepted plan trace no longer matches the verified manifest', async () => {
|
|
3616
|
+
const toolCaller = { callTool: vi.fn() };
|
|
3617
|
+
const executor = new PlanningWaveExecutor({
|
|
3618
|
+
toolCaller: toolCaller as never,
|
|
3619
|
+
planGenerator: { generateInitialPlan: vi.fn() } as never,
|
|
3620
|
+
});
|
|
3621
|
+
|
|
3622
|
+
const changed = await (
|
|
3623
|
+
executor as unknown as {
|
|
3624
|
+
normalizeAcceptedPlanState: (
|
|
3625
|
+
featureId: string,
|
|
3626
|
+
frontMatter: Record<string, unknown>,
|
|
3627
|
+
plan: Record<string, unknown>,
|
|
3628
|
+
planTraceContract: {
|
|
3629
|
+
valid: boolean;
|
|
3630
|
+
missing_obligation_ids: string[];
|
|
3631
|
+
unknown_obligation_ids: string[];
|
|
3632
|
+
duplicate_obligation_ids: string[];
|
|
3633
|
+
invalid_mappings: string[];
|
|
3634
|
+
} | null,
|
|
3635
|
+
) => Promise<boolean>;
|
|
3636
|
+
}
|
|
3637
|
+
).normalizeAcceptedPlanState(
|
|
3638
|
+
'feature_stale_trace',
|
|
3639
|
+
{
|
|
3640
|
+
status: STATUS.PLANNING,
|
|
3641
|
+
version: 3,
|
|
3642
|
+
gates: {
|
|
3643
|
+
plan: 'pass',
|
|
3644
|
+
},
|
|
3645
|
+
},
|
|
3646
|
+
basePlan('feature_stale_trace'),
|
|
3647
|
+
{
|
|
3648
|
+
valid: false,
|
|
3649
|
+
missing_obligation_ids: ['OBL-002'],
|
|
3650
|
+
unknown_obligation_ids: ['OBL-999'],
|
|
3651
|
+
duplicate_obligation_ids: [],
|
|
3652
|
+
invalid_mappings: [],
|
|
3653
|
+
},
|
|
3654
|
+
);
|
|
3655
|
+
|
|
3656
|
+
expect(changed).toBe(false);
|
|
3657
|
+
expect(toolCaller.callTool).not.toHaveBeenCalled();
|
|
3658
|
+
});
|
|
3659
|
+
|
|
3660
|
+
it('routes verified manifest trace gaps back to the planner instead of auto-submitting an invalid plan update', async () => {
|
|
3661
|
+
const featureId = 'feature_trace_revision';
|
|
3662
|
+
const workerDecisionRunner = {
|
|
3663
|
+
execute: vi.fn(async () => ({
|
|
3664
|
+
planSubmission: true,
|
|
3665
|
+
patchApplied: false,
|
|
3666
|
+
noteLogged: true,
|
|
3667
|
+
requestHandled: false,
|
|
3668
|
+
questionRequested: false,
|
|
3669
|
+
contextStall: false,
|
|
3670
|
+
contextRequestCount: 0,
|
|
3671
|
+
lastContextRequestAt: null,
|
|
3672
|
+
lastContextRequestRole: null,
|
|
3673
|
+
invalidOutput: false,
|
|
3674
|
+
noProgress: false,
|
|
3675
|
+
outputTypes: [],
|
|
3676
|
+
rawOutputs: [],
|
|
3677
|
+
priorityOrder: [],
|
|
3678
|
+
toolResults: [],
|
|
3679
|
+
errorCode: null,
|
|
3680
|
+
interactiveOutcome: null,
|
|
3681
|
+
checkpoint: null,
|
|
3682
|
+
})),
|
|
3683
|
+
};
|
|
3684
|
+
const toolCaller = {
|
|
3685
|
+
callTool: vi.fn(async (_role: string, toolName: string) => {
|
|
3686
|
+
if (toolName === TOOLS.FEATURE_GET_CONTEXT) {
|
|
3687
|
+
return {
|
|
3688
|
+
ok: true,
|
|
3689
|
+
data: {
|
|
3690
|
+
feature_id: featureId,
|
|
3691
|
+
state: {
|
|
3692
|
+
front_matter: {
|
|
3693
|
+
status: STATUS.READY_TO_MERGE,
|
|
3694
|
+
checkpoints: [
|
|
3695
|
+
{
|
|
3696
|
+
checkpoint_id: 'cp-1',
|
|
3697
|
+
validation_status: 'valid',
|
|
3698
|
+
diff_hash: 'hash-current',
|
|
3699
|
+
},
|
|
3700
|
+
],
|
|
3701
|
+
},
|
|
3702
|
+
},
|
|
3703
|
+
intake: {
|
|
3704
|
+
verified_manifest: {
|
|
3705
|
+
obligations: [
|
|
3706
|
+
{
|
|
3707
|
+
obligation_id: 'OBL-001',
|
|
3708
|
+
kind: 'artifact',
|
|
3709
|
+
verification_hint: 'required',
|
|
3710
|
+
},
|
|
3711
|
+
{
|
|
3712
|
+
obligation_id: 'OBL-002',
|
|
3713
|
+
kind: 'behavior',
|
|
3714
|
+
verification_hint: 'required',
|
|
3715
|
+
},
|
|
3716
|
+
],
|
|
3717
|
+
},
|
|
3718
|
+
},
|
|
3719
|
+
plan: {
|
|
3720
|
+
...basePlan(featureId),
|
|
3721
|
+
plan_trace: [
|
|
3722
|
+
{
|
|
3723
|
+
obligation_id: 'OBL-001',
|
|
3724
|
+
disposition: 'in_scope',
|
|
3725
|
+
planned_paths: ['apps/control-plane/src/file.ts'],
|
|
3726
|
+
notes: 'covered',
|
|
3727
|
+
},
|
|
3728
|
+
{
|
|
3729
|
+
obligation_id: 'OBL-999',
|
|
3730
|
+
disposition: 'in_scope',
|
|
3731
|
+
planned_paths: ['apps/control-plane/src/file.ts'],
|
|
3732
|
+
notes: 'obsolete',
|
|
3733
|
+
},
|
|
3734
|
+
],
|
|
3735
|
+
},
|
|
3736
|
+
qa_test_index: {
|
|
3737
|
+
summary: {
|
|
3738
|
+
pending: 0,
|
|
3739
|
+
failed: 0,
|
|
3740
|
+
running: 0,
|
|
3741
|
+
},
|
|
3742
|
+
},
|
|
3743
|
+
latest_evidence: {
|
|
3744
|
+
mode: 'full',
|
|
3745
|
+
overall: 'pass',
|
|
3746
|
+
input_diff_hash: 'hash-current',
|
|
3747
|
+
input_checkpoint_id: 'cp-1',
|
|
3748
|
+
input_worktree_validity: 'valid',
|
|
3749
|
+
},
|
|
3750
|
+
gate_evidence_by_mode: {
|
|
3751
|
+
full: {
|
|
3752
|
+
mode: 'full',
|
|
3753
|
+
overall: 'pass',
|
|
3754
|
+
input_diff_hash: 'hash-current',
|
|
3755
|
+
input_checkpoint_id: 'cp-1',
|
|
3756
|
+
input_worktree_validity: 'valid',
|
|
3757
|
+
},
|
|
3758
|
+
},
|
|
3759
|
+
},
|
|
3760
|
+
};
|
|
3761
|
+
}
|
|
3762
|
+
if (toolName === TOOLS.FEATURE_LOG_APPEND) {
|
|
3763
|
+
return { ok: true, data: { appended: true } };
|
|
3764
|
+
}
|
|
3765
|
+
throw new Error(`unexpected_tool:${toolName}`);
|
|
3766
|
+
}),
|
|
3767
|
+
};
|
|
3768
|
+
|
|
3769
|
+
const executor = new PlanningWaveExecutor({
|
|
3770
|
+
toolCaller: toolCaller as never,
|
|
3771
|
+
planGenerator: { generateInitialPlan: vi.fn() } as never,
|
|
3772
|
+
workerDecisionRunner: workerDecisionRunner as never,
|
|
3773
|
+
});
|
|
3774
|
+
|
|
3775
|
+
await executor.runPostQaReconciliation([featureId], 3);
|
|
3776
|
+
|
|
3777
|
+
expect(workerDecisionRunner.execute).toHaveBeenCalledWith(
|
|
3778
|
+
expect.objectContaining({
|
|
3779
|
+
role: 'planner',
|
|
3780
|
+
featureId,
|
|
3781
|
+
contextBundle: expect.objectContaining({
|
|
3782
|
+
plan_trace_contract: expect.objectContaining({
|
|
3783
|
+
missing_obligation_ids: ['OBL-002'],
|
|
3784
|
+
unknown_obligation_ids: ['OBL-999'],
|
|
3785
|
+
}),
|
|
3786
|
+
}),
|
|
3787
|
+
}),
|
|
3788
|
+
);
|
|
3789
|
+
expect(toolCaller.callTool).not.toHaveBeenCalledWith(
|
|
3790
|
+
'planner',
|
|
3791
|
+
TOOLS.PLAN_UPDATE,
|
|
3792
|
+
expect.any(Object),
|
|
3793
|
+
);
|
|
3794
|
+
});
|
|
609
3795
|
});
|