sdd-agent-platform 0.4.0 → 0.4.1

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 (417) hide show
  1. package/README.md +18 -23
  2. package/node_modules/@sdd-agent-platform/core/dist/ai-tools.js +31 -28
  3. package/node_modules/@sdd-agent-platform/core/dist/ai-tools.js.map +1 -1
  4. package/node_modules/@sdd-agent-platform/core/dist/config/init-project.js +3 -2
  5. package/node_modules/@sdd-agent-platform/core/dist/config/init-project.js.map +1 -1
  6. package/node_modules/@sdd-agent-platform/core/dist/config/starter-documents.d.ts +1 -1
  7. package/node_modules/@sdd-agent-platform/core/dist/config/starter-documents.js +14 -5
  8. package/node_modules/@sdd-agent-platform/core/dist/config/starter-documents.js.map +1 -1
  9. package/node_modules/@sdd-agent-platform/core/dist/contracts.d.ts +2 -0
  10. package/node_modules/@sdd-agent-platform/core/dist/contracts.js +2 -0
  11. package/node_modules/@sdd-agent-platform/core/dist/contracts.js.map +1 -1
  12. package/node_modules/@sdd-agent-platform/core/dist/doctor/checks/run-evidence.js +3 -3
  13. package/node_modules/@sdd-agent-platform/core/dist/doctor/checks/run-evidence.js.map +1 -1
  14. package/node_modules/@sdd-agent-platform/core/dist/doctor/doctor.js +155 -1
  15. package/node_modules/@sdd-agent-platform/core/dist/doctor/doctor.js.map +1 -1
  16. package/node_modules/@sdd-agent-platform/core/dist/evidence/lookup.d.ts +23 -0
  17. package/node_modules/@sdd-agent-platform/core/dist/evidence/lookup.js +54 -0
  18. package/node_modules/@sdd-agent-platform/core/dist/evidence/lookup.js.map +1 -0
  19. package/node_modules/@sdd-agent-platform/core/dist/evidence-runtime/contracts.d.ts +11 -0
  20. package/node_modules/@sdd-agent-platform/core/dist/execution/agent-execution-records.js +15 -8
  21. package/node_modules/@sdd-agent-platform/core/dist/execution/agent-execution-records.js.map +1 -1
  22. package/node_modules/@sdd-agent-platform/core/dist/execution/resident-worker.js +14 -6
  23. package/node_modules/@sdd-agent-platform/core/dist/execution/resident-worker.js.map +1 -1
  24. package/node_modules/@sdd-agent-platform/core/dist/execution/stage-team-runtime.d.ts +112 -0
  25. package/node_modules/@sdd-agent-platform/core/dist/execution/stage-team-runtime.js +145 -0
  26. package/node_modules/@sdd-agent-platform/core/dist/execution/stage-team-runtime.js.map +1 -0
  27. package/node_modules/@sdd-agent-platform/core/dist/instructions.js +36 -36
  28. package/node_modules/@sdd-agent-platform/core/dist/instructions.js.map +1 -1
  29. package/node_modules/@sdd-agent-platform/core/dist/lifecycle/ship.d.ts +2 -0
  30. package/node_modules/@sdd-agent-platform/core/dist/lifecycle/ship.js +37 -17
  31. package/node_modules/@sdd-agent-platform/core/dist/lifecycle/ship.js.map +1 -1
  32. package/node_modules/@sdd-agent-platform/core/dist/registries/agent-capability-catalog.d.ts +16 -1
  33. package/node_modules/@sdd-agent-platform/core/dist/registries/agent-capability-catalog.js +174 -16
  34. package/node_modules/@sdd-agent-platform/core/dist/registries/agent-capability-catalog.js.map +1 -1
  35. package/node_modules/@sdd-agent-platform/core/dist/registries/agent-registry.js +2 -2
  36. package/node_modules/@sdd-agent-platform/core/dist/registries/agent-registry.js.map +1 -1
  37. package/node_modules/@sdd-agent-platform/core/dist/registries/agent-runtime-static.d.ts +10 -0
  38. package/node_modules/@sdd-agent-platform/core/dist/registries/agent-runtime-static.js +31 -1
  39. package/node_modules/@sdd-agent-platform/core/dist/registries/agent-runtime-static.js.map +1 -1
  40. package/node_modules/@sdd-agent-platform/core/dist/registries/capability-sources.d.ts +2 -17
  41. package/node_modules/@sdd-agent-platform/core/dist/registries/capability-sources.js +222 -10
  42. package/node_modules/@sdd-agent-platform/core/dist/registries/capability-sources.js.map +1 -1
  43. package/node_modules/@sdd-agent-platform/core/dist/registries/workflow-gates.js +5 -5
  44. package/node_modules/@sdd-agent-platform/core/dist/registries/workflow-gates.js.map +1 -1
  45. package/node_modules/@sdd-agent-platform/core/dist/router/agent-runtime-config.js +27 -12
  46. package/node_modules/@sdd-agent-platform/core/dist/router/agent-runtime-config.js.map +1 -1
  47. package/node_modules/@sdd-agent-platform/core/dist/router/agent-runtime.d.ts +59 -1
  48. package/node_modules/@sdd-agent-platform/core/dist/router/route-projection.d.ts +3 -1
  49. package/node_modules/@sdd-agent-platform/core/dist/router/route-projection.js +191 -0
  50. package/node_modules/@sdd-agent-platform/core/dist/router/route-projection.js.map +1 -1
  51. package/node_modules/@sdd-agent-platform/core/dist/router/routing.js +32 -6
  52. package/node_modules/@sdd-agent-platform/core/dist/router/routing.js.map +1 -1
  53. package/node_modules/@sdd-agent-platform/core/dist/router/runtime-inspection.js +11 -4
  54. package/node_modules/@sdd-agent-platform/core/dist/router/runtime-inspection.js.map +1 -1
  55. package/node_modules/@sdd-agent-platform/core/dist/router/runtime-validation.js +31 -3
  56. package/node_modules/@sdd-agent-platform/core/dist/router/runtime-validation.js.map +1 -1
  57. package/node_modules/@sdd-agent-platform/core/dist/run-state/artifacts.js +48 -15
  58. package/node_modules/@sdd-agent-platform/core/dist/run-state/artifacts.js.map +1 -1
  59. package/node_modules/@sdd-agent-platform/core/dist/run-state/events.js +2 -2
  60. package/node_modules/@sdd-agent-platform/core/dist/run-state/events.js.map +1 -1
  61. package/node_modules/@sdd-agent-platform/core/dist/run-state/inspect-run.d.ts +3 -1
  62. package/node_modules/@sdd-agent-platform/core/dist/run-state/inspect-run.js +15 -49
  63. package/node_modules/@sdd-agent-platform/core/dist/run-state/inspect-run.js.map +1 -1
  64. package/node_modules/@sdd-agent-platform/core/dist/run-state/invocation-ledger.js +2 -2
  65. package/node_modules/@sdd-agent-platform/core/dist/run-state/invocation-ledger.js.map +1 -1
  66. package/node_modules/@sdd-agent-platform/core/dist/run-state/model.d.ts +25 -1
  67. package/node_modules/@sdd-agent-platform/core/dist/run-state/run-state.js +21 -14
  68. package/node_modules/@sdd-agent-platform/core/dist/run-state/run-state.js.map +1 -1
  69. package/node_modules/@sdd-agent-platform/core/dist/run-state/task-evidence.d.ts +62 -0
  70. package/node_modules/@sdd-agent-platform/core/dist/run-state/task-evidence.js +130 -0
  71. package/node_modules/@sdd-agent-platform/core/dist/run-state/task-evidence.js.map +1 -0
  72. package/node_modules/@sdd-agent-platform/core/dist/run-state.d.ts +1 -0
  73. package/node_modules/@sdd-agent-platform/core/dist/run-state.js +1 -0
  74. package/node_modules/@sdd-agent-platform/core/dist/run-state.js.map +1 -1
  75. package/node_modules/@sdd-agent-platform/core/dist/runtime-paths.d.ts +10 -0
  76. package/node_modules/@sdd-agent-platform/core/dist/runtime-paths.js +44 -14
  77. package/node_modules/@sdd-agent-platform/core/dist/runtime-paths.js.map +1 -1
  78. package/node_modules/@sdd-agent-platform/core/dist/sdd-docs/context.js +1 -1
  79. package/node_modules/@sdd-agent-platform/core/dist/sdd-docs/context.js.map +1 -1
  80. package/node_modules/@sdd-agent-platform/core/dist/sdd-docs/document-hashes.d.ts +4 -0
  81. package/node_modules/@sdd-agent-platform/core/dist/sdd-docs/document-hashes.js +189 -0
  82. package/node_modules/@sdd-agent-platform/core/dist/sdd-docs/document-hashes.js.map +1 -0
  83. package/node_modules/@sdd-agent-platform/core/dist/sdd-docs/run-binding.js +12 -3
  84. package/node_modules/@sdd-agent-platform/core/dist/sdd-docs/run-binding.js.map +1 -1
  85. package/node_modules/@sdd-agent-platform/core/dist/sdd-docs/task-parser.d.ts +20 -0
  86. package/node_modules/@sdd-agent-platform/core/dist/sdd-docs/task-parser.js +101 -21
  87. package/node_modules/@sdd-agent-platform/core/dist/sdd-docs/task-parser.js.map +1 -1
  88. package/node_modules/@sdd-agent-platform/core/dist/status/project-status.d.ts +62 -1
  89. package/node_modules/@sdd-agent-platform/core/dist/status/project-status.js +192 -4
  90. package/node_modules/@sdd-agent-platform/core/dist/status/project-status.js.map +1 -1
  91. package/node_modules/@sdd-agent-platform/core/dist/storage/runtime-store.d.ts +195 -2
  92. package/node_modules/@sdd-agent-platform/core/dist/storage/runtime-store.js +499 -2
  93. package/node_modules/@sdd-agent-platform/core/dist/storage/runtime-store.js.map +1 -1
  94. package/node_modules/@sdd-agent-platform/core/dist/sync-back/apply.js +23 -1
  95. package/node_modules/@sdd-agent-platform/core/dist/sync-back/apply.js.map +1 -1
  96. package/node_modules/@sdd-agent-platform/core/dist/sync-back/inspect.d.ts +19 -0
  97. package/node_modules/@sdd-agent-platform/core/dist/sync-back/inspect.js +114 -12
  98. package/node_modules/@sdd-agent-platform/core/dist/sync-back/inspect.js.map +1 -1
  99. package/node_modules/@sdd-agent-platform/core/dist/test-support/fixtures.js +21 -0
  100. package/node_modules/@sdd-agent-platform/core/dist/test-support/fixtures.js.map +1 -1
  101. package/node_modules/@sdd-agent-platform/core/dist/test-support/run-state.js +16 -2
  102. package/node_modules/@sdd-agent-platform/core/dist/test-support/run-state.js.map +1 -1
  103. package/node_modules/@sdd-agent-platform/core/dist/tsconfig.tsbuildinfo +1 -1
  104. package/node_modules/@sdd-agent-platform/core/dist/verification/goal-verify.js +34 -2
  105. package/node_modules/@sdd-agent-platform/core/dist/verification/goal-verify.js.map +1 -1
  106. package/node_modules/@sdd-agent-platform/core/dist/verification/rendering.js +15 -5
  107. package/node_modules/@sdd-agent-platform/core/dist/verification/rendering.js.map +1 -1
  108. package/node_modules/@sdd-agent-platform/core/dist/verification/review-gate.d.ts +22 -0
  109. package/node_modules/@sdd-agent-platform/core/dist/verification/review-gate.js +53 -0
  110. package/node_modules/@sdd-agent-platform/core/dist/verification/review-gate.js.map +1 -0
  111. package/node_modules/@sdd-agent-platform/core/dist/verification/single-task-loop.js +102 -9
  112. package/node_modules/@sdd-agent-platform/core/dist/verification/single-task-loop.js.map +1 -1
  113. package/node_modules/@sdd-agent-platform/core/dist/verification/test-runtime.d.ts +16 -1
  114. package/node_modules/@sdd-agent-platform/core/dist/verification/test-runtime.js +355 -69
  115. package/node_modules/@sdd-agent-platform/core/dist/verification/test-runtime.js.map +1 -1
  116. package/node_modules/@sdd-agent-platform/core/dist/verification/validation-wave.d.ts +58 -0
  117. package/node_modules/@sdd-agent-platform/core/dist/verification/validation-wave.js +428 -0
  118. package/node_modules/@sdd-agent-platform/core/dist/verification/validation-wave.js.map +1 -0
  119. package/node_modules/@sdd-agent-platform/core/dist/verification/verify-contract.d.ts +2 -0
  120. package/node_modules/@sdd-agent-platform/core/dist/verification/verify-contract.js +116 -18
  121. package/node_modules/@sdd-agent-platform/core/dist/verification/verify-contract.js.map +1 -1
  122. package/node_modules/@sdd-agent-platform/core/dist/verification.d.ts +2 -0
  123. package/node_modules/@sdd-agent-platform/core/dist/verification.js +2 -0
  124. package/node_modules/@sdd-agent-platform/core/dist/verification.js.map +1 -1
  125. package/node_modules/@sdd-agent-platform/core/dist/workflow-gate/evidence-packet.d.ts +24 -0
  126. package/node_modules/@sdd-agent-platform/core/dist/workflow-gate/evidence-packet.js +182 -0
  127. package/node_modules/@sdd-agent-platform/core/dist/workflow-gate/evidence-packet.js.map +1 -0
  128. package/node_modules/@sdd-agent-platform/core/dist/workflow-gate/hard-checks.d.ts +4 -0
  129. package/node_modules/@sdd-agent-platform/core/dist/workflow-gate/hard-checks.js +130 -0
  130. package/node_modules/@sdd-agent-platform/core/dist/workflow-gate/hard-checks.js.map +1 -0
  131. package/node_modules/@sdd-agent-platform/core/dist/workflow-gate/policy.d.ts +4 -0
  132. package/node_modules/@sdd-agent-platform/core/dist/workflow-gate/policy.js +146 -0
  133. package/node_modules/@sdd-agent-platform/core/dist/workflow-gate/policy.js.map +1 -0
  134. package/node_modules/@sdd-agent-platform/core/dist/workflow-gate/types.d.ts +89 -0
  135. package/node_modules/@sdd-agent-platform/core/dist/workflow-gate/types.js +2 -0
  136. package/node_modules/@sdd-agent-platform/core/dist/workflow-gate/types.js.map +1 -0
  137. package/node_modules/@sdd-agent-platform/core/dist/workflow-state/affected-file-conflicts.d.ts +1 -0
  138. package/node_modules/@sdd-agent-platform/core/dist/workflow-state/affected-file-conflicts.js +16 -1
  139. package/node_modules/@sdd-agent-platform/core/dist/workflow-state/affected-file-conflicts.js.map +1 -1
  140. package/node_modules/@sdd-agent-platform/core/dist/workflow-state/dependencies.d.ts +8 -4
  141. package/node_modules/@sdd-agent-platform/core/dist/workflow-state/dependencies.js +25 -11
  142. package/node_modules/@sdd-agent-platform/core/dist/workflow-state/dependencies.js.map +1 -1
  143. package/node_modules/@sdd-agent-platform/core/dist/workflow-state/latest-eligible-run.d.ts +38 -0
  144. package/node_modules/@sdd-agent-platform/core/dist/workflow-state/latest-eligible-run.js +122 -0
  145. package/node_modules/@sdd-agent-platform/core/dist/workflow-state/latest-eligible-run.js.map +1 -0
  146. package/node_modules/@sdd-agent-platform/core/dist/workflow-state/resolve.d.ts +27 -0
  147. package/node_modules/@sdd-agent-platform/core/dist/workflow-state/resolve.js +166 -37
  148. package/node_modules/@sdd-agent-platform/core/dist/workflow-state/resolve.js.map +1 -1
  149. package/node_modules/@sdd-agent-platform/core/dist/workflow-state.d.ts +1 -0
  150. package/node_modules/@sdd-agent-platform/core/dist/workflow-state.js +1 -0
  151. package/node_modules/@sdd-agent-platform/core/dist/workflow-state.js.map +1 -1
  152. package/node_modules/@sdd-agent-platform/core/package.json +1 -1
  153. package/node_modules/@sdd-agent-platform/core/src/ai-tools.ts +31 -28
  154. package/node_modules/@sdd-agent-platform/core/src/artifacts/sdd-result.test.ts +50 -4
  155. package/node_modules/@sdd-agent-platform/core/src/config/init-project.test.ts +13 -10
  156. package/node_modules/@sdd-agent-platform/core/src/config/init-project.ts +3 -2
  157. package/node_modules/@sdd-agent-platform/core/src/config/starter-documents.ts +15 -5
  158. package/node_modules/@sdd-agent-platform/core/src/contracts.ts +2 -0
  159. package/node_modules/@sdd-agent-platform/core/src/doctor/checks/run-evidence.ts +3 -3
  160. package/node_modules/@sdd-agent-platform/core/src/doctor/doctor.test.ts +117 -5
  161. package/node_modules/@sdd-agent-platform/core/src/doctor/doctor.ts +164 -1
  162. package/node_modules/@sdd-agent-platform/core/src/evidence/lookup.ts +80 -0
  163. package/node_modules/@sdd-agent-platform/core/src/evidence-runtime/contracts.ts +12 -0
  164. package/node_modules/@sdd-agent-platform/core/src/execution/agent-execution-records.ts +16 -11
  165. package/node_modules/@sdd-agent-platform/core/src/execution/background-executor.test.ts +7 -0
  166. package/node_modules/@sdd-agent-platform/core/src/execution/resident-worker.test.ts +5 -0
  167. package/node_modules/@sdd-agent-platform/core/src/execution/resident-worker.ts +14 -6
  168. package/node_modules/@sdd-agent-platform/core/src/execution/stage-team-runtime.test.ts +102 -0
  169. package/node_modules/@sdd-agent-platform/core/src/execution/stage-team-runtime.ts +271 -0
  170. package/node_modules/@sdd-agent-platform/core/src/execution/wave-executor.test.ts +4 -0
  171. package/node_modules/@sdd-agent-platform/core/src/governance/policy.test.ts +2 -0
  172. package/node_modules/@sdd-agent-platform/core/src/instructions.test.ts +11 -5
  173. package/node_modules/@sdd-agent-platform/core/src/instructions.ts +36 -36
  174. package/node_modules/@sdd-agent-platform/core/src/lifecycle/ship.ts +39 -17
  175. package/node_modules/@sdd-agent-platform/core/src/phase8-contracts.test.ts +3 -2
  176. package/node_modules/@sdd-agent-platform/core/src/phase8-risk-kernel.test.ts +5 -0
  177. package/node_modules/@sdd-agent-platform/core/src/planning/task-graph.test.ts +2 -0
  178. package/node_modules/@sdd-agent-platform/core/src/planning/wave-plan.test.ts +3 -0
  179. package/node_modules/@sdd-agent-platform/core/src/registries/agent-capability-catalog.ts +269 -17
  180. package/node_modules/@sdd-agent-platform/core/src/registries/agent-registry.ts +2 -2
  181. package/node_modules/@sdd-agent-platform/core/src/registries/agent-runtime-static.ts +41 -1
  182. package/node_modules/@sdd-agent-platform/core/src/registries/capability-sources.ts +238 -15
  183. package/node_modules/@sdd-agent-platform/core/src/registries/registries.test.ts +27 -2
  184. package/node_modules/@sdd-agent-platform/core/src/registries/workflow-gates.ts +5 -5
  185. package/node_modules/@sdd-agent-platform/core/src/router/agent-runtime-config.ts +31 -12
  186. package/node_modules/@sdd-agent-platform/core/src/router/agent-runtime.ts +66 -1
  187. package/node_modules/@sdd-agent-platform/core/src/router/route-projection.ts +211 -0
  188. package/node_modules/@sdd-agent-platform/core/src/router/route-sdd-task.test.ts +151 -3
  189. package/node_modules/@sdd-agent-platform/core/src/router/routing.ts +35 -6
  190. package/node_modules/@sdd-agent-platform/core/src/router/runtime-inspection.ts +11 -4
  191. package/node_modules/@sdd-agent-platform/core/src/router/runtime-validation.ts +32 -3
  192. package/node_modules/@sdd-agent-platform/core/src/run-state/artifacts.ts +48 -15
  193. package/node_modules/@sdd-agent-platform/core/src/run-state/events.ts +2 -2
  194. package/node_modules/@sdd-agent-platform/core/src/run-state/inspect-run.ts +17 -52
  195. package/node_modules/@sdd-agent-platform/core/src/run-state/invocation-ledger.ts +2 -2
  196. package/node_modules/@sdd-agent-platform/core/src/run-state/model.ts +28 -1
  197. package/node_modules/@sdd-agent-platform/core/src/run-state/run-state.test.ts +3 -0
  198. package/node_modules/@sdd-agent-platform/core/src/run-state/run-state.ts +22 -18
  199. package/node_modules/@sdd-agent-platform/core/src/run-state/task-evidence.ts +206 -0
  200. package/node_modules/@sdd-agent-platform/core/src/run-state.ts +1 -0
  201. package/node_modules/@sdd-agent-platform/core/src/runtime-paths.ts +54 -14
  202. package/node_modules/@sdd-agent-platform/core/src/sdd-docs/context.ts +1 -1
  203. package/node_modules/@sdd-agent-platform/core/src/sdd-docs/document-hashes.ts +207 -0
  204. package/node_modules/@sdd-agent-platform/core/src/sdd-docs/run-binding.ts +12 -3
  205. package/node_modules/@sdd-agent-platform/core/src/sdd-docs/task-parser.test.ts +139 -0
  206. package/node_modules/@sdd-agent-platform/core/src/sdd-docs/task-parser.ts +137 -24
  207. package/node_modules/@sdd-agent-platform/core/src/status/project-status.ts +268 -5
  208. package/node_modules/@sdd-agent-platform/core/src/storage/runtime-store.test.ts +368 -4
  209. package/node_modules/@sdd-agent-platform/core/src/storage/runtime-store.ts +697 -2
  210. package/node_modules/@sdd-agent-platform/core/src/sync-back/apply.ts +23 -1
  211. package/node_modules/@sdd-agent-platform/core/src/sync-back/inspect.ts +145 -12
  212. package/node_modules/@sdd-agent-platform/core/src/sync-back/sync-back.test.ts +132 -9
  213. package/node_modules/@sdd-agent-platform/core/src/test-support/fixtures.ts +21 -0
  214. package/node_modules/@sdd-agent-platform/core/src/test-support/run-state.ts +16 -2
  215. package/node_modules/@sdd-agent-platform/core/src/verification/goal-verify.test.ts +1 -1
  216. package/node_modules/@sdd-agent-platform/core/src/verification/goal-verify.ts +38 -5
  217. package/node_modules/@sdd-agent-platform/core/src/verification/rendering.ts +15 -5
  218. package/node_modules/@sdd-agent-platform/core/src/verification/review-gate.test.ts +77 -0
  219. package/node_modules/@sdd-agent-platform/core/src/verification/review-gate.ts +77 -0
  220. package/node_modules/@sdd-agent-platform/core/src/verification/single-task-loop.test.ts +64 -4
  221. package/node_modules/@sdd-agent-platform/core/src/verification/single-task-loop.ts +110 -12
  222. package/node_modules/@sdd-agent-platform/core/src/verification/test-runtime.test.ts +72 -25
  223. package/node_modules/@sdd-agent-platform/core/src/verification/test-runtime.ts +402 -77
  224. package/node_modules/@sdd-agent-platform/core/src/verification/validation-wave.test.ts +341 -0
  225. package/node_modules/@sdd-agent-platform/core/src/verification/validation-wave.ts +513 -0
  226. package/node_modules/@sdd-agent-platform/core/src/verification/verify-contract.test.ts +144 -5
  227. package/node_modules/@sdd-agent-platform/core/src/verification/verify-contract.ts +129 -18
  228. package/node_modules/@sdd-agent-platform/core/src/verification.ts +2 -0
  229. package/node_modules/@sdd-agent-platform/core/src/workflow-gate/evidence-packet.ts +196 -0
  230. package/node_modules/@sdd-agent-platform/core/src/workflow-gate/hard-checks.test.ts +171 -0
  231. package/node_modules/@sdd-agent-platform/core/src/workflow-gate/hard-checks.ts +143 -0
  232. package/node_modules/@sdd-agent-platform/core/src/workflow-gate/policy.test.ts +137 -0
  233. package/node_modules/@sdd-agent-platform/core/src/workflow-gate/policy.ts +155 -0
  234. package/node_modules/@sdd-agent-platform/core/src/workflow-gate/types.ts +114 -0
  235. package/node_modules/@sdd-agent-platform/core/src/workflow-state/affected-file-conflicts.ts +18 -1
  236. package/node_modules/@sdd-agent-platform/core/src/workflow-state/dependencies.test.ts +1 -1
  237. package/node_modules/@sdd-agent-platform/core/src/workflow-state/dependencies.ts +33 -11
  238. package/node_modules/@sdd-agent-platform/core/src/workflow-state/latest-eligible-run.ts +156 -0
  239. package/node_modules/@sdd-agent-platform/core/src/workflow-state/resolve.test.ts +351 -2
  240. package/node_modules/@sdd-agent-platform/core/src/workflow-state/resolve.ts +227 -39
  241. package/node_modules/@sdd-agent-platform/core/src/workflow-state.ts +1 -0
  242. package/package.json +1 -1
  243. package/packages/cli/dist/commands/status.js +2 -2
  244. package/packages/cli/dist/commands/status.js.map +1 -1
  245. package/packages/cli/dist/commands/sync-back.js +1 -1
  246. package/packages/cli/dist/commands/sync-back.js.map +1 -1
  247. package/packages/cli/dist/commands/tasks.js +4 -4
  248. package/packages/cli/dist/commands/tasks.js.map +1 -1
  249. package/packages/cli/dist/commands/test.js +94 -5
  250. package/packages/cli/dist/commands/test.js.map +1 -1
  251. package/packages/cli/dist/commands/verifies.js +5 -3
  252. package/packages/cli/dist/commands/verifies.js.map +1 -1
  253. package/packages/cli/dist/commands/verify.js +48 -7
  254. package/packages/cli/dist/commands/verify.js.map +1 -1
  255. package/packages/cli/dist/help.js +32 -18
  256. package/packages/cli/dist/help.js.map +1 -1
  257. package/packages/cli/dist/renderers/artifacts.js +1 -1
  258. package/packages/cli/dist/renderers/artifacts.js.map +1 -1
  259. package/packages/cli/dist/renderers/registry-runtime.js +7 -2
  260. package/packages/cli/dist/renderers/registry-runtime.js.map +1 -1
  261. package/packages/cli/dist/renderers/router.js +4 -2
  262. package/packages/cli/dist/renderers/router.js.map +1 -1
  263. package/packages/cli/dist/renderers/workflow.js +33 -12
  264. package/packages/cli/dist/renderers/workflow.js.map +1 -1
  265. package/packages/cli/dist/tsconfig.tsbuildinfo +1 -1
  266. package/packages/cli/package.json +2 -2
  267. package/packages/core/dist/ai-tools.js +31 -28
  268. package/packages/core/dist/ai-tools.js.map +1 -1
  269. package/packages/core/dist/config/init-project.js +3 -2
  270. package/packages/core/dist/config/init-project.js.map +1 -1
  271. package/packages/core/dist/config/starter-documents.d.ts +1 -1
  272. package/packages/core/dist/config/starter-documents.js +14 -5
  273. package/packages/core/dist/config/starter-documents.js.map +1 -1
  274. package/packages/core/dist/contracts.d.ts +2 -0
  275. package/packages/core/dist/contracts.js +2 -0
  276. package/packages/core/dist/contracts.js.map +1 -1
  277. package/packages/core/dist/doctor/checks/run-evidence.js +3 -3
  278. package/packages/core/dist/doctor/checks/run-evidence.js.map +1 -1
  279. package/packages/core/dist/doctor/doctor.js +155 -1
  280. package/packages/core/dist/doctor/doctor.js.map +1 -1
  281. package/packages/core/dist/evidence/lookup.d.ts +23 -0
  282. package/packages/core/dist/evidence/lookup.js +54 -0
  283. package/packages/core/dist/evidence/lookup.js.map +1 -0
  284. package/packages/core/dist/evidence-runtime/contracts.d.ts +11 -0
  285. package/packages/core/dist/execution/agent-execution-records.js +15 -8
  286. package/packages/core/dist/execution/agent-execution-records.js.map +1 -1
  287. package/packages/core/dist/execution/resident-worker.js +14 -6
  288. package/packages/core/dist/execution/resident-worker.js.map +1 -1
  289. package/packages/core/dist/execution/stage-team-runtime.d.ts +112 -0
  290. package/packages/core/dist/execution/stage-team-runtime.js +145 -0
  291. package/packages/core/dist/execution/stage-team-runtime.js.map +1 -0
  292. package/packages/core/dist/instructions.js +36 -36
  293. package/packages/core/dist/instructions.js.map +1 -1
  294. package/packages/core/dist/lifecycle/ship.d.ts +2 -0
  295. package/packages/core/dist/lifecycle/ship.js +37 -17
  296. package/packages/core/dist/lifecycle/ship.js.map +1 -1
  297. package/packages/core/dist/registries/agent-capability-catalog.d.ts +16 -1
  298. package/packages/core/dist/registries/agent-capability-catalog.js +174 -16
  299. package/packages/core/dist/registries/agent-capability-catalog.js.map +1 -1
  300. package/packages/core/dist/registries/agent-registry.js +2 -2
  301. package/packages/core/dist/registries/agent-registry.js.map +1 -1
  302. package/packages/core/dist/registries/agent-runtime-static.d.ts +10 -0
  303. package/packages/core/dist/registries/agent-runtime-static.js +31 -1
  304. package/packages/core/dist/registries/agent-runtime-static.js.map +1 -1
  305. package/packages/core/dist/registries/capability-sources.d.ts +2 -17
  306. package/packages/core/dist/registries/capability-sources.js +222 -10
  307. package/packages/core/dist/registries/capability-sources.js.map +1 -1
  308. package/packages/core/dist/registries/workflow-gates.js +5 -5
  309. package/packages/core/dist/registries/workflow-gates.js.map +1 -1
  310. package/packages/core/dist/router/agent-runtime-config.js +27 -12
  311. package/packages/core/dist/router/agent-runtime-config.js.map +1 -1
  312. package/packages/core/dist/router/agent-runtime.d.ts +59 -1
  313. package/packages/core/dist/router/route-projection.d.ts +3 -1
  314. package/packages/core/dist/router/route-projection.js +191 -0
  315. package/packages/core/dist/router/route-projection.js.map +1 -1
  316. package/packages/core/dist/router/routing.js +32 -6
  317. package/packages/core/dist/router/routing.js.map +1 -1
  318. package/packages/core/dist/router/runtime-inspection.js +11 -4
  319. package/packages/core/dist/router/runtime-inspection.js.map +1 -1
  320. package/packages/core/dist/router/runtime-validation.js +31 -3
  321. package/packages/core/dist/router/runtime-validation.js.map +1 -1
  322. package/packages/core/dist/run-state/artifacts.js +48 -15
  323. package/packages/core/dist/run-state/artifacts.js.map +1 -1
  324. package/packages/core/dist/run-state/events.js +2 -2
  325. package/packages/core/dist/run-state/events.js.map +1 -1
  326. package/packages/core/dist/run-state/inspect-run.d.ts +3 -1
  327. package/packages/core/dist/run-state/inspect-run.js +15 -49
  328. package/packages/core/dist/run-state/inspect-run.js.map +1 -1
  329. package/packages/core/dist/run-state/invocation-ledger.js +2 -2
  330. package/packages/core/dist/run-state/invocation-ledger.js.map +1 -1
  331. package/packages/core/dist/run-state/model.d.ts +25 -1
  332. package/packages/core/dist/run-state/run-state.js +21 -14
  333. package/packages/core/dist/run-state/run-state.js.map +1 -1
  334. package/packages/core/dist/run-state/task-evidence.d.ts +62 -0
  335. package/packages/core/dist/run-state/task-evidence.js +130 -0
  336. package/packages/core/dist/run-state/task-evidence.js.map +1 -0
  337. package/packages/core/dist/run-state.d.ts +1 -0
  338. package/packages/core/dist/run-state.js +1 -0
  339. package/packages/core/dist/run-state.js.map +1 -1
  340. package/packages/core/dist/runtime-paths.d.ts +10 -0
  341. package/packages/core/dist/runtime-paths.js +44 -14
  342. package/packages/core/dist/runtime-paths.js.map +1 -1
  343. package/packages/core/dist/sdd-docs/context.js +1 -1
  344. package/packages/core/dist/sdd-docs/context.js.map +1 -1
  345. package/packages/core/dist/sdd-docs/document-hashes.d.ts +4 -0
  346. package/packages/core/dist/sdd-docs/document-hashes.js +189 -0
  347. package/packages/core/dist/sdd-docs/document-hashes.js.map +1 -0
  348. package/packages/core/dist/sdd-docs/run-binding.js +12 -3
  349. package/packages/core/dist/sdd-docs/run-binding.js.map +1 -1
  350. package/packages/core/dist/sdd-docs/task-parser.d.ts +20 -0
  351. package/packages/core/dist/sdd-docs/task-parser.js +101 -21
  352. package/packages/core/dist/sdd-docs/task-parser.js.map +1 -1
  353. package/packages/core/dist/status/project-status.d.ts +62 -1
  354. package/packages/core/dist/status/project-status.js +192 -4
  355. package/packages/core/dist/status/project-status.js.map +1 -1
  356. package/packages/core/dist/storage/runtime-store.d.ts +195 -2
  357. package/packages/core/dist/storage/runtime-store.js +499 -2
  358. package/packages/core/dist/storage/runtime-store.js.map +1 -1
  359. package/packages/core/dist/sync-back/apply.js +23 -1
  360. package/packages/core/dist/sync-back/apply.js.map +1 -1
  361. package/packages/core/dist/sync-back/inspect.d.ts +19 -0
  362. package/packages/core/dist/sync-back/inspect.js +114 -12
  363. package/packages/core/dist/sync-back/inspect.js.map +1 -1
  364. package/packages/core/dist/test-support/fixtures.js +21 -0
  365. package/packages/core/dist/test-support/fixtures.js.map +1 -1
  366. package/packages/core/dist/test-support/run-state.js +16 -2
  367. package/packages/core/dist/test-support/run-state.js.map +1 -1
  368. package/packages/core/dist/tsconfig.tsbuildinfo +1 -1
  369. package/packages/core/dist/verification/goal-verify.js +34 -2
  370. package/packages/core/dist/verification/goal-verify.js.map +1 -1
  371. package/packages/core/dist/verification/rendering.js +15 -5
  372. package/packages/core/dist/verification/rendering.js.map +1 -1
  373. package/packages/core/dist/verification/review-gate.d.ts +22 -0
  374. package/packages/core/dist/verification/review-gate.js +53 -0
  375. package/packages/core/dist/verification/review-gate.js.map +1 -0
  376. package/packages/core/dist/verification/single-task-loop.js +102 -9
  377. package/packages/core/dist/verification/single-task-loop.js.map +1 -1
  378. package/packages/core/dist/verification/test-runtime.d.ts +16 -1
  379. package/packages/core/dist/verification/test-runtime.js +355 -69
  380. package/packages/core/dist/verification/test-runtime.js.map +1 -1
  381. package/packages/core/dist/verification/validation-wave.d.ts +58 -0
  382. package/packages/core/dist/verification/validation-wave.js +428 -0
  383. package/packages/core/dist/verification/validation-wave.js.map +1 -0
  384. package/packages/core/dist/verification/verify-contract.d.ts +2 -0
  385. package/packages/core/dist/verification/verify-contract.js +116 -18
  386. package/packages/core/dist/verification/verify-contract.js.map +1 -1
  387. package/packages/core/dist/verification.d.ts +2 -0
  388. package/packages/core/dist/verification.js +2 -0
  389. package/packages/core/dist/verification.js.map +1 -1
  390. package/packages/core/dist/workflow-gate/evidence-packet.d.ts +24 -0
  391. package/packages/core/dist/workflow-gate/evidence-packet.js +182 -0
  392. package/packages/core/dist/workflow-gate/evidence-packet.js.map +1 -0
  393. package/packages/core/dist/workflow-gate/hard-checks.d.ts +4 -0
  394. package/packages/core/dist/workflow-gate/hard-checks.js +130 -0
  395. package/packages/core/dist/workflow-gate/hard-checks.js.map +1 -0
  396. package/packages/core/dist/workflow-gate/policy.d.ts +4 -0
  397. package/packages/core/dist/workflow-gate/policy.js +146 -0
  398. package/packages/core/dist/workflow-gate/policy.js.map +1 -0
  399. package/packages/core/dist/workflow-gate/types.d.ts +89 -0
  400. package/packages/core/dist/workflow-gate/types.js +2 -0
  401. package/packages/core/dist/workflow-gate/types.js.map +1 -0
  402. package/packages/core/dist/workflow-state/affected-file-conflicts.d.ts +1 -0
  403. package/packages/core/dist/workflow-state/affected-file-conflicts.js +16 -1
  404. package/packages/core/dist/workflow-state/affected-file-conflicts.js.map +1 -1
  405. package/packages/core/dist/workflow-state/dependencies.d.ts +8 -4
  406. package/packages/core/dist/workflow-state/dependencies.js +25 -11
  407. package/packages/core/dist/workflow-state/dependencies.js.map +1 -1
  408. package/packages/core/dist/workflow-state/latest-eligible-run.d.ts +38 -0
  409. package/packages/core/dist/workflow-state/latest-eligible-run.js +122 -0
  410. package/packages/core/dist/workflow-state/latest-eligible-run.js.map +1 -0
  411. package/packages/core/dist/workflow-state/resolve.d.ts +27 -0
  412. package/packages/core/dist/workflow-state/resolve.js +166 -37
  413. package/packages/core/dist/workflow-state/resolve.js.map +1 -1
  414. package/packages/core/dist/workflow-state.d.ts +1 -0
  415. package/packages/core/dist/workflow-state.js +1 -0
  416. package/packages/core/dist/workflow-state.js.map +1 -1
  417. package/packages/core/package.json +1 -1
