@opengsd/gsd-pi 1.1.1-dev.74e8dd1 → 1.1.1-dev.75048e7

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 (329) hide show
  1. package/dist/cli.js +3 -2
  2. package/dist/help-text.js +10 -6
  3. package/dist/resources/.managed-resources-content-hash +1 -1
  4. package/dist/resources/extensions/browser-tools/engine/managed-gsd-browser.js +495 -0
  5. package/dist/resources/extensions/browser-tools/engine/selection.js +16 -0
  6. package/dist/resources/extensions/browser-tools/extension-manifest.json +2 -2
  7. package/dist/resources/extensions/browser-tools/index.js +57 -9
  8. package/dist/resources/extensions/browser-tools/package.json +5 -1
  9. package/dist/resources/extensions/gsd/auto/orchestrator.js +0 -1
  10. package/dist/resources/extensions/gsd/auto-dashboard.js +77 -13
  11. package/dist/resources/extensions/gsd/auto-dispatch.js +16 -0
  12. package/dist/resources/extensions/gsd/auto-post-unit.js +21 -3
  13. package/dist/resources/extensions/gsd/auto-prompts.js +63 -22
  14. package/dist/resources/extensions/gsd/auto-recovery.js +3 -4
  15. package/dist/resources/extensions/gsd/auto-runtime-state.js +3 -0
  16. package/dist/resources/extensions/gsd/auto-tool-tracking.js +1 -1
  17. package/dist/resources/extensions/gsd/auto-unit-tool-scope.js +18 -66
  18. package/dist/resources/extensions/gsd/auto-worktree.js +18 -5
  19. package/dist/resources/extensions/gsd/auto.js +9 -2
  20. package/dist/resources/extensions/gsd/bootstrap/db-tools.js +20 -14
  21. package/dist/resources/extensions/gsd/bootstrap/register-hooks.js +28 -13
  22. package/dist/resources/extensions/gsd/bootstrap/write-gate.js +18 -29
  23. package/dist/resources/extensions/gsd/browser-evidence.js +29 -2
  24. package/dist/resources/extensions/gsd/closeout-consistency-gate.js +61 -0
  25. package/dist/resources/extensions/gsd/commands/handlers/ops.js +2 -2
  26. package/dist/resources/extensions/gsd/commands-handlers.js +76 -11
  27. package/dist/resources/extensions/gsd/commands-mcp-status.js +2 -1
  28. package/dist/resources/extensions/gsd/dashboard-overlay.js +21 -7
  29. package/dist/resources/extensions/gsd/docs/preferences-reference.md +8 -0
  30. package/dist/resources/extensions/gsd/doctor-runtime-checks.js +2 -2
  31. package/dist/resources/extensions/gsd/escalation.js +4 -4
  32. package/dist/resources/extensions/gsd/forensics.js +74 -2
  33. package/dist/resources/extensions/gsd/gsd-db.js +5 -2
  34. package/dist/resources/extensions/gsd/guided-flow.js +118 -175
  35. package/dist/resources/extensions/gsd/mcp-project-config.js +9 -76
  36. package/dist/resources/extensions/gsd/memory-store.js +4 -1
  37. package/dist/resources/extensions/gsd/milestone-closeout.js +3 -1
  38. package/dist/resources/extensions/gsd/pending-auto-start.js +0 -1
  39. package/dist/resources/extensions/gsd/post-unit-hooks.js +9 -0
  40. package/dist/resources/extensions/gsd/preferences-validation.js +39 -0
  41. package/dist/resources/extensions/gsd/prompt-loader.js +7 -0
  42. package/dist/resources/extensions/gsd/prompts/forensics.md +61 -1
  43. package/dist/resources/extensions/gsd/prompts/gate-evaluate.md +3 -1
  44. package/dist/resources/extensions/gsd/prompts/parallel-research-slices.md +3 -1
  45. package/dist/resources/extensions/gsd/prompts/plan-slice.md +1 -1
  46. package/dist/resources/extensions/gsd/prompts/reactive-execute.md +3 -1
  47. package/dist/resources/extensions/gsd/prompts/run-uat.md +25 -21
  48. package/dist/resources/extensions/gsd/prompts/validate-milestone.md +3 -3
  49. package/dist/resources/extensions/gsd/recovery-classification.js +20 -0
  50. package/dist/resources/extensions/gsd/rule-registry.js +428 -52
  51. package/dist/resources/extensions/gsd/state.js +2 -2
  52. package/dist/resources/extensions/gsd/templates/plan.md +3 -1
  53. package/dist/resources/extensions/gsd/tool-contract.js +5 -0
  54. package/dist/resources/extensions/gsd/tool-presentation-plan.js +30 -7
  55. package/dist/resources/extensions/gsd/tools/complete-slice.js +15 -1
  56. package/dist/resources/extensions/gsd/tools/complete-task.js +11 -1
  57. package/dist/resources/extensions/gsd/tools/validate-milestone.js +46 -16
  58. package/dist/resources/extensions/gsd/tools/workflow-tool-executors.js +132 -18
  59. package/dist/resources/extensions/gsd/unit-tool-contracts.js +169 -0
  60. package/dist/resources/extensions/gsd/verdict-parser.js +59 -15
  61. package/dist/resources/extensions/gsd/verification-gate.js +72 -1
  62. package/dist/resources/extensions/gsd/workflow-mcp.js +3 -75
  63. package/dist/resources/extensions/shared/gsd-browser-cli.js +145 -0
  64. package/dist/rtk.d.ts +7 -1
  65. package/dist/rtk.js +27 -11
  66. package/dist/update-check.d.ts +15 -1
  67. package/dist/update-check.js +87 -12
  68. package/dist/update-cmd.d.ts +1 -0
  69. package/dist/update-cmd.js +53 -2
  70. package/dist/web/standalone/.next/BUILD_ID +1 -1
  71. package/dist/web/standalone/.next/app-path-routes-manifest.json +8 -8
  72. package/dist/web/standalone/.next/build-manifest.json +2 -2
  73. package/dist/web/standalone/.next/prerender-manifest.json +3 -3
  74. package/dist/web/standalone/.next/server/app/_global-error.html +1 -1
  75. package/dist/web/standalone/.next/server/app/_global-error.rsc +1 -1
  76. package/dist/web/standalone/.next/server/app/_global-error.segments/_full.segment.rsc +1 -1
  77. package/dist/web/standalone/.next/server/app/_global-error.segments/_global-error/__PAGE__.segment.rsc +1 -1
  78. package/dist/web/standalone/.next/server/app/_global-error.segments/_global-error.segment.rsc +1 -1
  79. package/dist/web/standalone/.next/server/app/_global-error.segments/_head.segment.rsc +1 -1
  80. package/dist/web/standalone/.next/server/app/_global-error.segments/_index.segment.rsc +1 -1
  81. package/dist/web/standalone/.next/server/app/_global-error.segments/_tree.segment.rsc +1 -1
  82. package/dist/web/standalone/.next/server/app/_not-found.html +1 -1
  83. package/dist/web/standalone/.next/server/app/_not-found.rsc +1 -1
  84. package/dist/web/standalone/.next/server/app/_not-found.segments/_full.segment.rsc +1 -1
  85. package/dist/web/standalone/.next/server/app/_not-found.segments/_head.segment.rsc +1 -1
  86. package/dist/web/standalone/.next/server/app/_not-found.segments/_index.segment.rsc +1 -1
  87. package/dist/web/standalone/.next/server/app/_not-found.segments/_not-found/__PAGE__.segment.rsc +1 -1
  88. package/dist/web/standalone/.next/server/app/_not-found.segments/_not-found.segment.rsc +1 -1
  89. package/dist/web/standalone/.next/server/app/_not-found.segments/_tree.segment.rsc +1 -1
  90. package/dist/web/standalone/.next/server/app/api/update/route.js +1 -1
  91. package/dist/web/standalone/.next/server/app/index.html +1 -1
  92. package/dist/web/standalone/.next/server/app/index.rsc +1 -1
  93. package/dist/web/standalone/.next/server/app/index.segments/__PAGE__.segment.rsc +1 -1
  94. package/dist/web/standalone/.next/server/app/index.segments/_full.segment.rsc +1 -1
  95. package/dist/web/standalone/.next/server/app/index.segments/_head.segment.rsc +1 -1
  96. package/dist/web/standalone/.next/server/app/index.segments/_index.segment.rsc +1 -1
  97. package/dist/web/standalone/.next/server/app/index.segments/_tree.segment.rsc +1 -1
  98. package/dist/web/standalone/.next/server/app-paths-manifest.json +8 -8
  99. package/dist/web/standalone/.next/server/chunks/8357.js +1 -1
  100. package/dist/web/standalone/.next/server/middleware-build-manifest.js +1 -1
  101. package/dist/web/standalone/.next/server/pages/404.html +1 -1
  102. package/dist/web/standalone/.next/server/pages/500.html +1 -1
  103. package/dist/web/standalone/.next/server/server-reference-manifest.json +1 -1
  104. package/package.json +4 -2
  105. package/packages/cloud-mcp-gateway/package.json +2 -2
  106. package/packages/contracts/package.json +1 -1
  107. package/packages/daemon/package.json +4 -4
  108. package/packages/gsd-agent-core/dist/agent-session.d.ts +9 -0
  109. package/packages/gsd-agent-core/dist/agent-session.d.ts.map +1 -1
  110. package/packages/gsd-agent-core/dist/agent-session.js +32 -0
  111. package/packages/gsd-agent-core/dist/agent-session.js.map +1 -1
  112. package/packages/gsd-agent-core/dist/index.d.ts +1 -0
  113. package/packages/gsd-agent-core/dist/index.d.ts.map +1 -1
  114. package/packages/gsd-agent-core/dist/index.js +1 -0
  115. package/packages/gsd-agent-core/dist/index.js.map +1 -1
  116. package/packages/gsd-agent-core/dist/session/agent-session-compaction.d.ts +2 -0
  117. package/packages/gsd-agent-core/dist/session/agent-session-compaction.d.ts.map +1 -1
  118. package/packages/gsd-agent-core/dist/session/agent-session-compaction.js +8 -2
  119. package/packages/gsd-agent-core/dist/session/agent-session-compaction.js.map +1 -1
  120. package/packages/gsd-agent-core/dist/session/agent-session-host.d.ts +7 -0
  121. package/packages/gsd-agent-core/dist/session/agent-session-host.d.ts.map +1 -1
  122. package/packages/gsd-agent-core/dist/session/agent-session-host.js.map +1 -1
  123. package/packages/gsd-agent-core/dist/session/agent-session-prompt.d.ts.map +1 -1
  124. package/packages/gsd-agent-core/dist/session/agent-session-prompt.js +69 -1
  125. package/packages/gsd-agent-core/dist/session/agent-session-prompt.js.map +1 -1
  126. package/packages/gsd-agent-core/dist/turn-latency.d.ts +47 -0
  127. package/packages/gsd-agent-core/dist/turn-latency.d.ts.map +1 -0
  128. package/packages/gsd-agent-core/dist/turn-latency.js +123 -0
  129. package/packages/gsd-agent-core/dist/turn-latency.js.map +1 -0
  130. package/packages/gsd-agent-core/package.json +6 -6
  131. package/packages/gsd-agent-modes/dist/modes/interactive/components/__prototype__/gsd-widget-prototype.d.ts +21 -0
  132. package/packages/gsd-agent-modes/dist/modes/interactive/components/__prototype__/gsd-widget-prototype.d.ts.map +1 -0
  133. package/packages/gsd-agent-modes/dist/modes/interactive/components/__prototype__/gsd-widget-prototype.js +213 -0
  134. package/packages/gsd-agent-modes/dist/modes/interactive/components/__prototype__/gsd-widget-prototype.js.map +1 -0
  135. package/packages/gsd-agent-modes/dist/modes/interactive/components/tool-execution.d.ts.map +1 -1
  136. package/packages/gsd-agent-modes/dist/modes/interactive/components/tool-execution.js +5 -0
  137. package/packages/gsd-agent-modes/dist/modes/interactive/components/tool-execution.js.map +1 -1
  138. package/packages/gsd-agent-modes/dist/modes/interactive/controllers/chat-controller.d.ts.map +1 -1
  139. package/packages/gsd-agent-modes/dist/modes/interactive/controllers/chat-controller.js +20 -0
  140. package/packages/gsd-agent-modes/dist/modes/interactive/controllers/chat-controller.js.map +1 -1
  141. package/packages/gsd-agent-modes/dist/modes/interactive/controllers/input-controller.d.ts.map +1 -1
  142. package/packages/gsd-agent-modes/dist/modes/interactive/controllers/input-controller.js +7 -1
  143. package/packages/gsd-agent-modes/dist/modes/interactive/controllers/input-controller.js.map +1 -1
  144. package/packages/gsd-agent-modes/dist/modes/interactive/interactive-command-handlers.d.ts.map +1 -1
  145. package/packages/gsd-agent-modes/dist/modes/interactive/interactive-command-handlers.js +6 -0
  146. package/packages/gsd-agent-modes/dist/modes/interactive/interactive-command-handlers.js.map +1 -1
  147. package/packages/gsd-agent-modes/package.json +7 -7
  148. package/packages/mcp-server/dist/remote-questions.d.ts.map +1 -1
  149. package/packages/mcp-server/dist/remote-questions.js +23 -9
  150. package/packages/mcp-server/dist/remote-questions.js.map +1 -1
  151. package/packages/mcp-server/dist/workflow-tools.js +2 -2
  152. package/packages/mcp-server/dist/workflow-tools.js.map +1 -1
  153. package/packages/mcp-server/package.json +3 -3
  154. package/packages/native/package.json +1 -1
  155. package/packages/pi-agent-core/dist/agent-loop.js +42 -3
  156. package/packages/pi-agent-core/dist/agent-loop.js.map +1 -1
  157. package/packages/pi-agent-core/dist/agent.d.ts +5 -1
  158. package/packages/pi-agent-core/dist/agent.d.ts.map +1 -1
  159. package/packages/pi-agent-core/dist/agent.js +2 -0
  160. package/packages/pi-agent-core/dist/agent.js.map +1 -1
  161. package/packages/pi-agent-core/dist/harness/agent-harness.d.ts.map +1 -1
  162. package/packages/pi-agent-core/dist/harness/agent-harness.js +3 -1
  163. package/packages/pi-agent-core/dist/harness/agent-harness.js.map +1 -1
  164. package/packages/pi-agent-core/dist/harness/types.d.ts +1 -0
  165. package/packages/pi-agent-core/dist/harness/types.d.ts.map +1 -1
  166. package/packages/pi-agent-core/dist/harness/types.js.map +1 -1
  167. package/packages/pi-agent-core/dist/types.d.ts +6 -1
  168. package/packages/pi-agent-core/dist/types.d.ts.map +1 -1
  169. package/packages/pi-agent-core/dist/types.js.map +1 -1
  170. package/packages/pi-agent-core/package.json +1 -1
  171. package/packages/pi-ai/dist/api-registry.d.ts +2 -0
  172. package/packages/pi-ai/dist/api-registry.d.ts.map +1 -1
  173. package/packages/pi-ai/dist/api-registry.js +23 -0
  174. package/packages/pi-ai/dist/api-registry.js.map +1 -1
  175. package/packages/pi-ai/dist/models.generated.d.ts +74 -23
  176. package/packages/pi-ai/dist/models.generated.d.ts.map +1 -1
  177. package/packages/pi-ai/dist/models.generated.js +82 -31
  178. package/packages/pi-ai/dist/models.generated.js.map +1 -1
  179. package/packages/pi-ai/dist/stream.js +6 -6
  180. package/packages/pi-ai/dist/stream.js.map +1 -1
  181. package/packages/pi-ai/package.json +1 -1
  182. package/packages/pi-coding-agent/dist/core/extensions/extension-upstream-types.d.ts +3 -0
  183. package/packages/pi-coding-agent/dist/core/extensions/extension-upstream-types.d.ts.map +1 -1
  184. package/packages/pi-coding-agent/dist/core/extensions/extension-upstream-types.js.map +1 -1
  185. package/packages/pi-coding-agent/dist/core/model-registry.d.ts.map +1 -1
  186. package/packages/pi-coding-agent/dist/core/model-registry.js +2 -2
  187. package/packages/pi-coding-agent/dist/core/model-registry.js.map +1 -1
  188. package/packages/pi-coding-agent/dist/core/tools/bash.js +2 -2
  189. package/packages/pi-coding-agent/dist/core/tools/bash.js.map +1 -1
  190. package/packages/pi-coding-agent/dist/core/tools/edit.d.ts.map +1 -1
  191. package/packages/pi-coding-agent/dist/core/tools/edit.js +3 -2
  192. package/packages/pi-coding-agent/dist/core/tools/edit.js.map +1 -1
  193. package/packages/pi-coding-agent/dist/core/tools/render-utils.d.ts +1 -0
  194. package/packages/pi-coding-agent/dist/core/tools/render-utils.d.ts.map +1 -1
  195. package/packages/pi-coding-agent/dist/core/tools/render-utils.js +6 -0
  196. package/packages/pi-coding-agent/dist/core/tools/render-utils.js.map +1 -1
  197. package/packages/pi-coding-agent/dist/core/tools/write.d.ts.map +1 -1
  198. package/packages/pi-coding-agent/dist/core/tools/write.js +3 -2
  199. package/packages/pi-coding-agent/dist/core/tools/write.js.map +1 -1
  200. package/packages/pi-coding-agent/package.json +7 -7
  201. package/packages/pi-tui/package.json +1 -1
  202. package/packages/rpc-client/package.json +2 -2
  203. package/pkg/package.json +1 -1
  204. package/src/resources/extensions/browser-tools/engine/managed-gsd-browser.ts +579 -0
  205. package/src/resources/extensions/browser-tools/engine/selection.ts +19 -0
  206. package/src/resources/extensions/browser-tools/extension-manifest.json +2 -2
  207. package/src/resources/extensions/browser-tools/index.ts +60 -9
  208. package/src/resources/extensions/browser-tools/package.json +5 -1
  209. package/src/resources/extensions/browser-tools/tests/browser-engine-selection.test.mjs +35 -0
  210. package/src/resources/extensions/browser-tools/tests/managed-gsd-browser-tools.test.mjs +33 -0
  211. package/src/resources/extensions/gsd/auto/orchestrator.ts +0 -1
  212. package/src/resources/extensions/gsd/auto-dashboard.ts +82 -14
  213. package/src/resources/extensions/gsd/auto-dispatch.ts +19 -0
  214. package/src/resources/extensions/gsd/auto-post-unit.ts +28 -2
  215. package/src/resources/extensions/gsd/auto-prompts.ts +97 -15
  216. package/src/resources/extensions/gsd/auto-recovery.ts +3 -3
  217. package/src/resources/extensions/gsd/auto-runtime-state.ts +4 -0
  218. package/src/resources/extensions/gsd/auto-tool-tracking.ts +1 -1
  219. package/src/resources/extensions/gsd/auto-unit-tool-scope.ts +43 -74
  220. package/src/resources/extensions/gsd/auto-worktree.ts +23 -5
  221. package/src/resources/extensions/gsd/auto.ts +12 -2
  222. package/src/resources/extensions/gsd/bootstrap/db-tools.ts +20 -14
  223. package/src/resources/extensions/gsd/bootstrap/register-hooks.ts +32 -13
  224. package/src/resources/extensions/gsd/bootstrap/write-gate.ts +50 -54
  225. package/src/resources/extensions/gsd/browser-evidence.ts +26 -2
  226. package/src/resources/extensions/gsd/closeout-consistency-gate.ts +137 -0
  227. package/src/resources/extensions/gsd/commands/handlers/ops.ts +2 -2
  228. package/src/resources/extensions/gsd/commands-handlers.ts +76 -11
  229. package/src/resources/extensions/gsd/commands-mcp-status.ts +2 -1
  230. package/src/resources/extensions/gsd/dashboard-overlay.ts +28 -7
  231. package/src/resources/extensions/gsd/docs/preferences-reference.md +8 -0
  232. package/src/resources/extensions/gsd/doctor-runtime-checks.ts +2 -2
  233. package/src/resources/extensions/gsd/escalation.ts +4 -4
  234. package/src/resources/extensions/gsd/forensics.ts +99 -5
  235. package/src/resources/extensions/gsd/gsd-db.ts +5 -2
  236. package/src/resources/extensions/gsd/guided-flow.ts +214 -216
  237. package/src/resources/extensions/gsd/mcp-project-config.ts +13 -78
  238. package/src/resources/extensions/gsd/memory-store.ts +4 -1
  239. package/src/resources/extensions/gsd/milestone-closeout.ts +3 -1
  240. package/src/resources/extensions/gsd/pending-auto-start.ts +0 -2
  241. package/src/resources/extensions/gsd/post-unit-hooks.ts +14 -1
  242. package/src/resources/extensions/gsd/preferences-validation.ts +36 -0
  243. package/src/resources/extensions/gsd/prompt-loader.ts +8 -0
  244. package/src/resources/extensions/gsd/prompts/forensics.md +61 -1
  245. package/src/resources/extensions/gsd/prompts/gate-evaluate.md +3 -1
  246. package/src/resources/extensions/gsd/prompts/parallel-research-slices.md +3 -1
  247. package/src/resources/extensions/gsd/prompts/plan-slice.md +1 -1
  248. package/src/resources/extensions/gsd/prompts/reactive-execute.md +3 -1
  249. package/src/resources/extensions/gsd/prompts/run-uat.md +25 -21
  250. package/src/resources/extensions/gsd/prompts/validate-milestone.md +3 -3
  251. package/src/resources/extensions/gsd/recovery-classification.ts +20 -0
  252. package/src/resources/extensions/gsd/rule-registry.ts +558 -58
  253. package/src/resources/extensions/gsd/rule-types.ts +2 -0
  254. package/src/resources/extensions/gsd/state.ts +2 -2
  255. package/src/resources/extensions/gsd/templates/plan.md +3 -1
  256. package/src/resources/extensions/gsd/tests/auto-dashboard.test.ts +105 -4
  257. package/src/resources/extensions/gsd/tests/auto-orchestrator.test.ts +37 -0
  258. package/src/resources/extensions/gsd/tests/auto-recovery.test.ts +10 -2
  259. package/src/resources/extensions/gsd/tests/auto-start-bootstrap-await-3420.test.ts +4 -1
  260. package/src/resources/extensions/gsd/tests/auto-warning-noise-regression.test.ts +12 -2
  261. package/src/resources/extensions/gsd/tests/browser-evidence.test.ts +142 -0
  262. package/src/resources/extensions/gsd/tests/check-auto-start-pending-gate.test.ts +9 -15
  263. package/src/resources/extensions/gsd/tests/check-auto-start-ready-guard.test.ts +26 -16
  264. package/src/resources/extensions/gsd/tests/commands-dispatcher-unmerged-milestone.test.ts +21 -0
  265. package/src/resources/extensions/gsd/tests/complete-milestone-excerpt.test.ts +30 -0
  266. package/src/resources/extensions/gsd/tests/complete-slice-verification-gate.test.ts +42 -0
  267. package/src/resources/extensions/gsd/tests/dashboard-overlay.test.ts +45 -0
  268. package/src/resources/extensions/gsd/tests/deep-planning-mode-dispatch.test.ts +53 -0
  269. package/src/resources/extensions/gsd/tests/discuss-milestone-structured-questions.test.ts +31 -0
  270. package/src/resources/extensions/gsd/tests/dispatch-complete-milestone-guard.test.ts +40 -1
  271. package/src/resources/extensions/gsd/tests/doctor-runtime-checks.test.ts +27 -0
  272. package/src/resources/extensions/gsd/tests/escalation.test.ts +16 -27
  273. package/src/resources/extensions/gsd/tests/forensics-issue-routing.test.ts +20 -0
  274. package/src/resources/extensions/gsd/tests/forensics-prompt-rendering.test.ts +3 -0
  275. package/src/resources/extensions/gsd/tests/forensics-tool-scope.test.ts +69 -0
  276. package/src/resources/extensions/gsd/tests/gate-1b-orphan-discrimination.test.ts +31 -79
  277. package/src/resources/extensions/gsd/tests/guided-discuss-milestone-prompt-rendering.test.ts +40 -1
  278. package/src/resources/extensions/gsd/tests/guided-dispatch-root.test.ts +86 -0
  279. package/src/resources/extensions/gsd/tests/guided-flow-session-isolation.test.ts +5 -3
  280. package/src/resources/extensions/gsd/tests/guided-flow-state-rebuild.test.ts +40 -4
  281. package/src/resources/extensions/gsd/tests/guided-flow.test.ts +12 -9
  282. package/src/resources/extensions/gsd/tests/integration/auto-recovery.test.ts +4 -4
  283. package/src/resources/extensions/gsd/tests/integration/auto-worktree-milestone-merge.test.ts +8 -0
  284. package/src/resources/extensions/gsd/tests/integration/parallel-merge.test.ts +16 -0
  285. package/src/resources/extensions/gsd/tests/integration/run-uat.test.ts +72 -10
  286. package/src/resources/extensions/gsd/tests/mcp-project-config.test.ts +32 -0
  287. package/src/resources/extensions/gsd/tests/mcp-status.test.ts +2 -0
  288. package/src/resources/extensions/gsd/tests/memory-maintenance.test.ts +39 -8
  289. package/src/resources/extensions/gsd/tests/merge-closeout-consistency-gate.test.ts +63 -0
  290. package/src/resources/extensions/gsd/tests/merge-db-cycle.test.ts +10 -1
  291. package/src/resources/extensions/gsd/tests/milestone-closeout.test.ts +9 -1
  292. package/src/resources/extensions/gsd/tests/new-milestone-discuss-routing.test.ts +3 -3
  293. package/src/resources/extensions/gsd/tests/plan-slice-prompt.test.ts +9 -0
  294. package/src/resources/extensions/gsd/tests/post-unit-hooks.test.ts +157 -0
  295. package/src/resources/extensions/gsd/tests/post-unit-retry-on-orchestrator-bridge.test.ts +179 -0
  296. package/src/resources/extensions/gsd/tests/preferences.test.ts +29 -0
  297. package/src/resources/extensions/gsd/tests/prompt-contracts.test.ts +73 -1
  298. package/src/resources/extensions/gsd/tests/prompt-loader-extension-dir.test.ts +14 -0
  299. package/src/resources/extensions/gsd/tests/queued-discuss-fast-path.test.ts +7 -8
  300. package/src/resources/extensions/gsd/tests/register-hooks-depth-verification.test.ts +44 -0
  301. package/src/resources/extensions/gsd/tests/rule-registry.test.ts +75 -0
  302. package/src/resources/extensions/gsd/tests/run-uat-composer.test.ts +4 -0
  303. package/src/resources/extensions/gsd/tests/runtime-invariant-modules.test.ts +36 -0
  304. package/src/resources/extensions/gsd/tests/session-start-footer.test.ts +100 -0
  305. package/src/resources/extensions/gsd/tests/state-reconciliation-drift.test.ts +139 -0
  306. package/src/resources/extensions/gsd/tests/token-tool-gating.test.ts +4 -4
  307. package/src/resources/extensions/gsd/tests/tool-invocation-error-loop-break.test.ts +19 -0
  308. package/src/resources/extensions/gsd/tests/tool-param-optionality.test.ts +7 -1
  309. package/src/resources/extensions/gsd/tests/validate-milestone-prompt-verification-classes.test.ts +6 -3
  310. package/src/resources/extensions/gsd/tests/validate-milestone-write-order.test.ts +133 -0
  311. package/src/resources/extensions/gsd/tests/verification-gate.test.ts +51 -0
  312. package/src/resources/extensions/gsd/tests/workflow-tool-executors.test.ts +410 -0
  313. package/src/resources/extensions/gsd/tests/write-gate-planning-unit.test.ts +15 -0
  314. package/src/resources/extensions/gsd/tool-contract.ts +6 -0
  315. package/src/resources/extensions/gsd/tool-presentation-plan.ts +63 -7
  316. package/src/resources/extensions/gsd/tools/complete-slice.ts +14 -1
  317. package/src/resources/extensions/gsd/tools/complete-task.ts +20 -2
  318. package/src/resources/extensions/gsd/tools/validate-milestone.ts +46 -15
  319. package/src/resources/extensions/gsd/tools/workflow-tool-executors.ts +163 -20
  320. package/src/resources/extensions/gsd/types.ts +69 -5
  321. package/src/resources/extensions/gsd/unit-tool-contracts.ts +186 -0
  322. package/src/resources/extensions/gsd/verdict-parser.ts +54 -13
  323. package/src/resources/extensions/gsd/verification-gate.ts +87 -1
  324. package/src/resources/extensions/gsd/workflow-mcp.ts +3 -75
  325. package/src/resources/extensions/shared/gsd-browser-cli.ts +172 -0
  326. package/src/resources/extensions/gsd/tests/gate-1b-recovery-bound-corrections.test.ts +0 -246
  327. package/src/resources/extensions/gsd/tests/gate-1b-recovery-bound.test.ts +0 -218
  328. /package/dist/web/standalone/.next/static/{eRWf-RI9bzbrwEurm_3uI → h4TGni4xJzlZjGkxaT6uU}/_buildManifest.js +0 -0
  329. /package/dist/web/standalone/.next/static/{eRWf-RI9bzbrwEurm_3uI → h4TGni4xJzlZjGkxaT6uU}/_ssgManifest.js +0 -0
