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,114 @@
1
+ import type { FanInEvidenceSetRecord, LlmAdvisorAssessmentRecord } from '../execution/stage-team-runtime.js';
2
+ import type { RuntimeDurableGapRecord, RuntimeSyncBackDecisionRecord } from '../storage/runtime-store.js';
3
+ import type { LatestEligibleRunSelection } from '../workflow-state/latest-eligible-run.js';
4
+ import type { WorkflowDependencyBlocker } from '../workflow-state/dependencies.js';
5
+ import type { WorkflowAffectedFileConflict } from '../workflow-state/affected-file-conflicts.js';
6
+ import type { SddTaskModel } from '../sdd-docs/task-parser.js';
7
+
8
+ export type WorkflowGateStatus = 'PASS' | 'WARN' | 'BLOCKED' | 'HUMAN_REQUIRED' | 'ADVISORY_ONLY';
9
+ export type WorkflowGateHardCheckSeverity = 'info' | 'warning' | 'blocked';
10
+ export type WorkflowGateAdvisorSummaryStatus = 'none' | 'low_concern' | 'medium_concern' | 'high_concern' | 'invalid';
11
+ export type WorkflowGateDecisionKind = 'test' | 'validation_wave' | 'review_gate' | 'sync_back' | 'ship' | 'stage_transition';
12
+
13
+ export type WorkflowGateHardCheckCode =
14
+ | 'schema_health_unavailable'
15
+ | 'missing_documents'
16
+ | 'stale_documents'
17
+ | 'contract_hash_mismatch'
18
+ | 'run_rejected'
19
+ | 'blocked_failed_or_archived_run'
20
+ | 'latest_eligible_missing'
21
+ | 'missing_payload'
22
+ | 'digest_drift'
23
+ | 'missing_required_artifact'
24
+ | 'validation_failure'
25
+ | 'dependency_blocker'
26
+ | 'authority_violation'
27
+ | 'sync_back_divergence'
28
+ | 'affected_file_conflict'
29
+ | 'durable_gap_blocking';
30
+
31
+ export interface WorkflowGateHardCheck {
32
+ code: WorkflowGateHardCheckCode;
33
+ severity: WorkflowGateHardCheckSeverity;
34
+ scope: string;
35
+ message: string;
36
+ recovery: string;
37
+ refs: string[];
38
+ }
39
+
40
+ export interface WorkflowGateArtifactPayloadHealth {
41
+ payloadId: string;
42
+ logicalRef: string;
43
+ physicalPayloadPath: string;
44
+ expectedDigest: string;
45
+ actualDigest: string | null;
46
+ status: 'ok' | 'missing' | 'digest_drift';
47
+ }
48
+
49
+ export interface WorkflowGateRuntimeHealth {
50
+ status: 'ok' | 'unavailable';
51
+ issues: string[];
52
+ }
53
+
54
+ export interface WorkflowGateScope {
55
+ waveRunId: string | null;
56
+ taskIds: string[];
57
+ runIds: string[];
58
+ evidenceRefs: string[];
59
+ }
60
+
61
+ export interface WorkflowGateEvidencePacket {
62
+ packetId: string;
63
+ generatedAt: string;
64
+ decisionKind: WorkflowGateDecisionKind;
65
+ partition: string;
66
+ taskId: string | null;
67
+ runId: string | null;
68
+ documents: SddTaskModel['documents'];
69
+ latestEligibleSelection: LatestEligibleRunSelection | null;
70
+ latestEligibleSelections: LatestEligibleRunSelection[];
71
+ workflowScope: WorkflowGateScope;
72
+ runtimeHealth: WorkflowGateRuntimeHealth;
73
+ durableGaps: RuntimeDurableGapRecord[];
74
+ dependencyBlockers: WorkflowDependencyBlocker[];
75
+ affectedFileConflicts: WorkflowAffectedFileConflict[];
76
+ syncBackDecision: RuntimeSyncBackDecisionRecord | null;
77
+ syncBackDecisions: RuntimeSyncBackDecisionRecord[];
78
+ fanInEvidenceSets: FanInEvidenceSetRecord[];
79
+ advisorAssessments: LlmAdvisorAssessmentRecord[];
80
+ canonicalEvidenceRefs: string[];
81
+ requiredArtifactRefs: string[];
82
+ artifactPayloadHealth: WorkflowGateArtifactPayloadHealth[];
83
+ hardChecks: WorkflowGateHardCheck[];
84
+ }
85
+
86
+ export interface WorkflowGateAdvisorSummary {
87
+ status: WorkflowGateAdvisorSummaryStatus;
88
+ highConcernCount: number;
89
+ mediumConcernCount: number;
90
+ invalidCount: number;
91
+ lowConfidenceCount: number;
92
+ summaries: string[];
93
+ }
94
+
95
+ export interface WorkflowGateDecision {
96
+ decisionId: string;
97
+ inputHash: string;
98
+ generatedAt: string;
99
+ partition: string;
100
+ taskId: string | null;
101
+ runId: string | null;
102
+ decisionKind: WorkflowGateDecisionKind;
103
+ status: WorkflowGateStatus;
104
+ decidedBy: 'runtime_policy';
105
+ hardBlocks: WorkflowGateHardCheck[];
106
+ warnings: WorkflowGateHardCheck[];
107
+ advisorSummary: WorkflowGateAdvisorSummary;
108
+ allowedNextActions: string[];
109
+ forbiddenNextActions: string[];
110
+ humanRequired: boolean;
111
+ reasons: string[];
112
+ evidenceRefs: string[];
113
+ payload: unknown;
114
+ }
@@ -40,6 +40,11 @@ export function affectedFileConflictsForSelectedRun(states: RunState[], selected
40
40
  return conflicts.sort((left, right) => left.file.localeCompare(right.file) || left.partition.localeCompare(right.partition) || left.taskId.localeCompare(right.taskId) || left.runId.localeCompare(right.runId));
41
41
  }
