@apralabs/apra-fleet 0.4.2 → 0.4.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +38 -5
- package/dist/agents/backlog-groomer.md +25 -0
- package/dist/agents/ci-watcher.md +11 -0
- package/dist/agents/deployer.md +37 -2
- package/dist/agents/doer.md +36 -12
- package/dist/agents/harvester.md +11 -0
- package/dist/agents/integ-test-runner.md +11 -0
- package/dist/agents/kb-reconciler.md +9 -0
- package/dist/agents/plan-reviewer.md +110 -22
- package/dist/agents/planner.md +125 -37
- package/dist/agents/regression-test-runner.md +11 -0
- package/dist/agents/reviewer.md +13 -2
- package/dist/agents/schemas/plan-reviewer-output.json +37 -0
- package/dist/cli/agent-transform.d.ts +83 -2
- package/dist/cli/agent-transform.d.ts.map +1 -1
- package/dist/cli/agent-transform.js +266 -21
- package/dist/cli/agent-transform.js.map +1 -1
- package/dist/cli/auth.d.ts.map +1 -1
- package/dist/cli/auth.js +28 -9
- package/dist/cli/auth.js.map +1 -1
- package/dist/cli/config.d.ts +7 -5
- package/dist/cli/config.d.ts.map +1 -1
- package/dist/cli/config.js +44 -34
- package/dist/cli/config.js.map +1 -1
- package/dist/cli/install.d.ts +33 -0
- package/dist/cli/install.d.ts.map +1 -1
- package/dist/cli/install.js +290 -23
- package/dist/cli/install.js.map +1 -1
- package/dist/cli/kb-directives.d.ts.map +1 -1
- package/dist/cli/kb-directives.js +2 -1
- package/dist/cli/kb-directives.js.map +1 -1
- package/dist/cli/register-member.d.ts.map +1 -1
- package/dist/cli/register-member.js +6 -2
- package/dist/cli/register-member.js.map +1 -1
- package/dist/commands/kb-server.d.ts +3 -0
- package/dist/commands/kb-server.d.ts.map +1 -1
- package/dist/commands/kb-server.js +43 -3
- package/dist/commands/kb-server.js.map +1 -1
- package/dist/index.js +3 -3
- package/dist/os/linux.d.ts +6 -0
- package/dist/os/linux.d.ts.map +1 -1
- package/dist/os/linux.js +35 -2
- package/dist/os/linux.js.map +1 -1
- package/dist/os/os-commands.d.ts +61 -2
- package/dist/os/os-commands.d.ts.map +1 -1
- package/dist/os/windows-gitbash.d.ts +5 -0
- package/dist/os/windows-gitbash.d.ts.map +1 -1
- package/dist/os/windows-gitbash.js +15 -0
- package/dist/os/windows-gitbash.js.map +1 -1
- package/dist/os/windows.d.ts +6 -0
- package/dist/os/windows.d.ts.map +1 -1
- package/dist/os/windows.js +46 -3
- package/dist/os/windows.js.map +1 -1
- package/dist/providers/agy.d.ts +115 -6
- package/dist/providers/agy.d.ts.map +1 -1
- package/dist/providers/agy.js +569 -53
- package/dist/providers/agy.js.map +1 -1
- package/dist/providers/claude.d.ts +81 -3
- package/dist/providers/claude.d.ts.map +1 -1
- package/dist/providers/claude.js +344 -10
- package/dist/providers/claude.js.map +1 -1
- package/dist/providers/codex.d.ts +4 -2
- package/dist/providers/codex.d.ts.map +1 -1
- package/dist/providers/codex.js +19 -2
- package/dist/providers/codex.js.map +1 -1
- package/dist/providers/copilot.d.ts +4 -2
- package/dist/providers/copilot.d.ts.map +1 -1
- package/dist/providers/copilot.js +20 -2
- package/dist/providers/copilot.js.map +1 -1
- package/dist/providers/none.d.ts +4 -2
- package/dist/providers/none.d.ts.map +1 -1
- package/dist/providers/none.js +17 -2
- package/dist/providers/none.js.map +1 -1
- package/dist/providers/opencode.d.ts +3 -1
- package/dist/providers/opencode.d.ts.map +1 -1
- package/dist/providers/opencode.js +22 -2
- package/dist/providers/opencode.js.map +1 -1
- package/dist/providers/provider.d.ts +201 -6
- package/dist/providers/provider.d.ts.map +1 -1
- package/dist/providers/provider.js +56 -0
- package/dist/providers/provider.js.map +1 -1
- package/dist/services/agy-project.d.ts +102 -0
- package/dist/services/agy-project.d.ts.map +1 -0
- package/dist/services/agy-project.js +356 -0
- package/dist/services/agy-project.js.map +1 -0
- package/dist/services/auth-socket.js +4 -4
- package/dist/services/auth-web.js +1 -1
- package/dist/services/cloud/lifecycle.d.ts.map +1 -1
- package/dist/services/cloud/lifecycle.js +33 -4
- package/dist/services/cloud/lifecycle.js.map +1 -1
- package/dist/services/credential-cleanup.d.ts.map +1 -1
- package/dist/services/credential-cleanup.js +35 -17
- package/dist/services/credential-cleanup.js.map +1 -1
- package/dist/services/exit-drain.d.ts +44 -0
- package/dist/services/exit-drain.d.ts.map +1 -0
- package/dist/services/exit-drain.js +52 -0
- package/dist/services/exit-drain.js.map +1 -0
- package/dist/services/github-app.d.ts.map +1 -1
- package/dist/services/github-app.js +32 -4
- package/dist/services/github-app.js.map +1 -1
- package/dist/services/http-transport.d.ts +1 -0
- package/dist/services/http-transport.d.ts.map +1 -1
- package/dist/services/http-transport.js +48 -1
- package/dist/services/http-transport.js.map +1 -1
- package/dist/services/knowledge/kb-config.d.ts +42 -0
- package/dist/services/knowledge/kb-config.d.ts.map +1 -0
- package/dist/services/knowledge/kb-config.js +54 -0
- package/dist/services/knowledge/kb-config.js.map +1 -0
- package/dist/services/knowledge/kb-providers.d.ts +7 -1
- package/dist/services/knowledge/kb-providers.d.ts.map +1 -1
- package/dist/services/knowledge/kb-providers.js +191 -17
- package/dist/services/knowledge/kb-providers.js.map +1 -1
- package/dist/services/knowledge/require-sqlite-project.d.ts +32 -0
- package/dist/services/knowledge/require-sqlite-project.d.ts.map +1 -0
- package/dist/services/knowledge/require-sqlite-project.js +38 -0
- package/dist/services/knowledge/require-sqlite-project.js.map +1 -0
- package/dist/services/model-pricing.d.ts.map +1 -1
- package/dist/services/model-pricing.js +7 -3
- package/dist/services/model-pricing.js.map +1 -1
- package/dist/services/secret-token.d.ts +38 -0
- package/dist/services/secret-token.d.ts.map +1 -0
- package/dist/services/secret-token.js +51 -0
- package/dist/services/secret-token.js.map +1 -0
- package/dist/services/service-manager/types.d.ts +3 -1
- package/dist/services/service-manager/types.d.ts.map +1 -1
- package/dist/services/service-manager/windows.d.ts +14 -2
- package/dist/services/service-manager/windows.d.ts.map +1 -1
- package/dist/services/service-manager/windows.js +65 -7
- package/dist/services/service-manager/windows.js.map +1 -1
- package/dist/services/ssh.d.ts.map +1 -1
- package/dist/services/ssh.js +58 -2
- package/dist/services/ssh.js.map +1 -1
- package/dist/services/stall/read-log-tail.d.ts.map +1 -1
- package/dist/services/stall/read-log-tail.js +20 -10
- package/dist/services/stall/read-log-tail.js.map +1 -1
- package/dist/services/stall/stall-detector.d.ts +53 -4
- package/dist/services/stall/stall-detector.d.ts.map +1 -1
- package/dist/services/stall/stall-detector.js +212 -34
- package/dist/services/stall/stall-detector.js.map +1 -1
- package/dist/services/strategy.d.ts.map +1 -1
- package/dist/services/strategy.js +79 -2
- package/dist/services/strategy.js.map +1 -1
- package/dist/services/substitution-engine.js +2 -2
- package/dist/services/substitution-engine.js.map +1 -1
- package/dist/services/tool-registry.d.ts.map +1 -1
- package/dist/services/tool-registry.js +5 -3
- package/dist/services/tool-registry.js.map +1 -1
- package/dist/services/vcs/azure-devops.d.ts +66 -1
- package/dist/services/vcs/azure-devops.d.ts.map +1 -1
- package/dist/services/vcs/azure-devops.js +192 -21
- package/dist/services/vcs/azure-devops.js.map +1 -1
- package/dist/services/vcs/types.d.ts +1 -1
- package/dist/skills/fleet-sprint-cli/SKILL.md +18 -0
- package/dist/skills/pm/SKILL.md +1 -1
- package/dist/skills/pm/cost.md +0 -3
- package/dist/skills/pm/fleet-addendum.md +2 -2
- package/dist/tools/check-status.d.ts +7 -4
- package/dist/tools/check-status.d.ts.map +1 -1
- package/dist/tools/check-status.js +2 -0
- package/dist/tools/check-status.js.map +1 -1
- package/dist/tools/compose-permissions.d.ts +6 -0
- package/dist/tools/compose-permissions.d.ts.map +1 -1
- package/dist/tools/compose-permissions.js +182 -34
- package/dist/tools/compose-permissions.js.map +1 -1
- package/dist/tools/credential-store-set.js +1 -1
- package/dist/tools/execute-command.d.ts.map +1 -1
- package/dist/tools/execute-command.js +31 -20
- package/dist/tools/execute-command.js.map +1 -1
- package/dist/tools/execute-prompt.d.ts +15 -2
- package/dist/tools/execute-prompt.d.ts.map +1 -1
- package/dist/tools/execute-prompt.js +1196 -892
- package/dist/tools/execute-prompt.js.map +1 -1
- package/dist/tools/kb-capture.d.ts +2 -2
- package/dist/tools/kb-capture.d.ts.map +1 -1
- package/dist/tools/kb-capture.js +29 -5
- package/dist/tools/kb-capture.js.map +1 -1
- package/dist/tools/kb-export.d.ts +2 -2
- package/dist/tools/kb-export.d.ts.map +1 -1
- package/dist/tools/kb-export.js +3 -28
- package/dist/tools/kb-export.js.map +1 -1
- package/dist/tools/kb-feedback.d.ts.map +1 -1
- package/dist/tools/kb-feedback.js +3 -1
- package/dist/tools/kb-feedback.js.map +1 -1
- package/dist/tools/kb-freshness-sweep.d.ts.map +1 -1
- package/dist/tools/kb-freshness-sweep.js +3 -1
- package/dist/tools/kb-freshness-sweep.js.map +1 -1
- package/dist/tools/kb-import.d.ts.map +1 -1
- package/dist/tools/kb-import.js +2 -1
- package/dist/tools/kb-import.js.map +1 -1
- package/dist/tools/kb-list.d.ts.map +1 -1
- package/dist/tools/kb-list.js +3 -1
- package/dist/tools/kb-list.js.map +1 -1
- package/dist/tools/kb-query.d.ts +2 -2
- package/dist/tools/kb-reconcile-prefilter.d.ts.map +1 -1
- package/dist/tools/kb-reconcile-prefilter.js +3 -1
- package/dist/tools/kb-reconcile-prefilter.js.map +1 -1
- package/dist/tools/kb-resolve-contradiction.d.ts.map +1 -1
- package/dist/tools/kb-resolve-contradiction.js +3 -1
- package/dist/tools/kb-resolve-contradiction.js.map +1 -1
- package/dist/tools/kb-setup.d.ts.map +1 -1
- package/dist/tools/kb-setup.js +125 -20
- package/dist/tools/kb-setup.js.map +1 -1
- package/dist/tools/kb-stats.d.ts.map +1 -1
- package/dist/tools/kb-stats.js +64 -43
- package/dist/tools/kb-stats.js.map +1 -1
- package/dist/tools/list-members.d.ts +2 -2
- package/dist/tools/list-members.d.ts.map +1 -1
- package/dist/tools/list-members.js +1 -0
- package/dist/tools/list-members.js.map +1 -1
- package/dist/tools/member-detail.d.ts +2 -2
- package/dist/tools/member-detail.d.ts.map +1 -1
- package/dist/tools/member-detail.js +17 -0
- package/dist/tools/member-detail.js.map +1 -1
- package/dist/tools/member-reservation.d.ts +58 -1
- package/dist/tools/member-reservation.d.ts.map +1 -1
- package/dist/tools/member-reservation.js +61 -20
- package/dist/tools/member-reservation.js.map +1 -1
- package/dist/tools/provision-auth.d.ts +80 -1
- package/dist/tools/provision-auth.d.ts.map +1 -1
- package/dist/tools/provision-auth.js +142 -54
- package/dist/tools/provision-auth.js.map +1 -1
- package/dist/tools/provision-vcs-auth.d.ts +91 -1
- package/dist/tools/provision-vcs-auth.d.ts.map +1 -1
- package/dist/tools/provision-vcs-auth.js +209 -49
- package/dist/tools/provision-vcs-auth.js.map +1 -1
- package/dist/tools/register-member.d.ts +12 -9
- package/dist/tools/register-member.d.ts.map +1 -1
- package/dist/tools/register-member.js +99 -12
- package/dist/tools/register-member.js.map +1 -1
- package/dist/tools/remove-member.d.ts.map +1 -1
- package/dist/tools/remove-member.js +27 -2
- package/dist/tools/remove-member.js.map +1 -1
- package/dist/tools/send-email.d.ts +2 -2
- package/dist/tools/setup-git-app.d.ts.map +1 -1
- package/dist/tools/setup-git-app.js +11 -7
- package/dist/tools/setup-git-app.js.map +1 -1
- package/dist/tools/shutdown-server.d.ts +2 -0
- package/dist/tools/shutdown-server.d.ts.map +1 -1
- package/dist/tools/shutdown-server.js +23 -1
- package/dist/tools/shutdown-server.js.map +1 -1
- package/dist/tools/update-member.d.ts +12 -9
- package/dist/tools/update-member.d.ts.map +1 -1
- package/dist/tools/update-member.js +43 -11
- package/dist/tools/update-member.js.map +1 -1
- package/dist/tools/vcs-credential-exec.d.ts +127 -0
- package/dist/tools/vcs-credential-exec.d.ts.map +1 -0
- package/dist/tools/vcs-credential-exec.js +197 -0
- package/dist/tools/vcs-credential-exec.js.map +1 -0
- package/dist/types.d.ts +13 -0
- package/dist/types.d.ts.map +1 -1
- package/dist/utils/log-helpers.d.ts.map +1 -1
- package/dist/utils/log-helpers.js +2 -2
- package/dist/utils/log-helpers.js.map +1 -1
- package/dist/utils/prompt-errors.d.ts.map +1 -1
- package/dist/utils/prompt-errors.js +7 -1
- package/dist/utils/prompt-errors.js.map +1 -1
- package/dist/utils/shell-escape.d.ts +16 -0
- package/dist/utils/shell-escape.d.ts.map +1 -1
- package/dist/utils/shell-escape.js +22 -2
- package/dist/utils/shell-escape.js.map +1 -1
- package/dist/utils/vcs-provider-detect.d.ts +65 -0
- package/dist/utils/vcs-provider-detect.d.ts.map +1 -0
- package/dist/utils/vcs-provider-detect.js +109 -0
- package/dist/utils/vcs-provider-detect.js.map +1 -0
- package/dist/utils/workspace-trust.d.ts +20 -17
- package/dist/utils/workspace-trust.d.ts.map +1 -1
- package/dist/utils/workspace-trust.js +87 -1
- package/dist/utils/workspace-trust.js.map +1 -1
- package/dist/workflows/auto-sprint.js +176 -15
- package/package.json +6 -4
- package/packages/apra-fleet-client/src/client/api.mjs +319 -17
- package/packages/apra-fleet-client/src/client/errors.mjs +6 -2
- package/packages/apra-fleet-se/apra-pm/agents/_shared/GRAPH-SEMANTICS.md +10 -2
- package/packages/apra-fleet-se/apra-pm/agents/backlog-groomer.md +25 -0
- package/packages/apra-fleet-se/apra-pm/agents/ci-watcher.md +11 -0
- package/packages/apra-fleet-se/apra-pm/agents/deployer.md +37 -2
- package/packages/apra-fleet-se/apra-pm/agents/doer.md +36 -12
- package/packages/apra-fleet-se/apra-pm/agents/harvester.md +11 -0
- package/packages/apra-fleet-se/apra-pm/agents/integ-test-runner.md +11 -0
- package/packages/apra-fleet-se/apra-pm/agents/kb-reconciler.md +9 -0
- package/packages/apra-fleet-se/apra-pm/agents/plan-reviewer.md +110 -22
- package/packages/apra-fleet-se/apra-pm/agents/planner.md +125 -37
- package/packages/apra-fleet-se/apra-pm/agents/regression-test-runner.md +11 -0
- package/packages/apra-fleet-se/apra-pm/agents/reviewer.md +13 -2
- package/packages/apra-fleet-se/apra-pm/agents/schemas/plan-reviewer-output.json +37 -0
- package/packages/apra-fleet-se/apra-pm/skills/pm/SKILL.md +1 -1
- 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/bin/cli.mjs +149 -1
- package/packages/apra-fleet-se/bin/serve.mjs +78 -4
- package/packages/apra-fleet-se/fleet-sprint/abort.mjs +481 -0
- package/packages/apra-fleet-se/fleet-sprint/beads-children.mjs +491 -0
- package/packages/apra-fleet-se/fleet-sprint/beads-identity-check.mjs +282 -0
- package/packages/apra-fleet-se/fleet-sprint/beads-identity.mjs +208 -0
- package/packages/apra-fleet-se/fleet-sprint/beads-scope.mjs +638 -0
- package/packages/apra-fleet-se/fleet-sprint/beads-transitions.mjs +301 -0
- package/packages/apra-fleet-se/fleet-sprint/branch-ensure.mjs +96 -0
- package/packages/apra-fleet-se/fleet-sprint/conflict-ladder.mjs +8 -0
- package/packages/apra-fleet-se/fleet-sprint/contracts.mjs +61 -14
- package/packages/apra-fleet-se/fleet-sprint/coordination.mjs +516 -0
- package/packages/apra-fleet-se/fleet-sprint/dispatch-failure.mjs +184 -0
- package/packages/apra-fleet-se/fleet-sprint/dispatch-role.mjs +1121 -0
- package/packages/apra-fleet-se/fleet-sprint/dispatch-safety-guard.mjs +216 -4
- package/packages/apra-fleet-se/fleet-sprint/docs/README.md +1 -1
- package/packages/apra-fleet-se/fleet-sprint/docs/dolt-sync-redesign.md +276 -0
- package/packages/apra-fleet-se/fleet-sprint/docs/escalate-to-llm-design.md +1 -1
- 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 +996 -32
- package/packages/apra-fleet-se/fleet-sprint/errors.mjs +267 -0
- package/packages/apra-fleet-se/fleet-sprint/explicit-id-create-guard.mjs +501 -0
- package/packages/apra-fleet-se/fleet-sprint/fatal-diagnostics.mjs +134 -0
- package/packages/apra-fleet-se/fleet-sprint/full-db-fetch-guard.mjs +102 -0
- package/packages/apra-fleet-se/fleet-sprint/git-sync.mjs +556 -0
- package/packages/apra-fleet-se/fleet-sprint/git-topology.mjs +495 -0
- package/packages/apra-fleet-se/fleet-sprint/guarded-modules.mjs +564 -0
- package/packages/apra-fleet-se/fleet-sprint/inline-ladder-guard.mjs +216 -0
- package/packages/apra-fleet-se/fleet-sprint/kb.mjs +728 -0
- package/packages/apra-fleet-se/fleet-sprint/mcp-result.mjs +75 -0
- package/packages/apra-fleet-se/fleet-sprint/member-provisioning.mjs +252 -0
- package/packages/apra-fleet-se/fleet-sprint/member-sync.mjs +581 -0
- package/packages/apra-fleet-se/fleet-sprint/member-target.mjs +93 -0
- package/packages/apra-fleet-se/fleet-sprint/newtask-text.mjs +266 -0
- package/packages/apra-fleet-se/fleet-sprint/parent-notes-staleness.mjs +201 -0
- package/packages/apra-fleet-se/fleet-sprint/phases/deploy.mjs +136 -0
- package/packages/apra-fleet-se/fleet-sprint/phases/develop.mjs +822 -0
- package/packages/apra-fleet-se/fleet-sprint/phases/ensure-sprint-branch.mjs +294 -0
- package/packages/apra-fleet-se/fleet-sprint/phases/final-review.mjs +403 -0
- package/packages/apra-fleet-se/fleet-sprint/phases/harvest.mjs +180 -0
- package/packages/apra-fleet-se/fleet-sprint/phases/integ-test.mjs +358 -0
- package/packages/apra-fleet-se/fleet-sprint/phases/plan.mjs +390 -0
- package/packages/apra-fleet-se/fleet-sprint/phases/publish-pr.mjs +323 -0
- package/packages/apra-fleet-se/fleet-sprint/phases/re-review.mjs +232 -0
- package/packages/apra-fleet-se/fleet-sprint/phases/regression-test.mjs +174 -0
- package/packages/apra-fleet-se/fleet-sprint/phases/replan.mjs +197 -0
- package/packages/apra-fleet-se/fleet-sprint/phases/review.mjs +305 -0
- package/packages/apra-fleet-se/fleet-sprint/prompts.mjs +559 -0
- package/packages/apra-fleet-se/fleet-sprint/role-policies.mjs +1416 -0
- package/packages/apra-fleet-se/fleet-sprint/round-session.mjs +100 -0
- package/packages/apra-fleet-se/fleet-sprint/runner.js +1467 -9798
- package/packages/apra-fleet-se/fleet-sprint/se-posix.mjs +17 -12
- package/packages/apra-fleet-se/fleet-sprint/shell-command-guard.mjs +304 -0
- package/packages/apra-fleet-se/fleet-sprint/skills/fleet-sprint-cli/SKILL.md +18 -0
- package/packages/apra-fleet-se/fleet-sprint/skills/fleet-supervisor/SKILL.md +21 -2
- package/packages/apra-fleet-se/fleet-sprint/sprint-args.mjs +454 -0
- package/packages/apra-fleet-se/fleet-sprint/sprint-report.mjs +239 -0
- package/packages/apra-fleet-se/fleet-sprint/sprint-state.mjs +163 -0
- package/packages/apra-fleet-se/fleet-sprint/unbracketed-push-guard.mjs +234 -0
- package/packages/apra-fleet-se/fleet-sprint/usage-limit-controller.mjs +211 -0
- package/packages/apra-fleet-se/fleet-sprint/vcs-auth.mjs +1279 -0
- package/packages/apra-fleet-se/fleet-sprint/vcs-module.mjs +153 -19
- package/packages/apra-fleet-se/fleet-sprint/vcs-providers/azure-devops.mjs +71 -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 +131 -0
- package/packages/apra-fleet-se/fleet-sprint/vcs-providers/index.mjs +140 -16
- package/packages/apra-fleet-se/fleet-sprint/vcs-providers/shell-helpers.mjs +1 -0
- package/packages/apra-fleet-se/fleet-sprint/viewer-extensions.mjs +77 -2
- package/packages/apra-fleet-se/fleet-sprint/worklists.mjs +559 -0
- package/packages/apra-fleet-se/package.json +1 -1
- package/packages/apra-fleet-workflow/src/viewer/index.mjs +17 -6
- package/packages/apra-fleet-workflow/src/workflow/index.mjs +49 -7
- 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 +5 -1
- package/skills/fleet/profiles/node.json +1 -1
- package/skills/fleet/troubleshooting.md +3 -3
- package/version.json +1 -1
|
@@ -0,0 +1,581 @@
|
|
|
1
|
+
// =============================================================================
|
|
2
|
+
// MEMBER SYNC -- the per-member git/dolt sync brackets
|
|
3
|
+
// (apra-fleet-3swo.6.10)
|
|
4
|
+
// =============================================================================
|
|
5
|
+
//
|
|
6
|
+
// Moved VERBATIM out of runner.js. This module owns the four bracket entry
|
|
7
|
+
// points the orchestrator wraps every dispatch (and every resume) in:
|
|
8
|
+
//
|
|
9
|
+
// 1. syncMemberBefore() -- G-pull: fetch + ff-only merge (or a reset to the
|
|
10
|
+
// remote tip on a mutating retry) before a member does any work.
|
|
11
|
+
// 2. syncMemberAfter() -- G-push: push, with ONE bounded pull-rebase retry
|
|
12
|
+
// and the Tier 2 conflict-resolution dispatch behind it.
|
|
13
|
+
// 3. syncMemberAfterOrdered() -- the ordered post-dispatch step: G-push
|
|
14
|
+
// (code) BEFORE D-push (beads), so a bead close can never be published
|
|
15
|
+
// ahead of the code that justifies it.
|
|
16
|
+
// 4. resyncReacquiredMember() -- the resume path's unconditional
|
|
17
|
+
// re-reconciliation of ONE member that was just re-acquired.
|
|
18
|
+
//
|
|
19
|
+
// These are the CALLERS of the git-topology layer (./git-topology.mjs), not
|
|
20
|
+
// part of it: every git command they issue goes through runGitStep, and every
|
|
21
|
+
// failure they classify goes through resolveGitProviderForClassification.
|
|
22
|
+
// git-topology.mjs's own header records that these four deliberately stayed in
|
|
23
|
+
// runner.js when it was extracted; they now live here, which is why this
|
|
24
|
+
// extraction had to run AFTER that one -- the other order would have forced a
|
|
25
|
+
// temporary back-import from runner.js into the new module.
|
|
26
|
+
//
|
|
27
|
+
// WHY resolveSettleShell did NOT move with them: syncMemberAfterOrdered calls
|
|
28
|
+
// it to resolve the member's registered shell before building the dolt-settle
|
|
29
|
+
// callback, but it stays DEFINED IN runner.js and is imported back from there
|
|
30
|
+
// (see the import below for the anchoring test and the call-site split). It was
|
|
31
|
+
// module-private before this extraction and is now merely exported so this
|
|
32
|
+
// module can reach it; it is not otherwise part of runner.js's moved surface.
|
|
33
|
+
//
|
|
34
|
+
// GUARD REGISTRATION: this module is registered in ./guarded-modules.mjs as
|
|
35
|
+
// part of this extraction (see that file's STANDING RULE). It carries
|
|
36
|
+
// syncMemberAfter's one member_name-bearing command() site -- the Tier 2
|
|
37
|
+
// post-resolution `git status --porcelain` read -- and, more importantly, it
|
|
38
|
+
// is where syncMemberAfterOrdered now lives, which is the sanctioned wrapper
|
|
39
|
+
// unbracketed-push-guard.mjs resolves BY NAME WITHIN A FILE: its bare
|
|
40
|
+
// syncMemberAfter()/DoltSync.syncAfter() calls stay sanctioned only because
|
|
41
|
+
// the wrapper that contains them travelled here with them.
|
|
42
|
+
//
|
|
43
|
+
// Dependency-injection stance is unchanged: nothing here does I/O of its own.
|
|
44
|
+
// Every git command is issued via an injected command() with an explicit
|
|
45
|
+
// `member_name`, and the resume path's git/dolt runners are injected too, so
|
|
46
|
+
// unit tests drive all of it with no live fleet.
|
|
47
|
+
// =============================================================================
|
|
48
|
+
|
|
49
|
+
import { GitDivergedError, GitSyncError } from './errors.mjs';
|
|
50
|
+
import { runGitStep, resolveGitProviderForClassification } from './git-topology.mjs';
|
|
51
|
+
import { parseUnmergedPaths, detectAndAbortRebaseConflict, dispatchConflictResolutionAgent } from './conflict-ladder.mjs';
|
|
52
|
+
import { DoltSync } from './dolt-sync.mjs';
|
|
53
|
+
import { buildSettleCallback } from './dolt-settle.mjs';
|
|
54
|
+
import { decideEnsureBranchAction } from './branch-ensure.mjs';
|
|
55
|
+
// resolveSettleShell stays in runner.js: test/sprint-state.test.mjs anchors it
|
|
56
|
+
// there by symbol ('resolveSettleShell must still exist in runner.js'), and six
|
|
57
|
+
// of its seven call sites are runner.js's own orchestrator-side settle brackets.
|
|
58
|
+
// This is the same runner.js back-import abort.mjs, prompts.mjs and worklists.mjs
|
|
59
|
+
// already use; nothing here touches it at module-evaluation time, so the cycle
|
|
60
|
+
// resolves through the hoisted function declaration at call time.
|
|
61
|
+
import { resolveSettleShell } from './runner.js';
|
|
62
|
+
|
|
63
|
+
// ---------------------------------------------------------------------------
|
|
64
|
+
// Orchestrator-bracketed git sync helpers
|
|
65
|
+
// ---------------------------------------------------------------------------
|
|
66
|
+
//
|
|
67
|
+
// Stance: SINGLE-WRITER TOKEN PASSING. The writer pushes, then the next reader
|
|
68
|
+
// pulls, so every intra-sprint git merge is fast-forward BY CONSTRUCTION. A
|
|
69
|
+
// non-FF result is therefore not a merge to resolve -- it is proof the
|
|
70
|
+
// invariant is already broken, so it is a HARD, TYPED error
|
|
71
|
+
// (GitDivergedError), never auto-resolved.
|
|
72
|
+
//
|
|
73
|
+
// Every bracket must fail-soft-with-retry in a way that DISTINGUISHES
|
|
74
|
+
// transient-retry (network unreachable, an index/ref lock) from diverged-abort
|
|
75
|
+
// (non-FF, unmerged/conflicted paths). A diverged state must NEVER be retried
|
|
76
|
+
// blindly. classifyGitFailure() is that classifier -- it moved to
|
|
77
|
+
// ./git-topology.mjs with runGitStep (apra-fleet-3swo.6.3); the two failure
|
|
78
|
+
// classes surface as two distinct WorkflowError subclasses (GitSyncError vs
|
|
79
|
+
// GitDivergedError) so callers and tests can assert them apart.
|
|
80
|
+
//
|
|
81
|
+
// Every git command is issued via the injected command() with an explicit
|
|
82
|
+
// `member_name` -- agents never run sync themselves; the orchestrator brackets
|
|
83
|
+
// each dispatch. `command` is dependency-injected so unit tests can drive these
|
|
84
|
+
// helpers with a mock command() and no live fleet.
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* True when `error` is git's exact "the named ref does not exist on the
|
|
88
|
+
* remote" message (`fatal: couldn't find remote ref <branch>`), as opposed to
|
|
89
|
+
* any other fetch/pull/rebase failure. This is the ONE place that text is
|
|
90
|
+
* matched (apra-fleet-ta3.3): syncMemberBefore's pre-dispatch fetch and
|
|
91
|
+
* syncMemberAfter's post-push pull-rebase both hit this exact message for the
|
|
92
|
+
* identical underlying reason -- a brand-new local branch that has never been
|
|
93
|
+
* pushed to `remote` yet, so there is nothing there to fetch/rebase against --
|
|
94
|
+
* and both treat it as a benign no-op / retry-directly signal via this shared
|
|
95
|
+
* predicate rather than each carrying its own copy of the regex.
|
|
96
|
+
* @param {string} error - the raw git stderr/stdout of a failed command
|
|
97
|
+
* @returns {boolean}
|
|
98
|
+
*/
|
|
99
|
+
export function isMissingRemoteRefError(error) {
|
|
100
|
+
return /couldn't find remote ref/i.test(error || '');
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
/**
|
|
104
|
+
* G-pull: bring `member` up to the shared branch tip before it does any work --
|
|
105
|
+
* `git fetch` then `git merge --ff-only`. Because of single-writer token
|
|
106
|
+
* passing this merge is fast-forward by construction; a non-FF result is a
|
|
107
|
+
* distinct typed GitDivergedError (NOT a generic failure), never auto-merged.
|
|
108
|
+
* Transient (network/lock) failures are retried up to `maxTransientRetries`;
|
|
109
|
+
* divergence is never retried.
|
|
110
|
+
*
|
|
111
|
+
* Every git command is issued via the injected command() with an explicit
|
|
112
|
+
* member_name.
|
|
113
|
+
*
|
|
114
|
+
* An optional injected `onAuthFailure` is threaded through to runGitStep's
|
|
115
|
+
* bounded one-shot self-heal, since a stale token can break a pull as easily as
|
|
116
|
+
* a push.
|
|
117
|
+
*
|
|
118
|
+
* An optional `resetToRemoteTip` (default false) changes the pull half from
|
|
119
|
+
* `git merge --ff-only` to `git reset --hard <remote>/<branch>` so a RETRIED
|
|
120
|
+
* doer dispatch resumes on the published tip instead of failing on (or
|
|
121
|
+
* re-committing over) a divergence its own prior attempt left behind. It must
|
|
122
|
+
* only be set on a retry that may have mutated state (withGitSync's
|
|
123
|
+
* resumeOntoRemoteTip); omitting it keeps the ff-only-merge behaviour for every
|
|
124
|
+
* first attempt.
|
|
125
|
+
*
|
|
126
|
+
* apra-fleet-417.7: an optional injected `resolveMemberProvider` (see
|
|
127
|
+
* createMemberVcsProviderResolver) is resolved ONCE at the top of this call
|
|
128
|
+
* and threaded into every runGitStep call below, so a G-pull auth failure for
|
|
129
|
+
* a non-GitHub member classifies via that member's own provider chain.
|
|
130
|
+
*
|
|
131
|
+
* @param {string} member
|
|
132
|
+
* @param {{ command: Function, log?: Function, maxTransientRetries?: number, remote?: string, branch?: string, onAuthFailure?: Function, resetToRemoteTip?: boolean, resolveMemberProvider?: (member: string) => Promise<string|undefined> }} opts
|
|
133
|
+
* @returns {Promise<{ ok: true, member: string }>}
|
|
134
|
+
*/
|
|
135
|
+
export async function syncMemberBefore(member, opts = {}) {
|
|
136
|
+
const { command, log = () => {}, maxTransientRetries = 1, remote = 'origin', branch, onAuthFailure, resetToRemoteTip = false, resolveMemberProvider } = opts;
|
|
137
|
+
if (typeof command !== 'function') {
|
|
138
|
+
throw new Error("syncMemberBefore requires an injected command() in opts");
|
|
139
|
+
}
|
|
140
|
+
const provider = await resolveGitProviderForClassification(resolveMemberProvider, member, log);
|
|
141
|
+
|
|
142
|
+
const fetchCmd = branch ? `git fetch ${remote} ${branch}` : `git fetch ${remote}`;
|
|
143
|
+
const fetch = await runGitStep({
|
|
144
|
+
command, member, cmd: fetchCmd,
|
|
145
|
+
label: `G-pull fetch for '${member}'`, log, maxTransientRetries, onAuthFailure, provider,
|
|
146
|
+
});
|
|
147
|
+
if (!fetch.ok) {
|
|
148
|
+
// A brand-new sprint branch created locally from base, before its
|
|
149
|
+
// first G-push, makes this fetch fail with "couldn't find remote ref
|
|
150
|
+
// <branch>". That is a benign, expected state: there is nothing on the
|
|
151
|
+
// remote to pull, so the bracket's pull half is a no-op, not an error.
|
|
152
|
+
// Only this precise git message may be treated as
|
|
153
|
+
// branch-doesn't-exist; anything else must still surface.
|
|
154
|
+
if (isMissingRemoteRefError(fetch.error)) {
|
|
155
|
+
log(`[Sync] G-pull for member '${member}': branch '${branch}' does not exist on '${remote}' yet (not pushed); skipping pull (nothing to sync down).`);
|
|
156
|
+
return { ok: true, member };
|
|
157
|
+
}
|
|
158
|
+
// A fetch cannot "diverge" -- any failure here is transient-exhausted
|
|
159
|
+
// or unknown; surface it as a (non-diverged) sync error.
|
|
160
|
+
throw new GitSyncError(
|
|
161
|
+
`[Sync] G-pull fetch failed for member '${member}': ${fetch.error}`,
|
|
162
|
+
{ member, gitOutput: fetch.error },
|
|
163
|
+
);
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
// On a RETRIED dispatch whose prior attempt was not provably a no-mutation
|
|
167
|
+
// failure (it may have committed and/or pushed its streak), `git merge
|
|
168
|
+
// --ff-only` is the wrong recovery: if the prior attempt pushed and the
|
|
169
|
+
// local tip then diverged with a re-implemented duplicate commit, the
|
|
170
|
+
// ff-only merge raises GitDivergedError and the streak can NEVER resume,
|
|
171
|
+
// because every subsequent push/merge fails non-fast-forward. Hard-resetting
|
|
172
|
+
// onto the freshly fetched remote tip makes the retry resume ON TOP of
|
|
173
|
+
// already-published work instead of re-committing it. Only the code checkout
|
|
174
|
+
// is touched (beads live in a separate Dolt clone); a local commit that was
|
|
175
|
+
// never published is intentionally dropped and simply re-done by the retry,
|
|
176
|
+
// which is what prevents the divergent duplicate commit. A concrete branch
|
|
177
|
+
// is required to name a remote tip; without one this falls through to the
|
|
178
|
+
// ff-only merge below.
|
|
179
|
+
if (resetToRemoteTip && branch) {
|
|
180
|
+
const resetTarget = `${remote}/${branch}`;
|
|
181
|
+
const reset = await runGitStep({
|
|
182
|
+
command, member, cmd: `git reset --hard ${resetTarget}`,
|
|
183
|
+
label: `G-pull reset-to-remote-tip for '${member}'`, log, maxTransientRetries, onAuthFailure, provider,
|
|
184
|
+
});
|
|
185
|
+
if (!reset.ok) {
|
|
186
|
+
throw new GitSyncError(
|
|
187
|
+
`[Sync] G-pull reset-to-remote-tip failed for member '${member}': ${reset.error}`,
|
|
188
|
+
{ member, gitOutput: reset.error },
|
|
189
|
+
);
|
|
190
|
+
}
|
|
191
|
+
log(`[Sync] G-pull for member '${member}': hard-reset local branch onto '${resetTarget}' so a retried dispatch resumes on the published tip instead of re-committing.`);
|
|
192
|
+
return { ok: true, member };
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
const mergeCmd = branch ? `git merge --ff-only ${remote}/${branch}` : 'git merge --ff-only';
|
|
196
|
+
const merge = await runGitStep({
|
|
197
|
+
command, member, cmd: mergeCmd,
|
|
198
|
+
label: `G-pull ff-only merge for '${member}'`, log, maxTransientRetries, onAuthFailure, provider,
|
|
199
|
+
});
|
|
200
|
+
if (!merge.ok) {
|
|
201
|
+
if (merge.kind === 'diverged') {
|
|
202
|
+
throw new GitDivergedError(
|
|
203
|
+
`[Sync] G-pull for member '${member}' could not fast-forward -- it has DIVERGED from the shared branch and must not be auto-merged: ${merge.error}`,
|
|
204
|
+
{ member, gitOutput: merge.error, operation: 'pull' },
|
|
205
|
+
);
|
|
206
|
+
}
|
|
207
|
+
throw new GitSyncError(
|
|
208
|
+
`[Sync] G-pull ff-only merge failed for member '${member}': ${merge.error}`,
|
|
209
|
+
{ member, gitOutput: merge.error },
|
|
210
|
+
);
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
return { ok: true, member };
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
/**
|
|
217
|
+
* G-push: publish `member`'s committed work to the shared branch after a
|
|
218
|
+
* dispatch -- `git push` with ONE bounded pull-rebase retry. If the
|
|
219
|
+
* push is rejected as non-FF (another writer got there first), do a single
|
|
220
|
+
* `git pull --rebase` and re-push exactly once; if it is STILL rejected, raise
|
|
221
|
+
* a typed GitDivergedError -- the single-writer invariant is violated and the
|
|
222
|
+
* push must never be retried further/blindly. Transient (network/lock)
|
|
223
|
+
* failures are retried up to `maxTransientRetries`; divergence is never
|
|
224
|
+
* retried beyond the one bounded rebase.
|
|
225
|
+
*
|
|
226
|
+
* `pushCode: false` makes this a no-op (a read-only bracket has nothing to
|
|
227
|
+
* publish). Every git command is issued via the injected command() with an
|
|
228
|
+
* explicit member_name.
|
|
229
|
+
*
|
|
230
|
+
* Tier 2 of the git conflict ladder: when the pull-rebase retry hits a REAL
|
|
231
|
+
* content conflict (unmerged paths, not just a plain non-FF race), an optional
|
|
232
|
+
* injected `agent()` gets exactly ONE bounded conflict-resolution-runbook
|
|
233
|
+
* dispatch before this function gives up and throws the typed
|
|
234
|
+
* GitDivergedError. The agent's own claim of success is never trusted: this
|
|
235
|
+
* function mechanically re-checks `git status --porcelain` for a clean tree and
|
|
236
|
+
* then attempts one real re-push; only that observed outcome decides whether
|
|
237
|
+
* Tier 2 resolved the conflict. Omitting `agent` leaves Tier 1 only.
|
|
238
|
+
*
|
|
239
|
+
* An optional injected `onAuthFailure` is threaded through to every runGitStep
|
|
240
|
+
* call below for a bounded one-shot self-heal (call it once, retry the same
|
|
241
|
+
* command once) whenever a step is classified 'auth'.
|
|
242
|
+
*
|
|
243
|
+
* apra-fleet-417.7: an optional injected `resolveMemberProvider` (see
|
|
244
|
+
* createMemberVcsProviderResolver) is resolved ONCE at the top of this call
|
|
245
|
+
* and threaded into every runGitStep call below, so a G-push auth failure for
|
|
246
|
+
* a non-GitHub member classifies via that member's own provider chain.
|
|
247
|
+
*
|
|
248
|
+
* @param {string} member
|
|
249
|
+
* @param {{
|
|
250
|
+
* command: Function, pushCode?: boolean, log?: Function,
|
|
251
|
+
* maxTransientRetries?: number, remote?: string, branch?: string,
|
|
252
|
+
* agent?: Function, resolveConflictModel?: string, onAuthFailure?: Function,
|
|
253
|
+
* resolveMemberProvider?: (member: string) => Promise<string|undefined>,
|
|
254
|
+
* }} opts
|
|
255
|
+
* @returns {Promise<{ ok: true, member: string, pushed: boolean, rebased: boolean, tier2Resolved?: boolean }>}
|
|
256
|
+
*/
|
|
257
|
+
export async function syncMemberAfter(member, opts = {}) {
|
|
258
|
+
const {
|
|
259
|
+
command, pushCode = true, log = () => {}, maxTransientRetries = 1, remote = 'origin', branch,
|
|
260
|
+
agent, resolveConflictModel, onAuthFailure, resolveMemberProvider, setUpstream = false,
|
|
261
|
+
} = opts;
|
|
262
|
+
if (typeof command !== 'function') {
|
|
263
|
+
throw new Error("syncMemberAfter requires an injected command() in opts");
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
if (!pushCode) {
|
|
267
|
+
return { ok: true, member, pushed: false, rebased: false };
|
|
268
|
+
}
|
|
269
|
+
const provider = await resolveGitProviderForClassification(resolveMemberProvider, member, log);
|
|
270
|
+
|
|
271
|
+
// apra-fleet: `setUpstream` (opt-in, default false -- every existing
|
|
272
|
+
// caller's command text is byte-for-byte unchanged) is for Publish PR's
|
|
273
|
+
// push specifically: it needs `-u` to set the tracking branch on a brand
|
|
274
|
+
// new sprint branch's first push, AND that distinct spelling is what lets
|
|
275
|
+
// mock-sprint-publish-push-failure.test.mjs's `gitGhFailurePattern` (and
|
|
276
|
+
// any real-world log grep) target Publish's push in isolation from every
|
|
277
|
+
// OTHER per-dispatch G-push in the same sprint, which all share the plain
|
|
278
|
+
// `git push <remote> <branch>` spelling below.
|
|
279
|
+
const pushCmd = branch ? `git push${setUpstream ? ' -u' : ''} ${remote} ${branch}` : 'git push';
|
|
280
|
+
|
|
281
|
+
let push = await runGitStep({
|
|
282
|
+
command, member, cmd: pushCmd,
|
|
283
|
+
label: `G-push for '${member}'`, log, maxTransientRetries, onAuthFailure, provider,
|
|
284
|
+
});
|
|
285
|
+
if (push.ok) {
|
|
286
|
+
return { ok: true, member, pushed: true, rebased: false };
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
if (push.kind !== 'diverged') {
|
|
290
|
+
// Transient-exhausted or unknown non-FF failure -- not a divergence,
|
|
291
|
+
// so no rebase retry; surface the (non-diverged) sync error.
|
|
292
|
+
throw new GitSyncError(
|
|
293
|
+
`[Sync] G-push for member '${member}' failed: ${push.error}`,
|
|
294
|
+
{ member, gitOutput: push.error },
|
|
295
|
+
);
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
// Non-FF push: attempt EXACTLY ONE pull --rebase then re-push.
|
|
299
|
+
log(`[Sync] G-push for member '${member}' was rejected as non-fast-forward; attempting a single pull --rebase then one re-push.`);
|
|
300
|
+
const rebaseCmd = branch ? `git pull --rebase ${remote} ${branch}` : 'git pull --rebase';
|
|
301
|
+
const rebase = await runGitStep({
|
|
302
|
+
command, member, cmd: rebaseCmd,
|
|
303
|
+
label: `G-push pull-rebase retry for '${member}'`, log, maxTransientRetries, onAuthFailure, provider,
|
|
304
|
+
});
|
|
305
|
+
if (!rebase.ok) {
|
|
306
|
+
// Missing-remote-ref guard (apra-fleet-ta3.3). ROOT CAUSE: the
|
|
307
|
+
// initial push above can be classified 'diverged' even when `remote`
|
|
308
|
+
// has NO such branch at all -- git's non-fast-forward rejection
|
|
309
|
+
// trailers ("failed to push some refs", "[rejected]") are GENERIC:
|
|
310
|
+
// they are also the trailer git prints for other push rejections,
|
|
311
|
+
// and nothing in that first push's own error text can distinguish
|
|
312
|
+
// "the remote branch exists and truly diverged" from "the remote
|
|
313
|
+
// branch does not exist yet". The only place that distinction
|
|
314
|
+
// becomes observable is here: `git pull --rebase` against a
|
|
315
|
+
// nonexistent remote branch fails with the SAME exact, unambiguous
|
|
316
|
+
// "couldn't find remote ref <branch>" message syncMemberBefore
|
|
317
|
+
// already treats as benign (see isMissingRemoteRefError() above) --
|
|
318
|
+
// so this is not a divergence to reconcile, it is a brand-new local
|
|
319
|
+
// branch that has simply never been pushed. Skip the doomed
|
|
320
|
+
// rebase/conflict machinery entirely and retry a plain push, which
|
|
321
|
+
// creates the branch on `remote`.
|
|
322
|
+
if (isMissingRemoteRefError(rebase.error)) {
|
|
323
|
+
log(`[Sync] G-push pull-rebase for member '${member}': branch '${branch}' does not exist on '${remote}' yet (never pushed) -- nothing to rebase against; retrying the push directly to create it.`);
|
|
324
|
+
const createPush = await runGitStep({
|
|
325
|
+
command, member, cmd: pushCmd,
|
|
326
|
+
label: `G-push retry (create missing remote branch) for '${member}'`, log, maxTransientRetries, onAuthFailure, provider,
|
|
327
|
+
});
|
|
328
|
+
if (createPush.ok) {
|
|
329
|
+
return { ok: true, member, pushed: true, rebased: false };
|
|
330
|
+
}
|
|
331
|
+
if (createPush.kind === 'diverged') {
|
|
332
|
+
// The branch now exists on the remote -- a concurrent writer
|
|
333
|
+
// must have published it between our rebase attempt and this
|
|
334
|
+
// retry. That IS a genuine divergence; the single-writer
|
|
335
|
+
// invariant is violated and this must not be retried further.
|
|
336
|
+
throw new GitDivergedError(
|
|
337
|
+
`[Sync] G-push for member '${member}' was rejected on retry after a missing-remote-ref rebase skip -- another writer published '${branch}' first; the single-writer token invariant is violated: ${createPush.error}`,
|
|
338
|
+
{ member, gitOutput: createPush.error, operation: 'push' },
|
|
339
|
+
);
|
|
340
|
+
}
|
|
341
|
+
throw new GitSyncError(
|
|
342
|
+
`[Sync] G-push retry (create missing remote branch) for member '${member}' failed: ${createPush.error}`,
|
|
343
|
+
{ member, gitOutput: createPush.error },
|
|
344
|
+
);
|
|
345
|
+
}
|
|
346
|
+
|
|
347
|
+
// Tier 1 scripted detection: confirm from git's own porcelain status --
|
|
348
|
+
// not from this failing command's exit code/message classification --
|
|
349
|
+
// whether the rebase actually left unmerged paths, and if so restore a
|
|
350
|
+
// clean tree via `git rebase --abort` BEFORE the typed divergence error
|
|
351
|
+
// below propagates. This is the single Tier 1 -> Tier 2 escalation
|
|
352
|
+
// point.
|
|
353
|
+
const unmergedPaths = await detectAndAbortRebaseConflict({ command, member, log, maxTransientRetries, runGitStep });
|
|
354
|
+
|
|
355
|
+
// Tier 2: unmergedPaths.length > 0 means a real content conflict, not
|
|
356
|
+
// just a non-FF race. Attempt exactly ONE bounded agent-with-runbook
|
|
357
|
+
// dispatch (when an agent() was injected) before falling back to the
|
|
358
|
+
// typed GitDivergedError below. Every outcome (agent throws, agent
|
|
359
|
+
// returns, or agent unavailable) is mechanically re-verified against
|
|
360
|
+
// real git state -- never the agent's own claim.
|
|
361
|
+
if (unmergedPaths.length > 0 && typeof agent === 'function') {
|
|
362
|
+
try {
|
|
363
|
+
await dispatchConflictResolutionAgent({
|
|
364
|
+
agent, member, branch, unmergedPaths, log, model: resolveConflictModel, remote,
|
|
365
|
+
});
|
|
366
|
+
} catch (tier2Err) {
|
|
367
|
+
log(`[Sync] Tier 2 conflict-resolution dispatch for member '${member}' threw and will not be retried (script-first: no further escalation): ${tier2Err.message}`);
|
|
368
|
+
}
|
|
369
|
+
|
|
370
|
+
const postTier2Status = await command('git status --porcelain', { member_name: member, silent: true, failSoft: true, label: `Tier 2 post-resolution clean-state check for '${member}'` });
|
|
371
|
+
const stillUnmerged = parseUnmergedPaths(postTier2Status && postTier2Status.output ? postTier2Status.output : '');
|
|
372
|
+
if (stillUnmerged.length === 0) {
|
|
373
|
+
const rePush = await runGitStep({
|
|
374
|
+
command, member, cmd: pushCmd,
|
|
375
|
+
label: `G-push after Tier 2 conflict resolution for '${member}'`, log, maxTransientRetries, onAuthFailure, provider,
|
|
376
|
+
});
|
|
377
|
+
if (rePush.ok) {
|
|
378
|
+
log(`[Sync] Tier 2 conflict resolution for member '${member}' succeeded -- working tree clean and the resolved code was pushed.`);
|
|
379
|
+
return { ok: true, member, pushed: true, rebased: true, tier2Resolved: true };
|
|
380
|
+
}
|
|
381
|
+
log(`[Sync] Tier 2 conflict resolution for member '${member}' left a clean tree but the re-push still failed: ${rePush.error}`);
|
|
382
|
+
} else {
|
|
383
|
+
log(`[Sync] Tier 2 conflict resolution for member '${member}' did not fully resolve -- porcelain still shows unmerged path(s): ${stillUnmerged.join(', ')}. Restoring a clean tree before failing this streak.`);
|
|
384
|
+
await detectAndAbortRebaseConflict({ command, member, log, maxTransientRetries, runGitStep });
|
|
385
|
+
}
|
|
386
|
+
}
|
|
387
|
+
|
|
388
|
+
if (rebase.kind === 'diverged' || unmergedPaths.length > 0) {
|
|
389
|
+
throw new GitDivergedError(
|
|
390
|
+
`[Sync] G-push pull-rebase for member '${member}' hit unmergeable divergence (conflict) -- must not be retried blindly: ${rebase.error}`,
|
|
391
|
+
{ member, gitOutput: rebase.error, operation: 'push-rebase', details: { unmergedPaths } },
|
|
392
|
+
);
|
|
393
|
+
}
|
|
394
|
+
throw new GitSyncError(
|
|
395
|
+
`[Sync] G-push pull-rebase for member '${member}' failed: ${rebase.error}`,
|
|
396
|
+
{ member, gitOutput: rebase.error },
|
|
397
|
+
);
|
|
398
|
+
}
|
|
399
|
+
|
|
400
|
+
push = await runGitStep({
|
|
401
|
+
command, member, cmd: pushCmd,
|
|
402
|
+
label: `G-push re-push after rebase for '${member}'`, log, maxTransientRetries, onAuthFailure, provider,
|
|
403
|
+
});
|
|
404
|
+
if (push.ok) {
|
|
405
|
+
return { ok: true, member, pushed: true, rebased: true };
|
|
406
|
+
}
|
|
407
|
+
|
|
408
|
+
// Still rejected after the one bounded rebase -- diverged, never retried further.
|
|
409
|
+
throw new GitDivergedError(
|
|
410
|
+
`[Sync] G-push for member '${member}' still rejected after one pull-rebase retry -- the single-writer token invariant is violated; refusing to retry further: ${push.error}`,
|
|
411
|
+
{ member, gitOutput: push.error, operation: 'push' },
|
|
412
|
+
);
|
|
413
|
+
}
|
|
414
|
+
|
|
415
|
+
/**
|
|
416
|
+
* The ordered post-dispatch sync step every withGitSync() bracket's `finally`
|
|
417
|
+
* runs: G-push (code) BEFORE D-push (beads).
|
|
418
|
+
*
|
|
419
|
+
* For code-writing roles (pushCode:true), G-push MUST succeed before D-push is
|
|
420
|
+
* attempted. If G-push throws at all, D-push is skipped ENTIRELY and the error
|
|
421
|
+
* is rethrown, never swallowed -- closing a bead in dolt while the code that
|
|
422
|
+
* justifies the close never left this member's checkout would advertise an
|
|
423
|
+
* UNREACHABLE CLOSE: a reviewer, or the next streak's G-pull, would see the
|
|
424
|
+
* bead done and find no matching commit on the shared branch.
|
|
425
|
+
*
|
|
426
|
+
* With pushCode:false, syncMemberAfter never touches git and cannot throw, so
|
|
427
|
+
* D-push always still runs.
|
|
428
|
+
*
|
|
429
|
+
* `agent`/`resolveConflictModel` are threaded through to syncMemberAfter's
|
|
430
|
+
* conflict-resolution escalation; `onAuthFailure` is threaded through to BOTH
|
|
431
|
+
* syncMemberAfter and doltPushAfter for their bounded one-shot self-heal.
|
|
432
|
+
*
|
|
433
|
+
* @param {string} member
|
|
434
|
+
* @param {{
|
|
435
|
+
* command: Function, pushCode?: boolean, pushBeads?: boolean,
|
|
436
|
+
* log?: Function, mutex?: { acquire: Function, release: Function },
|
|
437
|
+
* sprintId?: string, branch?: string, maxTransientRetries?: number,
|
|
438
|
+
* remote?: string, agent?: Function, resolveConflictModel?: string,
|
|
439
|
+
* onAuthFailure?: Function,
|
|
440
|
+
* resolveMemberProvider?: (member: string) => Promise<string|undefined>,
|
|
441
|
+
* args?: { callTool?: Function },
|
|
442
|
+
* sprintState?: object,
|
|
443
|
+
* }} opts
|
|
444
|
+
* @returns {Promise<{ ok: true, member: string, gPush: object, dPush: object }>}
|
|
445
|
+
*/
|
|
446
|
+
export async function syncMemberAfterOrdered(member, opts = {}) {
|
|
447
|
+
const {
|
|
448
|
+
command, pushCode = true, pushBeads = true, log = () => {},
|
|
449
|
+
mutex, sprintId, branch, maxTransientRetries = 1, remote = 'origin',
|
|
450
|
+
agent, resolveConflictModel, onAuthFailure, resolveMemberProvider, args, sprintState,
|
|
451
|
+
} = opts;
|
|
452
|
+
|
|
453
|
+
let gPush;
|
|
454
|
+
try {
|
|
455
|
+
gPush = await syncMemberAfter(member, { command, pushCode, log, branch, maxTransientRetries, remote, agent, resolveConflictModel, onAuthFailure, resolveMemberProvider });
|
|
456
|
+
} catch (gPushErr) {
|
|
457
|
+
log(`[Sync] G-push failed for member '${member}' -- skipping D-push and failing this streak rather than advertising an unreachable close (a beads close whose justifying code never reached the shared branch): ${gPushErr.message}`);
|
|
458
|
+
throw gPushErr;
|
|
459
|
+
}
|
|
460
|
+
|
|
461
|
+
// EXPLICITLY FATAL (apra-fleet-417.3.1): DoltSync.syncAfter is degraded by
|
|
462
|
+
// default, but this is the post-dispatch bracket -- the member's beads
|
|
463
|
+
// closes must reach the shared remote or the orchestrator's next read sees
|
|
464
|
+
// a bead this streak believes it closed. A silent degrade here would
|
|
465
|
+
// advertise an unreachable close, exactly what the G-push-before-D-push
|
|
466
|
+
// ordering above exists to prevent, and would erase the
|
|
467
|
+
// BEADS_SYNC_CONFLICT terminal reason the dashboard reports.
|
|
468
|
+
//
|
|
469
|
+
// Before that fatal divergence surfaces, run the deterministic settle
|
|
470
|
+
// (settleDoltConflicts, dolt-settle.mjs). It is TOTAL over row-level
|
|
471
|
+
// conflicts -- no gates, no allowlist, no LLM escalation -- and a resolved
|
|
472
|
+
// settle is a VERIFIED recovery, because settle republishes (bd dolt pull
|
|
473
|
+
// + push) and checks the push actually landed before returning. The streak
|
|
474
|
+
// only fails (DoltDivergedError -> BEADS_SYNC_CONFLICT) when settle itself
|
|
475
|
+
// hits an operational failure (no usable dolt binary, the ephemeral server
|
|
476
|
+
// would not start, a SQL statement errored).
|
|
477
|
+
//
|
|
478
|
+
// Notably, the data-loss hazard that forced the old ladder's Path B to be
|
|
479
|
+
// disabled at THIS call site does not exist for settle: it never discards
|
|
480
|
+
// and re-bootstraps a clone, so an arbitrary multi-command dispatch's bead
|
|
481
|
+
// mutations cannot be silently thrown away here. There is no pendingMutation
|
|
482
|
+
// to capture and replay because nothing is ever dropped.
|
|
483
|
+
// Thread this member's REGISTERED shell into dolt-settle the same way
|
|
484
|
+
// the pre-dispatch bracket does (apra-fleet-7dir.16/.24), guarded on
|
|
485
|
+
// `args.callTool` so a caller with no MCP client (mock-sprint scenarios)
|
|
486
|
+
// keeps the pre-shell-aware default.
|
|
487
|
+
const shell = await resolveSettleShell({ args, member, log, sprintState });
|
|
488
|
+
const settle = buildSettleCallback(member, { command, log, shell });
|
|
489
|
+
const dPush = await DoltSync.syncAfter(member, { command, pushBeads, log, mutex, sprintId, onAuthFailure, fatal: true, settle });
|
|
490
|
+
return { ok: true, member, gPush, dPush };
|
|
491
|
+
}
|
|
492
|
+
|
|
493
|
+
/**
|
|
494
|
+
* (apra-fleet-p2to.4.2) Re-sync ONE member that was just re-acquired on resume.
|
|
495
|
+
* Runs -- UNCONDITIONALLY, never gated on a "looks unchanged" heuristic -- the
|
|
496
|
+
* same three reconciliation steps a fresh dispatch would rely on, because while
|
|
497
|
+
* this sprint was paused both origin and the beads DB can have moved (another
|
|
498
|
+
* sprint, a human push) on top of the released member:
|
|
499
|
+
*
|
|
500
|
+
* 1. `git fetch` (base branch, then the sprint branch soft -- a brand-new
|
|
501
|
+
* branch legitimately has no remote ref yet).
|
|
502
|
+
* 2. The pure decideEnsureBranchAction() probe: fetch outcome + a local-branch
|
|
503
|
+
* existence probe + (when both tips exist) a two-way ancestor comparison,
|
|
504
|
+
* fed into the SAME decision helper the Ensure Sprint Branch phase uses.
|
|
505
|
+
* An 'abort' decision (fetch failed for a non-"missing ref" reason, or the
|
|
506
|
+
* tips diverged) THROWS rather than touch git -- resuming onto a diverged
|
|
507
|
+
* branch could silently discard real pushed work. A 'checkout' decision is
|
|
508
|
+
* executed so the member's working branch is reconciled to origin's new
|
|
509
|
+
* tip before work continues.
|
|
510
|
+
* 3. `bd dolt pull` -- re-sync the beads clone to whatever landed while paused.
|
|
511
|
+
*
|
|
512
|
+
* All I/O is injected so this stays transport-agnostic and unit-testable:
|
|
513
|
+
* - `runGit(cmd)` -> Promise<{ ok: boolean, stdout?: string, error?: string }>
|
|
514
|
+
* (a SOFT git runner: it never throws; this function decides which failures
|
|
515
|
+
* are fatal).
|
|
516
|
+
* - `doltPull(member)` -> Promise<any> (runs `bd dolt pull` on the member).
|
|
517
|
+
*
|
|
518
|
+
* @param {{ member: string, branch: string, baseBranch: string,
|
|
519
|
+
* runGit: (cmd: string) => Promise<{ ok: boolean, stdout?: string, error?: string }>,
|
|
520
|
+
* doltPull: (member: string) => Promise<any>, log?: Function }} opts
|
|
521
|
+
* @returns {Promise<void>}
|
|
522
|
+
*/
|
|
523
|
+
export async function resyncReacquiredMember(opts = {}) {
|
|
524
|
+
const { member, branch, baseBranch, runGit, doltPull, log = () => {} } = opts;
|
|
525
|
+
if (typeof runGit !== 'function' || typeof doltPull !== 'function') {
|
|
526
|
+
throw new TypeError('resyncReacquiredMember requires runGit() and doltPull() to be injected');
|
|
527
|
+
}
|
|
528
|
+
|
|
529
|
+
async function gitStep(cmd, { failSoft = false } = {}) {
|
|
530
|
+
const res = await runGit(cmd);
|
|
531
|
+
if (!failSoft && !(res && res.ok)) {
|
|
532
|
+
throw new Error(
|
|
533
|
+
`[resume-resync] '${cmd}' failed on member '${member}': ${(res && (res.error || res.stdout)) || 'unknown error'}`
|
|
534
|
+
);
|
|
535
|
+
}
|
|
536
|
+
return res || { ok: false };
|
|
537
|
+
}
|
|
538
|
+
|
|
539
|
+
// 1. git fetch: base (hard -- a missing base is a real problem) then the
|
|
540
|
+
// sprint branch (soft -- a brand-new branch has no remote ref yet).
|
|
541
|
+
await gitStep(`git fetch origin ${baseBranch} --quiet`);
|
|
542
|
+
const branchFetch = await gitStep(`git fetch origin ${branch} --quiet`, { failSoft: true });
|
|
543
|
+
|
|
544
|
+
// 2. decideEnsureBranchAction probe: local-branch existence + tip comparison.
|
|
545
|
+
const localProbe = await gitStep(`git rev-parse --verify --quiet refs/heads/${branch}`, { failSoft: true });
|
|
546
|
+
const localBranchExists = localProbe.ok;
|
|
547
|
+
let localTipStatus;
|
|
548
|
+
if (branchFetch.ok && localBranchExists) {
|
|
549
|
+
const localIsAncestorOfRemote = await gitStep(
|
|
550
|
+
`git merge-base --is-ancestor ${branch} origin/${branch}`, { failSoft: true }
|
|
551
|
+
);
|
|
552
|
+
const remoteIsAncestorOfLocal = await gitStep(
|
|
553
|
+
`git merge-base --is-ancestor origin/${branch} ${branch}`, { failSoft: true }
|
|
554
|
+
);
|
|
555
|
+
if (localIsAncestorOfRemote.ok) {
|
|
556
|
+
localTipStatus = 'behind-or-equal';
|
|
557
|
+
} else if (remoteIsAncestorOfLocal.ok) {
|
|
558
|
+
localTipStatus = 'ahead';
|
|
559
|
+
} else {
|
|
560
|
+
localTipStatus = 'diverged';
|
|
561
|
+
}
|
|
562
|
+
}
|
|
563
|
+
const decision = decideEnsureBranchAction({
|
|
564
|
+
branch,
|
|
565
|
+
baseBranch,
|
|
566
|
+
branchFetchOk: branchFetch.ok,
|
|
567
|
+
branchFetchError: branchFetch.error,
|
|
568
|
+
localBranchExists,
|
|
569
|
+
localTipStatus,
|
|
570
|
+
});
|
|
571
|
+
if (decision.action === 'abort') {
|
|
572
|
+
throw new Error(`[resume-resync] ${decision.message} (member '${member}')`);
|
|
573
|
+
}
|
|
574
|
+
// Reconcile the member's working branch to origin's (possibly moved) tip.
|
|
575
|
+
await gitStep(decision.command);
|
|
576
|
+
|
|
577
|
+
// 3. bd dolt pull: re-sync the beads clone.
|
|
578
|
+
await doltPull(member);
|
|
579
|
+
|
|
580
|
+
log(`[resume-resync] member '${member}' re-synced (git fetch + branch reconcile + beads D-pull) before work resumed`);
|
|
581
|
+
}
|