@apralabs/apra-fleet 0.4.1 → 0.4.3
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 +53 -12
- package/dist/agents/backlog-groomer.md +42 -21
- package/dist/agents/ci-watcher.md +14 -0
- package/dist/agents/deployer.md +59 -46
- package/dist/agents/doer.md +157 -134
- package/dist/agents/harvester.md +31 -32
- package/dist/agents/integ-test-runner.md +92 -113
- package/dist/agents/kb-reconciler.md +40 -42
- package/dist/agents/plan-reviewer.md +139 -63
- package/dist/agents/planner.md +176 -100
- package/dist/agents/regression-test-runner.md +77 -81
- package/dist/agents/reviewer.md +69 -85
- package/dist/agents/schemas/integ-test-runner-output.json +1 -1
- package/dist/agents/schemas/plan-reviewer-output.json +37 -0
- package/dist/agents/schemas/regression-test-runner-output.json +4 -17
- package/dist/cli/agent-transform.d.ts +83 -2
- package/dist/cli/agent-transform.d.ts.map +1 -1
- package/dist/cli/agent-transform.js +266 -21
- package/dist/cli/agent-transform.js.map +1 -1
- package/dist/cli/auth.d.ts.map +1 -1
- package/dist/cli/auth.js +29 -11
- package/dist/cli/auth.js.map +1 -1
- package/dist/cli/config.d.ts +7 -5
- package/dist/cli/config.d.ts.map +1 -1
- package/dist/cli/config.js +44 -43
- package/dist/cli/config.js.map +1 -1
- package/dist/cli/install.d.ts +33 -0
- package/dist/cli/install.d.ts.map +1 -1
- package/dist/cli/install.js +294 -61
- package/dist/cli/install.js.map +1 -1
- package/dist/cli/kb-directives.d.ts.map +1 -1
- package/dist/cli/kb-directives.js +2 -1
- package/dist/cli/kb-directives.js.map +1 -1
- package/dist/cli/register-member.d.ts.map +1 -1
- package/dist/cli/register-member.js +7 -3
- package/dist/cli/register-member.js.map +1 -1
- package/dist/cli/start.d.ts.map +1 -1
- package/dist/cli/start.js +7 -0
- package/dist/cli/start.js.map +1 -1
- package/dist/cli/uninstall.d.ts.map +1 -1
- package/dist/cli/uninstall.js +5 -3
- package/dist/cli/uninstall.js.map +1 -1
- package/dist/cli/watch.d.ts +26 -3
- package/dist/cli/watch.d.ts.map +1 -1
- package/dist/cli/watch.js +41 -9
- package/dist/cli/watch.js.map +1 -1
- package/dist/commands/kb-server.d.ts +3 -0
- package/dist/commands/kb-server.d.ts.map +1 -1
- package/dist/commands/kb-server.js +43 -3
- package/dist/commands/kb-server.js.map +1 -1
- package/dist/index.js +3 -3
- package/dist/os/git-bash-candidates.d.ts +35 -0
- package/dist/os/git-bash-candidates.d.ts.map +1 -0
- package/dist/os/git-bash-candidates.js +46 -0
- package/dist/os/git-bash-candidates.js.map +1 -0
- package/dist/os/index.d.ts +13 -4
- package/dist/os/index.d.ts.map +1 -1
- package/dist/os/index.js +17 -2
- package/dist/os/index.js.map +1 -1
- package/dist/os/linux.d.ts +6 -0
- package/dist/os/linux.d.ts.map +1 -1
- package/dist/os/linux.js +36 -3
- package/dist/os/linux.js.map +1 -1
- package/dist/os/os-commands.d.ts +68 -2
- package/dist/os/os-commands.d.ts.map +1 -1
- package/dist/os/os-commands.js.map +1 -1
- package/dist/os/windows-gitbash.d.ts +98 -0
- package/dist/os/windows-gitbash.d.ts.map +1 -0
- package/dist/os/windows-gitbash.js +259 -0
- package/dist/os/windows-gitbash.js.map +1 -0
- package/dist/os/windows.d.ts +6 -0
- package/dist/os/windows.d.ts.map +1 -1
- package/dist/os/windows.js +73 -8
- package/dist/os/windows.js.map +1 -1
- package/dist/providers/agy.d.ts +118 -8
- package/dist/providers/agy.d.ts.map +1 -1
- package/dist/providers/agy.js +580 -55
- package/dist/providers/agy.js.map +1 -1
- package/dist/providers/claude.d.ts +83 -4
- package/dist/providers/claude.d.ts.map +1 -1
- package/dist/providers/claude.js +365 -12
- package/dist/providers/claude.js.map +1 -1
- package/dist/providers/codex.d.ts +7 -4
- package/dist/providers/codex.d.ts.map +1 -1
- package/dist/providers/codex.js +24 -4
- package/dist/providers/codex.js.map +1 -1
- package/dist/providers/copilot.d.ts +7 -4
- package/dist/providers/copilot.d.ts.map +1 -1
- package/dist/providers/copilot.js +27 -4
- package/dist/providers/copilot.js.map +1 -1
- package/dist/providers/index.d.ts +0 -1
- package/dist/providers/index.d.ts.map +1 -1
- package/dist/providers/index.js +0 -3
- package/dist/providers/index.js.map +1 -1
- package/dist/providers/none.d.ts +7 -4
- package/dist/providers/none.d.ts.map +1 -1
- package/dist/providers/none.js +22 -4
- package/dist/providers/none.js.map +1 -1
- package/dist/providers/opencode.d.ts +6 -3
- package/dist/providers/opencode.d.ts.map +1 -1
- package/dist/providers/opencode.js +27 -4
- package/dist/providers/opencode.js.map +1 -1
- package/dist/providers/provider.d.ts +215 -11
- package/dist/providers/provider.d.ts.map +1 -1
- package/dist/providers/provider.js +58 -2
- package/dist/providers/provider.js.map +1 -1
- package/dist/services/agent-provisioner.js +2 -2
- package/dist/services/agent-provisioner.js.map +1 -1
- package/dist/services/agy-project.d.ts +102 -0
- package/dist/services/agy-project.d.ts.map +1 -0
- package/dist/services/agy-project.js +356 -0
- package/dist/services/agy-project.js.map +1 -0
- package/dist/services/auth-socket.js +4 -4
- package/dist/services/auth-web.js +1 -1
- package/dist/services/cloud/activity.js +2 -2
- package/dist/services/cloud/activity.js.map +1 -1
- package/dist/services/cloud/lifecycle.d.ts.map +1 -1
- package/dist/services/cloud/lifecycle.js +33 -4
- package/dist/services/cloud/lifecycle.js.map +1 -1
- package/dist/services/context-admission.d.ts.map +1 -1
- package/dist/services/context-admission.js +9 -7
- package/dist/services/context-admission.js.map +1 -1
- package/dist/services/credential-cleanup.d.ts.map +1 -1
- package/dist/services/credential-cleanup.js +47 -10
- package/dist/services/credential-cleanup.js.map +1 -1
- package/dist/services/exit-drain.d.ts +44 -0
- package/dist/services/exit-drain.d.ts.map +1 -0
- package/dist/services/exit-drain.js +52 -0
- package/dist/services/exit-drain.js.map +1 -0
- package/dist/services/github-app.d.ts.map +1 -1
- package/dist/services/github-app.js +32 -4
- package/dist/services/github-app.js.map +1 -1
- package/dist/services/http-transport.d.ts +1 -0
- package/dist/services/http-transport.d.ts.map +1 -1
- package/dist/services/http-transport.js +48 -1
- package/dist/services/http-transport.js.map +1 -1
- package/dist/services/knowledge/kb-config.d.ts +42 -0
- package/dist/services/knowledge/kb-config.d.ts.map +1 -0
- package/dist/services/knowledge/kb-config.js +54 -0
- package/dist/services/knowledge/kb-config.js.map +1 -0
- package/dist/services/knowledge/kb-providers.d.ts +7 -1
- package/dist/services/knowledge/kb-providers.d.ts.map +1 -1
- package/dist/services/knowledge/kb-providers.js +191 -17
- package/dist/services/knowledge/kb-providers.js.map +1 -1
- package/dist/services/knowledge/require-sqlite-project.d.ts +32 -0
- package/dist/services/knowledge/require-sqlite-project.d.ts.map +1 -0
- package/dist/services/knowledge/require-sqlite-project.js +38 -0
- package/dist/services/knowledge/require-sqlite-project.js.map +1 -0
- package/dist/services/member-home.d.ts +1 -1
- package/dist/services/member-home.d.ts.map +1 -1
- package/dist/services/member-home.js +15 -12
- package/dist/services/member-home.js.map +1 -1
- package/dist/services/model-pricing.d.ts.map +1 -1
- package/dist/services/model-pricing.js +7 -8
- package/dist/services/model-pricing.js.map +1 -1
- package/dist/services/orphan-recovery.d.ts +6 -3
- package/dist/services/orphan-recovery.d.ts.map +1 -1
- package/dist/services/orphan-recovery.js +17 -14
- package/dist/services/orphan-recovery.js.map +1 -1
- package/dist/services/preflight-check.js +2 -2
- package/dist/services/preflight-check.js.map +1 -1
- package/dist/services/secret-token.d.ts +38 -0
- package/dist/services/secret-token.d.ts.map +1 -0
- package/dist/services/secret-token.js +51 -0
- package/dist/services/secret-token.js.map +1 -0
- package/dist/services/service-manager/types.d.ts +3 -1
- package/dist/services/service-manager/types.d.ts.map +1 -1
- package/dist/services/service-manager/windows.d.ts +14 -2
- package/dist/services/service-manager/windows.d.ts.map +1 -1
- package/dist/services/service-manager/windows.js +65 -7
- package/dist/services/service-manager/windows.js.map +1 -1
- package/dist/services/shell-probe.d.ts +131 -0
- package/dist/services/shell-probe.d.ts.map +1 -0
- package/dist/services/shell-probe.js +210 -0
- package/dist/services/shell-probe.js.map +1 -0
- package/dist/services/singleton.d.ts +2 -0
- package/dist/services/singleton.d.ts.map +1 -1
- package/dist/services/singleton.js +1 -1
- package/dist/services/singleton.js.map +1 -1
- package/dist/services/ssh.d.ts.map +1 -1
- package/dist/services/ssh.js +60 -4
- package/dist/services/ssh.js.map +1 -1
- package/dist/services/stall/find-log-file.d.ts.map +1 -1
- package/dist/services/stall/find-log-file.js +22 -16
- package/dist/services/stall/find-log-file.js.map +1 -1
- package/dist/services/stall/read-log-tail.d.ts.map +1 -1
- package/dist/services/stall/read-log-tail.js +26 -15
- package/dist/services/stall/read-log-tail.js.map +1 -1
- package/dist/services/stall/stall-detector.d.ts +53 -4
- package/dist/services/stall/stall-detector.d.ts.map +1 -1
- package/dist/services/stall/stall-detector.js +212 -34
- package/dist/services/stall/stall-detector.js.map +1 -1
- package/dist/services/stall/stall-poller.d.ts.map +1 -1
- package/dist/services/stall/stall-poller.js +35 -42
- package/dist/services/stall/stall-poller.js.map +1 -1
- package/dist/services/strategy.d.ts +9 -0
- package/dist/services/strategy.d.ts.map +1 -1
- package/dist/services/strategy.js +119 -8
- package/dist/services/strategy.js.map +1 -1
- package/dist/services/substitution-engine.js +2 -2
- package/dist/services/substitution-engine.js.map +1 -1
- package/dist/services/tool-registry.d.ts.map +1 -1
- package/dist/services/tool-registry.js +5 -3
- package/dist/services/tool-registry.js.map +1 -1
- package/dist/services/user-config.js +1 -1
- package/dist/services/user-config.js.map +1 -1
- package/dist/services/vcs/azure-devops.d.ts +67 -2
- package/dist/services/vcs/azure-devops.d.ts.map +1 -1
- package/dist/services/vcs/azure-devops.js +281 -15
- package/dist/services/vcs/azure-devops.js.map +1 -1
- package/dist/services/vcs/bitbucket.d.ts.map +1 -1
- package/dist/services/vcs/bitbucket.js +16 -0
- package/dist/services/vcs/bitbucket.js.map +1 -1
- package/dist/services/vcs/github.d.ts.map +1 -1
- package/dist/services/vcs/github.js +24 -0
- package/dist/services/vcs/github.js.map +1 -1
- package/dist/services/vcs/types.d.ts +123 -2
- package/dist/services/vcs/types.d.ts.map +1 -1
- package/dist/skills/fleet-sprint-cli/SKILL.md +20 -1
- package/dist/skills/pm/SKILL.md +1 -2
- package/dist/skills/pm/cost.md +0 -4
- package/dist/skills/pm/fleet-addendum.md +2 -3
- package/dist/tools/check-status.d.ts +7 -4
- package/dist/tools/check-status.d.ts.map +1 -1
- package/dist/tools/check-status.js +5 -3
- package/dist/tools/check-status.js.map +1 -1
- package/dist/tools/cloud-control.js +2 -2
- package/dist/tools/cloud-control.js.map +1 -1
- package/dist/tools/compose-permissions.d.ts +6 -0
- package/dist/tools/compose-permissions.d.ts.map +1 -1
- package/dist/tools/compose-permissions.js +211 -50
- package/dist/tools/compose-permissions.js.map +1 -1
- package/dist/tools/credential-store-set.js +1 -1
- package/dist/tools/execute-command.d.ts.map +1 -1
- package/dist/tools/execute-command.js +56 -29
- package/dist/tools/execute-command.js.map +1 -1
- package/dist/tools/execute-prompt.d.ts +15 -2
- package/dist/tools/execute-prompt.d.ts.map +1 -1
- package/dist/tools/execute-prompt.js +1214 -873
- package/dist/tools/execute-prompt.js.map +1 -1
- package/dist/tools/kb-capture.d.ts +2 -2
- package/dist/tools/kb-capture.d.ts.map +1 -1
- package/dist/tools/kb-capture.js +29 -5
- package/dist/tools/kb-capture.js.map +1 -1
- package/dist/tools/kb-export.d.ts +2 -2
- package/dist/tools/kb-export.d.ts.map +1 -1
- package/dist/tools/kb-export.js +3 -28
- package/dist/tools/kb-export.js.map +1 -1
- package/dist/tools/kb-feedback.d.ts.map +1 -1
- package/dist/tools/kb-feedback.js +3 -1
- package/dist/tools/kb-feedback.js.map +1 -1
- package/dist/tools/kb-freshness-sweep.d.ts.map +1 -1
- package/dist/tools/kb-freshness-sweep.js +3 -1
- package/dist/tools/kb-freshness-sweep.js.map +1 -1
- package/dist/tools/kb-import.d.ts.map +1 -1
- package/dist/tools/kb-import.js +2 -1
- package/dist/tools/kb-import.js.map +1 -1
- package/dist/tools/kb-list.d.ts.map +1 -1
- package/dist/tools/kb-list.js +3 -1
- package/dist/tools/kb-list.js.map +1 -1
- package/dist/tools/kb-query.d.ts +2 -2
- package/dist/tools/kb-reconcile-prefilter.d.ts.map +1 -1
- package/dist/tools/kb-reconcile-prefilter.js +3 -1
- package/dist/tools/kb-reconcile-prefilter.js.map +1 -1
- package/dist/tools/kb-resolve-contradiction.d.ts.map +1 -1
- package/dist/tools/kb-resolve-contradiction.js +3 -1
- package/dist/tools/kb-resolve-contradiction.js.map +1 -1
- package/dist/tools/kb-setup.d.ts.map +1 -1
- package/dist/tools/kb-setup.js +125 -20
- package/dist/tools/kb-setup.js.map +1 -1
- package/dist/tools/kb-stats.d.ts.map +1 -1
- package/dist/tools/kb-stats.js +64 -43
- package/dist/tools/kb-stats.js.map +1 -1
- package/dist/tools/list-members.d.ts +2 -2
- package/dist/tools/list-members.d.ts.map +1 -1
- package/dist/tools/list-members.js +7 -2
- package/dist/tools/list-members.js.map +1 -1
- package/dist/tools/member-detail.d.ts +2 -2
- package/dist/tools/member-detail.d.ts.map +1 -1
- package/dist/tools/member-detail.js +22 -3
- package/dist/tools/member-detail.js.map +1 -1
- package/dist/tools/member-reservation.d.ts +58 -1
- package/dist/tools/member-reservation.d.ts.map +1 -1
- package/dist/tools/member-reservation.js +71 -18
- package/dist/tools/member-reservation.js.map +1 -1
- package/dist/tools/monitor-task.d.ts.map +1 -1
- package/dist/tools/monitor-task.js +17 -2
- package/dist/tools/monitor-task.js.map +1 -1
- package/dist/tools/provision-auth.d.ts +80 -1
- package/dist/tools/provision-auth.d.ts.map +1 -1
- package/dist/tools/provision-auth.js +147 -59
- package/dist/tools/provision-auth.js.map +1 -1
- package/dist/tools/provision-vcs-auth.d.ts +96 -3
- package/dist/tools/provision-vcs-auth.d.ts.map +1 -1
- package/dist/tools/provision-vcs-auth.js +254 -88
- package/dist/tools/provision-vcs-auth.js.map +1 -1
- package/dist/tools/register-member.d.ts +21 -12
- package/dist/tools/register-member.d.ts.map +1 -1
- package/dist/tools/register-member.js +141 -16
- package/dist/tools/register-member.js.map +1 -1
- package/dist/tools/remove-member.d.ts.map +1 -1
- package/dist/tools/remove-member.js +29 -4
- package/dist/tools/remove-member.js.map +1 -1
- package/dist/tools/revoke-vcs-auth.js +2 -2
- package/dist/tools/revoke-vcs-auth.js.map +1 -1
- package/dist/tools/send-email.d.ts +2 -2
- package/dist/tools/setup-git-app.d.ts.map +1 -1
- package/dist/tools/setup-git-app.js +11 -7
- package/dist/tools/setup-git-app.js.map +1 -1
- package/dist/tools/setup-ssh-key.d.ts.map +1 -1
- package/dist/tools/setup-ssh-key.js +2 -1
- package/dist/tools/setup-ssh-key.js.map +1 -1
- package/dist/tools/shutdown-server.d.ts +2 -0
- package/dist/tools/shutdown-server.d.ts.map +1 -1
- package/dist/tools/shutdown-server.js +23 -1
- package/dist/tools/shutdown-server.js.map +1 -1
- package/dist/tools/stop-prompt.js +2 -2
- package/dist/tools/stop-prompt.js.map +1 -1
- package/dist/tools/update-agent-cli.js +2 -2
- package/dist/tools/update-agent-cli.js.map +1 -1
- package/dist/tools/update-member.d.ts +21 -12
- package/dist/tools/update-member.d.ts.map +1 -1
- package/dist/tools/update-member.js +61 -12
- package/dist/tools/update-member.js.map +1 -1
- package/dist/tools/vcs-credential-exec.d.ts +127 -0
- package/dist/tools/vcs-credential-exec.d.ts.map +1 -0
- package/dist/tools/vcs-credential-exec.js +197 -0
- package/dist/tools/vcs-credential-exec.js.map +1 -0
- package/dist/types.d.ts +24 -1
- package/dist/types.d.ts.map +1 -1
- package/dist/utils/agent-helpers.d.ts +36 -0
- package/dist/utils/agent-helpers.d.ts.map +1 -1
- package/dist/utils/agent-helpers.js +39 -1
- package/dist/utils/agent-helpers.js.map +1 -1
- package/dist/utils/log-helpers.d.ts.map +1 -1
- package/dist/utils/log-helpers.js +2 -2
- package/dist/utils/log-helpers.js.map +1 -1
- package/dist/utils/platform.d.ts +7 -0
- package/dist/utils/platform.d.ts.map +1 -1
- package/dist/utils/platform.js +11 -1
- package/dist/utils/platform.js.map +1 -1
- package/dist/utils/prompt-errors.d.ts.map +1 -1
- package/dist/utils/prompt-errors.js +7 -1
- package/dist/utils/prompt-errors.js.map +1 -1
- package/dist/utils/shell-escape.d.ts +16 -0
- package/dist/utils/shell-escape.d.ts.map +1 -1
- package/dist/utils/shell-escape.js +22 -2
- package/dist/utils/shell-escape.js.map +1 -1
- package/dist/utils/vcs-provider-detect.d.ts +65 -0
- package/dist/utils/vcs-provider-detect.d.ts.map +1 -0
- package/dist/utils/vcs-provider-detect.js +109 -0
- package/dist/utils/vcs-provider-detect.js.map +1 -0
- package/dist/utils/workspace-trust.d.ts +20 -17
- package/dist/utils/workspace-trust.d.ts.map +1 -1
- package/dist/utils/workspace-trust.js +91 -1
- package/dist/utils/workspace-trust.js.map +1 -1
- package/dist/workflows/auto-sprint.js +180 -32
- package/package.json +7 -5
- package/packages/apra-fleet-client/src/client/api.mjs +403 -12
- package/packages/apra-fleet-client/src/client/errors.mjs +6 -2
- package/packages/apra-fleet-se/apra-pm/agents/_shared/GRAPH-SEMANTICS.md +10 -2
- package/packages/apra-fleet-se/apra-pm/agents/backlog-groomer.md +42 -21
- package/packages/apra-fleet-se/apra-pm/agents/ci-watcher.md +14 -0
- package/packages/apra-fleet-se/apra-pm/agents/deployer.md +59 -46
- package/packages/apra-fleet-se/apra-pm/agents/doer.md +157 -134
- package/packages/apra-fleet-se/apra-pm/agents/harvester.md +31 -32
- package/packages/apra-fleet-se/apra-pm/agents/integ-test-runner.md +92 -113
- package/packages/apra-fleet-se/apra-pm/agents/kb-reconciler.md +40 -42
- package/packages/apra-fleet-se/apra-pm/agents/plan-reviewer.md +139 -63
- package/packages/apra-fleet-se/apra-pm/agents/planner.md +176 -100
- package/packages/apra-fleet-se/apra-pm/agents/regression-test-runner.md +77 -81
- package/packages/apra-fleet-se/apra-pm/agents/reviewer.md +69 -85
- package/packages/apra-fleet-se/apra-pm/agents/schemas/integ-test-runner-output.json +1 -1
- package/packages/apra-fleet-se/apra-pm/agents/schemas/plan-reviewer-output.json +37 -0
- package/packages/apra-fleet-se/apra-pm/agents/schemas/regression-test-runner-output.json +4 -17
- package/packages/apra-fleet-se/apra-pm/skills/pm/SKILL.md +1 -2
- package/packages/apra-fleet-se/apra-pm/skills/pm/cost.md +0 -4
- package/packages/apra-fleet-se/apra-pm/skills/pm/fleet-addendum.md +2 -3
- package/packages/apra-fleet-se/bin/cli.mjs +280 -3
- package/packages/apra-fleet-se/bin/serve.mjs +114 -5
- package/packages/apra-fleet-se/fleet-sprint/abort.mjs +481 -0
- package/packages/apra-fleet-se/fleet-sprint/beads-children.mjs +491 -0
- package/packages/apra-fleet-se/fleet-sprint/beads-identity-check.mjs +282 -0
- package/packages/apra-fleet-se/fleet-sprint/beads-identity.mjs +208 -0
- package/packages/apra-fleet-se/fleet-sprint/beads-scope.mjs +638 -0
- package/packages/apra-fleet-se/fleet-sprint/beads-transitions.mjs +301 -0
- package/packages/apra-fleet-se/fleet-sprint/branch-ensure.mjs +96 -0
- package/packages/apra-fleet-se/fleet-sprint/conflict-ladder.mjs +8 -0
- package/packages/apra-fleet-se/fleet-sprint/contracts.mjs +199 -34
- package/packages/apra-fleet-se/fleet-sprint/coordination.mjs +516 -0
- package/packages/apra-fleet-se/fleet-sprint/dispatch-failure.mjs +184 -0
- package/packages/apra-fleet-se/fleet-sprint/dispatch-role.mjs +1121 -0
- package/packages/apra-fleet-se/fleet-sprint/dispatch-safety-guard.mjs +216 -4
- package/packages/apra-fleet-se/fleet-sprint/docs/README.md +23 -8
- package/packages/apra-fleet-se/fleet-sprint/docs/dolt-manual-recovery-verified.md +10 -8
- package/packages/apra-fleet-se/fleet-sprint/docs/dolt-sync-redesign.md +285 -4
- package/packages/apra-fleet-se/fleet-sprint/docs/escalate-to-llm-design.md +3 -3
- package/packages/apra-fleet-se/fleet-sprint/docs/run-sprint-cycle-prelude-decision.md +215 -0
- package/packages/apra-fleet-se/fleet-sprint/docs/shared-orchestrator-reservation-design.md +12 -12
- package/packages/apra-fleet-se/fleet-sprint/docs/stabilization-log.md +14 -4
- package/packages/apra-fleet-se/fleet-sprint/dolt-literal-guard.mjs +56 -1
- package/packages/apra-fleet-se/fleet-sprint/dolt-settle.mjs +275 -99
- package/packages/apra-fleet-se/fleet-sprint/dolt-sync.mjs +1054 -39
- package/packages/apra-fleet-se/fleet-sprint/errors.mjs +308 -0
- package/packages/apra-fleet-se/fleet-sprint/explicit-id-create-guard.mjs +501 -0
- package/packages/apra-fleet-se/fleet-sprint/fatal-diagnostics.mjs +134 -0
- package/packages/apra-fleet-se/fleet-sprint/full-db-fetch-guard.mjs +102 -0
- package/packages/apra-fleet-se/fleet-sprint/git-sync.mjs +556 -0
- package/packages/apra-fleet-se/fleet-sprint/git-topology.mjs +495 -0
- package/packages/apra-fleet-se/fleet-sprint/guarded-modules.mjs +564 -0
- package/packages/apra-fleet-se/fleet-sprint/inline-ladder-guard.mjs +216 -0
- package/packages/apra-fleet-se/fleet-sprint/kb.mjs +728 -0
- package/packages/apra-fleet-se/fleet-sprint/mcp-result.mjs +75 -0
- package/packages/apra-fleet-se/fleet-sprint/member-provisioning.mjs +252 -0
- package/packages/apra-fleet-se/fleet-sprint/member-sync.mjs +581 -0
- package/packages/apra-fleet-se/fleet-sprint/member-target.mjs +93 -0
- package/packages/apra-fleet-se/fleet-sprint/newtask-text.mjs +266 -0
- package/packages/apra-fleet-se/fleet-sprint/parent-notes-staleness.mjs +201 -0
- package/packages/apra-fleet-se/fleet-sprint/phases/deploy.mjs +136 -0
- package/packages/apra-fleet-se/fleet-sprint/phases/develop.mjs +822 -0
- package/packages/apra-fleet-se/fleet-sprint/phases/ensure-sprint-branch.mjs +294 -0
- package/packages/apra-fleet-se/fleet-sprint/phases/final-review.mjs +403 -0
- package/packages/apra-fleet-se/fleet-sprint/phases/harvest.mjs +180 -0
- package/packages/apra-fleet-se/fleet-sprint/phases/integ-test.mjs +358 -0
- package/packages/apra-fleet-se/fleet-sprint/phases/plan.mjs +390 -0
- package/packages/apra-fleet-se/fleet-sprint/phases/publish-pr.mjs +323 -0
- package/packages/apra-fleet-se/fleet-sprint/phases/re-review.mjs +232 -0
- package/packages/apra-fleet-se/fleet-sprint/phases/regression-test.mjs +174 -0
- package/packages/apra-fleet-se/fleet-sprint/phases/replan.mjs +197 -0
- package/packages/apra-fleet-se/fleet-sprint/phases/review.mjs +305 -0
- package/packages/apra-fleet-se/fleet-sprint/prompts.mjs +559 -0
- package/packages/apra-fleet-se/fleet-sprint/role-policies.mjs +1416 -0
- package/packages/apra-fleet-se/fleet-sprint/round-session.mjs +100 -0
- package/packages/apra-fleet-se/fleet-sprint/runner.js +1672 -9072
- package/packages/apra-fleet-se/fleet-sprint/se-os-commands.mjs +134 -0
- package/packages/apra-fleet-se/fleet-sprint/se-posix.mjs +159 -0
- package/packages/apra-fleet-se/fleet-sprint/se-windows-gitbash.mjs +97 -0
- package/packages/apra-fleet-se/fleet-sprint/se-windows.mjs +143 -0
- package/packages/apra-fleet-se/fleet-sprint/shell-command-guard.mjs +304 -0
- package/packages/apra-fleet-se/fleet-sprint/skills/fleet-sprint-cli/SKILL.md +20 -1
- package/packages/apra-fleet-se/fleet-sprint/skills/fleet-supervisor/SKILL.md +21 -2
- package/packages/apra-fleet-se/fleet-sprint/sprint-args.mjs +454 -0
- package/packages/apra-fleet-se/fleet-sprint/sprint-report.mjs +239 -0
- package/packages/apra-fleet-se/fleet-sprint/sprint-state.mjs +163 -0
- package/packages/apra-fleet-se/fleet-sprint/unbracketed-push-guard.mjs +234 -0
- package/packages/apra-fleet-se/fleet-sprint/usage-limit-controller.mjs +211 -0
- package/packages/apra-fleet-se/fleet-sprint/vcs-auth.mjs +1279 -0
- package/packages/apra-fleet-se/fleet-sprint/vcs-module.mjs +204 -19
- package/packages/apra-fleet-se/fleet-sprint/vcs-providers/azure-devops.mjs +707 -12
- package/packages/apra-fleet-se/fleet-sprint/vcs-providers/bitbucket.mjs +28 -0
- package/packages/apra-fleet-se/fleet-sprint/vcs-providers/dolt.mjs +33 -4
- package/packages/apra-fleet-se/fleet-sprint/vcs-providers/github.mjs +191 -43
- package/packages/apra-fleet-se/fleet-sprint/vcs-providers/index.mjs +333 -6
- package/packages/apra-fleet-se/fleet-sprint/vcs-providers/shell-helpers.mjs +165 -0
- package/packages/apra-fleet-se/fleet-sprint/viewer-extensions.mjs +167 -37
- package/packages/apra-fleet-se/fleet-sprint/worklists.mjs +559 -0
- package/packages/apra-fleet-se/package.json +1 -1
- package/packages/apra-fleet-workflow/src/viewer/index.mjs +178 -1
- package/packages/apra-fleet-workflow/src/workflow/index.mjs +478 -32
- package/skills/fleet/SKILL.md +27 -16
- package/skills/fleet/auth-azdevops.md +57 -7
- package/skills/fleet/auth-bitbucket.md +5 -5
- package/skills/fleet/auth-github.md +7 -6
- package/skills/fleet/beads-conflict-resolution.md +141 -0
- package/skills/fleet/beads.md +16 -12
- package/skills/fleet/onboarding.md +6 -6
- package/skills/fleet/permissions.md +11 -7
- package/skills/fleet/profiles/node.json +1 -1
- package/skills/fleet/skill-matrix.md +1 -1
- package/skills/fleet/troubleshooting.md +4 -3
- package/version.json +1 -1
- package/dist/providers/gemini.d.ts +0 -52
- package/dist/providers/gemini.d.ts.map +0 -1
- package/dist/providers/gemini.js +0 -236
- package/dist/providers/gemini.js.map +0 -1
- package/packages/apra-fleet-se/fleet-sprint/docs/coach-role-design.md +0 -23
|
@@ -0,0 +1,822 @@
|
|
|
1
|
+
// =============================================================================
|
|
2
|
+
// PHASE MODULE: Develop (apra-fleet-3swo.6.7).
|
|
3
|
+
//
|
|
4
|
+
// The FOURTH of runSprintCycle's twelve phase() boundaries -- one round of
|
|
5
|
+
// doer work: group this round's ready beads into streaks, pack the streaks
|
|
6
|
+
// into per-doer ordered worklists, and run every streak turn through the
|
|
7
|
+
// serialized doer barrier, recording a per-streak (and per-bead) outcome for
|
|
8
|
+
// each. Moved verbatim out of runner.js: every prompt, log line, dispatch
|
|
9
|
+
// option, sync bracket and outcome shape is byte-identical to the inline
|
|
10
|
+
// version, so the golden transcript is unchanged. Move-only, no behaviour
|
|
11
|
+
// change.
|
|
12
|
+
//
|
|
13
|
+
// WHERE THIS PHASE STARTS AND STOPS. It starts at its own phase() call and
|
|
14
|
+
// ends at the "streak outcomes" log line -- NOT at the next phase() call.
|
|
15
|
+
// Review runs in the SAME round loop iteration and consumes this phase's
|
|
16
|
+
// results, so the boundary is drawn where the doer work finishes rather than
|
|
17
|
+
// where the next label is emitted. Everything before the phase() call (the
|
|
18
|
+
// round loop's ready-set query, the scoped-replan branch -- now
|
|
19
|
+
// ./replan.mjs -- and the replan short-circuit that computes `currentReady`)
|
|
20
|
+
// stays in runner.js, because all three decide WHETHER this phase runs and
|
|
21
|
+
// two of them use loop control (`break`/`continue`) that cannot be expressed
|
|
22
|
+
// from inside a function.
|
|
23
|
+
//
|
|
24
|
+
// WHY devRounds IS PASSED IN ALREADY INCREMENTED. Same reason as ./replan.mjs:
|
|
25
|
+
// `devRounds` is the round loop's own counter, so the increment stays next to
|
|
26
|
+
// the loop and the incremented value arrives here only to build the
|
|
27
|
+
// `Develop C{cycle} R{devRounds}` label (and the two log lines that name the
|
|
28
|
+
// round).
|
|
29
|
+
//
|
|
30
|
+
// EXPLICIT STATE, NOT A CLOSURE. The inline version read roughly twenty
|
|
31
|
+
// runSprintCycle/round-loop locals off the enclosing scope. They arrive as
|
|
32
|
+
// one explicit state argument now, including `sprintState` -- the per-sprint
|
|
33
|
+
// resolved state from ../sprint-state.mjs, which the post-dispatch
|
|
34
|
+
// verifyDoerStreakClosed() read genuinely consumes -- and `parallel`, the
|
|
35
|
+
// workflow seam the per-worklist fan-out runs through. `perBeadFeedback` is a
|
|
36
|
+
// Map this phase only READS (the reviewer populates it); nothing here
|
|
37
|
+
// reassigns a caller binding, which is why the two values Review needs come
|
|
38
|
+
// back as an ordinary return value rather than being threaded.
|
|
39
|
+
//
|
|
40
|
+
// WHY THE RUNNER HELPERS ARE INJECTED RATHER THAN IMPORTED. claimBeadsBatched,
|
|
41
|
+
// verifyDoerStreakClosed, normalizeTierToken and kbQueryTerms are all exported
|
|
42
|
+
// BY runner.js. Importing them here would make phases/develop.mjs <->
|
|
43
|
+
// runner.js a circular pair for the sake of four helpers, so they come through
|
|
44
|
+
// the state argument instead -- the same rule phases/plan.mjs's header states.
|
|
45
|
+
// The dependencies that live in real sibling modules (dispatchRole/TURN_BASES,
|
|
46
|
+
// the prompt builders, the worklist/streak functions, policyFor, the error
|
|
47
|
+
// classes) are imported directly.
|
|
48
|
+
//
|
|
49
|
+
// GUARD COVERAGE: registered as 'phases/develop.mjs' in ../guarded-modules.mjs.
|
|
50
|
+
// It carries NO command() call site of its own -- every bd read/write it needs
|
|
51
|
+
// goes through an injected runner helper or a gitSync bracket -- plus the two
|
|
52
|
+
// dispatchRole call sites for the streak-assignment and doer ladders.
|
|
53
|
+
// =============================================================================
|
|
54
|
+
|
|
55
|
+
import { WorkflowError } from '@apralabs/apra-fleet-workflow';
|
|
56
|
+
|
|
57
|
+
import { dispatchRole, TURN_BASES } from '../dispatch-role.mjs';
|
|
58
|
+
import { buildStreakAssignmentPrompt, buildDoerPrompt } from '../prompts.mjs';
|
|
59
|
+
import {
|
|
60
|
+
selectStreaks, groupStreaksFromLaneMetadata, streakRequiredTier,
|
|
61
|
+
resolveWorklistTierPolicy, hasContextHeadroomForResume, assignDoerWorklists,
|
|
62
|
+
} from '../worklists.mjs';
|
|
63
|
+
import { isPostDispatchSyncFailure } from '../errors.mjs';
|
|
64
|
+
import { isPermissionScopePostDispatchSyncFailure } from '../dispatch-failure.mjs';
|
|
65
|
+
import { policyFor } from '../role-policies.mjs';
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* Runs ONE Develop round: streak grouping, per-doer worklist packing, and the
|
|
69
|
+
* serialized doer streak turns, with per-streak outcome attribution.
|
|
70
|
+
*
|
|
71
|
+
* @param {object} state Explicit phase state; see this file's header.
|
|
72
|
+
* @returns {Promise<{
|
|
73
|
+
* streakOutcomes: object[],
|
|
74
|
+
* readyTitleById: Map<string, string>,
|
|
75
|
+
* }>} `streakOutcomes` is this round's per-streak attribution (the Review
|
|
76
|
+
* phase filters its scope off it); `readyTitleById` is the stable
|
|
77
|
+
* (title, id) sort key Review's evidence command and reviewer prompt use so
|
|
78
|
+
* the non-deterministic completion order of parallel doer dispatches never
|
|
79
|
+
* leaks into a prompt.
|
|
80
|
+
*/
|
|
81
|
+
export async function runDevelopPhase({
|
|
82
|
+
// Presentation + dispatch seams.
|
|
83
|
+
phase,
|
|
84
|
+
log,
|
|
85
|
+
command,
|
|
86
|
+
parallel,
|
|
87
|
+
dispatchCtx,
|
|
88
|
+
// Sprint identity/config.
|
|
89
|
+
cycle,
|
|
90
|
+
validated,
|
|
91
|
+
args,
|
|
92
|
+
orchestratorMember,
|
|
93
|
+
// Per-sprint resolved state (../sprint-state.mjs), the git/beads sync
|
|
94
|
+
// brackets every doer dispatch and verification read goes through, and the
|
|
95
|
+
// dashboard refresh each completed streak turn triggers.
|
|
96
|
+
sprintState,
|
|
97
|
+
gitSync,
|
|
98
|
+
updateDashboard,
|
|
99
|
+
// The KB clients the doer prompt is primed from.
|
|
100
|
+
kbPriming,
|
|
101
|
+
kbWork,
|
|
102
|
+
// Per-round inputs. `devRounds` arrives already incremented (see header);
|
|
103
|
+
// `perBeadFeedback` is read-only here.
|
|
104
|
+
devRounds,
|
|
105
|
+
currentReady,
|
|
106
|
+
doerPool,
|
|
107
|
+
perBeadFeedback,
|
|
108
|
+
// Injected runner helpers -- see the header for why these are not imports.
|
|
109
|
+
claimBeadsBatched,
|
|
110
|
+
verifyDoerStreakClosed,
|
|
111
|
+
normalizeTierToken,
|
|
112
|
+
kbQueryTerms,
|
|
113
|
+
}) {
|
|
114
|
+
phase(`Develop C${cycle} R${devRounds}`);
|
|
115
|
+
|
|
116
|
+
// --- Permission-scope publish-blocked carry-over (apra-fleet-2wdc.4) ---
|
|
117
|
+
// A permission-scope post-dispatch sync failure (runStreakTurn's
|
|
118
|
+
// dispatchError handling below) can NEVER be fixed by re-dispatching: the
|
|
119
|
+
// App/token permission set that refused the push is the SAME set a fresh
|
|
120
|
+
// dispatch would push with, so a bead flagged here would otherwise be
|
|
121
|
+
// re-selected into `currentReady` every subsequent round -- and every
|
|
122
|
+
// subsequent CYCLE, since `sprintState` is created once per sprint and
|
|
123
|
+
// threaded unchanged through every phase call (see ../sprint-state.mjs) --
|
|
124
|
+
// spinning the sprint on a wall only an operator (granting the missing
|
|
125
|
+
// permission in the App's own settings) can clear. `permissionScopeBlockedBeads`
|
|
126
|
+
// is lazily attached to `sprintState` rather than passed as its own
|
|
127
|
+
// parameter, so this stays a develop.mjs-local concern with no change to
|
|
128
|
+
// sprint-state.mjs's documented shape or to runner.js's call site --
|
|
129
|
+
// consistent with review.mjs's own precedent of mutating a caller-held
|
|
130
|
+
// Map/Set in place (`replanIds`/`replannedThisCycle`) rather than
|
|
131
|
+
// threading a new return value through every round.
|
|
132
|
+
sprintState.permissionScopeBlockedBeads = sprintState.permissionScopeBlockedBeads || new Map();
|
|
133
|
+
const permissionScopeBlockedBeads = sprintState.permissionScopeBlockedBeads;
|
|
134
|
+
const carriedOverBlocked = currentReady.filter((b) => permissionScopeBlockedBeads.has(b.id));
|
|
135
|
+
if (carriedOverBlocked.length > 0) {
|
|
136
|
+
for (const b of carriedOverBlocked) {
|
|
137
|
+
log(`[Sync] PUBLISH BLOCKED (carried over from an earlier round this sprint): bead '${b.id}' -- ${permissionScopeBlockedBeads.get(b.id)}`);
|
|
138
|
+
}
|
|
139
|
+
log(
|
|
140
|
+
`Develop C${cycle} R${devRounds}: excluding ${carriedOverBlocked.length} bead(s) already publish-blocked by a ` +
|
|
141
|
+
`permission-scope sync failure (${carriedOverBlocked.map((b) => b.id).join(', ')}) from this round's streak ` +
|
|
142
|
+
'assignment -- not re-dispatching for that reason alone until an operator grants the missing permission.'
|
|
143
|
+
);
|
|
144
|
+
currentReady = currentReady.filter((b) => !permissionScopeBlockedBeads.has(b.id));
|
|
145
|
+
}
|
|
146
|
+
if (currentReady.length === 0) {
|
|
147
|
+
log(`Develop C${cycle} R${devRounds}: every still-ready bead this round is publish-blocked -- skipping streak assignment and dispatch entirely.`);
|
|
148
|
+
return { streakOutcomes: [], readyTitleById: new Map() };
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
// --- Streak grouping ------------------------------------------
|
|
152
|
+
// PREFER deterministic grouping straight from the planner's lane
|
|
153
|
+
// metadata (`streak`/`streakOrder`, emitted per planner.md through
|
|
154
|
+
// the same `--metadata` channel as `model`), intersected with THIS
|
|
155
|
+
// round's ready set. When every ready bead carries a `streak` id the
|
|
156
|
+
// grouping is fully determined by the plan, so the runtime "Streak
|
|
157
|
+
// Assignment" LLM dispatch is skipped entirely -- deterministic,
|
|
158
|
+
// zero prompt drift, one fewer agent round-trip. The LLM path below
|
|
159
|
+
// is retained ONLY as a fallback for plans that lack lane metadata;
|
|
160
|
+
// see groupStreaksFromLaneMetadata() for the all-or-nothing rule.
|
|
161
|
+
let streaks, usedFallback, reason;
|
|
162
|
+
const laneGrouping = groupStreaksFromLaneMetadata(currentReady);
|
|
163
|
+
if (laneGrouping) {
|
|
164
|
+
({ streaks, reason } = laneGrouping);
|
|
165
|
+
usedFallback = false;
|
|
166
|
+
log(
|
|
167
|
+
`Streak grouping: deterministic from lane metadata -- ${laneGrouping.streaks.length} streak(s), ` +
|
|
168
|
+
`no Streak Assignment dispatch (${laneGrouping.streaks.map((s) => `[${s.map((b) => b.id).join(', ')}]`).join(' ')}).`
|
|
169
|
+
);
|
|
170
|
+
} else {
|
|
171
|
+
// --- Streak assignment (FALLBACK) ---------------------------------
|
|
172
|
+
// Reached only when the plan lacks lane metadata (see above).
|
|
173
|
+
// Schema-validated {streaks: string[][]}; falls back to a
|
|
174
|
+
// deterministic one-bead-per-streak grouping whenever the candidate
|
|
175
|
+
// does not cover every ready bead id exactly once -- invalid output,
|
|
176
|
+
// or agent()'s own bounded schema-repair loop exhausted. See
|
|
177
|
+
// selectStreaks().
|
|
178
|
+
log('Streak grouping: no lane metadata on this round\'s ready beads -- falling back to LLM Streak Assignment dispatch (back-compat with pre-eft.76 plans).');
|
|
179
|
+
// apra-fleet-3swo.5.3: the 'streak-assignment' row of
|
|
180
|
+
// role-policies.mjs, executed by dispatchRole. That row owns the
|
|
181
|
+
// one variance nothing else in the table has -- NO git-sync
|
|
182
|
+
// bracket at all, because this is pure compute with no repo access
|
|
183
|
+
// -- plus the deliberate absence of an agentType (this call has no
|
|
184
|
+
// vendored persona of its own; see the streakAssignment schema
|
|
185
|
+
// comment in contracts.mjs, and activating the full `planner`
|
|
186
|
+
// persona on this narrow grouping task makes the model go
|
|
187
|
+
// exploring with its Bash/Read/Grep tools instead of answering
|
|
188
|
+
// from the prompt, which can run long enough to hit the transport
|
|
189
|
+
// timeout), the planner MEMBER borrowed purely for model-tier
|
|
190
|
+
// routing, its own cheap tier, and the transport-default budgets.
|
|
191
|
+
//
|
|
192
|
+
// The bounded semantic-repair re-ask is the row's
|
|
193
|
+
// `semanticRepairReAsks: 1` plus its `select-streaks-validate`
|
|
194
|
+
// postResult step: agent()'s own schema-repair only fixes
|
|
195
|
+
// JSON-shape problems, so a candidate can be schema-valid yet
|
|
196
|
+
// semantically invalid (e.g. bead ids returned with their prefix
|
|
197
|
+
// stripped). Dropping the whole grouping to the one-bead-per-streak
|
|
198
|
+
// fallback silently discards sequencing intent, which on a
|
|
199
|
+
// multi-doer fleet would PARALLELIZE beads the model said must run
|
|
200
|
+
// sequentially. The engine re-asks ONCE with the exact validation
|
|
201
|
+
// failure -- guarded, never looped -- and only then falls back.
|
|
202
|
+
//
|
|
203
|
+
// `validate` is that step: selectStreaks() is what decides whether
|
|
204
|
+
// the fallback is used, and the engine hands its result back as
|
|
205
|
+
// `validation` on BOTH the success path and the degrade path (a
|
|
206
|
+
// spent ladder validates a null candidate, which is exactly the
|
|
207
|
+
// deterministic one-bead-per-streak grouping the old ladder fell
|
|
208
|
+
// back to).
|
|
209
|
+
const streakPrompt = buildStreakAssignmentPrompt({ readyBeadIds: currentReady.map((b) => b.id) });
|
|
210
|
+
const streakOutcome = await dispatchRole(dispatchCtx, 'streak-assignment', {
|
|
211
|
+
prompt: streakPrompt,
|
|
212
|
+
label: 'Streak Assignment',
|
|
213
|
+
repairPrompt: (rejectionReason) => streakPrompt
|
|
214
|
+
+ `\n\nYour previous answer was REJECTED: ${rejectionReason}. `
|
|
215
|
+
+ 'Return the bead ids exactly as listed -- verbatim, full prefix included.',
|
|
216
|
+
repairLabel: 'Streak Assignment (semantic repair)',
|
|
217
|
+
roleLabel: 'Streak Assignment',
|
|
218
|
+
validate: (candidate) => {
|
|
219
|
+
const selected = selectStreaks(candidate, currentReady);
|
|
220
|
+
return { ok: !selected.usedFallback, reason: selected.reason, result: selected };
|
|
221
|
+
},
|
|
222
|
+
});
|
|
223
|
+
// No duplicate log() dump -- see dispatchReview() for why. The
|
|
224
|
+
// standard AGENT row (label 'Streak Assignment') already renders
|
|
225
|
+
// through the same generic path as every other dispatch.
|
|
226
|
+
({ streaks, usedFallback, reason } = streakOutcome.validation);
|
|
227
|
+
if (usedFallback) {
|
|
228
|
+
log(`Streak Assignment: using one-bead-per-streak fallback (${reason}).`);
|
|
229
|
+
}
|
|
230
|
+
} // end LLM-fallback branch (no lane metadata)
|
|
231
|
+
// Title lookup for the assignedBeadIds sort below. Doer dispatches
|
|
232
|
+
// run in `parallel`, so the order their outcomes are recorded in is
|
|
233
|
+
// completion order -- correctly non-deterministic. The Review
|
|
234
|
+
// phase's `bd show` evidence command and reviewer prompt must not
|
|
235
|
+
// inherit that race as prompt drift; see the sort-by-title comment
|
|
236
|
+
// above for why `title` is the only stable key.
|
|
237
|
+
const readyTitleById = new Map(currentReady.map((b) => [b.id, b.title]));
|
|
238
|
+
|
|
239
|
+
// beadId -> declared model tier, read out of the SAME `bd list
|
|
240
|
+
// --ready --json` response already fetched to build `currentReady`:
|
|
241
|
+
// that response carries each bead's full record including metadata,
|
|
242
|
+
// so no extra `bd show` round-trip is needed to recover the `model`
|
|
243
|
+
// key the planner records via `--metadata`. See resolveDoerModel()
|
|
244
|
+
// for how a possibly-multi-bead streak's model is picked from this
|
|
245
|
+
// map. normalizeTierToken() guards this single read site -- see its
|
|
246
|
+
// doc comment.
|
|
247
|
+
const modelByBeadId = new Map(currentReady.map((b) => [b.id, normalizeTierToken(b.metadata && b.metadata.model)]));
|
|
248
|
+
|
|
249
|
+
// --- Doer barrier: serialized turns, isolated failures ---
|
|
250
|
+
// Streak turns are strictly serialized through `globalDoerTurn`: a
|
|
251
|
+
// promise chain each turn awaits before doing any work and releases
|
|
252
|
+
// in a `finally`, so at most one doer dispatch is ever in flight and
|
|
253
|
+
// a thrown streak can never deadlock the next one. Serialization is
|
|
254
|
+
// required because concurrent writers break the
|
|
255
|
+
// fast-forward-by-construction invariant the git/beads sync brackets
|
|
256
|
+
// depend on. parallel() with continueOnError is retained only for
|
|
257
|
+
// per-worklist failure isolation and outcome accounting.
|
|
258
|
+
let globalDoerTurn = Promise.resolve();
|
|
259
|
+
const streakOutcomes = [];
|
|
260
|
+
|
|
261
|
+
// --- Per-doer ORDERED WORKLISTS -----------------------------------
|
|
262
|
+
// When this round has more ready streaks than doers, pack them into
|
|
263
|
+
// per-doer ordered worklists (dependency order -> priority -> the
|
|
264
|
+
// existing tie-break, plus tier grouping and an effort budget -- see
|
|
265
|
+
// assignDoerWorklists) instead of feeding one streak per doer. Each
|
|
266
|
+
// doer then works its worklist back to back: mode 'resume' (the
|
|
267
|
+
// default) re-dispatches per streak, resuming the SAME doer session
|
|
268
|
+
// by explicit session id so warm context carries across streaks
|
|
269
|
+
// while every engine checkpoint (sync bracket, per-streak failure
|
|
270
|
+
// attribution) is kept BETWEEN streaks; mode 'batch' sends one
|
|
271
|
+
// dispatch carrying the whole ordered worklist. When streaks <=
|
|
272
|
+
// doers, assignDoerWorklists is a pass-through.
|
|
273
|
+
const worklistMode = validated.doerWorklistMode || 'resume';
|
|
274
|
+
const { tierHomogeneous } = resolveWorklistTierPolicy({
|
|
275
|
+
mode: worklistMode,
|
|
276
|
+
resumeModelSwitch: validated.resumeModelSwitch === true,
|
|
277
|
+
});
|
|
278
|
+
const worklistPacking = assignDoerWorklists(streaks, doerPool.length, {
|
|
279
|
+
effortBudget: validated.worklistEffortBudget,
|
|
280
|
+
tierHomogeneous,
|
|
281
|
+
});
|
|
282
|
+
if (worklistPacking.packed) {
|
|
283
|
+
const fmtStreak = (s) => `(${s.map((b) => b.id).join(', ')})`;
|
|
284
|
+
const fmtWorklist = (wl) => `[${wl.map(fmtStreak).join(' -> ')}]`;
|
|
285
|
+
log(
|
|
286
|
+
`Doer worklists: ${streaks.length} ready streak(s) > ${doerPool.length} doer(s) -- ` +
|
|
287
|
+
`packed into per-doer ordered worklists (mode: ${worklistMode}, ` +
|
|
288
|
+
`${tierHomogeneous ? 'tier-homogeneous' : 'mixed tiers allowed (resume_model_switch)'}): ` +
|
|
289
|
+
worklistPacking.worklists.map((wl, i) => `doer '${doerPool[i % doerPool.length]}': ${fmtWorklist(wl)}`).join('; ') +
|
|
290
|
+
(worklistPacking.overflow.length > 0
|
|
291
|
+
? `; overflow queued to the next round (effort budget/tier grouping): ${worklistPacking.overflow.map(fmtStreak).join(' ')}`
|
|
292
|
+
: '')
|
|
293
|
+
);
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
// One streak's full dispatch turn (claim -> dispatch -> verify ->
|
|
297
|
+
// attribute), run once per streak of a worklist. Each call captures
|
|
298
|
+
// and replaces the global gate synchronously, before its first
|
|
299
|
+
// `await`, so the FIRST turn of each worklist enqueues in
|
|
300
|
+
// deterministic worklist order; subsequent turns of a worklist
|
|
301
|
+
// enqueue as their predecessors complete.
|
|
302
|
+
// `worklistCtx` carries the doer's session id + last reported usage
|
|
303
|
+
// across the streaks of ONE worklist (never across worklists/doers);
|
|
304
|
+
// `batchStreaks` (mode 'batch') is the ordered list of sub-streaks a
|
|
305
|
+
// single merged dispatch carries, for per-streak outcome
|
|
306
|
+
// attribution.
|
|
307
|
+
const runStreakTurn = async ({ streak, doerMember, worklistCtx, worklistPosition = 0, worklistLength = 1, packed = false, batchStreaks = null }) => {
|
|
308
|
+
const priorTurn = globalDoerTurn;
|
|
309
|
+
let releaseTurn;
|
|
310
|
+
globalDoerTurn = new Promise((resolve) => { releaseTurn = resolve; });
|
|
311
|
+
await priorTurn;
|
|
312
|
+
try {
|
|
313
|
+
let actualBeadIds = streak.map((b) => b.id); // May be reduced by claiming if assignee is set
|
|
314
|
+
let hasClaimedBeads = false; // Track whether we've done claiming yet
|
|
315
|
+
|
|
316
|
+
// The base turn budget the resume ladder escalates from. Read
|
|
317
|
+
// out of the ENGINE's TURN_BASES (apra-fleet-3swo.5.7) rather
|
|
318
|
+
// than re-declared here: the 'doer' policy row records its turn
|
|
319
|
+
// budget symbolically, by the NAME of this constant, and a
|
|
320
|
+
// second copy in runner.js is a second thing to drift.
|
|
321
|
+
const BASE_DOER_MAX_TURNS = TURN_BASES.BASE_DOER_MAX_TURNS;
|
|
322
|
+
// apra-fleet-3swo.5.7: the doer ladder -- its dispatch, its
|
|
323
|
+
// pushCode/pushBeads git-sync bracket, its bounded escalating
|
|
324
|
+
// max_turns resume ladder, its closed-streak short-circuit, its
|
|
325
|
+
// refusal to re-dispatch a streak whose post-dispatch sync
|
|
326
|
+
// failed, its auth self-heal plus bounded retry, its generic
|
|
327
|
+
// retry onto the streak branch's remote tip, and its per-bead
|
|
328
|
+
// attribution degrade -- is now the 'doer'/'doer-resume' rows of
|
|
329
|
+
// fleet-sprint/role-policies.mjs, executed by dispatchRole.
|
|
330
|
+
//
|
|
331
|
+
// THREE things make this ladder different from every other one,
|
|
332
|
+
// and all three are expressed as data:
|
|
333
|
+
//
|
|
334
|
+
// 1. The claim runs INSIDE the bracket. Per-bead claiming is
|
|
335
|
+
// only meaningful once the bracket's D-pull has brought in
|
|
336
|
+
// which beads other sprints already hold, so
|
|
337
|
+
// 'claim-beads-batched' is one of role-policies.mjs's
|
|
338
|
+
// PRE_DISPATCH_STEPS_IN_BRACKET. It can NARROW the streak,
|
|
339
|
+
// which is why the prompt, the label and the tier this
|
|
340
|
+
// dispatch is priced at are all built by `prepare` -- inside
|
|
341
|
+
// the bracket, after the claim -- rather than passed in.
|
|
342
|
+
//
|
|
343
|
+
// 2. The resume ladder ESCALATES and is bounded. The row records
|
|
344
|
+
// resumeAttempts: 2 and a 'runtime' turn budget; the bindings
|
|
345
|
+
// thunk below is handed the attempt number and doubles from
|
|
346
|
+
// the base each time. A resume that fails for any reason
|
|
347
|
+
// other than spending its turns again is not something more
|
|
348
|
+
// turns can fix, and the engine stops escalating there.
|
|
349
|
+
//
|
|
350
|
+
// 3. A turn-exhausted streak whose beads are ALL already closed
|
|
351
|
+
// is a SUCCESS, not a failure -- the doer merely ran past its
|
|
352
|
+
// VERIFY checkpoint. That is the 'verify-streak-closed'
|
|
353
|
+
// preDispatch step on the RESUME dispatch, recorded before
|
|
354
|
+
// 'kill-stale-session' precisely so the check happens before
|
|
355
|
+
// anything is killed or re-dispatched, and it short-circuits
|
|
356
|
+
// the resume entirely.
|
|
357
|
+
//
|
|
358
|
+
// The per-bead attribution below is what the CALLER does with a
|
|
359
|
+
// failed outcome, so it stays here: the row's degrade is
|
|
360
|
+
// 'per-bead-attribution' and fabricates nothing.
|
|
361
|
+
const streakScope = () => `[${actualBeadIds.join(', ')}]`;
|
|
362
|
+
const doerOutcome = await dispatchRole(dispatchCtx, 'doer', {
|
|
363
|
+
roleLabel: `Doer streak ${streakScope()}`,
|
|
364
|
+
// Never used: `prepare` builds both prompts, because both
|
|
365
|
+
// depend on the streak the claim actually secured.
|
|
366
|
+
prompt: null,
|
|
367
|
+
resumePrompt: null,
|
|
368
|
+
onSessionId: (id, meta) => {
|
|
369
|
+
if (!worklistCtx) return;
|
|
370
|
+
worklistCtx.sessionId = id;
|
|
371
|
+
worklistCtx.usage = meta && meta.usage ? meta.usage : null;
|
|
372
|
+
},
|
|
373
|
+
// The escalating resume ladder: BASE * 2^n, bounded by the
|
|
374
|
+
// row's resumeAttempts. resumeAttempt 0 is the main
|
|
375
|
+
// dispatch, which takes its budget from the row's constant.
|
|
376
|
+
bindings: ({ resumeAttempt }) => ({
|
|
377
|
+
doerMember,
|
|
378
|
+
maxTurns: BASE_DOER_MAX_TURNS * (2 ** Math.max(resumeAttempt, 1)),
|
|
379
|
+
}),
|
|
380
|
+
// Claim once per streak turn, after the D-pull. Batched into
|
|
381
|
+
// ONE bd update id-list --claim --json call
|
|
382
|
+
// (apra-fleet-7h6n.7) instead of one call per bead -- see the
|
|
383
|
+
// claimBeadsBatched doc comment above for the verified
|
|
384
|
+
// multi-id --claim contract (non-atomic, JSON-array-only
|
|
385
|
+
// success signal) this relies on.
|
|
386
|
+
claimBeads: async () => {
|
|
387
|
+
if (hasClaimedBeads) return;
|
|
388
|
+
hasClaimedBeads = true;
|
|
389
|
+
if (!validated.assignee) return;
|
|
390
|
+
const { claimedBeadIds, skippedBeadIds } = await claimBeadsBatched({
|
|
391
|
+
command, orchestratorMember, beadIds: actualBeadIds, log,
|
|
392
|
+
});
|
|
393
|
+
if (claimedBeadIds.length === 0) {
|
|
394
|
+
// All beads in this streak are already claimed by
|
|
395
|
+
// other sprints. Skip this streak entirely.
|
|
396
|
+
log(`Doer streak: all beads ${streakScope()} are already claimed by other sprints -- skipping this streak.`);
|
|
397
|
+
throw new WorkflowError(
|
|
398
|
+
`All beads already claimed by other sprints`,
|
|
399
|
+
{ beadIds: actualBeadIds, reason: 'all-beads-already-claimed' }
|
|
400
|
+
);
|
|
401
|
+
}
|
|
402
|
+
if (skippedBeadIds.length > 0) {
|
|
403
|
+
actualBeadIds = claimedBeadIds; // Only the successfully claimed ones
|
|
404
|
+
}
|
|
405
|
+
},
|
|
406
|
+
// CRITICAL: never trust the doer's own success claim -- verify
|
|
407
|
+
// via `bd show` that the assigned bead ids are actually
|
|
408
|
+
// closed. verifyDoerStreakClosed() D-pulls the orchestrator's
|
|
409
|
+
// OWN beads clone BEFORE this read: the doer closed its beads
|
|
410
|
+
// in ITS clone and D-pushed them, so on a multi-member sprint
|
|
411
|
+
// the orchestrator's clone is a DIFFERENT clone and without
|
|
412
|
+
// that D-pull this read sees stale (still-open) status and
|
|
413
|
+
// EVERY remote doer streak is falsely marked FAILED.
|
|
414
|
+
// (apra-fleet-p2to.4.1) it D-pulls internally
|
|
415
|
+
// (DoltSync.syncBefore) -- treat the whole call as one bracket.
|
|
416
|
+
verifyStreakClosed: async (phase) => {
|
|
417
|
+
const unclosed = await gitSync.withOpenSyncBracket(() => verifyDoerStreakClosed({
|
|
418
|
+
command, orchestratorMember, beadIds: actualBeadIds, log, args, sprintState,
|
|
419
|
+
}));
|
|
420
|
+
if (phase === 'preDispatch' && unclosed.length === 0) {
|
|
421
|
+
log(
|
|
422
|
+
`Doer streak ${streakScope()} on member '${doerMember}' exhausted its turn limit ` +
|
|
423
|
+
'(max_turns), but all assigned bead id(s) are already closed -- WARNING: the doer ' +
|
|
424
|
+
'missed the VERIFY checkpoint (kept running after its last bd close instead of ' +
|
|
425
|
+
'stopping). Treating this streak as a successful completion, not a failure; ' +
|
|
426
|
+
'issuing NO resume dispatch.'
|
|
427
|
+
);
|
|
428
|
+
}
|
|
429
|
+
return unclosed;
|
|
430
|
+
},
|
|
431
|
+
// Built INSIDE the bracket, after the claim: the streak this
|
|
432
|
+
// dispatch actually owns is only known once the claim has run.
|
|
433
|
+
prepare: async ({ dispatch, resumeAttempt }) => {
|
|
434
|
+
if (dispatch.kind === 'max-turns-resume') {
|
|
435
|
+
const resumeTurns = BASE_DOER_MAX_TURNS * (2 ** resumeAttempt);
|
|
436
|
+
log(
|
|
437
|
+
`Doer streak ${streakScope()} on member '${doerMember}' exhausted its turn limit ` +
|
|
438
|
+
`(max_turns) -- resuming the same session with max_turns=${resumeTurns} ` +
|
|
439
|
+
`(attempt ${resumeAttempt}/${policyFor('doer').retry.resumeAttempts}) instead of ` +
|
|
440
|
+
'giving up or regrouping.'
|
|
441
|
+
);
|
|
442
|
+
return {
|
|
443
|
+
// Restate the streak's scope: a resumed dispatch
|
|
444
|
+
// replaces the delivered prompt artifact, so a
|
|
445
|
+
// bare "continue" leaves the session with no
|
|
446
|
+
// record of what it was asked to do.
|
|
447
|
+
prompt:
|
|
448
|
+
'Continue exactly where you left off from this same session -- do not restart, re-read from scratch, or re-plan. ' +
|
|
449
|
+
`Your scope, restated so a resumed dispatch never loses it: assigned bead id(s) ${actualBeadIds.join(', ')} on sprint branch ${validated.branch}. ` +
|
|
450
|
+
'Pick up from your last action on those bead(s) and proceed to the VERIFY checkpoint.',
|
|
451
|
+
label: `Streak ${streakScope()} (resume, max_turns=${resumeTurns})`,
|
|
452
|
+
};
|
|
453
|
+
}
|
|
454
|
+
|
|
455
|
+
const feedbackForStreak = actualBeadIds
|
|
456
|
+
.map((id) => perBeadFeedback.get(id))
|
|
457
|
+
.filter(Boolean)
|
|
458
|
+
.join('\n\n');
|
|
459
|
+
|
|
460
|
+
// Resolve the model to price this dispatch against. Beads
|
|
461
|
+
// are normally streaked one-per-model, but when a streak
|
|
462
|
+
// DOES span beads with different declared models this
|
|
463
|
+
// deterministically picks the first (by bead-id order, not
|
|
464
|
+
// dispatch completion order) and logs the discrepancy
|
|
465
|
+
// rather than guessing a blended price. A bead with no
|
|
466
|
+
// `model` metadata resolves to `undefined`, which
|
|
467
|
+
// FleetWorkflow treats the same as never passing `model`
|
|
468
|
+
// -- the dispatch still runs, it is simply not priced
|
|
469
|
+
// (calculateCost() returns null; see pricing.mjs).
|
|
470
|
+
// CAVEAT: this is the model the PLANNER ASKED the doer to
|
|
471
|
+
// run on. The fleet does not echo back the model it
|
|
472
|
+
// actually resolved/ran with, so this -- and therefore
|
|
473
|
+
// budget._spent / BudgetExceededError -- is an ESTIMATE,
|
|
474
|
+
// not a verified actual.
|
|
475
|
+
const streakModels = [...new Set(actualBeadIds.map((id) => modelByBeadId.get(id)).filter(Boolean))];
|
|
476
|
+
let doerModel = streakModels[0];
|
|
477
|
+
// In a PACKED worklist round a streak must never dispatch
|
|
478
|
+
// below its REQUIRED tier (the max of its beads' declared
|
|
479
|
+
// models) -- override the first-bead pick with that tier.
|
|
480
|
+
// The non-packed (streaks <= doers) path keeps the
|
|
481
|
+
// first-bead behavior.
|
|
482
|
+
if (packed) {
|
|
483
|
+
const requiredTier = streakRequiredTier(streak);
|
|
484
|
+
if (requiredTier) doerModel = requiredTier;
|
|
485
|
+
}
|
|
486
|
+
if (streakModels.length > 1) {
|
|
487
|
+
log(`Doer streak ${streakScope()} spans beads with different declared models (${streakModels.join(', ')}) -- pricing this dispatch as '${doerModel}'.`);
|
|
488
|
+
}
|
|
489
|
+
|
|
490
|
+
// Mode (ii) RESUMED SEQUENCE: resume the doer's OWN
|
|
491
|
+
// prior-streak session by EXPLICIT session id when one was
|
|
492
|
+
// captured for this worklist and
|
|
493
|
+
// hasContextHeadroomForResume() passes. On refusal, or
|
|
494
|
+
// when no session id exists (first streak of the worklist,
|
|
495
|
+
// provider without resume support, prior streak failed),
|
|
496
|
+
// fall back to a FRESH session carrying the FULL prompt --
|
|
497
|
+
// never a delta prompt into a fresh session.
|
|
498
|
+
let worklistResumeArg = false;
|
|
499
|
+
if (worklistCtx && worklistCtx.sessionId) {
|
|
500
|
+
if (hasContextHeadroomForResume(worklistCtx.usage)) {
|
|
501
|
+
worklistResumeArg = worklistCtx.sessionId;
|
|
502
|
+
} else {
|
|
503
|
+
log(
|
|
504
|
+
`Doer worklist on '${doerMember}': context headroom insufficient to resume session ` +
|
|
505
|
+
`'${worklistCtx.sessionId}' for streak ${worklistPosition + 1}/${worklistLength} ` +
|
|
506
|
+
`${streakScope()} -- starting a FRESH session with the full prompt instead.`
|
|
507
|
+
);
|
|
508
|
+
worklistCtx.sessionId = null;
|
|
509
|
+
worklistCtx.usage = null;
|
|
510
|
+
}
|
|
511
|
+
}
|
|
512
|
+
if (worklistResumeArg) {
|
|
513
|
+
log(
|
|
514
|
+
`Doer worklist on '${doerMember}': dispatching streak ${worklistPosition + 1}/${worklistLength} ` +
|
|
515
|
+
`${streakScope()} as a RESUME of session '${worklistResumeArg}'` +
|
|
516
|
+
`${doerModel ? ` (model=${doerModel})` : ''} -- warm context carries over.`
|
|
517
|
+
);
|
|
518
|
+
}
|
|
519
|
+
|
|
520
|
+
// The doer cannot read the KB itself (the member's
|
|
521
|
+
// composed permission config disables the fleet MCP
|
|
522
|
+
// server), so the entries primed for THIS member travel in
|
|
523
|
+
// its prompt. Relevance-ranked read for THESE beads,
|
|
524
|
+
// falling back to the sprint-start primed set when the
|
|
525
|
+
// query returns nothing. The query terms are the bead ids
|
|
526
|
+
// and titles the engine already holds; expand_related on
|
|
527
|
+
// that call is what traverses the refines/contradiction_of
|
|
528
|
+
// edges.
|
|
529
|
+
const doerRepoPath = kbPriming.folderOf(doerMember);
|
|
530
|
+
const doerKnowledge = await kbWork.relevantKnowledge(doerRepoPath, kbQueryTerms(streak, actualBeadIds));
|
|
531
|
+
const basePrompt = buildDoerPrompt({
|
|
532
|
+
beadIds: actualBeadIds,
|
|
533
|
+
branch: validated.branch,
|
|
534
|
+
feedback: feedbackForStreak || null,
|
|
535
|
+
kbKnowledge: doerKnowledge.length > 0 ? doerKnowledge : kbPriming.knowledgeOf(doerMember),
|
|
536
|
+
});
|
|
537
|
+
let doerPrompt = basePrompt;
|
|
538
|
+
if (batchStreaks) {
|
|
539
|
+
// Mode (i) BATCH: one dispatch carries the whole
|
|
540
|
+
// ordered worklist. The prompt names each streak
|
|
541
|
+
// boundary and mandates strict in-order completion.
|
|
542
|
+
doerPrompt =
|
|
543
|
+
'ORDERED MULTI-STREAK WORKLIST (single batched dispatch): your assigned beads below form ' +
|
|
544
|
+
`${batchStreaks.length} streak(s). Work them strictly in this order, fully completing each ` +
|
|
545
|
+
'streak (implement, verify, `bd close` its beads) before starting the next: ' +
|
|
546
|
+
batchStreaks.map((s, i) => `streak ${i + 1}: [${s.map((b) => b.id).join(', ')}]`).join('; ') +
|
|
547
|
+
'.\n\n' + basePrompt;
|
|
548
|
+
} else if (worklistResumeArg) {
|
|
549
|
+
// A resumed dispatch restates its FULL scope (the
|
|
550
|
+
// entire buildDoerPrompt output), never a bare
|
|
551
|
+
// "continue" delta -- the preamble only tells the
|
|
552
|
+
// session it may reuse its warm context.
|
|
553
|
+
doerPrompt =
|
|
554
|
+
'WORKLIST CONTINUATION: you are the same doer session that just completed the previous ' +
|
|
555
|
+
'streak of your worklist. Your warm context (repository layout, conventions, files already ' +
|
|
556
|
+
'read) carries over -- do not re-explore the repository from scratch. Your NEXT assigned ' +
|
|
557
|
+
'streak follows, with its scope restated in full.\n\n' + basePrompt;
|
|
558
|
+
}
|
|
559
|
+
return {
|
|
560
|
+
prompt: doerPrompt,
|
|
561
|
+
label: `Streak ${streakScope()}`,
|
|
562
|
+
resumeArg: worklistResumeArg,
|
|
563
|
+
bindings: { doerMember, doerModel },
|
|
564
|
+
};
|
|
565
|
+
},
|
|
566
|
+
});
|
|
567
|
+
const report = doerOutcome.value;
|
|
568
|
+
const dispatchError = doerOutcome.error;
|
|
569
|
+
// A streak that needed a second dispatch of any kind -- a generic
|
|
570
|
+
// retry or a turn-exhaustion resume -- is recorded as retried.
|
|
571
|
+
const wasRetried = doerOutcome.attempts > 1 || doerOutcome.resumesIssued > 0;
|
|
572
|
+
if (dispatchError) {
|
|
573
|
+
// A dispatch-level failure means this worklist's captured
|
|
574
|
+
// session can no longer be trusted (the failed attempt may
|
|
575
|
+
// have run partial turns in it) -- clear it so the worklist's
|
|
576
|
+
// NEXT streak starts from a FRESH session with the full
|
|
577
|
+
// prompt, mirroring createRoundSessionRegistry's
|
|
578
|
+
// clear-on-failure rule. (The max-turns ladder is unaffected:
|
|
579
|
+
// it resumes the member's last session via `resume: true`,
|
|
580
|
+
// not this id.)
|
|
581
|
+
if (worklistCtx) {
|
|
582
|
+
worklistCtx.sessionId = null;
|
|
583
|
+
worklistCtx.usage = null;
|
|
584
|
+
}
|
|
585
|
+
// (apra-fleet-2wdc.4) A permission-scope post-dispatch sync
|
|
586
|
+
// failure is a DISTINCT case from every other post-dispatch sync
|
|
587
|
+
// failure: it is not merely un-redispatchable THIS turn (every
|
|
588
|
+
// PostDispatchSyncError already gets that via dispatch-role.mjs's
|
|
589
|
+
// skipRedispatchOnPostDispatchSyncFailure) -- it can never be
|
|
590
|
+
// fixed by ANY future redispatch either, because the App/token
|
|
591
|
+
// permission set that refused the push is exactly what a fresh
|
|
592
|
+
// dispatch would push with again. Detected below and handled
|
|
593
|
+
// distinctly from the generic isPostDispatchSyncFailure branch.
|
|
594
|
+
if (isPermissionScopePostDispatchSyncFailure(dispatchError)) {
|
|
595
|
+
log(`[Sync] PUBLISH BLOCKED: doer streak ${streakScope()} on member '${doerMember}' COMPLETED and its work is committed locally, but the post-dispatch G-push was refused for a permission-scope reason that a redispatch cannot fix: ${dispatchError.message} Reporting this streak as work done/publish-blocked, NOT as a failed dispatch -- not re-dispatching these bead(s) again this sprint until an operator grants the missing permission.`);
|
|
596
|
+
} else if (isPostDispatchSyncFailure(dispatchError)) {
|
|
597
|
+
log(`Doer streak ${streakScope()} on member '${doerMember}' COMPLETED but its post-dispatch sync failed: ${dispatchError.message} Not re-dispatching -- the work is already committed locally.`);
|
|
598
|
+
} else if (doerOutcome.resumesIssued > 0) {
|
|
599
|
+
log(`Doer streak ${streakScope()} on member '${doerMember}' still failing after ${doerOutcome.resumesIssued} resume attempt(s) (last: ${dispatchError.message}) -- flagging as too-complex-for-one-streak.`);
|
|
600
|
+
}
|
|
601
|
+
}
|
|
602
|
+
|
|
603
|
+
if (dispatchError) {
|
|
604
|
+
const permissionScopeBlocked = isPermissionScopePostDispatchSyncFailure(dispatchError);
|
|
605
|
+
// Per-bead failure attribution: a dispatch-level throw
|
|
606
|
+
// (crash, transport error, exhausted resumes) does NOT mean
|
|
607
|
+
// none of this streak's beads closed -- a doer can close bead
|
|
608
|
+
// 1 of 2, then error out on bead 2. Verify via `bd show`
|
|
609
|
+
// (same D-pull-then-read as the happy path below) rather than
|
|
610
|
+
// assuming every bead in the streak is still open, so
|
|
611
|
+
// completed work is never discarded because a sibling in the
|
|
612
|
+
// same streak was never reached.
|
|
613
|
+
// (apra-fleet-p2to.4.1) verifyDoerStreakClosed() D-pulls internally
|
|
614
|
+
// (DoltSync.syncBefore) -- treat the whole call as one sync bracket.
|
|
615
|
+
const unclosedIds = await gitSync.withOpenSyncBracket(() => verifyDoerStreakClosed({
|
|
616
|
+
command, orchestratorMember, beadIds: actualBeadIds, log, args, sprintState,
|
|
617
|
+
}));
|
|
618
|
+
const closedIds = actualBeadIds.filter((id) => !unclosedIds.includes(id));
|
|
619
|
+
log(`Doer streak attribution [${actualBeadIds.join(', ')}]: closed=[${closedIds.join(', ')}] failed=[${unclosedIds.join(', ')}] (dispatch error: ${dispatchError.message}).`);
|
|
620
|
+
// NOTE ON `outcome` STAYING 'failed' HERE (never 'publish-blocked')
|
|
621
|
+
// EVEN FOR THE PERMISSION-SCOPE CASE: review.mjs's ONLY read of
|
|
622
|
+
// this field is `streakOutcomes.filter((o) => o.outcome !== 'failed')`
|
|
623
|
+
// to build the round's REVIEW SCOPE, on the invariant that every
|
|
624
|
+
// non-'failed' outcome's beads are ACTUALLY closed (this file's own
|
|
625
|
+
// success path only ever records 'success'/'retried' when
|
|
626
|
+
// unclosedIds is empty). A permission-scope failure's beads are
|
|
627
|
+
// NOT closed in the shared beads DB (D-push was skipped -- see
|
|
628
|
+
// member-sync.mjs's syncMemberAfterOrdered) even though the doer's
|
|
629
|
+
// own local clone may show them closed, so feeding them to review.mjs
|
|
630
|
+
// would violate that invariant: the reviewer would be asked to
|
|
631
|
+
// evaluate acceptance criteria for beads with no evidence and no
|
|
632
|
+
// report, which risks a self-contradictory CHANGES_NEEDED verdict
|
|
633
|
+
// and dispatchReview()'s ReviewerContractViolationError -- a hard
|
|
634
|
+
// sprint ABORT, i.e. turning "the sprint spins" into "the sprint
|
|
635
|
+
// crashes". So `outcome` is kept 'failed' (review.mjs's existing,
|
|
636
|
+
// CORRECT exclusion for not-actually-done work) and the
|
|
637
|
+
// work-done/publish-blocked distinction is carried on the
|
|
638
|
+
// additional `publishBlocked` flag below instead, which review.mjs
|
|
639
|
+
// does not read.
|
|
640
|
+
if (batchStreaks) {
|
|
641
|
+
// Mode (i): PER-STREAK attribution for a failed batch
|
|
642
|
+
// dispatch -- a sub-streak whose beads all verifiably
|
|
643
|
+
// closed before the failure keeps its work (outcome
|
|
644
|
+
// 'success', its closes stand and go to review); only
|
|
645
|
+
// sub-streaks with still-open beads are 'failed' and
|
|
646
|
+
// re-lane next round (permission-scope ones are additionally
|
|
647
|
+
// recorded on `permissionScopeBlockedBeads` below so they are
|
|
648
|
+
// excluded from re-laning instead of actually retried).
|
|
649
|
+
for (const sub of batchStreaks) {
|
|
650
|
+
const subIds = sub.map((b) => b.id).filter((id) => actualBeadIds.includes(id));
|
|
651
|
+
if (subIds.length === 0) continue;
|
|
652
|
+
const subUnclosed = subIds.filter((id) => unclosedIds.includes(id));
|
|
653
|
+
const subClosed = subIds.filter((id) => !subUnclosed.includes(id));
|
|
654
|
+
streakOutcomes.push({
|
|
655
|
+
beadIds: subIds, doerMember, wasRetried, report: null,
|
|
656
|
+
unclosedIds: subUnclosed, closedIds: subClosed,
|
|
657
|
+
outcome: subUnclosed.length > 0 ? 'failed' : 'success',
|
|
658
|
+
...(subUnclosed.length > 0 ? {
|
|
659
|
+
error: dispatchError.message,
|
|
660
|
+
...(permissionScopeBlocked ? { publishBlocked: true } : {}),
|
|
661
|
+
} : {}),
|
|
662
|
+
});
|
|
663
|
+
}
|
|
664
|
+
} else {
|
|
665
|
+
streakOutcomes.push({
|
|
666
|
+
beadIds: actualBeadIds, doerMember, outcome: 'failed', wasRetried,
|
|
667
|
+
report: null, unclosedIds, closedIds, error: dispatchError.message,
|
|
668
|
+
...(permissionScopeBlocked ? { publishBlocked: true } : {}),
|
|
669
|
+
});
|
|
670
|
+
}
|
|
671
|
+
if (permissionScopeBlocked) {
|
|
672
|
+
// Record every still-open bead id so future rounds AND
|
|
673
|
+
// future cycles this sprint skip them outright (see the
|
|
674
|
+
// carry-over filter at the top of this function) instead of
|
|
675
|
+
// re-selecting them into `currentReady` and reproducing the
|
|
676
|
+
// identical refusal. Beads this dispatch DID manage to close
|
|
677
|
+
// (closedIds) are deliberately excluded -- their work already
|
|
678
|
+
// stands and they are not "ready" again regardless.
|
|
679
|
+
for (const id of unclosedIds) {
|
|
680
|
+
permissionScopeBlockedBeads.set(id, dispatchError.message);
|
|
681
|
+
}
|
|
682
|
+
// Refresh the dashboard/terminal summary state so the
|
|
683
|
+
// publish-blocked outcome (and its operator referral) is
|
|
684
|
+
// visible there too, exactly as a normal completed turn
|
|
685
|
+
// does below -- not just in the log.
|
|
686
|
+
await updateDashboard();
|
|
687
|
+
// Deliberately NOT rethrown: this is a recognised, handled
|
|
688
|
+
// condition (work done, publish blocked), not a dispatch
|
|
689
|
+
// crash for parallel()'s continueOnError accounting to
|
|
690
|
+
// isolate. Every OTHER dispatchError class still rethrows
|
|
691
|
+
// below, unchanged.
|
|
692
|
+
return;
|
|
693
|
+
}
|
|
694
|
+
// Rethrow so parallel()'s continueOnError:true isolates
|
|
695
|
+
// this failure from sibling streaks (the outcome above
|
|
696
|
+
// is already recorded via closure, so no information is
|
|
697
|
+
// lost when parallel() substitutes `null` for this branch).
|
|
698
|
+
throw dispatchError;
|
|
699
|
+
}
|
|
700
|
+
|
|
701
|
+
// No duplicate log() dump of `report` here -- see dispatchReview()
|
|
702
|
+
// for why. The doer streak's own AGENT row already carries this
|
|
703
|
+
// verbatim as its `output`, and its label names the bead ids.
|
|
704
|
+
|
|
705
|
+
// CRITICAL: never trust the doer's own success claim -- verify
|
|
706
|
+
// via `bd show` that the assigned bead ids are actually closed. A
|
|
707
|
+
// doer that returns a success-looking report but leaves a bead
|
|
708
|
+
// open is treated as a FAILED streak regardless of what it said.
|
|
709
|
+
//
|
|
710
|
+
// apra-fleet-3swo.5.7: that verification is the 'doer' row's
|
|
711
|
+
// 'verify-streak-closed' postResult step, which the engine ran
|
|
712
|
+
// immediately after the successful dispatch -- read its answer
|
|
713
|
+
// back off the outcome rather than doing the (D-pulling) read a
|
|
714
|
+
// second time. The row's 'kb-apply' step ran right after it:
|
|
715
|
+
// the doer decides what to capture and the engine executes it
|
|
716
|
+
// against the repo THAT doer worked in.
|
|
717
|
+
const unclosedIds = doerOutcome.stepResults['verify-streak-closed'];
|
|
718
|
+
const closedIds = actualBeadIds.filter((id) => !unclosedIds.includes(id));
|
|
719
|
+
|
|
720
|
+
// apra-fleet-eft.76.4: per-bead failure attribution -- always
|
|
721
|
+
// emitted (not only when something failed) so every streak's
|
|
722
|
+
// report leaves an audit trail of exactly which beads closed
|
|
723
|
+
// vs which stayed open. Closed beads stay closed regardless
|
|
724
|
+
// of a sibling bead in the same streak being refused; only
|
|
725
|
+
// the still-open ones are eligible for re-laning next round
|
|
726
|
+
// (the next dev round's `currentReady` query naturally omits
|
|
727
|
+
// whatever already closed here).
|
|
728
|
+
log(`Doer streak attribution [${actualBeadIds.join(', ')}]: closed=[${closedIds.join(', ')}] failed=[${unclosedIds.join(', ')}].`);
|
|
729
|
+
|
|
730
|
+
if (unclosedIds.length > 0) {
|
|
731
|
+
log(`Doer streak [${actualBeadIds.join(', ')}] reported status '${report ? report.status : 'unknown'}' but bead(s) still open: ${unclosedIds.join(', ')} -- treating streak as FAILED.`);
|
|
732
|
+
}
|
|
733
|
+
|
|
734
|
+
if (batchStreaks) {
|
|
735
|
+
// Mode (i): PER-STREAK outcome attribution for the batch
|
|
736
|
+
// dispatch -- one outcome per sub-streak, so review scope and
|
|
737
|
+
// re-laning stay per-streak exactly as in mode (ii).
|
|
738
|
+
for (const sub of batchStreaks) {
|
|
739
|
+
const subIds = sub.map((b) => b.id).filter((id) => actualBeadIds.includes(id));
|
|
740
|
+
if (subIds.length === 0) continue;
|
|
741
|
+
const subUnclosed = subIds.filter((id) => unclosedIds.includes(id));
|
|
742
|
+
const subClosed = subIds.filter((id) => !subUnclosed.includes(id));
|
|
743
|
+
streakOutcomes.push({
|
|
744
|
+
beadIds: subIds, doerMember, wasRetried, report,
|
|
745
|
+
unclosedIds: subUnclosed, closedIds: subClosed,
|
|
746
|
+
outcome: subUnclosed.length > 0 ? 'failed' : (wasRetried ? 'retried' : 'success'),
|
|
747
|
+
});
|
|
748
|
+
}
|
|
749
|
+
} else {
|
|
750
|
+
streakOutcomes.push({
|
|
751
|
+
beadIds: actualBeadIds, doerMember, wasRetried, report, unclosedIds, closedIds,
|
|
752
|
+
outcome: unclosedIds.length > 0 ? 'failed' : (wasRetried ? 'retried' : 'success'),
|
|
753
|
+
});
|
|
754
|
+
}
|
|
755
|
+
await updateDashboard();
|
|
756
|
+
} finally {
|
|
757
|
+
releaseTurn();
|
|
758
|
+
}
|
|
759
|
+
};
|
|
760
|
+
|
|
761
|
+
await parallel(worklistPacking.worklists, async (worklist, index) => {
|
|
762
|
+
if (!worklist || worklist.length === 0) return; // a packed round can leave a doer idle
|
|
763
|
+
const doerMember = doerPool[index % doerPool.length];
|
|
764
|
+
// Per-worklist session context: the doer's captured session id +
|
|
765
|
+
// last reported usage, carried across the streaks of THIS
|
|
766
|
+
// worklist only -- never across doers or rounds.
|
|
767
|
+
const worklistCtx = { sessionId: null, usage: null };
|
|
768
|
+
|
|
769
|
+
if (worklistMode === 'batch' && worklist.length > 1) {
|
|
770
|
+
// Mode (i) BATCH: one dispatch carries the whole ordered
|
|
771
|
+
// worklist (assignDoerWorklists guarantees it is
|
|
772
|
+
// tier-homogeneous). Per-streak outcomes are attributed
|
|
773
|
+
// after the fact via `batchStreaks`.
|
|
774
|
+
await runStreakTurn({
|
|
775
|
+
streak: worklist.flat(),
|
|
776
|
+
doerMember,
|
|
777
|
+
worklistCtx,
|
|
778
|
+
packed: worklistPacking.packed,
|
|
779
|
+
batchStreaks: worklist,
|
|
780
|
+
});
|
|
781
|
+
return;
|
|
782
|
+
}
|
|
783
|
+
|
|
784
|
+
// Mode (ii) RESUMED SEQUENCE (default): one dispatch per streak,
|
|
785
|
+
// in worklist order, each going through the SAME global FIFO
|
|
786
|
+
// gate (runStreakTurn acquires it per streak) and the same
|
|
787
|
+
// git/dolt sync brackets -- so every engine checkpoint is kept
|
|
788
|
+
// BETWEEN streaks. A failure in streak N is recorded and
|
|
789
|
+
// isolated: streaks 1..N-1's closes already stand (per-bead
|
|
790
|
+
// attribution), and N+1.. still dispatch (fresh session -- the
|
|
791
|
+
// catch clears the worklist session so a broken session is
|
|
792
|
+
// never resumed).
|
|
793
|
+
let firstError = null;
|
|
794
|
+
for (let wIdx = 0; wIdx < worklist.length; wIdx++) {
|
|
795
|
+
try {
|
|
796
|
+
await runStreakTurn({
|
|
797
|
+
streak: worklist[wIdx],
|
|
798
|
+
doerMember,
|
|
799
|
+
worklistCtx,
|
|
800
|
+
worklistPosition: wIdx,
|
|
801
|
+
worklistLength: worklist.length,
|
|
802
|
+
packed: worklistPacking.packed,
|
|
803
|
+
});
|
|
804
|
+
} catch (err) {
|
|
805
|
+
firstError = firstError || err;
|
|
806
|
+
worklistCtx.sessionId = null;
|
|
807
|
+
worklistCtx.usage = null;
|
|
808
|
+
}
|
|
809
|
+
}
|
|
810
|
+
// Rethrow (after ALL streaks ran) so parallel()'s
|
|
811
|
+
// continueOnError:true accounting records this worklist's
|
|
812
|
+
// failure.
|
|
813
|
+
if (firstError) throw firstError;
|
|
814
|
+
}, { continueOnError: true });
|
|
815
|
+
|
|
816
|
+
log(`Develop C${cycle} R${devRounds} streak outcomes: ${JSON.stringify(streakOutcomes.map((o) => ({ beadIds: o.beadIds, outcome: o.outcome })))}`);
|
|
817
|
+
|
|
818
|
+
// The two values the Review phase (still inline in runner.js, in this same
|
|
819
|
+
// round loop iteration) reads out of this round -- see the return shape in
|
|
820
|
+
// this function's doc comment.
|
|
821
|
+
return { streakOutcomes, readyTitleById };
|
|
822
|
+
}
|