42
42
 
43
+ export function affectedFileConflictsForSelectedRuns(states: RunState[], selectedRuns: RunState[]): WorkflowAffectedFileConflict[] {
44
+ const conflicts = selectedRuns.flatMap((selected) => affectedFileConflictsForSelectedRun(states, selected));
45
+ return uniqueBy(conflicts, (conflict) => `${conflict.file}:${conflict.partition}:${conflict.taskId}:${conflict.runId}`);
46
+ }
47
+
43
48
  function isAffectedFileConflictCandidate(candidate: RunState, selected: RunState): candidate is RunState & { partition: string; taskId: string } {
44
49
  if (candidate.runId === selected.runId || candidate.status === 'archived' || !candidate.partition || !candidate.taskId) {
45
50
  return false;
@@ -54,7 +59,7 @@ function isAffectedFileConflictCandidate(candidate: RunState, selected: RunState
54
59
  }
55
60
 
56
61
  function isActiveAffectedFileRun(state: RunState): boolean {
57
- return state.status === 'created' || state.status === 'running' || state.syncBack.status === 'proposed';
62
+ return state.status === 'created' || state.status === 'running';
58
63
  }
59
64
 
60
65
  function selectedSupersedesCandidate(selected: RunState, candidate: RunState): boolean {
@@ -77,3 +82,15 @@ function isNonAuthoritativeForegroundRun(state: RunState): boolean {
77
82
  const delegations = Object.values(state.delegations);
78
83
  return delegations.length > 0 && delegations.every((delegation) => delegation.runMode === 'foreground' && !delegation.blocking && !delegation.requiredForPhaseExit);
79
84
  }
85
+
86
+ function uniqueBy<T>(items: T[], keyOf: (item: T) => string): T[] {
87
+ const seen = new Set<string>();
88
+ return items.filter((item) => {
89
+ const key = keyOf(item);
90
+ if (seen.has(key)) {
91
+ return false;
92
+ }
93
+ seen.add(key);
94
+ return true;
95
+ });
96
+ }
@@ -16,7 +16,7 @@ test('dependency readiness blocks tasks until dependencies are completed', () =>
16
16
 
17
17
  assert.equal(readiness.ready, false);
18
18
  assert.deepEqual(readiness.dependencies.map((dependency) => `${dependency.taskId}:${dependency.status}:${dependency.ready}`), ['DEP1:pending:false']);
19
- assert.match(readiness.blockingReasons[0], /DEP2 depends on DEP1, but DEP1 status is pending/);
19
+ assert.match(readiness.blockingReasons[0], /DEP2 depends on DEP1, but DEP1 has not passed required verification/);
20
20
  assert.deepEqual(workflowDependencyBlockers(model).map((blocker) => `${blocker.taskId}->${blocker.dependencyId}:${blocker.dependencyStatus}`), ['DEP2->DEP1:pending']);
21
21
  });
22
22
 
@@ -1,6 +1,11 @@
1
+ import type { RunStateTaskRuntime } from '../run-state/model.js';
1
2
  import type { SddTask, SddTaskModel } from '../sdd-docs/task-parser.js';
2
3
  type TaskDependencyModel = Pick<SddTaskModel, 'tasks'>;
3
4
 
5
+ export interface TaskDependencyReadinessOptions {
6
+ runtimeByTask?: Map<string, RunStateTaskRuntime>;
7
+ }
8
+
4
9
  export interface TaskDependencyReadinessEntry {
5
10
  taskId: string;
6
11
  status: SddTask['status'] | 'missing';
@@ -22,13 +27,13 @@ export interface WorkflowDependencyBlocker {
22
27
  reason: string;
23
28
  }
24
29
 
25
- export function resolveTaskDependencyReadiness(model: TaskDependencyModel, taskId: string): TaskDependencyReadiness {
30
+ export function resolveTaskDependencyReadiness(model: TaskDependencyModel, taskId: string, options: TaskDependencyReadinessOptions = {}): TaskDependencyReadiness {
26
31
  const task = model.tasks.find((candidate) => candidate.id === taskId) ?? null;
27
32
  if (!task) {
28
33
  return { taskId, ready: false, dependencies: [], blockingReasons: [`Task ${taskId} was not found.`] };
29
34
  }
30
35
 
31
- const dependencies = task.dependsOn.map((dependencyId) => dependencyReadinessEntry(task.id, dependencyId, model.tasks.find((candidate) => candidate.id === dependencyId) ?? null));
36
+ const dependencies = task.dependsOn.map((dependencyId) => dependencyReadinessEntry(task.id, dependencyId, model.tasks.find((candidate) => candidate.id === dependencyId) ?? null, options.runtimeByTask?.get(dependencyId)));
32
37
  const blockingReasons = dependencies.map((dependency) => dependency.reason).filter((reason): reason is string => Boolean(reason));
33
38
  return {
34
39
  taskId: task.id,
@@ -38,17 +43,17 @@ export function resolveTaskDependencyReadiness(model: TaskDependencyModel, taskI
38
43
  };
39
44
  }
40
45
 
41
- export function dependencyBlockingReasonsForTask(model: TaskDependencyModel, taskId: string): string[] {
42
- return resolveTaskDependencyReadiness(model, taskId).blockingReasons;
46
+ export function dependencyBlockingReasonsForTask(model: TaskDependencyModel, taskId: string, options: TaskDependencyReadinessOptions = {}): string[] {
47
+ return resolveTaskDependencyReadiness(model, taskId, options).blockingReasons;
43
48
  }
44
49
 
45
- export function workflowDependencyBlockers(model: TaskDependencyModel): WorkflowDependencyBlocker[] {
50
+ export function workflowDependencyBlockers(model: TaskDependencyModel, options: TaskDependencyReadinessOptions = {}): WorkflowDependencyBlocker[] {
46
51
  const blockers: WorkflowDependencyBlocker[] = [];
47
52
  for (const task of model.tasks) {
48
53
  if (task.status === 'completed' || task.status === 'deferred') {
49
54
  continue;
50
55
  }
51
- for (const dependency of resolveTaskDependencyReadiness(model, task.id).dependencies) {
56
+ for (const dependency of resolveTaskDependencyReadiness(model, task.id, options).dependencies) {
52
57
  if (!dependency.ready && dependency.reason) {
53
58
  blockers.push({
54
59
  taskId: task.id,
@@ -62,11 +67,11 @@ export function workflowDependencyBlockers(model: TaskDependencyModel): Workflow
62
67
  return blockers;
63
68
  }
64
69
 
65
- export function nextDependencyTaskId(model: TaskDependencyModel, taskId: string): string | null {
66
- return resolveTaskDependencyReadiness(model, taskId).dependencies.find((dependency) => !dependency.ready)?.taskId ?? null;
70
+ export function nextDependencyTaskId(model: TaskDependencyModel, taskId: string, options: TaskDependencyReadinessOptions = {}): string | null {
71
+ return resolveTaskDependencyReadiness(model, taskId, options).dependencies.find((dependency) => !dependency.ready)?.taskId ?? null;
67
72
  }
68
73
 
69
- function dependencyReadinessEntry(taskId: string, dependencyId: string, dependency: SddTask | null): TaskDependencyReadinessEntry {
74
+ function dependencyReadinessEntry(taskId: string, dependencyId: string, dependency: SddTask | null, runtime: RunStateTaskRuntime | undefined): TaskDependencyReadinessEntry {
70
75
  if (!dependency) {
71
76
  return {
72
77
  taskId: dependencyId,
@@ -75,7 +80,7 @@ function dependencyReadinessEntry(taskId: string, dependencyId: string, dependen
75
80
  reason: `Task ${taskId} depends on ${dependencyId}, but ${dependencyId} was not found; restore or remove the dependency before continuing ${taskId}.`
76
81
  };
77
82
  }
78
- if (dependency.status === 'completed') {
83
+ if (dependency.status === 'completed' || dependencyRuntimeSatisfiesImplementationBoundary(dependency, runtime)) {
79
84
  return {
80
85
  taskId: dependency.id,
81
86
  status: dependency.status,
@@ -87,6 +92,23 @@ function dependencyReadinessEntry(taskId: string, dependencyId: string, dependen
87
92
  taskId: dependency.id,
88
93
  status: dependency.status,
89
94
  ready: false,
90
- reason: `Task ${taskId} depends on ${dependency.id}, but ${dependency.id} status is ${dependency.status}; complete and sync-back ${dependency.id} before continuing ${taskId}.`
95
+ reason: dependencyRequiresVerifiedBoundary(dependency)
96
+ ? `Task ${taskId} depends on ${dependency.id}, but ${dependency.id} has not passed required verification; run sdd test task ${dependency.id} before continuing ${taskId}.`
97
+ : `Task ${taskId} depends on ${dependency.id}, but ${dependency.id} is not implemented; run sdd do task ${dependency.id} before continuing ${taskId}.`
91
98
  };
92
99
  }
100
+
101
+ function dependencyRuntimeSatisfiesImplementationBoundary(task: SddTask, runtime: RunStateTaskRuntime | undefined): boolean {
102
+ if (!runtimeTaskImplemented(runtime)) {
103
+ return false;
104
+ }
105
+ return !dependencyRequiresVerifiedBoundary(task) || runtime?.verificationStatus === 'pass' || runtime?.status === 'implemented_verified';
106
+ }
107
+
108
+ function dependencyRequiresVerifiedBoundary(task: SddTask): boolean {
109
+ return task.requiresVerifyBeforeNext || task.validationTiming === 'task_end';
110
+ }
111
+
112
+ function runtimeTaskImplemented(runtime: RunStateTaskRuntime | undefined): boolean {
113
+ return runtime?.implementationStatus === 'implemented' || runtime?.status === 'implemented_pending_validation' || runtime?.status === 'implemented_verified';
114
+ }
@@ -0,0 +1,156 @@
1
+ import type { RunState } from '../run-state/model.js';
2
+ import type { SddTaskModel } from '../sdd-docs/task-parser.js';
3
+
4
+ export type DocumentCompatibilityClass = 'compatible' | 'soft_stale' | 'strict_stale' | 'incompatible';
5
+
6
+ export interface LatestEligibleRunCandidate {
7
+ partition: string;
8
+ gitBranch: string | null;
9
+ taskId: string;
10
+ runId: string;
11
+ runStatus: RunState['status'];
12
+ validationStatus: RunState['validation']['status'];
13
+ syncBackStatus: RunState['syncBack']['status'];
14
+ affectedFiles: string[];
15
+ updatedAt: string;
16
+ compatibility: DocumentCompatibilityClass;
17
+ eligibleForDefaultApply: boolean;
18
+ reasons: string[];
19
+ }
20
+
21
+ export interface LatestEligibleRunSelection {
22
+ partition: string;
23
+ taskId: string;
24
+ selected: LatestEligibleRunCandidate | null;
25
+ candidates: LatestEligibleRunCandidate[];
26
+ rejected: LatestEligibleRunCandidate[];
27
+ }
28
+
29
+ export function selectLatestEligibleRun(input: { states: RunState[]; model: SddTaskModel; partition: string; taskId: string; currentGitBranch?: string | null }): LatestEligibleRunSelection {
30
+ const candidates = input.states
31
+ .filter((state) => state.partition === input.partition && state.taskId === input.taskId)
32
+ .map((state) => latestEligibleCandidate(state, input.model));
33
+ const visible = candidates.filter((candidate) => candidate.runStatus !== 'archived').sort(compareCandidates);
34
+ const eligible = visible.filter((candidate) => candidate.eligibleForDefaultApply);
35
+ return {
36
+ partition: input.partition,
37
+ taskId: input.taskId,
38
+ selected: eligible[0] ?? null,
39
+ candidates: visible,
40
+ rejected: candidates.filter((candidate) => !candidate.eligibleForDefaultApply).sort(compareCandidates)
41
+ };
42
+ }
43
+
44
+ export function selectLatestEligibleRunsByTask(input: { states: RunState[]; model: SddTaskModel; partition: string; currentGitBranch?: string | null }): LatestEligibleRunSelection[] {
45
+ const taskIds = Array.from(new Set([
46
+ ...input.model.tasks.map((task) => task.id),
47
+ ...input.states
48
+ .filter((state) => state.partition === input.partition && state.taskId)
49
+ .map((state) => state.taskId as string)
50
+ ]))
51
+ .sort((left, right) => left.localeCompare(right));
52
+ return taskIds.map((taskId) => selectLatestEligibleRun({ ...input, taskId }));
53
+ }
54
+
55
+ function latestEligibleCandidate(state: RunState, model: SddTaskModel): LatestEligibleRunCandidate {
56
+ const compatibility = classifyDocumentCompatibility(state, model);
57
+ const reasons = candidateRejectionReasons(state, compatibility);
58
+ return {
59
+ partition: state.partition ?? model.branch,
60
+ gitBranch: state.gitBranch,
61
+ taskId: state.taskId ?? state.currentTask ?? '',
62
+ runId: state.runId,
63
+ runStatus: state.status,
64
+ validationStatus: state.validation.status,
65
+ syncBackStatus: state.syncBack.status,
66
+ affectedFiles: state.affectedFiles,
67
+ updatedAt: state.updatedAt,
68
+ compatibility,
69
+ eligibleForDefaultApply: reasons.length === 0,
70
+ reasons
71
+ };
72
+ }
73
+
74
+ export function classifyDocumentCompatibility(state: RunState, model: SddTaskModel): DocumentCompatibilityClass {
75
+ const snapshot = state.documentSnapshot;
76
+ const hasSnapshot = Boolean(snapshot.specHash || snapshot.planHash || snapshot.tasksHash || snapshot.specContractHash || snapshot.planContractHash || snapshot.tasksContractHash);
77
+ if (!hasSnapshot) {
78
+ return 'incompatible';
79
+ }
80
+ const specMismatch = snapshot.specContractHash !== null
81
+ ? documentHashMismatch(snapshot.specContractHash, model.documents.specContractHash ?? null)
82
+ : documentHashMismatch(snapshot.specHash, model.documents.specHash ?? null);
83
+ const planMismatch = snapshot.planContractHash !== null
84
+ ? documentHashMismatch(snapshot.planContractHash, model.documents.planContractHash ?? null)
85
+ : documentHashMismatch(snapshot.planHash, model.documents.planHash ?? null);
86
+ const tasksSemanticMismatch = snapshot.tasksContractHash !== null
87
+ ? documentHashMismatch(snapshot.tasksContractHash, model.documents.tasksContractHash ?? null)
88
+ : false;
89
+ const tasksDocMismatch = documentHashMismatch(snapshot.tasksHash, model.documents.tasksHash ?? null);
90
+ if (specMismatch || planMismatch) {
91
+ return 'strict_stale';
92
+ }
93
+ if (model.documents.planStale || model.documents.tasksStale) {
94
+ return 'strict_stale';
95
+ }
96
+ if (tasksSemanticMismatch) {
97
+ return 'strict_stale';
98
+ }
99
+ if (tasksDocMismatch) {
100
+ return 'soft_stale';
101
+ }
102
+ return 'compatible';
103
+ }
104
+
105
+ function candidateRejectionReasons(state: RunState, compatibility: DocumentCompatibilityClass): string[] {
106
+ const reasons: string[] = [];
107
+ if (state.status === 'archived') {
108
+ reasons.push('Run is archived.');
109
+ }
110
+ if (state.status === 'failed') {
111
+ reasons.push('Run failed.');
112
+ }
113
+ if (state.status === 'blocked') {
114
+ reasons.push('Run is blocked.');
115
+ }
116
+ if (state.validation.status === 'fail' || state.validation.status === 'blocked') {
117
+ reasons.push(`Run validation status is ${state.validation.status}.`);
118
+ }
119
+ if (compatibility === 'strict_stale') {
120
+ reasons.push('Run document compatibility is strict_stale.');
121
+ }
122
+ if (compatibility === 'incompatible') {
123
+ reasons.push('Run document compatibility is incompatible.');
124
+ }
125
+ return reasons;
126
+ }
127
+
128
+ function documentHashMismatch(expected: string | null, actual: string | null): boolean {
129
+ if (!expected && !actual) {
130
+ return false;
131
+ }
132
+ return expected !== actual;
133
+ }
134
+
135
+ function compareCandidates(left: LatestEligibleRunCandidate, right: LatestEligibleRunCandidate): number {
136
+ const leftRank = compatibilityRank(left.compatibility);
137
+ const rightRank = compatibilityRank(right.compatibility);
138
+ if (leftRank !== rightRank) {
139
+ return leftRank - rightRank;
140
+ }
141
+ const updatedAt = Date.parse(right.updatedAt) - Date.parse(left.updatedAt);
142
+ return updatedAt !== 0 ? updatedAt : right.runId.localeCompare(left.runId);
143
+ }
144
+
145
+ function compatibilityRank(compatibility: DocumentCompatibilityClass): number {
146
+ switch (compatibility) {
147
+ case 'compatible':
148
+ return 0;
149
+ case 'soft_stale':
150
+ return 1;
151
+ case 'strict_stale':
152
+ return 2;
153
+ case 'incompatible':
154
+ return 3;
155
+ }
156
+ }