gsd-pi 2.82.0-dev.3709f22a5 → 2.82.0-dev.3a3c6509d

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 (152) hide show
  1. package/README.md +1 -1
  2. package/dist/resources/.managed-resources-content-hash +1 -1
  3. package/dist/resources/extensions/claude-code-cli/stream-adapter.js +1 -1
  4. package/dist/resources/extensions/gsd/auto/phases.js +53 -29
  5. package/dist/resources/extensions/gsd/auto-direct-dispatch.js +1 -0
  6. package/dist/resources/extensions/gsd/auto-dispatch.js +12 -18
  7. package/dist/resources/extensions/gsd/auto-post-unit.js +1 -1
  8. package/dist/resources/extensions/gsd/auto-recovery.js +40 -13
  9. package/dist/resources/extensions/gsd/auto-start.js +3 -3
  10. package/dist/resources/extensions/gsd/auto-verification.js +17 -4
  11. package/dist/resources/extensions/gsd/auto-worktree.js +65 -9
  12. package/dist/resources/extensions/gsd/auto.js +0 -1
  13. package/dist/resources/extensions/gsd/bootstrap/agent-end-recovery.js +6 -1
  14. package/dist/resources/extensions/gsd/bootstrap/db-tools.js +1 -1
  15. package/dist/resources/extensions/gsd/bootstrap/write-gate.js +1 -1
  16. package/dist/resources/extensions/gsd/commands-prefs-wizard.js +7 -2
  17. package/dist/resources/extensions/gsd/crash-recovery.js +16 -4
  18. package/dist/resources/extensions/gsd/db/milestone-leases.js +24 -0
  19. package/dist/resources/extensions/gsd/forensics.js +3 -3
  20. package/dist/resources/extensions/gsd/git-service.js +6 -2
  21. package/dist/resources/extensions/gsd/gsd-db.js +20 -6
  22. package/dist/resources/extensions/gsd/guided-flow-queue.js +4 -3
  23. package/dist/resources/extensions/gsd/guided-flow.js +8 -5
  24. package/dist/resources/extensions/gsd/queue-reorder-ui.js +30 -13
  25. package/dist/resources/extensions/gsd/state.js +1 -1
  26. package/dist/resources/extensions/gsd/status-guards.js +7 -0
  27. package/dist/resources/extensions/gsd/workflow-mcp.js +17 -1
  28. package/dist/resources/extensions/gsd/worktree-manager.js +1 -1
  29. package/dist/tsconfig.extensions.tsbuildinfo +1 -1
  30. package/dist/web/standalone/.next/BUILD_ID +1 -1
  31. package/dist/web/standalone/.next/app-path-routes-manifest.json +9 -9
  32. package/dist/web/standalone/.next/build-manifest.json +2 -2
  33. package/dist/web/standalone/.next/prerender-manifest.json +3 -3
  34. package/dist/web/standalone/.next/server/app/_global-error.html +1 -1
  35. package/dist/web/standalone/.next/server/app/_global-error.rsc +1 -1
  36. package/dist/web/standalone/.next/server/app/_global-error.segments/_full.segment.rsc +1 -1
  37. package/dist/web/standalone/.next/server/app/_global-error.segments/_global-error/__PAGE__.segment.rsc +1 -1
  38. package/dist/web/standalone/.next/server/app/_global-error.segments/_global-error.segment.rsc +1 -1
  39. package/dist/web/standalone/.next/server/app/_global-error.segments/_head.segment.rsc +1 -1
  40. package/dist/web/standalone/.next/server/app/_global-error.segments/_index.segment.rsc +1 -1
  41. package/dist/web/standalone/.next/server/app/_global-error.segments/_tree.segment.rsc +1 -1
  42. package/dist/web/standalone/.next/server/app/_not-found.html +1 -1
  43. package/dist/web/standalone/.next/server/app/_not-found.rsc +1 -1
  44. package/dist/web/standalone/.next/server/app/_not-found.segments/_full.segment.rsc +1 -1
  45. package/dist/web/standalone/.next/server/app/_not-found.segments/_head.segment.rsc +1 -1
  46. package/dist/web/standalone/.next/server/app/_not-found.segments/_index.segment.rsc +1 -1
  47. package/dist/web/standalone/.next/server/app/_not-found.segments/_not-found/__PAGE__.segment.rsc +1 -1
  48. package/dist/web/standalone/.next/server/app/_not-found.segments/_not-found.segment.rsc +1 -1
  49. package/dist/web/standalone/.next/server/app/_not-found.segments/_tree.segment.rsc +1 -1
  50. package/dist/web/standalone/.next/server/app/api/browse-directories/route.js +1 -1
  51. package/dist/web/standalone/.next/server/app/index.html +1 -1
  52. package/dist/web/standalone/.next/server/app/index.rsc +1 -1
  53. package/dist/web/standalone/.next/server/app/index.segments/__PAGE__.segment.rsc +1 -1
  54. package/dist/web/standalone/.next/server/app/index.segments/_full.segment.rsc +1 -1
  55. package/dist/web/standalone/.next/server/app/index.segments/_head.segment.rsc +1 -1
  56. package/dist/web/standalone/.next/server/app/index.segments/_index.segment.rsc +1 -1
  57. package/dist/web/standalone/.next/server/app/index.segments/_tree.segment.rsc +1 -1
  58. package/dist/web/standalone/.next/server/app-paths-manifest.json +9 -9
  59. package/dist/web/standalone/.next/server/middleware-build-manifest.js +1 -1
  60. package/dist/web/standalone/.next/server/pages/404.html +1 -1
  61. package/dist/web/standalone/.next/server/pages/500.html +1 -1
  62. package/dist/web/standalone/.next/server/server-reference-manifest.json +1 -1
  63. package/package.json +1 -1
  64. package/packages/pi-ai/dist/providers/google-gemini-cli.d.ts.map +1 -1
  65. package/packages/pi-ai/dist/providers/google-gemini-cli.js +5 -0
  66. package/packages/pi-ai/dist/providers/google-gemini-cli.js.map +1 -1
  67. package/packages/pi-ai/dist/providers/google-gemini-cli.test.d.ts +2 -0
  68. package/packages/pi-ai/dist/providers/google-gemini-cli.test.d.ts.map +1 -0
  69. package/packages/pi-ai/dist/providers/google-gemini-cli.test.js +41 -0
  70. package/packages/pi-ai/dist/providers/google-gemini-cli.test.js.map +1 -0
  71. package/packages/pi-ai/src/providers/google-gemini-cli.test.ts +49 -0
  72. package/packages/pi-ai/src/providers/google-gemini-cli.ts +7 -0
  73. package/packages/pi-ai/tsconfig.tsbuildinfo +1 -1
  74. package/packages/pi-coding-agent/dist/core/chat-controller-ordering.test.js +44 -3
  75. package/packages/pi-coding-agent/dist/core/chat-controller-ordering.test.js.map +1 -1
  76. package/packages/pi-coding-agent/dist/core/sdk.js +1 -1
  77. package/packages/pi-coding-agent/dist/core/sdk.js.map +1 -1
  78. package/packages/pi-coding-agent/dist/modes/interactive/controllers/chat-controller.d.ts.map +1 -1
  79. package/packages/pi-coding-agent/dist/modes/interactive/controllers/chat-controller.js +71 -97
  80. package/packages/pi-coding-agent/dist/modes/interactive/controllers/chat-controller.js.map +1 -1
  81. package/packages/pi-coding-agent/dist/modes/interactive/interactive-mode-ordering.test.js +12 -0
  82. package/packages/pi-coding-agent/dist/modes/interactive/interactive-mode-ordering.test.js.map +1 -1
  83. package/packages/pi-coding-agent/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
  84. package/packages/pi-coding-agent/dist/modes/interactive/interactive-mode.js +19 -8
  85. package/packages/pi-coding-agent/dist/modes/interactive/interactive-mode.js.map +1 -1
  86. package/packages/pi-coding-agent/src/core/chat-controller-ordering.test.ts +53 -3
  87. package/packages/pi-coding-agent/src/core/sdk.ts +1 -1
  88. package/packages/pi-coding-agent/src/modes/interactive/controllers/chat-controller.ts +75 -102
  89. package/packages/pi-coding-agent/src/modes/interactive/interactive-mode-ordering.test.ts +14 -0
  90. package/packages/pi-coding-agent/src/modes/interactive/interactive-mode.ts +23 -8
  91. package/packages/pi-coding-agent/tsconfig.tsbuildinfo +1 -1
  92. package/packages/pi-tui/dist/__tests__/terminal.test.d.ts +2 -0
  93. package/packages/pi-tui/dist/__tests__/terminal.test.d.ts.map +1 -0
  94. package/packages/pi-tui/dist/__tests__/terminal.test.js +103 -0
  95. package/packages/pi-tui/dist/__tests__/terminal.test.js.map +1 -0
  96. package/packages/pi-tui/dist/terminal.d.ts +2 -0
  97. package/packages/pi-tui/dist/terminal.d.ts.map +1 -1
  98. package/packages/pi-tui/dist/terminal.js +12 -0
  99. package/packages/pi-tui/dist/terminal.js.map +1 -1
  100. package/packages/pi-tui/src/__tests__/terminal.test.ts +121 -0
  101. package/packages/pi-tui/src/terminal.ts +11 -0
  102. package/packages/pi-tui/tsconfig.tsbuildinfo +1 -1
  103. package/src/resources/extensions/claude-code-cli/stream-adapter.ts +1 -1
  104. package/src/resources/extensions/claude-code-cli/tests/stream-adapter.test.ts +9 -0
  105. package/src/resources/extensions/gsd/auto/phases.ts +60 -36
  106. package/src/resources/extensions/gsd/auto-direct-dispatch.ts +1 -0
  107. package/src/resources/extensions/gsd/auto-dispatch.ts +12 -18
  108. package/src/resources/extensions/gsd/auto-post-unit.ts +1 -1
  109. package/src/resources/extensions/gsd/auto-recovery.ts +45 -11
  110. package/src/resources/extensions/gsd/auto-start.ts +2 -3
  111. package/src/resources/extensions/gsd/auto-verification.ts +22 -2
  112. package/src/resources/extensions/gsd/auto-worktree.ts +74 -9
  113. package/src/resources/extensions/gsd/auto.ts +0 -1
  114. package/src/resources/extensions/gsd/bootstrap/agent-end-recovery.ts +9 -1
  115. package/src/resources/extensions/gsd/bootstrap/db-tools.ts +1 -1
  116. package/src/resources/extensions/gsd/bootstrap/write-gate.ts +1 -1
  117. package/src/resources/extensions/gsd/commands-prefs-wizard.ts +8 -3
  118. package/src/resources/extensions/gsd/crash-recovery.ts +16 -2
  119. package/src/resources/extensions/gsd/db/milestone-leases.ts +26 -0
  120. package/src/resources/extensions/gsd/forensics.ts +3 -3
  121. package/src/resources/extensions/gsd/git-service.ts +6 -3
  122. package/src/resources/extensions/gsd/gsd-db.ts +18 -6
  123. package/src/resources/extensions/gsd/guided-flow-queue.ts +4 -3
  124. package/src/resources/extensions/gsd/guided-flow.ts +8 -5
  125. package/src/resources/extensions/gsd/queue-reorder-ui.ts +31 -13
  126. package/src/resources/extensions/gsd/state.ts +1 -1
  127. package/src/resources/extensions/gsd/status-guards.ts +8 -0
  128. package/src/resources/extensions/gsd/tests/auto-loop.test.ts +2 -0
  129. package/src/resources/extensions/gsd/tests/auto-paused-ui-cleanup.test.ts +29 -1
  130. package/src/resources/extensions/gsd/tests/auto-recovery.test.ts +76 -5
  131. package/src/resources/extensions/gsd/tests/checkout-branch-stash-guard.test.ts +87 -0
  132. package/src/resources/extensions/gsd/tests/crash-recovery-via-db.test.ts +43 -0
  133. package/src/resources/extensions/gsd/tests/custom-engine-loop-integration.test.ts +2 -0
  134. package/src/resources/extensions/gsd/tests/dispatch-complete-milestone-guard.test.ts +27 -0
  135. package/src/resources/extensions/gsd/tests/gsd-db.test.ts +11 -0
  136. package/src/resources/extensions/gsd/tests/integration/git-service.test.ts +9 -0
  137. package/src/resources/extensions/gsd/tests/journal-integration.test.ts +46 -0
  138. package/src/resources/extensions/gsd/tests/merge-db-cycle.test.ts +179 -0
  139. package/src/resources/extensions/gsd/tests/pipeline-variant-dispatch.test.ts +2 -1
  140. package/src/resources/extensions/gsd/tests/prefs-wizard-coverage.test.ts +59 -0
  141. package/src/resources/extensions/gsd/tests/provider-errors.test.ts +18 -1
  142. package/src/resources/extensions/gsd/tests/queue-reorder-ui.test.ts +54 -0
  143. package/src/resources/extensions/gsd/tests/remediation-completion-guard.test.ts +43 -0
  144. package/src/resources/extensions/gsd/tests/run-uat-replay-cap.test.ts +2 -3
  145. package/src/resources/extensions/gsd/tests/status-guards.test.ts +13 -1
  146. package/src/resources/extensions/gsd/tests/unit-context-manifest.test.ts +17 -0
  147. package/src/resources/extensions/gsd/tests/validate-milestone-stuck-guard.test.ts +29 -2
  148. package/src/resources/extensions/gsd/tests/workflow-mcp.test.ts +18 -0
  149. package/src/resources/extensions/gsd/workflow-mcp.ts +18 -1
  150. package/src/resources/extensions/gsd/worktree-manager.ts +1 -1
  151. /package/dist/web/standalone/.next/static/{kkGf3_VaPFkiDNV_D7Dtl → O6femb9LLl3nlgsDaYwS-}/_buildManifest.js +0 -0
  152. /package/dist/web/standalone/.next/static/{kkGf3_VaPFkiDNV_D7Dtl → O6femb9LLl3nlgsDaYwS-}/_ssgManifest.js +0 -0
