agentic-orchestrator 0.1.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/.dockerignore +24 -0
- package/.github/workflows/mcp-contract-validation.yml +38 -0
- package/Agentic-Orchestrator.iml +9 -0
- package/LICENSE +21 -0
- package/README.md +679 -0
- package/agentic/orchestrator/agents.yaml +14 -0
- package/agentic/orchestrator/gates.yaml +31 -0
- package/agentic/orchestrator/policy.yaml +145 -0
- package/agentic/orchestrator/prompts/builder.system.md +1 -0
- package/agentic/orchestrator/prompts/planner.system.md +15 -0
- package/agentic/orchestrator/prompts/qa.system.md +1 -0
- package/agentic/orchestrator/schemas/agents.schema.json +49 -0
- package/agentic/orchestrator/schemas/gates.schema.json +65 -0
- package/agentic/orchestrator/schemas/index.schema.json +108 -0
- package/agentic/orchestrator/schemas/plan.schema.json +127 -0
- package/agentic/orchestrator/schemas/policy.schema.json +227 -0
- package/agentic/orchestrator/schemas/qa_test_index.schema.json +53 -0
- package/agentic/orchestrator/schemas/state.schema.json +92 -0
- package/agentic/orchestrator/tools/catalog.json +399 -0
- package/agentic/orchestrator/tools/errors.schema.json +21 -0
- package/agentic/orchestrator/tools/protocol.json +8 -0
- package/agentic/orchestrator/tools/schemas/input/collisions.scan.input.schema.json +7 -0
- package/agentic/orchestrator/tools/schemas/input/evidence.latest.input.schema.json +15 -0
- package/agentic/orchestrator/tools/schemas/input/feature.delete.input.schema.json +42 -0
- package/agentic/orchestrator/tools/schemas/input/feature.discover_specs.input.schema.json +7 -0
- package/agentic/orchestrator/tools/schemas/input/feature.get_context.input.schema.json +15 -0
- package/agentic/orchestrator/tools/schemas/input/feature.init.input.schema.json +21 -0
- package/agentic/orchestrator/tools/schemas/input/feature.log_append.input.schema.json +26 -0
- package/agentic/orchestrator/tools/schemas/input/feature.ready_to_merge.input.schema.json +34 -0
- package/agentic/orchestrator/tools/schemas/input/feature.state_get.input.schema.json +15 -0
- package/agentic/orchestrator/tools/schemas/input/feature.state_patch.input.schema.json +28 -0
- package/agentic/orchestrator/tools/schemas/input/gates.list.input.schema.json +11 -0
- package/agentic/orchestrator/tools/schemas/input/gates.run.input.schema.json +29 -0
- package/agentic/orchestrator/tools/schemas/input/locks.acquire.input.schema.json +29 -0
- package/agentic/orchestrator/tools/schemas/input/locks.release.input.schema.json +26 -0
- package/agentic/orchestrator/tools/schemas/input/mutating.schema.json +14 -0
- package/agentic/orchestrator/tools/schemas/input/plan.get.input.schema.json +15 -0
- package/agentic/orchestrator/tools/schemas/input/plan.submit.input.schema.json +28 -0
- package/agentic/orchestrator/tools/schemas/input/plan.update.input.schema.json +29 -0
- package/agentic/orchestrator/tools/schemas/input/qa.test_index_get.input.schema.json +15 -0
- package/agentic/orchestrator/tools/schemas/input/qa.test_index_update.input.schema.json +38 -0
- package/agentic/orchestrator/tools/schemas/input/read.schema.json +6 -0
- package/agentic/orchestrator/tools/schemas/input/repo.apply_patch.input.schema.json +25 -0
- package/agentic/orchestrator/tools/schemas/input/repo.diff.input.schema.json +21 -0
- package/agentic/orchestrator/tools/schemas/input/repo.diff_bundle.input.schema.json +15 -0
- package/agentic/orchestrator/tools/schemas/input/repo.ensure_worktree.input.schema.json +21 -0
- package/agentic/orchestrator/tools/schemas/input/repo.read_file.input.schema.json +20 -0
- package/agentic/orchestrator/tools/schemas/input/repo.search.input.schema.json +20 -0
- package/agentic/orchestrator/tools/schemas/input/repo.status.input.schema.json +15 -0
- package/agentic/orchestrator/tools/schemas/input/report.dashboard.input.schema.json +7 -0
- package/agentic/orchestrator/tools/schemas/input/report.feature_summary.input.schema.json +15 -0
- package/agentic/orchestrator/tools/schemas/output/collisions.scan.output.schema.json +17 -0
- package/agentic/orchestrator/tools/schemas/output/evidence.latest.output.schema.json +20 -0
- package/agentic/orchestrator/tools/schemas/output/feature.delete.output.schema.json +224 -0
- package/agentic/orchestrator/tools/schemas/output/feature.discover_specs.output.schema.json +32 -0
- package/agentic/orchestrator/tools/schemas/output/feature.get_context.output.schema.json +40 -0
- package/agentic/orchestrator/tools/schemas/output/feature.init.output.schema.json +24 -0
- package/agentic/orchestrator/tools/schemas/output/feature.log_append.output.schema.json +24 -0
- package/agentic/orchestrator/tools/schemas/output/feature.ready_to_merge.output.schema.json +30 -0
- package/agentic/orchestrator/tools/schemas/output/feature.state_get.output.schema.json +18 -0
- package/agentic/orchestrator/tools/schemas/output/feature.state_patch.output.schema.json +24 -0
- package/agentic/orchestrator/tools/schemas/output/gates.list.output.schema.json +42 -0
- package/agentic/orchestrator/tools/schemas/output/gates.run.output.schema.json +37 -0
- package/agentic/orchestrator/tools/schemas/output/locks.acquire.output.schema.json +34 -0
- package/agentic/orchestrator/tools/schemas/output/locks.release.output.schema.json +24 -0
- package/agentic/orchestrator/tools/schemas/output/plan.get.output.schema.json +26 -0
- package/agentic/orchestrator/tools/schemas/output/plan.submit.output.schema.json +23 -0
- package/agentic/orchestrator/tools/schemas/output/plan.update.output.schema.json +23 -0
- package/agentic/orchestrator/tools/schemas/output/qa.test_index_get.output.schema.json +22 -0
- package/agentic/orchestrator/tools/schemas/output/qa.test_index_update.output.schema.json +19 -0
- package/agentic/orchestrator/tools/schemas/output/repo.apply_patch.output.schema.json +33 -0
- package/agentic/orchestrator/tools/schemas/output/repo.diff.output.schema.json +19 -0
- package/agentic/orchestrator/tools/schemas/output/repo.diff_bundle.output.schema.json +32 -0
- package/agentic/orchestrator/tools/schemas/output/repo.ensure_worktree.output.schema.json +29 -0
- package/agentic/orchestrator/tools/schemas/output/repo.read_file.output.schema.json +24 -0
- package/agentic/orchestrator/tools/schemas/output/repo.search.output.schema.json +26 -0
- package/agentic/orchestrator/tools/schemas/output/repo.status.output.schema.json +27 -0
- package/agentic/orchestrator/tools/schemas/output/report.dashboard.output.schema.json +21 -0
- package/agentic/orchestrator/tools/schemas/output/report.feature_summary.output.schema.json +36 -0
- package/agentic/orchestrator/tools/schemas/output/standard_success.schema.json +6 -0
- package/agentic/orchestrator/tools.md +32 -0
- package/apps/control-plane/project.json +39 -0
- package/apps/control-plane/scripts/validate-architecture-rules.mjs +170 -0
- package/apps/control-plane/scripts/validate-docker-mcp-contract.mjs +84 -0
- package/apps/control-plane/scripts/validate-mcp-contracts.ts +61 -0
- package/apps/control-plane/src/application/services/collision-queue-service.ts +227 -0
- package/apps/control-plane/src/application/services/feature-deletion-service.ts +459 -0
- package/apps/control-plane/src/application/services/feature-lifecycle-service.ts +177 -0
- package/apps/control-plane/src/application/services/feature-state-service.ts +125 -0
- package/apps/control-plane/src/application/services/gate-service.ts +232 -0
- package/apps/control-plane/src/application/services/lock-service.ts +298 -0
- package/apps/control-plane/src/application/services/merge-service.ts +246 -0
- package/apps/control-plane/src/application/services/patch-service.ts +259 -0
- package/apps/control-plane/src/application/services/plan-service.ts +302 -0
- package/apps/control-plane/src/application/services/qa-index-service.ts +98 -0
- package/apps/control-plane/src/application/services/reporting-service.ts +120 -0
- package/apps/control-plane/src/application/services/run-lease-service.ts +340 -0
- package/apps/control-plane/src/application/tools/tool-metadata.ts +56 -0
- package/apps/control-plane/src/application/tools/tool-router.ts +43 -0
- package/apps/control-plane/src/cli/aop.ts +31 -0
- package/apps/control-plane/src/cli/cli-argument-parser.ts +116 -0
- package/apps/control-plane/src/cli/delete-command-handler.ts +90 -0
- package/apps/control-plane/src/cli/io.ts +14 -0
- package/apps/control-plane/src/cli/resume-command-handler.ts +228 -0
- package/apps/control-plane/src/cli/run-command-handler.ts +57 -0
- package/apps/control-plane/src/cli/spec-ingestion-service.ts +88 -0
- package/apps/control-plane/src/cli/spec-input-resolver.ts +95 -0
- package/apps/control-plane/src/cli/spec-utils.ts +40 -0
- package/apps/control-plane/src/cli/status-command-handler.ts +17 -0
- package/apps/control-plane/src/cli/stop-command-handler.ts +5 -0
- package/apps/control-plane/src/cli/tooling.ts +36 -0
- package/apps/control-plane/src/cli/types.ts +34 -0
- package/apps/control-plane/src/core/collisions.ts +121 -0
- package/apps/control-plane/src/core/constants.ts +72 -0
- package/apps/control-plane/src/core/error-codes.ts +54 -0
- package/apps/control-plane/src/core/frontmatter.ts +42 -0
- package/apps/control-plane/src/core/fs.ts +173 -0
- package/apps/control-plane/src/core/gates.ts +361 -0
- package/apps/control-plane/src/core/git.ts +115 -0
- package/apps/control-plane/src/core/kernel.ts +1077 -0
- package/apps/control-plane/src/core/patch.ts +152 -0
- package/apps/control-plane/src/core/path-layout.ts +113 -0
- package/apps/control-plane/src/core/path-rules.ts +71 -0
- package/apps/control-plane/src/core/qa-index.ts +179 -0
- package/apps/control-plane/src/core/response.ts +62 -0
- package/apps/control-plane/src/core/runtime-sessions.ts +20 -0
- package/apps/control-plane/src/core/schemas.ts +125 -0
- package/apps/control-plane/src/index.ts +21 -0
- package/apps/control-plane/src/interfaces/cli/bootstrap.ts +100 -0
- package/apps/control-plane/src/mcp/kernel-tool-executor.ts +39 -0
- package/apps/control-plane/src/mcp/mcp-server-adapter.ts +74 -0
- package/apps/control-plane/src/mcp/operation-ledger.ts +108 -0
- package/apps/control-plane/src/mcp/protocol-contract.ts +9 -0
- package/apps/control-plane/src/mcp/runtime-factory.ts +105 -0
- package/apps/control-plane/src/mcp/runtime-types.ts +44 -0
- package/apps/control-plane/src/mcp/token-auth-verifier.ts +63 -0
- package/apps/control-plane/src/mcp/token-claims-validator.ts +72 -0
- package/apps/control-plane/src/mcp/token-codec.ts +62 -0
- package/apps/control-plane/src/mcp/tool-authorizer.ts +43 -0
- package/apps/control-plane/src/mcp/tool-client.ts +78 -0
- package/apps/control-plane/src/mcp/tool-contract-validator.ts +83 -0
- package/apps/control-plane/src/mcp/tool-registry-loader.ts +135 -0
- package/apps/control-plane/src/mcp/tool-runtime.ts +336 -0
- package/apps/control-plane/src/mcp/tools-markdown-generator.ts +26 -0
- package/apps/control-plane/src/mcp/transport-types.ts +16 -0
- package/apps/control-plane/src/mcp/types.ts +2 -0
- package/apps/control-plane/src/providers/providers.ts +177 -0
- package/apps/control-plane/src/supervisor/build-wave-executor.ts +55 -0
- package/apps/control-plane/src/supervisor/lease-heartbeat-service.ts +22 -0
- package/apps/control-plane/src/supervisor/planning-wave-executor.ts +316 -0
- package/apps/control-plane/src/supervisor/prompt-bundle-loader.ts +62 -0
- package/apps/control-plane/src/supervisor/qa-wave-executor.ts +99 -0
- package/apps/control-plane/src/supervisor/run-coordinator.ts +224 -0
- package/apps/control-plane/src/supervisor/runtime.ts +347 -0
- package/apps/control-plane/src/supervisor/session-orchestrator.ts +268 -0
- package/apps/control-plane/src/supervisor/types.ts +149 -0
- package/apps/control-plane/src/supervisor/worker-decision-loop.ts +299 -0
- package/apps/control-plane/test/aop.spec.ts +101 -0
- package/apps/control-plane/test/cli-helpers.spec.ts +102 -0
- package/apps/control-plane/test/cli.spec.ts +12 -0
- package/apps/control-plane/test/cli.unit.spec.ts +609 -0
- package/apps/control-plane/test/collision-queue.spec.ts +158 -0
- package/apps/control-plane/test/collisions.spec.ts +138 -0
- package/apps/control-plane/test/core-utils.spec.ts +102 -0
- package/apps/control-plane/test/delete-command-handler.spec.ts +202 -0
- package/apps/control-plane/test/epoch-tracking.spec.ts +121 -0
- package/apps/control-plane/test/gates.spec.ts +452 -0
- package/apps/control-plane/test/helpers.ts +68 -0
- package/apps/control-plane/test/index.spec.ts +18 -0
- package/apps/control-plane/test/kernel-collision-replay.spec.ts +222 -0
- package/apps/control-plane/test/kernel.branches.spec.ts +321 -0
- package/apps/control-plane/test/kernel.coverage.spec.ts +408 -0
- package/apps/control-plane/test/kernel.spec.ts +369 -0
- package/apps/control-plane/test/mcp-helpers.spec.ts +195 -0
- package/apps/control-plane/test/mcp.spec.ts +776 -0
- package/apps/control-plane/test/merge-service.spec.ts +357 -0
- package/apps/control-plane/test/plan-service.spec.ts +195 -0
- package/apps/control-plane/test/planning-wave-executor.spec.ts +229 -0
- package/apps/control-plane/test/providers.spec.ts +168 -0
- package/apps/control-plane/test/qa-index-service.spec.ts +187 -0
- package/apps/control-plane/test/qa-index.spec.ts +317 -0
- package/apps/control-plane/test/response.spec.ts +55 -0
- package/apps/control-plane/test/run-coordinator.spec.ts +334 -0
- package/apps/control-plane/test/schema-date-time.spec.ts +170 -0
- package/apps/control-plane/test/service-retry-paths.spec.ts +305 -0
- package/apps/control-plane/test/services.spec.ts +693 -0
- package/apps/control-plane/test/spec-input-resolver.spec.ts +76 -0
- package/apps/control-plane/test/supervisor-collaborators.spec.ts +201 -0
- package/apps/control-plane/test/supervisor.calltool.spec.ts +120 -0
- package/apps/control-plane/test/supervisor.spec.ts +415 -0
- package/apps/control-plane/test/supervisor.unit.spec.ts +522 -0
- package/apps/control-plane/test/token-auth-verifier.spec.ts +111 -0
- package/apps/control-plane/test/tool-registry-loader.spec.ts +268 -0
- package/apps/control-plane/test/tool-runtime.spec.ts +294 -0
- package/apps/control-plane/test/worker-decision-loop.spec.ts +587 -0
- package/apps/control-plane/tsconfig.build.json +17 -0
- package/apps/control-plane/tsconfig.json +11 -0
- package/apps/control-plane/vitest.config.ts +28 -0
- package/dist/apps/control-plane/application/services/collision-queue-service.d.ts +69 -0
- package/dist/apps/control-plane/application/services/collision-queue-service.js +158 -0
- package/dist/apps/control-plane/application/services/collision-queue-service.js.map +1 -0
- package/dist/apps/control-plane/application/services/feature-deletion-service.d.ts +79 -0
- package/dist/apps/control-plane/application/services/feature-deletion-service.js +336 -0
- package/dist/apps/control-plane/application/services/feature-deletion-service.js.map +1 -0
- package/dist/apps/control-plane/application/services/feature-lifecycle-service.d.ts +81 -0
- package/dist/apps/control-plane/application/services/feature-lifecycle-service.js +117 -0
- package/dist/apps/control-plane/application/services/feature-lifecycle-service.js.map +1 -0
- package/dist/apps/control-plane/application/services/feature-state-service.d.ts +34 -0
- package/dist/apps/control-plane/application/services/feature-state-service.js +90 -0
- package/dist/apps/control-plane/application/services/feature-state-service.js.map +1 -0
- package/dist/apps/control-plane/application/services/gate-service.d.ts +46 -0
- package/dist/apps/control-plane/application/services/gate-service.js +160 -0
- package/dist/apps/control-plane/application/services/gate-service.js.map +1 -0
- package/dist/apps/control-plane/application/services/lock-service.d.ts +56 -0
- package/dist/apps/control-plane/application/services/lock-service.js +242 -0
- package/dist/apps/control-plane/application/services/lock-service.js.map +1 -0
- package/dist/apps/control-plane/application/services/merge-service.d.ts +33 -0
- package/dist/apps/control-plane/application/services/merge-service.js +194 -0
- package/dist/apps/control-plane/application/services/merge-service.js.map +1 -0
- package/dist/apps/control-plane/application/services/patch-service.d.ts +39 -0
- package/dist/apps/control-plane/application/services/patch-service.js +189 -0
- package/dist/apps/control-plane/application/services/patch-service.js.map +1 -0
- package/dist/apps/control-plane/application/services/plan-service.d.ts +60 -0
- package/dist/apps/control-plane/application/services/plan-service.js +234 -0
- package/dist/apps/control-plane/application/services/plan-service.js.map +1 -0
- package/dist/apps/control-plane/application/services/qa-index-service.d.ts +26 -0
- package/dist/apps/control-plane/application/services/qa-index-service.js +66 -0
- package/dist/apps/control-plane/application/services/qa-index-service.js.map +1 -0
- package/dist/apps/control-plane/application/services/reporting-service.d.ts +47 -0
- package/dist/apps/control-plane/application/services/reporting-service.js +90 -0
- package/dist/apps/control-plane/application/services/reporting-service.js.map +1 -0
- package/dist/apps/control-plane/application/services/run-lease-service.d.ts +74 -0
- package/dist/apps/control-plane/application/services/run-lease-service.js +263 -0
- package/dist/apps/control-plane/application/services/run-lease-service.js.map +1 -0
- package/dist/apps/control-plane/application/tools/tool-metadata.d.ts +8 -0
- package/dist/apps/control-plane/application/tools/tool-metadata.js +37 -0
- package/dist/apps/control-plane/application/tools/tool-metadata.js.map +1 -0
- package/dist/apps/control-plane/application/tools/tool-router.d.ts +16 -0
- package/dist/apps/control-plane/application/tools/tool-router.js +25 -0
- package/dist/apps/control-plane/application/tools/tool-router.js.map +1 -0
- package/dist/apps/control-plane/cli/aop.d.ts +5 -0
- package/dist/apps/control-plane/cli/aop.js +19 -0
- package/dist/apps/control-plane/cli/aop.js.map +1 -0
- package/dist/apps/control-plane/cli/cli-argument-parser.d.ts +5 -0
- package/dist/apps/control-plane/cli/cli-argument-parser.js +109 -0
- package/dist/apps/control-plane/cli/cli-argument-parser.js.map +1 -0
- package/dist/apps/control-plane/cli/delete-command-handler.d.ts +8 -0
- package/dist/apps/control-plane/cli/delete-command-handler.js +77 -0
- package/dist/apps/control-plane/cli/delete-command-handler.js.map +1 -0
- package/dist/apps/control-plane/cli/io.d.ts +2 -0
- package/dist/apps/control-plane/cli/io.js +14 -0
- package/dist/apps/control-plane/cli/io.js.map +1 -0
- package/dist/apps/control-plane/cli/resume-command-handler.d.ts +17 -0
- package/dist/apps/control-plane/cli/resume-command-handler.js +178 -0
- package/dist/apps/control-plane/cli/resume-command-handler.js.map +1 -0
- package/dist/apps/control-plane/cli/run-command-handler.d.ts +15 -0
- package/dist/apps/control-plane/cli/run-command-handler.js +39 -0
- package/dist/apps/control-plane/cli/run-command-handler.js.map +1 -0
- package/dist/apps/control-plane/cli/spec-ingestion-service.d.ts +8 -0
- package/dist/apps/control-plane/cli/spec-ingestion-service.js +77 -0
- package/dist/apps/control-plane/cli/spec-ingestion-service.js.map +1 -0
- package/dist/apps/control-plane/cli/spec-input-resolver.d.ts +9 -0
- package/dist/apps/control-plane/cli/spec-input-resolver.js +81 -0
- package/dist/apps/control-plane/cli/spec-input-resolver.js.map +1 -0
- package/dist/apps/control-plane/cli/spec-utils.d.ts +3 -0
- package/dist/apps/control-plane/cli/spec-utils.js +36 -0
- package/dist/apps/control-plane/cli/spec-utils.js.map +1 -0
- package/dist/apps/control-plane/cli/status-command-handler.d.ts +7 -0
- package/dist/apps/control-plane/cli/status-command-handler.js +14 -0
- package/dist/apps/control-plane/cli/status-command-handler.js.map +1 -0
- package/dist/apps/control-plane/cli/stop-command-handler.d.ts +3 -0
- package/dist/apps/control-plane/cli/stop-command-handler.js +6 -0
- package/dist/apps/control-plane/cli/stop-command-handler.js.map +1 -0
- package/dist/apps/control-plane/cli/tooling.d.ts +4 -0
- package/dist/apps/control-plane/cli/tooling.js +24 -0
- package/dist/apps/control-plane/cli/tooling.js.map +1 -0
- package/dist/apps/control-plane/cli/types.d.ts +31 -0
- package/dist/apps/control-plane/cli/types.js +2 -0
- package/dist/apps/control-plane/cli/types.js.map +1 -0
- package/dist/apps/control-plane/core/collisions.d.ts +39 -0
- package/dist/apps/control-plane/core/collisions.js +78 -0
- package/dist/apps/control-plane/core/collisions.js.map +1 -0
- package/dist/apps/control-plane/core/constants.d.ts +64 -0
- package/dist/apps/control-plane/core/constants.js +64 -0
- package/dist/apps/control-plane/core/constants.js.map +1 -0
- package/dist/apps/control-plane/core/error-codes.d.ts +50 -0
- package/dist/apps/control-plane/core/error-codes.js +52 -0
- package/dist/apps/control-plane/core/error-codes.js.map +1 -0
- package/dist/apps/control-plane/core/frontmatter.d.ts +11 -0
- package/dist/apps/control-plane/core/frontmatter.js +30 -0
- package/dist/apps/control-plane/core/frontmatter.js.map +1 -0
- package/dist/apps/control-plane/core/fs.d.ts +33 -0
- package/dist/apps/control-plane/core/fs.js +134 -0
- package/dist/apps/control-plane/core/fs.js.map +1 -0
- package/dist/apps/control-plane/core/gates.d.ts +88 -0
- package/dist/apps/control-plane/core/gates.js +229 -0
- package/dist/apps/control-plane/core/gates.js.map +1 -0
- package/dist/apps/control-plane/core/git.d.ts +31 -0
- package/dist/apps/control-plane/core/git.js +79 -0
- package/dist/apps/control-plane/core/git.js.map +1 -0
- package/dist/apps/control-plane/core/kernel.d.ts +445 -0
- package/dist/apps/control-plane/core/kernel.js +805 -0
- package/dist/apps/control-plane/core/kernel.js.map +1 -0
- package/dist/apps/control-plane/core/patch.d.ts +23 -0
- package/dist/apps/control-plane/core/patch.js +118 -0
- package/dist/apps/control-plane/core/patch.js.map +1 -0
- package/dist/apps/control-plane/core/path-layout.d.ts +23 -0
- package/dist/apps/control-plane/core/path-layout.js +90 -0
- package/dist/apps/control-plane/core/path-layout.js.map +1 -0
- package/dist/apps/control-plane/core/path-rules.d.ts +13 -0
- package/dist/apps/control-plane/core/path-rules.js +52 -0
- package/dist/apps/control-plane/core/path-rules.js.map +1 -0
- package/dist/apps/control-plane/core/qa-index.d.ts +53 -0
- package/dist/apps/control-plane/core/qa-index.js +112 -0
- package/dist/apps/control-plane/core/qa-index.js.map +1 -0
- package/dist/apps/control-plane/core/response.d.ts +19 -0
- package/dist/apps/control-plane/core/response.js +34 -0
- package/dist/apps/control-plane/core/response.js.map +1 -0
- package/dist/apps/control-plane/core/runtime-sessions.d.ts +19 -0
- package/dist/apps/control-plane/core/runtime-sessions.js +2 -0
- package/dist/apps/control-plane/core/runtime-sessions.js.map +1 -0
- package/dist/apps/control-plane/core/schemas.d.ts +23 -0
- package/dist/apps/control-plane/core/schemas.js +80 -0
- package/dist/apps/control-plane/core/schemas.js.map +1 -0
- package/dist/apps/control-plane/index.d.ts +11 -0
- package/dist/apps/control-plane/index.js +9 -0
- package/dist/apps/control-plane/index.js.map +1 -0
- package/dist/apps/control-plane/interfaces/cli/bootstrap.d.ts +2 -0
- package/dist/apps/control-plane/interfaces/cli/bootstrap.js +86 -0
- package/dist/apps/control-plane/interfaces/cli/bootstrap.js.map +1 -0
- package/dist/apps/control-plane/mcp/kernel-tool-executor.d.ts +14 -0
- package/dist/apps/control-plane/mcp/kernel-tool-executor.js +26 -0
- package/dist/apps/control-plane/mcp/kernel-tool-executor.js.map +1 -0
- package/dist/apps/control-plane/mcp/mcp-server-adapter.d.ts +19 -0
- package/dist/apps/control-plane/mcp/mcp-server-adapter.js +55 -0
- package/dist/apps/control-plane/mcp/mcp-server-adapter.js.map +1 -0
- package/dist/apps/control-plane/mcp/operation-ledger.d.ts +21 -0
- package/dist/apps/control-plane/mcp/operation-ledger.js +75 -0
- package/dist/apps/control-plane/mcp/operation-ledger.js.map +1 -0
- package/dist/apps/control-plane/mcp/protocol-contract.d.ts +8 -0
- package/dist/apps/control-plane/mcp/protocol-contract.js +9 -0
- package/dist/apps/control-plane/mcp/protocol-contract.js.map +1 -0
- package/dist/apps/control-plane/mcp/runtime-factory.d.ts +38 -0
- package/dist/apps/control-plane/mcp/runtime-factory.js +71 -0
- package/dist/apps/control-plane/mcp/runtime-factory.js.map +1 -0
- package/dist/apps/control-plane/mcp/runtime-types.d.ts +40 -0
- package/dist/apps/control-plane/mcp/runtime-types.js +2 -0
- package/dist/apps/control-plane/mcp/runtime-types.js.map +1 -0
- package/dist/apps/control-plane/mcp/token-auth-verifier.d.ts +24 -0
- package/dist/apps/control-plane/mcp/token-auth-verifier.js +45 -0
- package/dist/apps/control-plane/mcp/token-auth-verifier.js.map +1 -0
- package/dist/apps/control-plane/mcp/token-claims-validator.d.ts +9 -0
- package/dist/apps/control-plane/mcp/token-claims-validator.js +62 -0
- package/dist/apps/control-plane/mcp/token-claims-validator.js.map +1 -0
- package/dist/apps/control-plane/mcp/token-codec.d.ts +11 -0
- package/dist/apps/control-plane/mcp/token-codec.js +46 -0
- package/dist/apps/control-plane/mcp/token-codec.js.map +1 -0
- package/dist/apps/control-plane/mcp/tool-authorizer.d.ts +8 -0
- package/dist/apps/control-plane/mcp/tool-authorizer.js +36 -0
- package/dist/apps/control-plane/mcp/tool-authorizer.js.map +1 -0
- package/dist/apps/control-plane/mcp/tool-client.d.ts +30 -0
- package/dist/apps/control-plane/mcp/tool-client.js +50 -0
- package/dist/apps/control-plane/mcp/tool-client.js.map +1 -0
- package/dist/apps/control-plane/mcp/tool-contract-validator.d.ts +29 -0
- package/dist/apps/control-plane/mcp/tool-contract-validator.js +61 -0
- package/dist/apps/control-plane/mcp/tool-contract-validator.js.map +1 -0
- package/dist/apps/control-plane/mcp/tool-registry-loader.d.ts +15 -0
- package/dist/apps/control-plane/mcp/tool-registry-loader.js +109 -0
- package/dist/apps/control-plane/mcp/tool-registry-loader.js.map +1 -0
- package/dist/apps/control-plane/mcp/tool-runtime.d.ts +34 -0
- package/dist/apps/control-plane/mcp/tool-runtime.js +252 -0
- package/dist/apps/control-plane/mcp/tool-runtime.js.map +1 -0
- package/dist/apps/control-plane/mcp/tools-markdown-generator.d.ts +7 -0
- package/dist/apps/control-plane/mcp/tools-markdown-generator.js +22 -0
- package/dist/apps/control-plane/mcp/tools-markdown-generator.js.map +1 -0
- package/dist/apps/control-plane/mcp/transport-types.d.ts +14 -0
- package/dist/apps/control-plane/mcp/transport-types.js +2 -0
- package/dist/apps/control-plane/mcp/transport-types.js.map +1 -0
- package/dist/apps/control-plane/mcp/types.d.ts +2 -0
- package/dist/apps/control-plane/mcp/types.js +3 -0
- package/dist/apps/control-plane/mcp/types.js.map +1 -0
- package/dist/apps/control-plane/providers/providers.d.ts +72 -0
- package/dist/apps/control-plane/providers/providers.js +94 -0
- package/dist/apps/control-plane/providers/providers.js.map +1 -0
- package/dist/apps/control-plane/supervisor/build-wave-executor.d.ts +13 -0
- package/dist/apps/control-plane/supervisor/build-wave-executor.js +40 -0
- package/dist/apps/control-plane/supervisor/build-wave-executor.js.map +1 -0
- package/dist/apps/control-plane/supervisor/lease-heartbeat-service.d.ts +12 -0
- package/dist/apps/control-plane/supervisor/lease-heartbeat-service.js +14 -0
- package/dist/apps/control-plane/supervisor/lease-heartbeat-service.js.map +1 -0
- package/dist/apps/control-plane/supervisor/planning-wave-executor.d.ts +19 -0
- package/dist/apps/control-plane/supervisor/planning-wave-executor.js +249 -0
- package/dist/apps/control-plane/supervisor/planning-wave-executor.js.map +1 -0
- package/dist/apps/control-plane/supervisor/prompt-bundle-loader.d.ts +9 -0
- package/dist/apps/control-plane/supervisor/prompt-bundle-loader.js +53 -0
- package/dist/apps/control-plane/supervisor/prompt-bundle-loader.js.map +1 -0
- package/dist/apps/control-plane/supervisor/qa-wave-executor.d.ts +24 -0
- package/dist/apps/control-plane/supervisor/qa-wave-executor.js +70 -0
- package/dist/apps/control-plane/supervisor/qa-wave-executor.js.map +1 -0
- package/dist/apps/control-plane/supervisor/run-coordinator.d.ts +49 -0
- package/dist/apps/control-plane/supervisor/run-coordinator.js +162 -0
- package/dist/apps/control-plane/supervisor/run-coordinator.js.map +1 -0
- package/dist/apps/control-plane/supervisor/runtime.d.ts +58 -0
- package/dist/apps/control-plane/supervisor/runtime.js +270 -0
- package/dist/apps/control-plane/supervisor/runtime.js.map +1 -0
- package/dist/apps/control-plane/supervisor/session-orchestrator.d.ts +29 -0
- package/dist/apps/control-plane/supervisor/session-orchestrator.js +211 -0
- package/dist/apps/control-plane/supervisor/session-orchestrator.js.map +1 -0
- package/dist/apps/control-plane/supervisor/types.d.ts +148 -0
- package/dist/apps/control-plane/supervisor/types.js +2 -0
- package/dist/apps/control-plane/supervisor/types.js.map +1 -0
- package/dist/apps/control-plane/supervisor/worker-decision-loop.d.ts +37 -0
- package/dist/apps/control-plane/supervisor/worker-decision-loop.js +236 -0
- package/dist/apps/control-plane/supervisor/worker-decision-loop.js.map +1 -0
- package/docker/mcp.Dockerfile +14 -0
- package/docker/mcp.compose.yaml +15 -0
- package/docker/mcp.entrypoint.sh +17 -0
- package/eslint.config.mjs +93 -0
- package/example-configurations/README.md +26 -0
- package/example-configurations/java/agents.yaml +14 -0
- package/example-configurations/java/gates.yaml +29 -0
- package/example-configurations/java/policy.yaml +148 -0
- package/example-configurations/node/agents.yaml +14 -0
- package/example-configurations/node/gates.yaml +32 -0
- package/example-configurations/node/policy.yaml +143 -0
- package/nx.json +16 -0
- package/package.json +39 -0
- package/prompts/vitest-testing-standards.instructions.md +204 -0
- package/scripts/dev-shell-env.sh +7 -0
- package/scripts/nx-safe.mjs +33 -0
- package/spec-files/agentic_orchestrator_cli_delete_command_spec.md +310 -0
- package/spec-files/agentic_orchestrator_dot_aop_generated_artifacts_spec.md +211 -0
- package/spec-files/agentic_orchestrator_mcp_formalization_spec.md +379 -0
- package/spec-files/agentic_orchestrator_oop_refactor_spec.md +415 -0
- package/spec-files/agentic_orchestrator_single_global_orchestrator_spec.md +265 -0
- package/spec-files/agentic_orchestrator_spec.md +1334 -0
- package/spec-files/progress.md +452 -0
- package/tsconfig.base.json +15 -0
- package/tsconfig.json +11 -0
|
@@ -0,0 +1,357 @@
|
|
|
1
|
+
import { beforeEach, describe, expect, it, vi } from 'vitest';
|
|
2
|
+
|
|
3
|
+
const rmMock = vi.hoisted(() => vi.fn(async () => undefined));
|
|
4
|
+
|
|
5
|
+
vi.mock('node:fs/promises', () => ({
|
|
6
|
+
default: {
|
|
7
|
+
rm: rmMock
|
|
8
|
+
}
|
|
9
|
+
}));
|
|
10
|
+
|
|
11
|
+
vi.mock('../src/core/git.js', () => ({
|
|
12
|
+
runGit: vi.fn()
|
|
13
|
+
}));
|
|
14
|
+
|
|
15
|
+
import { MergeService } from '../src/application/services/merge-service.js';
|
|
16
|
+
import { GATE_RESULT, STATUS } from '../src/core/constants.js';
|
|
17
|
+
import { ERROR_CODES } from '../src/core/error-codes.js';
|
|
18
|
+
import { runGit } from '../src/core/git.js';
|
|
19
|
+
|
|
20
|
+
type AnyRecord = Record<string, any>;
|
|
21
|
+
|
|
22
|
+
function commandResult(overrides: Partial<Awaited<ReturnType<typeof runGit>>> = {}) {
|
|
23
|
+
return {
|
|
24
|
+
code: 0,
|
|
25
|
+
signal: null,
|
|
26
|
+
stdout: '',
|
|
27
|
+
stderr: '',
|
|
28
|
+
timeout: false,
|
|
29
|
+
...overrides
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
function clone<T>(value: T): T {
|
|
34
|
+
return JSON.parse(JSON.stringify(value)) as T;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
function makeHarness(options: {
|
|
38
|
+
stateOverrides?: AnyRecord;
|
|
39
|
+
policyOverrides?: AnyRecord;
|
|
40
|
+
} = {}) {
|
|
41
|
+
const state = {
|
|
42
|
+
frontMatter: {
|
|
43
|
+
feature_id: 'feature_merge',
|
|
44
|
+
version: 3,
|
|
45
|
+
status: STATUS.READY_TO_MERGE,
|
|
46
|
+
gates: {
|
|
47
|
+
fast: GATE_RESULT.PASS,
|
|
48
|
+
full: GATE_RESULT.PASS
|
|
49
|
+
},
|
|
50
|
+
locks: {
|
|
51
|
+
held: ['openapi', 'db_migrations']
|
|
52
|
+
},
|
|
53
|
+
evidence: {},
|
|
54
|
+
...(options.stateOverrides ?? {})
|
|
55
|
+
},
|
|
56
|
+
body: '# State\n'
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
const policy = {
|
|
60
|
+
merge_policy: {
|
|
61
|
+
allowed_strategies: ['merge_commit', 'squash', 'rebase'],
|
|
62
|
+
require_user_approval: false
|
|
63
|
+
},
|
|
64
|
+
required_modes: ['fast'],
|
|
65
|
+
required_merge_mode: 'full',
|
|
66
|
+
worktree: {
|
|
67
|
+
base_branch: 'main'
|
|
68
|
+
},
|
|
69
|
+
...(options.policyOverrides ?? {})
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
let index: AnyRecord = {
|
|
73
|
+
version: 5,
|
|
74
|
+
active: ['feature_merge'],
|
|
75
|
+
blocked: ['feature_merge'],
|
|
76
|
+
merged: [],
|
|
77
|
+
blocked_queue: [{ feature_id: 'feature_merge' }, { feature_id: 'other' }],
|
|
78
|
+
runtime_sessions: {
|
|
79
|
+
feature_sessions: {
|
|
80
|
+
feature_merge: {
|
|
81
|
+
planner_session_id: 'planner-a',
|
|
82
|
+
builder_session_id: 'builder-a',
|
|
83
|
+
qa_session_id: 'qa-a'
|
|
84
|
+
},
|
|
85
|
+
other: {
|
|
86
|
+
planner_session_id: 'planner-b',
|
|
87
|
+
builder_session_id: 'builder-b',
|
|
88
|
+
qa_session_id: 'qa-b'
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
};
|
|
93
|
+
|
|
94
|
+
const locksRelease = vi.fn(async () => ({ data: { released: true } }));
|
|
95
|
+
|
|
96
|
+
const service = new MergeService({
|
|
97
|
+
getRepoRoot: () => '/repo',
|
|
98
|
+
getPolicySnapshot: () => clone(policy),
|
|
99
|
+
featurePath: (featureId: string) => `/repo/.aop/features/${featureId}`,
|
|
100
|
+
readState: async () => clone(state),
|
|
101
|
+
worktreePath: (featureId: string) => `/repo/.worktrees/${featureId}`,
|
|
102
|
+
updateState: async (_featureId: string, expectedVersion: number | null, updater: any) => {
|
|
103
|
+
if (expectedVersion != null && expectedVersion !== state.frontMatter.version) {
|
|
104
|
+
throw new Error('unexpected_version_conflict');
|
|
105
|
+
}
|
|
106
|
+
const next = await updater(clone(state.frontMatter), state.body);
|
|
107
|
+
state.frontMatter = {
|
|
108
|
+
...state.frontMatter,
|
|
109
|
+
...(next.frontMatter ?? {}),
|
|
110
|
+
version: state.frontMatter.version + 1
|
|
111
|
+
};
|
|
112
|
+
state.body = next.body ?? state.body;
|
|
113
|
+
return clone(state.frontMatter);
|
|
114
|
+
},
|
|
115
|
+
locksRelease,
|
|
116
|
+
withIndexLock: async <T>(operation: () => Promise<T>) => await operation(),
|
|
117
|
+
readIndex: async () => clone(index),
|
|
118
|
+
writeIndex: async (nextIndex: AnyRecord) => {
|
|
119
|
+
index = clone(nextIndex);
|
|
120
|
+
}
|
|
121
|
+
});
|
|
122
|
+
|
|
123
|
+
return {
|
|
124
|
+
service,
|
|
125
|
+
state,
|
|
126
|
+
locksRelease,
|
|
127
|
+
getIndex: () => clone(index)
|
|
128
|
+
};
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
describe('MergeService', () => {
|
|
132
|
+
beforeEach(() => {
|
|
133
|
+
vi.clearAllMocks();
|
|
134
|
+
rmMock.mockClear();
|
|
135
|
+
});
|
|
136
|
+
|
|
137
|
+
it('GIVEN_strategy_not_allowed_WHEN_feature_ready_to_merge_THEN_returns_merge_disabled_error', async () => {
|
|
138
|
+
const harness = makeHarness({
|
|
139
|
+
policyOverrides: {
|
|
140
|
+
merge_policy: {
|
|
141
|
+
allowed_strategies: ['merge_commit'],
|
|
142
|
+
require_user_approval: false
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
});
|
|
146
|
+
|
|
147
|
+
await expect(
|
|
148
|
+
harness.service.featureReadyToMerge('feature_merge', 'merge', 'squash', null)
|
|
149
|
+
).rejects.toMatchObject({
|
|
150
|
+
normalizedResponse: {
|
|
151
|
+
error: {
|
|
152
|
+
code: ERROR_CODES.MERGE_DISABLED
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
});
|
|
156
|
+
expect(runGit).not.toHaveBeenCalled();
|
|
157
|
+
});
|
|
158
|
+
|
|
159
|
+
it('GIVEN_user_approval_required_without_token_WHEN_feature_ready_to_merge_THEN_returns_user_approval_required_error', async () => {
|
|
160
|
+
const harness = makeHarness({
|
|
161
|
+
policyOverrides: {
|
|
162
|
+
merge_policy: {
|
|
163
|
+
allowed_strategies: ['merge_commit', 'squash', 'rebase'],
|
|
164
|
+
require_user_approval: true
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
});
|
|
168
|
+
|
|
169
|
+
await expect(
|
|
170
|
+
harness.service.featureReadyToMerge('feature_merge', 'merge', 'merge_commit', null)
|
|
171
|
+
).rejects.toMatchObject({
|
|
172
|
+
normalizedResponse: {
|
|
173
|
+
error: {
|
|
174
|
+
code: ERROR_CODES.USER_APPROVAL_REQUIRED
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
});
|
|
178
|
+
expect(runGit).not.toHaveBeenCalled();
|
|
179
|
+
});
|
|
180
|
+
|
|
181
|
+
it('GIVEN_feature_not_ready_or_required_gates_missing_WHEN_feature_ready_to_merge_THEN_returns_precondition_errors', async () => {
|
|
182
|
+
const invalidStatus = makeHarness({
|
|
183
|
+
stateOverrides: {
|
|
184
|
+
status: STATUS.BUILDING
|
|
185
|
+
}
|
|
186
|
+
});
|
|
187
|
+
await expect(
|
|
188
|
+
invalidStatus.service.featureReadyToMerge('feature_merge', 'merge', 'merge_commit', 'approved')
|
|
189
|
+
).rejects.toMatchObject({
|
|
190
|
+
normalizedResponse: {
|
|
191
|
+
error: {
|
|
192
|
+
code: ERROR_CODES.INVALID_STATUS_TRANSITION
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
});
|
|
196
|
+
|
|
197
|
+
const missingGate = makeHarness({
|
|
198
|
+
stateOverrides: {
|
|
199
|
+
gates: {
|
|
200
|
+
fast: GATE_RESULT.PASS,
|
|
201
|
+
full: GATE_RESULT.FAIL
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
});
|
|
205
|
+
await expect(
|
|
206
|
+
missingGate.service.featureReadyToMerge('feature_merge', 'merge', 'merge_commit', 'approved')
|
|
207
|
+
).rejects.toMatchObject({
|
|
208
|
+
normalizedResponse: {
|
|
209
|
+
error: {
|
|
210
|
+
code: ERROR_CODES.MERGE_DISABLED,
|
|
211
|
+
details: {
|
|
212
|
+
mode: 'full'
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
});
|
|
217
|
+
});
|
|
218
|
+
|
|
219
|
+
it('GIVEN_git_add_or_commit_failures_WHEN_feature_ready_to_merge_THEN_returns_git_failure_error', async () => {
|
|
220
|
+
const addFailure = makeHarness();
|
|
221
|
+
vi.mocked(runGit).mockResolvedValueOnce(commandResult({ code: 1, stderr: 'add failed' }));
|
|
222
|
+
|
|
223
|
+
await expect(
|
|
224
|
+
addFailure.service.featureReadyToMerge('feature_merge', 'merge', 'merge_commit', 'approved')
|
|
225
|
+
).rejects.toMatchObject({
|
|
226
|
+
normalizedResponse: {
|
|
227
|
+
error: {
|
|
228
|
+
code: ERROR_CODES.GIT_FAILURE
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
});
|
|
232
|
+
|
|
233
|
+
const commitFailure = makeHarness();
|
|
234
|
+
vi.mocked(runGit)
|
|
235
|
+
.mockResolvedValueOnce(commandResult())
|
|
236
|
+
.mockResolvedValueOnce(commandResult({ code: 1, stderr: 'commit failed' }));
|
|
237
|
+
|
|
238
|
+
await expect(
|
|
239
|
+
commitFailure.service.featureReadyToMerge('feature_merge', 'merge', 'merge_commit', 'approved')
|
|
240
|
+
).rejects.toMatchObject({
|
|
241
|
+
normalizedResponse: {
|
|
242
|
+
error: {
|
|
243
|
+
code: ERROR_CODES.GIT_FAILURE
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
});
|
|
247
|
+
});
|
|
248
|
+
|
|
249
|
+
it('GIVEN_checkout_or_rebase_failures_WHEN_feature_ready_to_merge_THEN_returns_human_required_git_failure', async () => {
|
|
250
|
+
const checkoutFailure = makeHarness();
|
|
251
|
+
vi.mocked(runGit)
|
|
252
|
+
.mockResolvedValueOnce(commandResult())
|
|
253
|
+
.mockResolvedValueOnce(commandResult({ code: 1, stderr: 'nothing to commit' }))
|
|
254
|
+
.mockResolvedValueOnce(commandResult({ code: 1, stderr: 'checkout failed' }));
|
|
255
|
+
|
|
256
|
+
await expect(
|
|
257
|
+
checkoutFailure.service.featureReadyToMerge('feature_merge', 'merge', 'merge_commit', 'approved')
|
|
258
|
+
).rejects.toMatchObject({
|
|
259
|
+
normalizedResponse: {
|
|
260
|
+
error: {
|
|
261
|
+
code: ERROR_CODES.GIT_FAILURE,
|
|
262
|
+
details: {
|
|
263
|
+
requires_human: true
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
});
|
|
268
|
+
|
|
269
|
+
const rebaseFailure = makeHarness();
|
|
270
|
+
vi.mocked(runGit)
|
|
271
|
+
.mockResolvedValueOnce(commandResult())
|
|
272
|
+
.mockResolvedValueOnce(commandResult())
|
|
273
|
+
.mockResolvedValueOnce(commandResult())
|
|
274
|
+
.mockResolvedValueOnce(commandResult({ code: 1, stderr: 'rebase failed' }));
|
|
275
|
+
|
|
276
|
+
await expect(
|
|
277
|
+
rebaseFailure.service.featureReadyToMerge('feature_merge', 'merge', 'rebase', 'approved')
|
|
278
|
+
).rejects.toMatchObject({
|
|
279
|
+
normalizedResponse: {
|
|
280
|
+
error: {
|
|
281
|
+
code: ERROR_CODES.GIT_FAILURE,
|
|
282
|
+
details: {
|
|
283
|
+
requires_human: true
|
|
284
|
+
}
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
});
|
|
288
|
+
});
|
|
289
|
+
|
|
290
|
+
it('GIVEN_squash_merge_commit_fails_WHEN_feature_ready_to_merge_THEN_returns_merge_failed_error', async () => {
|
|
291
|
+
const harness = makeHarness();
|
|
292
|
+
vi.mocked(runGit)
|
|
293
|
+
.mockResolvedValueOnce(commandResult())
|
|
294
|
+
.mockResolvedValueOnce(commandResult({ code: 1, stderr: 'nothing to commit' }))
|
|
295
|
+
.mockResolvedValueOnce(commandResult())
|
|
296
|
+
.mockResolvedValueOnce(commandResult())
|
|
297
|
+
.mockResolvedValueOnce(commandResult({ code: 1, stderr: 'squash commit failed' }));
|
|
298
|
+
|
|
299
|
+
await expect(
|
|
300
|
+
harness.service.featureReadyToMerge('feature_merge', 'merge', 'squash', 'approved')
|
|
301
|
+
).rejects.toMatchObject({
|
|
302
|
+
normalizedResponse: {
|
|
303
|
+
error: {
|
|
304
|
+
code: ERROR_CODES.GIT_FAILURE,
|
|
305
|
+
details: {
|
|
306
|
+
requires_human: true
|
|
307
|
+
}
|
|
308
|
+
}
|
|
309
|
+
}
|
|
310
|
+
});
|
|
311
|
+
});
|
|
312
|
+
|
|
313
|
+
it('GIVEN_rebase_strategy_succeeds_WHEN_feature_ready_to_merge_THEN_updates_state_releases_locks_and_updates_index', async () => {
|
|
314
|
+
const harness = makeHarness({
|
|
315
|
+
stateOverrides: {
|
|
316
|
+
locks: {
|
|
317
|
+
held: ['openapi', 42]
|
|
318
|
+
}
|
|
319
|
+
}
|
|
320
|
+
});
|
|
321
|
+
|
|
322
|
+
vi.mocked(runGit)
|
|
323
|
+
.mockResolvedValueOnce(commandResult())
|
|
324
|
+
.mockResolvedValueOnce(commandResult())
|
|
325
|
+
.mockResolvedValueOnce(commandResult())
|
|
326
|
+
.mockResolvedValueOnce(commandResult())
|
|
327
|
+
.mockResolvedValueOnce(commandResult())
|
|
328
|
+
.mockResolvedValueOnce(commandResult({ stdout: 'abc123\n' }));
|
|
329
|
+
|
|
330
|
+
const result = await harness.service.featureReadyToMerge('feature_merge', 'merge', 'rebase', 'approved');
|
|
331
|
+
|
|
332
|
+
expect(result.data).toMatchObject({
|
|
333
|
+
feature_id: 'feature_merge',
|
|
334
|
+
merge_sha: 'abc123',
|
|
335
|
+
merge_strategy: 'rebase',
|
|
336
|
+
status: STATUS.MERGED
|
|
337
|
+
});
|
|
338
|
+
expect(harness.state.frontMatter.status).toBe(STATUS.MERGED);
|
|
339
|
+
expect((harness.state.frontMatter.evidence as AnyRecord).merge_strategy).toBe('rebase');
|
|
340
|
+
expect(harness.locksRelease).toHaveBeenCalledTimes(1);
|
|
341
|
+
expect(harness.locksRelease).toHaveBeenCalledWith('openapi', 'feature_merge');
|
|
342
|
+
|
|
343
|
+
const index = harness.getIndex();
|
|
344
|
+
expect(index.active).toEqual([]);
|
|
345
|
+
expect(index.blocked).toEqual([]);
|
|
346
|
+
expect(index.merged).toEqual(['feature_merge']);
|
|
347
|
+
expect(index.blocked_queue).toEqual([{ feature_id: 'other' }]);
|
|
348
|
+
expect(index.runtime_sessions.feature_sessions).not.toHaveProperty('feature_merge');
|
|
349
|
+
expect(index.runtime_sessions.feature_sessions.other).toMatchObject({
|
|
350
|
+
planner_session_id: 'planner-b'
|
|
351
|
+
});
|
|
352
|
+
expect(rmMock).toHaveBeenCalledWith('/repo/.aop/features/feature_merge', {
|
|
353
|
+
recursive: true,
|
|
354
|
+
force: true
|
|
355
|
+
});
|
|
356
|
+
});
|
|
357
|
+
});
|
|
@@ -0,0 +1,195 @@
|
|
|
1
|
+
import fs from 'node:fs/promises';
|
|
2
|
+
import os from 'node:os';
|
|
3
|
+
import path from 'node:path';
|
|
4
|
+
import { afterEach, describe, expect, it, vi } from 'vitest';
|
|
5
|
+
import { ERROR_CODES } from '../src/core/error-codes.js';
|
|
6
|
+
import type * as FsModule from '../src/core/fs.js';
|
|
7
|
+
|
|
8
|
+
vi.mock('../src/core/fs.js', async () => {
|
|
9
|
+
const actual = await vi.importActual<typeof FsModule>('../src/core/fs.js');
|
|
10
|
+
return {
|
|
11
|
+
...actual,
|
|
12
|
+
nowIso: () => '2026-01-01T00:00:00.000Z'
|
|
13
|
+
};
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
import { PlanService } from '../src/application/services/plan-service.js';
|
|
17
|
+
|
|
18
|
+
type AnyRecord = Record<string, any>;
|
|
19
|
+
|
|
20
|
+
function makePlan(featureId: string, overrides: AnyRecord = {}): AnyRecord {
|
|
21
|
+
return {
|
|
22
|
+
feature_id: featureId,
|
|
23
|
+
plan_version: 1,
|
|
24
|
+
summary: `${featureId} summary`,
|
|
25
|
+
allowed_areas: ['apps/control-plane/src'],
|
|
26
|
+
forbidden_areas: [],
|
|
27
|
+
base_ref: 'main',
|
|
28
|
+
files: {
|
|
29
|
+
create: [],
|
|
30
|
+
modify: ['apps/control-plane/src/shared.ts'],
|
|
31
|
+
delete: []
|
|
32
|
+
},
|
|
33
|
+
contracts: {
|
|
34
|
+
openapi: 'none',
|
|
35
|
+
events: 'none',
|
|
36
|
+
db: 'none'
|
|
37
|
+
},
|
|
38
|
+
acceptance_criteria: ['works'],
|
|
39
|
+
gate_profile: 'default',
|
|
40
|
+
revision_of: null,
|
|
41
|
+
...overrides
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
async function writePlan(repoRoot: string, featureId: string, plan: AnyRecord): Promise<void> {
|
|
46
|
+
const featureDir = path.join(repoRoot, featureId);
|
|
47
|
+
await fs.mkdir(featureDir, { recursive: true });
|
|
48
|
+
await fs.writeFile(path.join(featureDir, 'plan.json'), JSON.stringify(plan, null, 2), 'utf8');
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
async function createHarness(options: {
|
|
52
|
+
collisionPolicy?: 'block' | 'reject';
|
|
53
|
+
specs?: string[];
|
|
54
|
+
stateLocks?: string[];
|
|
55
|
+
}) {
|
|
56
|
+
const repoRoot = await fs.mkdtemp(path.join(os.tmpdir(), 'aop-plan-service-'));
|
|
57
|
+
const specs = options.specs ?? ['feature_a', 'feature_ref'];
|
|
58
|
+
const stateLocks = options.stateLocks ?? ['openapi', 'events', 'db_migrations'];
|
|
59
|
+
const writes: AnyRecord[] = [];
|
|
60
|
+
const stateUpdates: AnyRecord[] = [];
|
|
61
|
+
let index: AnyRecord = {
|
|
62
|
+
version: 1,
|
|
63
|
+
active: [],
|
|
64
|
+
blocked: [],
|
|
65
|
+
merged: [],
|
|
66
|
+
locks: {},
|
|
67
|
+
lock_leases: {},
|
|
68
|
+
blocked_queue: [],
|
|
69
|
+
runtime_sessions: {}
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
const service = new PlanService({
|
|
73
|
+
getPolicySnapshot: () => ({
|
|
74
|
+
collision_policy: options.collisionPolicy ?? 'block',
|
|
75
|
+
locks: {
|
|
76
|
+
contract_to_resource: {
|
|
77
|
+
openapi: 'openapi',
|
|
78
|
+
events: 'events',
|
|
79
|
+
db: 'db_migrations'
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
}),
|
|
83
|
+
planPath: (featureId: string) => path.join(repoRoot, featureId, 'plan.json'),
|
|
84
|
+
featureDiscoverSpecs: async () => ({ data: { specs: specs.map((feature_id) => ({ feature_id })) } }),
|
|
85
|
+
readState: async () => ({
|
|
86
|
+
frontMatter: {
|
|
87
|
+
status: 'planning',
|
|
88
|
+
locks: {
|
|
89
|
+
held: stateLocks
|
|
90
|
+
},
|
|
91
|
+
gates: {}
|
|
92
|
+
}
|
|
93
|
+
}),
|
|
94
|
+
validateSchema: async () => ({ valid: true }),
|
|
95
|
+
withFeatureLock: async <T>(_featureId: string, operation: () => Promise<T>) => await operation(),
|
|
96
|
+
withIndexLock: async <T>(operation: () => Promise<T>) => await operation(),
|
|
97
|
+
readIndex: async () => JSON.parse(JSON.stringify(index)),
|
|
98
|
+
writeIndex: async (nextIndex: AnyRecord) => {
|
|
99
|
+
index = JSON.parse(JSON.stringify(nextIndex));
|
|
100
|
+
writes.push(JSON.parse(JSON.stringify(nextIndex)));
|
|
101
|
+
},
|
|
102
|
+
updateState: async (_featureId: string, _expectedVersion: number | null, updater: any) => {
|
|
103
|
+
const existing = { status: 'planning', gates: {} };
|
|
104
|
+
const updated = await updater(existing, '');
|
|
105
|
+
stateUpdates.push(updated);
|
|
106
|
+
return updated.frontMatter ?? existing;
|
|
107
|
+
}
|
|
108
|
+
});
|
|
109
|
+
|
|
110
|
+
return {
|
|
111
|
+
repoRoot,
|
|
112
|
+
service,
|
|
113
|
+
writes,
|
|
114
|
+
stateUpdates,
|
|
115
|
+
getIndex: () => JSON.parse(JSON.stringify(index)),
|
|
116
|
+
cleanup: async () => await fs.rm(repoRoot, { recursive: true, force: true })
|
|
117
|
+
};
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
describe('PlanService', () => {
|
|
121
|
+
const cleanups: Array<() => Promise<void>> = [];
|
|
122
|
+
|
|
123
|
+
afterEach(async () => {
|
|
124
|
+
await Promise.all(cleanups.map((cleanup) => cleanup()));
|
|
125
|
+
cleanups.length = 0;
|
|
126
|
+
});
|
|
127
|
+
|
|
128
|
+
it('GIVEN_blocking_collisions_WHEN_queueing_multiple_features_THEN_sorts_queue_deterministically_and_captures_required_resources', async () => {
|
|
129
|
+
const harness = await createHarness({ specs: ['feature_a', 'feature_z', 'feature_ref'] });
|
|
130
|
+
cleanups.push(harness.cleanup);
|
|
131
|
+
|
|
132
|
+
await writePlan(harness.repoRoot, 'feature_ref', makePlan('feature_ref'));
|
|
133
|
+
|
|
134
|
+
const featureZPlan = makePlan('feature_z', {
|
|
135
|
+
contracts: { openapi: 'modify', events: 'modify', db: 'migration' }
|
|
136
|
+
});
|
|
137
|
+
const featureAPlan = makePlan('feature_a', {
|
|
138
|
+
contracts: { openapi: 'modify', events: 'none', db: 'migration' }
|
|
139
|
+
});
|
|
140
|
+
|
|
141
|
+
await expect(harness.service.planSubmit('feature_z', featureZPlan, null)).rejects.toMatchObject({
|
|
142
|
+
normalizedResponse: {
|
|
143
|
+
ok: false,
|
|
144
|
+
error: {
|
|
145
|
+
code: ERROR_CODES.BLOCKED_BY_COLLISION_POLICY
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
});
|
|
149
|
+
await expect(harness.service.planSubmit('feature_a', featureAPlan, null)).rejects.toMatchObject({
|
|
150
|
+
normalizedResponse: {
|
|
151
|
+
ok: false,
|
|
152
|
+
error: {
|
|
153
|
+
code: ERROR_CODES.BLOCKED_BY_COLLISION_POLICY
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
});
|
|
157
|
+
|
|
158
|
+
const queue = harness.getIndex().blocked_queue;
|
|
159
|
+
expect(queue.map((entry: AnyRecord) => entry.feature_id)).toEqual(['feature_a', 'feature_z']);
|
|
160
|
+
expect(queue[0]?.required_resources).toEqual(['db_migrations', 'openapi']);
|
|
161
|
+
expect(queue[1]?.required_resources).toEqual(['db_migrations', 'events', 'openapi']);
|
|
162
|
+
expect(harness.writes).toHaveLength(2);
|
|
163
|
+
});
|
|
164
|
+
|
|
165
|
+
it('GIVEN_blocked_collision_then_conflict_resolved_WHEN_resubmitting_same_plan_THEN_accepts_retry', async () => {
|
|
166
|
+
const harness = await createHarness({ specs: ['feature_a', 'feature_ref'] });
|
|
167
|
+
cleanups.push(harness.cleanup);
|
|
168
|
+
|
|
169
|
+
const referencePlan = makePlan('feature_ref');
|
|
170
|
+
const candidatePlan = makePlan('feature_a');
|
|
171
|
+
await writePlan(harness.repoRoot, 'feature_ref', referencePlan);
|
|
172
|
+
|
|
173
|
+
await expect(harness.service.planSubmit('feature_a', candidatePlan, null)).rejects.toMatchObject({
|
|
174
|
+
normalizedResponse: {
|
|
175
|
+
ok: false,
|
|
176
|
+
error: { code: ERROR_CODES.BLOCKED_BY_COLLISION_POLICY }
|
|
177
|
+
}
|
|
178
|
+
});
|
|
179
|
+
|
|
180
|
+
await fs.rm(path.join(harness.repoRoot, 'feature_ref', 'plan.json'));
|
|
181
|
+
|
|
182
|
+
const accepted = await harness.service.planSubmit('feature_a', candidatePlan, null);
|
|
183
|
+
expect(accepted).toMatchObject({
|
|
184
|
+
data: {
|
|
185
|
+
feature_id: 'feature_a',
|
|
186
|
+
accepted: true,
|
|
187
|
+
plan_version: 1
|
|
188
|
+
}
|
|
189
|
+
});
|
|
190
|
+
|
|
191
|
+
const savedPlan = JSON.parse(await fs.readFile(path.join(harness.repoRoot, 'feature_a', 'plan.json'), 'utf8'));
|
|
192
|
+
expect(savedPlan.feature_id).toBe('feature_a');
|
|
193
|
+
expect(harness.stateUpdates.length).toBe(1);
|
|
194
|
+
});
|
|
195
|
+
});
|