@@ -88,15 +88,15 @@ Use the local or globally installed \`sdd\` CLI as the source of truth for this
88
88
 
89
89
  1. Accept the user's natural-language intent, then run \`sdd status\` first and report only workflow state, blocker/current task, and the recommended next command; do not paste or restate full status unless asked.
90
90
  2. Run \`sdd instructions overview --json\` only when the next action is unclear or you need the full dynamic command contract.
91
- 3. Dynamic routing comes from CLI/core output, not this skill text; follow the recommended next command before choosing a dedicated \`/sdd:*\` entry.
92
- 4. If the intent is still ambiguous after status, ask one clarifying question before spec/plan/do/test/sync-back/ship work.
91
+ 3. Dynamic routing comes from CLI/core output, not this skill text; follow the recommended next command before choosing a projected command entry (\`spec\`, \`plan\`, \`tasks\`, \`do\`, \`test\`, \`ship\`, or \`doctor\`).
92
+ 4. If the intent is still ambiguous after status, ask one clarifying question before spec/plan/do/test/ship work.
93
93
  5. For risky requests that mention state-machine, concurrency, database, SQL, security, API/schema, CI/build, or external unknowns, run \`sdd lifecycle decide --from-text <text>\` before spec/plan work.
94
- 6. If status reports workflow_status=not_started, use \`/sdd:spec\` to create the current Git branch partition; do not use \`sdd init\` as the workflow branch entry.
94
+ 6. If status reports workflow_status=not_started, start the spec stage for the resolved Git branch partition; do not use \`sdd init\` as the workflow branch entry.
95
95
  7. If status points to gaps, drift, or doctor/update work, handle that maintenance action before do/test/ship.
96
- 8. If status recommends a task, run \`sdd tasks inspect <task_id>\` and use the task Boundary and Acceptance before offering \`/sdd:do\`.
97
- 9. If status recommends do, test, or sync-back, follow the dedicated \`/sdd:do\`, \`/sdd:test\`, or \`/sdd:sync-back\` entry instead of inferring completion from chat.
98
- 10. If status recommends sync-back, use \`/sdd:sync-back\` to run \`sdd sync-back inspect --branch <branch> --task <task_id>\` first and follow apply_policy; pass an explicit run id only for replay/CI/old-run inspection. Direct-safe tasks may apply directly, confirm-required tasks need human confirmation and \`--approved\`.
99
- 11. If the user asks to release or go online, use \`/sdd:ship\` / \`sdd ship --branch <branch> --dry-run\` for local readiness first; do not publish, push, tag, or create external release state without explicit confirmation.
96
+ 8. If status recommends a task, run \`sdd tasks inspect <task_id>\` and use the task Boundary and Acceptance before starting \`do\`.
97
+ 9. If status recommends do or test, follow the corresponding projected command entry or its canonical CLI command instead of inferring completion from chat.
98
+ 10. If status exposes legacy sync-back or projection drift, treat \`sdd sync-back inspect|apply\` as diagnostic/recovery/replay only; do not insert it into the ordinary happy path.
99
+ 11. If the user asks to release or go online, run \`sdd ship --branch <branch> --dry-run\` for local readiness first; do not publish, push, tag, or create external release state without explicit confirmation.
100
100
 
101
101
  Refresh this managed skill with \`sdd update\` when drift is reported.
102
102
  `
