@bhargavvc/sdd-cc 1.30.1 → 1.42.3

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 (1392) hide show
  1. package/README.ja-JP.md +165 -129
  2. package/README.ko-KR.md +161 -123
  3. package/README.md +103 -679
  4. package/README.pt-BR.md +92 -52
  5. package/README.zh-CN.md +145 -103
  6. package/agents/sdd-advisor-researcher.md +23 -0
  7. package/agents/sdd-ai-researcher.md +133 -0
  8. package/agents/sdd-code-fixer.md +668 -0
  9. package/agents/sdd-code-reviewer.md +387 -0
  10. package/agents/sdd-codebase-mapper.md +86 -3
  11. package/agents/sdd-debug-session-manager.md +314 -0
  12. package/agents/sdd-debugger.md +157 -78
  13. package/agents/sdd-doc-classifier.md +168 -0
  14. package/agents/sdd-doc-synthesizer.md +204 -0
  15. package/agents/sdd-doc-verifier.md +217 -0
  16. package/agents/sdd-doc-writer.md +615 -0
  17. package/agents/sdd-domain-researcher.md +153 -0
  18. package/agents/sdd-eval-auditor.md +191 -0
  19. package/agents/sdd-eval-planner.md +154 -0
  20. package/agents/sdd-executor.md +283 -40
  21. package/agents/sdd-framework-selector.md +160 -0
  22. package/agents/sdd-integration-checker.md +30 -3
  23. package/agents/sdd-intel-updater.md +342 -0
  24. package/agents/sdd-nyquist-auditor.md +31 -4
  25. package/agents/sdd-pattern-mapper.md +335 -0
  26. package/agents/sdd-phase-researcher.md +254 -24
  27. package/agents/sdd-plan-checker.md +223 -18
  28. package/agents/sdd-planner.md +286 -362
  29. package/agents/sdd-project-researcher.md +28 -5
  30. package/agents/sdd-research-synthesizer.md +4 -4
  31. package/agents/sdd-roadmapper.md +14 -5
  32. package/agents/sdd-security-auditor.md +155 -0
  33. package/agents/sdd-ui-auditor.md +60 -4
  34. package/agents/sdd-ui-checker.md +11 -2
  35. package/agents/sdd-ui-researcher.md +27 -4
  36. package/agents/sdd-user-profiler.md +2 -2
  37. package/agents/sdd-verifier.md +258 -41
  38. package/bin/install.js +6862 -618
  39. package/bin/sdd-sdk.js +37 -0
  40. package/commands/sdd/add-tests.md +3 -2
  41. package/commands/sdd/ai-integration-phase.md +37 -0
  42. package/commands/sdd/audit-fix.md +34 -0
  43. package/commands/sdd/audit-milestone.md +3 -2
  44. package/commands/sdd/autonomous.md +10 -5
  45. package/commands/sdd/capture.md +62 -0
  46. package/commands/sdd/cleanup.md +7 -1
  47. package/commands/sdd/code-review.md +59 -0
  48. package/commands/sdd/complete-milestone.md +11 -4
  49. package/commands/sdd/config.md +58 -0
  50. package/commands/sdd/debug.md +23 -144
  51. package/commands/sdd/discuss-phase.md +22 -10
  52. package/commands/sdd/docs-update.md +49 -0
  53. package/commands/sdd/eval-review.md +33 -0
  54. package/commands/sdd/execute-phase.md +9 -4
  55. package/commands/sdd/explore.md +27 -0
  56. package/commands/sdd/extract-learnings.md +23 -0
  57. package/commands/sdd/fast.md +2 -1
  58. package/commands/sdd/forensics.md +3 -2
  59. package/commands/sdd/graphify.md +199 -0
  60. package/commands/sdd/health.md +12 -3
  61. package/commands/sdd/help.md +3 -1
  62. package/commands/sdd/import.md +41 -0
  63. package/commands/sdd/inbox.md +39 -0
  64. package/commands/sdd/ingest-docs.md +42 -0
  65. package/commands/sdd/manager.md +9 -3
  66. package/commands/sdd/map-codebase.md +15 -3
  67. package/commands/sdd/milestone-summary.md +1 -1
  68. package/commands/sdd/mvp-phase.md +45 -0
  69. package/commands/sdd/new-milestone.md +3 -2
  70. package/commands/sdd/new-project.md +7 -2
  71. package/commands/sdd/ns-context.md +23 -0
  72. package/commands/sdd/ns-ideate.md +24 -0
  73. package/commands/sdd/ns-manage.md +29 -0
  74. package/commands/sdd/ns-project.md +22 -0
  75. package/commands/sdd/ns-review.md +26 -0
  76. package/commands/sdd/ns-workflow.md +28 -0
  77. package/commands/sdd/pause-work.md +6 -1
  78. package/commands/sdd/phase.md +56 -0
  79. package/commands/sdd/plan-phase.md +19 -4
  80. package/commands/sdd/plan-review-convergence.md +59 -0
  81. package/commands/sdd/pr-branch.md +2 -1
  82. package/commands/sdd/profile-user.md +2 -2
  83. package/commands/sdd/progress.md +27 -5
  84. package/commands/sdd/quick.md +132 -5
  85. package/commands/sdd/resume-work.md +2 -12
  86. package/commands/sdd/review-backlog.md +4 -2
  87. package/commands/sdd/review.md +7 -3
  88. package/commands/sdd/secure-phase.md +36 -0
  89. package/commands/sdd/settings.md +2 -9
  90. package/commands/sdd/ship.md +1 -0
  91. package/commands/sdd/sketch.md +60 -0
  92. package/commands/sdd/spec-phase.md +63 -0
  93. package/commands/sdd/spike.md +57 -0
  94. package/commands/sdd/stats.md +2 -1
  95. package/commands/sdd/surface.md +129 -0
  96. package/commands/sdd/thread.md +8 -111
  97. package/commands/sdd/ui-phase.md +3 -2
  98. package/commands/sdd/ui-review.md +3 -2
  99. package/commands/sdd/ultraplan-phase.md +34 -0
  100. package/commands/sdd/undo.md +35 -0
  101. package/commands/sdd/update.md +21 -10
  102. package/commands/sdd/validate-phase.md +3 -2
  103. package/commands/sdd/verify-work.md +4 -3
  104. package/commands/sdd/workspace.md +52 -0
  105. package/commands/sdd/workstreams.md +15 -8
  106. package/hooks/dist/sdd-check-update-worker.js +116 -0
  107. package/hooks/dist/sdd-check-update.js +19 -69
  108. package/hooks/dist/sdd-context-monitor.js +43 -7
  109. package/hooks/dist/sdd-phase-boundary.sh +47 -0
  110. package/hooks/dist/sdd-prompt-guard.js +1 -0
  111. package/hooks/dist/sdd-read-guard.js +101 -0
  112. package/hooks/dist/sdd-read-injection-scanner.js +152 -0
  113. package/hooks/dist/sdd-session-state.sh +59 -0
  114. package/hooks/dist/sdd-statusline.js +439 -21
  115. package/hooks/dist/sdd-update-banner.js +134 -0
  116. package/hooks/dist/sdd-validate-commit.sh +57 -0
  117. package/hooks/dist/sdd-workflow-guard.js +2 -2
  118. package/hooks/lib/git-cmd.js +150 -0
  119. package/hooks/sdd-check-update-worker.js +116 -0
  120. package/hooks/sdd-check-update.js +64 -0
  121. package/hooks/sdd-context-monitor.js +192 -0
  122. package/hooks/sdd-phase-boundary.sh +47 -0
  123. package/hooks/sdd-prompt-guard.js +97 -0
  124. package/hooks/sdd-read-guard.js +101 -0
  125. package/hooks/sdd-read-injection-scanner.js +152 -0
  126. package/hooks/sdd-session-state.sh +59 -0
  127. package/hooks/sdd-statusline.js +537 -0
  128. package/hooks/sdd-update-banner.js +134 -0
  129. package/hooks/sdd-validate-commit.sh +57 -0
  130. package/hooks/sdd-workflow-guard.js +94 -0
  131. package/package.json +34 -9
  132. package/scripts/audit-workflow-script-paths.cjs +73 -0
  133. package/scripts/build-hooks.js +114 -9
  134. package/scripts/changeset/cli.cjs +269 -0
  135. package/scripts/changeset/github-release-notes.cjs +198 -0
  136. package/scripts/changeset/lint.cjs +110 -0
  137. package/scripts/changeset/new.cjs +137 -0
  138. package/scripts/changeset/parse.cjs +60 -0
  139. package/scripts/changeset/render.cjs +34 -0
  140. package/scripts/changeset/serialize.cjs +74 -0
  141. package/scripts/command-contract-helpers.cjs +61 -0
  142. package/scripts/diff-touches-shipped-paths.cjs +147 -0
  143. package/scripts/fix-slash-commands.cjs +106 -0
  144. package/scripts/gen-inventory-manifest.cjs +109 -0
  145. package/scripts/lint-command-contract.cjs +108 -0
  146. package/scripts/lint-descriptions.cjs +83 -0
  147. package/scripts/lint-no-source-grep-extras.cjs +81 -0
  148. package/scripts/lint-no-source-grep.cjs +174 -0
  149. package/scripts/lint-shell-command-projection-drift.cjs +57 -0
  150. package/scripts/lint-skill-deps.cjs +180 -0
  151. package/scripts/pr-template-policy.cjs +169 -0
  152. package/scripts/prompt-injection-scan.sh +3 -0
  153. package/scripts/rebrand-gsd-to-sdd.sh +222 -220
  154. package/scripts/run-tests.cjs +5 -1
  155. package/scripts/strip-prose-atrefs.cjs +106 -0
  156. package/scripts/verify-tarball-sdk-dist.sh +69 -0
  157. package/sdd/bin/check-latest-version.cjs +104 -0
  158. package/sdd/bin/lib/active-workstream-store.cjs +85 -0
  159. package/sdd/bin/lib/adr-parser.cjs +394 -0
  160. package/sdd/bin/lib/artifacts.cjs +53 -0
  161. package/sdd/bin/lib/audit.cjs +755 -0
  162. package/sdd/bin/lib/cjs-command-router-adapter.cjs +39 -0
  163. package/sdd/bin/lib/clusters.cjs +135 -0
  164. package/sdd/bin/lib/command-aliases.generated.cjs +838 -0
  165. package/sdd/bin/lib/commands.cjs +179 -107
  166. package/sdd/bin/lib/config-schema.cjs +135 -0
  167. package/sdd/bin/lib/config.cjs +313 -86
  168. package/sdd/bin/lib/context-utilization.cjs +47 -0
  169. package/sdd/bin/lib/core.cjs +1146 -391
  170. package/sdd/bin/lib/decisions.cjs +48 -0
  171. package/sdd/bin/lib/docs.cjs +270 -0
  172. package/sdd/bin/lib/drift.cjs +379 -0
  173. package/sdd/bin/lib/fallow-runner.cjs +109 -0
  174. package/sdd/bin/lib/frontmatter.cjs +389 -336
  175. package/sdd/bin/lib/gap-checker.cjs +197 -0
  176. package/sdd/bin/lib/graphify.cjs +577 -0
  177. package/sdd/bin/lib/init-command-router.cjs +70 -0
  178. package/sdd/bin/lib/init.cjs +692 -97
  179. package/sdd/bin/lib/install-profiles.cjs +572 -0
  180. package/sdd/bin/lib/installer-migration-authoring.cjs +117 -0
  181. package/sdd/bin/lib/installer-migration-report.cjs +328 -0
  182. package/sdd/bin/lib/installer-migrations/000-first-time-baseline.cjs +220 -0
  183. package/sdd/bin/lib/installer-migrations/001-legacy-orphan-files.cjs +41 -0
  184. package/sdd/bin/lib/installer-migrations/002-codex-legacy-hooks-json.cjs +80 -0
  185. package/sdd/bin/lib/installer-migrations.cjs +703 -0
  186. package/sdd/bin/lib/intel.cjs +643 -0
  187. package/sdd/bin/lib/learnings.cjs +379 -0
  188. package/sdd/bin/lib/milestone.cjs +313 -252
  189. package/sdd/bin/lib/model-catalog.cjs +136 -0
  190. package/sdd/bin/lib/model-profiles.cjs +25 -68
  191. package/sdd/bin/lib/phase-command-router.cjs +96 -0
  192. package/sdd/bin/lib/phase.cjs +868 -335
  193. package/sdd/bin/lib/phases-command-router.cjs +39 -0
  194. package/sdd/bin/lib/plan-scan.cjs +138 -0
  195. package/sdd/bin/lib/planning-workspace.cjs +361 -0
  196. package/sdd/bin/lib/profile-output.cjs +197 -35
  197. package/sdd/bin/lib/profile-pipeline.cjs +1 -1
  198. package/sdd/bin/lib/review-reviewer-selection.cjs +125 -0
  199. package/sdd/bin/lib/roadmap-command-router.cjs +23 -0
  200. package/sdd/bin/lib/roadmap.cjs +416 -124
  201. package/sdd/bin/lib/runtime-homes.cjs +178 -0
  202. package/sdd/bin/lib/schema-detect.cjs +238 -0
  203. package/sdd/bin/lib/sdd2-import.cjs +511 -0
  204. package/sdd/bin/lib/secrets.cjs +33 -0
  205. package/sdd/bin/lib/security.cjs +131 -9
  206. package/sdd/bin/lib/shell-command-projection.cjs +548 -0
  207. package/sdd/bin/lib/state-command-router.cjs +100 -0
  208. package/sdd/bin/lib/state-document.cjs +12 -0
  209. package/sdd/bin/lib/state-document.generated.cjs +127 -0
  210. package/sdd/bin/lib/state.cjs +1253 -367
  211. package/sdd/bin/lib/surface.cjs +398 -0
  212. package/sdd/bin/lib/template.cjs +11 -5
  213. package/sdd/bin/lib/uat.cjs +9 -2
  214. package/sdd/bin/lib/validate-command-router.cjs +55 -0
  215. package/sdd/bin/lib/verify-command-router.cjs +34 -0
  216. package/sdd/bin/lib/verify.cjs +648 -140
  217. package/sdd/bin/lib/workstream-inventory.cjs +159 -0
  218. package/sdd/bin/lib/workstream-name-policy.cjs +33 -0
  219. package/sdd/bin/lib/workstream.cjs +78 -196
  220. package/sdd/bin/lib/worktree-safety.cjs +563 -0
  221. package/sdd/bin/sdd-tools.cjs +528 -222
  222. package/sdd/bin/verify-reapply-patches.cjs +247 -0
  223. package/sdd/contexts/dev.md +21 -0
  224. package/sdd/contexts/research.md +22 -0
  225. package/sdd/contexts/review.md +23 -0
  226. package/sdd/references/agent-contracts.md +79 -0
  227. package/sdd/references/ai-evals.md +156 -0
  228. package/sdd/references/ai-frameworks.md +186 -0
  229. package/sdd/references/artifact-types.md +131 -0
  230. package/sdd/references/autonomous-smart-discuss.md +277 -0
  231. package/sdd/references/checkpoints.md +36 -0
  232. package/sdd/references/common-bug-patterns.md +114 -0
  233. package/sdd/references/context-budget.md +85 -0
  234. package/sdd/references/continuation-format.md +30 -26
  235. package/sdd/references/debugger-philosophy.md +76 -0
  236. package/sdd/references/decimal-phase-calculation.md +5 -5
  237. package/sdd/references/doc-conflict-engine.md +91 -0
  238. package/sdd/references/domain-probes.md +125 -0
  239. package/sdd/references/execute-mvp-tdd.md +81 -0
  240. package/sdd/references/executor-examples.md +110 -0
  241. package/sdd/references/few-shot-examples/plan-checker.md +73 -0
  242. package/sdd/references/few-shot-examples/verifier.md +109 -0
  243. package/sdd/references/gate-prompts.md +100 -0
  244. package/sdd/references/gates.md +70 -0
  245. package/sdd/references/git-integration.md +9 -6
  246. package/sdd/references/git-planning-commit.md +6 -4
  247. package/sdd/references/ios-scaffold.md +123 -0
  248. package/sdd/references/mandatory-initial-read.md +2 -0
  249. package/sdd/references/model-profile-resolution.md +2 -0
  250. package/sdd/references/model-profiles.md +128 -22
  251. package/sdd/references/mvp-concepts.md +49 -0
  252. package/sdd/references/phase-argument-parsing.md +3 -3
  253. package/sdd/references/planner-antipatterns.md +89 -0
  254. package/sdd/references/planner-chunked.md +49 -0
  255. package/sdd/references/planner-gap-closure.md +62 -0
  256. package/sdd/references/planner-human-verify-mode.md +57 -0
  257. package/sdd/references/planner-mvp-mode.md +53 -0
  258. package/sdd/references/planner-reviews.md +39 -0
  259. package/sdd/references/planner-revision.md +87 -0
  260. package/sdd/references/planner-source-audit.md +73 -0
  261. package/sdd/references/planning-config.md +276 -7
  262. package/sdd/references/project-skills-discovery.md +19 -0
  263. package/sdd/references/revision-loop.md +97 -0
  264. package/sdd/references/scout-codebase.md +51 -0
  265. package/sdd/references/skeleton-template.md +48 -0
  266. package/sdd/references/sketch-interactivity.md +41 -0
  267. package/sdd/references/sketch-theme-system.md +94 -0
  268. package/sdd/references/sketch-tooling.md +45 -0
  269. package/sdd/references/sketch-variant-patterns.md +81 -0
  270. package/sdd/references/spidr-splitting.md +69 -0
  271. package/sdd/references/tdd.md +67 -0
  272. package/sdd/references/thinking-models-debug.md +44 -0
  273. package/sdd/references/thinking-models-execution.md +50 -0
  274. package/sdd/references/thinking-models-planning.md +62 -0
  275. package/sdd/references/thinking-models-research.md +50 -0
  276. package/sdd/references/thinking-models-verification.md +55 -0
  277. package/sdd/references/thinking-partner.md +96 -0
  278. package/sdd/references/ui-brand.md +4 -4
  279. package/sdd/references/universal-anti-patterns.md +63 -0
  280. package/sdd/references/user-story-template.md +58 -0
  281. package/sdd/references/verification-overrides.md +227 -0
  282. package/sdd/references/verify-mvp-mode.md +85 -0
  283. package/sdd/references/workstream-flag.md +63 -10
  284. package/sdd/references/worktree-path-safety.md +89 -0
  285. package/sdd/templates/AI-SPEC.md +246 -0
  286. package/sdd/templates/DEBUG.md +7 -2
  287. package/sdd/templates/README.md +77 -0
  288. package/sdd/templates/SECURITY.md +61 -0
  289. package/sdd/templates/VALIDATION.md +3 -3
  290. package/sdd/templates/claude-md.md +27 -4
  291. package/sdd/templates/config.json +20 -2
  292. package/sdd/templates/discovery.md +2 -2
  293. package/sdd/templates/research.md +40 -0
  294. package/sdd/templates/spec.md +307 -0
  295. package/sdd/templates/state.md +10 -2
  296. package/sdd/workflows/add-backlog.md +90 -0
  297. package/sdd/workflows/add-phase.md +12 -12
  298. package/sdd/workflows/add-tests.md +6 -3
  299. package/sdd/workflows/add-todo.md +8 -6
  300. package/sdd/workflows/ai-integration-phase.md +294 -0
  301. package/sdd/workflows/analyze-dependencies.md +96 -0
  302. package/sdd/workflows/audit-fix.md +177 -0
  303. package/sdd/workflows/audit-milestone.md +35 -18
  304. package/sdd/workflows/audit-uat.md +1 -1
  305. package/sdd/workflows/autonomous.md +202 -304
  306. package/sdd/workflows/check-todos.md +12 -10
  307. package/sdd/workflows/cleanup.md +3 -1
  308. package/sdd/workflows/code-review-fix.md +501 -0
  309. package/sdd/workflows/code-review.md +613 -0
  310. package/sdd/workflows/complete-milestone.md +115 -28
  311. package/sdd/workflows/debug.md +231 -0
  312. package/sdd/workflows/diagnose-issues.md +14 -5
  313. package/sdd/workflows/discovery-phase.md +3 -1
  314. package/sdd/workflows/discuss-phase/modes/advisor.md +175 -0
  315. package/sdd/workflows/discuss-phase/modes/all.md +28 -0
  316. package/sdd/workflows/discuss-phase/modes/analyze.md +44 -0
  317. package/sdd/workflows/discuss-phase/modes/auto.md +56 -0
  318. package/sdd/workflows/discuss-phase/modes/batch.md +52 -0
  319. package/sdd/workflows/discuss-phase/modes/chain.md +97 -0
  320. package/sdd/workflows/discuss-phase/modes/default.md +141 -0
  321. package/sdd/workflows/discuss-phase/modes/power.md +44 -0
  322. package/sdd/workflows/discuss-phase/modes/text.md +55 -0
  323. package/sdd/workflows/discuss-phase/templates/checkpoint.json +18 -0
  324. package/sdd/workflows/discuss-phase/templates/context.md +136 -0
  325. package/sdd/workflows/discuss-phase/templates/discussion-log.md +50 -0
  326. package/sdd/workflows/discuss-phase-assumptions.md +41 -20
  327. package/sdd/workflows/discuss-phase-power.md +291 -0
  328. package/sdd/workflows/discuss-phase.md +242 -792
  329. package/sdd/workflows/do.md +13 -7
  330. package/sdd/workflows/docs-update.md +1161 -0
  331. package/sdd/workflows/edit-phase.md +294 -0
  332. package/sdd/workflows/eval-review.md +155 -0
  333. package/sdd/workflows/execute-phase/steps/codebase-drift-gate.md +81 -0
  334. package/sdd/workflows/execute-phase/steps/per-plan-worktree-gate.md +94 -0
  335. package/sdd/workflows/execute-phase/steps/post-merge-gate.md +116 -0
  336. package/sdd/workflows/execute-phase.md +1062 -108
  337. package/sdd/workflows/execute-plan.md +118 -107
  338. package/sdd/workflows/explore.md +143 -0
  339. package/sdd/workflows/extract-learnings.md +242 -0
  340. package/sdd/workflows/forensics.md +17 -4
  341. package/sdd/workflows/graduation.md +195 -0
  342. package/sdd/workflows/health.md +45 -3
  343. package/sdd/workflows/help.md +265 -88
  344. package/sdd/workflows/import.md +253 -0
  345. package/sdd/workflows/inbox.md +387 -0
  346. package/sdd/workflows/ingest-docs.md +339 -0
  347. package/sdd/workflows/insert-phase.md +37 -16
  348. package/sdd/workflows/list-phase-assumptions.md +2 -2
  349. package/sdd/workflows/list-workspaces.md +3 -3
  350. package/sdd/workflows/manager.md +62 -32
  351. package/sdd/workflows/map-codebase.md +90 -24
  352. package/sdd/workflows/milestone-summary.md +6 -6
  353. package/sdd/workflows/mvp-phase.md +221 -0
  354. package/sdd/workflows/new-milestone.md +168 -20
  355. package/sdd/workflows/new-project.md +273 -47
  356. package/sdd/workflows/new-workspace.md +8 -6
  357. package/sdd/workflows/next.md +127 -4
  358. package/sdd/workflows/note.md +7 -5
  359. package/sdd/workflows/pause-work.md +79 -12
  360. package/sdd/workflows/plan-milestone-gaps.md +14 -7
  361. package/sdd/workflows/plan-phase.md +987 -62
  362. package/sdd/workflows/plan-review-convergence.md +329 -0
  363. package/sdd/workflows/plant-seed.md +145 -85
  364. package/sdd/workflows/pr-branch.md +41 -13
  365. package/sdd/workflows/profile-user.md +20 -18
  366. package/sdd/workflows/progress.md +186 -44
  367. package/sdd/workflows/quick.md +470 -58
  368. package/sdd/workflows/reapply-patches.md +390 -0
  369. package/sdd/workflows/remove-phase.md +12 -12
  370. package/sdd/workflows/remove-workspace.md +24 -7
  371. package/sdd/workflows/resume-project.md +18 -15
  372. package/sdd/workflows/review.md +242 -11
  373. package/sdd/workflows/scan.md +104 -0
  374. package/sdd/workflows/secure-phase.md +179 -0
  375. package/sdd/workflows/session-report.md +2 -2
  376. package/sdd/workflows/settings-advanced.md +579 -0
  377. package/sdd/workflows/settings-integrations.md +281 -0
  378. package/sdd/workflows/settings.md +221 -16
  379. package/sdd/workflows/ship.md +140 -13
  380. package/sdd/workflows/sketch-wrap-up.md +285 -0
  381. package/sdd/workflows/sketch.md +360 -0
  382. package/sdd/workflows/spec-phase.md +262 -0
  383. package/sdd/workflows/spike-wrap-up.md +306 -0
  384. package/sdd/workflows/spike.md +452 -0
  385. package/sdd/workflows/stats.md +20 -1
  386. package/sdd/workflows/sync-skills.md +182 -0
  387. package/sdd/workflows/thread.md +221 -0
  388. package/sdd/workflows/transition.md +44 -22
  389. package/sdd/workflows/ui-phase.md +39 -14
  390. package/sdd/workflows/ui-review.md +33 -6
  391. package/sdd/workflows/ultraplan-phase.md +198 -0
  392. package/sdd/workflows/undo.md +314 -0
  393. package/sdd/workflows/update.md +350 -29
  394. package/sdd/workflows/validate-phase.md +10 -6
  395. package/sdd/workflows/verify-phase.md +307 -18
  396. package/sdd/workflows/verify-work.md +153 -10
  397. package/sdk/dist/cli-transport.d.ts +19 -0
  398. package/sdk/dist/cli-transport.d.ts.map +1 -0
  399. package/sdk/dist/cli-transport.js +104 -0
  400. package/sdk/dist/cli-transport.js.map +1 -0
  401. package/sdk/dist/cli.d.ts +46 -0
  402. package/sdk/dist/cli.d.ts.map +1 -0
  403. package/sdk/dist/cli.js +511 -0
  404. package/sdk/dist/cli.js.map +1 -0
  405. package/sdk/dist/config.d.ts +84 -0
  406. package/sdk/dist/config.d.ts.map +1 -0
  407. package/sdk/dist/config.js +135 -0
  408. package/sdk/dist/config.js.map +1 -0
  409. package/sdk/dist/context-engine.d.ts +49 -0
  410. package/sdk/dist/context-engine.d.ts.map +1 -0
  411. package/sdk/dist/context-engine.js +142 -0
  412. package/sdk/dist/context-engine.js.map +1 -0
  413. package/sdk/dist/context-truncation.d.ts +33 -0
  414. package/sdk/dist/context-truncation.d.ts.map +1 -0
  415. package/sdk/dist/context-truncation.js +197 -0
  416. package/sdk/dist/context-truncation.js.map +1 -0
  417. package/sdk/dist/errors.d.ts +46 -0
  418. package/sdk/dist/errors.d.ts.map +1 -0
  419. package/sdk/dist/errors.js +64 -0
  420. package/sdk/dist/errors.js.map +1 -0
  421. package/sdk/dist/event-stream.d.ts +53 -0
  422. package/sdk/dist/event-stream.d.ts.map +1 -0
  423. package/sdk/dist/event-stream.js +321 -0
  424. package/sdk/dist/event-stream.js.map +1 -0
  425. package/sdk/dist/golden/capture.d.ts +15 -0
  426. package/sdk/dist/golden/capture.d.ts.map +1 -0
  427. package/sdk/dist/golden/capture.js +67 -0
  428. package/sdk/dist/golden/capture.js.map +1 -0
  429. package/sdk/dist/golden/golden-integration-covered.d.ts +6 -0
  430. package/sdk/dist/golden/golden-integration-covered.d.ts.map +1 -0
  431. package/sdk/dist/golden/golden-integration-covered.js +30 -0
  432. package/sdk/dist/golden/golden-integration-covered.js.map +1 -0
  433. package/sdk/dist/golden/golden-mutation-covered.d.ts +7 -0
  434. package/sdk/dist/golden/golden-mutation-covered.d.ts.map +1 -0
  435. package/sdk/dist/golden/golden-mutation-covered.js +17 -0
  436. package/sdk/dist/golden/golden-mutation-covered.js.map +1 -0
  437. package/sdk/dist/golden/golden-policy.d.ts +10 -0
  438. package/sdk/dist/golden/golden-policy.d.ts.map +1 -0
  439. package/sdk/dist/golden/golden-policy.js +98 -0
  440. package/sdk/dist/golden/golden-policy.js.map +1 -0
  441. package/sdk/dist/golden/init-golden-normalize.d.ts +8 -0
  442. package/sdk/dist/golden/init-golden-normalize.d.ts.map +1 -0
  443. package/sdk/dist/golden/init-golden-normalize.js +14 -0
  444. package/sdk/dist/golden/init-golden-normalize.js.map +1 -0
  445. package/sdk/dist/golden/read-only-golden-rows.d.ts +20 -0
  446. package/sdk/dist/golden/read-only-golden-rows.d.ts.map +1 -0
  447. package/sdk/dist/golden/read-only-golden-rows.js +67 -0
  448. package/sdk/dist/golden/read-only-golden-rows.js.map +1 -0
  449. package/sdk/dist/golden/registry-canonical-commands.d.ts +6 -0
  450. package/sdk/dist/golden/registry-canonical-commands.d.ts.map +1 -0
  451. package/sdk/dist/golden/registry-canonical-commands.js +30 -0
  452. package/sdk/dist/golden/registry-canonical-commands.js.map +1 -0
  453. package/sdk/dist/index.d.ts +125 -0
  454. package/sdk/dist/index.d.ts.map +1 -0
  455. package/sdk/dist/index.js +298 -0
  456. package/sdk/dist/index.js.map +1 -0
  457. package/sdk/dist/init-runner.d.ts +90 -0
  458. package/sdk/dist/init-runner.d.ts.map +1 -0
  459. package/sdk/dist/init-runner.js +613 -0
  460. package/sdk/dist/init-runner.js.map +1 -0
  461. package/sdk/dist/logger.d.ts +50 -0
  462. package/sdk/dist/logger.d.ts.map +1 -0
  463. package/sdk/dist/logger.js +70 -0
  464. package/sdk/dist/logger.js.map +1 -0
  465. package/sdk/dist/model-catalog.d.ts +31 -0
  466. package/sdk/dist/model-catalog.d.ts.map +1 -0
  467. package/sdk/dist/model-catalog.js +31 -0
  468. package/sdk/dist/model-catalog.js.map +1 -0
  469. package/sdk/dist/phase-prompt.d.ts +72 -0
  470. package/sdk/dist/phase-prompt.d.ts.map +1 -0
  471. package/sdk/dist/phase-prompt.js +213 -0
  472. package/sdk/dist/phase-prompt.js.map +1 -0
  473. package/sdk/dist/phase-runner.d.ts +145 -0
  474. package/sdk/dist/phase-runner.d.ts.map +1 -0
  475. package/sdk/dist/phase-runner.js +1206 -0
  476. package/sdk/dist/phase-runner.js.map +1 -0
  477. package/sdk/dist/plan-parser.d.ts +55 -0
  478. package/sdk/dist/plan-parser.d.ts.map +1 -0
  479. package/sdk/dist/plan-parser.js +389 -0
  480. package/sdk/dist/plan-parser.js.map +1 -0
  481. package/sdk/dist/planning-journal.d.ts +64 -0
  482. package/sdk/dist/planning-journal.d.ts.map +1 -0
  483. package/sdk/dist/planning-journal.js +88 -0
  484. package/sdk/dist/planning-journal.js.map +1 -0
  485. package/sdk/dist/planning-runtime.d.ts +67 -0
  486. package/sdk/dist/planning-runtime.d.ts.map +1 -0
  487. package/sdk/dist/planning-runtime.js +58 -0
  488. package/sdk/dist/planning-runtime.js.map +1 -0
  489. package/sdk/dist/prompt-builder.d.ts +44 -0
  490. package/sdk/dist/prompt-builder.d.ts.map +1 -0
  491. package/sdk/dist/prompt-builder.js +180 -0
  492. package/sdk/dist/prompt-builder.js.map +1 -0
  493. package/sdk/dist/prompt-sanitizer.d.ts +35 -0
  494. package/sdk/dist/prompt-sanitizer.d.ts.map +1 -0
  495. package/sdk/dist/prompt-sanitizer.js +101 -0
  496. package/sdk/dist/prompt-sanitizer.js.map +1 -0
  497. package/sdk/dist/query/active-workstream-store.d.ts +7 -0
  498. package/sdk/dist/query/active-workstream-store.d.ts.map +1 -0
  499. package/sdk/dist/query/active-workstream-store.js +56 -0
  500. package/sdk/dist/query/active-workstream-store.js.map +1 -0
  501. package/sdk/dist/query/agent-failure-classifier.d.ts +38 -0
  502. package/sdk/dist/query/agent-failure-classifier.d.ts.map +1 -0
  503. package/sdk/dist/query/agent-failure-classifier.js +83 -0
  504. package/sdk/dist/query/agent-failure-classifier.js.map +1 -0
  505. package/sdk/dist/query/audit-open.d.ts +46 -0
  506. package/sdk/dist/query/audit-open.d.ts.map +1 -0
  507. package/sdk/dist/query/audit-open.js +662 -0
  508. package/sdk/dist/query/audit-open.js.map +1 -0
  509. package/sdk/dist/query/check-auto-mode.d.ts +13 -0
  510. package/sdk/dist/query/check-auto-mode.d.ts.map +1 -0
  511. package/sdk/dist/query/check-auto-mode.js +40 -0
  512. package/sdk/dist/query/check-auto-mode.js.map +1 -0
  513. package/sdk/dist/query/check-completion.d.ts +10 -0
  514. package/sdk/dist/query/check-completion.d.ts.map +1 -0
  515. package/sdk/dist/query/check-completion.js +157 -0
  516. package/sdk/dist/query/check-completion.js.map +1 -0
  517. package/sdk/dist/query/check-decision-coverage.d.ts +33 -0
  518. package/sdk/dist/query/check-decision-coverage.d.ts.map +1 -0
  519. package/sdk/dist/query/check-decision-coverage.js +472 -0
  520. package/sdk/dist/query/check-decision-coverage.js.map +1 -0
  521. package/sdk/dist/query/check-gates.d.ts +10 -0
  522. package/sdk/dist/query/check-gates.d.ts.map +1 -0
  523. package/sdk/dist/query/check-gates.js +89 -0
  524. package/sdk/dist/query/check-gates.js.map +1 -0
  525. package/sdk/dist/query/check-ship-ready.d.ts +10 -0
  526. package/sdk/dist/query/check-ship-ready.d.ts.map +1 -0
  527. package/sdk/dist/query/check-ship-ready.js +93 -0
  528. package/sdk/dist/query/check-ship-ready.js.map +1 -0
  529. package/sdk/dist/query/check-verification-status.d.ts +10 -0
  530. package/sdk/dist/query/check-verification-status.d.ts.map +1 -0
  531. package/sdk/dist/query/check-verification-status.js +142 -0
  532. package/sdk/dist/query/check-verification-status.js.map +1 -0
  533. package/sdk/dist/query/command-aliases.generated.d.ts +31 -0
  534. package/sdk/dist/query/command-aliases.generated.d.ts.map +1 -0
  535. package/sdk/dist/query/command-aliases.generated.js +135 -0
  536. package/sdk/dist/query/command-aliases.generated.js.map +1 -0
  537. package/sdk/dist/query/command-catalog.d.ts +9 -0
  538. package/sdk/dist/query/command-catalog.d.ts.map +1 -0
  539. package/sdk/dist/query/command-catalog.js +17 -0
  540. package/sdk/dist/query/command-catalog.js.map +1 -0
  541. package/sdk/dist/query/command-definition.d.ts +19 -0
  542. package/sdk/dist/query/command-definition.d.ts.map +1 -0
  543. package/sdk/dist/query/command-definition.js +44 -0
  544. package/sdk/dist/query/command-definition.js.map +1 -0
  545. package/sdk/dist/query/command-family-handlers.d.ts +3 -0
  546. package/sdk/dist/query/command-family-handlers.d.ts.map +1 -0
  547. package/sdk/dist/query/command-family-handlers.js +94 -0
  548. package/sdk/dist/query/command-family-handlers.js.map +1 -0
  549. package/sdk/dist/query/command-manifest.d.ts +2 -0
  550. package/sdk/dist/query/command-manifest.d.ts.map +1 -0
  551. package/sdk/dist/query/command-manifest.init.d.ts +6 -0
  552. package/sdk/dist/query/command-manifest.init.d.ts.map +1 -0
  553. package/sdk/dist/query/command-manifest.init.js +23 -0
  554. package/sdk/dist/query/command-manifest.init.js.map +1 -0
  555. package/sdk/dist/query/command-manifest.js +17 -0
  556. package/sdk/dist/query/command-manifest.js.map +1 -0
  557. package/sdk/dist/query/command-manifest.non-family.d.ts +9 -0
  558. package/sdk/dist/query/command-manifest.non-family.d.ts.map +1 -0
  559. package/sdk/dist/query/command-manifest.non-family.js +59 -0
  560. package/sdk/dist/query/command-manifest.non-family.js.map +1 -0
  561. package/sdk/dist/query/command-manifest.phase.d.ts +6 -0
  562. package/sdk/dist/query/command-manifest.phase.d.ts.map +1 -0
  563. package/sdk/dist/query/command-manifest.phase.js +15 -0
  564. package/sdk/dist/query/command-manifest.phase.js.map +1 -0
  565. package/sdk/dist/query/command-manifest.phases.d.ts +7 -0
  566. package/sdk/dist/query/command-manifest.phases.d.ts.map +1 -0
  567. package/sdk/dist/query/command-manifest.phases.js +10 -0
  568. package/sdk/dist/query/command-manifest.phases.js.map +1 -0
  569. package/sdk/dist/query/command-manifest.roadmap.d.ts +6 -0
  570. package/sdk/dist/query/command-manifest.roadmap.d.ts.map +1 -0
  571. package/sdk/dist/query/command-manifest.roadmap.js +10 -0
  572. package/sdk/dist/query/command-manifest.roadmap.js.map +1 -0
  573. package/sdk/dist/query/command-manifest.state.d.ts +9 -0
  574. package/sdk/dist/query/command-manifest.state.d.ts.map +1 -0
  575. package/sdk/dist/query/command-manifest.state.js +30 -0
  576. package/sdk/dist/query/command-manifest.state.js.map +1 -0
  577. package/sdk/dist/query/command-manifest.types.d.ts +12 -0
  578. package/sdk/dist/query/command-manifest.types.d.ts.map +1 -0
  579. package/sdk/dist/query/command-manifest.types.js +2 -0
  580. package/sdk/dist/query/command-manifest.types.js.map +1 -0
  581. package/sdk/dist/query/command-manifest.validate.d.ts +6 -0
  582. package/sdk/dist/query/command-manifest.validate.d.ts.map +1 -0
  583. package/sdk/dist/query/command-manifest.validate.js +10 -0
  584. package/sdk/dist/query/command-manifest.validate.js.map +1 -0
  585. package/sdk/dist/query/command-manifest.verify.d.ts +6 -0
  586. package/sdk/dist/query/command-manifest.verify.d.ts.map +1 -0
  587. package/sdk/dist/query/command-manifest.verify.js +14 -0
  588. package/sdk/dist/query/command-manifest.verify.js.map +1 -0
  589. package/sdk/dist/query/command-static-catalog-domain.d.ts +3 -0
  590. package/sdk/dist/query/command-static-catalog-domain.d.ts.map +1 -0
  591. package/sdk/dist/query/command-static-catalog-domain.js +116 -0
  592. package/sdk/dist/query/command-static-catalog-domain.js.map +1 -0
  593. package/sdk/dist/query/command-static-catalog-foundation.d.ts +7 -0
  594. package/sdk/dist/query/command-static-catalog-foundation.d.ts.map +1 -0
  595. package/sdk/dist/query/command-static-catalog-foundation.js +98 -0
  596. package/sdk/dist/query/command-static-catalog-foundation.js.map +1 -0
  597. package/sdk/dist/query/command-topology.d.ts +32 -0
  598. package/sdk/dist/query/command-topology.d.ts.map +1 -0
  599. package/sdk/dist/query/command-topology.js +66 -0
  600. package/sdk/dist/query/command-topology.js.map +1 -0
  601. package/sdk/dist/query/commands-list.d.ts +14 -0
  602. package/sdk/dist/query/commands-list.d.ts.map +1 -0
  603. package/sdk/dist/query/commands-list.js +18 -0
  604. package/sdk/dist/query/commands-list.js.map +1 -0
  605. package/sdk/dist/query/commit.d.ts +79 -0
  606. package/sdk/dist/query/commit.d.ts.map +1 -0
  607. package/sdk/dist/query/commit.js +340 -0
  608. package/sdk/dist/query/commit.js.map +1 -0
  609. package/sdk/dist/query/config-gates.d.ts +12 -0
  610. package/sdk/dist/query/config-gates.d.ts.map +1 -0
  611. package/sdk/dist/query/config-gates.js +66 -0
  612. package/sdk/dist/query/config-gates.js.map +1 -0
  613. package/sdk/dist/query/config-mutation.d.ts +86 -0
  614. package/sdk/dist/query/config-mutation.d.ts.map +1 -0
  615. package/sdk/dist/query/config-mutation.js +518 -0
  616. package/sdk/dist/query/config-mutation.js.map +1 -0
  617. package/sdk/dist/query/config-query.d.ts +57 -0
  618. package/sdk/dist/query/config-query.d.ts.map +1 -0
  619. package/sdk/dist/query/config-query.js +208 -0
  620. package/sdk/dist/query/config-query.js.map +1 -0
  621. package/sdk/dist/query/config-schema.d.ts +36 -0
  622. package/sdk/dist/query/config-schema.d.ts.map +1 -0
  623. package/sdk/dist/query/config-schema.js +147 -0
  624. package/sdk/dist/query/config-schema.js.map +1 -0
  625. package/sdk/dist/query/decisions.d.ts +58 -0
  626. package/sdk/dist/query/decisions.d.ts.map +1 -0
  627. package/sdk/dist/query/decisions.js +161 -0
  628. package/sdk/dist/query/decisions.js.map +1 -0
  629. package/sdk/dist/query/detect-custom-files.d.ts +11 -0
  630. package/sdk/dist/query/detect-custom-files.d.ts.map +1 -0
  631. package/sdk/dist/query/detect-custom-files.js +89 -0
  632. package/sdk/dist/query/detect-custom-files.js.map +1 -0
  633. package/sdk/dist/query/detect-phase-type.d.ts +9 -0
  634. package/sdk/dist/query/detect-phase-type.d.ts.map +1 -0
  635. package/sdk/dist/query/detect-phase-type.js +124 -0
  636. package/sdk/dist/query/detect-phase-type.js.map +1 -0
  637. package/sdk/dist/query/docs-init.d.ts +26 -0
  638. package/sdk/dist/query/docs-init.d.ts.map +1 -0
  639. package/sdk/dist/query/docs-init.js +231 -0
  640. package/sdk/dist/query/docs-init.js.map +1 -0
  641. package/sdk/dist/query/fallow-audit.d.ts +44 -0
  642. package/sdk/dist/query/fallow-audit.d.ts.map +1 -0
  643. package/sdk/dist/query/fallow-audit.js +44 -0
  644. package/sdk/dist/query/fallow-audit.js.map +1 -0
  645. package/sdk/dist/query/frontmatter-mutation.d.ts +77 -0
  646. package/sdk/dist/query/frontmatter-mutation.d.ts.map +1 -0
  647. package/sdk/dist/query/frontmatter-mutation.js +317 -0
  648. package/sdk/dist/query/frontmatter-mutation.js.map +1 -0
  649. package/sdk/dist/query/frontmatter.d.ts +93 -0
  650. package/sdk/dist/query/frontmatter.d.ts.map +1 -0
  651. package/sdk/dist/query/frontmatter.js +365 -0
  652. package/sdk/dist/query/frontmatter.js.map +1 -0
  653. package/sdk/dist/query/helpers.d.ts +191 -0
  654. package/sdk/dist/query/helpers.d.ts.map +1 -0
  655. package/sdk/dist/query/helpers.js +613 -0
  656. package/sdk/dist/query/helpers.js.map +1 -0
  657. package/sdk/dist/query/index.d.ts +8 -0
  658. package/sdk/dist/query/index.d.ts.map +1 -0
  659. package/sdk/dist/query/index.js +6 -0
  660. package/sdk/dist/query/index.js.map +1 -0
  661. package/sdk/dist/query/init-complex.d.ts +47 -0
  662. package/sdk/dist/query/init-complex.d.ts.map +1 -0
  663. package/sdk/dist/query/init-complex.js +718 -0
  664. package/sdk/dist/query/init-complex.js.map +1 -0
  665. package/sdk/dist/query/init.d.ts +106 -0
  666. package/sdk/dist/query/init.d.ts.map +1 -0
  667. package/sdk/dist/query/init.js +1159 -0
  668. package/sdk/dist/query/init.js.map +1 -0
  669. package/sdk/dist/query/intel.d.ts +43 -0
  670. package/sdk/dist/query/intel.d.ts.map +1 -0
  671. package/sdk/dist/query/intel.js +416 -0
  672. package/sdk/dist/query/intel.js.map +1 -0
  673. package/sdk/dist/query/mutation-event-decorator.d.ts +5 -0
  674. package/sdk/dist/query/mutation-event-decorator.d.ts.map +1 -0
  675. package/sdk/dist/query/mutation-event-decorator.js +28 -0
  676. package/sdk/dist/query/mutation-event-decorator.js.map +1 -0
  677. package/sdk/dist/query/mutation-event-mapper.d.ts +4 -0
  678. package/sdk/dist/query/mutation-event-mapper.d.ts.map +1 -0
  679. package/sdk/dist/query/mutation-event-mapper.js +70 -0
  680. package/sdk/dist/query/mutation-event-mapper.js.map +1 -0
  681. package/sdk/dist/query/mvp.d.ts +113 -0
  682. package/sdk/dist/query/mvp.d.ts.map +1 -0
  683. package/sdk/dist/query/mvp.js +225 -0
  684. package/sdk/dist/query/mvp.js.map +1 -0
  685. package/sdk/dist/query/phase-filesystem-adapter.d.ts +4 -0
  686. package/sdk/dist/query/phase-filesystem-adapter.d.ts.map +1 -0
  687. package/sdk/dist/query/phase-filesystem-adapter.js +33 -0
  688. package/sdk/dist/query/phase-filesystem-adapter.js.map +1 -0
  689. package/sdk/dist/query/phase-lifecycle-policy.d.ts +34 -0
  690. package/sdk/dist/query/phase-lifecycle-policy.d.ts.map +1 -0
  691. package/sdk/dist/query/phase-lifecycle-policy.js +138 -0
  692. package/sdk/dist/query/phase-lifecycle-policy.js.map +1 -0
  693. package/sdk/dist/query/phase-lifecycle.d.ts +116 -0
  694. package/sdk/dist/query/phase-lifecycle.d.ts.map +1 -0
  695. package/sdk/dist/query/phase-lifecycle.js +1486 -0
  696. package/sdk/dist/query/phase-lifecycle.js.map +1 -0
  697. package/sdk/dist/query/phase-list-queries.d.ts +18 -0
  698. package/sdk/dist/query/phase-list-queries.d.ts.map +1 -0
  699. package/sdk/dist/query/phase-list-queries.js +129 -0
  700. package/sdk/dist/query/phase-list-queries.js.map +1 -0
  701. package/sdk/dist/query/phase-ready.d.ts +9 -0
  702. package/sdk/dist/query/phase-ready.d.ts.map +1 -0
  703. package/sdk/dist/query/phase-ready.js +132 -0
  704. package/sdk/dist/query/phase-ready.js.map +1 -0
  705. package/sdk/dist/query/phase-roadmap-mutation.d.ts +13 -0
  706. package/sdk/dist/query/phase-roadmap-mutation.d.ts.map +1 -0
  707. package/sdk/dist/query/phase-roadmap-mutation.js +65 -0
  708. package/sdk/dist/query/phase-roadmap-mutation.js.map +1 -0
  709. package/sdk/dist/query/phase.d.ts +48 -0
  710. package/sdk/dist/query/phase.d.ts.map +1 -0
  711. package/sdk/dist/query/phase.js +451 -0
  712. package/sdk/dist/query/phase.js.map +1 -0
  713. package/sdk/dist/query/pipeline.d.ts +53 -0
  714. package/sdk/dist/query/pipeline.d.ts.map +1 -0
  715. package/sdk/dist/query/pipeline.js +198 -0
  716. package/sdk/dist/query/pipeline.js.map +1 -0
  717. package/sdk/dist/query/plan-scan.d.ts +14 -0
  718. package/sdk/dist/query/plan-scan.d.ts.map +1 -0
  719. package/sdk/dist/query/plan-scan.js +70 -0
  720. package/sdk/dist/query/plan-scan.js.map +1 -0
  721. package/sdk/dist/query/plan-task-structure.d.ts +9 -0
  722. package/sdk/dist/query/plan-task-structure.d.ts.map +1 -0
  723. package/sdk/dist/query/plan-task-structure.js +59 -0
  724. package/sdk/dist/query/plan-task-structure.js.map +1 -0
  725. package/sdk/dist/query/profile-extract-messages.d.ts +40 -0
  726. package/sdk/dist/query/profile-extract-messages.d.ts.map +1 -0
  727. package/sdk/dist/query/profile-extract-messages.js +195 -0
  728. package/sdk/dist/query/profile-extract-messages.js.map +1 -0
  729. package/sdk/dist/query/profile-output.d.ts +11 -0
  730. package/sdk/dist/query/profile-output.d.ts.map +1 -0
  731. package/sdk/dist/query/profile-output.js +873 -0
  732. package/sdk/dist/query/profile-output.js.map +1 -0
  733. package/sdk/dist/query/profile-questionnaire-data.d.ts +21 -0
  734. package/sdk/dist/query/profile-questionnaire-data.d.ts.map +1 -0
  735. package/sdk/dist/query/profile-questionnaire-data.js +171 -0
  736. package/sdk/dist/query/profile-questionnaire-data.js.map +1 -0
  737. package/sdk/dist/query/profile-sample.d.ts +22 -0
  738. package/sdk/dist/query/profile-sample.d.ts.map +1 -0
  739. package/sdk/dist/query/profile-sample.js +136 -0
  740. package/sdk/dist/query/profile-sample.js.map +1 -0
  741. package/sdk/dist/query/profile-scan-sessions.d.ts +49 -0
  742. package/sdk/dist/query/profile-scan-sessions.d.ts.map +1 -0
  743. package/sdk/dist/query/profile-scan-sessions.js +137 -0
  744. package/sdk/dist/query/profile-scan-sessions.js.map +1 -0
  745. package/sdk/dist/query/profile.d.ts +61 -0
  746. package/sdk/dist/query/profile.d.ts.map +1 -0
  747. package/sdk/dist/query/profile.js +307 -0
  748. package/sdk/dist/query/profile.js.map +1 -0
  749. package/sdk/dist/query/progress.d.ts +77 -0
  750. package/sdk/dist/query/progress.d.ts.map +1 -0
  751. package/sdk/dist/query/progress.js +481 -0
  752. package/sdk/dist/query/progress.js.map +1 -0
  753. package/sdk/dist/query/query-cli-adapter.d.ts +8 -0
  754. package/sdk/dist/query/query-cli-adapter.d.ts.map +1 -0
  755. package/sdk/dist/query/query-cli-adapter.js +32 -0
  756. package/sdk/dist/query/query-cli-adapter.js.map +1 -0
  757. package/sdk/dist/query/query-cli-output.d.ts +9 -0
  758. package/sdk/dist/query/query-cli-output.d.ts.map +1 -0
  759. package/sdk/dist/query/query-cli-output.js +28 -0
  760. package/sdk/dist/query/query-cli-output.js.map +1 -0
  761. package/sdk/dist/query/query-command-diagnosis.d.ts +6 -0
  762. package/sdk/dist/query/query-command-diagnosis.d.ts.map +1 -0
  763. package/sdk/dist/query/query-command-diagnosis.js +6 -0
  764. package/sdk/dist/query/query-command-diagnosis.js.map +1 -0
  765. package/sdk/dist/query/query-command-resolution-strategy.d.ts +29 -0
  766. package/sdk/dist/query/query-command-resolution-strategy.d.ts.map +1 -0
  767. package/sdk/dist/query/query-command-resolution-strategy.js +103 -0
  768. package/sdk/dist/query/query-command-resolution-strategy.js.map +1 -0
  769. package/sdk/dist/query/query-command-semantics.d.ts +7 -0
  770. package/sdk/dist/query/query-command-semantics.d.ts.map +1 -0
  771. package/sdk/dist/query/query-command-semantics.js +7 -0
  772. package/sdk/dist/query/query-command-semantics.js.map +1 -0
  773. package/sdk/dist/query/query-dispatch-contract.d.ts +21 -0
  774. package/sdk/dist/query/query-dispatch-contract.d.ts.map +1 -0
  775. package/sdk/dist/query/query-dispatch-contract.js +2 -0
  776. package/sdk/dist/query/query-dispatch-contract.js.map +1 -0
  777. package/sdk/dist/query/query-dispatch-error-mapper.d.ts +6 -0
  778. package/sdk/dist/query/query-dispatch-error-mapper.d.ts.map +1 -0
  779. package/sdk/dist/query/query-dispatch-error-mapper.js +6 -0
  780. package/sdk/dist/query/query-dispatch-error-mapper.js.map +1 -0
  781. package/sdk/dist/query/query-dispatch-formatting.d.ts +6 -0
  782. package/sdk/dist/query/query-dispatch-formatting.d.ts.map +1 -0
  783. package/sdk/dist/query/query-dispatch-formatting.js +6 -0
  784. package/sdk/dist/query/query-dispatch-formatting.js.map +1 -0
  785. package/sdk/dist/query/query-dispatch-input-validation.d.ts +6 -0
  786. package/sdk/dist/query/query-dispatch-input-validation.d.ts.map +1 -0
  787. package/sdk/dist/query/query-dispatch-input-validation.js +6 -0
  788. package/sdk/dist/query/query-dispatch-input-validation.js.map +1 -0
  789. package/sdk/dist/query/query-dispatch-observability.d.ts +2 -0
  790. package/sdk/dist/query/query-dispatch-observability.d.ts.map +1 -0
  791. package/sdk/dist/query/query-dispatch-observability.js +7 -0
  792. package/sdk/dist/query/query-dispatch-observability.js.map +1 -0
  793. package/sdk/dist/query/query-dispatch-plan.d.ts +6 -0
  794. package/sdk/dist/query/query-dispatch-plan.d.ts.map +1 -0
  795. package/sdk/dist/query/query-dispatch-plan.js +6 -0
  796. package/sdk/dist/query/query-dispatch-plan.js.map +1 -0
  797. package/sdk/dist/query/query-dispatch-result-builder.d.ts +6 -0
  798. package/sdk/dist/query/query-dispatch-result-builder.d.ts.map +1 -0
  799. package/sdk/dist/query/query-dispatch-result-builder.js +6 -0
  800. package/sdk/dist/query/query-dispatch-result-builder.js.map +1 -0
  801. package/sdk/dist/query/query-dispatch.d.ts +48 -0
  802. package/sdk/dist/query/query-dispatch.d.ts.map +1 -0
  803. package/sdk/dist/query/query-dispatch.js +175 -0
  804. package/sdk/dist/query/query-dispatch.js.map +1 -0
  805. package/sdk/dist/query/query-error-details-schema.d.ts +19 -0
  806. package/sdk/dist/query/query-error-details-schema.d.ts.map +1 -0
  807. package/sdk/dist/query/query-error-details-schema.js +10 -0
  808. package/sdk/dist/query/query-error-details-schema.js.map +1 -0
  809. package/sdk/dist/query/query-error-taxonomy.d.ts +38 -0
  810. package/sdk/dist/query/query-error-taxonomy.d.ts.map +1 -0
  811. package/sdk/dist/query/query-error-taxonomy.js +74 -0
  812. package/sdk/dist/query/query-error-taxonomy.js.map +1 -0
  813. package/sdk/dist/query/query-fallback-bridge-adapter.d.ts +14 -0
  814. package/sdk/dist/query/query-fallback-bridge-adapter.d.ts.map +1 -0
  815. package/sdk/dist/query/query-fallback-bridge-adapter.js +33 -0
  816. package/sdk/dist/query/query-fallback-bridge-adapter.js.map +1 -0
  817. package/sdk/dist/query/query-fallback-executor.d.ts +11 -0
  818. package/sdk/dist/query/query-fallback-executor.d.ts.map +1 -0
  819. package/sdk/dist/query/query-fallback-executor.js +31 -0
  820. package/sdk/dist/query/query-fallback-executor.js.map +1 -0
  821. package/sdk/dist/query/query-fallback-output-classifier.d.ts +6 -0
  822. package/sdk/dist/query/query-fallback-output-classifier.d.ts.map +1 -0
  823. package/sdk/dist/query/query-fallback-output-classifier.js +27 -0
  824. package/sdk/dist/query/query-fallback-output-classifier.js.map +1 -0
  825. package/sdk/dist/query/query-fallback-policy.d.ts +6 -0
  826. package/sdk/dist/query/query-fallback-policy.d.ts.map +1 -0
  827. package/sdk/dist/query/query-fallback-policy.js +7 -0
  828. package/sdk/dist/query/query-fallback-policy.js.map +1 -0
  829. package/sdk/dist/query/query-native-dispatch-adapter.d.ts +7 -0
  830. package/sdk/dist/query/query-native-dispatch-adapter.d.ts.map +1 -0
  831. package/sdk/dist/query/query-native-dispatch-adapter.js +6 -0
  832. package/sdk/dist/query/query-native-dispatch-adapter.js.map +1 -0
  833. package/sdk/dist/query/query-policy-capability.d.ts +10 -0
  834. package/sdk/dist/query/query-policy-capability.d.ts.map +1 -0
  835. package/sdk/dist/query/query-policy-capability.js +17 -0
  836. package/sdk/dist/query/query-policy-capability.js.map +1 -0
  837. package/sdk/dist/query/query-runtime-context.d.ts +19 -0
  838. package/sdk/dist/query/query-runtime-context.d.ts.map +1 -0
  839. package/sdk/dist/query/query-runtime-context.js +31 -0
  840. package/sdk/dist/query/query-runtime-context.js.map +1 -0
  841. package/sdk/dist/query/query-unknown-command-hints.d.ts +2 -0
  842. package/sdk/dist/query/query-unknown-command-hints.d.ts.map +1 -0
  843. package/sdk/dist/query/query-unknown-command-hints.js +6 -0
  844. package/sdk/dist/query/query-unknown-command-hints.js.map +1 -0
  845. package/sdk/dist/query/registry-assembly-descriptor.d.ts +12 -0
  846. package/sdk/dist/query/registry-assembly-descriptor.d.ts.map +1 -0
  847. package/sdk/dist/query/registry-assembly-descriptor.js +61 -0
  848. package/sdk/dist/query/registry-assembly-descriptor.js.map +1 -0
  849. package/sdk/dist/query/registry-assembly-invariants.d.ts +30 -0
  850. package/sdk/dist/query/registry-assembly-invariants.d.ts.map +1 -0
  851. package/sdk/dist/query/registry-assembly-invariants.js +77 -0
  852. package/sdk/dist/query/registry-assembly-invariants.js.map +1 -0
  853. package/sdk/dist/query/registry-assembly.d.ts +10 -0
  854. package/sdk/dist/query/registry-assembly.d.ts.map +1 -0
  855. package/sdk/dist/query/registry-assembly.js +53 -0
  856. package/sdk/dist/query/registry-assembly.js.map +1 -0
  857. package/sdk/dist/query/registry.d.ts +90 -0
  858. package/sdk/dist/query/registry.d.ts.map +1 -0
  859. package/sdk/dist/query/registry.js +129 -0
  860. package/sdk/dist/query/registry.js.map +1 -0
  861. package/sdk/dist/query/requirements-extract-from-plans.d.ts +9 -0
  862. package/sdk/dist/query/requirements-extract-from-plans.d.ts.map +1 -0
  863. package/sdk/dist/query/requirements-extract-from-plans.js +76 -0
  864. package/sdk/dist/query/requirements-extract-from-plans.js.map +1 -0
  865. package/sdk/dist/query/roadmap-update-plan-progress.d.ts +11 -0
  866. package/sdk/dist/query/roadmap-update-plan-progress.d.ts.map +1 -0
  867. package/sdk/dist/query/roadmap-update-plan-progress.js +124 -0
  868. package/sdk/dist/query/roadmap-update-plan-progress.js.map +1 -0
  869. package/sdk/dist/query/roadmap.d.ts +137 -0
  870. package/sdk/dist/query/roadmap.d.ts.map +1 -0
  871. package/sdk/dist/query/roadmap.js +753 -0
  872. package/sdk/dist/query/roadmap.js.map +1 -0
  873. package/sdk/dist/query/route-next-action.d.ts +9 -0
  874. package/sdk/dist/query/route-next-action.d.ts.map +1 -0
  875. package/sdk/dist/query/route-next-action.js +318 -0
  876. package/sdk/dist/query/route-next-action.js.map +1 -0
  877. package/sdk/dist/query/schema-detect.d.ts +21 -0
  878. package/sdk/dist/query/schema-detect.d.ts.map +1 -0
  879. package/sdk/dist/query/schema-detect.js +146 -0
  880. package/sdk/dist/query/schema-detect.js.map +1 -0
  881. package/sdk/dist/query/secrets.d.ts +27 -0
  882. package/sdk/dist/query/secrets.d.ts.map +1 -0
  883. package/sdk/dist/query/secrets.js +42 -0
  884. package/sdk/dist/query/secrets.js.map +1 -0
  885. package/sdk/dist/query/skill-manifest.d.ts +50 -0
  886. package/sdk/dist/query/skill-manifest.d.ts.map +1 -0
  887. package/sdk/dist/query/skill-manifest.js +171 -0
  888. package/sdk/dist/query/skill-manifest.js.map +1 -0
  889. package/sdk/dist/query/skills.d.ts +27 -0
  890. package/sdk/dist/query/skills.d.ts.map +1 -0
  891. package/sdk/dist/query/skills.js +137 -0
  892. package/sdk/dist/query/skills.js.map +1 -0
  893. package/sdk/dist/query/state-document.d.ts +14 -0
  894. package/sdk/dist/query/state-document.d.ts.map +1 -0
  895. package/sdk/dist/query/state-document.js +110 -0
  896. package/sdk/dist/query/state-document.js.map +1 -0
  897. package/sdk/dist/query/state-mutation.d.ts +224 -0
  898. package/sdk/dist/query/state-mutation.d.ts.map +1 -0
  899. package/sdk/dist/query/state-mutation.js +1539 -0
  900. package/sdk/dist/query/state-mutation.js.map +1 -0
  901. package/sdk/dist/query/state-project-load.d.ts +23 -0
  902. package/sdk/dist/query/state-project-load.d.ts.map +1 -0
  903. package/sdk/dist/query/state-project-load.js +75 -0
  904. package/sdk/dist/query/state-project-load.js.map +1 -0
  905. package/sdk/dist/query/state.d.ts +78 -0
  906. package/sdk/dist/query/state.d.ts.map +1 -0
  907. package/sdk/dist/query/state.js +430 -0
  908. package/sdk/dist/query/state.js.map +1 -0
  909. package/sdk/dist/query/summary.d.ts +18 -0
  910. package/sdk/dist/query/summary.d.ts.map +1 -0
  911. package/sdk/dist/query/summary.js +249 -0
  912. package/sdk/dist/query/summary.js.map +1 -0
  913. package/sdk/dist/query/template.d.ts +46 -0
  914. package/sdk/dist/query/template.d.ts.map +1 -0
  915. package/sdk/dist/query/template.js +210 -0
  916. package/sdk/dist/query/template.js.map +1 -0
  917. package/sdk/dist/query/uat.d.ts +34 -0
  918. package/sdk/dist/query/uat.d.ts.map +1 -0
  919. package/sdk/dist/query/uat.js +339 -0
  920. package/sdk/dist/query/uat.js.map +1 -0
  921. package/sdk/dist/query/utils.d.ts +59 -0
  922. package/sdk/dist/query/utils.d.ts.map +1 -0
  923. package/sdk/dist/query/utils.js +74 -0
  924. package/sdk/dist/query/utils.js.map +1 -0
  925. package/sdk/dist/query/validate.d.ts +67 -0
  926. package/sdk/dist/query/validate.d.ts.map +1 -0
  927. package/sdk/dist/query/validate.js +908 -0
  928. package/sdk/dist/query/validate.js.map +1 -0
  929. package/sdk/dist/query/verify.d.ts +110 -0
  930. package/sdk/dist/query/verify.d.ts.map +1 -0
  931. package/sdk/dist/query/verify.js +631 -0
  932. package/sdk/dist/query/verify.js.map +1 -0
  933. package/sdk/dist/query/websearch.d.ts +24 -0
  934. package/sdk/dist/query/websearch.d.ts.map +1 -0
  935. package/sdk/dist/query/websearch.js +68 -0
  936. package/sdk/dist/query/websearch.js.map +1 -0
  937. package/sdk/dist/query/workspace.d.ts +62 -0
  938. package/sdk/dist/query/workspace.d.ts.map +1 -0
  939. package/sdk/dist/query/workspace.js +104 -0
  940. package/sdk/dist/query/workspace.js.map +1 -0
  941. package/sdk/dist/query/workstream-inventory.d.ts +52 -0
  942. package/sdk/dist/query/workstream-inventory.d.ts.map +1 -0
  943. package/sdk/dist/query/workstream-inventory.js +141 -0
  944. package/sdk/dist/query/workstream-inventory.js.map +1 -0
  945. package/sdk/dist/query/workstream.d.ts +35 -0
  946. package/sdk/dist/query/workstream.d.ts.map +1 -0
  947. package/sdk/dist/query/workstream.js +298 -0
  948. package/sdk/dist/query/workstream.js.map +1 -0
  949. package/sdk/dist/query/worktree.d.ts +3 -0
  950. package/sdk/dist/query/worktree.d.ts.map +1 -0
  951. package/sdk/dist/query/worktree.js +36 -0
  952. package/sdk/dist/query/worktree.js.map +1 -0
  953. package/sdk/dist/query-command-executor.d.ts +22 -0
  954. package/sdk/dist/query-command-executor.d.ts.map +1 -0
  955. package/sdk/dist/query-command-executor.js +22 -0
  956. package/sdk/dist/query-command-executor.js.map +1 -0
  957. package/sdk/dist/query-execution-policy.d.ts +24 -0
  958. package/sdk/dist/query-execution-policy.d.ts.map +1 -0
  959. package/sdk/dist/query-execution-policy.js +27 -0
  960. package/sdk/dist/query-execution-policy.js.map +1 -0
  961. package/sdk/dist/query-failure-classification.d.ts +9 -0
  962. package/sdk/dist/query-failure-classification.d.ts.map +1 -0
  963. package/sdk/dist/query-failure-classification.js +32 -0
  964. package/sdk/dist/query-failure-classification.js.map +1 -0
  965. package/sdk/dist/query-hotpath-methods.d.ts +19 -0
  966. package/sdk/dist/query-hotpath-methods.d.ts.map +1 -0
  967. package/sdk/dist/query-hotpath-methods.js +34 -0
  968. package/sdk/dist/query-hotpath-methods.js.map +1 -0
  969. package/sdk/dist/query-native-direct-adapter.d.ts +20 -0
  970. package/sdk/dist/query-native-direct-adapter.d.ts.map +1 -0
  971. package/sdk/dist/query-native-direct-adapter.js +52 -0
  972. package/sdk/dist/query-native-direct-adapter.js.map +1 -0
  973. package/sdk/dist/query-native-hotpath-adapter.d.ts +15 -0
  974. package/sdk/dist/query-native-hotpath-adapter.d.ts.map +1 -0
  975. package/sdk/dist/query-native-hotpath-adapter.js +32 -0
  976. package/sdk/dist/query-native-hotpath-adapter.js.map +1 -0
  977. package/sdk/dist/query-raw-output-projection.d.ts +6 -0
  978. package/sdk/dist/query-raw-output-projection.d.ts.map +1 -0
  979. package/sdk/dist/query-raw-output-projection.js +67 -0
  980. package/sdk/dist/query-raw-output-projection.js.map +1 -0
  981. package/sdk/dist/query-runtime-bridge.d.ts +61 -0
  982. package/sdk/dist/query-runtime-bridge.d.ts.map +1 -0
  983. package/sdk/dist/query-runtime-bridge.js +144 -0
  984. package/sdk/dist/query-runtime-bridge.js.map +1 -0
  985. package/sdk/dist/query-sdd-tools-path.d.ts +2 -0
  986. package/sdk/dist/query-sdd-tools-path.d.ts.map +1 -0
  987. package/sdk/dist/query-sdd-tools-path.js +2 -0
  988. package/sdk/dist/query-sdd-tools-path.js.map +1 -0
  989. package/sdk/dist/query-sdd-tools-runtime.d.ts +20 -0
  990. package/sdk/dist/query-sdd-tools-runtime.d.ts.map +1 -0
  991. package/sdk/dist/query-sdd-tools-runtime.js +47 -0
  992. package/sdk/dist/query-sdd-tools-runtime.js.map +1 -0
  993. package/sdk/dist/query-subprocess-adapter.d.ts +18 -0
  994. package/sdk/dist/query-subprocess-adapter.d.ts.map +1 -0
  995. package/sdk/dist/query-subprocess-adapter.js +92 -0
  996. package/sdk/dist/query-subprocess-adapter.js.map +1 -0
  997. package/sdk/dist/query-tools-error-factory.d.ts +16 -0
  998. package/sdk/dist/query-tools-error-factory.d.ts.map +1 -0
  999. package/sdk/dist/query-tools-error-factory.js +33 -0
  1000. package/sdk/dist/query-tools-error-factory.js.map +1 -0
  1001. package/sdk/dist/research-gate.d.ts +24 -0
  1002. package/sdk/dist/research-gate.d.ts.map +1 -0
  1003. package/sdk/dist/research-gate.js +70 -0
  1004. package/sdk/dist/research-gate.js.map +1 -0
  1005. package/sdk/dist/runtime-gate.d.ts +14 -0
  1006. package/sdk/dist/runtime-gate.d.ts.map +1 -0
  1007. package/sdk/dist/runtime-gate.js +48 -0
  1008. package/sdk/dist/runtime-gate.js.map +1 -0
  1009. package/sdk/dist/sdd-tools-error.d.ts +23 -0
  1010. package/sdk/dist/sdd-tools-error.d.ts.map +1 -0
  1011. package/sdk/dist/sdd-tools-error.js +29 -0
  1012. package/sdk/dist/sdd-tools-error.js.map +1 -0
  1013. package/sdk/dist/sdd-tools.d.ts +97 -0
  1014. package/sdk/dist/sdd-tools.d.ts.map +1 -0
  1015. package/sdk/dist/sdd-tools.js +168 -0
  1016. package/sdk/dist/sdd-tools.js.map +1 -0
  1017. package/sdk/dist/sdd-transport-policy.d.ts +10 -0
  1018. package/sdk/dist/sdd-transport-policy.d.ts.map +1 -0
  1019. package/sdk/dist/sdd-transport-policy.js +32 -0
  1020. package/sdk/dist/sdd-transport-policy.js.map +1 -0
  1021. package/sdk/dist/sdd-transport.d.ts +39 -0
  1022. package/sdk/dist/sdd-transport.d.ts.map +1 -0
  1023. package/sdk/dist/sdd-transport.js +78 -0
  1024. package/sdk/dist/sdd-transport.js.map +1 -0
  1025. package/sdk/dist/sdk-package-compatibility.d.ts +38 -0
  1026. package/sdk/dist/sdk-package-compatibility.d.ts.map +1 -0
  1027. package/sdk/dist/sdk-package-compatibility.js +90 -0
  1028. package/sdk/dist/sdk-package-compatibility.js.map +1 -0
  1029. package/sdk/dist/session-runner.d.ts +40 -0
  1030. package/sdk/dist/session-runner.d.ts.map +1 -0
  1031. package/sdk/dist/session-runner.js +274 -0
  1032. package/sdk/dist/session-runner.js.map +1 -0
  1033. package/sdk/dist/tool-scoping.d.ts +31 -0
  1034. package/sdk/dist/tool-scoping.d.ts.map +1 -0
  1035. package/sdk/dist/tool-scoping.js +54 -0
  1036. package/sdk/dist/tool-scoping.js.map +1 -0
  1037. package/sdk/dist/types.d.ts +794 -0
  1038. package/sdk/dist/types.d.ts.map +1 -0
  1039. package/sdk/dist/types.js +77 -0
  1040. package/sdk/dist/types.js.map +1 -0
  1041. package/sdk/dist/workstream-name-policy.d.ts +13 -0
  1042. package/sdk/dist/workstream-name-policy.d.ts.map +1 -0
  1043. package/sdk/dist/workstream-name-policy.js +24 -0
  1044. package/sdk/dist/workstream-name-policy.js.map +1 -0
  1045. package/sdk/dist/workstream-utils.d.ts +15 -0
  1046. package/sdk/dist/workstream-utils.d.ts.map +1 -0
  1047. package/sdk/dist/workstream-utils.js +21 -0
  1048. package/sdk/dist/workstream-utils.js.map +1 -0
  1049. package/sdk/dist/ws-transport.d.ts +32 -0
  1050. package/sdk/dist/ws-transport.d.ts.map +1 -0
  1051. package/sdk/dist/ws-transport.js +84 -0
  1052. package/sdk/dist/ws-transport.js.map +1 -0
  1053. package/sdk/package-lock.json +2502 -0
  1054. package/sdk/package.json +57 -0
  1055. package/sdk/prompts/templates/project.md +186 -0
  1056. package/sdk/prompts/templates/requirements.md +231 -0
  1057. package/sdk/prompts/templates/research-project/ARCHITECTURE.md +204 -0
  1058. package/sdk/prompts/templates/research-project/FEATURES.md +147 -0
  1059. package/sdk/prompts/templates/research-project/PITFALLS.md +200 -0
  1060. package/sdk/prompts/templates/research-project/STACK.md +120 -0
  1061. package/sdk/prompts/templates/research-project/SUMMARY.md +170 -0
  1062. package/sdk/prompts/templates/roadmap.md +202 -0
  1063. package/sdk/prompts/templates/state.md +175 -0
  1064. package/sdk/shared/model-catalog.json +122 -0
  1065. package/sdk/src/assembled-prompts.test.ts +349 -0
  1066. package/sdk/src/bug-3591-sddtools-runtime-workstream.test.ts +179 -0
  1067. package/sdk/src/cli-transport.test.ts +388 -0
  1068. package/sdk/src/cli-transport.ts +130 -0
  1069. package/sdk/src/cli.test.ts +426 -0
  1070. package/sdk/src/cli.ts +589 -0
  1071. package/sdk/src/config.test.ts +271 -0
  1072. package/sdk/src/config.ts +218 -0
  1073. package/sdk/src/context-engine.test.ts +295 -0
  1074. package/sdk/src/context-engine.ts +170 -0
  1075. package/sdk/src/context-truncation.test.ts +163 -0
  1076. package/sdk/src/context-truncation.ts +233 -0
  1077. package/sdk/src/e2e.integration.test.ts +181 -0
  1078. package/sdk/src/errors.ts +72 -0
  1079. package/sdk/src/event-stream.test.ts +661 -0
  1080. package/sdk/src/event-stream.ts +441 -0
  1081. package/sdk/src/golden/capture.ts +95 -0
  1082. package/sdk/src/golden/fixtures/generate-slug.golden.json +1 -0
  1083. package/sdk/src/golden/fixtures/profile-sample-sessions/demo-project/sample.jsonl +3 -0
  1084. package/sdk/src/golden/fixtures/summary-extract-sample.md +26 -0
  1085. package/sdk/src/golden/fixtures/uat-render-checkpoint-sample.md +15 -0
  1086. package/sdk/src/golden/golden-integration-covered.ts +30 -0
  1087. package/sdk/src/golden/golden-mutation-covered.ts +17 -0
  1088. package/sdk/src/golden/golden-policy.test.ts +8 -0
  1089. package/sdk/src/golden/golden-policy.ts +120 -0
  1090. package/sdk/src/golden/golden.integration.test.ts +677 -0
  1091. package/sdk/src/golden/init-golden-normalize.ts +15 -0
  1092. package/sdk/src/golden/read-only-golden-rows.ts +77 -0
  1093. package/sdk/src/golden/read-only-parity.integration.test.ts +133 -0
  1094. package/sdk/src/golden/registry-canonical-commands.ts +31 -0
  1095. package/sdk/src/index.ts +352 -0
  1096. package/sdk/src/init-e2e.integration.test.ts +138 -0
  1097. package/sdk/src/init-runner.test.ts +740 -0
  1098. package/sdk/src/init-runner.ts +734 -0
  1099. package/sdk/src/lifecycle-e2e.integration.test.ts +258 -0
  1100. package/sdk/src/logger.test.ts +149 -0
  1101. package/sdk/src/logger.ts +113 -0
  1102. package/sdk/src/milestone-runner.test.ts +421 -0
  1103. package/sdk/src/model-catalog.ts +70 -0
  1104. package/sdk/src/phase-prompt.test.ts +535 -0
  1105. package/sdk/src/phase-prompt.ts +259 -0
  1106. package/sdk/src/phase-runner-types.test.ts +421 -0
  1107. package/sdk/src/phase-runner.integration.test.ts +377 -0
  1108. package/sdk/src/phase-runner.test.ts +2720 -0
  1109. package/sdk/src/phase-runner.ts +1442 -0
  1110. package/sdk/src/plan-parser.test.ts +579 -0
  1111. package/sdk/src/plan-parser.ts +431 -0
  1112. package/sdk/src/planning-journal.test.ts +70 -0
  1113. package/sdk/src/planning-journal.ts +153 -0
  1114. package/sdk/src/planning-runtime.test.ts +29 -0
  1115. package/sdk/src/planning-runtime.ts +100 -0
  1116. package/sdk/src/prompt-builder.test.ts +318 -0
  1117. package/sdk/src/prompt-builder.ts +218 -0
  1118. package/sdk/src/prompt-sanitizer.test.ts +260 -0
  1119. package/sdk/src/prompt-sanitizer.ts +116 -0
  1120. package/sdk/src/query/QUERY-HANDLERS.md +349 -0
  1121. package/sdk/src/query/active-workstream-store.ts +50 -0
  1122. package/sdk/src/query/agent-failure-classifier.test.ts +157 -0
  1123. package/sdk/src/query/agent-failure-classifier.ts +105 -0
  1124. package/sdk/src/query/audit-open.ts +722 -0
  1125. package/sdk/src/query/check-auto-mode.test.ts +77 -0
  1126. package/sdk/src/query/check-auto-mode.ts +49 -0
  1127. package/sdk/src/query/check-completion.test.ts +113 -0
  1128. package/sdk/src/query/check-completion.ts +182 -0
  1129. package/sdk/src/query/check-decision-coverage.test.ts +519 -0
  1130. package/sdk/src/query/check-decision-coverage.ts +554 -0
  1131. package/sdk/src/query/check-gates.test.ts +103 -0
  1132. package/sdk/src/query/check-gates.ts +112 -0
  1133. package/sdk/src/query/check-ship-ready.test.ts +111 -0
  1134. package/sdk/src/query/check-ship-ready.ts +104 -0
  1135. package/sdk/src/query/check-verification-status.test.ts +143 -0
  1136. package/sdk/src/query/check-verification-status.ts +160 -0
  1137. package/sdk/src/query/command-aliases.generated.ts +156 -0
  1138. package/sdk/src/query/command-catalog.ts +31 -0
  1139. package/sdk/src/query/command-definition.test.ts +47 -0
  1140. package/sdk/src/query/command-definition.ts +70 -0
  1141. package/sdk/src/query/command-family-handlers.ts +117 -0
  1142. package/sdk/src/query/command-manifest.init.ts +24 -0
  1143. package/sdk/src/query/command-manifest.non-family.ts +85 -0
  1144. package/sdk/src/query/command-manifest.phase.ts +16 -0
  1145. package/sdk/src/query/command-manifest.phases.ts +11 -0
  1146. package/sdk/src/query/command-manifest.roadmap.ts +11 -0
  1147. package/sdk/src/query/command-manifest.state.ts +31 -0
  1148. package/sdk/src/query/command-manifest.ts +17 -0
  1149. package/sdk/src/query/command-manifest.types.ts +13 -0
  1150. package/sdk/src/query/command-manifest.validate.ts +11 -0
  1151. package/sdk/src/query/command-manifest.verify.ts +15 -0
  1152. package/sdk/src/query/command-resolution.test.ts +70 -0
  1153. package/sdk/src/query/command-seam-coverage.test.ts +118 -0
  1154. package/sdk/src/query/command-static-catalog-domain.ts +117 -0
  1155. package/sdk/src/query/command-static-catalog-foundation.ts +103 -0
  1156. package/sdk/src/query/command-topology.test.ts +28 -0
  1157. package/sdk/src/query/command-topology.ts +114 -0
  1158. package/sdk/src/query/commands-list.test.ts +36 -0
  1159. package/sdk/src/query/commands-list.ts +19 -0
  1160. package/sdk/src/query/commit.test.ts +485 -0
  1161. package/sdk/src/query/commit.ts +383 -0
  1162. package/sdk/src/query/config-gates.test.ts +89 -0
  1163. package/sdk/src/query/config-gates.ts +69 -0
  1164. package/sdk/src/query/config-mutation.test.ts +598 -0
  1165. package/sdk/src/query/config-mutation.ts +575 -0
  1166. package/sdk/src/query/config-query.test.ts +367 -0
  1167. package/sdk/src/query/config-query.ts +244 -0
  1168. package/sdk/src/query/config-schema.ts +159 -0
  1169. package/sdk/src/query/decisions.test.ts +215 -0
  1170. package/sdk/src/query/decisions.ts +192 -0
  1171. package/sdk/src/query/decomposed-handlers.test.ts +431 -0
  1172. package/sdk/src/query/detect-custom-files.test.ts +115 -0
  1173. package/sdk/src/query/detect-custom-files.ts +96 -0
  1174. package/sdk/src/query/detect-phase-type.test.ts +105 -0
  1175. package/sdk/src/query/detect-phase-type.ts +141 -0
  1176. package/sdk/src/query/docs-init.ts +258 -0
  1177. package/sdk/src/query/fallow-audit.ts +88 -0
  1178. package/sdk/src/query/frontmatter-array.test.ts +14 -0
  1179. package/sdk/src/query/frontmatter-mutation.test.ts +259 -0
  1180. package/sdk/src/query/frontmatter-mutation.ts +343 -0
  1181. package/sdk/src/query/frontmatter.test.ts +326 -0
  1182. package/sdk/src/query/frontmatter.ts +395 -0
  1183. package/sdk/src/query/helpers.test.ts +615 -0
  1184. package/sdk/src/query/helpers.ts +646 -0
  1185. package/sdk/src/query/index-thin-seam.test.ts +16 -0
  1186. package/sdk/src/query/index.ts +9 -0
  1187. package/sdk/src/query/init-complex.test.ts +616 -0
  1188. package/sdk/src/query/init-complex.ts +799 -0
  1189. package/sdk/src/query/init-progress-precedence.test.ts +177 -0
  1190. package/sdk/src/query/init-workstream-milestone-op.test.ts +321 -0
  1191. package/sdk/src/query/init.test.ts +792 -0
  1192. package/sdk/src/query/init.ts +1262 -0
  1193. package/sdk/src/query/intel.test.ts +90 -0
  1194. package/sdk/src/query/intel.ts +404 -0
  1195. package/sdk/src/query/mutation-event-decorator.test.ts +45 -0
  1196. package/sdk/src/query/mutation-event-decorator.ts +37 -0
  1197. package/sdk/src/query/mutation-event-mapper.test.ts +33 -0
  1198. package/sdk/src/query/mutation-event-mapper.ts +102 -0
  1199. package/sdk/src/query/mvp.test.ts +335 -0
  1200. package/sdk/src/query/mvp.ts +292 -0
  1201. package/sdk/src/query/normalize-query-command.test.ts +102 -0
  1202. package/sdk/src/query/phase-filesystem-adapter.ts +35 -0
  1203. package/sdk/src/query/phase-lifecycle-policy.ts +171 -0
  1204. package/sdk/src/query/phase-lifecycle.test.ts +1750 -0
  1205. package/sdk/src/query/phase-lifecycle.ts +1833 -0
  1206. package/sdk/src/query/phase-list-queries.test.ts +88 -0
  1207. package/sdk/src/query/phase-list-queries.ts +152 -0
  1208. package/sdk/src/query/phase-ready.test.ts +65 -0
  1209. package/sdk/src/query/phase-ready.ts +159 -0
  1210. package/sdk/src/query/phase-roadmap-mutation.ts +77 -0
  1211. package/sdk/src/query/phase.test.ts +651 -0
  1212. package/sdk/src/query/phase.ts +550 -0
  1213. package/sdk/src/query/pipeline.test.ts +169 -0
  1214. package/sdk/src/query/pipeline.ts +243 -0
  1215. package/sdk/src/query/plan-scan.test.ts +35 -0
  1216. package/sdk/src/query/plan-scan.ts +82 -0
  1217. package/sdk/src/query/plan-task-structure.test.ts +65 -0
  1218. package/sdk/src/query/plan-task-structure.ts +63 -0
  1219. package/sdk/src/query/policy-convergence.test.ts +28 -0
  1220. package/sdk/src/query/profile-extract-messages.ts +247 -0
  1221. package/sdk/src/query/profile-output.ts +929 -0
  1222. package/sdk/src/query/profile-questionnaire-data.ts +181 -0
  1223. package/sdk/src/query/profile-sample.ts +184 -0
  1224. package/sdk/src/query/profile-scan-sessions.ts +174 -0
  1225. package/sdk/src/query/profile.test.ts +136 -0
  1226. package/sdk/src/query/profile.ts +337 -0
  1227. package/sdk/src/query/progress.test.ts +156 -0
  1228. package/sdk/src/query/progress.ts +566 -0
  1229. package/sdk/src/query/query-cli-adapter.test.ts +79 -0
  1230. package/sdk/src/query/query-cli-adapter.ts +39 -0
  1231. package/sdk/src/query/query-cli-output.test.ts +33 -0
  1232. package/sdk/src/query/query-cli-output.ts +35 -0
  1233. package/sdk/src/query/query-command-diagnosis.test.ts +22 -0
  1234. package/sdk/src/query/query-command-diagnosis.ts +5 -0
  1235. package/sdk/src/query/query-command-resolution-strategy.test.ts +34 -0
  1236. package/sdk/src/query/query-command-resolution-strategy.ts +121 -0
  1237. package/sdk/src/query/query-command-semantics.test.ts +22 -0
  1238. package/sdk/src/query/query-command-semantics.ts +22 -0
  1239. package/sdk/src/query/query-dispatch-contract.ts +30 -0
  1240. package/sdk/src/query/query-dispatch-error-mapper.test.ts +62 -0
  1241. package/sdk/src/query/query-dispatch-error-mapper.ts +5 -0
  1242. package/sdk/src/query/query-dispatch-formatting.test.ts +28 -0
  1243. package/sdk/src/query/query-dispatch-formatting.ts +5 -0
  1244. package/sdk/src/query/query-dispatch-input-validation.test.ts +23 -0
  1245. package/sdk/src/query/query-dispatch-input-validation.ts +5 -0
  1246. package/sdk/src/query/query-dispatch-observability.test.ts +10 -0
  1247. package/sdk/src/query/query-dispatch-observability.ts +6 -0
  1248. package/sdk/src/query/query-dispatch-plan.test.ts +25 -0
  1249. package/sdk/src/query/query-dispatch-plan.ts +5 -0
  1250. package/sdk/src/query/query-dispatch-result-builder.test.ts +16 -0
  1251. package/sdk/src/query/query-dispatch-result-builder.ts +5 -0
  1252. package/sdk/src/query/query-dispatch.test.ts +399 -0
  1253. package/sdk/src/query/query-dispatch.ts +243 -0
  1254. package/sdk/src/query/query-error-details-schema.ts +29 -0
  1255. package/sdk/src/query/query-error-taxonomy.test.ts +39 -0
  1256. package/sdk/src/query/query-error-taxonomy.ts +117 -0
  1257. package/sdk/src/query/query-fallback-bridge-adapter.test.ts +32 -0
  1258. package/sdk/src/query/query-fallback-bridge-adapter.ts +54 -0
  1259. package/sdk/src/query/query-fallback-executor.test.ts +82 -0
  1260. package/sdk/src/query/query-fallback-executor.ts +44 -0
  1261. package/sdk/src/query/query-fallback-output-classifier.test.ts +36 -0
  1262. package/sdk/src/query/query-fallback-output-classifier.ts +31 -0
  1263. package/sdk/src/query/query-fallback-policy.test.ts +13 -0
  1264. package/sdk/src/query/query-fallback-policy.ts +11 -0
  1265. package/sdk/src/query/query-native-dispatch-adapter.ts +16 -0
  1266. package/sdk/src/query/query-policy-capability.test.ts +10 -0
  1267. package/sdk/src/query/query-policy-capability.ts +26 -0
  1268. package/sdk/src/query/query-policy-snapshot.test.ts +9 -0
  1269. package/sdk/src/query/query-registry-capability.test.ts +14 -0
  1270. package/sdk/src/query/query-runtime-context.ts +44 -0
  1271. package/sdk/src/query/query-unknown-command-hints.test.ts +9 -0
  1272. package/sdk/src/query/query-unknown-command-hints.ts +5 -0
  1273. package/sdk/src/query/registry-assembly-descriptor.ts +87 -0
  1274. package/sdk/src/query/registry-assembly-invariants.ts +127 -0
  1275. package/sdk/src/query/registry-assembly.test.ts +138 -0
  1276. package/sdk/src/query/registry-assembly.ts +78 -0
  1277. package/sdk/src/query/registry.test.ts +208 -0
  1278. package/sdk/src/query/registry.ts +142 -0
  1279. package/sdk/src/query/requirements-extract-from-plans.test.ts +58 -0
  1280. package/sdk/src/query/requirements-extract-from-plans.ts +86 -0
  1281. package/sdk/src/query/roadmap-update-plan-progress.test.ts +233 -0
  1282. package/sdk/src/query/roadmap-update-plan-progress.ts +159 -0
  1283. package/sdk/src/query/roadmap.test.ts +1181 -0
  1284. package/sdk/src/query/roadmap.ts +894 -0
  1285. package/sdk/src/query/route-next-action.test.ts +61 -0
  1286. package/sdk/src/query/route-next-action.ts +345 -0
  1287. package/sdk/src/query/schema-detect.ts +189 -0
  1288. package/sdk/src/query/secrets.test.ts +66 -0
  1289. package/sdk/src/query/secrets.ts +43 -0
  1290. package/sdk/src/query/skill-manifest.test.ts +62 -0
  1291. package/sdk/src/query/skill-manifest.ts +216 -0
  1292. package/sdk/src/query/skills.test.ts +234 -0
  1293. package/sdk/src/query/skills.ts +143 -0
  1294. package/sdk/src/query/state-document.test.ts +197 -0
  1295. package/sdk/src/query/state-document.ts +129 -0
  1296. package/sdk/src/query/state-mutation.test.ts +1198 -0
  1297. package/sdk/src/query/state-mutation.ts +1718 -0
  1298. package/sdk/src/query/state-project-load.ts +80 -0
  1299. package/sdk/src/query/state.test.ts +616 -0
  1300. package/sdk/src/query/state.ts +463 -0
  1301. package/sdk/src/query/sub-repos-root.integration.test.ts +79 -0
  1302. package/sdk/src/query/summary.test.ts +95 -0
  1303. package/sdk/src/query/summary.ts +296 -0
  1304. package/sdk/src/query/template.test.ts +180 -0
  1305. package/sdk/src/query/template.ts +242 -0
  1306. package/sdk/src/query/uat.test.ts +77 -0
  1307. package/sdk/src/query/uat.ts +365 -0
  1308. package/sdk/src/query/utils.test.ts +82 -0
  1309. package/sdk/src/query/utils.ts +106 -0
  1310. package/sdk/src/query/validate.test.ts +831 -0
  1311. package/sdk/src/query/validate.ts +952 -0
  1312. package/sdk/src/query/verify.test.ts +414 -0
  1313. package/sdk/src/query/verify.ts +692 -0
  1314. package/sdk/src/query/websearch.test.ts +31 -0
  1315. package/sdk/src/query/websearch.ts +82 -0
  1316. package/sdk/src/query/workspace.test.ts +120 -0
  1317. package/sdk/src/query/workspace.ts +145 -0
  1318. package/sdk/src/query/workstream-inventory.ts +195 -0
  1319. package/sdk/src/query/workstream.test.ts +153 -0
  1320. package/sdk/src/query/workstream.ts +324 -0
  1321. package/sdk/src/query/worktree.ts +39 -0
  1322. package/sdk/src/query-command-executor.ts +31 -0
  1323. package/sdk/src/query-execution-policy.test.ts +52 -0
  1324. package/sdk/src/query-execution-policy.ts +46 -0
  1325. package/sdk/src/query-failure-classification.test.ts +23 -0
  1326. package/sdk/src/query-failure-classification.ts +42 -0
  1327. package/sdk/src/query-hotpath-methods.ts +48 -0
  1328. package/sdk/src/query-native-direct-adapter.test.ts +35 -0
  1329. package/sdk/src/query-native-direct-adapter.ts +70 -0
  1330. package/sdk/src/query-native-hotpath-adapter.test.ts +43 -0
  1331. package/sdk/src/query-native-hotpath-adapter.ts +45 -0
  1332. package/sdk/src/query-raw-output-projection.test.ts +39 -0
  1333. package/sdk/src/query-raw-output-projection.ts +74 -0
  1334. package/sdk/src/query-runtime-bridge.test.ts +150 -0
  1335. package/sdk/src/query-runtime-bridge.ts +215 -0
  1336. package/sdk/src/query-runtime-seam-coverage.test.ts +20 -0
  1337. package/sdk/src/query-sdd-tools-path.ts +1 -0
  1338. package/sdk/src/query-sdd-tools-runtime.ts +89 -0
  1339. package/sdk/src/query-subprocess-adapter.test.ts +84 -0
  1340. package/sdk/src/query-subprocess-adapter.ts +146 -0
  1341. package/sdk/src/query-tools-error-factory.test.ts +35 -0
  1342. package/sdk/src/query-tools-error-factory.ts +76 -0
  1343. package/sdk/src/research-gate.test.ts +190 -0
  1344. package/sdk/src/research-gate.ts +94 -0
  1345. package/sdk/src/runtime-bridge-options.test.ts +33 -0
  1346. package/sdk/src/runtime-gate.test.ts +84 -0
  1347. package/sdk/src/runtime-gate.ts +52 -0
  1348. package/sdk/src/sdd-tools-error.test.ts +21 -0
  1349. package/sdk/src/sdd-tools-error.ts +65 -0
  1350. package/sdk/src/sdd-tools.test.ts +472 -0
  1351. package/sdk/src/sdd-tools.ts +237 -0
  1352. package/sdk/src/sdd-transport-policy.test.ts +34 -0
  1353. package/sdk/src/sdd-transport-policy.ts +48 -0
  1354. package/sdk/src/sdd-transport.test.ts +292 -0
  1355. package/sdk/src/sdd-transport.ts +117 -0
  1356. package/sdk/src/sdk-package-compatibility.test.ts +97 -0
  1357. package/sdk/src/sdk-package-compatibility.ts +141 -0
  1358. package/sdk/src/session-runner.test.ts +164 -0
  1359. package/sdk/src/session-runner.ts +327 -0
  1360. package/sdk/src/tool-scoping.test.ts +160 -0
  1361. package/sdk/src/tool-scoping.ts +61 -0
  1362. package/sdk/src/types.ts +927 -0
  1363. package/sdk/src/workflow-agent-skills-consistency.test.ts +98 -0
  1364. package/sdk/src/workstream-name-policy.ts +24 -0
  1365. package/sdk/src/workstream-utils.ts +21 -0
  1366. package/sdk/src/ws-flag.test.ts +285 -0
  1367. package/sdk/src/ws-transport.test.ts +161 -0
  1368. package/sdk/src/ws-transport.ts +93 -0
  1369. package/sdk/tsconfig.json +20 -0
  1370. package/commands/sdd/add-backlog.md +0 -76
  1371. package/commands/sdd/add-phase.md +0 -43
  1372. package/commands/sdd/add-todo.md +0 -47
  1373. package/commands/sdd/check-todos.md +0 -45
  1374. package/commands/sdd/do.md +0 -30
  1375. package/commands/sdd/insert-phase.md +0 -32
  1376. package/commands/sdd/join-discord.md +0 -18
  1377. package/commands/sdd/list-phase-assumptions.md +0 -46
  1378. package/commands/sdd/list-workspaces.md +0 -19
  1379. package/commands/sdd/new-workspace.md +0 -44
  1380. package/commands/sdd/next.md +0 -24
  1381. package/commands/sdd/note.md +0 -34
  1382. package/commands/sdd/plan-milestone-gaps.md +0 -34
  1383. package/commands/sdd/plant-seed.md +0 -28
  1384. package/commands/sdd/reapply-patches.md +0 -123
  1385. package/commands/sdd/remove-phase.md +0 -31
  1386. package/commands/sdd/remove-workspace.md +0 -26
  1387. package/commands/sdd/research-phase.md +0 -195
  1388. package/commands/sdd/session-report.md +0 -19
  1389. package/commands/sdd/set-profile.md +0 -12
  1390. package/scripts/sync-upstream.sh +0 -56
  1391. package/sdd/commands/sdd/workstreams.md +0 -63
  1392. package/sdd/workflows/research-phase.md +0 -82