@@ -1,14 +1,17 @@
1
- import { createHash } from "node:crypto";
2
1
  import { existsSync, mkdirSync, readFileSync, writeFileSync } from "node:fs";
3
- import { createRequire } from "node:module";
4
- import { basename, resolve } from "node:path";
2
+ import { resolve } from "node:path";
5
3
  import { fileURLToPath } from "node:url";
6
4
 
5
+ import {
6
+ GSD_BROWSER_MCP_SERVER_NAME,
7
+ resolveBundledGsdBrowserCliPath,
8
+ resolveGsdBrowserMcpLaunchConfig,
9
+ } from "../shared/gsd-browser-cli.js";
7
10
  import { assertSafeDirectory } from "./validate-directory.js";
8
11
  import { detectWorkflowMcpLaunchConfig } from "./workflow-mcp.js";
9
12
 
10
13
  export const GSD_WORKFLOW_MCP_SERVER_NAME = "gsd-workflow";
11
- export const GSD_BROWSER_MCP_SERVER_NAME = "gsd-browser";
14
+ export { GSD_BROWSER_MCP_SERVER_NAME, resolveBundledGsdBrowserCliPath };
12
15
 
13
16
  export interface ProjectMcpServerConfig {
14
17
  command?: string;
@@ -59,31 +62,6 @@ export function resolveBundledGsdCliPath(env: NodeJS.ProcessEnv = process.env):
59
62
  return null;
60
63
  }