@@ -119,7 +119,7 @@ sdd instructions spec --json
119
119
 
120
120
  Then create or refine \`specs/<partition>/spec.md\` with objective/customer value, problem/intent, users/actors, user stories or scenarios, in-scope/out-of-scope boundaries, functional and non-functional requirements, acceptance criteria with stable IDs such as AC-1, assumptions/dependencies, risks/hard gates, open questions, and lifecycle decision reference.
121
121
 
122
- Repeated /sdd:spec calls represent requirement revisions. If plan/tasks/run evidence already exists, status must expose stale downstream hash state before plan/tasks/do continues.
122
+ Repeated spec-stage revisions represent requirement revisions. If plan/tasks/run evidence already exists, status must expose stale downstream hash state before plan/tasks/do continues.
123
123
 
124
124
  Do not design implementation in \`spec.md\`; stop before plan work when requirements, acceptance IDs, or risk gates are unclear.
125
125
  `
@@ -129,7 +129,7 @@ Do not design implementation in \`spec.md\`; stop before plan work when requirem
129
129
  kind: 'command',
130
130
  relativePath: '.claude/commands/sdd/plan.md',
131
131
  title: 'SDD plan',
132
- body: `Refine the existing SDD plan document as a deliverable technical solution, not a lightweight approach summary. Include based_on_spec_hash from status so later /sdd:spec revisions can mark this plan stale. Agent visibility: scout/planner/spec-reviewer may participate; evidence lands in plan or review artifacts.
132
+ body: `Refine the existing SDD plan document as a deliverable technical solution, not a lightweight approach summary. Include based_on_spec_hash from status so later spec-stage revisions can mark this plan stale. Agent visibility: scout/planner/spec-reviewer may participate; evidence lands in plan or review artifacts.
133
133
 
134
134
  Run:
135
135
 
@@ -149,7 +149,7 @@ Stop before creating tasks when the technical solution is incomplete or has unre
149
149
  kind: 'command',
150
150
  relativePath: '.claude/commands/sdd/tasks.md',
151
151
  title: 'SDD tasks',
152
- body: `Refine the existing SDD tasks document as an executable evidence contract, not a plain TODO list or project-management backlog. Include based_on_plan_hash from status so later plan/spec revisions can mark these tasks stale. Agent visibility: planner/reviewer may participate; execution evidence later lands in implement/review/validation artifacts.
152
+ body: `Refine the existing SDD tasks stage outputs as executable task and verification contracts, not a plain TODO list or project-management backlog. Include based_on_plan_hash from status so later plan/spec revisions can mark these contracts stale. Agent visibility: task-planner writes tasks.md; task-quality, dependency/parallelization, validation-strategy, verification-designer, and verification-reviewer roles may participate before contracts freeze.
153
153
 
154
154
  Run:
155
155
 
@@ -158,9 +158,9 @@ sdd instructions tasks --json
158
158
  sdd tasks format
159
159
  \`\`\`
160
160
 
161
- Then write or refine \`specs/<branch>/tasks.md\` from the approved spec and plan. Include Delivery Map, Wave Plan, task blocks with acceptance_refs and plan_refs, affected_files, validation, risk, agent_fit, allowed_agents, required_artifacts, verification_availability, autonomy, plus companion sections for Boundary, Acceptance, Definition of Done, Evidence Expectations, and Implementation Notes.
161
+ Then write or refine \`specs/<branch>/tasks.md\` from the approved spec and plan, and ensure \`specs/<branch>/verify.md\` is created or refreshed by the verification-designer after the task contract is stable. Include Delivery Map, implementation waves, validation batches/waves, review gate declarations, task blocks with acceptance_refs and plan_refs, affected_files, change_surface, implementation_wave, validation_batch, validation_timing, requires_verify_before_next, validation, risk, agent_fit, allowed_agents, required_artifacts, verification_availability, autonomy, plus companion sections for Boundary, Acceptance, Definition of Done, Evidence Expectations, and Implementation Notes.
162
162
 
163
- Keep metadata inside the \`\`\`sdd-task fenced block and companion sections outside it. Stop before \`sdd do task\` when task boundary, acceptance refs, plan refs, or evidence requirements are unclear.
163
+ Keep metadata inside the \`\`\`sdd-task fenced block and companion sections outside it. Use \`validation_timing: task_end\` and \`requires_verify_before_next: true\` for strict/high-risk tasks; use \`batch_end\` or \`wave_end\` with \`validation_batch\` only when sequential accumulation is safe. Frontend-only tasks must not declare Maven/Gradle backend build validation. Stop before \`sdd do task\` when task boundary, acceptance refs, plan refs, evidence requirements, validation batches/waves, or verify contract expectations are unclear.
164
164
  `