@@ -8,13 +8,13 @@ Orchestrator coordinates, not executes. Each subagent loads the full execute-pla
8
8
 
9
9
  <runtime_compatibility>
10
10
  **Subagent spawning is runtime-specific:**
11
- - **Claude Code:** Uses `Task(subagent_type="sdd-executor", ...)` — blocks until complete, returns result
11
+ - **Claude Code:** Uses `Agent(subagent_type="sdd-executor", ...)` — blocks until complete, returns result
12
12
  - **Copilot:** Subagent spawning does not reliably return completion signals. **Default to
13
13
  sequential inline execution**: read and follow execute-plan.md directly for each plan
14
14
  instead of spawning parallel agents. Only attempt parallel spawning if the user
15
15
  explicitly requests it — and in that case, rely on the spot-check fallback in step 3
16
16
  to detect completion.
17
- - **Other runtimes:** If `Task`/`task` tool is unavailable, use sequential inline execution as the
17
+ - **Other runtimes:** If `Agent`/`agent` tool is unavailable, use sequential inline execution as the
18
18
  fallback. Check for tool availability at runtime rather than assuming based on runtime name.
19
19
 
20
20
  **Fallback rule:** If a spawned agent completes its work (commits visible, SUMMARY.md exists) but
@@ -25,6 +25,9 @@ via filesystem and git state.
25
25
 
