@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.
- package/README.md +49 -4
- package/dist/agents/backlog-groomer.md +5 -0
- package/dist/agents/ci-watcher.md +5 -0
- package/dist/agents/deployer.md +20 -2
- package/dist/agents/doer.md +38 -2
- package/dist/agents/harvester.md +12 -9
- package/dist/agents/integ-test-runner.md +5 -0
- package/dist/agents/kb-reconciler.md +6 -0
- package/dist/agents/plan-reviewer.md +5 -0
- package/dist/agents/planner.md +5 -0
- package/dist/agents/regression-test-runner.md +5 -0
- package/dist/agents/reviewer.md +67 -15
- package/dist/agents/schemas/deployer-output.json +5 -0
- package/dist/agents/schemas/doer-output.json +78 -2
- package/dist/agents/schemas/reviewer-output.json +104 -2
- package/dist/cli/auth.js +5 -1
- package/dist/cli/beads-pin.js +6 -7
- package/dist/cli/claude-mod.d.ts +75 -0
- package/dist/cli/claude-mod.js +288 -0
- package/dist/cli/dolt-install.d.ts +1 -1
- package/dist/cli/dolt-install.js +5 -1
- package/dist/cli/fleet-se-guard.d.ts +8 -0
- package/dist/cli/fleet-se-guard.js +19 -3
- package/dist/cli/install-guard.d.ts +9 -0
- package/dist/cli/install-guard.js +24 -0
- package/dist/cli/install.d.ts +12 -0
- package/dist/cli/install.js +180 -20
- package/dist/cli/kb-profile.d.ts +16 -0
- package/dist/cli/kb-profile.js +81 -0
- package/dist/cli/start.js +3 -0
- package/dist/cli/uninstall.js +13 -3
- package/dist/cli/update.d.ts +4 -0
- package/dist/cli/update.js +19 -3
- package/dist/commands/kb-server.d.ts +10 -1
- package/dist/commands/kb-server.js +285 -11
- package/dist/index.js +22 -1
- package/dist/os/git-executable.d.ts +57 -0
- package/dist/os/git-executable.js +85 -0
- package/dist/os/go-concurrency.d.ts +44 -0
- package/dist/os/go-concurrency.js +53 -0
- package/dist/os/index.d.ts +1 -0
- package/dist/os/index.js +1 -0
- package/dist/os/linux.d.ts +2 -0
- package/dist/os/linux.js +10 -1
- package/dist/os/os-commands.d.ts +25 -0
- package/dist/os/os-commands.js +2 -0
- package/dist/os/windows-executable.d.ts +53 -0
- package/dist/os/windows-executable.js +185 -0
- package/dist/os/windows-gitbash.d.ts +23 -14
- package/dist/os/windows-gitbash.js +40 -16
- package/dist/os/windows.d.ts +2 -0
- package/dist/os/windows.js +37 -6
- package/dist/paths.d.ts +10 -1
- package/dist/paths.js +19 -2
- package/dist/services/agy-project.d.ts +7 -1
- package/dist/services/agy-project.js +7 -2
- package/dist/services/auth-socket.d.ts +18 -0
- package/dist/services/auth-socket.js +30 -4
- package/dist/services/credential-store.d.ts +33 -0
- package/dist/services/credential-store.js +79 -2
- package/dist/services/http-transport.d.ts +29 -0
- package/dist/services/http-transport.js +166 -37
- package/dist/services/kb-tool-profile.d.ts +36 -0
- package/dist/services/kb-tool-profile.js +88 -0
- package/dist/services/knowledge/bible-blob-id.js +10 -1
- package/dist/services/knowledge/bible-import.d.ts +108 -0
- package/dist/services/knowledge/bible-import.js +137 -4
- package/dist/services/knowledge/file-hash.js +6 -5
- package/dist/services/knowledge/http-provider.d.ts +303 -20
- package/dist/services/knowledge/http-provider.js +795 -125
- package/dist/services/knowledge/kb-config.d.ts +65 -1
- package/dist/services/knowledge/kb-config.js +143 -3
- package/dist/services/knowledge/kb-http-auth-state.d.ts +26 -0
- package/dist/services/knowledge/kb-http-auth-state.js +40 -0
- package/dist/services/knowledge/kb-providers.d.ts +9 -2
- package/dist/services/knowledge/kb-providers.js +67 -37
- package/dist/services/knowledge/kb-removed-scope-keys.js +1 -1
- package/dist/services/knowledge/kb-self.d.ts +122 -9
- package/dist/services/knowledge/kb-self.js +196 -36
- package/dist/services/knowledge/member-bible-view.js +16 -3
- package/dist/services/knowledge/path-validation.d.ts +7 -0
- package/dist/services/knowledge/path-validation.js +11 -0
- package/dist/services/knowledge/project-slug.js +3 -2
- package/dist/services/knowledge/repository-header.d.ts +77 -0
- package/dist/services/knowledge/repository-header.js +233 -0
- package/dist/services/knowledge/require-sqlite-project.d.ts +1 -1
- package/dist/services/knowledge/require-sqlite-project.js +1 -1
- package/dist/services/knowledge/sqlite-provider.d.ts +169 -0
- package/dist/services/knowledge/sqlite-provider.js +416 -4
- package/dist/services/knowledge/types.d.ts +15 -2
- package/dist/services/member-busy.d.ts +12 -0
- package/dist/services/member-busy.js +20 -0
- package/dist/services/member-config-io.d.ts +3 -2
- package/dist/services/member-config-io.js +7 -4
- package/dist/services/member-fleet-install.js +1 -0
- package/dist/services/member-tool-allowlist.d.ts +1 -1
- package/dist/services/member-tool-allowlist.js +8 -4
- package/dist/services/port-holder.js +2 -1
- package/dist/services/service-manager/types.d.ts +17 -1
- package/dist/services/service-manager/windows.d.ts +7 -2
- package/dist/services/service-manager/windows.js +28 -11
- package/dist/services/service-notice.d.ts +7 -0
- package/dist/services/service-notice.js +19 -0
- package/dist/services/session-registry.d.ts +13 -0
- package/dist/services/session-registry.js +13 -0
- package/dist/services/session-roots.d.ts +67 -0
- package/dist/services/session-roots.js +126 -0
- package/dist/services/statusline.d.ts +21 -0
- package/dist/services/statusline.js +97 -1
- package/dist/services/supervisor-service-cleanup.js +2 -1
- package/dist/services/tool-registry.js +108 -20
- package/dist/services/tool-scope.d.ts +34 -1
- package/dist/services/tool-scope.js +27 -2
- package/dist/services/vcs/azure-devops.js +10 -0
- package/dist/services/vcs/bitbucket.d.ts +22 -1
- package/dist/services/vcs/bitbucket.js +163 -17
- package/dist/services/vcs/types.d.ts +25 -2
- package/dist/services/watch/project-resolver.js +2 -1
- package/dist/skills/pm/cost.md +5 -1
- package/dist/skills/pm/index.md +9 -9
- package/dist/skills/pm/sprint.md +2 -1
- package/dist/tools/check-status.d.ts +51 -0
- package/dist/tools/check-status.js +124 -12
- package/dist/tools/code-intelligence-freshness.js +1 -1
- package/dist/tools/code-intelligence-gitnexus.d.ts +19 -0
- package/dist/tools/code-intelligence-gitnexus.js +166 -9
- package/dist/tools/code-intelligence-readiness.d.ts +58 -1
- package/dist/tools/code-intelligence-readiness.js +93 -8
- package/dist/tools/code-intelligence-reindex.d.ts +25 -1
- package/dist/tools/code-intelligence-reindex.js +76 -4
- package/dist/tools/code-intelligence.d.ts +1 -1
- package/dist/tools/code-intelligence.js +1 -1
- package/dist/tools/execute-command.js +14 -8
- package/dist/tools/execute-prompt.js +6 -2
- package/dist/tools/fleet-snapshot.d.ts +21 -0
- package/dist/tools/fleet-snapshot.js +78 -0
- package/dist/tools/kb-bible-commit.d.ts +25 -11
- package/dist/tools/kb-bible-commit.js +142 -33
- package/dist/tools/kb-capture.d.ts +2 -2
- package/dist/tools/kb-context.js +47 -27
- package/dist/tools/kb-demote.d.ts +27 -0
- package/dist/tools/kb-demote.js +37 -0
- package/dist/tools/kb-export.d.ts +35 -3
- package/dist/tools/kb-export.js +56 -13
- package/dist/tools/kb-feedback.d.ts +2 -0
- package/dist/tools/kb-feedback.js +17 -7
- package/dist/tools/kb-harvest.js +28 -9
- package/dist/tools/kb-import.d.ts +18 -2
- package/dist/tools/kb-import.js +24 -9
- package/dist/tools/kb-invalidate.d.ts +11 -3
- package/dist/tools/kb-invalidate.js +80 -7
- package/dist/tools/kb-list.js +38 -10
- package/dist/tools/kb-promote.js +6 -4
- package/dist/tools/kb-query.d.ts +3 -0
- package/dist/tools/kb-query.js +181 -37
- package/dist/tools/kb-session-prime.d.ts +4 -4
- package/dist/tools/kb-session-prime.js +89 -9
- package/dist/tools/kb-setup.d.ts +20 -0
- package/dist/tools/kb-setup.js +149 -11
- package/dist/tools/list-members.js +1 -1
- package/dist/tools/member-detail.js +7 -3
- package/dist/tools/provision-vcs-auth.d.ts +28 -3
- package/dist/tools/provision-vcs-auth.js +53 -7
- package/dist/tools/receive-files.js +7 -4
- package/dist/tools/send-files.js +5 -4
- package/dist/tools/send-message.d.ts +3 -0
- package/dist/tools/send-message.js +15 -2
- package/dist/tools/stop-prompt.js +3 -1
- package/dist/tools/vcs-credential-exec.d.ts +45 -3
- package/dist/tools/vcs-credential-exec.js +90 -11
- package/dist/utils/process-utils.js +5 -1
- package/dist/utils/redact-known-secrets.d.ts +17 -0
- package/dist/utils/redact-known-secrets.js +70 -0
- package/dist/utils/skill-matrix.js +1 -1
- package/dist/utils/vcs-provider-detect.js +2 -2
- package/dist/workflows/auto-sprint.js +245 -9
- package/package.json +10 -7
- package/packages/apra-fleet-client/package.json +1 -1
- package/packages/apra-fleet-client/src/client/api.mjs +172 -19
- package/packages/apra-fleet-client/src/client/reconnecting-transport.mjs +35 -2
- package/packages/apra-fleet-client/src/client/transport.mjs +6 -0
- package/packages/apra-fleet-se/apra-pm/agents/backlog-groomer.md +5 -0
- package/packages/apra-fleet-se/apra-pm/agents/ci-watcher.md +5 -0
- package/packages/apra-fleet-se/apra-pm/agents/deployer.md +20 -2
- package/packages/apra-fleet-se/apra-pm/agents/doer.md +38 -2
- package/packages/apra-fleet-se/apra-pm/agents/harvester.md +12 -9
- package/packages/apra-fleet-se/apra-pm/agents/integ-test-runner.md +5 -0
- package/packages/apra-fleet-se/apra-pm/agents/kb-reconciler.md +6 -0
- package/packages/apra-fleet-se/apra-pm/agents/plan-reviewer.md +5 -0
- package/packages/apra-fleet-se/apra-pm/agents/planner.md +5 -0
- package/packages/apra-fleet-se/apra-pm/agents/regression-test-runner.md +5 -0
- package/packages/apra-fleet-se/apra-pm/agents/reviewer.md +67 -15
- package/packages/apra-fleet-se/apra-pm/agents/schemas/deployer-output.json +5 -0
- package/packages/apra-fleet-se/apra-pm/agents/schemas/doer-output.json +78 -2
- package/packages/apra-fleet-se/apra-pm/agents/schemas/reviewer-output.json +104 -2
- package/packages/apra-fleet-se/apra-pm/skills/pm/cost.md +5 -1
- package/packages/apra-fleet-se/apra-pm/skills/pm/index.md +9 -9
- package/packages/apra-fleet-se/apra-pm/skills/pm/sprint.md +2 -1
- package/packages/apra-fleet-se/bin/cli.mjs +104 -31
- package/packages/apra-fleet-se/bin/serve.mjs +46 -8
- package/packages/apra-fleet-se/fleet-sprint/abort.mjs +184 -32
- package/packages/apra-fleet-se/fleet-sprint/bd-sync-command.mjs +69 -0
- package/packages/apra-fleet-se/fleet-sprint/beads-children.mjs +21 -0
- package/packages/apra-fleet-se/fleet-sprint/beads-lock-probe.mjs +176 -0
- package/packages/apra-fleet-se/fleet-sprint/beads-reachability.mjs +126 -0
- package/packages/apra-fleet-se/fleet-sprint/beads-scope.mjs +158 -1
- package/packages/apra-fleet-se/fleet-sprint/contracts.mjs +82 -2
- package/packages/apra-fleet-se/fleet-sprint/coordination.mjs +23 -6
- package/packages/apra-fleet-se/fleet-sprint/decision-notify.mjs +338 -0
- package/packages/apra-fleet-se/fleet-sprint/decision-wait.mjs +731 -0
- package/packages/apra-fleet-se/fleet-sprint/decisions.mjs +372 -0
- package/packages/apra-fleet-se/fleet-sprint/dispatch-role.mjs +44 -11
- package/packages/apra-fleet-se/fleet-sprint/docs/README.md +4 -1
- package/packages/apra-fleet-se/fleet-sprint/dolt-settle.mjs +9 -3
- package/packages/apra-fleet-se/fleet-sprint/dolt-sync.mjs +314 -19
- package/packages/apra-fleet-se/fleet-sprint/errors.mjs +72 -4
- package/packages/apra-fleet-se/fleet-sprint/git-sync.mjs +7 -1
- package/packages/apra-fleet-se/fleet-sprint/git-topology.mjs +112 -1
- package/packages/apra-fleet-se/fleet-sprint/guarded-modules.mjs +36 -2
- package/packages/apra-fleet-se/fleet-sprint/kb.mjs +736 -101
- package/packages/apra-fleet-se/fleet-sprint/member-init-probe.mjs +1 -1
- package/packages/apra-fleet-se/fleet-sprint/member-provisioning.mjs +7 -1
- package/packages/apra-fleet-se/fleet-sprint/phases/deploy.mjs +49 -2
- package/packages/apra-fleet-se/fleet-sprint/phases/develop.mjs +206 -3
- package/packages/apra-fleet-se/fleet-sprint/phases/final-review.mjs +61 -3
- package/packages/apra-fleet-se/fleet-sprint/phases/harvest.mjs +81 -31
- package/packages/apra-fleet-se/fleet-sprint/phases/plan.mjs +7 -3
- package/packages/apra-fleet-se/fleet-sprint/phases/publish-pr.mjs +39 -14
- package/packages/apra-fleet-se/fleet-sprint/phases/re-review.mjs +17 -1
- package/packages/apra-fleet-se/fleet-sprint/phases/review.mjs +18 -3
- package/packages/apra-fleet-se/fleet-sprint/pr-body.mjs +14 -1
- package/packages/apra-fleet-se/fleet-sprint/prompts.mjs +32 -5
- package/packages/apra-fleet-se/fleet-sprint/runner.js +824 -98
- package/packages/apra-fleet-se/fleet-sprint/se-os-commands.mjs +4 -2
- package/packages/apra-fleet-se/fleet-sprint/se-posix.mjs +54 -1
- package/packages/apra-fleet-se/fleet-sprint/se-windows.mjs +29 -2
- package/packages/apra-fleet-se/fleet-sprint/set-aside.mjs +288 -0
- package/packages/apra-fleet-se/fleet-sprint/skills/fleet-supervisor/SKILL.md +3 -2
- package/packages/apra-fleet-se/fleet-sprint/sprint-args.mjs +20 -0
- package/packages/apra-fleet-se/fleet-sprint/sprint-report.mjs +21 -0
- package/packages/apra-fleet-se/fleet-sprint/sprint-state.mjs +9 -0
- package/packages/apra-fleet-se/fleet-sprint/vcs-auth.mjs +605 -32
- package/packages/apra-fleet-se/fleet-sprint/vcs-providers/bitbucket.mjs +811 -17
- package/packages/apra-fleet-se/fleet-sprint/vcs-providers/index.mjs +89 -1
- package/packages/apra-fleet-se/fleet-sprint/viewer-extensions.mjs +225 -2
- package/packages/apra-fleet-se/fleet-sprint/worklists.mjs +59 -3
- package/packages/apra-fleet-se/src/supervisor/api.mjs +148 -8
- package/packages/apra-fleet-se/src/supervisor/dashboard.mjs +6 -3
- package/packages/apra-fleet-se/src/supervisor/dolt-mutex.mjs +30 -10
- package/packages/apra-fleet-se/src/supervisor/fleet-members.mjs +17 -4
- package/packages/apra-fleet-se/src/supervisor/history.mjs +8 -1
- package/packages/apra-fleet-se/src/supervisor/id-allocator.mjs +92 -2
- package/packages/apra-fleet-se/src/supervisor/proxy.mjs +26 -1
- package/packages/apra-fleet-se/src/supervisor/server.mjs +151 -8
- package/packages/apra-fleet-se/src/supervisor/spawner.mjs +11 -9
- package/packages/apra-fleet-se/src/supervisor/watchdog.mjs +7 -1
- package/packages/apra-fleet-workflow/package.json +2 -1
- package/packages/apra-fleet-workflow/src/viewer/index.mjs +86 -5
- package/packages/apra-fleet-workflow/src/viewer/request-guard.mjs +222 -0
- package/packages/apra-fleet-workflow/src/workflow/index.mjs +34 -2
- package/plugins/claude-code/fleet-status/.claude-plugin/plugin.json +7 -0
- package/plugins/claude-code/fleet-status/hooks/hooks.json +1 -0
- package/plugins/claude-code/fleet-status/hooks/register.tsx +906 -0
- package/plugins/claude-code/fleet-status/types/index.d.ts +88 -0
- package/skills/fleet/auth-bitbucket.md +47 -20
- package/skills/fleet/onboarding.md +1 -1
- package/skills/fleet/skill-matrix.md +3 -3
- 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
|
-
|
|
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))}) --
|
|
690
|
-
`
|
|
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
|
-
|
|
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 --
|
|
702
|
-
`max_turns=${
|
|
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
|
-
(
|
|
710
|
-
?
|
|
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
|
-
|
|
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
|
-
|
|
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://
|
|
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
|
-
|
|
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
|
/**
|