gsd-pi 2.57.0 → 2.58.0-dev.d63175c

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 (194) hide show
  1. package/dist/resources/extensions/gsd/auto/infra-errors.js +4 -0
  2. package/dist/resources/extensions/gsd/auto-dispatch.js +3 -3
  3. package/dist/resources/extensions/gsd/auto-worktree.js +7 -2
  4. package/dist/resources/extensions/gsd/auto.js +4 -0
  5. package/dist/resources/extensions/gsd/bootstrap/db-tools.js +2 -1
  6. package/dist/resources/extensions/gsd/dispatch-guard.js +11 -1
  7. package/dist/resources/extensions/gsd/gsd-db.js +8 -1
  8. package/dist/resources/extensions/gsd/parallel-orchestrator.js +23 -6
  9. package/dist/resources/extensions/gsd/preferences.js +29 -15
  10. package/dist/resources/extensions/gsd/prompts/validate-milestone.md +2 -2
  11. package/dist/resources/extensions/gsd/tools/validate-milestone.js +4 -0
  12. package/dist/web/standalone/.next/BUILD_ID +1 -1
  13. package/dist/web/standalone/.next/app-path-routes-manifest.json +13 -13
  14. package/dist/web/standalone/.next/build-manifest.json +4 -4
  15. package/dist/web/standalone/.next/prerender-manifest.json +3 -3
  16. package/dist/web/standalone/.next/react-loadable-manifest.json +1 -1
  17. package/dist/web/standalone/.next/required-server-files.json +4 -4
  18. package/dist/web/standalone/.next/server/app/_global-error/page.js +3 -3
  19. package/dist/web/standalone/.next/server/app/_global-error/page_client-reference-manifest.js +1 -1
  20. package/dist/web/standalone/.next/server/app/_global-error.html +2 -2
  21. package/dist/web/standalone/.next/server/app/_global-error.rsc +1 -1
  22. package/dist/web/standalone/.next/server/app/_global-error.segments/_full.segment.rsc +1 -1
  23. package/dist/web/standalone/.next/server/app/_global-error.segments/_global-error/__PAGE__.segment.rsc +1 -1
  24. package/dist/web/standalone/.next/server/app/_global-error.segments/_global-error.segment.rsc +1 -1
  25. package/dist/web/standalone/.next/server/app/_global-error.segments/_head.segment.rsc +1 -1
  26. package/dist/web/standalone/.next/server/app/_global-error.segments/_index.segment.rsc +1 -1
  27. package/dist/web/standalone/.next/server/app/_global-error.segments/_tree.segment.rsc +1 -1
  28. package/dist/web/standalone/.next/server/app/_not-found/page.js +2 -2
  29. package/dist/web/standalone/.next/server/app/_not-found/page_client-reference-manifest.js +1 -1
  30. package/dist/web/standalone/.next/server/app/_not-found.html +1 -1
  31. package/dist/web/standalone/.next/server/app/_not-found.rsc +3 -3
  32. package/dist/web/standalone/.next/server/app/_not-found.segments/_full.segment.rsc +3 -3
  33. package/dist/web/standalone/.next/server/app/_not-found.segments/_head.segment.rsc +1 -1
  34. package/dist/web/standalone/.next/server/app/_not-found.segments/_index.segment.rsc +3 -3
  35. package/dist/web/standalone/.next/server/app/_not-found.segments/_not-found/__PAGE__.segment.rsc +1 -1
  36. package/dist/web/standalone/.next/server/app/_not-found.segments/_not-found.segment.rsc +1 -1
  37. package/dist/web/standalone/.next/server/app/_not-found.segments/_tree.segment.rsc +1 -1
  38. package/dist/web/standalone/.next/server/app/api/boot/route.js +1 -1
  39. package/dist/web/standalone/.next/server/app/api/boot/route_client-reference-manifest.js +1 -1
  40. package/dist/web/standalone/.next/server/app/api/bridge-terminal/input/route.js +1 -1
  41. package/dist/web/standalone/.next/server/app/api/bridge-terminal/input/route_client-reference-manifest.js +1 -1
  42. package/dist/web/standalone/.next/server/app/api/bridge-terminal/resize/route.js +1 -1
  43. package/dist/web/standalone/.next/server/app/api/bridge-terminal/resize/route_client-reference-manifest.js +1 -1
  44. package/dist/web/standalone/.next/server/app/api/bridge-terminal/stream/route.js +2 -2
  45. package/dist/web/standalone/.next/server/app/api/bridge-terminal/stream/route_client-reference-manifest.js +1 -1
  46. package/dist/web/standalone/.next/server/app/api/browse-directories/route.js +1 -1
  47. package/dist/web/standalone/.next/server/app/api/browse-directories/route_client-reference-manifest.js +1 -1
  48. package/dist/web/standalone/.next/server/app/api/captures/route.js +1 -1
  49. package/dist/web/standalone/.next/server/app/api/captures/route_client-reference-manifest.js +1 -1
  50. package/dist/web/standalone/.next/server/app/api/cleanup/route.js +1 -1
  51. package/dist/web/standalone/.next/server/app/api/cleanup/route_client-reference-manifest.js +1 -1
  52. package/dist/web/standalone/.next/server/app/api/dev-mode/route.js +1 -1
  53. package/dist/web/standalone/.next/server/app/api/dev-mode/route_client-reference-manifest.js +1 -1
  54. package/dist/web/standalone/.next/server/app/api/doctor/route.js +1 -1
  55. package/dist/web/standalone/.next/server/app/api/doctor/route_client-reference-manifest.js +1 -1
  56. package/dist/web/standalone/.next/server/app/api/experimental/route.js +2 -2
  57. package/dist/web/standalone/.next/server/app/api/experimental/route_client-reference-manifest.js +1 -1
  58. package/dist/web/standalone/.next/server/app/api/export-data/route.js +1 -1
  59. package/dist/web/standalone/.next/server/app/api/export-data/route_client-reference-manifest.js +1 -1
  60. package/dist/web/standalone/.next/server/app/api/files/route.js +1 -1
  61. package/dist/web/standalone/.next/server/app/api/files/route_client-reference-manifest.js +1 -1
  62. package/dist/web/standalone/.next/server/app/api/forensics/route.js +1 -1
  63. package/dist/web/standalone/.next/server/app/api/forensics/route_client-reference-manifest.js +1 -1
  64. package/dist/web/standalone/.next/server/app/api/git/route.js +1 -1
  65. package/dist/web/standalone/.next/server/app/api/git/route_client-reference-manifest.js +1 -1
  66. package/dist/web/standalone/.next/server/app/api/history/route.js +1 -1
  67. package/dist/web/standalone/.next/server/app/api/history/route_client-reference-manifest.js +1 -1
  68. package/dist/web/standalone/.next/server/app/api/hooks/route.js +1 -1
  69. package/dist/web/standalone/.next/server/app/api/hooks/route_client-reference-manifest.js +1 -1
  70. package/dist/web/standalone/.next/server/app/api/inspect/route.js +1 -1
  71. package/dist/web/standalone/.next/server/app/api/inspect/route_client-reference-manifest.js +1 -1
  72. package/dist/web/standalone/.next/server/app/api/knowledge/route.js +1 -1
  73. package/dist/web/standalone/.next/server/app/api/knowledge/route_client-reference-manifest.js +1 -1
  74. package/dist/web/standalone/.next/server/app/api/live-state/route.js +1 -1
  75. package/dist/web/standalone/.next/server/app/api/live-state/route_client-reference-manifest.js +1 -1
  76. package/dist/web/standalone/.next/server/app/api/onboarding/route.js +1 -1
  77. package/dist/web/standalone/.next/server/app/api/onboarding/route_client-reference-manifest.js +1 -1
  78. package/dist/web/standalone/.next/server/app/api/preferences/route.js +1 -1
  79. package/dist/web/standalone/.next/server/app/api/preferences/route_client-reference-manifest.js +1 -1
  80. package/dist/web/standalone/.next/server/app/api/projects/route.js +1 -1
  81. package/dist/web/standalone/.next/server/app/api/projects/route_client-reference-manifest.js +1 -1
  82. package/dist/web/standalone/.next/server/app/api/recovery/route.js +1 -1
  83. package/dist/web/standalone/.next/server/app/api/recovery/route_client-reference-manifest.js +1 -1
  84. package/dist/web/standalone/.next/server/app/api/remote-questions/route.js +2 -2
  85. package/dist/web/standalone/.next/server/app/api/remote-questions/route_client-reference-manifest.js +1 -1
  86. package/dist/web/standalone/.next/server/app/api/session/browser/route.js +1 -1
  87. package/dist/web/standalone/.next/server/app/api/session/browser/route_client-reference-manifest.js +1 -1
  88. package/dist/web/standalone/.next/server/app/api/session/command/route.js +1 -1
  89. package/dist/web/standalone/.next/server/app/api/session/command/route_client-reference-manifest.js +1 -1
  90. package/dist/web/standalone/.next/server/app/api/session/events/route.js +2 -2
  91. package/dist/web/standalone/.next/server/app/api/session/events/route_client-reference-manifest.js +1 -1
  92. package/dist/web/standalone/.next/server/app/api/session/manage/route.js +1 -1
  93. package/dist/web/standalone/.next/server/app/api/session/manage/route_client-reference-manifest.js +1 -1
  94. package/dist/web/standalone/.next/server/app/api/settings-data/route.js +1 -1
  95. package/dist/web/standalone/.next/server/app/api/settings-data/route_client-reference-manifest.js +1 -1
  96. package/dist/web/standalone/.next/server/app/api/shutdown/route.js +1 -1
  97. package/dist/web/standalone/.next/server/app/api/shutdown/route_client-reference-manifest.js +1 -1
  98. package/dist/web/standalone/.next/server/app/api/skill-health/route.js +1 -1
  99. package/dist/web/standalone/.next/server/app/api/skill-health/route_client-reference-manifest.js +1 -1
  100. package/dist/web/standalone/.next/server/app/api/steer/route.js +1 -1
  101. package/dist/web/standalone/.next/server/app/api/steer/route_client-reference-manifest.js +1 -1
  102. package/dist/web/standalone/.next/server/app/api/switch-root/route.js +1 -1
  103. package/dist/web/standalone/.next/server/app/api/switch-root/route_client-reference-manifest.js +1 -1
  104. package/dist/web/standalone/.next/server/app/api/terminal/input/route.js +2 -2
  105. package/dist/web/standalone/.next/server/app/api/terminal/input/route_client-reference-manifest.js +1 -1
  106. package/dist/web/standalone/.next/server/app/api/terminal/resize/route.js +2 -2
  107. package/dist/web/standalone/.next/server/app/api/terminal/resize/route_client-reference-manifest.js +1 -1
  108. package/dist/web/standalone/.next/server/app/api/terminal/sessions/route.js +2 -2
  109. package/dist/web/standalone/.next/server/app/api/terminal/sessions/route_client-reference-manifest.js +1 -1
  110. package/dist/web/standalone/.next/server/app/api/terminal/stream/route.js +4 -4
  111. package/dist/web/standalone/.next/server/app/api/terminal/stream/route_client-reference-manifest.js +1 -1
  112. package/dist/web/standalone/.next/server/app/api/terminal/upload/route.js +1 -1
  113. package/dist/web/standalone/.next/server/app/api/terminal/upload/route_client-reference-manifest.js +1 -1
  114. package/dist/web/standalone/.next/server/app/api/undo/route.js +1 -1
  115. package/dist/web/standalone/.next/server/app/api/undo/route_client-reference-manifest.js +1 -1
  116. package/dist/web/standalone/.next/server/app/api/update/route.js +1 -1
  117. package/dist/web/standalone/.next/server/app/api/update/route_client-reference-manifest.js +1 -1
  118. package/dist/web/standalone/.next/server/app/api/visualizer/route.js +1 -1
  119. package/dist/web/standalone/.next/server/app/api/visualizer/route_client-reference-manifest.js +1 -1
  120. package/dist/web/standalone/.next/server/app/index.html +1 -1
  121. package/dist/web/standalone/.next/server/app/index.rsc +4 -4
  122. package/dist/web/standalone/.next/server/app/index.segments/__PAGE__.segment.rsc +2 -2
  123. package/dist/web/standalone/.next/server/app/index.segments/_full.segment.rsc +4 -4
  124. package/dist/web/standalone/.next/server/app/index.segments/_head.segment.rsc +1 -1
  125. package/dist/web/standalone/.next/server/app/index.segments/_index.segment.rsc +3 -3
  126. package/dist/web/standalone/.next/server/app/index.segments/_tree.segment.rsc +1 -1
  127. package/dist/web/standalone/.next/server/app/page.js +2 -2
  128. package/dist/web/standalone/.next/server/app/page_client-reference-manifest.js +1 -1
  129. package/dist/web/standalone/.next/server/app-paths-manifest.json +13 -13
  130. package/dist/web/standalone/.next/server/chunks/2229.js +1 -1
  131. package/dist/web/standalone/.next/server/chunks/7471.js +3 -3
  132. package/dist/web/standalone/.next/server/middleware-build-manifest.js +1 -1
  133. package/dist/web/standalone/.next/server/middleware-react-loadable-manifest.js +1 -1
  134. package/dist/web/standalone/.next/server/middleware.js +2 -2
  135. package/dist/web/standalone/.next/server/next-font-manifest.js +1 -1
  136. package/dist/web/standalone/.next/server/next-font-manifest.json +1 -1
  137. package/dist/web/standalone/.next/server/pages/404.html +1 -1
  138. package/dist/web/standalone/.next/server/pages/500.html +2 -2
  139. package/dist/web/standalone/.next/server/server-reference-manifest.json +1 -1
  140. package/dist/web/standalone/.next/static/chunks/6502.8b732f67a11b11b4.js +9 -0
  141. package/dist/web/standalone/.next/static/chunks/app/_not-found/{page-2f24283c162b6ab3.js → page-f2a7482d42a5614b.js} +1 -1
  142. package/dist/web/standalone/.next/static/chunks/app/{layout-9ecfd95f343793f0.js → layout-a16c7a7ecdf0c2cf.js} +1 -1
  143. package/dist/web/standalone/.next/static/chunks/app/page-0c485498795110d6.js +1 -0
  144. package/dist/web/standalone/.next/static/chunks/main-app-fdab67f7802d7832.js +1 -0
  145. package/dist/web/standalone/.next/static/chunks/next/dist/client/components/builtin/global-error-459824ffb8c323dd.js +1 -0
  146. package/dist/web/standalone/.next/static/chunks/{webpack-4332cbd5dd1be584.js → webpack-61d3afac6d0f0ce7.js} +1 -1
  147. package/dist/web/standalone/node_modules/node-pty/build/Makefile +2 -2
  148. package/dist/web/standalone/node_modules/node-pty/build/Release/pty.node +0 -0
  149. package/dist/web/standalone/node_modules/node-pty/build/pty.target.mk +14 -14
  150. package/dist/web/standalone/node_modules/node-pty/node-addon-api/node_addon_api.target.mk +14 -14
  151. package/dist/web/standalone/node_modules/node-pty/node-addon-api/node_addon_api_except.target.mk +14 -14
  152. package/dist/web/standalone/node_modules/node-pty/node-addon-api/node_addon_api_maybe.target.mk +14 -14
  153. package/dist/web/standalone/server.js +1 -1
  154. package/package.json +1 -1
  155. package/packages/daemon/src/cli.ts +49 -0
  156. package/packages/daemon/src/daemon.test.ts +104 -1
  157. package/packages/daemon/src/daemon.ts +24 -1
  158. package/packages/daemon/src/discord-bot.ts +73 -3
  159. package/packages/daemon/src/event-bridge.ts +15 -9
  160. package/packages/daemon/src/event-formatter.ts +30 -2
  161. package/packages/daemon/src/index.ts +9 -0
  162. package/packages/daemon/src/launchd.test.ts +356 -0
  163. package/packages/daemon/src/launchd.ts +242 -0
  164. package/packages/daemon/src/message-batcher.test.ts +2 -2
  165. package/packages/daemon/src/message-batcher.ts +9 -3
  166. package/packages/daemon/src/orchestrator.test.ts +1 -0
  167. package/packages/daemon/src/orchestrator.ts +106 -2
  168. package/packages/pi-coding-agent/package.json +1 -1
  169. package/pkg/package.json +1 -1
  170. package/src/resources/extensions/gsd/auto/infra-errors.ts +3 -0
  171. package/src/resources/extensions/gsd/auto-dispatch.ts +3 -3
  172. package/src/resources/extensions/gsd/auto-worktree.ts +7 -2
  173. package/src/resources/extensions/gsd/auto.ts +5 -0
  174. package/src/resources/extensions/gsd/bootstrap/db-tools.ts +2 -1
  175. package/src/resources/extensions/gsd/dispatch-guard.ts +12 -1
  176. package/src/resources/extensions/gsd/gsd-db.ts +6 -1
  177. package/src/resources/extensions/gsd/parallel-orchestrator.ts +23 -6
  178. package/src/resources/extensions/gsd/preferences.ts +32 -14
  179. package/src/resources/extensions/gsd/prompts/validate-milestone.md +2 -2
  180. package/src/resources/extensions/gsd/tests/auto-loop.test.ts +18 -0
  181. package/src/resources/extensions/gsd/tests/dispatch-guard.test.ts +47 -0
  182. package/src/resources/extensions/gsd/tests/parallel-worker-monitoring.test.ts +9 -8
  183. package/src/resources/extensions/gsd/tests/preferences.test.ts +34 -0
  184. package/src/resources/extensions/gsd/tests/prompt-contracts.test.ts +7 -0
  185. package/src/resources/extensions/gsd/tests/validate-milestone-write-order.test.ts +23 -1
  186. package/src/resources/extensions/gsd/tests/validation-gate-patterns.test.ts +44 -2
  187. package/src/resources/extensions/gsd/tests/worktree-db-same-file.test.ts +175 -0
  188. package/src/resources/extensions/gsd/tools/validate-milestone.ts +5 -0
  189. package/dist/web/standalone/.next/static/chunks/6502.2305d0afd2385711.js +0 -9
  190. package/dist/web/standalone/.next/static/chunks/app/page-62be3b5fa91e4c8f.js +0 -1
  191. package/dist/web/standalone/.next/static/chunks/main-app-d3d4c336195465f9.js +0 -1
  192. package/dist/web/standalone/.next/static/chunks/next/dist/client/components/builtin/global-error-ab5a8926e07ec673.js +0 -1
  193. /package/dist/web/standalone/.next/static/{yowc5qPtuKxjOr22KmOAy → 5DLsjFHdSB6_a1EDQVjr7}/_buildManifest.js +0 -0
  194. /package/dist/web/standalone/.next/static/{yowc5qPtuKxjOr22KmOAy → 5DLsjFHdSB6_a1EDQVjr7}/_ssgManifest.js +0 -0