165
165
  },
166
166
  {
@@ -168,25 +168,28 @@ Keep metadata inside the \`\`\`sdd-task fenced block and companion sections outs
168
168
  kind: 'command',
169
169
  relativePath: '.claude/commands/sdd/test.md',
170
170
  title: 'SDD test',
171
- body: `Execute task validation commands, capture command output, evaluate acceptance evidence coverage, and return one unified test judgment for the task.
171
+ body: `Execute validation from the frozen tasks.md + verify.md contract, capture command output, evaluate acceptance evidence coverage, and return one unified test or validation-wave judgment.
172
172
 
173
173
  Run:
174
174
 
175
175
  \`\`\`bash
176
176
  sdd status
177
177
  sdd instructions test --json
178
- sdd verifies inspect --branch <branch>
178
+ # sdd test consumes the current verify.md contract and blocks if it is missing or stale; do not generate verify.md here.
179
179
  sdd test task <task_id> --branch <branch>
180
+ sdd test batch <batch_id> --branch <branch>
181
+ sdd test wave --branch <branch> --wave <n>
180
182
  \`\`\`
181
183
 
182
184
  Workflow:
183
185
 
184
- 1. Confirm \`verify.md\` exists and is current for the selected branch.
185
- 2. Run \`sdd test task <task_id> --branch <branch>\` to execute task validation commands and evaluate mapped acceptance coverage; use \`--command\` only for a deliberate narrowed override.
186
- 3. Treat generated command logs, test index, validator artifact, and unified evidence projection as runtime evidence references, not as workflow documents.
187
- 4. If \`/sdd:test\` returns PASS, proceed to \`/sdd:sync-back\` / \`sdd sync-back inspect\`; if it returns FAIL or BLOCKED, fix the reported command or evidence gaps and rerun \`/sdd:test\`.
186
+ 1. Confirm \`verify.md\` exists and is current for the selected branch; if it is missing or stale, return to \`/sdd:tasks\` or use explicit \`sdd verifies write\` recovery before testing.
187
+ 2. Use \`sdd test task <task_id>\` for strict or task_end tasks, or for deliberate narrowed overrides with \`--command\`, \`--run\`, \`--command-json\`, \`--command-file\`, or passthrough argv.
188
+ 3. For batch_end or wave_end tasks, use the verify-declared \`sdd test batch <batch_id>\` or \`sdd test wave\` boundary so accumulated implementation evidence is judged together; default \`sdd test task\` routes batch_end tasks to their batch and wave_end tasks to their wave boundary.
189
+ 4. Treat generated command logs, test index, validator artifact, acceptance maps, and workflow gate decisions as runtime evidence references, not as workflow documents.
190
+ 5. If validation returns PASS, proceed to a decision card if policy requires one, otherwise run \`sdd ship --branch <branch> --dry-run\`; if it returns FAIL or BLOCKED, fix the reported command or evidence gaps and rerun the same test boundary.
188
191
 
189
- Do not auto-fix failures, create sync-back proposals, commit, publish, or treat command success alone as semantic PASS.
192
+ Do not auto-fix failures, author or refresh \`verify.md\`, mutate \`tasks.md\`, apply sync-back, commit, publish, or treat command success alone as semantic PASS.
190
193
  `
191
194
  },