@@ -42,7 +42,6 @@ import {
42
42
  nativeCommit,
43
43
  nativeGetCurrentBranch,
44
44
  nativeDetectMainBranch,
45
- nativeCheckoutBranch,
46
45
  nativeBranchList,
47
46
  nativeBranchExists,
48
47
  nativeBranchListMerged,
@@ -56,7 +55,7 @@ import {
56
55
  detectWorktreeName,
57
56
  setActiveMilestoneId,
58
57
  } from "./worktree.js";
59
- import { getAutoWorktreePath, isInAutoWorktree } from "./auto-worktree.js";
58
+ import { getAutoWorktreePath, isInAutoWorktree, checkoutBranchWithStashGuard } from "./auto-worktree.js";
60
59
  import { readResourceVersion, cleanStaleRuntimeUnits } from "./auto-worktree.js";
61
60
  import { worktreePath as getWorktreeDir, isInsideWorktreesDir } from "./worktree-manager.js";
62
61
  import { emitWorktreeOrphaned } from "./worktree-telemetry.js";
@@ -1170,7 +1169,7 @@ export async function bootstrapAutoSession(
1170
1169
  isRepo,
1171
1170
  );
1172
1171
  if (branchToCheckout) {
1173
- nativeCheckoutBranch(base, branchToCheckout);
1172
+ checkoutBranchWithStashGuard(base, branchToCheckout, "isolation-none-recovery");
1174
1173
  logWarning("bootstrap", `Returned to "${branchToCheckout}" — HEAD was on stale milestone branch "${currentBranch}" (isolation: none does not use milestone branches).`);
1175
1174
  }
1176
1175
  } catch (err) {
@@ -105,11 +105,31 @@ async function runValidateMilestonePostCheck(
105
105
  const { milestone: mid } = parseUnitId(s.currentUnit.id);
106
106
  if (!mid) return "continue";
107
107
 
108
+ const setToolFailureRetry = (message: string): VerificationResult => {
109
+ const retryKey = verificationRetryKey(s.currentUnit!.type, s.currentUnit!.id);
110
+ const attempt = (s.verificationRetryCount.get(retryKey) ?? 0) + 1;
111
+ s.verificationRetryCount.set(retryKey, attempt);
112
+ s.pendingVerificationRetry = {
113
+ unitId: s.currentUnit!.id,
114
+ failureContext: message,
115
+ attempt,
116
+ };
117
+ return "retry";
118
+ };
119
+
108
120
  const validationFile = resolveMilestoneFile(s.basePath, mid, "VALIDATION");
109
- if (!validationFile) return "continue";
121
+ if (!validationFile) {
122
+ return setToolFailureRetry(
123
+ "You must call gsd_validate_milestone to persist the validation results. No VALIDATION.md was created.",
124
+ );
125
+ }
110
126
 
111
127
  const validationContent = await loadFile(validationFile);
112
- if (!validationContent) return "continue";
128
+ if (!validationContent) {
129
+ return setToolFailureRetry(
130
+ "You must call gsd_validate_milestone to persist the validation results. VALIDATION.md exists but is empty.",
131
+ );
132
+ }
113
133
 
114
134
  const verdict = extractVerdict(validationContent);
115
135
  if (verdict !== "needs-remediation") {
@@ -1007,7 +1007,73 @@ export function enterBranchModeForMilestone(
1007
1007
  });
1008
1008
  }
1009
1009
 
1010
- nativeCheckoutBranch(basePath, branch);
1010
+ checkoutBranchWithStashGuard(basePath, branch, `enter-branch-mode:${milestoneId}`);
1011
+ }
1012
+
1013
+ export function checkoutBranchWithStashGuard(
1014
+ basePath: string,
1015
+ branch: string,
1016
+ reason: string,
1017
+ ): void {
1018
+ let stashMarker: string | null = null;
1019
+ let stashed = false;
1020
+
1021
+ const status = nativeWorkingTreeStatus(basePath).trim();
1022
+ if (status.length > 0) {
1023
+ stashMarker = `gsd-checkout-stash:${reason}:${process.pid}:${Date.now()}:${process.hrtime.bigint().toString(36)}`;
1024
+ const stashListBefore = execFileSync("git", ["stash", "list"], {
1025
+ cwd: basePath,
1026
+ stdio: ["ignore", "pipe", "pipe"],
1027
+ encoding: "utf-8",
1028
+ });
1029
+ execFileSync(
1030
+ "git",
1031
+ ["stash", "push", "--include-untracked", "-m", `gsd: checkout stash [${stashMarker}]`],
1032
+ {
1033
+ cwd: basePath,
1034
+ stdio: ["ignore", "pipe", "pipe"],
1035
+ encoding: "utf-8",
1036
+ },
1037
+ );
1038
+ const stashListAfter = execFileSync("git", ["stash", "list"], {
1039
+ cwd: basePath,
1040
+ stdio: ["ignore", "pipe", "pipe"],
1041
+ encoding: "utf-8",
1042
+ });
1043
+ stashed = stashListAfter !== stashListBefore;
1044
+ }
1045
+
1046
+ // Checkout and stash-restore are split so we can distinguish two failure
1047
+ // modes: (a) checkout failed → HEAD did not move, restore stash and rethrow;
1048
+ // (b) checkout succeeded but stash pop failed → HEAD moved to `branch` but
1049
+ // the working-tree changes remain in the stash list. We surface a distinct
1050
+ // error in case (b) so callers don't assume the branch switch was rolled back.
1051
+ try {
1052
+ nativeCheckoutBranch(basePath, branch);
1053
+ } catch (checkoutErr) {
1054
+ if (stashed) {
1055
+ try {
1056
+ popStashByRef(basePath, stashMarker);
1057
+ } catch (restoreErr) {
1058
+ logWarning("worktree", `git stash pop failed during checkout restore: ${restoreErr instanceof Error ? restoreErr.message : String(restoreErr)}`);
1059
+ }
1060
+ }
1061
+ throw checkoutErr;
1062
+ }
1063
+
1064
+ if (stashed) {
1065
+ try {
1066
+ popStashByRef(basePath, stashMarker);
1067
+ } catch (popErr) {
1068
+ const msg = popErr instanceof Error ? popErr.message : String(popErr);
1069
+ const wrapped = new Error(
1070
+ `checkout to '${branch}' succeeded but stash restore failed; working tree changes remain in the stash list. Original error: ${msg}`,
1071
+ );
1072
+ const ref = (popErr as { stashRef?: string } | null)?.stashRef;
1073
+ if (ref) (wrapped as { stashRef?: string }).stashRef = ref;
1074
+ throw wrapped;
1075
+ }
1076
+ }
1011
1077
  }
