@apralabs/apra-fleet 0.4.1 → 0.4.2

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 (276) hide show
  1. package/README.md +16 -8
  2. package/dist/agents/backlog-groomer.md +17 -21
  3. package/dist/agents/ci-watcher.md +3 -0
  4. package/dist/agents/deployer.md +22 -44
  5. package/dist/agents/doer.md +131 -132
  6. package/dist/agents/harvester.md +20 -32
  7. package/dist/agents/integ-test-runner.md +81 -113
  8. package/dist/agents/kb-reconciler.md +31 -42
  9. package/dist/agents/plan-reviewer.md +32 -44
  10. package/dist/agents/planner.md +51 -63
  11. package/dist/agents/regression-test-runner.md +65 -80
  12. package/dist/agents/reviewer.md +56 -83
  13. package/dist/agents/schemas/integ-test-runner-output.json +1 -1
  14. package/dist/agents/schemas/regression-test-runner-output.json +4 -17
  15. package/dist/cli/auth.d.ts.map +1 -1
  16. package/dist/cli/auth.js +1 -2
  17. package/dist/cli/auth.js.map +1 -1
  18. package/dist/cli/config.d.ts +3 -3
  19. package/dist/cli/config.d.ts.map +1 -1
  20. package/dist/cli/config.js +4 -13
  21. package/dist/cli/config.js.map +1 -1
  22. package/dist/cli/install.d.ts.map +1 -1
  23. package/dist/cli/install.js +5 -39
  24. package/dist/cli/install.js.map +1 -1
  25. package/dist/cli/register-member.js +1 -1
  26. package/dist/cli/start.d.ts.map +1 -1
  27. package/dist/cli/start.js +7 -0
  28. package/dist/cli/start.js.map +1 -1
  29. package/dist/cli/uninstall.d.ts.map +1 -1
  30. package/dist/cli/uninstall.js +5 -3
  31. package/dist/cli/uninstall.js.map +1 -1
  32. package/dist/cli/watch.d.ts +26 -3
  33. package/dist/cli/watch.d.ts.map +1 -1
  34. package/dist/cli/watch.js +41 -9
  35. package/dist/cli/watch.js.map +1 -1
  36. package/dist/os/git-bash-candidates.d.ts +35 -0
  37. package/dist/os/git-bash-candidates.d.ts.map +1 -0
  38. package/dist/os/git-bash-candidates.js +46 -0
  39. package/dist/os/git-bash-candidates.js.map +1 -0
  40. package/dist/os/index.d.ts +13 -4
  41. package/dist/os/index.d.ts.map +1 -1
  42. package/dist/os/index.js +17 -2
  43. package/dist/os/index.js.map +1 -1
  44. package/dist/os/linux.js +1 -1
  45. package/dist/os/linux.js.map +1 -1
  46. package/dist/os/os-commands.d.ts +7 -0
  47. package/dist/os/os-commands.d.ts.map +1 -1
  48. package/dist/os/os-commands.js.map +1 -1
  49. package/dist/os/windows-gitbash.d.ts +93 -0
  50. package/dist/os/windows-gitbash.d.ts.map +1 -0
  51. package/dist/os/windows-gitbash.js +244 -0
  52. package/dist/os/windows-gitbash.js.map +1 -0
  53. package/dist/os/windows.d.ts.map +1 -1
  54. package/dist/os/windows.js +27 -5
  55. package/dist/os/windows.js.map +1 -1
  56. package/dist/providers/agy.d.ts +3 -2
  57. package/dist/providers/agy.d.ts.map +1 -1
  58. package/dist/providers/agy.js +11 -2
  59. package/dist/providers/agy.js.map +1 -1
  60. package/dist/providers/claude.d.ts +3 -2
  61. package/dist/providers/claude.d.ts.map +1 -1
  62. package/dist/providers/claude.js +22 -3
  63. package/dist/providers/claude.js.map +1 -1
  64. package/dist/providers/codex.d.ts +3 -2
  65. package/dist/providers/codex.d.ts.map +1 -1
  66. package/dist/providers/codex.js +5 -2
  67. package/dist/providers/codex.js.map +1 -1
  68. package/dist/providers/copilot.d.ts +3 -2
  69. package/dist/providers/copilot.d.ts.map +1 -1
  70. package/dist/providers/copilot.js +7 -2
  71. package/dist/providers/copilot.js.map +1 -1
  72. package/dist/providers/index.d.ts +0 -1
  73. package/dist/providers/index.d.ts.map +1 -1
  74. package/dist/providers/index.js +0 -3
  75. package/dist/providers/index.js.map +1 -1
  76. package/dist/providers/none.d.ts +3 -2
  77. package/dist/providers/none.d.ts.map +1 -1
  78. package/dist/providers/none.js +5 -2
  79. package/dist/providers/none.js.map +1 -1
  80. package/dist/providers/opencode.d.ts +3 -2
  81. package/dist/providers/opencode.d.ts.map +1 -1
  82. package/dist/providers/opencode.js +5 -2
  83. package/dist/providers/opencode.js.map +1 -1
  84. package/dist/providers/provider.d.ts +16 -7
  85. package/dist/providers/provider.d.ts.map +1 -1
  86. package/dist/providers/provider.js +2 -2
  87. package/dist/providers/provider.js.map +1 -1
  88. package/dist/services/agent-provisioner.js +2 -2
  89. package/dist/services/agent-provisioner.js.map +1 -1
  90. package/dist/services/cloud/activity.js +2 -2
  91. package/dist/services/cloud/activity.js.map +1 -1
  92. package/dist/services/context-admission.d.ts.map +1 -1
  93. package/dist/services/context-admission.js +9 -7
  94. package/dist/services/context-admission.js.map +1 -1
  95. package/dist/services/credential-cleanup.d.ts.map +1 -1
  96. package/dist/services/credential-cleanup.js +22 -3
  97. package/dist/services/credential-cleanup.js.map +1 -1
  98. package/dist/services/member-home.d.ts +1 -1
  99. package/dist/services/member-home.d.ts.map +1 -1
  100. package/dist/services/member-home.js +15 -12
  101. package/dist/services/member-home.js.map +1 -1
  102. package/dist/services/model-pricing.d.ts.map +1 -1
  103. package/dist/services/model-pricing.js +0 -5
  104. package/dist/services/model-pricing.js.map +1 -1
  105. package/dist/services/orphan-recovery.d.ts +6 -3
  106. package/dist/services/orphan-recovery.d.ts.map +1 -1
  107. package/dist/services/orphan-recovery.js +17 -14
  108. package/dist/services/orphan-recovery.js.map +1 -1
  109. package/dist/services/preflight-check.js +2 -2
  110. package/dist/services/preflight-check.js.map +1 -1
  111. package/dist/services/shell-probe.d.ts +131 -0
  112. package/dist/services/shell-probe.d.ts.map +1 -0
  113. package/dist/services/shell-probe.js +210 -0
  114. package/dist/services/shell-probe.js.map +1 -0
  115. package/dist/services/singleton.d.ts +2 -0
  116. package/dist/services/singleton.d.ts.map +1 -1
  117. package/dist/services/singleton.js +1 -1
  118. package/dist/services/singleton.js.map +1 -1
  119. package/dist/services/ssh.js +2 -2
  120. package/dist/services/ssh.js.map +1 -1
  121. package/dist/services/stall/find-log-file.d.ts.map +1 -1
  122. package/dist/services/stall/find-log-file.js +22 -16
  123. package/dist/services/stall/find-log-file.js.map +1 -1
  124. package/dist/services/stall/read-log-tail.d.ts.map +1 -1
  125. package/dist/services/stall/read-log-tail.js +6 -5
  126. package/dist/services/stall/read-log-tail.js.map +1 -1
  127. package/dist/services/stall/stall-poller.d.ts.map +1 -1
  128. package/dist/services/stall/stall-poller.js +35 -42
  129. package/dist/services/stall/stall-poller.js.map +1 -1
  130. package/dist/services/strategy.d.ts +9 -0
  131. package/dist/services/strategy.d.ts.map +1 -1
  132. package/dist/services/strategy.js +40 -6
  133. package/dist/services/strategy.js.map +1 -1
  134. package/dist/services/user-config.js +1 -1
  135. package/dist/services/user-config.js.map +1 -1
  136. package/dist/services/vcs/azure-devops.d.ts +1 -1
  137. package/dist/services/vcs/azure-devops.d.ts.map +1 -1
  138. package/dist/services/vcs/azure-devops.js +105 -10
  139. package/dist/services/vcs/azure-devops.js.map +1 -1
  140. package/dist/services/vcs/bitbucket.d.ts.map +1 -1
  141. package/dist/services/vcs/bitbucket.js +16 -0
  142. package/dist/services/vcs/bitbucket.js.map +1 -1
  143. package/dist/services/vcs/github.d.ts.map +1 -1
  144. package/dist/services/vcs/github.js +24 -0
  145. package/dist/services/vcs/github.js.map +1 -1
  146. package/dist/services/vcs/types.d.ts +123 -2
  147. package/dist/services/vcs/types.d.ts.map +1 -1
  148. package/dist/skills/fleet-sprint-cli/SKILL.md +2 -1
  149. package/dist/skills/pm/SKILL.md +0 -1
  150. package/dist/skills/pm/cost.md +0 -1
  151. package/dist/skills/pm/fleet-addendum.md +0 -1
  152. package/dist/tools/check-status.js +3 -3
  153. package/dist/tools/check-status.js.map +1 -1
  154. package/dist/tools/cloud-control.js +2 -2
  155. package/dist/tools/cloud-control.js.map +1 -1
  156. package/dist/tools/compose-permissions.d.ts.map +1 -1
  157. package/dist/tools/compose-permissions.js +37 -24
  158. package/dist/tools/compose-permissions.js.map +1 -1
  159. package/dist/tools/execute-command.d.ts.map +1 -1
  160. package/dist/tools/execute-command.js +28 -12
  161. package/dist/tools/execute-command.js.map +1 -1
  162. package/dist/tools/execute-prompt.d.ts.map +1 -1
  163. package/dist/tools/execute-prompt.js +55 -18
  164. package/dist/tools/execute-prompt.js.map +1 -1
  165. package/dist/tools/list-members.d.ts.map +1 -1
  166. package/dist/tools/list-members.js +6 -2
  167. package/dist/tools/list-members.js.map +1 -1
  168. package/dist/tools/member-detail.d.ts.map +1 -1
  169. package/dist/tools/member-detail.js +5 -3
  170. package/dist/tools/member-detail.js.map +1 -1
  171. package/dist/tools/member-reservation.d.ts.map +1 -1
  172. package/dist/tools/member-reservation.js +13 -1
  173. package/dist/tools/member-reservation.js.map +1 -1
  174. package/dist/tools/monitor-task.d.ts.map +1 -1
  175. package/dist/tools/monitor-task.js +17 -2
  176. package/dist/tools/monitor-task.js.map +1 -1
  177. package/dist/tools/provision-auth.js +5 -5
  178. package/dist/tools/provision-auth.js.map +1 -1
  179. package/dist/tools/provision-vcs-auth.d.ts +5 -2
  180. package/dist/tools/provision-vcs-auth.d.ts.map +1 -1
  181. package/dist/tools/provision-vcs-auth.js +58 -52
  182. package/dist/tools/provision-vcs-auth.js.map +1 -1
  183. package/dist/tools/register-member.d.ts +18 -12
  184. package/dist/tools/register-member.d.ts.map +1 -1
  185. package/dist/tools/register-member.js +42 -4
  186. package/dist/tools/register-member.js.map +1 -1
  187. package/dist/tools/remove-member.js +2 -2
  188. package/dist/tools/remove-member.js.map +1 -1
  189. package/dist/tools/revoke-vcs-auth.js +2 -2
  190. package/dist/tools/revoke-vcs-auth.js.map +1 -1
  191. package/dist/tools/setup-ssh-key.d.ts.map +1 -1
  192. package/dist/tools/setup-ssh-key.js +2 -1
  193. package/dist/tools/setup-ssh-key.js.map +1 -1
  194. package/dist/tools/stop-prompt.js +2 -2
  195. package/dist/tools/stop-prompt.js.map +1 -1
  196. package/dist/tools/update-agent-cli.js +2 -2
  197. package/dist/tools/update-agent-cli.js.map +1 -1
  198. package/dist/tools/update-member.d.ts +18 -12
  199. package/dist/tools/update-member.d.ts.map +1 -1
  200. package/dist/tools/update-member.js +18 -1
  201. package/dist/tools/update-member.js.map +1 -1
  202. package/dist/types.d.ts +11 -1
  203. package/dist/types.d.ts.map +1 -1
  204. package/dist/utils/agent-helpers.d.ts +36 -0
  205. package/dist/utils/agent-helpers.d.ts.map +1 -1
  206. package/dist/utils/agent-helpers.js +39 -1
  207. package/dist/utils/agent-helpers.js.map +1 -1
  208. package/dist/utils/platform.d.ts +7 -0
  209. package/dist/utils/platform.d.ts.map +1 -1
  210. package/dist/utils/platform.js +11 -1
  211. package/dist/utils/platform.js.map +1 -1
  212. package/dist/utils/workspace-trust.d.ts.map +1 -1
  213. package/dist/utils/workspace-trust.js +5 -1
  214. package/dist/utils/workspace-trust.js.map +1 -1
  215. package/dist/workflows/auto-sprint.js +4 -17
  216. package/package.json +2 -2
  217. package/packages/apra-fleet-client/src/client/api.mjs +92 -3
  218. package/packages/apra-fleet-se/apra-pm/agents/backlog-groomer.md +17 -21
  219. package/packages/apra-fleet-se/apra-pm/agents/ci-watcher.md +3 -0
  220. package/packages/apra-fleet-se/apra-pm/agents/deployer.md +22 -44
  221. package/packages/apra-fleet-se/apra-pm/agents/doer.md +131 -132
  222. package/packages/apra-fleet-se/apra-pm/agents/harvester.md +20 -32
  223. package/packages/apra-fleet-se/apra-pm/agents/integ-test-runner.md +81 -113
  224. package/packages/apra-fleet-se/apra-pm/agents/kb-reconciler.md +31 -42
  225. package/packages/apra-fleet-se/apra-pm/agents/plan-reviewer.md +32 -44
  226. package/packages/apra-fleet-se/apra-pm/agents/planner.md +51 -63
  227. package/packages/apra-fleet-se/apra-pm/agents/regression-test-runner.md +65 -80
  228. package/packages/apra-fleet-se/apra-pm/agents/reviewer.md +56 -83
  229. package/packages/apra-fleet-se/apra-pm/agents/schemas/integ-test-runner-output.json +1 -1
  230. package/packages/apra-fleet-se/apra-pm/agents/schemas/regression-test-runner-output.json +4 -17
  231. package/packages/apra-fleet-se/apra-pm/skills/pm/SKILL.md +0 -1
  232. package/packages/apra-fleet-se/apra-pm/skills/pm/cost.md +0 -1
  233. package/packages/apra-fleet-se/apra-pm/skills/pm/fleet-addendum.md +0 -1
  234. package/packages/apra-fleet-se/bin/cli.mjs +132 -3
  235. package/packages/apra-fleet-se/bin/serve.mjs +36 -1
  236. package/packages/apra-fleet-se/fleet-sprint/contracts.mjs +151 -33
  237. package/packages/apra-fleet-se/fleet-sprint/docs/README.md +22 -7
  238. package/packages/apra-fleet-se/fleet-sprint/docs/dolt-manual-recovery-verified.md +10 -8
  239. package/packages/apra-fleet-se/fleet-sprint/docs/dolt-sync-redesign.md +9 -4
  240. package/packages/apra-fleet-se/fleet-sprint/docs/escalate-to-llm-design.md +2 -2
  241. package/packages/apra-fleet-se/fleet-sprint/docs/shared-orchestrator-reservation-design.md +12 -12
  242. package/packages/apra-fleet-se/fleet-sprint/docs/stabilization-log.md +14 -4
  243. package/packages/apra-fleet-se/fleet-sprint/dolt-settle.mjs +275 -99
  244. package/packages/apra-fleet-se/fleet-sprint/dolt-sync.mjs +67 -16
  245. package/packages/apra-fleet-se/fleet-sprint/errors.mjs +41 -0
  246. package/packages/apra-fleet-se/fleet-sprint/runner.js +1140 -209
  247. package/packages/apra-fleet-se/fleet-sprint/se-os-commands.mjs +134 -0
  248. package/packages/apra-fleet-se/fleet-sprint/se-posix.mjs +154 -0
  249. package/packages/apra-fleet-se/fleet-sprint/se-windows-gitbash.mjs +97 -0
  250. package/packages/apra-fleet-se/fleet-sprint/se-windows.mjs +143 -0
  251. package/packages/apra-fleet-se/fleet-sprint/skills/fleet-sprint-cli/SKILL.md +2 -1
  252. package/packages/apra-fleet-se/fleet-sprint/vcs-module.mjs +51 -0
  253. package/packages/apra-fleet-se/fleet-sprint/vcs-providers/azure-devops.mjs +657 -12
  254. package/packages/apra-fleet-se/fleet-sprint/vcs-providers/dolt.mjs +33 -4
  255. package/packages/apra-fleet-se/fleet-sprint/vcs-providers/github.mjs +60 -43
  256. package/packages/apra-fleet-se/fleet-sprint/vcs-providers/index.mjs +205 -2
  257. package/packages/apra-fleet-se/fleet-sprint/vcs-providers/shell-helpers.mjs +164 -0
  258. package/packages/apra-fleet-se/fleet-sprint/viewer-extensions.mjs +92 -37
  259. package/packages/apra-fleet-workflow/src/viewer/index.mjs +167 -1
  260. package/packages/apra-fleet-workflow/src/workflow/index.mjs +435 -31
  261. package/skills/fleet/SKILL.md +20 -9
  262. package/skills/fleet/auth-azdevops.md +44 -5
  263. package/skills/fleet/auth-bitbucket.md +3 -3
  264. package/skills/fleet/auth-github.md +2 -2
  265. package/skills/fleet/beads-conflict-resolution.md +141 -0
  266. package/skills/fleet/beads.md +16 -12
  267. package/skills/fleet/onboarding.md +4 -4
  268. package/skills/fleet/permissions.md +6 -6
  269. package/skills/fleet/skill-matrix.md +1 -1
  270. package/skills/fleet/troubleshooting.md +2 -1
  271. package/version.json +1 -1
  272. package/dist/providers/gemini.d.ts +0 -52
  273. package/dist/providers/gemini.d.ts.map +0 -1
  274. package/dist/providers/gemini.js +0 -236
  275. package/dist/providers/gemini.js.map +0 -1
  276. package/packages/apra-fleet-se/fleet-sprint/docs/coach-role-design.md +0 -23