192
195
  {
@@ -212,10 +215,10 @@ Agent evidence flow: scout gathers bounded context only; implementer edits only
212
215
  1. Resolve exactly one task id from the user request or from the \`sdd status\` recommended next command. Stop and ask if it is ambiguous.
213
216
  2. Read \`sdd tasks inspect <task_id>\` and restate the task Boundary, Acceptance, gaps, and validation commands.
214
217
  3. Work only inside the selected task boundary; do not expand scope without a checkpoint.
215
- 4. Before creating explicit result artifacts, use templates such as \`sdd artifact template artifacts/implement-<task_id>.md --task <task_id> --agent implementer\`, \`sdd artifact template artifacts/review-<task_id>.md --task <task_id> --agent reviewer\`, and \`sdd artifact template artifacts/validation-<task_id>.md --task <task_id> --agent validator\`; save the physical file under branch evidence \`.sdd/runs/<branchSlug>/evidence/artifacts/\`, pass the run-relative \`artifacts/<file>\` path to CLI flags, and keep source/test files in \`## Evidence\`, not in \`sdd-result.artifacts\`.
218
+ 4. Before creating explicit result artifacts, create the task run first, then write templates through the CLI writer: \`sdd artifact template artifacts/implement-<task_id>.md --task <task_id> --agent implementer --run <run_id> --write\`, \`sdd artifact template artifacts/review-<task_id>.md --task <task_id> --agent reviewer --run <run_id> --write\`, and \`sdd artifact template artifacts/validation-<task_id>.md --task <task_id> --agent validator --run <run_id> --write\`; do not manually create copies under \`specs/<branch>/artifacts/\` or \`specs/<branch>/evidence/artifacts/\`. Pass the run-relative \`artifacts/<file>\` path to CLI flags, and keep source/test files in \`## Evidence\`, not in \`sdd-result.artifacts\`.
216
219
  5. Run \`sdd artifact validate <run_id> <artifact> --task <task_id> --agent <agent>\` before passing artifacts into \`sdd do task <task_id>\`.
217
220
  6. Run \`sdd do task <task_id>\` with explicit artifact paths when evidence is available; this path records Phase 3 artifact ingestion evidence for doctor.
218
- 7. Report the run id, status, agent evidence artifacts, gaps, and next gate. If completed, recommend \`/sdd:test\` / \`sdd test task <task_id> --branch <branch>\` so command execution and acceptance coverage are judged together.
221
+ 7. Report the run id, status, agent evidence artifacts, gaps, and next gate. If completed, follow the \`sdd status\` recommended next command: continue sequential \`sdd do task\` when safe, run \`sdd test task\` for strict/task_end work, or run \`sdd test batch\` / \`sdd test wave\` at the declared validation boundary.
219
222
 
220
223
  Do not create worktrees, auto commit, or mark missing evidence as PASS.
221
224
  `
@@ -225,7 +228,7 @@ Do not create worktrees, auto commit, or mark missing evidence as PASS.
225
228
  kind: 'command',
226
229
  relativePath: '.claude/commands/sdd/sync-back.md',
227
230
  title: 'SDD sync-back',
228
- body: `Inspect and optionally apply the verified task completion proposal back into tasks.md. Sync-back is a document write-back gate, not another implementation step.
231
+ body: `Inspect or replay legacy task completion write-back state for diagnostic, recovery, or compatibility use. Sync-back is a low-level projection repair command, not an ordinary happy-path workflow stage.
229
232
 
230
233
  Run:
231
234
 
@@ -235,16 +238,16 @@ sdd instructions sync-back --json
235
238
  sdd sync-back inspect --branch <branch> --task <task_id>
236
239
  \`\`\`
237
240
 
238
- Workflow:
241
+ Diagnostic workflow:
239
242
 
240
- 1. Resolve exactly one task id and workflow partition from \`sdd status\`, the recommended command, or the user request. Stop and ask if either is ambiguous.
243
+ 1. Resolve exactly one task id and workflow partition from an explicit recovery request, old run replay, CI inspection, or doctor/status diagnostic. Stop and ask if either is ambiguous.
241
244
  2. Run \`sdd sync-back inspect --branch <branch> --task <task_id>\` before any apply; pass \`<run_id>\` only for replay, CI, or old-run inspection.
242
245
  3. Report what apply would write: target tasks file, task id, markdown status transition, proposal path, evidence artifacts, apply_policy, and policy reasons.
243
- 4. If inspect reports \`status=ready\` and \`apply_policy=direct\`, run \`sdd sync-back apply --branch <branch> --task <task_id>\`.
246
+ 4. If inspect reports \`status=ready\` and \`apply_policy=direct\`, run \`sdd sync-back apply --branch <branch> --task <task_id>\` only for explicit recovery/replay.
244
247
  5. If inspect reports approval_required=true, ask for explicit human confirmation and only then run \`sdd sync-back apply --branch <branch> --task <task_id> --approved\`.
245
- 6. Explain that apply writes only tasks.md for the target task, appends the sync-back implementation note, marks run sync_back applied, and rebuilds the local run index.
248
+ 6. Explain that default apply writes only tasks.md for the target task, appends the sync-back implementation note, marks run sync_back applied, and rebuilds the local run index; \`--refresh-verify\` is an explicit recovery option after reviewed task-contract changes.
246
249
 
247
- Do not apply without inspect, do not use \`--approved\` without human confirmation, and do not change source files during sync-back.
250
+ Do not apply without inspect, do not use \`--approved\` without human confirmation, do not change source files during sync-back, and do not recommend sync-back after normal \`/sdd:test\` PASS.
248
251
  `
249
252
  },