@@ -22,6 +22,7 @@ import { normalizeStringArray } from "../shared/format-utils.js";
22
22
  import { resolveProfileDefaults as _resolveProfileDefaults } from "./preferences-models.js";
23
23
 
24
24
  import {
25
+ KNOWN_PREFERENCE_KEYS,
25
26
  MODE_DEFAULTS,
26
27
  type WorkflowMode,
27
28
  type GSDPreferences,
@@ -250,7 +251,7 @@ function parseFrontmatterBlock(frontmatter: string): GSDPreferences {
250
251
  * - planner: sonnet
251
252
  */
252
253
  function parseHeadingListFormat(content: string): GSDPreferences {
253
- const result: Record<string, Record<string, string>> = {};
254
+ const result: Record<string, string[]> = {};
254
255
  let currentSection: string | null = null;
255
256
 
256
257
  for (const rawLine of content.split('\n')) {
@@ -258,27 +259,44 @@ function parseHeadingListFormat(content: string): GSDPreferences {
258
259
  const headingMatch = line.match(/^##\s+(.+)$/);
259
260
  if (headingMatch) {
260
261
  currentSection = headingMatch[1].trim().toLowerCase().replace(/\s+/g, '_');
262
+ if (!result[currentSection]) result[currentSection] = [];
261
263
  continue;
262
264
  }
263
- if (currentSection) {
264
- const itemMatch = line.match(/^-\s+([^:]+):\s*(.*)$/);
265
- if (itemMatch) {
266
- if (!result[currentSection]) result[currentSection] = {};
267
- const value = itemMatch[2].trim();
268
- // Coerce "true"/"false" strings and numbers
269
- result[currentSection][itemMatch[1].trim()] = value;
270
- }
265
+ if (currentSection && line.trim() && !line.trimStart().startsWith('#')) {
266
+ result[currentSection].push(line);
271
267
  }
272
268
  }
273
269
 
274
- // Convert string values to appropriate types via YAML parser for each section
275
270
  const typed: Record<string, unknown> = {};
276
- for (const [section, entries] of Object.entries(result)) {
277
- const yamlLines = Object.entries(entries).map(([k, v]) => `${k}: ${v}`).join('\n');
271
+ for (const [section, lines] of Object.entries(result)) {
272
+ if (lines.length === 0) continue;
273
+
274
+ const usesLegacyListItems = lines.every((line) => /^\s*-\s+[^:]+:\s*.*$/.test(line));
275
+ const yamlBlock = usesLegacyListItems
276
+ ? lines.map((line) => line.replace(/^\s*-\s+/, '')).join('\n')
277
+ : lines.join('\n');
278
+
278
279
  try {
279
- typed[section] = parseYaml(yamlLines);
280
+ const parsed = parseYaml(yamlBlock);
281
+ if (typeof parsed !== 'object' || parsed === null) continue;
282
+
283
+ let targetSection = section;
284
+ let value: unknown = parsed;
285
+
286
+ if (!Array.isArray(parsed)) {
287
+ const keys = Object.keys(parsed);
288
+ if (keys.length === 1) {
289
+ const [onlyKey] = keys;
290
+ if (onlyKey === section || (!KNOWN_PREFERENCE_KEYS.has(section) && KNOWN_PREFERENCE_KEYS.has(onlyKey))) {
291
+ targetSection = onlyKey;
292
+ value = (parsed as Record<string, unknown>)[onlyKey];
293
+ }
294
+ }
295
+ }
296
+
297
+ typed[targetSection] = value;
280
298
  } catch {
281
- typed[section] = entries;
299
+ /* malformed section skip */
282
300
  }
283
301
  }
284
302
 
@@ -26,7 +26,7 @@ All relevant context has been preloaded below — the roadmap, all slice summari
26
26
  4. Check **requirement coverage** — are all active requirements addressed by at least one slice?
27
27
  5. If **Verification Classes** are provided in the inlined context above, check each non-empty class:
28
28
  - For each verification class (Contract, Integration, Operational, UAT), determine whether slice summaries, UAT results, or observable behavior provide evidence that this verification tier was addressed.
29
- - Document the compliance status of each class in your verdict rationale.
29
+ - Document the compliance status of each class in a dedicated verification classes section.
30
30
  - If `Operational` verification is non-empty and no evidence of operational verification exists, flag this explicitly — it means planned operational checks (migrations, deployments, runtime verification) were not proven.
31
31
  - A milestone with unaddressed verification classes may still pass if the gaps are minor, but the gaps MUST be documented in the Deferred Work Inventory.
32
32
  6. Determine a verdict:
@@ -36,7 +36,7 @@ All relevant context has been preloaded below — the roadmap, all slice summari
36
36
 
37
37
  ## Persist Validation
38
38
 
39
- **Persist validation results through `gsd_validate_milestone`.** Call it with: `milestoneId`, `verdict`, `remediationRound`, `successCriteriaChecklist`, `sliceDeliveryAudit`, `crossSliceIntegration`, `requirementCoverage`, `verdictRationale`, and `remediationPlan` (if verdict is `needs-remediation`). The tool writes the validation to the DB and renders VALIDATION.md to disk.
39
+ **Persist validation results through `gsd_validate_milestone`.** Call it with: `milestoneId`, `verdict`, `remediationRound`, `successCriteriaChecklist`, `sliceDeliveryAudit`, `crossSliceIntegration`, `requirementCoverage`, `verificationClasses` (when non-empty), `verdictRationale`, and `remediationPlan` (if verdict is `needs-remediation`). The tool writes the validation to the DB and renders VALIDATION.md to disk.
40
40
 
41
41
  If verdict is `needs-remediation`:
42
42
  - After calling `gsd_validate_milestone`, use `gsd_reassess_roadmap` to add remediation slices. Pass `milestoneId`, a synthetic `completedSliceId` (e.g. "VALIDATION"), `verdict: "roadmap-adjusted"`, `assessment` text, and `sliceChanges` with the new slices in the `added` array. The tool persists the changes to the DB and re-renders ROADMAP.md.
@@ -1233,6 +1233,24 @@ test("startAuto calls selfHealRuntimeRecords before autoLoop (#1727)", { skip: "
1233
1233
  );
1234
1234
  });
1235
1235
 
1236
+ test("startAuto guards against concurrent invocation (#2923)", () => {
1237
+ const src = readFileSync(
1238
+ resolve(import.meta.dirname, "..", "auto.ts"),
1239
+ "utf-8",
1240
+ );
1241
+ const fnIdx = src.indexOf("export async function startAuto");
1242
+ assert.ok(fnIdx > -1, "startAuto must exist in auto.ts");
1243
+ // The guard must appear before any other logic in the function body
1244
+ const fnBody = src.slice(fnIdx, fnIdx + 500);
1245
+ const activeGuard = fnBody.indexOf("if (s.active)");
1246
+ assert.ok(activeGuard > -1, "startAuto must check s.active to prevent concurrent auto-loops");
1247
+ const returnIdx = fnBody.indexOf("return;", activeGuard);
1248
+ assert.ok(
1249
+ returnIdx > -1 && returnIdx < activeGuard + 120,
1250
+ "s.active guard must early-return to prevent a second concurrent loop",
1251
+ );
1252
+ });
1253
+
1236
1254
  test("agent_end handler calls resolveAgentEnd (not handleAgentEnd)", () => {
1237
1255
  const hooksSrc = readFileSync(
1238
1256
  resolve(import.meta.dirname, "..", "bootstrap", "register-hooks.ts"),
@@ -216,3 +216,50 @@ test("dispatch guard works without git repo", (t) => {
216
216
 
217
217
  assert.equal(getPriorSliceCompletionBlocker(repo, "main", "plan-slice", "M001/S02"), null);
218
218
  });
219
+
220
+ test("dispatch guard skips cross-milestone check when GSD_MILESTONE_LOCK is set (#2797)", (t) => {
221
+ const repo = setupRepo();
222
+ t.after(() => {
223
+ delete process.env.GSD_MILESTONE_LOCK;
224
+ teardownRepo(repo);
225
+ });
226
+
227
+ mkdirSync(join(repo, ".gsd", "milestones", "M010"), { recursive: true });
228
+ mkdirSync(join(repo, ".gsd", "milestones", "M011"), { recursive: true });
229
+ mkdirSync(join(repo, ".gsd", "milestones", "M012"), { recursive: true });
230
+
231
+ // M010 and M011 have incomplete slices
232
+ insertMilestone({ id: "M010", title: "Analytics" });
233
+ insertSlice({ id: "S01", milestoneId: "M010", title: "Data Quality", status: "pending", depends: [], sequence: 1 });
234
+
235
+ insertMilestone({ id: "M011", title: "Builder Onboarding" });
236
+ insertSlice({ id: "S01", milestoneId: "M011", title: "Schema", status: "pending", depends: [], sequence: 1 });
237
+
238
+ insertMilestone({ id: "M012", title: "Shared Components" });
239
+ insertSlice({ id: "S01", milestoneId: "M012", title: "Foundation", status: "pending", depends: [], sequence: 1 });
240
+ insertSlice({ id: "S02", milestoneId: "M012", title: "Migrate Pages", status: "pending", depends: ["S01"], sequence: 2 });
241
+
242
+ writeFileSync(join(repo, ".gsd", "milestones", "M010", "M010-ROADMAP.md"), "# M010\n");
243
+ writeFileSync(join(repo, ".gsd", "milestones", "M011", "M011-ROADMAP.md"), "# M011\n");
244
+ writeFileSync(join(repo, ".gsd", "milestones", "M012", "M012-ROADMAP.md"), "# M012\n");
245
+
246
+ // Without lock: M012 blocked by M010's incomplete S01
247
+ delete process.env.GSD_MILESTONE_LOCK;
248
+ assert.match(
249
+ getPriorSliceCompletionBlocker(repo, "main", "execute-task", "M012/S01/T01") ?? "",
250
+ /earlier slice M010\/S01 is not complete/,
251
+ );
252
+
253
+ // With lock: M012 only checks its own intra-milestone deps — S01 has none, so unblocked
254
+ process.env.GSD_MILESTONE_LOCK = "M012";
255
+ assert.equal(
256
+ getPriorSliceCompletionBlocker(repo, "main", "execute-task", "M012/S01/T01"),
257
+ null,
258
+ );
259
+
260
+ // With lock: M012/S02 still blocked by M012/S01 (intra-milestone dep preserved)
261
+ assert.equal(
262
+ getPriorSliceCompletionBlocker(repo, "main", "execute-task", "M012/S02/T01"),
263
+ "Cannot dispatch execute-task M012/S02/T01: dependency slice M012/S01 is not complete.",
264
+ );
265
+ });
@@ -131,14 +131,15 @@ describe("parallel-worker-monitoring", () => {
131
131
  assert.ok(!(5.01 < ceiling), "5.01 is over ceiling");
132
132
  });
133
133
 
134
- it("worker spawn args include --mode json", () => {
135
- // Verify the spawn command includes JSON mode for NDJSON output.
136
- // We can't easily test the actual spawn, but we verify the args pattern.
137
- const expectedArgs = ["--mode", "json", "--print", "/gsd auto"];
138
- assert.ok(expectedArgs.includes("--mode"), "args include --mode");
139
- assert.ok(expectedArgs.includes("json"), "args include json");
140
- assert.ok(expectedArgs.indexOf("--mode") < expectedArgs.indexOf("json"),
141
- "--mode comes before json");
134
+ it("worker spawn args use headless --json auto (#2792)", () => {
135
+ // Verify the spawn command uses headless mode (not --print which exits
136
+ // before auto-mode can run). See #2792.
137
+ const expectedArgs = ["headless", "--json", "auto"];
138
+ assert.ok(expectedArgs.includes("headless"), "args include headless");
139
+ assert.ok(expectedArgs.includes("--json"), "args include --json");
140
+ assert.ok(expectedArgs.includes("auto"), "args include auto");
141
+ assert.ok(expectedArgs.indexOf("headless") < expectedArgs.indexOf("auto"),
142
+ "headless comes before auto");
142
143
  });
143
144
 
144
145
  it("refreshWorkerStatuses restores persisted workers from disk", () => {
@@ -352,6 +352,40 @@ test("handles empty models config", () => {
352
352
  assert.equal(prefs!.models, undefined);
353
353
  });
354
354
 
355
+ test("parses raw YAML blocks under headings", () => {
356
+ const content = `## Parallel
357
+ enabled: true
358
+ max_workers: 3
359
+ `;
360
+ const prefs = parsePreferencesMarkdown(content);
361
+ assert.notEqual(prefs, null);
362
+ assert.equal(prefs!.parallel?.enabled, true);
363
+ assert.equal(prefs!.parallel?.max_workers, 3);
364
+ });
365
+
366
+ test("unwraps nested top-level preference key under descriptive headings", () => {
367
+ const content = `## Parallel Orchestration
368
+ parallel:
369
+ enabled: true
370
+ max_workers: 3
371
+ `;
372
+ const prefs = parsePreferencesMarkdown(content);
373
+ assert.notEqual(prefs, null);
374
+ assert.equal(prefs!.parallel?.enabled, true);
375
+ assert.equal(prefs!.parallel?.max_workers, 3);
376
+ });
377
+
378
+ test("preserves legacy heading list format", () => {
379
+ const content = `## Git
380
+ - isolation: branch
381
+ - auto_push: true
382
+ `;
383
+ const prefs = parsePreferencesMarkdown(content);
384
+ assert.notEqual(prefs, null);
385
+ assert.equal(prefs!.git?.isolation, "branch");
386
+ assert.equal(prefs!.git?.auto_push, true);
387
+ });
388
+
355
389
  // ── Warn-once for unrecognized format (#2373) ────────────────────────────────
356
390
 
357
391
  test("unrecognized format warning is emitted at most once (#2373)", () => {
@@ -181,6 +181,13 @@ test("reassess-roadmap prompt references gsd_reassess_roadmap tool", () => {
181
181
  assert.match(prompt, /gsd_reassess_roadmap/);
182
182
  });
183
183
 
184
+ test("validate-milestone prompt persists verification classes through gsd_validate_milestone", () => {
185
+ const prompt = readPrompt("validate-milestone");
186
+ assert.match(prompt, /verification classes section/i);
187
+ assert.match(prompt, /verificationClasses/);
188
+ assert.match(prompt, /gsd_validate_milestone/);
189
+ });
190
+
184
191
  // ─── Prompt migration: replan-slice → gsd_replan_slice ────────────────
185
192
 
186
193
  test("replan-slice prompt names gsd_replan_slice as the tool to use", () => {
@@ -1,6 +1,6 @@
1
1
  import { describe, it, afterEach } from "node:test";
2
2
  import assert from "node:assert/strict";
3
- import { mkdirSync, existsSync, rmSync, writeFileSync } from "node:fs";
3
+ import { mkdirSync, existsSync, readFileSync, rmSync, writeFileSync } from "node:fs";
4
4
  import { join } from "node:path";
5
5
  import { tmpdir } from "node:os";
6
6
  import { randomUUID } from "node:crypto";
@@ -24,6 +24,7 @@ const VALID_PARAMS = {
24
24
  sliceDeliveryAudit: "| S01 | delivered |",
25
25
  crossSliceIntegration: "No issues",
26
26
  requirementCoverage: "All covered",
27
+ verificationClasses: "- Contract: covered\n- Integration: covered\n- Operational: gap noted",
27
28
  verdictRationale: "Everything checks out",
28
29
  };
29
30
 
@@ -59,6 +60,27 @@ describe("handleValidateMilestone write ordering (#2725)", () => {
59
60
  // Disk file exists
60
61
  const filePath = join(base, ".gsd", "milestones", "M001", "M001-VALIDATION.md");
61
62
  assert.ok(existsSync(filePath), "VALIDATION.md should exist on disk");
63
+ const validationMd = readFileSync(filePath, "utf-8");
64
+ assert.match(validationMd, /## Verification Class Compliance/);
65
+ assert.match(validationMd, /- Contract: covered/);
66
+ assert.match(validationMd, /## Verdict Rationale/);
67
+ });
68
+
69
+ it("omits verification class section when no verification classes are supplied", async () => {
70
+ base = makeTmpBase();
71
+ const dbPath = join(base, ".gsd", "gsd.db");
72
+ openDatabase(dbPath);
73
+ insertMilestone({ id: "M001" });
74
+
75
+ const result = await handleValidateMilestone(
76
+ { ...VALID_PARAMS, verificationClasses: undefined },
77
+ base,
78
+ );
79
+ assert.ok(!("error" in result), `unexpected error: ${"error" in result ? result.error : ""}`);
80
+
81
+ const filePath = join(base, ".gsd", "milestones", "M001", "M001-VALIDATION.md");
82
+ const validationMd = readFileSync(filePath, "utf-8");
83
+ assert.doesNotMatch(validationMd, /## Verification Class Compliance/);
62
84
  });
63
85
 
64
86
  it("rolls back DB row when disk write fails", async () => {
@@ -23,9 +23,9 @@ import assert from "node:assert/strict";
23
23
  function hasOperationalEvidence(validationContent: string): boolean {
24
24
  const structuredMatch =
25
25
  validationContent.includes("Operational") &&
26
- (validationContent.includes("MET") || validationContent.includes("N/A"));
26
+ (validationContent.includes("MET") || validationContent.includes("N/A") || validationContent.includes("SATISFIED"));
27
27
  const proseMatch =
28
- /[Oo]perational[\s:][^\n]*(?:pass|verified|confirmed|met|complete|true|yes|addressed|covered|n\/a|not\s+applicable)/i.test(
28
+ /[Oo]perational[\s\S]{0,500}?(?:✅|pass|verified|confirmed|met|complete|true|yes|addressed|covered|satisfied|partially|n\/a|not[\s-]+applicable)/i.test(
29
29
  validationContent,
30
30
  );
31
31
  return structuredMatch || proseMatch;
@@ -104,6 +104,48 @@ test('prose: "Operational: complete" passes', () => {
104
104
  assert.ok(hasOperationalEvidence(content));
105
105
  });
106
106
 
107
+ // ─── Issue #2862: checkmark emoji ────────────────────────────────────────────
108
+
109
+ test('prose: "Operational: ✅" checkmark emoji passes (issue #2862)', () => {
110
+ const content = `- **Operational:** ✅ DECISIONS.md documents D009-D013`;
111
+ assert.ok(hasOperationalEvidence(content));
112
+ });
113
+
114
+ // ─── Issue #2866: multi-line, "satisfied", markdown bold ─────────────────────
115
+
116
+ test('multi-line: verdict on next line after Operational heading passes (issue #2866)', () => {
117
+ const content = `### Operational Verification
118
+ All endpoints responsive. Health checks pass.`;
119
+ assert.ok(hasOperationalEvidence(content));
120
+ });
121
+
122
+ test('prose: "PARTIALLY SATISFIED" passes (issue #2866)', () => {
123
+ const content = `Operational class: ⚠️ PARTIALLY SATISFIED`;
124
+ assert.ok(hasOperationalEvidence(content));
125
+ });
126
+
127
+ test('prose: "FULLY SATISFIED" passes (issue #2866)', () => {
128
+ const content = `**Operational**: FULLY SATISFIED — all monitoring in place.`;
129
+ assert.ok(hasOperationalEvidence(content));
130
+ });
131
+
132
+ test('structured: Operational + SATISFIED passes (issue #2866)', () => {
133
+ const content = `| Criteria | Status |
134
+ | Operational | SATISFIED |`;
135
+ assert.ok(hasOperationalEvidence(content));
136
+ });
137
+
138
+ test('table with markdown bold: **Operational** passes (issue #2866)', () => {
139
+ const content = `| **Operational** | ⚠️ Partially satisfied — monitoring gap noted |`;
140
+ assert.ok(hasOperationalEvidence(content));
141
+ });
142
+
143
+ test('multi-line: Operational label and "confirmed" separated by line break passes (issue #2866)', () => {
144
+ const content = `## Operational
145
+ Smoke tests confirmed all services healthy after deploy.`;
146
+ assert.ok(hasOperationalEvidence(content));
147
+ });
148
+
107
149
  // ─── Rejection cases ─────────────────────────────────────────────────────────
108
150
 
109
151
  test("no operational evidence: unrelated content fails", () => {
@@ -0,0 +1,175 @@
1
+ /**
2
+ * worktree-db-same-file.test.ts — Regression test for #2823.
3
+ *
4
+ * Verifies that reconcileWorktreeDb() does not ATTACH a WAL-mode DB file
5
+ * to itself when the worktree DB path resolves to the same physical file
6
+ * as the main DB path (shared-WAL / symlink layout).
7
+ *
8
+ * Also verifies that the auto-loop classifies "database disk image is
9
+ * malformed" as an infrastructure error to prevent wasting retries.
10
+ */
11
+
12
+ import { describe, test, beforeEach, afterEach } from "node:test";
13
+ import assert from "node:assert/strict";
14
+ import {
15
+ existsSync,
16
+ mkdirSync,
17
+ mkdtempSync,
18
+ rmSync,
19
+ symlinkSync,
20
+ writeFileSync,
21
+ } from "node:fs";
22
+ import { join } from "node:path";
23
+ import { tmpdir } from "node:os";
24
+
25
+ import {
26
+ openDatabase,
27
+ closeDatabase,
28
+ reconcileWorktreeDb,
29
+ insertDecision,
30
+ } from "../gsd-db.ts";
31
+ import { isInfrastructureError } from "../auto/infra-errors.ts";
32
+
33
+ // ─── Fix 1 & 2: reconcileWorktreeDb same-file guard ─────────────────
34
+
35
+ describe("#2823: reconcileWorktreeDb same-file guard", () => {
36
+ let tmpDir: string;
37
+
38
+ beforeEach(() => {
39
+ tmpDir = mkdtempSync(join(tmpdir(), "gsd-2823-"));
40
+ });
41
+
42
+ afterEach(() => {
43
+ closeDatabase();
44
+ rmSync(tmpDir, { recursive: true, force: true });
45
+ });
46
+
47
+ test("returns zero result when both paths resolve to the same file", () => {
48
+ const mainGsd = join(tmpDir, "main", ".gsd");
49
+ mkdirSync(mainGsd, { recursive: true });
50
+ const mainDbPath = join(mainGsd, "gsd.db");
51
+
52
+ // Create a real DB at mainDbPath
53
+ openDatabase(mainDbPath);
54
+ insertDecision({
55
+ id: "D001",
56
+ when_context: "2026-01-01",
57
+ scope: "M001",
58
+ decision: "Test decision",
59
+ choice: "Test choice",
60
+ rationale: "Test rationale",
61
+ revisable: "yes",
62
+ made_by: "agent",
63
+ superseded_by: null,
64
+ });
65
+
66
+ // Create a worktree path that resolves to the same file via symlink
67
+ const wtGsd = join(tmpDir, "worktree", ".gsd");
68
+ mkdirSync(join(tmpDir, "worktree"), { recursive: true });
69
+ symlinkSync(mainGsd, wtGsd, "junction");
70
+ const worktreeDbPath = join(wtGsd, "gsd.db");
71
+
72
+ // Both paths exist and resolve to the same physical file
73
+ assert.ok(existsSync(mainDbPath), "main DB exists");
74
+ assert.ok(existsSync(worktreeDbPath), "worktree DB path exists (via symlink)");
75
+
76
+ // This should NOT attempt ATTACH — should return zero result
77
+ const result = reconcileWorktreeDb(mainDbPath, worktreeDbPath);
78
+
79
+ assert.equal(result.decisions, 0, "no decisions reconciled");
80
+ assert.equal(result.requirements, 0, "no requirements reconciled");
81
+ assert.equal(result.artifacts, 0, "no artifacts reconciled");
82
+ assert.equal(result.conflicts.length, 0, "no conflicts");
83
+ });
84
+
85
+ test("returns zero result when both paths are identical strings", () => {
86
+ const mainGsd = join(tmpDir, "project", ".gsd");
87
+ mkdirSync(mainGsd, { recursive: true });
88
+ const dbPath = join(mainGsd, "gsd.db");
89
+
90
+ openDatabase(dbPath);
91
+ insertDecision({
92
+ id: "D001",
93
+ when_context: "2026-01-01",
94
+ scope: "M001",
95
+ decision: "Test",
96
+ choice: "Test",
97
+ rationale: "Test",
98
+ revisable: "yes",
99
+ made_by: "agent",
100
+ superseded_by: null,
101
+ });
102
+
103
+ // Same exact path — should bail immediately
104
+ const result = reconcileWorktreeDb(dbPath, dbPath);
105
+
106
+ assert.equal(result.decisions, 0);
107
+ assert.equal(result.conflicts.length, 0);
108
+ });
109
+
110
+ test("still reconciles when paths are genuinely different files", () => {
111
+ // Main DB
112
+ const mainGsd = join(tmpDir, "main", ".gsd");
113
+ mkdirSync(mainGsd, { recursive: true });
114
+ const mainDbPath = join(mainGsd, "gsd.db");
115
+
116
+ openDatabase(mainDbPath);
117
+ insertDecision({
118
+ id: "D001",
119
+ when_context: "2026-01-01",
120
+ scope: "M001",
121
+ decision: "Main decision",
122
+ choice: "Main choice",
123
+ rationale: "Main rationale",
124
+ revisable: "yes",
125
+ made_by: "agent",
126
+ superseded_by: null,
127
+ });
128
+ closeDatabase();
129
+
130
+ // Create a separate worktree DB with different data
131
+ const wtGsd = join(tmpDir, "worktree", ".gsd");
132
+ mkdirSync(wtGsd, { recursive: true });
133
+ const worktreeDbPath = join(wtGsd, "gsd.db");
134
+
135
+ openDatabase(worktreeDbPath);
136
+ insertDecision({
137
+ id: "D002",
138
+ when_context: "2026-01-01",
139
+ scope: "M001",
140
+ decision: "WT decision",
141
+ choice: "WT choice",
142
+ rationale: "WT rationale",
143
+ revisable: "yes",
144
+ made_by: "agent",
145
+ superseded_by: null,
146
+ });
147
+ closeDatabase();
148
+
149
+ // Re-open main and reconcile — should work normally
150
+ openDatabase(mainDbPath);
151
+ const result = reconcileWorktreeDb(mainDbPath, worktreeDbPath);
152
+
153
+ assert.ok(
154
+ result.decisions > 0,
155
+ "should reconcile decisions from a genuinely different DB",
156
+ );
157
+ });
158
+ });
159
+
160
+ // ─── Fix 3: infrastructure error classification ─────────────────────
161
+
162
+ describe("#2823: malformed DB classified as infrastructure error", () => {
163
+ test("database disk image is malformed is detected as infra error", () => {
164
+ const err = new Error("database disk image is malformed");
165
+ const code = isInfrastructureError(err);
166
+ assert.ok(code !== null, "should be classified as infrastructure error");
167
+ assert.equal(code, "SQLITE_CORRUPT");
168
+ });
169
+
170
+ test("other SQLite errors are not falsely classified", () => {
171
+ const err = new Error("SQLITE_BUSY: database is locked");
172
+ const code = isInfrastructureError(err);
173
+ assert.equal(code, null, "SQLITE_BUSY should not be infra error (it's transient)");
174
+ });
175
+ });
@@ -25,6 +25,7 @@ export interface ValidateMilestoneParams {
25
25
  sliceDeliveryAudit: string;
26
26
  crossSliceIntegration: string;
27
27
  requirementCoverage: string;
28
+ verificationClasses?: string;
28
29
  verdictRationale: string;
29
30
  remediationPlan?: string;
30
31
  }
@@ -55,6 +56,10 @@ ${params.crossSliceIntegration}
55
56
  ## Requirement Coverage
56
57
  ${params.requirementCoverage}
57
58
 
59
+ ${params.verificationClasses ? `## Verification Class Compliance
60
+ ${params.verificationClasses}
61
+
62
+ ` : ""}
58
63
  ## Verdict Rationale
59
64
  ${params.verdictRationale}
60
65
  `;