@@ -227,8 +227,30 @@ export async function isMemberSyncRemoteConfigured(member, opts) {
227
227
  // instant re-issue -- the previous code retried with zero delay, which turned
228
228
  // the bound into "fail twice as fast". Delay is attempt-indexed and capped, and
229
229
  // `sleep` is injectable so unit suites never actually wait.
230
+ //
231
+ // apra-fleet-ka1u follow-up: a live Windows machine-wide git.exe spawn outage
232
+ // (fork/exec ... "Not enough memory resources") was directly measured to last
233
+ // 1-3 MINUTES per occurrence (fleet supervisor log analysis), during which
234
+ // essentially every dolt-initiated git spawn fails -- not an isolated blip.
235
+ // The original 8s cap meant even 5 retries covered at most ~15s of backoff,
236
+ // structurally unable to span an outage an order of magnitude longer; the
237
+ // sprint kept dying with retries correctly firing but exhausted. Raised to
238
+ // 30s so a realistic retry budget (see maxTransientRetries below) can
239
+ // actually outlast one of these windows instead of just softening it.
230
240
  const DOLT_BACKOFF_BASE_MS = 500;
231
- const DOLT_BACKOFF_MAX_MS = 8000;
241
+ const DOLT_BACKOFF_MAX_MS = 30000;
242
+
243
+ // apra-fleet-jxdf.2: every `bd dolt pull`/`bd dolt push` this module issues
244
+ // used to inherit whatever generic default the injected command() primitive
245
+ // falls back to when no timeout is specified (120s, sized for an ordinary
246
+ // shell command, not a Dolt sync). A live incident confirmed an INCREMENTAL
247
+ // pull against an already-cloned, several-hundred-MB embedded Dolt DB can
248
+ // take multiple minutes -- an order of magnitude past that default -- and
249
+ // every one of those pulls was timing out, silently, every single time,
250
+ // with no fatal error surfaced and the caller left reading stale data. Size
251
+ // this for realistic Dolt DB sizes in this fleet, not a toy DB; callers that
252
+ // need a different budget can still override via opts.timeoutS.
253
+ const DOLT_STEP_TIMEOUT_S = 600;
232
254
 
233
255
  /**
234
256
  * Delay before transient retry #`attempt` (1-based): base * 2^(attempt-1),
@@ -279,12 +301,12 @@ const defaultSleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
279
301
  *
280
302
  * @returns {Promise<{ ok: boolean, output: string, error: string|null, kind?: 'no-remote'|'empty-remote'|'remote-unreachable'|'diverged'|'auth'|'transient'|'unknown' }>}
281
303
  */
282
- async function runDoltStep({ command, member, cmd, label, log, maxTransientRetries, onAuthFailure, sleep = defaultSleep, backoffBaseMs = DOLT_BACKOFF_BASE_MS }) {
304
+ async function runDoltStep({ command, member, cmd, label, log, maxTransientRetries, onAuthFailure, sleep = defaultSleep, backoffBaseMs = DOLT_BACKOFF_BASE_MS, timeoutS = DOLT_STEP_TIMEOUT_S }) {
283
305
  let attempt = 0;
284
306
  let authHealAttempted = false;
285
307
  // eslint-disable-next-line no-constant-condition
286
308
  while (true) {
287
- const res = await command(cmd, { member_name: member, silent: true, failSoft: true, label });
309
+ const res = await command(cmd, { member_name: member, silent: true, failSoft: true, label, timeout_s: timeoutS });
288
310
  if (res && res.ok) return res;
289
311
  const error = res ? res.error : 'unknown command failure';
290
312
  const kind = classifyDoltFailure(error);
@@ -302,11 +324,22 @@ async function runDoltStep({ command, member, cmd, label, log, maxTransientRetri
302
324
  await onAuthFailure({ member, label, cmd, error, kind: 'dolt' });
303
325
  } catch (healErr) {
304
326
  log(`[Dolt] self-heal for member '${member}' (${label}) failed; not retrying further: ${healErr.message}`);
327
+ log(`[Dolt] ${label} FAILED (${kind}) -- reads/writes for member '${member}' may be stale until this is resolved. Raw: ${error}`);
305
328
  return { ok: false, output: res ? res.output : '', error, kind };
306
329
  }
307
330
  log(`[Dolt] self-heal for member '${member}' (${label}) completed; retrying the failed dolt command once.`);
308
331
  continue;
309
332
  }
333
+ // apra-fleet-jxdf.2: every non-ok exit from this function used to be
334
+ // reported ONLY as a structured return value -- a caller on the
335
+ // fatal:false path (the common case, e.g. refreshView's documented
336
+ // "never throws" contract) could silently proceed on stale data with
337
+ // no trace of this failure anywhere in the sprint log. Log it loudly
338
+ // here, once, at the single choke point every D-pull/D-push passes
339
+ // through, so a degraded read/write is always visible to whoever is
340
+ // watching a live sprint -- independent of whether the caller treats
341
+ // it as fatal.
342
+ log(`[Dolt] ${label} FAILED (${kind}) -- reads/writes for member '${member}' may be stale until this is resolved. Raw: ${error}`);
310
343
  return { ok: false, output: res ? res.output : '', error, kind };
311
344
  }
312
345
  }
@@ -382,7 +415,7 @@ async function attemptSettle({ settle, member, operation, error, log }) {
382
415
  }
383
416
 
384
417
  export async function doltPullBefore(member, opts = {}) {
385
- const { command, log = () => {}, maxTransientRetries = 1, checkSyncRemoteConfigured, skipPull = false, onAuthFailure, sleep, backoffBaseMs, settle } = opts;
418
+ const { command, log = () => {}, maxTransientRetries = 8, checkSyncRemoteConfigured, skipPull = false, onAuthFailure, sleep, backoffBaseMs, timeoutS, settle } = opts;
386
419
  if (typeof command !== 'function') {
387
420
  throw new Error("doltPullBefore requires an injected command() in opts");
388
421
  }
@@ -405,7 +438,7 @@ export async function doltPullBefore(member, opts = {}) {
405
438
 
406
439
  const pull = await runDoltStep({
407
440
  command, member, cmd: 'bd dolt pull',
408
- label: `D-pull for '${member}'`, log, maxTransientRetries, onAuthFailure, sleep, backoffBaseMs,
441
+ label: `D-pull for '${member}'`, log, maxTransientRetries, onAuthFailure, sleep, backoffBaseMs, timeoutS,
409
442
  });
410
443
  if (!pull.ok) {
411
444
  if (pull.kind === 'no-remote') {
@@ -596,7 +629,7 @@ export async function preflightBeadsHealthGate(member, opts = {}) {
596
629
  * @returns {Promise<{ ok: true, member: string, pushed: boolean, reconciled: boolean, skipped?: true, reason?: 'no-remote', recovered?: true, settledTables?: string[] }>}
597
630
  */
598
631
  export async function doltPushAfter(member, opts = {}) {
599
- const { command, pushBeads = true, log = () => {}, maxTransientRetries = 1, mutex, sprintId, checkSyncRemoteConfigured, onAuthFailure, sleep, backoffBaseMs, settle, renewIntervalMs = DOLT_MUTEX_RENEW_INTERVAL_MS } = opts;
632
+ const { command, pushBeads = true, log = () => {}, maxTransientRetries = 8, mutex, sprintId, checkSyncRemoteConfigured, onAuthFailure, sleep, backoffBaseMs, timeoutS, settle, renewIntervalMs = DOLT_MUTEX_RENEW_INTERVAL_MS } = opts;
600
633
  if (typeof command !== 'function') {
601
634
  throw new Error("doltPushAfter requires an injected command() in opts");
602
635
  }
@@ -613,7 +646,14 @@ export async function doltPushAfter(member, opts = {}) {
613
646
  // suppress a push that was already declared must not happen. The
614
647
  // failure-path downgrade below stays as defense in depth.
615
648
  const preGateCheckFn = checkSyncRemoteConfigured || isMemberSyncRemoteConfigured;
616
- if (!(await preGateCheckFn(member, { command, log }))) {
649
+ // apra-fleet-7h6n.5: cache the pre-gate's boolean result so the
650
+ // failure-path downgrade below (which used to re-invoke the same probe a
651
+ // second time in this call) can reuse it instead of re-probing. By the
652
+ // time the failure path runs, this pre-gate has already returned `true`
653
+ // (a `false` result exits right here), so reusing it there is
654
+ // behavior-preserving, not a new assumption.
655
+ const syncRemoteConfiguredAtPreGate = await preGateCheckFn(member, { command, log });
656
+ if (!syncRemoteConfiguredAtPreGate) {
617
657
  log(`[Dolt] D-push for member '${member}' skipped pre-attempt: bd-level sync.remote neutralized/absent -- no push command issued`);
618
658
  return { ok: true, member, pushed: false, reconciled: false, skipped: true, reason: 'no-remote' };
619
659
  }
@@ -683,7 +723,7 @@ export async function doltPushAfter(member, opts = {}) {
683
723
  async function doltPushGuarded() {
684
724
  let push = await runDoltStep({
685
725
  command, member, cmd: 'bd dolt push',
686
- label: `D-push for '${member}'`, log, maxTransientRetries, onAuthFailure, sleep, backoffBaseMs,
726
+ label: `D-push for '${member}'`, log, maxTransientRetries, onAuthFailure, sleep, backoffBaseMs, timeoutS,
687
727
  });
688
728
  if (push.ok) {
689
729
  return { ok: true, member, pushed: true, reconciled: false };
@@ -702,8 +742,11 @@ export async function doltPushAfter(member, opts = {}) {
702
742
  // misclassify a neutralized-sandbox failure as 'unknown'). An
703
743
  // absent sync.remote means nothing is supposed to be pushed from this
704
744
  // clone, so the failure is the same benign no-remote skip.
705
- const checkFn = checkSyncRemoteConfigured || isMemberSyncRemoteConfigured;
706
- const syncRemoteConfigured = await checkFn(member, { command, log });
745
+ // apra-fleet-7h6n.5: reuse the pre-gate's cached probe result instead
746
+ // of re-invoking checkSyncRemoteConfigured/isMemberSyncRemoteConfigured
747
+ // a second time -- see the pre-gate's comment above for why this is
748
+ // always `true` by the time this failure path is reachable.
749
+ const syncRemoteConfigured = syncRemoteConfiguredAtPreGate;
707
750
  if (!syncRemoteConfigured) {
708
751
  log(`[Dolt] D-push for member '${member}' skipped: no dolt remote configured (bd-level sync.remote neutralized/absent; push failure treated as benign: ${push.error})`);
709
752
  return { ok: true, member, pushed: false, reconciled: false, skipped: true, reason: 'no-remote' };
@@ -738,7 +781,7 @@ export async function doltPushAfter(member, opts = {}) {
738
781
  log(`[Dolt] D-push for member '${member}' was rejected (another writer pushed first); reconciling with a single D-pull then one re-push (first-successful-pusher-wins).`);
739
782
  const reconcile = await runDoltStep({
740
783
  command, member, cmd: 'bd dolt pull',
741
- label: `D-push reconcile pull for '${member}'`, log, maxTransientRetries, onAuthFailure, sleep, backoffBaseMs,
784
+ label: `D-push reconcile pull for '${member}'`, log, maxTransientRetries, onAuthFailure, sleep, backoffBaseMs, timeoutS,
742
785
  });
743
786
  if (!reconcile.ok) {
744
787
  if (reconcile.kind === 'diverged') {
@@ -758,7 +801,7 @@ export async function doltPushAfter(member, opts = {}) {
758
801
 
759
802
  push = await runDoltStep({
760
803
  command, member, cmd: 'bd dolt push',
761
- label: `D-push re-push after reconcile for '${member}'`, log, maxTransientRetries, onAuthFailure, sleep, backoffBaseMs,
804
+ label: `D-push re-push after reconcile for '${member}'`, log, maxTransientRetries, onAuthFailure, sleep, backoffBaseMs, timeoutS,
762
805
  });
763
806
  if (push.ok) {
764
807
  return { ok: true, member, pushed: true, reconciled: true };
@@ -1083,7 +1126,9 @@ async function runDegradable(run, ctx) {
1083
1126
  *
1084
1127
  * All other opts are passed through unchanged to doltPullBefore():
1085
1128
  * `command` (required), `log`, `maxTransientRetries`, `onAuthFailure`,
1086
- * `checkSyncRemoteConfigured`, `sleep`, `backoffBaseMs`.
1129
+ * `checkSyncRemoteConfigured`, `sleep`, `backoffBaseMs`, `timeoutS` (defaults
1130
+ * to DOLT_STEP_TIMEOUT_S -- override only for a call site with a known-
1131
+ * different Dolt DB size/latency profile).
1087
1132
  *
1088
1133
  * @param {string} member
1089
1134
  * @param {{ command: Function, readinessGate?: boolean, fatal?: boolean, onDegraded?: Function, log?: Function, maxTransientRetries?: number, checkSyncRemoteConfigured?: Function, skipRefresh?: boolean, onAuthFailure?: Function, sleep?: Function, backoffBaseMs?: number }} opts
@@ -1267,18 +1312,24 @@ export function flush(filter = {}) {
1267
1312
  * `platform`/`arch` are optional and probed from the member when absent.
1268
1313
  * `opts.settle` may be supplied to override the callback (tests do this).
1269
1314
  *
1315
+ * `opts.shell` threads the member's REGISTERED shell into dolt-settle
1316
+ * (apra-fleet-7dir.16/.24) the same way every other buildSettleCallback call
1317
+ * site does -- omitted (defaulting to '', the PowerShell dialect on
1318
+ * Windows) is the pre-shell-aware behavior, not a regression, for any
1319
+ * caller that has not resolved it.
1320
+ *
1270
1321
  * @param {string} member
1271
- * @param {{ command?: Function, log?: Function, platform?: string, arch?: string, settle?: Function, [key: string]: any }} [opts]
1322
+ * @param {{ command?: Function, log?: Function, platform?: string, arch?: string, shell?: string, settle?: Function, [key: string]: any }} [opts]
1272
1323
  * @returns {Promise<{ repaired: boolean, escalation?: string, result?: object }>}
1273
1324
  */
1274
1325
  export async function repair(member, opts = {}) {
1275
- const { command, log = () => {}, platform, arch } = opts;
1326
+ const { command, log = () => {}, platform, arch, shell = '' } = opts;
1276
1327
  if (typeof command !== 'function') {
1277
1328
  return { repaired: false, escalation: 'not-configured: repair() requires an injected command() to run settle' };
1278
1329
  }
1279
1330
  const settle = typeof opts.settle === 'function'
1280
1331
  ? opts.settle
1281
- : buildSettleCallback(member, { command, log, platform, arch });
1332
+ : buildSettleCallback(member, { command, log, platform, arch, shell });
1282
1333
  let result = null;
1283
1334
  try {
1284
1335
  result = await settle({ operation: 'repair' });
@@ -614,3 +614,44 @@ export class PostDispatchSyncError extends WorkflowError {
614
614
  export function isPostDispatchSyncFailure(err) {
615
615
  return err instanceof PostDispatchSyncError;
616
616
  }
617
+
618
+ // ---------------------------------------------------------------------------
619
+ // apra-fleet-p2to.4.2 -- resume could not re-reserve every member
620
+ // ---------------------------------------------------------------------------
621
+
622
+ /**
623
+ * Thrown when a cooperative resume (after a pause released this sprint's member
624
+ * reservations) cannot re-acquire one or more members because another sprint
625
+ * claimed them while this one was paused -- an OWNER-CHECKED re-reserve, so we
626
+ * refuse to silently continue on top of a member some other sprint now owns.
627
+ *
628
+ * The whole point of this error is that it NAMES the unavailable members, so an
629
+ * operator reading the failed resume knows exactly which members to free (or
630
+ * which other sprint to stop) before retrying the resume -- rather than a
631
+ * generic "resume failed" with no actionable detail.
632
+ *
633
+ * @property {string[]} members - the members that could NOT be re-reserved on
634
+ * resume (each already reserved by a different sprint).
635
+ */
636
+ export class MemberReservationResumeError extends WorkflowError {
637
+ /**
638
+ * @param {string[]} unavailableMembers
639
+ * @param {{ details?: object, cause?: unknown }} [opts]
640
+ */
641
+ constructor(unavailableMembers = [], opts = {}) {
642
+ const members = Array.isArray(unavailableMembers) ? unavailableMembers : [];
643
+ const { details, cause } = opts;
644
+ super(
645
+ `[Workflow Error] Resume failed: could not re-reserve ${members.length} member(s) ` +
646
+ `released at pause -- ${members.join(', ')} ` +
647
+ `${members.length === 1 ? 'is' : 'are'} now reserved by another sprint. ` +
648
+ `Free ${members.length === 1 ? 'it' : 'them'} (or stop the other sprint) before resuming.`,
649
+ {
650
+ code: 'MEMBER_RESERVATION_RESUME_FAILED',
651
+ details: { members, ...details },
652
+ cause,
653
+ }
654
+ );
655
+ this.members = members;
656
+ }
657
+ }