@opengsd/gsd-core 1.10.0 → 1.11.0

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 (328) hide show
  1. package/.claude-plugin/marketplace.json +1 -1
  2. package/.claude-plugin/plugin.json +1 -1
  3. package/agents/gsd-debug-session-manager.md +11 -0
  4. package/agents/gsd-doc-synthesizer.md +2 -4
  5. package/agents/gsd-executor.md +5 -5
  6. package/agents/gsd-mempalace-curator.md +5 -2
  7. package/agents/gsd-phase-researcher.md +20 -1
  8. package/agents/gsd-plan-checker.md +37 -0
  9. package/agents/gsd-planner.md +44 -46
  10. package/agents/gsd-user-profiler.md +3 -0
  11. package/agents/gsd-verifier.md +12 -3
  12. package/bin/install.js +841 -971
  13. package/bin/lib/ui-safety-gate.cjs +2 -0
  14. package/commands/gsd/code-review.md +1 -1
  15. package/commands/gsd/execute-phase.md +1 -1
  16. package/commands/gsd/map-codebase.md +1 -1
  17. package/commands/gsd/mempalace-capture.md +1 -1
  18. package/commands/gsd/mempalace-recall.md +1 -1
  19. package/commands/gsd/new-milestone.md +1 -1
  20. package/commands/gsd/quick.md +1 -1
  21. package/commands/gsd/review-backlog.md +2 -1
  22. package/commands/gsd/verify-work.md +1 -1
  23. package/gsd-core/bin/gsd-tools.cjs +469 -88
  24. package/gsd-core/bin/lib/active-workstream-store.cjs +138 -22
  25. package/gsd-core/bin/lib/agent-install-check.cjs +230 -32
  26. package/gsd-core/bin/lib/api-coverage.cjs +3 -5
  27. package/gsd-core/bin/lib/artifacts.cjs +3 -0
  28. package/gsd-core/bin/lib/assumption-delta.cjs +2 -4
  29. package/gsd-core/bin/lib/audit-command-router.cjs +9 -2
  30. package/gsd-core/bin/lib/audit.cjs +876 -240
  31. package/gsd-core/bin/lib/broken-windows.cjs +1 -1
  32. package/gsd-core/bin/lib/capability-consent.cjs +149 -15
  33. package/gsd-core/bin/lib/capability-lifecycle.cjs +45 -0
  34. package/gsd-core/bin/lib/capability-registry.cjs +575 -101
  35. package/gsd-core/bin/lib/capability-source.cjs +92 -0
  36. package/gsd-core/bin/lib/capability-trust.cjs +444 -25
  37. package/gsd-core/bin/lib/capability-validator.cjs +495 -22
  38. package/gsd-core/bin/lib/capability-writer.cjs +3 -2
  39. package/gsd-core/bin/lib/check-command-router.cjs +71 -37
  40. package/gsd-core/bin/lib/claude-orchestration.cjs +56 -3
  41. package/gsd-core/bin/lib/codex-agent-toml.cjs +329 -0
  42. package/gsd-core/bin/lib/command-aliases.cjs +22 -0
  43. package/gsd-core/bin/lib/command-roster.cjs +44 -1
  44. package/gsd-core/bin/lib/commands.cjs +651 -86
  45. package/gsd-core/bin/lib/commonjs-marker.cjs +12 -6
  46. package/gsd-core/bin/lib/complexity-trigger.cjs +1172 -0
  47. package/gsd-core/bin/lib/config-loader.cjs +75 -0
  48. package/gsd-core/bin/lib/config.cjs +10 -1
  49. package/gsd-core/bin/lib/core-utils.cjs +127 -29
  50. package/gsd-core/bin/lib/decisions.cjs +23 -0
  51. package/gsd-core/bin/lib/fallow-runner.cjs +20 -44
  52. package/gsd-core/bin/lib/frontmatter.cjs +155 -20
  53. package/gsd-core/bin/lib/gap-checker.cjs +68 -7
  54. package/gsd-core/bin/lib/git-base-branch.cjs +102 -0
  55. package/gsd-core/bin/lib/gsd2-import.cjs +10 -1
  56. package/gsd-core/bin/lib/health-diagnostic-rules/agent-install.cjs +101 -0
  57. package/gsd-core/bin/lib/health-diagnostic-rules/config-validation.cjs +348 -0
  58. package/gsd-core/bin/lib/health-diagnostic-rules/consistency.cjs +145 -0
  59. package/gsd-core/bin/lib/health-diagnostic-rules/install-surface-shadowing.cjs +98 -0
  60. package/gsd-core/bin/lib/health-diagnostic-rules/milestone-archive-hygiene.cjs +100 -0
  61. package/gsd-core/bin/lib/health-diagnostic-rules/phase-structure.cjs +222 -0
  62. package/gsd-core/bin/lib/health-diagnostic-rules/roadmap-disk-consistency.cjs +265 -0
  63. package/gsd-core/bin/lib/health-diagnostic-rules/root-existence.cjs +161 -0
  64. package/gsd-core/bin/lib/health-diagnostic-rules/state-consistency.cjs +303 -0
  65. package/gsd-core/bin/lib/health-diagnostic-rules/worktree-health.cjs +173 -0
  66. package/gsd-core/bin/lib/health-diagnostic-types.cjs +68 -0
  67. package/gsd-core/bin/lib/health-diagnostic.cjs +431 -0
  68. package/gsd-core/bin/lib/host-runtime-detection.cjs +134 -0
  69. package/gsd-core/bin/lib/init.cjs +321 -129
  70. package/gsd-core/bin/lib/install-effort-resolver.cjs +73 -30
  71. package/gsd-core/bin/lib/install-engine.cjs +745 -258
  72. package/gsd-core/bin/lib/install-fs-adapter.cjs +262 -0
  73. package/gsd-core/bin/lib/install-model-override-resolver.cjs +203 -0
  74. package/gsd-core/bin/lib/install-profiles.cjs +134 -57
  75. package/gsd-core/bin/lib/install-scope.cjs +270 -0
  76. package/gsd-core/bin/lib/install-shadow-report.cjs +385 -0
  77. package/gsd-core/bin/lib/installed-surface-resolver.cjs +381 -0
  78. package/gsd-core/bin/lib/installer-migrations.cjs +138 -31
  79. package/gsd-core/bin/lib/io.cjs +10 -0
  80. package/gsd-core/bin/lib/markdown-sectionizer.cjs +2 -1
  81. package/gsd-core/bin/lib/markdown-table.cjs +133 -20
  82. package/gsd-core/bin/lib/milestone-lock.cjs +248 -0
  83. package/gsd-core/bin/lib/milestone.cjs +754 -70
  84. package/gsd-core/bin/lib/model-catalog.cjs +59 -1
  85. package/gsd-core/bin/lib/model-resolver.cjs +183 -40
  86. package/gsd-core/bin/lib/normalize-test-command.cjs +1 -1
  87. package/gsd-core/bin/lib/pattern.cjs +122 -0
  88. package/gsd-core/bin/lib/phase-estimation.cjs +1 -1
  89. package/gsd-core/bin/lib/phase-id.cjs +444 -36
  90. package/gsd-core/bin/lib/phase-lifecycle.cjs +28 -3
  91. package/gsd-core/bin/lib/phase-locator.cjs +125 -18
  92. package/gsd-core/bin/lib/phase.cjs +646 -143
  93. package/gsd-core/bin/lib/plan-dependency-graph.cjs +72 -1
  94. package/gsd-core/bin/lib/plan-drift-guard.cjs +120 -0
  95. package/gsd-core/bin/lib/plan-scan.cjs +86 -2
  96. package/gsd-core/bin/lib/planning-scope.cjs +31 -0
  97. package/gsd-core/bin/lib/planning-snapshot.cjs +890 -0
  98. package/gsd-core/bin/lib/planning-workspace.cjs +56 -6
  99. package/gsd-core/bin/lib/probe-core.cjs +1 -1
  100. package/gsd-core/bin/lib/profile-output.cjs +1 -1
  101. package/gsd-core/bin/lib/refactor-trigger-command-router.cjs +740 -0
  102. package/gsd-core/bin/lib/retired-artifact-cleanup.cjs +11 -6
  103. package/gsd-core/bin/lib/review-lane-descriptor.cjs +13 -4
  104. package/gsd-core/bin/lib/review-lane-invocation.cjs +30 -0
  105. package/gsd-core/bin/lib/review-lane-runner.cjs +421 -66
  106. package/gsd-core/bin/lib/review-reviewer-selection.cjs +13 -18
  107. package/gsd-core/bin/lib/roadmap-command-router.cjs +34 -0
  108. package/gsd-core/bin/lib/roadmap-parser.cjs +943 -184
  109. package/gsd-core/bin/lib/roadmap-upgrade.cjs +37 -10
  110. package/gsd-core/bin/lib/roadmap.cjs +385 -94
  111. package/gsd-core/bin/lib/runtime-artifact-conversion.cjs +608 -46
  112. package/gsd-core/bin/lib/runtime-artifact-install-plan.cjs +14 -2
  113. package/gsd-core/bin/lib/runtime-artifact-layout.cjs +426 -55
  114. package/gsd-core/bin/lib/runtime-config-adapter-registry.cjs +3 -2
  115. package/gsd-core/bin/lib/runtime-homes.cjs +69 -3
  116. package/gsd-core/bin/lib/runtime-hooks-surface.cjs +115 -3
  117. package/gsd-core/bin/lib/runtime-name-policy.cjs +3 -1
  118. package/gsd-core/bin/lib/runtime-slash.cjs +27 -9
  119. package/gsd-core/bin/lib/security.cjs +104 -5
  120. package/gsd-core/bin/lib/shell-command-projection.cjs +275 -3
  121. package/gsd-core/bin/lib/smart-entry.cjs +142 -22
  122. package/gsd-core/bin/lib/state-command-router.cjs +5 -1
  123. package/gsd-core/bin/lib/state-document.cjs +152 -8
  124. package/gsd-core/bin/lib/state-transition.cjs +371 -117
  125. package/gsd-core/bin/lib/state.cjs +1794 -357
  126. package/gsd-core/bin/lib/surface.cjs +23 -9
  127. package/gsd-core/bin/lib/text-lines.cjs +80 -0
  128. package/gsd-core/bin/lib/token-scanner.cjs +76 -0
  129. package/gsd-core/bin/lib/uat-predicate.cjs +9 -3
  130. package/gsd-core/bin/lib/uat.cjs +399 -56
  131. package/gsd-core/bin/lib/ui-frontend-evidence.cjs +157 -0
  132. package/gsd-core/bin/lib/ui-safety-gate.cjs +14 -5
  133. package/gsd-core/bin/lib/unusable-input.cjs +24 -0
  134. package/gsd-core/bin/lib/update-context.cjs +8 -2
  135. package/gsd-core/bin/lib/user-artifact-staging.cjs +705 -0
  136. package/gsd-core/bin/lib/validate.cjs +20 -6
  137. package/gsd-core/bin/lib/vendor/README.md +37 -0
  138. package/gsd-core/bin/lib/vendor/re2js.cjs +6480 -0
  139. package/gsd-core/bin/lib/vendor/re2js.d.cts +938 -0
  140. package/gsd-core/bin/lib/verification-command-router.cjs +2 -1
  141. package/gsd-core/bin/lib/verification.cjs +258 -8
  142. package/gsd-core/bin/lib/verify.cjs +368 -888
  143. package/gsd-core/bin/lib/workstream-inventory-builder.cjs +53 -32
  144. package/gsd-core/bin/lib/workstream-inventory.cjs +63 -10
  145. package/gsd-core/bin/lib/workstream.cjs +2 -2
  146. package/gsd-core/bin/lib/worktree-safety.cjs +176 -9
  147. package/gsd-core/bin/shared/config-defaults.manifest.json +1 -0
  148. package/gsd-core/bin/shared/config-schema.manifest.json +7 -1
  149. package/gsd-core/references/agent-contracts.md +43 -26
  150. package/gsd-core/references/checkpoints.md +2 -2
  151. package/gsd-core/references/context-budget.md +1 -1
  152. package/gsd-core/references/dispatch-isolation-gate.md +138 -0
  153. package/gsd-core/references/doc-conflict-engine.md +1 -1
  154. package/gsd-core/references/execute-mvp-tdd.md +3 -3
  155. package/gsd-core/references/execute-phase-between-wave-reset.md +6 -2
  156. package/gsd-core/references/execute-phase-context-guard.md +1 -1
  157. package/gsd-core/references/execute-phase-response-language.md +1 -1
  158. package/gsd-core/references/execute-phase-wave-guard.md +6 -2
  159. package/gsd-core/references/gate-prompts.md +1 -1
  160. package/gsd-core/references/git-planning-commit.md +2 -1
  161. package/gsd-core/references/loop-hook-dispatch.md +39 -2
  162. package/gsd-core/references/model-profiles.md +12 -4
  163. package/gsd-core/references/mvp-concepts.md +9 -9
  164. package/gsd-core/references/planner-guidance.md +3 -9
  165. package/gsd-core/references/planner-preconditions.md +1 -1
  166. package/gsd-core/references/planner-reviews.md +1 -1
  167. package/gsd-core/references/planning-config.md +8 -6
  168. package/gsd-core/references/revision-loop.md +1 -1
  169. package/gsd-core/references/specless-probe-fallback.md +1 -1
  170. package/gsd-core/references/universal-anti-patterns.md +3 -3
  171. package/gsd-core/references/verifier-phase-gates.md +192 -0
  172. package/gsd-core/references/verify-mvp-mode.md +1 -1
  173. package/gsd-core/references/workstream-flag.md +22 -6
  174. package/gsd-core/templates/discussion-log.md +1 -1
  175. package/gsd-core/templates/phase-prompt.md +2 -4
  176. package/gsd-core/templates/state.md +4 -4
  177. package/gsd-core/templates/verification-report.md +9 -1
  178. package/gsd-core/workflows/ai-integration-phase.md +9 -11
  179. package/gsd-core/workflows/autonomous.md +1 -1
  180. package/gsd-core/workflows/cleanup.md +62 -3
  181. package/gsd-core/workflows/code-review/steps/structural-pre-pass.md +13 -3
  182. package/gsd-core/workflows/code-review-fix.md +37 -10
  183. package/gsd-core/workflows/code-review.md +38 -12
  184. package/gsd-core/workflows/complete-milestone.md +141 -18
  185. package/gsd-core/workflows/debug.md +7 -5
  186. package/gsd-core/workflows/diagnose-issues.md +35 -9
  187. package/gsd-core/workflows/discuss-phase/modes/chain.md +2 -1
  188. package/gsd-core/workflows/discuss-phase/modes/default.md +1 -1
  189. package/gsd-core/workflows/discuss-phase-assumptions.md +2 -1
  190. package/gsd-core/workflows/edit-phase.md +26 -1
  191. package/gsd-core/workflows/eval-review.md +3 -5
  192. package/gsd-core/workflows/execute-phase/steps/executor-isolation-dispatch.md +31 -6
  193. package/gsd-core/workflows/execute-phase/steps/per-plan-executor-routing.md +77 -0
  194. package/gsd-core/workflows/execute-phase/steps/per-plan-worktree-gate.md +2 -0
  195. package/gsd-core/workflows/execute-phase.md +38 -50
  196. package/gsd-core/workflows/execute-plan.md +36 -4
  197. package/gsd-core/workflows/explore.md +131 -4
  198. package/gsd-core/workflows/fast.md +10 -2
  199. package/gsd-core/workflows/health.md +73 -4
  200. package/gsd-core/workflows/import.md +4 -4
  201. package/gsd-core/workflows/ingest-docs.md +5 -5
  202. package/gsd-core/workflows/mvp-phase.md +6 -3
  203. package/gsd-core/workflows/new-milestone.md +14 -9
  204. package/gsd-core/workflows/new-project.md +14 -14
  205. package/gsd-core/workflows/next.md +12 -0
  206. package/gsd-core/workflows/plan-phase.md +41 -17
  207. package/gsd-core/workflows/plan-review-convergence.md +50 -2
  208. package/gsd-core/workflows/progress.md +34 -6
  209. package/gsd-core/workflows/quick/steps/plan-checker-loop.md +4 -4
  210. package/gsd-core/workflows/quick/steps/quick-verification.md +27 -6
  211. package/gsd-core/workflows/quick/steps/research-phase.md +2 -2
  212. package/gsd-core/workflows/quick.md +35 -15
  213. package/gsd-core/workflows/review.md +26 -5
  214. package/gsd-core/workflows/secure-phase.md +1 -1
  215. package/gsd-core/workflows/session-report.md +2 -1
  216. package/gsd-core/workflows/settings.md +66 -2
  217. package/gsd-core/workflows/ship.md +104 -44
  218. package/gsd-core/workflows/spec-phase.md +30 -12
  219. package/gsd-core/workflows/sync-skills.md +63 -8
  220. package/gsd-core/workflows/transition.md +46 -11
  221. package/gsd-core/workflows/ui-phase.md +5 -5
  222. package/gsd-core/workflows/ui-review.md +2 -2
  223. package/gsd-core/workflows/update.md +1 -1
  224. package/gsd-core/workflows/validate-phase.md +1 -1
  225. package/gsd-core/workflows/verify-work.md +9 -7
  226. package/hooks/dist/gsd-agent-isolation-guard.js +103 -14
  227. package/hooks/dist/gsd-check-update-worker.js +56 -13
  228. package/hooks/dist/gsd-check-update.js +19 -1
  229. package/hooks/dist/gsd-cursor-pre-tool.js +0 -3
  230. package/hooks/dist/gsd-cursor-subagent-start.js +77 -2
  231. package/hooks/dist/gsd-cursor-subagent-stop.js +3 -2
  232. package/hooks/dist/gsd-prompt-guard.js +21 -20
  233. package/hooks/dist/gsd-read-injection-scanner.js +38 -24
  234. package/hooks/dist/gsd-statusline.js +18 -0
  235. package/hooks/dist/gsd-update-banner.js +22 -1
  236. package/hooks/dist/gsd-workflow-guard.js +134 -36
  237. package/hooks/dist/lib/git-cmd.js +92 -59
  238. package/hooks/dist/lib/injection-patterns.js +45 -0
  239. package/hooks/dist/lib/isolation-deny-reason.js +39 -0
  240. package/hooks/dist/lib/isolation-sentinel.js +9 -0
  241. package/hooks/gsd-agent-isolation-guard.js +103 -14
  242. package/hooks/gsd-check-update-worker.js +56 -13
  243. package/hooks/gsd-check-update.js +19 -1
  244. package/hooks/gsd-cursor-pre-tool.js +0 -3
  245. package/hooks/gsd-cursor-subagent-start.js +77 -2
  246. package/hooks/gsd-cursor-subagent-stop.js +3 -2
  247. package/hooks/gsd-prompt-guard.js +21 -20
  248. package/hooks/gsd-read-injection-scanner.js +38 -24
  249. package/hooks/gsd-statusline.js +18 -0
  250. package/hooks/gsd-update-banner.js +22 -1
  251. package/hooks/gsd-workflow-guard.js +134 -36
  252. package/hooks/lib/git-cmd.js +92 -59
  253. package/hooks/lib/injection-patterns.js +45 -0
  254. package/hooks/lib/isolation-deny-reason.js +39 -0
  255. package/hooks/lib/isolation-sentinel.js +9 -0
  256. package/package.json +21 -9
  257. package/pi/gsd.cjs +19 -5
  258. package/scripts/baselines/planning-prompt-drift-baseline.json +4 -0
  259. package/scripts/baselines/planning-snapshot-bypass-baseline.json +12 -0
  260. package/scripts/baselines/unreachable-guard-drift-baseline.json +4 -0
  261. package/scripts/changeset/lint.cjs +60 -5
  262. package/scripts/check-alias-drift.cjs +7 -43
  263. package/scripts/check-contract-drift.cjs +297 -0
  264. package/scripts/ci-test-scope.cjs +19 -2
  265. package/scripts/command-contract-helpers.cjs +903 -1
  266. package/scripts/gen-adr-index.cjs +728 -38
  267. package/scripts/gen-capability-registry.cjs +3 -15
  268. package/scripts/gen-context-index.cjs +2 -11
  269. package/scripts/gen-health-docs.cjs +390 -0
  270. package/scripts/gen-inventory-manifest.cjs +50 -4
  271. package/scripts/gen-loop-host-contract.cjs +4 -24
  272. package/scripts/gen-registry.cjs +3 -14
  273. package/scripts/lib/alias-drift-families.cjs +46 -0
  274. package/scripts/lib/drift-scan.cjs +278 -0
  275. package/scripts/lint-allow-test-rule-refs.allowlist.json +1 -26
  276. package/scripts/lint-allow-test-rule-refs.effective-ceiling.json +4 -0
  277. package/scripts/lint-allow-test-rule-refs.unverified-ceiling.json +3 -0
  278. package/scripts/lint-canary-version-leak.cjs +73 -0
  279. package/scripts/lint-command-contract.cjs +96 -13
  280. package/scripts/lint-completion-predicate-drift.cjs +933 -0
  281. package/scripts/lint-completion-ratio-drift.cjs +214 -0
  282. package/scripts/lint-default-flip-documentation.cjs +193 -0
  283. package/scripts/lint-eslint-glob-coverage.allowlist.json +34 -0
  284. package/scripts/lint-eslint-glob-coverage.cjs +340 -0
  285. package/scripts/lint-frontmatter-scalar-broad-grep.cjs +237 -0
  286. package/scripts/lint-health-diagnostic-rule-table.cjs +404 -0
  287. package/scripts/lint-hooks-runtime-build-seam.cjs +262 -0
  288. package/scripts/lint-milestone-window-drift.cjs +468 -0
  289. package/scripts/lint-phase-enumeration-drift.cjs +479 -0
  290. package/scripts/lint-plan-count-drift.cjs +318 -0
  291. package/scripts/lint-planning-artifact-writer-drift.cjs +398 -0
  292. package/scripts/lint-planning-prompt-drift.cjs +434 -0
  293. package/scripts/lint-planning-snapshot-bypass-drift.cjs +544 -0
  294. package/scripts/lint-regression-test-names.cjs +15 -13
  295. package/scripts/lint-removed-but-needed.cjs +320 -0
  296. package/scripts/lint-state-field-drift.cjs +805 -0
  297. package/scripts/lint-state-write-path-drift.cjs +1045 -0
  298. package/scripts/lint-test-file-count.allowlist.json +21 -10
  299. package/scripts/lint-unreachable-guard-drift.cjs +843 -0
  300. package/scripts/lint-vendored-deps.cjs +124 -0
  301. package/scripts/pr-changed-files.cjs +63 -0
  302. package/scripts/pr-template-policy.cjs +14 -4
  303. package/scripts/prompt-injection-scan.sh +25 -0
  304. package/scripts/require-issue-link-policy.cjs +192 -0
  305. package/scripts/state-write-path-drift-baseline.json +19 -0
  306. package/scripts/sync-runtime-launcher.cjs +2 -4
  307. package/skills/gsd-autonomous/SKILL.md +0 -1
  308. package/skills/gsd-code-review/SKILL.md +1 -1
  309. package/skills/gsd-execute-phase/SKILL.md +1 -2
  310. package/skills/gsd-map-codebase/SKILL.md +1 -1
  311. package/skills/gsd-mempalace-capture/SKILL.md +1 -1
  312. package/skills/gsd-mempalace-recall/SKILL.md +1 -1
  313. package/skills/gsd-new-milestone/SKILL.md +1 -1
  314. package/skills/gsd-next/SKILL.md +0 -1
  315. package/skills/gsd-plan-phase/SKILL.md +0 -1
  316. package/skills/gsd-progress/SKILL.md +0 -1
  317. package/skills/gsd-quick/SKILL.md +1 -1
  318. package/skills/gsd-review-backlog/SKILL.md +2 -1
  319. package/skills/gsd-stats/SKILL.md +0 -1
  320. package/skills/gsd-verify-work/SKILL.md +1 -1
  321. package/vscode/package.json +1 -1
  322. package/gsd-core/workflows/discovery-phase.md +0 -298
  323. package/gsd-core/workflows/plan-milestone-gaps.md +0 -281
  324. package/gsd-core/workflows/verify-phase.md +0 -574
  325. package/scripts/affected-tests-lib.cjs +0 -554
  326. package/scripts/lint-allow-test-rule-refs.cjs +0 -162
  327. package/scripts/run-affected-tests.cjs +0 -7
  328. package/scripts/run-tests.cjs +0 -1051