250
253
  {
@@ -340,7 +343,7 @@ function workflowCommandEntry(id: string, relativePath: string, action: string,
340
343
  kind: 'command',
341
344
  relativePath,
342
345
  title: `SDD ${action}`,
343
- body: `${summary}\n\nRun:\n\n\`\`\`bash\nsdd instructions ${action} --json\n${helperCommand}\n\`\`\`\n\nUse the helper command output as the canonical format reference. Keep harness metadata such as agent_fit, verification_availability, autonomy, allowed_agents, and required_artifacts inside the fenced sdd-task block; keep companion sections such as #### Boundary and #### Acceptance outside the fence. Then follow the returned CLI/core instruction payload.\n`
346
+ body: `${summary}\n\nRun:\n\n\`\`\`bash\nsdd instructions ${action} --json\n${helperCommand}\n\`\`\`\n\nUse the helper command output as the canonical format reference. Keep harness metadata such as change_surface, implementation_wave, validation_batch, validation_timing, requires_verify_before_next, agent_fit, verification_availability, autonomy, allowed_agents, and required_artifacts inside the fenced sdd-task block; keep companion sections such as #### Boundary and #### Acceptance outside the fence. Then follow the returned CLI/core instruction payload.\n`
344
347
  };
345
348
  }
346
349
 
@@ -1,21 +1,21 @@
1
1
  import test from 'node:test';
2
2
  import assert from 'node:assert/strict';
3
- import { mkdtemp, rm } from 'node:fs/promises';
3
+ import { mkdir, mkdtemp, rm, stat, writeFile } from 'node:fs/promises';
4
4
  import { tmpdir } from 'node:os';
5
5
  import path from 'node:path';
6
6
 
7
7
  import { initProject } from '../config/init-project.js';
8
8
  import { writeArtifact } from '../run-state/artifacts.js';
9
9
  import { createRun } from '../run-state/run-state.js';
10
- import { validTaskMarkdown, writeBranchDocs } from '../test-support/fixtures.js';
11
- import { getArtifactPath, getRunRelativeArtifactPath, toArtifactRootRelativePath } from '../runtime-paths.js';
10
+ import { validResultArtifact, validTaskMarkdown, writeBranchDocs } from '../test-support/fixtures.js';
11
+ import { getLegacyArtifactPath, getRunRelativeArtifactPath, toArtifactRootRelativePath } from '../runtime-paths.js';
12
12
  import { parseSddResultMarkdown, validateSddResultArtifact } from './sdd-result.js';
13
13
  import { renderSddResultArtifactTemplate } from './templates.js';
14
14
 
15
15
  test('artifact path cannot escape artifacts directory', async () => {
16
16
  const root = await mkdtemp(path.join(tmpdir(), 'sdd-runtime-'));
17
17
  try {
18
- assert.throws(() => getArtifactPath(root, 'run-1', '../outside.md'), /escapes artifacts directory/);
18
+ assert.throws(() => getLegacyArtifactPath(root, 'run-1', '../outside.md'), /escapes artifacts directory/);
19
19
  } finally {
20
20
  await rm(root, { recursive: true, force: true });
21
21
  }
@@ -76,6 +76,52 @@ artifacts:
76
76
  }
77
77
  });
78
78
 
