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
@@ -0,0 +1,206 @@
1
+ import { branchToSafePartition } from '../path-safety.js';
2
+ import { listRuntimeAcceptanceEvidenceMaps, listRuntimeAgentExecutions, listRuntimeArtifactPayloads, listRuntimeDurableGaps, listRuntimeFanInEvidenceSets, listRuntimeLlmAdvisorAssessments, listRuntimeStageRoleResults, listRuntimeStageTeamSessions, listRuntimeSyncBackDecisions, listRuntimeTeamSessions, listRuntimeTestRuns, listRuntimeValidationEnvironmentSessions, listRuntimeValidationWaveRuns, listRuntimeWorkflowGateDecisions, listRuntimeWorkerRuntimes } from '../storage/runtime-store.js';
3
+ import type { RuntimeAcceptanceEvidenceMapRecord, RuntimeArtifactPayloadRecord, RuntimeDurableGapRecord, RuntimeSyncBackDecisionRecord, RuntimeTestRunRecord, RuntimeValidationEnvironmentSessionRecord, RuntimeValidationWaveRunRecord } from '../storage/runtime-store.js';
4
+ import type { AgentExecutionRecord, TeamSessionRecord } from '../router/agent-runtime.js';
5
+ import type { ResidentWorkerRuntimeRecord } from '../execution/resident-worker.js';
6
+ import type { FanInEvidenceSetRecord, LlmAdvisorAssessmentRecord, StageRoleResultRecord, StageTeamSessionRecord } from '../execution/stage-team-runtime.js';
7
+ import type { WorkflowGateDecision } from '../workflow-gate/types.js';
8
+ import type { RunState } from './model.js';
9
+ import { resolveWorkflowState } from '../workflow-state/resolve.js';
10
+ import type { LatestEligibleRunCandidate, LatestEligibleRunSelection } from '../workflow-state/latest-eligible-run.js';
11
+ import type { SddTaskGap } from '../sdd-docs/task-parser.js';
12
+
13
+ export const TASK_EVIDENCE_VIEW_CONTRACT_VERSION = 'phase-8.12-task-evidence-view-v1';
14
+
15
+ export interface TaskEvidencePayloadGroups {
16
+ active: RuntimeArtifactPayloadRecord[];
17
+ candidate: RuntimeArtifactPayloadRecord[];
18
+ rejected: RuntimeArtifactPayloadRecord[];
19
+ superseded: RuntimeArtifactPayloadRecord[];
20
+ all: RuntimeArtifactPayloadRecord[];
21
+ }
22
+
23
+ export interface TaskEvidenceRuntimeActivity {
24
+ agentExecutions: AgentExecutionRecord[];
25
+ teamSessions: TeamSessionRecord[];
26
+ workerRuntimes: ResidentWorkerRuntimeRecord[];
27
+ }
28
+
29
+ export interface TaskEvidenceValidationView {
30
+ runValidation: RunState['validation'] | null;
31
+ testRuns: RuntimeTestRunRecord[];
32
+ validationWaves: RuntimeValidationWaveRunRecord[];
33
+ environmentSessions: RuntimeValidationEnvironmentSessionRecord[];
34
+ acceptanceEvidenceMaps: RuntimeAcceptanceEvidenceMapRecord[];
35
+ }
36
+
37
+ export interface TaskEvidenceStageTeamView {
38
+ sessions: StageTeamSessionRecord[];
39
+ roleResults: StageRoleResultRecord[];
40
+ advisorAssessments: LlmAdvisorAssessmentRecord[];
41
+ fanInEvidenceSets: FanInEvidenceSetRecord[];
42
+ }
43
+
44
+ export interface TaskEvidenceWorkflowGateView {
45
+ latestDecision: WorkflowGateDecision | null;
46
+ decisions: WorkflowGateDecision[];
47
+ }
48
+
49
+ export interface TaskEvidenceView {
50
+ contract: typeof TASK_EVIDENCE_VIEW_CONTRACT_VERSION;
51
+ generatedAt: string;
52
+ retrievalMemoryOnly: false;
53
+ source: 'runtime.sqlite+branch-evidence-payloads';
54
+ branch: string;
55
+ taskId: string;
56
+ latestEligibleRun: LatestEligibleRunCandidate | null;
57
+ candidates: LatestEligibleRunCandidate[];
58
+ rejected: LatestEligibleRunCandidate[];
59
+ compatibility: LatestEligibleRunCandidate['compatibility'] | null;
60
+ payloads: TaskEvidencePayloadGroups;
61
+ validation: TaskEvidenceValidationView;
62
+ syncBackDecision: RuntimeSyncBackDecisionRecord | null;
63
+ runtimeActivity: TaskEvidenceRuntimeActivity;
64
+ gaps: SddTaskGap[];
65
+ durableGaps: RuntimeDurableGapRecord[];
66
+ stageTeam: TaskEvidenceStageTeamView;
67
+ workflowGate: TaskEvidenceWorkflowGateView;
68
+ }
69
+
70
+ export async function readTaskEvidenceView(projectRoot: string, input: { branch?: string | null; taskId: string }): Promise<TaskEvidenceView> {
71
+ const workflow = await resolveWorkflowState(projectRoot, { branch: input.branch, branchSource: input.branch ? 'cli_option' : undefined, taskId: input.taskId });
72
+ const selection = workflow.latestEligibleRunsByTask.find((entry) => entry.taskId === input.taskId) ?? emptySelection(workflow.branch, input.taskId);
73
+ const selectedRunState = selection.selected?.runId === workflow.latestRunState?.runId ? workflow.latestRunState : null;
74
+ const runIds = uniqueRunIds(selection);
75
+ const payloads = await readTaskPayloads(projectRoot, workflow.branch, input.taskId, runIds);
76
+ const [testRuns, validationWaveEvidence, syncBackDecision, runtimeActivity, durableGaps, stageTeam, workflowGate] = selection.selected
77
+ ? await Promise.all([
78
+ listRuntimeTestRuns(projectRoot, selection.selected.runId),
79
+ readValidationWaveEvidence(projectRoot, workflow.branch, input.taskId, selection.selected.runId),
80
+ latestSyncBackDecision(projectRoot, selection.selected.runId),
81
+ readRuntimeActivity(projectRoot, selection.selected.runId),
82
+ listRuntimeDurableGaps(projectRoot, { partition: workflow.branch, taskId: input.taskId, status: 'open_terminal' }),
83
+ readStageTeamEvidence(projectRoot, workflow.branch, input.taskId, selection.selected.runId),
84
+ readWorkflowGateEvidence(projectRoot, workflow.branch, input.taskId, selection.selected.runId)
85
+ ])
86
+ : await Promise.all([
87
+ Promise.resolve([]),
88
+ readValidationWaveEvidence(projectRoot, workflow.branch, input.taskId, null),
89
+ Promise.resolve(null),
90
+ Promise.resolve(emptyRuntimeActivity()),
91
+ listRuntimeDurableGaps(projectRoot, { partition: workflow.branch, taskId: input.taskId, status: 'open_terminal' }),
92
+ readStageTeamEvidence(projectRoot, workflow.branch, input.taskId, null),
93
+ readWorkflowGateEvidence(projectRoot, workflow.branch, input.taskId, null)
94
+ ]);
95
+
96
+ const [validationWaves, environmentSessions, acceptanceEvidenceMaps] = validationWaveEvidence;
97
+ return {
98
+ contract: TASK_EVIDENCE_VIEW_CONTRACT_VERSION,
99
+ generatedAt: new Date().toISOString(),
100
+ retrievalMemoryOnly: false,
101
+ source: 'runtime.sqlite+branch-evidence-payloads',
102
+ branch: workflow.branch,
103
+ taskId: input.taskId,
104
+ latestEligibleRun: selection.selected,
105
+ candidates: selection.candidates,
106
+ rejected: selection.rejected,
107
+ compatibility: selection.selected?.compatibility ?? null,
108
+ payloads,
109
+ validation: {
110
+ runValidation: selectedRunState?.validation ?? null,
111
+ testRuns: testRuns.filter((run) => run.taskId === input.taskId),
112
+ validationWaves,
113
+ environmentSessions,
114
+ acceptanceEvidenceMaps
115
+ },
116
+ syncBackDecision,
117
+ runtimeActivity,
118
+ gaps: [...workflow.visibleGaps.filter((gap) => gap.taskId === input.taskId || gap.taskId === null), ...runtimeTaskGaps(selectedRunState?.tasks[input.taskId])],
119
+ durableGaps,
120
+ stageTeam,
121
+ workflowGate
122
+ };
123
+ }
124
+
125
+ function emptySelection(partition: string, taskId: string): LatestEligibleRunSelection {
126
+ return { partition, taskId, selected: null, candidates: [], rejected: [] };
127
+ }
128
+
129
+ function uniqueRunIds(selection: LatestEligibleRunSelection): string[] {
130
+ return Array.from(new Set([...selection.candidates, ...selection.rejected].map((candidate) => candidate.runId)));
131
+ }
132
+
133
+ async function readTaskPayloads(projectRoot: string, branch: string, taskId: string, runIds: string[]): Promise<TaskEvidencePayloadGroups> {
134
+ const payloads = runIds.length > 0
135
+ ? (await Promise.all(runIds.map((runId) => listRuntimeArtifactPayloads(projectRoot, { runId, taskId })))).flat()
136
+ : await listRuntimeArtifactPayloads(projectRoot, { branchSlug: branchToSafePartition(branch), taskId });
137
+ return {
138
+ active: payloads.filter((payload) => payload.status === 'active'),
139
+ candidate: payloads.filter((payload) => payload.status === 'candidate'),
140
+ rejected: payloads.filter((payload) => payload.status === 'rejected'),
141
+ superseded: payloads.filter((payload) => payload.status === 'superseded'),
142
+ all: payloads
143
+ };
144
+ }
145
+
146
+ async function readValidationWaveEvidence(projectRoot: string, partition: string, taskId: string, runId: string | null): Promise<[RuntimeValidationWaveRunRecord[], RuntimeValidationEnvironmentSessionRecord[], RuntimeAcceptanceEvidenceMapRecord[]]> {
147
+ const query = runId ? { partition, runId, taskId } : { partition, taskId };
148
+ const validationWaves = await listRuntimeValidationWaveRuns(projectRoot, query);
149
+ const waveRunIds = validationWaves.map((wave) => wave.waveRunId);
150
+ const [environmentSessions, acceptanceEvidenceMaps] = await Promise.all([
151
+ Promise.all(waveRunIds.map((waveRunId) => listRuntimeValidationEnvironmentSessions(projectRoot, { partition, waveRunId }))).then((items) => items.flat()),
152
+ Promise.all(waveRunIds.map((waveRunId) => listRuntimeAcceptanceEvidenceMaps(projectRoot, { partition, taskId, waveRunId }))).then((items) => items.flat())
153
+ ]);
154
+ return [validationWaves, environmentSessions, acceptanceEvidenceMaps];
155
+ }
156
+
157
+ async function latestSyncBackDecision(projectRoot: string, runId: string): Promise<RuntimeSyncBackDecisionRecord | null> {
158
+ const decisions = await listRuntimeSyncBackDecisions(projectRoot, runId);
159
+ return decisions[0] ?? null;
160
+ }
161
+
162
+ async function readRuntimeActivity(projectRoot: string, runId: string): Promise<TaskEvidenceRuntimeActivity> {
163
+ const [agentExecutions, teamSessions, workerRuntimes] = await Promise.all([
164
+ listRuntimeAgentExecutions(projectRoot, runId),
165
+ listRuntimeTeamSessions(projectRoot, runId),
166
+ listRuntimeWorkerRuntimes(projectRoot, runId)
167
+ ]);
168
+ return { agentExecutions, teamSessions, workerRuntimes };
169
+ }
170
+
171
+ async function readStageTeamEvidence(projectRoot: string, partition: string, taskId: string, runId: string | null): Promise<TaskEvidenceStageTeamView> {
172
+ const query = runId ? { partition, taskId, runId } : { partition, taskId };
173
+ const [sessions, roleResults, advisorAssessments, fanInEvidenceSets] = await Promise.all([
174
+ listRuntimeStageTeamSessions(projectRoot, query),
175
+ listRuntimeStageRoleResults(projectRoot, query),
176
+ listRuntimeLlmAdvisorAssessments(projectRoot, query),
177
+ listRuntimeFanInEvidenceSets(projectRoot, query)
178
+ ]);
179
+ return { sessions, roleResults, advisorAssessments, fanInEvidenceSets };
180
+ }
181
+
182
+ async function readWorkflowGateEvidence(projectRoot: string, partition: string, taskId: string, runId: string | null): Promise<TaskEvidenceWorkflowGateView> {
183
+ const query = runId ? { partition, taskId, runId } : { partition, taskId };
184
+ const decisions = await listRuntimeWorkflowGateDecisions(projectRoot, query);
185
+ return { latestDecision: decisions[0] ?? null, decisions };
186
+ }
187
+
188
+ function emptyRuntimeActivity(): TaskEvidenceRuntimeActivity {
189
+ return { agentExecutions: [], teamSessions: [], workerRuntimes: [] };
190
+ }
191
+
192
+ function runtimeTaskGaps(taskState: unknown): SddTaskGap[] {
193
+ if (!taskState || typeof taskState !== 'object' || !('gaps' in taskState)) {
194
+ return [];
195
+ }
196
+ const gaps = (taskState as { gaps?: unknown }).gaps;
197
+ return Array.isArray(gaps) ? gaps.filter(isTaskGap) : [];
198
+ }
199
+
200
+ function isTaskGap(value: unknown): value is SddTaskGap {
201
+ if (!value || typeof value !== 'object') {
202
+ return false;
203
+ }
204
+ const gap = value as Partial<SddTaskGap>;
205
+ return typeof gap.type === 'string' && typeof gap.severity === 'string' && typeof gap.field === 'string' && typeof gap.message === 'string' && typeof gap.recommendation === 'string';
206
+ }
@@ -5,3 +5,4 @@ export * from './run-state/invocation-ledger.js';
5
5
  export * from './run-state/model.js';