61
64
 
62
- export function resolveBundledGsdBrowserCliPath(env: NodeJS.ProcessEnv = process.env): string | null {
63
- const explicit = env.GSD_BROWSER_CLI_PATH?.trim() || env.GSD_BROWSER_BIN_PATH?.trim();
64
- if (explicit) return explicit;
65
-
66
- try {
67
- const requireFromHere = createRequire(import.meta.url);
68
- const packageJsonPath = requireFromHere.resolve("@opengsd/gsd-browser/package.json");
69
- const candidate = resolve(packageJsonPath, "..", "bin", "gsd-browser");
70
- if (existsSync(candidate)) return candidate;
71
- } catch {
72
- // Fall through to path candidates for source/dist layouts.
73
- }
74
-
75
- const candidates = [
76
- resolve(fileURLToPath(new URL("../../../../node_modules/@opengsd/gsd-browser/bin/gsd-browser", import.meta.url))),
77
- resolve(fileURLToPath(new URL("../../../../node_modules/.bin/gsd-browser", import.meta.url))),
78
- ];
79
-
80
- for (const candidate of candidates) {
81
- if (existsSync(candidate)) return candidate;
82
- }
83
-
84
- return null;
85
- }
86
-
87
65
  export function buildProjectWorkflowMcpServerConfig(
88
66
  projectRoot: string,
89
67
  env: NodeJS.ProcessEnv = process.env,
@@ -119,31 +97,12 @@ function buildProjectWorkflowMcpServerSpec(
119
97
  };
120
98
  }