26
26
  <required_reading>
27
27
  Read STATE.md before any operation to load project context.
28
+ @~/.claude/sdd/references/agent-contracts.md
29
+ @~/.claude/sdd/references/context-budget.md
30
+ @~/.claude/sdd/references/gates.md
28
31
  </required_reading>
29
32
 
30
33
  <available_agent_types>
@@ -53,6 +56,8 @@ Parse `$ARGUMENTS` before loading any context:
53
56
  - First positional token → `PHASE_ARG`
54
57
  - Optional `--wave N` → `WAVE_FILTER`
55
58
  - Optional `--gaps-only` keeps its current meaning
59
+ - Optional `--cross-ai` → `CROSS_AI_FORCE=true` (force all plans through cross-AI execution)
60
+ - Optional `--no-cross-ai` → `CROSS_AI_DISABLED=true` (disable cross-AI for this run, overrides config and frontmatter)
56
61
 
57
62
  If `--wave` is absent, preserve the current behavior of executing all incomplete waves in the phase.
58
63
  </step>
@@ -61,12 +66,64 @@ If `--wave` is absent, preserve the current behavior of executing all incomplete
61
66
  Load all context in one call:
62
67
 
63
68
  ```bash
64
- INIT=$(node "$HOME/.claude/sdd/bin/sdd-tools.cjs" init execute-phase "${PHASE_ARG}")
69
+ INIT=$(sdd-sdk query init.execute-phase "${PHASE_ARG}")
65
70
  if [[ "$INIT" == @file:* ]]; then INIT=$(cat "${INIT#@file:}"); fi
66
- AGENT_SKILLS=$(node "$HOME/.claude/sdd/bin/sdd-tools.cjs" agent-skills sdd-executor 2>/dev/null)
71
+ AGENT_SKILLS=$(sdd-sdk query agent-skills sdd-executor)
67
72
  ```
