gsd-pi 2.82.0-dev.725028083 → 2.82.0-dev.9d5798940

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 (210) hide show
  1. package/README.md +3 -2
  2. package/dist/resources/.managed-resources-content-hash +1 -1
  3. package/dist/resources/GSD-WORKFLOW.md +3 -1
  4. package/dist/resources/extensions/claude-code-cli/partial-builder.js +2 -1
  5. package/dist/resources/extensions/cmux/index.js +5 -0
  6. package/dist/resources/extensions/gsd/auto/orchestrator.js +113 -6
  7. package/dist/resources/extensions/gsd/auto-dispatch.js +13 -6
  8. package/dist/resources/extensions/gsd/auto-post-unit.js +232 -126
  9. package/dist/resources/extensions/gsd/auto-prompts.js +2 -2
  10. package/dist/resources/extensions/gsd/auto-recovery.js +31 -1
  11. package/dist/resources/extensions/gsd/auto-start.js +7 -3
  12. package/dist/resources/extensions/gsd/auto-verification.js +28 -22
  13. package/dist/resources/extensions/gsd/auto-worktree.js +96 -0
  14. package/dist/resources/extensions/gsd/auto.js +128 -52
  15. package/dist/resources/extensions/gsd/bootstrap/agent-end-recovery.js +4 -1
  16. package/dist/resources/extensions/gsd/bootstrap/subagent-input.js +16 -7
  17. package/dist/resources/extensions/gsd/bootstrap/write-gate.js +16 -2
  18. package/dist/resources/extensions/gsd/clean-root-preflight.js +170 -8
  19. package/dist/resources/extensions/gsd/commands/catalog.js +4 -1
  20. package/dist/resources/extensions/gsd/commands/handlers/core.js +37 -0
  21. package/dist/resources/extensions/gsd/commands-bootstrap.js +5 -0
  22. package/dist/resources/extensions/gsd/db/unit-dispatches.js +2 -2
  23. package/dist/resources/extensions/gsd/export-html.js +27 -425
  24. package/dist/resources/extensions/gsd/md-importer.js +1 -1
  25. package/dist/resources/extensions/gsd/migrate/command.js +5 -0
  26. package/dist/resources/extensions/gsd/migrate/preview.js +9 -0
  27. package/dist/resources/extensions/gsd/migrate/transformer.js +51 -4
  28. package/dist/resources/extensions/gsd/migrate/writer.js +11 -1
  29. package/dist/resources/extensions/gsd/milestone-actions.js +11 -4
  30. package/dist/resources/extensions/gsd/native-git-bridge.js +8 -3
  31. package/dist/resources/extensions/gsd/state-reconciliation/drift/merge-state.js +6 -1
  32. package/dist/resources/extensions/gsd/tools/plan-slice.js +2 -1
  33. package/dist/resources/extensions/gsd/tools/workflow-tool-executors.js +119 -0
  34. package/dist/resources/extensions/gsd/unit-context-manifest.js +32 -10
  35. package/dist/resources/extensions/gsd/verification-verdict.js +26 -0
  36. package/dist/resources/extensions/gsd/worktree-lifecycle.js +49 -9
  37. package/dist/resources/extensions/shared/html-shell.js +388 -0
  38. package/dist/resources/extensions/subagent/index.js +448 -78
  39. package/dist/resources/extensions/subagent/launch.js +77 -0
  40. package/dist/resources/extensions/subagent/run-store.js +148 -0
  41. package/dist/resources/extensions/visual-brief/artifact-policy.js +29 -0
  42. package/dist/resources/extensions/visual-brief/extension-manifest.json +8 -0
  43. package/dist/resources/extensions/visual-brief/index.js +5 -0
  44. package/dist/resources/extensions/visual-brief/page-contract.js +124 -0
  45. package/dist/resources/extensions/visual-brief/prompts.js +140 -0
  46. package/dist/tsconfig.extensions.tsbuildinfo +1 -1
  47. package/dist/web/standalone/.next/BUILD_ID +1 -1
  48. package/dist/web/standalone/.next/app-path-routes-manifest.json +15 -15
  49. package/dist/web/standalone/.next/build-manifest.json +3 -3
  50. package/dist/web/standalone/.next/prerender-manifest.json +3 -3
  51. package/dist/web/standalone/.next/react-loadable-manifest.json +3 -3
  52. package/dist/web/standalone/.next/server/app/_global-error/page_client-reference-manifest.js +1 -1
  53. package/dist/web/standalone/.next/server/app/_global-error.html +1 -1
  54. package/dist/web/standalone/.next/server/app/_global-error.rsc +1 -1
  55. package/dist/web/standalone/.next/server/app/_global-error.segments/_full.segment.rsc +1 -1
  56. package/dist/web/standalone/.next/server/app/_global-error.segments/_global-error/__PAGE__.segment.rsc +1 -1
  57. package/dist/web/standalone/.next/server/app/_global-error.segments/_global-error.segment.rsc +1 -1
  58. package/dist/web/standalone/.next/server/app/_global-error.segments/_head.segment.rsc +1 -1
  59. package/dist/web/standalone/.next/server/app/_global-error.segments/_index.segment.rsc +1 -1
  60. package/dist/web/standalone/.next/server/app/_global-error.segments/_tree.segment.rsc +1 -1
  61. package/dist/web/standalone/.next/server/app/_not-found/page.js +2 -2
  62. package/dist/web/standalone/.next/server/app/_not-found/page.js.nft.json +1 -1
  63. package/dist/web/standalone/.next/server/app/_not-found/page_client-reference-manifest.js +1 -1
  64. package/dist/web/standalone/.next/server/app/_not-found.html +1 -1
  65. package/dist/web/standalone/.next/server/app/_not-found.rsc +4 -7
  66. package/dist/web/standalone/.next/server/app/_not-found.segments/_full.segment.rsc +4 -7
  67. package/dist/web/standalone/.next/server/app/_not-found.segments/_head.segment.rsc +1 -1
  68. package/dist/web/standalone/.next/server/app/_not-found.segments/_index.segment.rsc +4 -5
  69. package/dist/web/standalone/.next/server/app/_not-found.segments/_not-found/__PAGE__.segment.rsc +1 -1
  70. package/dist/web/standalone/.next/server/app/_not-found.segments/_not-found.segment.rsc +1 -1
  71. package/dist/web/standalone/.next/server/app/_not-found.segments/_tree.segment.rsc +2 -5
  72. package/dist/web/standalone/.next/server/app/index.html +1 -1
  73. package/dist/web/standalone/.next/server/app/index.rsc +4 -7
  74. package/dist/web/standalone/.next/server/app/index.segments/__PAGE__.segment.rsc +1 -1
  75. package/dist/web/standalone/.next/server/app/index.segments/_full.segment.rsc +4 -7
  76. package/dist/web/standalone/.next/server/app/index.segments/_head.segment.rsc +1 -1
  77. package/dist/web/standalone/.next/server/app/index.segments/_index.segment.rsc +4 -5
  78. package/dist/web/standalone/.next/server/app/index.segments/_tree.segment.rsc +2 -5
  79. package/dist/web/standalone/.next/server/app/page.js +2 -2
  80. package/dist/web/standalone/.next/server/app/page.js.nft.json +1 -1
  81. package/dist/web/standalone/.next/server/app/page_client-reference-manifest.js +1 -1
  82. package/dist/web/standalone/.next/server/app-paths-manifest.json +15 -15
  83. package/dist/web/standalone/.next/server/chunks/4266.js +2 -0
  84. package/dist/web/standalone/.next/server/middleware-build-manifest.js +1 -1
  85. package/dist/web/standalone/.next/server/middleware-react-loadable-manifest.js +1 -1
  86. package/dist/web/standalone/.next/server/next-font-manifest.js +1 -1
  87. package/dist/web/standalone/.next/server/next-font-manifest.json +1 -1
  88. package/dist/web/standalone/.next/server/pages/404.html +1 -1
  89. package/dist/web/standalone/.next/server/pages/500.html +1 -1
  90. package/dist/web/standalone/.next/server/server-reference-manifest.json +1 -1
  91. package/dist/web/standalone/.next/static/chunks/2973.33f26573894b6153.js +2 -0
  92. package/dist/web/standalone/.next/static/chunks/{8359.e059d86b255fce1c.js → 8359.7eb3bb8f8ecf4c01.js} +2 -2
  93. package/dist/web/standalone/.next/static/chunks/app/layout-8c10ec293ae0f1d5.js +1 -0
  94. package/dist/web/standalone/.next/static/chunks/{webpack-de742b64187e13fe.js → webpack-9a4db269f9ed63ad.js} +1 -1
  95. package/dist/web/standalone/.next/static/css/746ee28c929d1880.css +1 -0
  96. package/package.json +3 -3
  97. package/packages/contracts/dist/rpc.test.js +7 -0
  98. package/packages/contracts/dist/rpc.test.js.map +1 -1
  99. package/packages/contracts/dist/workflow.d.ts +21 -0
  100. package/packages/contracts/dist/workflow.d.ts.map +1 -1
  101. package/packages/contracts/dist/workflow.js +24 -0
  102. package/packages/contracts/dist/workflow.js.map +1 -1
  103. package/packages/contracts/src/rpc.test.ts +8 -0
  104. package/packages/contracts/src/workflow.ts +24 -0
  105. package/packages/mcp-server/README.md +13 -4
  106. package/packages/mcp-server/dist/workflow-tools.d.ts +0 -3
  107. package/packages/mcp-server/dist/workflow-tools.d.ts.map +1 -1
  108. package/packages/mcp-server/dist/workflow-tools.js +80 -0
  109. package/packages/mcp-server/dist/workflow-tools.js.map +1 -1
  110. package/packages/mcp-server/src/workflow-tools.test.ts +22 -0
  111. package/packages/mcp-server/src/workflow-tools.ts +168 -0
  112. package/packages/mcp-server/tsconfig.tsbuildinfo +1 -1
  113. package/packages/pi-coding-agent/tsconfig.tsbuildinfo +1 -1
  114. package/packages/pi-tui/dist/tui.d.ts.map +1 -1
  115. package/packages/pi-tui/dist/tui.js +5 -0
  116. package/packages/pi-tui/dist/tui.js.map +1 -1
  117. package/packages/pi-tui/src/tui.ts +6 -0
  118. package/packages/pi-tui/tsconfig.tsbuildinfo +1 -1
  119. package/packages/rpc-client/tsconfig.tsbuildinfo +1 -1
  120. package/src/resources/GSD-WORKFLOW.md +3 -1
  121. package/src/resources/extensions/claude-code-cli/partial-builder.ts +2 -1
  122. package/src/resources/extensions/claude-code-cli/tests/partial-builder.test.ts +19 -2
  123. package/src/resources/extensions/cmux/index.ts +6 -0
  124. package/src/resources/extensions/gsd/auto/contracts.ts +46 -11
  125. package/src/resources/extensions/gsd/auto/orchestrator.ts +118 -6
  126. package/src/resources/extensions/gsd/auto-dispatch.ts +14 -6
  127. package/src/resources/extensions/gsd/auto-post-unit.ts +265 -138
  128. package/src/resources/extensions/gsd/auto-prompts.ts +2 -2
  129. package/src/resources/extensions/gsd/auto-recovery.ts +29 -0
  130. package/src/resources/extensions/gsd/auto-start.ts +7 -3
  131. package/src/resources/extensions/gsd/auto-verification.ts +36 -34
  132. package/src/resources/extensions/gsd/auto-worktree.ts +104 -0
  133. package/src/resources/extensions/gsd/auto.ts +136 -51
  134. package/src/resources/extensions/gsd/bootstrap/agent-end-recovery.ts +6 -1
  135. package/src/resources/extensions/gsd/bootstrap/subagent-input.ts +16 -6
  136. package/src/resources/extensions/gsd/bootstrap/write-gate.ts +19 -3
  137. package/src/resources/extensions/gsd/clean-root-preflight.ts +174 -8
  138. package/src/resources/extensions/gsd/commands/catalog.ts +4 -1
  139. package/src/resources/extensions/gsd/commands/handlers/core.ts +40 -0
  140. package/src/resources/extensions/gsd/commands-bootstrap.ts +10 -0
  141. package/src/resources/extensions/gsd/db/unit-dispatches.ts +3 -3
  142. package/src/resources/extensions/gsd/export-html.ts +27 -427
  143. package/src/resources/extensions/gsd/md-importer.ts +1 -1
  144. package/src/resources/extensions/gsd/migrate/command.ts +5 -0
  145. package/src/resources/extensions/gsd/migrate/preview.ts +10 -0
  146. package/src/resources/extensions/gsd/migrate/transformer.ts +58 -4
  147. package/src/resources/extensions/gsd/migrate/writer.ts +14 -1
  148. package/src/resources/extensions/gsd/milestone-actions.ts +10 -4
  149. package/src/resources/extensions/gsd/native-git-bridge.ts +8 -3
  150. package/src/resources/extensions/gsd/state-reconciliation/drift/merge-state.ts +8 -1
  151. package/src/resources/extensions/gsd/tests/auto-deterministic-error-classification-4973.test.ts +116 -0
  152. package/src/resources/extensions/gsd/tests/auto-orchestrator.test.ts +408 -4
  153. package/src/resources/extensions/gsd/tests/auto-paused-ui-cleanup.test.ts +6 -5
  154. package/src/resources/extensions/gsd/tests/auto-post-unit-step-message.test.ts +12 -1
  155. package/src/resources/extensions/gsd/tests/auto-recovery.test.ts +15 -1
  156. package/src/resources/extensions/gsd/tests/auto-runtime-state.test.ts +4 -4
  157. package/src/resources/extensions/gsd/tests/auto-worktree-registry.test.ts +69 -1
  158. package/src/resources/extensions/gsd/tests/brief-command.test.ts +89 -0
  159. package/src/resources/extensions/gsd/tests/clean-root-preflight.test.ts +107 -2
  160. package/src/resources/extensions/gsd/tests/closeout-git-deferral.test.ts +16 -0
  161. package/src/resources/extensions/gsd/tests/deep-project-auto-loop.test.ts +57 -2
  162. package/src/resources/extensions/gsd/tests/dispatch-complete-milestone-guard.test.ts +39 -0
  163. package/src/resources/extensions/gsd/tests/evidence-cross-ref.test.ts +38 -0
  164. package/src/resources/extensions/gsd/tests/export-html-enhancements.test.ts +8 -0
  165. package/src/resources/extensions/gsd/tests/integration/migrate-command.test.ts +48 -3
  166. package/src/resources/extensions/gsd/tests/migrate-transformer.test.ts +5 -1
  167. package/src/resources/extensions/gsd/tests/migrate-writer-integration.test.ts +6 -1
  168. package/src/resources/extensions/gsd/tests/park-db-sync.test.ts +55 -1
  169. package/src/resources/extensions/gsd/tests/plan-slice.test.ts +25 -0
  170. package/src/resources/extensions/gsd/tests/post-exec-retry-bypass.test.ts +79 -1
  171. package/src/resources/extensions/gsd/tests/post-unit-git-failure.test.ts +1 -1
  172. package/src/resources/extensions/gsd/tests/remediation-completion-guard.test.ts +46 -2
  173. package/src/resources/extensions/gsd/tests/session-switch-abort-misclassification.test.ts +10 -0
  174. package/src/resources/extensions/gsd/tests/state-corruption-2945.test.ts +6 -0
  175. package/src/resources/extensions/gsd/tests/stuck-state-via-db.test.ts +39 -0
  176. package/src/resources/extensions/gsd/tests/unit-context-manifest.test.ts +86 -7
  177. package/src/resources/extensions/gsd/tests/verification-verdict.test.ts +78 -0
  178. package/src/resources/extensions/gsd/tests/worktree-journal-events.test.ts +64 -12
  179. package/src/resources/extensions/gsd/tests/worktree-lifecycle.test.ts +25 -0
  180. package/src/resources/extensions/gsd/tests/write-gate-planning-unit.test.ts +47 -0
  181. package/src/resources/extensions/gsd/tools/plan-slice.ts +2 -0
  182. package/src/resources/extensions/gsd/tools/workflow-tool-executors.ts +135 -0
  183. package/src/resources/extensions/gsd/unit-context-manifest.ts +47 -11
  184. package/src/resources/extensions/gsd/verification-verdict.ts +47 -0
  185. package/src/resources/extensions/gsd/worktree-lifecycle.ts +54 -9
  186. package/src/resources/extensions/shared/html-shell.ts +412 -0
  187. package/src/resources/extensions/subagent/index.ts +567 -103
  188. package/src/resources/extensions/subagent/launch.ts +131 -0
  189. package/src/resources/extensions/subagent/run-store.ts +218 -0
  190. package/src/resources/extensions/subagent/tests/launch.test.ts +115 -0
  191. package/src/resources/extensions/subagent/tests/run-store.test.ts +111 -0
  192. package/src/resources/extensions/visual-brief/artifact-policy.ts +41 -0
  193. package/src/resources/extensions/visual-brief/extension-manifest.json +8 -0
  194. package/src/resources/extensions/visual-brief/index.ts +8 -0
  195. package/src/resources/extensions/visual-brief/page-contract.ts +136 -0
  196. package/src/resources/extensions/visual-brief/prompts.ts +183 -0
  197. package/src/resources/extensions/visual-brief/tests/visual-brief.test.ts +212 -0
  198. package/dist/web/standalone/.next/server/chunks/5822.js +0 -2
  199. package/dist/web/standalone/.next/static/chunks/2556.0527fea66e123b7f.js +0 -1
  200. package/dist/web/standalone/.next/static/chunks/app/layout-a16c7a7ecdf0c2cf.js +0 -1
  201. package/dist/web/standalone/.next/static/css/54ec2745c1da488b.css +0 -1
  202. package/dist/web/standalone/.next/static/css/de70bee13400563f.css +0 -1
  203. package/dist/web/standalone/.next/static/media/4cf2300e9c8272f7-s.p.woff2 +0 -0
  204. package/dist/web/standalone/.next/static/media/747892c23ea88013-s.woff2 +0 -0
  205. package/dist/web/standalone/.next/static/media/8d697b304b401681-s.woff2 +0 -0
  206. package/dist/web/standalone/.next/static/media/93f479601ee12b01-s.p.woff2 +0 -0
  207. package/dist/web/standalone/.next/static/media/9610d9e46709d722-s.woff2 +0 -0
  208. package/dist/web/standalone/.next/static/media/ba015fad6dcf6784-s.woff2 +0 -0
  209. /package/dist/web/standalone/.next/static/{KDRTXR-22LPCsa80X9dey → BdZQhe8yKl6bdKLiXVEzh}/_buildManifest.js +0 -0
  210. /package/dist/web/standalone/.next/static/{KDRTXR-22LPCsa80X9dey → BdZQhe8yKl6bdKLiXVEzh}/_ssgManifest.js +0 -0
