sdd-agent-platform 0.4.1 → 0.4.2

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 (722) hide show
  1. package/README.md +30 -28
  2. package/node_modules/@sdd-agent-platform/core/dist/ai-tools.js +67 -69
  3. package/node_modules/@sdd-agent-platform/core/dist/ai-tools.js.map +1 -1
  4. package/node_modules/@sdd-agent-platform/core/dist/artifacts/ingestion.js +64 -9
  5. package/node_modules/@sdd-agent-platform/core/dist/artifacts/ingestion.js.map +1 -1
  6. package/node_modules/@sdd-agent-platform/core/dist/artifacts/sdd-evidence.js +0 -1
  7. package/node_modules/@sdd-agent-platform/core/dist/artifacts/sdd-evidence.js.map +1 -1
  8. package/node_modules/@sdd-agent-platform/core/dist/artifacts/sdd-result.js +26 -17
  9. package/node_modules/@sdd-agent-platform/core/dist/artifacts/sdd-result.js.map +1 -1
  10. package/node_modules/@sdd-agent-platform/core/dist/config/init-project.d.ts +3 -0
  11. package/node_modules/@sdd-agent-platform/core/dist/config/init-project.js +12 -9
  12. package/node_modules/@sdd-agent-platform/core/dist/config/init-project.js.map +1 -1
  13. package/node_modules/@sdd-agent-platform/core/dist/config/project-config.d.ts +3 -1
  14. package/node_modules/@sdd-agent-platform/core/dist/config/project-config.js +7 -3
  15. package/node_modules/@sdd-agent-platform/core/dist/config/project-config.js.map +1 -1
  16. package/node_modules/@sdd-agent-platform/core/dist/config/starter-documents.d.ts +4 -4
  17. package/node_modules/@sdd-agent-platform/core/dist/config/starter-documents.js +12 -25
  18. package/node_modules/@sdd-agent-platform/core/dist/config/starter-documents.js.map +1 -1
  19. package/node_modules/@sdd-agent-platform/core/dist/context/build-package.d.ts +1 -1
  20. package/node_modules/@sdd-agent-platform/core/dist/context/build-package.js +1 -7
  21. package/node_modules/@sdd-agent-platform/core/dist/context/build-package.js.map +1 -1
  22. package/node_modules/@sdd-agent-platform/core/dist/context/evidence-summary.js +26 -8
  23. package/node_modules/@sdd-agent-platform/core/dist/context/evidence-summary.js.map +1 -1
  24. package/node_modules/@sdd-agent-platform/core/dist/context/log-worker.js +2 -2
  25. package/node_modules/@sdd-agent-platform/core/dist/context/log-worker.js.map +1 -1
  26. package/node_modules/@sdd-agent-platform/core/dist/context-offload/contracts.d.ts +1 -1
  27. package/node_modules/@sdd-agent-platform/core/dist/contracts.d.ts +2 -1
  28. package/node_modules/@sdd-agent-platform/core/dist/contracts.js +1 -0
  29. package/node_modules/@sdd-agent-platform/core/dist/contracts.js.map +1 -1
  30. package/node_modules/@sdd-agent-platform/core/dist/delegation/model.d.ts +3 -0
  31. package/node_modules/@sdd-agent-platform/core/dist/delegation/validation.d.ts +3 -0
  32. package/node_modules/@sdd-agent-platform/core/dist/delegation/validation.js +7 -4
  33. package/node_modules/@sdd-agent-platform/core/dist/delegation/validation.js.map +1 -1
  34. package/node_modules/@sdd-agent-platform/core/dist/doctor/checks/document-chain.js +1 -1
  35. package/node_modules/@sdd-agent-platform/core/dist/doctor/checks/document-chain.js.map +1 -1
  36. package/node_modules/@sdd-agent-platform/core/dist/doctor/checks/project.js +8 -8
  37. package/node_modules/@sdd-agent-platform/core/dist/doctor/checks/project.js.map +1 -1
  38. package/node_modules/@sdd-agent-platform/core/dist/doctor/checks/registries.js +0 -1
  39. package/node_modules/@sdd-agent-platform/core/dist/doctor/checks/registries.js.map +1 -1
  40. package/node_modules/@sdd-agent-platform/core/dist/doctor/checks/run-evidence.js +4 -4
  41. package/node_modules/@sdd-agent-platform/core/dist/doctor/checks/run-evidence.js.map +1 -1
  42. package/node_modules/@sdd-agent-platform/core/dist/doctor/checks/run-trust.js +0 -24
  43. package/node_modules/@sdd-agent-platform/core/dist/doctor/checks/run-trust.js.map +1 -1
  44. package/node_modules/@sdd-agent-platform/core/dist/doctor/checks/runtime-contracts.js +1 -1
  45. package/node_modules/@sdd-agent-platform/core/dist/doctor/checks/runtime-contracts.js.map +1 -1
  46. package/node_modules/@sdd-agent-platform/core/dist/doctor/doctor.js +178 -58
  47. package/node_modules/@sdd-agent-platform/core/dist/doctor/doctor.js.map +1 -1
  48. package/node_modules/@sdd-agent-platform/core/dist/evidence/lookup.js +14 -7
  49. package/node_modules/@sdd-agent-platform/core/dist/evidence/lookup.js.map +1 -1
  50. package/node_modules/@sdd-agent-platform/core/dist/evidence-runtime/contracts.d.ts +0 -1
  51. package/node_modules/@sdd-agent-platform/core/dist/execution/background-executor.js +4 -4
  52. package/node_modules/@sdd-agent-platform/core/dist/execution/background-executor.js.map +1 -1
  53. package/node_modules/@sdd-agent-platform/core/dist/execution/foreground-subagents.js +3 -3
  54. package/node_modules/@sdd-agent-platform/core/dist/execution/foreground-subagents.js.map +1 -1
  55. package/node_modules/@sdd-agent-platform/core/dist/execution/host-invocation.js +5 -4
  56. package/node_modules/@sdd-agent-platform/core/dist/execution/host-invocation.js.map +1 -1
  57. package/node_modules/@sdd-agent-platform/core/dist/execution/resident-worker.js +3 -2
  58. package/node_modules/@sdd-agent-platform/core/dist/execution/resident-worker.js.map +1 -1
  59. package/node_modules/@sdd-agent-platform/core/dist/execution/stage-team-runtime.js +2 -2
  60. package/node_modules/@sdd-agent-platform/core/dist/execution/stage-team-runtime.js.map +1 -1
  61. package/node_modules/@sdd-agent-platform/core/dist/governance/policy.d.ts +1 -1
  62. package/node_modules/@sdd-agent-platform/core/dist/governance/policy.js +1 -1
  63. package/node_modules/@sdd-agent-platform/core/dist/governance/policy.js.map +1 -1
  64. package/node_modules/@sdd-agent-platform/core/dist/instructions.d.ts +1 -1
  65. package/node_modules/@sdd-agent-platform/core/dist/instructions.js +54 -61
  66. package/node_modules/@sdd-agent-platform/core/dist/instructions.js.map +1 -1
  67. package/node_modules/@sdd-agent-platform/core/dist/lifecycle/decision-gate.js +1 -1
  68. package/node_modules/@sdd-agent-platform/core/dist/lifecycle/decision-gate.js.map +1 -1
  69. package/node_modules/@sdd-agent-platform/core/dist/lifecycle/ship.d.ts +1 -0
  70. package/node_modules/@sdd-agent-platform/core/dist/lifecycle/ship.js +24 -8
  71. package/node_modules/@sdd-agent-platform/core/dist/lifecycle/ship.js.map +1 -1
  72. package/node_modules/@sdd-agent-platform/core/dist/orchestration/contracts.d.ts +1 -1
  73. package/node_modules/@sdd-agent-platform/core/dist/orchestration/runtime.d.ts +12 -2
  74. package/node_modules/@sdd-agent-platform/core/dist/orchestration/runtime.js +62 -21
  75. package/node_modules/@sdd-agent-platform/core/dist/orchestration/runtime.js.map +1 -1
  76. package/node_modules/@sdd-agent-platform/core/dist/registries/agent-capability-catalog.d.ts +5 -2
  77. package/node_modules/@sdd-agent-platform/core/dist/registries/agent-capability-catalog.js +69 -27
  78. package/node_modules/@sdd-agent-platform/core/dist/registries/agent-capability-catalog.js.map +1 -1
  79. package/node_modules/@sdd-agent-platform/core/dist/registries/agent-registry.js +15 -15
  80. package/node_modules/@sdd-agent-platform/core/dist/registries/agent-registry.js.map +1 -1
  81. package/node_modules/@sdd-agent-platform/core/dist/registries/agent-runtime-static.js +1 -1
  82. package/node_modules/@sdd-agent-platform/core/dist/registries/agent-runtime-static.js.map +1 -1
  83. package/node_modules/@sdd-agent-platform/core/dist/registries/capability-sources.js +1 -1
  84. package/node_modules/@sdd-agent-platform/core/dist/registries/command-team-runtime.d.ts +1 -1
  85. package/node_modules/@sdd-agent-platform/core/dist/registries/command-team-runtime.js +9 -9
  86. package/node_modules/@sdd-agent-platform/core/dist/registries/command-team-runtime.js.map +1 -1
  87. package/node_modules/@sdd-agent-platform/core/dist/registries/eval-learning-context.js +4 -4
  88. package/node_modules/@sdd-agent-platform/core/dist/registries/eval-learning-context.js.map +1 -1
  89. package/node_modules/@sdd-agent-platform/core/dist/registries/query-status.js +2 -2
  90. package/node_modules/@sdd-agent-platform/core/dist/registries/query-status.js.map +1 -1
  91. package/node_modules/@sdd-agent-platform/core/dist/registries/tool-capabilities.js +3 -3
  92. package/node_modules/@sdd-agent-platform/core/dist/registries/tool-capabilities.js.map +1 -1
  93. package/node_modules/@sdd-agent-platform/core/dist/registries/tool-plugins.js +2 -2
  94. package/node_modules/@sdd-agent-platform/core/dist/registries/tool-plugins.js.map +1 -1
  95. package/node_modules/@sdd-agent-platform/core/dist/registries/worker-adapters.js +11 -11
  96. package/node_modules/@sdd-agent-platform/core/dist/registries/worker-adapters.js.map +1 -1
  97. package/node_modules/@sdd-agent-platform/core/dist/registries/workflow-gates.js +12 -12
  98. package/node_modules/@sdd-agent-platform/core/dist/registries/workflow-gates.js.map +1 -1
  99. package/node_modules/@sdd-agent-platform/core/dist/risk/contracts.d.ts +2 -2
  100. package/node_modules/@sdd-agent-platform/core/dist/risk/kernel.js +4 -4
  101. package/node_modules/@sdd-agent-platform/core/dist/risk/kernel.js.map +1 -1
  102. package/node_modules/@sdd-agent-platform/core/dist/risk/legacy-adapters.js +4 -7
  103. package/node_modules/@sdd-agent-platform/core/dist/risk/legacy-adapters.js.map +1 -1
  104. package/node_modules/@sdd-agent-platform/core/dist/risk/workflow-gates.d.ts +2 -2
  105. package/node_modules/@sdd-agent-platform/core/dist/risk/workflow-gates.js +19 -17
  106. package/node_modules/@sdd-agent-platform/core/dist/risk/workflow-gates.js.map +1 -1
  107. package/node_modules/@sdd-agent-platform/core/dist/router/agent-runtime-config.js +1 -1
  108. package/node_modules/@sdd-agent-platform/core/dist/router/agent-runtime-config.js.map +1 -1
  109. package/node_modules/@sdd-agent-platform/core/dist/router/agent-runtime.d.ts +2 -0
  110. package/node_modules/@sdd-agent-platform/core/dist/router/route-projection.js +1 -1
  111. package/node_modules/@sdd-agent-platform/core/dist/router/route-projection.js.map +1 -1
  112. package/node_modules/@sdd-agent-platform/core/dist/router/routing.js +45 -15
  113. package/node_modules/@sdd-agent-platform/core/dist/router/routing.js.map +1 -1
  114. package/node_modules/@sdd-agent-platform/core/dist/router/runtime-import.d.ts +28 -0
  115. package/node_modules/@sdd-agent-platform/core/dist/router/runtime-import.js +373 -0
  116. package/node_modules/@sdd-agent-platform/core/dist/router/runtime-import.js.map +1 -0
  117. package/node_modules/@sdd-agent-platform/core/dist/router/runtime-validation.js +2 -2
  118. package/node_modules/@sdd-agent-platform/core/dist/router/runtime-validation.js.map +1 -1
  119. package/node_modules/@sdd-agent-platform/core/dist/router/stage-route-binding.d.ts +37 -0
  120. package/node_modules/@sdd-agent-platform/core/dist/router/stage-route-binding.js +235 -0
  121. package/node_modules/@sdd-agent-platform/core/dist/router/stage-route-binding.js.map +1 -0
  122. package/node_modules/@sdd-agent-platform/core/dist/router.d.ts +2 -0
  123. package/node_modules/@sdd-agent-platform/core/dist/router.js +2 -0
  124. package/node_modules/@sdd-agent-platform/core/dist/router.js.map +1 -1
  125. package/node_modules/@sdd-agent-platform/core/dist/run-state/artifacts.d.ts +16 -0
  126. package/node_modules/@sdd-agent-platform/core/dist/run-state/artifacts.js +126 -9
  127. package/node_modules/@sdd-agent-platform/core/dist/run-state/artifacts.js.map +1 -1
  128. package/node_modules/@sdd-agent-platform/core/dist/run-state/inspect-run.d.ts +0 -2
  129. package/node_modules/@sdd-agent-platform/core/dist/run-state/inspect-run.js +7 -5
  130. package/node_modules/@sdd-agent-platform/core/dist/run-state/inspect-run.js.map +1 -1
  131. package/node_modules/@sdd-agent-platform/core/dist/run-state/model.d.ts +28 -8
  132. package/node_modules/@sdd-agent-platform/core/dist/run-state/run-index.d.ts +0 -2
  133. package/node_modules/@sdd-agent-platform/core/dist/run-state/run-index.js +1 -3
  134. package/node_modules/@sdd-agent-platform/core/dist/run-state/run-index.js.map +1 -1
  135. package/node_modules/@sdd-agent-platform/core/dist/run-state/run-state.js +37 -27
  136. package/node_modules/@sdd-agent-platform/core/dist/run-state/run-state.js.map +1 -1
  137. package/node_modules/@sdd-agent-platform/core/dist/run-state/task-evidence.d.ts +5 -2
  138. package/node_modules/@sdd-agent-platform/core/dist/run-state/task-evidence.js +53 -14
  139. package/node_modules/@sdd-agent-platform/core/dist/run-state/task-evidence.js.map +1 -1
  140. package/node_modules/@sdd-agent-platform/core/dist/run-state/timing.d.ts +8 -0
  141. package/node_modules/@sdd-agent-platform/core/dist/run-state/timing.js +131 -0
  142. package/node_modules/@sdd-agent-platform/core/dist/run-state/timing.js.map +1 -0
  143. package/node_modules/@sdd-agent-platform/core/dist/run-state.d.ts +1 -0
  144. package/node_modules/@sdd-agent-platform/core/dist/run-state.js +1 -0
  145. package/node_modules/@sdd-agent-platform/core/dist/run-state.js.map +1 -1
  146. package/node_modules/@sdd-agent-platform/core/dist/runtime-analysis/build.js +0 -3
  147. package/node_modules/@sdd-agent-platform/core/dist/runtime-analysis/build.js.map +1 -1
  148. package/node_modules/@sdd-agent-platform/core/dist/runtime-analysis/findings.js +5 -44
  149. package/node_modules/@sdd-agent-platform/core/dist/runtime-analysis/findings.js.map +1 -1
  150. package/node_modules/@sdd-agent-platform/core/dist/runtime-analysis/model.d.ts +1 -17
  151. package/node_modules/@sdd-agent-platform/core/dist/runtime-paths.d.ts +10 -0
  152. package/node_modules/@sdd-agent-platform/core/dist/runtime-paths.js +65 -0
  153. package/node_modules/@sdd-agent-platform/core/dist/runtime-paths.js.map +1 -1
  154. package/node_modules/@sdd-agent-platform/core/dist/runtime-projection-p0.d.ts +64 -0
  155. package/node_modules/@sdd-agent-platform/core/dist/runtime-projection-p0.js +200 -0
  156. package/node_modules/@sdd-agent-platform/core/dist/runtime-projection-p0.js.map +1 -0
  157. package/node_modules/@sdd-agent-platform/core/dist/sdd-docs/document-hashes.d.ts +2 -0
  158. package/node_modules/@sdd-agent-platform/core/dist/sdd-docs/document-hashes.js +97 -10
  159. package/node_modules/@sdd-agent-platform/core/dist/sdd-docs/document-hashes.js.map +1 -1
  160. package/node_modules/@sdd-agent-platform/core/dist/sdd-docs/run-binding.d.ts +1 -1
  161. package/node_modules/@sdd-agent-platform/core/dist/sdd-docs/run-binding.js +8 -6
  162. package/node_modules/@sdd-agent-platform/core/dist/sdd-docs/run-binding.js.map +1 -1
  163. package/node_modules/@sdd-agent-platform/core/dist/sdd-docs/task-parser.d.ts +1 -0
  164. package/node_modules/@sdd-agent-platform/core/dist/sdd-docs/task-parser.js +55 -34
  165. package/node_modules/@sdd-agent-platform/core/dist/sdd-docs/task-parser.js.map +1 -1
  166. package/node_modules/@sdd-agent-platform/core/dist/stage-artifacts.d.ts +55 -0
  167. package/node_modules/@sdd-agent-platform/core/dist/stage-artifacts.js +322 -0
  168. package/node_modules/@sdd-agent-platform/core/dist/stage-artifacts.js.map +1 -0
  169. package/node_modules/@sdd-agent-platform/core/dist/stage-collaboration-contracts.d.ts +55 -0
  170. package/node_modules/@sdd-agent-platform/core/dist/stage-collaboration-contracts.js +241 -0
  171. package/node_modules/@sdd-agent-platform/core/dist/stage-collaboration-contracts.js.map +1 -0
  172. package/node_modules/@sdd-agent-platform/core/dist/stage-collaboration.d.ts +888 -0
  173. package/node_modules/@sdd-agent-platform/core/dist/stage-collaboration.js +3870 -0
  174. package/node_modules/@sdd-agent-platform/core/dist/stage-collaboration.js.map +1 -0
  175. package/node_modules/@sdd-agent-platform/core/dist/stage-runtime/runtime.js +8 -1
  176. package/node_modules/@sdd-agent-platform/core/dist/stage-runtime/runtime.js.map +1 -1
  177. package/node_modules/@sdd-agent-platform/core/dist/status/project-status.d.ts +44 -1
  178. package/node_modules/@sdd-agent-platform/core/dist/status/project-status.js +170 -23
  179. package/node_modules/@sdd-agent-platform/core/dist/status/project-status.js.map +1 -1
  180. package/node_modules/@sdd-agent-platform/core/dist/storage/runtime-store.d.ts +170 -18
  181. package/node_modules/@sdd-agent-platform/core/dist/storage/runtime-store.js +544 -32
  182. package/node_modules/@sdd-agent-platform/core/dist/storage/runtime-store.js.map +1 -1
  183. package/node_modules/@sdd-agent-platform/core/dist/subagents/contracts.d.ts +1 -1
  184. package/node_modules/@sdd-agent-platform/core/dist/subagents/runtime.js +7 -7
  185. package/node_modules/@sdd-agent-platform/core/dist/subagents/runtime.js.map +1 -1
  186. package/node_modules/@sdd-agent-platform/core/dist/test-support/fixtures.js +1 -1
  187. package/node_modules/@sdd-agent-platform/core/dist/test-support/run-state.d.ts +1 -1
  188. package/node_modules/@sdd-agent-platform/core/dist/test-support/run-state.js +8 -23
  189. package/node_modules/@sdd-agent-platform/core/dist/test-support/run-state.js.map +1 -1
  190. package/node_modules/@sdd-agent-platform/core/dist/truth-reconciliation.d.ts +44 -0
  191. package/node_modules/@sdd-agent-platform/core/dist/truth-reconciliation.js +138 -0
  192. package/node_modules/@sdd-agent-platform/core/dist/truth-reconciliation.js.map +1 -0
  193. package/node_modules/@sdd-agent-platform/core/dist/tsconfig.tsbuildinfo +1 -1
  194. package/node_modules/@sdd-agent-platform/core/dist/verification/goal-verify.d.ts +0 -1
  195. package/node_modules/@sdd-agent-platform/core/dist/verification/goal-verify.js +28 -53
  196. package/node_modules/@sdd-agent-platform/core/dist/verification/goal-verify.js.map +1 -1
  197. package/node_modules/@sdd-agent-platform/core/dist/verification/rendering.d.ts +0 -2
  198. package/node_modules/@sdd-agent-platform/core/dist/verification/rendering.js +10 -50
  199. package/node_modules/@sdd-agent-platform/core/dist/verification/rendering.js.map +1 -1
  200. package/node_modules/@sdd-agent-platform/core/dist/verification/single-task-loop.d.ts +0 -1
  201. package/node_modules/@sdd-agent-platform/core/dist/verification/single-task-loop.js +159 -150
  202. package/node_modules/@sdd-agent-platform/core/dist/verification/single-task-loop.js.map +1 -1
  203. package/node_modules/@sdd-agent-platform/core/dist/verification/test-runtime.d.ts +12 -2
  204. package/node_modules/@sdd-agent-platform/core/dist/verification/test-runtime.js +238 -103
  205. package/node_modules/@sdd-agent-platform/core/dist/verification/test-runtime.js.map +1 -1
  206. package/node_modules/@sdd-agent-platform/core/dist/verification/validation-cache.d.ts +26 -0
  207. package/node_modules/@sdd-agent-platform/core/dist/verification/validation-cache.js +73 -0
  208. package/node_modules/@sdd-agent-platform/core/dist/verification/validation-cache.js.map +1 -0
  209. package/node_modules/@sdd-agent-platform/core/dist/verification/validation-wave.d.ts +18 -0
  210. package/node_modules/@sdd-agent-platform/core/dist/verification/validation-wave.js +27 -5
  211. package/node_modules/@sdd-agent-platform/core/dist/verification/validation-wave.js.map +1 -1
  212. package/node_modules/@sdd-agent-platform/core/dist/verification/verify-contract.d.ts +1 -1
  213. package/node_modules/@sdd-agent-platform/core/dist/verification/verify-contract.js +9 -32
  214. package/node_modules/@sdd-agent-platform/core/dist/verification/verify-contract.js.map +1 -1
  215. package/node_modules/@sdd-agent-platform/core/dist/work-units/contracts.d.ts +1 -1
  216. package/node_modules/@sdd-agent-platform/core/dist/workflow-gate/evidence-packet.js +228 -15
  217. package/node_modules/@sdd-agent-platform/core/dist/workflow-gate/evidence-packet.js.map +1 -1
  218. package/node_modules/@sdd-agent-platform/core/dist/workflow-gate/hard-checks.js +49 -15
  219. package/node_modules/@sdd-agent-platform/core/dist/workflow-gate/hard-checks.js.map +1 -1
  220. package/node_modules/@sdd-agent-platform/core/dist/workflow-gate/policy.js +42 -6
  221. package/node_modules/@sdd-agent-platform/core/dist/workflow-gate/policy.js.map +1 -1
  222. package/node_modules/@sdd-agent-platform/core/dist/workflow-gate/types.d.ts +4 -5
  223. package/node_modules/@sdd-agent-platform/core/dist/workflow-state/affected-file-conflicts.d.ts +0 -1
  224. package/node_modules/@sdd-agent-platform/core/dist/workflow-state/affected-file-conflicts.js +1 -2
  225. package/node_modules/@sdd-agent-platform/core/dist/workflow-state/affected-file-conflicts.js.map +1 -1
  226. package/node_modules/@sdd-agent-platform/core/dist/workflow-state/dependencies.js +1 -1
  227. package/node_modules/@sdd-agent-platform/core/dist/workflow-state/latest-eligible-run.d.ts +0 -1
  228. package/node_modules/@sdd-agent-platform/core/dist/workflow-state/latest-eligible-run.js +72 -6
  229. package/node_modules/@sdd-agent-platform/core/dist/workflow-state/latest-eligible-run.js.map +1 -1
  230. package/node_modules/@sdd-agent-platform/core/dist/workflow-state/migration-recovery.d.ts +40 -0
  231. package/node_modules/@sdd-agent-platform/core/dist/workflow-state/migration-recovery.js +110 -0
  232. package/node_modules/@sdd-agent-platform/core/dist/workflow-state/migration-recovery.js.map +1 -0
  233. package/node_modules/@sdd-agent-platform/core/dist/workflow-state/repair-contract.d.ts +12 -0
  234. package/node_modules/@sdd-agent-platform/core/dist/workflow-state/repair-contract.js +63 -0
  235. package/node_modules/@sdd-agent-platform/core/dist/workflow-state/repair-contract.js.map +1 -0
  236. package/node_modules/@sdd-agent-platform/core/dist/workflow-state/resolve-task-run.d.ts +21 -0
  237. package/node_modules/@sdd-agent-platform/core/dist/workflow-state/resolve-task-run.js +95 -0
  238. package/node_modules/@sdd-agent-platform/core/dist/workflow-state/resolve-task-run.js.map +1 -0
  239. package/node_modules/@sdd-agent-platform/core/dist/workflow-state/resolve.d.ts +55 -5
  240. package/node_modules/@sdd-agent-platform/core/dist/workflow-state/resolve.js +538 -34
  241. package/node_modules/@sdd-agent-platform/core/dist/workflow-state/resolve.js.map +1 -1
  242. package/node_modules/@sdd-agent-platform/core/dist/workflow-state/runtime-projections.d.ts +228 -0
  243. package/node_modules/@sdd-agent-platform/core/dist/workflow-state/runtime-projections.js +452 -0
  244. package/node_modules/@sdd-agent-platform/core/dist/workflow-state/runtime-projections.js.map +1 -0
  245. package/node_modules/@sdd-agent-platform/core/package.json +3 -3
  246. package/node_modules/@sdd-agent-platform/core/src/ai-tools.test.ts +49 -1
  247. package/node_modules/@sdd-agent-platform/core/src/ai-tools.ts +67 -69
  248. package/node_modules/@sdd-agent-platform/core/src/artifacts/ingestion.test.ts +38 -0
  249. package/node_modules/@sdd-agent-platform/core/src/artifacts/ingestion.ts +65 -9
  250. package/node_modules/@sdd-agent-platform/core/src/artifacts/sdd-evidence.ts +0 -1
  251. package/node_modules/@sdd-agent-platform/core/src/artifacts/sdd-result.test.ts +2 -2
  252. package/node_modules/@sdd-agent-platform/core/src/artifacts/sdd-result.ts +26 -17
  253. package/node_modules/@sdd-agent-platform/core/src/config/init-project.test.ts +43 -31
  254. package/node_modules/@sdd-agent-platform/core/src/config/init-project.ts +14 -11
  255. package/node_modules/@sdd-agent-platform/core/src/config/project-config.ts +10 -4
  256. package/node_modules/@sdd-agent-platform/core/src/config/starter-documents.ts +12 -25
  257. package/node_modules/@sdd-agent-platform/core/src/context/build-package.ts +2 -8
  258. package/node_modules/@sdd-agent-platform/core/src/context/context-build.test.ts +3 -2
  259. package/node_modules/@sdd-agent-platform/core/src/context/evidence-summary.ts +27 -8
  260. package/node_modules/@sdd-agent-platform/core/src/context/log-worker.ts +2 -2
  261. package/node_modules/@sdd-agent-platform/core/src/context-offload/contracts.ts +1 -1
  262. package/node_modules/@sdd-agent-platform/core/src/contracts.ts +2 -1
  263. package/node_modules/@sdd-agent-platform/core/src/delegation/model.ts +3 -0
  264. package/node_modules/@sdd-agent-platform/core/src/delegation/validation.ts +8 -5
  265. package/node_modules/@sdd-agent-platform/core/src/doctor/checks/document-chain.ts +1 -1
  266. package/node_modules/@sdd-agent-platform/core/src/doctor/checks/project.ts +8 -8
  267. package/node_modules/@sdd-agent-platform/core/src/doctor/checks/registries.ts +0 -1
  268. package/node_modules/@sdd-agent-platform/core/src/doctor/checks/run-evidence.ts +4 -4
  269. package/node_modules/@sdd-agent-platform/core/src/doctor/checks/run-trust.ts +0 -21
  270. package/node_modules/@sdd-agent-platform/core/src/doctor/checks/runtime-contracts.ts +1 -1
  271. package/node_modules/@sdd-agent-platform/core/src/doctor/doctor.test.ts +143 -45
  272. package/node_modules/@sdd-agent-platform/core/src/doctor/doctor.ts +193 -58
  273. package/node_modules/@sdd-agent-platform/core/src/evidence/lookup.ts +15 -7
  274. package/node_modules/@sdd-agent-platform/core/src/evidence-runtime/contracts.ts +0 -1
  275. package/node_modules/@sdd-agent-platform/core/src/execution/background-executor.test.ts +50 -2
  276. package/node_modules/@sdd-agent-platform/core/src/execution/background-executor.ts +4 -4
  277. package/node_modules/@sdd-agent-platform/core/src/execution/foreground-subagents.test.ts +11 -2
  278. package/node_modules/@sdd-agent-platform/core/src/execution/foreground-subagents.ts +3 -3
  279. package/node_modules/@sdd-agent-platform/core/src/execution/host-invocation.ts +5 -4
  280. package/node_modules/@sdd-agent-platform/core/src/execution/resident-worker.test.ts +12 -1
  281. package/node_modules/@sdd-agent-platform/core/src/execution/resident-worker.ts +3 -2
  282. package/node_modules/@sdd-agent-platform/core/src/execution/stage-team-runtime.test.ts +1 -1
  283. package/node_modules/@sdd-agent-platform/core/src/execution/stage-team-runtime.ts +2 -2
  284. package/node_modules/@sdd-agent-platform/core/src/execution/wave-executor.test.ts +10 -0
  285. package/node_modules/@sdd-agent-platform/core/src/governance/policy.test.ts +8 -0
  286. package/node_modules/@sdd-agent-platform/core/src/governance/policy.ts +2 -2
  287. package/node_modules/@sdd-agent-platform/core/src/instructions.test.ts +33 -18
  288. package/node_modules/@sdd-agent-platform/core/src/instructions.ts +55 -62
  289. package/node_modules/@sdd-agent-platform/core/src/lifecycle/decision-gate.test.ts +1 -1
  290. package/node_modules/@sdd-agent-platform/core/src/lifecycle/decision-gate.ts +1 -1
  291. package/node_modules/@sdd-agent-platform/core/src/lifecycle/ship.test.ts +47 -0
  292. package/node_modules/@sdd-agent-platform/core/src/lifecycle/ship.ts +25 -8
  293. package/node_modules/@sdd-agent-platform/core/src/orchestration/contracts.ts +1 -1
  294. package/node_modules/@sdd-agent-platform/core/src/orchestration/runtime.ts +74 -22
  295. package/node_modules/@sdd-agent-platform/core/src/phase8-contracts.test.ts +2 -3
  296. package/node_modules/@sdd-agent-platform/core/src/phase8-risk-kernel.test.ts +3 -3
  297. package/node_modules/@sdd-agent-platform/core/src/registries/agent-capability-catalog.ts +82 -35
  298. package/node_modules/@sdd-agent-platform/core/src/registries/agent-registry.ts +15 -15
  299. package/node_modules/@sdd-agent-platform/core/src/registries/agent-runtime-static.ts +1 -1
  300. package/node_modules/@sdd-agent-platform/core/src/registries/capability-sources.ts +1 -1
  301. package/node_modules/@sdd-agent-platform/core/src/registries/command-team-runtime.ts +10 -10
  302. package/node_modules/@sdd-agent-platform/core/src/registries/eval-learning-context.ts +4 -4
  303. package/node_modules/@sdd-agent-platform/core/src/registries/query-status.ts +2 -2
  304. package/node_modules/@sdd-agent-platform/core/src/registries/registries.test.ts +18 -2
  305. package/node_modules/@sdd-agent-platform/core/src/registries/tool-capabilities.ts +3 -3
  306. package/node_modules/@sdd-agent-platform/core/src/registries/tool-plugins.ts +2 -2
  307. package/node_modules/@sdd-agent-platform/core/src/registries/worker-adapters.ts +11 -11
  308. package/node_modules/@sdd-agent-platform/core/src/registries/workflow-gates.ts +12 -12
  309. package/node_modules/@sdd-agent-platform/core/src/risk/contracts.ts +2 -2
  310. package/node_modules/@sdd-agent-platform/core/src/risk/kernel.ts +4 -4
  311. package/node_modules/@sdd-agent-platform/core/src/risk/legacy-adapters.ts +4 -7
  312. package/node_modules/@sdd-agent-platform/core/src/risk/workflow-gates.ts +20 -18
  313. package/node_modules/@sdd-agent-platform/core/src/router/agent-runtime-config.ts +1 -1
  314. package/node_modules/@sdd-agent-platform/core/src/router/agent-runtime.ts +2 -0
  315. package/node_modules/@sdd-agent-platform/core/src/router/route-projection.ts +1 -1
  316. package/node_modules/@sdd-agent-platform/core/src/router/route-sdd-task.test.ts +241 -4
  317. package/node_modules/@sdd-agent-platform/core/src/router/routing.ts +47 -15
  318. package/node_modules/@sdd-agent-platform/core/src/router/runtime-import.ts +453 -0
  319. package/node_modules/@sdd-agent-platform/core/src/router/runtime-validation.ts +2 -2
  320. package/node_modules/@sdd-agent-platform/core/src/router/stage-route-binding.ts +279 -0
  321. package/node_modules/@sdd-agent-platform/core/src/router.ts +2 -0
  322. package/node_modules/@sdd-agent-platform/core/src/run-state/artifacts.ts +132 -10
  323. package/node_modules/@sdd-agent-platform/core/src/run-state/inspect-run.ts +7 -7
  324. package/node_modules/@sdd-agent-platform/core/src/run-state/model.ts +31 -8
  325. package/node_modules/@sdd-agent-platform/core/src/run-state/run-index.ts +1 -5
  326. package/node_modules/@sdd-agent-platform/core/src/run-state/run-state.test.ts +50 -2
  327. package/node_modules/@sdd-agent-platform/core/src/run-state/run-state.ts +39 -29
  328. package/node_modules/@sdd-agent-platform/core/src/run-state/task-evidence.ts +62 -16
  329. package/node_modules/@sdd-agent-platform/core/src/run-state/timing.ts +146 -0
  330. package/node_modules/@sdd-agent-platform/core/src/run-state.ts +1 -0
  331. package/node_modules/@sdd-agent-platform/core/src/runtime-analysis/build.ts +0 -3
  332. package/node_modules/@sdd-agent-platform/core/src/runtime-analysis/findings.ts +6 -46
  333. package/node_modules/@sdd-agent-platform/core/src/runtime-analysis/model.ts +1 -13
  334. package/node_modules/@sdd-agent-platform/core/src/runtime-analysis.test.ts +0 -2
  335. package/node_modules/@sdd-agent-platform/core/src/runtime-paths.ts +77 -0
  336. package/node_modules/@sdd-agent-platform/core/src/runtime-projection-p0.test.ts +96 -0
  337. package/node_modules/@sdd-agent-platform/core/src/runtime-projection-p0.ts +292 -0
  338. package/node_modules/@sdd-agent-platform/core/src/sdd-docs/document-hashes.ts +109 -10
  339. package/node_modules/@sdd-agent-platform/core/src/sdd-docs/run-binding.ts +8 -6
  340. package/node_modules/@sdd-agent-platform/core/src/sdd-docs/task-parser.test.ts +123 -1
  341. package/node_modules/@sdd-agent-platform/core/src/sdd-docs/task-parser.ts +58 -43
  342. package/node_modules/@sdd-agent-platform/core/src/stage-artifacts.ts +450 -0
  343. package/node_modules/@sdd-agent-platform/core/src/stage-collaboration-contracts.ts +322 -0
  344. package/node_modules/@sdd-agent-platform/core/src/stage-collaboration.test.ts +2903 -0
  345. package/node_modules/@sdd-agent-platform/core/src/stage-collaboration.ts +5831 -0
  346. package/node_modules/@sdd-agent-platform/core/src/stage-runtime/runtime.test.ts +1 -1
  347. package/node_modules/@sdd-agent-platform/core/src/stage-runtime/runtime.ts +9 -1
  348. package/node_modules/@sdd-agent-platform/core/src/status/project-status.test.ts +239 -16
  349. package/node_modules/@sdd-agent-platform/core/src/status/project-status.ts +249 -23
  350. package/node_modules/@sdd-agent-platform/core/src/storage/runtime-store.test.ts +196 -4
  351. package/node_modules/@sdd-agent-platform/core/src/storage/runtime-store.ts +860 -54
  352. package/node_modules/@sdd-agent-platform/core/src/subagents/contracts.ts +1 -1
  353. package/node_modules/@sdd-agent-platform/core/src/subagents/runtime.test.ts +3 -3
  354. package/node_modules/@sdd-agent-platform/core/src/subagents/runtime.ts +7 -7
  355. package/node_modules/@sdd-agent-platform/core/src/test-support/fixtures.ts +1 -1
  356. package/node_modules/@sdd-agent-platform/core/src/test-support/run-state.ts +9 -23
  357. package/node_modules/@sdd-agent-platform/core/src/truth-reconciliation.test.ts +72 -0
  358. package/node_modules/@sdd-agent-platform/core/src/truth-reconciliation.ts +177 -0
  359. package/node_modules/@sdd-agent-platform/core/src/verification/goal-verify.test.ts +13 -87
  360. package/node_modules/@sdd-agent-platform/core/src/verification/goal-verify.ts +27 -56
  361. package/node_modules/@sdd-agent-platform/core/src/verification/rendering.ts +10 -54
  362. package/node_modules/@sdd-agent-platform/core/src/verification/review-gate.test.ts +8 -1
  363. package/node_modules/@sdd-agent-platform/core/src/verification/single-task-loop.test.ts +93 -79
  364. package/node_modules/@sdd-agent-platform/core/src/verification/single-task-loop.ts +166 -154
  365. package/node_modules/@sdd-agent-platform/core/src/verification/test-runtime.test.ts +100 -47
  366. package/node_modules/@sdd-agent-platform/core/src/verification/test-runtime.ts +265 -107
  367. package/node_modules/@sdd-agent-platform/core/src/verification/validation-cache.ts +106 -0
  368. package/node_modules/@sdd-agent-platform/core/src/verification/validation-wave.test.ts +47 -5
  369. package/node_modules/@sdd-agent-platform/core/src/verification/validation-wave.ts +48 -5
  370. package/node_modules/@sdd-agent-platform/core/src/verification/verify-contract.test.ts +15 -31
  371. package/node_modules/@sdd-agent-platform/core/src/verification/verify-contract.ts +9 -33
  372. package/node_modules/@sdd-agent-platform/core/src/work-units/contracts.ts +1 -1
  373. package/node_modules/@sdd-agent-platform/core/src/workflow-gate/evidence-packet.ts +246 -17
  374. package/node_modules/@sdd-agent-platform/core/src/workflow-gate/hard-checks.test.ts +339 -3
  375. package/node_modules/@sdd-agent-platform/core/src/workflow-gate/hard-checks.ts +53 -14
  376. package/node_modules/@sdd-agent-platform/core/src/workflow-gate/policy.test.ts +45 -8
  377. package/node_modules/@sdd-agent-platform/core/src/workflow-gate/policy.ts +45 -6
  378. package/node_modules/@sdd-agent-platform/core/src/workflow-gate/types.ts +6 -5
  379. package/node_modules/@sdd-agent-platform/core/src/workflow-state/affected-file-conflicts.ts +1 -3
  380. package/node_modules/@sdd-agent-platform/core/src/workflow-state/dependencies.ts +1 -1
  381. package/node_modules/@sdd-agent-platform/core/src/workflow-state/latest-eligible-run.ts +75 -7
  382. package/node_modules/@sdd-agent-platform/core/src/workflow-state/migration-recovery.ts +158 -0
  383. package/node_modules/@sdd-agent-platform/core/src/workflow-state/repair-contract.ts +77 -0
  384. package/node_modules/@sdd-agent-platform/core/src/workflow-state/resolve-task-run.ts +114 -0
  385. package/node_modules/@sdd-agent-platform/core/src/workflow-state/resolve.test.ts +518 -25
  386. package/node_modules/@sdd-agent-platform/core/src/workflow-state/resolve.ts +670 -41
  387. package/node_modules/@sdd-agent-platform/core/src/workflow-state/runtime-projections.ts +712 -0
  388. package/package.json +1 -1
  389. package/packages/cli/dist/args.js +2 -2
  390. package/packages/cli/dist/args.js.map +1 -1
  391. package/packages/cli/dist/commands/ai-tools.js +13 -2
  392. package/packages/cli/dist/commands/ai-tools.js.map +1 -1
  393. package/packages/cli/dist/commands/context.js +1 -1
  394. package/packages/cli/dist/commands/context.js.map +1 -1
  395. package/packages/cli/dist/commands/execution.js +49 -1
  396. package/packages/cli/dist/commands/execution.js.map +1 -1
  397. package/packages/cli/dist/commands/governance.js +1 -1
  398. package/packages/cli/dist/commands/governance.js.map +1 -1
  399. package/packages/cli/dist/commands/init.js +6 -1
  400. package/packages/cli/dist/commands/init.js.map +1 -1
  401. package/packages/cli/dist/commands/lifecycle.js +15 -2
  402. package/packages/cli/dist/commands/lifecycle.js.map +1 -1
  403. package/packages/cli/dist/commands/registry/runtime.js +48 -2
  404. package/packages/cli/dist/commands/registry/runtime.js.map +1 -1
  405. package/packages/cli/dist/commands/run.js +52 -2
  406. package/packages/cli/dist/commands/run.js.map +1 -1
  407. package/packages/cli/dist/commands/stage-close.d.ts +6 -0
  408. package/packages/cli/dist/commands/stage-close.js +295 -0
  409. package/packages/cli/dist/commands/stage-close.js.map +1 -0
  410. package/packages/cli/dist/commands/status.js +68 -2
  411. package/packages/cli/dist/commands/status.js.map +1 -1
  412. package/packages/cli/dist/commands/test.js +180 -2
  413. package/packages/cli/dist/commands/test.js.map +1 -1
  414. package/packages/cli/dist/commands/verifies.js +7 -5
  415. package/packages/cli/dist/commands/verifies.js.map +1 -1
  416. package/packages/cli/dist/commands/verify.js +222 -26
  417. package/packages/cli/dist/commands/verify.js.map +1 -1
  418. package/packages/cli/dist/dispatch.js +4 -9
  419. package/packages/cli/dist/dispatch.js.map +1 -1
  420. package/packages/cli/dist/help.js +27 -26
  421. package/packages/cli/dist/help.js.map +1 -1
  422. package/packages/cli/dist/renderers/doctor.js +1 -1
  423. package/packages/cli/dist/renderers/doctor.js.map +1 -1
  424. package/packages/cli/dist/renderers/execution.js +1 -1
  425. package/packages/cli/dist/renderers/execution.js.map +1 -1
  426. package/packages/cli/dist/renderers/json.d.ts +1 -0
  427. package/packages/cli/dist/renderers/json.js +3 -0
  428. package/packages/cli/dist/renderers/json.js.map +1 -1
  429. package/packages/cli/dist/renderers/registry-runtime.d.ts +2 -1
  430. package/packages/cli/dist/renderers/registry-runtime.js +20 -0
  431. package/packages/cli/dist/renderers/registry-runtime.js.map +1 -1
  432. package/packages/cli/dist/renderers/router.js +1 -1
  433. package/packages/cli/dist/renderers/router.js.map +1 -1
  434. package/packages/cli/dist/renderers/workflow.d.ts +0 -4
  435. package/packages/cli/dist/renderers/workflow.js +30 -89
  436. package/packages/cli/dist/renderers/workflow.js.map +1 -1
  437. package/packages/cli/dist/skill-import-args.d.ts +10 -0
  438. package/packages/cli/dist/skill-import-args.js +47 -0
  439. package/packages/cli/dist/skill-import-args.js.map +1 -0
  440. package/packages/cli/dist/tsconfig.tsbuildinfo +1 -1
  441. package/packages/cli/package.json +2 -2
  442. package/packages/core/dist/ai-tools.js +67 -69
  443. package/packages/core/dist/ai-tools.js.map +1 -1
  444. package/packages/core/dist/artifacts/ingestion.js +64 -9
  445. package/packages/core/dist/artifacts/ingestion.js.map +1 -1
  446. package/packages/core/dist/artifacts/sdd-evidence.js +0 -1
  447. package/packages/core/dist/artifacts/sdd-evidence.js.map +1 -1
  448. package/packages/core/dist/artifacts/sdd-result.js +26 -17
  449. package/packages/core/dist/artifacts/sdd-result.js.map +1 -1
  450. package/packages/core/dist/config/init-project.d.ts +3 -0
  451. package/packages/core/dist/config/init-project.js +12 -9
  452. package/packages/core/dist/config/init-project.js.map +1 -1
  453. package/packages/core/dist/config/project-config.d.ts +3 -1
  454. package/packages/core/dist/config/project-config.js +7 -3
  455. package/packages/core/dist/config/project-config.js.map +1 -1
  456. package/packages/core/dist/config/starter-documents.d.ts +4 -4
  457. package/packages/core/dist/config/starter-documents.js +12 -25
  458. package/packages/core/dist/config/starter-documents.js.map +1 -1
  459. package/packages/core/dist/context/build-package.d.ts +1 -1
  460. package/packages/core/dist/context/build-package.js +1 -7
  461. package/packages/core/dist/context/build-package.js.map +1 -1
  462. package/packages/core/dist/context/evidence-summary.js +26 -8
  463. package/packages/core/dist/context/evidence-summary.js.map +1 -1
  464. package/packages/core/dist/context/log-worker.js +2 -2
  465. package/packages/core/dist/context/log-worker.js.map +1 -1
  466. package/packages/core/dist/context-offload/contracts.d.ts +1 -1
  467. package/packages/core/dist/contracts.d.ts +2 -1
  468. package/packages/core/dist/contracts.js +1 -0
  469. package/packages/core/dist/contracts.js.map +1 -1
  470. package/packages/core/dist/delegation/model.d.ts +3 -0
  471. package/packages/core/dist/delegation/validation.d.ts +3 -0
  472. package/packages/core/dist/delegation/validation.js +7 -4
  473. package/packages/core/dist/delegation/validation.js.map +1 -1
  474. package/packages/core/dist/doctor/checks/document-chain.js +1 -1
  475. package/packages/core/dist/doctor/checks/document-chain.js.map +1 -1
  476. package/packages/core/dist/doctor/checks/project.js +8 -8
  477. package/packages/core/dist/doctor/checks/project.js.map +1 -1
  478. package/packages/core/dist/doctor/checks/registries.js +0 -1
  479. package/packages/core/dist/doctor/checks/registries.js.map +1 -1
  480. package/packages/core/dist/doctor/checks/run-evidence.js +4 -4
  481. package/packages/core/dist/doctor/checks/run-evidence.js.map +1 -1
  482. package/packages/core/dist/doctor/checks/run-trust.js +0 -24
  483. package/packages/core/dist/doctor/checks/run-trust.js.map +1 -1
  484. package/packages/core/dist/doctor/checks/runtime-contracts.js +1 -1
  485. package/packages/core/dist/doctor/checks/runtime-contracts.js.map +1 -1
  486. package/packages/core/dist/doctor/doctor.js +178 -58
  487. package/packages/core/dist/doctor/doctor.js.map +1 -1
  488. package/packages/core/dist/evidence/lookup.js +14 -7
  489. package/packages/core/dist/evidence/lookup.js.map +1 -1
  490. package/packages/core/dist/evidence-runtime/contracts.d.ts +0 -1
  491. package/packages/core/dist/execution/background-executor.js +4 -4
  492. package/packages/core/dist/execution/background-executor.js.map +1 -1
  493. package/packages/core/dist/execution/foreground-subagents.js +3 -3
  494. package/packages/core/dist/execution/foreground-subagents.js.map +1 -1
  495. package/packages/core/dist/execution/host-invocation.js +5 -4
  496. package/packages/core/dist/execution/host-invocation.js.map +1 -1
  497. package/packages/core/dist/execution/resident-worker.js +3 -2
  498. package/packages/core/dist/execution/resident-worker.js.map +1 -1
  499. package/packages/core/dist/execution/stage-team-runtime.js +2 -2
  500. package/packages/core/dist/execution/stage-team-runtime.js.map +1 -1
  501. package/packages/core/dist/governance/policy.d.ts +1 -1
  502. package/packages/core/dist/governance/policy.js +1 -1
  503. package/packages/core/dist/governance/policy.js.map +1 -1
  504. package/packages/core/dist/instructions.d.ts +1 -1
  505. package/packages/core/dist/instructions.js +54 -61
  506. package/packages/core/dist/instructions.js.map +1 -1
  507. package/packages/core/dist/lifecycle/decision-gate.js +1 -1
  508. package/packages/core/dist/lifecycle/decision-gate.js.map +1 -1
  509. package/packages/core/dist/lifecycle/ship.d.ts +1 -0
  510. package/packages/core/dist/lifecycle/ship.js +24 -8
  511. package/packages/core/dist/lifecycle/ship.js.map +1 -1
  512. package/packages/core/dist/orchestration/contracts.d.ts +1 -1
  513. package/packages/core/dist/orchestration/runtime.d.ts +12 -2
  514. package/packages/core/dist/orchestration/runtime.js +62 -21
  515. package/packages/core/dist/orchestration/runtime.js.map +1 -1
  516. package/packages/core/dist/registries/agent-capability-catalog.d.ts +5 -2
  517. package/packages/core/dist/registries/agent-capability-catalog.js +69 -27
  518. package/packages/core/dist/registries/agent-capability-catalog.js.map +1 -1
  519. package/packages/core/dist/registries/agent-registry.js +15 -15
  520. package/packages/core/dist/registries/agent-registry.js.map +1 -1
  521. package/packages/core/dist/registries/agent-runtime-static.js +1 -1
  522. package/packages/core/dist/registries/agent-runtime-static.js.map +1 -1
  523. package/packages/core/dist/registries/capability-sources.js +1 -1
  524. package/packages/core/dist/registries/command-team-runtime.d.ts +1 -1
  525. package/packages/core/dist/registries/command-team-runtime.js +9 -9
  526. package/packages/core/dist/registries/command-team-runtime.js.map +1 -1
  527. package/packages/core/dist/registries/eval-learning-context.js +4 -4
  528. package/packages/core/dist/registries/eval-learning-context.js.map +1 -1
  529. package/packages/core/dist/registries/query-status.js +2 -2
  530. package/packages/core/dist/registries/query-status.js.map +1 -1
  531. package/packages/core/dist/registries/tool-capabilities.js +3 -3
  532. package/packages/core/dist/registries/tool-capabilities.js.map +1 -1
  533. package/packages/core/dist/registries/tool-plugins.js +2 -2
  534. package/packages/core/dist/registries/tool-plugins.js.map +1 -1
  535. package/packages/core/dist/registries/worker-adapters.js +11 -11
  536. package/packages/core/dist/registries/worker-adapters.js.map +1 -1
  537. package/packages/core/dist/registries/workflow-gates.js +12 -12
  538. package/packages/core/dist/registries/workflow-gates.js.map +1 -1
  539. package/packages/core/dist/risk/contracts.d.ts +2 -2
  540. package/packages/core/dist/risk/kernel.js +4 -4
  541. package/packages/core/dist/risk/kernel.js.map +1 -1
  542. package/packages/core/dist/risk/legacy-adapters.js +4 -7
  543. package/packages/core/dist/risk/legacy-adapters.js.map +1 -1
  544. package/packages/core/dist/risk/workflow-gates.d.ts +2 -2
  545. package/packages/core/dist/risk/workflow-gates.js +19 -17
  546. package/packages/core/dist/risk/workflow-gates.js.map +1 -1
  547. package/packages/core/dist/router/agent-runtime-config.js +1 -1
  548. package/packages/core/dist/router/agent-runtime-config.js.map +1 -1
  549. package/packages/core/dist/router/agent-runtime.d.ts +2 -0
  550. package/packages/core/dist/router/route-projection.js +1 -1
  551. package/packages/core/dist/router/route-projection.js.map +1 -1
  552. package/packages/core/dist/router/routing.js +45 -15
  553. package/packages/core/dist/router/routing.js.map +1 -1
  554. package/packages/core/dist/router/runtime-import.d.ts +28 -0
  555. package/packages/core/dist/router/runtime-import.js +373 -0
  556. package/packages/core/dist/router/runtime-import.js.map +1 -0
  557. package/packages/core/dist/router/runtime-validation.js +2 -2
  558. package/packages/core/dist/router/runtime-validation.js.map +1 -1
  559. package/packages/core/dist/router/stage-route-binding.d.ts +37 -0
  560. package/packages/core/dist/router/stage-route-binding.js +235 -0
  561. package/packages/core/dist/router/stage-route-binding.js.map +1 -0
  562. package/packages/core/dist/router.d.ts +2 -0
  563. package/packages/core/dist/router.js +2 -0
  564. package/packages/core/dist/router.js.map +1 -1
  565. package/packages/core/dist/run-state/artifacts.d.ts +16 -0
  566. package/packages/core/dist/run-state/artifacts.js +126 -9
  567. package/packages/core/dist/run-state/artifacts.js.map +1 -1
  568. package/packages/core/dist/run-state/inspect-run.d.ts +0 -2
  569. package/packages/core/dist/run-state/inspect-run.js +7 -5
  570. package/packages/core/dist/run-state/inspect-run.js.map +1 -1
  571. package/packages/core/dist/run-state/model.d.ts +28 -8
  572. package/packages/core/dist/run-state/run-index.d.ts +0 -2
  573. package/packages/core/dist/run-state/run-index.js +1 -3
  574. package/packages/core/dist/run-state/run-index.js.map +1 -1
  575. package/packages/core/dist/run-state/run-state.js +37 -27
  576. package/packages/core/dist/run-state/run-state.js.map +1 -1
  577. package/packages/core/dist/run-state/task-evidence.d.ts +5 -2
  578. package/packages/core/dist/run-state/task-evidence.js +53 -14
  579. package/packages/core/dist/run-state/task-evidence.js.map +1 -1
  580. package/packages/core/dist/run-state/timing.d.ts +8 -0
  581. package/packages/core/dist/run-state/timing.js +131 -0
  582. package/packages/core/dist/run-state/timing.js.map +1 -0
  583. package/packages/core/dist/run-state.d.ts +1 -0
  584. package/packages/core/dist/run-state.js +1 -0
  585. package/packages/core/dist/run-state.js.map +1 -1
  586. package/packages/core/dist/runtime-analysis/build.js +0 -3
  587. package/packages/core/dist/runtime-analysis/build.js.map +1 -1
  588. package/packages/core/dist/runtime-analysis/findings.js +5 -44
  589. package/packages/core/dist/runtime-analysis/findings.js.map +1 -1
  590. package/packages/core/dist/runtime-analysis/model.d.ts +1 -17
  591. package/packages/core/dist/runtime-paths.d.ts +10 -0
  592. package/packages/core/dist/runtime-paths.js +65 -0
  593. package/packages/core/dist/runtime-paths.js.map +1 -1
  594. package/packages/core/dist/runtime-projection-p0.d.ts +64 -0
  595. package/packages/core/dist/runtime-projection-p0.js +200 -0
  596. package/packages/core/dist/runtime-projection-p0.js.map +1 -0
  597. package/packages/core/dist/sdd-docs/document-hashes.d.ts +2 -0
  598. package/packages/core/dist/sdd-docs/document-hashes.js +97 -10
  599. package/packages/core/dist/sdd-docs/document-hashes.js.map +1 -1
  600. package/packages/core/dist/sdd-docs/run-binding.d.ts +1 -1
  601. package/packages/core/dist/sdd-docs/run-binding.js +8 -6
  602. package/packages/core/dist/sdd-docs/run-binding.js.map +1 -1
  603. package/packages/core/dist/sdd-docs/task-parser.d.ts +1 -0
  604. package/packages/core/dist/sdd-docs/task-parser.js +55 -34
  605. package/packages/core/dist/sdd-docs/task-parser.js.map +1 -1
  606. package/packages/core/dist/stage-artifacts.d.ts +55 -0
  607. package/packages/core/dist/stage-artifacts.js +322 -0
  608. package/packages/core/dist/stage-artifacts.js.map +1 -0
  609. package/packages/core/dist/stage-collaboration-contracts.d.ts +55 -0
  610. package/packages/core/dist/stage-collaboration-contracts.js +241 -0
  611. package/packages/core/dist/stage-collaboration-contracts.js.map +1 -0
  612. package/packages/core/dist/stage-collaboration.d.ts +888 -0
  613. package/packages/core/dist/stage-collaboration.js +3870 -0
  614. package/packages/core/dist/stage-collaboration.js.map +1 -0
  615. package/packages/core/dist/stage-runtime/runtime.js +8 -1
  616. package/packages/core/dist/stage-runtime/runtime.js.map +1 -1
  617. package/packages/core/dist/status/project-status.d.ts +44 -1
  618. package/packages/core/dist/status/project-status.js +170 -23
  619. package/packages/core/dist/status/project-status.js.map +1 -1
  620. package/packages/core/dist/storage/runtime-store.d.ts +170 -18
  621. package/packages/core/dist/storage/runtime-store.js +544 -32
  622. package/packages/core/dist/storage/runtime-store.js.map +1 -1
  623. package/packages/core/dist/subagents/contracts.d.ts +1 -1
  624. package/packages/core/dist/subagents/runtime.js +7 -7
  625. package/packages/core/dist/subagents/runtime.js.map +1 -1
  626. package/packages/core/dist/test-support/fixtures.js +1 -1
  627. package/packages/core/dist/test-support/run-state.d.ts +1 -1
  628. package/packages/core/dist/test-support/run-state.js +8 -23
  629. package/packages/core/dist/test-support/run-state.js.map +1 -1
  630. package/packages/core/dist/truth-reconciliation.d.ts +44 -0
  631. package/packages/core/dist/truth-reconciliation.js +138 -0
  632. package/packages/core/dist/truth-reconciliation.js.map +1 -0
  633. package/packages/core/dist/tsconfig.tsbuildinfo +1 -1
  634. package/packages/core/dist/verification/goal-verify.d.ts +0 -1
  635. package/packages/core/dist/verification/goal-verify.js +28 -53
  636. package/packages/core/dist/verification/goal-verify.js.map +1 -1
  637. package/packages/core/dist/verification/rendering.d.ts +0 -2
  638. package/packages/core/dist/verification/rendering.js +10 -50
  639. package/packages/core/dist/verification/rendering.js.map +1 -1
  640. package/packages/core/dist/verification/single-task-loop.d.ts +0 -1
  641. package/packages/core/dist/verification/single-task-loop.js +159 -150
  642. package/packages/core/dist/verification/single-task-loop.js.map +1 -1
  643. package/packages/core/dist/verification/test-runtime.d.ts +12 -2
  644. package/packages/core/dist/verification/test-runtime.js +238 -103
  645. package/packages/core/dist/verification/test-runtime.js.map +1 -1
  646. package/packages/core/dist/verification/validation-cache.d.ts +26 -0
  647. package/packages/core/dist/verification/validation-cache.js +73 -0
  648. package/packages/core/dist/verification/validation-cache.js.map +1 -0
  649. package/packages/core/dist/verification/validation-wave.d.ts +18 -0
  650. package/packages/core/dist/verification/validation-wave.js +27 -5
  651. package/packages/core/dist/verification/validation-wave.js.map +1 -1
  652. package/packages/core/dist/verification/verify-contract.d.ts +1 -1
  653. package/packages/core/dist/verification/verify-contract.js +9 -32
  654. package/packages/core/dist/verification/verify-contract.js.map +1 -1
  655. package/packages/core/dist/work-units/contracts.d.ts +1 -1
  656. package/packages/core/dist/workflow-gate/evidence-packet.js +228 -15
  657. package/packages/core/dist/workflow-gate/evidence-packet.js.map +1 -1
  658. package/packages/core/dist/workflow-gate/hard-checks.js +49 -15
  659. package/packages/core/dist/workflow-gate/hard-checks.js.map +1 -1
  660. package/packages/core/dist/workflow-gate/policy.js +42 -6
  661. package/packages/core/dist/workflow-gate/policy.js.map +1 -1
  662. package/packages/core/dist/workflow-gate/types.d.ts +4 -5
  663. package/packages/core/dist/workflow-state/affected-file-conflicts.d.ts +0 -1
  664. package/packages/core/dist/workflow-state/affected-file-conflicts.js +1 -2
  665. package/packages/core/dist/workflow-state/affected-file-conflicts.js.map +1 -1
  666. package/packages/core/dist/workflow-state/dependencies.js +1 -1
  667. package/packages/core/dist/workflow-state/latest-eligible-run.d.ts +0 -1
  668. package/packages/core/dist/workflow-state/latest-eligible-run.js +72 -6
  669. package/packages/core/dist/workflow-state/latest-eligible-run.js.map +1 -1
  670. package/packages/core/dist/workflow-state/migration-recovery.d.ts +40 -0
  671. package/packages/core/dist/workflow-state/migration-recovery.js +110 -0
  672. package/packages/core/dist/workflow-state/migration-recovery.js.map +1 -0
  673. package/packages/core/dist/workflow-state/repair-contract.d.ts +12 -0
  674. package/packages/core/dist/workflow-state/repair-contract.js +63 -0
  675. package/packages/core/dist/workflow-state/repair-contract.js.map +1 -0
  676. package/packages/core/dist/workflow-state/resolve-task-run.d.ts +21 -0
  677. package/packages/core/dist/workflow-state/resolve-task-run.js +95 -0
  678. package/packages/core/dist/workflow-state/resolve-task-run.js.map +1 -0
  679. package/packages/core/dist/workflow-state/resolve.d.ts +55 -5
  680. package/packages/core/dist/workflow-state/resolve.js +538 -34
  681. package/packages/core/dist/workflow-state/resolve.js.map +1 -1
  682. package/packages/core/dist/workflow-state/runtime-projections.d.ts +228 -0
  683. package/packages/core/dist/workflow-state/runtime-projections.js +452 -0
  684. package/packages/core/dist/workflow-state/runtime-projections.js.map +1 -0
  685. package/packages/core/package.json +3 -3
  686. package/node_modules/@sdd-agent-platform/core/dist/doctor/render.d.ts +0 -2
  687. package/node_modules/@sdd-agent-platform/core/dist/doctor/render.js +0 -44
  688. package/node_modules/@sdd-agent-platform/core/dist/doctor/render.js.map +0 -1
  689. package/node_modules/@sdd-agent-platform/core/dist/sync-back/apply.d.ts +0 -17
  690. package/node_modules/@sdd-agent-platform/core/dist/sync-back/apply.js +0 -243
  691. package/node_modules/@sdd-agent-platform/core/dist/sync-back/apply.js.map +0 -1
  692. package/node_modules/@sdd-agent-platform/core/dist/sync-back/inspect.d.ts +0 -110
  693. package/node_modules/@sdd-agent-platform/core/dist/sync-back/inspect.js +0 -497
  694. package/node_modules/@sdd-agent-platform/core/dist/sync-back/inspect.js.map +0 -1
  695. package/node_modules/@sdd-agent-platform/core/dist/sync-back.d.ts +0 -2
  696. package/node_modules/@sdd-agent-platform/core/dist/sync-back.js +0 -3
  697. package/node_modules/@sdd-agent-platform/core/dist/sync-back.js.map +0 -1
  698. package/node_modules/@sdd-agent-platform/core/src/sync-back/apply.ts +0 -270
  699. package/node_modules/@sdd-agent-platform/core/src/sync-back/inspect.ts +0 -655
  700. package/node_modules/@sdd-agent-platform/core/src/sync-back/sync-back.test.ts +0 -569
  701. package/node_modules/@sdd-agent-platform/core/src/sync-back.ts +0 -2
  702. package/packages/cli/dist/commands/artifact.d.ts +0 -6
  703. package/packages/cli/dist/commands/artifact.js +0 -168
  704. package/packages/cli/dist/commands/artifact.js.map +0 -1
  705. package/packages/cli/dist/commands/sync-back.d.ts +0 -6
  706. package/packages/cli/dist/commands/sync-back.js +0 -82
  707. package/packages/cli/dist/commands/sync-back.js.map +0 -1
  708. package/packages/cli/dist/renderers/artifacts.d.ts +0 -5
  709. package/packages/cli/dist/renderers/artifacts.js +0 -43
  710. package/packages/cli/dist/renderers/artifacts.js.map +0 -1
  711. package/packages/core/dist/doctor/render.d.ts +0 -2
  712. package/packages/core/dist/doctor/render.js +0 -44
  713. package/packages/core/dist/doctor/render.js.map +0 -1
  714. package/packages/core/dist/sync-back/apply.d.ts +0 -17
  715. package/packages/core/dist/sync-back/apply.js +0 -243
  716. package/packages/core/dist/sync-back/apply.js.map +0 -1
  717. package/packages/core/dist/sync-back/inspect.d.ts +0 -110
  718. package/packages/core/dist/sync-back/inspect.js +0 -497
  719. package/packages/core/dist/sync-back/inspect.js.map +0 -1
  720. package/packages/core/dist/sync-back.d.ts +0 -2
  721. package/packages/core/dist/sync-back.js +0 -3
  722. package/packages/core/dist/sync-back.js.map +0 -1