68
73
 
69
- Parse JSON for: `executor_model`, `verifier_model`, `commit_docs`, `parallelization`, `branching_strategy`, `branch_name`, `phase_found`, `phase_dir`, `phase_number`, `phase_name`, `phase_slug`, `plans`, `incomplete_plans`, `plan_count`, `incomplete_count`, `state_exists`, `roadmap_exists`, `phase_req_ids`.
74
+ Parse JSON for: `executor_model`, `verifier_model`, `commit_docs`, `parallelization`, `branching_strategy`, `branch_name`, `phase_found`, `phase_dir`, `phase_number`, `phase_name`, `phase_slug`, `plans`, `incomplete_plans`, `plan_count`, `incomplete_count`, `state_exists`, `roadmap_exists`, `phase_req_ids`, `response_language`.
75
+
76
+ **Model resolution:** If `executor_model` is `"inherit"`, omit the `model=` parameter from all `Agent()` calls — do NOT pass `model="inherit"` to Agent. Omitting the `model=` parameter causes Claude Code to inherit the current orchestrator model automatically. Only set `model=` when `executor_model` is an explicit model name (e.g., `"claude-sonnet-4-6"`, `"claude-opus-4-7"`).
77
+
78
+ **If `response_language` is set:** Include `response_language: {value}` in all spawned subagent prompts so any user-facing output stays in the configured language.
79
+
80
+ Read runtime/worktree config and fail closed before any executor dispatch:
81
+
82
+ ```bash
83
+ RUNTIME=$(sdd-sdk query config-get runtime --default claude 2>/dev/null || echo "claude")
84
+ USE_WORKTREES=$(sdd-sdk query config-get workflow.use_worktrees 2>/dev/null || echo "true")
85
+ EXECUTOR_STALL_INTERVAL_MINUTES=$(sdd-sdk query config-get executor.stall_detect_interval_minutes 2>/dev/null || echo "5")
86
+ EXECUTOR_STALL_THRESHOLD_MINUTES=$(sdd-sdk query config-get executor.stall_threshold_minutes 2>/dev/null || echo "10")
87
+
88
+ if [ "$RUNTIME" = "codex" ] && [ "$USE_WORKTREES" != "false" ]; then
89
+ echo "FATAL: Codex execute-phase worktree isolation is unsupported. Set workflow.use_worktrees=false or use a runtime with Agent isolation=\"worktree\" support." >&2
90
+ exit 1
91
+ fi
92
+ ```
93
+ Codex maps subagents to `spawn_agent`, which has no direct Codex mapping for Claude Code's `isolation="worktree"` parameter. Failing closed prevents main-checkout edits while the workflow believes agents are isolated.
94
+
95
+ If the project uses git submodules, worktree isolation is unsafe **only when a plan touches a submodule path** — the executor commit protocol cannot correctly handle submodule commits inside isolated worktrees. The previous behavior unconditionally disabled worktree isolation whenever `.gitmodules` existed, which penalised every plan in a submodule project even when the plan was nowhere near a submodule. Compute submodule paths once and intersect them per-plan with the plan's declared `files_modified` frontmatter.
96
+
97
+ ```bash
98
+ # Parse submodule paths from .gitmodules once (empty if no .gitmodules).
99
+ # SUBMODULE_PATHS is a newline-separated list of repo-relative paths.
100
+ if [ -f .gitmodules ]; then
101
+ SUBMODULE_PATHS=$(git config --file .gitmodules --get-regexp '^submodule\..*\.path$' 2>/dev/null | awk '{print $2}')
102
+ else
103
+ SUBMODULE_PATHS=""
104
+ fi
105
+ ```
106
+
107
+ `SUBMODULE_PATHS` is exported to the `execute_waves` step, where the per-plan decision actually happens (see "Per-plan worktree decision" sub-step inside `execute_waves`). The decision is per-plan because different plans in the same wave can touch different files — only plans whose paths intersect a submodule must drop worktree isolation; plans nowhere near a submodule keep parallel isolation.
108
+
109
+ When `USE_WORKTREES` (project-level) is `false`, all executor agents run without `isolation="worktree"` — they execute sequentially on the main working tree instead of in parallel worktrees. The per-plan decision below has no effect when worktrees are project-disabled.
110
+
111
+ Read context window size for adaptive prompt enrichment:
112
+
113
+ ```bash
114
+ CONTEXT_WINDOW=$(sdd-sdk query config-get context_window 2>/dev/null || echo "200000")
115
+ ```
116
+
117
+ When `CONTEXT_WINDOW >= 500000` (1M-class models), subagent prompts include richer context:
118
+ - Executor agents receive prior wave SUMMARY.md files and the phase CONTEXT.md/RESEARCH.md
119
+ - Verifier agents receive all PLAN.md, SUMMARY.md, CONTEXT.md files plus REQUIREMENTS.md
120
+ - This enables cross-phase awareness and history-aware verification
121
+
122
+ When `CONTEXT_WINDOW < 200000` (sub-200K models), subagent prompts are thinned to reduce static overhead:
123
+ - Executor agents omit extended deviation rule examples and checkpoint examples from inline prompt — load on-demand via @~/.claude/sdd/references/executor-examples.md
124
+ - Planner agents omit extended anti-pattern lists and specificity examples from inline prompt — load on-demand via @~/.claude/sdd/references/planner-antipatterns.md
125
+ - Core rules and decision logic remain inline; only verbose examples and edge-case lists are extracted
126
+ - This reduces executor static overhead by ~40% while preserving behavioral correctness
70
127
 