121
99
 
122
- function parseJsonEnv<T>(env: NodeJS.ProcessEnv, name: string): T | undefined {
123
- const raw = env[name];
124
- if (!raw) return undefined;
125
- try {
126
- return JSON.parse(raw) as T;
127
- } catch {
128
- throw new Error(`Invalid JSON in ${name}`);
129
- }
130
- }
131
-
132
100
  function isEnvDisabled(value: string | undefined): boolean {
133
101
  if (!value) return false;
134
102
  const normalized = value.trim().toLowerCase();
135
103
  return normalized === "0" || normalized === "false" || normalized === "off";
136
104
  }
137
105
 
138
- function buildBrowserSessionName(projectRoot: string): string {
139
- const resolvedProjectRoot = resolve(projectRoot);
140
- const base = basename(resolvedProjectRoot)
141
- .replace(/[^a-zA-Z0-9._-]+/g, "-")
142
- .replace(/^-+|-+$/g, "") || "project";
143
- const hash = createHash("sha1").update(resolvedProjectRoot).digest("hex").slice(0, 8);
144
- return `gsd-${base}-${hash}`;
145
- }
146
-
147
106
  export function buildProjectBrowserMcpServerConfig(
148
107
  projectRoot: string,
149
108
  env: NodeJS.ProcessEnv = process.env,
@@ -157,39 +116,15 @@ function buildProjectBrowserMcpServerSpec(
157
116
  ): ProjectMcpServerSpec | null {
158
117
  if (isEnvDisabled(env.GSD_BROWSER_MCP_ENABLED)) return null;
159
118
 
160
- const resolvedProjectRoot = resolve(projectRoot);
161
- const serverName = env.GSD_BROWSER_MCP_NAME?.trim() || GSD_BROWSER_MCP_SERVER_NAME;
162
- const explicitArgs = parseJsonEnv<unknown>(env, "GSD_BROWSER_MCP_ARGS");
163
- const explicitEnv = parseJsonEnv<Record<string, string>>(env, "GSD_BROWSER_MCP_ENV");
164
- const explicitCommand = env.GSD_BROWSER_MCP_COMMAND?.trim();
165
- const explicitCliPath = env.GSD_BROWSER_CLI_PATH?.trim() || env.GSD_BROWSER_BIN_PATH?.trim();
166
- const bundledCliPath = !explicitCommand && !explicitCliPath ? resolveBundledGsdBrowserCliPath(env) : null;
167
- const command =
168
- explicitCommand
169
- || explicitCliPath
170
- || (bundledCliPath ? process.execPath : undefined)
171
- || "gsd-browser";
172
- const args = Array.isArray(explicitArgs) && explicitArgs.length > 0
173
- ? explicitArgs.map(String)
174
- : [
175
- ...(bundledCliPath ? [bundledCliPath] : []),
176
- "mcp",
177
- "--session",
178
- buildBrowserSessionName(resolvedProjectRoot),
179
- "--identity-scope",
180
- "project",
181
- "--identity-project",
182
- resolvedProjectRoot,
183
- ];
184
- const cwd = env.GSD_BROWSER_MCP_CWD?.trim() || resolvedProjectRoot;
119
+ const launch = resolveGsdBrowserMcpLaunchConfig(projectRoot, env);
185
120
 
186
121
  return {
187
- serverName,
122
+ serverName: launch.serverName,
188
123
  server: {
189
- command,
190
- args,
191
- cwd,
192
- ...(explicitEnv ? { env: explicitEnv } : {}),
124
+ command: launch.command,
125
+ args: launch.args,
126
+ cwd: launch.cwd,
127
+ ...(launch.env ? { env: launch.env } : {}),
193
128
  },
194
129
  };
195
130
  }
@@ -777,7 +777,10 @@ export function decayStaleMemories(thresholdUnits = 20): string[] {
777
777
  const cutoff = row['processed_at'] as string;
778
778
  const affected = adapter.prepare(
779
779
  `SELECT id FROM memories
780
- WHERE superseded_by IS NULL AND updated_at < :cutoff AND confidence > 0.1`,
780
+ WHERE superseded_by IS NULL
781
+ AND updated_at < :cutoff
782
+ AND confidence > 0.1
783
+ AND (structured_fields IS NULL OR structured_fields NOT LIKE '%"sourceDecisionId"%')`,
781
784
  ).all({ ':cutoff': cutoff }).map((r) => r['id'] as string);
782
785
 
783
786
  decayMemoriesBefore(cutoff, new Date().toISOString());
@@ -16,6 +16,7 @@ import { extractVerdict, isAcceptableUatVerdict } from "./verdict-parser.js";
16
16
  import { logWarning } from "./workflow-logger.js";
17
17
  import { hasImplementationArtifacts } from "./milestone-implementation-evidence.js";
18
18
  import { buildCompleteMilestonePrompt } from "./auto-prompts.js";
19
+ import { checkCloseoutConsistencyGate } from "./closeout-consistency-gate.js";
19
20
  import type { DispatchAction, DispatchContext } from "./auto-dispatch.js";
20
21
  import {
21
22
  commitPendingMilestoneCloseoutChanges,
@@ -37,7 +38,8 @@ export async function isMilestoneCloseoutSettled(mid: string, basePath: string):
37
38
  if (isDbAvailable()) {
38
39
  const milestone = getMilestone(mid);
39
40
  if (milestone && isClosedStatus(milestone.status)) {
40
- if (verifyExpectedArtifact("complete-milestone", mid, basePath)) {
41
+ const closeoutGate = checkCloseoutConsistencyGate(mid, { refreshFromDisk: true });
42
+ if (closeoutGate.ok && verifyExpectedArtifact("complete-milestone", mid, basePath)) {
41
43
  return true;
42
44
  }
43
45
  }
@@ -14,7 +14,6 @@ export interface PendingAutoStartEntry {
14
14
  createdAt: number;
15
15
  readyRejectCount?: number;
16
16
  scope: MilestoneScope;
17
- planBlockedRecoveryCount: number;
18
17
  r3bRecoveryCount: number;
19
18
  }
20
19
 
@@ -51,7 +50,6 @@ export function setPendingAutoStart(basePath: string, entry: PendingAutoStartInp
51
50
  const scope = scopeMilestone(ws, entry.milestoneId);
52
51
  pendingAutoStartMap.set(basePath, {
53
52
  createdAt: Date.now(),
54
- planBlockedRecoveryCount: 0,
55
53
  r3bRecoveryCount: 0,
56
54
  ...entry,
57
55
  scope,
@@ -9,6 +9,7 @@ import type {
9
9
  HookDispatchResult,
10
10
  PreDispatchResult,
11
11
  HookStatusEntry,
12
+ PostUnitGateBlock,
12
13
  } from "./types.js";
13
14
  import { getOrCreateRegistry, resolveHookArtifactPath } from "./rule-registry.js";
14
15
 
@@ -33,10 +34,22 @@ export function isRetryPending(): boolean {
33
34
  return getOrCreateRegistry().isRetryPending();
34
35
  }
35
36
 
36
- export function consumeRetryTrigger(): { unitType: string; unitId: string; retryArtifact: string } | null {
37
+ export function consumeRetryTrigger(): { unitType: string; unitId: string; retryArtifact?: string } | null {
37
38
  return getOrCreateRegistry().consumeRetryTrigger();
38
39
  }
39
40
 
41
+ export function consumeHookFailure(): { hookName: string; unitType: string; unitId: string; reason: string } | null {
42
+ return getOrCreateRegistry().consumeHookFailure();
43
+ }
44
+
45
+ export function isGateBlockPending(): boolean {
46
+ return getOrCreateRegistry().isGateBlockPending();
47
+ }
48
+
49
+ export function consumeGateBlock(): PostUnitGateBlock | null {
50
+ return getOrCreateRegistry().consumeGateBlock();
51
+ }
52
+
40
53
  export function resetHookState(): void {
41
54
  getOrCreateRegistry().resetState();
42
55
  }
@@ -29,6 +29,14 @@ const VALID_UOK_TURN_ACTIONS = new Set<"commit" | "snapshot" | "status-only">([
29
29
  "snapshot",
30
30
  "status-only",
31
31
  ]);
32
+ const VALID_POST_UNIT_HOOK_CRITICALITIES = new Set(["advisory", "blocking"]);
33
+ const VALID_POST_UNIT_HOOK_ON_BLOCK_ACTIONS = new Set([
34
+ "retry-unit",
35
+ "retry-task",
36
+ "queue-task",
37
+ "queue-slice",
38
+ "pause",
39
+ ]);
32
40
 
33
41
  export function validatePreferences(preferences: GSDPreferences): {
34
42
  preferences: GSDPreferences;
@@ -486,9 +494,37 @@ export function validatePreferences(preferences: GSDPreferences): {
486
494
  if (typeof hook.artifact === "string" && hook.artifact.trim()) {
487
495
  validHook.artifact = hook.artifact.trim();
488
496
  }
497
+ if (hook.criticality !== undefined) {
498
+ const criticality = typeof hook.criticality === "string" ? hook.criticality.trim() : "";
499
+ if (VALID_POST_UNIT_HOOK_CRITICALITIES.has(criticality)) {
500
+ validHook.criticality = criticality as PostUnitHookConfig["criticality"];
501
+ } else {
502
+ errors.push(`post_unit_hooks "${name}" invalid criticality: ${String(hook.criticality)}`);
503
+ }
504
+ }
489
505
  if (typeof hook.retry_on === "string" && hook.retry_on.trim()) {
490
506
  validHook.retry_on = hook.retry_on.trim();
491
507
  }
508
+ if (hook.on_block !== undefined) {
509
+ if (!hook.on_block || typeof hook.on_block !== "object") {
510
+ errors.push(`post_unit_hooks "${name}" on_block must be an object`);
511
+ } else {
512
+ const onBlock = hook.on_block as unknown as Record<string, unknown>;
513
+ const action = typeof onBlock.action === "string" ? onBlock.action.trim() : "";
514
+ if (!VALID_POST_UNIT_HOOK_ON_BLOCK_ACTIONS.has(action)) {
515
+ errors.push(`post_unit_hooks "${name}" invalid on_block action: ${String(onBlock.action)}`);
516
+ } else {
517
+ validHook.on_block = { action: action as NonNullable<PostUnitHookConfig["on_block"]>["action"] };
518
+ if (typeof onBlock.artifact === "string" && onBlock.artifact.trim()) {
519
+ validHook.on_block.artifact = onBlock.artifact.trim();
520
+ }
521
+ }
522
+ }
523
+ }
524
+ if (validHook.criticality === "blocking" && !validHook.artifact) {
525
+ errors.push(`post_unit_hooks "${name}" criticality blocking requires artifact`);
526
+ continue;
527
+ }
492
528
  if (typeof hook.agent === "string" && hook.agent.trim()) {
493
529
  validHook.agent = hook.agent.trim();
494
530
  }
@@ -33,6 +33,10 @@ function hasRequiredExtensionAssets(rootDir: string, exists: ExistsFn = existsSy
33
33
  );
34
34
  }
35
35
 
36
+ function isSourceExtensionDir(moduleDir: string): boolean {
37
+ return moduleDir.replaceAll("\\", "/").endsWith("/src/resources/extensions/gsd");
38
+ }
39
+
36
40
  export function resolveExtensionDirFromCandidates(
37
41
  moduleDir: string,
38
42
  agentGsdDir: string,
@@ -41,6 +45,10 @@ export function resolveExtensionDirFromCandidates(
41
45
  const moduleUsable = hasRequiredExtensionAssets(moduleDir, exists);
42
46
  const agentUsable = hasRequiredExtensionAssets(agentGsdDir, exists);
43
47
 
48
+ // Source checkouts must use their own prompt tree. Otherwise local tests and
49
+ // dev runs can silently render stale prompts from ~/.gsd/agent/extensions/gsd.
50
+ if (moduleUsable && isSourceExtensionDir(moduleDir)) return moduleDir;
51
+
44
52
  // Prefer the user-local extension tree when both are valid. This avoids
45
53
  // leaking npm/global-install paths into prompts on Windows.
46
54
  if (agentUsable) return agentGsdDir;
@@ -12,6 +12,8 @@ Debug GSD itself. Trace the symptom to root cause in current source and produce
12
12
 
13
13
  GSD extension source: `{{gsdSourceDir}}`
14
14
 
15
+ {{toolingSection}}
16
+
15
17
  ### Source Map by Domain
16
18
 
17
19
  | Domain | Files |
@@ -101,7 +103,7 @@ Then **offer GitHub issue creation**: "Would you like me to create a GitHub issu
101
103
 
102
104
  **CRITICAL:** The `github_issues` tool targets only the current user's repository and has no `repo` parameter. Use `gh issue create --repo open-gsd/gsd-pi` via `bash`. Do NOT use the `github_issues` tool.
103
105
 
104
- If yes, create using the `bash` tool:
106
+ If yes and `bash` is available, create using the `bash` tool:
105
107
 
106
108
  ```bash
107
109
  ISSUE_BODY_FILE="${TMPDIR:-${TEMP:-${TMP:-.}}}/gsd-forensic-issue.md"
@@ -142,6 +144,64 @@ TYPE_ID=$(gh api graphql -f query='{ repository(owner:"open-gsd",name:"gsd-pi")
142
144
  gh api graphql -f query='mutation { updateIssue(input:{id:"'"$ISSUE_ID"'",issueTypeId:"'"$TYPE_ID"'"}) { issue { number } } }'
143
145
  ```
144
146
 
147
+ If `bash` is unavailable, do not attempt `bash`, `write`, or `github_issues` tool calls. Instead, provide exactly one paste-once shell script for the user to run locally and say that the live duplicate check / issue creation must be run by the user:
148
+
149
+ ```bash
150
+ KEYWORDS="..."
151
+ echo "Searching closed issues for possible duplicates..."
152
+ gh issue list --repo open-gsd/gsd-pi --state closed --search "$KEYWORDS" --limit 20
153
+
154
+ echo "Searching open PRs for possible fixes..."
155
+ gh pr list --repo open-gsd/gsd-pi --state open --search "$KEYWORDS" --limit 10
156
+
157
+ echo "Searching merged PRs for possible fixes..."
158
+ gh pr list --repo open-gsd/gsd-pi --state merged --search "$KEYWORDS" --limit 10
159
+
160
+ read -r -p "Review the duplicate search above. Continue filing a new issue? [y/N] " SHOULD_FILE
161
+ case "$SHOULD_FILE" in
162
+ y|Y|yes|YES) ;;
163
+ *) echo "Issue filing aborted."; exit 0 ;;
164
+ esac
165
+
166
+ ISSUE_BODY_FILE="${TMPDIR:-${TEMP:-${TMP:-.}}}/gsd-forensic-issue.md"
167
+ cat > "$ISSUE_BODY_FILE" << 'GSD_ISSUE_BODY'
168
+ ## Problem
169
+ [1-2 sentence summary]
170
+
171
+ ## Root Cause
172
+ [Specific file:line in GSD source, with code snippet showing the bug]
173
+
174
+ ## Expected Behavior
175
+ [What the code should do instead — concrete fix suggestion]
176
+
177
+ ## Environment
178
+ - GSD version: [from report]
179
+ - Model: [from report]
180
+ - Unit: [type/id that failed]
181
+
182
+ ## Reproduction Context
183
+ [Phase, milestone, slice, what was happening when it failed]
184
+
185
+ ## Forensic Evidence
186
+ [Key anomalies, error traces, relevant tool call sequences from the report]
187
+
188
+ ---
189
+ *Auto-generated by `/gsd forensics`*
190
+ GSD_ISSUE_BODY
191
+
192
+ ISSUE_URL=$(gh issue create --repo open-gsd/gsd-pi \
193
+ --title "..." \
194
+ --label "auto-generated" \
195
+ --body-file "$ISSUE_BODY_FILE")
196
+ rm -f "$ISSUE_BODY_FILE"
197
+
198
+ ISSUE_NUM=$(echo "$ISSUE_URL" | grep -oE '[0-9]+$')
199
+ ISSUE_ID=$(gh api graphql -f query='{ repository(owner:"open-gsd",name:"gsd-pi") { issue(number:'"$ISSUE_NUM"') { id } } }' --jq '.data.repository.issue.id')
200
+ TYPE_ID=$(gh api graphql -f query='{ repository(owner:"open-gsd",name:"gsd-pi") { issueTypes(first:20) { nodes { id name } } } }' --jq '.data.repository.issueTypes.nodes[] | select(.name=="Bug") | .id')
201
+ gh api graphql -f query='mutation { updateIssue(input:{id:"'"$ISSUE_ID"'",issueTypeId:"'"$TYPE_ID"'"}) { issue { number } } }'
202
+ echo "$ISSUE_URL"
203
+ ```
204
+
145
205
  ### Redaction Rules (CRITICAL)
146
206
 
147
207
  Before creating the issue, you MUST:
@@ -8,6 +8,8 @@
8
8
 
9
9
  You are evaluating **quality gates in parallel** for this slice. Each gate is an independent question that must be answered before task execution begins. Use the `subagent` tool to dispatch all gate evaluations simultaneously.
10
10
 
11
+ **Tool call format:** Call `subagent` with `tasks: [...]` as a **native JSON array** — one object per gate. Do NOT JSON.stringify the array into a string; the tool validates that `tasks` is an array, and a serialized string will be rejected with "must be array".
12
+
11
13
  ## Slice Plan Context
12
14
 
13
15
  {{slicePlanContent}}
@@ -20,7 +22,7 @@ You are evaluating **quality gates in parallel** for this slice. Each gate is an
20
22
 
21
23
  ## Execution Protocol
22
24
 
23
- 1. **Dispatch all gates** using `subagent` in parallel mode. Each subagent prompt is provided below.
25
+ 1. **Dispatch all gates** using `subagent` in parallel mode. Call `subagent` with `tasks: [{ agent: "tester", task: "<prompt>" }, ...]` — one object per gate. Each subagent prompt is provided below.
24
26
  Pass `tasks` as a **JSON array**, not a string. Example shape:
25
27
 
26
28
  ```json
@@ -12,9 +12,11 @@ You are dispatching parallel research agents for **{{sliceCount}} slices** in mi
12
12
 
13
13
  Dispatch ALL slices simultaneously using the `subagent` tool in **parallel mode**. Each subagent will independently research its slice and write a RESEARCH file.
14
14
 
15
+ **Tool call format:** Call `subagent` with `tasks: [...]` as a **native JSON array** — one object per slice. Do NOT JSON.stringify the array into a string; the tool validates that `tasks` is an array, and a serialized string will be rejected with "must be array".
16
+
15
17
  ## Execution Protocol
16
18
 
17
- 1. Call `subagent` with `tasks: [...]` containing one entry per slice below
19
+ 1. Call `subagent` with `tasks: [{ agent: "scout", task: "<prompt>" }, ...]` containing one entry per slice below
18
20
  2. Wait for ALL subagents to complete
19
21
  3. Verify each slice's RESEARCH file was written (check `.gsd/milestones/{{mid}}/slices/<slice-id>/`)
20
22
  4. If a subagent failed to write its RESEARCH file, retry it **once** individually
@@ -43,7 +43,7 @@ If slice research is inlined, trust its architectural findings, but verify every
43
43
  5. Define slice verification before tasks. Non-trivial slices need real tests or executable assertions; boundary contracts need contract-exercising checks. Tests must not read .gitignore/gitignored paths such as `.gsd/`, `.planning/`, or `.audits/`.
44
44
  6. Include Threat Surface (Q3), Requirement Impact (Q4), proof level, observability, integration closure, Failure Modes (Q5), Load Profile (Q6), and Negative Tests (Q7) only where applicable.
45
45
  7. Right-size tasks. Simple slices can be one task; split only when context, ownership, or verification boundaries justify it.
46
- 8. Task `verify` commands must be safe, simple commands. Do not use shell pipes, redirects, semicolons, backticks, command substitution, output trimming, or grep regex alternation with `|`. If multiple checks are needed, create a small test file and run it with `node --test` or a package test script, or use separate simple commands joined only with `&&`.
46
+ 8. Task `verify` commands must be safe, simple commands. Do not use shell pipes, redirects, semicolons, backticks, command substitution, output trimming, or grep regex alternation with `|`. If multiple checks are needed, create a small test file and run it with `node --test` or a package test script, or use separate simple commands joined only with `&&`. For absence checks, verify a pattern does not exist with `! grep -q 'pattern' file` or `! rg -q 'pattern' file`; do not use `grep -c` or `rg -c` to assert zero matches because count commands exit 1 when they find zero matches, and the verification gate treats that as failure.
47
47
  9. Each task needs the exact `gsd_plan_slice.tasks[]` shape: `taskId`, `title`, `description`, `estimate`, `files`, `verify`, `inputs`, `expectedOutput`, and optional `observabilityImpact`. `description` should contain the Why / Do / Done-when narrative. `files`, `inputs`, and `expectedOutput` must be JSON arrays of strings, even when there is only one path (for example, `"inputs": ["src/index.ts"]`, never `"inputs": "src/index.ts"`). Use paths relative to `{{workingDirectory}}`; do not put absolute paths to the original checkout or any directory outside `{{workingDirectory}}` in `files`, `inputs`, `expectedOutput`, or verification commands. **`expectedOutput` must only list files the task actually creates or overwrites on disk.** Do NOT include files the task merely reads, verifies, or tests — those belong only in `inputs`. If a task is a pure verification or test task that produces no new files, `expectedOutput` may be `[]` or limited to test-result artifacts (e.g. a log or assertion output). A file that does not yet exist on disk and is needed as an `input` must be produced by an earlier task's `expectedOutput` — if no prior task creates it, add a task before this one that does.
48
48
  10. Persist with `gsd_plan_slice` using `milestoneId`, `sliceId`, `goal`, optional `successCriteria`/`proofLevel`/`integrationClosure`/`observabilityImpact`, and `tasks`. `gsd_plan_slice` handles task persistence transactionally and renders `{{outputPath}}` plus task plans; do not call `gsd_plan_task`. The DB-backed tool is the canonical write path. Do **not** rely on direct `PLAN.md` writes as the source of truth.
49
49
  11. Self-audit before finishing: goal/demo closure, requirement coverage, deliverable coverage audit (cross-check every file listed in CONTEXT.md `## Scope` / `### In Scope` against task `files` or `expectedOutput`), locked decisions, concrete paths, dependency order, wiring, scope size, proof truthfulness, feature completeness, and quality gates. Quality gates: non-trivial slices/tasks include specific Q3-Q7 coverage where applicable.
@@ -10,6 +10,8 @@ You are executing **multiple tasks in parallel** for this slice. The task graph
10
10
 
11
11
  **Critical rule:** Use the `subagent` tool in **parallel mode** to dispatch all ready tasks simultaneously. Each subagent gets a task-specific execution packet (task plan + dependency carry-forward + completion contract) and is responsible for its own implementation, verification, task summary, and completion tool calls. The parent batch agent orchestrates, verifies, and records failures only when a dispatched task failed before it could leave its own summary behind.
12
12
 
13
+ **Tool call format:** Call `subagent` with `tasks: [...]` as a **native JSON array** — one object per ready task. Do NOT JSON.stringify the array into a string; the tool validates that `tasks` is an array, and a serialized string will be rejected with "must be array".
14
+
13
15
  ## Task Dependency Graph
14
16
 
15
17
  {{graphContext}}
@@ -22,7 +24,7 @@ You are executing **multiple tasks in parallel** for this slice. The task graph
22
24
 
23
25
  ## Execution Protocol
24
26
 
25
- 1. **Dispatch all ready tasks** using `subagent` in parallel mode. Each subagent prompt is provided below.
27
+ 1. **Dispatch all ready tasks** using `subagent` in parallel mode. Call `subagent` with `tasks: [{ agent: "worker", task: "<prompt>" }, ...]` — one object per ready task. Each subagent prompt is provided below.
26
28
  2. **Wait for all subagents** to complete.
27
29
  3. **Verify each dispatched task's outputs** — check that expected files were created/modified, that verification commands pass where applicable, and that each task wrote its own `T##-SUMMARY.md`.
28
30
  4. **Do not rewrite successful task summaries or duplicate completion tool calls.** Treat a subagent-written summary as authoritative for that task.
@@ -63,35 +63,39 @@ After running all checks, compute the **overall verdict**:
63
63
  - `FAIL` — one or more automatable checks failed
64
64
  - `PARTIAL` — one or more automatable checks were skipped or returned inconclusive results (not the same as `NEEDS-HUMAN` — use PARTIAL only when the agent itself could not determine pass/fail for a check it was supposed to automate)
65
65
 
66
- Call `gsd_summary_save` with `milestone_id: "{{milestoneId}}"`, `slice_id: "{{sliceId}}"`, `artifact_type: "ASSESSMENT"`, and the full UAT result markdown as `content`. The tool computes the assessment path, persists to DB/disk, and saves the aggregate UAT gate. The content should follow this logical shape:
66
+ Call `gsd_uat_result_save` once after all checks are complete. The tool computes the assessment path, persists to DB/disk, saves attempt history, and saves the aggregate UAT gate.
67
67
 
68
- ```markdown
69
- ---
70
- sliceId: {{sliceId}}
71
- uatType: {{uatType}}
72
- verdict: PASS | FAIL | PARTIAL
73
- date: <ISO 8601 timestamp>
74
- ---
75
-
76
- # UAT Result — {{sliceId}}
77
-
78
- ## Checks
68
+ Pass these top-level fields:
79
69
 
80
- | Check | Mode | Result | Notes |
81
- |-------|------|--------|-------|
82
- | <check description> | artifact / runtime / human-follow-up | PASS / FAIL / NEEDS-HUMAN | <observed output, evidence, or reason> |
83
-
84
- ## Overall Verdict
70
+ ```ts
71
+ milestoneId: "{{milestoneId}}",
72
+ sliceId: "{{sliceId}}",
73
+ uatType: "{{uatType}}",
74
+ verdict: "PASS" | "FAIL" | "PARTIAL",
75
+ notes: "<one sentence overall verdict rationale>",
76
+ ```
85
77
 
86
- <PASS / FAIL / PARTIAL> <one sentence summary>
78
+ Use this canonical `presentation` object in the save call so the audit can verify the run-uat tool surface without retrying missing fields one by one. Keep `toolPresentationPlanId` as `{{toolPresentationPlanId}}`. If browser tools were actually presented for this run, add those concrete browser tool names to `presentedTools`; otherwise reuse this object exactly:
87
79
 
88
- ## Notes
80
+ ```json
81
+ {{canonicalPresentation}}
82
+ ```
89
83
 
90
- <any additional context, errors encountered, screenshots/logs gathered, or manual follow-up still required>
84
+ Pass `checks` with this logical shape:
85
+
86
+ ```ts
87
+ checks: [{
88
+ id: "<stable check id>",
89
+ description: "<check description from the UAT file>",
90
+ mode: "artifact" | "runtime" | "browser" | "human-follow-up",
91
+ result: "PASS" | "FAIL" | "NEEDS-HUMAN",
92
+ evidence: [{ kind: "gsd_uat_exec", ref: "<evidence id>" }],
93
+ notes: "<observed output, evidence, reason, or manual follow-up>",
94
+ }]
91
95
  ```
92
96
 
93
97
  ---
94
98
 
95
- **You MUST call `gsd_summary_save` with `artifact_type: "ASSESSMENT"` and the UAT result content before finishing. Do not write the assessment file directly.**
99
+ **You MUST call `gsd_uat_result_save` before finishing. Do not write the assessment file directly, and do not call `gsd_summary_save` as a substitute.**
96
100
 
97
101
  When done, say: "UAT {{sliceId}} complete."
@@ -33,7 +33,7 @@ Prompt: "Review milestone {{milestoneId}} requirements coverage. Working directo
33
33
  Prompt: "Review milestone {{milestoneId}} cross-slice integration. Working directory: {{workingDirectory}}. Read `{{roadmapPath}}` and find the boundary map (produces/consumes contracts). For each boundary, confirm producer SUMMARY produced the artifact and consumer SUMMARY consumed it. Output table: Boundary | Producer Summary | Consumer Summary | Status. End with one-line verdict: PASS if all boundaries honored, NEEDS-ATTENTION if any gaps."
34
34
 
35
35
  **Reviewer C - Assessment & Acceptance Criteria**
36
- Prompt: "Review milestone {{milestoneId}} assessment evidence and acceptance criteria. Working directory: {{workingDirectory}}. Read `.gsd/milestones/{{milestoneId}}/{{milestoneId}}-CONTEXT.md` for criteria. Check slice SUMMARY and ASSESSMENT files under `.gsd/milestones/{{milestoneId}}/slices/`; UAT files are specs, not evidence. Verify each criterion maps to passing evidence. Then review inlined milestone verification classes. For each non-empty planned class, output table: Class | Planned Check | Evidence | Verdict. Use the exact class names `Contract`, `Integration`, `Operational`, and `UAT` whenever those classes are present. If a planned browser/UAT class has no ASSESSMENT with browser/runtime actions and assertions, return NEEDS-ATTENTION. If no verification classes were planned, say that explicitly. Output sections `Acceptance Criteria` with checklist `[ ] Criterion | Evidence`, and `Verification Classes` with the table. End with one-line verdict: PASS if all criteria and classes are covered by evidence, NEEDS-ATTENTION if gaps exist."
36
+ Prompt: "Review milestone {{milestoneId}} assessment evidence and acceptance criteria. Working directory: {{workingDirectory}}. Read `.gsd/milestones/{{milestoneId}}/{{milestoneId}}-CONTEXT.md` for criteria. Check slice SUMMARY and ASSESSMENT files under `.gsd/milestones/{{milestoneId}}/slices/`; UAT files are specs, not evidence. Verify each criterion maps to passing evidence. Then review the inlined `Verification Classes (from planning)` table. For every planned row in that table, output a `Verification Classes` table with columns `Class | Planned Check | Evidence | Verdict`. Preserve every planned non-empty class row; do not summarize, rename, combine, or omit planned classes. The first cell of each row must be exactly `Contract`, `Integration`, `Operational`, or `UAT` when that class is present in planning. If a planned class lacks evidence, still include its canonical row and mark the verdict NEEDS-ATTENTION or FAIL. If a planned browser/UAT class has no ASSESSMENT with browser/runtime actions and assertions, return NEEDS-ATTENTION. If no verification classes were planned, say that explicitly. Output sections `Acceptance Criteria` with checklist `[ ] Criterion | Evidence`, and `Verification Classes` with the table. End with one-line verdict: PASS if all criteria and classes are covered by evidence, NEEDS-ATTENTION if gaps exist."
37
37
 
38
38
  ### Step 2 - Synthesize Findings
39
39
 
@@ -71,8 +71,8 @@ reviewers: 3
71
71
  <if verdict is not pass: specific actions required>
72
72
  ```
73
73
 
74
- Call `gsd_validate_milestone` with the camelCase fields `milestoneId`, `verdict`, `remediationRound`, `successCriteriaChecklist`, `sliceDeliveryAudit`, `crossSliceIntegration`, `requirementCoverage`, `verdictRationale`, and `remediationPlan` when needed. If you include verification-class analysis, pass it in `verificationClasses`.
75
- Extract the `Verification Classes` subsection from Reviewer C and pass it verbatim in `verificationClasses` so the persisted validation output uses the canonical class names `Contract`, `Integration`, `Operational`, and `UAT`.
74
+ Call `gsd_validate_milestone` with the camelCase fields `milestoneId`, `verdict`, `remediationRound`, `successCriteriaChecklist`, `sliceDeliveryAudit`, `crossSliceIntegration`, `requirementCoverage`, `verdictRationale`, and `remediationPlan` when needed. If planning included verification classes, pass a complete canonical table in `verificationClasses`.
75
+ Set `verificationClasses` to the `Verification Classes` subsection from Reviewer C. It must include one canonical row for every non-empty planned class from `Verification Classes (from planning)`: `Contract`, `Integration`, `Operational`, and/or `UAT`. If Reviewer C omitted a planned class, reconstruct the missing row from the planning table, set Evidence to the gap, and use NEEDS-ATTENTION or FAIL. Do not call `gsd_validate_milestone` with a partial `verificationClasses` table.
76
76
 
77
77
  **DB access safety:** Do NOT query `.gsd/gsd.db` directly via `sqlite3` or `node -e require('better-sqlite3')` - the engine owns the WAL connection. Use `gsd_milestone_status` for milestone and slice state. Data is already inlined or available via `gsd_*` tools. Direct DB access risks WAL corruption and bypasses validation.
78
78
 
@@ -6,7 +6,9 @@ import { ReconciliationFailedError } from "./state-reconciliation.js";
6
6
 
7
7
  export type RecoveryFailureKind =
8
8
  | "tool-schema"
9
+ | "tool-contract"
9
10
  | "deterministic-policy"
11
+ | "lifecycle-progression"
10
12
  | "stale-worker"
11
13
  | "worktree-invalid"
12
14
  | "verification-drift"
@@ -52,6 +54,14 @@ export function classifyFailure(input: RecoveryClassificationInput): RecoveryCla
52
54
  exitReason: "tool-schema",
53
55
  remediation: "Fix the Unit Tool Contract or tool schema before retrying.",
54
56
  };
57
+ case "tool-contract":
58
+ return {
59
+ failureKind,
60
+ action: "stop",
61
+ reason: `Tool Contract failure${unitSuffix(input)}: ${message}`,
62
+ exitReason: "tool-contract",
63
+ remediation: "Fix the Unit Tool Contract or prompt so the Unit is only asked to use tools owned by its phase.",
64
+ };
55
65
  case "deterministic-policy":
56
66
  return {
57
67
  failureKind,
@@ -60,6 +70,14 @@ export function classifyFailure(input: RecoveryClassificationInput): RecoveryCla
60
70
  exitReason: "deterministic-policy",
61
71
  remediation: "Resolve the policy blocker; retrying the same Unit will repeat the failure.",
62
72
  };
73
+ case "lifecycle-progression":
74
+ return {
75
+ failureKind,
76
+ action: "stop",
77
+ reason: `Lifecycle progression failure${unitSuffix(input)}: ${message}`,
78
+ exitReason: "lifecycle-progression",
79
+ remediation: "Route to the required owning Unit or restore the missing artifact before advancing lifecycle state.",
80
+ };
63
81
  case "stale-worker":
64
82
  return {
65
83
  failureKind,
@@ -118,6 +136,8 @@ export function classifyFailure(input: RecoveryClassificationInput): RecoveryCla
118
136
  }
119
137
 
120
138
  function inferFailureKind(message: string): RecoveryFailureKind {
139
+ if (/tool contract|auto-unit tool scope|phase-boundary gate|not permitted.*own/i.test(message)) return "tool-contract";
140
+ if (/lifecycle progression|required artifact|missing .*assessment|missing .*closeout|cannot legally (?:advance|progress)/i.test(message)) return "lifecycle-progression";
121
141
  if (/schema|invalid.*tool|tool.*invalid|enum/i.test(message)) return "tool-schema";
122
142
  if (/deterministic policy|policy rejection|write gate|blocked by policy/i.test(message)) return "deterministic-policy";
123
143
  if (/stale worker|stale lock|worker.*stale/i.test(message)) return "stale-worker";