6
6
  export * from './run-state/run-index.js';
7
7
  export * from './run-state/run-state.js';
8
+ export * from './run-state/task-evidence.js';
@@ -25,11 +25,15 @@ export function getRuntimeStorePath(projectRoot: string): string {
25
25
  return path.join(getSddDir(projectRoot), 'runtime.sqlite');
26
26
  }
27
27
 
28
- export function getRunDir(projectRoot: string, runId: string): string {
28
+ export function getLegacyRunDir(projectRoot: string, runId: string): string {
29
29
  assertSafePathSegment(runId, 'runId');
30
30
  return path.join(getRunsDir(projectRoot), runId);
31
31
  }
32
32
 
33
+ export function getRunDir(projectRoot: string, runId: string): string {
34
+ return getLegacyRunDir(projectRoot, runId);
35
+ }
36
+
33
37
  export function getBranchRunRoot(projectRoot: string, branchSlug: string): string {
34
38
  return path.join(getRunsDir(projectRoot), branchToSafePartition(branchSlug));
35
39
  }
@@ -48,24 +52,44 @@ export function getEvidenceAttachmentPath(projectRoot: string, branchSlug: strin
48
52
  return resolved;
49
53
  }
50
54
 
55
+ export function getLegacyArtifactsDir(projectRoot: string, runId: string): string {
56
+ return path.join(getLegacyRunDir(projectRoot, runId), 'artifacts');
57
+ }
58
+
51
59
  export function getArtifactsDir(projectRoot: string, runId: string): string {
52
- return path.join(getRunDir(projectRoot, runId), 'artifacts');
60
+ return getLegacyArtifactsDir(projectRoot, runId);
61
+ }
62
+
63
+ export function getLegacyAgentExecutionsDir(projectRoot: string, runId: string): string {
64
+ return path.join(getLegacyRunDir(projectRoot, runId), 'agent-executions');
53
65
  }
54
66
 
55
67
  export function getAgentExecutionsDir(projectRoot: string, runId: string): string {
56
- return path.join(getRunDir(projectRoot, runId), 'agent-executions');
68
+ return getLegacyAgentExecutionsDir(projectRoot, runId);
69
+ }
70
+
71
+ export function getLegacyTeamSessionsDir(projectRoot: string, runId: string): string {
72
+ return path.join(getLegacyRunDir(projectRoot, runId), 'team-sessions');
57
73
  }
58
74
 
59
75
  export function getTeamSessionsDir(projectRoot: string, runId: string): string {
60
- return path.join(getRunDir(projectRoot, runId), 'team-sessions');
76
+ return getLegacyTeamSessionsDir(projectRoot, runId);
77
+ }
78
+
79
+ export function getLegacyWorkerRuntimesDir(projectRoot: string, runId: string): string {
80
+ return path.join(getLegacyRunDir(projectRoot, runId), 'worker-runtimes');
61
81
  }
62
82
 
63
83
  export function getWorkerRuntimesDir(projectRoot: string, runId: string): string {
64
- return path.join(getRunDir(projectRoot, runId), 'worker-runtimes');
84
+ return getLegacyWorkerRuntimesDir(projectRoot, runId);
85
+ }
86
+
87
+ export function getLegacyInvocationLedgerPath(projectRoot: string, runId: string): string {
88
+ return path.join(getLegacyRunDir(projectRoot, runId), 'invocations.jsonl');
65
89
  }
66
90
 
67
91
  export function getInvocationLedgerPath(projectRoot: string, runId: string): string {
68
- return path.join(getRunDir(projectRoot, runId), 'invocations.jsonl');
92
+ return getLegacyInvocationLedgerPath(projectRoot, runId);
69
93
  }
70
94
 
71
95
  export function getRouteCacheDir(projectRoot: string): string {
@@ -77,23 +101,35 @@ export function getRouteCachePath(projectRoot: string, key: string): string {
77
101
  return path.join(getRouteCacheDir(projectRoot), `${key}.json`);
78
102
  }
79
103
 
80
- export function getWorkerRuntimeRecordPath(projectRoot: string, runId: string, runtimeId: string): string {
104
+ export function getLegacyWorkerRuntimeRecordPath(projectRoot: string, runId: string, runtimeId: string): string {
81
105
  assertSafePathSegment(runtimeId, 'runtimeId');
82
- return path.join(getWorkerRuntimesDir(projectRoot, runId), `${runtimeId}.json`);
106
+ return path.join(getLegacyWorkerRuntimesDir(projectRoot, runId), `${runtimeId}.json`);
83
107
  }
84
108
 
85
- export function getAgentExecutionRecordPath(projectRoot: string, runId: string, executionId: string): string {
109
+ export function getWorkerRuntimeRecordPath(projectRoot: string, runId: string, runtimeId: string): string {
110
+ return getLegacyWorkerRuntimeRecordPath(projectRoot, runId, runtimeId);
111
+ }
112
+
113
+ export function getLegacyAgentExecutionRecordPath(projectRoot: string, runId: string, executionId: string): string {
86
114
  assertSafePathSegment(executionId, 'executionId');
87
- return path.join(getAgentExecutionsDir(projectRoot, runId), `${executionId}.json`);
115
+ return path.join(getLegacyAgentExecutionsDir(projectRoot, runId), `${executionId}.json`);
88
116
  }
89
117
 
90
- export function getTeamSessionRecordPath(projectRoot: string, runId: string, teamId: string): string {
118
+ export function getAgentExecutionRecordPath(projectRoot: string, runId: string, executionId: string): string {
119
+ return getLegacyAgentExecutionRecordPath(projectRoot, runId, executionId);
120
+ }
121
+
122
+ export function getLegacyTeamSessionRecordPath(projectRoot: string, runId: string, teamId: string): string {
91
123
  assertSafePathSegment(teamId, 'teamId');
92
- return path.join(getTeamSessionsDir(projectRoot, runId), `${teamId}.json`);
124
+ return path.join(getLegacyTeamSessionsDir(projectRoot, runId), `${teamId}.json`);
93
125
  }
94
126
 
95
- export function getArtifactPath(projectRoot: string, runId: string, relativeArtifactPath: string): string {
96
- const artifactsDir = getArtifactsDir(projectRoot, runId);
127
+ export function getTeamSessionRecordPath(projectRoot: string, runId: string, teamId: string): string {
128
+ return getLegacyTeamSessionRecordPath(projectRoot, runId, teamId);
129
+ }
130
+
131
+ export function getLegacyArtifactPath(projectRoot: string, runId: string, relativeArtifactPath: string): string {
132
+ const artifactsDir = getLegacyArtifactsDir(projectRoot, runId);
97
133
  const resolved = path.resolve(artifactsDir, relativeArtifactPath);
98
134
  if (!resolved.startsWith(path.resolve(artifactsDir) + path.sep) && resolved !== path.resolve(artifactsDir)) {
99
135
  throw new Error(`Artifact path escapes artifacts directory: ${relativeArtifactPath}`);
@@ -101,6 +137,10 @@ export function getArtifactPath(projectRoot: string, runId: string, relativeArti
101
137
  return resolved;
102
138
  }
103
139
 
140
+ export function getArtifactPath(projectRoot: string, runId: string, relativeArtifactPath: string): string {
141
+ return getLegacyArtifactPath(projectRoot, runId, relativeArtifactPath);
142
+ }
143
+
104
144
  export function getRunRelativeArtifactPath(artifactRootRelativePath: string): string {
105
145
  return `artifacts/${normalizeArtifactRootRelativePath(artifactRootRelativePath)}`;
106
146
  }
@@ -39,7 +39,7 @@ export async function resolveSddContext(projectRoot: string, options: { branch?:
39
39
  return resolvedContext(projectRoot, projectConfigBranch, 'project_config', currentGitBranch);
40
40
  }
41
41
 
42
- throw new Error('Cannot resolve SDD branch. Run from a Git branch, pass --branch <branch>, or set sdd.default_branch in .sdd/project.yml. /sdd:spec is the workflow partition entry.');
42
+ throw new Error('Cannot resolve SDD branch. Run from a Git branch, pass --branch <branch>, or set sdd.default_branch in .sdd/project.yml. The spec stage is the workflow partition entry.');
43
43
  }
44
44
 
45
45
  export async function resolveRunStateContext(projectRoot: string, state: RunState): Promise<ContextResolverContract> {
@@ -0,0 +1,207 @@
1
+ import { createHash } from 'node:crypto';
2
+
3
+ const TASK_CONTRACT_METADATA_KEYS = [
4
+ 'id',
5
+ 'wave',
6
+ 'depends_on',
7
+ 'acceptance_refs',
8
+ 'plan_refs',
9
+ 'affected_files',
10
+ 'change_surface',
11
+ 'implementation_wave',
12
+ 'validation_batch',
13
+ 'validation_timing',
14
+ 'requires_verify_before_next',
15
+ 'validation',
16
+ 'risk',
17
+ 'required_artifacts',
18
+ 'allowed_agents',
19
+ 'verification_availability',
20
+ 'autonomy',
21
+ 'validation_wave',
22
+ 'review_gate'
23
+ ];
24
+
25
+ const TASK_CONTRACT_SECTION_TITLES = [
26
+ 'Boundary',
27
+ 'Acceptance',
28
+ 'Definition of Done',
29
+ 'Evidence Expectations'
30
+ ];
31
+
32
+ const TOP_LEVEL_CONTRACT_SECTION_TITLES = [
33
+ 'Delivery Map',
34
+ 'Wave Plan',
35
+ 'Implementation Waves',
36
+ 'Validation Waves',
37
+ 'Review Gate',
38
+ 'Review Gates',
39
+ 'Review Gate Declarations',
40
+ 'Phase Gate Checkpoint'
41
+ ];
42
+
43
+ export function hashDocumentContent(raw: string): string {
44
+ return sha256(raw.replace(/\r\n/g, '\n'));
45
+ }
46
+
47
+ export function hashSemanticDocument(raw: string | null): string | null {
48
+ return raw === null ? null : sha256(normalizeSemanticMarkdown(raw));
49
+ }
50
+
51
+ export function hashTasksContract(raw: string | null): string | null {
52
+ if (raw === null) {
53
+ return null;
54
+ }
55
+ return sha256(stableJson({
56
+ tasks: parseTaskContracts(raw),
57
+ declarations: TOP_LEVEL_CONTRACT_SECTION_TITLES.map((title) => [title, normalizeSectionText(sectionText(raw, title))]).filter(([, value]) => value !== null)
58
+ }));
59
+ }
60
+
61
+ export function documentHashMatches(expected: string, actual: string): boolean {
62
+ return expected.replace(/^sha256:/, '') === actual;
63
+ }
64
+
65
+ function parseTaskContracts(raw: string): unknown[] {
66
+ const fencedBlocks = Array.from(raw.matchAll(/^\s*```sdd-task\s*\r?\n([\s\S]*?)\r?^\s*```\s*$/gm));
67
+ return fencedBlocks.map((blockMatch, index) => {
68
+ const block = blockMatch[1] ?? '';
69
+ const blockStart = blockMatch.index ?? 0;
70
+ const blockEnd = blockStart + blockMatch[0].length;
71
+ const nextBlockStart = fencedBlocks[index + 1]?.index ?? raw.length;
72
+ const section = raw.slice(blockEnd, nextTaskStart(raw, blockEnd, nextBlockStart));
73
+ const metadata = parseSimpleYamlBlock(block);
74
+ const heading = nearestTaskHeading(raw.slice(0, blockStart));
75
+ const id = scalarValue(metadata.id) ?? heading?.id ?? null;
76
+ return {
77
+ id,
78
+ title: heading?.title ?? null,
79
+ metadata: Object.fromEntries(TASK_CONTRACT_METADATA_KEYS.map((key) => [key, normalizedMetadataValue(metadata[key])])),
80
+ sections: Object.fromEntries(TASK_CONTRACT_SECTION_TITLES.map((title) => [title, normalizeSectionText(sectionText(section, title))]))
81
+ };
82
+ }).sort((left, right) => String((left as { id: string | null }).id ?? '').localeCompare(String((right as { id: string | null }).id ?? '')));
83
+ }
84
+
85
+ function normalizeSemanticMarkdown(raw: string): string {
86
+ return raw
87
+ .replace(/\r\n/g, '\n')
88
+ .split('\n')
89
+ .filter((line) => !/^\s*(created_at|updated_at|generatedAt|generated_at|run_id):/i.test(line))
90
+ .map((line) => line.trim())
91
+ .filter(Boolean)
92
+ .join('\n');
93
+ }
94
+
95
+ function normalizeSectionText(value: string | null): string | null {
96
+ if (!value) {
97
+ return null;
98
+ }
99
+ return value.replace(/\r\n/g, '\n').split('\n').map((line) => line.trim()).filter((line) => line && !/^<!--.*-->$/.test(line)).join('\n');
100
+ }
101
+
102
+ function sectionText(raw: string, title: string): string | null {
103
+ const escaped = title.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
104
+ const sectionPattern = `^\\s*#{2,4}\\s+${escaped}\\s*$([\\s\\S]*?)(?=^\\s*#{2,4}\\s+|$(?![\\s\\S]))`;
105
+ const match = raw.match(new RegExp(sectionPattern, 'im'));
106
+ const text = match?.[1]?.trim() ?? '';
107
+ return text.length > 0 ? text : null;
108
+ }
109
+
110
+ function parseSimpleYamlBlock(raw: string): Record<string, string | string[]> {
111
+ const result: Record<string, string | string[]> = {};
112
+ const lines = raw.split(/\r?\n/);
113
+ let currentListKey: string | null = null;
114
+
115
+ for (const line of lines) {
116
+ const trimmed = line.trim();
117
+ if (!trimmed || trimmed.startsWith('#')) {
118
+ continue;
119
+ }
120
+ if (currentListKey && /^-\s+/.test(trimmed)) {
121
+ const current = result[currentListKey];
122
+ const items = Array.isArray(current) ? current : [];
123
+ items.push(unquoteSimpleYamlValue(trimmed.slice(2).trim()));
124
+ result[currentListKey] = items;
125
+ continue;
126
+ }
127
+
128
+ const scalarMatch = trimmed.match(/^([A-Za-z0-9_-]+):\s*(.*)$/);
129
+ if (!scalarMatch) {
130
+ currentListKey = null;
131
+ continue;
132
+ }
133
+ const key = scalarMatch[1];
134
+ const value = scalarMatch[2].trim();
135
+ if (value === '') {
136
+ result[key] = [];
137
+ currentListKey = key;
138
+ } else if (value === '[]') {
139
+ result[key] = [];
140
+ currentListKey = null;
141
+ } else if (value.startsWith('[') && value.endsWith(']')) {
142
+ result[key] = value.slice(1, -1).split(',').map((item) => unquoteSimpleYamlValue(item.trim())).filter(Boolean);
143
+ currentListKey = null;
144
+ } else {
145
+ result[key] = unquoteSimpleYamlValue(value);
146
+ currentListKey = null;
147
+ }
148
+ }
149
+
150
+ return result;
151
+ }
152
+
153
+ function normalizedMetadataValue(value: string | string[] | undefined): string | string[] | null {
154
+ if (Array.isArray(value)) {
155
+ return [...value].filter(Boolean).sort();
156
+ }
157
+ return value && value !== '[]' ? value : null;
158
+ }
159
+
160
+ function scalarValue(value: string | string[] | undefined): string | null {
161
+ return typeof value === 'string' && value.length > 0 ? value : null;
162
+ }
163
+
164
+ function unquoteSimpleYamlValue(value: string): string {
165
+ if (value.length >= 2) {
166
+ const first = value[0];
167
+ const last = value[value.length - 1];
168
+ if ((first === '"' && last === '"') || (first === "'" && last === "'")) {
169
+ return value.slice(1, -1);
170
+ }
171
+ }
172
+ return value;
173
+ }
174
+
175
+ function nearestTaskHeading(prefix: string): { raw: string; id: string | null; title: string | null } | null {
176
+ const matches = Array.from(prefix.matchAll(/^\s*###\s+(.+)$/gm));
177
+ const last = matches.at(-1);
178
+ if (!last) {
179
+ return null;
180
+ }
181
+ const raw = last[1].trim();
182
+ const parsed = raw.match(/^([^::\s]+)\s*[::]\s*(.+)$/);
183
+ return {
184
+ raw,
185
+ id: parsed?.[1]?.trim() ?? null,
186
+ title: parsed?.[2]?.trim() ?? raw
187
+ };
188
+ }
189
+
190
+ function nextTaskStart(raw: string, offset: number, limit = raw.length): number {
191
+ const next = raw.slice(offset, limit).search(/^\s*###\s+/m);
192
+ return next < 0 ? limit : offset + next;
193
+ }
194
+
195
+ function stableJson(value: unknown): string {
196
+ if (Array.isArray(value)) {
197
+ return `[${value.map(stableJson).join(',')}]`;
198
+ }
199
+ if (value && typeof value === 'object') {
200
+ return `{${Object.entries(value as Record<string, unknown>).sort(([left], [right]) => left.localeCompare(right)).map(([key, item]) => `${JSON.stringify(key)}:${stableJson(item)}`).join(',')}}`;
201
+ }
202
+ return JSON.stringify(value);
203
+ }
204
+
205
+ function sha256(value: string): string {
206
+ return createHash('sha256').update(value, 'utf8').digest('hex');
207
+ }
@@ -1,8 +1,10 @@
1
+ import path from 'node:path';
1
2
  import { appendEvent } from '../run-state/events.js';
2
3
  import { readRunState, writeRunState } from '../run-state/run-state.js';
3
4
  import type { RunDocumentSnapshot, RunState } from '../run-state/model.js';
4
5
  import type { ContextResolverContract } from './context.js';
5
6
  import type { SddTask, SddTaskModel } from './task-parser.js';
7
+ import { getEvidenceDir } from '../runtime-paths.js';
6
8
 
7
9
  export async function bindRunStateToTask(projectRoot: string, state: RunState, context: ContextResolverContract, model: SddTaskModel, task: SddTask | null, taskId: string): Promise<RunState> {
8
10
  if (state.partition && state.partition !== context.partition) {
@@ -22,7 +24,8 @@ export async function bindRunStateToTask(projectRoot: string, state: RunState, c
22
24
  gitBranch: context.rawBranch,
23
25
  taskId,
24
26
  affectedFiles: task?.affectedFiles ?? state.affectedFiles,
25
- documentSnapshot: documentSnapshotFromModel(model)
27
+ documentSnapshot: documentSnapshotFromModel(model),
28
+ artifactRoot: path.relative(projectRoot, getEvidenceDir(projectRoot, context.partition))
26
29
  };
27
30
  await writeRunState(projectRoot, nextState);
28
31
  await appendEvent(projectRoot, state.runId, {
@@ -57,7 +60,8 @@ export async function bindRunStateToTaskContext(projectRoot: string, state: RunS
57
60
  partition: context.partition,
58
61
  gitBranch: context.rawBranch,
59
62
  affectedFiles: [...new Set([...state.affectedFiles, ...(task?.affectedFiles ?? [])])],
60
- documentSnapshot: documentSnapshotFromModel(model)
63
+ documentSnapshot: documentSnapshotFromModel(model),
64
+ artifactRoot: path.relative(projectRoot, getEvidenceDir(projectRoot, context.partition))
61
65
  };
62
66
  await writeRunState(projectRoot, nextState);
63
67
  await appendEvent(projectRoot, state.runId, {
@@ -80,7 +84,12 @@ export function documentSnapshotFromModel(model: SddTaskModel): RunDocumentSnaps
80
84
  specHash: model.documents.specHash ?? null,
81
85
  planHash: model.documents.planHash ?? null,
82
86
  tasksHash: model.documents.tasksHash ?? null,
87
+ specContractHash: model.documents.specContractHash ?? null,
88
+ planContractHash: model.documents.planContractHash ?? null,
89
+ tasksContractHash: model.documents.tasksContractHash ?? null,
83
90
  planBasedOnSpecHash: model.documents.planBasedOnSpecHash ?? null,
84
- tasksBasedOnPlanHash: model.documents.tasksBasedOnPlanHash ?? null
91
+ tasksBasedOnPlanHash: model.documents.tasksBasedOnPlanHash ?? null,
92
+ planBasedOnSpecContractHash: model.documents.planBasedOnSpecContractHash ?? null,
93
+ tasksBasedOnPlanContractHash: model.documents.tasksBasedOnPlanContractHash ?? null
85
94
  };
86
95
  }