71
128
  **If `phase_found` is false:** Error — phase directory not found.
72
129
  **If `plan_count` is 0:** Error — no plans found in phase.
@@ -76,7 +133,7 @@ When `parallelization` is false, plans within a wave execute sequentially.
76
133
 
77
134
  **Runtime detection for Copilot:**
78
135
  Check if the current runtime is Copilot by testing for the `@sdd-executor` agent pattern
79
- or absence of the `Task()` subagent API. If running under Copilot, force sequential inline
136
+ or absence of the `Agent()` subagent API. If running under Copilot, force sequential inline
80
137
  execution regardless of the `parallelization` setting — Copilot's subagent completion
81
138
  signals are unreliable (see `<runtime_compatibility>`). Set `COPILOT_SEQUENTIAL=true`
82
139
  internally and skip the `execute_waves` step in favor of `check_interactive_mode`'s
@@ -86,9 +143,73 @@ inline path for each plan.
86
143
  ```bash
87
144
  # REQUIRED: prevents stale auto-chain from previous --auto runs
88
145
  if [[ ! "$ARGUMENTS" =~ --auto ]]; then
89
- node "$HOME/.claude/sdd/bin/sdd-tools.cjs" config-set workflow._auto_chain_active false 2>/dev/null
146
+ sdd-sdk query config-set workflow._auto_chain_active false || true
90
147
  fi
91
148
  ```
149
+
150
+ Resolve `MVP_MODE` once via the centralized `phase.mvp-mode` query verb (precedence chain: CLI flag → ROADMAP `**Mode:** mvp` → `workflow.mvp_mode` config → false):
151
+ ```bash
152
+ MVP_FLAG_ARG=""
153
+ if [[ "$ARGUMENTS" =~ (^|[[:space:]])--mvp([[:space:]]|$) ]]; then MVP_FLAG_ARG="--cli-flag"; fi
154
+ MVP_MODE=$(sdd-sdk query phase.mvp-mode "${PHASE_NUMBER}" $MVP_FLAG_ARG --pick active)
155
+ TDD_MODE=$(sdd-sdk query config-get workflow.tdd_mode 2>/dev/null || echo "false")
156
+ ```
157
+
158
+ <step name="safe_resume_gate">
159
+ Before trusting `STATE.md` or dispatching any executor, derive `CURRENT_PLAN_ID`
160
+ from the active incomplete plan in `INIT`, then search recent history:
161
+ ```bash
162
+ CURRENT_PLAN_ID="{phase_number}-{plan_padded}"
163
+ SUMMARY_PATH="{phase_dir}/{plan_padded}-SUMMARY.md"
164
+ PLAN_COMMITS=$(git log --oneline --grep="${CURRENT_PLAN_ID}" -30)
165
+ ```
166
+ If production commits exist and `SUMMARY.md is missing`, stop before spawning a
167
+ new executor; continuing risks duplicate work and stale `STATE.md`/ROADMAP progress.
168
+ Offer these recovery options:
169
+ - `close out manually` — inspect commits, write SUMMARY.md, then update STATE/ROADMAP.
170
+ - `re-execute from scratch` — revert or supersede partial commits before dispatch.
171
+ - `mark-and-skip` — record the anomaly and move on only with explicit confirmation.
172
+ </step>
173
+
174
+ **MVP+TDD gate.** Task-scoped enforcement runs inside plan execution (immediately before each implementation step), where `TASK_FILE`, `PLAN_ID`, and `TASK_ID` are defined. Keep the same predicate and RED-commit contract:
175
+ ```bash
176
+ if [ "$MVP_MODE" = "true" ] && [ "$TDD_MODE" = "true" ]; then
177
+ IS_BEHAVIOR_ADDING=$(sdd-sdk query task.is-behavior-adding "$TASK_FILE" --pick is_behavior_adding)
178
+ if [ "$IS_BEHAVIOR_ADDING" = "true" ]; then
179
+ RED_COMMIT=$(git log --oneline --grep="^test(${PHASE_NUMBER}-${PLAN_ID}):" -- "**/*.test.*" "**/*.spec.*" "tests/" | head -1)
180
+ if [ -z "$RED_COMMIT" ]; then
181
+ sdd-sdk query state.update last_gate_trip "${PLAN_ID}/${TASK_ID}" || true
182
+ echo "MVP+TDD GATE TRIPPED: missing RED commit for ${PLAN_ID}/${TASK_ID}"
183
+ exit 1
184
+ fi
185
+ fi
186
+ fi
187
+ ```
188
+ Pure doc-only / config-only / test-only tasks return `is_behavior_adding=false` and are exempt. See `execute-mvp-tdd.md` for the halt report format.
189
+ </step>
190
+
191
+ <step name="check_blocking_antipatterns" priority="first">
192
+ **MANDATORY — Check for blocking anti-patterns before any other work.**
193
+
194
+ Look for a `.continue-here.md` in the current phase directory:
195
+
196
+ ```bash
197
+ ls ${phase_dir}/.continue-here.md 2>/dev/null || true
198
+ ```
199
+
200
+ If `.continue-here.md` exists, parse its "Critical Anti-Patterns" table for rows with `severity` = `blocking`.
201
+
202
+ **If one or more `blocking` anti-patterns are found:**
203
+
204
+ This step cannot be skipped. Before proceeding to `check_interactive_mode` or any other step, the agent must demonstrate understanding of each blocking anti-pattern by answering all three questions for each one:
205
+
206
+ 1. **What is this anti-pattern?** — Describe it in your own words, not by quoting the handoff.
207
+ 2. **How did it manifest?** — Explain the specific failure that caused it to be recorded.
208
+ 3. **What structural mechanism (not acknowledgment) prevents it?** — Name the concrete step, checklist item, or enforcement mechanism that stops recurrence.
209
+
210
+ Write these answers inline before continuing. If a blocking anti-pattern cannot be answered from the context in `.continue-here.md`, stop and ask the user for clarification.
211
+
212
+ **If no `.continue-here.md` exists, or no `blocking` rows are found:** Proceed directly to `check_interactive_mode`.
92
213
  </step>
93
214
 
94
215
  <step name="check_interactive_mode">
@@ -144,9 +265,33 @@ Check `branching_strategy` from init:
144
265
 
145
266
  **"none":** Skip, continue on current branch.
146
267
 
