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,222 @@
|
|
|
1
|
+
import fs from 'node:fs/promises';
|
|
2
|
+
import path from 'node:path';
|
|
3
|
+
import { beforeEach, describe, expect, it } from 'vitest';
|
|
4
|
+
import { AopKernel } from '../src/index.js';
|
|
5
|
+
import { makeTempRepo, writeFeatureSpec } from './helpers.js';
|
|
6
|
+
|
|
7
|
+
const ORCHESTRATOR_CONTEXT = { actor_type: 'orchestrator', actor_id: 'test' };
|
|
8
|
+
|
|
9
|
+
let repoRoot: string;
|
|
10
|
+
|
|
11
|
+
beforeEach(async () => {
|
|
12
|
+
repoRoot = await makeTempRepo(process.cwd());
|
|
13
|
+
await fs.mkdir(path.join(repoRoot, 'src'), { recursive: true });
|
|
14
|
+
await fs.writeFile(path.join(repoRoot, 'src', 'shared.txt'), 'shared\n', 'utf8');
|
|
15
|
+
await fs.writeFile(path.join(repoRoot, 'src', 'leader.txt'), 'leader\n', 'utf8');
|
|
16
|
+
await fs.writeFile(path.join(repoRoot, 'src', 'unique-b.txt'), 'b\n', 'utf8');
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
function buildPlan(featureId: string, planVersion: number, modifyPath: string, revisionOf: number | null = null) {
|
|
20
|
+
const plan = {
|
|
21
|
+
feature_id: featureId,
|
|
22
|
+
plan_version: planVersion,
|
|
23
|
+
summary: `Plan ${featureId} v${planVersion}`,
|
|
24
|
+
allowed_areas: ['src'],
|
|
25
|
+
forbidden_areas: [],
|
|
26
|
+
base_ref: 'HEAD',
|
|
27
|
+
files: {
|
|
28
|
+
create: [],
|
|
29
|
+
modify: [modifyPath],
|
|
30
|
+
delete: []
|
|
31
|
+
},
|
|
32
|
+
contracts: {
|
|
33
|
+
openapi: 'none',
|
|
34
|
+
events: 'none',
|
|
35
|
+
db: 'none'
|
|
36
|
+
},
|
|
37
|
+
acceptance_criteria: ['Deterministic plan is accepted'],
|
|
38
|
+
gate_profile: 'default'
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
if (revisionOf != null) {
|
|
42
|
+
(plan as any).revision_of = revisionOf;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
return plan;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
async function initFeature(kernel: AopKernel, featureId: string) {
|
|
49
|
+
await writeFeatureSpec(repoRoot, featureId);
|
|
50
|
+
const init = await kernel.invoke('feature.init', { feature_id: featureId }, ORCHESTRATOR_CONTEXT);
|
|
51
|
+
expect(init.ok).toBe(true);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
describe('AopKernel collision queue replay integration', () => {
|
|
55
|
+
it('persists blocked queue entries with required collision fields under collision_policy=block', async () => {
|
|
56
|
+
const kernel = new AopKernel(repoRoot);
|
|
57
|
+
await kernel.ensureLoaded();
|
|
58
|
+
kernel.policy.collision_policy = 'block';
|
|
59
|
+
|
|
60
|
+
await initFeature(kernel, 'feature_a');
|
|
61
|
+
await initFeature(kernel, 'feature_b');
|
|
62
|
+
|
|
63
|
+
const accepted = await kernel.invoke(
|
|
64
|
+
'plan.submit',
|
|
65
|
+
{
|
|
66
|
+
feature_id: 'feature_a',
|
|
67
|
+
plan_json: buildPlan('feature_a', 1, 'src/shared.txt')
|
|
68
|
+
},
|
|
69
|
+
ORCHESTRATOR_CONTEXT
|
|
70
|
+
);
|
|
71
|
+
expect(accepted.ok).toBe(true);
|
|
72
|
+
|
|
73
|
+
const queued = await kernel.invoke(
|
|
74
|
+
'plan.submit',
|
|
75
|
+
{
|
|
76
|
+
feature_id: 'feature_b',
|
|
77
|
+
plan_json: buildPlan('feature_b', 1, 'src/shared.txt')
|
|
78
|
+
},
|
|
79
|
+
ORCHESTRATOR_CONTEXT
|
|
80
|
+
);
|
|
81
|
+
expect(queued.ok).toBe(false);
|
|
82
|
+
expect(queued.error.code).toBe('blocked_by_collision_policy');
|
|
83
|
+
|
|
84
|
+
const index = await kernel.readIndex();
|
|
85
|
+
expect(index.blocked_queue).toHaveLength(1);
|
|
86
|
+
expect(index.blocked_queue[0]).toMatchObject({
|
|
87
|
+
feature_id: 'feature_b',
|
|
88
|
+
plan_version: 1,
|
|
89
|
+
collision_fingerprint: expect.any(String),
|
|
90
|
+
detected_at: expect.any(String),
|
|
91
|
+
required_resources: expect.any(Array)
|
|
92
|
+
});
|
|
93
|
+
});
|
|
94
|
+
|
|
95
|
+
it('replays blocked queue deterministically when lock release triggers collision re-drive', async () => {
|
|
96
|
+
const kernel = new AopKernel(repoRoot);
|
|
97
|
+
await kernel.ensureLoaded();
|
|
98
|
+
kernel.policy.collision_policy = 'block';
|
|
99
|
+
|
|
100
|
+
for (const featureId of ['feature_a', 'feature_b', 'feature_c']) {
|
|
101
|
+
await initFeature(kernel, featureId);
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
const lockAcquire = await kernel.invoke(
|
|
105
|
+
'locks.acquire',
|
|
106
|
+
{ resource: 'openapi', feature_id: 'feature_a' },
|
|
107
|
+
ORCHESTRATOR_CONTEXT
|
|
108
|
+
);
|
|
109
|
+
expect(lockAcquire.ok).toBe(true);
|
|
110
|
+
|
|
111
|
+
const acceptedA1 = await kernel.invoke(
|
|
112
|
+
'plan.submit',
|
|
113
|
+
{
|
|
114
|
+
feature_id: 'feature_a',
|
|
115
|
+
plan_json: buildPlan('feature_a', 1, 'src/shared.txt')
|
|
116
|
+
},
|
|
117
|
+
ORCHESTRATOR_CONTEXT
|
|
118
|
+
);
|
|
119
|
+
expect(acceptedA1.ok).toBe(true);
|
|
120
|
+
|
|
121
|
+
const queuedB = await kernel.invoke(
|
|
122
|
+
'plan.submit',
|
|
123
|
+
{
|
|
124
|
+
feature_id: 'feature_b',
|
|
125
|
+
plan_json: buildPlan('feature_b', 1, 'src/shared.txt')
|
|
126
|
+
},
|
|
127
|
+
ORCHESTRATOR_CONTEXT
|
|
128
|
+
);
|
|
129
|
+
expect(queuedB.ok).toBe(false);
|
|
130
|
+
expect(queuedB.error.code).toBe('blocked_by_collision_policy');
|
|
131
|
+
|
|
132
|
+
const queuedC = await kernel.invoke(
|
|
133
|
+
'plan.submit',
|
|
134
|
+
{
|
|
135
|
+
feature_id: 'feature_c',
|
|
136
|
+
plan_json: buildPlan('feature_c', 1, 'src/shared.txt')
|
|
137
|
+
},
|
|
138
|
+
ORCHESTRATOR_CONTEXT
|
|
139
|
+
);
|
|
140
|
+
expect(queuedC.ok).toBe(false);
|
|
141
|
+
expect(queuedC.error.code).toBe('blocked_by_collision_policy');
|
|
142
|
+
|
|
143
|
+
const acceptedA2 = await kernel.invoke(
|
|
144
|
+
'plan.update',
|
|
145
|
+
{
|
|
146
|
+
feature_id: 'feature_a',
|
|
147
|
+
expected_plan_version: 1,
|
|
148
|
+
plan_json: buildPlan('feature_a', 2, 'src/leader.txt', 1)
|
|
149
|
+
},
|
|
150
|
+
ORCHESTRATOR_CONTEXT
|
|
151
|
+
);
|
|
152
|
+
expect(acceptedA2.ok).toBe(true);
|
|
153
|
+
|
|
154
|
+
const queueSeedIndex = await kernel.readIndex();
|
|
155
|
+
expect(queueSeedIndex.blocked_queue).toHaveLength(2);
|
|
156
|
+
const seeded = {
|
|
157
|
+
...queueSeedIndex,
|
|
158
|
+
blocked_queue: queueSeedIndex.blocked_queue.map((entry: any) => ({
|
|
159
|
+
...entry,
|
|
160
|
+
detected_at: '2026-02-28T12:00:00Z'
|
|
161
|
+
}))
|
|
162
|
+
};
|
|
163
|
+
await kernel.writeIndex(seeded);
|
|
164
|
+
|
|
165
|
+
const beforeFirstReplayVersion = (await kernel.readIndex()).version;
|
|
166
|
+
|
|
167
|
+
const firstReplayTrigger = await kernel.invoke(
|
|
168
|
+
'locks.release',
|
|
169
|
+
{ resource: 'openapi', feature_id: 'feature_a' },
|
|
170
|
+
ORCHESTRATOR_CONTEXT
|
|
171
|
+
);
|
|
172
|
+
expect(firstReplayTrigger.ok).toBe(true);
|
|
173
|
+
|
|
174
|
+
const afterFirstReplay = await kernel.readIndex();
|
|
175
|
+
expect(afterFirstReplay.version).toBeGreaterThan(beforeFirstReplayVersion);
|
|
176
|
+
expect(afterFirstReplay.blocked_queue).toHaveLength(1);
|
|
177
|
+
expect(afterFirstReplay.blocked_queue[0].feature_id).toBe('feature_c');
|
|
178
|
+
|
|
179
|
+
const planB = await kernel.invoke('plan.get', { feature_id: 'feature_b' }, ORCHESTRATOR_CONTEXT);
|
|
180
|
+
expect(planB.ok).toBe(true);
|
|
181
|
+
expect(planB.data.plan.plan_version).toBe(1);
|
|
182
|
+
|
|
183
|
+
const acceptedB2 = await kernel.invoke(
|
|
184
|
+
'plan.update',
|
|
185
|
+
{
|
|
186
|
+
feature_id: 'feature_b',
|
|
187
|
+
expected_plan_version: 1,
|
|
188
|
+
plan_json: buildPlan('feature_b', 2, 'src/unique-b.txt', 1)
|
|
189
|
+
},
|
|
190
|
+
ORCHESTRATOR_CONTEXT
|
|
191
|
+
);
|
|
192
|
+
expect(acceptedB2.ok).toBe(true);
|
|
193
|
+
|
|
194
|
+
const secondAcquire = await kernel.invoke(
|
|
195
|
+
'locks.acquire',
|
|
196
|
+
{ resource: 'openapi', feature_id: 'feature_a' },
|
|
197
|
+
ORCHESTRATOR_CONTEXT
|
|
198
|
+
);
|
|
199
|
+
expect(secondAcquire.ok).toBe(true);
|
|
200
|
+
|
|
201
|
+
const secondReplayTrigger = await kernel.invoke(
|
|
202
|
+
'locks.release',
|
|
203
|
+
{ resource: 'openapi', feature_id: 'feature_a' },
|
|
204
|
+
ORCHESTRATOR_CONTEXT
|
|
205
|
+
);
|
|
206
|
+
expect(secondReplayTrigger.ok).toBe(true);
|
|
207
|
+
|
|
208
|
+
const afterSecondReplay = await kernel.readIndex();
|
|
209
|
+
expect(afterSecondReplay.blocked_queue).toHaveLength(0);
|
|
210
|
+
|
|
211
|
+
const planC = await kernel.invoke('plan.get', { feature_id: 'feature_c' }, ORCHESTRATOR_CONTEXT);
|
|
212
|
+
expect(planC.ok).toBe(true);
|
|
213
|
+
expect(planC.data.plan.plan_version).toBe(1);
|
|
214
|
+
|
|
215
|
+
const stateB = await kernel.invoke('feature.state_get', { feature_id: 'feature_b' }, ORCHESTRATOR_CONTEXT);
|
|
216
|
+
const stateC = await kernel.invoke('feature.state_get', { feature_id: 'feature_c' }, ORCHESTRATOR_CONTEXT);
|
|
217
|
+
expect(stateB.ok).toBe(true);
|
|
218
|
+
expect(stateC.ok).toBe(true);
|
|
219
|
+
expect(stateB.data.front_matter.version).toBeGreaterThan(1);
|
|
220
|
+
expect(stateC.data.front_matter.version).toBeGreaterThan(1);
|
|
221
|
+
});
|
|
222
|
+
});
|
|
@@ -0,0 +1,321 @@
|
|
|
1
|
+
import fs from 'node:fs/promises';
|
|
2
|
+
import path from 'node:path';
|
|
3
|
+
import { beforeEach, describe, expect, it } from 'vitest';
|
|
4
|
+
import { AopKernel } from '../src/index.js';
|
|
5
|
+
import { runGit } from '../src/core/git.js';
|
|
6
|
+
import { ERROR_CODES } from '../src/core/error-codes.js';
|
|
7
|
+
import { STATUS } from '../src/core/constants.js';
|
|
8
|
+
import { makeTempRepo, writeFeatureSpec } from './helpers.js';
|
|
9
|
+
|
|
10
|
+
const ORCH = { actor_type: 'orchestrator', actor_id: 'orch:test' };
|
|
11
|
+
const BUILDER = { actor_type: 'builder', actor_id: 'builder:test' };
|
|
12
|
+
|
|
13
|
+
let repoRoot: string;
|
|
14
|
+
|
|
15
|
+
async function writeBranchGates(root: string): Promise<void> {
|
|
16
|
+
const gatesPath = path.join(root, 'agentic', 'orchestrator', 'gates.yaml');
|
|
17
|
+
await fs.writeFile(
|
|
18
|
+
gatesPath,
|
|
19
|
+
[
|
|
20
|
+
'version: 1',
|
|
21
|
+
'profiles:',
|
|
22
|
+
' default:',
|
|
23
|
+
' modes:',
|
|
24
|
+
' fast:',
|
|
25
|
+
' - name: fast_pass',
|
|
26
|
+
' cmd: ["node", "-e", "process.exit(0)"]',
|
|
27
|
+
' full:',
|
|
28
|
+
' - name: full_pass',
|
|
29
|
+
' cmd: ["node", "-e", "process.exit(0)"]',
|
|
30
|
+
' merge:',
|
|
31
|
+
' - name: merge_pass',
|
|
32
|
+
' cmd: ["node", "-e", "process.exit(0)"]',
|
|
33
|
+
' parsers:',
|
|
34
|
+
' coverage:',
|
|
35
|
+
' type: none',
|
|
36
|
+
' failing:',
|
|
37
|
+
' modes:',
|
|
38
|
+
' fast:',
|
|
39
|
+
' - name: fast_fail',
|
|
40
|
+
' cmd: ["node", "-e", "process.exit(1)"]',
|
|
41
|
+
' parsers:',
|
|
42
|
+
' coverage:',
|
|
43
|
+
' type: none',
|
|
44
|
+
' coverage_low:',
|
|
45
|
+
' modes:',
|
|
46
|
+
' full:',
|
|
47
|
+
' - name: tests',
|
|
48
|
+
' cmd: ["node", "-e", "process.exit(0)"]',
|
|
49
|
+
' parsers:',
|
|
50
|
+
' coverage:',
|
|
51
|
+
' type: lcov',
|
|
52
|
+
' path: coverage/lcov.info',
|
|
53
|
+
'capabilities:',
|
|
54
|
+
' - none',
|
|
55
|
+
' - lcov'
|
|
56
|
+
].join('\n'),
|
|
57
|
+
'utf8'
|
|
58
|
+
);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
function validPlan(featureId: string) {
|
|
62
|
+
return {
|
|
63
|
+
feature_id: featureId,
|
|
64
|
+
plan_version: 1,
|
|
65
|
+
summary: 'Valid plan',
|
|
66
|
+
allowed_areas: ['src'],
|
|
67
|
+
forbidden_areas: [],
|
|
68
|
+
base_ref: 'HEAD',
|
|
69
|
+
files: { create: [], modify: ['src/sample.txt'], delete: [] },
|
|
70
|
+
contracts: { openapi: 'none', events: 'none', db: 'none' },
|
|
71
|
+
acceptance_criteria: ['works'],
|
|
72
|
+
gate_profile: 'default'
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
beforeEach(async () => {
|
|
77
|
+
repoRoot = await makeTempRepo(process.cwd());
|
|
78
|
+
await writeBranchGates(repoRoot);
|
|
79
|
+
await fs.mkdir(path.join(repoRoot, 'src'), { recursive: true });
|
|
80
|
+
await fs.writeFile(path.join(repoRoot, 'src', 'sample.txt'), 'hello\n', 'utf8');
|
|
81
|
+
await runGit(repoRoot, ['add', '.']);
|
|
82
|
+
await runGit(repoRoot, ['commit', '-m', 'fixture']);
|
|
83
|
+
});
|
|
84
|
+
|
|
85
|
+
describe('AopKernel branch behavior', () => {
|
|
86
|
+
it('covers authorization, plan validation, revision conflicts, and reject collisions', async () => {
|
|
87
|
+
const kernel = new AopKernel(repoRoot);
|
|
88
|
+
await kernel.ensureLoaded();
|
|
89
|
+
|
|
90
|
+
const forbiddenUnknownActor = await kernel.invoke('feature.init', { feature_id: 'x' }, { actor_type: 'unknown', actor_id: 'x' });
|
|
91
|
+
expect(forbiddenUnknownActor.ok).toBe(false);
|
|
92
|
+
expect(forbiddenUnknownActor.error.code).toBe(ERROR_CODES.FORBIDDEN_TOOL_FOR_ROLE);
|
|
93
|
+
|
|
94
|
+
const forbiddenRoleTool = await kernel.invoke(
|
|
95
|
+
'repo.status',
|
|
96
|
+
{ feature_id: 'x' },
|
|
97
|
+
{ actor_type: 'planner', actor_id: 'planner:test' }
|
|
98
|
+
);
|
|
99
|
+
expect(forbiddenRoleTool.ok).toBe(false);
|
|
100
|
+
expect(forbiddenRoleTool.error.code).toBe(ERROR_CODES.FORBIDDEN_TOOL_FOR_ROLE);
|
|
101
|
+
|
|
102
|
+
const missingFeatureId = await kernel.invoke('feature.init', {}, ORCH);
|
|
103
|
+
expect(missingFeatureId.ok).toBe(false);
|
|
104
|
+
expect(missingFeatureId.error.code).toBe(ERROR_CODES.INVALID_ARGUMENT);
|
|
105
|
+
|
|
106
|
+
await writeFeatureSpec(repoRoot, 'feature_a');
|
|
107
|
+
await writeFeatureSpec(repoRoot, 'feature_b');
|
|
108
|
+
await kernel.invoke('feature.init', { feature_id: 'feature_a' }, ORCH);
|
|
109
|
+
await kernel.invoke('feature.init', { feature_id: 'feature_b' }, ORCH);
|
|
110
|
+
|
|
111
|
+
const invalidSchema = await kernel.invoke(
|
|
112
|
+
'plan.submit',
|
|
113
|
+
{ feature_id: 'feature_a', plan_json: { feature_id: 'feature_a' } },
|
|
114
|
+
ORCH
|
|
115
|
+
);
|
|
116
|
+
expect(invalidSchema.ok).toBe(false);
|
|
117
|
+
expect(invalidSchema.error.code).toBe(ERROR_CODES.PLAN_VALIDATION_FAILED);
|
|
118
|
+
|
|
119
|
+
const invalidInitialVersion = await kernel.invoke(
|
|
120
|
+
'plan.submit',
|
|
121
|
+
{
|
|
122
|
+
feature_id: 'feature_a',
|
|
123
|
+
plan_json: {
|
|
124
|
+
...validPlan('feature_a'),
|
|
125
|
+
plan_version: 2
|
|
126
|
+
}
|
|
127
|
+
},
|
|
128
|
+
ORCH
|
|
129
|
+
);
|
|
130
|
+
expect(invalidInitialVersion.ok).toBe(false);
|
|
131
|
+
expect(invalidInitialVersion.error.code).toBe(ERROR_CODES.PLAN_VALIDATION_FAILED);
|
|
132
|
+
|
|
133
|
+
const accepted = await kernel.invoke(
|
|
134
|
+
'plan.submit',
|
|
135
|
+
{ feature_id: 'feature_a', plan_json: validPlan('feature_a') },
|
|
136
|
+
ORCH
|
|
137
|
+
);
|
|
138
|
+
expect(accepted.ok).toBe(true);
|
|
139
|
+
|
|
140
|
+
const versionConflict = await kernel.invoke(
|
|
141
|
+
'plan.update',
|
|
142
|
+
{
|
|
143
|
+
feature_id: 'feature_a',
|
|
144
|
+
expected_plan_version: 2,
|
|
145
|
+
plan_json: {
|
|
146
|
+
...validPlan('feature_a'),
|
|
147
|
+
plan_version: 3,
|
|
148
|
+
revision_of: 2
|
|
149
|
+
}
|
|
150
|
+
},
|
|
151
|
+
ORCH
|
|
152
|
+
);
|
|
153
|
+
expect(versionConflict.ok).toBe(false);
|
|
154
|
+
expect(versionConflict.error.code).toBe(ERROR_CODES.VERSION_CONFLICT);
|
|
155
|
+
|
|
156
|
+
const invalidRevisionMetadata = await kernel.invoke(
|
|
157
|
+
'plan.update',
|
|
158
|
+
{
|
|
159
|
+
feature_id: 'feature_a',
|
|
160
|
+
expected_plan_version: 1,
|
|
161
|
+
plan_json: {
|
|
162
|
+
...validPlan('feature_a'),
|
|
163
|
+
plan_version: 3,
|
|
164
|
+
revision_of: 1
|
|
165
|
+
}
|
|
166
|
+
},
|
|
167
|
+
ORCH
|
|
168
|
+
);
|
|
169
|
+
expect(invalidRevisionMetadata.ok).toBe(false);
|
|
170
|
+
expect(invalidRevisionMetadata.error.code).toBe(ERROR_CODES.PLAN_VALIDATION_FAILED);
|
|
171
|
+
|
|
172
|
+
const collisionRejected = await kernel.invoke(
|
|
173
|
+
'plan.submit',
|
|
174
|
+
{ feature_id: 'feature_b', plan_json: validPlan('feature_b') },
|
|
175
|
+
ORCH
|
|
176
|
+
);
|
|
177
|
+
expect(collisionRejected.ok).toBe(false);
|
|
178
|
+
expect(collisionRejected.error.code).toBe(ERROR_CODES.COLLISION_DETECTED);
|
|
179
|
+
});
|
|
180
|
+
|
|
181
|
+
it('covers repo, QA index, evidence, and gate failure branches', async () => {
|
|
182
|
+
const kernel = new AopKernel(repoRoot);
|
|
183
|
+
await kernel.ensureLoaded();
|
|
184
|
+
|
|
185
|
+
await writeFeatureSpec(repoRoot, 'feature_c');
|
|
186
|
+
await writeFeatureSpec(repoRoot, 'feature_uninit');
|
|
187
|
+
await kernel.invoke('feature.init', { feature_id: 'feature_c' }, ORCH);
|
|
188
|
+
|
|
189
|
+
const noPlanPatch = await kernel.invoke(
|
|
190
|
+
'repo.apply_patch',
|
|
191
|
+
{ feature_id: 'feature_c', unified_diff: 'diff --git a/x b/x' },
|
|
192
|
+
BUILDER
|
|
193
|
+
);
|
|
194
|
+
expect(noPlanPatch.ok).toBe(false);
|
|
195
|
+
expect(noPlanPatch.error.code).toBe(ERROR_CODES.PLAN_REQUIRED);
|
|
196
|
+
|
|
197
|
+
await kernel.invoke('plan.submit', { feature_id: 'feature_c', plan_json: validPlan('feature_c') }, ORCH);
|
|
198
|
+
|
|
199
|
+
const badPatch = await kernel.invoke(
|
|
200
|
+
'repo.apply_patch',
|
|
201
|
+
{ feature_id: 'feature_c', unified_diff: 'not a patch' },
|
|
202
|
+
BUILDER
|
|
203
|
+
);
|
|
204
|
+
expect(badPatch.ok).toBe(false);
|
|
205
|
+
expect(badPatch.error.code).toBe(ERROR_CODES.GIT_FAILURE);
|
|
206
|
+
|
|
207
|
+
const evidenceMissing = await kernel.invoke('evidence.latest', { feature_id: 'feature_uninit' }, ORCH);
|
|
208
|
+
expect(evidenceMissing.ok).toBe(true);
|
|
209
|
+
expect(evidenceMissing.data.latest).toBeNull();
|
|
210
|
+
|
|
211
|
+
const qaPath = path.join(repoRoot, '.aop', 'features', 'feature_c', 'qa_test_index.json');
|
|
212
|
+
await fs.writeFile(qaPath, '{}\n', 'utf8');
|
|
213
|
+
const invalidQaIndex = await kernel.invoke('qa.test_index_get', { feature_id: 'feature_c' }, ORCH);
|
|
214
|
+
expect(invalidQaIndex.ok).toBe(false);
|
|
215
|
+
expect(invalidQaIndex.error.code).toBe(ERROR_CODES.INTERNAL_ERROR);
|
|
216
|
+
|
|
217
|
+
await fs.rm(qaPath, { force: true });
|
|
218
|
+
const missingQaIndex = await kernel.invoke(
|
|
219
|
+
'qa.test_index_update',
|
|
220
|
+
{ feature_id: 'feature_c', expected_version: 1, updates: [] },
|
|
221
|
+
{ actor_type: 'qa', actor_id: 'qa:test' }
|
|
222
|
+
);
|
|
223
|
+
expect(missingQaIndex.ok).toBe(false);
|
|
224
|
+
expect(missingQaIndex.error.code).toBe(ERROR_CODES.FILE_NOT_FOUND);
|
|
225
|
+
|
|
226
|
+
const coverageDir = path.join(repoRoot, '.worktrees', 'feature_c', 'coverage');
|
|
227
|
+
await fs.mkdir(coverageDir, { recursive: true });
|
|
228
|
+
await fs.writeFile(
|
|
229
|
+
path.join(coverageDir, 'lcov.info'),
|
|
230
|
+
['TN:', 'SF:src/a.ts', 'LF:20', 'LH:10', 'BRF:10', 'BRH:2', 'end_of_record', ''].join('\n'),
|
|
231
|
+
'utf8'
|
|
232
|
+
);
|
|
233
|
+
|
|
234
|
+
const coverageFail = await kernel.invoke(
|
|
235
|
+
'gates.run',
|
|
236
|
+
{ feature_id: 'feature_c', profile: 'coverage_low', mode: 'full' },
|
|
237
|
+
BUILDER
|
|
238
|
+
);
|
|
239
|
+
expect(coverageFail.ok).toBe(false);
|
|
240
|
+
expect(coverageFail.error.code).toBe(ERROR_CODES.COVERAGE_BELOW_MINIMUM);
|
|
241
|
+
|
|
242
|
+
const gateFail = await kernel.invoke(
|
|
243
|
+
'gates.run',
|
|
244
|
+
{ feature_id: 'feature_c', profile: 'failing', mode: 'fast' },
|
|
245
|
+
BUILDER
|
|
246
|
+
);
|
|
247
|
+
expect(gateFail.ok).toBe(true);
|
|
248
|
+
expect(gateFail.data.overall).toBe('fail');
|
|
249
|
+
|
|
250
|
+
const blockedState = await kernel.invoke('feature.state_get', { feature_id: 'feature_c' }, ORCH);
|
|
251
|
+
expect(blockedState.ok).toBe(true);
|
|
252
|
+
expect(blockedState.data.front_matter.status).toBe(STATUS.BLOCKED);
|
|
253
|
+
});
|
|
254
|
+
|
|
255
|
+
it('covers merge precondition branches for status and required gate modes', async () => {
|
|
256
|
+
const kernel = new AopKernel(repoRoot);
|
|
257
|
+
await kernel.ensureLoaded();
|
|
258
|
+
await writeFeatureSpec(repoRoot, 'feature_merge');
|
|
259
|
+
await kernel.invoke('feature.init', { feature_id: 'feature_merge' }, ORCH);
|
|
260
|
+
await kernel.invoke('plan.submit', { feature_id: 'feature_merge', plan_json: validPlan('feature_merge') }, ORCH);
|
|
261
|
+
|
|
262
|
+
const notReady = await kernel.invoke(
|
|
263
|
+
'feature.ready_to_merge',
|
|
264
|
+
{
|
|
265
|
+
feature_id: 'feature_merge',
|
|
266
|
+
commit_message: 'feat: merge',
|
|
267
|
+
merge_strategy: 'merge_commit',
|
|
268
|
+
user_approval_token: 'approved'
|
|
269
|
+
},
|
|
270
|
+
ORCH
|
|
271
|
+
);
|
|
272
|
+
expect(notReady.ok).toBe(false);
|
|
273
|
+
expect(notReady.error.code).toBe(ERROR_CODES.INVALID_STATUS_TRANSITION);
|
|
274
|
+
|
|
275
|
+
const state = await kernel.invoke('feature.state_get', { feature_id: 'feature_merge' }, ORCH);
|
|
276
|
+
expect(state.ok).toBe(true);
|
|
277
|
+
|
|
278
|
+
const toQa = await kernel.invoke(
|
|
279
|
+
'feature.state_patch',
|
|
280
|
+
{
|
|
281
|
+
feature_id: 'feature_merge',
|
|
282
|
+
expected_version: state.data.front_matter.version,
|
|
283
|
+
patch: {
|
|
284
|
+
front_matter: {
|
|
285
|
+
status: STATUS.QA
|
|
286
|
+
}
|
|
287
|
+
}
|
|
288
|
+
},
|
|
289
|
+
ORCH
|
|
290
|
+
);
|
|
291
|
+
expect(toQa.ok).toBe(true);
|
|
292
|
+
|
|
293
|
+
const toReady = await kernel.invoke(
|
|
294
|
+
'feature.state_patch',
|
|
295
|
+
{
|
|
296
|
+
feature_id: 'feature_merge',
|
|
297
|
+
expected_version: toQa.data.version,
|
|
298
|
+
patch: {
|
|
299
|
+
front_matter: {
|
|
300
|
+
status: STATUS.READY_TO_MERGE
|
|
301
|
+
}
|
|
302
|
+
}
|
|
303
|
+
},
|
|
304
|
+
ORCH
|
|
305
|
+
);
|
|
306
|
+
expect(toReady.ok).toBe(true);
|
|
307
|
+
|
|
308
|
+
const missingGatePass = await kernel.invoke(
|
|
309
|
+
'feature.ready_to_merge',
|
|
310
|
+
{
|
|
311
|
+
feature_id: 'feature_merge',
|
|
312
|
+
commit_message: 'feat: merge',
|
|
313
|
+
merge_strategy: 'merge_commit',
|
|
314
|
+
user_approval_token: 'approved'
|
|
315
|
+
},
|
|
316
|
+
ORCH
|
|
317
|
+
);
|
|
318
|
+
expect(missingGatePass.ok).toBe(false);
|
|
319
|
+
expect(missingGatePass.error.code).toBe(ERROR_CODES.MERGE_DISABLED);
|
|
320
|
+
});
|
|
321
|
+
});
|