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,152 @@
|
|
|
1
|
+
export type DiffChangeType = 'add' | 'modify' | 'delete';
|
|
2
|
+
|
|
3
|
+
export interface DiffHunk {
|
|
4
|
+
start_line: number;
|
|
5
|
+
end_line: number;
|
|
6
|
+
change_type: DiffChangeType;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export interface ParsedDiffFile {
|
|
10
|
+
oldPath: string;
|
|
11
|
+
newPath: string;
|
|
12
|
+
changeType: DiffChangeType;
|
|
13
|
+
hunks: DiffHunk[];
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export class DiffParseError extends Error {
|
|
17
|
+
readonly code: 'invalid_unified_diff';
|
|
18
|
+
|
|
19
|
+
constructor(message: string) {
|
|
20
|
+
super(message);
|
|
21
|
+
this.name = 'DiffParseError';
|
|
22
|
+
this.code = 'invalid_unified_diff';
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
function stripGitPath(value: string): string {
|
|
27
|
+
if (value.startsWith('a/')) {
|
|
28
|
+
return value.slice(2);
|
|
29
|
+
}
|
|
30
|
+
if (value.startsWith('b/')) {
|
|
31
|
+
return value.slice(2);
|
|
32
|
+
}
|
|
33
|
+
return value;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export class DiffParser {
|
|
37
|
+
parse(diffText: string): ParsedDiffFile[] {
|
|
38
|
+
if (typeof diffText !== 'string') {
|
|
39
|
+
throw new DiffParseError('Unified diff input must be a string');
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
const lines = diffText.replace(/\r\n/g, '\n').split('\n');
|
|
43
|
+
const files: ParsedDiffFile[] = [];
|
|
44
|
+
let current: ParsedDiffFile | null = null;
|
|
45
|
+
|
|
46
|
+
const pushCurrent = (): void => {
|
|
47
|
+
if (current) {
|
|
48
|
+
files.push(current);
|
|
49
|
+
current = null;
|
|
50
|
+
}
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
for (const line of lines) {
|
|
54
|
+
if (line.startsWith('diff --git ')) {
|
|
55
|
+
pushCurrent();
|
|
56
|
+
const parts = line.split(' ');
|
|
57
|
+
const oldPath = stripGitPath(parts[2] ?? 'a/unknown');
|
|
58
|
+
const newPath = stripGitPath(parts[3] ?? 'b/unknown');
|
|
59
|
+
current = {
|
|
60
|
+
oldPath,
|
|
61
|
+
newPath,
|
|
62
|
+
changeType: 'modify',
|
|
63
|
+
hunks: []
|
|
64
|
+
};
|
|
65
|
+
continue;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
if (!current) {
|
|
69
|
+
continue;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
if (line.startsWith('new file mode ')) {
|
|
73
|
+
current.changeType = 'add';
|
|
74
|
+
continue;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
if (line.startsWith('deleted file mode ')) {
|
|
78
|
+
current.changeType = 'delete';
|
|
79
|
+
continue;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
if (line.startsWith('rename from ')) {
|
|
83
|
+
current.oldPath = line.replace('rename from ', '').trim();
|
|
84
|
+
current.changeType = 'modify';
|
|
85
|
+
continue;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
if (line.startsWith('rename to ')) {
|
|
89
|
+
current.newPath = line.replace('rename to ', '').trim();
|
|
90
|
+
current.changeType = 'modify';
|
|
91
|
+
continue;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
if (line.startsWith('--- ')) {
|
|
95
|
+
const raw = line.replace('--- ', '').trim();
|
|
96
|
+
if (raw !== '/dev/null') {
|
|
97
|
+
current.oldPath = stripGitPath(raw);
|
|
98
|
+
}
|
|
99
|
+
continue;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
if (line.startsWith('+++ ')) {
|
|
103
|
+
const raw = line.replace('+++ ', '').trim();
|
|
104
|
+
if (raw !== '/dev/null') {
|
|
105
|
+
current.newPath = stripGitPath(raw);
|
|
106
|
+
}
|
|
107
|
+
continue;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
const hunkMatch = line.match(/^@@ -(\d+)(?:,(\d+))? \+(\d+)(?:,(\d+))? @@/);
|
|
111
|
+
if (hunkMatch) {
|
|
112
|
+
const oldStart = Number(hunkMatch[1]);
|
|
113
|
+
const oldCount = Number(hunkMatch[2] ?? 1);
|
|
114
|
+
const newStart = Number(hunkMatch[3]);
|
|
115
|
+
const newCount = Number(hunkMatch[4] ?? 1);
|
|
116
|
+
const changeType: DiffChangeType =
|
|
117
|
+
current.changeType === 'delete' ? 'delete' : current.changeType === 'add' ? 'add' : 'modify';
|
|
118
|
+
current.hunks.push({
|
|
119
|
+
start_line: changeType === 'delete' ? oldStart : newStart,
|
|
120
|
+
end_line: changeType === 'delete' ? oldStart + oldCount - 1 : newStart + newCount - 1,
|
|
121
|
+
change_type: changeType
|
|
122
|
+
});
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
pushCurrent();
|
|
127
|
+
return files;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
touchedPaths(parsedFiles: ParsedDiffFile[]): string[] {
|
|
131
|
+
const touched = new Set<string>();
|
|
132
|
+
for (const file of parsedFiles) {
|
|
133
|
+
if (file.oldPath && file.oldPath !== '/dev/null') {
|
|
134
|
+
touched.add(file.oldPath);
|
|
135
|
+
}
|
|
136
|
+
if (file.newPath && file.newPath !== '/dev/null') {
|
|
137
|
+
touched.add(file.newPath);
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
return [...touched];
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
export const diffParser = new DiffParser();
|
|
145
|
+
|
|
146
|
+
export function parseUnifiedDiff(diffText: string): ParsedDiffFile[] {
|
|
147
|
+
return diffParser.parse(diffText);
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
export function touchedPathsFromDiff(parsedFiles: ParsedDiffFile[]): string[] {
|
|
151
|
+
return diffParser.touchedPaths(parsedFiles);
|
|
152
|
+
}
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
import fs from 'node:fs/promises';
|
|
2
|
+
import path from 'node:path';
|
|
3
|
+
import { ensureDir, pathExists } from './fs.js';
|
|
4
|
+
|
|
5
|
+
export class AopPathLayout {
|
|
6
|
+
readonly repoRoot: string;
|
|
7
|
+
|
|
8
|
+
constructor(repoRoot: string) {
|
|
9
|
+
this.repoRoot = repoRoot;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
get orchestratorRoot(): string {
|
|
13
|
+
return path.join(this.repoRoot, 'agentic', 'orchestrator');
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
get runtimeRoot(): string {
|
|
17
|
+
return path.join(this.repoRoot, '.aop');
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
get featuresRoot(): string {
|
|
21
|
+
return path.join(this.runtimeRoot, 'features');
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
get runtimeDataRoot(): string {
|
|
25
|
+
return path.join(this.runtimeRoot, 'runtime');
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
get operationLedgerRoot(): string {
|
|
29
|
+
return path.join(this.runtimeDataRoot, 'operation-ledger');
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
get legacyFeaturesRoot(): string {
|
|
33
|
+
return path.join(this.repoRoot, 'agentic', 'features');
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
get legacyRuntimeRoot(): string {
|
|
37
|
+
return path.join(this.repoRoot, 'agentic', 'runtime');
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
get indexPath(): string {
|
|
41
|
+
return path.join(this.featuresRoot, 'index.json');
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
get indexLockPath(): string {
|
|
45
|
+
return path.join(this.featuresRoot, '.index.lock');
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
featureRoot(featureId: string): string {
|
|
49
|
+
return path.join(this.featuresRoot, featureId);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
featureLockPath(featureId: string): string {
|
|
53
|
+
return path.join(this.featureRoot(featureId), '.feature.lock');
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
statePath(featureId: string): string {
|
|
57
|
+
return path.join(this.featureRoot(featureId), 'state.md');
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
planPath(featureId: string): string {
|
|
61
|
+
return path.join(this.featureRoot(featureId), 'plan.json');
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
qaIndexPath(featureId: string): string {
|
|
65
|
+
return path.join(this.featureRoot(featureId), 'qa_test_index.json');
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
decisionsPath(featureId: string): string {
|
|
69
|
+
return path.join(this.featureRoot(featureId), 'decisions.md');
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
logsPath(featureId: string): string {
|
|
73
|
+
return path.join(this.featureRoot(featureId), 'logs');
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
evidencePath(featureId: string): string {
|
|
77
|
+
return path.join(this.featureRoot(featureId), 'evidence');
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
specPath(featureId: string): string {
|
|
81
|
+
return path.join(this.featureRoot(featureId), 'spec.md');
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
async function copyLegacyRuntimeTree(sourcePath: string, targetPath: string): Promise<void> {
|
|
86
|
+
await fs.cp(sourcePath, targetPath, {
|
|
87
|
+
recursive: true,
|
|
88
|
+
force: false,
|
|
89
|
+
errorOnExist: false
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
export async function ensureAopRuntimeLayout(layout: AopPathLayout): Promise<void> {
|
|
94
|
+
const runtimeRootExists = await pathExists(layout.runtimeRoot);
|
|
95
|
+
const legacyFeaturesExists = await pathExists(layout.legacyFeaturesRoot);
|
|
96
|
+
const legacyRuntimeExists = await pathExists(layout.legacyRuntimeRoot);
|
|
97
|
+
|
|
98
|
+
// Deterministic compatibility window:
|
|
99
|
+
// if .aop exists it is authoritative; only migrate when .aop is absent.
|
|
100
|
+
if (!runtimeRootExists && (legacyFeaturesExists || legacyRuntimeExists)) {
|
|
101
|
+
await ensureDir(layout.runtimeRoot);
|
|
102
|
+
if (legacyFeaturesExists) {
|
|
103
|
+
await copyLegacyRuntimeTree(layout.legacyFeaturesRoot, layout.featuresRoot);
|
|
104
|
+
}
|
|
105
|
+
if (legacyRuntimeExists) {
|
|
106
|
+
await copyLegacyRuntimeTree(layout.legacyRuntimeRoot, layout.runtimeDataRoot);
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
await ensureDir(layout.featuresRoot);
|
|
111
|
+
await ensureDir(layout.runtimeDataRoot);
|
|
112
|
+
await ensureDir(layout.operationLedgerRoot);
|
|
113
|
+
}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import fs from 'node:fs/promises';
|
|
2
|
+
import path from 'node:path';
|
|
3
|
+
import { Minimatch } from 'minimatch';
|
|
4
|
+
|
|
5
|
+
function normalizeSeparators(value: string): string {
|
|
6
|
+
return value.replaceAll('\\\\', '/');
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export class RepoPathNormalizer {
|
|
10
|
+
async normalize(repoRoot: string, candidatePath: string, allowSymlinkTraversal = false): Promise<string> {
|
|
11
|
+
const absoluteInput = path.isAbsolute(candidatePath) ? candidatePath : path.resolve(repoRoot, candidatePath);
|
|
12
|
+
|
|
13
|
+
const realPath = await fs.realpath(absoluteInput).catch(() => absoluteInput);
|
|
14
|
+
if (!allowSymlinkTraversal && !realPath.startsWith(repoRoot)) {
|
|
15
|
+
throw new Error('path_out_of_bounds');
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
const relative = normalizeSeparators(path.relative(repoRoot, absoluteInput));
|
|
19
|
+
const normalized = path.posix.normalize(relative);
|
|
20
|
+
|
|
21
|
+
if (
|
|
22
|
+
normalized === '' ||
|
|
23
|
+
normalized === '.' ||
|
|
24
|
+
normalized.startsWith('../') ||
|
|
25
|
+
normalized === '..' ||
|
|
26
|
+
normalized.startsWith('/')
|
|
27
|
+
) {
|
|
28
|
+
throw new Error('path_out_of_bounds');
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
return normalized;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export class AreaMatchingPolicy {
|
|
36
|
+
areaMatches(repoRelativePath: string, area: string, matchingMode = 'repo_prefix'): boolean {
|
|
37
|
+
if (matchingMode === 'glob') {
|
|
38
|
+
return new Minimatch(area, { dot: true, nocase: false }).match(repoRelativePath);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
const normalizedArea = area.endsWith('/') ? area : `${area}/`;
|
|
42
|
+
return repoRelativePath === area || repoRelativePath.startsWith(normalizedArea);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
anyAreaMatch(repoRelativePath: string, areas: string[], matchingMode = 'repo_prefix'): boolean {
|
|
46
|
+
return areas.some((area) => this.areaMatches(repoRelativePath, area, matchingMode));
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
export const repoPathNormalizer = new RepoPathNormalizer();
|
|
51
|
+
export const areaMatchingPolicy = new AreaMatchingPolicy();
|
|
52
|
+
|
|
53
|
+
export async function normalizeRepoPath(
|
|
54
|
+
repoRoot: string,
|
|
55
|
+
candidatePath: string,
|
|
56
|
+
allowSymlinkTraversal = false
|
|
57
|
+
): Promise<string> {
|
|
58
|
+
return await repoPathNormalizer.normalize(repoRoot, candidatePath, allowSymlinkTraversal);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
export function areaMatches(repoRelativePath: string, area: string, matchingMode = 'repo_prefix'): boolean {
|
|
62
|
+
return areaMatchingPolicy.areaMatches(repoRelativePath, area, matchingMode);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
export function anyAreaMatch(repoRelativePath: string, areas: string[], matchingMode = 'repo_prefix'): boolean {
|
|
66
|
+
return areaMatchingPolicy.anyAreaMatch(repoRelativePath, areas, matchingMode);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
export function sortResourcesDeterministically(resources: string[]): string[] {
|
|
70
|
+
return [...new Set(resources)].sort((a, b) => a.localeCompare(b));
|
|
71
|
+
}
|
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
import { nowIso, stableHash } from './fs.js';
|
|
2
|
+
import type { ParsedDiffFile, DiffHunk } from './patch.js';
|
|
3
|
+
|
|
4
|
+
export type QaStatus = 'pending' | 'running' | 'passed' | 'failed' | 'waived';
|
|
5
|
+
|
|
6
|
+
export interface QaIndexItem {
|
|
7
|
+
path: string;
|
|
8
|
+
hunks: DiffHunk[];
|
|
9
|
+
required_tests: string[];
|
|
10
|
+
status: QaStatus;
|
|
11
|
+
last_run_at?: string;
|
|
12
|
+
evidence_refs?: string[];
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export interface QaIndex {
|
|
16
|
+
feature_id: string;
|
|
17
|
+
version: number;
|
|
18
|
+
source_diff_ref: string;
|
|
19
|
+
items: QaIndexItem[];
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export interface QaUpdate {
|
|
23
|
+
path: string;
|
|
24
|
+
hunk: DiffHunk;
|
|
25
|
+
status: QaStatus;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export class QaIndexDomainService {
|
|
29
|
+
private hunkKey(filePath: string, hunk: DiffHunk): string {
|
|
30
|
+
return `${filePath}:${hunk.start_line}:${hunk.end_line}:${hunk.change_type}`;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
makeRequiredTests(gateProfile: string, profile: { modes?: Record<string, Array<{ name: string }>> }): string[] {
|
|
34
|
+
const required: string[] = [];
|
|
35
|
+
for (const [mode, steps] of Object.entries(profile.modes ?? {})) {
|
|
36
|
+
for (const step of steps) {
|
|
37
|
+
required.push(`${gateProfile}:${mode}:${step.name}`);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
return required;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
buildIndex(
|
|
44
|
+
featureId: string,
|
|
45
|
+
parsedDiffFiles: ParsedDiffFile[],
|
|
46
|
+
requiredTests: string[],
|
|
47
|
+
previousIndex: QaIndex | null = null
|
|
48
|
+
): QaIndex {
|
|
49
|
+
const previousItemsByKey = new Map<string, QaIndexItem>();
|
|
50
|
+
for (const item of previousIndex?.items ?? []) {
|
|
51
|
+
for (const hunk of item.hunks ?? []) {
|
|
52
|
+
previousItemsByKey.set(this.hunkKey(item.path, hunk), item);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
const items: QaIndexItem[] = [];
|
|
57
|
+
for (const file of parsedDiffFiles) {
|
|
58
|
+
const filePath = file.newPath === '/dev/null' ? file.oldPath : file.newPath;
|
|
59
|
+
if (!filePath) {
|
|
60
|
+
continue;
|
|
61
|
+
}
|
|
62
|
+
const hunks =
|
|
63
|
+
file.hunks?.length > 0
|
|
64
|
+
? file.hunks
|
|
65
|
+
: ([{ start_line: 1, end_line: 1, change_type: file.changeType }] as DiffHunk[]);
|
|
66
|
+
|
|
67
|
+
const existing = previousItemsByKey.get(this.hunkKey(filePath, hunks[0]));
|
|
68
|
+
items.push({
|
|
69
|
+
path: filePath,
|
|
70
|
+
hunks,
|
|
71
|
+
required_tests: requiredTests,
|
|
72
|
+
status: existing?.status ?? 'pending',
|
|
73
|
+
last_run_at: existing?.last_run_at,
|
|
74
|
+
evidence_refs: existing?.evidence_refs ?? []
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
const sourceDiffRef = stableHash(JSON.stringify(parsedDiffFiles));
|
|
79
|
+
|
|
80
|
+
return {
|
|
81
|
+
feature_id: featureId,
|
|
82
|
+
version: Number(previousIndex?.version ?? 0) + 1,
|
|
83
|
+
source_diff_ref: sourceDiffRef,
|
|
84
|
+
items
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
summarize(index: QaIndex): {
|
|
89
|
+
summary: Record<QaStatus, number>;
|
|
90
|
+
pending_by_file: Record<string, Array<{ hunks: DiffHunk[]; required_tests: string[] }>>;
|
|
91
|
+
} {
|
|
92
|
+
const summary: Record<QaStatus, number> = {
|
|
93
|
+
pending: 0,
|
|
94
|
+
running: 0,
|
|
95
|
+
passed: 0,
|
|
96
|
+
failed: 0,
|
|
97
|
+
waived: 0
|
|
98
|
+
};
|
|
99
|
+
|
|
100
|
+
const pendingByFile: Record<string, Array<{ hunks: DiffHunk[]; required_tests: string[] }>> = {};
|
|
101
|
+
|
|
102
|
+
for (const item of index.items ?? []) {
|
|
103
|
+
summary[item.status] = (summary[item.status] ?? 0) + 1;
|
|
104
|
+
if (item.status === 'pending') {
|
|
105
|
+
pendingByFile[item.path] = pendingByFile[item.path] ?? [];
|
|
106
|
+
pendingByFile[item.path].push({
|
|
107
|
+
hunks: item.hunks,
|
|
108
|
+
required_tests: item.required_tests
|
|
109
|
+
});
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
return { summary, pending_by_file: pendingByFile };
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
applyUpdates(index: QaIndex, expectedVersion: number, updates: QaUpdate[], evidenceRefs: string[] = []): QaIndex {
|
|
117
|
+
if (index.version !== expectedVersion) {
|
|
118
|
+
throw new Error('qa_index_version_conflict');
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
const keyedItems = new Map<string, QaIndexItem>();
|
|
122
|
+
for (const item of index.items ?? []) {
|
|
123
|
+
for (const hunk of item.hunks ?? []) {
|
|
124
|
+
keyedItems.set(this.hunkKey(item.path, hunk), item);
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
for (const update of updates) {
|
|
129
|
+
if (!update.path || !update.hunk) {
|
|
130
|
+
throw new Error('invalid_argument');
|
|
131
|
+
}
|
|
132
|
+
const key = this.hunkKey(update.path, update.hunk);
|
|
133
|
+
const item = keyedItems.get(key);
|
|
134
|
+
if (!item) {
|
|
135
|
+
throw new Error('invalid_argument');
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
item.status = update.status;
|
|
139
|
+
item.last_run_at = nowIso();
|
|
140
|
+
item.evidence_refs = [...new Set([...(item.evidence_refs ?? []), ...evidenceRefs])];
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
return {
|
|
144
|
+
...index,
|
|
145
|
+
version: index.version + 1
|
|
146
|
+
};
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
export const qaIndexDomainService = new QaIndexDomainService();
|
|
151
|
+
|
|
152
|
+
export function makeRequiredTests(gateProfile: string, profile: { modes?: Record<string, Array<{ name: string }>> }): string[] {
|
|
153
|
+
return qaIndexDomainService.makeRequiredTests(gateProfile, profile);
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
export function buildQaIndex(
|
|
157
|
+
featureId: string,
|
|
158
|
+
parsedDiffFiles: ParsedDiffFile[],
|
|
159
|
+
requiredTests: string[],
|
|
160
|
+
previousIndex: QaIndex | null = null
|
|
161
|
+
): QaIndex {
|
|
162
|
+
return qaIndexDomainService.buildIndex(featureId, parsedDiffFiles, requiredTests, previousIndex);
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
export function summarizeQaIndex(index: QaIndex): {
|
|
166
|
+
summary: Record<QaStatus, number>;
|
|
167
|
+
pending_by_file: Record<string, Array<{ hunks: DiffHunk[]; required_tests: string[] }>>;
|
|
168
|
+
} {
|
|
169
|
+
return qaIndexDomainService.summarize(index);
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
export function applyQaUpdates(
|
|
173
|
+
index: QaIndex,
|
|
174
|
+
expectedVersion: number,
|
|
175
|
+
updates: QaUpdate[],
|
|
176
|
+
evidenceRefs: string[] = []
|
|
177
|
+
): QaIndex {
|
|
178
|
+
return qaIndexDomainService.applyUpdates(index, expectedVersion, updates, evidenceRefs);
|
|
179
|
+
}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { ERROR_CODES, type ErrorCode } from './error-codes.js';
|
|
2
|
+
|
|
3
|
+
export interface OkResponse<T = Record<string, unknown>> {
|
|
4
|
+
ok: true;
|
|
5
|
+
data: T;
|
|
6
|
+
evidence?: Record<string, unknown>;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export interface FailResponse {
|
|
10
|
+
ok: false;
|
|
11
|
+
error: {
|
|
12
|
+
code: ErrorCode;
|
|
13
|
+
message: string;
|
|
14
|
+
details: Record<string, unknown>;
|
|
15
|
+
};
|
|
16
|
+
evidence?: Record<string, unknown>;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export type ToolResponse<T = Record<string, unknown>> = OkResponse<T> | FailResponse;
|
|
20
|
+
|
|
21
|
+
export function ok<T = Record<string, unknown>>(data: T = {} as T, evidence?: Record<string, unknown>): OkResponse<T> {
|
|
22
|
+
const response: OkResponse<T> = { ok: true, data };
|
|
23
|
+
if (evidence) {
|
|
24
|
+
response.evidence = evidence;
|
|
25
|
+
}
|
|
26
|
+
return response;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export function fail(
|
|
30
|
+
code: string,
|
|
31
|
+
message: string,
|
|
32
|
+
details: Record<string, unknown> = {},
|
|
33
|
+
evidence?: Record<string, unknown>
|
|
34
|
+
): FailResponse {
|
|
35
|
+
const normalizedCode = (Object.values(ERROR_CODES) as string[]).includes(code)
|
|
36
|
+
? (code as ErrorCode)
|
|
37
|
+
: ERROR_CODES.INTERNAL_ERROR;
|
|
38
|
+
const response: FailResponse = {
|
|
39
|
+
ok: false,
|
|
40
|
+
error: {
|
|
41
|
+
code: normalizedCode,
|
|
42
|
+
message,
|
|
43
|
+
details
|
|
44
|
+
}
|
|
45
|
+
};
|
|
46
|
+
if (evidence) {
|
|
47
|
+
response.evidence = evidence;
|
|
48
|
+
}
|
|
49
|
+
return response;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
export function withSuggestedActions(
|
|
53
|
+
details: Record<string, unknown>,
|
|
54
|
+
actions: string[] = []
|
|
55
|
+
): Record<string, unknown> {
|
|
56
|
+
return {
|
|
57
|
+
...details,
|
|
58
|
+
retryable: (details.retryable as boolean | undefined) ?? false,
|
|
59
|
+
requires_human: (details.requires_human as boolean | undefined) ?? false,
|
|
60
|
+
suggested_next_actions: actions
|
|
61
|
+
};
|
|
62
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export interface RuntimeFeatureSessions {
|
|
2
|
+
planner_session_id: string;
|
|
3
|
+
builder_session_id: string;
|
|
4
|
+
qa_session_id: string;
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
export interface RuntimeSessionsSnapshot {
|
|
8
|
+
run_id: string;
|
|
9
|
+
orchestrator_session_id: string;
|
|
10
|
+
provider: string;
|
|
11
|
+
model: string;
|
|
12
|
+
provider_config_ref_hash: string;
|
|
13
|
+
owner_instance_id: string;
|
|
14
|
+
lease_id: string;
|
|
15
|
+
started_at: string;
|
|
16
|
+
last_heartbeat_at: string;
|
|
17
|
+
lease_expires_at: string;
|
|
18
|
+
orchestrator_epoch?: number;
|
|
19
|
+
feature_sessions?: Record<string, RuntimeFeatureSessions>;
|
|
20
|
+
}
|