@apralabs/apra-fleet 0.4.4 → 0.4.5

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 (268) hide show
  1. package/README.md +49 -4
  2. package/dist/agents/backlog-groomer.md +5 -0
  3. package/dist/agents/ci-watcher.md +5 -0
  4. package/dist/agents/deployer.md +20 -2
  5. package/dist/agents/doer.md +38 -2
  6. package/dist/agents/harvester.md +12 -9
  7. package/dist/agents/integ-test-runner.md +5 -0
  8. package/dist/agents/kb-reconciler.md +6 -0
  9. package/dist/agents/plan-reviewer.md +5 -0
  10. package/dist/agents/planner.md +5 -0
  11. package/dist/agents/regression-test-runner.md +5 -0
  12. package/dist/agents/reviewer.md +67 -15
  13. package/dist/agents/schemas/deployer-output.json +5 -0
  14. package/dist/agents/schemas/doer-output.json +78 -2
  15. package/dist/agents/schemas/reviewer-output.json +104 -2
  16. package/dist/cli/auth.js +5 -1
  17. package/dist/cli/beads-pin.js +6 -7
  18. package/dist/cli/claude-mod.d.ts +75 -0
  19. package/dist/cli/claude-mod.js +288 -0
  20. package/dist/cli/dolt-install.d.ts +1 -1
  21. package/dist/cli/dolt-install.js +5 -1
  22. package/dist/cli/fleet-se-guard.d.ts +8 -0
  23. package/dist/cli/fleet-se-guard.js +19 -3
  24. package/dist/cli/install-guard.d.ts +9 -0
  25. package/dist/cli/install-guard.js +24 -0
  26. package/dist/cli/install.d.ts +12 -0
  27. package/dist/cli/install.js +180 -20
  28. package/dist/cli/kb-profile.d.ts +16 -0
  29. package/dist/cli/kb-profile.js +81 -0
  30. package/dist/cli/start.js +3 -0
  31. package/dist/cli/uninstall.js +13 -3
  32. package/dist/cli/update.d.ts +4 -0
  33. package/dist/cli/update.js +19 -3
  34. package/dist/commands/kb-server.d.ts +10 -1
  35. package/dist/commands/kb-server.js +285 -11
  36. package/dist/index.js +22 -1
  37. package/dist/os/git-executable.d.ts +57 -0
  38. package/dist/os/git-executable.js +85 -0
  39. package/dist/os/go-concurrency.d.ts +44 -0
  40. package/dist/os/go-concurrency.js +53 -0
  41. package/dist/os/index.d.ts +1 -0
  42. package/dist/os/index.js +1 -0
  43. package/dist/os/linux.d.ts +2 -0
  44. package/dist/os/linux.js +10 -1
  45. package/dist/os/os-commands.d.ts +25 -0
  46. package/dist/os/os-commands.js +2 -0
  47. package/dist/os/windows-executable.d.ts +53 -0
  48. package/dist/os/windows-executable.js +185 -0
  49. package/dist/os/windows-gitbash.d.ts +23 -14
  50. package/dist/os/windows-gitbash.js +40 -16
  51. package/dist/os/windows.d.ts +2 -0
  52. package/dist/os/windows.js +37 -6
  53. package/dist/paths.d.ts +10 -1
  54. package/dist/paths.js +19 -2
  55. package/dist/services/agy-project.d.ts +7 -1
  56. package/dist/services/agy-project.js +7 -2
  57. package/dist/services/auth-socket.d.ts +18 -0
  58. package/dist/services/auth-socket.js +30 -4
  59. package/dist/services/credential-store.d.ts +33 -0
  60. package/dist/services/credential-store.js +79 -2
  61. package/dist/services/http-transport.d.ts +29 -0
  62. package/dist/services/http-transport.js +166 -37
  63. package/dist/services/kb-tool-profile.d.ts +36 -0
  64. package/dist/services/kb-tool-profile.js +88 -0
  65. package/dist/services/knowledge/bible-blob-id.js +10 -1
  66. package/dist/services/knowledge/bible-import.d.ts +108 -0
  67. package/dist/services/knowledge/bible-import.js +137 -4
  68. package/dist/services/knowledge/file-hash.js +6 -5
  69. package/dist/services/knowledge/http-provider.d.ts +303 -20
  70. package/dist/services/knowledge/http-provider.js +795 -125
  71. package/dist/services/knowledge/kb-config.d.ts +65 -1
  72. package/dist/services/knowledge/kb-config.js +143 -3
  73. package/dist/services/knowledge/kb-http-auth-state.d.ts +26 -0
  74. package/dist/services/knowledge/kb-http-auth-state.js +40 -0
  75. package/dist/services/knowledge/kb-providers.d.ts +9 -2
  76. package/dist/services/knowledge/kb-providers.js +67 -37
  77. package/dist/services/knowledge/kb-removed-scope-keys.js +1 -1
  78. package/dist/services/knowledge/kb-self.d.ts +122 -9
  79. package/dist/services/knowledge/kb-self.js +196 -36
  80. package/dist/services/knowledge/member-bible-view.js +16 -3
  81. package/dist/services/knowledge/path-validation.d.ts +7 -0
  82. package/dist/services/knowledge/path-validation.js +11 -0
  83. package/dist/services/knowledge/project-slug.js +3 -2
  84. package/dist/services/knowledge/repository-header.d.ts +77 -0
  85. package/dist/services/knowledge/repository-header.js +233 -0
  86. package/dist/services/knowledge/require-sqlite-project.d.ts +1 -1
  87. package/dist/services/knowledge/require-sqlite-project.js +1 -1
  88. package/dist/services/knowledge/sqlite-provider.d.ts +169 -0
  89. package/dist/services/knowledge/sqlite-provider.js +416 -4
  90. package/dist/services/knowledge/types.d.ts +15 -2
  91. package/dist/services/member-busy.d.ts +12 -0
  92. package/dist/services/member-busy.js +20 -0
  93. package/dist/services/member-config-io.d.ts +3 -2
  94. package/dist/services/member-config-io.js +7 -4
  95. package/dist/services/member-fleet-install.js +1 -0
  96. package/dist/services/member-tool-allowlist.d.ts +1 -1
  97. package/dist/services/member-tool-allowlist.js +8 -4
  98. package/dist/services/port-holder.js +2 -1
  99. package/dist/services/service-manager/types.d.ts +17 -1
  100. package/dist/services/service-manager/windows.d.ts +7 -2
  101. package/dist/services/service-manager/windows.js +28 -11
  102. package/dist/services/service-notice.d.ts +7 -0
  103. package/dist/services/service-notice.js +19 -0
  104. package/dist/services/session-registry.d.ts +13 -0
  105. package/dist/services/session-registry.js +13 -0
  106. package/dist/services/session-roots.d.ts +67 -0
  107. package/dist/services/session-roots.js +126 -0
  108. package/dist/services/statusline.d.ts +21 -0
  109. package/dist/services/statusline.js +97 -1
  110. package/dist/services/supervisor-service-cleanup.js +2 -1
  111. package/dist/services/tool-registry.js +108 -20
  112. package/dist/services/tool-scope.d.ts +34 -1
  113. package/dist/services/tool-scope.js +27 -2
  114. package/dist/services/vcs/azure-devops.js +10 -0
  115. package/dist/services/vcs/bitbucket.d.ts +22 -1
  116. package/dist/services/vcs/bitbucket.js +163 -17
  117. package/dist/services/vcs/types.d.ts +25 -2
  118. package/dist/services/watch/project-resolver.js +2 -1
  119. package/dist/skills/pm/cost.md +5 -1
  120. package/dist/skills/pm/index.md +9 -9
  121. package/dist/skills/pm/sprint.md +2 -1
  122. package/dist/tools/check-status.d.ts +51 -0
  123. package/dist/tools/check-status.js +124 -12
  124. package/dist/tools/code-intelligence-freshness.js +1 -1
  125. package/dist/tools/code-intelligence-gitnexus.d.ts +19 -0
  126. package/dist/tools/code-intelligence-gitnexus.js +166 -9
  127. package/dist/tools/code-intelligence-readiness.d.ts +58 -1
  128. package/dist/tools/code-intelligence-readiness.js +93 -8
  129. package/dist/tools/code-intelligence-reindex.d.ts +25 -1
  130. package/dist/tools/code-intelligence-reindex.js +76 -4
  131. package/dist/tools/code-intelligence.d.ts +1 -1
  132. package/dist/tools/code-intelligence.js +1 -1
  133. package/dist/tools/execute-command.js +14 -8
  134. package/dist/tools/execute-prompt.js +6 -2
  135. package/dist/tools/fleet-snapshot.d.ts +21 -0
  136. package/dist/tools/fleet-snapshot.js +78 -0
  137. package/dist/tools/kb-bible-commit.d.ts +25 -11
  138. package/dist/tools/kb-bible-commit.js +142 -33
  139. package/dist/tools/kb-capture.d.ts +2 -2
  140. package/dist/tools/kb-context.js +47 -27
  141. package/dist/tools/kb-demote.d.ts +27 -0
  142. package/dist/tools/kb-demote.js +37 -0
  143. package/dist/tools/kb-export.d.ts +35 -3
  144. package/dist/tools/kb-export.js +56 -13
  145. package/dist/tools/kb-feedback.d.ts +2 -0
  146. package/dist/tools/kb-feedback.js +17 -7
  147. package/dist/tools/kb-harvest.js +28 -9
  148. package/dist/tools/kb-import.d.ts +18 -2
  149. package/dist/tools/kb-import.js +24 -9
  150. package/dist/tools/kb-invalidate.d.ts +11 -3
  151. package/dist/tools/kb-invalidate.js +80 -7
  152. package/dist/tools/kb-list.js +38 -10
  153. package/dist/tools/kb-promote.js +6 -4
  154. package/dist/tools/kb-query.d.ts +3 -0
  155. package/dist/tools/kb-query.js +181 -37
  156. package/dist/tools/kb-session-prime.d.ts +4 -4
  157. package/dist/tools/kb-session-prime.js +89 -9
  158. package/dist/tools/kb-setup.d.ts +20 -0
  159. package/dist/tools/kb-setup.js +149 -11
  160. package/dist/tools/list-members.js +1 -1
  161. package/dist/tools/member-detail.js +7 -3
  162. package/dist/tools/provision-vcs-auth.d.ts +28 -3
  163. package/dist/tools/provision-vcs-auth.js +53 -7
  164. package/dist/tools/receive-files.js +7 -4
  165. package/dist/tools/send-files.js +5 -4
  166. package/dist/tools/send-message.d.ts +3 -0
  167. package/dist/tools/send-message.js +15 -2
  168. package/dist/tools/stop-prompt.js +3 -1
  169. package/dist/tools/vcs-credential-exec.d.ts +45 -3
  170. package/dist/tools/vcs-credential-exec.js +90 -11
  171. package/dist/utils/process-utils.js +5 -1
  172. package/dist/utils/redact-known-secrets.d.ts +17 -0
  173. package/dist/utils/redact-known-secrets.js +70 -0
  174. package/dist/utils/skill-matrix.js +1 -1
  175. package/dist/utils/vcs-provider-detect.js +2 -2
  176. package/dist/workflows/auto-sprint.js +245 -9
  177. package/package.json +10 -7
  178. package/packages/apra-fleet-client/package.json +1 -1
  179. package/packages/apra-fleet-client/src/client/api.mjs +172 -19
  180. package/packages/apra-fleet-client/src/client/reconnecting-transport.mjs +35 -2
  181. package/packages/apra-fleet-client/src/client/transport.mjs +6 -0
  182. package/packages/apra-fleet-se/apra-pm/agents/backlog-groomer.md +5 -0
  183. package/packages/apra-fleet-se/apra-pm/agents/ci-watcher.md +5 -0
  184. package/packages/apra-fleet-se/apra-pm/agents/deployer.md +20 -2
  185. package/packages/apra-fleet-se/apra-pm/agents/doer.md +38 -2
  186. package/packages/apra-fleet-se/apra-pm/agents/harvester.md +12 -9
  187. package/packages/apra-fleet-se/apra-pm/agents/integ-test-runner.md +5 -0
  188. package/packages/apra-fleet-se/apra-pm/agents/kb-reconciler.md +6 -0
  189. package/packages/apra-fleet-se/apra-pm/agents/plan-reviewer.md +5 -0
  190. package/packages/apra-fleet-se/apra-pm/agents/planner.md +5 -0
  191. package/packages/apra-fleet-se/apra-pm/agents/regression-test-runner.md +5 -0
  192. package/packages/apra-fleet-se/apra-pm/agents/reviewer.md +67 -15
  193. package/packages/apra-fleet-se/apra-pm/agents/schemas/deployer-output.json +5 -0
  194. package/packages/apra-fleet-se/apra-pm/agents/schemas/doer-output.json +78 -2
  195. package/packages/apra-fleet-se/apra-pm/agents/schemas/reviewer-output.json +104 -2
  196. package/packages/apra-fleet-se/apra-pm/skills/pm/cost.md +5 -1
  197. package/packages/apra-fleet-se/apra-pm/skills/pm/index.md +9 -9
  198. package/packages/apra-fleet-se/apra-pm/skills/pm/sprint.md +2 -1
  199. package/packages/apra-fleet-se/bin/cli.mjs +104 -31
  200. package/packages/apra-fleet-se/bin/serve.mjs +46 -8
  201. package/packages/apra-fleet-se/fleet-sprint/abort.mjs +184 -32
  202. package/packages/apra-fleet-se/fleet-sprint/bd-sync-command.mjs +69 -0
  203. package/packages/apra-fleet-se/fleet-sprint/beads-children.mjs +21 -0
  204. package/packages/apra-fleet-se/fleet-sprint/beads-lock-probe.mjs +176 -0
  205. package/packages/apra-fleet-se/fleet-sprint/beads-reachability.mjs +126 -0
  206. package/packages/apra-fleet-se/fleet-sprint/beads-scope.mjs +158 -1
  207. package/packages/apra-fleet-se/fleet-sprint/contracts.mjs +82 -2
  208. package/packages/apra-fleet-se/fleet-sprint/coordination.mjs +23 -6
  209. package/packages/apra-fleet-se/fleet-sprint/decision-notify.mjs +338 -0
  210. package/packages/apra-fleet-se/fleet-sprint/decision-wait.mjs +731 -0
  211. package/packages/apra-fleet-se/fleet-sprint/decisions.mjs +372 -0
  212. package/packages/apra-fleet-se/fleet-sprint/dispatch-role.mjs +44 -11
  213. package/packages/apra-fleet-se/fleet-sprint/docs/README.md +4 -1
  214. package/packages/apra-fleet-se/fleet-sprint/dolt-settle.mjs +9 -3
  215. package/packages/apra-fleet-se/fleet-sprint/dolt-sync.mjs +314 -19
  216. package/packages/apra-fleet-se/fleet-sprint/errors.mjs +72 -4
  217. package/packages/apra-fleet-se/fleet-sprint/git-sync.mjs +7 -1
  218. package/packages/apra-fleet-se/fleet-sprint/git-topology.mjs +112 -1
  219. package/packages/apra-fleet-se/fleet-sprint/guarded-modules.mjs +36 -2
  220. package/packages/apra-fleet-se/fleet-sprint/kb.mjs +736 -101
  221. package/packages/apra-fleet-se/fleet-sprint/member-init-probe.mjs +1 -1
  222. package/packages/apra-fleet-se/fleet-sprint/member-provisioning.mjs +7 -1
  223. package/packages/apra-fleet-se/fleet-sprint/phases/deploy.mjs +49 -2
  224. package/packages/apra-fleet-se/fleet-sprint/phases/develop.mjs +206 -3
  225. package/packages/apra-fleet-se/fleet-sprint/phases/final-review.mjs +61 -3
  226. package/packages/apra-fleet-se/fleet-sprint/phases/harvest.mjs +81 -31
  227. package/packages/apra-fleet-se/fleet-sprint/phases/plan.mjs +7 -3
  228. package/packages/apra-fleet-se/fleet-sprint/phases/publish-pr.mjs +39 -14
  229. package/packages/apra-fleet-se/fleet-sprint/phases/re-review.mjs +17 -1
  230. package/packages/apra-fleet-se/fleet-sprint/phases/review.mjs +18 -3
  231. package/packages/apra-fleet-se/fleet-sprint/pr-body.mjs +14 -1
  232. package/packages/apra-fleet-se/fleet-sprint/prompts.mjs +32 -5
  233. package/packages/apra-fleet-se/fleet-sprint/runner.js +824 -98
  234. package/packages/apra-fleet-se/fleet-sprint/se-os-commands.mjs +4 -2
  235. package/packages/apra-fleet-se/fleet-sprint/se-posix.mjs +54 -1
  236. package/packages/apra-fleet-se/fleet-sprint/se-windows.mjs +29 -2
  237. package/packages/apra-fleet-se/fleet-sprint/set-aside.mjs +288 -0
  238. package/packages/apra-fleet-se/fleet-sprint/skills/fleet-supervisor/SKILL.md +3 -2
  239. package/packages/apra-fleet-se/fleet-sprint/sprint-args.mjs +20 -0
  240. package/packages/apra-fleet-se/fleet-sprint/sprint-report.mjs +21 -0
  241. package/packages/apra-fleet-se/fleet-sprint/sprint-state.mjs +9 -0
  242. package/packages/apra-fleet-se/fleet-sprint/vcs-auth.mjs +605 -32
  243. package/packages/apra-fleet-se/fleet-sprint/vcs-providers/bitbucket.mjs +811 -17
  244. package/packages/apra-fleet-se/fleet-sprint/vcs-providers/index.mjs +89 -1
  245. package/packages/apra-fleet-se/fleet-sprint/viewer-extensions.mjs +225 -2
  246. package/packages/apra-fleet-se/fleet-sprint/worklists.mjs +59 -3
  247. package/packages/apra-fleet-se/src/supervisor/api.mjs +148 -8
  248. package/packages/apra-fleet-se/src/supervisor/dashboard.mjs +6 -3
  249. package/packages/apra-fleet-se/src/supervisor/dolt-mutex.mjs +30 -10
  250. package/packages/apra-fleet-se/src/supervisor/fleet-members.mjs +17 -4
  251. package/packages/apra-fleet-se/src/supervisor/history.mjs +8 -1
  252. package/packages/apra-fleet-se/src/supervisor/id-allocator.mjs +92 -2
  253. package/packages/apra-fleet-se/src/supervisor/proxy.mjs +26 -1
  254. package/packages/apra-fleet-se/src/supervisor/server.mjs +151 -8
  255. package/packages/apra-fleet-se/src/supervisor/spawner.mjs +11 -9
  256. package/packages/apra-fleet-se/src/supervisor/watchdog.mjs +7 -1
  257. package/packages/apra-fleet-workflow/package.json +2 -1
  258. package/packages/apra-fleet-workflow/src/viewer/index.mjs +86 -5
  259. package/packages/apra-fleet-workflow/src/viewer/request-guard.mjs +222 -0
  260. package/packages/apra-fleet-workflow/src/workflow/index.mjs +34 -2
  261. package/plugins/claude-code/fleet-status/.claude-plugin/plugin.json +7 -0
  262. package/plugins/claude-code/fleet-status/hooks/hooks.json +1 -0
  263. package/plugins/claude-code/fleet-status/hooks/register.tsx +906 -0
  264. package/plugins/claude-code/fleet-status/types/index.d.ts +88 -0
  265. package/skills/fleet/auth-bitbucket.md +47 -20
  266. package/skills/fleet/onboarding.md +1 -1
  267. package/skills/fleet/skill-matrix.md +3 -3
  268. package/version.json +1 -1
