@apralabs/apra-fleet 0.4.2 → 0.4.4
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 +103 -34
- package/dist/agents/backlog-groomer.md +87 -14
- package/dist/agents/ci-watcher.md +35 -9
- package/dist/agents/deployer.md +63 -11
- package/dist/agents/doer.md +99 -41
- package/dist/agents/harvester.md +47 -27
- package/dist/agents/integ-test-runner.md +38 -10
- package/dist/agents/kb-reconciler.md +37 -7
- package/dist/agents/plan-reviewer.md +145 -32
- package/dist/agents/planner.md +180 -69
- package/dist/agents/regression-test-runner.md +98 -64
- package/dist/agents/reviewer.md +117 -45
- package/dist/agents/schemas/backlog-groomer-output.json +1 -1
- package/dist/agents/schemas/doer-output.json +32 -0
- package/dist/agents/schemas/harvester-input.json +1 -5
- package/dist/agents/schemas/plan-reviewer-output.json +37 -0
- 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 +62 -3
- package/dist/cli/agent-transform.d.ts +90 -2
- package/dist/cli/agent-transform.js +310 -20
- package/dist/cli/auth.d.ts +1 -0
- package/dist/cli/auth.js +66 -17
- 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 +27 -0
- package/dist/cli/call.d.ts +27 -0
- package/dist/cli/call.js +177 -0
- package/dist/cli/config.d.ts +31 -6
- package/dist/cli/config.js +113 -36
- package/dist/cli/dolt-install.d.ts +18 -2
- package/dist/cli/dolt-install.js +46 -15
- package/dist/cli/fleet-se-guard.d.ts +51 -0
- package/dist/cli/fleet-se-guard.js +215 -0
- package/dist/cli/install-guard.d.ts +54 -0
- package/dist/cli/install-guard.js +132 -4
- package/dist/cli/install.d.ts +100 -11
- package/dist/cli/install.js +864 -139
- package/dist/cli/kb-commit.d.ts +2 -1
- package/dist/cli/kb-commit.js +1 -1
- package/dist/cli/kb-directives.js +2 -1
- package/dist/cli/kb-import.d.ts +2 -1
- package/dist/cli/kb-import.js +1 -1
- package/dist/cli/register-member.js +26 -5
- 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 +59 -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 +101 -15
- package/dist/cli/update.js +33 -2
- package/dist/cli/watch.js +1 -1
- package/dist/cli/workflow.js +3 -2
- package/dist/commands/kb-server.d.ts +3 -0
- package/dist/commands/kb-server.js +52 -5
- package/dist/hub-service/http-server.d.ts +5 -1
- package/dist/hub-service/http-server.js +55 -5
- package/dist/index.js +158 -11
- package/dist/os/child-env-bound.d.ts +77 -0
- package/dist/os/child-env-bound.js +171 -0
- package/dist/os/linux.d.ts +13 -2
- package/dist/os/linux.js +75 -16
- package/dist/os/macos.d.ts +1 -1
- package/dist/os/macos.js +2 -11
- package/dist/os/os-commands.d.ts +78 -4
- package/dist/os/windows-gitbash.d.ts +6 -0
- package/dist/os/windows-gitbash.js +32 -3
- package/dist/os/windows-wrapper.d.ts +0 -4
- package/dist/os/windows-wrapper.js +2 -1
- package/dist/os/windows.d.ts +11 -2
- package/dist/os/windows.js +121 -32
- package/dist/paths.d.ts +21 -0
- package/dist/paths.js +35 -0
- package/dist/providers/agy.d.ts +120 -7
- package/dist/providers/agy.js +741 -86
- 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 +132 -6
- package/dist/providers/claude.js +644 -48
- package/dist/providers/codex.d.ts +4 -2
- package/dist/providers/codex.js +23 -2
- package/dist/providers/copilot.d.ts +4 -2
- package/dist/providers/copilot.js +24 -2
- package/dist/providers/none.d.ts +4 -2
- package/dist/providers/none.js +17 -2
- package/dist/providers/opencode.d.ts +12 -2
- package/dist/providers/opencode.js +135 -54
- package/dist/providers/provider.d.ts +368 -35
- package/dist/providers/provider.js +219 -2
- 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 +103 -0
- package/dist/services/agy-project.js +354 -0
- package/dist/services/auth-socket.d.ts +25 -0
- package/dist/services/auth-socket.js +72 -27
- package/dist/services/auth-web.js +2 -2
- 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 +52 -6
- package/dist/services/cloud/task-wrapper.d.ts +0 -9
- package/dist/services/cloud/task-wrapper.js +15 -6
- package/dist/services/credential-cleanup.js +35 -17
- package/dist/services/event-loop-watchdog.d.ts +32 -0
- package/dist/services/event-loop-watchdog.js +140 -0
- package/dist/services/exit-drain.d.ts +44 -0
- package/dist/services/exit-drain.js +52 -0
- package/dist/services/github-app.js +32 -4
- package/dist/services/http-transport.d.ts +50 -1
- package/dist/services/http-transport.js +238 -25
- package/dist/services/in-flight-agents.d.ts +2 -0
- package/dist/services/in-flight-agents.js +4 -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 +113 -0
- package/dist/services/knowledge/bible-import.d.ts +65 -0
- package/dist/services/knowledge/bible-import.js +211 -0
- package/dist/services/knowledge/file-hash.d.ts +31 -0
- package/dist/services/knowledge/file-hash.js +153 -23
- package/dist/services/knowledge/http-provider.d.ts +4 -3
- package/dist/services/knowledge/http-provider.js +17 -5
- package/dist/services/knowledge/kb-config.d.ts +42 -0
- package/dist/services/knowledge/kb-config.js +54 -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 +11 -1
- package/dist/services/knowledge/kb-providers.js +199 -17
- 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 +91 -0
- package/dist/services/knowledge/kb-self.js +198 -0
- package/dist/services/knowledge/member-bible-view.d.ts +21 -0
- package/dist/services/knowledge/member-bible-view.js +194 -0
- package/dist/services/knowledge/pre-init.js +1 -0
- package/dist/services/knowledge/project-slug.js +2 -2
- package/dist/services/knowledge/require-sqlite-project.d.ts +32 -0
- package/dist/services/knowledge/require-sqlite-project.js +38 -0
- package/dist/services/knowledge/sqlite-provider.d.ts +64 -11
- package/dist/services/knowledge/sqlite-provider.js +303 -41
- package/dist/services/knowledge/types.d.ts +45 -2
- package/dist/services/member-access-secret.d.ts +70 -0
- package/dist/services/member-access-secret.js +195 -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 +192 -0
- package/dist/services/member-config-io.js +443 -0
- package/dist/services/member-fleet-install.d.ts +710 -0
- package/dist/services/member-fleet-install.js +1895 -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 +111 -0
- package/dist/services/model-pricing.d.ts +19 -0
- package/dist/services/model-pricing.js +60 -10
- package/dist/services/port-holder.d.ts +86 -0
- package/dist/services/port-holder.js +351 -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/secret-token.d.ts +38 -0
- package/dist/services/secret-token.js +51 -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 +39 -2
- package/dist/services/service-manager/types.js +29 -0
- package/dist/services/service-manager/windows.d.ts +194 -3
- package/dist/services/service-manager/windows.js +705 -30
- package/dist/services/service-notice.d.ts +14 -0
- package/dist/services/service-notice.js +62 -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/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 +287 -40
- 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 +53 -12
- package/dist/services/stall/stall-detector.d.ts +78 -5
- package/dist/services/stall/stall-detector.js +296 -39
- package/dist/services/stall/stall-poller.d.ts +16 -0
- package/dist/services/stall/stall-poller.js +50 -6
- 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 +165 -19
- package/dist/services/substitution-engine.js +2 -2
- package/dist/services/supervisor-service-cleanup.d.ts +52 -0
- package/dist/services/supervisor-service-cleanup.js +332 -0
- package/dist/services/tool-registry.d.ts +8 -1
- package/dist/services/tool-registry.js +164 -61
- package/dist/services/tool-scope.d.ts +58 -0
- package/dist/services/tool-scope.js +99 -0
- package/dist/services/vcs/azure-devops.d.ts +66 -1
- package/dist/services/vcs/azure-devops.js +192 -21
- package/dist/services/vcs/types.d.ts +1 -1
- package/dist/services/watch/project-resolver.js +1 -0
- package/dist/skills/auto-sprint-args/SKILL.md +2 -2
- package/dist/skills/fleet-sprint-cli/SKILL.md +48 -6
- package/dist/skills/pm/SKILL.md +4 -4
- package/dist/skills/pm/cost.md +0 -3
- package/dist/skills/pm/fleet-addendum.md +2 -2
- package/dist/skills/pm/index.md +4 -2
- package/dist/skills/pm/kb-reconcile.md +29 -14
- package/dist/skills/pm/kb-review.md +1 -0
- package/dist/skills/pm/sprint.md +5 -5
- package/dist/tools/check-status.d.ts +60 -9
- package/dist/tools/check-status.js +211 -52
- 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 +30 -0
- package/dist/tools/code-intelligence-gitnexus.js +333 -57
- package/dist/tools/code-intelligence-kb-enrich.js +7 -6
- package/dist/tools/code-intelligence-readiness.d.ts +99 -0
- package/dist/tools/code-intelligence-readiness.js +206 -0
- package/dist/tools/code-intelligence-reindex.d.ts +195 -0
- package/dist/tools/code-intelligence-reindex.js +530 -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 +63 -2
- package/dist/tools/compose-permissions.js +673 -72
- package/dist/tools/credential-store-set.js +1 -1
- package/dist/tools/execute-command.d.ts +11 -0
- package/dist/tools/execute-command.js +111 -32
- package/dist/tools/execute-prompt.d.ts +69 -12
- package/dist/tools/execute-prompt.js +1610 -895
- package/dist/tools/kb-bible-commit.d.ts +65 -0
- package/dist/tools/kb-bible-commit.js +239 -0
- package/dist/tools/kb-capture.d.ts +15 -11
- package/dist/tools/kb-capture.js +71 -16
- package/dist/tools/kb-context.d.ts +27 -7
- package/dist/tools/kb-context.js +60 -9
- package/dist/tools/kb-export.d.ts +98 -9
- package/dist/tools/kb-export.js +230 -92
- package/dist/tools/kb-feedback.d.ts +13 -9
- package/dist/tools/kb-feedback.js +16 -8
- package/dist/tools/kb-freshness-sweep.d.ts +11 -7
- package/dist/tools/kb-freshness-sweep.js +10 -8
- package/dist/tools/kb-harvest.d.ts +11 -7
- package/dist/tools/kb-harvest.js +7 -7
- package/dist/tools/kb-import.d.ts +26 -10
- package/dist/tools/kb-import.js +170 -159
- package/dist/tools/kb-invalidate.d.ts +17 -10
- package/dist/tools/kb-invalidate.js +41 -8
- package/dist/tools/kb-list.d.ts +14 -10
- package/dist/tools/kb-list.js +33 -11
- package/dist/tools/kb-promote.d.ts +11 -7
- package/dist/tools/kb-promote.js +14 -8
- package/dist/tools/kb-query.d.ts +21 -11
- package/dist/tools/kb-query.js +76 -13
- package/dist/tools/kb-reconcile-prefilter.d.ts +11 -7
- package/dist/tools/kb-reconcile-prefilter.js +13 -9
- package/dist/tools/kb-resolve-contradiction.d.ts +11 -7
- package/dist/tools/kb-resolve-contradiction.js +10 -8
- package/dist/tools/kb-session-prime.d.ts +14 -7
- package/dist/tools/kb-session-prime.js +44 -44
- package/dist/tools/kb-setup.d.ts +11 -4
- package/dist/tools/kb-setup.js +146 -27
- package/dist/tools/kb-stats.d.ts +11 -10
- package/dist/tools/kb-stats.js +84 -82
- package/dist/tools/list-members.d.ts +2 -2
- package/dist/tools/list-members.js +6 -2
- package/dist/tools/member-detail.d.ts +5 -2
- package/dist/tools/member-detail.js +105 -17
- package/dist/tools/member-reservation.d.ts +60 -3
- package/dist/tools/member-reservation.js +61 -20
- package/dist/tools/provision-auth.d.ts +118 -1
- package/dist/tools/provision-auth.js +402 -92
- package/dist/tools/provision-vcs-auth.d.ts +93 -3
- package/dist/tools/provision-vcs-auth.js +209 -49
- package/dist/tools/receive-files.js +3 -1
- package/dist/tools/register-member.d.ts +44 -15
- package/dist/tools/register-member.js +175 -70
- package/dist/tools/remove-member.js +118 -15
- package/dist/tools/send-email.d.ts +2 -2
- package/dist/tools/send-files.js +6 -4
- package/dist/tools/session-stats.d.ts +17 -0
- package/dist/tools/session-stats.js +27 -0
- package/dist/tools/setup-git-app.js +11 -7
- package/dist/tools/shutdown-server.d.ts +2 -0
- package/dist/tools/shutdown-server.js +28 -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 +23 -17
- package/dist/tools/update-member.js +181 -18
- package/dist/tools/vcs-credential-exec.d.ts +127 -0
- package/dist/tools/vcs-credential-exec.js +203 -0
- package/dist/types.d.ts +111 -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 +108 -22
- 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 +68 -0
- package/dist/utils/prompt-errors.js +11 -2
- package/dist/utils/session-caller.d.ts +4 -2
- package/dist/utils/session-caller.js +3 -2
- package/dist/utils/shell-escape.d.ts +58 -3
- package/dist/utils/shell-escape.js +91 -5
- package/dist/utils/ssh-error-messages.js +3 -0
- package/dist/utils/vcs-provider-detect.d.ts +65 -0
- package/dist/utils/vcs-provider-detect.js +109 -0
- package/dist/utils/workspace-trust.d.ts +26 -0
- package/dist/utils/workspace-trust.js +91 -1
- package/dist/workflows/auto-sprint.js +397 -56
- package/package.json +15 -10
- package/packages/apra-fleet-client/package.json +2 -2
- package/packages/apra-fleet-client/src/client/api.mjs +864 -31
- 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/errors.mjs +6 -2
- package/packages/apra-fleet-client/src/client/factory.mjs +23 -4
- package/packages/apra-fleet-client/src/client/reconnecting-transport.mjs +137 -0
- package/packages/apra-fleet-client/src/client/server-resolution.mjs +267 -30
- package/packages/apra-fleet-client/src/client/transport.mjs +37 -3
- package/packages/apra-fleet-se/apra-pm/agents/_shared/GRAPH-SEMANTICS.md +10 -2
- package/packages/apra-fleet-se/apra-pm/agents/backlog-groomer.md +87 -14
- package/packages/apra-fleet-se/apra-pm/agents/ci-watcher.md +35 -9
- package/packages/apra-fleet-se/apra-pm/agents/deployer.md +63 -11
- package/packages/apra-fleet-se/apra-pm/agents/doer.md +99 -41
- package/packages/apra-fleet-se/apra-pm/agents/harvester.md +47 -27
- package/packages/apra-fleet-se/apra-pm/agents/integ-test-runner.md +38 -10
- package/packages/apra-fleet-se/apra-pm/agents/kb-reconciler.md +37 -7
- package/packages/apra-fleet-se/apra-pm/agents/plan-reviewer.md +145 -32
- package/packages/apra-fleet-se/apra-pm/agents/planner.md +180 -69
- package/packages/apra-fleet-se/apra-pm/agents/regression-test-runner.md +98 -64
- package/packages/apra-fleet-se/apra-pm/agents/reviewer.md +117 -45
- package/packages/apra-fleet-se/apra-pm/agents/schemas/backlog-groomer-output.json +1 -1
- package/packages/apra-fleet-se/apra-pm/agents/schemas/doer-output.json +32 -0
- package/packages/apra-fleet-se/apra-pm/agents/schemas/harvester-input.json +1 -5
- package/packages/apra-fleet-se/apra-pm/agents/schemas/plan-reviewer-output.json +37 -0
- 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 +62 -3
- package/packages/apra-fleet-se/apra-pm/skills/pm/SKILL.md +4 -4
- package/packages/apra-fleet-se/apra-pm/skills/pm/cost.md +0 -3
- package/packages/apra-fleet-se/apra-pm/skills/pm/fleet-addendum.md +2 -2
- package/packages/apra-fleet-se/apra-pm/skills/pm/index.md +4 -2
- 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 +5 -5
- package/packages/apra-fleet-se/bin/cli.mjs +326 -48
- package/packages/apra-fleet-se/bin/serve.mjs +218 -11
- package/packages/apra-fleet-se/fleet-sprint/abort.mjs +517 -0
- package/packages/apra-fleet-se/fleet-sprint/backlog-role.mjs +93 -0
- package/packages/apra-fleet-se/fleet-sprint/beads-children.mjs +646 -0
- package/packages/apra-fleet-se/fleet-sprint/beads-identity-check.mjs +825 -0
- package/packages/apra-fleet-se/fleet-sprint/beads-identity.mjs +217 -0
- package/packages/apra-fleet-se/fleet-sprint/beads-memory-hygiene.mjs +201 -0
- package/packages/apra-fleet-se/fleet-sprint/beads-scope.mjs +745 -0
- package/packages/apra-fleet-se/fleet-sprint/beads-transitions.mjs +447 -0
- package/packages/apra-fleet-se/fleet-sprint/branch-ensure.mjs +96 -0
- package/packages/apra-fleet-se/fleet-sprint/ci-gate.mjs +353 -0
- package/packages/apra-fleet-se/fleet-sprint/conflict-ladder.mjs +20 -0
- package/packages/apra-fleet-se/fleet-sprint/contracts.mjs +121 -15
- package/packages/apra-fleet-se/fleet-sprint/coordination.mjs +539 -0
- package/packages/apra-fleet-se/fleet-sprint/dispatch-accounting.mjs +270 -0
- package/packages/apra-fleet-se/fleet-sprint/dispatch-failure.mjs +204 -0
- package/packages/apra-fleet-se/fleet-sprint/dispatch-role.mjs +1310 -0
- package/packages/apra-fleet-se/fleet-sprint/dispatch-safety-guard.mjs +216 -4
- package/packages/apra-fleet-se/fleet-sprint/docs/README.md +53 -15
- package/packages/apra-fleet-se/fleet-sprint/docs/dolt-sync-redesign.md +281 -0
- package/packages/apra-fleet-se/fleet-sprint/docs/escalate-to-llm-design.md +1 -1
- package/packages/apra-fleet-se/fleet-sprint/docs/fleet-sprint-diagram.md +3 -3
- package/packages/apra-fleet-se/fleet-sprint/docs/run-sprint-cycle-prelude-decision.md +215 -0
- package/packages/apra-fleet-se/fleet-sprint/dolt-literal-guard.mjs +56 -1
- package/packages/apra-fleet-se/fleet-sprint/dolt-sync.mjs +1327 -44
- package/packages/apra-fleet-se/fleet-sprint/errors.mjs +470 -4
- package/packages/apra-fleet-se/fleet-sprint/explicit-id-create-guard.mjs +501 -0
- package/packages/apra-fleet-se/fleet-sprint/fatal-diagnostics.mjs +134 -0
- package/packages/apra-fleet-se/fleet-sprint/full-db-fetch-guard.mjs +102 -0
- package/packages/apra-fleet-se/fleet-sprint/git-sync.mjs +747 -0
- package/packages/apra-fleet-se/fleet-sprint/git-topology.mjs +543 -0
- package/packages/apra-fleet-se/fleet-sprint/guarded-modules.mjs +613 -0
- package/packages/apra-fleet-se/fleet-sprint/inline-ladder-guard.mjs +216 -0
- 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 +1684 -0
- package/packages/apra-fleet-se/fleet-sprint/lower-quality.mjs +39 -0
- package/packages/apra-fleet-se/fleet-sprint/mcp-result.mjs +75 -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 +699 -0
- package/packages/apra-fleet-se/fleet-sprint/member-sync.mjs +802 -0
- package/packages/apra-fleet-se/fleet-sprint/member-target.mjs +93 -0
- package/packages/apra-fleet-se/fleet-sprint/newtask-text.mjs +266 -0
- package/packages/apra-fleet-se/fleet-sprint/orphan-reclaim.mjs +153 -0
- package/packages/apra-fleet-se/fleet-sprint/parent-notes-staleness.mjs +201 -0
- package/packages/apra-fleet-se/fleet-sprint/phases/deploy.mjs +218 -0
- package/packages/apra-fleet-se/fleet-sprint/phases/develop.mjs +869 -0
- package/packages/apra-fleet-se/fleet-sprint/phases/ensure-sprint-branch.mjs +295 -0
- package/packages/apra-fleet-se/fleet-sprint/phases/final-review.mjs +466 -0
- package/packages/apra-fleet-se/fleet-sprint/phases/harvest.mjs +212 -0
- package/packages/apra-fleet-se/fleet-sprint/phases/integ-test.mjs +358 -0
- package/packages/apra-fleet-se/fleet-sprint/phases/plan.mjs +395 -0
- package/packages/apra-fleet-se/fleet-sprint/phases/publish-pr.mjs +345 -0
- package/packages/apra-fleet-se/fleet-sprint/phases/re-review.mjs +264 -0
- package/packages/apra-fleet-se/fleet-sprint/phases/regression-test.mjs +179 -0
- package/packages/apra-fleet-se/fleet-sprint/phases/replan.mjs +230 -0
- package/packages/apra-fleet-se/fleet-sprint/phases/review.mjs +365 -0
- package/packages/apra-fleet-se/fleet-sprint/pr-body.mjs +259 -0
- package/packages/apra-fleet-se/fleet-sprint/prompts.mjs +617 -0
- package/packages/apra-fleet-se/fleet-sprint/role-policies.mjs +1434 -0
- package/packages/apra-fleet-se/fleet-sprint/round-session.mjs +100 -0
- package/packages/apra-fleet-se/fleet-sprint/runner.js +2289 -9928
- package/packages/apra-fleet-se/fleet-sprint/se-os-commands.mjs +24 -0
- package/packages/apra-fleet-se/fleet-sprint/se-posix.mjs +147 -12
- package/packages/apra-fleet-se/fleet-sprint/se-windows.mjs +111 -0
- package/packages/apra-fleet-se/fleet-sprint/shell-command-guard.mjs +347 -0
- package/packages/apra-fleet-se/fleet-sprint/skills/fleet-sprint-cli/SKILL.md +48 -6
- package/packages/apra-fleet-se/fleet-sprint/skills/fleet-supervisor/SKILL.md +98 -25
- package/packages/apra-fleet-se/fleet-sprint/sprint-args.mjs +590 -0
- package/packages/apra-fleet-se/fleet-sprint/sprint-report.mjs +339 -0
- package/packages/apra-fleet-se/fleet-sprint/sprint-state.mjs +185 -0
- package/packages/apra-fleet-se/fleet-sprint/unbracketed-push-guard.mjs +234 -0
- package/packages/apra-fleet-se/fleet-sprint/usage-limit-controller.mjs +218 -0
- package/packages/apra-fleet-se/fleet-sprint/vcs-auth.mjs +1445 -0
- package/packages/apra-fleet-se/fleet-sprint/vcs-module.mjs +284 -23
- package/packages/apra-fleet-se/fleet-sprint/vcs-providers/azure-devops.mjs +170 -21
- package/packages/apra-fleet-se/fleet-sprint/vcs-providers/bitbucket.mjs +28 -0
- package/packages/apra-fleet-se/fleet-sprint/vcs-providers/github.mjs +354 -0
- package/packages/apra-fleet-se/fleet-sprint/vcs-providers/index.mjs +189 -16
- package/packages/apra-fleet-se/fleet-sprint/vcs-providers/shell-helpers.mjs +9 -4
- package/packages/apra-fleet-se/fleet-sprint/verify-block.mjs +152 -0
- package/packages/apra-fleet-se/fleet-sprint/viewer-extensions.mjs +311 -22
- package/packages/apra-fleet-se/fleet-sprint/worklists.mjs +559 -0
- package/packages/apra-fleet-se/package.json +2 -2
- package/packages/apra-fleet-se/src/supervisor/api.mjs +919 -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 +1659 -0
- package/packages/apra-fleet-se/src/supervisor/dolt-mutex.mjs +350 -0
- package/packages/apra-fleet-se/src/supervisor/dolt-orphan-sweep.mjs +338 -0
- package/packages/apra-fleet-se/src/supervisor/fleet-members.mjs +279 -0
- package/packages/apra-fleet-se/src/supervisor/history-view.mjs +276 -0
- package/packages/apra-fleet-se/src/supervisor/history.mjs +328 -0
- package/packages/apra-fleet-se/src/supervisor/id-allocator.mjs +521 -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 +474 -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 +399 -0
- package/packages/apra-fleet-se/src/supervisor/spawner.mjs +542 -0
- package/packages/apra-fleet-se/src/supervisor/sprint-identity.mjs +96 -0
- package/packages/apra-fleet-se/src/supervisor/watchdog.mjs +987 -0
- package/packages/apra-fleet-workflow/package.json +1 -1
- package/packages/apra-fleet-workflow/src/viewer/index.mjs +81 -15
- package/packages/apra-fleet-workflow/src/viewer/run-summary.mjs +127 -0
- package/packages/apra-fleet-workflow/src/workflow/index.mjs +118 -10
- package/packages/apra-fleet-workflow/src/workflow/pricing.mjs +75 -25
- package/skills/fleet/SKILL.md +8 -8
- package/skills/fleet/auth-azdevops.md +14 -3
- package/skills/fleet/auth-bitbucket.md +2 -2
- package/skills/fleet/auth-github.md +5 -4
- package/skills/fleet/onboarding.md +3 -3
- package/skills/fleet/permissions.md +14 -1
- package/skills/fleet/profiles/node.json +1 -1
- package/skills/fleet/profiles/tag-kb-reconciler.json +2 -6
- package/skills/fleet/troubleshooting.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/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/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-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/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/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/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/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
|
@@ -0,0 +1,521 @@
|
|
|
1
|
+
// =============================================================================
|
|
2
|
+
// fleet-sprint supervisor -- globally-coordinated child-id allocator
|
|
3
|
+
// (apra-fleet-eft.9.3, Plan Part 3.4)
|
|
4
|
+
// =============================================================================
|
|
5
|
+
//
|
|
6
|
+
// ONE supervisor-owned allocator that mints the next child id under a shared
|
|
7
|
+
// parent bead, so two concurrently-running sprints NEVER derive the same child
|
|
8
|
+
// id. This is a LOAD-BEARING v1 requirement, not a fallback:
|
|
9
|
+
//
|
|
10
|
+
// * PoC-confirmed constraint C.4: two sprints that each run
|
|
11
|
+
// `bd create --parent X` in their OWN dolt clone independently derive the
|
|
12
|
+
// same next child id (each clone only sees the siblings it already has), so
|
|
13
|
+
// both mint `X.<n>` -- and the two D-pushes then hard-conflict on that row
|
|
14
|
+
// (constraint C.2), which wedges the entire clone sync (constraint C.3).
|
|
15
|
+
//
|
|
16
|
+
// Therefore child-id minting for any shared parent MUST be globally serialized:
|
|
17
|
+
// the allocator lives HERE (the supervisor), the same authority that owns the
|
|
18
|
+
// dolt push mutex, and hands each creator an EXPLICIT, distinct child id that
|
|
19
|
+
// the sprint then passes to `bd create --id <childId>`. Because the id is
|
|
20
|
+
// pre-decided by one authority, the two creates target DIFFERENT rows and never
|
|
21
|
+
// conflict.
|
|
22
|
+
//
|
|
23
|
+
// -----------------------------------------------------------------------------
|
|
24
|
+
// Design points that map directly to the acceptance criteria:
|
|
25
|
+
//
|
|
26
|
+
// * Zero collisions under concurrent same-parent creation (C.4): each parent
|
|
27
|
+
// has its OWN monotonic sequence. allocate() assigns and advances that
|
|
28
|
+
// sequence SYNCHRONOUSLY (no await before the state mutation), so on JS's
|
|
29
|
+
// single thread two concurrent allocate() calls for the same parent can
|
|
30
|
+
// never read-modify-write the same counter -- they get strictly distinct,
|
|
31
|
+
// sequential ids.
|
|
32
|
+
//
|
|
33
|
+
// * Sequential per parent, concurrent across parents (NOT one global lock):
|
|
34
|
+
// the per-parent sequences are independent. There is no cross-parent lock
|
|
35
|
+
// held across an await, so an allocation under parent A never blocks an
|
|
36
|
+
// allocation under parent B. Same parent serializes (shared counter);
|
|
37
|
+
// different parents proceed in parallel.
|
|
38
|
+
//
|
|
39
|
+
// * State survives supervisor restart: every mutation is persisted atomically
|
|
40
|
+
// (temp file + rename) and allocate() does not resolve its id to the caller
|
|
41
|
+
// until the snapshot INCLUDING that id is durably on disk. A restarted
|
|
42
|
+
// supervisor reload()s the per-parent high-water marks, so it never re-mints
|
|
43
|
+
// an id it already handed out before the crash.
|
|
44
|
+
//
|
|
45
|
+
// * A child that dies mid-allocation does not leak or reserve a permanent gap
|
|
46
|
+
// that breaks later allocation: allocate() RESERVES a seq under a lease +
|
|
47
|
+
// recorded pid and returns a token; the sprint calls confirm(token) only
|
|
48
|
+
// AFTER `bd create` succeeds (durably committing the id), or release(token)
|
|
49
|
+
// if the create failed. A child that dies BEFORE confirming leaves an
|
|
50
|
+
// outstanding reservation whose lease expires / whose pid is found dead --
|
|
51
|
+
// reclaimExpired() then returns that seq to a per-parent free pool, and the
|
|
52
|
+
// next allocate() under that parent REUSES it. So an abandoned reservation
|
|
53
|
+
// becomes a benign, reclaimable hole, never a permanent gap and never a
|
|
54
|
+
// leaked/stuck counter.
|
|
55
|
+
// =============================================================================
|
|
56
|
+
|
|
57
|
+
import path from 'node:path';
|
|
58
|
+
import os from 'node:os';
|
|
59
|
+
import fsp from 'node:fs/promises';
|
|
60
|
+
|
|
61
|
+
import { isPidAlive } from './reconcile.mjs';
|
|
62
|
+
import { renameWithRetry } from './rename-with-retry.mjs';
|
|
63
|
+
|
|
64
|
+
/** On-disk schema version for the persisted allocator document. */
|
|
65
|
+
export const ID_ALLOCATOR_VERSION = 1;
|
|
66
|
+
|
|
67
|
+
/** Default file name for the persisted allocator state inside the data dir. */
|
|
68
|
+
export const ID_ALLOCATOR_FILENAME = 'child-id-allocator.json';
|
|
69
|
+
|
|
70
|
+
/** Default lease duration: how long a reserved-but-unconfirmed child id may
|
|
71
|
+
* stay outstanding before it is considered abandoned (crashed creator) and
|
|
72
|
+
* reclaimed. A `bd create` is sub-second; 60s is generous headroom. */
|
|
73
|
+
export const DEFAULT_LEASE_MS = 60_000;
|
|
74
|
+
|
|
75
|
+
/** Default background sweep interval for reclaiming abandoned reservations. */
|
|
76
|
+
export const DEFAULT_SWEEP_MS = 5_000;
|
|
77
|
+
|
|
78
|
+
let tokenSeq = 0;
|
|
79
|
+
/** Monotonic, collision-free reservation token. */
|
|
80
|
+
function nextToken(parentId) {
|
|
81
|
+
tokenSeq += 1;
|
|
82
|
+
return `${parentId}#${tokenSeq}#${Date.now().toString(36)}`;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
/** Default per-user data dir shared with the ledger. */
|
|
86
|
+
function defaultDataDir() {
|
|
87
|
+
return path.join(os.homedir() || os.tmpdir(), '.apra-fleet', 'supervisor');
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* Create the global child-id allocator.
|
|
92
|
+
*
|
|
93
|
+
* @param {{
|
|
94
|
+
* dataDir?: string,
|
|
95
|
+
* filePath?: string,
|
|
96
|
+
* leaseMs?: number,
|
|
97
|
+
* sweepMs?: number,
|
|
98
|
+
* now?: () => number,
|
|
99
|
+
* isPidAlive?: (pid: number) => boolean,
|
|
100
|
+
* setInterval?: typeof setInterval,
|
|
101
|
+
* clearInterval?: typeof clearInterval,
|
|
102
|
+
* fs?: {
|
|
103
|
+
* mkdir: typeof import('node:fs/promises').mkdir,
|
|
104
|
+
* readFile: typeof import('node:fs/promises').readFile,
|
|
105
|
+
* writeFile: typeof import('node:fs/promises').writeFile,
|
|
106
|
+
* rename: typeof import('node:fs/promises').rename,
|
|
107
|
+
* },
|
|
108
|
+
* logger?: { log?: Function, error?: Function },
|
|
109
|
+
* renameRetry?: {
|
|
110
|
+
* maxAttempts?: number,
|
|
111
|
+
* baseDelayMs?: number,
|
|
112
|
+
* sleep?: (ms: number) => Promise<void>,
|
|
113
|
+
* },
|
|
114
|
+
* apra-fleet-cvb.5: bounded EPERM/EBUSY retry options for the persist()
|
|
115
|
+
* rename step (see rename-with-retry.mjs), mirroring history.mjs's and
|
|
116
|
+
* ledger.mjs's ed4.1 wiring -- injectable so a test can drive a fake clock
|
|
117
|
+
* with no real sleeps. Defaults to renameWithRetry()'s own defaults
|
|
118
|
+
* (5 attempts, ~10ms escalating).
|
|
119
|
+
* }} [deps]
|
|
120
|
+
*/
|
|
121
|
+
export function createIdAllocator(deps = {}) {
|
|
122
|
+
const dataDir = deps.dataDir ?? defaultDataDir();
|
|
123
|
+
const filePath = deps.filePath ?? path.join(dataDir, ID_ALLOCATOR_FILENAME);
|
|
124
|
+
const tmpPath = `${filePath}.tmp`;
|
|
125
|
+
const leaseMs = Number.isFinite(deps.leaseMs) && deps.leaseMs > 0 ? deps.leaseMs : DEFAULT_LEASE_MS;
|
|
126
|
+
const sweepMs = Number.isFinite(deps.sweepMs) && deps.sweepMs > 0 ? deps.sweepMs : DEFAULT_SWEEP_MS;
|
|
127
|
+
const now = deps.now ?? (() => Date.now());
|
|
128
|
+
const probe = deps.isPidAlive ?? isPidAlive;
|
|
129
|
+
const setIntervalFn = deps.setInterval ?? setInterval;
|
|
130
|
+
const clearIntervalFn = deps.clearInterval ?? clearInterval;
|
|
131
|
+
const fs = deps.fs ?? fsp;
|
|
132
|
+
const logger = deps.logger ?? console;
|
|
133
|
+
const log = (...a) => logger.log?.(...a);
|
|
134
|
+
const renameRetryOpts = deps.renameRetry ?? {};
|
|
135
|
+
|
|
136
|
+
/**
|
|
137
|
+
* Per-parent allocation state. Each parent id maps to:
|
|
138
|
+
* highWater -- highest seq ever handed out for this parent (monotonic).
|
|
139
|
+
* free -- reclaimed seqs (abandoned reservations), reused smallest-
|
|
140
|
+
* first before advancing highWater, so a dead creator leaves
|
|
141
|
+
* no permanent gap.
|
|
142
|
+
* reserved -- outstanding reservations keyed by token:
|
|
143
|
+
* { seq, pid, sprintId, reservedAt, expiresAt }.
|
|
144
|
+
* @type {Map<string, { highWater: number, free: number[], reserved: Map<string, { seq: number, pid: number|null, sprintId: string|null, reservedAt: number, expiresAt: number }> }>}
|
|
145
|
+
*/
|
|
146
|
+
let parents = new Map();
|
|
147
|
+
let loaded = false;
|
|
148
|
+
let sweepTimer = null;
|
|
149
|
+
|
|
150
|
+
// Serialize every disk write so concurrent persists cannot interleave their
|
|
151
|
+
// temp-file writes and renames. The IN-MEMORY seq assignment is synchronous
|
|
152
|
+
// and happens BEFORE we enqueue the write, so different parents never block
|
|
153
|
+
// each other's id assignment -- they only queue behind the shared writer.
|
|
154
|
+
let persistChain = Promise.resolve();
|
|
155
|
+
|
|
156
|
+
function parentState(parentId) {
|
|
157
|
+
let st = parents.get(parentId);
|
|
158
|
+
if (!st) {
|
|
159
|
+
st = { highWater: 0, free: [], reserved: new Map() };
|
|
160
|
+
parents.set(parentId, st);
|
|
161
|
+
}
|
|
162
|
+
return st;
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
/** Serialize the whole allocator into the persisted document shape. */
|
|
166
|
+
function currentDocument() {
|
|
167
|
+
const doc = { version: ID_ALLOCATOR_VERSION, parents: {} };
|
|
168
|
+
for (const [parentId, st] of parents) {
|
|
169
|
+
const reserved = {};
|
|
170
|
+
for (const [token, r] of st.reserved) {
|
|
171
|
+
reserved[token] = { seq: r.seq, pid: r.pid, sprintId: r.sprintId, reservedAt: r.reservedAt, expiresAt: r.expiresAt };
|
|
172
|
+
}
|
|
173
|
+
doc.parents[parentId] = {
|
|
174
|
+
highWater: st.highWater,
|
|
175
|
+
free: [...st.free].sort((a, b) => a - b),
|
|
176
|
+
reserved,
|
|
177
|
+
};
|
|
178
|
+
}
|
|
179
|
+
return doc;
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
/**
|
|
183
|
+
* Atomically replace the on-disk state with a snapshot taken NOW (which
|
|
184
|
+
* already includes the just-made synchronous mutation). Chained so writes
|
|
185
|
+
* never interleave; the returned promise resolves once THIS snapshot is
|
|
186
|
+
* durably on disk. allocate() awaits it before resolving its id so a crash
|
|
187
|
+
* can never lose an already-handed-out id.
|
|
188
|
+
*/
|
|
189
|
+
function persist() {
|
|
190
|
+
const snapshot = `${JSON.stringify(currentDocument(), null, 2)}\n`;
|
|
191
|
+
const run = persistChain.then(async () => {
|
|
192
|
+
await fs.mkdir(path.dirname(filePath), { recursive: true });
|
|
193
|
+
await fs.writeFile(tmpPath, snapshot, 'utf-8');
|
|
194
|
+
// apra-fleet-cvb.5: bounded EPERM/EBUSY retry -- on Windows this
|
|
195
|
+
// rename can transiently fail while the destination is momentarily
|
|
196
|
+
// locked/open elsewhere, which would otherwise silently drop this
|
|
197
|
+
// allocator snapshot (same gap ed4.1 closed for history.mjs and
|
|
198
|
+
// ledger.mjs).
|
|
199
|
+
await renameWithRetry(fs, tmpPath, filePath, renameRetryOpts);
|
|
200
|
+
});
|
|
201
|
+
// Keep the chain alive regardless of this write's outcome so one failed
|
|
202
|
+
// write cannot poison every later write; the error still propagates to
|
|
203
|
+
// this caller via the returned promise.
|
|
204
|
+
persistChain = run.catch(() => {});
|
|
205
|
+
return run;
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
/**
|
|
209
|
+
* Load allocator state from disk. A missing file yields empty state. A
|
|
210
|
+
* corrupt/foreign-version file is a hard error -- the supervisor must not
|
|
211
|
+
* silently drop high-water marks and start re-minting live ids.
|
|
212
|
+
*/
|
|
213
|
+
async function load() {
|
|
214
|
+
let raw;
|
|
215
|
+
try {
|
|
216
|
+
raw = await fs.readFile(filePath, 'utf-8');
|
|
217
|
+
} catch (err) {
|
|
218
|
+
if (err && err.code === 'ENOENT') {
|
|
219
|
+
parents = new Map();
|
|
220
|
+
loaded = true;
|
|
221
|
+
return;
|
|
222
|
+
}
|
|
223
|
+
throw err;
|
|
224
|
+
}
|
|
225
|
+
let doc;
|
|
226
|
+
try {
|
|
227
|
+
doc = JSON.parse(raw);
|
|
228
|
+
} catch (err) {
|
|
229
|
+
throw new Error(`id-allocator file ${filePath} is not valid JSON: ${err.message}`);
|
|
230
|
+
}
|
|
231
|
+
if (!doc || typeof doc !== 'object' || doc.version !== ID_ALLOCATOR_VERSION || typeof doc.parents !== 'object') {
|
|
232
|
+
throw new Error(`id-allocator file ${filePath} has an unexpected shape or version (expected ${ID_ALLOCATOR_VERSION})`);
|
|
233
|
+
}
|
|
234
|
+
const next = new Map();
|
|
235
|
+
for (const [parentId, st] of Object.entries(doc.parents)) {
|
|
236
|
+
const reserved = new Map();
|
|
237
|
+
for (const [token, r] of Object.entries(st.reserved ?? {})) {
|
|
238
|
+
reserved.set(token, {
|
|
239
|
+
seq: r.seq,
|
|
240
|
+
pid: r.pid ?? null,
|
|
241
|
+
sprintId: r.sprintId ?? null,
|
|
242
|
+
reservedAt: r.reservedAt ?? 0,
|
|
243
|
+
expiresAt: r.expiresAt ?? 0,
|
|
244
|
+
});
|
|
245
|
+
}
|
|
246
|
+
next.set(parentId, {
|
|
247
|
+
highWater: Number.isInteger(st.highWater) ? st.highWater : 0,
|
|
248
|
+
free: Array.isArray(st.free) ? st.free.filter(Number.isInteger).sort((a, b) => a - b) : [],
|
|
249
|
+
reserved,
|
|
250
|
+
});
|
|
251
|
+
}
|
|
252
|
+
parents = next;
|
|
253
|
+
loaded = true;
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
/**
|
|
257
|
+
* Reclaim abandoned reservations across ALL parents: any reservation whose
|
|
258
|
+
* lease has expired OR whose recorded pid is no longer alive (a crashed
|
|
259
|
+
* creator that never confirmed/released) has its seq returned to that
|
|
260
|
+
* parent's free pool for reuse. Returns how many were reclaimed. Driven both
|
|
261
|
+
* on every allocate() and by the optional background sweep, so an abandoned
|
|
262
|
+
* reservation never permanently reserves an id.
|
|
263
|
+
* @returns {number}
|
|
264
|
+
*/
|
|
265
|
+
function reclaimExpired() {
|
|
266
|
+
const t = now();
|
|
267
|
+
let reclaimed = 0;
|
|
268
|
+
for (const [parentId, st] of parents) {
|
|
269
|
+
for (const [token, r] of st.reserved) {
|
|
270
|
+
const leaseExpired = t >= r.expiresAt;
|
|
271
|
+
// pid == null means the caller opted out of pid-probing (e.g.
|
|
272
|
+
// in-process test) -- rely on the lease alone.
|
|
273
|
+
const pidDead = r.pid != null && !probe(r.pid);
|
|
274
|
+
if (!leaseExpired && !pidDead) continue;
|
|
275
|
+
st.reserved.delete(token);
|
|
276
|
+
if (!st.free.includes(r.seq)) st.free.push(r.seq);
|
|
277
|
+
st.free.sort((a, b) => a - b);
|
|
278
|
+
reclaimed += 1;
|
|
279
|
+
log(`[id-allocator] reclaimed ${leaseExpired ? 'expired' : 'dead-pid'} reservation '${parentId}.${r.seq}' (sprint ${r.sprintId ?? 'n/a'}, pid ${r.pid ?? 'n/a'})`);
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
return reclaimed;
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
/**
|
|
286
|
+
* Allocate the next child id under `parentId`. Resolves ONLY after the
|
|
287
|
+
* allocation is durably persisted, so a crash can never lose it. The seq is
|
|
288
|
+
* assigned SYNCHRONOUSLY (before any await) so concurrent same-parent calls
|
|
289
|
+
* get strictly distinct, sequential ids; different parents never block.
|
|
290
|
+
*
|
|
291
|
+
* @param {string} parentId the parent bead id children hang under
|
|
292
|
+
* @param {{ pid?: number|null, sprintId?: string, floor?: number }} [opts]
|
|
293
|
+
* pid -- the creating child's pid, for dead-pid reclaim of an
|
|
294
|
+
* abandoned reservation.
|
|
295
|
+
* sprintId-- for introspection/logging.
|
|
296
|
+
* floor -- the count of children the parent ALREADY has (max existing
|
|
297
|
+
* child seq). On first touch of a parent, the counter is seeded
|
|
298
|
+
* above this so the allocator never mints an id colliding with a
|
|
299
|
+
* pre-existing child created before the allocator existed.
|
|
300
|
+
* @returns {Promise<{ childId: string, parentId: string, seq: number, token: string, expiresAt: number }>}
|
|
301
|
+
*/
|
|
302
|
+
async function allocate(parentId, opts = {}) {
|
|
303
|
+
if (typeof parentId !== 'string' || parentId.length === 0) {
|
|
304
|
+
throw new TypeError('allocate() requires a non-empty parentId');
|
|
305
|
+
}
|
|
306
|
+
const pid = opts.pid == null ? null : opts.pid;
|
|
307
|
+
if (pid !== null && !Number.isInteger(pid)) {
|
|
308
|
+
throw new TypeError('allocate() pid must be an integer or null');
|
|
309
|
+
}
|
|
310
|
+
// Opportunistically reclaim abandoned reservations before we mint, so a
|
|
311
|
+
// crashed creator's hole is reused rather than skipped.
|
|
312
|
+
reclaimExpired();
|
|
313
|
+
|
|
314
|
+
const st = parentState(parentId);
|
|
315
|
+
// Seed the high-water above any pre-existing children on first contact.
|
|
316
|
+
if (Number.isInteger(opts.floor)) {
|
|
317
|
+
// Only lift the high-water; never drop it.
|
|
318
|
+
if (opts.floor > st.highWater) st.highWater = opts.floor;
|
|
319
|
+
// Always discard free holes <= floor, even when the floor does not
|
|
320
|
+
// raise the high-water: the floor is the highest existing child, so
|
|
321
|
+
// a pooled seq at or below it may belong to a bead that already
|
|
322
|
+
// exists (e.g. one released after a failed create), and must never
|
|
323
|
+
// be handed out again (GitHub #615).
|
|
324
|
+
st.free = st.free.filter((n) => n > opts.floor);
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
// Reuse the smallest reclaimed hole before advancing the counter, so an
|
|
328
|
+
// abandoned reservation leaves no permanent gap.
|
|
329
|
+
let seq;
|
|
330
|
+
if (st.free.length > 0) {
|
|
331
|
+
seq = st.free.shift();
|
|
332
|
+
} else {
|
|
333
|
+
st.highWater += 1;
|
|
334
|
+
seq = st.highWater;
|
|
335
|
+
}
|
|
336
|
+
const at = now();
|
|
337
|
+
const token = nextToken(parentId);
|
|
338
|
+
st.reserved.set(token, {
|
|
339
|
+
seq,
|
|
340
|
+
pid,
|
|
341
|
+
sprintId: opts.sprintId ?? null,
|
|
342
|
+
reservedAt: at,
|
|
343
|
+
expiresAt: at + leaseMs,
|
|
344
|
+
});
|
|
345
|
+
|
|
346
|
+
// Durability barrier: do not hand the id back until it is on disk, so a
|
|
347
|
+
// restart re-adopts the same high-water and never re-mints this id.
|
|
348
|
+
await persist();
|
|
349
|
+
return { childId: `${parentId}.${seq}`, parentId, seq, token, expiresAt: at + leaseMs };
|
|
350
|
+
}
|
|
351
|
+
|
|
352
|
+
/**
|
|
353
|
+
* Durably commit a reservation: the sprint has successfully run
|
|
354
|
+
* `bd create --id <childId>`, so the id is now permanently used. Removes the
|
|
355
|
+
* reservation WITHOUT returning its seq to the free pool (the id is real
|
|
356
|
+
* now). Idempotent: an unknown/already-committed token is a no-op.
|
|
357
|
+
* @param {string} token the reservation token returned by allocate()
|
|
358
|
+
* @returns {Promise<boolean>} whether a reservation was committed
|
|
359
|
+
*/
|
|
360
|
+
async function confirm(token) {
|
|
361
|
+
for (const st of parents.values()) {
|
|
362
|
+
const r = st.reserved.get(token);
|
|
363
|
+
if (r) {
|
|
364
|
+
st.reserved.delete(token);
|
|
365
|
+
await persist();
|
|
366
|
+
return true;
|
|
367
|
+
}
|
|
368
|
+
}
|
|
369
|
+
return false;
|
|
370
|
+
}
|
|
371
|
+
|
|
372
|
+
/**
|
|
373
|
+
* Release (abandon) a reservation whose `bd create` did NOT succeed: return
|
|
374
|
+
* its seq to the parent's free pool so the next allocate() reuses it, leaving
|
|
375
|
+
* no permanent gap. Idempotent: an unknown token is a no-op.
|
|
376
|
+
* @param {string} token
|
|
377
|
+
* @returns {Promise<boolean>} whether a reservation was released
|
|
378
|
+
*/
|
|
379
|
+
async function release(token) {
|
|
380
|
+
for (const st of parents.values()) {
|
|
381
|
+
const r = st.reserved.get(token);
|
|
382
|
+
if (r) {
|
|
383
|
+
st.reserved.delete(token);
|
|
384
|
+
if (!st.free.includes(r.seq)) st.free.push(r.seq);
|
|
385
|
+
st.free.sort((a, b) => a - b);
|
|
386
|
+
await persist();
|
|
387
|
+
return true;
|
|
388
|
+
}
|
|
389
|
+
}
|
|
390
|
+
return false;
|
|
391
|
+
}
|
|
392
|
+
|
|
393
|
+
/** Introspection snapshot (clone -- callers cannot mutate internal state). */
|
|
394
|
+
function status() {
|
|
395
|
+
const out = {};
|
|
396
|
+
for (const [parentId, st] of parents) {
|
|
397
|
+
out[parentId] = {
|
|
398
|
+
highWater: st.highWater,
|
|
399
|
+
free: [...st.free].sort((a, b) => a - b),
|
|
400
|
+
reserved: [...st.reserved.values()].map((r) => ({ seq: r.seq, pid: r.pid, sprintId: r.sprintId, expiresAt: r.expiresAt })),
|
|
401
|
+
};
|
|
402
|
+
}
|
|
403
|
+
return { parents: out };
|
|
404
|
+
}
|
|
405
|
+
|
|
406
|
+
return {
|
|
407
|
+
name: 'id-allocator',
|
|
408
|
+
filePath,
|
|
409
|
+
dataDir,
|
|
410
|
+
|
|
411
|
+
// -- seam lifecycle (server.mjs calls start()/stop()) ----------------
|
|
412
|
+
async start() {
|
|
413
|
+
if (!loaded) await load();
|
|
414
|
+
if (sweepTimer) return;
|
|
415
|
+
sweepTimer = setIntervalFn(() => {
|
|
416
|
+
if (reclaimExpired() > 0) persist().catch(() => {});
|
|
417
|
+
}, sweepMs);
|
|
418
|
+
// Do not keep the process alive solely for the sweep timer.
|
|
419
|
+
if (sweepTimer && typeof sweepTimer.unref === 'function') sweepTimer.unref();
|
|
420
|
+
},
|
|
421
|
+
async stop() {
|
|
422
|
+
if (sweepTimer) {
|
|
423
|
+
clearIntervalFn(sweepTimer);
|
|
424
|
+
sweepTimer = null;
|
|
425
|
+
}
|
|
426
|
+
// Let any in-flight write settle so on-disk state is consistent.
|
|
427
|
+
await persistChain;
|
|
428
|
+
},
|
|
429
|
+
|
|
430
|
+
load,
|
|
431
|
+
allocate,
|
|
432
|
+
confirm,
|
|
433
|
+
release,
|
|
434
|
+
reclaimExpired,
|
|
435
|
+
status,
|
|
436
|
+
get leaseMs() { return leaseMs; },
|
|
437
|
+
};
|
|
438
|
+
}
|
|
439
|
+
|
|
440
|
+
/**
|
|
441
|
+
* Register the child-id allocator HTTP routes against a supervisor (server.mjs).
|
|
442
|
+
* Detached sprint children mint ids through these:
|
|
443
|
+
*
|
|
444
|
+
* POST /api/child-id-allocator/:parentId/allocate body { pid?, sprintId?, floor? }
|
|
445
|
+
* -> 200 { childId, seq, token, expiresAt }. The child then runs
|
|
446
|
+
* `bd create --id <childId>` followed by `bd update <childId>
|
|
447
|
+
* --parent <parentId>` -- NOT one create carrying both flags, which
|
|
448
|
+
* bd rejects outright ("cannot specify both --id and --parent
|
|
449
|
+
* flags"); see createChildBeadWithAllocatedId in fleet-sprint/
|
|
450
|
+
* runner.js and the apra-fleet-xuo.7 note.
|
|
451
|
+
* POST /api/child-id-allocator/confirm body { token }
|
|
452
|
+
* -> 200 { confirmed: boolean }. Called after a successful create.
|
|
453
|
+
* POST /api/child-id-allocator/release body { token }
|
|
454
|
+
* -> 200 { released: boolean }. Called if the create failed.
|
|
455
|
+
* GET /api/child-id-allocator -> 200 status snapshot.
|
|
456
|
+
*
|
|
457
|
+
* @param {{ route: Function }} supervisor
|
|
458
|
+
* @param {ReturnType<typeof createIdAllocator>} allocator
|
|
459
|
+
* @param {{ readJsonBody: Function, sendJson: Function }} http
|
|
460
|
+
*/
|
|
461
|
+
export function registerIdAllocatorRoutes(supervisor, allocator, http) {
|
|
462
|
+
const { readJsonBody, sendJson } = http;
|
|
463
|
+
|
|
464
|
+
supervisor.route('POST', '/api/child-id-allocator/:parentId/allocate', async (req, res, ctx) => {
|
|
465
|
+
const parentId = ctx?.params?.parentId;
|
|
466
|
+
if (!parentId) { sendJson(res, 400, { error: 'missing parentId in path' }); return; }
|
|
467
|
+
const body = (await readJsonBody(req)) ?? {};
|
|
468
|
+
try {
|
|
469
|
+
const grant = await allocator.allocate(parentId, {
|
|
470
|
+
pid: body.pid,
|
|
471
|
+
sprintId: body.sprintId,
|
|
472
|
+
floor: body.floor,
|
|
473
|
+
});
|
|
474
|
+
sendJson(res, 200, { status: 'allocated', ...grant });
|
|
475
|
+
} catch (err) {
|
|
476
|
+
sendJson(res, 503, { error: `allocate failed: ${err.message}` });
|
|
477
|
+
}
|
|
478
|
+
});
|
|
479
|
+
|
|
480
|
+
supervisor.route('POST', '/api/child-id-allocator/confirm', async (req, res) => {
|
|
481
|
+
const body = (await readJsonBody(req)) ?? {};
|
|
482
|
+
if (typeof body.token !== 'string' || body.token.length === 0) {
|
|
483
|
+
sendJson(res, 400, { error: 'confirm requires a token' });
|
|
484
|
+
return;
|
|
485
|
+
}
|
|
486
|
+
const confirmed = await allocator.confirm(body.token);
|
|
487
|
+
sendJson(res, 200, { confirmed });
|
|
488
|
+
});
|
|
489
|
+
|
|
490
|
+
supervisor.route('POST', '/api/child-id-allocator/release', async (req, res) => {
|
|
491
|
+
const body = (await readJsonBody(req)) ?? {};
|
|
492
|
+
if (typeof body.token !== 'string' || body.token.length === 0) {
|
|
493
|
+
sendJson(res, 400, { error: 'release requires a token' });
|
|
494
|
+
return;
|
|
495
|
+
}
|
|
496
|
+
const released = await allocator.release(body.token);
|
|
497
|
+
sendJson(res, 200, { released });
|
|
498
|
+
});
|
|
499
|
+
|
|
500
|
+
supervisor.route('GET', '/api/child-id-allocator', async (req, res) => {
|
|
501
|
+
sendJson(res, 200, allocator.status());
|
|
502
|
+
});
|
|
503
|
+
}
|
|
504
|
+
|
|
505
|
+
/**
|
|
506
|
+
* A no-op allocator client with the allocate()/confirm()/release() surface the
|
|
507
|
+
* runner.js bead-creation path calls. Used when a sprint runs WITHOUT a
|
|
508
|
+
* supervisor (single-process/dev/test): there is, by definition, no second
|
|
509
|
+
* sprint that could mint a colliding child id, so `bd create` derives the id
|
|
510
|
+
* itself. `childId: null` signals the runner to OMIT `--id` and let bd pick.
|
|
511
|
+
* Keeps the create call sites uniform -- they always allocate/confirm; only the
|
|
512
|
+
* client wiring differs.
|
|
513
|
+
* @returns {{ allocate: Function, confirm: Function, release: Function }}
|
|
514
|
+
*/
|
|
515
|
+
export function nullChildIdAllocatorClient() {
|
|
516
|
+
return {
|
|
517
|
+
async allocate() { return { childId: null, token: null }; },
|
|
518
|
+
async confirm() { return true; },
|
|
519
|
+
async release() { return true; },
|
|
520
|
+
};
|
|
521
|
+
}
|