@@ -1,3 +1,5 @@
1
+ // Project/App: GSD-2
2
+ // File Purpose: Tests for post-execution retry bypass and verification gate failure handling.
1
3
  /**
2
4
  * post-exec-retry-bypass.test.ts — Tests for post-execution blocking failure retry bypass.
3
5
  *
@@ -9,7 +11,7 @@
9
11
  import { describe, test, mock, beforeEach, afterEach } from "node:test";
10
12
  import assert from "node:assert/strict";
11
13
  import { tmpdir } from "node:os";
12
- import { mkdirSync, writeFileSync, rmSync, existsSync } from "node:fs";
14
+ import { mkdirSync, readFileSync, writeFileSync, rmSync } from "node:fs";
13
15
  import { join } from "node:path";
14
16
 
15
17
  import { runPostUnitVerification, type VerificationContext } from "../auto-verification.ts";
@@ -71,6 +73,7 @@ function setupTestEnvironment(): void {
71
73
  mkdirSync(milestonesDir, { recursive: true });
72
74
 
73
75
  process.chdir(tempDir);
76
+ invalidateAllCaches();
74
77
  _clearGsdRootCache();
75
78
 
76
79
  dbPath = join(gsdDir, "gsd.db");
@@ -140,6 +143,34 @@ function createBasicTask(): void {
140
143
  });
141
144
  }
142
145
 
146
+ function createTaskWithoutVerify(): void {
147
+ insertMilestone({ id: "M001" });
148
+ insertSlice({
149
+ id: "S01",
150
+ milestoneId: "M001",
151
+ title: "Test Slice",
152
+ risk: "low",
153
+ });
154
+
155
+ insertTask({
156
+ id: "T01",
157
+ sliceId: "S01",
158
+ milestoneId: "M001",
159
+ title: "Task without host verification",
160
+ status: "pending",
161
+ planning: {
162
+ description: "Task intentionally missing runnable verification",
163
+ estimate: "1h",
164
+ files: [],
165
+ verify: "",
166
+ inputs: [],
167
+ expectedOutput: [],
168
+ observabilityImpact: "",
169
+ },
170
+ sequence: 0,
171
+ });
172
+ }
173
+
143
174
  function createPostExecFailureTask(): void {
144
175
  insertMilestone({ id: "M001" });
145
176
  insertSlice({
@@ -327,6 +358,53 @@ describe("Post-execution blocking failure retry bypass", () => {
327
358
  assert.equal(row?.outcome, "fail");
328
359
  assert.equal(row?.failure_class, "artifact");
329
360
  });
361
+
362
+ test("execute-task with no host-owned verification pauses fail-closed", async () => {
363
+ createTaskWithoutVerify();
364
+
365
+ const ctx = makeMockCtx();
366
+ const pi = makeMockPi();
367
+ const pauseAutoMock = mock.fn(async () => {});
368
+ const s = makeMockSession(tempDir, { type: "execute-task", id: "M001/S01/T01" });
369
+
370
+ const result = await runPostUnitVerification({ s, ctx, pi }, pauseAutoMock);
371
+
372
+ assert.equal(result, "pause");
373
+ assert.equal(pauseAutoMock.mock.callCount(), 1);
374
+ assert.equal(s.pendingVerificationRetry, null);
375
+
376
+ const evidencePath = join(tempDir, ".gsd", "milestones", "M001", "slices", "S01", "tasks", "T01-VERIFY.json");
377
+ const evidence = JSON.parse(readFileSync(evidencePath, "utf-8"));
378
+ assert.equal(evidence.passed, false);
379
+ assert.equal(evidence.discoverySource, "none");
380
+ assert.ok(!("retryAttempt" in evidence), "no-host-checks evidence must not include retryAttempt");
381
+ assert.ok(!("maxRetries" in evidence), "no-host-checks evidence must not include maxRetries");
382
+ });
383
+
384
+ test("auto-discovered package.json verification failure retries instead of continuing", async () => {
385
+ createTaskWithoutVerify();
386
+ writeFileSync(
387
+ join(tempDir, "package.json"),
388
+ JSON.stringify({ scripts: { test: "exit 1" } }),
389
+ "utf-8",
390
+ );
391
+ writePreferences({
392
+ verification_auto_fix: true,
393
+ verification_max_retries: 2,
394
+ });
395
+
396
+ const ctx = makeMockCtx();
397
+ const pi = makeMockPi();
398
+ const pauseAutoMock = mock.fn(async () => {});
399
+ const s = makeMockSession(tempDir, { type: "execute-task", id: "M001/S01/T01" });
400
+
401
+ const result = await runPostUnitVerification({ s, ctx, pi }, pauseAutoMock);
402
+
403
+ assert.equal(result, "retry");
404
+ assert.equal(pauseAutoMock.mock.callCount(), 0);
405
+ assert.equal(s.pendingVerificationRetry?.unitId, "M001/S01/T01");
406
+ assert.match(s.pendingVerificationRetry?.failureContext ?? "", /npm run test/);
407
+ });
330
408
  });
331
409
 
332
410
  describe("Post-execution retry behavior", () => {
@@ -11,7 +11,7 @@ const source = readFileSync(
11
11
 
12
12
  test("postUnitPreVerification blocks on git action failure", () => {
13
13
  const failureBlock = extractSourceRegion(source, 'if (gitResult.status === "failed")');
14
- assert.ok(failureBlock.includes('ctx.ui.notify(failureMsg, "error")'));
14
+ assert.ok(failureBlock.includes('ctx.ui.notify(failureMsg, opts?.softFailure ? "warning" : "error")'));
15
15
  assert.ok(failureBlock.includes("await pauseAuto(ctx, pi)"));
16
16
  assert.ok(failureBlock.includes('return "dispatched"'));
17
17
  assert.ok(!failureBlock.includes("git-action-failed-nonblocking"));
@@ -1,6 +1,6 @@
1
1
  /**
2
- * Regression test for #2675: completing-milestone dispatch rule must
3
- * block completion when VALIDATION verdict is "needs-remediation".
2
+ * Regression tests for non-passing VALIDATION verdicts: completing-milestone
3
+ * dispatch must block completion when VALIDATION needs remediation or attention.
4
4
  *
5
5
  * Without this guard, needs-remediation + allSlicesDone causes a loop:
6
6
  * complete-milestone dispatched → agent refuses (correct) → no SUMMARY
@@ -66,6 +66,50 @@ test("completing-milestone blocks when VALIDATION verdict is needs-remediation (
66
66
  }
67
67
  });
68
68
 
69
+ test("completing-milestone blocks when VALIDATION verdict is needs-attention (#5747)", async () => {
70
+ const base = mkdtempSync(join(tmpdir(), "gsd-attention-"));
71
+ mkdirSync(join(base, ".gsd", "milestones", "M001"), { recursive: true });
72
+
73
+ try {
74
+ writeFileSync(
75
+ join(base, ".gsd", "milestones", "M001", "M001-VALIDATION.md"),
76
+ [
77
+ "---",
78
+ "verdict: needs-attention",
79
+ "remediation_round: 0",
80
+ "---",
81
+ "",
82
+ "# Validation Report",
83
+ "",
84
+ "Acceptance proof is incomplete and needs human attention.",
85
+ ].join("\n"),
86
+ );
87
+
88
+ const ctx = {
89
+ mid: "M001",
90
+ midTitle: "Test Milestone",
91
+ basePath: base,
92
+ state: { phase: "completing-milestone" } as any,
93
+ prefs: {} as any,
94
+ session: undefined,
95
+ };
96
+
97
+ const result = await completingRule!.match(ctx);
98
+
99
+ assert.ok(result !== null, "rule should match");
100
+ assert.equal(result!.action, "stop", "should return stop action");
101
+ if (result!.action === "stop") {
102
+ assert.equal(result!.level, "warning", "should be warning level (pausable)");
103
+ assert.ok(
104
+ result!.reason.includes("needs-attention"),
105
+ "reason should mention needs-attention",
106
+ );
107
+ }
108
+ } finally {
109
+ rmSync(base, { recursive: true, force: true });
110
+ }
111
+ });
112
+
69
113
  test("completing-milestone proceeds normally when VALIDATION verdict is pass (#2675 guard)", async () => {
70
114
  const base = mkdtempSync(join(tmpdir(), "gsd-remediation-"));
71
115
  mkdirSync(join(base, ".gsd", "milestones", "M001"), { recursive: true });
@@ -5,6 +5,7 @@ import test from "node:test";
5
5
  import assert from "node:assert/strict";
6
6
 
7
7
  import {
8
+ _hasEmptyAgentEndContent,
8
9
  _handleSessionSwitchAgentEnd,
9
10
  isBareClaudeCodeStreamAbortPlaceholder,
10
11
  isClaudeCodeSessionSwitchAbortMessage,
@@ -188,6 +189,15 @@ test("empty-content aborted during session-switch is silently ignored", () => {
188
189
  assert.equal(cancelledWith, null);
189
190
  });
190
191
 
192
+ test("missing agent_end content is classified as empty abort content", () => {
193
+ // Providers may omit content entirely for a late aborted agent_end. That is
194
+ // equivalent to empty content and must not pause/cancel the next unit.
195
+ assert.equal(_hasEmptyAgentEndContent(undefined), true);
196
+ assert.equal(_hasEmptyAgentEndContent(null), true);
197
+ assert.equal(_hasEmptyAgentEndContent([]), true);
198
+ assert.equal(_hasEmptyAgentEndContent([{ type: "text", text: "partial" }]), false);
199
+ });
200
+
191
201
  test("completed assistant content with aborted stopReason during session-switch is ignored", () => {
192
202
  // newSession() can abort the just-finished provider stream while the last
193
203
  // assistant message still carries the completed unit summary. That is a
@@ -271,6 +271,11 @@ describe("#2945 Bug 3: mergeAndExit must teardown worktree after successful merg
271
271
  // a real git fixture and verify the worktree directory is removed
272
272
  // from disk after the merge.
273
273
  const tmpBase = realpathSync(mkdtempSync(join(tmpdir(), "gsd-2945-bug3-")));
274
+ // ADR-016 phase 3 (#5693): Lifecycle.restoreToProjectRoot now chdirs to
275
+ // s.originalBasePath. Save cwd before the test so we can restore it
276
+ // before rmSync removes tmpBase — otherwise the next test in this file
277
+ // inherits a deleted cwd and process.cwd() throws ENOENT (uv_cwd).
278
+ const prevCwd = process.cwd();
274
279
  try {
275
280
  const git = (args: string[]): void => {
276
281
  execFileSync("git", args, { cwd: tmpBase, stdio: "pipe" });
@@ -325,6 +330,7 @@ describe("#2945 Bug 3: mergeAndExit must teardown worktree after successful merg
325
330
  `teardownAutoWorktree must be called after successful merge — worktree directory at ${wt} should be removed`,
326
331
  );
327
332
  } finally {
333
+ try { process.chdir(prevCwd); } catch { /* noop */ }
328
334
  try { rmSync(tmpBase, { recursive: true, force: true }); } catch { /* noop */ }