147
- **"phase" or "milestone":** Use pre-computed `branch_name` from init:
268
+ **"phase" or "milestone":** Use pre-computed `branch_name` from init.
269
+
270
+ Fork the new phase branch off `origin/HEAD` (the project's default branch), not the current HEAD — otherwise consecutive phases compound and stay unpushed (#2916). If `$BRANCH_NAME` already exists locally, reuse it as-is.
271
+
148
272
  ```bash
149
- git checkout -b "$BRANCH_NAME" 2>/dev/null || git checkout "$BRANCH_NAME"
273
+ DEFAULT_BRANCH=$(git symbolic-ref --quiet --short refs/remotes/origin/HEAD 2>/dev/null | sed 's|^origin/||')
274
+ DEFAULT_BRANCH=${DEFAULT_BRANCH:-main}
275
+
276
+ if git show-ref --verify --quiet "refs/heads/$BRANCH_NAME"; then
277
+ git switch "$BRANCH_NAME" || { echo "ERROR: Could not switch to existing branch '$BRANCH_NAME'." >&2; exit 1; }
278
+ else
279
+ if ! git fetch --quiet origin "$DEFAULT_BRANCH"; then # #2916
280
+ git show-ref --verify --quiet "refs/remotes/origin/$DEFAULT_BRANCH" \
281
+ || { echo "ERROR: fetch origin/$DEFAULT_BRANCH failed and no local copy exists. Refusing to create '$BRANCH_NAME' off current HEAD (#2916)." >&2; exit 1; }
282
+ echo "WARNING: fetch origin/$DEFAULT_BRANCH failed; using local copy as base." >&2
283
+ fi
284
+ if [ -n "$(git status --porcelain)" ]; then
285
+ echo "WARNING: Uncommitted changes will be carried onto '$BRANCH_NAME' (branched off origin/$DEFAULT_BRANCH, not previous HEAD)."
286
+ else
287
+ git switch --quiet "$DEFAULT_BRANCH" 2>/dev/null && git merge --ff-only --quiet "origin/$DEFAULT_BRANCH" 2>/dev/null || true
288
+ fi
289
+ # Pinned base + fail-fast: on success HEAD is exactly at origin/$DEFAULT_BRANCH,
290
+ # so a post-creation merge-base or "ahead-of" guard would be unreachable. The
291
+ # explicit base argument here is the single source of correctness for #2916.
292
+ git checkout -b "$BRANCH_NAME" "origin/$DEFAULT_BRANCH" \
293
+ || { echo "ERROR: Could not create '$BRANCH_NAME' from origin/$DEFAULT_BRANCH (#2916)." >&2; exit 1; }
294
+ fi
150
295
  ```
151
296
 
152
297
  All subsequent commits go to this branch. User handles merging.
@@ -159,7 +304,7 @@ Report: "Found {plan_count} plans in {phase_dir} ({incomplete_count} incomplete)
159
304
 
160
305
  **Update STATE.md for phase start:**
161
306
  ```bash
162
- node "$HOME/.claude/sdd/bin/sdd-tools.cjs" state begin-phase --phase "${PHASE_NUMBER}" --name "${PHASE_NAME}" --plans "${PLAN_COUNT}"
307
+ sdd-sdk query state.begin-phase --phase "${PHASE_NUMBER}" --name "${PHASE_NAME}" --plans "${PLAN_COUNT}"
163
308
  ```
164
309
  This updates Status, Last Activity, Current focus, Current Position, and plan counts in STATE.md so frontmatter and body text reflect the active phase immediately.
165
310
  </step>
@@ -168,7 +313,7 @@ This updates Status, Last Activity, Current focus, Current Position, and plan co
168
313
  Load plan inventory with wave grouping in one call:
169
314
 
170
315
  ```bash
171
- PLAN_INDEX=$(node "$HOME/.claude/sdd/bin/sdd-tools.cjs" phase-plan-index "${PHASE_NUMBER}")
316
+ PLAN_INDEX=$(sdd-sdk query phase-plan-index "${PHASE_NUMBER}")
172
317
  ```
173
318
 
174
319
  Parse JSON for: `phase`, `plans[]` (each with `id`, `wave`, `autonomous`, `objective`, `files_modified`, `task_count`, `has_summary`), `waves` (map of wave number → plan IDs), `incomplete`, `has_checkpoints`.
@@ -194,14 +339,147 @@ Report:
194
339
  ```
195
340
  </step>
196
341
 
342
+ <step name="cross_ai_delegation">
343
+ **Optional step 2.5 — Delegate plans to an external AI runtime.**
344
+
345
+ This step runs after plan discovery and before normal wave execution. It identifies plans
346
+ that should be delegated to an external AI command and executes them via stdin-based prompt
347
+ delivery. Plans handled here are removed from the execute_waves plan list so the normal
348
+ executor skips them.
349
+
350
+ **Activation logic:**
351
+
352
+ 1. If `CROSS_AI_DISABLED` is true (`--no-cross-ai` flag): skip this step entirely.
353
+ 2. If `CROSS_AI_FORCE` is true (`--cross-ai` flag): mark ALL incomplete plans for cross-AI execution.
354
+ 3. Otherwise: check each plan's frontmatter for `cross_ai: true` AND verify config
355
+ `workflow.cross_ai_execution` is `true`. Plans matching both conditions are marked for cross-AI.
356
+
357
+ ```bash
358
+ CROSS_AI_ENABLED=$(sdd-sdk query config-get workflow.cross_ai_execution 2>/dev/null || echo "false")
359
+ CROSS_AI_CMD=$(sdd-sdk query config-get workflow.cross_ai_command 2>/dev/null || echo "")
360
+ CROSS_AI_TIMEOUT=$(sdd-sdk query config-get workflow.cross_ai_timeout 2>/dev/null || echo "300")
361
+ ```
362
+
363
+ **If no plans are marked for cross-AI:** Skip to execute_waves.
364
+
365
+ **If plans are marked but `cross_ai_command` is empty:** Error — tell user to set
366
+ `workflow.cross_ai_command` via `sdd-sdk query config-set workflow.cross_ai_command "<command>"`.
367
+
368
+ **For each cross-AI plan (sequentially):**
369
+
370
+ 1. **Construct the task prompt** from the plan file:
371
+ - Extract `<objective>` and `<tasks>` sections from the PLAN.md
372
+ - Append PROJECT.md context (project name, description, tech stack)
373
+ - Format as a self-contained execution prompt
374
+
375
+ 2. **Check for dirty working tree before execution:**
376
+ ```bash
377
+ if ! git diff --quiet HEAD 2>/dev/null; then
378
+ echo "WARNING: dirty working tree detected — the external AI command may produce uncommitted changes that conflict with existing modifications"
379
+ fi
380
+ ```
381
+
382
+ 3. **Run the external command** from the project root, writing the prompt to stdin.
383
+ Never shell-interpolate the prompt — always pipe via stdin to prevent injection:
384
+ ```bash
385
+ echo "$TASK_PROMPT" | timeout "${CROSS_AI_TIMEOUT}s" ${CROSS_AI_CMD} > "$CANDIDATE_SUMMARY" 2>"$ERROR_LOG"
386
+ EXIT_CODE=$?
387
+ ```
388
+
389
+ 4. **Evaluate the result:**
390
+
391
+ **Success (exit 0 + valid summary):**
392
+ - Read `$CANDIDATE_SUMMARY` and validate it contains meaningful content
393
+ (not empty, has at least a heading and description — a valid SUMMARY.md structure)
394
+ - Write it as the plan's SUMMARY.md file
395
+ - Update STATE.md plan status to complete
396
+ - Update ROADMAP.md progress
397
+ - Mark plan as handled — skip it in execute_waves
398
+
399
+ **Failure (non-zero exit or invalid summary):**
400
+ - Display the error output and exit code
401
+ - Warn: "The external command may have left uncommitted changes or partial edits
402
+ in the working tree. Review `git status` and `git diff` before proceeding."
403
+ - Offer three choices:
404
+ - **retry** — run the same plan through cross-AI again
405
+ - **skip** — fall back to normal executor for this plan (re-add to execute_waves list)
406
+ - **abort** — stop execution entirely, preserve state for resume
407
+
408
+ 5. **After all cross-AI plans processed:** Remove successfully handled plans from the
409
+ incomplete plan list so execute_waves skips them. Any skipped-to-fallback plans remain
410
+ in the list for normal executor processing.
411
+ </step>
412
+
197
413
  <step name="execute_waves">
198
414
  Execute each selected wave in sequence. Within a wave: parallel if `PARALLELIZATION=true`, sequential if `false`.
199
415
 
416
+ **Stream-idle-timeout prevention — checkpoint heartbeats (#2410):**
417
+
418
+ Multi-plan phases can accumulate enough subagent context that the Claude API
419
+ SSE layer terminates with `Stream idle timeout - partial response received`
420
+ between a large tool_result and the next assistant turn (seen on Claude Code
421
+ + Opus 4.7 at ~200K+ cache_read). To keep the stream warm, emit short
422
+ assistant-text heartbeats — **no tool call, just a literal line** — at every
423
+ wave and plan boundary. Each heartbeat MUST start with `[checkpoint]` so
424
+ tooling and `/sdd:manager`'s background-completion handler can grep partial
425
+ transcripts. `{P}/{Q}` is the phase-wide completed/total plans counter and
426
+ increases monotonically across waves. `{status}` is `complete` (success),
427
+ `failed` (executor error), or `checkpoint` (human-gate returned).
428
+
429
+ ```
430
+ [checkpoint] phase {PHASE_NUMBER} wave {N}/{M} starting, {wave_plan_count} plan(s), {P}/{Q} plans done
431
+ [checkpoint] phase {PHASE_NUMBER} wave {N}/{M} plan {plan_id} starting ({P}/{Q} plans done)
432
+ [checkpoint] phase {PHASE_NUMBER} wave {N}/{M} plan {plan_id} {status} ({P}/{Q} plans done)
433
+ [checkpoint] phase {PHASE_NUMBER} wave {N}/{M} complete, {P}/{Q} plans done ({wave_success}/{wave_plan_count} ok)
434
+ ```
435
+
200
436
  **For each wave:**
201
437
 
202
- 1. **Describe what's being built (BEFORE spawning):**
438
+ 1. **Intra-wave files_modified overlap check (BEFORE spawning):**
439
+
440
+ Before spawning any agents for this wave, inspect the `files_modified` list of all plans
441
+ in the wave. Check every pair of plans in the wave — if any two plans share even one file
442
+ in their `files_modified` lists, those plans have an implicit dependency and MUST NOT run
443
+ in parallel.
444
+
445
+ **Detection algorithm (pseudocode):**
446
+ ```
447
+ seen_files = {}
448
+ overlapping_plans = []
449
+ for each plan in wave_plans:
450
+ for each file in plan.files_modified:
451
+ if file in seen_files:
452
+ overlapping_plans.add(plan, seen_files[file]) # both plans overlap on this file
453
+ else:
454
+ seen_files[file] = plan
455
+ ```
456
+
457
+ **If overlap is detected:**
458
+ - Warn the user:
459
+ ```
460
+ ⚠ Intra-wave files_modified overlap detected in Wave {N}:
461
+ Plan {A} and Plan {B} both modify {file}
462
+ Running these plans sequentially to avoid parallel worktree conflicts.
463
+ ```
464
+ - Override `PARALLELIZATION` to `false` for this wave only — run all plans in the wave
465
+ sequentially regardless of the global parallelization setting.
466
+ - This is a safety net for plans that were incorrectly assigned to the same wave.
467
+ The planner should have caught this; flag it as a planning defect so the user can
468
+ replan the phase if desired.
469
+
470
+ **If no overlap:** proceed normally (parallel if `PARALLELIZATION=true`).
471
+
472
+ 2. **Describe what's being built (BEFORE spawning):**
203
473
 
204
- Read each plan's `<objective>`. Extract what's being built and why.
474
+ **First, emit the wave-start checkpoint heartbeat as a literal assistant-text
475
+ line — no tool call (#2410). Do NOT skip this even for single-plan waves; it
476
+ is required before any further reasoning or spawning:**
477
+
478
+ ```
479
+ [checkpoint] phase {PHASE_NUMBER} wave {N}/{M} starting, {wave_plan_count} plan(s), {P}/{Q} plans done
480
+ ```
481
+
482
+ Then read each plan's `<objective>`. Extract what's being built and why.
205
483
 
206
484
  ```
207
485
  ---
@@ -217,29 +495,107 @@ Execute each selected wave in sequence. Within a wave: parallel if `PARALLELIZAT
217
495
  - Bad: "Executing terrain generation plan"
218
496
  - Good: "Procedural terrain generator using Perlin noise — creates height maps, biome zones, and collision meshes. Required before vehicle physics can interact with ground."
219
497
 
220
- 2. **Spawn executor agents:**
498
+ 2.5. **Per-plan worktree decision (run for each plan in this wave BEFORE its dispatch):**
499
+
500
+ Read and execute `sdd/workflows/execute-phase/steps/per-plan-worktree-gate.md` for each plan. It extracts `PLAN_FILES` from the plan's JSON, intersects against `SUBMODULE_PATHS` (with normalization, bidirectional matching, and glob-prefix handling), and sets `USE_WORKTREES_FOR_PLAN` to `false` when the plan touches a submodule path. Append `plan_id` to a `WAVE_WORKTREE_PLANS` accumulator when `USE_WORKTREES_FOR_PLAN != false`.
501
+
502
+ The dispatch branches in step 3 below MUST gate on `USE_WORKTREES_FOR_PLAN` for the current plan, not on the project-level `USE_WORKTREES`.
503
+
504
+ 3. **Spawn executor agents:**
505
+
506
+ **Emit a plan-start heartbeat (literal line, no tool call) immediately before
507
+ each `Agent()` dispatch (#2410):**
508
+
509
+ `[checkpoint] phase {PHASE_NUMBER} wave {N}/{M} plan {plan_id} starting ({P}/{Q} plans done)`
221
510
 
222
511
  Pass paths only — executors read files themselves with their fresh context window.
223
512
  For 200k models, this keeps orchestrator context lean (~10-15%).
224
513
  For 1M+ models (Opus 4.6, Sonnet 4.6), richer context can be passed directly.
225
514
 
515
+ **Worktree mode** (`USE_WORKTREES_FOR_PLAN` is not `false` — evaluated per-plan in step 2.5):
516
+
517
+ Before spawning, capture the current HEAD:
518
+ ```bash
519
+ EXPECTED_BASE=$(git rev-parse HEAD)
520
+ DISPATCH_TS=$(date -u +"%Y-%m-%dT%H:%M:%SZ")
521
+ EXPECTED_BRANCH=$(git rev-parse --abbrev-ref HEAD)
522
+ if [ "${USE_WORKTREES_FOR_PLAN:-true}" != "false" ] && [ -z "${WAVE_WORKTREE_MANIFEST:-}" ]; then
523
+ WAVE_WORKTREE_MANIFEST=$(mktemp "${TMPDIR:-/tmp}/sdd-worktree-wave-XXXXXX.json")
524
+ printf '{"worktrees":[]}\n' > "$WAVE_WORKTREE_MANIFEST"
525
+ export WAVE_WORKTREE_MANIFEST
526
+ fi
226
527
  ```
227
- Task(
528
+
529
+ **Sequential dispatch for parallel execution (waves with 2+ agents):**
530
+ Dispatch each `Agent()` call **one at a time with `run_in_background: true`**. Do NOT
531
+ send all Agent calls in a single message: simultaneous `git worktree add` calls race
532
+ on `.git/config.lock`. Agents still run in parallel once their worktrees are created.
533
+
534
+ ```text
535
+ # CORRECT: one Agent() per message with run_in_background: true
536
+ # WRONG: multiple Agent() calls in one message -> .git/config.lock contention
537
+ ```
538
+
539
+ ```text
540
+ Agent(
228
541
  subagent_type="sdd-executor",
229
- model="{executor_model}",
542
+ description="Execute plan {plan_number} of phase {phase_number}",
543
+ # Only include model= when executor_model is an explicit model name.
544
+ # When executor_model is "inherit", omit this parameter entirely so
545
+ # Claude Code inherits the orchestrator model automatically.
546
+ model="{executor_model}", # omit this line when executor_model == "inherit"
230
547
  isolation="worktree",
231
548
  prompt="
232
549
  <objective>
233
550
  Execute plan {plan_number} of phase {phase_number}-{phase_name}.
234
- Commit each task atomically. Create SUMMARY.md. Update STATE.md and ROADMAP.md.
551
+ Commit each task atomically. Create SUMMARY.md.
552
+ Do NOT update STATE.md or ROADMAP.md — the orchestrator owns those writes after all worktree agents in the wave complete.
235
553
  </objective>
236
554
 
555
+ <worktree_branch_check>
556
+ FIRST ACTION: HEAD assertion MUST run before any reset/checkout. Worktrees
557
+ spawned by Claude Code's `isolation="worktree"` use the `worktree-agent-<id>`
558
+ namespace. If HEAD is on a protected ref (main/master/develop/trunk/release/*)
559
+ or detached, HALT — do NOT self-recover by force-rewinding via `git update-ref`,
560
+ that destroys concurrent commits in multi-active scenarios (#2924). Only after
561
+ Step 1 passes is `git reset --hard` safe (#2015 — affects all platforms).
562
+ ```bash
563
+ HEAD_REF=$(git symbolic-ref --quiet HEAD || echo "DETACHED")
564
+ ACTUAL_BRANCH=$(git rev-parse --abbrev-ref HEAD)
565
+ if [ "$HEAD_REF" = "DETACHED" ] || echo "$ACTUAL_BRANCH" | grep -Eq '^(main|master|develop|trunk|release/.*)$'; then
566
+ echo "FATAL: worktree HEAD on '$ACTUAL_BRANCH' (expected worktree-agent-*); refusing to self-recover via 'git update-ref' (#2924)." >&2
567
+ exit 1
568
+ fi
569
+ if ! echo "$ACTUAL_BRANCH" | grep -Eq '^worktree-agent-[A-Za-z0-9._/-]+$'; then
570
+ echo "FATAL: worktree HEAD '$ACTUAL_BRANCH' is not in the worktree-agent-* namespace; refusing to commit (#2924)." >&2
571
+ exit 1
572
+ fi
573
+ ACTUAL_BASE=$(git merge-base HEAD {EXPECTED_BASE})
574
+ if [ "$ACTUAL_BASE" != "{EXPECTED_BASE}" ]; then
575
+ git reset --hard {EXPECTED_BASE}
576
+ [ "$(git rev-parse HEAD)" != "{EXPECTED_BASE}" ] && { echo "ERROR: could not correct worktree base"; exit 1; }
577
+ fi
578
+ ```
579
+ Per-commit HEAD/cwd-drift/path-guard: `agents/sdd-executor.md` steps 0/0a/0b + `references/worktree-path-safety.md` (in <execution_context>).
580
+ </worktree_branch_check>
581
+
237
582
  <parallel_execution>
238
- You are running as a PARALLEL executor agent. Use --no-verify on all git
239
- commits to avoid pre-commit hook contention with other agents. The
240
- orchestrator validates hooks once after all agents complete.
241
- For sdd-tools commits: add --no-verify flag.
242
- For direct git commits: use git commit --no-verify -m "..."
583
+ You are running as a PARALLEL executor agent in a git worktree. Worktree path safety (cwd-drift, absolute-path guards) is in `worktree-path-safety.md` (loaded below).
584
+ Run `git commit` normally hooks run by default. Do NOT pass `--no-verify`
585
+ unless the orchestrator surfaces `workflow.worktree_skip_hooks=true` in this
586
+ prompt; silent bypass violates project CLAUDE.md guidance (#2924).
587
+
588
+ IMPORTANT: Do NOT modify STATE.md or ROADMAP.md. execute-plan.md
589
+ auto-detects worktree mode (`.git` is a file, not a directory) and skips
590
+ shared file updates automatically. The orchestrator updates them centrally
591
+ after merge.
592
+
593
+ REQUIRED: SUMMARY.md MUST be committed before you return. In worktree mode the
594
+ git_commit_metadata step in execute-plan.md commits SUMMARY.md and REQUIREMENTS.md
595
+ only (STATE.md and ROADMAP.md are excluded automatically). Do NOT skip or defer
596
+ this commit — the orchestrator force-removes the worktree after you return, and
597
+ any uncommitted SUMMARY.md will be permanently lost (#2070).
598
+ REQUIRED ORDER: Write SUMMARY.md → commit → only then any narration. No text between Write and commit (truncation risk; #2070 rescue is not primary defense).
243
599
  </parallel_execution>
244
600
 
245
601
  <execution_context>
@@ -247,6 +603,8 @@ Execute each selected wave in sequence. Within a wave: parallel if `PARALLELIZAT
247
603
  @~/.claude/sdd/templates/summary.md
248
604
  @~/.claude/sdd/references/checkpoints.md
249
605
  @~/.claude/sdd/references/tdd.md
606
+ @~/.claude/sdd/references/worktree-path-safety.md
607
+ ${CONTEXT_WINDOW < 200000 ? '' : '@~/.claude/sdd/references/executor-examples.md'}
250
608
  </execution_context>
251
609
 
252
610
  <files_to_read>
@@ -255,6 +613,11 @@ Execute each selected wave in sequence. Within a wave: parallel if `PARALLELIZAT
255
613
  - .planning/PROJECT.md (Project context — core value, requirements, evolution rules)
256
614
  - .planning/STATE.md (State)
257
615
  - .planning/config.json (Config, if exists)
616
+ ${CONTEXT_WINDOW >= 500000 ? `
617
+ - ${phase_dir}/*-CONTEXT.md (User decisions from discuss-phase — honors locked choices)
618
+ - ${phase_dir}/*-RESEARCH.md (Technical research — pitfalls and patterns to follow)
619
+ - ${prior_wave_summaries} (SUMMARY.md files from earlier waves in this phase — what was already built)
620
+ ` : ''}
258
621
  - ./CLAUDE.md (Project instructions, if exists — follow project-specific guidelines and coding conventions)
259
622
  - .claude/skills/ or .agents/skills/ (Project skills, if either exists — list skills, read SKILL.md for each, follow relevant rules during implementation)
260
623
  </files_to_read>
@@ -272,16 +635,55 @@ Execute each selected wave in sequence. Within a wave: parallel if `PARALLELIZAT
272
635
  - [ ] All tasks executed
273
636
  - [ ] Each task committed individually
274
637
  - [ ] SUMMARY.md created in plan directory
275
- - [ ] STATE.md updated with position and decisions
276
- - [ ] ROADMAP.md updated with plan progress (via `roadmap update-plan-progress`)
638
+ - [ ] No modifications to shared orchestrator artifacts (the orchestrator handles all post-wave shared-file writes)
277
639
  </success_criteria>
278
640
  "
279
641
  )
280
642
  ```
281
643
 
282
- 3. **Wait for all agents in wave to complete.**
644
+ Immediately after each worktree `Agent()` spawn returns metadata, atomically append `{agent_id, worktree_path, branch, expected_base}` to `WAVE_WORKTREE_MANIFEST`. If any field is missing, stop and ask for recovery instead of scanning all agent worktrees.
645
+
646
+ > **ORCHESTRATOR RULE — CODEX RUNTIME**: After calling Agent() above to spawn executor agent(s), stop working on this task immediately. Do not read more files, edit code, or run tests related to this task while the subagent is active. Wait for the subagent to return its result. This prevents duplicate work, conflicting edits, and wasted context. Only resume when the subagent result is available.
647
+
648
+ **Sequential mode** (`USE_WORKTREES_FOR_PLAN` is `false` — either project-level `USE_WORKTREES=false`, or per-plan submodule intersection forced it false in step 2.5):
649
+
650
+ Omit `isolation="worktree"` from the Agent call. Replace the `<parallel_execution>` block with:
651
+
652
+ ```
653
+ <sequential_execution>
654
+ You are running as a SEQUENTIAL executor agent on the main working tree.
655
+ Use normal git commits (with hooks). Do NOT use --no-verify.
656
+ REQUIRED ORDER: Write SUMMARY.md → commit → only then any narration. No text between Write and commit (truncation risk; #2070 rescue is not primary defense).
657
+ </sequential_execution>
658
+ ```
659
+
660
+ The sequential mode Agent prompt uses the same structure as worktree mode but with these differences in success_criteria — since there is only one agent writing at a time, there are no shared-file conflicts:
661
+
662
+ ```
663
+ <success_criteria>
664
+ - [ ] All tasks executed
665
+ - [ ] Each task committed individually
666
+ - [ ] SUMMARY.md created in plan directory
667
+ - [ ] STATE.md updated with position and decisions
668
+ - [ ] ROADMAP.md updated with plan progress (via `roadmap update-plan-progress`)
669
+ </success_criteria>
670
+ ```
671
+
672
+ When worktrees are disabled for a plan (per-plan or project-level), that plan's executor runs on the main working tree. If **any** plan in the current wave dropped to sequential mode, execute the affected plan(s) **one at a time** to avoid concurrent writes to the main working tree — plans in the same wave that retained worktree isolation can still run in parallel alongside the sequential ones, but two non-worktree plans in the same wave must serialize. When the project-level `USE_WORKTREES=false`, all plans in the wave serialize regardless of the `PARALLELIZATION` setting.
673
+
674
+ 4. **Wait for all agents in wave to complete.**
675
+
676
+ **Plan-complete heartbeat (#2410):** as each executor returns (or is verified
677
+ via spot-check below), emit one line — `complete` advances `{P}`, `failed`
678
+ and `checkpoint` do not but still warm the stream:
283
679
 
284
- **Completion signal fallback (Copilot and runtimes where Task() may not return):**
680
+ ```
681
+ [checkpoint] phase {PHASE_NUMBER} wave {N}/{M} plan {plan_id} complete ({P}/{Q} plans done)
682
+ [checkpoint] phase {PHASE_NUMBER} wave {N}/{M} plan {plan_id} failed ({P}/{Q} plans done)
683
+ [checkpoint] phase {PHASE_NUMBER} wave {N}/{M} plan {plan_id} checkpoint ({P}/{Q} plans done)
684
+ ```
685
+
686
+ **Completion signal fallback (Copilot and runtimes where Agent() may not return):**
285
687
 
286
688
  If a spawned agent does not return a completion signal but appears to have finished
287
689
  its work, do NOT block indefinitely. Instead, verify completion via spot-checks:
@@ -290,30 +692,298 @@ Execute each selected wave in sequence. Within a wave: parallel if `PARALLELIZAT
290
692
  # For each plan in this wave, check if the executor finished:
291
693
  SUMMARY_EXISTS=$(test -f "{phase_dir}/{plan_number}-{plan_padded}-SUMMARY.md" && echo "true" || echo "false")
292
694
  COMMITS_FOUND=$(git log --oneline --all --grep="{phase_number}-{plan_padded}" --since="1 hour ago" | head -1)
695
+ COMMITS_SINCE_DISPATCH=$(git log "${EXPECTED_BRANCH}" --since="${DISPATCH_TS}" --oneline | head -1)
293
696
  ```
294
697
 
295
698
  **If SUMMARY.md exists AND commits are found:** The agent completed successfully —
296
- treat as done and proceed to step 4. Log: `"✓ {Plan ID} completed (verified via spot-check — completion signal not received)"`
699
+ treat as done and proceed to step 5. Log: `"✓ {Plan ID} completed (verified via spot-check — completion signal not received)"`
297
700
 
298
701
  **If SUMMARY.md does NOT exist after a reasonable wait:** The agent may still be
299
702
  running or may have failed silently. Check `git log --oneline -5` for recent
300
703
  activity. If commits are still appearing, wait longer. If no activity, report
301
- the plan as failed and route to the failure handler in step 5.
704
+ the plan as failed and route to the failure handler in step 6.
302
705
 
303
- **This fallback applies automatically to all runtimes.** Claude Code's Task() normally
304
- returns synchronously, but the fallback ensures resilience if it doesn't.
706
+ **Configurable stall surveillance (#3212):** Every `${EXECUTOR_STALL_INTERVAL_MINUTES}`
707
+ minutes while waiting, inspect `git log "${EXPECTED_BRANCH}" --since="${DISPATCH_TS}"`
708
+ for activity. If no completion signal, no SUMMARY.md, and no expected-branch
709
+ commits appear for `${EXECUTOR_STALL_THRESHOLD_MINUTES}` minutes, pause and
710
+ ask for one recovery path: `continue waiting`, `kill and retry`, or
711
+ `kill and switch to inline execution`.
305
712
 
306
- 4. **Post-wave hook validation (parallel mode only):**
713
+ **This fallback applies automatically to all runtimes.** Claude Code's Agent() normally
714
+ returns synchronously, but the fallback ensures resilience if it doesn't.
307
715
 
308
- When agents committed with `--no-verify`, run pre-commit hooks once after the wave:
716
+ 5. **Post-wave hook validation (parallel mode only):** Hooks run on every executor commit by default (#2924); this post-wave run only fires when `workflow.worktree_skip_hooks=true` opted out of per-commit hooks:
309
717
  ```bash
310
- # Run project's pre-commit hooks on the current state
311
- git diff --cached --quiet || git stash # stash any unstaged changes
312
- git hook run pre-commit 2>&1 || echo "⚠ Pre-commit hooks failed review before continuing"
718
+ SKIP_HOOKS=$(sdd-sdk query config-get workflow.worktree_skip_hooks 2>/dev/null || echo "false")
719
+ if [ "$SKIP_HOOKS" = "true" ]; then
720
+ # Stash uncommitted changes under a named ref so we always pop (bare `git stash` strands them on hook/script failure). #3542: `refs/stash` is shared across worktrees, so this helper runs ONLY in the orchestrator's main checkout after all wave worktrees have been merged + removed; executors are forbidden from running any `git stash` subcommand (see `<destructive_git_prohibition>` in `agents/sdd-executor.md`).
721
+ STASHED=false
722
+ if (! git diff --quiet || ! git diff --cached --quiet) && git stash push -u -m "sdd-post-wave-hook-$$" >/dev/null 2>&1; then STASHED=true; fi
723
+ git hook run pre-commit 2>&1 || echo "⚠ Pre-commit hooks failed — review before continuing"
724
+ [ "$STASHED" = "true" ] && (git stash pop >/dev/null 2>&1 || echo "⚠ Could not pop sdd-post-wave-hook stash — recover manually")
725
+ fi
313
726
  ```
314
727
  If hooks fail: report the failure and ask "Fix hook issues now?" or "Continue to next wave?"
315
728
 
316
- 5. **Report completion spot-check claims first:**
729
+ 5.5. **Worktree cleanup (when `isolation="worktree"` was used):**
730
+
731
+ **Standard wave contract:** Each wave's worktrees merge to main via the templated path below before the next wave's worktrees fork. The cleanup loop runs once per wave at the end of the wave lifecycle. Worktrees created in wave N must be fully removed before wave N+1 forks new ones.
732
+
733
+ **Cross-wave dependency deviation (supported execution mode):** When the orchestrator legitimately deviates from the standard wave model — for example, a phase with cross-wave plan dependencies that requires custom inter-worktree base-update merges (e.g., `merge: bring 09-01 + 09-02 into 09-03 base`) — the cleanup loop below is NOT automatically re-entered for those custom merges. The deviation path produces correct final history but bypasses this loop, leaving `worktree-agent-*` directories in place. Use the **cleanup-tail snippet** below to remove any residual worktrees after such a deviation.
734
+
735
+ When executor agents ran in worktree isolation, their commits land on temporary branches in separate working trees. After the wave completes, merge these changes back and clean up:
736
+
737
+ **Manifest source of truth (#3384):** Cleanup consumes the `WAVE_WORKTREE_MANIFEST` created and populated during executor dispatch in step 3. Do not recreate or truncate it here.
738
+
739
+ Prefer the bounded helper, which validates branch identity, expected base, deletion
740
+ diffs, merge result, and worktree removal before deleting the temporary branch.
741
+ If the helper reports a blocked cleanup, resolve the reported manifest entry and
742
+ rerun the same command. Do not fall back to broad worktree discovery.
743
+
744
+ ```bash
745
+ [ -n "${WAVE_WORKTREE_MANIFEST:-}" ] && [ -f "$WAVE_WORKTREE_MANIFEST" ] || {
746
+ echo "BLOCKED: missing WAVE_WORKTREE_MANIFEST; refusing broad worktree cleanup (#3384)." >&2
747
+ exit 1
748
+ }
749
+
750
+ # Guard: pin cleanup back to the primary worktree and fail on branch drift (#3174).
751
+ PRIMARY_WT=$(git worktree list --porcelain | awk '/^worktree /{print substr($0,10); exit}')
752
+ if [ -z "$PRIMARY_WT" ]; then
753
+ echo "FATAL: could not resolve primary worktree before cleanup" >&2
754
+ exit 1
755
+ fi
756
+ if [ -n "$PRIMARY_WT" ] && [ "$(pwd -P 2>/dev/null)" != "$(cd "$PRIMARY_WT" 2>/dev/null && pwd -P)" ]; then echo "⚠ Orchestrator CWD drifted to $(pwd) — pinning to $PRIMARY_WT before worktree cleanup (#3174)"; cd "$PRIMARY_WT" || { echo "FATAL: cannot cd to primary worktree $PRIMARY_WT" >&2; exit 1; }; fi
757
+ ORCH_BRANCH=$(git rev-parse --abbrev-ref HEAD)
758
+ [ -z "${EXPECTED_BRANCH:-}" ] || [ "$ORCH_BRANCH" = "$EXPECTED_BRANCH" ] || { echo "FATAL: orchestrator on '$ORCH_BRANCH' but expected '$EXPECTED_BRANCH' before worktree cleanup — refusing to merge (#3174-class drift)" >&2; exit 1; }
759
+
760
+ if command -v sdd-sdk >/dev/null 2>&1; then
761
+ sdd-sdk query worktree.cleanup-wave --manifest "$WAVE_WORKTREE_MANIFEST" || exit 1
762
+ else
763
+ echo "WARN: sdd-sdk unavailable; using manifest-scoped shell fallback (#3384)." >&2
764
+ WT_PATHS_FILE=$(mktemp "${TMPDIR:-/tmp}/sdd-worktree-paths-XXXXXX")
765
+ node -e 'const fs=require("fs");const p=process.env.WAVE_WORKTREE_MANIFEST;try{if(!p)throw new Error("WAVE_WORKTREE_MANIFEST is unset");if(!fs.existsSync(p))throw new Error("manifest does not exist");const s=fs.readFileSync(p,"utf8");if(!s.trim())throw new Error("manifest is empty");const j=JSON.parse(s);for(const w of j.worktrees||[])if(w.worktree_path)console.log(w.worktree_path)}catch(e){console.error(`ERROR: cannot read worktree manifest ${p||"(unset)"}: ${e.message}`);process.exit(1)}' > "$WT_PATHS_FILE" || { echo "BLOCKED: cannot read WAVE_WORKTREE_MANIFEST; refusing cleanup (#3384)." >&2; exit 1; }
766
+ while IFS= read -r WT; do
767
+ [ -z "$WT" ] && continue
768
+ WT_BRANCH=$(git -C "$WT" rev-parse --abbrev-ref HEAD 2>/dev/null)
769
+ if [ -n "$WT_BRANCH" ] && [ "$WT_BRANCH" != "HEAD" ]; then
770
+ CURRENT_BRANCH=$(git rev-parse --abbrev-ref HEAD)
771
+ STATE_BACKUP=$(mktemp)
772
+ ROADMAP_BACKUP=$(mktemp)
773
+ [ -f .planning/STATE.md ] && cp .planning/STATE.md "$STATE_BACKUP" || true
774
+ [ -f .planning/ROADMAP.md ] && cp .planning/ROADMAP.md "$ROADMAP_BACKUP" || true
775
+ DELETIONS=$(git diff --diff-filter=D --name-only HEAD..."$WT_BRANCH" 2>/dev/null || true)
776
+ if [ -n "$DELETIONS" ]; then
777
+ echo "BLOCKED: Worktree branch $WT_BRANCH contains file deletions: $DELETIONS"
778
+ echo "Review these deletions before merging. If intentional, remove this guard and re-run."
779
+ rm -f "$STATE_BACKUP" "$ROADMAP_BACKUP"
780
+ continue
781
+ fi
782
+ git merge "$WT_BRANCH" --no-ff --no-edit -m "chore: merge executor worktree ($WT_BRANCH)" 2>&1 || {
783
+ echo "⚠ Merge conflict from worktree $WT_BRANCH — resolve manually"
784
+ echo " STATE.md backup: $STATE_BACKUP"
785
+ echo " ROADMAP.md backup: $ROADMAP_BACKUP"
786
+ echo " Restore with: cp \$STATE_BACKUP .planning/STATE.md && cp \$ROADMAP_BACKUP .planning/ROADMAP.md"
787
+ break
788
+ }
789
+ MERGE_DEL_COUNT=$(git diff --diff-filter=D --name-only HEAD~1 HEAD 2>/dev/null | grep -vc '^\.planning/' || true)
790
+ if [ "$MERGE_DEL_COUNT" -gt 5 ] && [ "${ALLOW_BULK_DELETE:-0}" != "1" ]; then
791
+ MERGE_DELETIONS=$(git diff --diff-filter=D --name-only HEAD~1 HEAD 2>/dev/null | grep -v '^\.planning/' || true)
792
+ echo "⚠ BLOCKED: Merge of $WT_BRANCH deleted $MERGE_DEL_COUNT files outside .planning/ — reverting to protect repository integrity (#2384)"
793
+ echo "$MERGE_DELETIONS"
794
+ echo " If these deletions are intentional, re-run with ALLOW_BULK_DELETE=1"
795
+ git reset --hard HEAD~1 2>/dev/null || true
796
+ rm -f "$STATE_BACKUP" "$ROADMAP_BACKUP"
797
+ continue
798
+ fi
799
+ if [ -s "$STATE_BACKUP" ]; then
800
+ cp "$STATE_BACKUP" .planning/STATE.md
801
+ fi
802
+ if [ -s "$ROADMAP_BACKUP" ]; then
803
+ cp "$ROADMAP_BACKUP" .planning/ROADMAP.md
804
+ fi
805
+ rm -f "$STATE_BACKUP" "$ROADMAP_BACKUP"
806
+ # Detect files deleted on main but re-added by worktree merge (#2501).
807
+ DELETED_FILES=$(git diff --diff-filter=A --name-only HEAD~1 -- .planning/ 2>/dev/null || true)
808
+ for RESURRECTED in $DELETED_FILES; do
809
+ WAS_DELETED=$(git log --follow --diff-filter=D --name-only --format="" HEAD~1 -- "$RESURRECTED" 2>/dev/null | grep -c . || true)
810
+ if [ "${WAS_DELETED:-0}" -gt 0 ]; then
811
+ git rm -f "$RESURRECTED" 2>/dev/null || true
812
+ fi
813
+ done
814
+ if ! git diff --quiet .planning/STATE.md .planning/ROADMAP.md 2>/dev/null || \
815
+ [ -n "$DELETED_FILES" ]; then
816
+ COMMIT_DOCS=$(sdd-sdk query config-get commit_docs 2>/dev/null || echo "true")
817
+ if [ "$COMMIT_DOCS" != "false" ]; then
818
+ git add .planning/STATE.md .planning/ROADMAP.md 2>/dev/null || true
819
+ git commit --amend --no-edit 2>/dev/null || true
820
+ fi
821
+ fi
822
+ # Safety net: rescue uncommitted SUMMARY.md before worktree removal (#2070, #2838).
823
+ while IFS= read -r SUMMARY; do
824
+ [ -z "$SUMMARY" ] && continue
825
+ REL_PATH="${SUMMARY#$WT/}"
826
+ if [ ! -f "$REL_PATH" ] || ! cmp -s "$SUMMARY" "$REL_PATH"; then
827
+ mkdir -p "$(dirname "$REL_PATH")"
828
+ cp "$SUMMARY" "$REL_PATH"
829
+ echo "⚠ Rescued $REL_PATH from worktree before removal"
830
+ fi
831
+ done < <(find "$WT/.planning" -name "*SUMMARY.md" 2>/dev/null)
832
+ REMOVE_OK=false
833
+ if git worktree remove "$WT" --force; then
834
+ REMOVE_OK=true
835
+ else
836
+ WT_NAME=$(basename "$WT")
837
+ if [ -f ".git/worktrees/${WT_NAME}/locked" ]; then
838
+ echo "⚠ Worktree $WT is locked — attempting to unlock and retry"
839
+ git worktree unlock "$WT" 2>/dev/null || true
840
+ if git worktree remove "$WT" --force; then
841
+ REMOVE_OK=true
842
+ else
843
+ echo "⚠ Residual worktree at $WT — manual cleanup required after session exits:"
844
+ echo " git worktree unlock \"$WT\" && git worktree remove \"$WT\" --force && git branch -D \"$WT_BRANCH\""
845
+ fi
846
+ else
847
+ echo "⚠ Residual worktree at $WT (remove failed) — investigate manually"
848
+ fi
849
+ fi
850
+ if [ "$REMOVE_OK" = "true" ]; then
851
+ git branch -D "$WT_BRANCH" 2>/dev/null || true
852
+ else
853
+ echo "⚠ Keeping branch $WT_BRANCH because worktree removal failed (#3384)"
854
+ fi
855
+ fi
856
+ done < "$WT_PATHS_FILE"
857
+ fi
858
+ ```
859
+
860
+ **Cleanup-tail snippet (use after any wave whose merges did not flow through the templated path above):**
861
+
862
+ If the orchestrator deviated from the standard wave merge path (e.g., custom inter-worktree base-update merges with `merge: bring …` style messages), run this snippet after the custom merges are complete. It reads only `WAVE_WORKTREE_MANIFEST`; do not discover unrelated `worktree-agent-*` worktrees.
863
+
864
+ ```bash
865
+ # Cleanup-tail: pin orchestrator CWD to primary worktree before cleanup-tail (#3174).
866
+ PRIMARY_WT=$(git worktree list --porcelain | awk '/^worktree /{print substr($0,10); exit}')
867
+ if [ -n "$PRIMARY_WT" ] && [ "$(pwd -P 2>/dev/null)" != "$(cd "$PRIMARY_WT" 2>/dev/null && pwd -P)" ]; then echo "⚠ Orchestrator CWD drifted to $(pwd) — pinning to $PRIMARY_WT before cleanup-tail (#3174)"; cd "$PRIMARY_WT" || { echo "FATAL: cannot cd to primary worktree $PRIMARY_WT" >&2; exit 1; }; fi
868
+ # Cleanup-tail: remove residual agent worktrees after a cross-wave-dependency deviation.
869
+ # Uses only the current wave manifest to avoid touching unrelated active agents (#3384).
870
+ WT_PATHS_FILE=$(mktemp "${TMPDIR:-/tmp}/sdd-worktree-paths-XXXXXX")
871
+ node -e 'const fs=require("fs");const p=process.env.WAVE_WORKTREE_MANIFEST;try{if(!p)throw new Error("WAVE_WORKTREE_MANIFEST is unset");if(!fs.existsSync(p))throw new Error("manifest does not exist");const s=fs.readFileSync(p,"utf8");if(!s.trim())throw new Error("manifest is empty");const j=JSON.parse(s);for(const w of j.worktrees||[])if(w.worktree_path)console.log(w.worktree_path)}catch(e){console.error(`ERROR: cannot read worktree manifest ${p||"(unset)"}: ${e.message}`);process.exit(1)}' > "$WT_PATHS_FILE" || { echo "BLOCKED: cannot read WAVE_WORKTREE_MANIFEST; refusing cleanup (#3384)." >&2; exit 1; }
872
+ while IFS= read -r WT; do
873
+ [ -z "$WT" ] && continue
874
+ WT_BRANCH=$(git -C "$WT" rev-parse --abbrev-ref HEAD 2>/dev/null)
875
+ [ -z "$WT_BRANCH" ] || [ "$WT_BRANCH" = "HEAD" ] && continue
876
+ echo "Cleaning up residual worktree: $WT (branch: $WT_BRANCH)"
877
+ git worktree unlock "$WT" 2>/dev/null || true
878
+ if ! git worktree remove "$WT" --force; then
879
+ WT_NAME=$(basename "$WT")
880
+ if [ -f ".git/worktrees/${WT_NAME}/locked" ]; then
881
+ echo "⚠ Worktree $WT is locked — unlock failed; manual cleanup required:"
882
+ echo " git worktree unlock \"$WT\" && git worktree remove \"$WT\" --force && git branch -D \"$WT_BRANCH\""
883
+ else
884
+ echo "⚠ Residual worktree at $WT — remove failed; manual cleanup required"
885
+ fi
886
+ else
887
+ git branch -D "$WT_BRANCH" 2>/dev/null || true
888
+ fi
889
+ done < "$WT_PATHS_FILE"
890
+ git worktree prune
891
+ ```
892
+
893
+ **When to skip step 5.5:**
894
+
895
+ **If no plan in this wave used worktree isolation** (project-level `USE_WORKTREES=false` OR every plan in the wave had `USE_WORKTREES_FOR_PLAN=false` — i.e. `WAVE_WORKTREE_PLANS` from step 2.5 is empty): all agents ran on the main working tree — skip this step entirely.
896
+
897
+ **If the orchestrator merged via custom messages (cross-wave-dependency deviation):** the templated cleanup loop above was not triggered for those merges. Run the cleanup-tail snippet above instead. After the snippet completes, proceed to step 5.6.
898
+
899
+ **If at least one plan used worktrees but others did not:** still run this cleanup — it iterates over actual `git worktree list` output and only merges back the worktrees that were created, leaving sequential plans' commits on the main tree untouched.
900
+
901
+ **If no worktrees found at runtime:** Skip silently — agents may have been spawned without worktree isolation, or the orchestrator already cleaned them up.
902
+
903
+ 5.6. **Post-merge build & test gate:**
904
+
905
+ After merging all worktrees in a wave (parallel mode), or after the last plan completes
906
+ (serial mode), run a build and then the project's test suite to catch cross-plan
907
+ integration issues that individual worktree self-checks cannot detect (e.g., conflicting
908
+ type definitions, removed exports, import changes, link errors).
909
+
910
+ This addresses the Generator self-evaluation blind spot identified in Anthropic's
911
+ harness engineering research: agents reliably report Self-Check: PASSED even when
912
+ merging their work creates failures.
913
+
914
+ Read and execute `sdd/workflows/execute-phase/steps/post-merge-gate.md`.
915
+
916
+ 5.7. **Post-wave shared artifact update (when at least one plan used worktrees, skip if tests failed):**
917
+
918
+ When **any** executor agent in this wave ran with `isolation="worktree"`, that agent skipped STATE.md and ROADMAP.md updates to avoid last-merge-wins overwrites. The orchestrator is the single writer for these files. After worktrees are merged back, update shared artifacts once for every completed plan in the wave (worktree-mode plans **and** sequential plans that ran on the main tree but deferred to the orchestrator for tracking writes).
919
+
920
+ **Only update tracking when tests passed (TEST_EXIT=0).**
921
+ If tests failed or timed out, skip the tracking update — plans should
922
+ not be marked as complete when integration tests are failing or inconclusive.
923
+
924
+ ```bash
925
+ # Guard: only update tracking if post-merge tests passed
926
+ # Timeout (124) is treated as inconclusive — do NOT mark plans complete
927
+ if [ "${TEST_EXIT}" -eq 0 ]; then
928
+ # Update ROADMAP plan progress for each completed plan in this wave
929
+ for plan_id in {completed_plan_ids}; do
930
+ sdd-sdk query roadmap.update-plan-progress "${PHASE_NUMBER}" "${plan_id}" "complete"
931
+ done
932
+
933
+ # Only commit tracking files if they actually changed
934
+ if ! git diff --quiet .planning/ROADMAP.md .planning/STATE.md 2>/dev/null; then
935
+ sdd-sdk query commit "docs(phase-${PHASE_NUMBER}): update tracking after wave ${N}" --files .planning/ROADMAP.md .planning/STATE.md
936
+ fi
937
+ elif [ "${TEST_EXIT}" -eq 124 ]; then
938
+ echo "⚠ Skipping tracking update — test suite timed out. Plans remain in-progress. Run tests manually to confirm."
939
+ else
940
+ echo "⚠ Skipping tracking update — post-merge tests failed (exit ${TEST_EXIT}). Plans remain in-progress until tests pass."
941
+ fi
942
+ ```
943
+
944
+ Where `WAVE_PLAN_IDS` is the space-separated list of plan IDs that completed in this wave.
945
+
946
+ **If no plan in this wave used worktrees** (project-level `USE_WORKTREES=false` OR `WAVE_WORKTREE_PLANS` is empty): sequential agents already updated STATE.md and ROADMAP.md themselves — skip this step.
947
+
948
+ 5.8. **Handle test gate failures (when `WAVE_FAILURE_COUNT > 0`):**
949
+
950
+ ```
951
+ ## ⚠ Post-Merge Test Failure (cumulative failures: ${WAVE_FAILURE_COUNT})
952
+
953
+ Wave {N} worktrees merged successfully, but {M} tests fail after merge.
954
+ This typically indicates conflicting changes across parallel plans
955
+ (e.g., type definitions, shared imports, API contracts).
956
+
957
+ Failed tests:
958
+ {first 10 lines of failure output}
959
+
960
+ Options:
961
+ 1. Fix now (recommended) — resolve conflicts before next wave
962
+ 2. Continue — failures may compound in subsequent waves
963
+ ```
964
+
965
+ Note: If `WAVE_FAILURE_COUNT > 1`, strongly recommend "Fix now" — compounding
966
+ failures across multiple waves become exponentially harder to diagnose.
967
+
968
+ If "Fix now": diagnose failures (typically import conflicts, missing types,
969
+ or changed function signatures from parallel plans modifying the same module).
970
+ Fix, commit as `fix: resolve post-merge conflicts from wave {N}`, re-run tests.
971
+
972
+ **Why this matters:** Worktree isolation means each agent's Self-Check passes
973
+ in isolation. But when merged, add/add conflicts in shared files (models, registries,
974
+ CLI entry points) can silently drop code. The post-merge gate catches this before
975
+ the next wave builds on a broken foundation.
976
+
977
+ 6. **Report completion — spot-check claims first:**
978
+
979
+ **Wave-close heartbeat (#2410):** after spot-checks finish (pass or fail),
980
+ before the `## Wave {N} Complete` summary, emit as a literal line:
981
+
982
+ ```
983
+ [checkpoint] phase {PHASE_NUMBER} wave {N}/{M} complete, {P}/{Q} plans done ({wave_success}/{wave_plan_count} ok)
984
+ ```
985
+
986
+
317
987
 
318
988
  For each SUMMARY.md:
319
989
  - Verify first 2 files from `key-files.created` exist on disk
@@ -335,53 +1005,52 @@ Execute each selected wave in sequence. Within a wave: parallel if `PARALLELIZAT
335
1005
  ---
336
1006
  ```
337
1007
 
338
- - Bad: "Wave 2 complete. Proceeding to Wave 3."
339
- - Good: "Terrain system complete 3 biome types, height-based texturing, physics collision meshes. Vehicle physics (Wave 3) can now reference ground surfaces."
340
-
341
- 5. **Handle failures:**
342
-
343
- **Known Claude Code bug (classifyHandoffIfNeeded):** If an agent reports "failed" with error containing `classifyHandoffIfNeeded is not defined`, this is a Claude Code runtime bug — not a SDD or agent issue. The error fires in the completion handler AFTER all tool calls finish. In this case: run the same spot-checks as step 4 (SUMMARY.md exists, git commits present, no Self-Check: FAILED). If spot-checks PASS → treat as **successful**. If spot-checks FAIL → treat as real failure below.
344
-
345
- For real failures: report which plan failed ask "Continue?" or "Stop?" → if continue, dependent plans may also fail. If stop, partial completion report.
346
-
347
- 5b. **Pre-wave dependency check (waves 2+ only):**
348
-
349
- Before spawning wave N+1, for each plan in the upcoming wave:
350
- ```bash
351
- node "$HOME/.claude/sdd/bin/sdd-tools.cjs" verify key-links {phase_dir}/{plan}-PLAN.md
352
- ```
353
-
354
- If any key-link from a PRIOR wave's artifact fails verification:
355
-
356
- ## Cross-Plan Wiring Gap
357
-
358
- | Plan | Link | From | Expected Pattern | Status |
359
- |------|------|------|-----------------|--------|
360
- | {plan} | {via} | {from} | {pattern} | NOT FOUND |
361
-
362
- Wave {N} artifacts may not be properly wired. Options:
363
- 1. Investigate and fix before continuing
364
- 2. Continue (may cause cascading failures in wave {N+1})
365
-
366
- Key-links referencing files in the CURRENT (upcoming) wave are skipped.
367
-
368
- 6. **Execute checkpoint plans between waves** — see `<checkpoint_handling>`.
369
-
370
- 7. **Proceed to next wave.**
1008
+ 7. **Handle failures:**
1009
+ **Step 7.0classify before branching (#3095):**
1010
+ ```bash
1011
+ CLASS_JSON=$(sdd-sdk query agent.classify-failure -- "$AGENT_RETURN_BODY")
1012
+ CLASS=$(echo "$CLASS_JSON" | jq -r '.class')
1013
+ SENTINEL=$(echo "$CLASS_JSON" | jq -r '.sentinel // empty')
1014
+ RETRY_AFTER=$(echo "$CLASS_JSON" | jq -r '.retryAfterSeconds // empty')
1015
+ if [ -n "$RETRY_AFTER" ]; then RETRY_HINT=" Provider hinted retry-after: ${RETRY_AFTER}s"; else RETRY_HINT=""; fi
1016
+ ```
1017
+ One classifier branch handles sentinels across Claude/Copilot/Codex/Gemini. Reference: `docs/research/provider-rate-limit-signals.md`.
1018
+ **Step 7.1 — `class == "quota-exceeded"`:**
1019
+ Do not offer "retry now". Run step-5 spot-check first; if SUMMARY.md is missing but commits exist, route to safe-resume (`state.verify-against-disk`) instead of immediate redispatch.
1020
+ ```text
1021
+ Plan {plan_id} terminated by provider quota / rate limit
1022
+ Runtime sentinel: {SENTINEL}
1023
+ {RETRY_HINT}
1024
+ Partial commits on worktree branch: {N}
1025
+ SUMMARY.md present: {yes|no}
1026
+ 1. Wait for quota reset, then resume (recommended)
1027
+ 2. Switch to a different runtime / model and resume
1028
+ 3. Abort phase and report partial state
1029
+ ```
1030
+ Re-run `/sdd:execute-phase` after quota reset for Option 1.
1031
+ **Step 7.2 — `class == "classify-handoff-bug"`:**
1032
+ If error contains `classifyHandoffIfNeeded is not defined`, treat as Claude runtime bug. Run the same step-5 spot-checks; PASS => treat as success, FAIL => fall through.
1033
+ **Step 7.3 `class == "unknown-failure"`:**
1034
+ Report failed plan and ask Continue/Stop; continuing may cascade into dependent plan failures.
1035
+
1036
+ 7b. **Pre-wave dependency check (waves 2+ only):**
1037
+ Before wave N+1, run `sdd-sdk query verify.key-links {phase_dir}/{plan}-PLAN.md` for each upcoming plan.
1038
+ If any PRIOR-wave artifact link fails, present:
1039
+ - `## Cross-Plan Wiring Gap` with plan/link/from/pattern rows
1040
+ - Options: investigate+fix before continue, or continue with cascade risk
1041
+ Skip key-links that reference files in the CURRENT (upcoming) wave.
1042
+ 8. **Execute checkpoint plans between waves** — see `<checkpoint_handling>`.
1043
+ 9. **Proceed to next wave.**
371
1044
  </step>
372
-
373
1045
  <step name="checkpoint_handling">
374
1046
  Plans with `autonomous: false` require user interaction.
375
-
376
1047
  **Auto-mode checkpoint handling:**
377
-
378
- Read auto-advance config (chain flag + user preference):
1048
+ Read auto-advance config (chain flag OR user preference — same boolean as `check.auto-mode`):
379
1049
  ```bash
380
- AUTO_CHAIN=$(node "$HOME/.claude/sdd/bin/sdd-tools.cjs" config-get workflow._auto_chain_active 2>/dev/null || echo "false")
381
- AUTO_CFG=$(node "$HOME/.claude/sdd/bin/sdd-tools.cjs" config-get workflow.auto_advance 2>/dev/null || echo "false")
1050
+ AUTO_MODE=$(sdd-sdk query check auto-mode --pick active 2>/dev/null || echo "false")
382
1051
  ```
383
1052
 
384
- When executor returns a checkpoint AND (`AUTO_CHAIN` is `"true"` OR `AUTO_CFG` is `"true"`):
1053
+ When executor returns a checkpoint AND `AUTO_MODE` is `true`:
385
1054
  - **human-verify** → Auto-spawn continuation agent with `{user_response}` = `"approved"`. Log `⚡ Auto-approved checkpoint`.
386
1055
  - **decision** → Auto-spawn continuation agent with `{user_response}` = first option from checkpoint details. Log `⚡ Auto-selected: [option]`.
387
1056
  - **human-action** → Present to user (existing behavior below). Auth gates cannot be automated.
@@ -436,13 +1105,87 @@ After all waves:
436
1105
  ### Issues Encountered
437
1106
  [Aggregate from SUMMARYs, or "None"]
438
1107
  ```
1108
+
1109
+ **Security gate check:**
1110
+ ```bash
1111
+ SECURITY_CFG=$(sdd-sdk query config-get workflow.security_enforcement --raw 2>/dev/null || echo "true")
1112
+ SECURITY_FILE=$(ls "${PHASE_DIR}"/*-SECURITY.md 2>/dev/null | head -1)
1113
+ ```
1114
+
1115
+ If `SECURITY_CFG` is `false`: skip.
1116
+
1117
+ If `SECURITY_CFG` is `true` AND `SECURITY_FILE` is empty (no SECURITY.md yet):
1118
+ Include in the next-steps routing output:
1119
+ ```
1120
+ ⚠ Security enforcement enabled — run before advancing:
1121
+ /sdd:secure-phase {PHASE} ${SDD_WS}
1122
+ ```
1123
+
1124
+ If `SECURITY_CFG` is `true` AND SECURITY.md exists: check frontmatter `threats_open`. If > 0:
1125
+ ```
1126
+ ⚠ Security gate: {threats_open} threats open
1127
+ /sdd:secure-phase {PHASE} — resolve before advancing
1128
+ ```
1129
+ </step>
1130
+
1131
+ <step name="tdd_review_checkpoint">
1132
+ **Optional step — TDD collaborative review.**
1133
+
1134
+ ```bash
1135
+ TDD_MODE=$(sdd-sdk query config-get workflow.tdd_mode 2>/dev/null || echo "false")
1136
+ ```
1137
+
1138
+ **Skip if `TDD_MODE` is `false`.**
1139
+
1140
+ When `TDD_MODE` is `true`, check whether any completed plans in this phase have `type: tdd` in their frontmatter:
1141
+
1142
+ ```bash
1143
+ TDD_PLANS=$(grep -rl "^type: tdd" "${PHASE_DIR}"/*-PLAN.md 2>/dev/null | wc -l | tr -d ' ')
1144
+ ```
1145
+
1146
+ **If `TDD_PLANS` > 0:** Insert end-of-phase collaborative review checkpoint.
1147
+
1148
+ 1. Collect all SUMMARY.md files for TDD plans
1149
+ 2. For each TDD plan summary, verify the RED/GREEN/REFACTOR gate sequence:
1150
+ - RED gate: A failing test commit exists (`test(...)` commit with MUST-fail evidence)
1151
+ - GREEN gate: An implementation commit exists (`feat(...)` commit making tests pass)
1152
+ - REFACTOR gate: Optional cleanup commit (`refactor(...)` commit, tests still pass)
1153
+ 3. If any TDD plan is missing the RED or GREEN gate commits, flag it:
1154
+ ```
1155
+ ⚠ TDD gate violation: Plan {plan_id} missing {RED|GREEN} phase commit.
1156
+ Expected commit pattern: test({phase}-{plan}): ... → feat({phase}-{plan}): ...
1157
+ ```
1158
+ 4. Present collaborative review summary:
1159
+ ```
1160
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
1161
+ TDD REVIEW — Phase {X}
1162
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
1163
+
1164
+ TDD Plans: {TDD_PLANS} | Gate violations: {count}
1165
+
1166
+ | Plan | RED | GREEN | REFACTOR | Status |
1167
+ |------|-----|-------|----------|--------|
1168
+ | {id} | ✓ | ✓ | ✓ | Pass |
1169
+ | {id} | ✓ | ✗ | — | FAIL |
1170
+ ```
1171
+
1172
+ **Escalation under MVP+TDD.** When `MVP_MODE=true` AND `TDD_MODE=true`, the review verdict escalates from advisory to **blocking**: missing RED or GREEN gate commits prevent marking the phase complete.
1173
+ ```text
1174
+ Phase blocked: {N} TDD plan(s) violate the RED→GREEN gate sequence under MVP+TDD.
1175
+ Resolve and re-run /sdd execute-phase, or override with
1176
+ /sdd execute-phase {phase} --force-mvp-gate to ship anyway.
1177
+ ```
1178
+ `--force-mvp-gate` is the escape hatch (documented, not yet implemented). Policy is:
1179
+ - `MVP_MODE=true` AND `TDD_MODE=true`: violations are **blocking** unless explicitly overridden.
1180
+ - otherwise: violations are advisory/non-blocking and are surfaced for review.
1181
+ The verifier agent (step `verify_phase_goal`) still checks TDD discipline in both cases.
439
1182
  </step>
440
1183
 
441
1184
  <step name="handle_partial_wave_execution">
442
1185
  If `WAVE_FILTER` was used, re-run plan discovery after execution:
443
1186
 
444
1187
  ```bash
445
- POST_PLAN_INDEX=$(node "$HOME/.claude/sdd/bin/sdd-tools.cjs" phase-plan-index "${PHASE_NUMBER}")
1188
+ POST_PLAN_INDEX=$(sdd-sdk query phase-plan-index "${PHASE_NUMBER}")
446
1189
  ```
447
1190
 
448
1191
  Apply the same "incomplete" filtering rules as earlier:
@@ -469,6 +1212,39 @@ Selected wave finished successfully. This phase still has incomplete plans, so p
469
1212
  - this means the selected wave happened to be the last remaining work in the phase
470
1213
  </step>
471
1214
 
1215
+ <step name="code_review_gate" required="true">
1216
+ **This step is REQUIRED and must not be skipped.** Auto-invoke code review on the phase's source changes. Advisory only — never blocks execution flow.
1217
+
1218
+ **Config gate:**
1219
+ ```bash
1220
+ CODE_REVIEW_ENABLED=$(sdd-sdk query config-get workflow.code_review 2>/dev/null || echo "true")
1221
+ ```
1222
+
1223
+ If `CODE_REVIEW_ENABLED` is `"false"`: display "Code review skipped (workflow.code_review=false)" and proceed to next step.
1224
+
1225
+ **Invoke review:**
1226
+ ```
1227
+ Skill(skill="sdd-code-review", args="${PHASE_NUMBER}")
1228
+ ```
1229
+
1230
+ **Check results using deterministic path (not glob):**
1231
+ ```bash
1232
+ PADDED=$(printf "%02d" "${PHASE_NUMBER}")
1233
+ REVIEW_FILE="${PHASE_DIR}/${PADDED}-REVIEW.md"
1234
+ REVIEW_STATUS=$(sed -n '/^---$/,/^---$/p' "$REVIEW_FILE" | grep "^status:" | head -1 | cut -d: -f2 | tr -d ' ')
1235
+ ```
1236
+
1237
+ If REVIEW_STATUS is not "clean" and not "skipped" and not empty, display:
1238
+ ```
1239
+ Code review found issues. Consider running:
1240
+ /sdd:code-review ${PHASE_NUMBER} --fix
1241
+ ```
1242
+
1243
+ **Error handling:** If the Skill invocation fails or throws, catch the error, display "Code review encountered an error (non-blocking): {error}" and proceed to next step. Review failures must never block execution.
1244
+
1245
+ Regardless of review result, ALWAYS proceed to close_parent_artifacts → regression_gate → verify_phase_goal.
1246
+ </step>
1247
+
472
1248
  <step name="close_parent_artifacts">
473
1249
  **For decimal/polish phases only (X.Y pattern):** Close the feedback loop by resolving parent UAT and debug artifacts.
474
1250
 
@@ -484,7 +1260,7 @@ fi
484
1260
 
485
1261
  **2. Find parent UAT file:**
486
1262
  ```bash
487
- PARENT_INFO=$(node "$HOME/.claude/sdd/bin/sdd-tools.cjs" find-phase "${PARENT_PHASE}" --raw)
1263
+ PARENT_INFO=$(sdd-sdk query find-phase "${PARENT_PHASE}" --raw)
488
1264
  # Extract directory from PARENT_INFO JSON, then find UAT file in that directory
489
1265
  ```
490
1266
 
@@ -515,7 +1291,7 @@ mv .planning/debug/{slug}.md .planning/debug/resolved/
515
1291
 
516
1292
  **6. Commit updated artifacts:**
517
1293
  ```bash
518
- node "$HOME/.claude/sdd/bin/sdd-tools.cjs" commit "docs(phase-${PARENT_PHASE}): resolve UAT gaps and debug sessions after ${PHASE_NUMBER} gap closure" --files .planning/phases/*${PARENT_PHASE}*/*-UAT.md .planning/debug/resolved/*.md
1294
+ sdd-sdk query commit "docs(phase-${PARENT_PHASE}): resolve UAT gaps and debug sessions after ${PHASE_NUMBER} gap closure" --files .planning/phases/*${PARENT_PHASE}*/*-UAT.md .planning/debug/resolved/*.md
519
1295
  ```
520
1296
  </step>
521
1297
 
@@ -542,15 +1318,27 @@ Collect all unique test file paths into `REGRESSION_FILES`.
542
1318
  **Step 3: Run regression tests (if any found)**
543
1319
 
544
1320
  ```bash
545
- # Detect test runner and run prior phase tests
546
- if [ -f "package.json" ]; then
547
- # Node.js use project's test runner
548
- npx jest ${REGRESSION_FILES} --passWithNoTests --no-coverage -q 2>&1 || npx vitest run ${REGRESSION_FILES} 2>&1
549
- elif [ -f "Cargo.toml" ]; then
550
- cargo test 2>&1
551
- elif [ -f "requirements.txt" ] || [ -f "pyproject.toml" ]; then
552
- python -m pytest ${REGRESSION_FILES} -q --tb=short 2>&1
1321
+ # Resolve test command: project config > Makefile > language sniff
1322
+ REG_TEST_CMD=$(sdd-sdk query config-get workflow.test_command --default "" 2>/dev/null || true)
1323
+ if [ -z "$REG_TEST_CMD" ]; then
1324
+ if [ -f "Makefile" ] && grep -q "^test:" Makefile; then
1325
+ REG_TEST_CMD="make test"
1326
+ elif [ -f "Justfile" ] || [ -f "justfile" ]; then
1327
+ REG_TEST_CMD="just test"
1328
+ elif [ -f "package.json" ]; then
1329
+ REG_TEST_CMD="npm test"
1330
+ elif [ -f "Cargo.toml" ]; then
1331
+ REG_TEST_CMD="cargo test"
1332
+ elif [ -f "go.mod" ]; then
1333
+ REG_TEST_CMD="go test ./..."
1334
+ elif [ -f "requirements.txt" ] || [ -f "pyproject.toml" ]; then
1335
+ REG_TEST_CMD="python -m pytest ${REGRESSION_FILES} -q --tb=short"
1336
+ else
1337
+ REG_TEST_CMD="true"
1338
+ fi
553
1339
  fi
1340
+ # Detect test runner and run prior phase tests
1341
+ eval "$REG_TEST_CMD" 2>&1
554
1342
  ```
555
1343
 
556
1344
  **Step 4: Report results**
@@ -580,15 +1368,93 @@ Options:
580
1368
  Use AskUserQuestion to present the options.
581
1369
  </step>
582
1370
 
1371
+ <step name="schema_drift_gate">
1372
+ Post-execution schema drift detection. Catches false-positive verification where
1373
+ build/types pass because TypeScript types come from config, not the live database.
1374
+
1375
+ **Run after execution completes but BEFORE verification marks success.**
1376
+
1377
+ ```bash
1378
+ SCHEMA_DRIFT=$(sdd-sdk query verify.schema-drift "${PHASE_NUMBER}" 2>/dev/null)
1379
+ ```
1380
+
1381
+ Parse JSON result for: `drift_detected`, `blocking`, `schema_files`, `orms`, `unpushed_orms`, `message`.
1382
+
1383
+ **If `drift_detected` is false:** Skip to verify_phase_goal.
1384
+
1385
+ **If `drift_detected` is true AND `blocking` is true:**
1386
+
1387
+ Check for override:
1388
+ ```bash
1389
+ SKIP_SCHEMA=$(echo "${SDD_SKIP_SCHEMA_CHECK:-false}")
1390
+ ```
1391
+
1392
+ **If `SKIP_SCHEMA` is `true`:**
1393
+
1394
+ Display:
1395
+ ```
1396
+ ⚠ Schema drift detected but SDD_SKIP_SCHEMA_CHECK=true — bypassing gate.
1397
+
1398
+ Schema files changed: {schema_files}
1399
+ ORMs requiring push: {unpushed_orms}
1400
+
1401
+ Proceeding to verification (database may be out of sync).
1402
+ ```
1403
+ → Continue to verify_phase_goal.
1404
+
1405
+ **If `SKIP_SCHEMA` is not `true`:**
1406
+
1407
+ BLOCK verification. Display:
1408
+
1409
+ ```
1410
+ ## BLOCKED: Schema Drift Detected
1411
+
1412
+ Schema-relevant files changed during this phase but no database push command
1413
+ was executed. Build and type checks pass because TypeScript types come from
1414
+ config, not the live database — verification would produce a false positive.
1415
+
1416
+ Schema files changed: {schema_files}
1417
+ ORMs requiring push: {unpushed_orms}
1418
+
1419
+ Required push commands:
1420
+ {For each unpushed ORM, show the push command from the message}
1421
+
1422
+ Options:
1423
+ 1. Run push command now (recommended) — execute the push, then re-verify
1424
+ 2. Skip schema check (SDD_SKIP_SCHEMA_CHECK=true) — bypass this gate
1425
+ 3. Abort — stop execution and investigate
1426
+ ```
1427
+
1428
+ If `TEXT_MODE` is true, present as a plain-text numbered list. Otherwise use AskUserQuestion.
1429
+
1430
+ **If user selects option 1:** Present the specific push command(s) to run. After user confirms execution, re-run the schema drift check. If it passes, continue to verify_phase_goal.
1431
+
1432
+ **If user selects option 2:** Set override and continue to verify_phase_goal.
1433
+
1434
+ **If user selects option 3:** Stop execution. Report partial completion.
1435
+ </step>
1436
+
1437
+ <step name="codebase_drift_gate">
1438
+ Post-execution structural drift detection (#2003). Non-blocking by contract:
1439
+ any internal error here MUST fall through to `verify_phase_goal`. The phase
1440
+ is never failed by this gate.
1441
+
1442
+ Load and follow the full step spec from
1443
+ `sdd/workflows/execute-phase/steps/codebase-drift-gate.md` —
1444
+ covers the SDK call, JSON contract, `warn` vs `auto-remap` branches, mapper
1445
+ spawn template, and the two `workflow.drift_*` config keys.
1446
+ </step>
1447
+
583
1448
  <step name="verify_phase_goal">
584
1449
  Verify phase achieved its GOAL, not just completed tasks.
585
1450
 
586
1451
  ```bash
587
- VERIFIER_SKILLS=$(node "$HOME/.claude/sdd/bin/sdd-tools.cjs" agent-skills sdd-verifier 2>/dev/null)
1452
+ VERIFIER_SKILLS=$(sdd-sdk query agent-skills sdd-verifier)
588
1453
  ```
589
1454
 
590
1455
  ```
591
- Task(
1456
+ Agent(
1457
+ description="Verify phase {phase_number} goal achievement",
592
1458
  prompt="Verify phase {phase_number} goal achievement.
593
1459
  Phase directory: {phase_dir}
594
1460
  Phase goal: {goal from ROADMAP.md}
@@ -596,12 +1462,26 @@ Phase requirement IDs: {phase_req_ids}
596
1462
  Check must_haves against actual codebase.
597
1463
  Cross-reference requirement IDs from PLAN frontmatter against REQUIREMENTS.md — every ID MUST be accounted for.
598
1464
  Create VERIFICATION.md.
1465
+
1466
+ <files_to_read>
1467
+ Read these files before verification:
1468
+ - {phase_dir}/*-PLAN.md (All plans — understand intent, check must_haves)
1469
+ - {phase_dir}/*-SUMMARY.md (All summaries — cross-reference claimed vs actual)
1470
+ - .planning/REQUIREMENTS.md (Requirement traceability)
1471
+ ${CONTEXT_WINDOW >= 500000 ? `- {phase_dir}/*-CONTEXT.md (User decisions — verify they were honored)
1472
+ - {phase_dir}/*-RESEARCH.md (Known pitfalls — check for traps)
1473
+ - Prior VERIFICATION.md files from earlier phases (regression check)
1474
+ ` : ''}
1475
+ </files_to_read>
1476
+
599
1477
  ${VERIFIER_SKILLS}",
600
1478
  subagent_type="sdd-verifier",
601
1479
  model="{verifier_model}"
602
1480
  )
603
1481
  ```
604
1482
 
1483
+ > **ORCHESTRATOR RULE — CODEX RUNTIME**: After calling Agent() above, stop working on this task immediately. Do not read more files, edit code, or run tests related to this task while the subagent is active. Wait for the subagent to return its result. This prevents duplicate work, conflicting edits, and wasted context. Only resume when the subagent result is available.
1484
+
605
1485
  Read status:
606
1486
  ```bash
607
1487
  grep "^status:" "$PHASE_DIR"/*-VERIFICATION.md | cut -d: -f2 | tr -d ' '
@@ -610,7 +1490,7 @@ grep "^status:" "$PHASE_DIR"/*-VERIFICATION.md | cut -d: -f2 | tr -d ' '
610
1490
  | Status | Action |
611
1491
  |--------|--------|
612
1492
  | `passed` | → update_roadmap |
613
- | `human_needed` | Present items for human testing, get approval or feedback |
1493
+ | `human_needed` | Persist and present human testing items; keep phase pending until verification reruns as `passed` |
614
1494
  | `gaps_found` | Present gap summary, offer `/sdd:plan-phase {phase} --gaps ${SDD_WS}` |
615
1495
 
616
1496
  **If human_needed:**
@@ -654,7 +1534,7 @@ blocked: 0
654
1534
 
655
1535
  Commit the file:
656
1536
  ```bash
657
- node "$HOME/.claude/sdd/bin/sdd-tools.cjs" commit "test({phase_num}): persist human verification items as UAT" --files "{phase_dir}/{phase_num}-HUMAN-UAT.md"
1537
+ sdd-sdk query commit "test({phase_num}): persist human verification items as UAT" --files "{phase_dir}/{phase_num}-HUMAN-UAT.md"
658
1538
  ```
659
1539
 
660
1540
  **Step B: Present to user:**
@@ -686,11 +1566,11 @@ Items saved to `{phase_num}-HUMAN-UAT.md` — they will appear in `/sdd:progress
686
1566
  {Gap summaries from VERIFICATION.md}
687
1567
 
688
1568
  ---
689
- ## ▶ Next Up
1569
+ ## ▶ Next Up — [${PROJECT_CODE}] ${PROJECT_TITLE}
690
1570
 
691
- `/sdd:plan-phase {X} --gaps ${SDD_WS}`
1571
+ `/clear` then:
692
1572
 
693
- <sub>`/clear` first fresh context window</sub>
1573
+ `/sdd:plan-phase {X} --gaps ${SDD_WS}`
694
1574
 
695
1575
  Also: `cat {phase_dir}/{phase_num}-VERIFICATION.md` — full report
696
1576
  Also: `/sdd:verify-work {X} ${SDD_WS}` — manual testing first
@@ -703,7 +1583,7 @@ Gap closure cycle: `/sdd:plan-phase {X} --gaps ${SDD_WS}` reads VERIFICATION.md
703
1583
  **Mark phase complete and update all tracking files:**
704
1584
 
705
1585
  ```bash
706
- COMPLETION=$(node "$HOME/.claude/sdd/bin/sdd-tools.cjs" phase complete "${PHASE_NUMBER}")
1586
+ COMPLETION=$(sdd-sdk query phase.complete "${PHASE_NUMBER}")
707
1587
  ```
708
1588
 
709
1589
  The CLI handles:
@@ -726,8 +1606,63 @@ These items are tracked and will appear in `/sdd:progress` and `/sdd:audit-uat`.
726
1606
  ```
727
1607
 
728
1608
  ```bash
729
- node "$HOME/.claude/sdd/bin/sdd-tools.cjs" commit "docs(phase-{X}): complete phase execution" --files .planning/ROADMAP.md .planning/STATE.md .planning/REQUIREMENTS.md {phase_dir}/*-VERIFICATION.md
1609
+ sdd-sdk query commit "docs(phase-{X}): complete phase execution" --files .planning/ROADMAP.md .planning/STATE.md .planning/REQUIREMENTS.md {phase_dir}/*-VERIFICATION.md
1610
+ ```
1611
+ </step>
1612
+
1613
+ <step name="auto_copy_learnings">
1614
+ **Auto-copy phase learnings to global store (when enabled).**
1615
+
1616
+ This step runs AFTER phase completion and SUMMARY.md is written. It copies any LEARNINGS.md
1617
+ entries from the completed phase to the global learnings store at `~/.sdd/knowledge/`.
1618
+
1619
+ **Check config gate:**
1620
+ ```bash
1621
+ GL_ENABLED=$(sdd-sdk query config-get features.global_learnings --raw 2>/dev/null || echo "false")
1622
+ ```
1623
+
1624
+ **If `GL_ENABLED` is not `true`:** Skip this step entirely (feature disabled by default).
1625
+
1626
+ **If enabled:**
1627
+
1628
+ 1. Check if LEARNINGS.md exists in the phase directory (use the `phase_dir` value from init context)
1629
+ 2. If found, copy to global store:
1630
+ ```bash
1631
+ sdd-sdk query learnings.copy 2>/dev/null || echo "⚠ Learnings copy failed — continuing"
1632
+ ```
1633
+ Copy failure must NOT block phase completion.
1634
+ </step>
1635
+
1636
+ <step name="close_phase_todos">
1637
+ **Auto-close pending todos tagged for this phase (#2433).**
1638
+
1639
+ This step runs AFTER `update_roadmap` marks the phase complete. It moves any pending todos that carry `resolves_phase: <current-phase-number>` to the completed directory.
1640
+
1641
+ ```bash
1642
+ PHASE_NUM="${PHASE_NUMBER}"
1643
+ PENDING_DIR=".planning/todos/pending"
1644
+ COMPLETED_DIR=".planning/todos/completed"
1645
+ mkdir -p "$COMPLETED_DIR"
1646
+
1647
+ CLOSED=()
1648
+ for TODO_FILE in "$PENDING_DIR"/*.md; do
1649
+ [ -f "$TODO_FILE" ] || continue
1650
+ # Extract resolves_phase from YAML frontmatter (first --- block only)
1651
+ RP=$(awk '/^---/{c++;next} c==1 && /^resolves_phase:/{print $2;exit} c==2{exit}' "$TODO_FILE" 2>/dev/null || true)
1652
+ if [ "$RP" = "$PHASE_NUM" ] || [ "$RP" = "\"$PHASE_NUM\"" ]; then
1653
+ mv "$TODO_FILE" "$COMPLETED_DIR/"
1654
+ CLOSED+=("$(basename "$TODO_FILE")")
1655
+ fi
1656
+ done
1657
+
1658
+ if [ ${#CLOSED[@]} -gt 0 ]; then
1659
+ sdd-sdk query commit "docs(phase-${PHASE_NUMBER}): auto-close ${#CLOSED[@]} todo(s) resolved by this phase" --files .planning/todos/completed/ .planning/STATE.md|| true
1660
+ echo "◆ Closed ${#CLOSED[@]} todo(s) resolved by Phase ${PHASE_NUMBER}:"
1661
+ for f in "${CLOSED[@]}"; do echo " ✓ $f"; done
1662
+ fi
730
1663
  ```
1664
+
1665
+ **If no todos have `resolves_phase: <this-phase>`:** Skip silently — this step is always additive and never blocks phase completion.
731
1666
  </step>
732
1667
 
733
1668
  <step name="update_project_md">
@@ -746,7 +1681,7 @@ PROJECT.md falls behind silently over multiple phases.
746
1681
  5. Commit the change:
747
1682
 
748
1683
  ```bash
749
- node "$HOME/.claude/sdd/bin/sdd-tools.cjs" commit "docs(phase-{X}): evolve PROJECT.md after phase completion" --files .planning/PROJECT.md
1684
+ sdd-sdk query commit "docs(phase-{X}): evolve PROJECT.md after phase completion" --files .planning/PROJECT.md
750
1685
  ```
751
1686
 
752
1687
  **Skip this step if** `.planning/PROJECT.md` does not exist.
@@ -782,13 +1717,12 @@ STOP. Do not proceed to auto-advance or transition.
782
1717
  **Auto-advance detection:**
783
1718
 
784
1719
  1. Parse `--auto` flag from $ARGUMENTS
785
- 2. Read both the chain flag and user preference (chain flag already synced in init step):
1720
+ 2. Read consolidated auto-mode (`active` = chain flag OR user preference; chain flag already synced in init step):
786
1721
  ```bash
787
- AUTO_CHAIN=$(node "$HOME/.claude/sdd/bin/sdd-tools.cjs" config-get workflow._auto_chain_active 2>/dev/null || echo "false")
788
- AUTO_CFG=$(node "$HOME/.claude/sdd/bin/sdd-tools.cjs" config-get workflow.auto_advance 2>/dev/null || echo "false")
1722
+ AUTO_MODE=$(sdd-sdk query check auto-mode --pick active 2>/dev/null || echo "false")
789
1723
  ```
790
1724
 
791
- **If `--auto` flag present OR `AUTO_CHAIN` is true OR `AUTO_CFG` is true (AND verification passed with no gaps):**
1725
+ **If `--auto` flag present OR `AUTO_MODE` is true (AND verification passed with no gaps):**
792
1726
 
793
1727
  ```
794
1728
  ╔══════════════════════════════════════════╗
@@ -797,23 +1731,42 @@ STOP. Do not proceed to auto-advance or transition.
797
1731
  ╚══════════════════════════════════════════╝
798
1732
  ```
799
1733
 
800
- Execute the transition workflow inline (do NOT use Task — orchestrator context is ~10-15%, transition needs phase completion data already in context):
1734
+ Execute the transition workflow inline (do NOT use Agent — orchestrator context is ~10-15%, transition needs phase completion data already in context):
801
1735
 
802
1736
  Read and follow `~/.claude/sdd/workflows/transition.md`, passing through the `--auto` flag so it propagates to the next phase invocation.
803
1737
 
804
- **If none of `--auto`, `AUTO_CHAIN`, or `AUTO_CFG` is true:**
1738
+ **If neither `--auto` nor `AUTO_MODE` is true:**
805
1739
 
806
1740
  **STOP. Do not auto-advance. Do not execute transition. Do not plan next phase. Present options to the user and wait.**
807
1741
 
808
- **IMPORTANT: There is NO `/sdd:transition` command. Never suggest it. The transition workflow is internal only.**
1742
+ **IMPORTANT: There is NO `/sdd-transition` command. Never suggest it. The transition workflow is internal only.**
1743
+
1744
+ Check whether CONTEXT.md already exists for the next phase:
1745
+
1746
+ ```bash
1747
+ ls .planning/phases/*{next}*/{next}-CONTEXT.md 2>/dev/null || echo "no-context"
1748
+ ```
1749
+
1750
+ If CONTEXT.md does **not** exist for the next phase, present:
1751
+
1752
+ ```
1753
+ ## ✓ Phase {X}: {Name} Complete
1754
+
1755
+ /sdd:progress ${SDD_WS} — see updated roadmap
1756
+ /sdd:discuss-phase {next} ${SDD_WS} — start here: discuss next phase before planning ← recommended
1757
+ /sdd:plan-phase {next} ${SDD_WS} — plan next phase (skip discuss)
1758
+ /sdd:execute-phase {next} ${SDD_WS} — execute next phase (skip discuss and plan)
1759
+ ```
1760
+
1761
+ If CONTEXT.md **exists** for the next phase, present:
809
1762
 
810
1763
  ```
811
1764
  ## ✓ Phase {X}: {Name} Complete
812
1765
 
813
1766
  /sdd:progress ${SDD_WS} — see updated roadmap
814
- /sdd:discuss-phase {next} ${SDD_WS} — discuss next phase before planning
815
- /sdd:plan-phase {next} ${SDD_WS} — plan next phase
816
- /sdd:execute-phase {next} ${SDD_WS} — execute next phase
1767
+ /sdd:plan-phase {next} ${SDD_WS} — start here: plan next phase (CONTEXT.md already present) ← recommended
1768
+ /sdd:discuss-phase {next} ${SDD_WS} — re-discuss next phase
1769
+ /sdd:execute-phase {next} ${SDD_WS} — execute next phase (skip planning)
817
1770
  ```
818
1771
 
819
1772
  Only suggest the commands listed above. Do not invent or hallucinate command names.
@@ -823,7 +1776,7 @@ Only suggest the commands listed above. Do not invent or hallucinate command nam
823
1776
 
824
1777
  <context_efficiency>
825
1778
  Orchestrator: ~10-15% context for 200k windows, can use more for 1M+ windows.
826
- Subagents: fresh context each (200k-1M depending on model). No polling (Task blocks). No context bleed.
1779
+ Subagents: fresh context each (200k-1M depending on model). No polling (Agent blocks). No context bleed.
827
1780
 
828
1781
  For 1M+ context models, consider:
829
1782
  - Passing richer context (code snippets, dependency outputs) directly to executors instead of just file paths
@@ -832,6 +1785,7 @@ For 1M+ context models, consider:
832
1785
  </context_efficiency>
833
1786
 
834
1787
  <failure_handling>
1788
+ - **Quota / rate-limit (any runtime — #3095):** Agent return body contains a sentinel like `usage limit`, `rate limit`, `429`, `too many requests`, `RESOURCE_EXHAUSTED`, `usage_limit_reached`. Route via `sdd-sdk query agent.classify-failure` → `class: "quota-exceeded"`. Do not offer retry-now; the right action is wait-for-reset and resume.
835
1789
  - **classifyHandoffIfNeeded false failure:** Agent reports "failed" but error is `classifyHandoffIfNeeded is not defined` → Claude Code bug, not SDD. Spot-check (SUMMARY exists, commits present) → if pass, treat as success
836
1790
  - **Agent fails mid-plan:** Missing SUMMARY.md → report, ask user how to proceed
837
1791
  - **Dependency chain breaks:** Wave 1 fails → Wave 2 dependents likely fail → user chooses attempt or skip