@apralabs/apra-fleet 0.4.3 → 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 +114 -33
- package/dist/agents/backlog-groomer.md +80 -27
- package/dist/agents/ci-watcher.md +42 -22
- package/dist/agents/deployer.md +59 -24
- package/dist/agents/doer.md +111 -41
- package/dist/agents/harvester.md +60 -48
- package/dist/agents/integ-test-runner.md +45 -23
- package/dist/agents/kb-reconciler.md +34 -7
- package/dist/agents/plan-reviewer.md +54 -24
- package/dist/agents/planner.md +71 -43
- package/dist/agents/regression-test-runner.md +106 -78
- package/dist/agents/reviewer.md +170 -57
- package/dist/agents/schemas/backlog-groomer-output.json +1 -1
- package/dist/agents/schemas/deployer-output.json +5 -0
- package/dist/agents/schemas/doer-output.json +110 -2
- package/dist/agents/schemas/harvester-input.json +1 -5
- package/dist/agents/schemas/planner-output.json +1 -1
- package/dist/agents/schemas/regression-test-runner-output.json +41 -7
- package/dist/agents/schemas/reviewer-output.json +166 -5
- package/dist/cli/agent-transform.d.ts +7 -0
- package/dist/cli/agent-transform.js +46 -1
- package/dist/cli/auth.d.ts +1 -0
- package/dist/cli/auth.js +42 -8
- package/dist/cli/beads-install.d.ts +35 -0
- package/dist/cli/beads-install.js +125 -0
- package/dist/cli/beads-pin.d.ts +5 -0
- package/dist/cli/beads-pin.js +26 -0
- package/dist/cli/call.d.ts +27 -0
- package/dist/cli/call.js +177 -0
- package/dist/cli/claude-mod.d.ts +75 -0
- package/dist/cli/claude-mod.js +288 -0
- package/dist/cli/config.d.ts +24 -1
- package/dist/cli/config.js +69 -2
- package/dist/cli/dolt-install.d.ts +19 -3
- package/dist/cli/dolt-install.js +51 -16
- package/dist/cli/fleet-se-guard.d.ts +59 -0
- package/dist/cli/fleet-se-guard.js +231 -0
- package/dist/cli/install-guard.d.ts +63 -0
- package/dist/cli/install-guard.js +156 -4
- package/dist/cli/install.d.ts +89 -21
- package/dist/cli/install.js +778 -160
- package/dist/cli/kb-commit.d.ts +2 -1
- package/dist/cli/kb-commit.js +1 -1
- package/dist/cli/kb-import.d.ts +2 -1
- package/dist/cli/kb-import.js +1 -1
- package/dist/cli/kb-profile.d.ts +16 -0
- package/dist/cli/kb-profile.js +81 -0
- package/dist/cli/register-member.js +20 -3
- package/dist/cli/remove-member.d.ts +4 -0
- package/dist/cli/remove-member.js +63 -0
- package/dist/cli/secret.js +9 -0
- package/dist/cli/start.js +62 -4
- package/dist/cli/status.d.ts +3 -0
- package/dist/cli/status.js +45 -12
- package/dist/cli/stop.js +64 -9
- package/dist/cli/uninstall.js +112 -16
- package/dist/cli/update.d.ts +4 -0
- package/dist/cli/update.js +52 -5
- package/dist/cli/watch.js +1 -1
- package/dist/cli/workflow.js +3 -2
- package/dist/commands/kb-server.d.ts +10 -1
- package/dist/commands/kb-server.js +292 -11
- package/dist/hub-service/http-server.d.ts +5 -1
- package/dist/hub-service/http-server.js +55 -5
- package/dist/index.js +177 -9
- package/dist/os/child-env-bound.d.ts +77 -0
- package/dist/os/child-env-bound.js +171 -0
- 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 +9 -2
- package/dist/os/linux.js +50 -15
- package/dist/os/macos.d.ts +1 -1
- package/dist/os/macos.js +2 -11
- package/dist/os/os-commands.d.ts +42 -2
- 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 +24 -14
- package/dist/os/windows-gitbash.js +56 -18
- package/dist/os/windows-wrapper.d.ts +0 -4
- package/dist/os/windows-wrapper.js +2 -1
- package/dist/os/windows.d.ts +7 -2
- package/dist/os/windows.js +109 -32
- package/dist/paths.d.ts +30 -0
- package/dist/paths.js +52 -0
- package/dist/providers/agy.d.ts +6 -2
- package/dist/providers/agy.js +245 -106
- package/dist/providers/claude-permission-denial.d.ts +7 -0
- package/dist/providers/claude-permission-denial.js +137 -0
- package/dist/providers/claude.d.ts +86 -38
- package/dist/providers/claude.js +426 -164
- package/dist/providers/codex.js +5 -1
- package/dist/providers/copilot.js +5 -1
- package/dist/providers/opencode.d.ts +10 -2
- package/dist/providers/opencode.js +114 -53
- package/dist/providers/provider.d.ts +171 -33
- package/dist/providers/provider.js +164 -3
- package/dist/services/agent-provisioner.d.ts +29 -0
- package/dist/services/agent-provisioner.js +107 -0
- package/dist/services/agent-shadow.d.ts +96 -0
- package/dist/services/agent-shadow.js +479 -0
- package/dist/services/agy-project.d.ts +9 -2
- package/dist/services/agy-project.js +22 -19
- package/dist/services/auth-socket.d.ts +43 -0
- package/dist/services/auth-socket.js +97 -26
- package/dist/services/auth-web.js +1 -1
- package/dist/services/budget-awareness.d.ts +11 -11
- package/dist/services/budget-awareness.js +15 -3
- package/dist/services/claude-local-scope-mcp.d.ts +19 -0
- package/dist/services/claude-local-scope-mcp.js +91 -0
- package/dist/services/cloud/aws.js +2 -1
- package/dist/services/cloud/lifecycle.js +19 -2
- package/dist/services/cloud/task-wrapper.d.ts +0 -9
- package/dist/services/cloud/task-wrapper.js +15 -6
- package/dist/services/credential-store.d.ts +33 -0
- package/dist/services/credential-store.js +79 -2
- package/dist/services/event-loop-watchdog.d.ts +32 -0
- package/dist/services/event-loop-watchdog.js +140 -0
- package/dist/services/http-transport.d.ts +78 -1
- package/dist/services/http-transport.js +347 -52
- package/dist/services/in-flight-agents.d.ts +2 -0
- package/dist/services/in-flight-agents.js +4 -0
- package/dist/services/kb-tool-profile.d.ts +36 -0
- package/dist/services/kb-tool-profile.js +88 -0
- package/dist/services/knowledge/bible-basis-filter.d.ts +53 -0
- package/dist/services/knowledge/bible-basis-filter.js +134 -0
- package/dist/services/knowledge/bible-blob-id.d.ts +44 -0
- package/dist/services/knowledge/bible-blob-id.js +122 -0
- package/dist/services/knowledge/bible-import.d.ts +173 -0
- package/dist/services/knowledge/bible-import.js +344 -0
- package/dist/services/knowledge/file-hash.d.ts +31 -0
- package/dist/services/knowledge/file-hash.js +155 -24
- package/dist/services/knowledge/http-provider.d.ts +305 -21
- package/dist/services/knowledge/http-provider.js +801 -119
- 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-maintainer-grant.d.ts +15 -0
- package/dist/services/knowledge/kb-maintainer-grant.js +34 -0
- package/dist/services/knowledge/kb-providers.d.ts +13 -2
- package/dist/services/knowledge/kb-providers.js +75 -37
- package/dist/services/knowledge/kb-removed-scope-keys.d.ts +28 -0
- package/dist/services/knowledge/kb-removed-scope-keys.js +59 -0
- package/dist/services/knowledge/kb-scopes.d.ts +14 -0
- package/dist/services/knowledge/kb-scopes.js +47 -0
- package/dist/services/knowledge/kb-self.d.ts +204 -0
- package/dist/services/knowledge/kb-self.js +358 -0
- package/dist/services/knowledge/member-bible-view.d.ts +21 -0
- package/dist/services/knowledge/member-bible-view.js +207 -0
- package/dist/services/knowledge/path-validation.d.ts +7 -0
- package/dist/services/knowledge/path-validation.js +11 -0
- package/dist/services/knowledge/pre-init.js +1 -0
- package/dist/services/knowledge/project-slug.js +5 -4
- 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 +233 -11
- package/dist/services/knowledge/sqlite-provider.js +719 -45
- package/dist/services/knowledge/types.d.ts +59 -3
- package/dist/services/member-access-secret.d.ts +70 -0
- package/dist/services/member-access-secret.js +195 -0
- package/dist/services/member-busy.d.ts +12 -0
- package/dist/services/member-busy.js +20 -0
- package/dist/services/member-call-counts.d.ts +24 -0
- package/dist/services/member-call-counts.js +58 -0
- package/dist/services/member-config-io.d.ts +193 -0
- package/dist/services/member-config-io.js +446 -0
- package/dist/services/member-fleet-install.d.ts +710 -0
- package/dist/services/member-fleet-install.js +1896 -0
- package/dist/services/member-secret-env.d.ts +42 -0
- package/dist/services/member-secret-env.js +68 -0
- package/dist/services/member-tool-allowlist.d.ts +49 -0
- package/dist/services/member-tool-allowlist.js +115 -0
- package/dist/services/model-pricing.d.ts +19 -0
- package/dist/services/model-pricing.js +54 -8
- package/dist/services/port-holder.d.ts +86 -0
- package/dist/services/port-holder.js +352 -0
- package/dist/services/preflight-check.js +2 -0
- package/dist/services/registry.d.ts +13 -2
- package/dist/services/registry.js +27 -1
- package/dist/services/relay-strategy.d.ts +2 -0
- package/dist/services/relay-strategy.js +8 -0
- package/dist/services/server-lifecycle.d.ts +26 -0
- package/dist/services/server-lifecycle.js +85 -0
- package/dist/services/service-manager/index.d.ts +7 -1
- package/dist/services/service-manager/index.js +17 -4
- package/dist/services/service-manager/linux.d.ts +1 -1
- package/dist/services/service-manager/linux.js +15 -7
- package/dist/services/service-manager/macos.d.ts +11 -1
- package/dist/services/service-manager/macos.js +45 -7
- package/dist/services/service-manager/service-path.d.ts +24 -0
- package/dist/services/service-manager/service-path.js +55 -0
- package/dist/services/service-manager/types.d.ts +54 -3
- package/dist/services/service-manager/types.js +29 -0
- package/dist/services/service-manager/windows.d.ts +187 -3
- package/dist/services/service-manager/windows.js +684 -50
- package/dist/services/service-notice.d.ts +21 -0
- package/dist/services/service-notice.js +81 -0
- package/dist/services/service-start-guard.d.ts +20 -0
- package/dist/services/service-start-guard.js +86 -0
- package/dist/services/session-cost.d.ts +24 -0
- package/dist/services/session-cost.js +105 -0
- package/dist/services/session-mcp-config.d.ts +83 -0
- package/dist/services/session-mcp-config.js +211 -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/sftp.d.ts +34 -0
- package/dist/services/sftp.js +304 -76
- package/dist/services/shell-probe.d.ts +0 -24
- package/dist/services/shell-probe.js +28 -3
- package/dist/services/singleton.d.ts +68 -2
- package/dist/services/singleton.js +168 -11
- package/dist/services/sprint-coordination.js +9 -3
- package/dist/services/ssh.d.ts +27 -0
- package/dist/services/ssh.js +229 -38
- package/dist/services/stall/find-log-file.js +12 -5
- package/dist/services/stall/index.d.ts +1 -1
- package/dist/services/stall/read-log-tail.d.ts +23 -0
- package/dist/services/stall/read-log-tail.js +33 -2
- package/dist/services/stall/stall-detector.d.ts +25 -1
- package/dist/services/stall/stall-detector.js +85 -6
- package/dist/services/stall/stall-poller.d.ts +16 -0
- package/dist/services/stall/stall-poller.js +50 -6
- package/dist/services/statusline.d.ts +21 -0
- package/dist/services/statusline.js +97 -1
- package/dist/services/stopped-marker.d.ts +16 -0
- package/dist/services/stopped-marker.js +55 -0
- package/dist/services/strategy.d.ts +33 -1
- package/dist/services/strategy.js +86 -17
- package/dist/services/supervisor-service-cleanup.d.ts +52 -0
- package/dist/services/supervisor-service-cleanup.js +333 -0
- package/dist/services/tool-registry.d.ts +8 -1
- package/dist/services/tool-registry.js +251 -62
- package/dist/services/tool-scope.d.ts +91 -0
- package/dist/services/tool-scope.js +124 -0
- 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 +3 -1
- package/dist/skills/auto-sprint-args/SKILL.md +2 -2
- package/dist/skills/fleet-sprint-cli/SKILL.md +39 -15
- package/dist/skills/pm/SKILL.md +3 -3
- package/dist/skills/pm/cost.md +5 -1
- package/dist/skills/pm/index.md +11 -9
- package/dist/skills/pm/kb-reconcile.md +29 -14
- package/dist/skills/pm/kb-review.md +1 -0
- package/dist/skills/pm/sprint.md +7 -6
- package/dist/tools/check-status.d.ts +104 -5
- package/dist/tools/check-status.js +326 -57
- package/dist/tools/child-id-allocator.d.ts +2 -2
- package/dist/tools/child-id-allocator.js +1 -1
- package/dist/tools/code-index-heal.d.ts +8 -0
- package/dist/tools/code-index-heal.js +21 -0
- package/dist/tools/code-index-state.d.ts +45 -0
- package/dist/tools/code-index-state.js +115 -0
- package/dist/tools/code-intelligence-codebase-memory.js +6 -33
- package/dist/tools/code-intelligence-freshness.js +1 -1
- package/dist/tools/code-intelligence-gitnexus.d.ts +49 -0
- package/dist/tools/code-intelligence-gitnexus.js +488 -55
- package/dist/tools/code-intelligence-kb-enrich.js +7 -6
- package/dist/tools/code-intelligence-readiness.d.ts +156 -0
- package/dist/tools/code-intelligence-readiness.js +291 -0
- package/dist/tools/code-intelligence-reindex.d.ts +219 -0
- package/dist/tools/code-intelligence-reindex.js +602 -50
- package/dist/tools/code-intelligence-telemetry.d.ts +6 -1
- package/dist/tools/code-intelligence-telemetry.js +12 -3
- package/dist/tools/code-intelligence.d.ts +81 -31
- package/dist/tools/code-intelligence.js +156 -52
- package/dist/tools/compose-permissions.d.ts +57 -2
- package/dist/tools/compose-permissions.js +497 -44
- package/dist/tools/execute-command.d.ts +11 -0
- package/dist/tools/execute-command.js +92 -18
- package/dist/tools/execute-prompt.d.ts +59 -15
- package/dist/tools/execute-prompt.js +550 -135
- 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 +79 -0
- package/dist/tools/kb-bible-commit.js +348 -0
- package/dist/tools/kb-capture.d.ts +15 -11
- package/dist/tools/kb-capture.js +42 -11
- package/dist/tools/kb-context.d.ts +27 -7
- package/dist/tools/kb-context.js +85 -14
- package/dist/tools/kb-demote.d.ts +27 -0
- package/dist/tools/kb-demote.js +37 -0
- package/dist/tools/kb-export.d.ts +128 -7
- package/dist/tools/kb-export.js +273 -67
- package/dist/tools/kb-feedback.d.ts +15 -9
- package/dist/tools/kb-feedback.js +27 -11
- package/dist/tools/kb-freshness-sweep.d.ts +11 -7
- package/dist/tools/kb-freshness-sweep.js +7 -7
- package/dist/tools/kb-harvest.d.ts +11 -7
- package/dist/tools/kb-harvest.js +35 -16
- package/dist/tools/kb-import.d.ts +42 -10
- package/dist/tools/kb-import.js +185 -160
- package/dist/tools/kb-invalidate.d.ts +26 -11
- package/dist/tools/kb-invalidate.js +118 -12
- package/dist/tools/kb-list.d.ts +14 -10
- package/dist/tools/kb-list.js +61 -13
- package/dist/tools/kb-promote.d.ts +11 -7
- package/dist/tools/kb-promote.js +16 -8
- package/dist/tools/kb-query.d.ts +24 -11
- package/dist/tools/kb-query.js +230 -23
- package/dist/tools/kb-reconcile-prefilter.d.ts +11 -7
- package/dist/tools/kb-reconcile-prefilter.js +10 -8
- package/dist/tools/kb-resolve-contradiction.d.ts +11 -7
- package/dist/tools/kb-resolve-contradiction.js +7 -7
- package/dist/tools/kb-session-prime.d.ts +14 -7
- package/dist/tools/kb-session-prime.js +127 -47
- package/dist/tools/kb-setup.d.ts +31 -4
- package/dist/tools/kb-setup.js +172 -20
- package/dist/tools/kb-stats.d.ts +11 -10
- package/dist/tools/kb-stats.js +22 -41
- package/dist/tools/list-members.js +6 -3
- package/dist/tools/member-detail.d.ts +3 -0
- package/dist/tools/member-detail.js +95 -20
- package/dist/tools/member-reservation.d.ts +2 -2
- package/dist/tools/provision-auth.d.ts +39 -1
- package/dist/tools/provision-auth.js +269 -47
- package/dist/tools/provision-vcs-auth.d.ts +30 -5
- package/dist/tools/provision-vcs-auth.js +53 -7
- package/dist/tools/receive-files.js +8 -3
- package/dist/tools/register-member.d.ts +34 -8
- package/dist/tools/register-member.js +76 -58
- package/dist/tools/remove-member.js +110 -32
- package/dist/tools/send-email.d.ts +2 -2
- package/dist/tools/send-files.js +9 -6
- package/dist/tools/send-message.d.ts +3 -0
- package/dist/tools/send-message.js +15 -2
- package/dist/tools/session-stats.d.ts +17 -0
- package/dist/tools/session-stats.js +27 -0
- package/dist/tools/shutdown-server.js +5 -0
- package/dist/tools/stop-prompt.js +3 -1
- package/dist/tools/update-agent-cli.d.ts +19 -0
- package/dist/tools/update-agent-cli.js +59 -2
- package/dist/tools/update-member.d.ts +13 -10
- package/dist/tools/update-member.js +138 -7
- package/dist/tools/vcs-credential-exec.d.ts +45 -3
- package/dist/tools/vcs-credential-exec.js +98 -13
- package/dist/types.d.ts +98 -1
- package/dist/utils/agent-helpers.js +2 -0
- package/dist/utils/auth-env.d.ts +15 -4
- package/dist/utils/auth-env.js +52 -23
- package/dist/utils/find-on-path.d.ts +37 -0
- package/dist/utils/find-on-path.js +85 -0
- package/dist/utils/log-helpers.d.ts +37 -0
- package/dist/utils/log-helpers.js +106 -20
- package/dist/utils/owner-only-fs.d.ts +56 -0
- package/dist/utils/owner-only-fs.js +98 -0
- package/dist/utils/process-utils.d.ts +28 -0
- package/dist/utils/process-utils.js +72 -0
- package/dist/utils/prompt-errors.js +4 -1
- package/dist/utils/redact-known-secrets.d.ts +17 -0
- package/dist/utils/redact-known-secrets.js +70 -0
- package/dist/utils/session-caller.d.ts +4 -2
- package/dist/utils/session-caller.js +3 -2
- package/dist/utils/shell-escape.d.ts +42 -3
- package/dist/utils/shell-escape.js +70 -4
- package/dist/utils/skill-matrix.js +1 -1
- package/dist/utils/ssh-error-messages.js +3 -0
- package/dist/utils/vcs-provider-detect.js +2 -2
- package/dist/utils/workspace-trust.d.ts +24 -1
- package/dist/utils/workspace-trust.js +21 -17
- package/dist/workflows/auto-sprint.js +468 -52
- package/package.json +15 -9
- package/packages/apra-fleet-client/package.json +2 -2
- package/packages/apra-fleet-client/src/client/api.mjs +722 -38
- package/packages/apra-fleet-client/src/client/auto-start.mjs +434 -0
- package/packages/apra-fleet-client/src/client/client.mjs +9 -0
- package/packages/apra-fleet-client/src/client/factory.mjs +23 -4
- package/packages/apra-fleet-client/src/client/reconnecting-transport.mjs +170 -0
- package/packages/apra-fleet-client/src/client/server-resolution.mjs +267 -30
- package/packages/apra-fleet-client/src/client/transport.mjs +43 -3
- package/packages/apra-fleet-se/apra-pm/agents/backlog-groomer.md +80 -27
- package/packages/apra-fleet-se/apra-pm/agents/ci-watcher.md +42 -22
- package/packages/apra-fleet-se/apra-pm/agents/deployer.md +59 -24
- package/packages/apra-fleet-se/apra-pm/agents/doer.md +111 -41
- package/packages/apra-fleet-se/apra-pm/agents/harvester.md +60 -48
- package/packages/apra-fleet-se/apra-pm/agents/integ-test-runner.md +45 -23
- package/packages/apra-fleet-se/apra-pm/agents/kb-reconciler.md +34 -7
- package/packages/apra-fleet-se/apra-pm/agents/plan-reviewer.md +54 -24
- package/packages/apra-fleet-se/apra-pm/agents/planner.md +71 -43
- package/packages/apra-fleet-se/apra-pm/agents/regression-test-runner.md +106 -78
- package/packages/apra-fleet-se/apra-pm/agents/reviewer.md +170 -57
- package/packages/apra-fleet-se/apra-pm/agents/schemas/backlog-groomer-output.json +1 -1
- 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 +110 -2
- package/packages/apra-fleet-se/apra-pm/agents/schemas/harvester-input.json +1 -5
- package/packages/apra-fleet-se/apra-pm/agents/schemas/planner-output.json +1 -1
- package/packages/apra-fleet-se/apra-pm/agents/schemas/regression-test-runner-output.json +41 -7
- package/packages/apra-fleet-se/apra-pm/agents/schemas/reviewer-output.json +166 -5
- package/packages/apra-fleet-se/apra-pm/skills/pm/SKILL.md +3 -3
- package/packages/apra-fleet-se/apra-pm/skills/pm/cost.md +5 -1
- package/packages/apra-fleet-se/apra-pm/skills/pm/index.md +11 -9
- package/packages/apra-fleet-se/apra-pm/skills/pm/kb-reconcile.md +29 -14
- package/packages/apra-fleet-se/apra-pm/skills/pm/kb-review.md +1 -0
- package/packages/apra-fleet-se/apra-pm/skills/pm/sprint.md +7 -6
- package/packages/apra-fleet-se/bin/cli.mjs +282 -79
- package/packages/apra-fleet-se/bin/serve.mjs +186 -15
- package/packages/apra-fleet-se/fleet-sprint/abort.mjs +234 -46
- package/packages/apra-fleet-se/fleet-sprint/backlog-role.mjs +93 -0
- package/packages/apra-fleet-se/fleet-sprint/bd-sync-command.mjs +69 -0
- package/packages/apra-fleet-se/fleet-sprint/beads-children.mjs +229 -53
- package/packages/apra-fleet-se/fleet-sprint/beads-identity-check.mjs +576 -33
- package/packages/apra-fleet-se/fleet-sprint/beads-identity.mjs +9 -0
- package/packages/apra-fleet-se/fleet-sprint/beads-lock-probe.mjs +176 -0
- package/packages/apra-fleet-se/fleet-sprint/beads-memory-hygiene.mjs +201 -0
- package/packages/apra-fleet-se/fleet-sprint/beads-reachability.mjs +126 -0
- package/packages/apra-fleet-se/fleet-sprint/beads-scope.mjs +271 -7
- package/packages/apra-fleet-se/fleet-sprint/beads-transitions.mjs +154 -8
- package/packages/apra-fleet-se/fleet-sprint/ci-gate.mjs +353 -0
- package/packages/apra-fleet-se/fleet-sprint/conflict-ladder.mjs +12 -0
- package/packages/apra-fleet-se/fleet-sprint/contracts.mjs +142 -3
- package/packages/apra-fleet-se/fleet-sprint/coordination.mjs +48 -8
- 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-accounting.mjs +270 -0
- package/packages/apra-fleet-se/fleet-sprint/dispatch-failure.mjs +22 -2
- package/packages/apra-fleet-se/fleet-sprint/dispatch-role.mjs +244 -22
- package/packages/apra-fleet-se/fleet-sprint/docs/README.md +56 -15
- package/packages/apra-fleet-se/fleet-sprint/docs/dolt-sync-redesign.md +6 -1
- package/packages/apra-fleet-se/fleet-sprint/docs/fleet-sprint-diagram.md +3 -3
- package/packages/apra-fleet-se/fleet-sprint/dolt-settle.mjs +9 -3
- package/packages/apra-fleet-se/fleet-sprint/dolt-sync.mjs +651 -37
- package/packages/apra-fleet-se/fleet-sprint/errors.mjs +282 -15
- package/packages/apra-fleet-se/fleet-sprint/explicit-id-create-guard.mjs +4 -4
- package/packages/apra-fleet-se/fleet-sprint/git-sync.mjs +207 -10
- package/packages/apra-fleet-se/fleet-sprint/git-topology.mjs +169 -10
- package/packages/apra-fleet-se/fleet-sprint/guarded-modules.mjs +88 -5
- package/packages/apra-fleet-se/fleet-sprint/kb-hints.mjs +181 -0
- package/packages/apra-fleet-se/fleet-sprint/kb-injection.mjs +64 -0
- package/packages/apra-fleet-se/fleet-sprint/kb-maintainer.mjs +298 -0
- package/packages/apra-fleet-se/fleet-sprint/kb.mjs +1896 -305
- package/packages/apra-fleet-se/fleet-sprint/lower-quality.mjs +39 -0
- package/packages/apra-fleet-se/fleet-sprint/member-align.mjs +391 -0
- package/packages/apra-fleet-se/fleet-sprint/member-call.mjs +374 -0
- package/packages/apra-fleet-se/fleet-sprint/member-init-probe.mjs +644 -0
- package/packages/apra-fleet-se/fleet-sprint/member-provisioning.mjs +454 -1
- package/packages/apra-fleet-se/fleet-sprint/member-sync.mjs +250 -29
- package/packages/apra-fleet-se/fleet-sprint/orphan-reclaim.mjs +153 -0
- package/packages/apra-fleet-se/fleet-sprint/phases/deploy.mjs +129 -0
- package/packages/apra-fleet-se/fleet-sprint/phases/develop.mjs +302 -52
- package/packages/apra-fleet-se/fleet-sprint/phases/ensure-sprint-branch.mjs +1 -0
- package/packages/apra-fleet-se/fleet-sprint/phases/final-review.mjs +142 -21
- package/packages/apra-fleet-se/fleet-sprint/phases/harvest.mjs +118 -36
- package/packages/apra-fleet-se/fleet-sprint/phases/integ-test.mjs +6 -6
- package/packages/apra-fleet-se/fleet-sprint/phases/plan.mjs +27 -18
- package/packages/apra-fleet-se/fleet-sprint/phases/publish-pr.mjs +99 -52
- package/packages/apra-fleet-se/fleet-sprint/phases/re-review.mjs +58 -10
- package/packages/apra-fleet-se/fleet-sprint/phases/regression-test.mjs +16 -11
- package/packages/apra-fleet-se/fleet-sprint/phases/replan.mjs +36 -3
- package/packages/apra-fleet-se/fleet-sprint/phases/review.mjs +90 -15
- package/packages/apra-fleet-se/fleet-sprint/pr-body.mjs +272 -0
- package/packages/apra-fleet-se/fleet-sprint/prompts.mjs +113 -28
- package/packages/apra-fleet-se/fleet-sprint/role-policies.mjs +19 -1
- package/packages/apra-fleet-se/fleet-sprint/runner.js +1631 -213
- package/packages/apra-fleet-se/fleet-sprint/se-os-commands.mjs +26 -0
- package/packages/apra-fleet-se/fleet-sprint/se-posix.mjs +183 -0
- package/packages/apra-fleet-se/fleet-sprint/se-windows.mjs +138 -0
- package/packages/apra-fleet-se/fleet-sprint/set-aside.mjs +288 -0
- package/packages/apra-fleet-se/fleet-sprint/shell-command-guard.mjs +44 -1
- package/packages/apra-fleet-se/fleet-sprint/skills/fleet-sprint-cli/SKILL.md +39 -15
- package/packages/apra-fleet-se/fleet-sprint/skills/fleet-supervisor/SKILL.md +87 -32
- package/packages/apra-fleet-se/fleet-sprint/sprint-args.mjs +158 -2
- package/packages/apra-fleet-se/fleet-sprint/sprint-report.mjs +132 -11
- package/packages/apra-fleet-se/fleet-sprint/sprint-state.mjs +31 -0
- package/packages/apra-fleet-se/fleet-sprint/usage-limit-controller.mjs +7 -0
- package/packages/apra-fleet-se/fleet-sprint/vcs-auth.mjs +774 -35
- package/packages/apra-fleet-se/fleet-sprint/vcs-module.mjs +134 -7
- package/packages/apra-fleet-se/fleet-sprint/vcs-providers/azure-devops.mjs +99 -0
- package/packages/apra-fleet-se/fleet-sprint/vcs-providers/bitbucket.mjs +811 -17
- package/packages/apra-fleet-se/fleet-sprint/vcs-providers/github.mjs +223 -0
- package/packages/apra-fleet-se/fleet-sprint/vcs-providers/index.mjs +138 -1
- package/packages/apra-fleet-se/fleet-sprint/vcs-providers/shell-helpers.mjs +8 -4
- package/packages/apra-fleet-se/fleet-sprint/verify-block.mjs +152 -0
- package/packages/apra-fleet-se/fleet-sprint/viewer-extensions.mjs +460 -23
- package/packages/apra-fleet-se/fleet-sprint/worklists.mjs +59 -3
- package/packages/apra-fleet-se/package.json +2 -2
- package/packages/apra-fleet-se/src/supervisor/api.mjs +1059 -0
- package/packages/apra-fleet-se/src/supervisor/backlog-member.mjs +332 -0
- package/packages/apra-fleet-se/src/supervisor/backlog.mjs +982 -0
- package/packages/apra-fleet-se/src/supervisor/beads-identity.mjs +246 -0
- package/packages/apra-fleet-se/src/supervisor/beads-view.mjs +438 -0
- package/packages/apra-fleet-se/src/supervisor/child-port.mjs +36 -0
- package/packages/apra-fleet-se/src/supervisor/dashboard.mjs +1662 -0
- package/packages/apra-fleet-se/src/supervisor/dolt-mutex.mjs +370 -0
- package/packages/apra-fleet-se/src/supervisor/dolt-orphan-sweep.mjs +338 -0
- package/packages/apra-fleet-se/src/supervisor/fleet-members.mjs +292 -0
- package/packages/apra-fleet-se/src/supervisor/history-view.mjs +276 -0
- package/packages/apra-fleet-se/src/supervisor/history.mjs +335 -0
- package/packages/apra-fleet-se/src/supervisor/id-allocator.mjs +611 -0
- package/packages/apra-fleet-se/src/supervisor/launch-form.mjs +444 -0
- package/packages/apra-fleet-se/src/supervisor/ledger.mjs +629 -0
- package/packages/apra-fleet-se/src/supervisor/lib/exec-bd.mjs +303 -0
- package/packages/apra-fleet-se/src/supervisor/log-timestamp.mjs +51 -0
- package/packages/apra-fleet-se/src/supervisor/log-view.mjs +159 -0
- package/packages/apra-fleet-se/src/supervisor/proxy.mjs +499 -0
- package/packages/apra-fleet-se/src/supervisor/readopt.mjs +136 -0
- package/packages/apra-fleet-se/src/supervisor/reconcile.mjs +263 -0
- package/packages/apra-fleet-se/src/supervisor/rename-with-retry.mjs +87 -0
- package/packages/apra-fleet-se/src/supervisor/scope-overlap.mjs +327 -0
- package/packages/apra-fleet-se/src/supervisor/self-log.mjs +133 -0
- package/packages/apra-fleet-se/src/supervisor/server.mjs +542 -0
- package/packages/apra-fleet-se/src/supervisor/spawner.mjs +544 -0
- package/packages/apra-fleet-se/src/supervisor/sprint-identity.mjs +96 -0
- package/packages/apra-fleet-se/src/supervisor/watchdog.mjs +993 -0
- package/packages/apra-fleet-workflow/package.json +3 -2
- package/packages/apra-fleet-workflow/src/viewer/index.mjs +150 -14
- package/packages/apra-fleet-workflow/src/viewer/request-guard.mjs +222 -0
- package/packages/apra-fleet-workflow/src/viewer/run-summary.mjs +127 -0
- package/packages/apra-fleet-workflow/src/workflow/index.mjs +105 -7
- package/packages/apra-fleet-workflow/src/workflow/pricing.mjs +75 -25
- 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/permissions.md +9 -0
- package/skills/fleet/profiles/tag-kb-reconciler.json +2 -6
- package/skills/fleet/skill-matrix.md +3 -3
- package/version.json +1 -1
- package/dist/cli/agent-transform.d.ts.map +0 -1
- package/dist/cli/agent-transform.js.map +0 -1
- package/dist/cli/auth.d.ts.map +0 -1
- package/dist/cli/auth.js.map +0 -1
- package/dist/cli/config.d.ts.map +0 -1
- package/dist/cli/config.js.map +0 -1
- package/dist/cli/dolt-install.d.ts.map +0 -1
- package/dist/cli/dolt-install.js.map +0 -1
- package/dist/cli/install-guard.d.ts.map +0 -1
- package/dist/cli/install-guard.js.map +0 -1
- package/dist/cli/install.d.ts.map +0 -1
- package/dist/cli/install.js.map +0 -1
- package/dist/cli/join.d.ts.map +0 -1
- package/dist/cli/join.js.map +0 -1
- package/dist/cli/kb-commit.d.ts.map +0 -1
- package/dist/cli/kb-commit.js.map +0 -1
- package/dist/cli/kb-directives.d.ts.map +0 -1
- package/dist/cli/kb-directives.js.map +0 -1
- package/dist/cli/kb-import.d.ts.map +0 -1
- package/dist/cli/kb-import.js.map +0 -1
- package/dist/cli/register-member.d.ts.map +0 -1
- package/dist/cli/register-member.js.map +0 -1
- package/dist/cli/restart.d.ts.map +0 -1
- package/dist/cli/restart.js.map +0 -1
- package/dist/cli/secret.d.ts.map +0 -1
- package/dist/cli/secret.js.map +0 -1
- package/dist/cli/spoke.d.ts.map +0 -1
- package/dist/cli/spoke.js.map +0 -1
- package/dist/cli/start.d.ts.map +0 -1
- package/dist/cli/start.js.map +0 -1
- package/dist/cli/status.d.ts.map +0 -1
- package/dist/cli/status.js.map +0 -1
- package/dist/cli/stop.d.ts.map +0 -1
- package/dist/cli/stop.js.map +0 -1
- package/dist/cli/uninstall.d.ts.map +0 -1
- package/dist/cli/uninstall.js.map +0 -1
- package/dist/cli/update.d.ts.map +0 -1
- package/dist/cli/update.js.map +0 -1
- package/dist/cli/watch.d.ts.map +0 -1
- package/dist/cli/watch.js.map +0 -1
- package/dist/cli/workflow-assets.d.ts.map +0 -1
- package/dist/cli/workflow-assets.js.map +0 -1
- package/dist/cli/workflow.d.ts.map +0 -1
- package/dist/cli/workflow.js.map +0 -1
- package/dist/commands/kb-server.d.ts.map +0 -1
- package/dist/commands/kb-server.js.map +0 -1
- package/dist/delivery-mode.d.ts.map +0 -1
- package/dist/delivery-mode.js.map +0 -1
- package/dist/hub-service/activity.d.ts.map +0 -1
- package/dist/hub-service/activity.js.map +0 -1
- package/dist/hub-service/audit-log.d.ts.map +0 -1
- package/dist/hub-service/audit-log.js.map +0 -1
- package/dist/hub-service/db/pool.d.ts.map +0 -1
- package/dist/hub-service/db/pool.js.map +0 -1
- package/dist/hub-service/enrollment.d.ts.map +0 -1
- package/dist/hub-service/enrollment.js.map +0 -1
- package/dist/hub-service/envelope-routes.d.ts.map +0 -1
- package/dist/hub-service/envelope-routes.js.map +0 -1
- package/dist/hub-service/handlers/installers.d.ts.map +0 -1
- package/dist/hub-service/handlers/installers.js.map +0 -1
- package/dist/hub-service/http-server.d.ts.map +0 -1
- package/dist/hub-service/http-server.js.map +0 -1
- package/dist/hub-service/hub-jwt.d.ts.map +0 -1
- package/dist/hub-service/hub-jwt.js.map +0 -1
- package/dist/hub-service/jwt-revocation.d.ts.map +0 -1
- package/dist/hub-service/jwt-revocation.js.map +0 -1
- package/dist/hub-service/machines.d.ts.map +0 -1
- package/dist/hub-service/machines.js.map +0 -1
- package/dist/hub-service/main.d.ts.map +0 -1
- package/dist/hub-service/main.js.map +0 -1
- package/dist/hub-service/member-tokens.d.ts.map +0 -1
- package/dist/hub-service/member-tokens.js.map +0 -1
- package/dist/hub-service/member-view.d.ts.map +0 -1
- package/dist/hub-service/member-view.js.map +0 -1
- package/dist/hub-service/members.d.ts.map +0 -1
- package/dist/hub-service/members.js.map +0 -1
- package/dist/hub-service/presence.d.ts.map +0 -1
- package/dist/hub-service/presence.js.map +0 -1
- package/dist/hub-service/project-view.d.ts.map +0 -1
- package/dist/hub-service/project-view.js.map +0 -1
- package/dist/hub-service/projects.d.ts.map +0 -1
- package/dist/hub-service/projects.js.map +0 -1
- package/dist/hub-service/relay-queue.d.ts.map +0 -1
- package/dist/hub-service/relay-queue.js.map +0 -1
- package/dist/hub-service/session-jwt.d.ts.map +0 -1
- package/dist/hub-service/session-jwt.js.map +0 -1
- package/dist/hub-service/usage.d.ts.map +0 -1
- package/dist/hub-service/usage.js.map +0 -1
- package/dist/hub-service/users.d.ts.map +0 -1
- package/dist/hub-service/users.js.map +0 -1
- package/dist/hub-service/workspaces.d.ts.map +0 -1
- package/dist/hub-service/workspaces.js.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/onboarding/text.d.ts.map +0 -1
- package/dist/onboarding/text.js.map +0 -1
- package/dist/os/git-bash-candidates.d.ts.map +0 -1
- package/dist/os/git-bash-candidates.js.map +0 -1
- package/dist/os/index.d.ts.map +0 -1
- package/dist/os/index.js.map +0 -1
- package/dist/os/linux.d.ts.map +0 -1
- package/dist/os/linux.js.map +0 -1
- package/dist/os/macos.d.ts.map +0 -1
- package/dist/os/macos.js.map +0 -1
- package/dist/os/os-commands.d.ts.map +0 -1
- package/dist/os/os-commands.js.map +0 -1
- package/dist/os/windows-gitbash.d.ts.map +0 -1
- package/dist/os/windows-gitbash.js.map +0 -1
- package/dist/os/windows-wrapper.d.ts.map +0 -1
- package/dist/os/windows-wrapper.js.map +0 -1
- package/dist/os/windows.d.ts.map +0 -1
- package/dist/os/windows.js.map +0 -1
- package/dist/paths.d.ts.map +0 -1
- package/dist/paths.js.map +0 -1
- package/dist/providers/agy.d.ts.map +0 -1
- package/dist/providers/agy.js.map +0 -1
- package/dist/providers/claude.d.ts.map +0 -1
- package/dist/providers/claude.js.map +0 -1
- package/dist/providers/codex.d.ts.map +0 -1
- package/dist/providers/codex.js.map +0 -1
- package/dist/providers/copilot.d.ts.map +0 -1
- package/dist/providers/copilot.js.map +0 -1
- package/dist/providers/email/headers.d.ts.map +0 -1
- package/dist/providers/email/headers.js.map +0 -1
- package/dist/providers/email/index.d.ts.map +0 -1
- package/dist/providers/email/index.js.map +0 -1
- package/dist/providers/email/provider.d.ts.map +0 -1
- package/dist/providers/email/provider.js.map +0 -1
- package/dist/providers/email/sendgrid.d.ts.map +0 -1
- package/dist/providers/email/sendgrid.js.map +0 -1
- package/dist/providers/email/smtp.d.ts.map +0 -1
- package/dist/providers/email/smtp.js.map +0 -1
- package/dist/providers/index.d.ts.map +0 -1
- package/dist/providers/index.js.map +0 -1
- package/dist/providers/none.d.ts.map +0 -1
- package/dist/providers/none.js.map +0 -1
- package/dist/providers/opencode.d.ts.map +0 -1
- package/dist/providers/opencode.js.map +0 -1
- package/dist/providers/provider.d.ts.map +0 -1
- package/dist/providers/provider.js.map +0 -1
- package/dist/services/agent-provisioner.d.ts.map +0 -1
- package/dist/services/agent-provisioner.js.map +0 -1
- package/dist/services/agy-project.d.ts.map +0 -1
- package/dist/services/agy-project.js.map +0 -1
- package/dist/services/auth-socket.d.ts.map +0 -1
- package/dist/services/auth-socket.js.map +0 -1
- package/dist/services/auth-web.d.ts.map +0 -1
- package/dist/services/auth-web.js.map +0 -1
- package/dist/services/budget-awareness.d.ts.map +0 -1
- package/dist/services/budget-awareness.js.map +0 -1
- package/dist/services/cloud/activity.d.ts.map +0 -1
- package/dist/services/cloud/activity.js.map +0 -1
- package/dist/services/cloud/aws.d.ts.map +0 -1
- package/dist/services/cloud/aws.js.map +0 -1
- package/dist/services/cloud/cost.d.ts.map +0 -1
- package/dist/services/cloud/cost.js.map +0 -1
- package/dist/services/cloud/idle-manager.d.ts.map +0 -1
- package/dist/services/cloud/idle-manager.js.map +0 -1
- package/dist/services/cloud/lifecycle.d.ts.map +0 -1
- package/dist/services/cloud/lifecycle.js.map +0 -1
- package/dist/services/cloud/task-wrapper.d.ts.map +0 -1
- package/dist/services/cloud/task-wrapper.js.map +0 -1
- package/dist/services/cloud/types.d.ts.map +0 -1
- package/dist/services/cloud/types.js.map +0 -1
- package/dist/services/cloud-sync.d.ts.map +0 -1
- package/dist/services/cloud-sync.js.map +0 -1
- package/dist/services/context-admission.d.ts.map +0 -1
- package/dist/services/context-admission.js.map +0 -1
- package/dist/services/credential-cleanup.d.ts.map +0 -1
- package/dist/services/credential-cleanup.js.map +0 -1
- package/dist/services/credential-store.d.ts.map +0 -1
- package/dist/services/credential-store.js.map +0 -1
- package/dist/services/event-bus.d.ts.map +0 -1
- package/dist/services/event-bus.js.map +0 -1
- package/dist/services/exit-drain.d.ts.map +0 -1
- package/dist/services/exit-drain.js.map +0 -1
- package/dist/services/file-chunker.d.ts.map +0 -1
- package/dist/services/file-chunker.js.map +0 -1
- package/dist/services/file-transfer-relay.d.ts.map +0 -1
- package/dist/services/file-transfer-relay.js.map +0 -1
- package/dist/services/file-transfer.d.ts.map +0 -1
- package/dist/services/file-transfer.js.map +0 -1
- package/dist/services/git-config.d.ts.map +0 -1
- package/dist/services/git-config.js.map +0 -1
- package/dist/services/github-app.d.ts.map +0 -1
- package/dist/services/github-app.js.map +0 -1
- package/dist/services/http-transport.d.ts.map +0 -1
- package/dist/services/http-transport.js.map +0 -1
- package/dist/services/hub-client.d.ts.map +0 -1
- package/dist/services/hub-client.js.map +0 -1
- package/dist/services/icons.d.ts.map +0 -1
- package/dist/services/icons.js.map +0 -1
- package/dist/services/jwt.d.ts.map +0 -1
- package/dist/services/jwt.js.map +0 -1
- package/dist/services/knowledge/audn.d.ts.map +0 -1
- package/dist/services/knowledge/audn.js.map +0 -1
- package/dist/services/knowledge/file-hash.d.ts.map +0 -1
- package/dist/services/knowledge/file-hash.js.map +0 -1
- package/dist/services/knowledge/http-provider.d.ts.map +0 -1
- package/dist/services/knowledge/http-provider.js.map +0 -1
- package/dist/services/knowledge/kb-config.d.ts.map +0 -1
- package/dist/services/knowledge/kb-config.js.map +0 -1
- package/dist/services/knowledge/kb-providers.d.ts.map +0 -1
- package/dist/services/knowledge/kb-providers.js.map +0 -1
- package/dist/services/knowledge/kb-scope-input.d.ts +0 -5
- package/dist/services/knowledge/kb-scope-input.d.ts.map +0 -1
- package/dist/services/knowledge/kb-scope-input.js +0 -11
- package/dist/services/knowledge/kb-scope-input.js.map +0 -1
- package/dist/services/knowledge/kb-service.d.ts.map +0 -1
- package/dist/services/knowledge/kb-service.js.map +0 -1
- package/dist/services/knowledge/path-validation.d.ts.map +0 -1
- package/dist/services/knowledge/path-validation.js.map +0 -1
- package/dist/services/knowledge/pre-init.d.ts.map +0 -1
- package/dist/services/knowledge/pre-init.js.map +0 -1
- package/dist/services/knowledge/project-slug.d.ts.map +0 -1
- package/dist/services/knowledge/project-slug.js.map +0 -1
- package/dist/services/knowledge/require-sqlite-project.d.ts.map +0 -1
- package/dist/services/knowledge/require-sqlite-project.js.map +0 -1
- package/dist/services/knowledge/sqlite-provider.d.ts.map +0 -1
- package/dist/services/knowledge/sqlite-provider.js.map +0 -1
- package/dist/services/knowledge/types.d.ts.map +0 -1
- package/dist/services/knowledge/types.js.map +0 -1
- package/dist/services/known-hosts.d.ts.map +0 -1
- package/dist/services/known-hosts.js.map +0 -1
- package/dist/services/known-sessions.d.ts.map +0 -1
- package/dist/services/known-sessions.js.map +0 -1
- package/dist/services/member-home.d.ts.map +0 -1
- package/dist/services/member-home.js.map +0 -1
- package/dist/services/member-remote-url.d.ts.map +0 -1
- package/dist/services/member-remote-url.js.map +0 -1
- package/dist/services/model-pricing.d.ts.map +0 -1
- package/dist/services/model-pricing.js.map +0 -1
- package/dist/services/onboarding.d.ts.map +0 -1
- package/dist/services/onboarding.js.map +0 -1
- package/dist/services/orphan-recovery.d.ts.map +0 -1
- package/dist/services/orphan-recovery.js.map +0 -1
- package/dist/services/pending-responses.d.ts.map +0 -1
- package/dist/services/pending-responses.js.map +0 -1
- package/dist/services/preflight-check.d.ts.map +0 -1
- package/dist/services/preflight-check.js.map +0 -1
- package/dist/services/registry.d.ts.map +0 -1
- package/dist/services/registry.js.map +0 -1
- package/dist/services/relay-context.d.ts.map +0 -1
- package/dist/services/relay-context.js.map +0 -1
- package/dist/services/relay-executor.d.ts.map +0 -1
- package/dist/services/relay-executor.js.map +0 -1
- package/dist/services/relay-request.d.ts.map +0 -1
- package/dist/services/relay-request.js.map +0 -1
- package/dist/services/relay-strategy.d.ts.map +0 -1
- package/dist/services/relay-strategy.js.map +0 -1
- package/dist/services/secret-token.d.ts.map +0 -1
- package/dist/services/secret-token.js.map +0 -1
- package/dist/services/service-manager/index.d.ts.map +0 -1
- package/dist/services/service-manager/index.js.map +0 -1
- package/dist/services/service-manager/linux.d.ts.map +0 -1
- package/dist/services/service-manager/linux.js.map +0 -1
- package/dist/services/service-manager/macos.d.ts.map +0 -1
- package/dist/services/service-manager/macos.js.map +0 -1
- package/dist/services/service-manager/types.d.ts.map +0 -1
- package/dist/services/service-manager/types.js.map +0 -1
- package/dist/services/service-manager/windows.d.ts.map +0 -1
- package/dist/services/service-manager/windows.js.map +0 -1
- package/dist/services/session-registry.d.ts.map +0 -1
- package/dist/services/session-registry.js.map +0 -1
- package/dist/services/sftp.d.ts.map +0 -1
- package/dist/services/sftp.js.map +0 -1
- package/dist/services/shell-probe.d.ts.map +0 -1
- package/dist/services/shell-probe.js.map +0 -1
- package/dist/services/singleton.d.ts.map +0 -1
- package/dist/services/singleton.js.map +0 -1
- package/dist/services/sprint-coordination.d.ts.map +0 -1
- package/dist/services/sprint-coordination.js.map +0 -1
- package/dist/services/ssh.d.ts.map +0 -1
- package/dist/services/ssh.js.map +0 -1
- package/dist/services/stall/find-log-file.d.ts.map +0 -1
- package/dist/services/stall/find-log-file.js.map +0 -1
- package/dist/services/stall/index.d.ts.map +0 -1
- package/dist/services/stall/index.js.map +0 -1
- package/dist/services/stall/log-path-resolver.d.ts.map +0 -1
- package/dist/services/stall/log-path-resolver.js.map +0 -1
- package/dist/services/stall/read-log-tail.d.ts.map +0 -1
- package/dist/services/stall/read-log-tail.js.map +0 -1
- package/dist/services/stall/stall-detector.d.ts.map +0 -1
- package/dist/services/stall/stall-detector.js.map +0 -1
- package/dist/services/stall/stall-poller.d.ts.map +0 -1
- package/dist/services/stall/stall-poller.js.map +0 -1
- package/dist/services/stall/time-utils.d.ts.map +0 -1
- package/dist/services/stall/time-utils.js.map +0 -1
- package/dist/services/statusline.d.ts.map +0 -1
- package/dist/services/statusline.js.map +0 -1
- package/dist/services/strategy.d.ts.map +0 -1
- package/dist/services/strategy.js.map +0 -1
- package/dist/services/substitution-engine.d.ts.map +0 -1
- package/dist/services/substitution-engine.js.map +0 -1
- package/dist/services/task-cleanup.d.ts.map +0 -1
- package/dist/services/task-cleanup.js.map +0 -1
- package/dist/services/token-issuer.d.ts.map +0 -1
- package/dist/services/token-issuer.js.map +0 -1
- package/dist/services/tool-registry.d.ts.map +0 -1
- package/dist/services/tool-registry.js.map +0 -1
- package/dist/services/update-check.d.ts.map +0 -1
- package/dist/services/update-check.js.map +0 -1
- package/dist/services/user-config.d.ts.map +0 -1
- package/dist/services/user-config.js.map +0 -1
- package/dist/services/vcs/azure-devops.d.ts.map +0 -1
- package/dist/services/vcs/azure-devops.js.map +0 -1
- package/dist/services/vcs/bitbucket.d.ts.map +0 -1
- package/dist/services/vcs/bitbucket.js.map +0 -1
- package/dist/services/vcs/constants.d.ts.map +0 -1
- package/dist/services/vcs/constants.js.map +0 -1
- package/dist/services/vcs/github.d.ts.map +0 -1
- package/dist/services/vcs/github.js.map +0 -1
- package/dist/services/vcs/types.d.ts.map +0 -1
- package/dist/services/vcs/types.js.map +0 -1
- package/dist/services/version-check.d.ts.map +0 -1
- package/dist/services/version-check.js.map +0 -1
- package/dist/services/watch/fleet-log.d.ts.map +0 -1
- package/dist/services/watch/fleet-log.js.map +0 -1
- package/dist/services/watch/project-resolver.d.ts.map +0 -1
- package/dist/services/watch/project-resolver.js.map +0 -1
- package/dist/services/watch/transcript-formatter.d.ts.map +0 -1
- package/dist/services/watch/transcript-formatter.js.map +0 -1
- package/dist/smoke-test.d.ts.map +0 -1
- package/dist/smoke-test.js.map +0 -1
- package/dist/tools/check-status.d.ts.map +0 -1
- package/dist/tools/check-status.js.map +0 -1
- package/dist/tools/child-id-allocator.d.ts.map +0 -1
- package/dist/tools/child-id-allocator.js.map +0 -1
- package/dist/tools/cloud-control.d.ts.map +0 -1
- package/dist/tools/cloud-control.js.map +0 -1
- package/dist/tools/code-intelligence-codebase-memory.d.ts.map +0 -1
- package/dist/tools/code-intelligence-codebase-memory.js.map +0 -1
- package/dist/tools/code-intelligence-freshness.d.ts.map +0 -1
- package/dist/tools/code-intelligence-freshness.js.map +0 -1
- package/dist/tools/code-intelligence-gitnexus.d.ts.map +0 -1
- package/dist/tools/code-intelligence-gitnexus.js.map +0 -1
- package/dist/tools/code-intelligence-kb-enrich.d.ts.map +0 -1
- package/dist/tools/code-intelligence-kb-enrich.js.map +0 -1
- package/dist/tools/code-intelligence-reindex.d.ts.map +0 -1
- package/dist/tools/code-intelligence-reindex.js.map +0 -1
- package/dist/tools/code-intelligence-telemetry.d.ts.map +0 -1
- package/dist/tools/code-intelligence-telemetry.js.map +0 -1
- package/dist/tools/code-intelligence-tests.d.ts.map +0 -1
- package/dist/tools/code-intelligence-tests.js.map +0 -1
- package/dist/tools/code-intelligence.d.ts.map +0 -1
- package/dist/tools/code-intelligence.js.map +0 -1
- package/dist/tools/compose-permissions.d.ts.map +0 -1
- package/dist/tools/compose-permissions.js.map +0 -1
- package/dist/tools/credential-store-delete.d.ts.map +0 -1
- package/dist/tools/credential-store-delete.js.map +0 -1
- package/dist/tools/credential-store-list.d.ts.map +0 -1
- package/dist/tools/credential-store-list.js.map +0 -1
- package/dist/tools/credential-store-set.d.ts.map +0 -1
- package/dist/tools/credential-store-set.js.map +0 -1
- package/dist/tools/credential-store-update.d.ts.map +0 -1
- package/dist/tools/credential-store-update.js.map +0 -1
- package/dist/tools/dolt-push-mutex.d.ts.map +0 -1
- package/dist/tools/dolt-push-mutex.js.map +0 -1
- package/dist/tools/execute-command.d.ts.map +0 -1
- package/dist/tools/execute-command.js.map +0 -1
- package/dist/tools/execute-prompt.d.ts.map +0 -1
- package/dist/tools/execute-prompt.js.map +0 -1
- package/dist/tools/get-member-model-pricing.d.ts.map +0 -1
- package/dist/tools/get-member-model-pricing.js.map +0 -1
- package/dist/tools/kb-capture.d.ts.map +0 -1
- package/dist/tools/kb-capture.js.map +0 -1
- package/dist/tools/kb-context.d.ts.map +0 -1
- package/dist/tools/kb-context.js.map +0 -1
- package/dist/tools/kb-export.d.ts.map +0 -1
- package/dist/tools/kb-export.js.map +0 -1
- package/dist/tools/kb-feedback.d.ts.map +0 -1
- package/dist/tools/kb-feedback.js.map +0 -1
- package/dist/tools/kb-freshness-sweep.d.ts.map +0 -1
- package/dist/tools/kb-freshness-sweep.js.map +0 -1
- package/dist/tools/kb-harvest.d.ts.map +0 -1
- package/dist/tools/kb-harvest.js.map +0 -1
- package/dist/tools/kb-import.d.ts.map +0 -1
- package/dist/tools/kb-import.js.map +0 -1
- package/dist/tools/kb-invalidate.d.ts.map +0 -1
- package/dist/tools/kb-invalidate.js.map +0 -1
- package/dist/tools/kb-list.d.ts.map +0 -1
- package/dist/tools/kb-list.js.map +0 -1
- package/dist/tools/kb-promote.d.ts.map +0 -1
- package/dist/tools/kb-promote.js.map +0 -1
- package/dist/tools/kb-query.d.ts.map +0 -1
- package/dist/tools/kb-query.js.map +0 -1
- package/dist/tools/kb-reconcile-prefilter.d.ts.map +0 -1
- package/dist/tools/kb-reconcile-prefilter.js.map +0 -1
- package/dist/tools/kb-resolve-contradiction.d.ts.map +0 -1
- package/dist/tools/kb-resolve-contradiction.js.map +0 -1
- package/dist/tools/kb-session-prime.d.ts.map +0 -1
- package/dist/tools/kb-session-prime.js.map +0 -1
- package/dist/tools/kb-setup.d.ts.map +0 -1
- package/dist/tools/kb-setup.js.map +0 -1
- package/dist/tools/kb-stats.d.ts.map +0 -1
- package/dist/tools/kb-stats.js.map +0 -1
- package/dist/tools/list-members.d.ts.map +0 -1
- package/dist/tools/list-members.js.map +0 -1
- package/dist/tools/member-detail.d.ts.map +0 -1
- package/dist/tools/member-detail.js.map +0 -1
- package/dist/tools/member-reservation.d.ts.map +0 -1
- package/dist/tools/member-reservation.js.map +0 -1
- package/dist/tools/monitor-task.d.ts.map +0 -1
- package/dist/tools/monitor-task.js.map +0 -1
- package/dist/tools/provision-auth.d.ts.map +0 -1
- package/dist/tools/provision-auth.js.map +0 -1
- package/dist/tools/provision-vcs-auth.d.ts.map +0 -1
- package/dist/tools/provision-vcs-auth.js.map +0 -1
- package/dist/tools/receive-files.d.ts.map +0 -1
- package/dist/tools/receive-files.js.map +0 -1
- package/dist/tools/register-member.d.ts.map +0 -1
- package/dist/tools/register-member.js.map +0 -1
- package/dist/tools/remove-member.d.ts.map +0 -1
- package/dist/tools/remove-member.js.map +0 -1
- package/dist/tools/report-status.d.ts.map +0 -1
- package/dist/tools/report-status.js.map +0 -1
- package/dist/tools/respond-to-message.d.ts.map +0 -1
- package/dist/tools/respond-to-message.js.map +0 -1
- package/dist/tools/revoke-vcs-auth.d.ts.map +0 -1
- package/dist/tools/revoke-vcs-auth.js.map +0 -1
- package/dist/tools/send-email.d.ts.map +0 -1
- package/dist/tools/send-email.js.map +0 -1
- package/dist/tools/send-files.d.ts.map +0 -1
- package/dist/tools/send-files.js.map +0 -1
- package/dist/tools/send-message.d.ts.map +0 -1
- package/dist/tools/send-message.js.map +0 -1
- package/dist/tools/setup-git-app.d.ts.map +0 -1
- package/dist/tools/setup-git-app.js.map +0 -1
- package/dist/tools/setup-ssh-key.d.ts.map +0 -1
- package/dist/tools/setup-ssh-key.js.map +0 -1
- package/dist/tools/shutdown-server.d.ts.map +0 -1
- package/dist/tools/shutdown-server.js.map +0 -1
- package/dist/tools/stop-prompt.d.ts.map +0 -1
- package/dist/tools/stop-prompt.js.map +0 -1
- package/dist/tools/update-agent-cli.d.ts.map +0 -1
- package/dist/tools/update-agent-cli.js.map +0 -1
- package/dist/tools/update-member.d.ts.map +0 -1
- package/dist/tools/update-member.js.map +0 -1
- package/dist/tools/vcs-credential-exec.d.ts.map +0 -1
- package/dist/tools/vcs-credential-exec.js.map +0 -1
- package/dist/tools/version.d.ts.map +0 -1
- package/dist/tools/version.js.map +0 -1
- package/dist/types.d.ts.map +0 -1
- package/dist/types.js.map +0 -1
- package/dist/utils/agent-helpers.d.ts.map +0 -1
- package/dist/utils/agent-helpers.js.map +0 -1
- package/dist/utils/ansi.d.ts.map +0 -1
- package/dist/utils/ansi.js.map +0 -1
- package/dist/utils/auth-env.d.ts.map +0 -1
- package/dist/utils/auth-env.js.map +0 -1
- package/dist/utils/collect-secret.d.ts.map +0 -1
- package/dist/utils/collect-secret.js.map +0 -1
- package/dist/utils/credential-validation.d.ts.map +0 -1
- package/dist/utils/credential-validation.js.map +0 -1
- package/dist/utils/crypto.d.ts.map +0 -1
- package/dist/utils/crypto.js.map +0 -1
- package/dist/utils/deep-merge.d.ts.map +0 -1
- package/dist/utils/deep-merge.js.map +0 -1
- package/dist/utils/file-permissions.d.ts.map +0 -1
- package/dist/utils/file-permissions.js.map +0 -1
- package/dist/utils/gpu-parser.d.ts.map +0 -1
- package/dist/utils/gpu-parser.js.map +0 -1
- package/dist/utils/log-helpers.d.ts.map +0 -1
- package/dist/utils/log-helpers.js.map +0 -1
- package/dist/utils/oob-timeout.d.ts.map +0 -1
- package/dist/utils/oob-timeout.js.map +0 -1
- package/dist/utils/opencode-model-validation.d.ts.map +0 -1
- package/dist/utils/opencode-model-validation.js.map +0 -1
- package/dist/utils/pid-helpers.d.ts.map +0 -1
- package/dist/utils/pid-helpers.js.map +0 -1
- package/dist/utils/platform.d.ts.map +0 -1
- package/dist/utils/platform.js.map +0 -1
- package/dist/utils/process-utils.d.ts.map +0 -1
- package/dist/utils/process-utils.js.map +0 -1
- package/dist/utils/prompt-errors.d.ts.map +0 -1
- package/dist/utils/prompt-errors.js.map +0 -1
- package/dist/utils/resolve-member.d.ts.map +0 -1
- package/dist/utils/resolve-member.js.map +0 -1
- package/dist/utils/secure-input.d.ts.map +0 -1
- package/dist/utils/secure-input.js.map +0 -1
- package/dist/utils/session-caller.d.ts.map +0 -1
- package/dist/utils/session-caller.js.map +0 -1
- package/dist/utils/shell-escape.d.ts.map +0 -1
- package/dist/utils/shell-escape.js.map +0 -1
- package/dist/utils/skill-matrix.d.ts.map +0 -1
- package/dist/utils/skill-matrix.js.map +0 -1
- package/dist/utils/ssh-error-messages.d.ts.map +0 -1
- package/dist/utils/ssh-error-messages.js.map +0 -1
- package/dist/utils/vcs-provider-detect.d.ts.map +0 -1
- package/dist/utils/vcs-provider-detect.js.map +0 -1
- package/dist/utils/work-folder-validation.d.ts.map +0 -1
- package/dist/utils/work-folder-validation.js.map +0 -1
- package/dist/utils/workspace-trust.d.ts.map +0 -1
- package/dist/utils/workspace-trust.js.map +0 -1
- package/dist/version.d.ts.map +0 -1
- package/dist/version.js.map +0 -1
|
@@ -5,12 +5,12 @@ import {
|
|
|
5
5
|
ROLES, planReviewerVerdict, doerReport, reviewerVerdict, streakAssignment,
|
|
6
6
|
deployerReport, integReport, regressionReport, finalVerdict, harvesterReport, wrapUntrustedBlock,
|
|
7
7
|
} from './contracts.mjs';
|
|
8
|
-
import { SprintPlanRejectedError, StalledSprintError, ReviewerContractViolationError, DoltSyncError, PlanReviewDispatchFailedError, PreSprintValidationError, PRE_SPRINT_REFUSAL_REASONS, isNonRetryableDispatchError, isAuthDispatchError, isInfraDispatchFailure, isPostDispatchSyncFailure } from './errors.mjs';
|
|
8
|
+
import { SprintPlanRejectedError, StalledSprintError, ReviewerContractViolationError, DoltSyncError, GitSyncError,PlanReviewDispatchFailedError, PreSprintValidationError, PRE_SPRINT_REFUSAL_REASONS, isNonRetryableDispatchError, isAuthDispatchError, isInfraDispatchFailure, isPostDispatchSyncFailure } from './errors.mjs';
|
|
9
9
|
// The ONLY dolt command surface in fleet-sprint (apra-fleet-417.2.1). Every
|
|
10
10
|
// runner.js call site uses the purpose-based entry points on DoltSync
|
|
11
11
|
// (apra-fleet-417.2.2); the named primitives are imported here only to be
|
|
12
12
|
// re-exported below for the existing unit suites that drive them directly.
|
|
13
|
-
import { DoltSync, doltPullBefore, doltPushAfter, preflightBeadsHealthGate } from './dolt-sync.mjs';
|
|
13
|
+
import { DoltSync, doltPullBefore, doltPushAfter, preflightBeadsHealthGate, setMemberTargetResolver } from './dolt-sync.mjs';
|
|
14
14
|
|
|
15
15
|
import { parseUnmergedPaths } from './conflict-ladder.mjs';
|
|
16
16
|
// The deterministic dolt conflict settlement callback (docs/dolt-sync-
|
|
@@ -52,10 +52,15 @@ import { buildCreatePrCommand, resolveProvider, parseProviderRepoRef, getVcsProv
|
|
|
52
52
|
// brackets that were its only caller here.
|
|
53
53
|
import {
|
|
54
54
|
checkMemberTopology, classifyGitFailure, runGitStep, commandResultToSoftGit,
|
|
55
|
+
resolveReviewMergeBase,
|
|
55
56
|
} from './git-topology.mjs';
|
|
56
57
|
import { getSeCommands } from './se-os-commands.mjs';
|
|
57
58
|
import { resultText, toolErrorText } from './mcp-result.mjs';
|
|
58
59
|
import { resolveMemberTarget, resolveMemberOs, clearMemberOsCache } from './member-target.mjs';
|
|
60
|
+
import { createMemberCall, buildRemoteCallCommand, MemberCallError, MEMBER_CALL_ARGS_DIR } from './member-call.mjs';
|
|
61
|
+
import { createDispatchAccounting } from './dispatch-accounting.mjs';
|
|
62
|
+
import { lowerQuality, logLowerQualityWarn } from './lower-quality.mjs';
|
|
63
|
+
import { createMemberInitProbe, createMemberVerifiedLookup, MEMBER_INIT_LOG_PREFIX, MEMBER_INIT_STATE_NAMESPACE } from './member-init-probe.mjs';
|
|
59
64
|
import { createSprintState, sprintScopedFleetApi, resolveSettleShellWith } from './sprint-state.mjs';
|
|
60
65
|
// apra-fleet-3swo.6.10: the per-member git/dolt sync brackets, moved verbatim
|
|
61
66
|
// out of this file into ./member-sync.mjs (see that module's header for the
|
|
@@ -81,6 +86,8 @@ import {
|
|
|
81
86
|
import {
|
|
82
87
|
createMemberSessionGuard, createUnattendedAutoProvisioner,
|
|
83
88
|
createDeployPermissionsProvisioner, stageCommandBodyMemberSide,
|
|
89
|
+
createPermissionConfigPreflight,
|
|
90
|
+
createPermissionDenialHeal, permissionLedgerFolder,
|
|
84
91
|
} from './member-provisioning.mjs';
|
|
85
92
|
import {
|
|
86
93
|
parseOwnerRepoFromRemoteUrl, parseRepoScopeFromRemoteUrl, vcsCredentialLabelForProvider,
|
|
@@ -93,8 +100,11 @@ import {
|
|
|
93
100
|
createWorkflowsPermissionPreflightCallback,
|
|
94
101
|
createLlmAuthSelfHealCallback,
|
|
95
102
|
} from './vcs-auth.mjs';
|
|
96
|
-
import { validateIssueId, validateBranchName, validateArgs } from './sprint-args.mjs';
|
|
97
|
-
import { verifyBeadsIdentity } from './beads-identity-check.mjs';
|
|
103
|
+
import { validateIssueId, validateBranchName, validateBranchPair, validateArgs } from './sprint-args.mjs';
|
|
104
|
+
import { verifyBeadsIdentity, createBeadsIdentityProber, BEADS_READING_ROLES } from './beads-identity-check.mjs';
|
|
105
|
+
import { ROLE_BACKLOG, selectBacklogMember, formatBacklogSelection } from './backlog-role.mjs';
|
|
106
|
+
import { createKbMaintainerSelector, createMemberDetailResolver, ROLE_KB_MAINTAINER } from './kb-maintainer.mjs';
|
|
107
|
+
import { sweepTokenMemories } from './beads-memory-hygiene.mjs';
|
|
98
108
|
import {
|
|
99
109
|
buildPlannerPrompt, buildPlanReviewerPrompt, buildStreakAssignmentPrompt, buildDoerPrompt,
|
|
100
110
|
buildReviewerPrompt, buildFinalVerdictPrompt, buildHarvesterPrompt,
|
|
@@ -103,6 +113,7 @@ import {
|
|
|
103
113
|
selectStreaks, groupStreaksFromLaneMetadata, SIZE_POINTS, MODEL_WEIGHT, DEFAULT_EFFORT_THRESHOLD,
|
|
104
114
|
computeLaneEffort, streakRequiredTier, streakMinPriority, streakEffortPoints, beadBlocksDependencyIds,
|
|
105
115
|
resolveWorklistTierPolicy, hasContextHeadroomForResume, assignDoerWorklists,
|
|
116
|
+
holdBackByLaneOrder,
|
|
106
117
|
} from './worklists.mjs';
|
|
107
118
|
import {
|
|
108
119
|
isTypedAbortError, finalizeAbort, persistNewTaskBestEffort, validateNewTask,
|
|
@@ -125,10 +136,12 @@ import { dispatchRole, TURN_BASES } from './dispatch-role.mjs';
|
|
|
125
136
|
// log line, the bound the row itself sets -- never to re-implement a ladder.
|
|
126
137
|
// USAGE_LIMIT_BUDGET_DEFAULTS is the usage-limit controller's budget row,
|
|
127
138
|
// recorded as data in the same table (apra-fleet-hzeb.4.1/.4.2).
|
|
128
|
-
import { policyFor, USAGE_LIMIT_BUDGET_DEFAULTS } from './role-policies.mjs';
|
|
139
|
+
import { policyFor, USAGE_LIMIT_BUDGET_DEFAULTS, agentTypeAppliesKbCaptures } from './role-policies.mjs';
|
|
129
140
|
// apra-fleet-hzeb.4.2: the usage-limit pause/resume/re-probe controller wired
|
|
130
141
|
// into the dispatchRole engine as ctx.onUsageLimit below.
|
|
131
142
|
import { createUsageLimitPauseController } from './usage-limit-controller.mjs';
|
|
143
|
+
import { createDecisionWait } from './decision-wait.mjs';
|
|
144
|
+
import { notifyDecision, prepareDecisionNotify } from './decision-notify.mjs';
|
|
132
145
|
// apra-fleet-3swo.6.2: the first two of runSprintCycle's twelve phase()
|
|
133
146
|
// boundaries, sliced into their own modules under ./phases/. Each takes ONE
|
|
134
147
|
// explicit state argument instead of closing over runSprintCycle's locals; the
|
|
@@ -153,7 +166,8 @@ import { runDevelopPhase } from './phases/develop.mjs';
|
|
|
153
166
|
// around Deploy, and the dashboard/still-open loop control after Review,
|
|
154
167
|
// stayed here.
|
|
155
168
|
import { runReviewPhase } from './phases/review.mjs';
|
|
156
|
-
import { runDeployPhase } from './phases/deploy.mjs';
|
|
169
|
+
import { runDeployPhase, latestDeployFailure, formatDeployFailureReason, formatDeploySetAsideNotes, DEPLOY_RETRY_CYCLE_LIMIT } from './phases/deploy.mjs';
|
|
170
|
+
import { collectSetAsideEntries, evaluateSetAsideStall, formatSetAsideStallMessage, stuckBehindSetAside, collectWaitEntries } from './set-aside.mjs';
|
|
157
171
|
// apra-fleet-3swo.6.8: the next two phase() boundaries -- the per-cycle Integ
|
|
158
172
|
// Test and the Re-Review that Cycle Evaluation dispatches when the goal-
|
|
159
173
|
// priority count already reads 0 but no review ran this cycle. Integ Test is
|
|
@@ -188,7 +202,7 @@ import { runRegressionTestPhase } from './phases/regression-test.mjs';
|
|
|
188
202
|
// return value is its own contract, and group('Finalization')/endGroup() wrap
|
|
189
203
|
// all four Finalization phases rather than either of these two). Their ORDER
|
|
190
204
|
// is load-bearing: the harvester is a code-writing role whose
|
|
191
|
-
// docs/
|
|
205
|
+
// docs/README commits must be G-pushed by its own policy
|
|
192
206
|
// bracket before Publish PR pushes the branch and raises the PR a human reads.
|
|
193
207
|
// See each module's header for where its boundary is drawn.
|
|
194
208
|
import { runHarvestPhase } from './phases/harvest.mjs';
|
|
@@ -201,8 +215,7 @@ import {
|
|
|
201
215
|
createMcpDoltPushMutexClient, createMcpChildIdAllocatorClient,
|
|
202
216
|
createMemberReservationClient,
|
|
203
217
|
} from './coordination.mjs';
|
|
204
|
-
// The KB work concern: the
|
|
205
|
-
// kb_query read, kb_captures/kb_promotions vetting and forwarding, and the
|
|
218
|
+
// The KB work concern: the per-dispatch kb_query read, kb_captures/kb_promotions vetting and forwarding, and the
|
|
206
219
|
// canonical-bible publish. Moved verbatim out of runner.js
|
|
207
220
|
// (apra-fleet-3swo.4.4). KB_MAX_KNOWLEDGE_ENTRIES is imported back here so it
|
|
208
221
|
// can be re-exported below for existing importers of runner.js.
|
|
@@ -215,13 +228,15 @@ import {
|
|
|
215
228
|
// check, the per-dispatch kb_query FTS terms, and the two "KNOWLEDGE BANK"
|
|
216
229
|
// prompt blocks). Moved verbatim out of runner.js into the existing
|
|
217
230
|
// kb.mjs (apra-fleet-3swo.6.11) -- kb.mjs already owned the rest of the KB
|
|
218
|
-
// surface (createKbWorkClient,
|
|
231
|
+
// surface (createKbWorkClient, vetKbWork, the KB_* limit
|
|
219
232
|
// constants), so these five join that single home rather than starting a
|
|
220
233
|
// second one.
|
|
221
234
|
import {
|
|
222
235
|
createKbPrimingClient, KB_SELF_INJECTING_ROLES, kbQueryTerms,
|
|
223
|
-
kbKnowledgeBlock, kbPromotionBlock,
|
|
236
|
+
kbKnowledgeBlock, kbPromotionBlock, kbDemotionBlock,
|
|
224
237
|
} from './kb.mjs';
|
|
238
|
+
import { createKbInjection } from './kb-injection.mjs';
|
|
239
|
+
import { pathsFromText, isPriorityTierToken } from './kb-hints.mjs';
|
|
225
240
|
// Beads scope discovery + the shared full-DB snapshot: the single in-memory
|
|
226
241
|
// BFS scope rule (now shared by bdListScoped and classifyVerifySet instead of
|
|
227
242
|
// duplicated), the `bd list --all --limit 0 --json` snapshot, and the
|
|
@@ -234,6 +249,11 @@ import {
|
|
|
234
249
|
// moved here from runner.js; imported back and re-exported (facade region
|
|
235
250
|
// below) so no importer of runner.js is edited by the move.
|
|
236
251
|
parseBdJson, goalPriorityMax, partitionByGoalMembership,
|
|
252
|
+
// Develop-dispatch goal filter: below-goal ready leaves are excluded
|
|
253
|
+
// unless they block in-goal work or the sprint already worked on them.
|
|
254
|
+
partitionReadyByGoal, formatBelowGoalExclusionLog,
|
|
255
|
+
// Set-aside v2: a waiting bead is held until its prerequisites close.
|
|
256
|
+
unmetPrerequisites,
|
|
237
257
|
// apra-fleet-rp7a.1: the deferred split the Cycle Evaluation completion
|
|
238
258
|
// math and phases/final-review.mjs's closing count BOTH apply, so the two
|
|
239
259
|
// cannot drift apart. See its own doc comment for why 'deferred' -- and
|
|
@@ -297,6 +317,20 @@ import {
|
|
|
297
317
|
// (apra-fleet-3swo.6.15); imported only to be re-exported below, unchanged, so
|
|
298
318
|
// no importer of runner.js is edited by the move.
|
|
299
319
|
import { DEFAULT_CONTEXT_CEILING, createRoundSessionRegistry } from './round-session.mjs';
|
|
320
|
+
// GitHub #715: run-scoped bookkeeping of beads THIS sprint's doers were
|
|
321
|
+
// dispatched on, so a claim a failed doer of this run left in_progress is
|
|
322
|
+
// re-laned in the same sprint (see reclaimInRunOrphanedClaims below).
|
|
323
|
+
import { createOrphanClaimTracker } from './orphan-reclaim.mjs';
|
|
324
|
+
// The pre-launch stale-claim rule, its fresh-read gate, and the downstream
|
|
325
|
+
// beads each reclaim unblocks (see reclaimStaleInProgress below).
|
|
326
|
+
import {
|
|
327
|
+
isPreLaunchReclaimCandidate, confirmPreLaunchCandidates, downstreamSuffix,
|
|
328
|
+
} from './beads-reachability.mjs';
|
|
329
|
+
// GitHub #717: the verify-block deadlock diagnosis -- a bead blocked only by
|
|
330
|
+
// verify-routed beads while the Integration Test phase cannot run.
|
|
331
|
+
import {
|
|
332
|
+
integCanRun, integBlockCause, findVerifyBlockedBeads, partitionByGoal, buildVerifyBlockDiagnosis,
|
|
333
|
+
} from './verify-block.mjs';
|
|
300
334
|
// The dispatch-outcome classification surface: isTerminalSprintFailure,
|
|
301
335
|
// isNoMutationDispatchFailure and withDispatchWatchdog. Extracted out of
|
|
302
336
|
// runner.js (apra-fleet-3swo.6.15); imported only to be re-exported below,
|
|
@@ -338,7 +372,7 @@ export {
|
|
|
338
372
|
// Re-exported so importers of the CLI arg-contract validators from runner.js
|
|
339
373
|
// keep working (notably bin/cli.mjs); sprint-args.mjs is the single source of
|
|
340
374
|
// truth for their implementation (apra-fleet-3swo.3.3).
|
|
341
|
-
export { validateIssueId, validateBranchName, validateArgs };
|
|
375
|
+
export { validateIssueId, validateBranchName, validateBranchPair, validateArgs };
|
|
342
376
|
// Re-exported so importers of the five previously-exported prompt builders
|
|
343
377
|
// from runner.js keep working; prompts.mjs is the single source of truth for
|
|
344
378
|
// their implementation (apra-fleet-3swo.3.4). buildPlanReviewerPrompt and
|
|
@@ -376,8 +410,8 @@ export {
|
|
|
376
410
|
createMcpDoltPushMutexClient, createMcpChildIdAllocatorClient,
|
|
377
411
|
createMemberReservationClient,
|
|
378
412
|
};
|
|
379
|
-
// Re-exported so importers of the KB work helpers (
|
|
380
|
-
// kb_capture/kb_promote vetting+forwarding,
|
|
413
|
+
// Re-exported so importers of the KB work helpers (kb_query,
|
|
414
|
+
// kb_capture/kb_promote vetting+forwarding, the bible commit) from runner.js keep
|
|
381
415
|
// working; kb.mjs is the single source of truth for their implementation
|
|
382
416
|
// (apra-fleet-3swo.4.4).
|
|
383
417
|
export {
|
|
@@ -385,13 +419,17 @@ export {
|
|
|
385
419
|
KB_CAPTURE_TYPES, KB_MAX_PROMOTION_CANDIDATES, vetKbWork, createKbWorkClient,
|
|
386
420
|
};
|
|
387
421
|
// Re-exported so importers of the KB priming client and the prompt-
|
|
388
|
-
// construction helpers (kbKnowledgeBlock, kbPromotionBlock,
|
|
389
|
-
// KB_SELF_INJECTING_ROLES) from runner.js keep working; kb.mjs
|
|
390
|
-
// single source of truth for their implementation (apra-fleet-3swo.6.11).
|
|
422
|
+
// construction helpers (kbKnowledgeBlock, kbPromotionBlock, kbDemotionBlock,
|
|
423
|
+
// kbQueryTerms, KB_SELF_INJECTING_ROLES) from runner.js keep working; kb.mjs
|
|
424
|
+
// is the single source of truth for their implementation (apra-fleet-3swo.6.11).
|
|
391
425
|
export {
|
|
392
426
|
createKbPrimingClient, KB_SELF_INJECTING_ROLES, kbQueryTerms,
|
|
393
|
-
kbKnowledgeBlock, kbPromotionBlock,
|
|
427
|
+
kbKnowledgeBlock, kbPromotionBlock, kbDemotionBlock,
|
|
394
428
|
};
|
|
429
|
+
// member-call.mjs is the single owner of memberCall/listTools (a MEMBER-scoped
|
|
430
|
+
// tool call: local in-process session, or remote/relay via send_files +
|
|
431
|
+
// execute_command of `apra-fleet call`). Re-exported on the runner facade.
|
|
432
|
+
export { createMemberCall, buildRemoteCallCommand, MemberCallError, MEMBER_CALL_ARGS_DIR };
|
|
395
433
|
// Re-exported so importers of the verify-set classifier from runner.js keep
|
|
396
434
|
// working; beads-scope.mjs is the single source of truth for its
|
|
397
435
|
// implementation, and for the BFS scope-discovery rule it now shares with
|
|
@@ -493,6 +531,241 @@ function resolveDispatchInactivityTimeoutS(dispatchTimeoutS) {
|
|
|
493
531
|
}
|
|
494
532
|
export { resolveDispatchInactivityTimeoutS };
|
|
495
533
|
|
|
534
|
+
// The members the sprint-branch ensure (and every per-cycle re-ensure) runs
|
|
535
|
+
// on: every member of a dispatched git-touching role, plus every selected
|
|
536
|
+
// kb_maintainer -- it G-pulls, bible-commits and G-pushes the sprint branch
|
|
537
|
+
// even when it holds no dispatched role (selection prefers such a member).
|
|
538
|
+
// De-duplicated, roles first. A selector without maintainers() (an injected
|
|
539
|
+
// stub) or a repository with no selected maintainer contributes nothing.
|
|
540
|
+
// Exported so tests drive the production list, not a re-derivation of it.
|
|
541
|
+
// backlogMembers (the backlog role, roleMap.backlog -- formerly the
|
|
542
|
+
// orchestrator alias, see backlog-role.mjs): such a member is never added
|
|
543
|
+
// through the maintainer path (defence in depth); a dispatch role still
|
|
544
|
+
// includes it.
|
|
545
|
+
function computeBranchEnsureMembers(getMembersForRole, kbMaintainers, backlogMembers) {
|
|
546
|
+
const backlogSet = new Set(backlogMembers || []);
|
|
547
|
+
const maintainerMembers = [];
|
|
548
|
+
if (kbMaintainers && typeof kbMaintainers.maintainers === 'function') {
|
|
549
|
+
for (const sel of kbMaintainers.maintainers().values()) {
|
|
550
|
+
if (sel && typeof sel.member === 'string' && sel.member && !backlogSet.has(sel.member)) maintainerMembers.push(sel.member);
|
|
551
|
+
}
|
|
552
|
+
}
|
|
553
|
+
return [...new Set([
|
|
554
|
+
...getMembersForRole(ROLE_DOER),
|
|
555
|
+
...getMembersForRole(ROLE_REVIEWER),
|
|
556
|
+
...getMembersForRole('planner'),
|
|
557
|
+
...getMembersForRole('plan-reviewer'),
|
|
558
|
+
...getMembersForRole('deployer'),
|
|
559
|
+
...getMembersForRole('integ-test-runner'),
|
|
560
|
+
...getMembersForRole('regression-test-runner'),
|
|
561
|
+
...getMembersForRole('harvester'),
|
|
562
|
+
...maintainerMembers,
|
|
563
|
+
])];
|
|
564
|
+
}
|
|
565
|
+
export { computeBranchEnsureMembers };
|
|
566
|
+
|
|
567
|
+
// Factory for kbWork.demotionCandidates()'s
|
|
568
|
+
// roundChangedFiles callback -- THIS REVIEW ROUND's changed-file set,
|
|
569
|
+
// deliberately separate from kbInjection's diffFiles (the cumulative
|
|
570
|
+
// origin/base...branch diff computed for the reviewer/harvester hint
|
|
571
|
+
// context, left completely unchanged by this).
|
|
572
|
+
//
|
|
573
|
+
// Pulled out as its own factory, injected with `command` and `pullGitBefore`
|
|
574
|
+
// rather than written inline, so this can be unit-tested directly against
|
|
575
|
+
// fakes that discriminate the two defects a diff guard spawning git is prone
|
|
576
|
+
// to (a detection function welded to its own git spawn can only be
|
|
577
|
+
// exercised against the one diff a test can cheaply construct in-repo,
|
|
578
|
+
// which proves nothing). Here the two defects are: (1) computing the diff
|
|
579
|
+
// BEFORE the fetch/fast-forward-merge instead of after -- a stale read that
|
|
580
|
+
// can miss exactly the files this round touched -- and (2) collapsing to
|
|
581
|
+
// the cumulative sprint diff instead of the per-round one. A fake
|
|
582
|
+
// `pullGitBefore` and `command` can flip between a pre-merge and a
|
|
583
|
+
// post-merge tree deterministically, so a test can assert the returned set
|
|
584
|
+
// came from the POST-merge tree without needing a real git repository.
|
|
585
|
+
//
|
|
586
|
+
// One factory call carries ONE piece of state across its returned
|
|
587
|
+
// function's calls: the previous round's diffed-to commit sha (`lastSha`).
|
|
588
|
+
// The first call has no previous round, so it diffs from the sprint's base
|
|
589
|
+
// branch instead -- the only point "the previous round" can mean before any
|
|
590
|
+
// round has run.
|
|
591
|
+
//
|
|
592
|
+
// @param {{
|
|
593
|
+
// command: (cmd: string, opts: { member_name: string, silent?: boolean, failSoft?: boolean }) => Promise<{ ok: boolean, output?: string }>,
|
|
594
|
+
// pullGitBefore: (memberName: string) => Promise<any>,
|
|
595
|
+
// baseBranch: string,
|
|
596
|
+
// log?: Function,
|
|
597
|
+
// }} opts
|
|
598
|
+
// @returns {(memberName: string) => Promise<string[]>}
|
|
599
|
+
function createRoundChangedFiles({ command, pullGitBefore, baseBranch, log = () => {} }) {
|
|
600
|
+
let lastSha = null;
|
|
601
|
+
return async function roundChangedFiles(memberName) {
|
|
602
|
+
// AFTER the fetch and fast-forward merge, never before -- computing
|
|
603
|
+
// the diff first would read a snapshot that has not yet absorbed
|
|
604
|
+
// this round's commits (the superseded upstream attempt's defect).
|
|
605
|
+
try {
|
|
606
|
+
await pullGitBefore(memberName);
|
|
607
|
+
} catch (err) {
|
|
608
|
+
log(`[kb-work] could not fetch/fast-forward-merge '${memberName}' before computing this round's changed files (non-fatal): ${err && err.message ? err.message : String(err)}`);
|
|
609
|
+
return [];
|
|
610
|
+
}
|
|
611
|
+
const revParseCmd = 'git rev-parse HEAD';
|
|
612
|
+
const headRes = await command(revParseCmd, { member_name: memberName, silent: true, failSoft: true });
|
|
613
|
+
const head = (headRes && headRes.ok) ? String(headRes.output || '').trim() : '';
|
|
614
|
+
if (!head) {
|
|
615
|
+
log(`[kb-work] WARN: '${revParseCmd}' failed on '${memberName}' -- no changed files for this round's demotion candidates${failedCommandDetail(headRes)}`);
|
|
616
|
+
return [];
|
|
617
|
+
}
|
|
618
|
+
// THIS round's diff only: from the previous round's merged tip (or,
|
|
619
|
+
// on the first round, the sprint's base branch) to the new tip --
|
|
620
|
+
// never the cumulative origin/base...branch diff diffFiles computes.
|
|
621
|
+
const fromRef = lastSha || `origin/${baseBranch}`;
|
|
622
|
+
const diffCmd = `git diff --name-only ${fromRef}...${head}`;
|
|
623
|
+
const diffRes = await command(diffCmd, { member_name: memberName, silent: true, failSoft: true });
|
|
624
|
+
if (!diffRes || !diffRes.ok) {
|
|
625
|
+
// lastSha is NOT advanced: the next round diffs from the last tip
|
|
626
|
+
// whose diff succeeded, so this round's files are not lost.
|
|
627
|
+
log(`[kb-work] WARN: '${diffCmd}' failed on '${memberName}' -- no changed files for this round's demotion candidates; the next round diffs from ${fromRef} again${failedCommandDetail(diffRes)}`);
|
|
628
|
+
return [];
|
|
629
|
+
}
|
|
630
|
+
lastSha = head;
|
|
631
|
+
return String(diffRes.output || '').split('\n').map((l) => l.trim()).filter(Boolean);
|
|
632
|
+
};
|
|
633
|
+
}
|
|
634
|
+
export { createRoundChangedFiles };
|
|
635
|
+
|
|
636
|
+
// Factory for kbWork.demotionCandidates({ scope: 'sprint' })'s
|
|
637
|
+
// sprintChangedFiles callback -- the CUMULATIVE sprint changed-file set, which
|
|
638
|
+
// is the FINAL review's scope.
|
|
639
|
+
//
|
|
640
|
+
// WHY THIS EXISTS SEPARATELY FROM createRoundChangedFiles. Final review judges
|
|
641
|
+
// the WHOLE sprint diff in one pass, so "this round" is not a thing it has:
|
|
642
|
+
// there is no previous round's merged tip to diff from, and scoping its
|
|
643
|
+
// demotion candidates to the last round's diff would hide every entry the
|
|
644
|
+
// earlier rounds' files made worth re-checking. The two scopes are therefore
|
|
645
|
+
// two injected callbacks chosen by an explicit `scope` argument, not one
|
|
646
|
+
// callback that tries to work out which review is asking.
|
|
647
|
+
//
|
|
648
|
+
// WHY IT IS NOT kbInjection's `diffFiles` either. That one computes the same
|
|
649
|
+
// cumulative range but is wired for the reviewer/harvester KB-injection HINT
|
|
650
|
+
// context and is deliberately left untouched; it also does no fetch/merge
|
|
651
|
+
// first. This pulls before diffing for exactly the reason its round sibling
|
|
652
|
+
// does -- a pre-merge tree has not absorbed the sprint's latest commits -- and
|
|
653
|
+
// is STATELESS, unlike the round factory, because a cumulative range has
|
|
654
|
+
// nothing to carry between calls.
|
|
655
|
+
//
|
|
656
|
+
// @param {{
|
|
657
|
+
// command: (cmd: string, opts: { member_name: string, silent?: boolean, failSoft?: boolean }) => Promise<{ ok: boolean, output?: string }>,
|
|
658
|
+
// pullGitBefore: (memberName: string) => Promise<any>,
|
|
659
|
+
// baseBranch: string,
|
|
660
|
+
// branch: string,
|
|
661
|
+
// log?: Function,
|
|
662
|
+
// }} opts
|
|
663
|
+
// @returns {(memberName: string) => Promise<string[]>}
|
|
664
|
+
function createSprintChangedFiles({ command, pullGitBefore, baseBranch, branch, log = () => {} }) {
|
|
665
|
+
return async function sprintChangedFiles(memberName) {
|
|
666
|
+
try {
|
|
667
|
+
await pullGitBefore(memberName);
|
|
668
|
+
} catch (err) {
|
|
669
|
+
log(`[kb-work] could not fetch/fast-forward-merge '${memberName}' before computing the sprint's cumulative changed files (non-fatal): ${err && err.message ? err.message : String(err)}`);
|
|
670
|
+
return [];
|
|
671
|
+
}
|
|
672
|
+
const diffCmd = `git diff --name-only origin/${baseBranch}...${branch}`;
|
|
673
|
+
const diffRes = await command(diffCmd, { member_name: memberName, silent: true, failSoft: true });
|
|
674
|
+
if (!diffRes || !diffRes.ok) {
|
|
675
|
+
log(`[kb-work] WARN: '${diffCmd}' failed on '${memberName}' -- no changed files for the final review's demotion candidates${failedCommandDetail(diffRes)}`);
|
|
676
|
+
return [];
|
|
677
|
+
}
|
|
678
|
+
return String(diffRes.output || '').split('\n').map((l) => l.trim()).filter(Boolean);
|
|
679
|
+
};
|
|
680
|
+
}
|
|
681
|
+
export { createSprintChangedFiles };
|
|
682
|
+
|
|
683
|
+
// Factory for kbWork.promotionCandidates()'s D6 in-sprint ping-pong guard:
|
|
684
|
+
// the CURRENT sha256 of a bounded set of files, read on a member's own
|
|
685
|
+
// checkout. kb.mjs has no shell/fs access of its own (every kb_* call there
|
|
686
|
+
// goes through memberCall, never a shell) and this is the one disk fact no
|
|
687
|
+
// kb_* tool answers -- demoted_basis_hashes (surfaced on an INFERRED entry's
|
|
688
|
+
// kb_query row once it has ever been demoted) is a snapshot taken AT DEMOTE
|
|
689
|
+
// TIME, not a live one, so telling "basis unchanged" from "basis moved on"
|
|
690
|
+
// needs a fresh read of the SAME files right now.
|
|
691
|
+
//
|
|
692
|
+
// MUST hash the SAME way SqliteProvider's demoteBasisHashes does -- plain
|
|
693
|
+
// sha256 of the raw bytes, never `git hash-object` (which normalizes line
|
|
694
|
+
// endings and therefore would not reliably equal a plain sha256 of the same
|
|
695
|
+
// content) -- or the two sides of kb.mjs's comparison would silently never
|
|
696
|
+
// match. Run through a disposable `node -e` script rather than a shell
|
|
697
|
+
// pipeline. The file list is KB-supplied text, so it is NEVER interpolated
|
|
698
|
+
// into the command string: it travels as one base64 argv token (alphabet
|
|
699
|
+
// A-Za-z0-9+/=, inert in POSIX shells, PowerShell and cmd.exe) and the fixed
|
|
700
|
+
// script, which carries no `$`, backticks or double quotes, decodes it --
|
|
701
|
+
// the same recipe as stageCommandBodyMemberSide in member-provisioning.mjs.
|
|
702
|
+
// A JSON.stringify'd list inside a double-quoted shell string is NOT safe:
|
|
703
|
+
// POSIX shells still expand `$(...)` and backticks inside double quotes.
|
|
704
|
+
//
|
|
705
|
+
// A missing or unreadable file is simply absent from the result (never a
|
|
706
|
+
// fabricated hash); a failed command, or output that is not the JSON object
|
|
707
|
+
// this script prints, degrades to {} with a WARN naming the member -- the caller's "never falsely
|
|
708
|
+
// suppress" rule then leaves every candidate offered, exactly as it does for
|
|
709
|
+
// an unparseable demoted_basis_hashes snapshot.
|
|
710
|
+
//
|
|
711
|
+
// @param {{
|
|
712
|
+
// command: (cmd: string, opts: { member_name: string, silent?: boolean, failSoft?: boolean }) => Promise<{ ok: boolean, output?: string }>,
|
|
713
|
+
// log?: Function,
|
|
714
|
+
// }} opts
|
|
715
|
+
// @returns {(memberName: string, files: string[]) => Promise<Record<string, string>>}
|
|
716
|
+
const CURRENT_FILE_HASHES_SCRIPT =
|
|
717
|
+
"const fs=require('fs'),crypto=require('crypto');" +
|
|
718
|
+
"const files=JSON.parse(Buffer.from(process.argv[1],'base64').toString('utf8'));" +
|
|
719
|
+
"const out={};" +
|
|
720
|
+
"for (const f of files) { try { out[f]=crypto.createHash('sha256').update(fs.readFileSync(f)).digest('hex'); } catch (e) {} }" +
|
|
721
|
+
"process.stdout.write(JSON.stringify(out));";
|
|
722
|
+
// How a WARN line names the hashing command: the full string carries the whole
|
|
723
|
+
// script plus a base64 file list, which would bury the message.
|
|
724
|
+
const CURRENT_FILE_HASHES_LABEL = 'node -e <current-file-hashes script> <base64 file list>';
|
|
725
|
+
const FAILED_OUTPUT_MAX_CHARS = 300;
|
|
726
|
+
|
|
727
|
+
// ": <the command's output, capped at FAILED_OUTPUT_MAX_CHARS>", or "" when it
|
|
728
|
+
// printed nothing -- the reason a WARN line quotes for a failed member command.
|
|
729
|
+
function failedCommandDetail(res) {
|
|
730
|
+
const out = res && typeof res.output === 'string' ? res.output.trim() : '';
|
|
731
|
+
if (!out) return '';
|
|
732
|
+
return `: ${out.length > FAILED_OUTPUT_MAX_CHARS ? `${out.slice(0, FAILED_OUTPUT_MAX_CHARS)}...` : out}`;
|
|
733
|
+
}
|
|
734
|
+
|
|
735
|
+
function createCurrentFileHashes({ command, log = () => {} }) {
|
|
736
|
+
return async function currentFileHashes(memberName, files) {
|
|
737
|
+
const list = Array.isArray(files) ? files.filter((f) => typeof f === 'string' && f.length > 0) : [];
|
|
738
|
+
if (list.length === 0) return {};
|
|
739
|
+
const filesB64 = Buffer.from(JSON.stringify(list), 'utf-8').toString('base64');
|
|
740
|
+
let res;
|
|
741
|
+
try {
|
|
742
|
+
res = await command(`node -e "${CURRENT_FILE_HASHES_SCRIPT}" "${filesB64}"`, { member_name: memberName, silent: true, failSoft: true });
|
|
743
|
+
} catch (err) {
|
|
744
|
+
log(`[kb-work] could not re-hash ${list.length} file(s) on '${memberName}' for the in-sprint ping-pong guard (non-fatal): ${err && err.message ? err.message : String(err)}`);
|
|
745
|
+
return {};
|
|
746
|
+
}
|
|
747
|
+
// A member without a working `node` lands here on every call, which
|
|
748
|
+
// disables the guard -- so say so, every time.
|
|
749
|
+
if (!res || !res.ok) {
|
|
750
|
+
log(`[kb-work] WARN: '${CURRENT_FILE_HASHES_LABEL}' failed on '${memberName}' -- the in-sprint ping-pong guard has no current hashes for ${list.length} file(s) and suppresses nothing${failedCommandDetail(res)}`);
|
|
751
|
+
return {};
|
|
752
|
+
}
|
|
753
|
+
let parsed;
|
|
754
|
+
try {
|
|
755
|
+
parsed = JSON.parse(String(res.output || '{}'));
|
|
756
|
+
} catch (err) {
|
|
757
|
+
log(`[kb-work] WARN: '${CURRENT_FILE_HASHES_LABEL}' on '${memberName}' printed output that is not JSON (${err.message}) -- the in-sprint ping-pong guard has no current hashes for ${list.length} file(s) and suppresses nothing${failedCommandDetail(res)}`);
|
|
758
|
+
return {};
|
|
759
|
+
}
|
|
760
|
+
if (!parsed || typeof parsed !== 'object' || Array.isArray(parsed)) {
|
|
761
|
+
log(`[kb-work] WARN: '${CURRENT_FILE_HASHES_LABEL}' on '${memberName}' printed JSON that is not a file -> hash object -- the in-sprint ping-pong guard suppresses nothing${failedCommandDetail(res)}`);
|
|
762
|
+
return {};
|
|
763
|
+
}
|
|
764
|
+
return parsed;
|
|
765
|
+
};
|
|
766
|
+
}
|
|
767
|
+
export { createCurrentFileHashes };
|
|
768
|
+
|
|
496
769
|
// ---------------------------------------------------------------------------
|
|
497
770
|
// Canonical role-name constants for the Develop/Review loop
|
|
498
771
|
// ---------------------------------------------------------------------------
|
|
@@ -511,10 +784,10 @@ const ROLE_DOER = roleConst('doer');
|
|
|
511
784
|
const ROLE_REVIEWER = roleConst('reviewer');
|
|
512
785
|
|
|
513
786
|
// ---------------------------------------------------------------------------
|
|
514
|
-
// '
|
|
787
|
+
// 'backlog' pseudo-role
|
|
515
788
|
// ---------------------------------------------------------------------------
|
|
516
789
|
//
|
|
517
|
-
// 'orchestrator' is deliberately NOT a member of `contracts.ROLES` and must
|
|
790
|
+
// 'backlog' (formerly 'orchestrator', see backlog-role.mjs) is deliberately NOT a member of `contracts.ROLES` and must
|
|
518
791
|
// never be added to it: that enum is vendored (it mirrors the `name:`
|
|
519
792
|
// frontmatter of packages/apra-fleet-se/apra-pm/agents/*.md 1:1) and this repo
|
|
520
793
|
// must not diverge from it. 'orchestrator' has no agent definition, no
|
|
@@ -527,7 +800,6 @@ const ROLE_REVIEWER = roleConst('reviewer');
|
|
|
527
800
|
// a `bd show`-derived model-metadata lookup or any vendored schema table.
|
|
528
801
|
// Always reference it via this constant (the canonical lowercase form) rather
|
|
529
802
|
// than a literal, so a roleMap author's lowercase key is always honored.
|
|
530
|
-
const ROLE_ORCHESTRATOR = 'orchestrator';
|
|
531
803
|
|
|
532
804
|
// ---------------------------------------------------------------------------
|
|
533
805
|
// Fixed-role tier defaults
|
|
@@ -546,7 +818,7 @@ const ROLE_ORCHESTRATOR = 'orchestrator';
|
|
|
546
818
|
// deployer -> 'standard' (mostly mechanical: follow deploy.md)
|
|
547
819
|
// integ-test-runner -> 'standard' (mostly mechanical: follow integ-test-playbook.md)
|
|
548
820
|
// regression-test-runner -> 'standard' (mostly mechanical: follow regression-test-playbook.md)
|
|
549
|
-
// harvester -> 'standard' (docs
|
|
821
|
+
// harvester -> 'standard' (docs synthesis, not code-critical)
|
|
550
822
|
// These tier keywords ('cheap' | 'standard' | 'premium') are resolved to a
|
|
551
823
|
// concrete model PER MEMBER, server-side, by execute-prompt.ts's
|
|
552
824
|
// resolveModelForTier() (via each member's registered model_tiers). That is
|
|
@@ -608,7 +880,10 @@ export const meta = { name: 'fleet-sprint-runner' };
|
|
|
608
880
|
// would pass them literally into argv. Double quotes are stripped as real
|
|
609
881
|
// quoting by PowerShell and cmd.exe alike, and are a harmless no-op under POSIX
|
|
610
882
|
// shells.
|
|
611
|
-
const
|
|
883
|
+
const NOT_DONE_STATUS_LIST = ['open', 'in_progress', 'blocked', 'deferred'];
|
|
884
|
+
const NOT_DONE_STATUSES = `"${NOT_DONE_STATUS_LIST.join(',')}"`;
|
|
885
|
+
// The same statuses as a Set, for filtering already-fetched bead records.
|
|
886
|
+
const NOT_DONE_STATUS_SET = new Set(NOT_DONE_STATUS_LIST);
|
|
612
887
|
|
|
613
888
|
// ---------------------------------------------------------------------------
|
|
614
889
|
// Git sync brackets: G-pull / G-push -- MOVED to ./member-sync.mjs
|
|
@@ -820,6 +1095,10 @@ async function runSprintCycle(context) {
|
|
|
820
1095
|
// controller is only wired when BOTH are present, so those callers keep the
|
|
821
1096
|
// pre-feature behaviour (a usage-limit error falls through the retry ladder).
|
|
822
1097
|
const { requestPause, requestResume } = context;
|
|
1098
|
+
// The engine's run stop signal (absent for direct/legacy callers): lets
|
|
1099
|
+
// the decision wait see an operator stop while it holds the run parked
|
|
1100
|
+
// with nothing dispatched.
|
|
1101
|
+
const stopSignal = typeof context.stopSignal === 'function' ? context.stopSignal : undefined;
|
|
823
1102
|
|
|
824
1103
|
// Validate BEFORE any agent()/command() dispatch: a rejected/malformed arg
|
|
825
1104
|
// must result in zero fleet dispatches. This must happen early so the
|
|
@@ -857,11 +1136,11 @@ async function runSprintCycle(context) {
|
|
|
857
1136
|
targetIssues: validated.targetIssues,
|
|
858
1137
|
assignee: validated.assignee,
|
|
859
1138
|
parseBdJson,
|
|
860
|
-
// A getter, not a value: `
|
|
1139
|
+
// A getter, not a value: `backlogMember` is resolved from the
|
|
861
1140
|
// role->member mapping further down this function, but this client
|
|
862
1141
|
// has to exist BEFORE `command` does. No beads read can happen in
|
|
863
1142
|
// between, so the getter is always called on a resolved value.
|
|
864
|
-
|
|
1143
|
+
getBacklogMember: () => backlogMember,
|
|
865
1144
|
});
|
|
866
1145
|
const { invalidateAllBeadsCache, fetchAllBeadsShared, bdListScoped } = beadsScope;
|
|
867
1146
|
const command = beadsScope.wrapCommand(rawCommand, {
|
|
@@ -925,18 +1204,69 @@ async function runSprintCycle(context) {
|
|
|
925
1204
|
// in withGitSync (which awaits this promise before syncing) on success
|
|
926
1205
|
// AND on failure, and covers the dispatches outside withGitSync too
|
|
927
1206
|
// (Streak Assignment).
|
|
1207
|
+
// Assigned once kbPriming exists (below); until then (no dispatch can run
|
|
1208
|
+
// before it) a pass-through.
|
|
1209
|
+
let dispatchAccounting = { around: (_info, fn) => fn() };
|
|
1210
|
+
// KNOWLEDGE BANK injection (kb-injection.mjs), bound once kbWork exists
|
|
1211
|
+
// below; sprint-level hint sources the dispatch wrapper falls back to.
|
|
1212
|
+
let kbInjection = null;
|
|
1213
|
+
const kbSprintContext = { goals: [], beadTitles: [], closedBeadTitles: [], beadIds: [], testFiles: [] };
|
|
1214
|
+
// bead id -> bead, refreshed with the sprint tree; the reviewer's hint
|
|
1215
|
+
// sources (titles of the beads under review) are read from it.
|
|
1216
|
+
let kbBeadIndex = new Map();
|
|
1217
|
+
const kbBeadTitles = (ids) => (Array.isArray(ids) ? ids : []).map((id) => kbBeadIndex.get(id)?.title).filter((t) => typeof t === 'string' && t);
|
|
928
1218
|
const agent = async (prompt, opts = {}) => {
|
|
929
1219
|
let finalPrompt = prompt;
|
|
930
1220
|
if (opts.agentType && !KB_SELF_INJECTING_ROLES.has(opts.agentType) && opts.member_name) {
|
|
931
|
-
|
|
1221
|
+
// Only promise the kb_captures channel to a persona whose returned
|
|
1222
|
+
// captures the engine actually applies (e.g. harvester); planner,
|
|
1223
|
+
// plan-reviewer, deployer and the test runners have none.
|
|
1224
|
+
// A member whose own fleet MCP was verified at sprint init reads
|
|
1225
|
+
// the KB itself and gets no block; every other member gets one,
|
|
1226
|
+
// fetched from the repository's kb_maintainer (kb-injection.mjs).
|
|
1227
|
+
const captureChannel = agentTypeAppliesKbCaptures(opts.agentType);
|
|
1228
|
+
const [block] = kbInjection
|
|
1229
|
+
? await kbInjection.blockFor({
|
|
1230
|
+
role: opts.agentType,
|
|
1231
|
+
member: opts.member_name,
|
|
1232
|
+
context: { ...kbSprintContext, ...(opts.kbContext || {}) },
|
|
1233
|
+
captureChannel,
|
|
1234
|
+
})
|
|
1235
|
+
: kbKnowledgeBlock(kbPriming.knowledgeOf(opts.member_name), { captureChannel });
|
|
932
1236
|
if (block) finalPrompt = prompt + '\n\n' + block;
|
|
933
1237
|
}
|
|
1238
|
+
return withKbDispatchLifecycle(opts.member_name, async () => {
|
|
1239
|
+
try {
|
|
1240
|
+
// Per-dispatch kb_* and code_* counts: session_stats snapshots of the
|
|
1241
|
+
// dispatched member immediately before and after (best-effort;
|
|
1242
|
+
// an unreadable count is recorded as unknown, never 0).
|
|
1243
|
+
return await dispatchAccounting.around(
|
|
1244
|
+
{ memberName: opts.member_name, role: opts.agentType, label: opts.label },
|
|
1245
|
+
() => agentRaw(finalPrompt, { sprint_id: sprintMutexId, ...opts }),
|
|
1246
|
+
);
|
|
1247
|
+
} finally {
|
|
1248
|
+
if (opts.member_name) DoltSync.noteMemberDispatchCompleted(opts.member_name);
|
|
1249
|
+
}
|
|
1250
|
+
});
|
|
1251
|
+
};
|
|
1252
|
+
|
|
1253
|
+
// KB write queue dispatch lifecycle (kb.mjs createKbWorkClient): bound
|
|
1254
|
+
// once kbWork exists below. A member is BUSY for the whole of every
|
|
1255
|
+
// dispatch -- the agent() call here and, through the withGitSync alias,
|
|
1256
|
+
// its entire sync bracket -- so a KB write for a repository it maintains
|
|
1257
|
+
// is never applied during one; the end of its last open dispatch applies
|
|
1258
|
+
// what queued up behind it. The hooks never throw (kbWork logs and keeps
|
|
1259
|
+
// writes queued instead), so they cannot replace a dispatch's own result.
|
|
1260
|
+
let kbDispatchHooks = null;
|
|
1261
|
+
async function withKbDispatchLifecycle(memberName, fn) {
|
|
1262
|
+
const hooks = memberName ? kbDispatchHooks : null;
|
|
1263
|
+
if (hooks) await hooks.started(memberName);
|
|
934
1264
|
try {
|
|
935
|
-
return await
|
|
1265
|
+
return await fn();
|
|
936
1266
|
} finally {
|
|
937
|
-
if (
|
|
1267
|
+
if (hooks) await hooks.ended(memberName);
|
|
938
1268
|
}
|
|
939
|
-
}
|
|
1269
|
+
}
|
|
940
1270
|
|
|
941
1271
|
// The global dolt push mutex client. Every D-push below serializes through
|
|
942
1272
|
// it so two sprints never push at the same time. Four sources, in
|
|
@@ -1024,6 +1354,14 @@ async function runSprintCycle(context) {
|
|
|
1024
1354
|
log,
|
|
1025
1355
|
});
|
|
1026
1356
|
|
|
1357
|
+
// Every `bd dolt pull`/`bd dolt push` DoltSync issues is built per member
|
|
1358
|
+
// OS/shell (a Windows member runs bd with a bounded GOMAXPROCS). Install
|
|
1359
|
+
// the sprint's cached member_detail-backed resolver once, here; with no
|
|
1360
|
+
// fleet client the resolver is cleared and members are treated as POSIX.
|
|
1361
|
+
setMemberTargetResolver(sprintState.fleetApi
|
|
1362
|
+
? (member) => resolveMemberTarget({ fleetApi: sprintState.fleetApi, member, log })
|
|
1363
|
+
: null);
|
|
1364
|
+
|
|
1027
1365
|
// Guards every resume re-dispatch below against spawning a second
|
|
1028
1366
|
// concurrent session on top of a prior one that is presumed dead/timed out
|
|
1029
1367
|
// but may still be alive (see createMemberSessionGuard's doc comment).
|
|
@@ -1111,7 +1449,9 @@ async function runSprintCycle(context) {
|
|
|
1111
1449
|
const ensureVcsAuthFresh = context.ensureVcsAuthFresh ?? (
|
|
1112
1450
|
(args && typeof args.callTool === 'function')
|
|
1113
1451
|
? createVcsAuthPreflightCallback({ callTool: args.callTool, command, log, azdevopsPatSecretName: validated.azdevopsPatSecretName })
|
|
1114
|
-
: async () => {
|
|
1452
|
+
: async (member) => {
|
|
1453
|
+
log(`[Sync] preflight: provision_vcs_auth skipped for member '${member}': no callTool wired -- no proactive preflight (the reactive self-heal is the only auth recovery).`);
|
|
1454
|
+
}
|
|
1115
1455
|
);
|
|
1116
1456
|
|
|
1117
1457
|
// Sync-step "does this push touch .github/workflows without the
|
|
@@ -1219,6 +1559,15 @@ async function runSprintCycle(context) {
|
|
|
1219
1559
|
|
|
1220
1560
|
let cycle = 1;
|
|
1221
1561
|
const MAX_CYCLES = validated.maxCycles;
|
|
1562
|
+
// The cycle loop's ceiling. A decision answered at Cycle Evaluation of the
|
|
1563
|
+
// last allowed cycle (a "late" answer) raises it by one cycle -- when the
|
|
1564
|
+
// run's budget allows -- so the released bead is still dispatched; see
|
|
1565
|
+
// handleLateDecisionAnswers(). Starts at MAX_CYCLES.
|
|
1566
|
+
let effectiveMaxCycles = MAX_CYCLES;
|
|
1567
|
+
// Answers applied at the last cycle's evaluation, not yet resolved into an
|
|
1568
|
+
// extra cycle or a report; and the beads reported released too late.
|
|
1569
|
+
let lateDecisionAnswers = [];
|
|
1570
|
+
const lateUnworkedReports = [];
|
|
1222
1571
|
|
|
1223
1572
|
// Per-(role, cycle) session registry: a role's session is resumed across
|
|
1224
1573
|
// ROUNDS within one cycle via an explicit session id, but NEVER across
|
|
@@ -1260,31 +1609,246 @@ async function runSprintCycle(context) {
|
|
|
1260
1609
|
// the Step 0 Knowledge Bank block in every role contract has something warm
|
|
1261
1610
|
// to read. This engine had no KB priming at all -- it lived only in the
|
|
1262
1611
|
// Claude workflow copy. Best-effort: a cold KB never fails a sprint.
|
|
1612
|
+
//
|
|
1613
|
+
// Every member-targeted kb_* call runs AS that member (memberCall: a
|
|
1614
|
+
// member-scoped session, so the KB resolves the member's own work folder;
|
|
1615
|
+
// no kb_* tool takes a repo/scope argument). The orchestrator's callTool
|
|
1616
|
+
// is only used for member_detail. context.memberCall is a test seam.
|
|
1617
|
+
// Built lazily, on the first kb call, so a sprint that never reaches one
|
|
1618
|
+
// constructs nothing extra.
|
|
1619
|
+
let memberCaller = context.memberCall ?? null;
|
|
1620
|
+
const canMemberCall = !!memberCaller || !!(args && typeof args.callTool === 'function');
|
|
1621
|
+
const kbMemberCall = canMemberCall
|
|
1622
|
+
? (member, tool, toolArgs, callOpts) => {
|
|
1623
|
+
memberCaller ??= createMemberCall({ fleetApi: sprintScopedFleetApi({ callTool: args.callTool, log }), log });
|
|
1624
|
+
// callOpts carries the kb_maintainer grant (kb.mjs passes it only
|
|
1625
|
+
// when calling as a repository's kb_maintainer).
|
|
1626
|
+
return callOpts === undefined
|
|
1627
|
+
? memberCaller.memberCall(member, tool, toolArgs)
|
|
1628
|
+
: memberCaller.memberCall(member, tool, toolArgs, callOpts);
|
|
1629
|
+
}
|
|
1630
|
+
: undefined;
|
|
1631
|
+
// One beads-identity prober per run, shared by kb_maintainer selection
|
|
1632
|
+
// (which reads each member's origin remote from it) and the beads identity
|
|
1633
|
+
// precondition below: each member's probes run once, never twice.
|
|
1634
|
+
const beadsIdentityProber = createBeadsIdentityProber({ command });
|
|
1635
|
+
|
|
1636
|
+
// kb_maintainer selection: one member per repository receives every KB
|
|
1637
|
+
// write for that repository (kb-maintainer.mjs). Computed once here --
|
|
1638
|
+
// after members are resolved, before any KB priming -- logged one line
|
|
1639
|
+
// per repository, and stored on the sprint context (context.kbMaintainers,
|
|
1640
|
+
// also the test seam) for the write-routing step and later phases. Only
|
|
1641
|
+
// members member_detail resolves to an id are probed, so a sprint without
|
|
1642
|
+
// member access issues no extra command.
|
|
1643
|
+
const kbMaintainers = context.kbMaintainers ?? createKbMaintainerSelector({
|
|
1644
|
+
members: physicalMembers,
|
|
1645
|
+
roleMap: validated.roleMap,
|
|
1646
|
+
resolveMember: (kbMemberCall && args && typeof args.callTool === 'function') ? createMemberDetailResolver(args.callTool) : undefined,
|
|
1647
|
+
probeOrigin: async (member) => (await beadsIdentityProber.probe(member)).identity.repoRemote,
|
|
1648
|
+
probeMember: kbMemberCall ? (record) => kbMemberCall(record, 'kb_stats', {}) : undefined,
|
|
1649
|
+
log,
|
|
1650
|
+
});
|
|
1651
|
+
await kbMaintainers.selectAll();
|
|
1652
|
+
context.kbMaintainers = kbMaintainers;
|
|
1653
|
+
|
|
1654
|
+
// Per-member sprint-init probe (member-init-probe.mjs): once per member,
|
|
1655
|
+
// after kb_maintainer selection and before KB priming and the first
|
|
1656
|
+
// dispatch -- start-if-down (remote), the MEMBER tools/list check plus a
|
|
1657
|
+
// recorded fleetMcp refresh, the CONFIRMED count and the code index first
|
|
1658
|
+
// tick. Every kb_*/code_* call goes through the same memberCall the KB work
|
|
1659
|
+
// uses; the orchestrator callTool only reads member_detail. Never blocks:
|
|
1660
|
+
// a probe that throws leaves every member unverified and the sprint goes
|
|
1661
|
+
// on. Records land in sprint state (sprintState.memberInit), on the
|
|
1662
|
+
// context (context.memberInit + context.isMemberVerified, read by the
|
|
1663
|
+
// KNOWLEDGE BANK injection) and in the published viewer state.
|
|
1664
|
+
// context.memberInitProbe is the test seam.
|
|
1665
|
+
const kbListTools = canMemberCall
|
|
1666
|
+
? (member) => {
|
|
1667
|
+
memberCaller ??= createMemberCall({ fleetApi: sprintScopedFleetApi({ callTool: args.callTool, log }), log });
|
|
1668
|
+
if (typeof memberCaller.listTools !== 'function') throw new Error('member session channel has no listTools');
|
|
1669
|
+
return memberCaller.listTools(member);
|
|
1670
|
+
}
|
|
1671
|
+
: undefined;
|
|
1672
|
+
// The member-call --kb-maintainer capability verdict (cached per member on
|
|
1673
|
+
// the same memberCaller the KB writes use): member-init warns about a
|
|
1674
|
+
// remote kb_maintainer whose install cannot open the grant.
|
|
1675
|
+
const kbMaintainerCapability = canMemberCall
|
|
1676
|
+
? (member) => {
|
|
1677
|
+
memberCaller ??= createMemberCall({ fleetApi: sprintScopedFleetApi({ callTool: args.callTool, log }), log });
|
|
1678
|
+
return typeof memberCaller.kbMaintainerCapability === 'function' ? memberCaller.kbMaintainerCapability(member) : 'inconclusive';
|
|
1679
|
+
}
|
|
1680
|
+
: undefined;
|
|
1681
|
+
const memberInitProbe = context.memberInitProbe ?? createMemberInitProbe({
|
|
1682
|
+
members: physicalMembers,
|
|
1683
|
+
roleMap: validated.roleMap,
|
|
1684
|
+
callTool: (args && typeof args.callTool === 'function') ? args.callTool : undefined,
|
|
1685
|
+
memberCall: kbMemberCall,
|
|
1686
|
+
listTools: kbListTools,
|
|
1687
|
+
fleetApi: sprintState.fleetApi,
|
|
1688
|
+
kbMaintainers: () => context.kbMaintainers,
|
|
1689
|
+
kbMaintainerCapability,
|
|
1690
|
+
log,
|
|
1691
|
+
});
|
|
1692
|
+
let memberInitRecords = [];
|
|
1693
|
+
try {
|
|
1694
|
+
const probed = await memberInitProbe.probeAll();
|
|
1695
|
+
memberInitRecords = Array.isArray(probed) ? probed : [];
|
|
1696
|
+
} catch (err) {
|
|
1697
|
+
log(`${MEMBER_INIT_LOG_PREFIX} WARN probe failed (non-fatal; every member is treated as unverified): ${err && err.message ? err.message : err}`);
|
|
1698
|
+
}
|
|
1699
|
+
sprintState.memberInit.splice(0, sprintState.memberInit.length, ...memberInitRecords);
|
|
1700
|
+
context.memberInit = sprintState.memberInit;
|
|
1701
|
+
context.isMemberVerified = createMemberVerifiedLookup(() => sprintState.memberInit);
|
|
1702
|
+
// Banner WARN at init (the per-member WARN lines come from the probe).
|
|
1703
|
+
logLowerQualityWarn(log, MEMBER_INIT_LOG_PREFIX, sprintState.memberInit, 'init');
|
|
1704
|
+
if (typeof publishState === 'function') {
|
|
1705
|
+
try {
|
|
1706
|
+
publishState(MEMBER_INIT_STATE_NAMESPACE, { members: sprintState.memberInit.slice(), banner: lowerQuality(sprintState.memberInit).banner });
|
|
1707
|
+
} catch (err) {
|
|
1708
|
+
log(`${MEMBER_INIT_LOG_PREFIX} could not publish the init records (non-fatal): ${err && err.message ? err.message : err}`);
|
|
1709
|
+
}
|
|
1710
|
+
}
|
|
1711
|
+
|
|
1263
1712
|
const kbPriming = context.kbPriming ?? createKbPrimingClient({
|
|
1264
1713
|
callTool: (args && typeof args.callTool === 'function') ? args.callTool : undefined,
|
|
1714
|
+
memberCall: kbMemberCall,
|
|
1265
1715
|
members: physicalMembers,
|
|
1716
|
+
// Knowledge is primed from each repository's kb_maintainer (selected
|
|
1717
|
+
// above); its bible import reads the base branch's committed bible.
|
|
1718
|
+
maintainers: () => context.kbMaintainers,
|
|
1719
|
+
baseBranch: validated.baseBranch,
|
|
1720
|
+
// A remote maintainer's kb_import must advertise `ref` (version gate).
|
|
1721
|
+
listTools: kbListTools,
|
|
1266
1722
|
log,
|
|
1267
1723
|
});
|
|
1268
1724
|
await kbPriming.primeAll();
|
|
1269
1725
|
|
|
1726
|
+
// Per-dispatch kb_* and code_* call accounting (dispatch-accounting.mjs),
|
|
1727
|
+
// used by the agent() wrapper above. Reads session_stats AS the member
|
|
1728
|
+
// through the same memberCall the kb work uses (engine-origin, so the
|
|
1729
|
+
// reads themselves are not counted); records land in sprint state and
|
|
1730
|
+
// are published to the viewer. context.dispatchAccounting is a test seam.
|
|
1731
|
+
dispatchAccounting = context.dispatchAccounting ?? createDispatchAccounting({
|
|
1732
|
+
memberCall: kbMemberCall,
|
|
1733
|
+
memberOf: (name) => (typeof kbPriming.memberOf === 'function' ? kbPriming.memberOf(name) : null),
|
|
1734
|
+
getMemberInit: (name) => sprintState.memberInit.find((r) => r && r.member === name) || null,
|
|
1735
|
+
store: sprintState.dispatchToolCalls,
|
|
1736
|
+
publishState,
|
|
1737
|
+
log,
|
|
1738
|
+
});
|
|
1739
|
+
|
|
1270
1740
|
// The role output schemas are shared with apra-pm, so every role dispatched
|
|
1271
1741
|
// below is now asked for kb_captures (and the reviewer for kb_promotions).
|
|
1272
1742
|
// This is the consumer: without it those fields would be gathered and
|
|
1273
|
-
// silently dropped. Unlike apra-pm's workflow script, this engine
|
|
1274
|
-
//
|
|
1743
|
+
// silently dropped. Unlike apra-pm's workflow script, this engine can call
|
|
1744
|
+
// tools itself, so the kb_capture/kb_promote calls are made directly.
|
|
1745
|
+
//
|
|
1746
|
+
// Every KB WRITE is routed through the producing member's repository
|
|
1747
|
+
// kb_maintainer (kbMaintainers above), never the producing member itself
|
|
1748
|
+
// and never the orchestrator's own session: queued per repository, G-pulled
|
|
1749
|
+
// on the maintainer before each batch (gitSync.pullGitBefore -- the same
|
|
1750
|
+
// syncMemberBefore every dispatch bracket opens with), and held while the
|
|
1751
|
+
// maintainer is mid-dispatch (dispatchStarted/dispatchEnded below).
|
|
1752
|
+
// gitSync is bound further down; the G-pull closure resolves it lazily,
|
|
1753
|
+
// and no KB write can be applied before the first dispatch completes.
|
|
1754
|
+
// THIS REVIEW ROUND's changed-file set for
|
|
1755
|
+
// kbWork.demotionCandidates(), deliberately separate from kbInjection's
|
|
1756
|
+
// diffFiles below (the cumulative origin/base...branch diff, left
|
|
1757
|
+
// unchanged for its existing reviewer/harvester hint-context callers).
|
|
1758
|
+
// gitSync.pullGitBefore is bound lazily here exactly like gPull/gPush
|
|
1759
|
+
// below -- gitSync is defined further down in this function, and
|
|
1760
|
+
// roundChangedFiles is not CALLED until long after that assignment runs.
|
|
1761
|
+
const roundChangedFiles = context.roundChangedFiles ?? createRoundChangedFiles({
|
|
1762
|
+
command,
|
|
1763
|
+
pullGitBefore: (memberName) => gitSync.pullGitBefore(memberName),
|
|
1764
|
+
baseBranch: validated.baseBranch,
|
|
1765
|
+
log,
|
|
1766
|
+
});
|
|
1767
|
+
// THE SPRINT's CUMULATIVE changed-file set, for the FINAL review's
|
|
1768
|
+
// demotion-candidate read -- final review has no round, so it scopes to
|
|
1769
|
+
// the whole baseBranch...branch diff. Same lazy gitSync binding as its
|
|
1770
|
+
// per-round sibling above.
|
|
1771
|
+
const sprintChangedFiles = context.sprintChangedFiles ?? createSprintChangedFiles({
|
|
1772
|
+
command,
|
|
1773
|
+
pullGitBefore: (memberName) => gitSync.pullGitBefore(memberName),
|
|
1774
|
+
baseBranch: validated.baseBranch,
|
|
1775
|
+
branch: validated.branch,
|
|
1776
|
+
log,
|
|
1777
|
+
});
|
|
1778
|
+
const currentFileHashes = context.currentFileHashes ?? createCurrentFileHashes({ command, log });
|
|
1275
1779
|
const kbWork = context.kbWork ?? createKbWorkClient({
|
|
1276
|
-
|
|
1780
|
+
memberCall: kbMemberCall,
|
|
1781
|
+
maintainers: () => context.kbMaintainers,
|
|
1782
|
+
gPull: (maintainerName, options) => gitSync.pullGitBefore(maintainerName, options),
|
|
1783
|
+
roundChangedFiles,
|
|
1784
|
+
sprintChangedFiles,
|
|
1785
|
+
// D6 in-sprint ping-pong guard (promotionCandidates): re-hash a
|
|
1786
|
+
// candidate's cited files on demand to tell "basis unchanged since
|
|
1787
|
+
// the demotion" from "basis moved on" -- see createCurrentFileHashes.
|
|
1788
|
+
currentFileHashes,
|
|
1789
|
+
// The review-round bible commit (kbWork.commitRound): G-push, the
|
|
1790
|
+
// retry's rebase --abort, and the base branch/commit recorded as the
|
|
1791
|
+
// bible's provenance -- all on the maintainer, all bracketed.
|
|
1792
|
+
gPush: (maintainerName) => gitSync.pushBibleCommit(maintainerName),
|
|
1793
|
+
abortRebase: (maintainerName) => gitSync.abortRebase(maintainerName),
|
|
1794
|
+
bibleBase: (maintainerName) => gitSync.resolveBibleBase(maintainerName),
|
|
1795
|
+
canResetCheckout: (maintainerName, bibleFile) => gitSync.canResetBibleCheckout(maintainerName, bibleFile),
|
|
1796
|
+
// The bible-commit branch guard: no G-pull, reset, commit or push on a
|
|
1797
|
+
// maintainer whose checkout is not the sprint branch.
|
|
1798
|
+
checkedOutBranch: (maintainerName) => gitSync.checkedOutBranch(maintainerName),
|
|
1799
|
+
// A bible push must publish only bible commit(s), never a doer's
|
|
1800
|
+
// unpushed commit underneath them.
|
|
1801
|
+
unpushedOnlyBible: (maintainerName, bibleFile) => gitSync.unpushedOnlyBible(maintainerName, bibleFile),
|
|
1802
|
+
// After a kb_bible_commit that committed nothing: does origin hold the
|
|
1803
|
+
// bible, or is an earlier round's bible commit still unpushed?
|
|
1804
|
+
bibleUnpushed: (maintainerName, bibleFile) => gitSync.bibleUnpushed(maintainerName, bibleFile),
|
|
1805
|
+
// Promotion candidates are limited to entries created since the
|
|
1806
|
+
// sprint started -- the sprint state's one start stamp.
|
|
1807
|
+
sprintStartMs: () => sprintState.startedAtMs,
|
|
1808
|
+
// Reviewer demotion loop switch ('on' default, 'off'): sprint arg kb_demotion_loop.
|
|
1809
|
+
demotionLoop: validated.kbDemotionLoop,
|
|
1277
1810
|
log,
|
|
1278
|
-
// Scope every kb_* call below to the member's OWN project KB. The repo
|
|
1279
|
-
// path each call site already threads is a path on the MEMBER's host,
|
|
1280
|
-
// so the server cannot derive a slug from it -- without this lookup a
|
|
1281
|
-
// remote member's reads and writes all land in the shared 'default' KB
|
|
1282
|
-
// (apra-fleet-b4g.15). Resolved through the path rather than passed
|
|
1283
|
-
// per call site so no site can thread the path and forget the scope.
|
|
1284
|
-
// context.kbPriming above is an injection seam; a stub that predates
|
|
1285
|
-
// remoteUrlForPath degrades to no scope rather than crashing a sprint.
|
|
1286
|
-
remoteUrlFor: (repoPath) => (typeof kbPriming.remoteUrlForPath === 'function' ? kbPriming.remoteUrlForPath(repoPath) : null),
|
|
1287
1811
|
});
|
|
1812
|
+
// Stored on the sprint context (like kbMaintainers) so the terminal-abort
|
|
1813
|
+
// handler can seal the bible commit: an aborted sprint commits nothing
|
|
1814
|
+
// further to the bible.
|
|
1815
|
+
context.kbWork = kbWork;
|
|
1816
|
+
// Engine-side KNOWLEDGE BANK injection: skipped for a member whose own
|
|
1817
|
+
// fleet MCP was verified at sprint init (context.isMemberVerified, set by
|
|
1818
|
+
// the init probe above), applied to every other member.
|
|
1819
|
+
if (typeof validated.goal === 'string' && validated.goal.trim() && !isPriorityTierToken(validated.goal.trim())) {
|
|
1820
|
+
kbSprintContext.goals = [validated.goal.trim()];
|
|
1821
|
+
}
|
|
1822
|
+
kbInjection = context.kbInjection ?? createKbInjection({
|
|
1823
|
+
kbWork,
|
|
1824
|
+
isMemberVerified: (name) => (typeof context.isMemberVerified === 'function' ? context.isMemberVerified(name) : false),
|
|
1825
|
+
// Deploy targets: the file paths named in the runbook the role follows
|
|
1826
|
+
// (deploy.md for the deployer, the playbooks for the test runners).
|
|
1827
|
+
deployTargets: async (memberName, role) => {
|
|
1828
|
+
const file = role === 'deployer' ? 'deploy.md'
|
|
1829
|
+
: role === 'integ-test-runner' ? 'integ-test-playbook.md' : 'regression-test-playbook.md';
|
|
1830
|
+
const res = await command(
|
|
1831
|
+
`node -e "try{console.log(require('fs').readFileSync('${file}','utf8').slice(0,20000))}catch(e){}"`,
|
|
1832
|
+
{ member_name: memberName, silent: true, failSoft: true, label: `Read '${file}' for KB hints` },
|
|
1833
|
+
);
|
|
1834
|
+
if (!res || !res.ok) return [];
|
|
1835
|
+
return pathsFromText([String(res.output || '')]);
|
|
1836
|
+
},
|
|
1837
|
+
diffFiles: async (memberName) => {
|
|
1838
|
+
const res = await command(`git diff --name-only origin/${validated.baseBranch}...${validated.branch}`, { member_name: memberName, silent: true, failSoft: true });
|
|
1839
|
+
if (!res || !res.ok) return [];
|
|
1840
|
+
return String(res.output || '').split('\n').map((l) => l.trim()).filter(Boolean);
|
|
1841
|
+
},
|
|
1842
|
+
log,
|
|
1843
|
+
});
|
|
1844
|
+
// Dispatch lifecycle for the KB write queue: a member is busy from the
|
|
1845
|
+
// moment its dispatch bracket opens until it closes, and writes queued for
|
|
1846
|
+
// a repository it maintains are applied when it goes idle. Both hooks are
|
|
1847
|
+
// optional on an injected kbWork stub.
|
|
1848
|
+
kbDispatchHooks = {
|
|
1849
|
+
started: (memberName) => (typeof kbWork.dispatchStarted === 'function' ? kbWork.dispatchStarted(memberName) : undefined),
|
|
1850
|
+
ended: (memberName) => (typeof kbWork.dispatchEnded === 'function' ? kbWork.dispatchEnded(memberName) : undefined),
|
|
1851
|
+
};
|
|
1288
1852
|
// A member named in ANY roleMap value is a "specialist" for whatever
|
|
1289
1853
|
// role(s) named it -- e.g. a member pinned to roleMap.reviewer has been
|
|
1290
1854
|
// deliberately reserved for review. Without this, a role the caller left
|
|
@@ -1301,11 +1865,15 @@ async function runSprintCycle(context) {
|
|
|
1301
1865
|
// whenever roleMap is absent entirely (every member is a generalist).
|
|
1302
1866
|
const roleMapSpecialists = new Set();
|
|
1303
1867
|
if (validated.roleMap) {
|
|
1304
|
-
for (const list of Object.
|
|
1868
|
+
for (const [role, list] of Object.entries(validated.roleMap)) {
|
|
1869
|
+
// kb_maintainer is not a dispatched role: naming a member as its
|
|
1870
|
+
// repository's KB maintainer must not take it out of the
|
|
1871
|
+
// generalist pool for unmapped roles.
|
|
1872
|
+
if (role === ROLE_KB_MAINTAINER) continue;
|
|
1305
1873
|
if (Array.isArray(list)) for (const m of list) roleMapSpecialists.add(m);
|
|
1306
1874
|
}
|
|
1307
1875
|
}
|
|
1308
|
-
// apra-fleet: roleMap.
|
|
1876
|
+
// apra-fleet: roleMap.backlog members are excluded from BOTH the
|
|
1309
1877
|
// generalist pool and its degenerate physicalMembers fallback -- not just
|
|
1310
1878
|
// from the generalist filter -- because the orchestrator role may be a
|
|
1311
1879
|
// shared/unreservable, git-less member (docs/design-orchestrator-
|
|
@@ -1315,13 +1883,13 @@ async function runSprintCycle(context) {
|
|
|
1315
1883
|
// removal and every probeFileExists/publishGitMember fix elsewhere in this
|
|
1316
1884
|
// file: those call getMemberForRole()/getMembersForRole() for roles that
|
|
1317
1885
|
// still expect a real git checkout.
|
|
1318
|
-
const
|
|
1319
|
-
(validated.roleMap && Array.isArray(validated.roleMap[
|
|
1320
|
-
? validated.roleMap[
|
|
1886
|
+
const backlogRoleMapMembers = new Set(
|
|
1887
|
+
(validated.roleMap && Array.isArray(validated.roleMap[ROLE_BACKLOG]))
|
|
1888
|
+
? validated.roleMap[ROLE_BACKLOG]
|
|
1321
1889
|
: []
|
|
1322
1890
|
);
|
|
1323
1891
|
const unmappedRoleFallbackPool = (() => {
|
|
1324
|
-
const eligible = physicalMembers.filter((m) => !
|
|
1892
|
+
const eligible = physicalMembers.filter((m) => !backlogRoleMapMembers.has(m));
|
|
1325
1893
|
const generalists = eligible.filter((m) => !roleMapSpecialists.has(m));
|
|
1326
1894
|
if (generalists.length > 0) return generalists;
|
|
1327
1895
|
if (eligible.length > 0) return eligible;
|
|
@@ -1353,21 +1921,21 @@ async function runSprintCycle(context) {
|
|
|
1353
1921
|
return [unmappedRoleFallbackPool[0]];
|
|
1354
1922
|
};
|
|
1355
1923
|
|
|
1356
|
-
// Uses the canonical
|
|
1924
|
+
// Uses the canonical ROLE_BACKLOG constant, not a literal -- see its
|
|
1357
1925
|
// doc comment for why 'orchestrator' is an application-level pseudo-role
|
|
1358
1926
|
// deliberately outside contracts.ROLES.
|
|
1359
1927
|
//
|
|
1360
|
-
//
|
|
1361
|
-
//
|
|
1362
|
-
//
|
|
1363
|
-
|
|
1364
|
-
|
|
1365
|
-
|
|
1366
|
-
|
|
1367
|
-
|
|
1368
|
-
//
|
|
1369
|
-
//
|
|
1370
|
-
const
|
|
1928
|
+
// An unmapped backlog does NOT fail the launch: the shared selector
|
|
1929
|
+
// (backlog-role.mjs, also used by bin/cli.mjs) auto-selects a member and
|
|
1930
|
+
// the choice is reported loudly below.
|
|
1931
|
+
const backlogSelection = selectBacklogMember({ roleMap: validated.roleMap, members: physicalMembers });
|
|
1932
|
+
const backlogMember = backlogSelection.member;
|
|
1933
|
+
const backlogSelectionLine = formatBacklogSelection(backlogSelection);
|
|
1934
|
+
if (backlogSelectionLine) log(backlogSelectionLine);
|
|
1935
|
+
|
|
1936
|
+
// Deprecated-alias warnings (deprecated orchestrator key -> backlog),
|
|
1937
|
+
// collected by validateArgs() and/or forwarded by bin/cli.mjs.
|
|
1938
|
+
for (const w of (validated.roleMapWarnings || [])) log(`[role-map] WARNING: ${w}`);
|
|
1371
1939
|
|
|
1372
1940
|
// Beads identity precondition: prove which .beads every member's bd
|
|
1373
1941
|
// resolves to BEFORE the first mutating bd command (the earliest bd
|
|
@@ -1377,21 +1945,101 @@ async function runSprintCycle(context) {
|
|
|
1377
1945
|
// absent that, the orchestrator's own identity). A probe that fails or
|
|
1378
1946
|
// resolves nothing is a logged `[beads-identity] WARNING:` (with the
|
|
1379
1947
|
// fix) and that field is left out of the comparison -- only a proven
|
|
1380
|
-
// mismatch is fatal.
|
|
1948
|
+
// mismatch, or bd itself missing on a member, is fatal.
|
|
1381
1949
|
// Sits here rather than next to wrapCommand() above because the
|
|
1382
|
-
//
|
|
1950
|
+
// backlog member is only resolved at this point; nothing between
|
|
1383
1951
|
// the two spots issues a command(). `context.verifyBeadsIdentity` is the
|
|
1384
1952
|
// test-harness seam (same shape as the other injected preconditions);
|
|
1385
1953
|
// there is deliberately no CLI flag to skip it.
|
|
1954
|
+
//
|
|
1955
|
+
// A member that a beads-reading role is dispatched to and that has no
|
|
1956
|
+
// beads database (or no sync.remote while the expectation names one) is
|
|
1957
|
+
// set up HERE, before any dispatch, from the expected beads remote -- its
|
|
1958
|
+
// VCS credential ensured first -- and re-verified; failing that, the
|
|
1959
|
+
// sprint stops with BEADS_SETUP_FAILED. The set-up commands go through
|
|
1960
|
+
// command() above, so noteMemberCommand() sees them.
|
|
1961
|
+
// Member-bound SE command builder per member OS/shell, shared by the two
|
|
1962
|
+
// member preflights below.
|
|
1963
|
+
const memberSeCommands = async (member) => getSeCommands(await resolveMemberTarget({
|
|
1964
|
+
fleetApi: (args && typeof args.callTool === 'function') ? sprintScopedFleetApi({ callTool: args.callTool, log }) : undefined,
|
|
1965
|
+
member,
|
|
1966
|
+
log,
|
|
1967
|
+
}));
|
|
1968
|
+
const beadsSetupMembers = [...new Set([
|
|
1969
|
+
backlogMember,
|
|
1970
|
+
...BEADS_READING_ROLES.flatMap((role) => getMembersForRole(role) || []),
|
|
1971
|
+
])];
|
|
1386
1972
|
await (context.verifyBeadsIdentity ?? verifyBeadsIdentity)({
|
|
1387
1973
|
command,
|
|
1388
1974
|
log,
|
|
1389
1975
|
publishState,
|
|
1390
|
-
|
|
1976
|
+
backlogMember,
|
|
1391
1977
|
members: physicalMembers,
|
|
1392
1978
|
expected: validated.expectBeads ?? null,
|
|
1979
|
+
prober: beadsIdentityProber,
|
|
1980
|
+
setupMembers: beadsSetupMembers,
|
|
1981
|
+
ensureVcsAuth: ensureVcsAuthFresh,
|
|
1982
|
+
// The set-up's beads pull goes through DoltSync with the same
|
|
1983
|
+
// reactive VCS-auth self-heal every D-pull bracket gets.
|
|
1984
|
+
onAuthFailure,
|
|
1985
|
+
// Built per member OS/shell (member_detail via resolveMemberTarget,
|
|
1986
|
+
// which degrades to POSIX and logs when the member cannot be resolved).
|
|
1987
|
+
memberShell: memberSeCommands,
|
|
1393
1988
|
});
|
|
1394
1989
|
|
|
1990
|
+
// Member permission-config preflight: every dispatch member's composed
|
|
1991
|
+
// per-folder config (its provider's permissionConfigPaths, reported by
|
|
1992
|
+
// member_detail) must be in its work folder before any dispatch. A
|
|
1993
|
+
// re-clone / `git clean -xdf` / fresh worktree drops it while member init
|
|
1994
|
+
// still reports OK, and the role's tool calls (bd included) are then
|
|
1995
|
+
// refused as "requires approval". Missing -> one compose_permissions call
|
|
1996
|
+
// for the member's role and a re-probe; still missing or compose failing
|
|
1997
|
+
// -> MemberPermissionConfigError naming member, file and fix. Present
|
|
1998
|
+
// configs are untouched. Same three-way precedence as
|
|
1999
|
+
// ensureDeployPermissions below: an injected
|
|
2000
|
+
// `context.verifyPermissionConfigs` (tests), else the real
|
|
2001
|
+
// compose_permissions-backed check from `args.callTool`, else a no-op when
|
|
2002
|
+
// there is no fleet connection to compose through.
|
|
2003
|
+
const permissionConfigMembers = new Map();
|
|
2004
|
+
for (const role of ROLES) {
|
|
2005
|
+
for (const m of (getMembersForRole(role) || [])) {
|
|
2006
|
+
if (!m) continue;
|
|
2007
|
+
if (!permissionConfigMembers.has(m)) permissionConfigMembers.set(m, []);
|
|
2008
|
+
const roles = permissionConfigMembers.get(m);
|
|
2009
|
+
if (!roles.includes(role)) roles.push(role);
|
|
2010
|
+
}
|
|
2011
|
+
}
|
|
2012
|
+
// Per-member compose_permissions ledger folder (project_folder): grants
|
|
2013
|
+
// the permission heal adds are recorded there, and every proactive compose
|
|
2014
|
+
// of the member passes it, so the next sprint keeps them.
|
|
2015
|
+
const ledgerFolderFor = (m) => permissionLedgerFolder(m, args && args.permissionLedgerDir);
|
|
2016
|
+
const verifyPermissionConfigs = context.verifyPermissionConfigs ?? (
|
|
2017
|
+
(args && typeof args.callTool === 'function')
|
|
2018
|
+
? createPermissionConfigPreflight({ callTool: args.callTool, command, log, memberShell: memberSeCommands, ledgerFolderFor })
|
|
2019
|
+
: async () => ({ composed: [] })
|
|
2020
|
+
);
|
|
2021
|
+
await verifyPermissionConfigs(permissionConfigMembers);
|
|
2022
|
+
|
|
2023
|
+
// Mid-sprint counterpart of the preflight above: a dispatch whose member
|
|
2024
|
+
// CLI refused tool calls for lack of a grant (execute_prompt reason
|
|
2025
|
+
// 'permission_denied') is healed PROGRESSIVELY by the dispatch engine
|
|
2026
|
+
// through this hook -- each refusal gets the missing grant within the
|
|
2027
|
+
// member's composed policy and a retry, until no progress is possible;
|
|
2028
|
+
// see createPermissionDenialHeal. Same precedence: an injected
|
|
2029
|
+
// `context.onPermissionDenied` (tests), else the real compose_permissions
|
|
2030
|
+
// heal from `args.callTool`, else none (the engine then fails the sprint
|
|
2031
|
+
// on the first refusal, naming member, actions and fix).
|
|
2032
|
+
const onPermissionDenied = context.onPermissionDenied ?? (
|
|
2033
|
+
(args && typeof args.callTool === 'function')
|
|
2034
|
+
? createPermissionDenialHeal({
|
|
2035
|
+
callTool: args.callTool,
|
|
2036
|
+
log,
|
|
2037
|
+
memberRoles: (m) => permissionConfigMembers.get(m) || [],
|
|
2038
|
+
ledgerFolderFor,
|
|
2039
|
+
})
|
|
2040
|
+
: undefined
|
|
2041
|
+
);
|
|
2042
|
+
|
|
1395
2043
|
// Self-heals deploy.md's declared Permissions onto the deployer /
|
|
1396
2044
|
// integ-test-runner / regression-test-runner member before each of
|
|
1397
2045
|
// those dispatches -- see createDeployPermissionsProvisioner's doc
|
|
@@ -1427,7 +2075,12 @@ async function runSprintCycle(context) {
|
|
|
1427
2075
|
});
|
|
1428
2076
|
// Local alias so this file's dispatch brackets keep their existing shape:
|
|
1429
2077
|
// withGitSync member, pushCode, dispatch thunk, options.
|
|
1430
|
-
|
|
2078
|
+
// The KB write queue sees the whole bracket (G-pull, dispatch, G-push) as
|
|
2079
|
+
// the member being busy -- see kbDispatchHooks.
|
|
2080
|
+
const withGitSync = (member, pushCode, dispatchFn, options) => withKbDispatchLifecycle(
|
|
2081
|
+
member,
|
|
2082
|
+
() => gitSync.withGitSync(member, pushCode, dispatchFn, options),
|
|
2083
|
+
);
|
|
1431
2084
|
|
|
1432
2085
|
// --- usage-limit pause/resume controller (apra-fleet-hzeb.4.2) -----------
|
|
1433
2086
|
// The budgets the controller reads: role-policies.mjs's frozen defaults,
|
|
@@ -1453,6 +2106,50 @@ async function runSprintCycle(context) {
|
|
|
1453
2106
|
})
|
|
1454
2107
|
: undefined;
|
|
1455
2108
|
|
|
2109
|
+
// NEEDS-DECISION wait (./decision-wait.mjs): when the run would stall
|
|
2110
|
+
// with a decision still pending, it parks once through the same
|
|
2111
|
+
// cooperative pause instead of throwing StalledSprintError (members stay
|
|
2112
|
+
// reserved and idle) and resumes once an answer is available. Only wired with the engine's pause/resume
|
|
2113
|
+
// primitives (absent for direct/legacy runSprintCycle() callers, which
|
|
2114
|
+
// keep the stall). recordDecisionAnswer is exposed on sprintState for an
|
|
2115
|
+
// in-process answer route.
|
|
2116
|
+
const decisionWait = (typeof requestPause === 'function' && typeof requestResume === 'function')
|
|
2117
|
+
? createDecisionWait({
|
|
2118
|
+
sprintState,
|
|
2119
|
+
requestPause,
|
|
2120
|
+
requestResume,
|
|
2121
|
+
command,
|
|
2122
|
+
member: backlogMember,
|
|
2123
|
+
pullBeads: (m) => gitSync.syncBeadsBefore(m),
|
|
2124
|
+
pushBeads: (m) => gitSync.syncBeadsAfter(m, { pushBeads: true }),
|
|
2125
|
+
publishState: typeof publishState === 'function' ? publishState : undefined,
|
|
2126
|
+
log,
|
|
2127
|
+
...(stopSignal ? { stopSignal } : {}),
|
|
2128
|
+
})
|
|
2129
|
+
: null;
|
|
2130
|
+
if (decisionWait) sprintState.recordDecisionAnswer = decisionWait.recordDecisionAnswer;
|
|
2131
|
+
// Operator notification (message + email, once per decision, never fatal).
|
|
2132
|
+
// Targets are resolved ONCE here at launch (default message target: the
|
|
2133
|
+
// operator's orchestrating session); a channel with no target is logged
|
|
2134
|
+
// once now, not once per decision.
|
|
2135
|
+
// The message target is also checked once here (a read-only probe):
|
|
2136
|
+
// when no channel-capable session holds it, one launch line names the
|
|
2137
|
+
// remedy and later decisions log one short line each.
|
|
2138
|
+
const notifyFleetApi = (args && typeof args.callTool === 'function') ? sprintScopedFleetApi({ callTool: args.callTool, log }) : null;
|
|
2139
|
+
const notifyConfig = await prepareDecisionNotify({ config: validated.decisionNotify, fleetApi: notifyFleetApi, log });
|
|
2140
|
+
sprintState.notifyDecision = async (record) => {
|
|
2141
|
+
// Publish first (the banner shows the decision at once), notify, then
|
|
2142
|
+
// publish again so the per-channel outcome shows.
|
|
2143
|
+
if (decisionWait) decisionWait.publish();
|
|
2144
|
+
await notifyDecision({
|
|
2145
|
+
decision: record,
|
|
2146
|
+
config: notifyConfig,
|
|
2147
|
+
fleetApi: notifyFleetApi,
|
|
2148
|
+
log,
|
|
2149
|
+
});
|
|
2150
|
+
if (decisionWait) decisionWait.publish();
|
|
2151
|
+
};
|
|
2152
|
+
|
|
1456
2153
|
// --- dispatchRole engine context (apra-fleet-3swo.5.3) -------------------
|
|
1457
2154
|
// Every runner-side primitive fleet-sprint/dispatch-role.mjs needs to run
|
|
1458
2155
|
// a role's ladder out of role-policies.mjs's data table. INJECTED, never
|
|
@@ -1476,6 +2173,8 @@ async function runSprintCycle(context) {
|
|
|
1476
2173
|
// apra-fleet-hzeb.4.2: the usage-limit pause/resume/re-probe hook the
|
|
1477
2174
|
// engine arms for a role whose retry.usageLimitPause is set.
|
|
1478
2175
|
onUsageLimit,
|
|
2176
|
+
// The one bounded heal for a 'permission_denied' dispatch.
|
|
2177
|
+
onPermissionDenied,
|
|
1479
2178
|
fixedRoleTier: FIXED_ROLE_TIER,
|
|
1480
2179
|
budgets: {
|
|
1481
2180
|
DISPATCH_TIMEOUT_S,
|
|
@@ -1508,7 +2207,10 @@ async function runSprintCycle(context) {
|
|
|
1508
2207
|
// one implementation serves the harvester, the doer, the per-round
|
|
1509
2208
|
// reviewer and the final review alike.
|
|
1510
2209
|
'kb-apply': async ({ policy, value, member }) => {
|
|
1511
|
-
|
|
2210
|
+
// `member` is the member the engine dispatched: it names the
|
|
2211
|
+
// repository the writes belong to, and kbWork routes them to
|
|
2212
|
+
// that repository's kb_maintainer.
|
|
2213
|
+
await kbWork.apply(policy.agentType, member, value);
|
|
1512
2214
|
},
|
|
1513
2215
|
// deploy.md's active-sprints gate stops for a FOREIGN reservation,
|
|
1514
2216
|
// so a deployer prompt that does not state this sprint's OWN
|
|
@@ -1625,84 +2327,244 @@ async function runSprintCycle(context) {
|
|
|
1625
2327
|
return ready.filter((b) => !parentIds.has(b.id));
|
|
1626
2328
|
}
|
|
1627
2329
|
|
|
1628
|
-
//
|
|
1629
|
-
//
|
|
1630
|
-
//
|
|
1631
|
-
//
|
|
1632
|
-
|
|
1633
|
-
|
|
1634
|
-
//
|
|
1635
|
-
//
|
|
1636
|
-
//
|
|
1637
|
-
//
|
|
2330
|
+
// Bead ids the PRE-LAUNCH rule (reclaimStaleInProgress below) must never
|
|
2331
|
+
// touch again this run: every id it has already reclaimed, and every id a
|
|
2332
|
+
// doer of this run was dispatched on (added after each Develop round).
|
|
2333
|
+
// From then on any claim of that bead is this run's own (or a later
|
|
2334
|
+
// actor's), and only the in-run tracker (reclaimInRunOrphanedClaims) may
|
|
2335
|
+
// re-lane it, under its own rules (claimed-elsewhere, completed work, its
|
|
2336
|
+
// re-dispatch cap). started_at cannot draw that line: bd keeps a bead's
|
|
2337
|
+
// FIRST claim stamp on every re-claim, so this run's own claim of a bead
|
|
2338
|
+
// that was stale at launch still reads as predating the launch. Also
|
|
2339
|
+
// bounds the pre-launch rule to one reclaim per bead per sprint.
|
|
2340
|
+
const preLaunchSettledIds = new Set();
|
|
2341
|
+
// Read once, on the FIRST call to reclaimStaleInProgress (the pre-sprint
|
|
2342
|
+
// one), from the sprint state's start stamp (createSprintState) -- the
|
|
2343
|
+
// same instant the KB promotion-candidate window starts at, so the sprint
|
|
2344
|
+
// has one start time, not two. Declared here (not at the capture site) so its
|
|
1638
2345
|
// TDZ covers every call to reclaimStaleInProgress, including the
|
|
1639
2346
|
// pre-sprint one.
|
|
1640
2347
|
let sprintLaunchTime = null;
|
|
1641
2348
|
|
|
1642
2349
|
/**
|
|
1643
2350
|
* Reclaims 'in_progress' beads that are safe to redispatch to 'open':
|
|
1644
|
-
* no unmet `blocks` dependencies (nothing left to wait on)
|
|
1645
|
-
* BEFORE this sprint incarnation's own launch time
|
|
1646
|
-
*
|
|
1647
|
-
*
|
|
1648
|
-
*
|
|
1649
|
-
*
|
|
1650
|
-
*
|
|
1651
|
-
*
|
|
2351
|
+
* no unmet `blocks` dependencies (nothing left to wait on), claimed
|
|
2352
|
+
* BEFORE this sprint incarnation's own launch time, and not in
|
|
2353
|
+
* preLaunchSettledIds (never reclaimed or dispatched by this run). So this
|
|
2354
|
+
* sprint's own work is never touched here -- a claim a failed doer of
|
|
2355
|
+
* THIS run left behind is reclaimed separately, by
|
|
2356
|
+
* reclaimInRunOrphanedClaims -- and each bead is reclaimed by this rule
|
|
2357
|
+
* at most once per sprint. A bead with no parseable `started_at` is
|
|
2358
|
+
* treated as predating this sprint (`bd update --claim` stamps
|
|
2359
|
+
* `started_at` on a first claim, so an absent value can only mean
|
|
2360
|
+
* orphaned state from something else, e.g. a bare `--status
|
|
2361
|
+
* in_progress`).
|
|
2362
|
+
*
|
|
2363
|
+
* THE WRITE. `bd update <id> --status open --assignee= --force
|
|
2364
|
+
* --if-status in_progress`, the same write reclaimInRunOrphanedClaims
|
|
2365
|
+
* uses: the stale assignee is cleared because a different actor's `bd
|
|
2366
|
+
* update --claim` refuses a bead another actor still holds (`--force` is
|
|
2367
|
+
* bd's documented override for that abandoned-claim case), and
|
|
2368
|
+
* `--if-status in_progress` makes bd refuse the write if the bead
|
|
2369
|
+
* changed since it was read (logged, left as is).
|
|
2370
|
+
*
|
|
2371
|
+
* `freshRead`: set when `notDoneBeads` came from the cached snapshot,
|
|
2372
|
+
* which can lag a cycle behind agent-made closes. The candidates are then
|
|
2373
|
+
* re-read with `bd show`, and only those a fresh read still shows
|
|
2374
|
+
* in_progress under the same assignee are written. Callers passing a
|
|
2375
|
+
* fresh `bd list` need no second read.
|
|
1652
2376
|
*
|
|
1653
|
-
*
|
|
1654
|
-
*
|
|
1655
|
-
*
|
|
1656
|
-
*
|
|
1657
|
-
* surfaced as needing human investigation instead -- the same
|
|
1658
|
-
* bounce-cap precedent already used for the verify-route gap counter
|
|
1659
|
-
* (VERIFY_GAP_LIMIT) elsewhere in this file, applied to this failure
|
|
1660
|
-
* mode.
|
|
2377
|
+
* Call sites: pre-sprint ONCE whether or not other work is ready (a stale
|
|
2378
|
+
* claim hides its whole `blocks` chain from `bd ready` even while
|
|
2379
|
+
* unrelated work is ready -- see the pre-sprint stale-claim check), and
|
|
2380
|
+
* per cycle only when the ready set is otherwise empty.
|
|
1661
2381
|
*
|
|
1662
|
-
*
|
|
1663
|
-
*
|
|
1664
|
-
*
|
|
1665
|
-
* a
|
|
1666
|
-
*
|
|
1667
|
-
*
|
|
1668
|
-
*
|
|
1669
|
-
*
|
|
1670
|
-
*
|
|
1671
|
-
*
|
|
1672
|
-
*
|
|
1673
|
-
*
|
|
2382
|
+
* KNOWN LIMIT -- this rule cannot tell an abandoned claim from a live one.
|
|
2383
|
+
* "Claimed before this launch" is all it knows. A bead's assignee is a bd
|
|
2384
|
+
* actor name, and the engine has no map from an actor to a live sprint
|
|
2385
|
+
* or a working human (member reservations are keyed by member, not by bd
|
|
2386
|
+
* actor), so no liveness gate is possible here. Specifically, it WILL
|
|
2387
|
+
* reopen and clear the assignee of: (a) a claim held by an
|
|
2388
|
+
* earlier-launched sprint that is still running, if that bead is inside
|
|
2389
|
+
* this sprint's scope -- only the supervisor's issue-scope overlap guard
|
|
2390
|
+
* prevents that, so two sprints launched directly from the CLI over
|
|
2391
|
+
* overlapping scope (bypassing the supervisor) can both work such a bead;
|
|
2392
|
+
* (b) a bead a human claimed before the launch and is still working.
|
|
2393
|
+
* Because the pre-sprint call is unconditional, this applies to every
|
|
2394
|
+
* launch, not only one with nothing ready. Each such bead is reclaimed at
|
|
2395
|
+
* most once per sprint (preLaunchSettledIds) and every reclaim is logged
|
|
2396
|
+
* with the bead id.
|
|
2397
|
+
*
|
|
2398
|
+
* Each reclaim log names the downstream beads (its `blocks` dependents)
|
|
2399
|
+
* the reclaim puts back on the path to ready.
|
|
2400
|
+
* @param {{ notDoneBeads: object[], reasonTag: string, freshRead?: boolean }} opts
|
|
2401
|
+
* @returns {Promise<{ reclaimedIds: string[] }>}
|
|
1674
2402
|
*/
|
|
1675
|
-
async function reclaimStaleInProgress({ notDoneBeads, reasonTag }) {
|
|
1676
|
-
if (sprintLaunchTime === null) sprintLaunchTime =
|
|
2403
|
+
async function reclaimStaleInProgress({ notDoneBeads, reasonTag, freshRead = false }) {
|
|
2404
|
+
if (sprintLaunchTime === null) sprintLaunchTime = sprintState.startedAtMs;
|
|
1677
2405
|
const notDoneIds = new Set(notDoneBeads.map((b) => b.id));
|
|
1678
|
-
|
|
1679
|
-
|
|
1680
|
-
|
|
1681
|
-
|
|
1682
|
-
const candidates = notDoneBeads.filter((b) => {
|
|
1683
|
-
if (b.status !== 'in_progress') return false;
|
|
1684
|
-
if (unmetBlockers(b).length > 0) return false;
|
|
1685
|
-
const startedAtMs = b.started_at ? Date.parse(b.started_at) : NaN;
|
|
1686
|
-
return Number.isNaN(startedAtMs) || startedAtMs < sprintLaunchTime;
|
|
1687
|
-
});
|
|
2406
|
+
let candidates = notDoneBeads.filter((b) => isPreLaunchReclaimCandidate(b, {
|
|
2407
|
+
notDoneIds, sprintLaunchTime, settledIds: preLaunchSettledIds,
|
|
2408
|
+
}));
|
|
1688
2409
|
|
|
1689
2410
|
const reclaimedIds = [];
|
|
1690
|
-
|
|
2411
|
+
if (candidates.length === 0) return { reclaimedIds };
|
|
2412
|
+
|
|
2413
|
+
if (freshRead) {
|
|
2414
|
+
const ids = candidates.map((b) => b.id);
|
|
2415
|
+
const showLabel = `bd show ${ids.join(' ')} --json`;
|
|
2416
|
+
const fresh = parseBdJson(await command(showLabel, { member_name: backlogMember, silent: true }), showLabel);
|
|
2417
|
+
const { confirmed, rejected } = confirmPreLaunchCandidates(candidates, fresh);
|
|
2418
|
+
for (const r of rejected) {
|
|
2419
|
+
log(`${reasonTag}: ${r.id} looked stuck 'in_progress' with a pre-launch claim in the cached snapshot, but ${r.reason} -- not reclaiming it.`);
|
|
2420
|
+
}
|
|
2421
|
+
candidates = confirmed;
|
|
2422
|
+
}
|
|
2423
|
+
|
|
1691
2424
|
for (const bead of candidates) {
|
|
1692
|
-
|
|
1693
|
-
|
|
1694
|
-
|
|
2425
|
+
try {
|
|
2426
|
+
await command(`bd update ${bead.id} --status open --assignee= --force --if-status in_progress`, { member_name: backlogMember, silent: true });
|
|
2427
|
+
} catch (err) {
|
|
2428
|
+
log(`${reasonTag}: reclaiming ${bead.id} was refused (${err.message}) -- leaving it as it is.`);
|
|
1695
2429
|
continue;
|
|
1696
2430
|
}
|
|
1697
|
-
|
|
1698
|
-
log(`${reasonTag}: ${bead.id} is stuck 'in_progress' (started_at=${bead.started_at || 'n/a'}) with no unmet blockers and predates this sprint's launch --
|
|
1699
|
-
await command(`bd update ${bead.id} --status open`, { member_name: orchestratorMember, silent: true });
|
|
2431
|
+
preLaunchSettledIds.add(bead.id);
|
|
2432
|
+
log(`${reasonTag}: ${bead.id} is stuck 'in_progress' (started_at=${bead.started_at || 'n/a'}, assignee=${bead.assignee || 'none'}) with no unmet blockers and predates this sprint's launch -- ${freshRead ? 'confirmed by a fresh read and ' : ''}reclaimed to 'open' with its assignee cleared so the sprint can dispatch it (once per sprint; any later claim of it is this run's own).${downstreamSuffix(notDoneBeads, bead.id)}`);
|
|
1700
2433
|
reclaimedIds.push(bead.id);
|
|
1701
2434
|
}
|
|
1702
|
-
|
|
1703
|
-
|
|
2435
|
+
return { reclaimedIds };
|
|
2436
|
+
}
|
|
2437
|
+
|
|
2438
|
+
/**
|
|
2439
|
+
* GitHub #715: re-lanes beads a failed doer of THIS run left
|
|
2440
|
+
* 'in_progress'. reclaimStaleInProgress() above cannot: it only reclaims
|
|
2441
|
+
* claims older than the sprint launch, so a doer of this run that claimed
|
|
2442
|
+
* a bead and then died, exhausted its resumes or returned BLOCKED left the
|
|
2443
|
+
* bead -- and its whole `blocks` chain -- hidden from `bd ready` for the
|
|
2444
|
+
* rest of the sprint, which then ended FAIL through the stall net.
|
|
2445
|
+
*
|
|
2446
|
+
* Called at the top of every cycle, before Plan. Costs NOTHING on the
|
|
2447
|
+
* common path: with no failed doer dispatch on record it returns before
|
|
2448
|
+
* any bd call. Otherwise, per candidate (./orphan-reclaim.mjs decides who
|
|
2449
|
+
* is one, from each bead's latest streak outcome):
|
|
2450
|
+
*
|
|
2451
|
+
* 1. FRESH READ. The cached snapshot only pre-filters; it can lag a full
|
|
2452
|
+
* cycle (see beads-scope.mjs), so it never authorizes a write. The
|
|
2453
|
+
* orchestrator's beads clone is D-pulled (a remote doer closes in its
|
|
2454
|
+
* OWN clone) and the candidates are re-read with `bd show`. Only a
|
|
2455
|
+
* bead that is STILL in_progress proceeds; one found closed is
|
|
2456
|
+
* dropped from the record and never reopened.
|
|
2457
|
+
* 2. LIVENESS. A returned dispatch does not prove the doer session is
|
|
2458
|
+
* dead (a stalled-but-alive session can outlive its dispatch), so the
|
|
2459
|
+
* failed streak's doer session is STOPPED (memberSessionGuard
|
|
2460
|
+
* .killIfAlive) before its bead is re-laned. Chosen over skipping
|
|
2461
|
+
* reclaim for may-still-be-running failures: skipping would leave
|
|
2462
|
+
* exactly those beads stuck, which is the bug.
|
|
2463
|
+
* 3. GUARDED WRITE. `--if-status in_progress` makes the write itself
|
|
2464
|
+
* refuse a bead that closed after the fresh read (bd exits non-zero,
|
|
2465
|
+
* logged, nothing changes). The stale assignee is cleared because a
|
|
2466
|
+
* different doer's `bd update --claim` refuses a bead another actor
|
|
2467
|
+
* still holds; `--force` is bd's documented override for exactly this
|
|
2468
|
+
* abandoned-claim case.
|
|
2469
|
+
*
|
|
2470
|
+
* Claims another sprint holds are identified by the structured
|
|
2471
|
+
* all-beads-already-claimed failure reason on the streak outcome and are
|
|
2472
|
+
* never touched. A reclaimed id leaves the record and only returns when a
|
|
2473
|
+
* doer of this run is dispatched on it again, so a later claim of the same
|
|
2474
|
+
* bead by another actor is never reset. NOT a concurrency guarantee: with
|
|
2475
|
+
* no engine-side claim (no assignee configured) a concurrent sprint that
|
|
2476
|
+
* claimed the bead between this sprint's ready read and its own doer's
|
|
2477
|
+
* claim is indistinguishable from this run's doer here; as for the
|
|
2478
|
+
* pre-launch rule, only the supervisor's issue-scope overlap guard keeps
|
|
2479
|
+
* two sprints off the same beads. Each bead is re-laned at most
|
|
2480
|
+
* ORPHAN_RECLAIM_LIMIT times; a bead past the cap stays in_progress and is
|
|
2481
|
+
* named in the final sprint notes.
|
|
2482
|
+
*
|
|
2483
|
+
* Introduces no launch timestamp of its own: in-run orphans are found by
|
|
2484
|
+
* this run's own dispatch record, and the sprint keeps the single launch
|
|
2485
|
+
* time sprintState.startedAtMs (read only by reclaimStaleInProgress).
|
|
2486
|
+
* @param {{ reasonTag: string }} opts
|
|
2487
|
+
* @returns {Promise<string[]>} the reclaimed bead ids
|
|
2488
|
+
*/
|
|
2489
|
+
async function reclaimInRunOrphanedClaims({ reasonTag }) {
|
|
2490
|
+
if (!orphanClaims.hasFailed()) return [];
|
|
2491
|
+
const snapshotBeads = await fetchAllBeadsShared();
|
|
2492
|
+
const { candidates, newlyCappedIds } = orphanClaims.candidates(snapshotBeads);
|
|
2493
|
+
if (newlyCappedIds.length > 0) {
|
|
2494
|
+
log(`${reasonTag}: ${newlyCappedIds.length} bead(s) a failed doer of this run left 'in_progress' already hit the re-dispatch cap (limit ${orphanClaims.limit}) and are left as they are -- needs human investigation: ${newlyCappedIds.join(', ')}.`);
|
|
2495
|
+
}
|
|
2496
|
+
if (candidates.length === 0) return [];
|
|
2497
|
+
|
|
2498
|
+
const settleShell = await resolveSettleShell({ args, member: backlogMember, log, sprintState });
|
|
2499
|
+
await gitSync.syncBeadsBefore(backlogMember, { fatal: true, settle: buildSettleCallback(backlogMember, { command, log, shell: settleShell }) });
|
|
2500
|
+
const ids = candidates.map((c) => c.id);
|
|
2501
|
+
const showLabel = `bd show ${ids.join(' ')} --json`;
|
|
2502
|
+
const fresh = parseBdJson(await command(showLabel, { member_name: backlogMember, silent: true }), showLabel);
|
|
2503
|
+
const freshStatusById = new Map((Array.isArray(fresh) ? fresh : []).map((b) => [b.id, b.status]));
|
|
2504
|
+
|
|
2505
|
+
const confirmed = [];
|
|
2506
|
+
for (const c of candidates) {
|
|
2507
|
+
const status = freshStatusById.get(c.id);
|
|
2508
|
+
if (status === 'in_progress') {
|
|
2509
|
+
confirmed.push(c);
|
|
2510
|
+
continue;
|
|
2511
|
+
}
|
|
2512
|
+
if (status === 'closed') orphanClaims.forget(c.id);
|
|
2513
|
+
log(`${reasonTag}: ${c.id} looked orphaned 'in_progress' in the cached snapshot but a fresh read shows '${status || 'unknown'}' -- not reclaiming it.`);
|
|
2514
|
+
}
|
|
2515
|
+
if (confirmed.length === 0) return [];
|
|
2516
|
+
|
|
2517
|
+
const doerMembers = [...new Set(confirmed.map((c) => c.doerMember).filter(Boolean))];
|
|
2518
|
+
for (const member of doerMembers) {
|
|
2519
|
+
log(`${reasonTag}: stopping any still-running session on doer member '${member}' before re-laning the bead(s) its failed streak left 'in_progress'.`);
|
|
2520
|
+
await memberSessionGuard.killIfAlive(member);
|
|
2521
|
+
}
|
|
2522
|
+
|
|
2523
|
+
const reclaimedIds = [];
|
|
2524
|
+
for (const c of confirmed) {
|
|
2525
|
+
try {
|
|
2526
|
+
await command(`bd update ${c.id} --status open --assignee= --force --if-status in_progress`, { member_name: backlogMember, silent: true });
|
|
2527
|
+
} catch (err) {
|
|
2528
|
+
log(`${reasonTag}: re-laning ${c.id} was refused (${err.message}) -- leaving it as it is.`);
|
|
2529
|
+
continue;
|
|
2530
|
+
}
|
|
2531
|
+
const attempt = orphanClaims.markReclaimed(c.id);
|
|
2532
|
+
log(`${reasonTag}: ${c.id} was left 'in_progress' by a failed doer streak of this run (member '${c.doerMember || 'unknown'}') -- confirmed by a fresh read and reclaimed to 'open' so it is dispatched again this sprint (attempt ${attempt}/${orphanClaims.limit}).${downstreamSuffix(snapshotBeads, c.id)}`);
|
|
2533
|
+
reclaimedIds.push(c.id);
|
|
1704
2534
|
}
|
|
1705
|
-
return
|
|
2535
|
+
return reclaimedIds;
|
|
2536
|
+
}
|
|
2537
|
+
|
|
2538
|
+
/**
|
|
2539
|
+
* The review diff base SHA for `member` (see resolveReviewMergeBase in
|
|
2540
|
+
* git-topology.mjs). Shared by the per-round reviewer and Final Review.
|
|
2541
|
+
* @param {string} member
|
|
2542
|
+
* @returns {Promise<string>}
|
|
2543
|
+
*/
|
|
2544
|
+
function reviewMergeBaseFor(member) {
|
|
2545
|
+
return resolveReviewMergeBase({
|
|
2546
|
+
command, member, baseBranch: validated.baseBranch, branch: validated.branch,
|
|
2547
|
+
log, onAuthFailure, resolveMemberProvider: resolveMemberVcsProvider,
|
|
2548
|
+
});
|
|
2549
|
+
}
|
|
2550
|
+
|
|
2551
|
+
/**
|
|
2552
|
+
* The degraded verdict for a review round whose diff base could not be
|
|
2553
|
+
* computed: the reviewer policy's own synthesized-verdict degrade (same
|
|
2554
|
+
* shape, note template, dispatchFailed marker and clear-round-session
|
|
2555
|
+
* step), applied without dispatching the reviewer.
|
|
2556
|
+
* @param {Error} err
|
|
2557
|
+
*/
|
|
2558
|
+
function degradedReviewForReviewBase(err) {
|
|
2559
|
+
const reviewerPolicy = policyFor('reviewer');
|
|
2560
|
+
const d = reviewerPolicy.degrade;
|
|
2561
|
+
roundSessions.clear(reviewerPolicy.ladder);
|
|
2562
|
+
log(
|
|
2563
|
+
`Reviewer: review diff base failed, degrading (${d.kind}) -- the reviewer was NOT dispatched this round ` +
|
|
2564
|
+
`and no fallback to the local '${validated.baseBranch}' branch was used: ${err.message}`
|
|
2565
|
+
);
|
|
2566
|
+
const note = d.noteTemplates.dispatch.replace(/\{(message|name)\}/g, (_, f) => (f === 'name' ? err.name : err.message));
|
|
2567
|
+
return { ...d.synthesized, [d.notesField]: note, ...(d.marker ? { [d.marker]: true } : {}) };
|
|
1706
2568
|
}
|
|
1707
2569
|
|
|
1708
2570
|
/**
|
|
@@ -1719,25 +2581,56 @@ async function runSprintCycle(context) {
|
|
|
1719
2581
|
*/
|
|
1720
2582
|
async function dispatchReview({ beadIds, acceptanceCriteriaJson }) {
|
|
1721
2583
|
const reviewerPool = getMembersForRole(ROLE_REVIEWER);
|
|
2584
|
+
// The diff range the reviewer is told to use: the fork point of the
|
|
2585
|
+
// sprint branch from a freshly fetched origin/<base>, computed on the
|
|
2586
|
+
// reviewer's own member. Throws (fails the review loudly) rather than
|
|
2587
|
+
// ever falling back to the member's possibly stale local base branch.
|
|
2588
|
+
//
|
|
2589
|
+
// A GitSyncError here (fetch/merge-base failed after runGitStep's own
|
|
2590
|
+
// retry and auth self-heal) degrades the ROUND exactly like the
|
|
2591
|
+
// reviewer ladder's own read-side sync failure does: the reviewer is
|
|
2592
|
+
// NOT dispatched (never with a wrong range), the round is recorded as a
|
|
2593
|
+
// synthesized CHANGES_NEEDED marked dispatchFailed (counts toward the
|
|
2594
|
+
// stall budget, not a contract violation), and its session is not
|
|
2595
|
+
// resumed by the next round. Anything else still propagates.
|
|
2596
|
+
let mergeBaseSha;
|
|
2597
|
+
try {
|
|
2598
|
+
mergeBaseSha = await reviewMergeBaseFor(reviewerPool[0]);
|
|
2599
|
+
} catch (err) {
|
|
2600
|
+
if (!(err instanceof GitSyncError)) throw err;
|
|
2601
|
+
return degradedReviewForReviewBase(err);
|
|
2602
|
+
}
|
|
1722
2603
|
// apra-fleet-0ef: fetch the INFERRED entries this reviewer may promote
|
|
1723
2604
|
// and hand them to it in the prompt. The reviewer has no MCP kb_* tools
|
|
1724
2605
|
// of its own, so without this it can never name an entry id and
|
|
1725
2606
|
// `kb_promotions` comes back empty every round -- which is exactly why
|
|
1726
|
-
// kb_promote had never once fired.
|
|
1727
|
-
//
|
|
1728
|
-
//
|
|
1729
|
-
|
|
1730
|
-
const kbCandidates = await kbWork.promotionCandidates(
|
|
2607
|
+
// kb_promote had never once fired. Read from the reviewer's
|
|
2608
|
+
// repository kb_maintainer -- the session every KB write is routed to,
|
|
2609
|
+
// so the one holding this sprint's captures -- and best-effort: a
|
|
2610
|
+
// cold KB must not fail the review.
|
|
2611
|
+
const kbCandidates = await kbWork.promotionCandidates(reviewerPool[0]);
|
|
1731
2612
|
if (kbCandidates.length > 0) {
|
|
1732
2613
|
log(`[kb-work] offering ${kbCandidates.length} INFERRED entr(ies) to the reviewer for promotion.`);
|
|
1733
2614
|
}
|
|
2615
|
+
// The CONFIRMED entries this reviewer may demote
|
|
2616
|
+
// back to INFERRED, scoped to the files THIS round's diff actually
|
|
2617
|
+
// touched (see createKbWorkClient's roundChangedFiles wiring above).
|
|
2618
|
+
// Best-effort exactly like promotionCandidates: a cold or unreachable
|
|
2619
|
+
// KB, or a round diff that could not be computed, must not fail the
|
|
2620
|
+
// review.
|
|
2621
|
+
const kbDemoteCandidates = await kbWork.demotionCandidates(reviewerPool[0], { scope: 'round' });
|
|
2622
|
+
if (kbDemoteCandidates.length > 0) {
|
|
2623
|
+
log(`[kb-work] offering ${kbDemoteCandidates.length} CONFIRMED entr(ies) to the reviewer for demotion.`);
|
|
2624
|
+
}
|
|
1734
2625
|
// What the KB knows about the beads UNDER REVIEW, not just whatever the
|
|
1735
2626
|
// sprint-start prime happened to surface. Falls back to the primed set
|
|
1736
2627
|
// when the query returns nothing (a KB with no matching rows yet).
|
|
1737
|
-
const
|
|
1738
|
-
|
|
1739
|
-
|
|
1740
|
-
:
|
|
2628
|
+
const reviewerKbBlock = await kbInjection.blockFor({
|
|
2629
|
+
role: ROLE_REVIEWER,
|
|
2630
|
+
member: reviewerPool[0],
|
|
2631
|
+
context: { ...kbSprintContext, beadIds, beadTitles: kbBeadTitles(beadIds) },
|
|
2632
|
+
captureChannel: true,
|
|
2633
|
+
});
|
|
1741
2634
|
// A full-cycle review can genuinely exhaust the fleet's default turn
|
|
1742
2635
|
// budget, and a fresh retry deterministically hits the same wall. Make
|
|
1743
2636
|
// the budget explicit and, on max_turns exhaustion, RESUME the same
|
|
@@ -1773,9 +2666,11 @@ async function runSprintCycle(context) {
|
|
|
1773
2666
|
acceptanceCriteriaJson,
|
|
1774
2667
|
baseBranch: validated.baseBranch,
|
|
1775
2668
|
branch: validated.branch,
|
|
2669
|
+
mergeBaseSha,
|
|
1776
2670
|
goal: validated.goal,
|
|
1777
2671
|
kbCandidates,
|
|
1778
|
-
|
|
2672
|
+
kbDemoteCandidates,
|
|
2673
|
+
kbBlock: reviewerKbBlock,
|
|
1779
2674
|
}),
|
|
1780
2675
|
// Restate the review scope: a resumed dispatch replaces the
|
|
1781
2676
|
// delivered prompt artifact, so the scope must be repeated inline.
|
|
@@ -1788,7 +2683,7 @@ async function runSprintCycle(context) {
|
|
|
1788
2683
|
+ (Array.isArray(beadIds) && beadIds.length > 0
|
|
1789
2684
|
? `bead id(s) under review ${beadIds.join(', ')} `
|
|
1790
2685
|
: `the entire sprint scope (no individual bead ids -- you are judging whether the sprint as a whole is complete) `)
|
|
1791
|
-
+ `on branch ${validated.branch}
|
|
2686
|
+
+ `on branch ${validated.branch}, diff range ${mergeBaseSha}..${validated.branch} (use exactly this range for git diff and git log). ` +
|
|
1792
2687
|
'Finish evaluating the remaining acceptance criteria and return your final verdict now.',
|
|
1793
2688
|
roleLabel: 'Reviewer',
|
|
1794
2689
|
resumeLabel: `Review (resume, max_turns=${TURN_BASES.BASE_REVIEWER_MAX_TURNS * 2})`,
|
|
@@ -1801,8 +2696,10 @@ async function runSprintCycle(context) {
|
|
|
1801
2696
|
// on the first round of any cycle (roundSessions never resumes
|
|
1802
2697
|
// across cycles) and cleared on a failed round by the policy's
|
|
1803
2698
|
// 'clear-round-session' degrade step. The max_turns-exhaustion
|
|
1804
|
-
// resume overrides this
|
|
1805
|
-
//
|
|
2699
|
+
// resume overrides this with the exhausted dispatch's OWN session
|
|
2700
|
+
// id (`resume: "<sessionId>"`, never `resume: true`, which the
|
|
2701
|
+
// server resolves to the member's last session, whichever role ran
|
|
2702
|
+
// it) -- an in-dispatch continuation, not a cross-round one.
|
|
1806
2703
|
resumeArg: roundSessions.resumeArgFor('reviewer', cycle),
|
|
1807
2704
|
onSessionId: (id, meta) => roundSessions.record('reviewer', cycle, id, meta),
|
|
1808
2705
|
onResultRejected: (reason) => new ReviewerContractViolationError(
|
|
@@ -1824,6 +2721,11 @@ async function runSprintCycle(context) {
|
|
|
1824
2721
|
// A degraded round counts toward the bounded stall-abort budget like
|
|
1825
2722
|
// every other role's dispatch failure -- it is NOT a reviewer contract
|
|
1826
2723
|
// violation, which is what the dispatchFailed marker records.
|
|
2724
|
+
// The round's confirmations go to the bible on each repository's
|
|
2725
|
+
// kb_maintainer: G-pull, kb_bible_commit, G-push. Covers both callers
|
|
2726
|
+
// (the per-round review and the scope-wide re-review); a round with
|
|
2727
|
+
// no confirmations makes no call. Never throws.
|
|
2728
|
+
if (typeof kbWork.commitRound === 'function') await kbWork.commitRound(`review C${cycle}`);
|
|
1827
2729
|
return reviewOutcome.value;
|
|
1828
2730
|
}
|
|
1829
2731
|
|
|
@@ -1853,30 +2755,21 @@ async function runSprintCycle(context) {
|
|
|
1853
2755
|
// silently absorbed the sprint branch's commits this way.
|
|
1854
2756
|
//
|
|
1855
2757
|
// SUPPORTED-TOPOLOGY NOTE: there is no cross-member bd/git sync layer here.
|
|
1856
|
-
// Every `bd` command below runs against the
|
|
2758
|
+
// Every `bd` command below runs against the backlog member's beads DB
|
|
1857
2759
|
// and a doer's own `bd close` runs against its member's DB, which only
|
|
1858
2760
|
// coheres when all members share one workspace/DB (or there is a single
|
|
1859
2761
|
// member). bin/cli.mjs enforces that via checkMemberTopology() before the
|
|
1860
2762
|
// sprint starts; this ensure-everywhere is the git half of the same "every
|
|
1861
2763
|
// member starts from the same state" guarantee. See docs/architecture.md
|
|
1862
2764
|
// "Multi-member topology (fleet-sprint)".
|
|
1863
|
-
// apra-fleet:
|
|
2765
|
+
// apra-fleet: backlogMember is deliberately NOT included here -- the
|
|
1864
2766
|
// orchestrator role issues only bd/Dolt commands (never git), and a
|
|
1865
|
-
// shared/unreservable
|
|
2767
|
+
// shared/unreservable backlog member used across concurrent sprints
|
|
1866
2768
|
// cannot be checked out onto N different branches at once. If an operator
|
|
1867
2769
|
// explicitly role-maps a dispatch member (doer/reviewer/planner/etc.) as
|
|
1868
2770
|
// orchestrator too, that member is still included below via its dispatch
|
|
1869
2771
|
// role, so the ensure-everywhere guarantee is unaffected for that case.
|
|
1870
|
-
const branchEnsureMembers =
|
|
1871
|
-
...getMembersForRole(ROLE_DOER),
|
|
1872
|
-
...getMembersForRole(ROLE_REVIEWER),
|
|
1873
|
-
...getMembersForRole('planner'),
|
|
1874
|
-
...getMembersForRole('plan-reviewer'),
|
|
1875
|
-
...getMembersForRole('deployer'),
|
|
1876
|
-
...getMembersForRole('integ-test-runner'),
|
|
1877
|
-
...getMembersForRole('regression-test-runner'),
|
|
1878
|
-
...getMembersForRole('harvester'),
|
|
1879
|
-
])];
|
|
2772
|
+
const branchEnsureMembers = computeBranchEnsureMembers(getMembersForRole, context.kbMaintainers, backlogRoleMapMembers);
|
|
1880
2773
|
|
|
1881
2774
|
// Read the requirementsFile (if any) once, up front, so its content can
|
|
1882
2775
|
// be threaded into every Plan-phase planner prompt.
|
|
@@ -1900,11 +2793,11 @@ async function runSprintCycle(context) {
|
|
|
1900
2793
|
// Routed through the single dolt-sync module (apra-fleet-417.2.1):
|
|
1901
2794
|
// readinessGate (apra-fleet-417.5 rename of healthGate) selects the
|
|
1902
2795
|
// pre-flight variant of the BEFORE bracket.
|
|
1903
|
-
// Thread the
|
|
2796
|
+
// Thread the backlog member's REGISTERED shell into dolt-settle,
|
|
1904
2797
|
// guarded on args.callTool the same way the pre-dispatch bracket is
|
|
1905
2798
|
// (apra-fleet-7dir.24).
|
|
1906
|
-
const preflightSettleShell = await resolveSettleShell({ args, member:
|
|
1907
|
-
await gitSync.syncBeadsBefore(
|
|
2799
|
+
const preflightSettleShell = await resolveSettleShell({ args, member: backlogMember, log, sprintState });
|
|
2800
|
+
await gitSync.syncBeadsBefore(backlogMember, { readinessGate: true, settle: buildSettleCallback(backlogMember, { command, log, shell: preflightSettleShell }) });
|
|
1908
2801
|
|
|
1909
2802
|
// =======================
|
|
1910
2803
|
// 0. Git Setup: ensure the sprint branch exists off base_branch
|
|
@@ -1952,6 +2845,10 @@ async function runSprintCycle(context) {
|
|
|
1952
2845
|
// round.
|
|
1953
2846
|
async function updateDashboard() {
|
|
1954
2847
|
let sprintTasks = [];
|
|
2848
|
+
// When the sprint-tree bd fetch completed -- carried in the beads
|
|
2849
|
+
// payload so the viewer's progress summary reports data age, not
|
|
2850
|
+
// render/publish time.
|
|
2851
|
+
let fetchedAt = null;
|
|
1955
2852
|
try {
|
|
1956
2853
|
// The no-args path is required here: any non-empty rest args route
|
|
1957
2854
|
// through a second `bd list` query, and plain `bd list` defaults to
|
|
@@ -1959,6 +2856,14 @@ async function runSprintCycle(context) {
|
|
|
1959
2856
|
// dashboard's sprint tree. No-args returns the shared `bd list
|
|
1960
2857
|
// --all` fetch filtered to scope -- every status, one query fewer.
|
|
1961
2858
|
sprintTasks = await bdListScoped('');
|
|
2859
|
+
fetchedAt = new Date().toISOString();
|
|
2860
|
+
// Sprint-level KB hint sources for the roles whose dispatch does
|
|
2861
|
+
// not name its own beads (planner, deployer, test runners, ...).
|
|
2862
|
+
kbSprintContext.beadTitles = sprintTasks.filter((t) => t && typeof t.title === 'string').map((t) => t.title);
|
|
2863
|
+
kbSprintContext.closedBeadTitles = sprintTasks.filter((t) => t && t.status === 'closed' && typeof t.title === 'string').map((t) => t.title);
|
|
2864
|
+
kbSprintContext.beadIds = sprintTasks.filter((t) => t && typeof t.id === 'string').map((t) => t.id);
|
|
2865
|
+
kbSprintContext.testFiles = pathsFromText(sprintTasks.map((t) => t && t.description)).filter((p) => /test|spec/i.test(p));
|
|
2866
|
+
kbBeadIndex = new Map(sprintTasks.filter((t) => t && t.id).map((t) => [t.id, t]));
|
|
1962
2867
|
// A bead whose stored `status` is 'open' but which is NOT in the
|
|
1963
2868
|
// scope's `--ready` set is blocked. The viewer only sees stored
|
|
1964
2869
|
// status, so without this flag a deadlocked bead renders
|
|
@@ -2010,6 +2915,7 @@ async function runSprintCycle(context) {
|
|
|
2010
2915
|
payload.decomposedParentIds = [...new Set(
|
|
2011
2916
|
sprintTasks.filter((b) => b && b.parent).map((b) => b.parent)
|
|
2012
2917
|
)];
|
|
2918
|
+
payload.fetchedAt = fetchedAt;
|
|
2013
2919
|
publishState('beads', payload);
|
|
2014
2920
|
}
|
|
2015
2921
|
}
|
|
@@ -2020,7 +2926,7 @@ async function runSprintCycle(context) {
|
|
|
2020
2926
|
// escaped-quote-inside-quote traps). failSoft, so a probe failure can never
|
|
2021
2927
|
// throw and kill the sprint -- it just means "skip the dependent phase".
|
|
2022
2928
|
// Runs on `member` -- the role member about to consume the probed file --
|
|
2023
|
-
// never on
|
|
2929
|
+
// never on backlogMember: a shared/unreservable backlog member
|
|
2024
2930
|
// carries no git checkout to probe.
|
|
2025
2931
|
async function probeFileExists(filename, member) {
|
|
2026
2932
|
const res = await command(
|
|
@@ -2039,11 +2945,22 @@ async function runSprintCycle(context) {
|
|
|
2039
2945
|
// doer's work, so pull again immediately before the verification read.
|
|
2040
2946
|
// DoltSync.syncBefore() is a benign no-op when the clone is current and
|
|
2041
2947
|
// when no dolt remote is configured at all.
|
|
2042
|
-
// Thread the
|
|
2948
|
+
// Thread the backlog member's REGISTERED shell into dolt-settle,
|
|
2043
2949
|
// guarded on args.callTool the same way the pre-dispatch bracket is
|
|
2044
2950
|
// (apra-fleet-7dir.24).
|
|
2045
|
-
const verifyReadSettleShell = await resolveSettleShell({ args, member:
|
|
2046
|
-
await gitSync.syncBeadsBefore(
|
|
2951
|
+
const verifyReadSettleShell = await resolveSettleShell({ args, member: backlogMember, log, sprintState });
|
|
2952
|
+
await gitSync.syncBeadsBefore(backlogMember, { fatal: true, settle: buildSettleCallback(backlogMember, { command, log, shell: verifyReadSettleShell }) });
|
|
2953
|
+
|
|
2954
|
+
// Beads memory hygiene: forget token-usage memories (and retired keys)
|
|
2955
|
+
// before any dispatch, so `bd prime` never injects them into a session.
|
|
2956
|
+
// Sprint start only; one non-fatal bracketed push when anything was
|
|
2957
|
+
// forgotten; never throws. `context.sweepTokenMemories` is the test seam.
|
|
2958
|
+
await (context.sweepTokenMemories ?? sweepTokenMemories)({
|
|
2959
|
+
command,
|
|
2960
|
+
log,
|
|
2961
|
+
member: backlogMember,
|
|
2962
|
+
pushBeads: () => gitSync.syncBeadsAfter(backlogMember, { pushBeads: true }),
|
|
2963
|
+
});
|
|
2047
2964
|
|
|
2048
2965
|
await updateDashboard();
|
|
2049
2966
|
|
|
@@ -2068,6 +2985,31 @@ async function runSprintCycle(context) {
|
|
|
2068
2985
|
log(`Pre-sprint validation: no ready leaf beads, but ${preSprintVerifyIds.length} bead(s) are implementation-complete and routed to verify: ${preSprintVerifyIds.join(', ')}. Proceeding as a verify-only sprint.`);
|
|
2069
2986
|
}
|
|
2070
2987
|
|
|
2988
|
+
// GitHub #715: pre-sprint stale-claim check, run ONCE whether or not other
|
|
2989
|
+
// work is ready. A bead left in_progress by an earlier run is invisible to
|
|
2990
|
+
// `bd ready`, and so is every bead blocked on it -- unrelated ready work
|
|
2991
|
+
// must not hide that whole chain for the entire sprint. The empty-ready
|
|
2992
|
+
// case runs the same reclaim inside the refusal block below (from a fresh
|
|
2993
|
+
// `bd list` it needs there anyway), so this covers every other case.
|
|
2994
|
+
// Pre-filters on the shared snapshot readyLeafBeads() just cached -- no
|
|
2995
|
+
// bd call at all unless a candidate exists -- then confirms each
|
|
2996
|
+
// candidate with a fresh `bd show` before writing (freshRead), because
|
|
2997
|
+
// the snapshot alone never authorizes a write. Same pre-launch rule and
|
|
2998
|
+
// concurrency caveat as reclaimStaleInProgress' doc comment.
|
|
2999
|
+
if (initialBeads.length > 0 || preSprintVerifyIds.length > 0) {
|
|
3000
|
+
const notDoneFromSnapshot = (await bdListScoped(''))
|
|
3001
|
+
.filter((b) => NOT_DONE_STATUS_SET.has(b.status))
|
|
3002
|
+
.filter((b) => !validated.assignee || b.assignee === validated.assignee);
|
|
3003
|
+
const { reclaimedIds: preSprintStaleReclaimedIds } = await reclaimStaleInProgress({
|
|
3004
|
+
notDoneBeads: notDoneFromSnapshot,
|
|
3005
|
+
reasonTag: 'Pre-sprint self-heal',
|
|
3006
|
+
freshRead: true,
|
|
3007
|
+
});
|
|
3008
|
+
if (preSprintStaleReclaimedIds.length > 0) {
|
|
3009
|
+
initialBeads = await readyLeafBeads();
|
|
3010
|
+
}
|
|
3011
|
+
}
|
|
3012
|
+
|
|
2071
3013
|
if (initialBeads.length === 0 && preSprintVerifyIds.length === 0) {
|
|
2072
3014
|
// An empty `--ready` set is not by itself "nothing left to do": real
|
|
2073
3015
|
// unblocked work can be deadlocked on a bead stuck in a stale
|
|
@@ -2113,7 +3055,7 @@ async function runSprintCycle(context) {
|
|
|
2113
3055
|
if (invisibleTargets.length > 0) {
|
|
2114
3056
|
throw new PreSprintValidationError(
|
|
2115
3057
|
`Pre-sprint validation failed: ${invisibleTargets.length} of ${targetIssues.length} target issue id(s) ` +
|
|
2116
|
-
`are not visible to the
|
|
3058
|
+
`are not visible to the backlog member ('${backlogMember}')'s bd clone at all: ` +
|
|
2117
3059
|
`${invisibleTargets.join(', ')}. This is NOT the same as those beads being closed/done -- it usually ` +
|
|
2118
3060
|
`means they were created/updated on a different clone that was never synced to the shared Dolt remote ` +
|
|
2119
3061
|
`(dolt-push it there first) or this member's clone has not picked them up yet. Scope: '${sprintFilter}'.`,
|
|
@@ -2165,7 +3107,7 @@ async function runSprintCycle(context) {
|
|
|
2165
3107
|
// the throw; it is never silently swallowed.
|
|
2166
3108
|
try {
|
|
2167
3109
|
for (const pair of cyclePairs) {
|
|
2168
|
-
await command(`bd dep remove ${pair.blockedIssue} ${pair.blockedBy}`, { member_name:
|
|
3110
|
+
await command(`bd dep remove ${pair.blockedIssue} ${pair.blockedBy}`, { member_name: backlogMember, silent: true });
|
|
2169
3111
|
log(`Pre-sprint auto-repair: removed the 'blocks' edge between ${pair.blockedIssue} and ${pair.blockedBy} (parent-child + blocks cycle) -- auto-removed via bd dep remove.`);
|
|
2170
3112
|
}
|
|
2171
3113
|
} catch (repairErr) {
|
|
@@ -2208,6 +3150,43 @@ async function runSprintCycle(context) {
|
|
|
2208
3150
|
}
|
|
2209
3151
|
}
|
|
2210
3152
|
|
|
3153
|
+
// GitHub #717: a bead whose only unmet `blocks` dependencies are
|
|
3154
|
+
// verify-routed beads (all children closed; only the Integration Test
|
|
3155
|
+
// phase closes them) can never become ready while that phase cannot run
|
|
3156
|
+
// -- no integ-test-playbook.md or no deploy.md. Runs AFTER the pre-sprint
|
|
3157
|
+
// stale-claim reclaim above, from the shared snapshot those reads already
|
|
3158
|
+
// fetched (no extra bd call on the common path); the two runbook probes
|
|
3159
|
+
// run only when the shape exists. A goal-priority bead in that shape stops
|
|
3160
|
+
// the sprint here, before any cycle is paid for, with a diagnosis naming
|
|
3161
|
+
// the bead, its blockers and the exact fix; a below-goal one only warns.
|
|
3162
|
+
// Diagnose only: the DAG is never rewritten.
|
|
3163
|
+
{
|
|
3164
|
+
const allForVerifyBlock = await fetchAllBeadsShared();
|
|
3165
|
+
const { verifyIds: verifyIdsForBlockCheck } = classifyVerifySet(allForVerifyBlock, targetIssues);
|
|
3166
|
+
const blockedByVerify = findVerifyBlockedBeads(await bdListScoped(''), allForVerifyBlock, verifyIdsForBlockCheck);
|
|
3167
|
+
if (blockedByVerify.length > 0) {
|
|
3168
|
+
const hasDeployPreSprint = await probeFileExists('deploy.md', getMemberForRole('deployer'));
|
|
3169
|
+
const hasPlaybookPreSprint = await probeFileExists('integ-test-playbook.md', getMemberForRole('integ-test-runner'));
|
|
3170
|
+
const cause = integBlockCause({ hasPlaybook: hasPlaybookPreSprint, hasDeploy: hasDeployPreSprint });
|
|
3171
|
+
if (cause) {
|
|
3172
|
+
const { atGoal, belowGoal } = partitionByGoal(blockedByVerify, goalPriorityMax(validated.goal));
|
|
3173
|
+
if (belowGoal.length > 0) {
|
|
3174
|
+
log(`Pre-sprint validation: WARNING -- ${buildVerifyBlockDiagnosis({ blocked: belowGoal, cause })} These bead(s) are below goal priority ${validated.goal}, so the sprint is not stopped for them.`);
|
|
3175
|
+
}
|
|
3176
|
+
if (atGoal.length > 0) {
|
|
3177
|
+
throw new PreSprintValidationError(
|
|
3178
|
+
`Pre-sprint validation failed: ${buildVerifyBlockDiagnosis({ blocked: atGoal, cause })}`,
|
|
3179
|
+
{
|
|
3180
|
+
reason: PRE_SPRINT_REFUSAL_REASONS.VERIFY_BLOCKED,
|
|
3181
|
+
scope: sprintFilter,
|
|
3182
|
+
details: { cause, blocked: atGoal },
|
|
3183
|
+
}
|
|
3184
|
+
);
|
|
3185
|
+
}
|
|
3186
|
+
}
|
|
3187
|
+
}
|
|
3188
|
+
}
|
|
3189
|
+
|
|
2211
3190
|
// =======================
|
|
2212
3191
|
// Goal-priority exit condition + stall-abort bookkeeping
|
|
2213
3192
|
// =======================
|
|
@@ -2218,6 +3197,81 @@ async function runSprintCycle(context) {
|
|
|
2218
3197
|
// priority", NOT "bd list --ready returned []".
|
|
2219
3198
|
const goalMax = goalPriorityMax(validated.goal);
|
|
2220
3199
|
|
|
3200
|
+
// Every bead id this sprint has handed to a doer (dispatched; a doer's
|
|
3201
|
+
// close is a subset). The reviewer-reopen goal-scope guard never defers a
|
|
3202
|
+
// bead in this set -- the sprint's own commits for it are on the branch,
|
|
3203
|
+
// so a reopen of it is the sprint repairing its own work (see
|
|
3204
|
+
// isDeferredScopeReopen in beads-transitions.mjs). Passed explicitly to
|
|
3205
|
+
// every verdict site: Review, Re-Review and Final Review.
|
|
3206
|
+
const workedOnBeadIds = new Set();
|
|
3207
|
+
|
|
3208
|
+
// GitHub #715: the run-scoped "dispatched to a doer this run" record, by
|
|
3209
|
+
// each bead's LATEST streak outcome. See ./orphan-reclaim.mjs for the
|
|
3210
|
+
// rules and reclaimInRunOrphanedClaims() for the fresh-read/stop/write.
|
|
3211
|
+
const orphanClaims = createOrphanClaimTracker();
|
|
3212
|
+
|
|
3213
|
+
// The develop loop's ready set: readyLeafBeads() minus below-goal beads
|
|
3214
|
+
// that neither (transitively) block an open in-goal bead nor were already
|
|
3215
|
+
// dispatched by this sprint (see partitionReadyByGoal in beads-scope.mjs).
|
|
3216
|
+
// Used by every Develop/Review-loop readiness read -- the per-cycle seed,
|
|
3217
|
+
// the per-round streak input and the round-loop "still open" check -- so
|
|
3218
|
+
// an excluded bead can neither be dispatched nor keep the loop spinning.
|
|
3219
|
+
// The completion gate needs no change: it already counts only beads at or
|
|
3220
|
+
// above goal priority, so an excluded bead never holds the sprint open.
|
|
3221
|
+
// Pre-sprint validation keeps the unfiltered readyLeafBeads(): its
|
|
3222
|
+
// deadlock diagnosis is about the graph, not about goal membership.
|
|
3223
|
+
//
|
|
3224
|
+
// Set-aside v2 (all in-memory over the same scope read, no extra bd call):
|
|
3225
|
+
// - a bead that WAITS after a BLOCKED report (sprintState.waitingIds)
|
|
3226
|
+
// is held while any prerequisite of it is still open;
|
|
3227
|
+
// - lane order is a prerequisite: a laned bead whose lower-order
|
|
3228
|
+
// lane-mate is open and not itself dispatchable this round is held
|
|
3229
|
+
// (holdBackByLaneOrder). Set-aside and publish-blocked beads stay in
|
|
3230
|
+
// the returned list (phases/develop.mjs excludes them and the
|
|
3231
|
+
// start-of-round check reads them) but never count as "ahead" of a
|
|
3232
|
+
// lane-mate.
|
|
3233
|
+
// A hold line is logged whenever it changes.
|
|
3234
|
+
const loggedBelowGoalExclusions = new Set();
|
|
3235
|
+
let lastDispatchHoldLog = '';
|
|
3236
|
+
async function dispatchableReadyLeafBeads() {
|
|
3237
|
+
const [ready, scopeAll] = await Promise.all([readyLeafBeads(), bdListScoped('')]);
|
|
3238
|
+
const setAsideMap = sprintState.doctorBlockedIds instanceof Map ? sprintState.doctorBlockedIds : new Map();
|
|
3239
|
+
const waitingMap = sprintState.waitingIds instanceof Map ? sprintState.waitingIds : new Map();
|
|
3240
|
+
const permissionBlocked = sprintState.permissionScopeBlockedBeads instanceof Map ? sprintState.permissionScopeBlockedBeads : new Map();
|
|
3241
|
+
const holdLines = [];
|
|
3242
|
+
const { dispatchable, excluded } = partitionReadyByGoal(ready, scopeAll, validated.goal, { workedOnIds: workedOnBeadIds });
|
|
3243
|
+
const fresh = excluded.filter((e) => !loggedBelowGoalExclusions.has(e.id));
|
|
3244
|
+
if (fresh.length > 0) {
|
|
3245
|
+
for (const e of fresh) loggedBelowGoalExclusions.add(e.id);
|
|
3246
|
+
log(formatBelowGoalExclusionLog(fresh, validated.goal));
|
|
3247
|
+
}
|
|
3248
|
+
let candidates = dispatchable;
|
|
3249
|
+
if (waitingMap.size > 0) {
|
|
3250
|
+
const stillWaiting = [];
|
|
3251
|
+
candidates = dispatchable.filter((b) => {
|
|
3252
|
+
if (!waitingMap.has(b.id)) return true;
|
|
3253
|
+
const on = unmetPrerequisites(b, { scopeBeads: scopeAll }).inScope;
|
|
3254
|
+
if (on.length === 0) return true;
|
|
3255
|
+
stillWaiting.push(`${b.id} waiting on ${on.join(', ')}`);
|
|
3256
|
+
return false;
|
|
3257
|
+
});
|
|
3258
|
+
if (stillWaiting.length > 0) holdLines.push(`WAITING ${stillWaiting.join('; ')} (reported BLOCKED while a prerequisite was open)`);
|
|
3259
|
+
}
|
|
3260
|
+
const isAside = (b) => setAsideMap.has(b.id) || permissionBlocked.has(b.id);
|
|
3261
|
+
const { dispatchable: laneOk, held } = holdBackByLaneOrder(candidates.filter((b) => !isAside(b)), scopeAll);
|
|
3262
|
+
if (held.length > 0) {
|
|
3263
|
+
holdLines.push(`HELD by lane order ${held.map((h) => `${h.id} (after ${h.on.join(', ')})`).join('; ')} -- ` +
|
|
3264
|
+
'a lower-order lane-mate is still open and not dispatchable this round');
|
|
3265
|
+
}
|
|
3266
|
+
if (holdLines.length > 0) {
|
|
3267
|
+
const line = `Develop dispatch: ${holdLines.join('. ')}.`;
|
|
3268
|
+
if (line !== lastDispatchHoldLog) { lastDispatchHoldLog = line; log(line); }
|
|
3269
|
+
}
|
|
3270
|
+
if (held.length === 0) return candidates;
|
|
3271
|
+
const keep = new Set([...laneOk, ...candidates.filter(isAside)].map((b) => b.id));
|
|
3272
|
+
return candidates.filter((b) => keep.has(b.id));
|
|
3273
|
+
}
|
|
3274
|
+
|
|
2221
3275
|
// Stall detection: abort with a typed StalledSprintError after two
|
|
2222
3276
|
// consecutive cycles that made no forward progress, rather than burning
|
|
2223
3277
|
// every remaining cycle on a develop/review loop that keeps reopening and
|
|
@@ -2257,6 +3311,171 @@ async function runSprintCycle(context) {
|
|
|
2257
3311
|
// oscillating in and out of eligibility.
|
|
2258
3312
|
const verifyEverIds = new Set();
|
|
2259
3313
|
|
|
3314
|
+
// Applies the decision answers recorded while the run was running
|
|
3315
|
+
// (decision-wait.mjs recordDecisionAnswer only queues them). The bd writes
|
|
3316
|
+
// and the beads push happen INSIDE one sync bracket, after its pull, under
|
|
3317
|
+
// the same dolt mutex as every other phase's pull/push -- never as a
|
|
3318
|
+
// free-standing push. No bracket and no command when nothing is queued.
|
|
3319
|
+
async function applyRecordedDecisionAnswers() {
|
|
3320
|
+
if (!decisionWait || !decisionWait.hasQueuedAnswers()) return [];
|
|
3321
|
+
const settleShell = await resolveSettleShell({ args, member: backlogMember, log, sprintState });
|
|
3322
|
+
return gitSync.withOpenSyncBracket(async () => {
|
|
3323
|
+
await gitSync.syncBeadsBefore(backlogMember, { fatal: true, settle: buildSettleCallback(backlogMember, { command, log, shell: settleShell }) });
|
|
3324
|
+
return decisionWait.applyRecordedAnswers();
|
|
3325
|
+
});
|
|
3326
|
+
}
|
|
3327
|
+
|
|
3328
|
+
// Whether the run's cost budget leaves room to dispatch more work.
|
|
3329
|
+
function budgetAllowsMoreWork() {
|
|
3330
|
+
try {
|
|
3331
|
+
return !(budget && typeof budget.remaining === 'function' && budget.remaining() <= 0);
|
|
3332
|
+
} catch { return true; }
|
|
3333
|
+
}
|
|
3334
|
+
|
|
3335
|
+
// Called at the end of a cycle. A decision answered at the evaluation of the
|
|
3336
|
+
// last allowed cycle grants exactly ONE extra cycle (per late answer batch)
|
|
3337
|
+
// when the budget allows, so the released bead is dispatched; otherwise the
|
|
3338
|
+
// unworked released bead and its decision are named in the log and in the
|
|
3339
|
+
// final verdict notes.
|
|
3340
|
+
function handleLateDecisionAnswers() {
|
|
3341
|
+
if (lateDecisionAnswers.length === 0) return;
|
|
3342
|
+
const batch = lateDecisionAnswers;
|
|
3343
|
+
lateDecisionAnswers = [];
|
|
3344
|
+
const named = batch.map((a) => `${(a.released && a.released.length ? a.released : [a.beadId]).join(', ')} (decision ${a.decisionId})`).join('; ');
|
|
3345
|
+
if (cycle >= effectiveMaxCycles && budgetAllowsMoreWork()) {
|
|
3346
|
+
effectiveMaxCycles = cycle + 1;
|
|
3347
|
+
log(`Cycle ${cycle}: decision answered at the last allowed cycle (maxCycles ${MAX_CYCLES}); granting one extra cycle (${cycle + 1}) so the released bead(s) are dispatched: ${named}.`);
|
|
3348
|
+
return;
|
|
3349
|
+
}
|
|
3350
|
+
const why = budgetAllowsMoreWork() ? `maxCycles ${MAX_CYCLES} reached` : 'the budget is exhausted';
|
|
3351
|
+
const line = `Decision answered too late to be worked: released bead(s) ${named} were not dispatched in this run (${why}). Re-run the sprint to work them.`;
|
|
3352
|
+
lateUnworkedReports.push(line);
|
|
3353
|
+
log(line);
|
|
3354
|
+
}
|
|
3355
|
+
|
|
3356
|
+
// Immediate set-aside stall (see ./set-aside.mjs). When nothing is ready
|
|
3357
|
+
// and every open in-scope bead at goal priority is set aside for this run
|
|
3358
|
+
// -- doer-BLOCKED (sprintState.doctorBlockedIds) or, while the deploy is
|
|
3359
|
+
// set aside (sprintState.deploySetAside), bound to Integration Test -- no
|
|
3360
|
+
// further round or cycle can make progress, so throw StalledSprintError
|
|
3361
|
+
// now instead of after STALL_CYCLE_LIMIT empty cycles. A no-op (no bd
|
|
3362
|
+
// call at all) unless something was set aside this run. `openAtGoal` and
|
|
3363
|
+
// `closedIds` may be passed in when the caller already read them (Cycle
|
|
3364
|
+
// Evaluation); otherwise they are read fresh here. `runbooks`
|
|
3365
|
+
// ({ hasDeploy, hasPlaybook }) may likewise be passed in; otherwise the
|
|
3366
|
+
// two runbooks are probed here when the deploy is not set aside.
|
|
3367
|
+
//
|
|
3368
|
+
// An open verify-routed parent (every child closed, the parent itself
|
|
3369
|
+
// waiting on Integration Test) is neither set aside nor waiting on a
|
|
3370
|
+
// set-aside deploy while Integration Test can still run (deploy.md and
|
|
3371
|
+
// integ-test-playbook.md present, deploy not set aside): Deploy and
|
|
3372
|
+
// Integration Test later in this cycle can still close it, so it counts
|
|
3373
|
+
// as open work that keeps the run going. Without the runbooks it cannot
|
|
3374
|
+
// be verified at all; the existing "cannot verify" exit owns that case.
|
|
3375
|
+
//
|
|
3376
|
+
// A pending operator decision turns the stall into a resumable pause
|
|
3377
|
+
// (./decision-wait.mjs): when the stall would be thrown and any decision
|
|
3378
|
+
// is still pending -- even if other set-aside reasons are mixed in, since
|
|
3379
|
+
// the answer may unblock work -- the run waits in state
|
|
3380
|
+
// 'paused-awaiting-decision' until at least one decision is answered,
|
|
3381
|
+
// releases the answered bead(s), resets the no-progress counter (an answer
|
|
3382
|
+
// is progress), and returns true so the caller re-reads the ready set.
|
|
3383
|
+
// Returns false when there is no stall; throws StalledSprintError when
|
|
3384
|
+
// there is one and no decision is pending. A decision whose decision bead
|
|
3385
|
+
// could not be filed does not count as pending here (nothing can answer
|
|
3386
|
+
// it in-run); the stall error names it with its full question.
|
|
3387
|
+
async function throwIfSetAsideStall({ where, cycle, openAtGoal = null, closedIds = null, runbooks = null, queueLateAnswers = false }) {
|
|
3388
|
+
const doctorBlockedIds = sprintState.doctorBlockedIds instanceof Map ? sprintState.doctorBlockedIds : new Map();
|
|
3389
|
+
const deploySetAside = sprintState.deploySetAside || null;
|
|
3390
|
+
if (doctorBlockedIds.size === 0 && !deploySetAside) return false;
|
|
3391
|
+
let open = openAtGoal;
|
|
3392
|
+
if (!open) {
|
|
3393
|
+
const [raw, parentIds] = await Promise.all([
|
|
3394
|
+
bdListScoped(`--status=${NOT_DONE_STATUSES} --priority-max=${goalMax} --json`),
|
|
3395
|
+
decomposedParentIds(),
|
|
3396
|
+
]);
|
|
3397
|
+
open = partitionDeferredBeads(raw.filter((b) => !parentIds.has(b.id))).active;
|
|
3398
|
+
}
|
|
3399
|
+
let integBoundIds = [];
|
|
3400
|
+
let verifyBlockedIds = [];
|
|
3401
|
+
if (deploySetAside) {
|
|
3402
|
+
// Beads that can only close through Integration Test: verify-routed
|
|
3403
|
+
// parents (classified fresh -- a parent whose last child closed this
|
|
3404
|
+
// cycle is not in verifyEverIds yet) plus beads blocked only by them.
|
|
3405
|
+
invalidateAllBeadsCache();
|
|
3406
|
+
const allBeads = await fetchAllBeadsShared();
|
|
3407
|
+
const closed = closedIds || new Set(allBeads.filter((b) => b.status === 'closed').map((b) => b.id));
|
|
3408
|
+
const fresh = classifyVerifySet(allBeads, targetIssues).verifyIds;
|
|
3409
|
+
integBoundIds = [...new Set([...fresh, ...[...verifyEverIds].filter((id) => !closed.has(id))])];
|
|
3410
|
+
const knownClosed = [...closed].map((id) => ({ id, status: 'closed' }));
|
|
3411
|
+
verifyBlockedIds = findVerifyBlockedBeads(open, knownClosed, integBoundIds).map((b) => b.id);
|
|
3412
|
+
} else {
|
|
3413
|
+
const { hasDeploy, hasPlaybook } = runbooks || await (async () => {
|
|
3414
|
+
const deployMd = await probeFileExists('deploy.md', getMemberForRole('deployer'));
|
|
3415
|
+
const playbook = deployMd && await probeFileExists('integ-test-playbook.md', getMemberForRole('integ-test-runner'));
|
|
3416
|
+
return { hasDeploy: deployMd, hasPlaybook: playbook };
|
|
3417
|
+
})();
|
|
3418
|
+
if (hasDeploy && hasPlaybook) {
|
|
3419
|
+
// Open verify-routed parents become uncovered candidates:
|
|
3420
|
+
// with the deploy not set aside, evaluateSetAsideStall never
|
|
3421
|
+
// treats an integ-bound id as covered.
|
|
3422
|
+
invalidateAllBeadsCache();
|
|
3423
|
+
const allBeads = await fetchAllBeadsShared();
|
|
3424
|
+
const closed = closedIds || new Set(allBeads.filter((b) => b.status === 'closed').map((b) => b.id));
|
|
3425
|
+
integBoundIds = classifyVerifySet(allBeads, targetIssues).verifyIds.filter((id) => !closed.has(id));
|
|
3426
|
+
}
|
|
3427
|
+
}
|
|
3428
|
+
// Set-aside v2: an open bead that is not set aside but can only run
|
|
3429
|
+
// after a prerequisite that cannot close in this run (set aside,
|
|
3430
|
+
// itself stuck, or -- for a bead waiting after a BLOCKED report --
|
|
3431
|
+
// outside the scope) is stuck too. Computed only when some open bead
|
|
3432
|
+
// is otherwise uncovered, from the same in-memory scope read.
|
|
3433
|
+
let stuckIds = new Map();
|
|
3434
|
+
if (doctorBlockedIds.size > 0 && open.some((b) => !doctorBlockedIds.has(b.id))) {
|
|
3435
|
+
const scopeAll = await bdListScoped('');
|
|
3436
|
+
const allBeads = await fetchAllBeadsShared();
|
|
3437
|
+
stuckIds = stuckBehindSetAside({
|
|
3438
|
+
scopeBeads: scopeAll, allBeads, doctorBlockedIds,
|
|
3439
|
+
waitingIds: sprintState.waitingIds instanceof Map ? sprintState.waitingIds : new Map(),
|
|
3440
|
+
});
|
|
3441
|
+
}
|
|
3442
|
+
const stall = evaluateSetAsideStall({
|
|
3443
|
+
openIds: open.map((b) => b.id), integBoundIds, verifyBlockedIds, doctorBlockedIds, deploySetAside, stuckIds,
|
|
3444
|
+
});
|
|
3445
|
+
if (!stall) return false;
|
|
3446
|
+
if (decisionWait && decisionWait.hasPending()) {
|
|
3447
|
+
const answers = await decisionWait.awaitAnswer({ where, cycle });
|
|
3448
|
+
staleCycles = 0;
|
|
3449
|
+
// Answered at the end of the last allowed cycle: the loop would
|
|
3450
|
+
// end before the released bead is dispatched.
|
|
3451
|
+
// Only a wait at Cycle Evaluation is late: a wait at the start of a
|
|
3452
|
+
// Develop round dispatches the released bead in the same cycle.
|
|
3453
|
+
if (queueLateAnswers && cycle >= effectiveMaxCycles && Array.isArray(answers)) lateDecisionAnswers.push(...answers);
|
|
3454
|
+
return true;
|
|
3455
|
+
}
|
|
3456
|
+
const unfiledDecisions = decisionWait ? decisionWait.unfiled() : [];
|
|
3457
|
+
if (unfiledDecisions.length > 0) {
|
|
3458
|
+
// A pending decision whose decision bead could not be filed has
|
|
3459
|
+
// no answer path in this run, so it cannot hold a pause open.
|
|
3460
|
+
log(
|
|
3461
|
+
`Not pausing for ${unfiledDecisions.length} pending decision(s) whose decision bead could NOT be filed ` +
|
|
3462
|
+
`(no bd human respond path): ${unfiledDecisions.map((d) => `${d.beadId} -- ${d.question}`).join('; ')}`,
|
|
3463
|
+
);
|
|
3464
|
+
}
|
|
3465
|
+
const message = formatSetAsideStallMessage(stall, { where, scope: sprintFilter });
|
|
3466
|
+
log(message);
|
|
3467
|
+
throw new StalledSprintError(message, {
|
|
3468
|
+
staleCycles, closedCountHistory, highWaterClosedCount,
|
|
3469
|
+
thrashIds: thrashingBeadIds(),
|
|
3470
|
+
blockerIds: stall.blockerIds,
|
|
3471
|
+
blockerReasons: stall.blockerReasons,
|
|
3472
|
+
setAside: stall.entries,
|
|
3473
|
+
waited: collectWaitEntries(sprintState),
|
|
3474
|
+
cycle,
|
|
3475
|
+
details: { setAsideStall: true, where },
|
|
3476
|
+
});
|
|
3477
|
+
}
|
|
3478
|
+
|
|
2260
3479
|
// apra-fleet-rp7a.1: every bead id ever seen DEFERRED at/above goal
|
|
2261
3480
|
// priority during Cycle Evaluation, monotone for the same reason
|
|
2262
3481
|
// verifyEverIds is. These beads are excluded from the completion/stall
|
|
@@ -2290,6 +3509,17 @@ async function runSprintCycle(context) {
|
|
|
2290
3509
|
// evidence-based prompt below -- never silently swallowed.
|
|
2291
3510
|
const deployFailures = [];
|
|
2292
3511
|
const integFailures = [];
|
|
3512
|
+
// apra-fleet-b4g.102.1: the LATEST cycle's deploy outcome ({cycle, notes}
|
|
3513
|
+
// when deploy.md exists and that cycle's deploy failed, else null), and
|
|
3514
|
+
// how many consecutive cycles ended otherwise-satisfied but deploy-blocked.
|
|
3515
|
+
// Cycle Evaluation never exits as satisfied while lastDeployFailure is
|
|
3516
|
+
// set, and Final Review forces FAIL if it is still set when the loop ends
|
|
3517
|
+
// (see the deploy-failure verdict gate in ./phases/deploy.mjs).
|
|
3518
|
+
let lastDeployFailure = null;
|
|
3519
|
+
let deployBlockedCycles = 0;
|
|
3520
|
+
// GitHub #717: set (to the named diagnosis) when the cycle loop exits on a
|
|
3521
|
+
// verify-block deadlock; Final Review then forces the verdict to FAIL.
|
|
3522
|
+
let verifyBlockDiagnosis = null;
|
|
2293
3523
|
|
|
2294
3524
|
// apra-fleet-nwh.1: integ-test-runner's own tracked spend, broken out of
|
|
2295
3525
|
// the harvester's cost block so it is never silently folded into
|
|
@@ -2335,9 +3565,13 @@ async function runSprintCycle(context) {
|
|
|
2335
3565
|
let lastReviewVerdict = null;
|
|
2336
3566
|
let reviewedThisCycle = false;
|
|
2337
3567
|
|
|
2338
|
-
while (cycle <=
|
|
3568
|
+
while (cycle <= effectiveMaxCycles) {
|
|
2339
3569
|
group(`Sprint Cycle ${cycle}`);
|
|
2340
3570
|
|
|
3571
|
+
// Answers recorded since the last bracket are applied (and pushed) now,
|
|
3572
|
+
// inside a sync bracket, before this cycle reads the ready set.
|
|
3573
|
+
await applyRecordedDecisionAnswers();
|
|
3574
|
+
|
|
2341
3575
|
// Reset per-cycle review state -- a verdict is only ever trustworthy
|
|
2342
3576
|
// for the cycle that actually produced it.
|
|
2343
3577
|
lastReviewVerdict = null;
|
|
@@ -2365,6 +3599,12 @@ async function runSprintCycle(context) {
|
|
|
2365
3599
|
log(`Route C${cycle}: ${verifySetThisCycle.length} bead(s) implementation-complete, routed to verify (excluded from Plan/Develop): ${verifySetThisCycle.join(', ')}`);
|
|
2366
3600
|
}
|
|
2367
3601
|
|
|
3602
|
+
// GitHub #715: re-lane beads a failed doer of THIS run left
|
|
3603
|
+
// in_progress, before Plan and before readiness is computed, so they
|
|
3604
|
+
// (and the beads they block) are dispatchable again this cycle. No bd
|
|
3605
|
+
// call at all unless a doer streak of this run failed.
|
|
3606
|
+
await reclaimInRunOrphanedClaims({ reasonTag: `Cycle ${cycle} in-run reclaim` });
|
|
3607
|
+
|
|
2368
3608
|
// =======================
|
|
2369
3609
|
// 1. Planning Loop
|
|
2370
3610
|
// =======================
|
|
@@ -2377,7 +3617,7 @@ async function runSprintCycle(context) {
|
|
|
2377
3617
|
const planOutcome = await runPlanPhase({
|
|
2378
3618
|
phase, log, command, dispatchCtx,
|
|
2379
3619
|
cycle, validated, targetIssues, requirementsContent,
|
|
2380
|
-
|
|
3620
|
+
backlogMember, getMemberForRole,
|
|
2381
3621
|
sprintState, gitSync, args,
|
|
2382
3622
|
verifySetThisCycle, roundSessions, pendingRejectedNewTasks,
|
|
2383
3623
|
resolveSettleShell,
|
|
@@ -2418,7 +3658,7 @@ async function runSprintCycle(context) {
|
|
|
2418
3658
|
// filter exists to stop NON-target parents/bugs from wasting doer
|
|
2419
3659
|
// dispatches, never to make a sprint's own target unreachable.
|
|
2420
3660
|
const targetIssueSet = new Set(targetIssues);
|
|
2421
|
-
let readyBeads = (await
|
|
3661
|
+
let readyBeads = (await dispatchableReadyLeafBeads())
|
|
2422
3662
|
.filter((b) => targetIssueSet.has(b.id) || !b.issue_type || b.issue_type === 'task')
|
|
2423
3663
|
.slice().sort((a, b) => a.title.localeCompare(b.title) || a.id.localeCompare(b.id));
|
|
2424
3664
|
|
|
@@ -2439,7 +3679,7 @@ async function runSprintCycle(context) {
|
|
|
2439
3679
|
});
|
|
2440
3680
|
if (cycleReclaimedIds.length > 0) {
|
|
2441
3681
|
log(`Cycle ${cycle} self-heal: reclaimed ${cycleReclaimedIds.length} orphaned bead(s), re-checking readiness: ${cycleReclaimedIds.join(', ')}.`);
|
|
2442
|
-
readyBeads = (await
|
|
3682
|
+
readyBeads = (await dispatchableReadyLeafBeads())
|
|
2443
3683
|
.filter((b) => targetIssueSet.has(b.id) || !b.issue_type || b.issue_type === 'task')
|
|
2444
3684
|
.slice().sort((a, b) => a.title.localeCompare(b.title) || a.id.localeCompare(b.id));
|
|
2445
3685
|
}
|
|
@@ -2521,12 +3761,31 @@ async function runSprintCycle(context) {
|
|
|
2521
3761
|
// after the plan phase (a reviewer newTask, an out-of-band filing)
|
|
2522
3762
|
// would otherwise land in a doer streak and burn a dispatch on a
|
|
2523
3763
|
// contract-bound refusal. Same target-issue exemption as above.
|
|
2524
|
-
const currentReadyAll = (await
|
|
3764
|
+
const currentReadyAll = (await dispatchableReadyLeafBeads())
|
|
2525
3765
|
.filter((b) => targetIssueSet.has(b.id) || !b.issue_type || b.issue_type === 'task')
|
|
2526
3766
|
.slice().sort((a, b) => a.title.localeCompare(b.title) || a.id.localeCompare(b.id));
|
|
2527
3767
|
|
|
2528
3768
|
if (currentReadyAll.length === 0) break;
|
|
2529
3769
|
|
|
3770
|
+
// Start-of-round set-aside check: when every still-ready bead is set
|
|
3771
|
+
// aside for this run (doer-BLOCKED or a dependent of one), stall now
|
|
3772
|
+
// if nothing else open can progress; otherwise skip the remaining
|
|
3773
|
+
// rounds (nothing here is dispatchable) and go on to Cycle
|
|
3774
|
+
// Evaluation. Mixed rounds are passed through unchanged --
|
|
3775
|
+
// ./phases/develop.mjs excludes the set-aside beads itself.
|
|
3776
|
+
const roundSetAside = sprintState.doctorBlockedIds instanceof Map ? sprintState.doctorBlockedIds : null;
|
|
3777
|
+
if (roundSetAside && currentReadyAll.every((b) => roundSetAside.has(b.id))) {
|
|
3778
|
+
// true: an operator answered a pending decision while the run
|
|
3779
|
+
// was paused -- re-read the ready set (the released bead is
|
|
3780
|
+
// in it again) and dispatch this round.
|
|
3781
|
+
if (await throwIfSetAsideStall({ where: `start of Develop C${cycle} R${devRounds + 1}`, cycle })) continue;
|
|
3782
|
+
log(
|
|
3783
|
+
`Develop C${cycle} R${devRounds + 1}: every still-ready bead is set aside for this run ` +
|
|
3784
|
+
`(${currentReadyAll.map((b) => b.id).join(', ')}) -- skipping the remaining develop/review rounds this cycle.`
|
|
3785
|
+
);
|
|
3786
|
+
break;
|
|
3787
|
+
}
|
|
3788
|
+
|
|
2530
3789
|
// In-cycle SCOPED replan, taken on a bead's FIRST replan flag: when
|
|
2531
3790
|
// a reviewer flags a still-ready bead via `replanIds` -- its
|
|
2532
3791
|
// acceptance criteria are defective and cannot be satisfied by
|
|
@@ -2557,10 +3816,10 @@ async function runSprintCycle(context) {
|
|
|
2557
3816
|
await runReplanPhase({
|
|
2558
3817
|
phase, log, dispatchCtx,
|
|
2559
3818
|
cycle, validated, targetIssues, requirementsContent,
|
|
2560
|
-
|
|
3819
|
+
backlogMember,
|
|
2561
3820
|
gitSync, updateDashboard,
|
|
2562
3821
|
verifySetThisCycle, pendingRejectedNewTasks,
|
|
2563
|
-
devRounds, eligibleReplan, replanIds, replannedThisCycle,
|
|
3822
|
+
devRounds, eligibleReplan, replanIds, replannedThisCycle, perBeadFeedback,
|
|
2564
3823
|
});
|
|
2565
3824
|
continue;
|
|
2566
3825
|
}
|
|
@@ -2608,15 +3867,26 @@ async function runSprintCycle(context) {
|
|
|
2608
3867
|
// reviewer prompt free of doer-completion-order drift.
|
|
2609
3868
|
const { streakOutcomes, readyTitleById } = await runDevelopPhase({
|
|
2610
3869
|
phase, log, command, parallel, dispatchCtx,
|
|
2611
|
-
cycle, validated, args,
|
|
3870
|
+
cycle, validated, args, backlogMember,
|
|
2612
3871
|
sprintState, gitSync, updateDashboard,
|
|
2613
|
-
kbPriming, kbWork,
|
|
3872
|
+
kbPriming, kbWork, kbInjection, kbSprintContext,
|
|
2614
3873
|
devRounds, currentReady, doerPool, perBeadFeedback,
|
|
3874
|
+
bdListScoped,
|
|
3875
|
+
fetchAllBeadsShared,
|
|
2615
3876
|
claimBeadsBatched,
|
|
2616
3877
|
verifyDoerStreakClosed,
|
|
2617
3878
|
normalizeTierToken,
|
|
2618
3879
|
kbQueryTerms,
|
|
2619
3880
|
});
|
|
3881
|
+
for (const o of streakOutcomes) {
|
|
3882
|
+
for (const id of (o.beadIds || [])) workedOnBeadIds.add(id);
|
|
3883
|
+
}
|
|
3884
|
+
orphanClaims.recordOutcomes(streakOutcomes);
|
|
3885
|
+
// Dispatched by this run: the pre-launch rule never touches these
|
|
3886
|
+
// again (see preLaunchSettledIds).
|
|
3887
|
+
for (const o of streakOutcomes) {
|
|
3888
|
+
for (const id of (o.beadIds || [])) preLaunchSettledIds.add(id);
|
|
3889
|
+
}
|
|
2620
3890
|
|
|
2621
3891
|
// --- Review: self-contained, schema-validated, orchestrator-applied ---
|
|
2622
3892
|
// The phase body lives in ./phases/review.mjs
|
|
@@ -2632,12 +3902,13 @@ async function runSprintCycle(context) {
|
|
|
2632
3902
|
// unchanged, which is why no `if` is needed here.
|
|
2633
3903
|
({ lastReviewVerdict, reviewedThisCycle, pendingRejectedNewTasks } = await runReviewPhase({
|
|
2634
3904
|
phase, log, command,
|
|
2635
|
-
cycle, validated, targetIssues,
|
|
2636
|
-
gitSync,
|
|
3905
|
+
cycle, validated, targetIssues, backlogMember,
|
|
3906
|
+
gitSync, sprintState,
|
|
2637
3907
|
replanIds, replannedThisCycle, perBeadFeedback, rejectedNewTasks,
|
|
2638
3908
|
devRounds, streakOutcomes, readyTitleById,
|
|
2639
3909
|
lastReviewVerdict, reviewedThisCycle, pendingRejectedNewTasks,
|
|
2640
3910
|
dispatchReview, bdListScoped, goalMax, recordReopen,
|
|
3911
|
+
workedOnIds: workedOnBeadIds,
|
|
2641
3912
|
childIdAllocator, sprintMutexId,
|
|
2642
3913
|
computeChildFloor, createChildBeadWithAllocatedId,
|
|
2643
3914
|
trackRejectedNewTaskForResurfacing, clearResubmittedNewTask,
|
|
@@ -2652,7 +3923,7 @@ async function runSprintCycle(context) {
|
|
|
2652
3923
|
// must not read as "work still pending" here -- it is never a
|
|
2653
3924
|
// dispatchable leaf, so it must not keep this loop from
|
|
2654
3925
|
// organically completing (apra-fleet-66u.1/66u.2 rework).
|
|
2655
|
-
const stillOpen = await
|
|
3926
|
+
const stillOpen = await dispatchableReadyLeafBeads();
|
|
2656
3927
|
lastStillOpenCount = stillOpen.length; // Track for post-loop round-cap detection
|
|
2657
3928
|
|
|
2658
3929
|
if (stillOpen.length === 0) {
|
|
@@ -2683,7 +3954,13 @@ async function runSprintCycle(context) {
|
|
|
2683
3954
|
|
|
2684
3955
|
let deployedThisCycle = false;
|
|
2685
3956
|
|
|
2686
|
-
|
|
3957
|
+
// Deploy set aside for the run (a Permissions pre-step failure in an
|
|
3958
|
+
// earlier cycle -- see DEPLOY SET-ASIDE in ./phases/deploy.mjs): never
|
|
3959
|
+
// dispatch the deployer again; this cycle's deploy counts as failed.
|
|
3960
|
+
const deploySetAside = sprintState.deploySetAside || null;
|
|
3961
|
+
if (hasDeploy && deploySetAside) {
|
|
3962
|
+
log(`Skipping Deploy Phase C${cycle}: ${formatDeploySetAsideNotes(deploySetAside)}. Skipping Integration Test phase.`);
|
|
3963
|
+
} else if (hasDeploy) {
|
|
2687
3964
|
// The phase body lives in ./phases/deploy.mjs
|
|
2688
3965
|
// (apra-fleet-3swo.6.5), which receives its state explicitly
|
|
2689
3966
|
// instead of closing over runSprintCycle's locals. The
|
|
@@ -2697,11 +3974,14 @@ async function runSprintCycle(context) {
|
|
|
2697
3974
|
phase, log, dispatchCtx,
|
|
2698
3975
|
cycle, sprintSelfIdLine,
|
|
2699
3976
|
getMemberForRole, ensureUnattendedAuto, ensureDeployPermissions,
|
|
3977
|
+
sprintState,
|
|
2700
3978
|
deployFailures, deployedThisCycle,
|
|
2701
3979
|
}));
|
|
2702
3980
|
} else {
|
|
2703
3981
|
log('Skipping Deploy Phase (no deploy.md found, or the probe itself failed -- see prior log line)');
|
|
2704
3982
|
}
|
|
3983
|
+
lastDeployFailure = latestDeployFailure({ hasDeploy, deployedThisCycle, cycle, deployFailures, deploySetAside });
|
|
3984
|
+
if (!lastDeployFailure) deployBlockedCycles = 0;
|
|
2705
3985
|
|
|
2706
3986
|
// apra-fleet-66u.2: declared here, OUTSIDE the `if (hasPlaybook &&
|
|
2707
3987
|
// deployedThisCycle)` block below, so Cycle Evaluation's
|
|
@@ -2726,7 +4006,7 @@ async function runSprintCycle(context) {
|
|
|
2726
4006
|
// the closure did; the three genuinely reassigned values come back.
|
|
2727
4007
|
({ verifySetForIntegTest, integTestRunnerDispatchCount, integTestRunnerSpend } = await runIntegTestPhase({
|
|
2728
4008
|
phase, log, command, dispatchCtx,
|
|
2729
|
-
cycle, targetIssues,
|
|
4009
|
+
cycle, targetIssues, backlogMember, sprintSelfIdLine,
|
|
2730
4010
|
budget,
|
|
2731
4011
|
integFailures, verifyEverIds, verifyGapCounts,
|
|
2732
4012
|
verifySetForIntegTest, integTestRunnerDispatchCount, integTestRunnerSpend,
|
|
@@ -2754,11 +4034,11 @@ async function runSprintCycle(context) {
|
|
|
2754
4034
|
// counts so the completion/stall math reads the current cross-member
|
|
2755
4035
|
// beads state (every member's D-pushed closes) rather than the
|
|
2756
4036
|
// orchestrator's stale local copy.
|
|
2757
|
-
// Thread the
|
|
4037
|
+
// Thread the backlog member's REGISTERED shell into dolt-settle,
|
|
2758
4038
|
// guarded on args.callTool the same way the pre-dispatch bracket is
|
|
2759
4039
|
// (apra-fleet-7dir.24).
|
|
2760
|
-
const cycleEvalSettleShell = await resolveSettleShell({ args, member:
|
|
2761
|
-
await gitSync.syncBeadsBefore(
|
|
4040
|
+
const cycleEvalSettleShell = await resolveSettleShell({ args, member: backlogMember, log, sprintState });
|
|
4041
|
+
await gitSync.syncBeadsBefore(backlogMember, { fatal: true, settle: buildSettleCallback(backlogMember, { command, log, shell: cycleEvalSettleShell }) });
|
|
2762
4042
|
// A decomposed parent (any bead that is itself someone's --parent,
|
|
2763
4043
|
// including a childful --issue target) is excluded here the same way
|
|
2764
4044
|
// readyLeafBeads() excludes it from dispatch: its own "done" status
|
|
@@ -2850,7 +4130,21 @@ async function runSprintCycle(context) {
|
|
|
2850
4130
|
staleCycles++;
|
|
2851
4131
|
}
|
|
2852
4132
|
|
|
2853
|
-
|
|
4133
|
+
// Immediate set-aside stall, checked BEFORE the STALL_CYCLE_LIMIT
|
|
4134
|
+
// stall and the deploy-blocked retry exit below, so neither can delay
|
|
4135
|
+
// it: everything left is set aside, so no later cycle can progress.
|
|
4136
|
+
await throwIfSetAsideStall({
|
|
4137
|
+
where: `Cycle ${cycle} evaluation`, cycle, openAtGoal, closedIds: closedIdsNow,
|
|
4138
|
+
runbooks: { hasDeploy, hasPlaybook }, queueLateAnswers: true,
|
|
4139
|
+
});
|
|
4140
|
+
|
|
4141
|
+
// apra-fleet-b4g.102.1: a cycle spent re-attempting a failed deploy
|
|
4142
|
+
// after the work itself was already satisfied is not a stall -- it is
|
|
4143
|
+
// bounded separately (DEPLOY_RETRY_CYCLE_LIMIT and maxCycles) by the
|
|
4144
|
+
// deploy-blocked exit below, which ends the sprint with a FAIL naming
|
|
4145
|
+
// the deploy failure instead of a SPRINT_STALLED abort that would not.
|
|
4146
|
+
const waitingOnDeployRetry = deployBlockedCycles > 0 && lastDeployFailure !== null && openAtGoal.length === 0;
|
|
4147
|
+
if (staleCycles >= STALL_CYCLE_LIMIT && !waitingOnDeployRetry) {
|
|
2854
4148
|
const thrashIds = thrashingBeadIds();
|
|
2855
4149
|
// apra-fleet-mjo: counts alone ("history: [9, 14, 14, 14]") do not
|
|
2856
4150
|
// tell an operator WHAT is holding the sprint open, which is
|
|
@@ -2860,10 +4154,18 @@ async function runSprintCycle(context) {
|
|
|
2860
4154
|
// a "blocker" told an operator to go unblock something the
|
|
2861
4155
|
// dispatcher was never going to offer in the first place. They are
|
|
2862
4156
|
// reported separately, as skipped scope, by deferredStallSuffix.
|
|
2863
|
-
|
|
2864
|
-
|
|
2865
|
-
|
|
2866
|
-
|
|
4157
|
+
// Beads set aside for this run (doer-BLOCKED and their dependents)
|
|
4158
|
+
// are named too, even below goal priority, unless already closed.
|
|
4159
|
+
const setAsideOpenIds = sprintState.doctorBlockedIds instanceof Map
|
|
4160
|
+
? [...sprintState.doctorBlockedIds.keys()].filter((id) => !closedIdsNow.has(id))
|
|
4161
|
+
: [];
|
|
4162
|
+
const openAtGoalIds = openAtGoal.map((b) => b.id);
|
|
4163
|
+
const blockerIds = [...new Set([...openAtGoalIds, ...setAsideOpenIds])];
|
|
4164
|
+
const setAsideOnlyIds = setAsideOpenIds.filter((id) => !openAtGoalIds.includes(id));
|
|
4165
|
+
const blockerSuffix = (openAtGoalIds.length > 0
|
|
4166
|
+
? ` Still open at/above goal priority ${goalMax}: [${openAtGoalIds.join(', ')}].`
|
|
4167
|
+
: ' No beads remain open at/above goal priority -- the stall is in closing out the sprint, not in the work itself.') +
|
|
4168
|
+
(setAsideOnlyIds.length > 0 ? ` Also set aside for this run (doer-BLOCKED or a dependent of one): [${setAsideOnlyIds.join(', ')}].` : '');
|
|
2867
4169
|
const deferredStallIds = [...deferredEverIds];
|
|
2868
4170
|
const deferredStallSuffix = deferredStallIds.length > 0
|
|
2869
4171
|
? ` Not counted as blockers (deferred, therefore never dispatchable): [${deferredStallIds.join(', ')}].`
|
|
@@ -2899,21 +4201,48 @@ async function runSprintCycle(context) {
|
|
|
2899
4201
|
`[${closedCountHistory.join(', ')}] (high-water mark on progress score: ${highWaterClosedCount}).` +
|
|
2900
4202
|
blockerSuffix + deferredStallSuffix + thrashSuffix + verifySuffix +
|
|
2901
4203
|
` Aborting rather than burning the remaining cycles.`,
|
|
2902
|
-
{ staleCycles, closedCountHistory, highWaterClosedCount, blockerIds, deferredIds: deferredStallIds, thrashIds, reopenCounts: Object.fromEntries(reopenCounts), verifyEverIds: [...verifyEverIds], cycle }
|
|
4204
|
+
{ staleCycles, closedCountHistory, highWaterClosedCount, blockerIds, deferredIds: deferredStallIds, thrashIds, reopenCounts: Object.fromEntries(reopenCounts), verifyEverIds: [...verifyEverIds], cycle, setAside: collectSetAsideEntries(sprintState), waited: collectWaitEntries(sprintState) }
|
|
2903
4205
|
);
|
|
2904
4206
|
}
|
|
2905
4207
|
|
|
2906
4208
|
// apra-fleet-jfo D5: if the ONLY open-at-goal beads remaining are
|
|
2907
|
-
// verify-routed and
|
|
2908
|
-
// cycle can make progress by construction -- exit to
|
|
2909
|
-
// directly rather than let the stall net eventually
|
|
2910
|
-
// "finished but unverifiable" into an ABORT.
|
|
2911
|
-
|
|
2912
|
-
|
|
4209
|
+
// verify-routed and the Integration Test phase cannot run to verify
|
|
4210
|
+
// them, no further cycle can make progress by construction -- exit to
|
|
4211
|
+
// Finalization directly rather than let the stall net eventually
|
|
4212
|
+
// convert "finished but unverifiable" into an ABORT. GitHub #717: keyed
|
|
4213
|
+
// on the one integCanRun predicate (playbook AND deploy.md AND the
|
|
4214
|
+
// deploy did not fail this cycle), not on the playbook alone.
|
|
4215
|
+
const integCanRunThisCycle = integCanRun({ hasPlaybook, hasDeploy, deployAttempted: hasDeploy, deployedThisCycle });
|
|
4216
|
+
if (!integCanRunThisCycle && openAtGoal.length > 0 && openAtGoal.every((b) => verifyEverIds.has(b.id))) {
|
|
4217
|
+
log(`Cycle ${cycle}: all ${openAtGoal.length} remaining open-at-goal bead(s) are verify-routed (${openAtGoal.map((b) => b.id).join(', ')}) and the Integration Test phase cannot run to verify them (it needs integ-test-playbook.md, deploy.md and a successful deploy) -- exiting cycle loop, cannot make further progress by construction.`);
|
|
2913
4218
|
endGroup();
|
|
2914
4219
|
break;
|
|
2915
4220
|
}
|
|
2916
4221
|
|
|
4222
|
+
// GitHub #717, mid-run: the same deadlock the pre-sprint check stops,
|
|
4223
|
+
// arising while the sprint runs (a blocker's last child closed, or the
|
|
4224
|
+
// deploy failed). When the Integration Test phase cannot run this cycle
|
|
4225
|
+
// and every remaining open-at-goal bead is verify-routed or blocked
|
|
4226
|
+
// ONLY by verify-routed beads, no cycle can progress: exit with the
|
|
4227
|
+
// named diagnosis, and Final Review forces the verdict to FAIL. Read
|
|
4228
|
+
// from this cycle's own fresh closed list and verify set -- no extra
|
|
4229
|
+
// bd call.
|
|
4230
|
+
if (!integCanRunThisCycle && openAtGoal.length > 0) {
|
|
4231
|
+
const knownClosed = [...closedIdsNow].map((id) => ({ id, status: 'closed' }));
|
|
4232
|
+
const blockedAtGoal = findVerifyBlockedBeads(openAtGoal, knownClosed, verifySetThisCycle);
|
|
4233
|
+
const blockedAtGoalIds = new Set(blockedAtGoal.map((b) => b.id));
|
|
4234
|
+
if (blockedAtGoal.length > 0 && openAtGoal.every((b) => verifyEverIds.has(b.id) || blockedAtGoalIds.has(b.id))) {
|
|
4235
|
+
verifyBlockDiagnosis = buildVerifyBlockDiagnosis({
|
|
4236
|
+
blocked: blockedAtGoal,
|
|
4237
|
+
cause: integBlockCause({ hasPlaybook, hasDeploy, deployAttempted: hasDeploy, deployedThisCycle }),
|
|
4238
|
+
deployNotes: lastDeployFailure && lastDeployFailure.notes ? lastDeployFailure.notes : null,
|
|
4239
|
+
});
|
|
4240
|
+
log(`Cycle ${cycle}: ${verifyBlockDiagnosis} Exiting cycle loop; the sprint verdict will be FAIL.`);
|
|
4241
|
+
endGroup();
|
|
4242
|
+
break;
|
|
4243
|
+
}
|
|
4244
|
+
}
|
|
4245
|
+
|
|
2917
4246
|
// The exit decision below must never rely on a verdict from an EARLIER
|
|
2918
4247
|
// cycle. `lastReviewVerdict` is reset to null at the top of every cycle
|
|
2919
4248
|
// and only set when a review genuinely ran THIS cycle
|
|
@@ -2934,11 +4263,12 @@ async function runSprintCycle(context) {
|
|
|
2934
4263
|
// reassigned values come back.
|
|
2935
4264
|
({ lastReviewVerdict, reviewedThisCycle, pendingRejectedNewTasks } = await runReReviewPhase({
|
|
2936
4265
|
phase, log, command,
|
|
2937
|
-
cycle, validated, targetIssues,
|
|
2938
|
-
gitSync,
|
|
4266
|
+
cycle, validated, targetIssues, backlogMember,
|
|
4267
|
+
gitSync, sprintState,
|
|
2939
4268
|
rejectedNewTasks,
|
|
2940
4269
|
lastReviewVerdict, reviewedThisCycle, pendingRejectedNewTasks,
|
|
2941
4270
|
dispatchReview, bdListScoped, goalMax, recordReopen,
|
|
4271
|
+
workedOnIds: workedOnBeadIds,
|
|
2942
4272
|
childIdAllocator, sprintMutexId,
|
|
2943
4273
|
computeChildFloor, createChildBeadWithAllocatedId,
|
|
2944
4274
|
trackRejectedNewTaskForResurfacing, clearResubmittedNewTask,
|
|
@@ -2994,13 +4324,46 @@ async function runSprintCycle(context) {
|
|
|
2994
4324
|
// open/in_progress/blocked can never satisfy `.every()` here, so this
|
|
2995
4325
|
// never fires for that case and every gate above/below runs exactly
|
|
2996
4326
|
// as before.
|
|
2997
|
-
|
|
4327
|
+
// apra-fleet-b4g.102.1: neither "satisfied" exit below may fire while
|
|
4328
|
+
// the LATEST cycle's deploy failed (Integration Test was skipped, so
|
|
4329
|
+
// nothing verified the deployed build). Re-attempt the deploy in
|
|
4330
|
+
// another cycle while the budget allows; otherwise exit to the finish
|
|
4331
|
+
// phases, where Final Review forces a FAIL that names the failure. A
|
|
4332
|
+
// sprint with no deploy.md never sets lastDeployFailure.
|
|
4333
|
+
const rootsAllClosed = targetIssues.length > 0 && targetIssues.every((id) => closedIdsNow.has(id));
|
|
4334
|
+
const goalSatisfied = openAtGoal.length === 0 && lastReviewVerdict === 'APPROVED' && stillOpenVerifyIds.length === 0;
|
|
4335
|
+
if ((rootsAllClosed || goalSatisfied) && lastDeployFailure) {
|
|
4336
|
+
const which = rootsAllClosed ? 'every configured sprint root/target bead is closed' : `goal priority ${validated.goal} (<=${goalMax}) is otherwise satisfied`;
|
|
4337
|
+
// A deploy set aside for the run is never re-dispatched, so a
|
|
4338
|
+
// retry cycle could only spin (Plan, Re-Review) waiting on a
|
|
4339
|
+
// deploy that will not run: exit to the finish phases now. The
|
|
4340
|
+
// set-aside deploy is reported in the result and its "Set aside
|
|
4341
|
+
// this run" section, and the deploy-failure verdict gate forces
|
|
4342
|
+
// FAIL.
|
|
4343
|
+
if (sprintState.deploySetAside) {
|
|
4344
|
+
log(`Cycle ${cycle}: ${which}, but NOT exiting as satisfied -- ${formatDeploySetAsideNotes(sprintState.deploySetAside)}. No deploy retry is possible this run; exiting cycle loop, the sprint verdict will be FAIL.`);
|
|
4345
|
+
endGroup();
|
|
4346
|
+
break;
|
|
4347
|
+
}
|
|
4348
|
+
deployBlockedCycles++;
|
|
4349
|
+
if (cycle < MAX_CYCLES && deployBlockedCycles < DEPLOY_RETRY_CYCLE_LIMIT) {
|
|
4350
|
+
log(`Cycle ${cycle}: ${which}, but NOT exiting as satisfied -- ${formatDeployFailureReason(lastDeployFailure)}. Re-attempting deploy next cycle (deploy-blocked cycle ${deployBlockedCycles} of at most ${DEPLOY_RETRY_CYCLE_LIMIT}).`);
|
|
4351
|
+
cycle++;
|
|
4352
|
+
endGroup();
|
|
4353
|
+
continue;
|
|
4354
|
+
}
|
|
4355
|
+
log(`Cycle ${cycle}: ${which}, but the deploy re-attempt budget is exhausted (${deployBlockedCycles} consecutive deploy-blocked cycle(s), maxCycles ${MAX_CYCLES}) -- ${formatDeployFailureReason(lastDeployFailure)}. Exiting cycle loop; the sprint verdict will be FAIL.`);
|
|
4356
|
+
endGroup();
|
|
4357
|
+
break;
|
|
4358
|
+
}
|
|
4359
|
+
|
|
4360
|
+
if (rootsAllClosed) {
|
|
2998
4361
|
log(`Cycle ${cycle}: every configured sprint root/target bead is already closed (${targetIssues.join(', ')}) -- no further cycle can make progress. Exiting cycle loop straight into the finish phases.`);
|
|
2999
4362
|
endGroup();
|
|
3000
4363
|
break;
|
|
3001
4364
|
}
|
|
3002
4365
|
|
|
3003
|
-
if (
|
|
4366
|
+
if (goalSatisfied) {
|
|
3004
4367
|
// apra-fleet-rp7a.1: the deferred enumeration rides on the EXIT
|
|
3005
4368
|
// line specifically, because this is the line that says the sprint
|
|
3006
4369
|
// is finished -- a scope whose only remaining not-done beads were
|
|
@@ -3032,14 +4395,22 @@ async function runSprintCycle(context) {
|
|
|
3032
4395
|
`. Continuing.`
|
|
3033
4396
|
);
|
|
3034
4397
|
|
|
4398
|
+
handleLateDecisionAnswers();
|
|
3035
4399
|
cycle++;
|
|
3036
4400
|
endGroup();
|
|
3037
4401
|
}
|
|
3038
4402
|
|
|
4403
|
+
// An answer recorded after the last cycle's bracket never reached a cycle.
|
|
4404
|
+
if (decisionWait && decisionWait.hasQueuedAnswers()) {
|
|
4405
|
+
const line = 'Decision answer(s) recorded too late to be applied in this run (the cycle loop had ended); the decision(s) stay pending. Re-run the sprint to work the released bead(s).';
|
|
4406
|
+
lateUnworkedReports.push(line);
|
|
4407
|
+
log(line);
|
|
4408
|
+
}
|
|
4409
|
+
|
|
3039
4410
|
// When the loop exits because `cycle` exceeded MAX_CYCLES (rather than via
|
|
3040
4411
|
// an early `break`), `cycle` is MAX_CYCLES + 1 at this point; the labels
|
|
3041
4412
|
// below must report the last cycle actually run.
|
|
3042
|
-
const finalCycleLabel = Math.min(cycle,
|
|
4413
|
+
const finalCycleLabel = Math.min(cycle, effectiveMaxCycles);
|
|
3043
4414
|
|
|
3044
4415
|
// =======================
|
|
3045
4416
|
// 6. Finalization: the evidence-based final verdict drives the return value
|
|
@@ -3062,13 +4433,18 @@ async function runSprintCycle(context) {
|
|
|
3062
4433
|
// hold the line.
|
|
3063
4434
|
const { finalVerdictResult, finalClosedCount, finalOpenAtGoalCount, finalDeferredAtGoalIds } = await runFinalReviewPhase({
|
|
3064
4435
|
phase, log, command, dispatchCtx,
|
|
3065
|
-
args, validated, targetIssues,
|
|
4436
|
+
args, validated, targetIssues, backlogMember, finalCycleLabel, sprintState,
|
|
3066
4437
|
gitSync,
|
|
3067
4438
|
deployFailures, integFailures, rejectedNewTasks, verifyEverIds,
|
|
4439
|
+
lastDeployFailure,
|
|
3068
4440
|
bdListScoped, decomposedParentIds, goalMax, NOT_DONE_STATUSES,
|
|
3069
|
-
|
|
4441
|
+
reclaimCappedIds: orphanClaims.cappedIds(),
|
|
4442
|
+
verifyBlockDiagnosis,
|
|
4443
|
+
workedOnIds: workedOnBeadIds,
|
|
4444
|
+
kbPriming, kbWork, kbInjection, kbSprintContext, getMemberForRole,
|
|
3070
4445
|
childIdAllocator, sprintMutexId, resolveSettleShell,
|
|
3071
4446
|
computeChildFloor, createChildBeadWithAllocatedId, sanitizePrText,
|
|
4447
|
+
reviewMergeBaseFor,
|
|
3072
4448
|
});
|
|
3073
4449
|
|
|
3074
4450
|
// =======================
|
|
@@ -3101,8 +4477,17 @@ async function runSprintCycle(context) {
|
|
|
3101
4477
|
// part 2 provisions its own fresh sandbox install, so neither depends on
|
|
3102
4478
|
// the per-cycle Deploy target.
|
|
3103
4479
|
let regressionResult = null;
|
|
3104
|
-
|
|
3105
|
-
|
|
4480
|
+
// An explicit launch option (skip_regression) skips the pass outright --
|
|
4481
|
+
// checked BEFORE the playbook probe so a deliberate skip is never reported
|
|
4482
|
+
// as "no playbook found". The skip is carried to the sprint report and the
|
|
4483
|
+
// PR body (regressionSkippedBy) so it can never read as a pass.
|
|
4484
|
+
const regressionSkippedBy = validated.skipRegression ? 'launch option' : null;
|
|
4485
|
+
const hasRegressionPlaybook = regressionSkippedBy
|
|
4486
|
+
? false
|
|
4487
|
+
: await probeFileExists('regression-test-playbook.md', getMemberForRole('regression-test-runner'));
|
|
4488
|
+
if (regressionSkippedBy) {
|
|
4489
|
+
log(`Skipping Regression Test Phase: skipped by ${regressionSkippedBy} (skip_regression).`);
|
|
4490
|
+
} else if (hasRegressionPlaybook) {
|
|
3106
4491
|
// The phase body lives in ./phases/regression-test.mjs
|
|
3107
4492
|
// (apra-fleet-3swo.6.6). The probeFileExists call that produces
|
|
3108
4493
|
// hasRegressionPlaybook, the `let regressionResult = null` default and
|
|
@@ -3121,21 +4506,27 @@ async function runSprintCycle(context) {
|
|
|
3121
4506
|
log('Skipping Regression Test Phase (no regression-test-playbook.md found, or the probe itself failed -- see prior log line)');
|
|
3122
4507
|
}
|
|
3123
4508
|
|
|
3124
|
-
// The phase body lives in ./phases/harvest.mjs (apra-fleet-3swo.6.9).
|
|
3125
|
-
//
|
|
3126
|
-
// and the issue deferrals are all
|
|
3127
|
-
// its own repo, and the 'harvester' policy row's pushCode/pushBeads
|
|
3128
|
-
// publishes
|
|
4509
|
+
// The phase body lives in ./phases/harvest.mjs (apra-fleet-3swo.6.9). The
|
|
4510
|
+
// sprint-analysis document (written locally, never committed), the docs
|
|
4511
|
+
// commits and the issue deferrals are all made by the DISPATCHED harvester
|
|
4512
|
+
// in its own repo, and the 'harvester' policy row's pushCode/pushBeads
|
|
4513
|
+
// bracket publishes the commits and deferrals. The
|
|
4514
|
+
// only value it returns is the cost block Publish PR renders. It must
|
|
3129
4515
|
// nonetheless run HERE, after Regression Test (whose summary it folds into
|
|
3130
4516
|
// the analysis document) and before Publish PR (which pushes the branch the
|
|
3131
4517
|
// harvester just committed to).
|
|
3132
|
-
await runHarvestPhase({
|
|
4518
|
+
const { costAnalysis } = await runHarvestPhase({
|
|
3133
4519
|
phase, log, dispatchCtx,
|
|
3134
4520
|
validated, targetIssues, finalCycleLabel, budget,
|
|
3135
4521
|
closedCountHistory, highWaterClosedCount,
|
|
3136
4522
|
deployFailures, integFailures, rejectedNewTasks,
|
|
3137
4523
|
integTestRunnerSpend, integTestRunnerDispatchCount,
|
|
3138
|
-
finalVerdictResult, finalClosedCount, finalOpenAtGoalCount, finalDeferredAtGoalIds, regressionResult,
|
|
4524
|
+
finalVerdictResult, finalClosedCount, finalOpenAtGoalCount, finalDeferredAtGoalIds, regressionResult, regressionSkippedBy,
|
|
4525
|
+
dispatchToolCalls: sprintState.dispatchToolCalls,
|
|
4526
|
+
setAside: collectSetAsideEntries(sprintState),
|
|
4527
|
+
waited: collectWaitEntries(sprintState),
|
|
4528
|
+
kbWork,
|
|
4529
|
+
command, memberSeCommands,
|
|
3139
4530
|
computeBranchSlug, buildAnalysisText, buildCostAnalysis,
|
|
3140
4531
|
});
|
|
3141
4532
|
|
|
@@ -3154,14 +4545,23 @@ async function runSprintCycle(context) {
|
|
|
3154
4545
|
// unpushed branch) while PRESERVING the sprint's own computed verdict; a
|
|
3155
4546
|
// genuine PR-creation failure still throws a typed CommandError out of the
|
|
3156
4547
|
// phase, before the endGroup() below, exactly as the inline version did.
|
|
3157
|
-
|
|
4548
|
+
// Sprint-summary WARN: repeat the lower-quality banner once at the end.
|
|
4549
|
+
const lowerQualityBanner = logLowerQualityWarn(log, MEMBER_INIT_LOG_PREFIX, sprintState.memberInit, 'summary');
|
|
4550
|
+
const { pushed, prSkipped } = await runPublishPrPhase({
|
|
4551
|
+
lowerQualityBanner,
|
|
3158
4552
|
phase, log, command,
|
|
3159
|
-
args, validated, targetIssues,
|
|
4553
|
+
args, validated, targetIssues, backlogMember, finalCycleLabel,
|
|
3160
4554
|
gitSync, getMemberForRole,
|
|
3161
|
-
finalVerdictResult,
|
|
3162
|
-
|
|
4555
|
+
finalVerdictResult, costAnalysis,
|
|
4556
|
+
setAside: collectSetAsideEntries(sprintState),
|
|
4557
|
+
waited: collectWaitEntries(sprintState),
|
|
3163
4558
|
});
|
|
3164
4559
|
|
|
4560
|
+
// Final summary line: a skipped PR must not read as a clean success.
|
|
4561
|
+
if (prSkipped) {
|
|
4562
|
+
log(`[Sprint Summary] ${finalVerdictResult.verdict}, ${prSkipped.message} (reason: ${prSkipped.reason}); branch '${validated.branch}' is pushed.`);
|
|
4563
|
+
}
|
|
4564
|
+
|
|
3165
4565
|
endGroup();
|
|
3166
4566
|
|
|
3167
4567
|
// The final verdict -- not a blanket, unconditional 'success' -- drives the
|
|
@@ -3174,12 +4574,24 @@ async function runSprintCycle(context) {
|
|
|
3174
4574
|
return {
|
|
3175
4575
|
status: finalVerdictResult.verdict === 'PASS' ? 'success' : 'failed',
|
|
3176
4576
|
verdict: finalVerdictResult.verdict,
|
|
3177
|
-
notes: finalVerdictResult.notes
|
|
4577
|
+
notes: lateUnworkedReports.length > 0 && typeof finalVerdictResult.notes === 'string'
|
|
4578
|
+
? `${finalVerdictResult.notes}\n${lateUnworkedReports.join('\n')}`
|
|
4579
|
+
: finalVerdictResult.notes,
|
|
3178
4580
|
branch: validated.branch,
|
|
3179
4581
|
baseBranch: validated.baseBranch,
|
|
3180
4582
|
goal: validated.goal,
|
|
3181
4583
|
maxCycles: validated.maxCycles,
|
|
3182
4584
|
pushed,
|
|
4585
|
+
// Present only when the branch was pushed but no PR was opened
|
|
4586
|
+
// ({ reason, message }); surfaces in the supervisor's persisted
|
|
4587
|
+
// terminal state as state.result.prSkipped. Never changes the verdict.
|
|
4588
|
+
// A PASS whose PR was skipped (push ok, PR not opened) ends as
|
|
4589
|
+
// 'success-with-warnings' so it never reads as a plain success.
|
|
4590
|
+
...(prSkipped ? {
|
|
4591
|
+
...(finalVerdictResult.verdict === 'PASS' ? { status: 'success-with-warnings' } : {}),
|
|
4592
|
+
prSkipped,
|
|
4593
|
+
warnings: [`${prSkipped.message} (reason: ${prSkipped.reason})`],
|
|
4594
|
+
} : {}),
|
|
3183
4595
|
};
|
|
3184
4596
|
}
|
|
3185
4597
|
|
|
@@ -3252,6 +4664,11 @@ export async function main(context) {
|
|
|
3252
4664
|
try {
|
|
3253
4665
|
return await runSprintCycle(runContext);
|
|
3254
4666
|
} catch (err) {
|
|
4667
|
+
// An aborted sprint commits nothing further to the KB bible: its
|
|
4668
|
+
// queued confirmations are not flushed.
|
|
4669
|
+
if (runContext.kbWork && typeof runContext.kbWork.seal === 'function') {
|
|
4670
|
+
runContext.kbWork.seal(`sprint aborted: ${err && err.message ? err.message : String(err)}`);
|
|
4671
|
+
}
|
|
3255
4672
|
if (!isTerminalSprintFailure(err)) {
|
|
3256
4673
|
throw err;
|
|
3257
4674
|
}
|
|
@@ -3274,20 +4691,20 @@ export async function main(context) {
|
|
|
3274
4691
|
if (isTypedAbortError(err)) {
|
|
3275
4692
|
try {
|
|
3276
4693
|
// apra-fleet: finalizeAbort() runs `git fetch`/`git push` against
|
|
3277
|
-
// this member's LOCAL checkout, which the
|
|
4694
|
+
// this member's LOCAL checkout, which the backlog role no
|
|
3278
4695
|
// longer has (it may be a shared/unreservable, git-less member --
|
|
3279
4696
|
// see docs/design-orchestrator-worktree-model-v2.md section 4.5).
|
|
3280
4697
|
// Resolve a git-capable DISPATCH member instead: the harvester's
|
|
3281
4698
|
// member (the last code-writing role, so its clone pushed most
|
|
3282
4699
|
// recently), falling back to the first doer, never
|
|
3283
|
-
// roleMap.
|
|
4700
|
+
// roleMap.backlog and never a bare validatedForLock.members[0]
|
|
3284
4701
|
// pick (that silent pick is the original bug this closes).
|
|
3285
4702
|
const roleMap = validatedForLock.roleMap;
|
|
3286
4703
|
const harvesterMembers = (roleMap && Array.isArray(roleMap['harvester'])) ? roleMap['harvester'] : [];
|
|
3287
4704
|
const doerMembers = (roleMap && Array.isArray(roleMap[ROLE_DOER])) ? roleMap[ROLE_DOER] : [];
|
|
3288
4705
|
const member = harvesterMembers[0]
|
|
3289
4706
|
?? doerMembers[0]
|
|
3290
|
-
?? validatedForLock.members.find((m) => !roleMap || !roleMap[
|
|
4707
|
+
?? validatedForLock.members.find((m) => !roleMap || !roleMap[ROLE_BACKLOG] || !roleMap[ROLE_BACKLOG].includes(m));
|
|
3291
4708
|
if (!member) {
|
|
3292
4709
|
log('[Terminal History] finalizeAbort() skipped: no harvester/doer/dispatch member could be resolved to push the aborted branch.');
|
|
3293
4710
|
throw new Error('no git-capable member resolved for finalizeAbort');
|
|
@@ -3301,6 +4718,7 @@ export async function main(context) {
|
|
|
3301
4718
|
log,
|
|
3302
4719
|
onAuthFailure: abortOnAuthFailure,
|
|
3303
4720
|
callTool: (args && typeof args.callTool === 'function') ? args.callTool : undefined,
|
|
4721
|
+
runId: (args && typeof args.run_id === 'string') ? args.run_id : undefined,
|
|
3304
4722
|
});
|
|
3305
4723
|
} catch (finalizeErr) {
|
|
3306
4724
|
log(
|