329
335
  }
330
336
  });
@@ -23,9 +23,12 @@ import { registerAutoWorker } from "../db/auto-workers.ts";
23
23
  import { claimMilestoneLease } from "../db/milestone-leases.ts";
24
24
  import {
25
25
  recordDispatchClaim,
26
+ markCanceled,
26
27
  getRecentUnitKeysForWorker,
28
+ getRecentUnitKeysForProjectRoot,
27
29
  } from "../db/unit-dispatches.ts";
28
30
  import { setRuntimeKv, getRuntimeKv } from "../db/runtime-kv.ts";
31
+ import { detectStuck } from "../auto/detect-stuck.ts";
29
32
 
30
33
  function makeBase(): string {
31
34
  const base = mkdtempSync(join(tmpdir(), "gsd-stuck-state-db-"));
@@ -67,6 +70,42 @@ test("getRecentUnitKeysForWorker reconstructs the recentUnits sliding window", (
67
70
  assert.deepEqual(window.map(w => w.key), ["U1", "U2", "U3"]);
68
71
  });
69
72
 
73
+ test("getRecentUnitKeysForProjectRoot restores compound keys used by stuck detection", (t) => {
74
+ const base = makeBase();
75
+ t.after(() => cleanup(base));
76
+ openDatabase(join(base, ".gsd", "gsd.db"));
77
+ insertMilestone({ id: "M001", title: "T", status: "active" });
78
+ const worker = registerAutoWorker({ projectRootRealpath: base });
79
+ const lease = claimMilestoneLease(worker, "M001");
80
+ assert.equal(lease.ok, true);
81
+ if (!lease.ok) return;
82
+
83
+ for (let i = 0; i < 2; i++) {
84
+ const claim = recordDispatchClaim({
85
+ traceId: `t${i}`,
86
+ workerId: worker,
87
+ milestoneLeaseToken: lease.token,
88
+ milestoneId: "M001",
89
+ sliceId: "S01",
90
+ unitType: "complete-slice",
91
+ unitId: "M001/S01",
92
+ });
93
+ assert.equal(claim.ok, true);
94
+ if (!claim.ok) return;
95
+ markCanceled(claim.dispatchId, "pause");
96
+ }
97
+
98
+ const window = getRecentUnitKeysForProjectRoot(base, 20);
99
+ assert.deepEqual(window.map(w => w.key), [
100
+ "complete-slice/M001/S01",
101
+ "complete-slice/M001/S01",
102
+ ]);
103
+
104
+ const result = detectStuck([...window, { key: "complete-slice/M001/S01" }]);
105
+ assert.equal(result?.stuck, true);
106
+ assert.match(result?.reason ?? "", /3 consecutive times/);
107
+ });
108
+
70
109
  test("getRecentUnitKeysForWorker honors the limit parameter", (t) => {
71
110
  const base = makeBase();
72
111
  t.after(() => cleanup(base));
@@ -7,13 +7,17 @@ import {
7
7
  ARTIFACT_KEYS,
8
8
  KNOWN_UNIT_TYPES,
9
9
  UNIT_MANIFESTS,
10
+ resolveSubagentPermissionContract,
10
11
  resolveManifest,
11
12
  type ArtifactKey,
12
13
  type ContextModePolicy,
13
14
  type SkillsPolicy,
14
15
  type UnitContextManifest,
15
16
  } from "../unit-context-manifest.ts";
16
- import { ALLOWED_PLANNING_DISPATCH_AGENTS } from "../bootstrap/write-gate.ts";
17
+ import {
18
+ ALLOWED_PLANNING_DISPATCH_AGENTS,
19
+ shouldBlockPlanningUnit,
20
+ } from "../bootstrap/write-gate.ts";
17
21
  import {
18
22
  getRequiredWorkflowToolsForAutoUnit,
19
23
  getRequiredWorkflowToolsForGuidedUnit,
@@ -216,7 +220,7 @@ test("#4934: every manifest declares a tools policy", () => {
216
220
  });
217
221
 
218
222
  test("#4934: tools.mode is one of the declared policies", () => {
219
- const validModes = new Set(["all", "read-only", "planning", "planning-dispatch", "docs"]);
223
+ const validModes = new Set(["all", "read-only", "planning", "planning-dispatch", "docs", "verification"]);
220
224
  for (const [unitType, manifest] of Object.entries(UNIT_MANIFESTS)) {
221
225
  const mode = (manifest as { tools: { mode: string } }).tools.mode;
222
226
  assert.ok(
@@ -226,27 +230,84 @@ test("#4934: tools.mode is one of the declared policies", () => {
226
230
  }
227
231
  });
228
232
 
229
- test('#4934: only execute-task and reactive-execute may use tools.mode "all" (full source-tree write access)', () => {
230
- const allowedAllUnits = new Set(["execute-task", "reactive-execute"]);
233
+ test('#4934: only execution units and complete-milestone may use tools.mode "all"', () => {
234
+ const allowedAllUnits = new Set(["execute-task", "reactive-execute", "complete-milestone"]);
231
235
  for (const [unitType, manifest] of Object.entries(UNIT_MANIFESTS)) {
232
236
  const mode = (manifest as { tools: { mode: string } }).tools.mode;
233
237
  if (mode === "all") {
234
238
  assert.ok(
235
239
  allowedAllUnits.has(unitType),
236
- `manifest "${unitType}" declares tools.mode = "all" but is not on the execute-track. ` +
237
- 'Only execute-task and reactive-execute should have full source write access; ' +
240
+ `manifest "${unitType}" declares tools.mode = "all" but is not explicitly allowed. ` +
241
+ 'Only execute-task, reactive-execute, and complete-milestone should have full source write access; ' +
238
242
  'planning/discuss/research units must use "planning" or "planning-dispatch" (or "docs" for rewrite-docs).',
239
243
  );
240
244
  }
241
245
  }
242
246
  });
243
247
 
248
+ test("#5453: complete-milestone uses all tools so bash verification is not planning-dispatch blocked", () => {
249
+ const manifest = UNIT_MANIFESTS["complete-milestone"];
250
+
251
+ assert.strictEqual(manifest.tools.mode, "all");
252
+ assert.deepEqual(resolveSubagentPermissionContract("complete-milestone"), {
253
+ allowed: true,
254
+ allowedSubagents: ["*"],
255
+ toolsMode: "all",
256
+ });
257
+ // Runtime gate-level regression: these verification commands were blocked
258
+ // under planning-dispatch in #5453; complete-milestone must bypass that gate.
259
+ for (const cmd of ["git diff --name-only HEAD~1", "git log -n1 --oneline"]) {
260
+ const result = shouldBlockPlanningUnit(
261
+ "bash",
262
+ cmd,
263
+ process.cwd(),
264
+ "complete-milestone",
265
+ manifest.tools,
266
+ );
267
+ assert.strictEqual(
268
+ result.block,
269
+ false,
270
+ `shouldBlockPlanningUnit must not block ${cmd} for complete-milestone: ${result.reason}`,
271
+ );
272
+ }
273
+ });
274
+
275
+ test("#5843: run-uat uses verification tools policy so build/test commands can run", () => {
276
+ const manifest = UNIT_MANIFESTS["run-uat"];
277
+
278
+ assert.strictEqual(manifest.tools.mode, "verification");
279
+
280
+ const buildResult = shouldBlockPlanningUnit(
281
+ "bash",
282
+ "npm run build 2>&1",
283
+ process.cwd(),
284
+ "run-uat",
285
+ manifest.tools,
286
+ );
287
+ assert.strictEqual(
288
+ buildResult.block,
289
+ false,
290
+ `run-uat must allow build verification commands: ${buildResult.reason}`,
291
+ );
292
+
293
+ const sourceWriteResult = shouldBlockPlanningUnit(
294
+ "edit",
295
+ "src/main.ts",
296
+ process.cwd(),
297
+ "run-uat",
298
+ manifest.tools,
299
+ );
300
+ assert.strictEqual(sourceWriteResult.block, true);
301
+ assert.match(sourceWriteResult.reason!, /tools-policy "verification"/);
302
+ });
303
+
244
304
  test('planning-dispatch mode is reserved for slice-level decomposition and completion units', () => {
245
305
  const allowedDispatchUnits = new Set([
246
306
  "plan-slice",
307
+ "research-slice",
247
308
  "refine-slice",
248
309
  "complete-slice",
249
- "complete-milestone",
310
+ "gate-evaluate",
250
311
  // Deep planning mode: research-project orchestrates 4 parallel research
251
312
  // subagents (stack/features/architecture/pitfalls). Subagent dispatch is
252
313
  // the unit's core mechanism — without it, the unit cannot do its job.
@@ -265,6 +326,24 @@ test('planning-dispatch mode is reserved for slice-level decomposition and compl
265
326
  }
266
327
  });
267
328
 
329
+ test('Unit Tool Contract exposes subagent dispatch permissions', () => {
330
+ assert.deepEqual(resolveSubagentPermissionContract("plan-slice"), {
331
+ allowed: true,
332
+ allowedSubagents: ["scout", "planner"],
333
+ toolsMode: "planning-dispatch",
334
+ });
335
+ assert.deepEqual(resolveSubagentPermissionContract("gate-evaluate"), {
336
+ allowed: true,
337
+ allowedSubagents: ["reviewer", "security", "tester"],
338
+ toolsMode: "planning-dispatch",
339
+ });
340
+ assert.deepEqual(resolveSubagentPermissionContract("discuss-milestone"), {
341
+ allowed: false,
342
+ allowedSubagents: [],
343
+ toolsMode: "planning",
344
+ });
345
+ });
346
+
268
347
  test('planning-dispatch manifests declare non-empty allowedSubagents lists', () => {
269
348
  for (const [unitType, manifest] of Object.entries(UNIT_MANIFESTS)) {
270
349
  if (manifest.tools.mode !== "planning-dispatch") continue;
@@ -0,0 +1,78 @@
1
+ // Project/App: GSD-2
2
+ // File Purpose: Tests for host-owned auto-mode verification verdict policy.
3
+
4
+ import test from "node:test";
5
+ import assert from "node:assert/strict";
6
+
7
+ import { decideVerificationVerdict } from "../verification-verdict.ts";
8
+ import type { VerificationResult } from "../types.ts";
9
+
10
+ function makeResult(overrides: Partial<VerificationResult> = {}): VerificationResult {
11
+ return {
12
+ passed: true,
13
+ checks: [],
14
+ discoverySource: "none",
15
+ timestamp: 1,
16
+ ...overrides,
17
+ };
18
+ }
19
+
20
+ test("execute-task fails closed when no host-owned checks are discovered", () => {
21
+ const verdict = decideVerificationVerdict("execute-task", makeResult());
22
+
23
+ assert.equal(verdict.passed, false);
24
+ assert.equal(verdict.reason, "no-host-checks");
25
+ assert.equal(verdict.retryable, false);
26
+ assert.match(verdict.failureContext, /No runnable host-owned verification command/);
27
+ });
28
+
29
+ test("non execute-task units preserve no-check pass semantics", () => {
30
+ const verdict = decideVerificationVerdict("plan-slice", makeResult());
31
+
32
+ assert.equal(verdict.passed, true);
33
+ assert.equal(verdict.reason, "passed");
34
+ });
35
+
36
+ test("execute-task command failure remains retryable verification failure", () => {
37
+ const verdict = decideVerificationVerdict(
38
+ "execute-task",
39
+ makeResult({
40
+ passed: false,
41
+ discoverySource: "package-json",
42
+ checks: [
43
+ {
44
+ command: "npm test",
45
+ exitCode: 1,
46
+ stdout: "",
47
+ stderr: "failed",
48
+ durationMs: 10,
49
+ },
50
+ ],
51
+ }),
52
+ );
53
+
54
+ assert.equal(verdict.passed, false);
55
+ assert.equal(verdict.reason, "checks-failed");
56
+ assert.equal(verdict.retryable, true);
57
+ });
58
+
59
+ test("execute-task passes when a discovered host check succeeds", () => {
60
+ const verdict = decideVerificationVerdict(
61
+ "execute-task",
62
+ makeResult({
63
+ discoverySource: "preference",
64
+ checks: [
65
+ {
66
+ command: "npm test",
67
+ exitCode: 0,
68
+ stdout: "ok",
69
+ stderr: "",
70
+ durationMs: 10,
71
+ },
72
+ ],
73
+ }),
74
+ );
75
+
76
+ assert.equal(verdict.passed, true);
77
+ assert.equal(verdict.reason, "passed");
78
+ });
@@ -30,11 +30,13 @@ function initGitRepoIn(base: string, isolation: "worktree" | "branch" | "none"):
30
30
  }
31
31
  import {
32
32
  WorktreeLifecycle,
33
+ resetRecentWorktreeMergeFailuresForTest,
33
34
  type WorktreeLifecycleDeps,
34
35
  type NotifyCtx,
35
36
  } from "../worktree-lifecycle.js";
36
37
  import { WorktreeStateProjection } from "../worktree-state-projection.js";
37
38
  import { type TaskCommitContext } from "../worktree.js";
39
+ import { MergeConflictError } from "../git-service.js";
38
40
 
39
41
  // ADR-016 phase 2 / C-track retired all worktree-manager + cache + prefs
40
42
  // fields from `WorktreeLifecycleDeps`. Tests still pass them as overrides
@@ -141,6 +143,20 @@ function readJournalEntries(basePath: string): JournalEntry[] {
141
143
  }
142
144
  }
143
145
 
146
+ function setupMergeWorktree(basePath: string, milestoneId: string): string {
147
+ initGitRepoIn(basePath, "worktree");
148
+ execFileSync("git", ["checkout", "-b", `milestone/${milestoneId}`], { cwd: basePath, stdio: "pipe" });
149
+ execFileSync("git", ["checkout", "main"], { cwd: basePath, stdio: "pipe" });
150
+ const wt = join(basePath, ".gsd", "worktrees", milestoneId);
151
+ execFileSync("git", ["worktree", "add", wt, `milestone/${milestoneId}`], { cwd: basePath, stdio: "pipe" });
152
+ mkdirSync(join(basePath, ".gsd", "milestones", milestoneId), { recursive: true });
153
+ writeFileSync(
154
+ join(basePath, ".gsd", "milestones", milestoneId, `${milestoneId}-ROADMAP.md`),
155
+ `# ${milestoneId}\n- [x] S01: Slice one\n`,
156
+ );
157
+ return wt;
158
+ }
159
+
144
160
  // ─── Tests ───────────────────────────────────────────────────────────────────
145
161
 
146
162
  describe("worktree journal events", () => {
@@ -148,6 +164,7 @@ describe("worktree journal events", () => {
148
164
  const originalCwd = process.cwd();
149
165
 
150
166
  beforeEach(() => {
167
+ resetRecentWorktreeMergeFailuresForTest();
151
168
  // realpathSync to match what `auto-worktree.ts` returns from
152
169
  // `resolveWorktreeProjectRoot` (macOS resolves `/var` → `/private/var`).
153
170
  tmp = realpathSync(mkdtempSync(join(tmpdir(), "wt-journal-")));
@@ -284,17 +301,7 @@ describe("worktree journal events", () => {
284
301
  });
285
302
 
286
303
  test("mergeAndExit emits worktree-merge-failed on error", () => {
287
- initGitRepoIn(tmp, "worktree");
288
- execFileSync("git", ["checkout", "-b", "milestone/M001"], { cwd: tmp, stdio: "pipe" });
289
- execFileSync("git", ["checkout", "main"], { cwd: tmp, stdio: "pipe" });
290
- const wt = join(tmp, ".gsd", "worktrees", "M001");
291
- execFileSync("git", ["worktree", "add", wt, "milestone/M001"], { cwd: tmp, stdio: "pipe" });
292
- mkdirSync(join(tmp, ".gsd", "milestones", "M001"), { recursive: true });
293
- writeFileSync(
294
- join(tmp, ".gsd", "milestones", "M001", "M001-ROADMAP.md"),
295
- "# M001\n- [x] S01: Slice one\n",
296
- );
297
-
304
+ const wt = setupMergeWorktree(tmp, "M001");
298
305
  const s = makeSession({ basePath: wt, originalBasePath: tmp });
299
306
  const deps = makeDeps({
300
307
  mergeMilestoneToMain: () => { throw new Error("conflict in main"); },
@@ -318,11 +325,56 @@ describe("worktree journal events", () => {
318
325
  );
319
326
  }
320
327
 
328
+ new WorktreeLifecycle(s, deps).exitMilestone(
329
+ "M001",
330
+ { merge: true },
331
+ makeNotifyCtx(),
332
+ );
333
+
321
334
  const entries = readJournalEntries(tmp);
322
- const failed = entries.find(e => e.eventType === "worktree-merge-failed");
335
+ const failures = entries.filter(e => e.eventType === "worktree-merge-failed");
336
+ const failed = failures[0];
323
337
  assert.ok(failed, "worktree-merge-failed event should be emitted");
324
338
  assert.equal(failed!.data?.milestoneId, "M001");
325
339
  assert.equal(failed!.data?.error, "conflict in main");
340
+ assert.equal(failures.length, 1, "duplicate merge failures are journaled once");
341
+ });
342
+
343
+ test("merge failure dedupe uses stable conflict category and expires", (t) => {
344
+ let now = 1_000_000;
345
+ t.mock.method(Date, "now", () => now);
346
+ const wt = setupMergeWorktree(tmp, "M001");
347
+ const s = makeSession({ basePath: wt, originalBasePath: tmp });
348
+ let attempt = 0;
349
+ const deps = makeDeps({
350
+ mergeMilestoneToMain: () => {
351
+ attempt += 1;
352
+ throw new MergeConflictError(
353
+ attempt === 1 ? ["src/a.ts"] : ["src/b.ts", "src/c.ts"],
354
+ "squash",
355
+ "milestone/M001",
356
+ "main",
357
+ );
358
+ },
359
+ });
360
+ const lifecycle = new WorktreeLifecycle(s, deps);
361
+
362
+ lifecycle.exitMilestone("M001", { merge: true }, makeNotifyCtx());
363
+ lifecycle.exitMilestone("M001", { merge: true }, makeNotifyCtx());
364
+
365
+ let failures = readJournalEntries(tmp).filter(e => e.eventType === "worktree-merge-failed");
366
+ assert.equal(failures.length, 1, "variable conflict filenames should not bypass dedupe");
367
+ assert.match(
368
+ String(failures[0]!.data?.error),
369
+ /src\/a\.ts/,
370
+ "journal payload keeps the original error message",
371
+ );
372
+
373
+ now += 60_001;
374
+ lifecycle.exitMilestone("M001", { merge: true }, makeNotifyCtx());
375
+
376
+ failures = readJournalEntries(tmp).filter(e => e.eventType === "worktree-merge-failed");
377
+ assert.equal(failures.length, 2, "same merge failure is journaled again after dedupe expiry");
326
378
  });
327
379
 
328
380
  test("journal entries have valid flowId, seq, and ts fields", () => {
@@ -538,6 +538,31 @@ test("restoreToProjectRoot is no-op when originalBasePath is empty", () => {
538
538
  assert.equal(deps.calls.filter((c) => c.fn === "gitServiceFactory").length, 0);
539
539
  });
540
540
 
541
+ test("restoreToProjectRoot completes session-state restore even when chdir fails (ADR-016 phase 3, #5693)", () => {
542
+ // The verb attempts process.chdir to s.basePath after restoring it. The
543
+ // chdir is best-effort; failure must not abort the session-state restore.
544
+ // We exercise that contract by pointing originalBasePath at a path that
545
+ // cannot be chdir'd into.
546
+ const s = makeSession();
547
+ s.originalBasePath = "/this/path/should/not/exist/in/any/test/env";
548
+ s.basePath = "/project/.gsd/worktrees/M001";
549
+ const deps = makeDeps();
550
+ const lifecycle = new WorktreeLifecycle(s, deps);
551
+
552
+ // Capture cwd so we can confirm we did NOT successfully chdir.
553
+ const cwdBefore = process.cwd();
554
+ lifecycle.restoreToProjectRoot();
555
+
556
+ // Session-state restore happened despite chdir failure.
557
+ assert.equal(s.basePath, "/this/path/should/not/exist/in/any/test/env");
558
+ assert.equal(
559
+ deps.calls.filter((c) => c.fn === "gitServiceFactory").length,
560
+ 1,
561
+ );
562
+ // cwd is unchanged because chdir threw and was swallowed.
563
+ assert.equal(process.cwd(), cwdBefore);
564
+ });
565
+
541
566
  // ─── adoptSessionRoot (ADR-016 phase 2 / B2, issue #5620) ─────────────────────
542
567
 
543
568
  test("adoptSessionRoot sets basePath and seeds originalBasePath on a fresh session", () => {