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,302 @@
|
|
|
1
|
+
import { atomicWriteJson, nowIso, readJson } from '../../core/fs.js';
|
|
2
|
+
import { detectPlanCollisions } from '../../core/collisions.js';
|
|
3
|
+
import { sortResourcesDeterministically } from '../../core/path-rules.js';
|
|
4
|
+
import { ERROR_CODES } from '../../core/error-codes.js';
|
|
5
|
+
import { fail } from '../../core/response.js';
|
|
6
|
+
import { GATE_RESULT, STATUS } from '../../core/constants.js';
|
|
7
|
+
|
|
8
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
9
|
+
type AnyRecord = Record<string, any>;
|
|
10
|
+
|
|
11
|
+
type StateReadResult = {
|
|
12
|
+
frontMatter: AnyRecord;
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
type StateUpdater = (
|
|
16
|
+
frontMatter: AnyRecord,
|
|
17
|
+
body: string
|
|
18
|
+
) => Promise<{ frontMatter?: AnyRecord; body?: string }>;
|
|
19
|
+
|
|
20
|
+
function asArray<T = unknown>(value: unknown): T[] {
|
|
21
|
+
return Array.isArray(value) ? (value as T[]) : [];
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
function normalizeSet(array: string[]): string[] {
|
|
25
|
+
return [...new Set(array)].sort((a, b) => a.localeCompare(b));
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
function readObjectField(record: AnyRecord, key: string): AnyRecord {
|
|
29
|
+
const value = record[key];
|
|
30
|
+
return value && typeof value === 'object' ? (value as AnyRecord) : {};
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
function readHeldLocks(frontMatter: AnyRecord): string[] {
|
|
34
|
+
const locks = readObjectField(frontMatter, 'locks');
|
|
35
|
+
return asArray<string>(locks.held).filter((item) => typeof item === 'string');
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export interface PlanServicePort {
|
|
39
|
+
getPolicySnapshot(): AnyRecord;
|
|
40
|
+
planPath(featureId: string): string;
|
|
41
|
+
featureDiscoverSpecs(): Promise<{ data: { specs: Array<{ feature_id: string }> } }>;
|
|
42
|
+
readState(featureId: string): Promise<StateReadResult>;
|
|
43
|
+
validateSchema(schemaName: string, value: unknown): Promise<{ valid: boolean; errors?: unknown }>;
|
|
44
|
+
withFeatureLock<T>(featureId: string, operation: () => Promise<T>): Promise<T>;
|
|
45
|
+
withIndexLock<T>(operation: () => Promise<T>): Promise<T>;
|
|
46
|
+
readIndex(): Promise<AnyRecord>;
|
|
47
|
+
writeIndex(index: AnyRecord): Promise<void>;
|
|
48
|
+
updateState(featureId: string, expectedVersion: number | null, updater: StateUpdater): Promise<AnyRecord>;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
export class PlanService {
|
|
52
|
+
private readonly port: PlanServicePort;
|
|
53
|
+
|
|
54
|
+
constructor(port: PlanServicePort) {
|
|
55
|
+
this.port = port;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
async planGet(featureId: string): Promise<{ data: { feature_id: string; plan: unknown } }> {
|
|
59
|
+
const plan = await readJson(this.port.planPath(featureId), null);
|
|
60
|
+
return {
|
|
61
|
+
data: {
|
|
62
|
+
feature_id: featureId,
|
|
63
|
+
plan
|
|
64
|
+
}
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
async collectAcceptedPlans(excludeFeatureId: string | null = null): Promise<AnyRecord[]> {
|
|
69
|
+
const specs = await this.port.featureDiscoverSpecs();
|
|
70
|
+
const plans: AnyRecord[] = [];
|
|
71
|
+
for (const item of specs.data.specs) {
|
|
72
|
+
if (item.feature_id === excludeFeatureId) {
|
|
73
|
+
continue;
|
|
74
|
+
}
|
|
75
|
+
const plan = await readJson(this.port.planPath(item.feature_id), null);
|
|
76
|
+
if (plan) {
|
|
77
|
+
plans.push(plan);
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
return plans;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
requiredResourcesForPlan(plan: AnyRecord): string[] {
|
|
84
|
+
const resources: string[] = [];
|
|
85
|
+
const policy = this.port.getPolicySnapshot();
|
|
86
|
+
if (plan.contracts?.openapi === 'modify') {
|
|
87
|
+
resources.push(policy.locks.contract_to_resource.openapi);
|
|
88
|
+
}
|
|
89
|
+
if (plan.contracts?.events === 'modify') {
|
|
90
|
+
resources.push(policy.locks.contract_to_resource.events);
|
|
91
|
+
}
|
|
92
|
+
if (plan.contracts?.db === 'migration') {
|
|
93
|
+
resources.push(policy.locks.contract_to_resource.db);
|
|
94
|
+
}
|
|
95
|
+
return sortResourcesDeterministically(resources);
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
async assertPlanLocksHeld(featureId: string, plan: AnyRecord): Promise<void> {
|
|
99
|
+
const state = await this.port.readState(featureId);
|
|
100
|
+
const held = new Set(readHeldLocks(state.frontMatter));
|
|
101
|
+
const required = await this.requiredResourcesForPlan(plan);
|
|
102
|
+
const missing = required.filter((resource) => !held.has(resource));
|
|
103
|
+
if (missing.length > 0) {
|
|
104
|
+
throw {
|
|
105
|
+
normalizedResponse: fail(ERROR_CODES.LOCK_NOT_HELD, 'Plan requires lock(s) that are not held', {
|
|
106
|
+
feature_id: featureId,
|
|
107
|
+
missing_resources: missing,
|
|
108
|
+
retryable: true,
|
|
109
|
+
requires_human: false,
|
|
110
|
+
suggested_next_actions: ['Acquire required locks before submitting plan']
|
|
111
|
+
})
|
|
112
|
+
};
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
validatePlanRevisionRules(existingPlan: AnyRecord | null, plan: AnyRecord, expectedPlanVersion: number | null = null): void {
|
|
117
|
+
if (!existingPlan) {
|
|
118
|
+
if (plan.plan_version !== 1 || plan.revision_of != null) {
|
|
119
|
+
throw {
|
|
120
|
+
normalizedResponse: fail(ERROR_CODES.PLAN_VALIDATION_FAILED, 'Initial plan must be version 1 without revision_of', {
|
|
121
|
+
retryable: false,
|
|
122
|
+
requires_human: true
|
|
123
|
+
})
|
|
124
|
+
};
|
|
125
|
+
}
|
|
126
|
+
return;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
if (expectedPlanVersion == null || existingPlan.plan_version !== expectedPlanVersion) {
|
|
130
|
+
throw {
|
|
131
|
+
normalizedResponse: fail(ERROR_CODES.VERSION_CONFLICT, 'Plan version conflict', {
|
|
132
|
+
expected_plan_version: expectedPlanVersion,
|
|
133
|
+
actual_plan_version: existingPlan.plan_version,
|
|
134
|
+
retryable: true,
|
|
135
|
+
requires_human: false
|
|
136
|
+
})
|
|
137
|
+
};
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
if (plan.plan_version !== expectedPlanVersion + 1 || plan.revision_of !== expectedPlanVersion) {
|
|
141
|
+
throw {
|
|
142
|
+
normalizedResponse: fail(ERROR_CODES.PLAN_VALIDATION_FAILED, 'Invalid plan revision metadata', {
|
|
143
|
+
retryable: false,
|
|
144
|
+
requires_human: true
|
|
145
|
+
})
|
|
146
|
+
};
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
async validatePlanSchema(plan: AnyRecord): Promise<void> {
|
|
151
|
+
const validation = await this.port.validateSchema('plan.schema.json', plan);
|
|
152
|
+
if (!validation.valid) {
|
|
153
|
+
throw {
|
|
154
|
+
normalizedResponse: fail(ERROR_CODES.PLAN_VALIDATION_FAILED, 'plan.json failed schema validation', {
|
|
155
|
+
errors: validation.errors,
|
|
156
|
+
retryable: false,
|
|
157
|
+
requires_human: true
|
|
158
|
+
})
|
|
159
|
+
};
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
async checkPlanCollision(featureId: string, plan: AnyRecord): Promise<unknown> {
|
|
164
|
+
const policy = this.port.getPolicySnapshot();
|
|
165
|
+
const acceptedPlans = await this.collectAcceptedPlans(featureId);
|
|
166
|
+
const collisionResult = detectPlanCollisions(
|
|
167
|
+
plan as Parameters<typeof detectPlanCollisions>[0],
|
|
168
|
+
acceptedPlans as Parameters<typeof detectPlanCollisions>[1],
|
|
169
|
+
policy as Parameters<typeof detectPlanCollisions>[2]
|
|
170
|
+
);
|
|
171
|
+
|
|
172
|
+
if (!collisionResult.hasCollisions) {
|
|
173
|
+
return collisionResult;
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
if (policy.collision_policy === 'reject') {
|
|
177
|
+
throw {
|
|
178
|
+
normalizedResponse: fail(ERROR_CODES.COLLISION_DETECTED, 'Plan collides with accepted plans', {
|
|
179
|
+
feature_id: featureId,
|
|
180
|
+
collisions: collisionResult.collisions,
|
|
181
|
+
collision_fingerprint: collisionResult.fingerprint,
|
|
182
|
+
conflicting_feature_ids: normalizeSet(
|
|
183
|
+
collisionResult.collisions.files
|
|
184
|
+
.map((x) => x.with_feature_id)
|
|
185
|
+
.concat(
|
|
186
|
+
collisionResult.collisions.areas.map((x) => x.with_feature_id),
|
|
187
|
+
collisionResult.collisions.contracts.map((x) => x.with_feature_id)
|
|
188
|
+
)
|
|
189
|
+
),
|
|
190
|
+
retryable: false,
|
|
191
|
+
requires_human: true,
|
|
192
|
+
suggested_next_actions: [
|
|
193
|
+
'Acquire relevant lock and resubmit',
|
|
194
|
+
'Revise plan scope to avoid overlap',
|
|
195
|
+
'Create shared prerequisite feature'
|
|
196
|
+
]
|
|
197
|
+
})
|
|
198
|
+
};
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
await this.port.withIndexLock(async () => {
|
|
202
|
+
const index = await this.port.readIndex();
|
|
203
|
+
index.blocked_queue.push({
|
|
204
|
+
feature_id: featureId,
|
|
205
|
+
plan_version: plan.plan_version,
|
|
206
|
+
detected_at: nowIso(),
|
|
207
|
+
collision_fingerprint: collisionResult.fingerprint,
|
|
208
|
+
required_resources: await this.requiredResourcesForPlan(plan),
|
|
209
|
+
plan_snapshot: plan
|
|
210
|
+
});
|
|
211
|
+
index.blocked_queue.sort(
|
|
212
|
+
(a: AnyRecord, b: AnyRecord) => a.detected_at.localeCompare(b.detected_at) || a.feature_id.localeCompare(b.feature_id)
|
|
213
|
+
);
|
|
214
|
+
index.version += 1;
|
|
215
|
+
index.updated_at = nowIso();
|
|
216
|
+
await this.port.writeIndex(index);
|
|
217
|
+
});
|
|
218
|
+
|
|
219
|
+
throw {
|
|
220
|
+
normalizedResponse: fail(ERROR_CODES.BLOCKED_BY_COLLISION_POLICY, 'Plan queued due to collision policy=block', {
|
|
221
|
+
feature_id: featureId,
|
|
222
|
+
collision_fingerprint: collisionResult.fingerprint,
|
|
223
|
+
collisions: collisionResult.collisions,
|
|
224
|
+
retryable: true,
|
|
225
|
+
requires_human: false
|
|
226
|
+
})
|
|
227
|
+
};
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
async planSubmit(
|
|
231
|
+
featureId: string | null,
|
|
232
|
+
plan: AnyRecord | null,
|
|
233
|
+
expectedVersion: number | null = null
|
|
234
|
+
): Promise<{ data: { feature_id: string | null; accepted: boolean; plan_version: number } }> {
|
|
235
|
+
if (!plan || typeof plan !== 'object') {
|
|
236
|
+
throw {
|
|
237
|
+
normalizedResponse: fail(ERROR_CODES.INVALID_ARGUMENT, 'plan_json is required', {
|
|
238
|
+
retryable: false,
|
|
239
|
+
requires_human: true
|
|
240
|
+
})
|
|
241
|
+
};
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
if (plan.feature_id !== featureId) {
|
|
245
|
+
throw {
|
|
246
|
+
normalizedResponse: fail(ERROR_CODES.INVALID_ARGUMENT, 'plan.feature_id must match feature_id', {
|
|
247
|
+
feature_id: featureId,
|
|
248
|
+
plan_feature_id: plan.feature_id,
|
|
249
|
+
retryable: false,
|
|
250
|
+
requires_human: true
|
|
251
|
+
})
|
|
252
|
+
};
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
await this.validatePlanSchema(plan);
|
|
256
|
+
await this.assertPlanLocksHeld(featureId, plan);
|
|
257
|
+
|
|
258
|
+
const existing = await readJson(this.port.planPath(featureId), null);
|
|
259
|
+
this.validatePlanRevisionRules(existing, plan, expectedVersion);
|
|
260
|
+
|
|
261
|
+
await this.checkPlanCollision(featureId, plan);
|
|
262
|
+
|
|
263
|
+
await this.port.withFeatureLock(featureId, async () => {
|
|
264
|
+
await atomicWriteJson(this.port.planPath(featureId), plan);
|
|
265
|
+
});
|
|
266
|
+
|
|
267
|
+
await this.port.updateState(featureId, null, (frontMatter, body) => {
|
|
268
|
+
const nextStatus =
|
|
269
|
+
frontMatter.status === STATUS.PLANNING || frontMatter.status === STATUS.BLOCKED
|
|
270
|
+
? STATUS.BUILDING
|
|
271
|
+
: frontMatter.status;
|
|
272
|
+
return Promise.resolve({
|
|
273
|
+
frontMatter: {
|
|
274
|
+
gate_profile: plan.gate_profile,
|
|
275
|
+
gates: {
|
|
276
|
+
...frontMatter.gates,
|
|
277
|
+
plan: GATE_RESULT.PASS
|
|
278
|
+
},
|
|
279
|
+
status: nextStatus,
|
|
280
|
+
collisions: {
|
|
281
|
+
files: [],
|
|
282
|
+
areas: [],
|
|
283
|
+
contracts: []
|
|
284
|
+
}
|
|
285
|
+
},
|
|
286
|
+
body
|
|
287
|
+
});
|
|
288
|
+
});
|
|
289
|
+
|
|
290
|
+
return {
|
|
291
|
+
data: {
|
|
292
|
+
feature_id: featureId,
|
|
293
|
+
accepted: true,
|
|
294
|
+
plan_version: plan.plan_version
|
|
295
|
+
}
|
|
296
|
+
};
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
async planUpdate(featureId: string | null, expectedPlanVersion: number | null, plan: AnyRecord | null) {
|
|
300
|
+
return await this.planSubmit(featureId, plan, expectedPlanVersion);
|
|
301
|
+
}
|
|
302
|
+
}
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import { atomicWriteJson, readJson, stableHash } from '../../core/fs.js';
|
|
2
|
+
import { applyQaUpdates, summarizeQaIndex } from '../../core/qa-index.js';
|
|
3
|
+
import { ERROR_CODES } from '../../core/error-codes.js';
|
|
4
|
+
import { fail } from '../../core/response.js';
|
|
5
|
+
|
|
6
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
7
|
+
type AnyRecord = Record<string, any>;
|
|
8
|
+
|
|
9
|
+
export interface QaIndexServicePort {
|
|
10
|
+
qaIndexPath(featureId: string): string;
|
|
11
|
+
validateSchema(schemaName: string, value: unknown): Promise<{ valid: boolean; errors?: unknown }>;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export class QaIndexService {
|
|
15
|
+
private readonly port: QaIndexServicePort;
|
|
16
|
+
|
|
17
|
+
constructor(port: QaIndexServicePort) {
|
|
18
|
+
this.port = port;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
async qaTestIndexGet(featureId: string): Promise<{
|
|
22
|
+
data: {
|
|
23
|
+
index: AnyRecord;
|
|
24
|
+
summary: AnyRecord;
|
|
25
|
+
pending_required_tests: AnyRecord;
|
|
26
|
+
};
|
|
27
|
+
}> {
|
|
28
|
+
const index = await readJson(this.port.qaIndexPath(featureId), {
|
|
29
|
+
feature_id: featureId,
|
|
30
|
+
version: 1,
|
|
31
|
+
source_diff_ref: stableHash('empty'),
|
|
32
|
+
items: []
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
const validation = await this.port.validateSchema('qa_test_index.schema.json', index);
|
|
36
|
+
if (!validation.valid) {
|
|
37
|
+
throw {
|
|
38
|
+
normalizedResponse: fail(ERROR_CODES.INTERNAL_ERROR, 'qa_test_index file is invalid', {
|
|
39
|
+
errors: validation.errors,
|
|
40
|
+
retryable: false,
|
|
41
|
+
requires_human: true
|
|
42
|
+
})
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
const summary = summarizeQaIndex(index);
|
|
47
|
+
return {
|
|
48
|
+
data: {
|
|
49
|
+
index,
|
|
50
|
+
summary: summary.summary,
|
|
51
|
+
pending_required_tests: summary.pending_by_file
|
|
52
|
+
}
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
async qaTestIndexUpdate(
|
|
57
|
+
featureId: string,
|
|
58
|
+
expectedVersion: number | null,
|
|
59
|
+
updates: unknown,
|
|
60
|
+
evidenceRefs: unknown[]
|
|
61
|
+
): Promise<{ data: { feature_id: string; version: number } }> {
|
|
62
|
+
const current = await readJson(this.port.qaIndexPath(featureId), null);
|
|
63
|
+
if (!current) {
|
|
64
|
+
throw {
|
|
65
|
+
normalizedResponse: fail(ERROR_CODES.FILE_NOT_FOUND, 'qa_test_index.json not found', {
|
|
66
|
+
retryable: false,
|
|
67
|
+
requires_human: true
|
|
68
|
+
})
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
const next = applyQaUpdates(
|
|
73
|
+
current,
|
|
74
|
+
expectedVersion,
|
|
75
|
+
updates as Parameters<typeof applyQaUpdates>[2],
|
|
76
|
+
evidenceRefs as Parameters<typeof applyQaUpdates>[3]
|
|
77
|
+
);
|
|
78
|
+
const validation = await this.port.validateSchema('qa_test_index.schema.json', next);
|
|
79
|
+
if (!validation.valid) {
|
|
80
|
+
throw {
|
|
81
|
+
normalizedResponse: fail(ERROR_CODES.INTERNAL_ERROR, 'qa_test_index update failed validation', {
|
|
82
|
+
errors: validation.errors,
|
|
83
|
+
retryable: false,
|
|
84
|
+
requires_human: true
|
|
85
|
+
})
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
await atomicWriteJson(this.port.qaIndexPath(featureId), next);
|
|
90
|
+
|
|
91
|
+
return {
|
|
92
|
+
data: {
|
|
93
|
+
feature_id: featureId,
|
|
94
|
+
version: next.version
|
|
95
|
+
}
|
|
96
|
+
};
|
|
97
|
+
}
|
|
98
|
+
}
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
import { detectPlanCollisions } from '../../core/collisions.js';
|
|
2
|
+
import { pathExists, stableHash } from '../../core/fs.js';
|
|
3
|
+
|
|
4
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
5
|
+
type AnyRecord = Record<string, any>;
|
|
6
|
+
|
|
7
|
+
function normalizeSet(array: string[]): string[] {
|
|
8
|
+
return [...new Set(array)].sort((a, b) => a.localeCompare(b));
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
function readHeldLocks(frontMatter: AnyRecord): string[] {
|
|
12
|
+
const locks = frontMatter?.locks && typeof frontMatter.locks === 'object' ? frontMatter.locks : {};
|
|
13
|
+
const held = Array.isArray(locks.held) ? locks.held : [];
|
|
14
|
+
return held.filter((item: unknown): item is string => typeof item === 'string');
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
function createCollisionFingerprint(collisions: unknown): string {
|
|
18
|
+
return stableHash(JSON.stringify(collisions));
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export interface ReportingServicePort {
|
|
22
|
+
collectAcceptedPlans(excludeFeatureId?: string | null): Promise<AnyRecord[]>;
|
|
23
|
+
getPolicySnapshot(): AnyRecord;
|
|
24
|
+
readIndex(): Promise<AnyRecord>;
|
|
25
|
+
statePath(featureId: string): string;
|
|
26
|
+
readState(featureId: string): Promise<{ frontMatter: AnyRecord }>;
|
|
27
|
+
featureStateGet(featureId: string): Promise<{ data: { front_matter: AnyRecord } }>;
|
|
28
|
+
repoDiffBundle(featureId: string): Promise<{ data: AnyRecord }>;
|
|
29
|
+
qaTestIndexGet(featureId: string): Promise<{ data: AnyRecord }>;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export class ReportingService {
|
|
33
|
+
private readonly port: ReportingServicePort;
|
|
34
|
+
|
|
35
|
+
constructor(port: ReportingServicePort) {
|
|
36
|
+
this.port = port;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
async collisionsScan() {
|
|
40
|
+
const plans = await this.port.collectAcceptedPlans();
|
|
41
|
+
const matrix = [];
|
|
42
|
+
|
|
43
|
+
for (let i = 0; i < plans.length; i += 1) {
|
|
44
|
+
for (let j = i + 1; j < plans.length; j += 1) {
|
|
45
|
+
const candidatePlan = plans[i] as Parameters<typeof detectPlanCollisions>[0];
|
|
46
|
+
const comparisonPlan = plans[j] as Parameters<typeof detectPlanCollisions>[0];
|
|
47
|
+
const result = detectPlanCollisions(
|
|
48
|
+
candidatePlan,
|
|
49
|
+
[comparisonPlan],
|
|
50
|
+
this.port.getPolicySnapshot() as Parameters<typeof detectPlanCollisions>[2]
|
|
51
|
+
);
|
|
52
|
+
if (result.hasCollisions) {
|
|
53
|
+
matrix.push({
|
|
54
|
+
feature_id: candidatePlan.feature_id,
|
|
55
|
+
with_feature_id: comparisonPlan.feature_id,
|
|
56
|
+
collisions: result.collisions,
|
|
57
|
+
fingerprint: createCollisionFingerprint(result.collisions)
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
return {
|
|
64
|
+
data: {
|
|
65
|
+
collisions: matrix
|
|
66
|
+
}
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
async reportDashboard() {
|
|
71
|
+
const index = await this.port.readIndex();
|
|
72
|
+
const featureIds = normalizeSet([
|
|
73
|
+
...index.active,
|
|
74
|
+
...index.blocked,
|
|
75
|
+
...index.merged,
|
|
76
|
+
...Object.values(index.locks).filter(Boolean)
|
|
77
|
+
]);
|
|
78
|
+
|
|
79
|
+
const features = [];
|
|
80
|
+
for (const featureId of featureIds) {
|
|
81
|
+
const statePath = this.port.statePath(featureId);
|
|
82
|
+
if (!(await pathExists(statePath))) {
|
|
83
|
+
continue;
|
|
84
|
+
}
|
|
85
|
+
const state = await this.port.readState(featureId);
|
|
86
|
+
features.push({
|
|
87
|
+
feature_id: featureId,
|
|
88
|
+
status: state.frontMatter.status,
|
|
89
|
+
locks: readHeldLocks(state.frontMatter),
|
|
90
|
+
gate_profile: state.frontMatter.gate_profile,
|
|
91
|
+
gates: state.frontMatter.gates,
|
|
92
|
+
last_updated: state.frontMatter.last_updated
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
return {
|
|
97
|
+
data: {
|
|
98
|
+
index,
|
|
99
|
+
features
|
|
100
|
+
}
|
|
101
|
+
};
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
async reportFeatureSummary(featureId: string | null) {
|
|
105
|
+
const state = await this.port.featureStateGet(featureId as unknown as string);
|
|
106
|
+
const bundle = await this.port.repoDiffBundle(featureId as unknown as string);
|
|
107
|
+
const qa = await this.port.qaTestIndexGet(featureId as unknown as string);
|
|
108
|
+
|
|
109
|
+
return {
|
|
110
|
+
data: {
|
|
111
|
+
feature_id: featureId,
|
|
112
|
+
state: state.data.front_matter,
|
|
113
|
+
diff_stat: bundle.data.diff_stat,
|
|
114
|
+
touched_files: bundle.data.touched_files,
|
|
115
|
+
last_gate_summary: bundle.data.last_gate_summary,
|
|
116
|
+
qa_summary: qa.data.summary
|
|
117
|
+
}
|
|
118
|
+
};
|
|
119
|
+
}
|
|
120
|
+
}
|