@@ -1,5 +1,5 @@
1
- import { readdir, stat } from 'node:fs/promises';
2
- import path from 'node:path';
1
+ import { readFile } from 'node:fs/promises';
2
+
3
3
  import { inspectAiToolEntryEvidence } from './checks/ai-entries.js';
4
4
  import { inspectDocumentChainEvidence } from './checks/document-chain.js';
5
5
  import { inspectLocalRunIndexEvidence } from './checks/local-run-index.js';
@@ -7,10 +7,15 @@ import { inspectGitRepository, inspectProjectConfig, inspectRunsDirectoryAccess,
7
7
  import { inspectRunEvidence } from './checks/run-evidence.js';
8
8
  import { inspectAgentCapabilityCatalogDoctorContract, inspectAgentSkillTeamRuntimeDoctorContract, inspectCapabilityRegistry, inspectCommandTeamRuntimeDoctorContract, inspectGovernancePolicyContract, inspectHarnessLearningDoctorContract, inspectProjectContextPackDoctorContract, inspectQueryStatusBoundaryContract, inspectSkillAgentEvalDoctorContract, inspectToolPluginContracts } from './checks/registries.js';
9
9
  import { inspectBackgroundExecutorContract, inspectDelegationQueueContract, inspectDelegationStateMachineContract, inspectLocalRunIndexContract, inspectTaskGraphPlannerContract, inspectWaveExecutorContract, inspectWavePlannerContract, inspectWorkerAdapterContracts, inspectWorktreeIsolationContract, inspectWorktreeLifecycleContract } from './checks/runtime-contracts.js';
10
- import { inspectRuntimeStoreEvidence, listRuntimeSyncBackDecisions } from '../storage/runtime-store.js';
11
- import { getLegacyAgentExecutionsDir, getLegacyRunDir, getLegacyTeamSessionsDir, getLegacyWorkerRuntimesDir } from '../runtime-paths.js';
10
+ import { inspectRuntimeStoreEvidence, listRuntimeRepairs, listRuntimeTestRuns, listRuntimeTestSteps, listRuntimeValidationCacheEntries, listRuntimeValidationCacheUses, recordRuntimeRepair, type RuntimeRepairRecord } from '../storage/runtime-store.js';
11
+
12
12
  import { branchToSafePartition } from '../path-safety.js';
13
13
  import { readAllRunStates } from '../run-state/run-state.js';
14
+ import { readRunEvents } from '../run-state/events.js';
15
+ import { buildRunDurationBreakdown } from '../run-state/timing.js';
16
+ import { parseSddBranch } from '../sdd-docs/task-parser.js';
17
+ import { buildMixedVersionRecoveryPlan } from '../workflow-state/migration-recovery.js';
18
+ import { buildOpenRepairRecord } from '../workflow-state/repair-contract.js';
14
19
  import { getProjectStatus, statuslineProjectionFromStatus, type ProjectStatus } from '../status/project-status.js';
15
20
  import type { DoctorCheck, DoctorReport } from './model.js';
16
21
  import { summarizeDoctorStatus } from './summary.js';
@@ -68,7 +73,14 @@ export async function doctor(projectRoot: string, options: { allRuns?: boolean;
68
73
  checks.push(...inspectDurableGapRuntime(statusSnapshot));
69
74
  checks.push(...inspectStageTeamRuntime(statusSnapshot));
70
75
  checks.push(...inspectWorkflowGateRuntime(statusSnapshot));
71
- checks.push(...await inspectPhase818Compatibility(projectRoot, options));
76
+ checks.push(...inspectSpecCollaborationRuntime(statusSnapshot));
77
+ checks.push(...await inspectRuntimePerformanceObservability(projectRoot, options));
78
+ checks.push(...await inspectValidationCacheVisibility(projectRoot, options));
79
+ checks.push(...await inspectMixedVersionRecovery(projectRoot, statusSnapshot, options));
80
+
81
+
82
+ checks.push(...await inspectRepairRecords(projectRoot, options));
83
+ await recordDoctorRepairs(projectRoot, checks, options.branch ?? null);
72
84
 
73
85
  return {
74
86
  status: summarizeDoctorStatus(checks),
@@ -101,83 +113,191 @@ function unavailableRuntimeCheck(check: string, label: string, error: unknown):
101
113
  }];
102
114
  }
103
115
 
104
- async function inspectPhase818Compatibility(projectRoot: string, options: { allRuns?: boolean; branch?: string | null } = {}): Promise<DoctorCheck[]> {
116
+ const STALE_OPEN_RUN_MS = 30 * 60 * 1000;
117
+ const WAITING_DOMINATED_MIN_MS = 10_000;
118
+ const SLOW_VALIDATION_STEP_MS = 30_000;
119
+
120
+ async function inspectRuntimePerformanceObservability(projectRoot: string, options: { allRuns?: boolean; branch?: string | null } = {}): Promise<DoctorCheck[]> {
105
121
  try {
106
122
  const branchPartition = options.branch ? branchToSafePartition(options.branch) : null;
107
123
  const states = (await readAllRunStates(projectRoot))
108
124
  .filter((state) => options.allRuns || state.status !== 'archived')
109
125
  .filter((state) => !branchPartition || state.partition === branchPartition || state.gitBranch === options.branch || (state.gitBranch ? branchToSafePartition(state.gitBranch) === branchPartition : false));
110
- const legacyRunFiles: string[] = [];
111
- const legacySidecars: string[] = [];
112
- const syncBackJsonOnly: string[] = [];
113
- const syncBackDivergence: string[] = [];
126
+ const staleOpenRuns: string[] = [];
127
+ const missingTestSteps: string[] = [];
128
+ const waitingDominatedRuns: string[] = [];
129
+ const slowValidationSteps: string[] = [];
130
+ const hostNoOutputRuns: string[] = [];
114
131
 
115
132
  for (const state of states) {
116
- const legacyRunDir = getLegacyRunDir(projectRoot, state.runId);
117
- const runLocalFiles = ['state.json', 'events.jsonl', 'invocations.jsonl'];
118
- for (const fileName of runLocalFiles) {
119
- if (await fileExists(path.join(legacyRunDir, fileName))) {
120
- legacyRunFiles.push(`${state.runId}:${fileName}`);
121
- }
133
+ const ageMs = Date.now() - Date.parse(state.updatedAt);
134
+ if (!isTerminalRunStatus(state.status) && Number.isFinite(ageMs) && ageMs >= STALE_OPEN_RUN_MS) {
135
+ staleOpenRuns.push(state.runId);
122
136
  }
123
137
 
124
- const sidecarDirs = [
125
- getLegacyAgentExecutionsDir(projectRoot, state.runId),
126
- getLegacyTeamSessionsDir(projectRoot, state.runId),
127
- getLegacyWorkerRuntimesDir(projectRoot, state.runId)
128
- ];
129
- if ((await Promise.all(sidecarDirs.map(directoryHasEntries))).some(Boolean)) {
130
- legacySidecars.push(state.runId);
138
+ const [events, testRuns, testSteps] = await Promise.all([
139
+ readRunEvents(projectRoot, state.runId),
140
+ listRuntimeTestRuns(projectRoot, state.runId),
141
+ listRuntimeTestSteps(projectRoot, { runId: state.runId })
142
+ ]);
143
+ if (testRuns.length > 0 && testSteps.length === 0) {
144
+ missingTestSteps.push(state.runId);
131
145
  }
132
146
 
133
- const decisions = await listRuntimeSyncBackDecisions(projectRoot, state.runId);
134
- const latestDecision = decisions[0] ?? null;
135
- if (state.syncBack.status !== 'not_created' && !latestDecision) {
136
- syncBackJsonOnly.push(state.runId);
147
+ const breakdown = buildRunDurationBreakdown(state, { events, testRuns, testSteps });
148
+ if (breakdown.waitingDurationMs >= WAITING_DOMINATED_MIN_MS && breakdown.waitingDurationMs > breakdown.activeRuntimeDurationMs) {
149
+ waitingDominatedRuns.push(`${state.runId}:${breakdown.waitingDurationMs}ms`);
150
+ }
151
+ if (breakdown.hostWaitingDurationMs >= WAITING_DOMINATED_MIN_MS && testSteps.length === 0) {
152
+ hostNoOutputRuns.push(`${state.runId}:${breakdown.hostWaitingDurationMs}ms`);
137
153
  }
138
- if (latestDecision && latestDecision.status !== state.syncBack.status) {
139
- syncBackDivergence.push(`${state.runId}:${state.syncBack.status}->${latestDecision.status}`);
154
+ for (const step of testSteps) {
155
+ if (step.durationMs >= SLOW_VALIDATION_STEP_MS) {
156
+ slowValidationSteps.push(`${step.runId}:${step.stepId}:${step.durationMs}ms`);
157
+ }
140
158
  }
141
159
  }
142
160
 
143
- const oldSyncBackProjection = await fileExists(path.join(projectRoot, '.claude', 'commands', 'sdd', 'syncback.md'));
144
- return [
145
- legacyRunFiles.length > 0
146
- ? { level: 'WARN', check: 'phase8_18_legacy_run_files', message: `legacy_run_files=${legacyRunFiles.join(',')}`, action: 'Runtime authority is runtime.sqlite; keep legacy run-local state/events/invocation files as import fallback only.' }
147
- : { level: 'PASS', check: 'phase8_18_legacy_run_files', message: 'No legacy run-local state, event, or invocation files found in inspected runs.' },
148
- legacySidecars.length > 0
149
- ? { level: 'WARN', check: 'phase8_18_legacy_sidecars', message: `legacy_sidecar_runs=${legacySidecars.join(',')}`, action: 'Runtime authority is runtime.sqlite; keep old sidecars as import fallback and avoid writing new per-run structured sidecars.' }
150
- : { level: 'PASS', check: 'phase8_18_legacy_sidecars', message: 'No legacy per-run agent/team/worker sidecar directories found in inspected runs.' },
151
- syncBackJsonOnly.length > 0 || syncBackDivergence.length > 0
152
- ? { level: 'WARN', check: 'phase8_18_sync_back_compat', message: `state_json_only=${syncBackJsonOnly.join(',') || 'none'} divergence=${syncBackDivergence.join(',') || 'none'}`, action: 'Use sdd sync-back inspect only for explicit diagnostic/recovery/replay, then reconcile canonical sync_back_decisions before relying on write-back state.' }
153
- : { level: 'PASS', check: 'phase8_18_sync_back_compat', message: 'Canonical sync_back_decisions are consistent with inspected run compatibility summaries.' },
154
- oldSyncBackProjection
155
- ? { level: 'WARN', check: 'phase8_18_ai_projection_compat', message: 'Found legacy /sdd:syncback projection at .claude/commands/sdd/syncback.md.', action: 'Run sdd update to remove obsolete managed syncback projection; use diagnostic sync-back only when explicitly requested.' }
156
- : { level: 'PASS', check: 'phase8_18_ai_projection_compat', message: 'No legacy /sdd:syncback projection found.' },
157
- { level: 'PASS', check: 'phase9_readiness', message: 'code_graph_signals=optional_advisory_only authority=phase8_runtime_policy', action: 'Phase 9 graph providers may feed risk/context/test-impact/status/doctor signals but cannot replace Phase 8 gate truth.' }
158
- ];
161
+ const warnings = staleOpenRuns.length + missingTestSteps.length + waitingDominatedRuns.length + slowValidationSteps.length + hostNoOutputRuns.length;
162
+ return [{
163
+ level: warnings > 0 ? 'WARN' : 'PASS',
164
+ check: 'runtime_performance_observability',
165
+ message: `runs=${states.length} stale_open=${staleOpenRuns.join(',') || 'none'} missing_test_steps=${missingTestSteps.join(',') || 'none'} waiting_dominated=${waitingDominatedRuns.join(',') || 'none'} slow_validation=${slowValidationSteps.join(',') || 'none'} host_no_output=${hostNoOutputRuns.join(',') || 'none'}`,
166
+ action: warnings > 0 ? 'Inspect run duration breakdowns with sdd run inspect; persist test_steps for validation commands and investigate long waiting or host-no-output gaps.' : undefined
167
+ }];
159
168
  } catch (error) {
160
- return unavailableRuntimeCheck('phase8_18_compatibility', 'Phase 8.18 compatibility diagnostics', error);
169
+ return unavailableRuntimeCheck('runtime_performance_observability', 'runtime performance observability', error);
161
170
  }
162
171
  }
163
172
 
164
- async function directoryHasEntries(directory: string): Promise<boolean> {
173
+ async function inspectValidationCacheVisibility(projectRoot: string, options: { branch?: string | null } = {}): Promise<DoctorCheck[]> {
165
174
  try {
166
- return (await readdir(directory)).length > 0;
167
- } catch {
168
- return false;
175
+ const branchPartition = options.branch ? branchToSafePartition(options.branch) : null;
176
+ const entries = await listRuntimeValidationCacheEntries(projectRoot, { branchSlug: branchPartition, status: 'valid' });
177
+ const uses = await listRuntimeValidationCacheUses(projectRoot, { branchSlug: branchPartition });
178
+ const staleEntries = entries.filter((entry) => !entry.payload || typeof entry.payload !== 'object' || !('cachePlan' in entry.payload));
179
+ return [{
180
+ level: staleEntries.length > 0 ? 'WARN' : 'PASS',
181
+ check: 'validation_cache_visibility',
182
+ message: `entries=${entries.length} uses=${uses.length} stale_entries=${staleEntries.map((entry) => entry.cacheKey).join(',') || 'none'} hit_sources=${[...new Set(uses.map((use) => use.sourceTestRunId))].join(',') || 'none'}`,
183
+ action: staleEntries.length > 0 ? 'Replay stale validation cache entries; cache hits must remain tied to current cachePlan payload and accepted evidence mapping.' : undefined
184
+ }];
185
+ } catch (error) {
186
+ return unavailableRuntimeCheck('validation_cache_visibility', 'validation cache visibility', error);
169
187
  }
170
188
  }
171
189
 
172
- async function fileExists(filePath: string): Promise<boolean> {
190
+ async function inspectRepairRecords(projectRoot: string, options: { branch?: string | null } = {}): Promise<DoctorCheck[]> {
173
191
  try {
174
- await stat(filePath);
175
- return true;
192
+ const branchPartition = options.branch ? branchToSafePartition(options.branch) : null;
193
+ const repairs = await listRuntimeRepairs(projectRoot, { branchSlug: branchPartition, status: 'open' });
194
+ return [{
195
+ level: repairs.length > 0 ? 'WARN' : 'PASS',
196
+ check: 'repair_records',
197
+ message: `open=${repairs.length} types=${[...new Set(repairs.map((repair) => repair.repairType))].join(',') || 'none'} next=${repairs.flatMap((repair) => repair.recommendedCommands).slice(0, 3).join(' | ') || 'none'}`,
198
+ action: repairs.length > 0 ? 'Resolve open repair records with new accepted evidence or a fresh gate PASS; diagnostic text alone does not close repairs.' : undefined
199
+ }];
200
+ } catch (error) {
201
+ return unavailableRuntimeCheck('repair_records', 'repair records', error);
202
+ }
203
+ }
204
+
205
+ async function recordDoctorRepairs(projectRoot: string, checks: DoctorCheck[], branch: string | null): Promise<void> {
206
+ const branchSlug = branch ? branchToSafePartition(branch) : 'master';
207
+ const repairable = checks.filter((check) => doctorCheckCreatesRepair(check));
208
+ const repairableCheckNames = new Set(repairable.map((check) => check.check));
209
+ try {
210
+ const openRepairs = await listRuntimeRepairs(projectRoot, { branchSlug, status: 'open' });
211
+ for (const repair of openRepairs) {
212
+ const checkName = doctorRepairCheckName(repair);
213
+ if (checkName && (!repairableCheckNames.has(checkName) || repair.recommendedCommands.some((command) => !doctorRepairCommandLooksExecutable(command)))) {
214
+ await recordRuntimeRepair(projectRoot, {
215
+ ...repair,
216
+ status: 'superseded',
217
+ resolvedAt: new Date().toISOString(),
218
+ payload: { ...doctorRepairPayload(repair.payload), supersededBy: 'doctor_fail_check_cleared' }
219
+ });
220
+ }
221
+ }
176
222
  } catch {
177
- return false;
223
+ return;
224
+ }
225
+ for (const check of repairable) {
226
+ try {
227
+ await recordRuntimeRepair(projectRoot, buildOpenRepairRecord({
228
+ branchSlug,
229
+ message: `${check.check}: ${check.message}`,
230
+ recommendedCommands: doctorRepairCommands(branchSlug, check),
231
+ requiredEvidence: ['new accepted evidence or fresh gate PASS']
232
+ }));
233
+ } catch {
234
+ return;
235
+ }
178
236
  }
179
237
  }
180
238
 
239
+ function doctorCheckCreatesRepair(check: DoctorCheck): boolean {
240
+ return check.check !== 'repair_records' && check.check !== 'capability_health' && check.level === 'FAIL';
241
+ }
242
+
243
+ function doctorRepairCheckName(repair: RuntimeRepairRecord): string | null {
244
+ const blocker = repair.blockers[0] ?? '';
245
+ const separator = blocker.indexOf(':');
246
+ return separator > 0 ? blocker.slice(0, separator) : null;
247
+ }
248
+
249
+ function doctorRepairPayload(payload: unknown): Record<string, unknown> {
250
+ return payload && typeof payload === 'object' && !Array.isArray(payload) ? payload as Record<string, unknown> : { previousPayload: payload };
251
+ }
252
+
253
+ function doctorRepairCommands(branchSlug: string, check: DoctorCheck): string[] {
254
+ if (check.check === 'ai_entry_projection') {
255
+ return ['sdd update'];
256
+ }
257
+ if (check.check === 'capability_health') {
258
+ return [`sdd status --branch ${branchSlug} --compact-json`];
259
+ }
260
+ if (check.check === 'document_chain' || check.check === 'verify_contract' || check.message.includes('verify.md')) {
261
+ return [`sdd verifies write --branch ${branchSlug} --force`];
262
+ }
263
+ return [`sdd doctor --branch ${branchSlug} --latest-only`];
264
+ }
265
+
266
+ function doctorRepairCommandLooksExecutable(command: string): boolean {
267
+ const normalized = command.trim().toLowerCase();
268
+ return normalized.startsWith('sdd ') || normalized.startsWith('npm ') || normalized.startsWith('node ') || normalized.startsWith('npx ');
269
+ }
270
+
271
+ function isTerminalRunStatus(status: string): boolean {
272
+ return status === 'completed' || status === 'failed' || status === 'blocked' || status === 'archived';
273
+ }
274
+
275
+
276
+ async function inspectMixedVersionRecovery(projectRoot: string, snapshot: DoctorProjectStatusSnapshot, options: { branch?: string | null } = {}): Promise<DoctorCheck[]> {
277
+ if (!snapshot.status) {
278
+ return unavailableRuntimeCheck('mixed_version_recovery', 'mixed-version recovery plan', snapshot.error);
279
+ }
280
+ try {
281
+ const model = await parseSddBranch(projectRoot, snapshot.status.branch);
282
+ const verifyText = model.documents.verifyExists ? await readFile(model.verifyPath, 'utf8') : null;
283
+ const plan = buildMixedVersionRecoveryPlan({ model, latestEligibleRunsByTask: snapshot.status.latestEligibleRunsByTask, verifyText });
284
+ const blocking = plan.detectedIssues.filter((issue) => issue.severity === 'blocking').length;
285
+ const warnings = plan.detectedIssues.filter((issue) => issue.severity === 'warn').length;
286
+ const legacyArtifacts = plan.detectedIssues.filter((issue) => issue.kind === 'legacy_artifact_ref').map((issue) => `${issue.taskId}:${issue.current}->${issue.expected}`);
287
+ const strictStale = plan.staleRunImpact.map((impact) => `${impact.taskId}:${impact.runId}`);
288
+ return [{
289
+ level: blocking > 0 ? 'FAIL' : warnings > 0 || plan.staleRunImpact.length > 0 ? 'WARN' : 'PASS',
290
+ check: 'mixed_version_recovery',
291
+ message: `issues=${plan.detectedIssues.length} safe_fixes=${plan.safeMechanicalUpdates.length} behavior_changes=${plan.behaviorChangingUpdates.length} legacy_artifacts=${legacyArtifacts.join(',') || 'none'} stale_runs=${strictStale.join(',') || 'none'} replay=${plan.evidenceReplayNeeded.join(',') || 'none'} next=${plan.nextCommands.join(' | ')}`,
292
+ action: plan.detectedIssues.length > 0 ? 'Apply only safe mechanical fixes in dry-run/preview first, then replay validation evidence; do not promote legacy stale runs as accepted truth.' : undefined
293
+ }];
294
+ } catch (error) {
295
+ return unavailableRuntimeCheck('mixed_version_recovery', 'mixed-version recovery plan', error);
296
+ }
297
+ }
298
+
299
+
300
+
181
301
  function inspectContextTokenRuntime(snapshot: DoctorProjectStatusSnapshot): DoctorCheck[] {
182
302
  if (!snapshot.status) {
183
303
  return unavailableRuntimeCheck('context_token_runtime', 'token runtime projection', snapshot.error);
@@ -200,7 +320,7 @@ function inspectLifecycleRiskRuntime(snapshot: DoctorProjectStatusSnapshot): Doc
200
320
  level: risk.status === 'blocked' || risk.status === 'incompatible' || risk.approvalPolicy === 'blocked' ? 'FAIL' : risk.status === 'missing' || risk.status === 'stale' || risk.approvalPolicy === 'human-required' ? 'WARN' : 'PASS',
201
321
  check: 'lifecycle_risk_decision',
202
322
  message: `status=${risk.status} profile=${risk.profile ?? 'none'} approval=${risk.approvalPolicy ?? 'none'} input=${risk.inputHash ?? 'none'} expected=${risk.expectedInputHash}`,
203
- action: risk.status === 'fresh' ? undefined : `Run lifecycle risk projection for ${risk.scopeKey}; workflow gates now consume this decision directly.`
323
+ action: risk.status === 'fresh' ? undefined : `sdd status --branch ${snapshot.status.branch} --compact-json`
204
324
  }];
205
325
  }
206
326
 
@@ -213,7 +333,7 @@ function inspectWorkflowHandoffRuntime(snapshot: DoctorProjectStatusSnapshot): D
213
333
  level: handoff.status === 'blocked' || handoff.status === 'rejected' || handoff.status === 'incompatible' ? 'FAIL' : handoff.status === 'stale' ? 'WARN' : 'PASS',
214
334
  check: 'workflow_handoff_state',
215
335
  message: `status=${handoff.status} active_stage=${handoff.activeStage?.stage ?? 'none'} latest_stage=${handoff.latestStageRun?.stage ?? 'none'} latest_handoff=${handoff.latestHandoff ? `${handoff.latestHandoff.fromStage}->${handoff.latestHandoff.toStage}:${handoff.latestHandoff.status}` : 'none'} stage_projections=${handoff.projectionCounts.stageRuns} handoff_projections=${handoff.projectionCounts.handoffs}`,
216
- action: handoff.status === 'fresh' || handoff.status === 'missing' ? undefined : `Resolve workflow handoff projection for ${snapshot.status.branch}; workflow gates now consume this state directly.`
336
+ action: handoff.status === 'fresh' || handoff.status === 'missing' ? undefined : `sdd status --branch ${snapshot.status.branch} --compact-json`
217
337
  }];
218
338
  }
219
339
 
@@ -251,8 +371,8 @@ function inspectCapabilityHealthRuntime(snapshot: DoctorProjectStatusSnapshot):
251
371
  return [{
252
372
  level: health.status === 'blocked' ? 'FAIL' : health.status === 'warn' ? 'WARN' : 'PASS',
253
373
  check: 'capability_health',
254
- message: `status=${health.status} baseline=${health.baselineDomains.length}/${health.requiredProfessionalDomains.length} packs=${health.materialPacks} active=${health.activeDomains.join(',') || 'none'} sources_quarantined=${health.sources.quarantined} sources_denied=${health.sources.denied} evidence_candidate=${health.evidence.candidate} release_critical_gaps=${health.releaseCriticalGaps.join(',') || 'none'}`,
255
- action: health.status === 'pass' ? undefined : health.reasons.join(' ')
374
+ message: `status=${health.status} baseline=${health.baselineDomains.length}/${health.requiredProfessionalDomains.length} packs=${health.materialPacks} active=${health.activeDomains.join(',') || 'none'} sources_quarantined=${health.sources.quarantined} sources_denied=${health.sources.denied} evidence_candidate=${health.evidence.candidate} adoptions=${health.adoptions.adopted}/${health.adoptions.rejected}/${health.adoptions.unresolved} adoption_closures=${health.adoptions.releaseCriticalClosures.join(',') || 'none'} release_critical_gaps=${health.releaseCriticalGaps.join(',') || 'none'}`,
375
+ action: health.status === 'pass' ? undefined : `sdd status --branch ${snapshot.status.branch} --compact-json`
256
376
  }];
257
377
  }
258
378
 
@@ -285,6 +405,21 @@ function inspectStageTeamRuntime(snapshot: DoctorProjectStatusSnapshot): DoctorC
285
405
  }];
286
406
  }
