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.
Files changed (439) hide show
  1. package/.dockerignore +24 -0
  2. package/.github/workflows/mcp-contract-validation.yml +38 -0
  3. package/Agentic-Orchestrator.iml +9 -0
  4. package/LICENSE +21 -0
  5. package/README.md +679 -0
  6. package/agentic/orchestrator/agents.yaml +14 -0
  7. package/agentic/orchestrator/gates.yaml +31 -0
  8. package/agentic/orchestrator/policy.yaml +145 -0
  9. package/agentic/orchestrator/prompts/builder.system.md +1 -0
  10. package/agentic/orchestrator/prompts/planner.system.md +15 -0
  11. package/agentic/orchestrator/prompts/qa.system.md +1 -0
  12. package/agentic/orchestrator/schemas/agents.schema.json +49 -0
  13. package/agentic/orchestrator/schemas/gates.schema.json +65 -0
  14. package/agentic/orchestrator/schemas/index.schema.json +108 -0
  15. package/agentic/orchestrator/schemas/plan.schema.json +127 -0
  16. package/agentic/orchestrator/schemas/policy.schema.json +227 -0
  17. package/agentic/orchestrator/schemas/qa_test_index.schema.json +53 -0
  18. package/agentic/orchestrator/schemas/state.schema.json +92 -0
  19. package/agentic/orchestrator/tools/catalog.json +399 -0
  20. package/agentic/orchestrator/tools/errors.schema.json +21 -0
  21. package/agentic/orchestrator/tools/protocol.json +8 -0
  22. package/agentic/orchestrator/tools/schemas/input/collisions.scan.input.schema.json +7 -0
  23. package/agentic/orchestrator/tools/schemas/input/evidence.latest.input.schema.json +15 -0
  24. package/agentic/orchestrator/tools/schemas/input/feature.delete.input.schema.json +42 -0
  25. package/agentic/orchestrator/tools/schemas/input/feature.discover_specs.input.schema.json +7 -0
  26. package/agentic/orchestrator/tools/schemas/input/feature.get_context.input.schema.json +15 -0
  27. package/agentic/orchestrator/tools/schemas/input/feature.init.input.schema.json +21 -0
  28. package/agentic/orchestrator/tools/schemas/input/feature.log_append.input.schema.json +26 -0
  29. package/agentic/orchestrator/tools/schemas/input/feature.ready_to_merge.input.schema.json +34 -0
  30. package/agentic/orchestrator/tools/schemas/input/feature.state_get.input.schema.json +15 -0
  31. package/agentic/orchestrator/tools/schemas/input/feature.state_patch.input.schema.json +28 -0
  32. package/agentic/orchestrator/tools/schemas/input/gates.list.input.schema.json +11 -0
  33. package/agentic/orchestrator/tools/schemas/input/gates.run.input.schema.json +29 -0
  34. package/agentic/orchestrator/tools/schemas/input/locks.acquire.input.schema.json +29 -0
  35. package/agentic/orchestrator/tools/schemas/input/locks.release.input.schema.json +26 -0
  36. package/agentic/orchestrator/tools/schemas/input/mutating.schema.json +14 -0
  37. package/agentic/orchestrator/tools/schemas/input/plan.get.input.schema.json +15 -0
  38. package/agentic/orchestrator/tools/schemas/input/plan.submit.input.schema.json +28 -0
  39. package/agentic/orchestrator/tools/schemas/input/plan.update.input.schema.json +29 -0
  40. package/agentic/orchestrator/tools/schemas/input/qa.test_index_get.input.schema.json +15 -0
  41. package/agentic/orchestrator/tools/schemas/input/qa.test_index_update.input.schema.json +38 -0
  42. package/agentic/orchestrator/tools/schemas/input/read.schema.json +6 -0
  43. package/agentic/orchestrator/tools/schemas/input/repo.apply_patch.input.schema.json +25 -0
  44. package/agentic/orchestrator/tools/schemas/input/repo.diff.input.schema.json +21 -0
  45. package/agentic/orchestrator/tools/schemas/input/repo.diff_bundle.input.schema.json +15 -0
  46. package/agentic/orchestrator/tools/schemas/input/repo.ensure_worktree.input.schema.json +21 -0
  47. package/agentic/orchestrator/tools/schemas/input/repo.read_file.input.schema.json +20 -0
  48. package/agentic/orchestrator/tools/schemas/input/repo.search.input.schema.json +20 -0
  49. package/agentic/orchestrator/tools/schemas/input/repo.status.input.schema.json +15 -0
  50. package/agentic/orchestrator/tools/schemas/input/report.dashboard.input.schema.json +7 -0
  51. package/agentic/orchestrator/tools/schemas/input/report.feature_summary.input.schema.json +15 -0
  52. package/agentic/orchestrator/tools/schemas/output/collisions.scan.output.schema.json +17 -0
  53. package/agentic/orchestrator/tools/schemas/output/evidence.latest.output.schema.json +20 -0
  54. package/agentic/orchestrator/tools/schemas/output/feature.delete.output.schema.json +224 -0
  55. package/agentic/orchestrator/tools/schemas/output/feature.discover_specs.output.schema.json +32 -0
  56. package/agentic/orchestrator/tools/schemas/output/feature.get_context.output.schema.json +40 -0
  57. package/agentic/orchestrator/tools/schemas/output/feature.init.output.schema.json +24 -0
  58. package/agentic/orchestrator/tools/schemas/output/feature.log_append.output.schema.json +24 -0
  59. package/agentic/orchestrator/tools/schemas/output/feature.ready_to_merge.output.schema.json +30 -0
  60. package/agentic/orchestrator/tools/schemas/output/feature.state_get.output.schema.json +18 -0
  61. package/agentic/orchestrator/tools/schemas/output/feature.state_patch.output.schema.json +24 -0
  62. package/agentic/orchestrator/tools/schemas/output/gates.list.output.schema.json +42 -0
  63. package/agentic/orchestrator/tools/schemas/output/gates.run.output.schema.json +37 -0
  64. package/agentic/orchestrator/tools/schemas/output/locks.acquire.output.schema.json +34 -0
  65. package/agentic/orchestrator/tools/schemas/output/locks.release.output.schema.json +24 -0
  66. package/agentic/orchestrator/tools/schemas/output/plan.get.output.schema.json +26 -0
  67. package/agentic/orchestrator/tools/schemas/output/plan.submit.output.schema.json +23 -0
  68. package/agentic/orchestrator/tools/schemas/output/plan.update.output.schema.json +23 -0
  69. package/agentic/orchestrator/tools/schemas/output/qa.test_index_get.output.schema.json +22 -0
  70. package/agentic/orchestrator/tools/schemas/output/qa.test_index_update.output.schema.json +19 -0
  71. package/agentic/orchestrator/tools/schemas/output/repo.apply_patch.output.schema.json +33 -0
  72. package/agentic/orchestrator/tools/schemas/output/repo.diff.output.schema.json +19 -0
  73. package/agentic/orchestrator/tools/schemas/output/repo.diff_bundle.output.schema.json +32 -0
  74. package/agentic/orchestrator/tools/schemas/output/repo.ensure_worktree.output.schema.json +29 -0
  75. package/agentic/orchestrator/tools/schemas/output/repo.read_file.output.schema.json +24 -0
  76. package/agentic/orchestrator/tools/schemas/output/repo.search.output.schema.json +26 -0
  77. package/agentic/orchestrator/tools/schemas/output/repo.status.output.schema.json +27 -0
  78. package/agentic/orchestrator/tools/schemas/output/report.dashboard.output.schema.json +21 -0
  79. package/agentic/orchestrator/tools/schemas/output/report.feature_summary.output.schema.json +36 -0
  80. package/agentic/orchestrator/tools/schemas/output/standard_success.schema.json +6 -0
  81. package/agentic/orchestrator/tools.md +32 -0
  82. package/apps/control-plane/project.json +39 -0
  83. package/apps/control-plane/scripts/validate-architecture-rules.mjs +170 -0
  84. package/apps/control-plane/scripts/validate-docker-mcp-contract.mjs +84 -0
  85. package/apps/control-plane/scripts/validate-mcp-contracts.ts +61 -0
  86. package/apps/control-plane/src/application/services/collision-queue-service.ts +227 -0
  87. package/apps/control-plane/src/application/services/feature-deletion-service.ts +459 -0
  88. package/apps/control-plane/src/application/services/feature-lifecycle-service.ts +177 -0
  89. package/apps/control-plane/src/application/services/feature-state-service.ts +125 -0
  90. package/apps/control-plane/src/application/services/gate-service.ts +232 -0
  91. package/apps/control-plane/src/application/services/lock-service.ts +298 -0
  92. package/apps/control-plane/src/application/services/merge-service.ts +246 -0
  93. package/apps/control-plane/src/application/services/patch-service.ts +259 -0
  94. package/apps/control-plane/src/application/services/plan-service.ts +302 -0
  95. package/apps/control-plane/src/application/services/qa-index-service.ts +98 -0
  96. package/apps/control-plane/src/application/services/reporting-service.ts +120 -0
  97. package/apps/control-plane/src/application/services/run-lease-service.ts +340 -0
  98. package/apps/control-plane/src/application/tools/tool-metadata.ts +56 -0
  99. package/apps/control-plane/src/application/tools/tool-router.ts +43 -0
  100. package/apps/control-plane/src/cli/aop.ts +31 -0
  101. package/apps/control-plane/src/cli/cli-argument-parser.ts +116 -0
  102. package/apps/control-plane/src/cli/delete-command-handler.ts +90 -0
  103. package/apps/control-plane/src/cli/io.ts +14 -0
  104. package/apps/control-plane/src/cli/resume-command-handler.ts +228 -0
  105. package/apps/control-plane/src/cli/run-command-handler.ts +57 -0
  106. package/apps/control-plane/src/cli/spec-ingestion-service.ts +88 -0
  107. package/apps/control-plane/src/cli/spec-input-resolver.ts +95 -0
  108. package/apps/control-plane/src/cli/spec-utils.ts +40 -0
  109. package/apps/control-plane/src/cli/status-command-handler.ts +17 -0
  110. package/apps/control-plane/src/cli/stop-command-handler.ts +5 -0
  111. package/apps/control-plane/src/cli/tooling.ts +36 -0
  112. package/apps/control-plane/src/cli/types.ts +34 -0
  113. package/apps/control-plane/src/core/collisions.ts +121 -0
  114. package/apps/control-plane/src/core/constants.ts +72 -0
  115. package/apps/control-plane/src/core/error-codes.ts +54 -0
  116. package/apps/control-plane/src/core/frontmatter.ts +42 -0
  117. package/apps/control-plane/src/core/fs.ts +173 -0
  118. package/apps/control-plane/src/core/gates.ts +361 -0
  119. package/apps/control-plane/src/core/git.ts +115 -0
  120. package/apps/control-plane/src/core/kernel.ts +1077 -0
  121. package/apps/control-plane/src/core/patch.ts +152 -0
  122. package/apps/control-plane/src/core/path-layout.ts +113 -0
  123. package/apps/control-plane/src/core/path-rules.ts +71 -0
  124. package/apps/control-plane/src/core/qa-index.ts +179 -0
  125. package/apps/control-plane/src/core/response.ts +62 -0
  126. package/apps/control-plane/src/core/runtime-sessions.ts +20 -0
  127. package/apps/control-plane/src/core/schemas.ts +125 -0
  128. package/apps/control-plane/src/index.ts +21 -0
  129. package/apps/control-plane/src/interfaces/cli/bootstrap.ts +100 -0
  130. package/apps/control-plane/src/mcp/kernel-tool-executor.ts +39 -0
  131. package/apps/control-plane/src/mcp/mcp-server-adapter.ts +74 -0
  132. package/apps/control-plane/src/mcp/operation-ledger.ts +108 -0
  133. package/apps/control-plane/src/mcp/protocol-contract.ts +9 -0
  134. package/apps/control-plane/src/mcp/runtime-factory.ts +105 -0
  135. package/apps/control-plane/src/mcp/runtime-types.ts +44 -0
  136. package/apps/control-plane/src/mcp/token-auth-verifier.ts +63 -0
  137. package/apps/control-plane/src/mcp/token-claims-validator.ts +72 -0
  138. package/apps/control-plane/src/mcp/token-codec.ts +62 -0
  139. package/apps/control-plane/src/mcp/tool-authorizer.ts +43 -0
  140. package/apps/control-plane/src/mcp/tool-client.ts +78 -0
  141. package/apps/control-plane/src/mcp/tool-contract-validator.ts +83 -0
  142. package/apps/control-plane/src/mcp/tool-registry-loader.ts +135 -0
  143. package/apps/control-plane/src/mcp/tool-runtime.ts +336 -0
  144. package/apps/control-plane/src/mcp/tools-markdown-generator.ts +26 -0
  145. package/apps/control-plane/src/mcp/transport-types.ts +16 -0
  146. package/apps/control-plane/src/mcp/types.ts +2 -0
  147. package/apps/control-plane/src/providers/providers.ts +177 -0
  148. package/apps/control-plane/src/supervisor/build-wave-executor.ts +55 -0
  149. package/apps/control-plane/src/supervisor/lease-heartbeat-service.ts +22 -0
  150. package/apps/control-plane/src/supervisor/planning-wave-executor.ts +316 -0
  151. package/apps/control-plane/src/supervisor/prompt-bundle-loader.ts +62 -0
  152. package/apps/control-plane/src/supervisor/qa-wave-executor.ts +99 -0
  153. package/apps/control-plane/src/supervisor/run-coordinator.ts +224 -0
  154. package/apps/control-plane/src/supervisor/runtime.ts +347 -0
  155. package/apps/control-plane/src/supervisor/session-orchestrator.ts +268 -0
  156. package/apps/control-plane/src/supervisor/types.ts +149 -0
  157. package/apps/control-plane/src/supervisor/worker-decision-loop.ts +299 -0
  158. package/apps/control-plane/test/aop.spec.ts +101 -0
  159. package/apps/control-plane/test/cli-helpers.spec.ts +102 -0
  160. package/apps/control-plane/test/cli.spec.ts +12 -0
  161. package/apps/control-plane/test/cli.unit.spec.ts +609 -0
  162. package/apps/control-plane/test/collision-queue.spec.ts +158 -0
  163. package/apps/control-plane/test/collisions.spec.ts +138 -0
  164. package/apps/control-plane/test/core-utils.spec.ts +102 -0
  165. package/apps/control-plane/test/delete-command-handler.spec.ts +202 -0
  166. package/apps/control-plane/test/epoch-tracking.spec.ts +121 -0
  167. package/apps/control-plane/test/gates.spec.ts +452 -0
  168. package/apps/control-plane/test/helpers.ts +68 -0
  169. package/apps/control-plane/test/index.spec.ts +18 -0
  170. package/apps/control-plane/test/kernel-collision-replay.spec.ts +222 -0
  171. package/apps/control-plane/test/kernel.branches.spec.ts +321 -0
  172. package/apps/control-plane/test/kernel.coverage.spec.ts +408 -0
  173. package/apps/control-plane/test/kernel.spec.ts +369 -0
  174. package/apps/control-plane/test/mcp-helpers.spec.ts +195 -0
  175. package/apps/control-plane/test/mcp.spec.ts +776 -0
  176. package/apps/control-plane/test/merge-service.spec.ts +357 -0
  177. package/apps/control-plane/test/plan-service.spec.ts +195 -0
  178. package/apps/control-plane/test/planning-wave-executor.spec.ts +229 -0
  179. package/apps/control-plane/test/providers.spec.ts +168 -0
  180. package/apps/control-plane/test/qa-index-service.spec.ts +187 -0
  181. package/apps/control-plane/test/qa-index.spec.ts +317 -0
  182. package/apps/control-plane/test/response.spec.ts +55 -0
  183. package/apps/control-plane/test/run-coordinator.spec.ts +334 -0
  184. package/apps/control-plane/test/schema-date-time.spec.ts +170 -0
  185. package/apps/control-plane/test/service-retry-paths.spec.ts +305 -0
  186. package/apps/control-plane/test/services.spec.ts +693 -0
  187. package/apps/control-plane/test/spec-input-resolver.spec.ts +76 -0
  188. package/apps/control-plane/test/supervisor-collaborators.spec.ts +201 -0
  189. package/apps/control-plane/test/supervisor.calltool.spec.ts +120 -0
  190. package/apps/control-plane/test/supervisor.spec.ts +415 -0
  191. package/apps/control-plane/test/supervisor.unit.spec.ts +522 -0
  192. package/apps/control-plane/test/token-auth-verifier.spec.ts +111 -0
  193. package/apps/control-plane/test/tool-registry-loader.spec.ts +268 -0
  194. package/apps/control-plane/test/tool-runtime.spec.ts +294 -0
  195. package/apps/control-plane/test/worker-decision-loop.spec.ts +587 -0
  196. package/apps/control-plane/tsconfig.build.json +17 -0
  197. package/apps/control-plane/tsconfig.json +11 -0
  198. package/apps/control-plane/vitest.config.ts +28 -0
  199. package/dist/apps/control-plane/application/services/collision-queue-service.d.ts +69 -0
  200. package/dist/apps/control-plane/application/services/collision-queue-service.js +158 -0
  201. package/dist/apps/control-plane/application/services/collision-queue-service.js.map +1 -0
  202. package/dist/apps/control-plane/application/services/feature-deletion-service.d.ts +79 -0
  203. package/dist/apps/control-plane/application/services/feature-deletion-service.js +336 -0
  204. package/dist/apps/control-plane/application/services/feature-deletion-service.js.map +1 -0
  205. package/dist/apps/control-plane/application/services/feature-lifecycle-service.d.ts +81 -0
  206. package/dist/apps/control-plane/application/services/feature-lifecycle-service.js +117 -0
  207. package/dist/apps/control-plane/application/services/feature-lifecycle-service.js.map +1 -0
  208. package/dist/apps/control-plane/application/services/feature-state-service.d.ts +34 -0
  209. package/dist/apps/control-plane/application/services/feature-state-service.js +90 -0
  210. package/dist/apps/control-plane/application/services/feature-state-service.js.map +1 -0
  211. package/dist/apps/control-plane/application/services/gate-service.d.ts +46 -0
  212. package/dist/apps/control-plane/application/services/gate-service.js +160 -0
  213. package/dist/apps/control-plane/application/services/gate-service.js.map +1 -0
  214. package/dist/apps/control-plane/application/services/lock-service.d.ts +56 -0
  215. package/dist/apps/control-plane/application/services/lock-service.js +242 -0
  216. package/dist/apps/control-plane/application/services/lock-service.js.map +1 -0
  217. package/dist/apps/control-plane/application/services/merge-service.d.ts +33 -0
  218. package/dist/apps/control-plane/application/services/merge-service.js +194 -0
  219. package/dist/apps/control-plane/application/services/merge-service.js.map +1 -0
  220. package/dist/apps/control-plane/application/services/patch-service.d.ts +39 -0
  221. package/dist/apps/control-plane/application/services/patch-service.js +189 -0
  222. package/dist/apps/control-plane/application/services/patch-service.js.map +1 -0
  223. package/dist/apps/control-plane/application/services/plan-service.d.ts +60 -0
  224. package/dist/apps/control-plane/application/services/plan-service.js +234 -0
  225. package/dist/apps/control-plane/application/services/plan-service.js.map +1 -0
  226. package/dist/apps/control-plane/application/services/qa-index-service.d.ts +26 -0
  227. package/dist/apps/control-plane/application/services/qa-index-service.js +66 -0
  228. package/dist/apps/control-plane/application/services/qa-index-service.js.map +1 -0
  229. package/dist/apps/control-plane/application/services/reporting-service.d.ts +47 -0
  230. package/dist/apps/control-plane/application/services/reporting-service.js +90 -0
  231. package/dist/apps/control-plane/application/services/reporting-service.js.map +1 -0
  232. package/dist/apps/control-plane/application/services/run-lease-service.d.ts +74 -0
  233. package/dist/apps/control-plane/application/services/run-lease-service.js +263 -0
  234. package/dist/apps/control-plane/application/services/run-lease-service.js.map +1 -0
  235. package/dist/apps/control-plane/application/tools/tool-metadata.d.ts +8 -0
  236. package/dist/apps/control-plane/application/tools/tool-metadata.js +37 -0
  237. package/dist/apps/control-plane/application/tools/tool-metadata.js.map +1 -0
  238. package/dist/apps/control-plane/application/tools/tool-router.d.ts +16 -0
  239. package/dist/apps/control-plane/application/tools/tool-router.js +25 -0
  240. package/dist/apps/control-plane/application/tools/tool-router.js.map +1 -0
  241. package/dist/apps/control-plane/cli/aop.d.ts +5 -0
  242. package/dist/apps/control-plane/cli/aop.js +19 -0
  243. package/dist/apps/control-plane/cli/aop.js.map +1 -0
  244. package/dist/apps/control-plane/cli/cli-argument-parser.d.ts +5 -0
  245. package/dist/apps/control-plane/cli/cli-argument-parser.js +109 -0
  246. package/dist/apps/control-plane/cli/cli-argument-parser.js.map +1 -0
  247. package/dist/apps/control-plane/cli/delete-command-handler.d.ts +8 -0
  248. package/dist/apps/control-plane/cli/delete-command-handler.js +77 -0
  249. package/dist/apps/control-plane/cli/delete-command-handler.js.map +1 -0
  250. package/dist/apps/control-plane/cli/io.d.ts +2 -0
  251. package/dist/apps/control-plane/cli/io.js +14 -0
  252. package/dist/apps/control-plane/cli/io.js.map +1 -0
  253. package/dist/apps/control-plane/cli/resume-command-handler.d.ts +17 -0
  254. package/dist/apps/control-plane/cli/resume-command-handler.js +178 -0
  255. package/dist/apps/control-plane/cli/resume-command-handler.js.map +1 -0
  256. package/dist/apps/control-plane/cli/run-command-handler.d.ts +15 -0
  257. package/dist/apps/control-plane/cli/run-command-handler.js +39 -0
  258. package/dist/apps/control-plane/cli/run-command-handler.js.map +1 -0
  259. package/dist/apps/control-plane/cli/spec-ingestion-service.d.ts +8 -0
  260. package/dist/apps/control-plane/cli/spec-ingestion-service.js +77 -0
  261. package/dist/apps/control-plane/cli/spec-ingestion-service.js.map +1 -0
  262. package/dist/apps/control-plane/cli/spec-input-resolver.d.ts +9 -0
  263. package/dist/apps/control-plane/cli/spec-input-resolver.js +81 -0
  264. package/dist/apps/control-plane/cli/spec-input-resolver.js.map +1 -0
  265. package/dist/apps/control-plane/cli/spec-utils.d.ts +3 -0
  266. package/dist/apps/control-plane/cli/spec-utils.js +36 -0
  267. package/dist/apps/control-plane/cli/spec-utils.js.map +1 -0
  268. package/dist/apps/control-plane/cli/status-command-handler.d.ts +7 -0
  269. package/dist/apps/control-plane/cli/status-command-handler.js +14 -0
  270. package/dist/apps/control-plane/cli/status-command-handler.js.map +1 -0
  271. package/dist/apps/control-plane/cli/stop-command-handler.d.ts +3 -0
  272. package/dist/apps/control-plane/cli/stop-command-handler.js +6 -0
  273. package/dist/apps/control-plane/cli/stop-command-handler.js.map +1 -0
  274. package/dist/apps/control-plane/cli/tooling.d.ts +4 -0
  275. package/dist/apps/control-plane/cli/tooling.js +24 -0
  276. package/dist/apps/control-plane/cli/tooling.js.map +1 -0
  277. package/dist/apps/control-plane/cli/types.d.ts +31 -0
  278. package/dist/apps/control-plane/cli/types.js +2 -0
  279. package/dist/apps/control-plane/cli/types.js.map +1 -0
  280. package/dist/apps/control-plane/core/collisions.d.ts +39 -0
  281. package/dist/apps/control-plane/core/collisions.js +78 -0
  282. package/dist/apps/control-plane/core/collisions.js.map +1 -0
  283. package/dist/apps/control-plane/core/constants.d.ts +64 -0
  284. package/dist/apps/control-plane/core/constants.js +64 -0
  285. package/dist/apps/control-plane/core/constants.js.map +1 -0
  286. package/dist/apps/control-plane/core/error-codes.d.ts +50 -0
  287. package/dist/apps/control-plane/core/error-codes.js +52 -0
  288. package/dist/apps/control-plane/core/error-codes.js.map +1 -0
  289. package/dist/apps/control-plane/core/frontmatter.d.ts +11 -0
  290. package/dist/apps/control-plane/core/frontmatter.js +30 -0
  291. package/dist/apps/control-plane/core/frontmatter.js.map +1 -0
  292. package/dist/apps/control-plane/core/fs.d.ts +33 -0
  293. package/dist/apps/control-plane/core/fs.js +134 -0
  294. package/dist/apps/control-plane/core/fs.js.map +1 -0
  295. package/dist/apps/control-plane/core/gates.d.ts +88 -0
  296. package/dist/apps/control-plane/core/gates.js +229 -0
  297. package/dist/apps/control-plane/core/gates.js.map +1 -0
  298. package/dist/apps/control-plane/core/git.d.ts +31 -0
  299. package/dist/apps/control-plane/core/git.js +79 -0
  300. package/dist/apps/control-plane/core/git.js.map +1 -0
  301. package/dist/apps/control-plane/core/kernel.d.ts +445 -0
  302. package/dist/apps/control-plane/core/kernel.js +805 -0
  303. package/dist/apps/control-plane/core/kernel.js.map +1 -0
  304. package/dist/apps/control-plane/core/patch.d.ts +23 -0
  305. package/dist/apps/control-plane/core/patch.js +118 -0
  306. package/dist/apps/control-plane/core/patch.js.map +1 -0
  307. package/dist/apps/control-plane/core/path-layout.d.ts +23 -0
  308. package/dist/apps/control-plane/core/path-layout.js +90 -0
  309. package/dist/apps/control-plane/core/path-layout.js.map +1 -0
  310. package/dist/apps/control-plane/core/path-rules.d.ts +13 -0
  311. package/dist/apps/control-plane/core/path-rules.js +52 -0
  312. package/dist/apps/control-plane/core/path-rules.js.map +1 -0
  313. package/dist/apps/control-plane/core/qa-index.d.ts +53 -0
  314. package/dist/apps/control-plane/core/qa-index.js +112 -0
  315. package/dist/apps/control-plane/core/qa-index.js.map +1 -0
  316. package/dist/apps/control-plane/core/response.d.ts +19 -0
  317. package/dist/apps/control-plane/core/response.js +34 -0
  318. package/dist/apps/control-plane/core/response.js.map +1 -0
  319. package/dist/apps/control-plane/core/runtime-sessions.d.ts +19 -0
  320. package/dist/apps/control-plane/core/runtime-sessions.js +2 -0
  321. package/dist/apps/control-plane/core/runtime-sessions.js.map +1 -0
  322. package/dist/apps/control-plane/core/schemas.d.ts +23 -0
  323. package/dist/apps/control-plane/core/schemas.js +80 -0
  324. package/dist/apps/control-plane/core/schemas.js.map +1 -0
  325. package/dist/apps/control-plane/index.d.ts +11 -0
  326. package/dist/apps/control-plane/index.js +9 -0
  327. package/dist/apps/control-plane/index.js.map +1 -0
  328. package/dist/apps/control-plane/interfaces/cli/bootstrap.d.ts +2 -0
  329. package/dist/apps/control-plane/interfaces/cli/bootstrap.js +86 -0
  330. package/dist/apps/control-plane/interfaces/cli/bootstrap.js.map +1 -0
  331. package/dist/apps/control-plane/mcp/kernel-tool-executor.d.ts +14 -0
  332. package/dist/apps/control-plane/mcp/kernel-tool-executor.js +26 -0
  333. package/dist/apps/control-plane/mcp/kernel-tool-executor.js.map +1 -0
  334. package/dist/apps/control-plane/mcp/mcp-server-adapter.d.ts +19 -0
  335. package/dist/apps/control-plane/mcp/mcp-server-adapter.js +55 -0
  336. package/dist/apps/control-plane/mcp/mcp-server-adapter.js.map +1 -0
  337. package/dist/apps/control-plane/mcp/operation-ledger.d.ts +21 -0
  338. package/dist/apps/control-plane/mcp/operation-ledger.js +75 -0
  339. package/dist/apps/control-plane/mcp/operation-ledger.js.map +1 -0
  340. package/dist/apps/control-plane/mcp/protocol-contract.d.ts +8 -0
  341. package/dist/apps/control-plane/mcp/protocol-contract.js +9 -0
  342. package/dist/apps/control-plane/mcp/protocol-contract.js.map +1 -0
  343. package/dist/apps/control-plane/mcp/runtime-factory.d.ts +38 -0
  344. package/dist/apps/control-plane/mcp/runtime-factory.js +71 -0
  345. package/dist/apps/control-plane/mcp/runtime-factory.js.map +1 -0
  346. package/dist/apps/control-plane/mcp/runtime-types.d.ts +40 -0
  347. package/dist/apps/control-plane/mcp/runtime-types.js +2 -0
  348. package/dist/apps/control-plane/mcp/runtime-types.js.map +1 -0
  349. package/dist/apps/control-plane/mcp/token-auth-verifier.d.ts +24 -0
  350. package/dist/apps/control-plane/mcp/token-auth-verifier.js +45 -0
  351. package/dist/apps/control-plane/mcp/token-auth-verifier.js.map +1 -0
  352. package/dist/apps/control-plane/mcp/token-claims-validator.d.ts +9 -0
  353. package/dist/apps/control-plane/mcp/token-claims-validator.js +62 -0
  354. package/dist/apps/control-plane/mcp/token-claims-validator.js.map +1 -0
  355. package/dist/apps/control-plane/mcp/token-codec.d.ts +11 -0
  356. package/dist/apps/control-plane/mcp/token-codec.js +46 -0
  357. package/dist/apps/control-plane/mcp/token-codec.js.map +1 -0
  358. package/dist/apps/control-plane/mcp/tool-authorizer.d.ts +8 -0
  359. package/dist/apps/control-plane/mcp/tool-authorizer.js +36 -0
  360. package/dist/apps/control-plane/mcp/tool-authorizer.js.map +1 -0
  361. package/dist/apps/control-plane/mcp/tool-client.d.ts +30 -0
  362. package/dist/apps/control-plane/mcp/tool-client.js +50 -0
  363. package/dist/apps/control-plane/mcp/tool-client.js.map +1 -0
  364. package/dist/apps/control-plane/mcp/tool-contract-validator.d.ts +29 -0
  365. package/dist/apps/control-plane/mcp/tool-contract-validator.js +61 -0
  366. package/dist/apps/control-plane/mcp/tool-contract-validator.js.map +1 -0
  367. package/dist/apps/control-plane/mcp/tool-registry-loader.d.ts +15 -0
  368. package/dist/apps/control-plane/mcp/tool-registry-loader.js +109 -0
  369. package/dist/apps/control-plane/mcp/tool-registry-loader.js.map +1 -0
  370. package/dist/apps/control-plane/mcp/tool-runtime.d.ts +34 -0
  371. package/dist/apps/control-plane/mcp/tool-runtime.js +252 -0
  372. package/dist/apps/control-plane/mcp/tool-runtime.js.map +1 -0
  373. package/dist/apps/control-plane/mcp/tools-markdown-generator.d.ts +7 -0
  374. package/dist/apps/control-plane/mcp/tools-markdown-generator.js +22 -0
  375. package/dist/apps/control-plane/mcp/tools-markdown-generator.js.map +1 -0
  376. package/dist/apps/control-plane/mcp/transport-types.d.ts +14 -0
  377. package/dist/apps/control-plane/mcp/transport-types.js +2 -0
  378. package/dist/apps/control-plane/mcp/transport-types.js.map +1 -0
  379. package/dist/apps/control-plane/mcp/types.d.ts +2 -0
  380. package/dist/apps/control-plane/mcp/types.js +3 -0
  381. package/dist/apps/control-plane/mcp/types.js.map +1 -0
  382. package/dist/apps/control-plane/providers/providers.d.ts +72 -0
  383. package/dist/apps/control-plane/providers/providers.js +94 -0
  384. package/dist/apps/control-plane/providers/providers.js.map +1 -0
  385. package/dist/apps/control-plane/supervisor/build-wave-executor.d.ts +13 -0
  386. package/dist/apps/control-plane/supervisor/build-wave-executor.js +40 -0
  387. package/dist/apps/control-plane/supervisor/build-wave-executor.js.map +1 -0
  388. package/dist/apps/control-plane/supervisor/lease-heartbeat-service.d.ts +12 -0
  389. package/dist/apps/control-plane/supervisor/lease-heartbeat-service.js +14 -0
  390. package/dist/apps/control-plane/supervisor/lease-heartbeat-service.js.map +1 -0
  391. package/dist/apps/control-plane/supervisor/planning-wave-executor.d.ts +19 -0
  392. package/dist/apps/control-plane/supervisor/planning-wave-executor.js +249 -0
  393. package/dist/apps/control-plane/supervisor/planning-wave-executor.js.map +1 -0
  394. package/dist/apps/control-plane/supervisor/prompt-bundle-loader.d.ts +9 -0
  395. package/dist/apps/control-plane/supervisor/prompt-bundle-loader.js +53 -0
  396. package/dist/apps/control-plane/supervisor/prompt-bundle-loader.js.map +1 -0
  397. package/dist/apps/control-plane/supervisor/qa-wave-executor.d.ts +24 -0
  398. package/dist/apps/control-plane/supervisor/qa-wave-executor.js +70 -0
  399. package/dist/apps/control-plane/supervisor/qa-wave-executor.js.map +1 -0
  400. package/dist/apps/control-plane/supervisor/run-coordinator.d.ts +49 -0
  401. package/dist/apps/control-plane/supervisor/run-coordinator.js +162 -0
  402. package/dist/apps/control-plane/supervisor/run-coordinator.js.map +1 -0
  403. package/dist/apps/control-plane/supervisor/runtime.d.ts +58 -0
  404. package/dist/apps/control-plane/supervisor/runtime.js +270 -0
  405. package/dist/apps/control-plane/supervisor/runtime.js.map +1 -0
  406. package/dist/apps/control-plane/supervisor/session-orchestrator.d.ts +29 -0
  407. package/dist/apps/control-plane/supervisor/session-orchestrator.js +211 -0
  408. package/dist/apps/control-plane/supervisor/session-orchestrator.js.map +1 -0
  409. package/dist/apps/control-plane/supervisor/types.d.ts +148 -0
  410. package/dist/apps/control-plane/supervisor/types.js +2 -0
  411. package/dist/apps/control-plane/supervisor/types.js.map +1 -0
  412. package/dist/apps/control-plane/supervisor/worker-decision-loop.d.ts +37 -0
  413. package/dist/apps/control-plane/supervisor/worker-decision-loop.js +236 -0
  414. package/dist/apps/control-plane/supervisor/worker-decision-loop.js.map +1 -0
  415. package/docker/mcp.Dockerfile +14 -0
  416. package/docker/mcp.compose.yaml +15 -0
  417. package/docker/mcp.entrypoint.sh +17 -0
  418. package/eslint.config.mjs +93 -0
  419. package/example-configurations/README.md +26 -0
  420. package/example-configurations/java/agents.yaml +14 -0
  421. package/example-configurations/java/gates.yaml +29 -0
  422. package/example-configurations/java/policy.yaml +148 -0
  423. package/example-configurations/node/agents.yaml +14 -0
  424. package/example-configurations/node/gates.yaml +32 -0
  425. package/example-configurations/node/policy.yaml +143 -0
  426. package/nx.json +16 -0
  427. package/package.json +39 -0
  428. package/prompts/vitest-testing-standards.instructions.md +204 -0
  429. package/scripts/dev-shell-env.sh +7 -0
  430. package/scripts/nx-safe.mjs +33 -0
  431. package/spec-files/agentic_orchestrator_cli_delete_command_spec.md +310 -0
  432. package/spec-files/agentic_orchestrator_dot_aop_generated_artifacts_spec.md +211 -0
  433. package/spec-files/agentic_orchestrator_mcp_formalization_spec.md +379 -0
  434. package/spec-files/agentic_orchestrator_oop_refactor_spec.md +415 -0
  435. package/spec-files/agentic_orchestrator_single_global_orchestrator_spec.md +265 -0
  436. package/spec-files/agentic_orchestrator_spec.md +1334 -0
  437. package/spec-files/progress.md +452 -0
  438. package/tsconfig.base.json +15 -0
  439. package/tsconfig.json +11 -0
