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
@@ -123,12 +123,36 @@ function validateAgentSkillTeamRuntimeInspection(inspection: AgentSkillTeamRunti
123
123
  if (!source.attribution.trim()) {
124
124
  issues.push(contractIssue(`${source.id}.attribution`, 'Capability source has no attribution.', 'Declare attribution before external material can enter the runtime registry.'));
125
125
  }
126
- if (source.quarantineRequired && source.reuseDecision === 'reuse_direct') {
127
- issues.push(contractIssue(`${source.id}.reuseDecision`, 'Quarantined source cannot be reused directly.', 'Use adapt_via_host_adapter or borrow_mechanism until quarantine evidence promotes the source.'));
126
+ if (source.permissionModel.length === 0) {
127
+ issues.push(contractIssue(`${source.id}.permissionModel`, 'Capability source has no permission model.', 'Declare how host/tool permissions are bounded before routing this source.'));
128
128
  }
129
- if (source.quarantineRequired && sourceDeclaresUnsafeAuthority(source)) {
129
+ if (source.provenanceRequirements.length === 0) {
130
+ issues.push(contractIssue(`${source.id}.provenanceRequirements`, 'Capability source has no provenance requirements.', 'Declare source, session, artifact, or tool provenance before external output can be cited.'));
131
+ }
132
+ if (source.hostCompatibility.length === 0) {
133
+ issues.push(contractIssue(`${source.id}.hostCompatibility`, 'Capability source has no host compatibility declaration.', 'Declare supported, future_adapter, or unsupported host compatibility.'));
134
+ }
135
+ if (source.allowedEvidenceTypes.length === 0) {
136
+ issues.push(contractIssue(`${source.id}.allowedEvidenceTypes`, 'Capability source has no allowed evidence type.', 'Declare whether output is none, candidate evidence, command output, browser snapshot, design context, execution record, or external reference.'));
137
+ }
138
+ if (source.forbiddenAuthority.length === 0 || !sourceForbidsRuntimeAuthority(source)) {
139
+ issues.push(contractIssue(`${source.id}.forbiddenAuthority`, 'Capability source does not forbid runtime authority.', 'External sources must forbid lifecycle, completion, sync-back, ship, and permission authority.'));
140
+ }
141
+ if (!source.quarantineRequired && source.quarantineStatus !== 'not_required') {
142
+ issues.push(contractIssue(`${source.id}.quarantineStatus`, 'Non-quarantined source has a quarantine status.', 'Use not_required unless quarantine is required.'));
143
+ }
144
+ if (source.quarantineRequired && source.quarantineStatus === 'not_required') {
145
+ issues.push(contractIssue(`${source.id}.quarantineStatus`, 'Quarantined source is missing active quarantine status.', 'Use required, quarantined, or denied for external sources that require quarantine.'));
146
+ }
147
+ if ((source.quarantineRequired || source.quarantineStatus === 'quarantined' || source.quarantineStatus === 'denied') && source.reuseDecision === 'reuse_direct') {
148
+ issues.push(contractIssue(`${source.id}.reuseDecision`, 'Quarantined source cannot be reused directly.', 'Use adapt_via_host_adapter, borrow_mechanism, or avoid until quarantine evidence promotes the source.'));
149
+ }
150
+ if ((source.quarantineRequired || source.quarantineStatus === 'quarantined') && sourceDeclaresUnsafeAuthority(source)) {
130
151
  issues.push(contractIssue(`${source.id}.allowedUse`, 'Quarantined source requests prompt import, direct execution, or lifecycle authority.', 'Keep external material declarative and route only through validated profiles, capabilities, and adapter mappings.'));
131
152
  }
153
+ if (source.quarantineStatus === 'denied' && source.reuseDecision !== 'avoid') {
154
+ issues.push(contractIssue(`${source.id}.reuseDecision`, 'Denied capability source is still routable.', 'Set reuse_decision to avoid for denied or unsupported sources.'));
155
+ }
132
156
  }
133
157
  for (const capability of inspection.skillCapabilities) {
134
158
  const registrySource = inspectionRegistrySource(inspection, 'skill_capability', capability.id);
@@ -226,6 +250,11 @@ function sourceDeclaresUnsafeAuthority(source: CapabilitySourceCatalogEntry): bo
226
250
  return /prompt\s*(body|import)|direct\s+execution|execute\s+(third[- ]party|external)|run\s+(agent\s+)?pack|lifecycle\s+authority|completion\s+authority|unscoped\s+write|permission\s+escalation/i.test([source.allowedUse, source.rationale].join('\n'));
227
251
  }
228
252
 
253
+ function sourceForbidsRuntimeAuthority(source: CapabilitySourceCatalogEntry): boolean {
254
+ const forbidden = source.forbiddenAuthority.join('\n').toLowerCase();
255
+ return ['lifecycle', 'stage completion', 'sync-back', 'ship', 'permission'].every((term) => forbidden.includes(term));
256
+ }
257
+
229
258
  function builtInProfileAliasTarget(value: string): AgentProfileId | null {
230
259
  const normalized = normalizeAgentToken(value);
231
260
  if (normalized === 'scout') {
@@ -1,16 +1,17 @@
1
1
  import { createHash } from 'node:crypto';
2
2
  import { mkdir, readFile, writeFile } from 'node:fs/promises';
3
3
  import path from 'node:path';
4
- import { getArtifactPath, getEvidenceAttachmentPath, getRunRelativeArtifactPath, normalizeArtifactRootRelativePath } from '../runtime-paths.js';
5
- import { readRuntimeRunState, recordRuntimeEvidenceAttachment, runtimeScopedId, withRuntimeStore } from '../storage/runtime-store.js';
6
- import { exists } from '../storage/json-io.js';
4
+ import { getEvidenceAttachmentPath, getLegacyArtifactPath, getRunRelativeArtifactPath, normalizeArtifactRootRelativePath } from '../runtime-paths.js';
5
+ import { readRuntimeRunState, recordRuntimeArtifactPayload, recordRuntimeEvidenceAttachment, resolveRuntimeArtifactPayload, runtimeScopedId, withRuntimeStore } from '../storage/runtime-store.js';
7
6
  import { appendArtifactHashLedgerEntry } from './invocation-ledger.js';
8
7
 
9
8
  export async function writeArtifact(projectRoot: string, runId: string, artifactRootRelativePath: string, content: string): Promise<{ absolutePath: string; runRelativePath: string }> {
10
9
  const normalized = normalizeArtifactRootRelativePath(artifactRootRelativePath);
11
10
  const runRelativePath = getRunRelativeArtifactPath(normalized);
12
- const branchSlug = await resolveRunBranchSlug(projectRoot, runId);
13
- const absolutePath = getEvidenceAttachmentPath(projectRoot, branchSlug, runRelativePath);
11
+ const runScope = await resolveRunScope(projectRoot, runId);
12
+ const contentHash = hashDocumentContent(content);
13
+ const physicalPayloadPath = uniquePhysicalPayloadPath(runRelativePath, runId, contentHash);
14
+ const absolutePath = getEvidenceAttachmentPath(projectRoot, runScope.branchSlug, physicalPayloadPath);
14
15
  await mkdir(path.dirname(absolutePath), { recursive: true });
15
16
  await writeFile(absolutePath, content, 'utf8');
16
17
  await appendArtifactHashLedgerEntry(projectRoot, {
@@ -19,15 +20,29 @@ export async function writeArtifact(projectRoot: string, runId: string, artifact
19
20
  content,
20
21
  status: 'written'
21
22
  });
22
- await recordRuntimeArtifact(projectRoot, { runId, path: runRelativePath, content, status: 'written' });
23
+ await recordRuntimeArtifact(projectRoot, { runId, path: runRelativePath, content, status: 'written', taskId: runScope.taskId });
24
+ await recordRuntimeArtifactPayload(projectRoot, {
25
+ payloadId: runtimeScopedId(runId, runRelativePath, contentHash),
26
+ runId,
27
+ sourceRunId: runId,
28
+ branchSlug: runScope.branchSlug,
29
+ taskId: runScope.taskId,
30
+ logicalRef: runRelativePath,
31
+ physicalPayloadPath,
32
+ artifactRole: artifactKind(runRelativePath),
33
+ digest: contentHash,
34
+ status: 'active',
35
+ payload: { logicalRef: runRelativePath, physicalPayloadPath, artifactPath: runRelativePath, status: 'written' }
36
+ });
23
37
  await recordRuntimeEvidenceAttachment(projectRoot, {
24
- branchSlug,
38
+ branchSlug: runScope.branchSlug,
25
39
  runId,
40
+ taskId: runScope.taskId,
26
41
  kind: artifactKind(runRelativePath),
27
- relativePath: runRelativePath,
28
- contentHash: hashDocumentContent(content),
42
+ relativePath: physicalPayloadPath,
43
+ contentHash,
29
44
  bytes: Buffer.byteLength(content, 'utf8'),
30
- payload: { artifactPath: runRelativePath, status: 'written' }
45
+ payload: { logicalRef: runRelativePath, physicalPayloadPath, status: 'written' }
31
46
  });
32
47
  return { absolutePath, runRelativePath };
33
48
  }
@@ -35,11 +50,23 @@ export async function writeArtifact(projectRoot: string, runId: string, artifact
35
50
  export async function readArtifact(projectRoot: string, runId: string, artifactRootRelativePath: string): Promise<string> {
36
51
  const normalized = normalizeArtifactRootRelativePath(artifactRootRelativePath);
37
52
  const runRelativePath = getRunRelativeArtifactPath(normalized);
38
- const evidencePath = getEvidenceAttachmentPath(projectRoot, await resolveRunBranchSlug(projectRoot, runId), runRelativePath);
39
- if (await exists(evidencePath)) {
53
+ const payload = await resolveRuntimeArtifactPayload(projectRoot, runId, runRelativePath);
54
+ const runScope = await resolveRunScope(projectRoot, runId);
55
+ const evidencePath = getEvidenceAttachmentPath(projectRoot, runScope.branchSlug, payload?.physicalPayloadPath ?? runRelativePath);
56
+ if (payload) {
40
57
  return readFile(evidencePath, 'utf8');
41
58
  }
42
- return readFile(getArtifactPath(projectRoot, runId, normalized), 'utf8');
59
+ try {
60
+ return await readFile(evidencePath, 'utf8');
61
+ } catch {
62
+ return readFile(getLegacyArtifactPath(projectRoot, runId, normalized), 'utf8');
63
+ }
64
+ }
65
+
66
+ function uniquePhysicalPayloadPath(logicalRef: string, runId: string, digest: string): string {
67
+ const parsed = path.posix.parse(logicalRef.replace(/\\/g, '/'));
68
+ const suffix = `${runId}-${digest.slice(0, 12)}`;
69
+ return path.posix.join(parsed.dir, `${parsed.name}-${suffix}${parsed.ext}`);
43
70
  }
44
71
 
45
72
  export function artifactKind(artifactPath: string): string {
@@ -53,6 +80,9 @@ export function artifactKind(artifactPath: string): string {
53
80
  if (fileName.startsWith('debug-')) {
54
81
  return 'debug';
55
82
  }
83
+ if (fileName.startsWith('test-validation-')) {
84
+ return 'test-validation';
85
+ }
56
86
  if (fileName.startsWith('validation-')) {
57
87
  return 'validation';
58
88
  }
@@ -75,9 +105,12 @@ async function recordRuntimeArtifact(projectRoot: string, input: { runId: string
75
105
  });
76
106
  }
77
107
 
78
- async function resolveRunBranchSlug(projectRoot: string, runId: string): Promise<string> {
108
+ async function resolveRunScope(projectRoot: string, runId: string): Promise<{ branchSlug: string; taskId: string | null }> {
79
109
  const state = await readRuntimeRunState(projectRoot, runId);
80
- return state?.gitBranch ?? state?.partition ?? 'unscoped';
110
+ return {
111
+ branchSlug: state?.gitBranch ?? state?.partition ?? 'unscoped',
112
+ taskId: state?.taskId ?? state?.currentTask ?? null
113
+ };
81
114
  }
82
115
 
83
116
  function hashDocumentContent(raw: string): string {
@@ -1,7 +1,7 @@
1
1
 
2
2
  import path from 'node:path';
3
3
  import { EVENT_LOG_CONTRACT } from '../contracts.js';
4
- import { getRunDir } from '../runtime-paths.js';
4
+ import { getLegacyRunDir } from '../runtime-paths.js';
5
5
 
6
6
  import { importLegacyRunEventsIfNeeded, readRuntimeRunEvents, recordRuntimeEvent } from '../storage/runtime-store.js';
7
7
  import type { RuntimeEvent } from './model.js';
@@ -21,7 +21,7 @@ export async function readRunEvents(projectRoot: string, runId: string): Promise
21
21
  if (storedEvents.length > 0) {
22
22
  return storedEvents;
23
23
  }
24
- const eventPath = path.join(getRunDir(projectRoot, runId), 'events.jsonl');
24
+ const eventPath = path.join(getLegacyRunDir(projectRoot, runId), 'events.jsonl');
25
25
  await importLegacyRunEventsIfNeeded(projectRoot, runId, eventPath);
26
26
  return readRuntimeRunEvents(projectRoot, runId);
27
27
  }
@@ -1,12 +1,11 @@
1
- import { readdir, readFile } from 'node:fs/promises';
2
- import path from 'node:path';
3
1
  import { TASK_RUN_EVIDENCE_CONTRACT_VERSION } from '../contracts.js';
4
- import { getAgentExecutionsDir, getTeamSessionsDir, getWorkerRuntimesDir } from '../runtime-paths.js';
5
- import { exists } from '../storage/json-io.js';
2
+ import { listAgentExecutionRecords as listRuntimeBackedAgentExecutionRecords, listTeamSessionRecords as listRuntimeBackedTeamSessionRecords } from '../execution/agent-execution-records.js';
3
+ import { listResidentWorkerRuntimeRecords as listRuntimeBackedResidentWorkerRuntimeRecords } from '../execution/resident-worker.js';
6
4
  import type { ArtifactIndexEntry, InvocationLedgerEntry, RunState, RunStateArtifactIngestionRecord, RunStateWorktreeLifecycleRecord, RunStatus, RunSummary, RuntimeEvent } from './model.js';
7
5
  import { readRunEvents } from './events.js';
8
6
  import { listInvocationLedgerEntries } from './invocation-ledger.js';
9
7
  import { readRunState, summarizeRunState } from './run-state.js';
8
+ import { readTaskEvidenceView, type TaskEvidenceView } from './task-evidence.js';
10
9
 
11
10
  export interface TaskRunEvidenceGap {
12
11
  type: string;
@@ -26,7 +25,7 @@ export interface AgentExecutionRecordView {
26
25
  artifacts: string[];
27
26
  toolPermission: { profile?: string } | null;
28
27
  routeId: string;
29
- routeDecision: { recommendedProfile?: string };
28
+ routeDecision: { recommendedProfile?: string | null };
30
29
  createdAt: string;
31
30
  [key: string]: unknown;
32
31
  }
@@ -84,6 +83,7 @@ export interface RunInspection {
84
83
  syncBack: RunState['syncBack'];
85
84
  tasks: Record<string, unknown>;
86
85
  taskRunEvidence: TaskRunEvidenceContract;
86
+ taskEvidenceView: TaskEvidenceView | null;
87
87
  agentExecutions: AgentExecutionRecordView[];
88
88
  invocationLedger: InvocationLedgerEntry[];
89
89
  teamSessions: TeamSessionRecordView[];
@@ -94,11 +94,15 @@ export async function inspectRun(projectRoot: string, runId: string): Promise<Ru
94
94
  const state = await readRunState(projectRoot, runId);
95
95
  const [events, agentExecutions, teamSessions, workerRuntimes, invocationLedger] = await Promise.all([
96
96
  readRunEvents(projectRoot, runId),
97
- listAgentExecutionRecords(projectRoot, runId),
98
- listTeamSessionRecords(projectRoot, runId),
99
- listResidentWorkerRuntimeRecords(projectRoot, runId),
97
+ listRuntimeBackedAgentExecutionRecords(projectRoot, runId),
98
+ listRuntimeBackedTeamSessionRecords(projectRoot, runId),
99
+ listRuntimeBackedResidentWorkerRuntimeRecords(projectRoot, runId),
100
100
  listInvocationLedgerEntries(projectRoot, runId)
101
101
  ]);
102
+ const agentExecutionViews = agentExecutions.map((record) => ({ ...record }) as AgentExecutionRecordView);
103
+ const teamSessionViews = teamSessions.map((record) => ({ ...record }) as TeamSessionRecordView);
104
+ const workerRuntimeViews = workerRuntimes.map((record) => ({ ...record }) as ResidentWorkerRuntimeRecordView);
105
+ const taskEvidenceView = state.partition && state.taskId ? await readTaskEvidenceView(projectRoot, { branch: state.partition, taskId: state.taskId }) : null;
102
106
  return {
103
107
  summary: summarizeRunState(state),
104
108
  state,
@@ -110,55 +114,16 @@ export async function inspectRun(projectRoot: string, runId: string): Promise<Ru
110
114
  worktrees: Object.values(state.worktrees ?? {}),
111
115
  validation: state.validation,
112
116
  syncBack: state.syncBack,
113
- taskRunEvidence: buildTaskRunEvidence(state, events, agentExecutions, teamSessions, workerRuntimes, invocationLedger),
117
+ taskRunEvidence: buildTaskRunEvidence(state, events, agentExecutionViews, teamSessionViews, workerRuntimeViews, invocationLedger),
118
+ taskEvidenceView,
114
119
  tasks: state.tasks,
115
- agentExecutions,
116
- teamSessions,
117
- workerRuntimes,
120
+ agentExecutions: agentExecutionViews,
121
+ teamSessions: teamSessionViews,
122
+ workerRuntimes: workerRuntimeViews,
118
123
  invocationLedger
119
124
  };
120
125
  }
121
126
 
122
- async function listAgentExecutionRecords(projectRoot: string, runId: string): Promise<AgentExecutionRecordView[]> {
123
- const recordsDir = getAgentExecutionsDir(projectRoot, runId);
124
- if (!await exists(recordsDir)) {
125
- return [];
126
- }
127
- const records = await readJsonRecords<AgentExecutionRecordView>(recordsDir);
128
- return records.sort((left, right) => left.createdAt.localeCompare(right.createdAt) || left.executionId.localeCompare(right.executionId));
129
- }
130
-
131
- async function listTeamSessionRecords(projectRoot: string, runId: string): Promise<TeamSessionRecordView[]> {
132
- const recordsDir = getTeamSessionsDir(projectRoot, runId);
133
- if (!await exists(recordsDir)) {
134
- return [];
135
- }
136
- const records = await readJsonRecords<TeamSessionRecordView>(recordsDir);
137
- return records.sort((left, right) => left.createdAt.localeCompare(right.createdAt) || left.teamId.localeCompare(right.teamId));
138
- }
139
-
140
- async function listResidentWorkerRuntimeRecords(projectRoot: string, runId: string): Promise<ResidentWorkerRuntimeRecordView[]> {
141
- const recordsDir = getWorkerRuntimesDir(projectRoot, runId);
142
- if (!await exists(recordsDir)) {
143
- return [];
144
- }
145
- const records = await readJsonRecords<ResidentWorkerRuntimeRecordView>(recordsDir);
146
- return records.sort((left, right) => left.updatedAt.localeCompare(right.updatedAt) || left.runtimeId.localeCompare(right.runtimeId));
147
- }
148
-
149
- async function readJsonRecords<T>(recordsDir: string): Promise<T[]> {
150
- const entries = await readdir(recordsDir, { withFileTypes: true });
151
- const records: T[] = [];
152
- for (const entry of entries.filter((candidate) => candidate.isFile() && candidate.name.endsWith('.json'))) {
153
- try {
154
- const raw = await readFile(path.join(recordsDir, entry.name), 'utf8');
155
- records.push(JSON.parse(raw) as T);
156
- } catch {
157
- continue;
158
- }
159
- }
160
- return records;
161
- }
162
127
 
163
128
  function buildTaskRunEvidence(state: RunState, events: RuntimeEvent[], agentExecutions: AgentExecutionRecordView[] = [], teamSessions: TeamSessionRecordView[] = [], workerRuntimes: ResidentWorkerRuntimeRecordView[] = [], invocationLedger: InvocationLedgerEntry[] = []): TaskRunEvidenceContract {
164
129
  return {
@@ -1,7 +1,7 @@
1
1
  import { createHash } from 'node:crypto';
2
2
  import { readFile } from 'node:fs/promises';
3
3
  import { INVOCATION_LEDGER_CONTRACT_VERSION } from '../contracts.js';
4
- import { getInvocationLedgerPath } from '../runtime-paths.js';
4
+ import { getLegacyInvocationLedgerPath } from '../runtime-paths.js';
5
5
  import { exists } from '../storage/json-io.js';
6
6
  import { RuntimeStoreError, legacyImportId, readRuntimeActivities, recordLegacyImportFailure, recordRuntimeActivity, withRuntimeStore } from '../storage/runtime-store.js';
7
7
  import type { InvocationLedgerEntry } from './model.js';
@@ -24,7 +24,7 @@ export async function listInvocationLedgerEntries(projectRoot: string, runId: st
24
24
  if (entries.length > 0) {
25
25
  return entries;
26
26
  }
27
- const ledgerPath = getInvocationLedgerPath(projectRoot, runId);
27
+ const ledgerPath = getLegacyInvocationLedgerPath(projectRoot, runId);
28
28
  await importLegacyInvocationLedgerIfNeeded(projectRoot, runId, ledgerPath);
29
29
  return readRuntimeActivities(projectRoot, runId);
30
30
  }
@@ -25,8 +25,13 @@ export interface RunDocumentSnapshot {
25
25
  specHash: string | null;
26
26
  planHash: string | null;
27
27
  tasksHash: string | null;
28
+ specContractHash: string | null;
29
+ planContractHash: string | null;
30
+ tasksContractHash: string | null;
28
31
  planBasedOnSpecHash: string | null;
29
32
  tasksBasedOnPlanHash: string | null;
33
+ planBasedOnSpecContractHash: string | null;
34
+ tasksBasedOnPlanContractHash: string | null;
30
35
  }
31
36
 
32
37
  export interface RunStateContractValidationIssue {
@@ -117,6 +122,28 @@ export interface RunStateWorktreeLifecycleRecord {
117
122
  dirty: boolean;
118
123
  }
119
124
 
125
+ export type RunTaskImplementationStatus = 'not_started' | 'running' | 'implemented' | 'blocked' | 'failed';
126
+
127
+ export type RunTaskVerificationStatus = 'not_run' | 'pending_batch' | 'ready_for_validation' | 'running' | 'pass' | 'pass_with_gaps' | 'blocked' | 'failed';
128
+
129
+ export interface RunStateTaskRuntime {
130
+ status: string;
131
+ implementationStatus?: RunTaskImplementationStatus;
132
+ verificationStatus?: RunTaskVerificationStatus;
133
+ validationBatch?: string | null;
134
+ validationTiming?: 'task_end' | 'batch_end' | 'wave_end';
135
+ requiresVerifyBeforeNext?: boolean;
136
+ gaps?: unknown[];
137
+ artifacts?: string[];
138
+ testStatus?: string;
139
+ validationStatus?: string;
140
+ verifyStatus?: string;
141
+ workflowGateStatus?: string;
142
+ workflowGateDecisionId?: string;
143
+ evidence?: string[];
144
+ acceptanceCoverage?: unknown[];
145
+ }
146
+
120
147
  export interface RunState {
121
148
  contract: typeof RUN_STATE_CONTRACT;
122
149
  runtimeVersion: typeof RUNTIME_VERSION;
@@ -136,7 +163,7 @@ export interface RunState {
136
163
  eventLogPath: string;
137
164
  artifactRoot: string;
138
165
  lifecycleDecision: RunStateLifecycleDecisionRecord | null;
139
- tasks: Record<string, unknown>;
166
+ tasks: Record<string, RunStateTaskRuntime>;
140
167
  agents: Record<string, unknown>;
141
168
  delegations: Record<string, RunStateDelegationRecord>;
142
169
  artifacts: ArtifactIndexEntry[];
@@ -8,6 +8,8 @@ import { initProject } from '../config/init-project.js';
8
8
  import { readRunEvents } from './events.js';
9
9
  import { createRun, listRuns, readRunState, writeRunState } from './run-state.js';
10
10
  import { validTaskMarkdown, writeBranchDocs } from '../test-support/fixtures.js';
11
+ import { getRunDir } from '../runtime-paths.js';
12
+ import { exists } from '../storage/json-io.js';
11
13
 
12
14
  test('createRun writes state and append-only events', async () => {
13
15
  const root = await mkdtemp(path.join(tmpdir(), 'sdd-runtime-'));
@@ -21,6 +23,7 @@ test('createRun writes state and append-only events', async () => {
21
23
  const events = await readRunEvents(root, state.runId);
22
24
  assert.equal(events.some((event) => event.event === 'run_started'), true);
23
25
  assert.equal(events.some((event) => event.event === 'lifecycle_decision_recorded'), true);
26
+ assert.equal(await exists(getRunDir(root, state.runId)), false);
24
27
  } finally {
25
28
  await rm(root, { recursive: true, force: true });
26
29
  }
@@ -2,13 +2,10 @@ import { createHash } from 'node:crypto';
2
2
  import { mkdir, readdir, readFile } from 'node:fs/promises';
3
3
  import path from 'node:path';
4
4
  import {
5
- getAgentExecutionsDir,
6
5
  getEvidenceDir,
6
+ getLegacyRunDir,
7
7
  getProjectConfigPath,
8
- getRunDir,
9
- getRunsDir,
10
- getTeamSessionsDir,
11
- getWorkerRuntimesDir
8
+ getRunsDir
12
9
  } from '../runtime-paths.js';
13
10
  import { exists } from '../storage/json-io.js';
14
11
  import { RuntimeStoreError, legacyImportId, listRuntimeRunStates, readRuntimeRunState, recordLegacyImportFailure, runtimeScopedId, upsertRuntimeRunState, withRuntimeStore } from '../storage/runtime-store.js';
@@ -26,7 +23,7 @@ export async function readRunState(projectRoot: string, runId: string): Promise<
26
23
  if (storedState) {
27
24
  return normalizeRunState(storedState);
28
25
  }
29
- const statePath = path.join(getRunDir(projectRoot, runId), 'state.json');
26
+ const statePath = path.join(getLegacyRunDir(projectRoot, runId), 'state.json');
30
27
  const legacyState = await importLegacyRunStateIfNeeded(projectRoot, runId, statePath);
31
28
  if (legacyState) {
32
29
  return legacyState;
@@ -94,14 +91,6 @@ export async function createRun(projectRoot: string, options: CreateRunOptions =
94
91
  await mkdir(getRunsDir(projectRoot), { recursive: true });
95
92
  const runId = options.runId ?? await createUniqueRunId(projectRoot);
96
93
 
97
- const agentExecutionsDir = getAgentExecutionsDir(projectRoot, runId);
98
- const teamSessionsDir = getTeamSessionsDir(projectRoot, runId);
99
- const workerRuntimesDir = getWorkerRuntimesDir(projectRoot, runId);
100
- await Promise.all([
101
- mkdir(agentExecutionsDir, { recursive: true }),
102
- mkdir(teamSessionsDir, { recursive: true }),
103
- mkdir(workerRuntimesDir, { recursive: true })
104
- ]);
105
94
 
106
95
  const now = new Date().toISOString();
107
96
  const state: RunState = {
@@ -175,7 +164,7 @@ export async function createUniqueRunId(projectRoot: string): Promise<string> {
175
164
  for (let sequence = 1; sequence <= 999; sequence += 1) {
176
165
  const runId = `${base}-${String(sequence).padStart(3, '0')}`;
177
166
  const storedState = await readRuntimeRunState(projectRoot, runId);
178
- if (!storedState && !await exists(getRunDir(projectRoot, runId))) {
167
+ if (!storedState && !await exists(getLegacyRunDir(projectRoot, runId))) {
179
168
  return runId;
180
169
  }
181
170
  }
@@ -261,8 +250,13 @@ export function normalizeRunDocumentSnapshot(snapshot: unknown): RunDocumentSnap
261
250
  specHash: stringOrNull(snapshot.specHash),
262
251
  planHash: stringOrNull(snapshot.planHash),
263
252
  tasksHash: stringOrNull(snapshot.tasksHash),
253
+ specContractHash: stringOrNull(snapshot.specContractHash),
254
+ planContractHash: stringOrNull(snapshot.planContractHash),
255
+ tasksContractHash: stringOrNull(snapshot.tasksContractHash),
264
256
  planBasedOnSpecHash: stringOrNull(snapshot.planBasedOnSpecHash),
265
- tasksBasedOnPlanHash: stringOrNull(snapshot.tasksBasedOnPlanHash)
257
+ tasksBasedOnPlanHash: stringOrNull(snapshot.tasksBasedOnPlanHash),
258
+ planBasedOnSpecContractHash: stringOrNull(snapshot.planBasedOnSpecContractHash),
259
+ tasksBasedOnPlanContractHash: stringOrNull(snapshot.tasksBasedOnPlanContractHash)
266
260
  };
267
261
  }
268
262
 
@@ -271,8 +265,13 @@ export function emptyRunDocumentSnapshot(): RunDocumentSnapshot {
271
265
  specHash: null,
272
266
  planHash: null,
273
267
  tasksHash: null,
268
+ specContractHash: null,
269
+ planContractHash: null,
270
+ tasksContractHash: null,
274
271
  planBasedOnSpecHash: null,
275
- tasksBasedOnPlanHash: null
272
+ tasksBasedOnPlanHash: null,
273
+ planBasedOnSpecContractHash: null,
274
+ tasksBasedOnPlanContractHash: null
276
275
  };
277
276
  }
278
277
 
@@ -324,8 +323,13 @@ async function resolveCreateRunScope(projectRoot: string, branch: string, taskId
324
323
  specHash: model.documents.specHash ?? null,
325
324
  planHash: model.documents.planHash ?? null,
326
325
  tasksHash: model.documents.tasksHash ?? null,
326
+ specContractHash: model.documents.specContractHash ?? null,
327
+ planContractHash: model.documents.planContractHash ?? null,
328
+ tasksContractHash: model.documents.tasksContractHash ?? null,
327
329
  planBasedOnSpecHash: model.documents.planBasedOnSpecHash ?? null,
328
- tasksBasedOnPlanHash: model.documents.tasksBasedOnPlanHash ?? null
330
+ tasksBasedOnPlanHash: model.documents.tasksBasedOnPlanHash ?? null,
331
+ planBasedOnSpecContractHash: model.documents.planBasedOnSpecContractHash ?? null,
332
+ tasksBasedOnPlanContractHash: model.documents.tasksBasedOnPlanContractHash ?? null
329
333
  }
330
334
  };
331
335
  }