287
407
 
408
+ function inspectSpecCollaborationRuntime(snapshot: DoctorProjectStatusSnapshot): DoctorCheck[] {
409
+ if (!snapshot.status) {
410
+ return unavailableRuntimeCheck('spec_collaboration_runtime', 'spec collaboration runtime', snapshot.error);
411
+ }
412
+ const health = snapshot.status.specCollaborationHealth;
413
+ const level = health.status === 'blocked' || health.status === 'rejected' || health.status === 'incompatible' ? 'FAIL' : health.status === 'needs_clarification' ? 'WARN' : 'PASS';
414
+ return [{
415
+ level,
416
+ check: 'spec_collaboration_runtime',
417
+ message: `status=${health.status} projections=${health.projectionCount} clarification=${health.latestClarificationGateId ?? 'none'} handoff=${health.latestHandoffId ?? 'none'} rejection=${health.latestRejectionReason ?? 'none'}`,
418
+ action: level === 'PASS' ? undefined : health.reasons.join(' ')
419
+ }];
420
+ }
421
+
422
+
288
423
  function inspectDurableGapRuntime(snapshot: DoctorProjectStatusSnapshot): DoctorCheck[] {
289
424
  if (!snapshot.status) {
290
425
  return unavailableRuntimeCheck('durable_gap_runtime', 'durable gap runtime', snapshot.error);
@@ -41,16 +41,24 @@ export async function lookupEvidence(projectRoot: string, filters: EvidenceLooku
41
41
  generatedAt: new Date().toISOString(),
42
42
  retrievalMemoryOnly: true,
43
43
  gateTruthAuthority: false,
44
- reason: 'Evidence Lookup is retrieval memory over SQLite metadata and payload refs; PASS, verify, and sync-back authority must use runtime evidence gates.',
44
+ reason: 'Evidence Lookup is retrieval memory over SQLite metadata and payload refs; PASS, verify, and truth-alignment authority must use runtime evidence gates.',
45
45
  filters,
46
46
  payloads: filtered,
47
47
  resolvedPayloads,
48
- counts: {
49
- active: filtered.filter((payload) => payload.status === 'active').length,
50
- candidate: filtered.filter((payload) => payload.status === 'candidate').length,
51
- rejected: filtered.filter((payload) => payload.status === 'rejected').length,
52
- superseded: filtered.filter((payload) => payload.status === 'superseded').length
53
- }
48
+ counts: countByStatus(filtered)
49
+ };
50
+ }
51
+
52
+ function countByStatus(payloads: RuntimeArtifactPayloadRecord[]): Record<RuntimeArtifactPayloadStatus, number> {
53
+ return {
54
+ active: payloads.filter((payload) => payload.status === 'active').length,
55
+ candidate: payloads.filter((payload) => payload.status === 'candidate').length,
56
+ partial: payloads.filter((payload) => payload.status === 'partial').length,
57
+ active_attempt: payloads.filter((payload) => payload.status === 'active_attempt').length,
58
+ rejected: payloads.filter((payload) => payload.status === 'rejected').length,
59
+ superseded: payloads.filter((payload) => payload.status === 'superseded').length,
60
+ quarantined: payloads.filter((payload) => payload.status === 'quarantined').length,
61
+ stale: payloads.filter((payload) => payload.status === 'stale').length
54
62
  };
55
63
  }
56
64
 
@@ -42,7 +42,6 @@ export interface UnifiedTestEvidenceRun {
42
42
  commands: TestCommandEvidence[];
43
43
  acceptanceCoverage: AcceptanceEvidenceCoverage[];
44
44
  capabilityEvidence: CapabilityEvidenceClassification[];
45
- syncBackReady: boolean;
46
45
  gaps: string[];
47
46
  next: string;
48
47
  generatedAt: string;
@@ -10,14 +10,22 @@ import { writeArtifact } from '../run-state/artifacts.js';
10
10
  import { readRunState } from '../run-state/run-state.js';
11
11
  import { validResultArtifact, validTaskMarkdown, writeBranchDocs } from '../test-support/fixtures.js';
12
12
  import { writeVerifyContract } from '../verification/verify-contract.js';
13
+ import { evaluateLifecycleRiskDecisionForModel, recordLifecycleRiskDecisionProjection } from '../risk.js';
14
+ import { parseSddBranch } from '../sdd-docs/task-parser.js';
13
15
  import { inspectBackgroundExecutor, runBackgroundExecutor } from './background-executor.js';
14
16
 
17
+ async function seedLifecycleRiskDecision(root: string, branch: string): Promise<void> {
18
+ const model = await parseSddBranch(root, branch);
19
+ await recordLifecycleRiskDecisionProjection(root, evaluateLifecycleRiskDecisionForModel(branch, model));
20
+ }
21
+
15
22
  test('background executor claims one delegation and persists background run state', async () => {
16
23
  const root = await mkdtemp(path.join(tmpdir(), 'sdd-background-claim-'));
17
24
  try {
18
25
  await initProject(root);
19
26
  await writeBranchDocs(root, 'master', validTaskMarkdown('B1', []));
20
27
  await writeVerifyContract(root, { branch: 'master', branchSource: 'cli_option', force: true });
28
+ await seedLifecycleRiskDecision(root, 'master');
21
29
 
22
30
  const result = await runBackgroundExecutor(root, { taskId: 'B1' });
23
31
  const state = await readRunState(root, result.runId);
@@ -42,6 +50,7 @@ test('background executor ingests supplied artifact and reaches terminal state',
42
50
  await initProject(root);
43
51
  await writeBranchDocs(root, 'master', validTaskMarkdown('B1', []));
44
52
  await writeVerifyContract(root, { branch: 'master', branchSource: 'cli_option', force: true });
53
+ await seedLifecycleRiskDecision(root, 'master');
45
54
 
46
55
  const claimed = await runBackgroundExecutor(root, { taskId: 'B1' });
47
56
  await writeArtifact(root, claimed.runId, 'implementer-B1.md', validResultArtifact('implementer', 'B1', 'PASS', 'artifacts/implementer-B1.md'));
@@ -66,17 +75,53 @@ test('background executor ingests supplied artifact and reaches terminal state',
66
75
  }
67
76
  });
68
77
 
78
+ test('background executor replays changed terminal artifact into a new attempt', async () => {
79
+ const root = await mkdtemp(path.join(tmpdir(), 'sdd-background-replay-'));
80
+ try {
81
+ await initProject(root);
82
+ await writeBranchDocs(root, 'master', validTaskMarkdown('B1', []));
83
+ await writeVerifyContract(root, { branch: 'master', branchSource: 'cli_option', force: true });
84
+ await seedLifecycleRiskDecision(root, 'master');
85
+
86
+ const claimed = await runBackgroundExecutor(root, { taskId: 'B1' });
87
+ await writeArtifact(root, claimed.runId, 'implementer-B1.md', validResultArtifact('implementer', 'B1', 'PASS', 'artifacts/implementer-B1.md'));
88
+ const completed = await runBackgroundExecutor(root, {
89
+ runId: claimed.runId,
90
+ taskId: 'B1',
91
+ artifactPath: 'artifacts/implementer-B1.md'
92
+ });
93
+ await writeArtifact(root, claimed.runId, 'implementer-B1.md', `${validResultArtifact('implementer', 'B1', 'PASS', 'artifacts/implementer-B1.md')}\nReplay evidence.\n`);
94
+ const replayed = await runBackgroundExecutor(root, {
95
+ runId: claimed.runId,
96
+ taskId: 'B1',
97
+ artifactPath: 'artifacts/implementer-B1.md'
98
+ });
99
+ const state = await readRunState(root, claimed.runId);
100
+
101
+ assert.equal(completed.status, 'completed');
102
+ assert.equal(replayed.status, 'completed');
103
+ assert.equal(replayed.delegationId, 'B-B1-implementer-001');
104
+ assert.equal(replayed.ingestion?.delegationId, 'B-B1-implementer-002');
105
+ assert.equal(replayed.ingestion?.retryOf, 'B-B1-implementer-001');
106
+ assert.equal(state.delegations['B-B1-implementer-001']?.status, 'COMPLETED');
107
+ assert.equal(state.delegations['B-B1-implementer-002']?.status, 'COMPLETED');
108
+ } finally {
109
+ await rm(root, { recursive: true, force: true });
110
+ }
111
+ });
112
+
69
113
  test('claude code subagent worker spawns host process and ingests stdout artifact', async () => {
70
114
  const root = await mkdtemp(path.join(tmpdir(), 'sdd-background-claude-host-'));
71
115
  try {
72
116
  await initProject(root);
73
117
  await writeBranchDocs(root, 'master', validTaskMarkdown('B1', []));
74
118
  await writeVerifyContract(root, { branch: 'master', branchSource: 'cli_option', force: true });
119
+ await seedLifecycleRiskDecision(root, 'master');
75
120
  const hostScript = path.join(root, 'fake-claude-host.mjs');
76
121
  await writeFile(hostScript, [
77
122
  "const prompt = process.argv[2] ?? '';",
78
123
  "if (!prompt.includes('Queue item id:')) process.exit(2);",
79
- "process.stdout.write('# implementer result\\n\\n```sdd-result\\ncontract: sdd-result-v1\\nversion: 1.3.0\\nagent: implementer\\ntask: B1\\nstatus: PASS\\nartifacts:\\n - artifacts/implementer-B1.md\\n```\\n');"
124
+ "process.stdout.write('# implementer result\\n\\n```sdd-result\\ncontract: sdd-result-v1\\nversion: 1.3.0\\nagent: implementer\\ntask: B1\\nstatus: PASS\\nartifacts:\\n - .sdd/runs/master/do/implementer-B1.md\\n```\\n');"
80
125
  ].join('\n'), 'utf8');
81
126
 
82
127
  const completed = await runBackgroundExecutor(root, {
@@ -90,7 +135,7 @@ test('claude code subagent worker spawns host process and ingests stdout artifac
90
135
 
91
136
  assert.equal(completed.status, 'completed');
92
137
  assert.equal(completed.hostInvocation?.exitCode, 0);
93
- assert.equal(completed.hostInvocation?.artifactPath, 'artifacts/implementer-B1.md');
138
+ assert.equal(completed.hostInvocation?.artifactPath, '.sdd/runs/master/do/implementer-B1.md');
94
139
  assert.equal(completed.ingestion?.delegationStatus, 'COMPLETED');
95
140
  assert.equal(state.delegations['B-B1-implementer-001']?.status, 'COMPLETED');
96
141
  assert.equal(inspection.terminalDelegations, 1);
@@ -106,6 +151,7 @@ test('background executor blocks invalid artifact evidence instead of completing
106
151
  await initProject(root);
107
152
  await writeBranchDocs(root, 'master', validTaskMarkdown('B1', []));
108
153
  await writeVerifyContract(root, { branch: 'master', branchSource: 'cli_option', force: true });
154
+ await seedLifecycleRiskDecision(root, 'master');
109
155
 
110
156
  const claimed = await runBackgroundExecutor(root, { taskId: 'B1' });
111
157
  await writeArtifact(root, claimed.runId, 'implementer-B1.md', '# Missing contract\n');
@@ -131,6 +177,7 @@ test('background executor requires approval for database manual gate and accepts
131
177
  await initProject(root);
132
178
  await writeBranchDocs(root, 'master', validTaskMarkdown('B1', []).replace('risk: []', 'risk:\n - database'));
133
179
  await writeVerifyContract(root, { branch: 'master', branchSource: 'cli_option', force: true });
180
+ await seedLifecycleRiskDecision(root, 'master');
134
181
 
135
182
  const blocked = await runBackgroundExecutor(root, { taskId: 'B1' });
136
183
  assert.equal(blocked.status, 'blocked');
@@ -160,6 +207,7 @@ test('background executor blocks manual handoff worker adapters', async () => {
160
207
  await initProject(root);
161
208
  await writeBranchDocs(root, 'master', validTaskMarkdown('B1', []));
162
209
  await writeVerifyContract(root, { branch: 'master', branchSource: 'cli_option', force: true });
210
+ await seedLifecycleRiskDecision(root, 'master');
163
211
 
164
212
  const result = await runBackgroundExecutor(root, { taskId: 'B1', workerAdapterId: 'manual-handoff-worker' });
165
213
 
@@ -6,7 +6,7 @@ import { createDelegationRecord, isDelegationTerminal } from '../delegation/vali
6
6
  import { listDelegationQueueItems } from '../delegation/queue.js';
7
7
  import { persistDelegation } from '../delegation/run-state.js';
8
8
  import { evaluateGovernancePolicy } from '../governance/policy.js';
9
- import { getRunRelativeArtifactPath, toArtifactRootRelativePath } from '../runtime-paths.js';
9
+ import { normalizeStageEvidenceOrLegacyArtifactRef, toBranchStageEvidenceRef } from '../runtime-paths.js';
10
10
  import { appendEvent } from '../run-state/events.js';
11
11
  import { createRun, readRunState, writeRunState } from '../run-state/run-state.js';
12
12
  import type { DelegationQueueItem } from '../run-state/run-index.js';
@@ -119,10 +119,10 @@ export async function runBackgroundExecutor(projectRoot: string, options: Backgr
119
119
  }
120
120
 
121
121
  const delegationId = options.delegationId ?? `B-${options.taskId}-${agent}-001`;
122
- const expectedArtifact = options.artifactPath ? getRunRelativeArtifactPath(toArtifactRootRelativePath(options.artifactPath)) : `artifacts/${agent}-${options.taskId}.md`;
122
+ const expectedArtifact = options.artifactPath ? normalizeStageEvidenceOrLegacyArtifactRef(options.artifactPath) : toBranchStageEvidenceRef(branch, agent === 'validator' ? 'test' : 'do', `${agent}-${options.taskId}.md`);
123
123
  const existingDelegation = boundRunState.delegations[delegationId];
124
- if (existingDelegation && isDelegationTerminal(existingDelegation.status)) {
125
- issues.push(contractIssue('delegationId', `Delegation ${delegationId} is already terminal.`, 'Create a new delegation id for retry instead of reopening a terminal delegation.'));
124
+ if (existingDelegation && isDelegationTerminal(existingDelegation.status) && !options.artifactPath) {
125
+ issues.push(contractIssue('delegationId', `Delegation ${delegationId} is already terminal.`, 'Rerun with an artifact path to idempotently reingest the same digest or allocate a retry attempt for changed evidence.'));
126
126
  }
127
127
 
128
128
  const governance = await evaluateGovernancePolicy(projectRoot, {
@@ -8,6 +8,8 @@ import { initProject } from '../config/init-project.js';
8
8
  import { readRunState } from '../run-state/run-state.js';
9
9
  import { listRuntimeProjections } from '../storage/runtime-store.js';
10
10
  import { validTaskMarkdown, writeBranchDocs } from '../test-support/fixtures.js';
11
+ import { evaluateLifecycleRiskDecisionForModel, recordLifecycleRiskDecisionProjection } from '../risk.js';
12
+ import { parseSddBranch } from '../sdd-docs/task-parser.js';
11
13
  import { runForegroundSubagents } from './foreground-subagents.js';
12
14
 
13
15
  const hostCommand = [
@@ -20,11 +22,17 @@ const hostCommand = [
20
22
  "process.stdout.write(result + evidence);"
21
23
  ].join('\n');
22
24
 
23
- test('runForegroundSubagents collects all foreground subagent artifacts without lifecycle authority', async () => {
25
+ async function seedLifecycleRiskDecision(root: string, branch: string): Promise<void> {
26
+ const model = await parseSddBranch(root, branch);
27
+ await recordLifecycleRiskDecisionProjection(root, evaluateLifecycleRiskDecisionForModel(branch, model));
28
+ }
29
+
30
+ test('runForegroundSubagents collects non-authoritative foreground artifacts after lifecycle decision', async () => {
24
31
  const root = await mkdtemp(path.join(tmpdir(), 'sdd-foreground-subagents-'));
25
32
  try {
26
33
  await initProject(root);
27
34
  await writeBranchDocs(root, 'feature', validTaskMarkdown('T1', []).replace('packages/core/src/index.ts', 'docs/t1.md'));
35
+ await seedLifecycleRiskDecision(root, 'feature');
28
36
 
29
37
  const result = await runForegroundSubagents(root, {
30
38
  branch: 'feature',
@@ -35,7 +43,7 @@ test('runForegroundSubagents collects all foreground subagent artifacts without
35
43
 
36
44
  assert.equal(result.status, 'completed');
37
45
  assert.deepEqual(result.agents.map((agent) => `${agent.agent}:${agent.status}`), ['reviewer:completed', 'validator:completed']);
38
- assert.equal(result.agents.every((agent) => agent.artifactPath?.startsWith('artifacts/')), true);
46
+ assert.equal(result.agents.every((agent) => agent.artifactPath?.startsWith('.sdd/runs/feature/do/')), true);
39
47
  assert.equal(result.agents.every((agent) => agent.ingestion?.status === 'accepted'), true);
40
48
 
41
49
  const state = await readRunState(root, result.runId);
@@ -74,6 +82,7 @@ test('runForegroundSubagents blocks before host invocation when dependencies are
74
82
  try {
75
83
  await initProject(root);
76
84
  await writeBranchDocs(root, 'feature', `# Tasks\n\n${validTaskMarkdown('DEP1', [])}\n${validTaskMarkdown('DEP2', ['DEP1']).replace('packages/core/src/index.ts', 'docs/dep2.md')}`);
85
+ await seedLifecycleRiskDecision(root, 'feature');
77
86
 
78
87
  const result = await runForegroundSubagents(root, {
79
88
  branch: 'feature',
@@ -13,7 +13,7 @@ import { parseSddBranch } from '../sdd-docs/task-parser.js';
13
13
  import { routeSddTask } from '../router/route-sdd-task.js';
14
14
  import { buildAgentExecutionRecord, writeAgentExecutionRecord } from './agent-execution-records.js';
15
15
  import { invokeClaudeCodeSubagentHost, type HostInvocationCommandOptions, type HostInvocationResult } from './host-invocation.js';
16
- import { getRunRelativeArtifactPath, toArtifactRootRelativePath } from '../runtime-paths.js';
16
+ import { toBranchStageEvidenceRef, toEvidencePayloadFileName } from '../runtime-paths.js';
17
17
  import { recordRuntimeProjection } from '../storage/runtime-store.js';
18
18
  import { recordSubagentDispatchProjection, recordSubagentResultProjection } from '../subagents/runtime.js';
19
19
  import type { SubagentDispatch, SubagentResult } from '../subagents/contracts.js';
@@ -122,7 +122,7 @@ export async function runForegroundSubagents(projectRoot: string, options: Foreg
122
122
 
123
123
  const slots = agents.map((agent, index) => {
124
124
  const delegationId = `F-${options.taskId}-${safeToken(agent)}-${String(index + 1).padStart(3, '0')}`;
125
- const expectedArtifact = getRunRelativeArtifactPath(toArtifactRootRelativePath(`artifacts/${safeToken(agent)}-${options.taskId}-${String(index + 1).padStart(3, '0')}.md`));
125
+ const expectedArtifact = toBranchStageEvidenceRef(branch, 'do', `${safeToken(agent)}-${options.taskId}-${String(index + 1).padStart(3, '0')}.md`);
126
126
  return { agent, delegationId, expectedArtifact };
127
127
  });
128
128
 
@@ -342,7 +342,7 @@ function buildHostFailureDigest(taskId: string, agent: string, delegationId: str
342
342
 
343
343
  async function readArtifactText(projectRoot: string, runId: string, artifactPath: string): Promise<string> {
344
344
  try {
345
- return await readArtifact(projectRoot, runId, toArtifactRootRelativePath(artifactPath));
345
+ return await readArtifact(projectRoot, runId, toEvidencePayloadFileName(artifactPath));
346
346
  } catch {
347
347
  return '';
348
348
  }