@@ -0,0 +1,204 @@
1
+ # Agentic Vitest Test Generation Prompt (TypeScript Package)
2
+
3
+ You are a senior TypeScript engineer and testing specialist. Your job is to add **production-grade Vitest tests** to an existing TypeScript package with **minimal churn** and **maximum correctness**.
4
+
5
+ ---
6
+
7
+ ## Mission
8
+
9
+ Given a repository/package, produce a **complete, reliable** test suite using **Vitest** that:
10
+
11
+ - Validates behavior (not implementation details)
12
+ - Covers edge cases and failure modes
13
+ - Is deterministic (no flaky timing/network/randomness)
14
+ - Integrates cleanly with the repo’s existing tooling and conventions
15
+
16
+ ---
17
+
18
+ ## Non-Negotiables
19
+
20
+ - **Use Vitest** (`describe/it/expect`, `vi` mocks/spies, fake timers when needed).
21
+ - **Match existing repo conventions**: folder structure, naming, lint rules, tsconfig, ESM/CJS style, path aliases, formatting.
22
+ - **No brittle tests**: avoid testing private functions via hacks; test through public API unless explicitly instructed.
23
+ - **No snapshot spam**: only use snapshots when they clearly add value (e.g., stable formatted outputs).
24
+ - **Deterministic tests**: do not depend on real time, environment, network, filesystem state, or execution order.
25
+ - **Minimal churn**: don’t refactor product code unless a tiny change is necessary for testability; if needed, propose the smallest safe change.
26
+
27
+ ---
28
+
29
+ ## Phase 0 — Setup Recon (Repository Understanding)
30
+
31
+ 1. Inspect and summarize:
32
+ - Package type: ESM/CJS, Node/browser, library entrypoints
33
+ - Build tool (tsup, tsc, rollup, vite, etc.)
34
+ - Test setup: `vitest.config.*`, existing test files, setup files, globals config
35
+ - Lint/format rules and strictness
36
+ - Any existing mocking utilities / test helpers
37
+ 2. Identify **how tests should be run in this repo**, including:
38
+ - `pnpm/yarn/npm` commands
39
+ - coverage commands
40
+ - watch mode conventions
41
+
42
+ **Output:** A short **Test Environment Summary** and the exact commands to run tests locally.
43
+
44
+ ---
45
+
46
+ ## Phase 1 — Test Strategy + Coverage Map (Before Writing Tests)
47
+
48
+ 1. List the **public API surface** (exports) and important internal modules.
49
+ 2. Create a **coverage map**:
50
+ - Each function/class/module → key behaviors to test
51
+ - Happy path + edge cases + error handling
52
+ - Any concurrency/async behavior
53
+ - Any parsing/validation boundaries
54
+ 3. Call out what should be mocked vs. tested real:
55
+ - External I/O (fs, http, database): mock (or use temp dirs if explicitly permitted)
56
+ - Pure logic: test directly
57
+ - Time: fake timers / fixed clocks
58
+ 4. Identify “hard parts” (e.g., timers, retries, nondeterminism) and specify the approach.
59
+
60
+ **Output:** A structured test plan with a checklist of tests to implement.
61
+
62
+ ---
63
+
64
+ ## Phase 2 — Implementation Rules (How to Write Tests)
65
+
66
+ ### File placement and naming
67
+
68
+ - Follow the repo’s pattern (e.g., `src/**/__tests__/*.test.ts` or `test/*.spec.ts`).
69
+ - Prefer co-located tests near modules unless repo uses centralized `test/`.
70
+
71
+ ### Test design principles
72
+
73
+ - Use **Given / When / Then** structure in test naming:
74
+ - `GIVEN_<context>_WHEN_<action>_THEN_<expected>`
75
+ - One behavior per test.
76
+ - Prefer black-box tests through exported functions/classes.
77
+ - Avoid over-mocking. Mock only what introduces nondeterminism or heavy I/O.
78
+
79
+ ### Mocking and isolation
80
+
81
+ - Use `vi.mock()` for module mocks; `vi.spyOn()` for selective mocking.
82
+ - Reset state between tests:
83
+ - `beforeEach(() => { vi.restoreAllMocks(); vi.clearAllMocks(); })` as appropriate
84
+ - Ensure module isolation when needed:
85
+ - Use `vi.resetModules()` only when truly necessary (it can slow down and hide issues).
86
+
87
+ ### Async + timers
88
+
89
+ - For async:
90
+ - Use `await` and proper assertions (no dangling promises).
91
+ - For timers/retries:
92
+ - Use `vi.useFakeTimers()` and `vi.advanceTimersByTimeAsync()` / `vi.runAllTimersAsync()`.
93
+
94
+ ### Error handling assertions
95
+
96
+ - Assert on error type and message (when stable), e.g.:
97
+ - `await expect(fn()).rejects.toThrow(/pattern/)`
98
+
99
+ ---
100
+
101
+ ## Phase 3 — Change Policy (When You Must Touch Product Code)
102
+
103
+ If tests are blocked because the code is untestable:
104
+
105
+ 1. Propose the smallest change (e.g., dependency injection, parameterizing time, separating pure logic).
106
+ 2. Explain why it’s necessary.
107
+ 3. Implement only after ensuring it doesn’t change runtime behavior.
108
+
109
+ ---
110
+
111
+ ## Phase 4 — Deliverables
112
+
113
+ You must provide:
114
+
115
+ 1. **A list of files created/modified** (with short purpose notes).
116
+ 2. The **complete test code** for each new/modified file.
117
+ 3. Any **config changes** required for Vitest (aliases, setup files, environment, coverage).
118
+ 4. The exact commands to run:
119
+ - unit tests
120
+ - coverage
121
+ - a focused subset (single file / single test name)
122
+
123
+ ---
124
+
125
+ ## Test Coverage Requirements (Required Section)
126
+
127
+ You must include a dedicated coverage section in your output and ensure coverage is configured correctly.
128
+
129
+ ### Coverage configuration
130
+
131
+ 1. Detect current coverage tooling:
132
+ - Vitest coverage provider (`v8` or `istanbul`)
133
+ - Existing thresholds (global and per-file) from config or CI
134
+ 2. Ensure include/exclude patterns align with the package layout:
135
+ - Include: `src/**/*.{ts,tsx}` (or repo-specific)
136
+ - Exclude: `**/*.d.ts`, `**/*.test.*`, `**/*.spec.*`, `**/__tests__/**`, build outputs (`dist/**`), generated files
137
+ 3. If the repo uses path aliases, ensure coverage maps to original TS sources (not built JS).
138
+
139
+ ### Coverage goals
140
+
141
+ - Prioritize **meaningful coverage**:
142
+ - Core logic, branching conditions, error paths, parsing/validation boundaries
143
+ - Avoid chasing trivial lines (barrel exports, constants with no logic, type-only files)
144
+ - If no thresholds exist, propose sensible defaults:
145
+ - **Statements/Lines:** 85–95% on core modules
146
+ - **Branches:** 80–90% on core modules
147
+ - **Functions:** 85–95% on core modules
148
+ - Note: do **not** set aggressive global thresholds if the repo is currently far below; instead, propose incremental improvement.
149
+
150
+ ### Coverage reporting output
151
+
152
+ In your final response, include:
153
+
154
+ - Coverage command(s) to run
155
+ - Summary of what improved (which modules are now covered)
156
+ - Any gaps you intentionally left and why (e.g., thin wrappers, environment-specific code)
157
+
158
+ ---
159
+
160
+ ## Quality Gates (You Must Pass These)
161
+
162
+ Before finalizing, verify:
163
+
164
+ - Tests pass locally with the repo’s package manager command.
165
+ - Coverage meets or improves existing thresholds (or your proposed incremental target).
166
+ - No flaky behavior:
167
+ - time is controlled
168
+ - random is seeded or stubbed
169
+ - network/fs not used unless explicitly allowed
170
+ - CI friendliness:
171
+ - no reliance on machine-specific paths
172
+ - no long sleeps; use fake timers
173
+
174
+ ---
175
+
176
+ ## Required Questions (Ask Early, Then Proceed With Best Assumptions)
177
+
178
+ Ask only what you truly need. If unanswered, proceed with **sensible defaults** and clearly state assumptions.
179
+
180
+ 1. Package manager: pnpm / yarn / npm?
181
+ 2. Runtime target: Node / browser / both?
182
+ 3. ESM or CJS?
183
+ 4. Coverage expectations: any thresholds or “must test” modules?
184
+ 5. Should we mock I/O or run in temp dirs (if filesystem is involved)?
185
+
186
+ ---
187
+
188
+ ## Output Format
189
+
190
+ Produce your response in this exact structure:
191
+
192
+ 1. **Test Environment Summary**
193
+ 2. **Test Plan + Coverage Map**
194
+ 3. **Test Coverage**
195
+ 4. **Changes Made (Files + Rationale)**
196
+ 5. **Patch (Code)**
197
+ 6. **How to Run (Commands)**
198
+ 7. **Notes / Assumptions**
199
+
200
+ ---
201
+
202
+ ## Optional Add-On: Existing Tests
203
+
204
+ If tests already exist, **extend them** rather than rewriting. Only introduce new helpers if they reduce duplication meaningfully.
@@ -0,0 +1,7 @@
1
+ #!/usr/bin/env sh
2
+
3
+ # Source this script to configure Nx for environments that disallow
4
+ # Unix socket listeners used by daemon/plugin worker isolation.
5
+ export NX_DAEMON="${NX_DAEMON:-false}"
6
+ export NX_ISOLATE_PLUGINS="${NX_ISOLATE_PLUGINS:-false}"
7
+
@@ -0,0 +1,33 @@
1
+ #!/usr/bin/env node
2
+ import { spawn } from "node:child_process";
3
+ import { createRequire } from "node:module";
4
+ import process from "node:process";
5
+
6
+ const require = createRequire(import.meta.url);
7
+ const nxCliPath = require.resolve("nx/bin/nx.js");
8
+
9
+ const env = {
10
+ ...process.env,
11
+ NX_DAEMON: process.env.NX_DAEMON ?? "false",
12
+ NX_ISOLATE_PLUGINS: process.env.NX_ISOLATE_PLUGINS ?? "false"
13
+ };
14
+
15
+ const child = spawn(process.execPath, [nxCliPath, ...process.argv.slice(2)], {
16
+ stdio: "inherit",
17
+ env
18
+ });
19
+
20
+ child.on("error", (error) => {
21
+ const message = error instanceof Error ? error.message : String(error);
22
+ console.error(`[nx-safe] Failed to execute Nx CLI: ${message}`);
23
+ process.exit(1);
24
+ });
25
+
26
+ child.on("exit", (code, signal) => {
27
+ if (signal) {
28
+ process.kill(process.pid, signal);
29
+ return;
30
+ }
31
+
32
+ process.exit(code ?? 1);
33
+ });
@@ -0,0 +1,310 @@
1
+ # Feature Spec: CLI `delete` Command with Deterministic Feature Cleanup (AOP)
2
+
3
+ > **Purpose of this document**: Define an implementation-ready, safety-first `aop delete` command that replaces the current CLI placeholder behavior with deterministic cleanup of feature runtime artifacts, index/session references, locks/queue residue, and optional git worktree/branch state.
4
+
5
+ ---
6
+
7
+ ## 1. Objectives
8
+
9
+ ### 1.1 Must-Have Outcomes
10
+
11
+ - Provide a real `aop delete` command for feature cleanup.
12
+ - Keep deterministic behavior aligned with MCP/kernel architecture:
13
+ - schema-validated tool contracts
14
+ - atomic canonical state mutation
15
+ - role authorization and idempotent mutation semantics
16
+ - Delete command MUST safely clean orchestration residue for a feature:
17
+ - feature runtime files
18
+ - index references (`active`, `blocked`, `merged`, blocked queue entries, runtime session assignment)
19
+ - held lock references and lock leases
20
+ - optional git worktree cleanup
21
+ - optional local branch cleanup
22
+ - Command MUST be safe-by-default (preview path before destructive mutation).
23
+ - Preserve current `run/status/resume/stop` behavior while introducing `delete`.
24
+
25
+ ### 1.2 Non-Goals
26
+
27
+ - No change to orchestration algorithm, gate policy, or merge semantics.
28
+ - No implementation of remote branch deletion.
29
+ - No stop-command redesign in this phase beyond clarifying placeholder status.
30
+
31
+ ---
32
+
33
+ ## 2. Current State Analysis (Codebase)
34
+
35
+ 1. CLI supports only `run|status|resume|stop` (`apps/control-plane/src/interfaces/cli/bootstrap.ts`).
36
+ 2. Placeholder behavior exists in `StopCommandHandler` only:
37
+ - returns `{ status: "stop_not_implemented_yet" }`
38
+ - no lease/session/worktree cleanup (`apps/control-plane/src/cli/stop-command-handler.ts`).
39
+ 3. There is no `delete` command parser path and no `DeleteCommandHandler`.
40
+ 4. There is no MCP tool contract for feature deletion:
41
+ - no `feature.delete` in `agentic/orchestrator/tools/catalog.json`
42
+ - no input/output schemas for deletion.
43
+ 5. Kernel/service layer has no cohesive feature cleanup use case:
44
+ - no API for deleting feature artifacts + index/runtime/lock residue in one deterministic operation.
45
+
46
+ ---
47
+
48
+ ## 3. CLI Contract for `delete`
49
+
50
+ ### 3.1 Primary Command
51
+
52
+ ```bash
53
+ aop delete --feature-id <feature_id> [options]
54
+ ```
55
+
56
+ ### 3.2 Options
57
+
58
+ - `--feature-id <id>` (required)
59
+ - `--dry-run` (optional; default when `--yes` is absent)
60
+ - `--yes` (required for destructive execution)
61
+ - `--remove-worktree` (optional; default `true`)
62
+ - `--remove-branch <none|safe|force>` (optional; default `none`)
63
+ - `--transport <mcp|inprocess>` (existing behavior retained)
64
+
65
+ ### 3.3 Safety Rules
66
+
67
+ - If `--yes` is not provided, command MUST run preview-only and perform no mutations.
68
+ - `--dry-run` and `--yes` MAY both be provided only if `--dry-run=true` semantics are explicitly chosen; otherwise fail `invalid_cli_args`.
69
+ - If a fresh active run lease exists, deletion MUST fail with `run_already_active` (unless later explicitly expanded by policy in a separate spec).
70
+
71
+ ### 3.4 Response Contract
72
+
73
+ On success:
74
+ - `ok: true`
75
+ - `data.command: "delete"`
76
+ - `data.feature_id`
77
+ - `data.dry_run`
78
+ - `data.plan` (preview) and/or `data.applied` (execution)
79
+ - `data.summary` with explicit booleans/counts:
80
+ - `feature_dir_removed`
81
+ - `worktree_removed`
82
+ - `branch_removed`
83
+ - `index_updated`
84
+ - `locks_released[]`
85
+ - `blocked_queue_entries_removed`
86
+ - `runtime_session_assignment_removed`
87
+
88
+ On failure:
89
+ - standard normalized error envelope already used by CLI.
90
+
91
+ ---
92
+
93
+ ## 4. Core Capabilities (Required)
94
+
95
+ 1. Deterministic preview:
96
+ - enumerate exactly what will be removed/updated before execution.
97
+ 2. Active-run guard:
98
+ - block deletion when lease is fresh to prevent state/session races.
99
+ 3. Lock and queue residue cleanup:
100
+ - release held locks for target feature.
101
+ - remove blocked-queue entries for target feature.
102
+ 4. Canonical index/session cleanup:
103
+ - remove feature from `active`, `blocked`, `merged`.
104
+ - remove `runtime_sessions.feature_sessions[feature_id]`.
105
+ 5. Runtime artifact deletion:
106
+ - remove feature runtime directory recursively.
107
+ 6. Git cleanup options:
108
+ - remove feature worktree (`git worktree remove --force`).
109
+ - optional local branch delete (`git branch -d` safe, `-D` force).
110
+ 7. Idempotent mutation behavior:
111
+ - tool-level mutation participates in existing operation ledger semantics.
112
+
113
+ ---
114
+
115
+ ## 5. Optimal Architecture
116
+
117
+ ### 5.1 Implement as MCP Mutating Tool, not CLI-Local FS Logic
118
+
119
+ Add new tool: `feature.delete`
120
+
121
+ - Rationale:
122
+ - keeps deterministic mutation in control plane (kernel/service), not ad-hoc CLI code
123
+ - preserves MCP/in-process parity
124
+ - preserves RBAC + schema + idempotency guarantees
125
+ - enables future orchestrator/system-initiated cleanup reuse
126
+
127
+ ### 5.2 Add Dedicated Service
128
+
129
+ - New application service:
130
+ - `apps/control-plane/src/application/services/feature-deletion-service.ts`
131
+ - Kernel registers tool handler that delegates to service.
132
+ - Service owns cleanup algorithm and returns structured deterministic summary.
133
+
134
+ ### 5.3 Path Layout Compatibility
135
+
136
+ - Service MUST use kernel/path accessors (`featurePath`, `worktreePath`, etc.) and MUST NOT hardcode layout roots.
137
+ - This keeps compatibility with current `agentic/features/**` and upcoming `.aop/**` runtime-root migration spec.
138
+
139
+ ---
140
+
141
+ ## 6. Tool Contract Additions
142
+
143
+ ### 6.1 Catalog and Metadata
144
+
145
+ - Add `feature.delete` entry to:
146
+ - `agentic/orchestrator/tools/catalog.json`
147
+ - `apps/control-plane/src/core/constants.ts` (`TOOLS.FEATURE_DELETE`)
148
+ - `apps/control-plane/src/application/tools/tool-metadata.ts` (mutating, requires operation id)
149
+ - `agentic/orchestrator/policy.yaml` RBAC:
150
+ - allow `system`
151
+ - optional `orchestrator` (recommended)
152
+
153
+ ### 6.2 Schemas
154
+
155
+ Add:
156
+ - `agentic/orchestrator/tools/schemas/input/feature.delete.input.schema.json`
157
+ - `agentic/orchestrator/tools/schemas/output/feature.delete.output.schema.json`
158
+
159
+ Input MUST include:
160
+ - `operation_id`
161
+ - `feature_id`
162
+ - execution mode fields (`dry_run`/`confirm` or equivalent)
163
+ - cleanup toggles (`remove_worktree`, `remove_branch`)
164
+
165
+ Output MUST include:
166
+ - target `feature_id`
167
+ - mode (`dry_run`)
168
+ - deterministic summary fields listed in Section 3.4.
169
+
170
+ ### 6.3 Tools Markdown and Contract Validation
171
+
172
+ - Regenerate `agentic/orchestrator/tools.md`.
173
+ - `npm run validate:mcp-contracts` MUST pass with the new tool included.
174
+
175
+ ---
176
+
177
+ ## 7. Deterministic Delete Algorithm (Normative)
178
+
179
+ For target `feature_id`:
180
+
181
+ 1. Validate arguments and feature identifier.
182
+ 2. Load index/runtime sessions and fail if run lease is fresh.
183
+ 3. Build preflight snapshot:
184
+ - feature files present/missing
185
+ - held locks in state
186
+ - blocked queue entries
187
+ - runtime session assignment
188
+ - worktree/branch existence
189
+ 4. If preview mode: return preflight summary only.
190
+ 5. Execution mode:
191
+ - release each held lock via existing lock service path
192
+ - remove blocked queue entries for feature
193
+ - atomically update index:
194
+ - remove feature from `active|blocked|merged`
195
+ - clear any `locks`/`lock_leases` still pointing to feature
196
+ - remove `runtime_sessions.feature_sessions[feature_id]`
197
+ - increment index version and timestamp
198
+ - remove feature runtime directory recursively
199
+ - remove worktree if enabled
200
+ - remove local branch per `remove_branch` policy
201
+ 6. Return applied summary with explicit per-step results.
202
+
203
+ ---
204
+
205
+ ## 8. File-Level Change Targets
206
+
207
+ - CLI:
208
+ - `apps/control-plane/src/cli/cli-argument-parser.ts`
209
+ - `apps/control-plane/src/cli/types.ts`
210
+ - `apps/control-plane/src/cli/delete-command-handler.ts` (new)
211
+ - `apps/control-plane/src/interfaces/cli/bootstrap.ts`
212
+ - Core/Application:
213
+ - `apps/control-plane/src/core/constants.ts`
214
+ - `apps/control-plane/src/core/kernel.ts`
215
+ - `apps/control-plane/src/application/services/feature-deletion-service.ts` (new)
216
+ - `apps/control-plane/src/application/tools/tool-metadata.ts`
217
+ - `apps/control-plane/src/core/error-codes.ts` (if new delete-specific codes are introduced)
218
+ - MCP contracts:
219
+ - `agentic/orchestrator/tools/catalog.json`
220
+ - `agentic/orchestrator/tools/schemas/input/feature.delete.input.schema.json` (new)
221
+ - `agentic/orchestrator/tools/schemas/output/feature.delete.output.schema.json` (new)
222
+ - `agentic/orchestrator/tools.md` (generated)
223
+ - `agentic/orchestrator/policy.yaml` (rbac entries as needed)
224
+ - Docs:
225
+ - `README.md`
226
+
227
+ ---
228
+
229
+ ## 9. Test Plan (Vitest, Normative)
230
+
231
+ ### 9.1 CLI Tests
232
+
233
+ - `delete` command recognized by parser/bootstrap.
234
+ - `--feature-id` required.
235
+ - preview mode default (no `--yes`) performs no mutation.
236
+ - destructive mode requires explicit confirmation.
237
+ - invalid option combinations return `invalid_cli_args`.
238
+
239
+ ### 9.2 Service and Kernel Tests
240
+
241
+ - delete fails when fresh run lease exists (`run_already_active`).
242
+ - delete releases locks and removes blocked-queue entries.
243
+ - delete removes index membership and feature session assignment.
244
+ - delete removes feature directory and optional worktree.
245
+ - branch deletion mode `safe` vs `force` behavior.
246
+ - idempotent re-run behavior on already-deleted feature (defined and tested).
247
+
248
+ ### 9.3 MCP Contract Tests
249
+
250
+ - `feature.delete` listed in tools list with expected mutating contract.
251
+ - input/output schema validation enforced.
252
+ - role authorization intersection behavior verified.
253
+
254
+ ---
255
+
256
+ ## 10. Milestones
257
+
258
+ ### M23: CLI + Contract Surface
259
+
260
+ - Add `delete` command parsing/dispatch and command handler.
261
+ - Add tool catalog entry + schemas + generated tools doc.
262
+
263
+ ### M24: Service Implementation
264
+
265
+ - Implement `FeatureDeletionService` and kernel handler wiring.
266
+ - Implement deterministic cleanup algorithm and summaries.
267
+
268
+ ### M25: Safety and Git Cleanup
269
+
270
+ - Implement fresh-lease guard, preview/confirm flow, optional worktree/branch cleanup.
271
+
272
+ ### M26: Docs + Validation
273
+
274
+ - Update README command docs and examples.
275
+ - Re-verify with `lint`, `typecheck`, `test`, and `validate:mcp-contracts`.
276
+
277
+ ---
278
+
279
+ ## 11. Acceptance Criteria
280
+
281
+ 1. `aop delete --feature-id <id>` exists and returns deterministic preview output by default.
282
+ 2. Destructive execution requires explicit confirmation and returns explicit cleanup summary.
283
+ 3. No deletion proceeds while a fresh run lease is active.
284
+ 4. Feature deletion clears feature state from index + runtime session assignment + blocked queue + lock residue.
285
+ 5. Optional worktree/branch cleanup behaves as specified.
286
+ 6. MCP contract artifacts and validation gates remain green.
287
+ 7. Existing `run/status/resume` behavior remains unchanged; `stop` placeholder remains explicitly documented until separately implemented.
288
+
289
+ ---
290
+
291
+ ## 12. Risks and Mitigations
292
+
293
+ - Risk: accidental destructive deletion.
294
+ - Mitigation: preview-by-default + explicit `--yes` requirement.
295
+ - Risk: deleting during active run corrupts orchestration state.
296
+ - Mitigation: hard fresh-lease guard (`run_already_active`).
297
+ - Risk: partial cleanup leaves stale references.
298
+ - Mitigation: ordered deterministic algorithm + summary assertions + tests.
299
+ - Risk: contract drift after adding tool.
300
+ - Mitigation: catalog/schema/tools.md regeneration and contract CI validation.
301
+
302
+ ---
303
+
304
+ ## 13. Dependency Notes
305
+
306
+ - Aligns with:
307
+ - `spec-files/agentic_orchestrator_spec.md` (CLI/runtime deterministic contract)
308
+ - `spec-files/agentic_orchestrator_mcp_formalization_spec.md` (formal tool contract + idempotency requirements)
309
+ - `spec-files/agentic_orchestrator_oop_refactor_spec.md` (service-oriented extension points)
310
+ - `spec-files/agentic_orchestrator_dot_aop_generated_artifacts_spec.md` (runtime path abstraction compatibility)