1012
1078
 
1013
1079
  // ─── Public API ────────────────────────────────────────────────────────────
@@ -1992,14 +2058,6 @@ export function mergeMilestoneToMain(
1992
2058
  logWarning("worktree", `git stash failed: ${err instanceof Error ? err.message : String(err)}`);
1993
2059
  }
1994
2060
 
1995
- if (needsDbCycle && dbPathToReopen) {
1996
- try {
1997
- openDatabase(dbPathToReopen);
1998
- } catch (err) {
1999
- logWarning("worktree", `post-stash db reopen failed: ${err instanceof Error ? err.message : String(err)}`);
2000
- }
2001
- }
2002
-
2003
2061
  // 7b. Clean up stale merge state before attempting squash merge (#2912).
2004
2062
  // A leftover MERGE_HEAD (from a previous failed merge, libgit2 native path,
2005
2063
  // or interrupted operation) causes `git merge --squash` to refuse with
@@ -2009,6 +2067,13 @@ export function mergeMilestoneToMain(
2009
2067
 
2010
2068
  // 8. Squash merge — auto-resolve .gsd/ state file conflicts (#530)
2011
2069
  const mergeResult = nativeMergeSquash(originalBasePath_, milestoneBranch);
2070
+ if (needsDbCycle && dbPathToReopen) {
2071
+ try {
2072
+ openDatabase(dbPathToReopen);
2073
+ } catch (err) {
2074
+ logWarning("worktree", `post-merge db reopen failed: ${err instanceof Error ? err.message : String(err)}`);
2075
+ }
2076
+ }
2012
2077
 
2013
2078
  if (!mergeResult.success) {
2014
2079
  // Dirty working tree — the merge was rejected before it started (e.g.
@@ -1731,7 +1731,6 @@ export async function pauseAuto(
1731
1731
  restoreProjectRootEnv();
1732
1732
  restoreMilestoneLockEnv();
1733
1733
  s.pendingVerificationRetry = null;
1734
- s.verificationRetryCount.clear();
1735
1734
  ctx?.ui.setStatus("gsd-auto", "paused");
1736
1735
  ctx?.ui.setWidget("gsd-progress", undefined);
1737
1736
  const resumeCmd = s.stepMode ? "/gsd next" : "/gsd auto";
@@ -100,6 +100,14 @@ export function isUserInitiatedAbortMessage(message: string | undefined | null):
100
100
  return /\b(?:claude code process aborted by user|request aborted by user|process aborted by user)\b/i.test(message);
101
101
  }
102
102
 
103
+ export function shouldDeferTransientErrorToCoreRetry(
104
+ cls: ErrorClass,
105
+ rawErrorMsg: string,
106
+ ): boolean {
107
+ if (!isTransient(cls) || cls.kind === "rate-limit") return false;
108
+ return !/retry failed after \d+ attempts:/i.test(rawErrorMsg);
109
+ }
110
+
103
111
  function isBareClaudeCodeSessionSwitchAbortMarker(message: string | undefined | null): boolean {
104
112
  if (!message) return false;
105
113
  const normalized = message.trim().replace(/\s+/g, " ").toLowerCase();
@@ -488,7 +496,7 @@ export async function handleAgentEnd(
488
496
  // Core retries transient failures in-session after this handler.
489
497
  // Keep that behavior for non-rate-limit classes to avoid pause/retry races,
490
498
  // but let rate-limit continue into model fallback logic below (#4373).
491
- if (isTransient(cls) && cls.kind !== "rate-limit") {
499
+ if (shouldDeferTransientErrorToCoreRetry(cls, rawErrorMsg)) {
492
500
  return;
493
501
  }
494
502
 
@@ -913,7 +913,7 @@ export function registerDbTools(pi: ExtensionAPI): void {
913
913
  label: "Skip Slice",
914
914
  description:
915
915
  "Mark a slice as skipped so auto-mode advances past it without executing. " +
916
- "Non-closed tasks within the slice are cascaded to skipped so milestone completion is not blocked by leftover pending tasks (#4375). " +
916
+ "Non-closed tasks within the slice are cascaded to skipped so milestone completion is not blocked by leftover pending tasks. " +
917
917
  "The slice data is preserved for reference. The state machine treats skipped slices like completed ones for dependency satisfaction.",
918
918
  promptSnippet: "Skip a GSD slice (mark as skipped, auto-mode will advance past it)",
919
919
  promptGuidelines: [
@@ -748,7 +748,7 @@ function matchesAllowedGlob(absPath: string, basePath: string, globs: readonly s
748
748
  function blockReason(unitType: string, mode: string, what: string): string {
749
749
  return [
750
750
  `HARD BLOCK: unit "${unitType}" runs under tools-policy "${mode}" — ${what}.`,
751
- `This is a mechanical gate enforced by manifest.tools (#4934). You MUST NOT proceed,`,
751
+ `This is a mechanical gate enforced by manifest.tools. You MUST NOT proceed,`,
752
752
  `retry the same call, or rationalize past this block. If you need to write user source,`,
753
753
  `the work belongs in execute-task, not in a planning unit.`,
754
754
  ].join(" ");
@@ -587,10 +587,15 @@ async function configureModels(ctx: ExtensionCommandContext, prefs: Record<strin
587
587
  const models: Record<string, unknown> = (prefs.models as Record<string, unknown>) ?? {};
588
588
 
589
589
  const availableModels = ctx.modelRegistry.getAvailable();
590
- if (availableModels.length > 0) {
590
+ const getAllWithDiscovered = (ctx.modelRegistry as { getAllWithDiscovered?: () => typeof availableModels }).getAllWithDiscovered;
591
+ const availableProviders = new Set(availableModels.map((m) => m.provider));
592
+ const selectableModels = typeof getAllWithDiscovered === "function"
593
+ ? getAllWithDiscovered().filter((m) => availableProviders.has(m.provider))
594
+ : availableModels;
595
+ if (selectableModels.length > 0) {
591
596
  // Group models by provider, sorted alphabetically
592
- const byProvider = new Map<string, typeof availableModels>();
593
- for (const m of availableModels) {
597
+ const byProvider = new Map<string, typeof selectableModels>();
598
+ for (const m of selectableModels) {
594
599
  let group = byProvider.get(m.provider);
595
600
  if (!group) {
596
601
  group = [];
@@ -31,8 +31,10 @@ import {
31
31
  findStaleWorkerForProject,
32
32
  getAllAutoWorkers,
33
33
  markWorkerCrashed,
34
+ markWorkerStopping,
34
35
  type AutoWorkerRow,
35
36
  } from "./db/auto-workers.js";
37
+ import { forceReleaseLeasesForWorker } from "./db/milestone-leases.js";
36
38
  import { markLatestActiveForWorkerCanceled, type DispatchStatus } from "./db/unit-dispatches.js";
37
39
  import { getRuntimeKv, setRuntimeKv, deleteRuntimeKv } from "./db/runtime-kv.js";
38
40
  import { _getAdapter, isDbAvailable } from "./gsd-db.js";
@@ -219,9 +221,21 @@ export function clearLock(basePath: string): void {
219
221
  if (!isDbAvailable()) return;
220
222
  try {
221
223
  const projectRoot = normalizeRealPath(basePath);
224
+ const staleWorker = findStaleWorkerForProject(projectRoot);
225
+ if (staleWorker) {
226
+ markWorkerCrashed(staleWorker.worker_id);
227
+ forceReleaseLeasesForWorker(staleWorker.worker_id);
228
+ deleteRuntimeKv("worker", staleWorker.worker_id, SESSION_FILE_KV_KEY);
229
+ return;
230
+ }
222
231
  const worker = findActiveWorkerForCurrentProcess(projectRoot);
223
- if (!worker) return;
224
- deleteRuntimeKv("worker", worker.worker_id, SESSION_FILE_KV_KEY);
232
+ if (worker) deleteRuntimeKv("worker", worker.worker_id, SESSION_FILE_KV_KEY);
233
+
234
+ const stale = findStaleWorkerForProject(projectRoot);
235
+ if (stale) {
236
+ markWorkerStopping(stale.worker_id);
237
+ deleteRuntimeKv("worker", stale.worker_id, SESSION_FILE_KV_KEY);
238
+ }
225
239
  } catch {
226
240
  // Best-effort.
227
241
  }
@@ -255,6 +255,32 @@ export function releaseMilestoneLease(
255
255
  });
256
256
  }
257
257
 
258
+ /**
259
+ * Force-release all held leases for a worker.
260
+ *
261
+ * Used by crash recovery once PID liveness has confirmed the worker is dead.
262
+ * No fencing token is required because this path is cleanup-only for a
263
+ * non-running process.
264
+ */
265
+ export function forceReleaseLeasesForWorker(workerId: string): number {
266
+ if (!isDbAvailable()) return 0;
267
+ const db = _getAdapter()!;
268
+ let changes = 0;
269
+ transaction(() => {
270
+ const result = db.prepare(
271
+ `UPDATE milestone_leases
272
+ SET status = 'released'
273
+ WHERE worker_id = :worker_id
274
+ AND status = 'held'`,
275
+ ).run({ ":worker_id": workerId });
276
+ changes =
277
+ typeof (result as { changes?: unknown }).changes === "number"
278
+ ? (result as { changes: number }).changes
279
+ : 0;
280
+ });
281
+ return changes;
282
+ }
283
+
258
284
  /**
259
285
  * Read current lease row for diagnostics. Returns null if no row exists.
260
286
  */
@@ -837,7 +837,7 @@ export function detectWorktreeOrphans(
837
837
  type: "worktree-unmerged-exit",
838
838
  severity: "warning",
839
839
  summary: `${summary.exitsWithUnmergedWork} auto-exit(s) left milestone work unmerged`,
840
- details: `Exit reasons: ${reasonBreakdown || "(none)"} · Producer-side signal for #4761-class orphans. Inspect .gsd/journal/*.jsonl with eventType:"auto-exit" for per-exit detail.`,
840
+ details: `Exit reasons: ${reasonBreakdown || "(none)"} · Producer-side signal for orphaned worktrees. Inspect .gsd/journal/*.jsonl with eventType:"auto-exit" for per-exit detail.`,
841
841
  });
842
842
  }
843
843
  }
@@ -1056,7 +1056,7 @@ function saveForensicReport(basePath: string, report: ForensicReport, problemDes
1056
1056
  .map(([r, n]) => `${r}=${n}`).join(", ");
1057
1057
  sections.push(` - Exit reasons: ${breakdown}`);
1058
1058
  }
1059
- sections.push(`- Canonical-root redirects (#4761 fix fired): ${t.canonicalRedirects}`);
1059
+ sections.push(`- Canonical-root redirects: ${t.canonicalRedirects}`);
1060
1060
  // #4765 slice-cadence counters
1061
1061
  if (t.slicesMerged + t.sliceMergeConflicts + t.milestoneResquashes > 0) {
1062
1062
  sections.push(`- Slices merged: ${t.slicesMerged} · Slice merge conflicts: ${t.sliceMergeConflicts}`);
@@ -1220,7 +1220,7 @@ function formatReportForPrompt(report: ForensicReport): string {
1220
1220
  if (hasSignal) {
1221
1221
  sections.push("### Worktree Telemetry");
1222
1222
  sections.push(`- Created: ${t.worktreesCreated} · Merged: ${t.worktreesMerged} · Conflicts: ${t.mergeConflicts}`);
1223
- sections.push(`- Orphans: ${t.orphansDetected} · Unmerged exits: ${t.exitsWithUnmergedWork} · Redirects (#4761): ${t.canonicalRedirects}`);
1223
+ sections.push(`- Orphans: ${t.orphansDetected} · Unmerged exits: ${t.exitsWithUnmergedWork} · Redirects: ${t.canonicalRedirects}`);
1224
1224
  if (t.orphansDetected > 0) {
1225
1225
  const breakdown = Object.entries(t.orphansByReason)
1226
1226
  .map(([r, n]) => `${r}=${n}`).join(", ");
@@ -388,6 +388,9 @@ export function readIntegrationBranch(basePath: string, milestoneId: string): st
388
388
  }
389
389
  }
390
390
 
391
+ /** Re-export for backward compatibility — canonical definitions in branch-patterns.ts */
392
+ export { QUICK_BRANCH_RE, WORKFLOW_BRANCH_RE } from "./branch-patterns.js";
393
+
391
394
  /**
392
395
  * Persist the integration branch for a milestone.
393
396
  *
@@ -398,14 +401,14 @@ export function readIntegrationBranch(basePath: string, milestoneId: string): st
398
401
  *
399
402
  * The file is committed immediately so the metadata is persisted in git.
400
403
  */
401
- /** Re-export for backward compatibility — canonical definitions in branch-patterns.ts */
402
- export { QUICK_BRANCH_RE, WORKFLOW_BRANCH_RE } from "./branch-patterns.js";
403
-
404
404
  export function writeIntegrationBranch(
405
405
  basePath: string,
406
406
  milestoneId: string,
407
407
  branch: string,
408
408
  ): void {
409
+ // Never persist milestone branches as integration targets.
410
+ // They are ephemeral execution branches and can cause self-diff corruption.
411
+ if (branch.startsWith("milestone/")) return;
409
412
  // Don't record slice branches as the integration target
410
413
  if (SLICE_BRANCH_RE.test(branch)) return;
411
414
  // Don't record quick-task branches — they are ephemeral and merge back
@@ -111,13 +111,14 @@ const providerLoader = createSqliteProviderLoader({
111
111
 
112
112
  export const SCHEMA_VERSION = 28;
113
113
 
114
- function initSchema(db: DbAdapter, fileBacked: boolean): void {
115
- if (fileBacked) db.exec("PRAGMA journal_mode=WAL");
114
+ function initSchema(db: DbAdapter, fileBacked: boolean, dbPath: string | null): void {
115
+ const conservativeFilePragmas = fileBacked && _isLikelyWslDrvFsPathForTest(dbPath);
116
+ if (fileBacked) db.exec(conservativeFilePragmas ? "PRAGMA journal_mode=DELETE" : "PRAGMA journal_mode=WAL");
116
117
  if (fileBacked) db.exec("PRAGMA busy_timeout = 5000");
117
- if (fileBacked) db.exec("PRAGMA synchronous = NORMAL");
118
+ if (fileBacked) db.exec(conservativeFilePragmas ? "PRAGMA synchronous = FULL" : "PRAGMA synchronous = NORMAL");
118
119
  if (fileBacked) db.exec("PRAGMA auto_vacuum = INCREMENTAL");
119
120
  if (fileBacked) db.exec("PRAGMA cache_size = -8000"); // 8 MB page cache
120
- if (fileBacked && process.platform !== "darwin") db.exec("PRAGMA mmap_size = 67108864"); // 64 MB mmap
121
+ if (fileBacked && !conservativeFilePragmas && process.platform !== "darwin") db.exec("PRAGMA mmap_size = 67108864"); // 64 MB mmap
121
122
  db.exec("PRAGMA temp_store = MEMORY");
122
123
  db.exec("PRAGMA foreign_keys = ON");
123
124
 
@@ -156,6 +157,17 @@ function initSchema(db: DbAdapter, fileBacked: boolean): void {
156
157
  migrateSchema(db);
157
158
  }
158
159
 
160
+ export function _isLikelyWslDrvFsPathForTest(dbPath: string | null): boolean {
161
+ if (!dbPath || process.platform !== "linux") return false;
162
+ const drvFsPathPattern = /^\/mnt\/[a-z](?:\/|$)/i;
163
+ if (drvFsPathPattern.test(dbPath)) return true;
164
+ try {
165
+ return drvFsPathPattern.test(realpathSync(dbPath));
166
+ } catch {
167
+ return false;
168
+ }
169
+ }
170
+
159
171
  /**
160
172
  * Create the FTS5 virtual table for memories plus the triggers that keep it
161
173
  * in sync with the base table. FTS5 may be unavailable on stripped-down
@@ -605,14 +617,14 @@ export function openDatabase(path: string): boolean {
605
617
  const adapter = createDbAdapter(rawDb);
606
618
  const fileBacked = path !== ":memory:";
607
619
  try {
608
- initSchema(adapter, fileBacked);
620
+ initSchema(adapter, fileBacked, path);
609
621
  } catch (err) {
610
622
  // Corrupt freelist: DDL fails with "malformed" but VACUUM can rebuild.
611
623
  // Attempt VACUUM recovery before giving up (see #2519).
612
624
  if (fileBacked && err instanceof Error && err.message?.includes("malformed")) {
613
625
  try {
614
626
  adapter.exec("VACUUM");
615
- initSchema(adapter, fileBacked);
627
+ initSchema(adapter, fileBacked, path);
616
628
  process.stderr.write("gsd-db: recovered corrupt database via VACUUM\n");
617
629
  } catch (retryErr) {
618
630
  _dbOpenState.recordError("vacuum-recovery", retryErr);
@@ -23,6 +23,7 @@ import { nativeAddPaths, nativeCommit } from "./native-git-bridge.js";
23
23
  import { loadEffectiveGSDPreferences } from "./preferences.js";
24
24
  import { loadQueueOrder, sortByQueueOrder, saveQueueOrder } from "./queue-order.js";
25
25
  import { findMilestoneIds, nextMilestoneId } from "./milestone-ids.js";
26
+ import { isFutureMilestoneStatus } from "./status-guards.js";
26
27
 
27
28
  // ─── Queue Entry Point ──────────────────────────────────────────────────────
28
29
 
@@ -63,7 +64,7 @@ export async function showQueue(
63
64
 
64
65
  // ── Count pending milestones ────────────────────────────────────────
65
66
  const pendingMilestones = state.registry.filter(
66
- m => m.status === "pending" || m.status === "active",
67
+ m => isFutureMilestoneStatus(m.status) || m.status === "active",
67
68
  );
68
69
  const completeCount = state.registry.filter(m => m.status === "complete").length;
69
70
  const parkedCount = state.registry.filter(m => m.status === "parked").length;
@@ -182,7 +183,7 @@ export async function showQueueAdd(
182
183
  ? `Currently executing: ${state.activeMilestone.id} — ${state.activeMilestone.title} (phase: ${state.phase}).`
183
184
  : "No milestone currently active.";
184
185
 
185
- const pendingCount = state.registry.filter(m => m.status === "pending").length;
186
+ const pendingCount = state.registry.filter(m => isFutureMilestoneStatus(m.status)).length;
186
187
  const completeCount = state.registry.filter(m => m.status === "complete").length;
187
188
 
188
189
  const preamble = [
@@ -284,7 +285,7 @@ export async function buildExistingMilestonesContext(
284
285
 
285
286
  // For active/pending/parked milestones, include the roadmap if it exists
286
287
  // (shows what's planned but not yet built)
287
- if (status === "active" || status === "pending" || status === "parked") {
288
+ if (status === "active" || isFutureMilestoneStatus(status) || status === "parked") {
288
289
  const roadmapFile = resolveMilestoneFile(basePath, mid, "ROADMAP");
289
290
  if (roadmapFile) {
290
291
  const content = await loadFile(roadmapFile);
@@ -48,6 +48,7 @@ import { getIsolationMode, loadEffectiveGSDPreferences } from "./preferences.js"
48
48
  import { resolveUokFlags } from "./uok/flags.js";
49
49
  import { ensurePlanV2Graph, isMissingFinalizedContextResult } from "./uok/plan-v2.js";
50
50
  import { detectProjectState, hasGsdBootstrapArtifacts } from "./detection.js";
51
+ import { isFutureMilestoneStatus } from "./status-guards.js";
51
52
  import { showProjectInit, offerMigration } from "./init-wizard.js";
52
53
  import { validateDirectory } from "./validate-directory.js";
53
54
  import { showConfirm } from "../shared/tui.js";
@@ -1042,6 +1043,7 @@ async function dispatchWorkflow(
1042
1043
  ? ctx.modelRegistry.getProviderAuthMode(ctx.model.provider)
1043
1044
  : undefined,
1044
1045
  baseUrl: result.appliedModel?.baseUrl ?? ctx.model?.baseUrl,
1046
+ activeTools: typeof pi.getActiveTools === "function" ? pi.getActiveTools() : [],
1045
1047
  },
1046
1048
  );
1047
1049
  if (compatibilityError) {
@@ -1471,7 +1473,7 @@ export async function showDiscuss(
1471
1473
  // No active milestone (or corrupted milestone with undefined id) —
1472
1474
  // check for pending milestones to discuss instead
1473
1475
  if (!state.activeMilestone?.id) {
1474
- const pendingMilestones = state.registry.filter(m => m.status === "pending");
1476
+ const pendingMilestones = state.registry.filter(m => isFutureMilestoneStatus(m.status));
1475
1477
  if (pendingMilestones.length === 0) {
1476
1478
  ctx.ui.notify("No active milestone. Run /gsd to create one first.", "warning");
1477
1479
  return;
@@ -1583,7 +1585,7 @@ export async function showDiscuss(
1583
1585
 
1584
1586
  if (pendingSlices.length === 0) {
1585
1587
  // All slices complete — but queued milestones may still need discussion (#3150)
1586
- const pendingMilestones = state.registry.filter(m => m.status === "pending");
1588
+ const pendingMilestones = state.registry.filter(m => isFutureMilestoneStatus(m.status));
1587
1589
  if (pendingMilestones.length > 0) {
1588
1590
  await showDiscussQueuedMilestone(ctx, pi, basePath, pendingMilestones);
1589
1591
  return;
@@ -1607,7 +1609,7 @@ export async function showDiscuss(
1607
1609
  // If all pending slices are discussed, check for queued milestones before exiting (#3150)
1608
1610
  const allDiscussed = pendingSlices.every(s => discussedMap.get(s.id));
1609
1611
  if (allDiscussed) {
1610
- const pendingMilestones = state.registry.filter(m => m.status === "pending");
1612
+ const pendingMilestones = state.registry.filter(m => isFutureMilestoneStatus(m.status));
1611
1613
  if (pendingMilestones.length > 0) {
1612
1614
  await showDiscussQueuedMilestone(ctx, pi, basePath, pendingMilestones);
1613
1615
  return;
@@ -1643,7 +1645,7 @@ export async function showDiscuss(
1643
1645
  });
1644
1646
 
1645
1647
  // Offer access to queued milestones when any exist
1646
- const pendingMilestones = state.registry.filter(m => m.status === "pending");
1648
+ const pendingMilestones = state.registry.filter(m => isFutureMilestoneStatus(m.status));
1647
1649
  if (pendingMilestones.length > 0) {
1648
1650
  actions.push({
1649
1651
  id: "discuss_queued_milestone",
@@ -1718,10 +1720,11 @@ async function showDiscussQueuedMilestone(
1718
1720
  const hasContext = !!resolveMilestoneFile(basePath, m.id, "CONTEXT");
1719
1721
  const hasDraft = !hasContext && !!resolveMilestoneFile(basePath, m.id, "CONTEXT-DRAFT");
1720
1722
  const contextStatus = hasContext ? "context ✓" : hasDraft ? "draft context" : "no context yet";
1723
+ const statusLabel = m.status === "planned" ? "planned" : "queued";
1721
1724
  return {
1722
1725
  id: m.id,
1723
1726
  label: `${m.id}: ${m.title}`,
1724
- description: `[queued] · ${contextStatus}`,
1727
+ description: `[${statusLabel}] · ${contextStatus}`,
1725
1728
  recommended: i === 0,
1726
1729
  };
1727
1730
  });
@@ -43,6 +43,7 @@ export async function showQueueReorder(
43
43
  const items = [...pending];
44
44
  let cursor = 0;
45
45
  let grabbed = false;
46
+ let scrollOffset = 0;
46
47
  let cachedLines: string[] | undefined;
47
48
  let validation: DependencyValidation;
48
49
 
@@ -154,8 +155,10 @@ export async function showQueueReorder(
154
155
 
155
156
  const ui = makeUI(theme, width);
156
157
  const lines: string[] = [];
158
+ const queueRows: string[] = [];
157
159
  const push = (...rows: string[][]) => { for (const r of rows) lines.push(...r); };
158
160
  const add = (s: string) => truncateToWidth(s, width);
161
+ let cursorQueueRow = 0;
159
162
 
160
163
  const headerText = grabbed ? " Queue Reorder — Moving Item" : " Queue Reorder";
161
164
  push(ui.bar(), ui.blank(), ui.header(headerText), ui.blank());
@@ -188,11 +191,13 @@ export async function showQueueReorder(
188
191
  const label = item.title && item.title !== item.id ? `${item.id} ${item.title}` : item.id;
189
192
 
190
193
  if (isCursor && grabbed) {
191
- lines.push(add(` ${theme.fg("warning", `▸▸ ${num}. ${label}`)}`));
194
+ cursorQueueRow = queueRows.length;
195
+ queueRows.push(add(` ${theme.fg("warning", `▸▸ ${num}. ${label}`)}`));
192
196
  } else if (isCursor) {
193
- lines.push(add(` ${theme.fg("accent", `${GLYPH.cursor} ${num}. ${label}`)}`));
197
+ cursorQueueRow = queueRows.length;
198
+ queueRows.push(add(` ${theme.fg("accent", `${GLYPH.cursor} ${num}. ${label}`)}`));
194
199
  } else {
195
- lines.push(add(` ${theme.fg("text", `${num}. ${label}`)}`));
200
+ queueRows.push(add(` ${theme.fg("text", `${num}. ${label}`)}`));
196
201
  }
197
202
 
198
203
  // depends_on annotations
@@ -201,36 +206,37 @@ export async function showQueueReorder(
201
206
  if (completedIds.has(dep)) continue;
202
207
  const pairKey = `${item.id}:${dep}`;
203
208
  if (violatedPairs.has(pairKey)) {
204
- lines.push(add(` ${theme.fg("warning", `${GLYPH.statusWarning} depends_on: ${dep} — auto-removed on confirm`)}`));
209
+ queueRows.push(add(` ${theme.fg("warning", `${GLYPH.statusWarning} depends_on: ${dep} — auto-removed on confirm`)}`));
205
210
  } else if (redundantPairs.has(pairKey)) {
206
- lines.push(add(` ${theme.fg("dim", `↳ depends_on: ${dep} (redundant)`)}`));
211
+ queueRows.push(add(` ${theme.fg("dim", `↳ depends_on: ${dep} (redundant)`)}`));
207
212
  } else {
208
- lines.push(add(` ${theme.fg("dim", `↳ depends_on: ${dep}`)}`));
213
+ queueRows.push(add(` ${theme.fg("dim", `↳ depends_on: ${dep}`)}`));
209
214
  }
210
215
  }
211
216
 
212
217
  // Missing deps
213
218
  for (const v of validation.violations.filter(v => v.milestone === item.id && v.type === 'missing_dep')) {
214
- lines.push(add(` ${theme.fg("error", `${GLYPH.statusWarning} depends_on: ${v.dependsOn} (does not exist)`)}`));
219
+ queueRows.push(add(` ${theme.fg("error", `${GLYPH.statusWarning} depends_on: ${v.dependsOn} (does not exist)`)}`));
215
220
  }
216
221
  }
217
222
 
218
223
  // Removed deps feedback
224
+ const trailingLines: string[] = [];
219
225
  if (removedDeps.length > 0) {
220
- push(ui.blank());
226
+ trailingLines.push(...ui.blank());
221
227
  for (const r of removedDeps) {
222
- lines.push(add(` ${theme.fg("success", `${GLYPH.statusDone} Removed: ${r.milestone} depends_on ${r.dep}`)}`));
228
+ trailingLines.push(add(` ${theme.fg("success", `${GLYPH.statusDone} Removed: ${r.milestone} depends_on ${r.dep}`)}`));
223
229
  }
224
230
  }
225
231
 
226
232
  // Circular warning
227
233
  const circ = validation.violations.find(v => v.type === 'circular');
228
234
  if (circ) {
229
- push(ui.blank());
230
- lines.push(add(` ${theme.fg("error", `${GLYPH.statusWarning} ${circ.message}`)}`));
235
+ trailingLines.push(...ui.blank());
236
+ trailingLines.push(add(` ${theme.fg("error", `${GLYPH.statusWarning} ${circ.message}`)}`));
231
237
  }
232
238
 
233
- push(ui.blank());
239
+ trailingLines.push(...ui.blank());
234
240
 
235
241
  // Hints — context-sensitive based on grab state
236
242
  const hints: string[] = [];
@@ -250,7 +256,19 @@ export async function showQueueReorder(
250
256
  }
251
257
  hints.push("esc");
252
258
 
253
- push(ui.hints(hints), ui.bar());
259
+ trailingLines.push(...ui.hints(hints), ...ui.bar());
260
+
261
+ const maxOverlayRows = Math.max(10, process.stdout.rows ? Math.floor(process.stdout.rows * 0.8) : 24);
262
+ const availableQueueRows = Math.max(1, maxOverlayRows - lines.length - trailingLines.length);
263
+ const maxScroll = Math.max(0, queueRows.length - availableQueueRows);
264
+ if (cursorQueueRow < scrollOffset) {
265
+ scrollOffset = cursorQueueRow;
266
+ } else if (cursorQueueRow >= scrollOffset + availableQueueRows) {
267
+ scrollOffset = cursorQueueRow - availableQueueRows + 1;
268
+ }
269
+ scrollOffset = Math.min(Math.max(scrollOffset, 0), maxScroll);
270
+
271
+ lines.push(...queueRows.slice(scrollOffset, scrollOffset + availableQueueRows), ...trailingLines);
254
272
 
255
273
  cachedLines = lines;
256
274
  return lines;
@@ -1441,7 +1441,7 @@ export async function _deriveStateImpl(
1441
1441
  const summaryPath = resolveTaskFile(basePath, activeMilestone.id, activeSlice.id, t.id, "SUMMARY");
1442
1442
  if (summaryPath && existsSync(summaryPath)) {
1443
1443
  t.done = true;
1444
- logWarning("reconcile", `task ${activeMilestone.id}/${activeSlice.id}/${t.id} reconciled via SUMMARY on disk (#2514)`, { mid: activeMilestone.id, sid: activeSlice.id, tid: t.id });
1444
+ logWarning("reconcile", `task ${activeMilestone.id}/${activeSlice.id}/${t.id} reconciled via SUMMARY on disk`, { mid: activeMilestone.id, sid: activeSlice.id, tid: t.id });
1445
1445
  }
1446
1446
  }
1447
1447
 
@@ -30,3 +30,11 @@ export function isInactiveStatus(status: string): boolean {
30
30
  export function isSkippedForDispatch(status: string): boolean {
31
31
  return isClosedStatus(status) || status === "parked" || isDeferredStatus(status);
32
32
  }
33
+
34
+ /**
35
+ * Returns true when a milestone is future/backlog work (not currently executing).
36
+ * Includes legacy/project-specific alias "planned" for compatibility.
37
+ */
38
+ export function isFutureMilestoneStatus(status: string): boolean {
39
+ return status === "pending" || status === "queued" || status === "planned";
40
+ }
@@ -129,6 +129,8 @@ function makeMockPi() {
129
129
  setModelCalls.push(args);
130
130
  return true;
131
131
  },
132
+ getThinkingLevel: () => "off",
133
+ setThinkingLevel: () => {},
132
134
  calls,
133
135
  setModelCalls,
134
136
  } as any;