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,587 @@
|
|
|
1
|
+
import { describe, expect, it, vi } from 'vitest';
|
|
2
|
+
import { TOOLS } from '../src/core/constants.js';
|
|
3
|
+
import { NOOP_WORKER_DECISION_RUNNER, WorkerDecisionLoop } from '../src/supervisor/worker-decision-loop.js';
|
|
4
|
+
|
|
5
|
+
describe('WorkerDecisionLoop', () => {
|
|
6
|
+
function makeProvider(runWorkerResult: Record<string, unknown>) {
|
|
7
|
+
return {
|
|
8
|
+
selection: {
|
|
9
|
+
provider: 'custom',
|
|
10
|
+
model: 'model-test',
|
|
11
|
+
provider_config_ref: null
|
|
12
|
+
},
|
|
13
|
+
runWorker: vi.fn(async () => runWorkerResult)
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
function makeToolCaller() {
|
|
18
|
+
return {
|
|
19
|
+
callTool: vi.fn(async (_role: string, toolName: string) => {
|
|
20
|
+
if (toolName === TOOLS.FEATURE_GET_CONTEXT) {
|
|
21
|
+
return { ok: true, data: { refreshed: true } };
|
|
22
|
+
}
|
|
23
|
+
return { ok: true, data: { accepted: true } };
|
|
24
|
+
})
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
it('GIVEN_noop_runner_WHEN_executed_THEN_returns_empty_decision_result', async () => {
|
|
29
|
+
const result = await NOOP_WORKER_DECISION_RUNNER.execute({
|
|
30
|
+
role: 'planner',
|
|
31
|
+
featureId: 'feature_a',
|
|
32
|
+
contextBundle: {},
|
|
33
|
+
instructions: 'noop'
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
expect(result).toEqual({
|
|
37
|
+
planSubmission: false,
|
|
38
|
+
patchApplied: false,
|
|
39
|
+
noteLogged: false,
|
|
40
|
+
requestHandled: false,
|
|
41
|
+
priorityOrder: [],
|
|
42
|
+
toolResults: []
|
|
43
|
+
});
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
it('GIVEN_provider_without_runWorker_WHEN_executed_THEN_returns_empty_result_without_tool_calls', async () => {
|
|
47
|
+
const provider = {
|
|
48
|
+
selection: {
|
|
49
|
+
provider: 'custom',
|
|
50
|
+
model: 'model-test',
|
|
51
|
+
provider_config_ref: null
|
|
52
|
+
}
|
|
53
|
+
};
|
|
54
|
+
const toolCaller = makeToolCaller();
|
|
55
|
+
const loop = new WorkerDecisionLoop({
|
|
56
|
+
provider: provider as never,
|
|
57
|
+
toolCaller: toolCaller as never
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
const result = await loop.execute({
|
|
61
|
+
role: 'builder',
|
|
62
|
+
featureId: 'feature_a',
|
|
63
|
+
contextBundle: {},
|
|
64
|
+
instructions: 'build'
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
expect(result.patchApplied).toBe(false);
|
|
68
|
+
expect(result.requestHandled).toBe(false);
|
|
69
|
+
expect(toolCaller.callTool).not.toHaveBeenCalled();
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
it('GIVEN_planner_submission_without_existing_plan_WHEN_executed_THEN_routes_to_plan_submit', async () => {
|
|
73
|
+
const provider = makeProvider({
|
|
74
|
+
type: 'PLAN_SUBMISSION',
|
|
75
|
+
plan_json: {
|
|
76
|
+
feature_id: 'feature_a',
|
|
77
|
+
plan_version: 1,
|
|
78
|
+
summary: 'Initial plan'
|
|
79
|
+
}
|
|
80
|
+
});
|
|
81
|
+
const toolCaller = makeToolCaller();
|
|
82
|
+
const loop = new WorkerDecisionLoop({
|
|
83
|
+
provider: provider as never,
|
|
84
|
+
toolCaller: toolCaller as never
|
|
85
|
+
});
|
|
86
|
+
|
|
87
|
+
const result = await loop.execute({
|
|
88
|
+
role: 'planner',
|
|
89
|
+
featureId: 'feature_a',
|
|
90
|
+
contextBundle: { plan: null },
|
|
91
|
+
instructions: 'plan'
|
|
92
|
+
});
|
|
93
|
+
|
|
94
|
+
expect(result.planSubmission).toBe(true);
|
|
95
|
+
expect(provider.runWorker).toHaveBeenCalledWith(
|
|
96
|
+
expect.objectContaining({
|
|
97
|
+
last_tool_results: [],
|
|
98
|
+
runtime_selection: {
|
|
99
|
+
provider: 'custom',
|
|
100
|
+
model: 'model-test',
|
|
101
|
+
provider_config_ref: null
|
|
102
|
+
}
|
|
103
|
+
})
|
|
104
|
+
);
|
|
105
|
+
expect(toolCaller.callTool).toHaveBeenCalledWith(
|
|
106
|
+
'planner',
|
|
107
|
+
TOOLS.PLAN_SUBMIT,
|
|
108
|
+
expect.objectContaining({
|
|
109
|
+
feature_id: 'feature_a'
|
|
110
|
+
})
|
|
111
|
+
);
|
|
112
|
+
});
|
|
113
|
+
|
|
114
|
+
it('GIVEN_planner_submission_with_existing_plan_WHEN_executed_THEN_routes_to_plan_update', async () => {
|
|
115
|
+
const provider = makeProvider({
|
|
116
|
+
type: 'PLAN_SUBMISSION',
|
|
117
|
+
plan_json: {
|
|
118
|
+
feature_id: 'feature_a',
|
|
119
|
+
plan_version: 3,
|
|
120
|
+
summary: 'Revised plan'
|
|
121
|
+
},
|
|
122
|
+
expected_plan_version: 2
|
|
123
|
+
});
|
|
124
|
+
const toolCaller = makeToolCaller();
|
|
125
|
+
const loop = new WorkerDecisionLoop({
|
|
126
|
+
provider: provider as never,
|
|
127
|
+
toolCaller: toolCaller as never
|
|
128
|
+
});
|
|
129
|
+
|
|
130
|
+
const result = await loop.execute({
|
|
131
|
+
role: 'planner',
|
|
132
|
+
featureId: 'feature_a',
|
|
133
|
+
contextBundle: { plan: { plan_version: 2 } },
|
|
134
|
+
instructions: 'plan',
|
|
135
|
+
lastToolResults: [{ tool: 'x' }]
|
|
136
|
+
});
|
|
137
|
+
|
|
138
|
+
expect(result.planSubmission).toBe(true);
|
|
139
|
+
expect(toolCaller.callTool).toHaveBeenCalledWith(
|
|
140
|
+
'planner',
|
|
141
|
+
TOOLS.PLAN_UPDATE,
|
|
142
|
+
expect.objectContaining({
|
|
143
|
+
feature_id: 'feature_a',
|
|
144
|
+
expected_plan_version: 2
|
|
145
|
+
})
|
|
146
|
+
);
|
|
147
|
+
});
|
|
148
|
+
|
|
149
|
+
it('GIVEN_non_planner_or_empty_plan_submission_WHEN_executed_THEN_ignores_submission', async () => {
|
|
150
|
+
const provider = makeProvider({
|
|
151
|
+
outputs: [
|
|
152
|
+
{
|
|
153
|
+
type: 'PLAN_SUBMISSION',
|
|
154
|
+
plan_json: {}
|
|
155
|
+
},
|
|
156
|
+
{
|
|
157
|
+
type: 'PLAN_SUBMISSION',
|
|
158
|
+
plan_json: {
|
|
159
|
+
feature_id: 'feature_a',
|
|
160
|
+
plan_version: 1
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
]
|
|
164
|
+
});
|
|
165
|
+
const toolCaller = makeToolCaller();
|
|
166
|
+
const loop = new WorkerDecisionLoop({
|
|
167
|
+
provider: provider as never,
|
|
168
|
+
toolCaller: toolCaller as never
|
|
169
|
+
});
|
|
170
|
+
|
|
171
|
+
const result = await loop.execute({
|
|
172
|
+
role: 'builder',
|
|
173
|
+
featureId: 'feature_a',
|
|
174
|
+
contextBundle: {},
|
|
175
|
+
instructions: 'build'
|
|
176
|
+
});
|
|
177
|
+
|
|
178
|
+
expect(result.planSubmission).toBe(false);
|
|
179
|
+
expect(toolCaller.callTool).not.toHaveBeenCalledWith('planner', TOOLS.PLAN_SUBMIT, expect.any(Object));
|
|
180
|
+
});
|
|
181
|
+
|
|
182
|
+
it('GIVEN_builder_patch_output_WHEN_executed_THEN_routes_to_repo_apply_patch', async () => {
|
|
183
|
+
const provider = makeProvider({
|
|
184
|
+
outputs: [
|
|
185
|
+
{
|
|
186
|
+
type: 'PATCH',
|
|
187
|
+
diff: 'diff --git a/src/a.ts b/src/a.ts\n--- a/src/a.ts\n+++ b/src/a.ts\n@@ -1 +1 @@\n-a\n+b\n'
|
|
188
|
+
}
|
|
189
|
+
]
|
|
190
|
+
});
|
|
191
|
+
const toolCaller = makeToolCaller();
|
|
192
|
+
const loop = new WorkerDecisionLoop({
|
|
193
|
+
provider: provider as never,
|
|
194
|
+
toolCaller: toolCaller as never
|
|
195
|
+
});
|
|
196
|
+
|
|
197
|
+
const result = await loop.execute({
|
|
198
|
+
role: 'qa',
|
|
199
|
+
featureId: 'feature_a',
|
|
200
|
+
contextBundle: {},
|
|
201
|
+
instructions: 'qa'
|
|
202
|
+
});
|
|
203
|
+
|
|
204
|
+
expect(result.patchApplied).toBe(true);
|
|
205
|
+
expect(toolCaller.callTool).toHaveBeenCalledWith(
|
|
206
|
+
'qa',
|
|
207
|
+
TOOLS.REPO_APPLY_PATCH,
|
|
208
|
+
expect.objectContaining({
|
|
209
|
+
feature_id: 'feature_a'
|
|
210
|
+
})
|
|
211
|
+
);
|
|
212
|
+
});
|
|
213
|
+
|
|
214
|
+
it('GIVEN_patch_without_diff_or_unsupported_role_WHEN_executed_THEN_skips_patch_routing', async () => {
|
|
215
|
+
const provider = makeProvider({
|
|
216
|
+
outputs: [
|
|
217
|
+
{
|
|
218
|
+
type: 'PATCH',
|
|
219
|
+
unified_diff: ' '
|
|
220
|
+
}
|
|
221
|
+
]
|
|
222
|
+
});
|
|
223
|
+
const toolCaller = makeToolCaller();
|
|
224
|
+
const loop = new WorkerDecisionLoop({
|
|
225
|
+
provider: provider as never,
|
|
226
|
+
toolCaller: toolCaller as never
|
|
227
|
+
});
|
|
228
|
+
|
|
229
|
+
const result = await loop.execute({
|
|
230
|
+
role: 'planner',
|
|
231
|
+
featureId: 'feature_a',
|
|
232
|
+
contextBundle: {},
|
|
233
|
+
instructions: 'plan'
|
|
234
|
+
});
|
|
235
|
+
|
|
236
|
+
expect(result.patchApplied).toBe(false);
|
|
237
|
+
expect(toolCaller.callTool).not.toHaveBeenCalledWith('planner', TOOLS.REPO_APPLY_PATCH, expect.any(Object));
|
|
238
|
+
});
|
|
239
|
+
|
|
240
|
+
it('GIVEN_note_output_WHEN_log_append_succeeds_THEN_marks_note_logged', async () => {
|
|
241
|
+
const provider = makeProvider({
|
|
242
|
+
type: 'NOTE',
|
|
243
|
+
content: 'worker note'
|
|
244
|
+
});
|
|
245
|
+
const toolCaller = makeToolCaller();
|
|
246
|
+
const loop = new WorkerDecisionLoop({
|
|
247
|
+
provider: provider as never,
|
|
248
|
+
toolCaller: toolCaller as never
|
|
249
|
+
});
|
|
250
|
+
|
|
251
|
+
const result = await loop.execute({
|
|
252
|
+
role: 'builder',
|
|
253
|
+
featureId: 'feature_a',
|
|
254
|
+
contextBundle: {},
|
|
255
|
+
instructions: 'note'
|
|
256
|
+
});
|
|
257
|
+
|
|
258
|
+
expect(result.noteLogged).toBe(true);
|
|
259
|
+
expect(toolCaller.callTool).toHaveBeenCalledWith(
|
|
260
|
+
'orchestrator',
|
|
261
|
+
TOOLS.FEATURE_LOG_APPEND,
|
|
262
|
+
expect.objectContaining({
|
|
263
|
+
feature_id: 'feature_a',
|
|
264
|
+
note: 'worker note'
|
|
265
|
+
})
|
|
266
|
+
);
|
|
267
|
+
});
|
|
268
|
+
|
|
269
|
+
it('GIVEN_note_output_WHEN_log_append_fails_THEN_swallows_error_and_keeps_note_unset', async () => {
|
|
270
|
+
const provider = makeProvider({
|
|
271
|
+
type: 'NOTE',
|
|
272
|
+
metadata: { info: 'fallback-json' }
|
|
273
|
+
});
|
|
274
|
+
const toolCaller = {
|
|
275
|
+
callTool: vi.fn(async (role: string, toolName: string) => {
|
|
276
|
+
if (role === 'orchestrator' && toolName === TOOLS.FEATURE_LOG_APPEND) {
|
|
277
|
+
throw new Error('append_failed');
|
|
278
|
+
}
|
|
279
|
+
return { ok: true, data: {} };
|
|
280
|
+
})
|
|
281
|
+
};
|
|
282
|
+
const loop = new WorkerDecisionLoop({
|
|
283
|
+
provider: provider as never,
|
|
284
|
+
toolCaller: toolCaller as never
|
|
285
|
+
});
|
|
286
|
+
|
|
287
|
+
const result = await loop.execute({
|
|
288
|
+
role: 'qa',
|
|
289
|
+
featureId: 'feature_a',
|
|
290
|
+
contextBundle: {},
|
|
291
|
+
instructions: 'note'
|
|
292
|
+
});
|
|
293
|
+
|
|
294
|
+
expect(result.noteLogged).toBe(false);
|
|
295
|
+
expect(result.toolResults).toEqual([]);
|
|
296
|
+
});
|
|
297
|
+
|
|
298
|
+
it('GIVEN_request_prioritize_with_empty_order_WHEN_executed_THEN_request_remains_unhandled', async () => {
|
|
299
|
+
const provider = makeProvider({
|
|
300
|
+
type: 'REQUEST',
|
|
301
|
+
request: {
|
|
302
|
+
action: 'prioritize',
|
|
303
|
+
feature_order: [null, ' ']
|
|
304
|
+
}
|
|
305
|
+
});
|
|
306
|
+
const toolCaller = makeToolCaller();
|
|
307
|
+
const loop = new WorkerDecisionLoop({
|
|
308
|
+
provider: provider as never,
|
|
309
|
+
toolCaller: toolCaller as never
|
|
310
|
+
});
|
|
311
|
+
|
|
312
|
+
const result = await loop.execute({
|
|
313
|
+
role: 'orchestrator',
|
|
314
|
+
featureId: 'global',
|
|
315
|
+
contextBundle: {},
|
|
316
|
+
instructions: 'prioritize'
|
|
317
|
+
});
|
|
318
|
+
|
|
319
|
+
expect(result.requestHandled).toBe(false);
|
|
320
|
+
expect(result.priorityOrder).toEqual([]);
|
|
321
|
+
});
|
|
322
|
+
|
|
323
|
+
it('GIVEN_request_lock_acquire_and_release_WHEN_executed_THEN_routes_lock_operations', async () => {
|
|
324
|
+
const provider = makeProvider({
|
|
325
|
+
outputs: [
|
|
326
|
+
{
|
|
327
|
+
type: 'REQUEST',
|
|
328
|
+
request: { action: 'lock_acquire', resources: ['openapi'] }
|
|
329
|
+
},
|
|
330
|
+
{
|
|
331
|
+
type: 'REQUEST',
|
|
332
|
+
request: { action: 'lock_release', resources: ['openapi'] }
|
|
333
|
+
}
|
|
334
|
+
]
|
|
335
|
+
});
|
|
336
|
+
const toolCaller = makeToolCaller();
|
|
337
|
+
const loop = new WorkerDecisionLoop({
|
|
338
|
+
provider: provider as never,
|
|
339
|
+
toolCaller: toolCaller as never
|
|
340
|
+
});
|
|
341
|
+
|
|
342
|
+
const result = await loop.execute({
|
|
343
|
+
role: 'builder',
|
|
344
|
+
featureId: 'feature_a',
|
|
345
|
+
contextBundle: {},
|
|
346
|
+
instructions: 'locks'
|
|
347
|
+
});
|
|
348
|
+
|
|
349
|
+
expect(result.requestHandled).toBe(true);
|
|
350
|
+
expect(toolCaller.callTool).toHaveBeenCalledWith(
|
|
351
|
+
'orchestrator',
|
|
352
|
+
TOOLS.LOCKS_ACQUIRE,
|
|
353
|
+
expect.objectContaining({ feature_id: 'feature_a', resources: ['openapi'] })
|
|
354
|
+
);
|
|
355
|
+
expect(toolCaller.callTool).toHaveBeenCalledWith(
|
|
356
|
+
'orchestrator',
|
|
357
|
+
TOOLS.LOCKS_RELEASE,
|
|
358
|
+
expect.objectContaining({ feature_id: 'feature_a', resources: ['openapi'] })
|
|
359
|
+
);
|
|
360
|
+
});
|
|
361
|
+
|
|
362
|
+
it('GIVEN_lock_requests_with_missing_resources_WHEN_executed_THEN_skips_lock_tool_calls', async () => {
|
|
363
|
+
const provider = makeProvider({
|
|
364
|
+
outputs: [
|
|
365
|
+
{
|
|
366
|
+
type: 'REQUEST',
|
|
367
|
+
request: { action: 'lock_acquire', resources: [] }
|
|
368
|
+
},
|
|
369
|
+
{
|
|
370
|
+
type: 'REQUEST',
|
|
371
|
+
request: { action: 'lock_release', resources: [null] }
|
|
372
|
+
}
|
|
373
|
+
]
|
|
374
|
+
});
|
|
375
|
+
const toolCaller = makeToolCaller();
|
|
376
|
+
const loop = new WorkerDecisionLoop({
|
|
377
|
+
provider: provider as never,
|
|
378
|
+
toolCaller: toolCaller as never
|
|
379
|
+
});
|
|
380
|
+
|
|
381
|
+
const result = await loop.execute({
|
|
382
|
+
role: 'planner',
|
|
383
|
+
featureId: 'feature_a',
|
|
384
|
+
contextBundle: {},
|
|
385
|
+
instructions: 'locks'
|
|
386
|
+
});
|
|
387
|
+
|
|
388
|
+
expect(result.requestHandled).toBe(false);
|
|
389
|
+
expect(toolCaller.callTool).not.toHaveBeenCalledWith('orchestrator', TOOLS.LOCKS_ACQUIRE, expect.any(Object));
|
|
390
|
+
expect(toolCaller.callTool).not.toHaveBeenCalledWith('orchestrator', TOOLS.LOCKS_RELEASE, expect.any(Object));
|
|
391
|
+
});
|
|
392
|
+
|
|
393
|
+
it('GIVEN_context_refresh_requests_WHEN_executed_THEN_requests_feature_context', async () => {
|
|
394
|
+
const provider = makeProvider({
|
|
395
|
+
outputs: [
|
|
396
|
+
{
|
|
397
|
+
type: 'REQUEST',
|
|
398
|
+
request: { action: 'more_context' }
|
|
399
|
+
},
|
|
400
|
+
{
|
|
401
|
+
type: 'REQUEST',
|
|
402
|
+
request: { request_type: 'context_refresh' }
|
|
403
|
+
}
|
|
404
|
+
]
|
|
405
|
+
});
|
|
406
|
+
const toolCaller = makeToolCaller();
|
|
407
|
+
const loop = new WorkerDecisionLoop({
|
|
408
|
+
provider: provider as never,
|
|
409
|
+
toolCaller: toolCaller as never
|
|
410
|
+
});
|
|
411
|
+
|
|
412
|
+
const result = await loop.execute({
|
|
413
|
+
role: 'qa',
|
|
414
|
+
featureId: 'feature_a',
|
|
415
|
+
contextBundle: {},
|
|
416
|
+
instructions: 'context'
|
|
417
|
+
});
|
|
418
|
+
|
|
419
|
+
expect(result.requestHandled).toBe(true);
|
|
420
|
+
const contextCalls = toolCaller.callTool.mock.calls.filter((call) => call[1] === TOOLS.FEATURE_GET_CONTEXT);
|
|
421
|
+
expect(contextCalls).toHaveLength(2);
|
|
422
|
+
});
|
|
423
|
+
|
|
424
|
+
it('GIVEN_planner_amend_plan_request_WHEN_existing_version_missing_THEN_submits_new_plan', async () => {
|
|
425
|
+
const provider = makeProvider({
|
|
426
|
+
type: 'REQUEST',
|
|
427
|
+
request: {
|
|
428
|
+
action: 'amend_plan',
|
|
429
|
+
plan_json: {
|
|
430
|
+
feature_id: 'feature_a',
|
|
431
|
+
plan_version: 1
|
|
432
|
+
}
|
|
433
|
+
}
|
|
434
|
+
});
|
|
435
|
+
const toolCaller = makeToolCaller();
|
|
436
|
+
const loop = new WorkerDecisionLoop({
|
|
437
|
+
provider: provider as never,
|
|
438
|
+
toolCaller: toolCaller as never
|
|
439
|
+
});
|
|
440
|
+
|
|
441
|
+
const result = await loop.execute({
|
|
442
|
+
role: 'planner',
|
|
443
|
+
featureId: 'feature_a',
|
|
444
|
+
contextBundle: { plan: null },
|
|
445
|
+
instructions: 'amend'
|
|
446
|
+
});
|
|
447
|
+
|
|
448
|
+
expect(result.requestHandled).toBe(true);
|
|
449
|
+
expect(result.planSubmission).toBe(true);
|
|
450
|
+
expect(toolCaller.callTool).toHaveBeenCalledWith(
|
|
451
|
+
'planner',
|
|
452
|
+
TOOLS.PLAN_SUBMIT,
|
|
453
|
+
expect.objectContaining({ feature_id: 'feature_a' })
|
|
454
|
+
);
|
|
455
|
+
});
|
|
456
|
+
|
|
457
|
+
it('GIVEN_planner_amend_plan_request_WHEN_existing_version_present_THEN_updates_plan', async () => {
|
|
458
|
+
const provider = makeProvider({
|
|
459
|
+
type: 'REQUEST',
|
|
460
|
+
request: {
|
|
461
|
+
action: 'amend_plan',
|
|
462
|
+
expected_plan_version: 3,
|
|
463
|
+
plan_json: {
|
|
464
|
+
feature_id: 'feature_a',
|
|
465
|
+
plan_version: 4
|
|
466
|
+
}
|
|
467
|
+
}
|
|
468
|
+
});
|
|
469
|
+
const toolCaller = makeToolCaller();
|
|
470
|
+
const loop = new WorkerDecisionLoop({
|
|
471
|
+
provider: provider as never,
|
|
472
|
+
toolCaller: toolCaller as never
|
|
473
|
+
});
|
|
474
|
+
|
|
475
|
+
const result = await loop.execute({
|
|
476
|
+
role: 'planner',
|
|
477
|
+
featureId: 'feature_a',
|
|
478
|
+
contextBundle: { plan: { plan_version: 2 } },
|
|
479
|
+
instructions: 'amend'
|
|
480
|
+
});
|
|
481
|
+
|
|
482
|
+
expect(result.requestHandled).toBe(true);
|
|
483
|
+
expect(result.planSubmission).toBe(true);
|
|
484
|
+
expect(toolCaller.callTool).toHaveBeenCalledWith(
|
|
485
|
+
'planner',
|
|
486
|
+
TOOLS.PLAN_UPDATE,
|
|
487
|
+
expect.objectContaining({
|
|
488
|
+
feature_id: 'feature_a',
|
|
489
|
+
expected_plan_version: 3
|
|
490
|
+
})
|
|
491
|
+
);
|
|
492
|
+
});
|
|
493
|
+
|
|
494
|
+
it('GIVEN_amend_plan_without_payload_or_non_planner_role_WHEN_executed_THEN_ignores_request', async () => {
|
|
495
|
+
const provider = makeProvider({
|
|
496
|
+
outputs: [
|
|
497
|
+
{
|
|
498
|
+
type: 'REQUEST',
|
|
499
|
+
request: {
|
|
500
|
+
action: 'amend_plan',
|
|
501
|
+
plan_json: {}
|
|
502
|
+
}
|
|
503
|
+
},
|
|
504
|
+
{
|
|
505
|
+
type: 'REQUEST',
|
|
506
|
+
request: {
|
|
507
|
+
action: 'amend_plan',
|
|
508
|
+
plan_json: {
|
|
509
|
+
feature_id: 'feature_a'
|
|
510
|
+
}
|
|
511
|
+
}
|
|
512
|
+
}
|
|
513
|
+
]
|
|
514
|
+
});
|
|
515
|
+
const toolCaller = makeToolCaller();
|
|
516
|
+
const loop = new WorkerDecisionLoop({
|
|
517
|
+
provider: provider as never,
|
|
518
|
+
toolCaller: toolCaller as never
|
|
519
|
+
});
|
|
520
|
+
|
|
521
|
+
const result = await loop.execute({
|
|
522
|
+
role: 'builder',
|
|
523
|
+
featureId: 'feature_a',
|
|
524
|
+
contextBundle: {},
|
|
525
|
+
instructions: 'amend'
|
|
526
|
+
});
|
|
527
|
+
|
|
528
|
+
expect(result.planSubmission).toBe(false);
|
|
529
|
+
expect(result.requestHandled).toBe(false);
|
|
530
|
+
});
|
|
531
|
+
|
|
532
|
+
it('GIVEN_unknown_or_malformed_outputs_WHEN_executed_THEN_ignores_them_without_crashing', async () => {
|
|
533
|
+
const provider = makeProvider({
|
|
534
|
+
outputs: [
|
|
535
|
+
null,
|
|
536
|
+
{},
|
|
537
|
+
{ type: 'UNSUPPORTED' },
|
|
538
|
+
{ type: 'REQUEST', request: {} },
|
|
539
|
+
{ type: 'NOTE', content: 'x' }
|
|
540
|
+
]
|
|
541
|
+
});
|
|
542
|
+
const toolCaller = makeToolCaller();
|
|
543
|
+
const loop = new WorkerDecisionLoop({
|
|
544
|
+
provider: provider as never,
|
|
545
|
+
toolCaller: toolCaller as never
|
|
546
|
+
});
|
|
547
|
+
|
|
548
|
+
const result = await loop.execute({
|
|
549
|
+
role: 'orchestrator',
|
|
550
|
+
featureId: 'global',
|
|
551
|
+
contextBundle: {},
|
|
552
|
+
instructions: 'noop'
|
|
553
|
+
});
|
|
554
|
+
|
|
555
|
+
expect(result.noteLogged).toBe(true);
|
|
556
|
+
expect(result.planSubmission).toBe(false);
|
|
557
|
+
expect(result.patchApplied).toBe(false);
|
|
558
|
+
});
|
|
559
|
+
|
|
560
|
+
it('extracts orchestrator prioritize requests into deterministic priority ordering', async () => {
|
|
561
|
+
const provider = makeProvider({
|
|
562
|
+
type: 'REQUEST',
|
|
563
|
+
request: {
|
|
564
|
+
action: 'prioritize',
|
|
565
|
+
feature_order: ['feature_c', 'feature_a']
|
|
566
|
+
}
|
|
567
|
+
});
|
|
568
|
+
|
|
569
|
+
const toolCaller = makeToolCaller();
|
|
570
|
+
const loop = new WorkerDecisionLoop({
|
|
571
|
+
provider: provider as never,
|
|
572
|
+
toolCaller: toolCaller as never
|
|
573
|
+
});
|
|
574
|
+
|
|
575
|
+
const result = await loop.execute({
|
|
576
|
+
role: 'orchestrator',
|
|
577
|
+
featureId: 'global',
|
|
578
|
+
contextBundle: {
|
|
579
|
+
active_feature_ids: ['feature_a', 'feature_b', 'feature_c']
|
|
580
|
+
},
|
|
581
|
+
instructions: 'prioritize'
|
|
582
|
+
});
|
|
583
|
+
|
|
584
|
+
expect(result.requestHandled).toBe(true);
|
|
585
|
+
expect(result.priorityOrder).toEqual(['feature_c', 'feature_a']);
|
|
586
|
+
});
|
|
587
|
+
});
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
{
|
|
2
|
+
"extends": "./tsconfig.json",
|
|
3
|
+
"compilerOptions": {
|
|
4
|
+
"noEmit": false,
|
|
5
|
+
"outDir": "../../dist/apps/control-plane",
|
|
6
|
+
"declaration": true,
|
|
7
|
+
"declarationMap": false,
|
|
8
|
+
"sourceMap": true
|
|
9
|
+
},
|
|
10
|
+
"include": [
|
|
11
|
+
"src/**/*.ts"
|
|
12
|
+
],
|
|
13
|
+
"exclude": [
|
|
14
|
+
"test/**/*.ts",
|
|
15
|
+
"vitest.config.ts"
|
|
16
|
+
]
|
|
17
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { defineConfig } from 'vitest/config';
|
|
2
|
+
|
|
3
|
+
export default defineConfig({
|
|
4
|
+
test: {
|
|
5
|
+
environment: 'node',
|
|
6
|
+
include: ['apps/control-plane/test/**/*.spec.ts'],
|
|
7
|
+
coverage: {
|
|
8
|
+
enabled: true,
|
|
9
|
+
provider: 'v8',
|
|
10
|
+
reporter: ['text', 'json-summary', 'lcov'],
|
|
11
|
+
reportsDirectory: 'coverage/control-plane',
|
|
12
|
+
include: ['apps/control-plane/src/**/*.{ts,tsx}'],
|
|
13
|
+
exclude: [
|
|
14
|
+
'**/*.d.ts',
|
|
15
|
+
'**/*.test.*',
|
|
16
|
+
'**/*.spec.*',
|
|
17
|
+
'**/__tests__/**',
|
|
18
|
+
'dist/**'
|
|
19
|
+
],
|
|
20
|
+
thresholds: {
|
|
21
|
+
lines: 70,
|
|
22
|
+
branches: 70,
|
|
23
|
+
functions: 85,
|
|
24
|
+
statements: 70
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
});
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
type AnyRecord = Record<string, any>;
|
|
2
|
+
type StateReadResult = {
|
|
3
|
+
frontMatter: AnyRecord;
|
|
4
|
+
};
|
|
5
|
+
type StateUpdater = (frontMatter: AnyRecord, body: string) => Promise<{
|
|
6
|
+
frontMatter?: AnyRecord;
|
|
7
|
+
body?: string;
|
|
8
|
+
}>;
|
|
9
|
+
interface QueueEntry {
|
|
10
|
+
feature_id: string;
|
|
11
|
+
plan_version: number;
|
|
12
|
+
detected_at: string;
|
|
13
|
+
collision_fingerprint: string;
|
|
14
|
+
required_resources: string[];
|
|
15
|
+
plan_snapshot?: AnyRecord;
|
|
16
|
+
}
|
|
17
|
+
export interface CollisionQueueServicePort {
|
|
18
|
+
getPolicySnapshot(): AnyRecord;
|
|
19
|
+
planPath(featureId: string): string;
|
|
20
|
+
statePath(featureId: string): string;
|
|
21
|
+
featureDiscoverSpecs(): Promise<{
|
|
22
|
+
data: {
|
|
23
|
+
specs: Array<{
|
|
24
|
+
feature_id: string;
|
|
25
|
+
}>;
|
|
26
|
+
};
|
|
27
|
+
}>;
|
|
28
|
+
readState(featureId: string): Promise<StateReadResult>;
|
|
29
|
+
withFeatureLock<T>(featureId: string, operation: () => Promise<T>): Promise<T>;
|
|
30
|
+
withIndexLock<T>(operation: () => Promise<T>): Promise<T>;
|
|
31
|
+
readIndex(): Promise<AnyRecord>;
|
|
32
|
+
writeIndex(index: AnyRecord): Promise<void>;
|
|
33
|
+
updateState(featureId: string, expectedVersion: number | null, updater: StateUpdater): Promise<AnyRecord>;
|
|
34
|
+
planSubmit(featureId: string, plan: AnyRecord, expectedVersion: number | null): Promise<{
|
|
35
|
+
data: {
|
|
36
|
+
feature_id: string;
|
|
37
|
+
accepted: boolean;
|
|
38
|
+
plan_version: number;
|
|
39
|
+
};
|
|
40
|
+
}>;
|
|
41
|
+
}
|
|
42
|
+
export declare class CollisionQueueService {
|
|
43
|
+
private readonly port;
|
|
44
|
+
constructor(port: CollisionQueueServicePort);
|
|
45
|
+
collectAcceptedPlans(excludeFeatureId?: string | null): Promise<AnyRecord[]>;
|
|
46
|
+
requiredResourcesForPlan(plan: AnyRecord): string[];
|
|
47
|
+
assertPlanLocksHeld(featureId: string, plan: AnyRecord): Promise<boolean>;
|
|
48
|
+
checkPlanCollision(featureId: string, plan: AnyRecord): Promise<{
|
|
49
|
+
hasCollisions: boolean;
|
|
50
|
+
fingerprint?: string;
|
|
51
|
+
}>;
|
|
52
|
+
processSingleQueueEntry(entry: QueueEntry): Promise<{
|
|
53
|
+
retried: boolean;
|
|
54
|
+
reason?: string;
|
|
55
|
+
}>;
|
|
56
|
+
reDriveBlockedQueue(): Promise<{
|
|
57
|
+
data: {
|
|
58
|
+
processed: number;
|
|
59
|
+
retried: number;
|
|
60
|
+
still_blocked: number;
|
|
61
|
+
};
|
|
62
|
+
}>;
|
|
63
|
+
clearQueueEntry(featureId: string): Promise<{
|
|
64
|
+
data: {
|
|
65
|
+
removed: boolean;
|
|
66
|
+
};
|
|
67
|
+
}>;
|
|
68
|
+
}
|
|
69
|
+
export {};
|