agentic-orchestrator 0.1.6 → 0.1.8
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/.prettierignore +10 -0
- package/.prettierrc.json +24 -0
- package/CLAUDE.md +3 -2
- package/README.md +71 -48
- package/agentic/orchestrator/defaults/policy.defaults.yaml +1 -1
- package/agentic/orchestrator/prompts/planner.system.md +1 -0
- package/agentic/orchestrator/schemas/agents.schema.json +5 -22
- package/agentic/orchestrator/schemas/gates.schema.json +4 -19
- package/agentic/orchestrator/schemas/index.schema.json +3 -14
- package/agentic/orchestrator/schemas/multi-project.schema.json +2 -8
- package/agentic/orchestrator/schemas/plan.schema.json +6 -26
- package/agentic/orchestrator/schemas/policy.schema.json +19 -81
- package/agentic/orchestrator/schemas/policy.user.schema.json +1 -5
- package/agentic/orchestrator/schemas/qa_test_index.schema.json +5 -29
- package/agentic/orchestrator/schemas/state.schema.json +11 -61
- package/agentic/orchestrator/tools/catalog.json +33 -164
- package/agentic/orchestrator/tools/schemas/input/evidence.latest.input.schema.json +1 -3
- package/agentic/orchestrator/tools/schemas/input/feature.delete.input.schema.json +1 -5
- package/agentic/orchestrator/tools/schemas/input/feature.get_context.input.schema.json +1 -3
- package/agentic/orchestrator/tools/schemas/input/feature.init.input.schema.json +1 -4
- package/agentic/orchestrator/tools/schemas/input/feature.log_append.input.schema.json +1 -5
- package/agentic/orchestrator/tools/schemas/input/feature.ready_to_merge.input.schema.json +1 -6
- package/agentic/orchestrator/tools/schemas/input/feature.state_get.input.schema.json +1 -3
- package/agentic/orchestrator/tools/schemas/input/feature.state_patch.input.schema.json +1 -5
- package/agentic/orchestrator/tools/schemas/input/gates.run.input.schema.json +1 -5
- package/agentic/orchestrator/tools/schemas/input/locks.acquire.input.schema.json +1 -5
- package/agentic/orchestrator/tools/schemas/input/locks.release.input.schema.json +1 -5
- package/agentic/orchestrator/tools/schemas/input/performance.record_outcome.input.schema.json +10 -1
- package/agentic/orchestrator/tools/schemas/input/plan.get.input.schema.json +1 -3
- package/agentic/orchestrator/tools/schemas/input/plan.submit.input.schema.json +1 -5
- package/agentic/orchestrator/tools/schemas/input/plan.update.input.schema.json +1 -6
- package/agentic/orchestrator/tools/schemas/input/qa.test_index_get.input.schema.json +1 -3
- package/agentic/orchestrator/tools/schemas/input/qa.test_index_update.input.schema.json +1 -6
- package/agentic/orchestrator/tools/schemas/input/repo.apply_patch.input.schema.json +1 -5
- package/agentic/orchestrator/tools/schemas/input/repo.diff.input.schema.json +1 -3
- package/agentic/orchestrator/tools/schemas/input/repo.diff_bundle.input.schema.json +1 -3
- package/agentic/orchestrator/tools/schemas/input/repo.ensure_worktree.input.schema.json +1 -4
- package/agentic/orchestrator/tools/schemas/input/repo.read_file.input.schema.json +1 -4
- package/agentic/orchestrator/tools/schemas/input/repo.search.input.schema.json +1 -4
- package/agentic/orchestrator/tools/schemas/input/repo.status.input.schema.json +1 -3
- package/agentic/orchestrator/tools/schemas/input/report.feature_summary.input.schema.json +1 -3
- package/agentic/orchestrator/tools/schemas/output/collisions.scan.output.schema.json +1 -3
- package/agentic/orchestrator/tools/schemas/output/evidence.latest.output.schema.json +1 -4
- package/agentic/orchestrator/tools/schemas/output/feature.delete.output.schema.json +4 -20
- package/agentic/orchestrator/tools/schemas/output/feature.discover_specs.output.schema.json +2 -7
- package/agentic/orchestrator/tools/schemas/output/feature.get_context.output.schema.json +1 -8
- package/agentic/orchestrator/tools/schemas/output/feature.init.output.schema.json +1 -5
- package/agentic/orchestrator/tools/schemas/output/feature.log_append.output.schema.json +1 -5
- package/agentic/orchestrator/tools/schemas/output/feature.ready_to_merge.output.schema.json +1 -6
- package/agentic/orchestrator/tools/schemas/output/feature.state_get.output.schema.json +1 -4
- package/agentic/orchestrator/tools/schemas/output/feature.state_patch.output.schema.json +1 -5
- package/agentic/orchestrator/tools/schemas/output/gates.list.output.schema.json +2 -7
- package/agentic/orchestrator/tools/schemas/output/gates.run.output.schema.json +1 -8
- package/agentic/orchestrator/tools/schemas/output/locks.acquire.output.schema.json +1 -7
- package/agentic/orchestrator/tools/schemas/output/locks.release.output.schema.json +1 -5
- package/agentic/orchestrator/tools/schemas/output/performance.get_analytics.output.schema.json +22 -2
- package/agentic/orchestrator/tools/schemas/output/plan.get.output.schema.json +1 -4
- package/agentic/orchestrator/tools/schemas/output/plan.submit.output.schema.json +1 -5
- package/agentic/orchestrator/tools/schemas/output/plan.update.output.schema.json +1 -5
- package/agentic/orchestrator/tools/schemas/output/qa.test_index_get.output.schema.json +1 -5
- package/agentic/orchestrator/tools/schemas/output/qa.test_index_update.output.schema.json +1 -4
- package/agentic/orchestrator/tools/schemas/output/repo.apply_patch.output.schema.json +1 -6
- package/agentic/orchestrator/tools/schemas/output/repo.diff.output.schema.json +1 -4
- package/agentic/orchestrator/tools/schemas/output/repo.diff_bundle.output.schema.json +1 -7
- package/agentic/orchestrator/tools/schemas/output/repo.ensure_worktree.output.schema.json +1 -6
- package/agentic/orchestrator/tools/schemas/output/repo.read_file.output.schema.json +1 -5
- package/agentic/orchestrator/tools/schemas/output/repo.search.output.schema.json +1 -5
- package/agentic/orchestrator/tools/schemas/output/repo.status.output.schema.json +1 -5
- package/agentic/orchestrator/tools/schemas/output/report.dashboard.output.schema.json +1 -4
- package/apps/control-plane/scripts/validate-architecture-rules.mjs +16 -5
- package/apps/control-plane/scripts/validate-docker-mcp-contract.mjs +30 -8
- package/apps/control-plane/scripts/validate-mcp-contracts.ts +13 -7
- package/apps/control-plane/src/application/adapters/adapter-registry.ts +35 -15
- package/apps/control-plane/src/application/multi-project-loader.ts +27 -10
- package/apps/control-plane/src/application/services/activity-monitor-service.ts +26 -14
- package/apps/control-plane/src/application/services/collision-queue-service.ts +31 -17
- package/apps/control-plane/src/application/services/cost-tracking-service.ts +23 -16
- package/apps/control-plane/src/application/services/dependency-scheduler-service.ts +12 -4
- package/apps/control-plane/src/application/services/feature-deletion-service.ts +94 -58
- package/apps/control-plane/src/application/services/feature-lifecycle-service.ts +19 -13
- package/apps/control-plane/src/application/services/feature-state-service.ts +29 -19
- package/apps/control-plane/src/application/services/gate-interpolation-service.ts +7 -2
- package/apps/control-plane/src/application/services/gate-service.ts +64 -41
- package/apps/control-plane/src/application/services/instance-isolation-service.ts +1 -1
- package/apps/control-plane/src/application/services/issue-tracker-service.ts +49 -38
- package/apps/control-plane/src/application/services/lock-service.ts +75 -49
- package/apps/control-plane/src/application/services/merge-service.ts +91 -50
- package/apps/control-plane/src/application/services/notifier-service.ts +42 -20
- package/apps/control-plane/src/application/services/patch-service.ts +73 -44
- package/apps/control-plane/src/application/services/performance-analytics-service.ts +8 -6
- package/apps/control-plane/src/application/services/plan-service.ts +148 -89
- package/apps/control-plane/src/application/services/policy-loader-service.ts +10 -4
- package/apps/control-plane/src/application/services/pr-monitor-service.ts +33 -14
- package/apps/control-plane/src/application/services/qa-index-service.ts +20 -16
- package/apps/control-plane/src/application/services/reactions-service.ts +30 -15
- package/apps/control-plane/src/application/services/reporting-service.ts +16 -12
- package/apps/control-plane/src/application/services/run-lease-service.ts +138 -81
- package/apps/control-plane/src/application/tools/tool-metadata.ts +5 -5
- package/apps/control-plane/src/application/tools/tool-router.ts +6 -3
- package/apps/control-plane/src/cli/aop.ts +2 -2
- package/apps/control-plane/src/cli/attach-command-handler.ts +9 -9
- package/apps/control-plane/src/cli/cleanup-command-handler.ts +16 -11
- package/apps/control-plane/src/cli/cli-argument-parser.ts +6 -3
- package/apps/control-plane/src/cli/dashboard-command-handler.ts +28 -8
- package/apps/control-plane/src/cli/delete-command-handler.ts +7 -7
- package/apps/control-plane/src/cli/env-file.ts +115 -0
- package/apps/control-plane/src/cli/help-command-handler.ts +61 -32
- package/apps/control-plane/src/cli/init-command-handler.ts +182 -56
- package/apps/control-plane/src/cli/io.ts +7 -3
- package/apps/control-plane/src/cli/resume-command-handler.ts +21 -13
- package/apps/control-plane/src/cli/retry-command-handler.ts +12 -11
- package/apps/control-plane/src/cli/run-command-handler.ts +12 -8
- package/apps/control-plane/src/cli/send-command-handler.ts +6 -6
- package/apps/control-plane/src/cli/spec-ingestion-service.ts +14 -8
- package/apps/control-plane/src/cli/spec-input-resolver.ts +6 -1
- package/apps/control-plane/src/cli/spec-utils.ts +2 -2
- package/apps/control-plane/src/cli/status-command-handler.ts +13 -12
- package/apps/control-plane/src/cli/tooling.ts +3 -3
- package/apps/control-plane/src/cli/types.ts +1 -1
- package/apps/control-plane/src/core/collisions.ts +27 -10
- package/apps/control-plane/src/core/constants.ts +13 -7
- package/apps/control-plane/src/core/error-codes.ts +1 -1
- package/apps/control-plane/src/core/fs.ts +11 -5
- package/apps/control-plane/src/core/gates.ts +53 -27
- package/apps/control-plane/src/core/git.ts +18 -6
- package/apps/control-plane/src/core/kernel.ts +513 -227
- package/apps/control-plane/src/core/patch.ts +7 -3
- package/apps/control-plane/src/core/path-layout.ts +5 -1
- package/apps/control-plane/src/core/path-rules.ts +19 -5
- package/apps/control-plane/src/core/qa-index.ts +26 -12
- package/apps/control-plane/src/core/response.ts +9 -6
- package/apps/control-plane/src/core/schemas.ts +29 -10
- package/apps/control-plane/src/core/tool-caller.ts +1 -1
- package/apps/control-plane/src/core/workspace-hooks.ts +5 -5
- package/apps/control-plane/src/index.ts +3 -9
- package/apps/control-plane/src/interfaces/cli/bootstrap.ts +79 -35
- package/apps/control-plane/src/mcp/kernel-tool-executor.ts +7 -3
- package/apps/control-plane/src/mcp/mcp-server-adapter.ts +12 -10
- package/apps/control-plane/src/mcp/operation-ledger.ts +18 -8
- package/apps/control-plane/src/mcp/protocol-contract.ts +2 -2
- package/apps/control-plane/src/mcp/runtime-factory.ts +15 -6
- package/apps/control-plane/src/mcp/token-auth-verifier.ts +3 -2
- package/apps/control-plane/src/mcp/token-claims-validator.ts +11 -7
- package/apps/control-plane/src/mcp/tool-authorizer.ts +1 -3
- package/apps/control-plane/src/mcp/tool-client.ts +17 -5
- package/apps/control-plane/src/mcp/tool-contract-validator.ts +17 -8
- package/apps/control-plane/src/mcp/tool-registry-loader.ts +7 -3
- package/apps/control-plane/src/mcp/tool-runtime.ts +66 -39
- package/apps/control-plane/src/mcp/tools-markdown-generator.ts +6 -1
- package/apps/control-plane/src/providers/providers.ts +137 -54
- package/apps/control-plane/src/supervisor/build-wave-executor.ts +44 -25
- package/apps/control-plane/src/supervisor/planning-wave-executor.ts +46 -33
- package/apps/control-plane/src/supervisor/prompt-bundle-loader.ts +1 -1
- package/apps/control-plane/src/supervisor/qa-wave-executor.ts +38 -23
- package/apps/control-plane/src/supervisor/run-coordinator.ts +71 -36
- package/apps/control-plane/src/supervisor/runtime.ts +59 -35
- package/apps/control-plane/src/supervisor/session-orchestrator.ts +48 -31
- package/apps/control-plane/src/supervisor/types.ts +22 -7
- package/apps/control-plane/src/supervisor/worker-decision-loop.ts +30 -20
- package/apps/control-plane/test/activity-monitor.spec.ts +54 -30
- package/apps/control-plane/test/adapter-registry.spec.ts +5 -5
- package/apps/control-plane/test/aop.spec.ts +4 -4
- package/apps/control-plane/test/batch-operations.spec.ts +20 -18
- package/apps/control-plane/test/bootstrap-attach.spec.ts +52 -19
- package/apps/control-plane/test/bootstrap-edge-cases.spec.ts +58 -27
- package/apps/control-plane/test/bootstrap.spec.ts +72 -40
- package/apps/control-plane/test/cleanup-command.spec.ts +86 -32
- package/apps/control-plane/test/cli-helpers.spec.ts +119 -66
- package/apps/control-plane/test/cli.spec.ts +1 -1
- package/apps/control-plane/test/cli.unit.spec.ts +226 -167
- package/apps/control-plane/test/collision-queue.spec.ts +49 -40
- package/apps/control-plane/test/collisions.spec.ts +30 -30
- package/apps/control-plane/test/core-utils.spec.ts +29 -15
- package/apps/control-plane/test/cost-tracking.spec.ts +38 -22
- package/apps/control-plane/test/dashboard-api.integration.spec.ts +68 -36
- package/apps/control-plane/test/dashboard-client.spec.ts +18 -12
- package/apps/control-plane/test/dashboard-command.spec.ts +11 -7
- package/apps/control-plane/test/delete-command-handler.spec.ts +49 -41
- package/apps/control-plane/test/dependency-scheduler.spec.ts +47 -20
- package/apps/control-plane/test/epoch-tracking.spec.ts +9 -9
- package/apps/control-plane/test/feature-deletion-service.spec.ts +60 -52
- package/apps/control-plane/test/feature-lifecycle.spec.ts +36 -17
- package/apps/control-plane/test/gates.spec.ts +101 -81
- package/apps/control-plane/test/git-spawn-error.spec.ts +1 -1
- package/apps/control-plane/test/helpers.ts +10 -6
- package/apps/control-plane/test/incremental-gates.spec.ts +59 -20
- package/apps/control-plane/test/init-wizard.spec.ts +328 -68
- package/apps/control-plane/test/instance-isolation.spec.ts +43 -10
- package/apps/control-plane/test/issue-tracker.spec.ts +368 -128
- package/apps/control-plane/test/kernel-collision-replay.spec.ts +50 -29
- package/apps/control-plane/test/kernel.branches.spec.ts +64 -40
- package/apps/control-plane/test/kernel.coverage.spec.ts +85 -49
- package/apps/control-plane/test/kernel.coverage2.spec.ts +109 -65
- package/apps/control-plane/test/kernel.spec.ts +134 -51
- package/apps/control-plane/test/lock-service.spec.ts +92 -68
- package/apps/control-plane/test/mcp-helpers.spec.ts +53 -39
- package/apps/control-plane/test/mcp.spec.ts +231 -115
- package/apps/control-plane/test/merge-service.spec.ts +142 -94
- package/apps/control-plane/test/multi-project.spec.ts +28 -22
- package/apps/control-plane/test/notifier-service.spec.ts +136 -92
- package/apps/control-plane/test/parallel-gates.spec.ts +51 -35
- package/apps/control-plane/test/patch-service.spec.ts +128 -48
- package/apps/control-plane/test/performance-analytics.spec.ts +99 -63
- package/apps/control-plane/test/plan-service.spec.ts +50 -39
- package/apps/control-plane/test/planning-wave-executor.spec.ts +95 -71
- package/apps/control-plane/test/policy-loader-service.spec.ts +41 -19
- package/apps/control-plane/test/pr-monitor.spec.ts +113 -64
- package/apps/control-plane/test/providers.spec.ts +208 -104
- package/apps/control-plane/test/qa-index-service.spec.ts +31 -33
- package/apps/control-plane/test/qa-index.spec.ts +58 -61
- package/apps/control-plane/test/reactions.spec.ts +88 -45
- package/apps/control-plane/test/response.spec.ts +5 -5
- package/apps/control-plane/test/resume-command.spec.ts +121 -80
- package/apps/control-plane/test/run-coordinator.spec.ts +205 -136
- package/apps/control-plane/test/schema-date-time.spec.ts +49 -41
- package/apps/control-plane/test/service-retry-paths.spec.ts +77 -57
- package/apps/control-plane/test/services.spec.ts +147 -129
- package/apps/control-plane/test/session-management.spec.ts +136 -74
- package/apps/control-plane/test/spec-ingestion.spec.ts +23 -21
- package/apps/control-plane/test/spec-input-resolver.spec.ts +11 -10
- package/apps/control-plane/test/supervisor-collaborators.spec.ts +168 -121
- package/apps/control-plane/test/supervisor.calltool.spec.ts +21 -18
- package/apps/control-plane/test/supervisor.spec.ts +67 -43
- package/apps/control-plane/test/supervisor.unit.spec.ts +195 -126
- package/apps/control-plane/test/token-auth-verifier.spec.ts +29 -14
- package/apps/control-plane/test/tool-registry-loader.spec.ts +51 -27
- package/apps/control-plane/test/tool-runtime.spec.ts +63 -46
- package/apps/control-plane/test/worker-decision-loop.spec.ts +143 -122
- package/apps/control-plane/test/workspace-hooks.spec.ts +61 -23
- package/apps/control-plane/tsconfig.build.json +2 -7
- package/apps/control-plane/tsconfig.json +1 -5
- package/apps/control-plane/vitest.config.ts +7 -7
- package/config/agentic/orchestrator/adapters.yaml +3 -0
- package/config/agentic/orchestrator/agents.yaml +14 -0
- package/config/agentic/orchestrator/gates.yaml +28 -0
- package/config/agentic/orchestrator/policy.yaml +22 -0
- package/config/agentic/orchestrator/prompts/builder.system.md +1 -0
- package/config/agentic/orchestrator/prompts/planner.system.md +16 -0
- package/config/agentic/orchestrator/prompts/qa.system.md +1 -0
- package/dist/apps/control-plane/application/adapters/adapter-registry.js +12 -5
- package/dist/apps/control-plane/application/adapters/adapter-registry.js.map +1 -1
- package/dist/apps/control-plane/application/multi-project-loader.js +26 -9
- package/dist/apps/control-plane/application/multi-project-loader.js.map +1 -1
- package/dist/apps/control-plane/application/services/activity-monitor-service.js +7 -7
- package/dist/apps/control-plane/application/services/activity-monitor-service.js.map +1 -1
- package/dist/apps/control-plane/application/services/collision-queue-service.js +7 -7
- package/dist/apps/control-plane/application/services/collision-queue-service.js.map +1 -1
- package/dist/apps/control-plane/application/services/cost-tracking-service.js +6 -8
- package/dist/apps/control-plane/application/services/cost-tracking-service.js.map +1 -1
- package/dist/apps/control-plane/application/services/dependency-scheduler-service.js.map +1 -1
- package/dist/apps/control-plane/application/services/feature-deletion-service.js +37 -29
- package/dist/apps/control-plane/application/services/feature-deletion-service.js.map +1 -1
- package/dist/apps/control-plane/application/services/feature-lifecycle-service.js +10 -10
- package/dist/apps/control-plane/application/services/feature-lifecycle-service.js.map +1 -1
- package/dist/apps/control-plane/application/services/feature-state-service.js +11 -11
- package/dist/apps/control-plane/application/services/feature-state-service.js.map +1 -1
- package/dist/apps/control-plane/application/services/gate-interpolation-service.js +3 -1
- package/dist/apps/control-plane/application/services/gate-interpolation-service.js.map +1 -1
- package/dist/apps/control-plane/application/services/gate-service.js +26 -26
- package/dist/apps/control-plane/application/services/gate-service.js.map +1 -1
- package/dist/apps/control-plane/application/services/instance-isolation-service.js +1 -1
- package/dist/apps/control-plane/application/services/instance-isolation-service.js.map +1 -1
- package/dist/apps/control-plane/application/services/issue-tracker-service.js +25 -15
- package/dist/apps/control-plane/application/services/issue-tracker-service.js.map +1 -1
- package/dist/apps/control-plane/application/services/lock-service.js +32 -32
- package/dist/apps/control-plane/application/services/lock-service.js.map +1 -1
- package/dist/apps/control-plane/application/services/merge-service.js +41 -27
- package/dist/apps/control-plane/application/services/merge-service.js.map +1 -1
- package/dist/apps/control-plane/application/services/notifier-service.js +29 -15
- package/dist/apps/control-plane/application/services/notifier-service.js.map +1 -1
- package/dist/apps/control-plane/application/services/patch-service.js +21 -19
- package/dist/apps/control-plane/application/services/patch-service.js.map +1 -1
- package/dist/apps/control-plane/application/services/performance-analytics-service.js +4 -4
- package/dist/apps/control-plane/application/services/performance-analytics-service.js.map +1 -1
- package/dist/apps/control-plane/application/services/plan-service.js +33 -33
- package/dist/apps/control-plane/application/services/plan-service.js.map +1 -1
- package/dist/apps/control-plane/application/services/policy-loader-service.js.map +1 -1
- package/dist/apps/control-plane/application/services/pr-monitor-service.js +23 -11
- package/dist/apps/control-plane/application/services/pr-monitor-service.js.map +1 -1
- package/dist/apps/control-plane/application/services/qa-index-service.js +11 -11
- package/dist/apps/control-plane/application/services/qa-index-service.js.map +1 -1
- package/dist/apps/control-plane/application/services/reactions-service.js +13 -9
- package/dist/apps/control-plane/application/services/reactions-service.js.map +1 -1
- package/dist/apps/control-plane/application/services/reporting-service.js +11 -9
- package/dist/apps/control-plane/application/services/reporting-service.js.map +1 -1
- package/dist/apps/control-plane/application/services/run-lease-service.js +34 -33
- package/dist/apps/control-plane/application/services/run-lease-service.js.map +1 -1
- package/dist/apps/control-plane/application/tools/tool-metadata.js +2 -2
- package/dist/apps/control-plane/application/tools/tool-router.js.map +1 -1
- package/dist/apps/control-plane/cli/attach-command-handler.js +9 -9
- package/dist/apps/control-plane/cli/cleanup-command-handler.js +11 -9
- package/dist/apps/control-plane/cli/cleanup-command-handler.js.map +1 -1
- package/dist/apps/control-plane/cli/cli-argument-parser.js +4 -3
- package/dist/apps/control-plane/cli/cli-argument-parser.js.map +1 -1
- package/dist/apps/control-plane/cli/dashboard-command-handler.js +23 -7
- package/dist/apps/control-plane/cli/dashboard-command-handler.js.map +1 -1
- package/dist/apps/control-plane/cli/delete-command-handler.js +7 -7
- package/dist/apps/control-plane/cli/env-file.d.ts +4 -0
- package/dist/apps/control-plane/cli/env-file.js +89 -0
- package/dist/apps/control-plane/cli/env-file.js.map +1 -0
- package/dist/apps/control-plane/cli/help-command-handler.js +58 -30
- package/dist/apps/control-plane/cli/help-command-handler.js.map +1 -1
- package/dist/apps/control-plane/cli/init-command-handler.js +97 -37
- package/dist/apps/control-plane/cli/init-command-handler.js.map +1 -1
- package/dist/apps/control-plane/cli/io.js +2 -2
- package/dist/apps/control-plane/cli/io.js.map +1 -1
- package/dist/apps/control-plane/cli/resume-command-handler.js +9 -9
- package/dist/apps/control-plane/cli/resume-command-handler.js.map +1 -1
- package/dist/apps/control-plane/cli/retry-command-handler.js +12 -11
- package/dist/apps/control-plane/cli/retry-command-handler.js.map +1 -1
- package/dist/apps/control-plane/cli/run-command-handler.js +12 -8
- package/dist/apps/control-plane/cli/run-command-handler.js.map +1 -1
- package/dist/apps/control-plane/cli/send-command-handler.js +6 -6
- package/dist/apps/control-plane/cli/spec-ingestion-service.js +10 -8
- package/dist/apps/control-plane/cli/spec-ingestion-service.js.map +1 -1
- package/dist/apps/control-plane/cli/spec-input-resolver.js.map +1 -1
- package/dist/apps/control-plane/cli/spec-utils.js.map +1 -1
- package/dist/apps/control-plane/cli/status-command-handler.js +8 -8
- package/dist/apps/control-plane/cli/status-command-handler.js.map +1 -1
- package/dist/apps/control-plane/cli/tooling.js +1 -1
- package/dist/apps/control-plane/core/collisions.js +11 -8
- package/dist/apps/control-plane/core/collisions.js.map +1 -1
- package/dist/apps/control-plane/core/constants.js +13 -7
- package/dist/apps/control-plane/core/constants.js.map +1 -1
- package/dist/apps/control-plane/core/error-codes.js +1 -1
- package/dist/apps/control-plane/core/fs.js.map +1 -1
- package/dist/apps/control-plane/core/gates.d.ts +2 -2
- package/dist/apps/control-plane/core/gates.js +26 -19
- package/dist/apps/control-plane/core/gates.js.map +1 -1
- package/dist/apps/control-plane/core/git.js +3 -3
- package/dist/apps/control-plane/core/git.js.map +1 -1
- package/dist/apps/control-plane/core/kernel.d.ts +1 -0
- package/dist/apps/control-plane/core/kernel.js +134 -81
- package/dist/apps/control-plane/core/kernel.js.map +1 -1
- package/dist/apps/control-plane/core/patch.js +7 -3
- package/dist/apps/control-plane/core/patch.js.map +1 -1
- package/dist/apps/control-plane/core/path-layout.d.ts +1 -0
- package/dist/apps/control-plane/core/path-layout.js +4 -1
- package/dist/apps/control-plane/core/path-layout.js.map +1 -1
- package/dist/apps/control-plane/core/path-rules.js +3 -1
- package/dist/apps/control-plane/core/path-rules.js.map +1 -1
- package/dist/apps/control-plane/core/qa-index.js +5 -5
- package/dist/apps/control-plane/core/qa-index.js.map +1 -1
- package/dist/apps/control-plane/core/response.js +3 -3
- package/dist/apps/control-plane/core/response.js.map +1 -1
- package/dist/apps/control-plane/core/schemas.js +10 -6
- package/dist/apps/control-plane/core/schemas.js.map +1 -1
- package/dist/apps/control-plane/core/workspace-hooks.js +3 -3
- package/dist/apps/control-plane/index.d.ts +1 -1
- package/dist/apps/control-plane/index.js +1 -1
- package/dist/apps/control-plane/index.js.map +1 -1
- package/dist/apps/control-plane/interfaces/cli/bootstrap.js +40 -23
- package/dist/apps/control-plane/interfaces/cli/bootstrap.js.map +1 -1
- package/dist/apps/control-plane/mcp/kernel-tool-executor.js +1 -1
- package/dist/apps/control-plane/mcp/kernel-tool-executor.js.map +1 -1
- package/dist/apps/control-plane/mcp/mcp-server-adapter.js +6 -7
- package/dist/apps/control-plane/mcp/mcp-server-adapter.js.map +1 -1
- package/dist/apps/control-plane/mcp/operation-ledger.js +5 -5
- package/dist/apps/control-plane/mcp/operation-ledger.js.map +1 -1
- package/dist/apps/control-plane/mcp/protocol-contract.js +2 -2
- package/dist/apps/control-plane/mcp/runtime-factory.js +2 -2
- package/dist/apps/control-plane/mcp/runtime-factory.js.map +1 -1
- package/dist/apps/control-plane/mcp/token-auth-verifier.js +1 -1
- package/dist/apps/control-plane/mcp/token-auth-verifier.js.map +1 -1
- package/dist/apps/control-plane/mcp/token-claims-validator.js +5 -5
- package/dist/apps/control-plane/mcp/token-claims-validator.js.map +1 -1
- package/dist/apps/control-plane/mcp/tool-authorizer.js +1 -3
- package/dist/apps/control-plane/mcp/tool-authorizer.js.map +1 -1
- package/dist/apps/control-plane/mcp/tool-client.js +2 -2
- package/dist/apps/control-plane/mcp/tool-client.js.map +1 -1
- package/dist/apps/control-plane/mcp/tool-contract-validator.js +3 -3
- package/dist/apps/control-plane/mcp/tool-contract-validator.js.map +1 -1
- package/dist/apps/control-plane/mcp/tool-registry-loader.js +1 -1
- package/dist/apps/control-plane/mcp/tool-registry-loader.js.map +1 -1
- package/dist/apps/control-plane/mcp/tool-runtime.js +17 -17
- package/dist/apps/control-plane/mcp/tool-runtime.js.map +1 -1
- package/dist/apps/control-plane/mcp/tools-markdown-generator.js +6 -1
- package/dist/apps/control-plane/mcp/tools-markdown-generator.js.map +1 -1
- package/dist/apps/control-plane/providers/providers.d.ts +3 -2
- package/dist/apps/control-plane/providers/providers.js +81 -39
- package/dist/apps/control-plane/providers/providers.js.map +1 -1
- package/dist/apps/control-plane/supervisor/build-wave-executor.js +12 -12
- package/dist/apps/control-plane/supervisor/build-wave-executor.js.map +1 -1
- package/dist/apps/control-plane/supervisor/planning-wave-executor.js +19 -16
- package/dist/apps/control-plane/supervisor/planning-wave-executor.js.map +1 -1
- package/dist/apps/control-plane/supervisor/prompt-bundle-loader.js +1 -1
- package/dist/apps/control-plane/supervisor/qa-wave-executor.js +13 -13
- package/dist/apps/control-plane/supervisor/qa-wave-executor.js.map +1 -1
- package/dist/apps/control-plane/supervisor/run-coordinator.js +37 -20
- package/dist/apps/control-plane/supervisor/run-coordinator.js.map +1 -1
- package/dist/apps/control-plane/supervisor/runtime.js +25 -21
- package/dist/apps/control-plane/supervisor/runtime.js.map +1 -1
- package/dist/apps/control-plane/supervisor/session-orchestrator.js +29 -23
- package/dist/apps/control-plane/supervisor/session-orchestrator.js.map +1 -1
- package/dist/apps/control-plane/supervisor/types.d.ts +3 -3
- package/dist/apps/control-plane/supervisor/types.js.map +1 -1
- package/dist/apps/control-plane/supervisor/worker-decision-loop.js +14 -16
- package/dist/apps/control-plane/supervisor/worker-decision-loop.js.map +1 -1
- package/eslint.config.mjs +20 -20
- package/example-configurations/README.md +1 -1
- package/example-configurations/java/agents.yaml +3 -3
- package/example-configurations/java/policy.yaml +1 -1
- package/example-configurations/node/agents.yaml +3 -3
- package/example-configurations/node/policy.yaml +1 -1
- package/package.json +10 -5
- package/packages/web-dashboard/next.config.js +2 -2
- package/packages/web-dashboard/src/app/api/actions/route.ts +25 -9
- package/packages/web-dashboard/src/app/api/events/route.ts +20 -6
- package/packages/web-dashboard/src/app/api/features/[id]/checkout/route.ts +88 -37
- package/packages/web-dashboard/src/app/api/features/[id]/evidence/[artifact]/route.ts +8 -5
- package/packages/web-dashboard/src/app/api/features/[id]/review/route.ts +27 -9
- package/packages/web-dashboard/src/app/api/features/[id]/route.ts +5 -2
- package/packages/web-dashboard/src/app/api/projects/route.ts +5 -5
- package/packages/web-dashboard/src/app/globals.css +10 -2
- package/packages/web-dashboard/src/app/page.tsx +100 -37
- package/packages/web-dashboard/src/lib/aop-client.ts +68 -37
- package/packages/web-dashboard/src/lib/multi-project-config.ts +28 -7
- package/packages/web-dashboard/src/lib/orchestrator-tools.ts +59 -36
- package/packages/web-dashboard/tsconfig.json +3 -11
- package/scripts/nx-safe.mjs +10 -10
- package/spec-files/completed/agentic_orchestrator_cli_delete_command_spec.md +5 -0
- package/spec-files/completed/agentic_orchestrator_feature_gaps_closure_spec.md +189 -90
- package/spec-files/completed/agentic_orchestrator_init_policy_ux_simplification_spec.md +49 -16
- package/spec-files/completed/agentic_orchestrator_mcp_formalization_spec.md +24 -1
- package/spec-files/completed/agentic_orchestrator_single_global_orchestrator_spec.md +9 -0
- package/spec-files/completed/agentic_orchestrator_spec.md +171 -75
- package/spec-files/completed/agentic_orchestrator_validator_hardening_spec.md +25 -17
- package/spec-files/outstanding/agentic_orchestrator_artifact_database_publishing_spec.md +40 -5
- package/spec-files/outstanding/agentic_orchestrator_enterprise_governance_dashboard_spec.md +23 -12
- package/spec-files/outstanding/agentic_orchestrator_knowledge_canary_spec.md +16 -4
- package/spec-files/outstanding/agentic_orchestrator_observability_integrity_diagnostics_spec.md +42 -2
- package/spec-files/outstanding/agentic_orchestrator_performance_improvements_spec.md +209 -130
- package/spec-files/outstanding/agentic_orchestrator_planning_review_quality_spec.md +56 -3
- package/spec-files/outstanding/agentic_orchestrator_productization_commercial_spec.md +77 -10
- package/spec-files/outstanding/agentic_orchestrator_provider_auth_bootstrap_spec.md +384 -0
- package/spec-files/outstanding/agentic_orchestrator_quality_adoption_execution_spec.md +29 -14
- package/spec-files/progress.md +186 -175
- package/tsconfig.json +2 -8
|
@@ -9,18 +9,24 @@ type AnyRecord = Record<string, any>;
|
|
|
9
9
|
|
|
10
10
|
type StateUpdater = (
|
|
11
11
|
frontMatter: AnyRecord,
|
|
12
|
-
body: string
|
|
12
|
+
body: string,
|
|
13
13
|
) => Promise<{ frontMatter?: AnyRecord; body?: string }>;
|
|
14
14
|
|
|
15
15
|
interface CollisionQueueDrivePort {
|
|
16
|
-
reDriveBlockedQueue(): Promise<{
|
|
16
|
+
reDriveBlockedQueue(): Promise<{
|
|
17
|
+
data: { processed: number; retried: number; still_blocked: number };
|
|
18
|
+
}>;
|
|
17
19
|
}
|
|
18
20
|
|
|
19
21
|
export interface LockServicePort {
|
|
20
22
|
withIndexLock<T>(operation: () => Promise<T>): Promise<T>;
|
|
21
23
|
readIndex(): Promise<AnyRecord>;
|
|
22
24
|
writeIndex(index: AnyRecord): Promise<void>;
|
|
23
|
-
updateState(
|
|
25
|
+
updateState(
|
|
26
|
+
featureId: string,
|
|
27
|
+
expectedVersion: number | null,
|
|
28
|
+
updater: StateUpdater,
|
|
29
|
+
): Promise<AnyRecord>;
|
|
24
30
|
statePath(featureId: string): string;
|
|
25
31
|
getPolicySnapshot(): AnyRecord;
|
|
26
32
|
collisionQueueService?: CollisionQueueDrivePort;
|
|
@@ -41,7 +47,11 @@ export class LockService {
|
|
|
41
47
|
this.port = port;
|
|
42
48
|
}
|
|
43
49
|
|
|
44
|
-
async locksAcquire(
|
|
50
|
+
async locksAcquire(
|
|
51
|
+
resource: string | null,
|
|
52
|
+
featureId: string | null,
|
|
53
|
+
waitTimeoutSeconds: number | null = null,
|
|
54
|
+
) {
|
|
45
55
|
const policy = this.port.getPolicySnapshot();
|
|
46
56
|
|
|
47
57
|
if (!resource || !policy.locks.resources.includes(resource)) {
|
|
@@ -49,8 +59,8 @@ export class LockService {
|
|
|
49
59
|
normalizedResponse: fail(ERROR_CODES.INVALID_ARGUMENT, 'Unknown lock resource', {
|
|
50
60
|
resource,
|
|
51
61
|
retryable: false,
|
|
52
|
-
requires_human: true
|
|
53
|
-
})
|
|
62
|
+
requires_human: true,
|
|
63
|
+
}),
|
|
54
64
|
};
|
|
55
65
|
}
|
|
56
66
|
|
|
@@ -58,8 +68,8 @@ export class LockService {
|
|
|
58
68
|
throw {
|
|
59
69
|
normalizedResponse: fail(ERROR_CODES.INVALID_ARGUMENT, 'feature_id is required', {
|
|
60
70
|
retryable: false,
|
|
61
|
-
requires_human: true
|
|
62
|
-
})
|
|
71
|
+
requires_human: true,
|
|
72
|
+
}),
|
|
63
73
|
};
|
|
64
74
|
}
|
|
65
75
|
|
|
@@ -84,12 +94,14 @@ export class LockService {
|
|
|
84
94
|
|
|
85
95
|
if (!index.locks[resource] || index.locks[resource] === featureId) {
|
|
86
96
|
const leaseId = crypto.randomUUID();
|
|
87
|
-
const expiresAt = new Date(
|
|
97
|
+
const expiresAt = new Date(
|
|
98
|
+
Date.now() + policy.locks.lease_ttl_seconds * 1000,
|
|
99
|
+
).toISOString();
|
|
88
100
|
index.locks[resource] = featureId;
|
|
89
101
|
index.lock_leases[resource] = {
|
|
90
102
|
holder: featureId,
|
|
91
103
|
lease_id: leaseId,
|
|
92
|
-
expires_at: expiresAt
|
|
104
|
+
expires_at: expiresAt,
|
|
93
105
|
};
|
|
94
106
|
index.version += 1;
|
|
95
107
|
index.updated_at = nowIso();
|
|
@@ -99,24 +111,24 @@ export class LockService {
|
|
|
99
111
|
Promise.resolve({
|
|
100
112
|
frontMatter: {
|
|
101
113
|
locks: {
|
|
102
|
-
held: normalizeSet([...(frontMatter.locks?.held ?? []), resource])
|
|
103
|
-
}
|
|
114
|
+
held: normalizeSet([...(frontMatter.locks?.held ?? []), resource]),
|
|
115
|
+
},
|
|
104
116
|
},
|
|
105
|
-
body
|
|
106
|
-
})
|
|
117
|
+
body,
|
|
118
|
+
}),
|
|
107
119
|
);
|
|
108
120
|
|
|
109
121
|
return {
|
|
110
122
|
acquired: true,
|
|
111
123
|
staleReclaimed,
|
|
112
124
|
lease_id: leaseId,
|
|
113
|
-
expires_at: expiresAt
|
|
125
|
+
expires_at: expiresAt,
|
|
114
126
|
};
|
|
115
127
|
}
|
|
116
128
|
|
|
117
129
|
return {
|
|
118
130
|
acquired: false,
|
|
119
|
-
holder: index.locks[resource]
|
|
131
|
+
holder: index.locks[resource],
|
|
120
132
|
};
|
|
121
133
|
});
|
|
122
134
|
|
|
@@ -127,14 +139,14 @@ export class LockService {
|
|
|
127
139
|
feature_id: featureId,
|
|
128
140
|
lease_id: result.lease_id,
|
|
129
141
|
expires_at: result.expires_at,
|
|
130
|
-
stale_reclaimed: result.staleReclaimed
|
|
142
|
+
stale_reclaimed: result.staleReclaimed,
|
|
131
143
|
},
|
|
132
144
|
evidence: result.staleReclaimed
|
|
133
145
|
? {
|
|
134
146
|
code: ERROR_CODES.STALE_LOCK_RECLAIMED,
|
|
135
|
-
message: `Reclaimed stale lock for ${resource}
|
|
147
|
+
message: `Reclaimed stale lock for ${resource}`,
|
|
136
148
|
}
|
|
137
|
-
: undefined
|
|
149
|
+
: undefined,
|
|
138
150
|
};
|
|
139
151
|
}
|
|
140
152
|
|
|
@@ -144,8 +156,8 @@ export class LockService {
|
|
|
144
156
|
resource,
|
|
145
157
|
holder: result.holder,
|
|
146
158
|
retryable: true,
|
|
147
|
-
requires_human: false
|
|
148
|
-
})
|
|
159
|
+
requires_human: false,
|
|
160
|
+
}),
|
|
149
161
|
};
|
|
150
162
|
}
|
|
151
163
|
|
|
@@ -154,8 +166,8 @@ export class LockService {
|
|
|
154
166
|
normalizedResponse: fail(ERROR_CODES.LOCK_CONFLICT, 'Timed out waiting for lock', {
|
|
155
167
|
resource,
|
|
156
168
|
retryable: true,
|
|
157
|
-
requires_human: false
|
|
158
|
-
})
|
|
169
|
+
requires_human: false,
|
|
170
|
+
}),
|
|
159
171
|
};
|
|
160
172
|
}
|
|
161
173
|
|
|
@@ -167,10 +179,14 @@ export class LockService {
|
|
|
167
179
|
async locksRelease(resource: string | null, featureId: string | null) {
|
|
168
180
|
if (!resource || !featureId) {
|
|
169
181
|
throw {
|
|
170
|
-
normalizedResponse: fail(
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
182
|
+
normalizedResponse: fail(
|
|
183
|
+
ERROR_CODES.INVALID_ARGUMENT,
|
|
184
|
+
'resource and feature_id are required',
|
|
185
|
+
{
|
|
186
|
+
retryable: false,
|
|
187
|
+
requires_human: true,
|
|
188
|
+
},
|
|
189
|
+
),
|
|
174
190
|
};
|
|
175
191
|
}
|
|
176
192
|
|
|
@@ -179,12 +195,16 @@ export class LockService {
|
|
|
179
195
|
const holder = index.locks[resource];
|
|
180
196
|
if (holder && holder !== featureId) {
|
|
181
197
|
throw {
|
|
182
|
-
normalizedResponse: fail(
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
198
|
+
normalizedResponse: fail(
|
|
199
|
+
ERROR_CODES.LOCK_CONFLICT,
|
|
200
|
+
'Cannot release lock held by another feature',
|
|
201
|
+
{
|
|
202
|
+
resource,
|
|
203
|
+
holder,
|
|
204
|
+
retryable: false,
|
|
205
|
+
requires_human: true,
|
|
206
|
+
},
|
|
207
|
+
),
|
|
188
208
|
};
|
|
189
209
|
}
|
|
190
210
|
|
|
@@ -199,16 +219,16 @@ export class LockService {
|
|
|
199
219
|
Promise.resolve({
|
|
200
220
|
frontMatter: {
|
|
201
221
|
locks: {
|
|
202
|
-
held: (frontMatter.locks?.held ?? []).filter((item) => item !== resource)
|
|
203
|
-
}
|
|
222
|
+
held: (frontMatter.locks?.held ?? []).filter((item) => item !== resource),
|
|
223
|
+
},
|
|
204
224
|
},
|
|
205
|
-
body
|
|
206
|
-
})
|
|
225
|
+
body,
|
|
226
|
+
}),
|
|
207
227
|
);
|
|
208
228
|
|
|
209
229
|
if (this.port.collisionQueueService) {
|
|
210
230
|
await this.port.collisionQueueService.reDriveBlockedQueue().catch(() => ({
|
|
211
|
-
data: { processed: 0, retried: 0, still_blocked: 0 }
|
|
231
|
+
data: { processed: 0, retried: 0, still_blocked: 0 },
|
|
212
232
|
}));
|
|
213
233
|
}
|
|
214
234
|
|
|
@@ -216,8 +236,8 @@ export class LockService {
|
|
|
216
236
|
data: {
|
|
217
237
|
resource,
|
|
218
238
|
feature_id: featureId,
|
|
219
|
-
released: true
|
|
220
|
-
}
|
|
239
|
+
released: true,
|
|
240
|
+
},
|
|
221
241
|
};
|
|
222
242
|
}
|
|
223
243
|
|
|
@@ -227,13 +247,15 @@ export class LockService {
|
|
|
227
247
|
await this.port.withIndexLock(async () => {
|
|
228
248
|
const index = await this.port.readIndex();
|
|
229
249
|
let changed = false;
|
|
230
|
-
for (const [resource, lease] of Object.entries(
|
|
250
|
+
for (const [resource, lease] of Object.entries(
|
|
251
|
+
index.lock_leases as Record<string, AnyRecord>,
|
|
252
|
+
)) {
|
|
231
253
|
if (!lease || !set.has(lease.holder)) {
|
|
232
254
|
continue;
|
|
233
255
|
}
|
|
234
256
|
index.lock_leases[resource] = {
|
|
235
257
|
...lease,
|
|
236
|
-
expires_at: new Date(Date.now() + policy.locks.lease_ttl_seconds * 1000).toISOString()
|
|
258
|
+
expires_at: new Date(Date.now() + policy.locks.lease_ttl_seconds * 1000).toISOString(),
|
|
237
259
|
};
|
|
238
260
|
changed = true;
|
|
239
261
|
}
|
|
@@ -245,13 +267,17 @@ export class LockService {
|
|
|
245
267
|
});
|
|
246
268
|
}
|
|
247
269
|
|
|
248
|
-
async recoverFromState(): Promise<{
|
|
270
|
+
async recoverFromState(): Promise<{
|
|
271
|
+
data: { recovered: boolean; stale_features: string[]; active: unknown };
|
|
272
|
+
}> {
|
|
249
273
|
const index = await this.port.readIndex();
|
|
250
274
|
const staleFeatures: string[] = [];
|
|
251
275
|
|
|
252
276
|
await this.port.withIndexLock(async () => {
|
|
253
277
|
const current = await this.port.readIndex();
|
|
254
|
-
for (const [resource, lease] of Object.entries(
|
|
278
|
+
for (const [resource, lease] of Object.entries(
|
|
279
|
+
current.lock_leases as Record<string, AnyRecord>,
|
|
280
|
+
)) {
|
|
255
281
|
if (!lease) {
|
|
256
282
|
continue;
|
|
257
283
|
}
|
|
@@ -280,10 +306,10 @@ export class LockService {
|
|
|
280
306
|
Promise.resolve({
|
|
281
307
|
frontMatter: {
|
|
282
308
|
status: STATUS.BLOCKED,
|
|
283
|
-
status_reason: 'Lease expired and was reclaimed'
|
|
309
|
+
status_reason: 'Lease expired and was reclaimed',
|
|
284
310
|
},
|
|
285
|
-
body
|
|
286
|
-
})
|
|
311
|
+
body,
|
|
312
|
+
}),
|
|
287
313
|
);
|
|
288
314
|
}
|
|
289
315
|
|
|
@@ -291,8 +317,8 @@ export class LockService {
|
|
|
291
317
|
data: {
|
|
292
318
|
recovered: true,
|
|
293
319
|
stale_features: normalizeSet(staleFeatures),
|
|
294
|
-
active: index.active
|
|
295
|
-
}
|
|
320
|
+
active: index.active,
|
|
321
|
+
},
|
|
296
322
|
};
|
|
297
323
|
}
|
|
298
324
|
}
|
|
@@ -11,7 +11,7 @@ type AnyRecord = Record<string, any>;
|
|
|
11
11
|
|
|
12
12
|
type StateUpdater = (
|
|
13
13
|
frontMatter: AnyRecord,
|
|
14
|
-
body: string
|
|
14
|
+
body: string,
|
|
15
15
|
) => Promise<{ frontMatter?: AnyRecord; body?: string }>;
|
|
16
16
|
|
|
17
17
|
function normalizeSet(array: string[]): string[] {
|
|
@@ -19,7 +19,8 @@ function normalizeSet(array: string[]): string[] {
|
|
|
19
19
|
}
|
|
20
20
|
|
|
21
21
|
function readHeldLocks(frontMatter: AnyRecord): string[] {
|
|
22
|
-
const locks =
|
|
22
|
+
const locks =
|
|
23
|
+
frontMatter?.locks && typeof frontMatter.locks === 'object' ? frontMatter.locks : {};
|
|
23
24
|
const held = Array.isArray(locks.held) ? locks.held : [];
|
|
24
25
|
return held.filter((item: unknown): item is string => typeof item === 'string');
|
|
25
26
|
}
|
|
@@ -38,7 +39,11 @@ export interface MergeServicePort {
|
|
|
38
39
|
featurePath(featureId: string): string;
|
|
39
40
|
readState(featureId: string): Promise<{ frontMatter: AnyRecord; body: string }>;
|
|
40
41
|
worktreePath(featureId: string): string;
|
|
41
|
-
updateState(
|
|
42
|
+
updateState(
|
|
43
|
+
featureId: string,
|
|
44
|
+
expectedVersion: number | null,
|
|
45
|
+
updater: StateUpdater,
|
|
46
|
+
): Promise<AnyRecord>;
|
|
42
47
|
locksRelease(resource: string, featureId: string): Promise<unknown>;
|
|
43
48
|
withIndexLock<T>(operation: () => Promise<T>): Promise<T>;
|
|
44
49
|
readIndex(): Promise<AnyRecord>;
|
|
@@ -56,11 +61,16 @@ export class MergeService {
|
|
|
56
61
|
const repoRoot = this.port.getRepoRoot();
|
|
57
62
|
const worktreePath = this.port.worktreePath(featureId);
|
|
58
63
|
|
|
59
|
-
const removeWorktreeResult = await runGit(repoRoot, [
|
|
64
|
+
const removeWorktreeResult = await runGit(repoRoot, [
|
|
65
|
+
'worktree',
|
|
66
|
+
'remove',
|
|
67
|
+
'--force',
|
|
68
|
+
worktreePath,
|
|
69
|
+
]);
|
|
60
70
|
if (removeWorktreeResult.code !== 0) {
|
|
61
71
|
// Best-effort cleanup; merged state must remain intact even if git cleanup fails.
|
|
62
72
|
console.warn(
|
|
63
|
-
`[aop] auto-cleanup worktree removal failed for ${featureId}: ${removeWorktreeResult.stderr.trim() || `exit ${removeWorktreeResult.code}`}
|
|
73
|
+
`[aop] auto-cleanup worktree removal failed for ${featureId}: ${removeWorktreeResult.stderr.trim() || `exit ${removeWorktreeResult.code}`}`,
|
|
64
74
|
);
|
|
65
75
|
}
|
|
66
76
|
|
|
@@ -68,7 +78,7 @@ export class MergeService {
|
|
|
68
78
|
if (removeBranchResult.code !== 0) {
|
|
69
79
|
// Best-effort cleanup; branch may already be removed.
|
|
70
80
|
console.warn(
|
|
71
|
-
`[aop] auto-cleanup branch removal failed for ${featureId}: ${removeBranchResult.stderr.trim() || `exit ${removeBranchResult.code}`}
|
|
81
|
+
`[aop] auto-cleanup branch removal failed for ${featureId}: ${removeBranchResult.stderr.trim() || `exit ${removeBranchResult.code}`}`,
|
|
72
82
|
);
|
|
73
83
|
}
|
|
74
84
|
|
|
@@ -80,7 +90,7 @@ export class MergeService {
|
|
|
80
90
|
const timeout = setTimeout(() => {
|
|
81
91
|
void this.cleanupMergedFeatureArtifacts(featureId).catch((error) => {
|
|
82
92
|
console.warn(
|
|
83
|
-
`[aop] auto-cleanup failed for ${featureId}: ${error instanceof Error ? error.message : String(error)}
|
|
93
|
+
`[aop] auto-cleanup failed for ${featureId}: ${error instanceof Error ? error.message : String(error)}`,
|
|
84
94
|
);
|
|
85
95
|
});
|
|
86
96
|
}, delayMs);
|
|
@@ -93,7 +103,7 @@ export class MergeService {
|
|
|
93
103
|
featureId: string,
|
|
94
104
|
commitMessage: string,
|
|
95
105
|
mergeStrategy: string,
|
|
96
|
-
userApprovalToken: string | null
|
|
106
|
+
userApprovalToken: string | null,
|
|
97
107
|
): Promise<{
|
|
98
108
|
data: {
|
|
99
109
|
feature_id: string;
|
|
@@ -109,30 +119,42 @@ export class MergeService {
|
|
|
109
119
|
|
|
110
120
|
if (!policy.merge_policy.allowed_strategies.includes(mergeStrategy)) {
|
|
111
121
|
throw {
|
|
112
|
-
normalizedResponse: fail(
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
122
|
+
normalizedResponse: fail(
|
|
123
|
+
ERROR_CODES.MERGE_DISABLED,
|
|
124
|
+
'Merge strategy is not allowed by policy',
|
|
125
|
+
{
|
|
126
|
+
merge_strategy: mergeStrategy,
|
|
127
|
+
retryable: false,
|
|
128
|
+
requires_human: true,
|
|
129
|
+
},
|
|
130
|
+
),
|
|
117
131
|
};
|
|
118
132
|
}
|
|
119
133
|
|
|
120
134
|
if (policy.merge_policy.require_user_approval && !userApprovalToken) {
|
|
121
135
|
throw {
|
|
122
|
-
normalizedResponse: fail(
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
136
|
+
normalizedResponse: fail(
|
|
137
|
+
ERROR_CODES.USER_APPROVAL_REQUIRED,
|
|
138
|
+
'User approval token is required',
|
|
139
|
+
{
|
|
140
|
+
retryable: false,
|
|
141
|
+
requires_human: true,
|
|
142
|
+
},
|
|
143
|
+
),
|
|
126
144
|
};
|
|
127
145
|
}
|
|
128
146
|
|
|
129
147
|
if (state.frontMatter.status !== STATUS.READY_TO_MERGE) {
|
|
130
148
|
throw {
|
|
131
|
-
normalizedResponse: fail(
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
149
|
+
normalizedResponse: fail(
|
|
150
|
+
ERROR_CODES.INVALID_STATUS_TRANSITION,
|
|
151
|
+
'Feature must be ready_to_merge before merge',
|
|
152
|
+
{
|
|
153
|
+
current_status: state.frontMatter.status,
|
|
154
|
+
retryable: false,
|
|
155
|
+
requires_human: true,
|
|
156
|
+
},
|
|
157
|
+
),
|
|
136
158
|
};
|
|
137
159
|
}
|
|
138
160
|
|
|
@@ -140,11 +162,15 @@ export class MergeService {
|
|
|
140
162
|
for (const mode of requiredModes) {
|
|
141
163
|
if (state.frontMatter.gates?.[mode] !== GATE_RESULT.PASS) {
|
|
142
164
|
throw {
|
|
143
|
-
normalizedResponse: fail(
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
165
|
+
normalizedResponse: fail(
|
|
166
|
+
ERROR_CODES.MERGE_DISABLED,
|
|
167
|
+
'Required gate mode has not passed',
|
|
168
|
+
{
|
|
169
|
+
mode,
|
|
170
|
+
retryable: true,
|
|
171
|
+
requires_human: false,
|
|
172
|
+
},
|
|
173
|
+
),
|
|
148
174
|
};
|
|
149
175
|
}
|
|
150
176
|
}
|
|
@@ -157,19 +183,21 @@ export class MergeService {
|
|
|
157
183
|
normalizedResponse: fail(ERROR_CODES.GIT_FAILURE, 'Failed to stage changes before merge', {
|
|
158
184
|
stderr: commitResult.stderr,
|
|
159
185
|
retryable: true,
|
|
160
|
-
requires_human: false
|
|
161
|
-
})
|
|
186
|
+
requires_human: false,
|
|
187
|
+
}),
|
|
162
188
|
};
|
|
163
189
|
}
|
|
164
190
|
|
|
165
|
-
const commit = await runGit(repoRoot, ['commit', '-m', commitMessage], {
|
|
191
|
+
const commit = await runGit(repoRoot, ['commit', '-m', commitMessage], {
|
|
192
|
+
cwd: featureWorktree,
|
|
193
|
+
});
|
|
166
194
|
if (commit.code !== 0 && !commit.stderr.includes('nothing to commit')) {
|
|
167
195
|
throw {
|
|
168
196
|
normalizedResponse: fail(ERROR_CODES.GIT_FAILURE, 'Failed to commit feature branch', {
|
|
169
197
|
stderr: commit.stderr,
|
|
170
198
|
retryable: true,
|
|
171
|
-
requires_human: false
|
|
172
|
-
})
|
|
199
|
+
requires_human: false,
|
|
200
|
+
}),
|
|
173
201
|
};
|
|
174
202
|
}
|
|
175
203
|
|
|
@@ -177,17 +205,27 @@ export class MergeService {
|
|
|
177
205
|
const checkoutBase = await runGit(repoRoot, ['checkout', baseBranch]);
|
|
178
206
|
if (checkoutBase.code !== 0) {
|
|
179
207
|
throw {
|
|
180
|
-
normalizedResponse: fail(
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
208
|
+
normalizedResponse: fail(
|
|
209
|
+
ERROR_CODES.GIT_FAILURE,
|
|
210
|
+
'Failed to checkout base branch for merge',
|
|
211
|
+
{
|
|
212
|
+
stderr: checkoutBase.stderr,
|
|
213
|
+
retryable: true,
|
|
214
|
+
requires_human: true,
|
|
215
|
+
},
|
|
216
|
+
),
|
|
185
217
|
};
|
|
186
218
|
}
|
|
187
219
|
|
|
188
220
|
let merge;
|
|
189
221
|
if (mergeStrategy === 'merge_commit') {
|
|
190
|
-
merge = await runGit(repoRoot, [
|
|
222
|
+
merge = await runGit(repoRoot, [
|
|
223
|
+
'merge',
|
|
224
|
+
'--no-ff',
|
|
225
|
+
featureId,
|
|
226
|
+
'-m',
|
|
227
|
+
`Merge feature ${featureId}`,
|
|
228
|
+
]);
|
|
191
229
|
} else if (mergeStrategy === 'squash') {
|
|
192
230
|
merge = await runGit(repoRoot, ['merge', '--squash', featureId]);
|
|
193
231
|
if (merge.code === 0) {
|
|
@@ -200,8 +238,8 @@ export class MergeService {
|
|
|
200
238
|
normalizedResponse: fail(ERROR_CODES.GIT_FAILURE, 'Rebase failed before merge', {
|
|
201
239
|
stderr: rebase.stderr,
|
|
202
240
|
retryable: true,
|
|
203
|
-
requires_human: true
|
|
204
|
-
})
|
|
241
|
+
requires_human: true,
|
|
242
|
+
}),
|
|
205
243
|
};
|
|
206
244
|
}
|
|
207
245
|
merge = await runGit(repoRoot, ['merge', '--ff-only', featureId]);
|
|
@@ -212,8 +250,8 @@ export class MergeService {
|
|
|
212
250
|
normalizedResponse: fail(ERROR_CODES.GIT_FAILURE, 'Merge failed', {
|
|
213
251
|
stderr: merge.stderr,
|
|
214
252
|
retryable: true,
|
|
215
|
-
requires_human: true
|
|
216
|
-
})
|
|
253
|
+
requires_human: true,
|
|
254
|
+
}),
|
|
217
255
|
};
|
|
218
256
|
}
|
|
219
257
|
|
|
@@ -229,11 +267,11 @@ export class MergeService {
|
|
|
229
267
|
...(frontMatter.evidence ?? {}),
|
|
230
268
|
merge_sha: mergeSha,
|
|
231
269
|
merge_strategy: mergeStrategy,
|
|
232
|
-
merge_at: nowIso()
|
|
233
|
-
}
|
|
270
|
+
merge_at: nowIso(),
|
|
271
|
+
},
|
|
234
272
|
},
|
|
235
|
-
body: `${body}\n\n## Merge\n\nMerged at ${nowIso()} as ${mergeSha}.\n
|
|
236
|
-
})
|
|
273
|
+
body: `${body}\n\n## Merge\n\nMerged at ${nowIso()} as ${mergeSha}.\n`,
|
|
274
|
+
}),
|
|
237
275
|
);
|
|
238
276
|
|
|
239
277
|
const heldLocks = [...readHeldLocks(state.frontMatter)];
|
|
@@ -248,7 +286,9 @@ export class MergeService {
|
|
|
248
286
|
index.merged = normalizeSet([...asArray<string>(index.merged), featureId]);
|
|
249
287
|
|
|
250
288
|
const blockedQueue = asArray<AnyRecord>(index.blocked_queue);
|
|
251
|
-
index.blocked_queue = blockedQueue.filter(
|
|
289
|
+
index.blocked_queue = blockedQueue.filter(
|
|
290
|
+
(entry) => asRecord(entry).feature_id !== featureId,
|
|
291
|
+
);
|
|
252
292
|
|
|
253
293
|
const locks = asRecord(index.locks);
|
|
254
294
|
for (const [resource, holder] of Object.entries(locks)) {
|
|
@@ -285,7 +325,8 @@ export class MergeService {
|
|
|
285
325
|
const cleanupPolicy = asRecord(policy.cleanup);
|
|
286
326
|
const autoAfterMerge = cleanupPolicy.auto_after_merge === true;
|
|
287
327
|
const gracePeriodSeconds =
|
|
288
|
-
typeof cleanupPolicy.grace_period_seconds === 'number' &&
|
|
328
|
+
typeof cleanupPolicy.grace_period_seconds === 'number' &&
|
|
329
|
+
Number.isFinite(cleanupPolicy.grace_period_seconds)
|
|
289
330
|
? cleanupPolicy.grace_period_seconds
|
|
290
331
|
: 3600;
|
|
291
332
|
const shouldCleanupNow = autoAfterMerge && gracePeriodSeconds <= 0;
|
|
@@ -303,8 +344,8 @@ export class MergeService {
|
|
|
303
344
|
merge_strategy: mergeStrategy,
|
|
304
345
|
status: STATUS.MERGED,
|
|
305
346
|
retained_for_cleanup: !shouldCleanupNow,
|
|
306
|
-
cleanup_grace_period_seconds: gracePeriodSeconds
|
|
307
|
-
}
|
|
347
|
+
cleanup_grace_period_seconds: gracePeriodSeconds,
|
|
348
|
+
},
|
|
308
349
|
};
|
|
309
350
|
}
|
|
310
351
|
}
|