@@ -114,6 +114,68 @@ function buildSummaryFileIndex(summaryFiles, extractCanonicalPlanId) {
114
114
  }
115
115
  return index;
116
116
  }
117
+ /**
118
+ * #3345: the one place "does this SUMMARY status value mean blocked" is
119
+ * decided, sibling to `isHaltedStatus` above. A SUMMARY declaring
120
+ * `status: blocked` records a plan that could NOT finish — it is a failure
121
+ * record, not a completion record — so it must not count toward
122
+ * `completed_plans` (scanPhasePlans's summaryCount) nor read as
123
+ * `has_summary: true` in phase-plan-index's `incomplete` construction.
124
+ *
125
+ * `halted` is deliberately NOT matched here: a designed stop still writes a
126
+ * completion record (#2830's model — its dependents get `blocked_by` halt
127
+ * propagation), so a `status: halted` SUMMARY keeps counting as summarized.
128
+ * Case-insensitive, trims whitespace, and strips an unquoted trailing YAML
129
+ * comment exactly like `isHaltedStatus` (same #2830 review defect-2 rule).
130
+ */
131
+ function isBlockedStatus(status) {
132
+ if (typeof status !== 'string')
133
+ return false;
134
+ const withoutTrailingComment = status.replace(/\s+#.*$/, '');
135
+ return withoutTrailingComment.trim().toLowerCase() === 'blocked';
136
+ }
137
+ // #3345: SUMMARY frontmatter sits at byte 0 and closes well before the body,
138
+ // so only a bounded prefix is ever needed to read the `status` marker — the
139
+ // same cap discipline as plan-scan.cts's PLAN_FRONTMATTER_READ_CAP (#2349),
140
+ // kept here because this predicate's primary caller (scanPhasePlans) loops
141
+ // over every phase directory on hot paths (state sync, roadmap progress).
142
+ const SUMMARY_FRONTMATTER_READ_CAP = 64 * 1024;
143
+ /**
144
+ * #3345: read a SUMMARY file's frontmatter `status` (bounded-prefix read) and
145
+ * report whether it declares `status: blocked`. Returns false — never throws —
146
+ * on a missing/unreadable/malformed/non-regular SUMMARY, so an unreadable file
147
+ * degrades to the pre-#3345 filename-existence behaviour rather than breaking
148
+ * either caller. Fail-open by design, mirroring `isPlanSuperseded`'s posture.
149
+ *
150
+ * Callers: plan-scan.cts's `scanPhasePlans` (the count side) and phase.cts's
151
+ * `cmdPhasePlanIndex` (the read side) BOTH filter their summary lists through
152
+ * this one predicate, so the count and the `incomplete` list can never
153
+ * re-diverge on the blocked rule.
154
+ */
155
+ function isSummaryFileBlocked(summaryPath) {
156
+ let content;
157
+ try {
158
+ const st = node_fs_1.default.statSync(summaryPath); // follows symlinks → resolves to the target's real type
159
+ if (!st.isFile())
160
+ return false;
161
+ const length = Math.min(st.size, SUMMARY_FRONTMATTER_READ_CAP);
162
+ if (length === 0)
163
+ return false;
164
+ const fd = node_fs_1.default.openSync(summaryPath, 'r');
165
+ try {
166
+ const buf = Buffer.allocUnsafe(length);
167
+ const bytesRead = node_fs_1.default.readSync(fd, buf, 0, length, 0);
168
+ content = buf.toString('utf8', 0, bytesRead);
169
+ }
170
+ finally {
171
+ node_fs_1.default.closeSync(fd);
172
+ }
173
+ }
174
+ catch {
175
+ return false;
176
+ }
177
+ return isBlockedStatus(extractFrontmatter(content, summaryPath)['status']);
178
+ }
117
179
  /**
118
180
  * Computes halt-propagation over a plan dependency DAG.
119
181
  *
@@ -229,4 +291,13 @@ function computeHaltPropagation(nodes, precomputedOrder) {
229
291
  }
230
292
  return { order, visited, blockedBy };
231
293
  }
232
- module.exports = { computeHaltPropagation, isHaltedStatus, buildSummaryFileIndex, isSummaryFileHalted };
294
+ module.exports = {
295
+ computeHaltPropagation,
296
+ isHaltedStatus,
297
+ buildSummaryFileIndex,
298
+ isSummaryFileHalted,
299
+ // #3345: blocked-SUMMARY detection, shared by the count side (scanPhasePlans)
300
+ // and the read side (phase-plan-index) so the two cannot diverge.
301
+ isBlockedStatus,
302
+ isSummaryFileBlocked,
303
+ };
@@ -20,6 +20,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
20
20
  exports.AUTHORITY_RUNGS = void 0;
21
21
  exports.getEffectiveAuthority = getEffectiveAuthority;
22
22
  exports.classifyDriftSeverity = classifyDriftSeverity;
23
+ exports.comparePhaseStatus = comparePhaseStatus;
23
24
  /**
24
25
  * Frozen map from authority name to its rung number.
25
26
  *
@@ -115,3 +116,122 @@ function classifyDriftSeverity({ status, authority, }) {
115
116
  return { severity: 'INFO', hardBlock: false };
116
117
  }
117
118
  }
119
+ /**
120
+ * Frozen map from lowercased phase-status text to a shared ordinal rank,
121
+ * covering the union of the STATE.md "Current Position" vocabulary
122
+ * (gsd-core/templates/state.md) and the FULL ROADMAP.md "## Progress" table
123
+ * Status column vocabulary declared by gsd-core/templates/roadmap.md:133 —
124
+ * `Not started | In progress | Complete | Deferred`.
125
+ *
126
+ * The two vocabularies overlap on 'in progress', which is rank 1 in both —
127
+ * no conflict. 'deferred' is rank 0 (no work done) — see comparePhaseStatus's
128
+ * doc comment for how a deferred/non-rank-0 mismatch is classified; it is NOT
129
+ * simply numeric distance from rank 0 like an ordinary lag.
130
+ */
131
+ const PHASE_STATUS_RANKS = Object.freeze({
132
+ // STATE.md "Current Position" vocabulary
133
+ 'ready to plan': 0,
134
+ 'planning': 0,
135
+ 'ready to execute': 1,
136
+ 'in progress': 1,
137
+ 'phase complete': 2,
138
+ // ROADMAP.md "## Progress" table Status column vocabulary
139
+ 'not started': 0,
140
+ 'complete': 2,
141
+ 'deferred': 0,
142
+ });
143
+ /** Rank at which a status asserts work is DONE (terminal, not comparative). */
144
+ const TERMINAL_RANK = 2;
145
+ /**
146
+ * Normalize a raw phase-status string for lookup/comparison: trims
147
+ * surrounding whitespace and lowercases. Returns null for missing/empty
148
+ * values. Single owner of this normalization so `resolvePhaseStatusRank` and
149
+ * the 'deferred' declared-intent check in `comparePhaseStatus` cannot drift
150
+ * apart on what counts as "empty".
151
+ */
152
+ function normalizePhaseStatusText(value) {
153
+ if (value === null || value === undefined)
154
+ return null;
155
+ const normalized = value.trim().toLowerCase();
156
+ return normalized === '' ? null : normalized;
157
+ }
158
+ /**
159
+ * Resolve a raw phase-status string to its shared ordinal rank, or null when
160
+ * the value is missing/empty/unrecognized. Case-insensitive, trims
161
+ * surrounding whitespace.
162
+ *
163
+ * @param value - raw status text from STATE.md or ROADMAP.md
164
+ * @returns the resolved rank, or null if unresolvable
165
+ */
166
+ function resolvePhaseStatusRank(value) {
167
+ const normalized = normalizePhaseStatusText(value);
168
+ if (normalized === null)
169
+ return null;
170
+ if (!Object.prototype.hasOwnProperty.call(PHASE_STATUS_RANKS, normalized))
171
+ return null;
172
+ return PHASE_STATUS_RANKS[normalized];
173
+ }
174
+ /**
175
+ * Compare a phase's status as reported by STATE.md against the same phase's
176
+ * status as reported by ROADMAP.md's "## Progress" table, and classify the
177
+ * result.
178
+ *
179
+ * Unlike classifyDriftSeverity, this never throws for an unrecognized
180
+ * status: the inputs are user document text (prose a human or agent typed
181
+ * into STATE.md/ROADMAP.md), not config, so an unrecognized value is data —
182
+ * surfaced as 'uncheckable' — not a programming error.
183
+ *
184
+ * Rank 2 ('phase complete' / 'Complete') is TERMINAL: it asserts the work is
185
+ * DONE. If exactly one side reports rank 2 and the other does not, that is
186
+ * always 'drifted', regardless of numeric distance — a document claiming
187
+ * "done" while another claims "still going" is a direct contradiction, not
188
+ * mere lag. This is the issue's canonical example: complete in STATE.md but
189
+ * in progress in ROADMAP.md.
190
+ *
191
+ * 'Deferred' is a second declared-intent rank-0 status (gsd-core/templates/
192
+ * roadmap.md:133's full vocabulary: `Not started | In progress | Complete |
193
+ * Deferred`) that is NOT ordinary lag from rank 0: it is an explicit
194
+ * decision to STOP work, not merely "hasn't started yet". If exactly one
195
+ * side declares 'deferred' and the other side's rank is >= 1 (work is
196
+ * reported as in progress or complete), that is always 'drifted' — a phase
197
+ * declared deferred while the other document says work is happening is a
198
+ * direct contradiction, checked here (like the terminal-completeness rule
199
+ * above) BEFORE the numeric distance comparison. 'Deferred' against a
200
+ * rank-0 status on the other side (e.g. 'Not started') stays 'consistent' —
201
+ * both agree no work has happened.
202
+ *
203
+ * Otherwise, ranks are compared numerically: equal → 'consistent';
204
+ * off-by-one → 'lag'; off-by-two-or-more → 'drifted'.
205
+ *
206
+ * @param opts.stateStatus - raw Status value from STATE.md's Current Position
207
+ * @param opts.roadmapStatus - raw Status cell from ROADMAP.md's Progress table
208
+ * @returns { verdict, stateRank, roadmapRank }
209
+ */
210
+ function comparePhaseStatus({ stateStatus, roadmapStatus, }) {
211
+ const stateRank = resolvePhaseStatusRank(stateStatus);
212
+ const roadmapRank = resolvePhaseStatusRank(roadmapStatus);
213
+ if (stateRank === null || roadmapRank === null) {
214
+ return { verdict: 'uncheckable', stateRank, roadmapRank };
215
+ }
216
+ const stateIsTerminal = stateRank === TERMINAL_RANK;
217
+ const roadmapIsTerminal = roadmapRank === TERMINAL_RANK;
218
+ if (stateIsTerminal !== roadmapIsTerminal) {
219
+ return { verdict: 'drifted', stateRank, roadmapRank };
220
+ }
221
+ const stateIsDeferred = normalizePhaseStatusText(stateStatus) === 'deferred';
222
+ const roadmapIsDeferred = normalizePhaseStatusText(roadmapStatus) === 'deferred';
223
+ if (stateIsDeferred !== roadmapIsDeferred) {
224
+ const otherRank = stateIsDeferred ? roadmapRank : stateRank;
225
+ if (otherRank >= 1) {
226
+ return { verdict: 'drifted', stateRank, roadmapRank };
227
+ }
228
+ }
229
+ const diff = Math.abs(stateRank - roadmapRank);
230
+ if (diff === 0) {
231
+ return { verdict: 'consistent', stateRank, roadmapRank };
232
+ }
233
+ if (diff === 1) {
234
+ return { verdict: 'lag', stateRank, roadmapRank };
235
+ }
236
+ return { verdict: 'drifted', stateRank, roadmapRank };
237
+ }
@@ -15,6 +15,12 @@ const { countMatchedSummaries } = coreUtils;
15
15
  // eslint-disable-next-line @typescript-eslint/no-require-imports
16
16
  const frontmatterMod = require("./frontmatter.cjs");
17
17
  const { extractFrontmatter } = frontmatterMod;
18
+ // eslint-disable-next-line @typescript-eslint/no-require-imports
19
+ const planningScopeMod = require("./planning-scope.cjs");
20
+ const { SCOPE } = planningScopeMod;
21
+ // eslint-disable-next-line @typescript-eslint/no-require-imports
22
+ const planDependencyGraphMod = require("./plan-dependency-graph.cjs");
23
+ const { isSummaryFileBlocked } = planDependencyGraphMod;
18
24
  // Excluded derivative files
19
25
  const PLAN_OUTLINE_RE = /-OUTLINE\.md$/i;
20
26
  const PLAN_PRE_BOUNCE_RE = /\.pre-bounce\.md$/i;
@@ -97,6 +103,43 @@ function isRootSummaryFile(fileName) {
97
103
  function isNestedSummaryFile(fileName) {
98
104
  return /^SUMMARY-\d+.*\.md$/i.test(fileName) || /-SUMMARY-\d+.*\.md$/i.test(fileName);
99
105
  }
106
+ /**
107
+ * Strict canonical-naming predicate over a `scanPhasePlans` `planFiles`/
108
+ * `allPlanFiles` ENTRY (root form bare, nested form `plans/`-prefixed, exactly
109
+ * as those arrays store them) — root `<phase>-<NN>-PLAN.md`/bare `PLAN.md`,
110
+ * or nested `plans/PLAN-<NN>....md`/`plans/<x>-PLAN-<NN>....md` — WITHOUT
111
+ * `isRootPlanFile`'s loose `/\.md$/i && /PLAN/i` fallback.
112
+ *
113
+ * The `plans/` prefix check is load-bearing, not cosmetic: `isNestedPlanFile`
114
+ * matches ANY basename containing `-PLAN-<digits>...md` with no anchor
115
+ * requiring an actual `plans/` directory — that shape is exactly the #2893
116
+ * reporter's non-canonical example, `01-PLAN-01-foundation.md`. Applying
117
+ * `isNestedPlanFile` directly to a bare root-level name would therefore
118
+ * misclassify that exact offender as canonical. Only entries scanPhasePlans
119
+ * itself produced with the `plans/` prefix (i.e. read from the real nested
120
+ * subdirectory) are eligible for the nested check.
121
+ *
122
+ * #2893/#3183: `isRootPlanFile`'s loose fallback is deliberately permissive
123
+ * for live-plan COUNTING (a lowercase `plan.md` still counts toward
124
+ * completion — see plan-count-single-owner.test.cjs's pinned case-sensitivity
125
+ * asymmetry). But the #2893 "non-canonical filename" diagnostic (phase.cts's
126
+ * `describeNonCanonicalPlans`, used by find-phase/phase-plan-index/phases
127
+ * list --type plans) exists specifically to CATCH a plan-shaped file that
128
+ * does NOT match the canonical contract and warn instead of silently
129
+ * scheduling it. Feeding that diagnostic (and the `plans`/`files` lists those
130
+ * commands return) the loose `allPlanFiles`/`planFiles` set defeats the
131
+ * diagnostic entirely, since the loose fallback already recognizes the
132
+ * non-canonical file as "matched". This predicate is the STRICT filter those
133
+ * three call sites intersect against so the diagnostic (and what counts as a
134
+ * schedulable plan for those commands specifically) stays canonical-only,
135
+ * while scanPhasePlans's own planCount/summaryCount/completed stay on the
136
+ * loose, permissive rule.
137
+ */
138
+ function isCanonicalPlanFile(fileEntry) {
139
+ if (fileEntry.startsWith('plans/'))
140
+ return isNestedPlanFile(fileEntry.slice('plans/'.length));
141
+ return fileEntry.endsWith('-PLAN.md') || fileEntry === 'PLAN.md';
142
+ }
100
143
  function scanPhasePlans(phaseDir) {
101
144
  let rootFiles;
102
145
  try {
@@ -109,7 +152,9 @@ function scanPhasePlans(phaseDir) {
109
152
  completed: false,
110
153
  hasNestedPlans: false,
111
154
  planFiles: [],
155
+ allPlanFiles: [],
112
156
  summaryFiles: [],
157
+ scope: SCOPE.UNREADABLE,
113
158
  };
114
159
  }
115
160
  const rootPlanFiles = rootFiles.filter(isRootPlanFile);
@@ -117,6 +162,7 @@ function scanPhasePlans(phaseDir) {
117
162
  let nestedPlanFiles = [];
118
163
  let nestedSummaryFiles = [];
119
164
  let hasNestedPlans = false;
165
+ let scope = SCOPE.COMPLETE;
120
166
  const nestedDir = (0, node_path_1.join)(phaseDir, 'plans');
121
167
  if ((0, node_fs_1.existsSync)(nestedDir)) {
122
168
  try {
@@ -125,7 +171,12 @@ function scanPhasePlans(phaseDir) {
125
171
  nestedSummaryFiles = nestedFiles.filter(isNestedSummaryFile).map((file) => `plans/${file}`);
126
172
  hasNestedPlans = nestedPlanFiles.length > 0;
127
173
  }
128
- catch { /* ignore unreadable nested layout */ }
174
+ catch {
175
+ // #3183 (ADR-3180 Decision 2): the nested plans/ dir exists but could not
176
+ // be read — this scan cannot see plans it knows are there, so zero is
177
+ // NOT a reliable answer; mark TRUNCATED rather than COMPLETE.
178
+ scope = SCOPE.TRUNCATED;
179
+ }
129
180
  }
130
181
  const allPlanFiles = rootPlanFiles.concat(nestedPlanFiles);
131
182
  // #2349: drop plans explicitly marked `status: superseded` from the plan set
@@ -144,7 +195,18 @@ function scanPhasePlans(phaseDir) {
144
195
  // 30-GAPCLOSURE-SUMMARY.md) must not inflate summary_count or flip a phase to
145
196
  // Complete when plans are still missing summaries. summaryFiles (the array)
146
197
  // still holds every summary on disk for callers that read/list them.
147
- const summaryCount = countMatchedSummaries(planFiles, summaryFiles);
198
+ //
199
+ // #3345: a SUMMARY whose frontmatter declares `status: blocked` is a failure
200
+ // record, not a completion record — it is dropped from the COUNTABLE pairing
201
+ // set before matching. The bounded-prefix status read is the SHARED predicate
202
+ // (plan-dependency-graph.cjs's isSummaryFileBlocked) that phase.cts's read
203
+ // path also filters through, so the count and the `incomplete` list cannot
204
+ // diverge. Fail-open: a SUMMARY with no `status` key, or one that cannot be read,
205
+ // keeps its pre-#3345 filename-existence meaning — untouched projects are
206
+ // byte-for-behaviour identical. `status: halted` stays counted (#2830: a
207
+ // designed stop still writes a completion record).
208
+ const countableSummaryFiles = summaryFiles.filter((f) => !isSummaryFileBlocked((0, node_path_1.join)(phaseDir, f)));
209
+ const summaryCount = countMatchedSummaries(planFiles, countableSummaryFiles);
148
210
  return {
149
211
  planCount,
150
212
  summaryCount,
@@ -155,10 +217,31 @@ function scanPhasePlans(phaseDir) {
155
217
  // (0 >= 0) rather than being pinned below 100% forever, which is the very
156
218
  // failure this fix removes. A genuinely empty phase (no plans authored)
157
219
  // still has allPlanFiles.length 0 and stays not-completed, exactly as before.
220
+ //
221
+ // ADR-3180 §7.4 (issue #3186) — DELIBERATELY NOT routed through
222
+ // `isPhaseComplete` (src/verification.cts). This field answers "are all
223
+ // plans summarized?", NOT "is the phase complete?" — completion
224
+ // additionally requires a passing `*-VERIFICATION.md`, which is the
225
+ // whole point of that owner's unconditional readVerificationStatus call.
226
+ // Folding this field onto `isPhaseComplete` would either over-report
227
+ // completion (a phase whose plans are done but never verified) or drag a
228
+ // verification read into this module, inverting the dependency
229
+ // direction between this Phase-1 owner (plan counting) and the Phase-4
230
+ // owner (completion) — the owner must consume plan counts, never the
231
+ // reverse. Kept as its own, differently-scoped answer per the design's
232
+ // "0.x split" and exempted (function-scoped, not file-scoped) in
233
+ // scripts/lint-completion-predicate-drift.cjs's FUNCTION_SCOPED_EXEMPTIONS.
234
+ // The field name is left unchanged (not renamed to e.g.
235
+ // `summariesMeetPlanCount`) — scanPhasePlans has 11 direct callers, and a
236
+ // rename's blast radius is out of this phase's declared scope; noted
237
+ // here as a deliberate, considered-and-declined option rather than an
238
+ // oversight.
158
239
  completed: allPlanFiles.length > 0 && summaryCount >= planCount,
159
240
  hasNestedPlans,
160
241
  planFiles,
242
+ allPlanFiles,
161
243
  summaryFiles,
244
+ scope,
162
245
  };
163
246
  }
164
247
  module.exports = Object.assign(scanPhasePlans, {
@@ -167,4 +250,5 @@ module.exports = Object.assign(scanPhasePlans, {
167
250
  isNestedPlanFile,
168
251
  isRootSummaryFile,
169
252
  isNestedSummaryFile,
253
+ isCanonicalPlanFile,
170
254
  });
@@ -0,0 +1,31 @@
1
+ "use strict";
2
+ /**
3
+ * Planning Scope — shared result discriminator for live-plan scanning.
4
+ *
5
+ * ADR-3180 Decision 2 (docs/adr/3180-planning-semantic-model-single-owner.md):
6
+ * `scanPhasePlans` is the single owner of live-plan counting, and every
7
+ * consumer of that count needs to distinguish a REAL answer from a
8
+ * NON-answer. `SCOPE.COMPLETE` with zero items is a real answer — a phase
9
+ * genuinely has no plans yet. `SCOPE.TRUNCATED`, `SCOPE.UNSCOPED`, and
10
+ * `SCOPE.UNREADABLE` with zero items are NOT — they mean the scan could not
11
+ * see (part of) the phase directory, so a caller must not treat that zero as
12
+ * "this phase has no plans."
13
+ *
14
+ * This is a frozen enum, not a message string: CONTRIBUTING.md bans raw-text
15
+ * matching on outputs and requires a typed IR, so callers branch on the
16
+ * `SCOPE` value rather than pattern-matching prose.
17
+ *
18
+ * PROVISIONAL: this contract is pending this phase's validation and may be
19
+ * revised before the epic (#3180) ships.
20
+ *
21
+ * Dependencies: none — this is a leaf module (mirrors src/phase-id.cts). It
22
+ * imports nothing, so any consumer can depend on it without risking a cycle.
23
+ */
24
+ const SCOPE = Object.freeze({
25
+ COMPLETE: 'complete',
26
+ TRUNCATED: 'truncated',
27
+ UNSCOPED: 'unscoped',
28
+ UNREADABLE: 'unreadable',
29
+ });
30
+ const planningScope = { SCOPE };
31
+ module.exports = planningScope;