79
+ test('validateSddResultArtifact accepts legacy run artifact directory for replay compatibility', async () => {
80
+ const root = await mkdtemp(path.join(tmpdir(), 'sdd-result-legacy-artifact-'));
81
+ try {
82
+ await initProject(root);
83
+ const state = await createRun(root, { runId: 'run-1' });
84
+ const legacyPath = getLegacyArtifactPath(root, state.runId, 'review-T1.md');
85
+ await mkdir(path.dirname(legacyPath), { recursive: true });
86
+ await writeFile(legacyPath, `# Review
87
+
88
+ \`\`\`sdd-result
89
+ contract: sdd-result-v1
90
+ version: 1.3.0
91
+ agent: reviewer
92
+ task: T1
93
+ status: PASS
94
+ artifacts:
95
+ - artifacts/review-T1.md
96
+ \`\`\`
97
+ `, 'utf8');
98
+
99
+ const report = await validateSddResultArtifact(root, state.runId, 'artifacts/review-T1.md', { expectedTask: 'T1', expectedAgent: 'reviewer' });
100
+
101
+ assert.equal(report.valid, true);
102
+ assert.equal(report.result?.task, 'T1');
103
+ } finally {
104
+ await rm(root, { recursive: true, force: true });
105
+ }
106
+ });
107
+
108
+ test('writeArtifact stores new payloads in branch evidence without creating legacy artifact dirs', async () => {
109
+ const root = await mkdtemp(path.join(tmpdir(), 'sdd-result-evidence-artifact-'));
110
+ try {
111
+ await initProject(root);
112
+ await writeBranchDocs(root, 'feature', validTaskMarkdown('T1', []));
113
+ const state = await createRun(root, { runId: 'run-1', branch: 'feature', taskId: 'T1' });
114
+ const written = await writeArtifact(root, state.runId, 'review-T1.md', validResultArtifact('reviewer', 'T1', 'PASS', 'artifacts/review-T1.md'));
115
+ const portablePath = written.absolutePath.replace(/\\/g, '/');
116
+
117
+ assert.equal(written.runRelativePath, 'artifacts/review-T1.md');
118
+ assert.match(portablePath, /\.sdd\/runs\/feature\/evidence\/artifacts\/review-T1-run-1-[a-f0-9]{12}\.md$/);
119
+ await assert.rejects(stat(path.join(root, '.sdd', 'runs', state.runId, 'artifacts')), /ENOENT/);
120
+ } finally {
121
+ await rm(root, { recursive: true, force: true });
122
+ }
123
+ });
124
+
79
125
  test('renderSddResultArtifactTemplate renders self-referencing reviewer artifact', async () => {
80
126
  const root = await mkdtemp(path.join(tmpdir(), 'sdd-artifact-template-review-'));
81
127
  try {
@@ -203,13 +203,13 @@ test('initProject projects managed Claude Code entries by default', async () =>
203
203
  assert.match(skill, /do not paste or restate full status/);
204
204
  assert.match(skill, /natural-language intent/);
205
205
  assert.match(skill, /CLI\/core output/);
206
- assert.match(skill, /\/sdd:\*/);
206
+ assert.match(skill, /projected command entry/);
207
207
  assert.match(skill, /ambiguous after status/);
208
208
  assert.match(skill, /sdd tasks inspect <task_id>/);
209
- assert.match(skill, /sdd sync-back inspect --branch <branch> --task <task_id>/);
210
- assert.match(skill, /\/sdd:ship/);
211
- assert.match(skill, /\/sdd:test/);
212
- assert.match(skill, /follow apply_policy/);
209
+ assert.match(skill, /treat `sdd sync-back inspect\|apply` as diagnostic\/recovery\/replay only/);
210
+ assert.match(skill, /sdd ship --branch <branch> --dry-run/);
211
+ assert.match(skill, /`test`/);
212
+ assert.doesNotMatch(skill, /follow apply_policy/);
213
213
  assert.match(skill, /workflow_status=not_started/);
214
214
  assert.match(skill, /workflow branch entry/);
215
215
  assert.match(doctorCommand, /sdd instructions doctor --json/);
@@ -240,7 +240,7 @@ test('initProject projects managed Claude Code entries by default', async () =>
240
240
  assert.match(planCommand, /based_on_spec_hash/);
241
241
  assert.match(planCommand, /PlantUML/);
242
242
  assert.match(planCommand, /state-machine risk needs a state diagram/);
243
- assert.match(tasksCommand, /executable evidence contract/);
243
+ assert.match(tasksCommand, /executable task and verification contracts/);
244
244
  assert.match(tasksCommand, /based_on_plan_hash/);
245
245
  assert.match(doCommand, /sdd status/);
246
246
  assert.match(doCommand, /sdd instructions do --json/);
@@ -248,13 +248,16 @@ test('initProject projects managed Claude Code entries by default', async () =>
248
248
  assert.match(doCommand, /artifacts\/implement-<task_id>\.md/);
249
249
  assert.match(doCommand, /--agent implementer/);
250
250
  assert.match(doCommand, /sdd do task <task_id>/);
251
- assert.match(doCommand, /sdd test task <task_id> --branch <branch>/);
251
+ assert.match(doCommand, /sdd test batch/);
252
+ assert.match(doCommand, /sdd test wave/);
252
253
  assert.match(testCommand, /sdd instructions test --json/);
253
- assert.match(testCommand, /sdd verifies inspect --branch <branch>/);
254
- assert.match(testCommand, /Execute task validation commands/);
254
+ assert.match(testCommand, /sdd test batch <batch_id> --branch <branch>/);
255
+ assert.match(testCommand, /sdd test wave --branch <branch> --wave <n>/);
256
+ assert.match(testCommand, /Execute validation from the frozen tasks\.md \+ verify\.md contract/);
257
+ assert.match(testCommand, /sdd ship --branch <branch> --dry-run/);
255
258
  assert.match(syncBackCommand, /sdd instructions sync-back --json/);
256
259
  assert.match(syncBackCommand, /sdd sync-back inspect --branch <branch> --task <task_id>/);
257
- assert.match(syncBackCommand, /approval_required=true/);
260
+ assert.match(syncBackCommand, /explicit recovery\/replay/);
258
261
  assert.match(syncBackCommand, /Do not apply without inspect/);
259
262
  assert.match(shipCommand, /sdd instructions ship --json/);
260
263
  assert.match(shipCommand, /sdd ship --branch <branch> --dry-run/);
@@ -33,11 +33,12 @@ export async function applyInitDocuments(projectRoot: string, options: { branch:
33
33
  assertSafePathSegment(options.branch, 'branch');
34
34
  const docsRoot = path.join(projectRoot, 'specs', options.branch);
35
35
  const now = new Date().toISOString();
36
+ const tasksContent = renderInitTasksDocument(options.branch, now, options.docsLanguage);
36
37
  const documents = [
37
38
  { name: 'spec.md', content: renderInitSpecDocument(options.branch, now, options.docsLanguage) },
38
39
  { name: 'plan.md', content: renderInitPlanDocument(options.branch, now, options.docsLanguage) },
39
- { name: 'tasks.md', content: renderInitTasksDocument(options.branch, now, options.docsLanguage) },
40
- { name: 'verify.md', content: renderInitVerifyDocument(options.branch, now, options.docsLanguage) }
40
+ { name: 'tasks.md', content: tasksContent },
41
+ { name: 'verify.md', content: renderInitVerifyDocument(options.branch, now, options.docsLanguage, tasksContent) }
41
42
  ];
42
43
 
43
44
  if (!options.scaffoldDocuments) {
@@ -1,3 +1,5 @@
1
+ import { hashDocumentContent, hashTasksContract } from '../sdd-docs/document-hashes.js';
2
+
1
3
  function usesChineseInitDocs(value: string): boolean {
2
4
  return value === 'zh-CN';
3
5
  }
@@ -389,21 +391,29 @@ ${implementationNotes}
389
391
  `;
390
392
  }
391
393
 
392
- export function renderInitVerifyDocument(branch: string, timestamp: string, docsLanguage: string): string {
394
+ export function renderInitVerifyDocument(branch: string, timestamp: string, docsLanguage: string, tasksContent: string): string {
393
395
  const zh = usesChineseInitDocs(docsLanguage);
394
396
  const title = zh ? '# Verify: Project Onboarding / 项目入门' : '# Verify: Project Onboarding';
395
397
  const purpose = zh
396
- ? '这份 verify.md 是从 starter tasks 派生的 verification guidance,不是 runtime evidence,也不替代 `/sdd:test` 产生的验证证据。'
397
- : 'This verify.md is task-derived verification guidance, not runtime evidence, and it does not replace validation evidence produced by `/sdd:test`.';
398
+ ? '这份 verify.md 是从 starter tasks 派生的 verification guidance,不是 runtime evidence,也不替代 `sdd test task|batch|wave` 产生的验证证据。'
399
+ : 'This verify.md is task-derived verification guidance, not runtime evidence, and it does not replace validation evidence produced by `sdd test task|batch|wave`.';
398
400
  const availability = zh
399
401
  ? '在替换真实 spec/plan/tasks 前,只能检查 onboarding scaffold 是否仍然可见且未被误当作已批准实现。'
400
402
  : 'Before replacing the real spec/plan/tasks, verification can only inspect that the onboarding scaffold is visible and not mistaken for approved implementation.';
403
+ const tasksContractHash = hashTasksContract(tasksContent) ?? 'missing';
404
+ const tasksHash = hashDocumentContent(tasksContent);
401
405
  return `---
402
406
  template: sdd-init-onboarding-verify-v1
403
407
  version: 1.4.0
404
408
  contract: sdd-verify-doc-v1
405
409
  sdd_managed_starter: true
406
410
  branch: ${branch}
411
+ based_on_tasks_contract_hash: ${tasksContractHash}
412
+ based_on_tasks_hash: ${tasksHash}
413
+ author_role: verification-designer
414
+ independent_from_roles:
415
+ - task-planner
416
+ - implementer
407
417
  created_at: ${timestamp}
408
418
  updated_at: ${timestamp}
409
419
  ---
@@ -418,13 +428,13 @@ ${purpose}
418
428
 
419
429
  | Task | Acceptance refs | Validation commands | Required artifacts | Verification availability |
420
430
  |---|---|---|---|---|
421
- | ONBOARDING-1 | AC-1<br>AC-2 | sdd status --branch ${branch}<br>sdd verifies inspect --branch ${branch} | none | ${availability} |
431
+ | ONBOARDING-1 | AC-1<br>AC-2 | sdd status --branch ${branch}<br>sdd test task ONBOARDING-1 --branch ${branch} | none | ${availability} |
422
432
 
423
433
  ## 3. Verification Rules
424
434
 
425
435
  - This starter verify contract does not authorize source changes, validation execution, runtime mutation, sync-back, commit, push, publish, or release.
426
436
  - Replace starter spec, plan, tasks, and verify documents with a real branch contract before implementation.
427
- - Runtime PASS is judged by \`/sdd:test\` / \`sdd test task <task_id> --branch ${branch}\`; low-level verify remains available for compatibility diagnostics.
437
+ - Runtime PASS is judged by \`sdd test task <task_id> --branch ${branch}\`, \`sdd test batch <batch_id> --branch ${branch}\`, or \`sdd test wave --branch ${branch}\` consuming the current verify contract; low-level verify remains available for compatibility diagnostics.
428
438
  - Re-run \`sdd verifies write --branch ${branch} --force\` only after reviewing changed task expectations.
429
439
 
430
440
  ## 4. Out of Scope
@@ -56,6 +56,8 @@ export const WORKFLOW_STATE_RESOLVER_CONTRACT_VERSION = 'phase-7.3-workflow-stat
56
56
  export const VERIFY_DOCUMENT_CONTRACT_VERSION = 'sdd-verify-doc-v1';
57
57
  export const AGENT_CAPABILITY_CATALOG_CONTRACT_VERSION = 'phase-7.6-agent-capability-catalog-v1';
58
58
  export const COMMAND_TEAM_RUNTIME_CONTRACT_VERSION = 'phase-7.7-command-team-runtime-v1';
59
+ export const STAGE_TEAM_RUNTIME_CONTRACT_VERSION = 'phase-8.15-stage-team-runtime-v1';
60
+ export const WORKFLOW_GATE_RUNTIME_CONTRACT_VERSION = 'phase-8.16-workflow-gate-runtime-v1';
59
61
  export const RUNTIME_PROJECTION_ENVELOPE_CONTRACT_VERSION = 'sdd-runtime-projection-envelope-v1';
60
62
  export const CODING_FACT_SET_CONTRACT_VERSION = 'sdd-coding-fact-set-v1';
61
63
  export const CODING_RISK_PROFILE_CONTRACT_VERSION = 'sdd-coding-risk-profile-v1';
@@ -109,11 +109,11 @@ export async function inspectRunEvidence(projectRoot: string, options: { allRuns
109
109
  }
110
110
  if (routePreflightEvents.length > 0 && agentExecutionRecords.length === 0) {
111
111
  issueCount += 1;
112
- checks.push({ level: 'FAIL', check: 'agent_execution_record', message: `${runId}: agent_router_preflight exists but no AgentExecutionRecord was persisted.`, action: 'Persist blocked/skipped/claimed/completed execution provenance under .sdd/runs/<run_id>/agent-executions/.' });
112
+ checks.push({ level: 'FAIL', check: 'agent_execution_record', message: `${runId}: agent_router_preflight exists but no AgentExecutionRecord was persisted.`, action: 'Persist blocked/skipped/claimed/completed execution provenance in runtime.sqlite agent_executions.' });
113
113
  }
114
114
  if (routePreflightEvents.some(routePreflightNeedsTeamSession) && teamSessionRecords.length === 0) {
115
115
  issueCount += 1;
116
- checks.push({ level: 'FAIL', check: 'team_session_record', message: `${runId}: team-mode preflight exists but no TeamSessionRecord was persisted.`, action: 'Persist team-mode provenance under .sdd/runs/<run_id>/team-sessions/.' });
116
+ checks.push({ level: 'FAIL', check: 'team_session_record', message: `${runId}: team-mode preflight exists but no TeamSessionRecord was persisted.`, action: 'Persist team-mode provenance in runtime.sqlite team_sessions.' });
117
117
  }
118
118
  for (const delegation of Object.values(state.delegations).filter((candidate) => isDelegationTerminal(candidate.status))) {
119
119
  if (agentExecutionRecords.length > 0 && !agentExecutionRecords.some((record) => record.delegationId === delegation.delegationId)) {
@@ -167,7 +167,7 @@ export async function inspectRunEvidence(projectRoot: string, options: { allRuns
167
167
 
168
168
 
169
169
  if (states.length === 0) {
170
- checks.push({ level: 'WARN', check: 'run_evidence', message: 'No runs found in runtime.sqlite.', action: 'Create a run before /sdd:do or /sdd:test.' });
170
+ checks.push({ level: 'WARN', check: 'run_evidence', message: 'No runs found in runtime.sqlite.', action: 'Create a run before do/test execution.' });
171
171
  } else if (inspected.length === 0 && issueCount === 0) {
172
172
  checks.push({ level: 'WARN', check: 'run_evidence', message: branchPartition ? `No non-archived runs were inspected for branch ${branchPartition}.` : 'No non-archived runs were inspected.', action: 'Use sdd doctor --all-runs to audit archived history or create a new run.' });
173
173
  } else if (issueCount === 0) {
@@ -1,7 +1,7 @@
1
1
  import test from 'node:test';
2
2
  import assert from 'node:assert/strict';
3
3
  import { execFile } from 'node:child_process';
4
- import { mkdtemp, readFile, rm, writeFile } from 'node:fs/promises';
4
+ import { mkdir, mkdtemp, readFile, rm, writeFile } from 'node:fs/promises';
5
5
  import { tmpdir } from 'node:os';
6
6
  import path from 'node:path';
7
7
  import { promisify } from 'node:util';
@@ -20,7 +20,8 @@ import { recordStageRunProjection, recordWorkflowHandoffProjection, type StageRu
20
20
  import { decideContextOffload, evaluateContextLoadSignal, recordContextLoadSignalProjection, recordContextOffloadDecisionProjection } from '../context-offload.js';
21
21
  import { recordSubagentDispatchProjection, type SubagentDispatch } from '../subagents.js';
22
22
  import { runShip } from '../lifecycle/ship.js';
23
- import { withRuntimeStore } from '../storage/runtime-store.js';
23
+ import { recordRuntimeSyncBackDecision, runtimeScopedId, withRuntimeStore } from '../storage/runtime-store.js';
24
+ import { getProjectStatus } from '../status/project-status.js';
24
25
  import { doctor } from './doctor.js';
25
26
 
26
27
  const execFileAsync = promisify(execFile);
@@ -409,6 +410,34 @@ test('doctor reports unavailable Phase 8 runtime checks as warnings', async () =
409
410
  }
410
411
  });
411
412
 
413
+ test('Phase 8.9 surfaces capability health in status, doctor, and ship gates', async () => {
414
+ const root = await mkdtemp(path.join(tmpdir(), 'sdd-capability-health-'));
415
+ try {
416
+ await initProject(root);
417
+ await writeBranchDocs(root, 'master', capabilityHealthTaskMarkdown('SECURITY'));
418
+
419
+ const status = await getProjectStatus(root, { branch: 'master' });
420
+ const report = await doctor(root, { latestOnly: true, branch: 'master' });
421
+ const ship = await runShip(root, { branch: 'master', dryRun: true });
422
+ const doctorCheck = report.checks.find((check) => check.check === 'capability_health');
423
+ const shipCheck = ship.checks.find((check) => check.name === 'capability_health');
424
+
425
+ assert.equal(status.capabilityHealth.status, 'warn');
426
+ assert.equal(status.capabilityHealth.missingBaselineDomains.length, 0);
427
+ assert.equal(status.capabilityHealth.sources.quarantined > 0, true);
428
+ assert.equal(status.capabilityHealth.sources.denied > 0, true);
429
+ assert.deepEqual(status.capabilityHealth.releaseCriticalGaps, ['security-engineering']);
430
+ assert.equal(status.capabilityHealth.warnings.some((warning) => /release-critical capability gap security-engineering/.test(warning)), true);
431
+ assert.equal(doctorCheck?.level, 'WARN');
432
+ assert.match(doctorCheck?.message ?? '', /release_critical_gaps=security-engineering/);
433
+ assert.equal(shipCheck?.status, 'PASS');
434
+ assert.match(shipCheck?.message ?? '', /release_critical_gaps=security-engineering/);
435
+ assert.equal(shipCheck?.nextAction, undefined);
436
+ } finally {
437
+ await rm(root, { recursive: true, force: true });
438
+ }
439
+ });
440
+
412
441
  test('ship reports token pressure as diagnostic pass', async () => {
413
442
  const root = await mkdtemp(path.join(tmpdir(), 'sdd-ship-token-diagnostic-'));
414
443
  try {
@@ -432,8 +461,8 @@ test('ship reports token pressure as diagnostic pass', async () => {
432
461
  }
433
462
  });
434
463
 
435
- test('ship blocks validated runs until sync-back is applied', async () => {
436
- const root = await mkdtemp(path.join(tmpdir(), 'sdd-ship-syncback-required-'));
464
+ test('ship accepts validated runs without requiring sync-back apply', async () => {
465
+ const root = await mkdtemp(path.join(tmpdir(), 'sdd-ship-syncback-not-required-'));
437
466
  try {
438
467
  await initProject(root);
439
468
  await writeBranchDocs(root, 'master', validTaskMarkdown('T1', []));
@@ -453,13 +482,66 @@ test('ship blocks validated runs until sync-back is applied', async () => {
453
482
  const ship = await runShip(root, { branch: 'master', dryRun: true });
454
483
  const latestRunCheck = ship.checks.find((check) => check.name === 'latest_run');
455
484
 
456
- assert.equal(latestRunCheck?.status, 'BLOCKED');
485
+ assert.equal(latestRunCheck?.status, 'PASS');
457
486
  assert.match(latestRunCheck?.message ?? '', /sync_back=not_created/);
458
487
  } finally {
459
488
  await rm(root, { recursive: true, force: true });
460
489
  }
461
490
  });
462
491
 
492
+ test('doctor reports Phase 8.18 compatibility and Phase 9 readiness diagnostics', async () => {
493
+ const root = await mkdtemp(path.join(tmpdir(), 'sdd-phase818-doctor-'));
494
+ try {
495
+ await initProject(root);
496
+ await writeBranchDocs(root, 'master', validTaskMarkdown('T1', []));
497
+ const state = await createRun(root, { runId: 'run-1', branch: 'master', taskId: 'T1' });
498
+ await writeArtifact(root, state.runId, 'review-T1.md', validResultArtifact('reviewer', 'T1', 'PASS', 'artifacts/review-T1.md'));
499
+ const legacyRunDir = path.join(root, '.sdd', 'runs', state.runId);
500
+ await mkdir(path.join(legacyRunDir, 'agent-executions'), { recursive: true });
501
+ await writeFile(path.join(legacyRunDir, 'state.json'), '{}', 'utf8');
502
+ await writeFile(path.join(legacyRunDir, 'events.jsonl'), '{}\n', 'utf8');
503
+ await writeFile(path.join(legacyRunDir, 'invocations.jsonl'), '{}\n', 'utf8');
504
+ await writeFile(path.join(legacyRunDir, 'agent-executions', 'legacy.json'), '{}', 'utf8');
505
+ await writeRunState(root, {
506
+ ...state,
507
+ syncBack: {
508
+ ...state.syncBack,
509
+ status: 'proposed',
510
+ proposalPath: 'artifacts/sync-back-proposal.md',
511
+ proposalDigest: 'legacy-digest'
512
+ }
513
+ });
514
+ await recordRuntimeSyncBackDecision(root, {
515
+ decisionId: runtimeScopedId(state.runId, 'T1', 'sync-back'),
516
+ runId: state.runId,
517
+ branch: 'master',
518
+ taskId: 'T1',
519
+ status: 'blocked',
520
+ proposalPath: 'artifacts/sync-back-proposal.md',
521
+ proposalDigest: 'legacy-digest',
522
+ proposalPayloadId: null,
523
+ reasons: ['legacy divergence'],
524
+ createdAt: '2026-05-21T00:00:00.000Z',
525
+ updatedAt: '2026-05-21T00:00:00.000Z',
526
+ payload: {}
527
+ });
528
+
529
+ const report = await doctor(root, { allRuns: true, branch: 'master' });
530
+
531
+ const legacyRunFiles = report.checks.find((check) => check.check === 'phase8_18_legacy_run_files');
532
+ assert.equal(legacyRunFiles?.level, 'WARN');
533
+ assert.match(legacyRunFiles?.message ?? '', /run-1:state\.json/);
534
+ assert.match(legacyRunFiles?.message ?? '', /run-1:events\.jsonl/);
535
+ assert.match(legacyRunFiles?.message ?? '', /run-1:invocations\.jsonl/);
536
+ assert.doesNotMatch(legacyRunFiles?.message ?? '', /evidence/);
537
+ assert.equal(report.checks.some((check) => check.check === 'phase8_18_legacy_sidecars' && check.level === 'WARN' && /run-1/.test(check.message)), true);
538
+ assert.equal(report.checks.some((check) => check.check === 'phase8_18_sync_back_compat' && check.level === 'WARN' && /proposed->blocked/.test(check.message)), true);
539
+ assert.equal(report.checks.some((check) => check.check === 'phase9_readiness' && check.level === 'PASS' && /optional_advisory_only/.test(check.message)), true);
540
+ } finally {
541
+ await rm(root, { recursive: true, force: true });
542
+ }
543
+ });
544
+
463
545
  test('ship still blocks context offload curation', async () => {
464
546
  const root = await mkdtemp(path.join(tmpdir(), 'sdd-ship-context-curation-'));
465
547
  try {
@@ -486,6 +568,36 @@ test('ship still blocks context offload curation', async () => {
486
568
  }
487
569
  });
488
570
 
571
+ function capabilityHealthTaskMarkdown(taskId: string): string {
572
+ return `# Tasks
573
+
574
+ ### ${taskId}: Security readiness task
575
+
576
+ \`\`\`sdd-task
577
+ id: ${taskId}
578
+ status: pending
579
+ wave: 1
580
+ depends_on: []
581
+ acceptance_refs:
582
+ - AC-1
583
+ affected_files:
584
+ - packages/core/src/auth.ts
585
+ validation:
586
+ - npm test
587
+ risk:
588
+ - security
589
+ \`\`\`
590
+
591
+ #### Boundary
592
+
593
+ Stay inside security readiness fixtures.
594
+
595
+ #### Acceptance
596
+
597
+ - AC-1: Security readiness is covered.
598
+ `;
599
+ }
600
+
489
601
  const doctorScope: RuntimeScope = { branch: 'master', taskId: 'T1', runId: 'run-1' };
490
602
 
491
603
  function doctorStageRun(): StageRun {