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,369 @@
|
|
|
1
|
+
import fs from 'node:fs/promises';
|
|
2
|
+
import path from 'node:path';
|
|
3
|
+
import { describe, it, expect, beforeEach } from 'vitest';
|
|
4
|
+
import { AopKernel } from '../src/index.js';
|
|
5
|
+
import { runGit } from '../src/core/git.js';
|
|
6
|
+
import { makeTempRepo, writeFeatureSpec } from './helpers.js';
|
|
7
|
+
|
|
8
|
+
let repoRoot: string;
|
|
9
|
+
|
|
10
|
+
beforeEach(async () => {
|
|
11
|
+
repoRoot = await makeTempRepo(process.cwd());
|
|
12
|
+
await fs.mkdir(path.join(repoRoot, 'src'), { recursive: true });
|
|
13
|
+
await fs.writeFile(path.join(repoRoot, 'src', 'sample.txt'), 'hello\n', 'utf8');
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
describe('AopKernel', () => {
|
|
17
|
+
it('migrates legacy runtime artifacts from agentic into .aop when .aop is absent', async () => {
|
|
18
|
+
await fs.rm(path.join(repoRoot, '.aop'), { recursive: true, force: true });
|
|
19
|
+
await fs.mkdir(path.join(repoRoot, 'agentic', 'features'), { recursive: true });
|
|
20
|
+
|
|
21
|
+
const legacyIndexPath = path.join(repoRoot, 'agentic', 'features', 'index.json');
|
|
22
|
+
const legacySpecPath = path.join(repoRoot, 'agentic', 'features', 'legacy_feature', 'spec.md');
|
|
23
|
+
await fs.mkdir(path.dirname(legacySpecPath), { recursive: true });
|
|
24
|
+
await fs.writeFile(legacySpecPath, '# Legacy Spec\n', 'utf8');
|
|
25
|
+
await fs.writeFile(
|
|
26
|
+
legacyIndexPath,
|
|
27
|
+
`${JSON.stringify(
|
|
28
|
+
{
|
|
29
|
+
version: 1,
|
|
30
|
+
active: [],
|
|
31
|
+
blocked: [],
|
|
32
|
+
merged: [],
|
|
33
|
+
locks: {},
|
|
34
|
+
lock_leases: {},
|
|
35
|
+
blocked_queue: [],
|
|
36
|
+
updated_at: new Date().toISOString()
|
|
37
|
+
},
|
|
38
|
+
null,
|
|
39
|
+
2
|
|
40
|
+
)}\n`,
|
|
41
|
+
'utf8'
|
|
42
|
+
);
|
|
43
|
+
|
|
44
|
+
const kernel = new AopKernel(repoRoot);
|
|
45
|
+
await kernel.ensureLoaded();
|
|
46
|
+
|
|
47
|
+
const index = await (kernel as any).readIndex();
|
|
48
|
+
expect(await fs.readFile(path.join(repoRoot, '.aop', 'features', 'legacy_feature', 'spec.md'), 'utf8')).toContain('Legacy Spec');
|
|
49
|
+
expect(index.runtime_sessions).toBeTruthy();
|
|
50
|
+
expect(index.runtime_sessions.orchestrator_session_id).toBe('unknown');
|
|
51
|
+
expect(typeof index.runtime_sessions.lease_expires_at).toBe('string');
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
it('prefers existing .aop runtime artifacts over legacy agentic artifacts when both exist', async () => {
|
|
55
|
+
const legacySpecPath = path.join(repoRoot, 'agentic', 'features', 'priority_feature', 'spec.md');
|
|
56
|
+
await fs.mkdir(path.dirname(legacySpecPath), { recursive: true });
|
|
57
|
+
await fs.writeFile(legacySpecPath, '# Legacy Priority Spec\n', 'utf8');
|
|
58
|
+
|
|
59
|
+
const aopSpecPath = path.join(repoRoot, '.aop', 'features', 'priority_feature', 'spec.md');
|
|
60
|
+
await fs.mkdir(path.dirname(aopSpecPath), { recursive: true });
|
|
61
|
+
await fs.writeFile(aopSpecPath, '# AOP Priority Spec\n', 'utf8');
|
|
62
|
+
|
|
63
|
+
const kernel = new AopKernel(repoRoot);
|
|
64
|
+
await kernel.ensureLoaded();
|
|
65
|
+
await kernel.invoke('feature.init', { feature_id: 'priority_feature' }, { actor_type: 'orchestrator', actor_id: 't-priority' });
|
|
66
|
+
|
|
67
|
+
const context = await kernel.invoke(
|
|
68
|
+
'feature.get_context',
|
|
69
|
+
{ feature_id: 'priority_feature' },
|
|
70
|
+
{ actor_type: 'orchestrator', actor_id: 't-priority' }
|
|
71
|
+
);
|
|
72
|
+
expect(context.ok).toBe(true);
|
|
73
|
+
expect(context.data.spec).toContain('AOP Priority Spec');
|
|
74
|
+
expect(context.data.spec).not.toContain('Legacy Priority Spec');
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
it('initializes feature state and worktree', async () => {
|
|
78
|
+
const kernel = new AopKernel(repoRoot);
|
|
79
|
+
await kernel.ensureLoaded();
|
|
80
|
+
await writeFeatureSpec(repoRoot, 'feature_one');
|
|
81
|
+
|
|
82
|
+
const init = await kernel.invoke('feature.init', { feature_id: 'feature_one' }, { actor_type: 'orchestrator', actor_id: 't1' });
|
|
83
|
+
expect(init.ok).toBe(true);
|
|
84
|
+
|
|
85
|
+
const state = await kernel.invoke('feature.state_get', { feature_id: 'feature_one' }, { actor_type: 'orchestrator', actor_id: 't1' });
|
|
86
|
+
expect(state.ok).toBe(true);
|
|
87
|
+
expect(state.data.front_matter.status).toBe('planning');
|
|
88
|
+
|
|
89
|
+
const worktreePath = path.join(repoRoot, '.worktrees', 'feature_one');
|
|
90
|
+
await expect(fs.stat(worktreePath)).resolves.toBeTruthy();
|
|
91
|
+
});
|
|
92
|
+
|
|
93
|
+
it('enforces contract locks during plan submission', async () => {
|
|
94
|
+
const kernel = new AopKernel(repoRoot);
|
|
95
|
+
await kernel.ensureLoaded();
|
|
96
|
+
await writeFeatureSpec(repoRoot, 'feature_two');
|
|
97
|
+
await kernel.invoke('feature.init', { feature_id: 'feature_two' }, { actor_type: 'orchestrator', actor_id: 't2' });
|
|
98
|
+
|
|
99
|
+
const plan = {
|
|
100
|
+
feature_id: 'feature_two',
|
|
101
|
+
plan_version: 1,
|
|
102
|
+
summary: 'Add migration',
|
|
103
|
+
allowed_areas: ['src'],
|
|
104
|
+
forbidden_areas: [],
|
|
105
|
+
base_ref: 'HEAD',
|
|
106
|
+
files: { create: [], modify: ['src/sample.txt'], delete: [] },
|
|
107
|
+
contracts: { openapi: 'none', events: 'none', db: 'migration' },
|
|
108
|
+
acceptance_criteria: ['works'],
|
|
109
|
+
gate_profile: 'default'
|
|
110
|
+
};
|
|
111
|
+
|
|
112
|
+
const rejected = await kernel.invoke('plan.submit', { feature_id: 'feature_two', plan_json: plan }, { actor_type: 'orchestrator', actor_id: 't2' });
|
|
113
|
+
expect(rejected.ok).toBe(false);
|
|
114
|
+
expect(rejected.error.code).toBe('lock_not_held');
|
|
115
|
+
|
|
116
|
+
const lock = await kernel.invoke('locks.acquire', { resource: 'db_migrations', feature_id: 'feature_two' }, { actor_type: 'orchestrator', actor_id: 't2' });
|
|
117
|
+
expect(lock.ok).toBe(true);
|
|
118
|
+
|
|
119
|
+
const accepted = await kernel.invoke('plan.submit', { feature_id: 'feature_two', plan_json: plan }, { actor_type: 'orchestrator', actor_id: 't2' });
|
|
120
|
+
expect(accepted.ok).toBe(true);
|
|
121
|
+
});
|
|
122
|
+
|
|
123
|
+
it('rejects patch files outside planned file set', async () => {
|
|
124
|
+
const kernel = new AopKernel(repoRoot);
|
|
125
|
+
await kernel.ensureLoaded();
|
|
126
|
+
await writeFeatureSpec(repoRoot, 'feature_three');
|
|
127
|
+
await kernel.invoke('feature.init', { feature_id: 'feature_three' }, { actor_type: 'orchestrator', actor_id: 't3' });
|
|
128
|
+
|
|
129
|
+
const plan = {
|
|
130
|
+
feature_id: 'feature_three',
|
|
131
|
+
plan_version: 1,
|
|
132
|
+
summary: 'touch only sample file',
|
|
133
|
+
allowed_areas: ['src'],
|
|
134
|
+
forbidden_areas: [],
|
|
135
|
+
base_ref: 'HEAD',
|
|
136
|
+
files: { create: [], modify: ['src/sample.txt'], delete: [] },
|
|
137
|
+
contracts: { openapi: 'none', events: 'none', db: 'none' },
|
|
138
|
+
acceptance_criteria: ['works'],
|
|
139
|
+
gate_profile: 'default'
|
|
140
|
+
};
|
|
141
|
+
|
|
142
|
+
const planResult = await kernel.invoke('plan.submit', { feature_id: 'feature_three', plan_json: plan }, { actor_type: 'orchestrator', actor_id: 't3' });
|
|
143
|
+
expect(planResult.ok).toBe(true);
|
|
144
|
+
|
|
145
|
+
const diff = [
|
|
146
|
+
'diff --git a/src/other.txt b/src/other.txt',
|
|
147
|
+
'new file mode 100644',
|
|
148
|
+
'--- /dev/null',
|
|
149
|
+
'+++ b/src/other.txt',
|
|
150
|
+
'@@ -0,0 +1,1 @@',
|
|
151
|
+
'+x'
|
|
152
|
+
].join('\n');
|
|
153
|
+
|
|
154
|
+
const patchResult = await kernel.invoke('repo.apply_patch', { feature_id: 'feature_three', unified_diff: diff }, { actor_type: 'builder', actor_id: 't3' });
|
|
155
|
+
expect(patchResult.ok).toBe(false);
|
|
156
|
+
expect(patchResult.error.code).toBe('patch_policy_violation');
|
|
157
|
+
});
|
|
158
|
+
|
|
159
|
+
it('updates QA index with optimistic concurrency', async () => {
|
|
160
|
+
const kernel = new AopKernel(repoRoot);
|
|
161
|
+
await kernel.ensureLoaded();
|
|
162
|
+
await writeFeatureSpec(repoRoot, 'feature_four');
|
|
163
|
+
await kernel.invoke('feature.init', { feature_id: 'feature_four' }, { actor_type: 'orchestrator', actor_id: 't4' });
|
|
164
|
+
|
|
165
|
+
const initial = await kernel.invoke('qa.test_index_get', { feature_id: 'feature_four' }, { actor_type: 'qa', actor_id: 't4' });
|
|
166
|
+
expect(initial.ok).toBe(true);
|
|
167
|
+
|
|
168
|
+
const conflict = await kernel.invoke(
|
|
169
|
+
'qa.test_index_update',
|
|
170
|
+
{
|
|
171
|
+
feature_id: 'feature_four',
|
|
172
|
+
expected_version: initial.data.index.version + 1,
|
|
173
|
+
updates: []
|
|
174
|
+
},
|
|
175
|
+
{ actor_type: 'qa', actor_id: 't4' }
|
|
176
|
+
);
|
|
177
|
+
|
|
178
|
+
expect(conflict.ok).toBe(false);
|
|
179
|
+
expect(conflict.error.code).toBe('qa_index_version_conflict');
|
|
180
|
+
});
|
|
181
|
+
|
|
182
|
+
it('previews and applies deterministic feature deletion with residue cleanup', async () => {
|
|
183
|
+
const kernel = new AopKernel(repoRoot);
|
|
184
|
+
await kernel.ensureLoaded();
|
|
185
|
+
await writeFeatureSpec(repoRoot, 'feature_delete');
|
|
186
|
+
await kernel.invoke('feature.init', { feature_id: 'feature_delete' }, { actor_type: 'orchestrator', actor_id: 't-delete' });
|
|
187
|
+
await kernel.invoke(
|
|
188
|
+
'locks.acquire',
|
|
189
|
+
{ resource: 'openapi', feature_id: 'feature_delete' },
|
|
190
|
+
{ actor_type: 'orchestrator', actor_id: 't-delete' }
|
|
191
|
+
);
|
|
192
|
+
|
|
193
|
+
const indexPath = path.join(repoRoot, '.aop', 'features', 'index.json');
|
|
194
|
+
const index = JSON.parse(await fs.readFile(indexPath, 'utf8')) as Record<string, unknown>;
|
|
195
|
+
index.blocked_queue = [
|
|
196
|
+
{
|
|
197
|
+
feature_id: 'feature_delete',
|
|
198
|
+
plan_version: 1,
|
|
199
|
+
detected_at: '2026-03-01T00:00:00.000Z',
|
|
200
|
+
collision_fingerprint: 'fp:feature_delete',
|
|
201
|
+
required_resources: ['openapi']
|
|
202
|
+
},
|
|
203
|
+
{
|
|
204
|
+
feature_id: 'other_feature',
|
|
205
|
+
plan_version: 1,
|
|
206
|
+
detected_at: '2026-03-01T00:00:00.000Z',
|
|
207
|
+
collision_fingerprint: 'fp:other_feature',
|
|
208
|
+
required_resources: ['openapi']
|
|
209
|
+
}
|
|
210
|
+
];
|
|
211
|
+
const runtimeSessions = index.runtime_sessions as { feature_sessions?: Record<string, unknown> };
|
|
212
|
+
runtimeSessions.feature_sessions = {
|
|
213
|
+
...(runtimeSessions.feature_sessions ?? {}),
|
|
214
|
+
feature_delete: {
|
|
215
|
+
planner_session_id: 'planner:1',
|
|
216
|
+
builder_session_id: 'builder:1',
|
|
217
|
+
qa_session_id: 'qa:1'
|
|
218
|
+
}
|
|
219
|
+
};
|
|
220
|
+
index.runtime_sessions = runtimeSessions;
|
|
221
|
+
await fs.writeFile(indexPath, `${JSON.stringify(index, null, 2)}\n`, 'utf8');
|
|
222
|
+
|
|
223
|
+
const preview = await kernel.invoke(
|
|
224
|
+
'feature.delete',
|
|
225
|
+
{
|
|
226
|
+
feature_id: 'feature_delete',
|
|
227
|
+
dry_run: true,
|
|
228
|
+
confirm: false,
|
|
229
|
+
remove_worktree: true,
|
|
230
|
+
remove_branch: 'none'
|
|
231
|
+
},
|
|
232
|
+
{ actor_type: 'system', actor_id: 'cleanup:preview' }
|
|
233
|
+
);
|
|
234
|
+
expect(preview.ok).toBe(true);
|
|
235
|
+
expect(preview.data.dry_run).toBe(true);
|
|
236
|
+
expect(preview.data.plan.blocked_queue_entries).toBe(1);
|
|
237
|
+
expect(preview.data.plan.runtime_session_assignment_exists).toBe(true);
|
|
238
|
+
expect(preview.data.summary.feature_dir_removed).toBe(false);
|
|
239
|
+
|
|
240
|
+
await expect(fs.stat(path.join(repoRoot, '.aop', 'features', 'feature_delete'))).resolves.toBeTruthy();
|
|
241
|
+
await expect(fs.stat(path.join(repoRoot, '.worktrees', 'feature_delete'))).resolves.toBeTruthy();
|
|
242
|
+
|
|
243
|
+
const applied = await kernel.invoke(
|
|
244
|
+
'feature.delete',
|
|
245
|
+
{
|
|
246
|
+
feature_id: 'feature_delete',
|
|
247
|
+
dry_run: false,
|
|
248
|
+
confirm: true,
|
|
249
|
+
remove_worktree: true,
|
|
250
|
+
remove_branch: 'none'
|
|
251
|
+
},
|
|
252
|
+
{ actor_type: 'system', actor_id: 'cleanup:apply' }
|
|
253
|
+
);
|
|
254
|
+
expect(applied.ok).toBe(true);
|
|
255
|
+
expect(applied.data.summary.locks_released).toContain('openapi');
|
|
256
|
+
expect(applied.data.summary.blocked_queue_entries_removed).toBe(1);
|
|
257
|
+
expect(applied.data.summary.runtime_session_assignment_removed).toBe(true);
|
|
258
|
+
expect(applied.data.summary.feature_dir_removed).toBe(true);
|
|
259
|
+
expect(applied.data.summary.worktree_removed).toBe(true);
|
|
260
|
+
|
|
261
|
+
await expect(fs.stat(path.join(repoRoot, '.aop', 'features', 'feature_delete'))).rejects.toThrow();
|
|
262
|
+
await expect(fs.stat(path.join(repoRoot, '.worktrees', 'feature_delete'))).rejects.toThrow();
|
|
263
|
+
|
|
264
|
+
const postIndex = JSON.parse(await fs.readFile(indexPath, 'utf8')) as {
|
|
265
|
+
active: string[];
|
|
266
|
+
blocked_queue: Array<{ feature_id?: string }>;
|
|
267
|
+
locks: Record<string, string | null>;
|
|
268
|
+
runtime_sessions: { feature_sessions?: Record<string, unknown> };
|
|
269
|
+
};
|
|
270
|
+
expect(postIndex.active).not.toContain('feature_delete');
|
|
271
|
+
expect(postIndex.blocked_queue.map((entry) => entry.feature_id)).not.toContain('feature_delete');
|
|
272
|
+
expect(postIndex.locks.openapi).toBeNull();
|
|
273
|
+
expect(postIndex.runtime_sessions.feature_sessions?.feature_delete).toBeUndefined();
|
|
274
|
+
|
|
275
|
+
const rerun = await kernel.invoke(
|
|
276
|
+
'feature.delete',
|
|
277
|
+
{
|
|
278
|
+
feature_id: 'feature_delete',
|
|
279
|
+
dry_run: false,
|
|
280
|
+
confirm: true,
|
|
281
|
+
remove_worktree: true,
|
|
282
|
+
remove_branch: 'none'
|
|
283
|
+
},
|
|
284
|
+
{ actor_type: 'system', actor_id: 'cleanup:rerun' }
|
|
285
|
+
);
|
|
286
|
+
expect(rerun.ok).toBe(true);
|
|
287
|
+
expect(rerun.data.summary.feature_dir_removed).toBe(false);
|
|
288
|
+
expect(rerun.data.summary.worktree_removed).toBe(false);
|
|
289
|
+
expect(rerun.data.summary.blocked_queue_entries_removed).toBe(0);
|
|
290
|
+
});
|
|
291
|
+
|
|
292
|
+
it('rejects feature.delete when a fresh run lease exists', async () => {
|
|
293
|
+
const kernel = new AopKernel(repoRoot);
|
|
294
|
+
await kernel.ensureLoaded();
|
|
295
|
+
await writeFeatureSpec(repoRoot, 'feature_guard');
|
|
296
|
+
await kernel.invoke('feature.init', { feature_id: 'feature_guard' }, { actor_type: 'orchestrator', actor_id: 't-guard' });
|
|
297
|
+
|
|
298
|
+
await kernel.acquireRunLease({
|
|
299
|
+
run_id: 'run:guard',
|
|
300
|
+
owner_instance_id: 'owner:guard',
|
|
301
|
+
provider: 'custom',
|
|
302
|
+
model: 'test',
|
|
303
|
+
provider_config_ref_hash: 'hash'
|
|
304
|
+
});
|
|
305
|
+
|
|
306
|
+
const blocked = await kernel.invoke(
|
|
307
|
+
'feature.delete',
|
|
308
|
+
{
|
|
309
|
+
feature_id: 'feature_guard',
|
|
310
|
+
dry_run: true,
|
|
311
|
+
confirm: false,
|
|
312
|
+
remove_worktree: true,
|
|
313
|
+
remove_branch: 'none'
|
|
314
|
+
},
|
|
315
|
+
{ actor_type: 'system', actor_id: 'cleanup:guard' }
|
|
316
|
+
);
|
|
317
|
+
|
|
318
|
+
expect(blocked.ok).toBe(false);
|
|
319
|
+
expect(blocked.error.code).toBe('run_already_active');
|
|
320
|
+
});
|
|
321
|
+
|
|
322
|
+
it('enforces safe-vs-force branch deletion behavior for feature.delete', async () => {
|
|
323
|
+
const kernel = new AopKernel(repoRoot);
|
|
324
|
+
await kernel.ensureLoaded();
|
|
325
|
+
await writeFeatureSpec(repoRoot, 'feature_branch_cleanup');
|
|
326
|
+
await kernel.invoke(
|
|
327
|
+
'feature.init',
|
|
328
|
+
{ feature_id: 'feature_branch_cleanup' },
|
|
329
|
+
{ actor_type: 'orchestrator', actor_id: 't-branch' }
|
|
330
|
+
);
|
|
331
|
+
|
|
332
|
+
const worktree = path.join(repoRoot, '.worktrees', 'feature_branch_cleanup');
|
|
333
|
+
await fs.mkdir(path.join(worktree, 'src'), { recursive: true });
|
|
334
|
+
await fs.writeFile(path.join(worktree, 'src', 'branch-only.txt'), 'branch only\n', 'utf8');
|
|
335
|
+
await runGit(repoRoot, ['add', '-A'], { cwd: worktree });
|
|
336
|
+
await runGit(repoRoot, ['commit', '-m', 'branch-only commit'], { cwd: worktree });
|
|
337
|
+
|
|
338
|
+
const safeDelete = await kernel.invoke(
|
|
339
|
+
'feature.delete',
|
|
340
|
+
{
|
|
341
|
+
feature_id: 'feature_branch_cleanup',
|
|
342
|
+
dry_run: false,
|
|
343
|
+
confirm: true,
|
|
344
|
+
remove_worktree: true,
|
|
345
|
+
remove_branch: 'safe'
|
|
346
|
+
},
|
|
347
|
+
{ actor_type: 'system', actor_id: 'cleanup:safe' }
|
|
348
|
+
);
|
|
349
|
+
expect(safeDelete.ok).toBe(false);
|
|
350
|
+
expect(safeDelete.error.code).toBe('git_failure');
|
|
351
|
+
|
|
352
|
+
const forceDelete = await kernel.invoke(
|
|
353
|
+
'feature.delete',
|
|
354
|
+
{
|
|
355
|
+
feature_id: 'feature_branch_cleanup',
|
|
356
|
+
dry_run: false,
|
|
357
|
+
confirm: true,
|
|
358
|
+
remove_worktree: true,
|
|
359
|
+
remove_branch: 'force'
|
|
360
|
+
},
|
|
361
|
+
{ actor_type: 'system', actor_id: 'cleanup:force' }
|
|
362
|
+
);
|
|
363
|
+
expect(forceDelete.ok).toBe(true);
|
|
364
|
+
expect(forceDelete.data.summary.branch_removed).toBe(true);
|
|
365
|
+
|
|
366
|
+
const branchLookup = await runGit(repoRoot, ['show-ref', '--verify', 'refs/heads/feature_branch_cleanup']);
|
|
367
|
+
expect(branchLookup.code).not.toBe(0);
|
|
368
|
+
});
|
|
369
|
+
});
|
|
@@ -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 { ok } from '../src/core/response.js';
|
|
6
|
+
import { ERROR_CODES } from '../src/core/error-codes.js';
|
|
7
|
+
import { McpServerAdapter } from '../src/index.js';
|
|
8
|
+
import { OperationLedger } from '../src/mcp/operation-ledger.js';
|
|
9
|
+
import { ToolAuthorizer } from '../src/mcp/tool-authorizer.js';
|
|
10
|
+
import { ToolContractValidator } from '../src/mcp/tool-contract-validator.js';
|
|
11
|
+
|
|
12
|
+
describe('McpServerAdapter helpers', () => {
|
|
13
|
+
it('GIVEN_valid_token_and_empty_arguments_WHEN_calling_tool_THEN_forwards_claims', async () => {
|
|
14
|
+
const runtime = {
|
|
15
|
+
listTools: vi.fn(async () => [{ name: 'report.dashboard' }]),
|
|
16
|
+
callTool: vi.fn(async () => ok({ accepted: true }))
|
|
17
|
+
};
|
|
18
|
+
const auth = {
|
|
19
|
+
verifyToken: vi.fn(() => ({
|
|
20
|
+
run_id: 'run-1',
|
|
21
|
+
session_id: 'session-1',
|
|
22
|
+
actor_type: 'orchestrator',
|
|
23
|
+
actor_id: 'actor-1',
|
|
24
|
+
issued_at: new Date().toISOString(),
|
|
25
|
+
expires_at: new Date(Date.now() + 60_000).toISOString()
|
|
26
|
+
}))
|
|
27
|
+
};
|
|
28
|
+
const adapter = new McpServerAdapter(runtime as any, auth as any);
|
|
29
|
+
|
|
30
|
+
await expect(adapter.toolsList()).resolves.toEqual({ tools: [{ name: 'report.dashboard' }] });
|
|
31
|
+
const response = await adapter.toolsCall({ name: 'report.dashboard' });
|
|
32
|
+
|
|
33
|
+
expect(response).toMatchObject({ ok: true, data: { accepted: true } });
|
|
34
|
+
expect(runtime.callTool).toHaveBeenCalledWith(
|
|
35
|
+
'report.dashboard',
|
|
36
|
+
{},
|
|
37
|
+
expect.objectContaining({ actor_type: 'orchestrator', actor_id: 'actor-1' })
|
|
38
|
+
);
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
it('GIVEN_mismatched_actor_claim_or_normalized_error_WHEN_calling_tool_THEN_returns_expected_failure', async () => {
|
|
42
|
+
const runtime = {
|
|
43
|
+
callTool: vi.fn()
|
|
44
|
+
};
|
|
45
|
+
const auth = {
|
|
46
|
+
verifyToken: vi.fn(() => ({
|
|
47
|
+
run_id: 'run-1',
|
|
48
|
+
session_id: 'session-1',
|
|
49
|
+
actor_type: 'orchestrator',
|
|
50
|
+
actor_id: 'actor-1',
|
|
51
|
+
issued_at: new Date().toISOString(),
|
|
52
|
+
expires_at: new Date(Date.now() + 60_000).toISOString()
|
|
53
|
+
}))
|
|
54
|
+
};
|
|
55
|
+
const adapter = new McpServerAdapter(runtime as any, auth as any);
|
|
56
|
+
|
|
57
|
+
const mismatch = await adapter.toolsCall({
|
|
58
|
+
name: 'report.dashboard',
|
|
59
|
+
arguments: { actor_id: 'other-actor' }
|
|
60
|
+
});
|
|
61
|
+
expect(mismatch).toMatchObject({
|
|
62
|
+
ok: false,
|
|
63
|
+
error: { code: ERROR_CODES.INVALID_ACTOR_CLAIM }
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
auth.verifyToken = vi.fn(() => {
|
|
67
|
+
throw {
|
|
68
|
+
normalizedResponse: {
|
|
69
|
+
ok: false,
|
|
70
|
+
error: { code: 'normalized_error' }
|
|
71
|
+
}
|
|
72
|
+
};
|
|
73
|
+
});
|
|
74
|
+
const normalized = await adapter.toolsCall({ name: 'report.dashboard', arguments: {} });
|
|
75
|
+
expect(normalized).toMatchObject({
|
|
76
|
+
ok: false,
|
|
77
|
+
error: { code: 'normalized_error' }
|
|
78
|
+
});
|
|
79
|
+
|
|
80
|
+
auth.verifyToken = vi.fn(() => {
|
|
81
|
+
throw new Error('invalid signature');
|
|
82
|
+
});
|
|
83
|
+
const unauthenticated = await adapter.toolsCall({ name: 'report.dashboard', arguments: {} });
|
|
84
|
+
expect(unauthenticated).toMatchObject({
|
|
85
|
+
ok: false,
|
|
86
|
+
error: { code: ERROR_CODES.UNAUTHENTICATED }
|
|
87
|
+
});
|
|
88
|
+
});
|
|
89
|
+
});
|
|
90
|
+
|
|
91
|
+
describe('OperationLedger', () => {
|
|
92
|
+
let repoRoot = '';
|
|
93
|
+
|
|
94
|
+
afterEach(async () => {
|
|
95
|
+
if (repoRoot) {
|
|
96
|
+
await fs.rm(repoRoot, { recursive: true, force: true });
|
|
97
|
+
repoRoot = '';
|
|
98
|
+
}
|
|
99
|
+
vi.restoreAllMocks();
|
|
100
|
+
});
|
|
101
|
+
|
|
102
|
+
it('GIVEN_missing_ledger_file_WHEN_resolving_or_recording_THEN_uses_null-safe_fallbacks', async () => {
|
|
103
|
+
repoRoot = await fs.mkdtemp(path.join(os.tmpdir(), 'aop-op-ledger-'));
|
|
104
|
+
const ledger = new OperationLedger(repoRoot);
|
|
105
|
+
vi.spyOn(ledger, 'ensureRunLedger').mockResolvedValue(undefined);
|
|
106
|
+
|
|
107
|
+
await expect(ledger.resolveOperation('run-x', 'op-x', 'hash-x')).resolves.toEqual({ status: 'new' });
|
|
108
|
+
await ledger.recordOperation('run-x', 'op-x', 'feature.init', 'hash-x', ok({ initialized: true }));
|
|
109
|
+
|
|
110
|
+
const stored = JSON.parse(await fs.readFile(ledger.ledgerPath('run-x'), 'utf8'));
|
|
111
|
+
expect(stored.operations['op-x']).toMatchObject({
|
|
112
|
+
operation_id: 'op-x',
|
|
113
|
+
tool_name: 'feature.init',
|
|
114
|
+
request_hash: 'hash-x'
|
|
115
|
+
});
|
|
116
|
+
});
|
|
117
|
+
|
|
118
|
+
it('GIVEN_existing_operation_record_WHEN_recording_same_operation_THEN_preserves_created_at', async () => {
|
|
119
|
+
repoRoot = await fs.mkdtemp(path.join(os.tmpdir(), 'aop-op-ledger-'));
|
|
120
|
+
const ledger = new OperationLedger(repoRoot);
|
|
121
|
+
|
|
122
|
+
await ledger.recordOperation('run-y', 'op-y', 'feature.init', 'hash-1', ok({ first: true }));
|
|
123
|
+
const first = JSON.parse(await fs.readFile(ledger.ledgerPath('run-y'), 'utf8'));
|
|
124
|
+
const createdAt = first.operations['op-y'].created_at;
|
|
125
|
+
|
|
126
|
+
await ledger.recordOperation('run-y', 'op-y', 'feature.init', 'hash-2', ok({ second: true }));
|
|
127
|
+
const second = JSON.parse(await fs.readFile(ledger.ledgerPath('run-y'), 'utf8'));
|
|
128
|
+
|
|
129
|
+
expect(second.operations['op-y'].created_at).toBe(createdAt);
|
|
130
|
+
expect(second.operations['op-y'].request_hash).toBe('hash-2');
|
|
131
|
+
});
|
|
132
|
+
});
|
|
133
|
+
|
|
134
|
+
describe('ToolAuthorizer', () => {
|
|
135
|
+
const registry = {
|
|
136
|
+
toolsByName: new Map([
|
|
137
|
+
['report.dashboard', { supported_roles: ['orchestrator'] }],
|
|
138
|
+
['feature.init', { supported_roles: ['orchestrator', 'system'] }]
|
|
139
|
+
])
|
|
140
|
+
};
|
|
141
|
+
|
|
142
|
+
it('GIVEN_missing_tool_or_role_allowlist_WHEN_authorizing_THEN_returns_false', () => {
|
|
143
|
+
const authorizer = new ToolAuthorizer({}, registry as any);
|
|
144
|
+
expect(authorizer.isAuthorized('orchestrator', 'missing.tool')).toBe(false);
|
|
145
|
+
expect(authorizer.isAuthorized('qa', 'report.dashboard')).toBe(false);
|
|
146
|
+
});
|
|
147
|
+
|
|
148
|
+
it('GIVEN_policy_references_unknown_tool_WHEN_constructing_THEN_throws', () => {
|
|
149
|
+
expect(() => new ToolAuthorizer({ orchestrator: ['missing.tool'] }, registry as any)).toThrow(
|
|
150
|
+
'policy_references_unknown_tool:orchestrator:missing.tool'
|
|
151
|
+
);
|
|
152
|
+
});
|
|
153
|
+
});
|
|
154
|
+
|
|
155
|
+
describe('ToolContractValidator', () => {
|
|
156
|
+
it('GIVEN_invalid_input_or_output_payload_WHEN_validating_THEN_returns_errors', async () => {
|
|
157
|
+
const loader = {
|
|
158
|
+
readErrorsSchema: vi.fn(async () => ({
|
|
159
|
+
type: 'object',
|
|
160
|
+
required: ['ok'],
|
|
161
|
+
properties: { ok: { type: 'boolean' } }
|
|
162
|
+
})),
|
|
163
|
+
readSchemaByRef: vi.fn(async (schemaRef: string) => {
|
|
164
|
+
if (schemaRef.includes('input')) {
|
|
165
|
+
return {
|
|
166
|
+
type: 'object',
|
|
167
|
+
required: ['id'],
|
|
168
|
+
properties: { id: { type: 'string' } }
|
|
169
|
+
};
|
|
170
|
+
}
|
|
171
|
+
return {
|
|
172
|
+
type: 'object',
|
|
173
|
+
required: ['result'],
|
|
174
|
+
properties: { result: { type: 'string' } }
|
|
175
|
+
};
|
|
176
|
+
})
|
|
177
|
+
};
|
|
178
|
+
const registry = {
|
|
179
|
+
toolsRoot: '/tmp'
|
|
180
|
+
};
|
|
181
|
+
const tool = {
|
|
182
|
+
input_schema_ref: 'schemas/input/tool.schema.json',
|
|
183
|
+
output_schema_ref: 'schemas/output/tool.schema.json'
|
|
184
|
+
};
|
|
185
|
+
|
|
186
|
+
const validator = await ToolContractValidator.create(loader as any, registry as any);
|
|
187
|
+
const invalidInput = await validator.validateInput(tool as any, {});
|
|
188
|
+
const invalidOutput = await validator.validateOutput(tool as any, {});
|
|
189
|
+
|
|
190
|
+
expect(invalidInput.valid).toBe(false);
|
|
191
|
+
expect(invalidInput.errors.length).toBeGreaterThan(0);
|
|
192
|
+
expect(invalidOutput.valid).toBe(false);
|
|
193
|
+
expect(invalidOutput.errors.length).toBeGreaterThan(0);
|
|
194
|
+
});
|
|
195
|
+
});
|