@@ -0,0 +1,372 @@
1
+ // =============================================================================
2
+ // NEEDS-DECISION: a doer or reviewer asks a human operator to choose.
3
+ //
4
+ // A doer (status) or reviewer (verdict) may return NEEDS-DECISION with a
5
+ // `decision` object -- { beadId, question, options: [{ id, text }, ...],
6
+ // recommendation } (doer-output.json / reviewer-output.json). The bead cannot
7
+ // go on until an operator chooses, so re-dispatching it only burns dispatches.
8
+ // recordPendingDecision() below:
9
+ //
10
+ // 1. files a dedicated DECISION bead for the operator: labelled `human`,
11
+ // type `decision`, status `deferred`, carrying the full question and
12
+ // every option verbatim, linked to the work bead by a `discovered-from`
13
+ // edge. It is NEVER the work bead itself: `bd human respond <id>` adds a
14
+ // comment AND CLOSES the bead it is given (reason "Responded"), so a
15
+ // `human` label on the work bead would let an operator's answer close
16
+ // unfinished work. It is not a child of anything and has no blocks edge,
17
+ // so it is never sprint work; the deferred status keeps it out of
18
+ // `bd ready` and out of the open-bead counts even in a sprint whose
19
+ // scope is the whole database. `bd human list` still lists it.
20
+ // 2. appends the full request to the work bead's notes (`bd note --file`,
21
+ // which appends; never `bd update --notes`, which replaces);
22
+ // 3. records the decision on `sprintState.pendingDecisions` (Map
23
+ // decisionId -> { decisionId, beadId, question, options, recommendation,
24
+ // decisionBeadId, raisedBy, cycle, round, notification: {} });
25
+ // 4. sets the work bead aside for the rest of the run on
26
+ // `sprintState.doctorBlockedIds` with kind 'needs-decision' (and its open
27
+ // blocks-edge dependents with kind 'dependent'), exactly like a doer
28
+ // BLOCKED report, so it is excluded from every later round's streaks and
29
+ // counts as set aside for the stall decision and the "Set aside this
30
+ // run" report.
31
+ //
32
+ // The question and options are never truncated anywhere on this path: the
33
+ // set-aside reason carries the whole question.
34
+ //
35
+ // Every bd write is best-effort: a failed decision-bead create or note
36
+ // append is logged and the bead is still set aside (re-dispatching it would
37
+ // not answer the question either).
38
+ // =============================================================================
39
+
40
+ import { stageCommandBodyMemberSide } from './member-provisioning.mjs';
41
+ import { openBlocksDependents } from './beads-scope.mjs';
42
+ import { createDecisionBead } from './beads-children.mjs';
43
+
44
+ /** The doer status / reviewer verdict asking for an operator decision. */
45
+ export const NEEDS_DECISION = 'NEEDS-DECISION';
46
+
47
+ /** The set-aside kind recorded on sprintState.doctorBlockedIds for it. */
48
+ export const NEEDS_DECISION_KIND = 'needs-decision';
49
+
50
+ /** The label `bd human list` / `bd human respond` select on. */
51
+ export const DECISION_BEAD_LABEL = 'human';
52
+
53
+ const BEAD_ID_RE = /^[A-Za-z0-9][A-Za-z0-9._-]*$/;
54
+
55
+ /**
56
+ * Checks a NEEDS-DECISION request beyond the schema: trimmed non-empty
57
+ * question and recommendation, at least two options each with an id and
58
+ * text, unique option ids, and a bead id safe to put on a command line.
59
+ * Returns the normalized request (strings trimmed, nothing shortened).
60
+ *
61
+ * @param {unknown} decision
62
+ * @returns {{ ok: true, decision: { beadId: string, question: string, options: { id: string, text: string }[], recommendation: string } } | { ok: false, reason: string }}
63
+ */
64
+ export function validateDecisionRequest(decision) {
65
+ if (!decision || typeof decision !== 'object') return { ok: false, reason: 'no decision object' };
66
+ const beadId = typeof decision.beadId === 'string' ? decision.beadId.trim() : '';
67
+ if (!BEAD_ID_RE.test(beadId)) return { ok: false, reason: `decision.beadId ${JSON.stringify(decision.beadId)} is not a bead id` };
68
+ const question = typeof decision.question === 'string' ? decision.question.trim() : '';
69
+ if (!question) return { ok: false, reason: 'decision.question is empty' };
70
+ const recommendation = typeof decision.recommendation === 'string' ? decision.recommendation.trim() : '';
71
+ if (!recommendation) return { ok: false, reason: 'decision.recommendation is empty' };
72
+ const rawOptions = Array.isArray(decision.options) ? decision.options : [];
73
+ const options = [];
74
+ for (const o of rawOptions) {
75
+ const id = o && typeof o.id === 'string' ? o.id.trim() : '';
76
+ const text = o && typeof o.text === 'string' ? o.text.trim() : '';
77
+ if (!id || !text) return { ok: false, reason: 'every decision option needs an id and a text' };
78
+ options.push({ id, text });
79
+ }
80
+ if (options.length < 2) return { ok: false, reason: `decision needs at least 2 options, got ${options.length}` };
81
+ if (new Set(options.map((o) => o.id)).size !== options.length) return { ok: false, reason: 'decision option ids must be unique' };
82
+ return { ok: true, decision: { beadId, question, options, recommendation } };
83
+ }
84
+
85
+ /**
86
+ * The full, untruncated decision request text: the body of the decision
87
+ * bead and of the note appended to the work bead.
88
+ *
89
+ * @param {{ beadId: string, question: string, options: { id: string, text: string }[], recommendation: string }} decision
90
+ * @param {{ raisedBy?: string, cycle?: number, round?: number, decisionBeadId?: string|null }} [meta]
91
+ * @returns {string}
92
+ */
93
+ export function formatDecisionRequest(decision, { raisedBy, cycle, round, decisionBeadId } = {}) {
94
+ const where = Number.isInteger(cycle) ? ` in C${cycle}${Number.isInteger(round) ? ` R${round}` : ''}` : '';
95
+ const lines = [
96
+ `[fleet-sprint] NEEDS-DECISION on ${decision.beadId}${raisedBy ? ` (raised by ${raisedBy}${where})` : where}`,
97
+ '',
98
+ 'Question:',
99
+ decision.question,
100
+ '',
101
+ 'Options:',
102
+ ...decision.options.map((o) => `(${o.id}) ${o.text}`),
103
+ '',
104
+ 'Recommendation:',
105
+ decision.recommendation,
106
+ ];
107
+ if (decisionBeadId) {
108
+ lines.push('', `Answer with: bd human respond ${decisionBeadId} "<chosen option id and any instructions>" ` +
109
+ '(then resume the run from its dashboard), or answer from the sprint dashboard\'s decision banner.');
110
+ }
111
+ return lines.join('\n');
112
+ }
113
+
114
+ /** The decision bead's title (inline on the command line: bead ids only). */
115
+ export function decisionBeadTitle(beadId) {
116
+ return `Decision needed for ${beadId}`;
117
+ }
118
+
119
+ /**
120
+ * Looks up an existing NOT-closed decision bead for `beadId` (a relaunch has a
121
+ * fresh sprintState, so the per-run pending map cannot see the prior run's).
122
+ * Decision beads are filed `deferred`, so every non-closed status counts.
123
+ * Best-effort: a failed or unparseable lookup returns null (caller files).
124
+ * @returns {Promise<string|null>} the open decision bead's id, or null
125
+ */
126
+ export async function findOpenDecisionBead({ command, member, beadId, log = () => {} }) {
127
+ const title = decisionBeadTitle(beadId);
128
+ try {
129
+ const out = await command(
130
+ `bd list -t decision -l ${DECISION_BEAD_LABEL} --title-contains "${title}" --status open,in_progress,blocked,deferred --json`,
131
+ { member_name: member, silent: true, label: `Look up open decision bead for ${beadId}` },
132
+ );
133
+ const parsed = JSON.parse(String(out ?? '').trim() || '[]');
134
+ const list = Array.isArray(parsed) ? parsed : [];
135
+ const hit = list.find((b) => b && b.title === title && b.status !== 'closed' && BEAD_ID_RE.test(String(b.id)));
136
+ return hit ? String(hit.id) : null;
137
+ } catch (err) {
138
+ log(`NEEDS-DECISION on '${beadId}': open decision bead lookup FAILED (non-fatal, filing a new one): ${err.message}`);
139
+ return null;
140
+ }
141
+ }
142
+
143
+ /** The set-aside reason for the work bead: names the decision bead and carries the whole question. */
144
+ export function needsDecisionReason({ decision, raisedBy, decisionBeadId }) {
145
+ const where = decisionBeadId
146
+ ? ` (decision bead ${decisionBeadId})`
147
+ : ' (the decision bead could NOT be filed, so this run has no bd human respond path for it: ' +
148
+ 'record the decision in this bead\'s notes and re-run)';
149
+ return `awaiting an operator decision${where} raised by ${raisedBy}: ${decision.question}`;
150
+ }
151
+
152
+ // Deletes a member-side staged body file once bd has read it. Best-effort:
153
+ // a failure only leaves one temp file behind. No backticks or `$`, like the
154
+ // staging script itself, so it is inert on every member shell.
155
+ export async function removeStagedBody({ command, member, file, log = () => {} }) {
156
+ if (!file) return;
157
+ try {
158
+ await command(
159
+ `node -e "require('fs').rmSync(process.argv[1],{force:true})" "${file}"`,
160
+ { member_name: member, silent: true, label: 'Remove staged decision body' },
161
+ );
162
+ } catch (err) {
163
+ log(`NEEDS-DECISION: could not remove staged body file (non-fatal): ${err.message}`);
164
+ }
165
+ }
166
+
167
+ function normalizePriority(priority) {
168
+ const n = Number(String(priority ?? '').replace(/^P/i, ''));
169
+ return Number.isInteger(n) && n >= 0 && n <= 4 ? n : 2;
170
+ }
171
+
172
+ /**
173
+ * Records one NEEDS-DECISION request (see this file's header). A bead with a
174
+ * decision already pending this run is not filed twice.
175
+ *
176
+ * @param {object} opts
177
+ * @param {object} opts.sprintState
178
+ * @param {object} opts.decision a request that passed validateDecisionRequest()
179
+ * @param {string} opts.raisedBy e.g. "doer on member 'm1'"
180
+ * @param {number} opts.cycle
181
+ * @param {number|null} [opts.round]
182
+ * @param {Function} opts.command the workflow command() seam
183
+ * @param {string} opts.member the member whose beads clone the engine writes through
184
+ * @param {Array<object>} [opts.scopeBeads] every in-scope bead (for blocks-edge dependents and the priority)
185
+ * @param {Function} [opts.log]
186
+ * @returns {Promise<object|null>} the pending-decision record, or null when one was already pending
187
+ */
188
+ export async function recordPendingDecision({ sprintState, decision, raisedBy, cycle, round = null, command, member, scopeBeads = [], log = () => {} }) {
189
+ sprintState.pendingDecisions = sprintState.pendingDecisions instanceof Map ? sprintState.pendingDecisions : new Map();
190
+ sprintState.doctorBlockedIds = sprintState.doctorBlockedIds instanceof Map ? sprintState.doctorBlockedIds : new Map();
191
+ const pending = sprintState.pendingDecisions;
192
+ const blocked = sprintState.doctorBlockedIds;
193
+ const beadId = decision.beadId;
194
+ for (const existing of pending.values()) {
195
+ if (existing.beadId === beadId) {
196
+ log(`NEEDS-DECISION on '${beadId}' from ${raisedBy}: a decision is already pending for this bead (${existing.decisionId}) -- not filing a second one.`);
197
+ return null;
198
+ }
199
+ }
200
+ sprintState.decisionSeq = (Number.isInteger(sprintState.decisionSeq) ? sprintState.decisionSeq : 0) + 1;
201
+ const decisionId = `decision-${sprintState.decisionSeq}-${beadId}`;
202
+ const workBead = (scopeBeads || []).find((b) => b && String(b.id) === beadId);
203
+ const priority = normalizePriority(workBead && workBead.priority);
204
+
205
+ let decisionBeadId = await findOpenDecisionBead({ command, member, beadId, log });
206
+ const reused = decisionBeadId !== null;
207
+ if (reused) log(`NEEDS-DECISION on '${beadId}': reusing the open decision bead ${decisionBeadId} from an earlier run -- not filing a new one.`);
208
+ let bodyFile = null;
209
+ if (!reused) try {
210
+ bodyFile = await stageCommandBodyMemberSide({
211
+ command, member,
212
+ content: formatDecisionRequest(decision, { raisedBy, cycle, round }),
213
+ label: `Stage decision request for ${beadId}`,
214
+ });
215
+ const out = await createDecisionBead({
216
+ command, member, workBeadId: beadId, title: decisionBeadTitle(beadId), bodyFile, priority,
217
+ labelName: DECISION_BEAD_LABEL, label: `File decision bead for ${beadId}`,
218
+ });
219
+ const id = String(out ?? '').trim().split(/\s+/).pop() || '';
220
+ decisionBeadId = BEAD_ID_RE.test(id) ? id : null;
221
+ if (!decisionBeadId) log(`NEEDS-DECISION on '${beadId}': bd create returned no bead id (${JSON.stringify(String(out ?? ''))}).`);
222
+ } catch (err) {
223
+ log(`NEEDS-DECISION on '${beadId}': filing the decision bead FAILED (non-fatal, the bead is still set aside): ${err.message}`);
224
+ }
225
+ await removeStagedBody({ command, member, file: bodyFile, log });
226
+
227
+ let noteFile = null;
228
+ try {
229
+ noteFile = await stageCommandBodyMemberSide({
230
+ command, member,
231
+ content: formatDecisionRequest(decision, { raisedBy, cycle, round, decisionBeadId }),
232
+ label: `Stage decision note for ${beadId}`,
233
+ });
234
+ await command(
235
+ `bd note ${beadId} --file "${noteFile}"`,
236
+ { member_name: member, silent: true, label: `Append decision request to ${beadId} notes` },
237
+ );
238
+ } catch (err) {
239
+ log(`NEEDS-DECISION on '${beadId}': appending the request to its notes FAILED (non-fatal): ${err.message}`);
240
+ }
241
+ await removeStagedBody({ command, member, file: noteFile, log });
242
+
243
+ const record = {
244
+ decisionId, beadId,
245
+ question: decision.question,
246
+ options: decision.options.map((o) => ({ id: o.id, text: o.text })),
247
+ recommendation: decision.recommendation,
248
+ decisionBeadId, raisedBy, cycle,
249
+ raisedAt: new Date().toISOString(),
250
+ round: Number.isInteger(round) ? round : null,
251
+ notification: {},
252
+ };
253
+ pending.set(decisionId, record);
254
+
255
+ const where = { cycle, round: record.round };
256
+ blocked.set(beadId, {
257
+ kind: NEEDS_DECISION_KIND, blockedBy: beadId,
258
+ reason: needsDecisionReason({ decision, raisedBy, decisionBeadId }),
259
+ decisionId, decisionBeadId,
260
+ ...where,
261
+ });
262
+ const dependents = [];
263
+ for (const [id, root] of openBlocksDependents([beadId], scopeBeads || [])) {
264
+ if (blocked.has(id)) continue;
265
+ blocked.set(id, {
266
+ kind: 'dependent', blockedBy: root,
267
+ reason: `depends (via blocks edges) on bead '${root}', which awaits an operator decision${decisionBeadId ? ` (${decisionBeadId})` : ''}`,
268
+ decisionId,
269
+ ...where,
270
+ });
271
+ dependents.push(id);
272
+ }
273
+ log(
274
+ `NEEDS-DECISION set-aside C${cycle}${record.round !== null ? ` R${record.round}` : ''}: bead '${beadId}' awaits an operator decision ` +
275
+ `(${decisionId}, decision bead ${decisionBeadId || 'NOT FILED'}); set aside for the rest of this run with its open dependent(s) ` +
276
+ `[${dependents.join(', ')}] and not re-dispatched while the decision is pending. Request: ${JSON.stringify(record)}`,
277
+ );
278
+ // Tell the operator (decision-notify.mjs). Injected by the runner as
279
+ // sprintState.notifyDecision; it never throws, and a failure here must
280
+ // never change the sprint, so this guard is belt and braces.
281
+ if (typeof sprintState.notifyDecision === 'function') {
282
+ try {
283
+ await sprintState.notifyDecision(record);
284
+ } catch (err) {
285
+ log(`NOTIFICATION FAILED for decision ${decisionId}: ${err && err.message}. The sprint continues unchanged.`);
286
+ }
287
+ }
288
+ return record;
289
+ }
290
+
291
+ /**
292
+ * Every pending decision of this run, in raise order.
293
+ * @param {{ pendingDecisions?: Map<string, object> }|null|undefined} sprintState
294
+ * @returns {object[]}
295
+ */
296
+ export function collectPendingDecisions(sprintState) {
297
+ const pending = sprintState && sprintState.pendingDecisions instanceof Map ? sprintState.pendingDecisions : new Map();
298
+ return [...pending.values()];
299
+ }
300
+
301
+ /**
302
+ * The reopen entries for a reviewer verdict: its `reopenIds`, plus -- for a
303
+ * usable NEEDS-DECISION naming a bead in this review's scope -- that bead, so
304
+ * a closed bead is reopened through the SAME guarded reopen call as every
305
+ * other reopen of the verdict (applyGuardedReopens in
306
+ * beads-transitions.mjs). Reopening a bead that is already open is a no-op.
307
+ *
308
+ * @param {{ verdict: string, reopenIds?: string[], decision?: object }} verdict
309
+ * @param {string[]} scopeIds bead ids this review covered
310
+ * @returns {string[]}
311
+ */
312
+ export function reviewerReopenEntries(verdict, scopeIds) {
313
+ const entries = Array.isArray(verdict && verdict.reopenIds) ? [...verdict.reopenIds] : [];
314
+ if (!verdict || verdict.verdict !== NEEDS_DECISION) return entries;
315
+ const checked = validateDecisionRequest(verdict.decision);
316
+ if (!checked.ok || !(scopeIds || []).map(String).includes(checked.decision.beadId)) return entries;
317
+ if (!entries.includes(checked.decision.beadId)) entries.push(checked.decision.beadId);
318
+ return entries;
319
+ }
320
+
321
+ /**
322
+ * Applies a reviewer NEEDS-DECISION verdict (per-round Review and
323
+ * Re-Review), AFTER the caller applied the verdict's reopens with
324
+ * reviewerReopenEntries(): the named bead must be in this review's scope and
325
+ * open now (it was open already, or the guarded reopen just reopened it);
326
+ * the decision is then recorded exactly as for a doer
327
+ * (recordPendingDecision). A non-NEEDS-DECISION verdict is a no-op.
328
+ *
329
+ * @param {object} opts
330
+ * @param {{ verdict: string, decision?: object }} opts.verdict
331
+ * @param {string[]} opts.scopeIds bead ids this review covered
332
+ * @param {Set<string>} opts.reopenedIds ids the guarded reopen actually reopened
333
+ * @param {object} opts.sprintState
334
+ * @param {Function} opts.command
335
+ * @param {string} opts.member
336
+ * @param {Function} opts.bdListScoped
337
+ * @param {number} opts.cycle
338
+ * @param {number|null} [opts.round]
339
+ * @param {string} opts.site e.g. 'Review C1 R2'
340
+ * @param {Function} [opts.log]
341
+ * @returns {Promise<object|null>} the pending-decision record, or null
342
+ */
343
+ export async function applyReviewerDecision({ verdict, scopeIds, reopenedIds = new Set(), sprintState, command, member, bdListScoped, cycle, round = null, site, log = () => {} }) {
344
+ if (!verdict || verdict.verdict !== NEEDS_DECISION) return null;
345
+ const checked = validateDecisionRequest(verdict.decision);
346
+ if (!checked.ok) {
347
+ log(`${site}: reviewer returned NEEDS-DECISION with an unusable decision (${checked.reason}) -- nothing is set aside.`);
348
+ return null;
349
+ }
350
+ const decision = checked.decision;
351
+ if (!(scopeIds || []).map(String).includes(decision.beadId)) {
352
+ log(`${site}: reviewer returned NEEDS-DECISION on '${decision.beadId}', which is not in this review's scope -- nothing is set aside.`);
353
+ return null;
354
+ }
355
+ const reopened = reopenedIds instanceof Set && reopenedIds.has(decision.beadId);
356
+ const scopeBeads = (await bdListScoped(''))
357
+ .map((b) => (b && reopened && String(b.id) === decision.beadId ? { ...b, status: 'open' } : b));
358
+ const bead = scopeBeads.find((b) => b && String(b.id) === decision.beadId);
359
+ if (!bead) {
360
+ log(`${site}: reviewer returned NEEDS-DECISION on '${decision.beadId}', which is not in the sprint scope -- nothing is set aside.`);
361
+ return null;
362
+ }
363
+ if (bead.status === 'closed') {
364
+ log(`${site}: reviewer returned NEEDS-DECISION on closed bead '${decision.beadId}', which the guarded reopen did not reopen -- nothing is set aside.`);
365
+ return null;
366
+ }
367
+ return recordPendingDecision({
368
+ sprintState, decision,
369
+ raisedBy: `reviewer (${site})`,
370
+ cycle, round, command, member, scopeBeads, log,
371
+ });
372
+ }
@@ -2,6 +2,8 @@ import { policyFor, PRE_DISPATCH_STEPS_IN_BRACKET } from './role-policies.mjs';
2
2
  import {
3
3
  isNonRetryableDispatchError,
4
4
  isAuthDispatchError,
5
+ SECRET_DELIVERY_UNAVAILABLE_REASON,
6
+ SECRET_DELIVERY_UNAVAILABLE_REMEDY,
5
7
  isPostDispatchSyncFailure,
6
8
  isInfraDispatchFailure,
7
9
  isUsageLimitDispatchError,
@@ -667,7 +669,9 @@ export async function dispatchRole(ctx, roleName, opts = {}) {
667
669
  // fresh session carrying the FULL role prompt (never resume: true,
668
670
  // which could reattach another role's session on a shared member).
669
671
  let resumeSessionId = sessionIdOfError(err);
670
- let sessionLostOnce = false;
672
+ // The id of a session the server answered session_not_found for
673
+ // (named in the fresh-fallback log), or null.
674
+ let lostSessionId = null;
671
675
  while (resumeAttempt < Math.max(retry.resumeAttempts, resumesOnInfra ? 1 : 0)) {
672
676
  resumeAttempt += 1;
673
677
  const freshFallback = !resumeSessionId;
@@ -683,31 +687,36 @@ export async function dispatchRole(ctx, roleName, opts = {}) {
683
687
  // dispatch in the log.
684
688
  const shortCircuit = await runPreDispatchSteps(ctx, secondary, member, opts, { resumeAttempt });
685
689
  if (shortCircuit) return shortCircuit.value;
690
+ // The announcement never claims "resuming the same session" for
691
+ // a fresh fallback: there is no session to resume then, and the
692
+ // line just below says why.
693
+ const resumeTurns = resolveMaxTurns(secondary.maxTurns, bindingsFor(resumeAttempt));
694
+ const continuation = freshFallback ? 'continuing in a FRESH session' : 'resuming the same session';
686
695
  if (resumeAttempt === 1 && resumesOnExhaustion) {
687
696
  ctx.log(
688
697
  `${roleLabel} exhausted its turn limit ` +
689
- `(max_turns=${resolveMaxTurns(policy.maxTurns, bindingsFor(0))}) -- resuming the same ` +
690
- `session with max_turns=${resolveMaxTurns(secondary.maxTurns, bindingsFor(1))}.`
698
+ `(max_turns=${resolveMaxTurns(policy.maxTurns, bindingsFor(0))}) -- ${continuation} ` +
699
+ `with max_turns=${resumeTurns}.`
691
700
  );
692
701
  } else if (resumeAttempt === 1) {
693
702
  ctx.log(
694
703
  `${roleLabel}: infrastructure dispatch failure ` +
695
704
  `(${(err.details && err.details.reason) || 'unknown'}) -- the member produced no result ` +
696
- 'envelope. This is NOT a failure verdict; resuming the same session once to recover ' +
705
+ `envelope. This is NOT a failure verdict; ${continuation} once to recover ` +
697
706
  'before recording anything.'
698
707
  );
699
708
  } else {
700
709
  ctx.log(
701
- `${roleLabel} exhausted its turn limit again -- resuming the same session with ` +
702
- `max_turns=${resolveMaxTurns(secondary.maxTurns, bindingsFor(resumeAttempt))} ` +
710
+ `${roleLabel} exhausted its turn limit again -- ${continuation} with ` +
711
+ `max_turns=${resumeTurns} ` +
703
712
  `(attempt ${resumeAttempt}/${retry.resumeAttempts}).`
704
713
  );
705
714
  }
706
715
  if (freshFallback) {
707
716
  ctx.log(
708
717
  `${roleLabel}: starting a FRESH session with the full role prompt instead of resuming -- ` +
709
- (sessionLostOnce
710
- ? 'the session to resume was not found on the member.'
718
+ (lostSessionId
719
+ ? `the session to resume was not found on the member (the server reported session_not_found for session '${lostSessionId}').`
711
720
  : 'the failed dispatch reported no session id, so there is no explicit session to resume.')
712
721
  );
713
722
  } else {
@@ -731,7 +740,7 @@ export async function dispatchRole(ctx, roleName, opts = {}) {
731
740
  const sessionNotFound = resumeErr instanceof AgentDispatchError
732
741
  && resumeErr.details && resumeErr.details.reason === 'session_not_found';
733
742
  if (sessionNotFound && !freshFallback) {
734
- sessionLostOnce = true;
743
+ lostSessionId = resumeSessionId;
735
744
  resumeSessionId = null;
736
745
  resumeAttempt -= 1;
737
746
  continue;
@@ -740,6 +749,7 @@ export async function dispatchRole(ctx, roleName, opts = {}) {
740
749
  // A re-exhaustion moves the resume target to the NEW
741
750
  // session's id (none -> a fresh full-prompt session).
742
751
  resumeSessionId = sessionIdOfError(resumeErr);
752
+ lostSessionId = null;
743
753
  continue;
744
754
  }
745
755
  throw resumeErr;
@@ -761,13 +771,27 @@ export async function dispatchRole(ctx, roleName, opts = {}) {
761
771
  // session it hit the limit on (warm context kept) rather than starting a
762
772
  // fresh one. Only reached when the failing attempt reported a sessionId and
763
773
  // the role actually has a max-turns resume secondary; otherwise the caller
764
- // re-runs runAttempt fresh.
774
+ // re-runs runAttempt fresh. If the server no longer knows that session
775
+ // (session_not_found -- e.g. the member restarted during the wait), the
776
+ // role starts a FRESH session with its FULL prompt instead, and says so:
777
+ // the short resume prompt is meaningless without the old context.
765
778
  const redispatchViaUsageLimitResume = async (attemptOpts, sessionId) => {
766
779
  const secondary = policy.secondary;
767
780
  const shortCircuit = await runPreDispatchSteps(ctx, secondary, member, opts, { resumeAttempt: 1 });
768
781
  if (shortCircuit) return shortCircuit.value;
769
782
  // Resumes the session the limit hit, by its explicit id.
770
- return runDispatch(secondary, opts.resumePrompt ?? opts.prompt, opts.resumeLabel ?? opts.label, attemptOpts, { resumeAttempt: 1, resumeSessionId: sessionId });
783
+ try {
784
+ return await runDispatch(secondary, opts.resumePrompt ?? opts.prompt, opts.resumeLabel ?? opts.label, attemptOpts, { resumeAttempt: 1, resumeSessionId: sessionId });
785
+ } catch (resumeErr) {
786
+ const sessionNotFound = resumeErr instanceof AgentDispatchError
787
+ && resumeErr.details && resumeErr.details.reason === 'session_not_found';
788
+ if (!sessionNotFound) throw resumeErr;
789
+ ctx.log(
790
+ `${roleLabel}: the server reported session_not_found for session '${sessionId}' after the usage-limit ` +
791
+ 'wait -- starting a FRESH session with the full role prompt instead.'
792
+ );
793
+ return runDispatch(secondary, opts.prompt, opts.label ?? opts.resumeLabel, attemptOpts, { resumeAttempt: 1, freshSession: true });
794
+ }
771
795
  };
772
796
 
773
797
  let lastErr = null;
@@ -1055,6 +1079,15 @@ export async function dispatchRole(ctx, roleName, opts = {}) {
1055
1079
  throw (outcome && outcome.error) || err;
1056
1080
  }
1057
1081
 
1082
+ // A member that cannot receive its stored credentials fails the same
1083
+ // way on every attempt, on EVERY ladder (abortOnNonRetryable or not):
1084
+ // stop after the first failure and name the remedy. No self-heal.
1085
+ if (!completedButSyncFailed && err?.details?.reason === SECRET_DELIVERY_UNAVAILABLE_REASON) {
1086
+ ctx.log(`${roleLabel} dispatch failed: member '${member}' cannot receive its stored credentials (${SECRET_DELIVERY_UNAVAILABLE_REASON}); not retrying. Remedy: ${SECRET_DELIVERY_UNAVAILABLE_REMEDY}. Detail: ${err.message}`);
1087
+ if (!err.message.includes(SECRET_DELIVERY_UNAVAILABLE_REMEDY)) err.message += ` [${SECRET_DELIVERY_UNAVAILABLE_REMEDY}]`;
1088
+ if (retry.rethrowsUnhealedNonRetryable) throw err;
1089
+ break;
1090
+ }
1058
1091
  // Auth/workspace-trust failures are deterministic -- no retry can
1059
1092
  // succeed -- so a ladder that declares abortOnNonRetryable ends
1060
1093
  // rather than burning its remaining attempts on the same wall.
@@ -75,7 +75,10 @@ Start-Process -FilePath "apra-fleet" -ArgumentList "workflow","fleet-sprint", `
75
75
  -WindowStyle Hidden -PassThru
76
76
  ```
77
77
 
78
- On start it prints the dashboard URL (`http://localhost:<viewer-port>`).
78
+ On start it prints the dashboard URL (`http://127.0.0.1:<viewer-port>`). The
79
+ dashboard viewer and the supervisor (`fleet-se serve`) bind loopback only by
80
+ default; `fleet-se serve --host <addr>` (e.g. `0.0.0.0`) is the explicit opt-in
81
+ to expose the unauthenticated supervisor API off-box.
79
82
  Watch progress there rather than tailing raw stdout.
80
83
 
81
84
  ## Arguments
@@ -57,6 +57,7 @@
57
57
 
58
58
  import { DoltDivergedError, DoltSyncError, DoltBinaryUnavailableError } from './errors.mjs';
59
59
  import { getSeCommands } from './se-os-commands.mjs';
60
+ import { bdSyncCommandFor } from './bd-sync-command.mjs';
60
61
 
61
62
  /** Must equal src/cli/dolt-install.ts's DOLT_VERSION byte-for-byte -- a
62
63
  * drift-guard test (dolt-settle.test.mjs) asserts this against that file's
@@ -110,6 +111,9 @@ export function resolveDoltAsset(platform, arch) {
110
111
  } else if (platform === 'linux' && arch === 'x64') {
111
112
  assetName = 'dolt-linux-amd64.tar.gz';
112
113
  archiveType = 'tar.gz';
114
+ } else if (platform === 'linux' && arch === 'arm64') {
115
+ assetName = 'dolt-linux-arm64.tar.gz';
116
+ archiveType = 'tar.gz';
113
117
  } else if (platform === 'darwin' && arch === 'x64') {
114
118
  assetName = 'dolt-darwin-amd64.tar.gz';
115
119
  archiveType = 'tar.gz';
@@ -1022,11 +1026,11 @@ export async function settleDoltConflicts(member, opts = {}) {
1022
1026
  pid = null;
1023
1027
  }
1024
1028
 
1025
- const pull = await command('bd dolt pull', { member_name: member, silent: true, failSoft: true, label: `settle: post-resolve D-pull for '${member}'` });
1029
+ const pull = await command(bdSyncCommandFor('bd dolt pull', { os: platform, shell }), { member_name: member, silent: true, failSoft: true, label: `settle: post-resolve D-pull for '${member}'` });
1026
1030
  if (pull && pull.ok === false) {
1027
1031
  throw new DoltDivergedError(`[Dolt Settle] post-resolve pull still failed for member '${member}': ${pull.error}`, { member, doltOutput: pull.error, operation: 'settle-pull' });
1028
1032
  }
1029
- const push = await command('bd dolt push', { member_name: member, silent: true, failSoft: true, label: `settle: post-resolve D-push for '${member}'` });
1033
+ const push = await command(bdSyncCommandFor('bd dolt push', { os: platform, shell }), { member_name: member, silent: true, failSoft: true, label: `settle: post-resolve D-push for '${member}'` });
1030
1034
  if (push && push.ok === false) {
1031
1035
  throw new DoltDivergedError(`[Dolt Settle] resolved every conflict but the republishing push was still rejected for member '${member}': ${push.error}`, { member, doltOutput: push.error, operation: 'settle-push' });
1032
1036
  }
@@ -1072,7 +1076,9 @@ export async function detectMemberPlatform({ command, member }) {
1072
1076
  { member, doltOutput: text },
1073
1077
  );
1074
1078
  }
1075
- return { platform: match[1], arch: match[2] === 'arm64' ? 'arm64' : 'x64' };
1079
+ // The member's real arch, never coerced to x64: an unpublished arch must
1080
+ // hit resolveDoltAsset's named error, not download the x64 build.
1081
+ return { platform: match[1], arch: match[2] };
1076
1082
  }
1077
1083
 
1078
1084
  /**