@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,323 @@
|
|
|
1
|
+
// =============================================================================
|
|
2
|
+
// PHASE MODULE: Publish PR (apra-fleet-3swo.6.9).
|
|
3
|
+
//
|
|
4
|
+
// The TWELFTH and LAST of runSprintCycle's twelve phase() boundaries: push the
|
|
5
|
+
// sprint branch and raise (but never merge) a pull request for it. Per the pm
|
|
6
|
+
// skill's R12 rule a human -- or a later, explicitly-scoped issue -- must
|
|
7
|
+
// review and merge; nothing here merges anything. Moved verbatim out of
|
|
8
|
+
// runner.js: every log line, PR title/body string and command() option is
|
|
9
|
+
// byte-identical to the inline version, so the golden transcript is unchanged.
|
|
10
|
+
// Move-only, no behaviour change.
|
|
11
|
+
//
|
|
12
|
+
// WHERE THIS PHASE STARTS AND STOPS. It starts at its own phase() call and
|
|
13
|
+
// ends where the inline version's final `endGroup()` used to sit. The
|
|
14
|
+
// `// 7. Publish` section banner above it, BOTH endGroup() calls and the two
|
|
15
|
+
// return objects stay in runner.js -- group('Finalization')/endGroup() wrap all
|
|
16
|
+
// four Finalization phases, not this one, and runSprintCycle's return value is
|
|
17
|
+
// the function's own contract. This phase returns `{ pushed }` and runner.js
|
|
18
|
+
// builds both return objects from it; that is the ONLY structural change, and
|
|
19
|
+
// it is behaviour-preserving in both directions:
|
|
20
|
+
// - push failed: this phase logs [Publish Push Failed] and returns
|
|
21
|
+
// pushed:false WITHOUT doing any PR/target-issue work, exactly as the
|
|
22
|
+
// inline early return did; runner.js then endGroup()s and returns the
|
|
23
|
+
// COMPUTED verdict with pushed:false.
|
|
24
|
+
// - push succeeded: this phase runs the PR/target-issue work and returns
|
|
25
|
+
// pushed:true; runner.js endGroup()s and returns the computed verdict.
|
|
26
|
+
// A genuine PR-creation failure still throws a typed CommandError from inside
|
|
27
|
+
// this phase, so it propagates out BEFORE runner.js's endGroup() -- same
|
|
28
|
+
// ordering the inline version had.
|
|
29
|
+
//
|
|
30
|
+
// THE BRANCH PUSH STAYS INSIDE A SYNC BRACKET (apra-fleet-3swo.4.1). The push
|
|
31
|
+
// goes through gitSync.pushGitAfter(), the bracketed syncMemberAfter() entry
|
|
32
|
+
// point -- never a raw `git push` and never the bare primitive -- so the pause
|
|
33
|
+
// guard reads "not clean" for its whole duration and a pause can never land
|
|
34
|
+
// mid-push of the sprint branch. Registering this module in
|
|
35
|
+
// ../guarded-modules.mjs is what keeps unbracketed-push-guard covering that
|
|
36
|
+
// site instead of silently losing it now that it has left runner.js. The
|
|
37
|
+
// non-hosted-remote target-issue closure's D-push likewise goes through
|
|
38
|
+
// gitSync.syncBeadsAfter(..., { pushBeads: true }).
|
|
39
|
+
//
|
|
40
|
+
// WHICH MEMBER DOES WHAT, AND WHY IT MATTERS. The branch push and the
|
|
41
|
+
// `git remote get-url origin` read run on publishGitMember -- the role-resolved
|
|
42
|
+
// 'harvester' member, a real dispatch member with an actual git checkout --
|
|
43
|
+
// NEVER orchestratorMember, which may be a shared/unreservable, git-less member
|
|
44
|
+
// (docs/design-orchestrator-worktree-model-v2.md section 4.3/4.5).
|
|
45
|
+
// raiseVcsPrForMember() and the direct `bd close` calls stay on
|
|
46
|
+
// orchestratorMember: a credential-file read plus a REST call, and beads
|
|
47
|
+
// mutations, neither of which needs a git checkout (section 4.6).
|
|
48
|
+
//
|
|
49
|
+
// WHY ITS HELPERS ARE INJECTED RATHER THAN IMPORTED. sanitizePrText is defined
|
|
50
|
+
// in ../runner.js, so importing it would be a circular import back into the
|
|
51
|
+
// file this module was sliced out of -- it is injected exactly as
|
|
52
|
+
// ./final-review.mjs injects it. command, gitSync, getMemberForRole and args
|
|
53
|
+
// are runSprintCycle-scoped, so there is nothing to import; vcsCapabilities,
|
|
54
|
+
// raiseVcsPrForMember, ApraFleet and CommandError live in real modules and are
|
|
55
|
+
// imported directly.
|
|
56
|
+
//
|
|
57
|
+
// GUARD COVERAGE: registered as 'phases/publish-pr.mjs' in
|
|
58
|
+
// ../guarded-modules.mjs. It took TWO member_name-bearing command() call sites
|
|
59
|
+
// out of runner.js -- the `git remote get-url origin` capability probe on
|
|
60
|
+
// publishGitMember and the per-target-issue `bd close` on orchestratorMember --
|
|
61
|
+
// plus the branch push and the beads D-push described above, and NO
|
|
62
|
+
// dispatchRole() site (it dispatches no agent; raiseVcsPrForMember is a REST
|
|
63
|
+
// call). That is exactly what dispatch-safety-guard, unbracketed-push-guard
|
|
64
|
+
// and the phase 3 dispatch census read, so all three baselines are pinned
|
|
65
|
+
// rather than assumed. It also owns the ONLY remaining vcsCapabilities() call
|
|
66
|
+
// site outside abort.mjs, which test/vcs-capabilities-table.test.mjs counts.
|
|
67
|
+
// =============================================================================
|
|
68
|
+
|
|
69
|
+
import { CommandError } from '@apralabs/apra-fleet-workflow';
|
|
70
|
+
import { ApraFleet } from '@apralabs/apra-fleet-client';
|
|
71
|
+
import { capabilities as vcsCapabilities } from '../vcs-module.mjs';
|
|
72
|
+
import { raiseVcsPrForMember } from '../vcs-auth.mjs';
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* Runs the Publish PR phase: push the sprint branch, then either raise a PR on
|
|
76
|
+
* a hosted remote or (on a remote that can never open one) close the target
|
|
77
|
+
* issue(s) directly when the verdict passed.
|
|
78
|
+
*
|
|
79
|
+
* @param {object} state Explicit phase state; see this file's header.
|
|
80
|
+
* @returns {Promise<{ pushed: boolean }>} Whether the sprint branch actually
|
|
81
|
+
* reached the remote. runner.js folds this straight into runSprintCycle's
|
|
82
|
+
* return value -- it never overrides the sprint's own computed verdict.
|
|
83
|
+
*/
|
|
84
|
+
export async function runPublishPrPhase({
|
|
85
|
+
// Presentation + command seams.
|
|
86
|
+
phase,
|
|
87
|
+
log,
|
|
88
|
+
command,
|
|
89
|
+
// Sprint identity/config.
|
|
90
|
+
args,
|
|
91
|
+
validated,
|
|
92
|
+
targetIssues,
|
|
93
|
+
orchestratorMember,
|
|
94
|
+
finalCycleLabel,
|
|
95
|
+
// The sync brackets this phase's branch push and beads D-push go through.
|
|
96
|
+
gitSync,
|
|
97
|
+
// Role resolution for the git-capable publishing member (see header).
|
|
98
|
+
getMemberForRole,
|
|
99
|
+
// The verdict this phase publishes but must never change.
|
|
100
|
+
finalVerdictResult,
|
|
101
|
+
// Exported BY runner.js; injected to avoid a circular import (see header).
|
|
102
|
+
sanitizePrText,
|
|
103
|
+
}) {
|
|
104
|
+
phase(`Publish PR C${finalCycleLabel}`);
|
|
105
|
+
// The branch push is the LAST step of a sprint that has already done all of
|
|
106
|
+
// its work and computed a final verdict. A transient push failure (a racing
|
|
107
|
+
// writer, a momentarily unreachable remote, a credential refresh in flight)
|
|
108
|
+
// used to throw a CommandError from here, which converted a computed PASS
|
|
109
|
+
// into `verdict: 'ABORTED'` and discarded the whole run's conclusion over a
|
|
110
|
+
// network hiccup at the very end. So: failSoft plus the same short, bounded
|
|
111
|
+
// sync backoff every other push round trip uses, and -- if it STILL will not
|
|
112
|
+
// go through -- log loudly and return the COMPUTED verdict with
|
|
113
|
+
// `pushed: false` rather than destroying it.
|
|
114
|
+
//
|
|
115
|
+
// A persistent failure also skips everything downstream of the push (PR
|
|
116
|
+
// creation on a hosted remote; direct target-issue closure + D-push on a
|
|
117
|
+
// non-hosted one). None of that may run against a branch whose commits
|
|
118
|
+
// never reached the remote: a PR cannot be raised for unpushed work, and
|
|
119
|
+
// closing the sprint's target issue would advertise a completion nobody can
|
|
120
|
+
// see. This is the deliberately MINIMAL hardening -- the pluggable-publish
|
|
121
|
+
// restructure is apra-fleet-647.2, which supersedes it.
|
|
122
|
+
// apra-fleet: this push and the origin-remote read just below it run on
|
|
123
|
+
// publishGitMember -- a real dispatch member with an actual git checkout
|
|
124
|
+
// (harvester, falling back to the fallback pool like every other role
|
|
125
|
+
// resolution in ../runner.js) -- NEVER orchestratorMember, which may be a
|
|
126
|
+
// shared/unreservable, git-less member (docs/design-orchestrator-
|
|
127
|
+
// worktree-model-v2.md section 4.3/4.5). raiseVcsPrForMember() below
|
|
128
|
+
// stays on orchestratorMember: it is a credential-file read + REST call,
|
|
129
|
+
// not git, and is explicitly designed to stay there (section 4.6).
|
|
130
|
+
const publishGitMember = getMemberForRole('harvester');
|
|
131
|
+
let pushed = false;
|
|
132
|
+
let lastPushError = '';
|
|
133
|
+
// apra-fleet-9wdh-adjacent (Publish-PR push self-heal): this used to retry
|
|
134
|
+
// the byte-identical `git push` up to 3 times with no fetch/rebase step in
|
|
135
|
+
// between -- fine for a transient/busy-remote failure, but a genuine
|
|
136
|
+
// non-fast-forward rejection ("fetch first") is deterministic, so all 3
|
|
137
|
+
// attempts failed identically and the branch's work was stranded local-
|
|
138
|
+
// only. syncMemberAfter() (../git-sync.mjs) already implements the
|
|
139
|
+
// correct self-heal for exactly this failure shape -- bounded transient
|
|
140
|
+
// retry, then one pull-rebase-then-re-push on a genuine non-fast-forward
|
|
141
|
+
// divergence, never a blind force-push -- and every OTHER post-dispatch
|
|
142
|
+
// G-push in fleet-sprint already routes through it. Publish PR is the one
|
|
143
|
+
// push site that bypassed it. Route through it here too instead of the
|
|
144
|
+
// raw retry loop. NOTE: no `agent` is passed here, so a real content
|
|
145
|
+
// conflict during the rebase (not just a plain non-FF race) throws
|
|
146
|
+
// GitDivergedError directly rather than getting syncMemberAfter's
|
|
147
|
+
// optional Tier 2 conflict-resolution-agent dispatch -- same as the old
|
|
148
|
+
// loop, which had no Tier 2 either; not a regression.
|
|
149
|
+
// (apra-fleet-3swo.4.1) ... and this G-push, unlike the Publish-PR D-push
|
|
150
|
+
// just below, was never inside a sync bracket either -- a pause could land
|
|
151
|
+
// mid-`git push` of the sprint branch. pushGitAfter() is the bracketed
|
|
152
|
+
// syncMemberAfter() entry point; it threads the same command/log/branch/
|
|
153
|
+
// onAuthFailure/provider-resolver state the bare call passed by hand.
|
|
154
|
+
try {
|
|
155
|
+
await gitSync.pushGitAfter(publishGitMember, { remote: 'origin', setUpstream: true });
|
|
156
|
+
pushed = true;
|
|
157
|
+
} catch (pushErr) {
|
|
158
|
+
lastPushError = pushErr.message;
|
|
159
|
+
}
|
|
160
|
+
if (!pushed) {
|
|
161
|
+
log(`[Publish Push Failed] Could not push sprint branch '${validated.branch}' to origin (bounded transient retry, and a rebase-then-re-push if diverged, both exhausted) -- the sprint's work is COMMITTED LOCALLY ONLY and is NOT on the remote. Skipping PR creation and target-issue closure (neither is meaningful for an unpushed branch); the sprint's own computed verdict (${finalVerdictResult.verdict}) is preserved and returned with pushed:false. Push the branch by hand and raise the PR, or re-run finalization once the remote is reachable. Last error: ${lastPushError}`);
|
|
162
|
+
return { pushed: false };
|
|
163
|
+
}
|
|
164
|
+
// The final verdict is surfaced directly in the PR title and body -- a
|
|
165
|
+
// human reviewer must never have to dig through sprint logs to learn
|
|
166
|
+
// whether the run's own review gate passed. A FAIL verdict still publishes
|
|
167
|
+
// the PR (never suppressed), with the verdict stated plainly so the
|
|
168
|
+
// reviewer can weigh it before merging.
|
|
169
|
+
const finalVerdictLabel = finalVerdictResult.verdict === 'PASS' ? 'PASS' : 'FAIL';
|
|
170
|
+
|
|
171
|
+
// Resolve the sprint's own git 'origin' remote and classify it via
|
|
172
|
+
// VCSModule.capabilities() BEFORE ever attempting the VCSModule REST
|
|
173
|
+
// create-pull-request call. A remote whose provider cannot open a PR (a
|
|
174
|
+
// file:// bare mirror, or any other host with no hosting API support)
|
|
175
|
+
// means PR creation can never succeed, and attempting it anyway throws a
|
|
176
|
+
// hard 'gh auth login required'-shaped CommandError that would fail the
|
|
177
|
+
// whole sprint. Resolving the remote is itself failSoft -- an
|
|
178
|
+
// unresolvable remote fails closed to canOpenPullRequest:false, per
|
|
179
|
+
// capabilities()'s own contract -- so a probe hiccup here can never kill
|
|
180
|
+
// the sprint.
|
|
181
|
+
const originUrlRes = await command('git remote get-url origin', {
|
|
182
|
+
member_name: publishGitMember,
|
|
183
|
+
silent: true,
|
|
184
|
+
failSoft: true,
|
|
185
|
+
label: 'Resolve origin remote URL',
|
|
186
|
+
});
|
|
187
|
+
const originUrl = originUrlRes.ok ? originUrlRes.output.trim() : '';
|
|
188
|
+
// (apra-fleet-3swo.4.10) capabilities() is already the provider-agnostic
|
|
189
|
+
// hook -- it dispatches to WHICHEVER registered provider's matchesHost()
|
|
190
|
+
// claims this remote's host (github, azure-devops, bitbucket, ... see
|
|
191
|
+
// vcs-module.mjs's capabilities()), never a hardcoded GitHub check. The
|
|
192
|
+
// log line below used to say "not a gh-hostable GitHub remote" even
|
|
193
|
+
// though the gate itself was already provider-neutral -- that wording
|
|
194
|
+
// was pure residue, not control flow, but a broken/misconfigured
|
|
195
|
+
// Azure DevOps or Bitbucket remote hitting this same branch would have
|
|
196
|
+
// been told (wrongly) that it looked like a GitHub problem. `host` is
|
|
197
|
+
// carried through so the log names what was actually resolved, matching
|
|
198
|
+
// finalizeAbort's identical gate (abort.mjs) which never had the stale
|
|
199
|
+
// GitHub wording in the first place.
|
|
200
|
+
const publishPrCapabilities = vcsCapabilities(originUrl);
|
|
201
|
+
const hostedRemote = publishPrCapabilities.canOpenPullRequest;
|
|
202
|
+
|
|
203
|
+
if (!hostedRemote) {
|
|
204
|
+
log(`Publish PR: origin remote '${originUrl || '(unresolved)'}' cannot open a pull request (host: ${publishPrCapabilities.host || 'unknown'}) -- ` +
|
|
205
|
+
'skipping PR creation entirely (no dependency on any VCS provider\'s auth for this path).');
|
|
206
|
+
// A non-hosted remote can never complete PR creation, so target-issue
|
|
207
|
+
// closure cannot be gated on it -- close the target issue(s) directly,
|
|
208
|
+
// but only when the sprint's own final verdict actually passed. A FAIL
|
|
209
|
+
// verdict must never be masked by closing the issue anyway; it still
|
|
210
|
+
// ends the sprint 'failed' via the return value below, same as the
|
|
211
|
+
// hosted-remote path.
|
|
212
|
+
if (finalVerdictResult.verdict === 'PASS') {
|
|
213
|
+
for (const id of targetIssues) {
|
|
214
|
+
const closeRes = await command(`bd close ${id}`, {
|
|
215
|
+
member_name: orchestratorMember,
|
|
216
|
+
silent: true,
|
|
217
|
+
failSoft: true,
|
|
218
|
+
label: `Close target issue '${id}' directly (non-hosted remote, no PR gate)`,
|
|
219
|
+
});
|
|
220
|
+
if (closeRes.ok) {
|
|
221
|
+
log(`Publish PR: closed target issue '${id}' directly (non-hosted remote, PASS verdict).`);
|
|
222
|
+
} else {
|
|
223
|
+
log(`Publish PR: failed to close target issue '${id}' directly (non-fatal, continuing): ${closeRes.error}`);
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
await gitSync.syncBeadsAfter(orchestratorMember, { pushBeads: true });
|
|
227
|
+
} else {
|
|
228
|
+
log('Publish PR: final verdict is FAIL -- leaving target issue(s) open (not closing on a non-PASS verdict).');
|
|
229
|
+
}
|
|
230
|
+
} else {
|
|
231
|
+
// finalVerdictResult.notes is LLM-authored free text -- sanitize with
|
|
232
|
+
// sanitizePrText() (see the comment above its definition) BEFORE it is
|
|
233
|
+
// ever embedded in the VCSModule-built create-pull-request command()
|
|
234
|
+
// string below. validated.goal/validated.branch need no sanitization
|
|
235
|
+
// here: both are already validated against shell-injection-safe patterns
|
|
236
|
+
// (GOAL_PATTERN/BRANCH_NAME_PATTERN) at arg-validation time.
|
|
237
|
+
const prTitle = `Auto-sprint [${finalVerdictLabel}]: ${validated.branch}`;
|
|
238
|
+
const safeNotes = sanitizePrText(finalVerdictResult.notes);
|
|
239
|
+
const prBody = [
|
|
240
|
+
`Automated apra-fleet-se sprint (goal: ${validated.goal}).`,
|
|
241
|
+
'',
|
|
242
|
+
`Final Verdict: ${finalVerdictLabel}`,
|
|
243
|
+
safeNotes ? `Notes: ${safeNotes}` : null,
|
|
244
|
+
'',
|
|
245
|
+
'Do NOT auto-merge -- see pm skill R12; a human must review and merge this PR.',
|
|
246
|
+
].filter((line) => line !== null).join('\n');
|
|
247
|
+
|
|
248
|
+
// Idempotent PR creation via VCSModule (apra-fleet-tfx.8: the reverted
|
|
249
|
+
// gh-based path is gone). A push+pr credential is minted just-in-time immediately
|
|
250
|
+
// before this one call (never at sprint setup, never for any other
|
|
251
|
+
// phase), VCSModule builds the orchestrator-side curl command, and
|
|
252
|
+
// `orchestratorMember` dispatches it via execute_command -- no gh, no
|
|
253
|
+
// server-side fallback. A re-run of finalization against a branch
|
|
254
|
+
// that ALREADY has an open PR from a prior, otherwise-successful run
|
|
255
|
+
// can be told apart from a genuine failure: the REST create-PR call
|
|
256
|
+
// returns 422 "already exists" in that case -- that specific outcome
|
|
257
|
+
// is swallowed (logged, not thrown) because it means the desired end
|
|
258
|
+
// state (a PR is open for this branch) already holds. Any OTHER
|
|
259
|
+
// failure (auth, network, a real API error, the injectable mock
|
|
260
|
+
// failure below) is NOT swallowed -- it is re-raised as a typed
|
|
261
|
+
// CommandError so it surfaces clearly rather than being silently
|
|
262
|
+
// invisible.
|
|
263
|
+
const fleetApiForPr = (args && typeof args.callTool === 'function') ? new ApraFleet({ callTool: args.callTool }) : null;
|
|
264
|
+
if (!fleetApiForPr) {
|
|
265
|
+
// Graceful degradation (apra-fleet-tfx.8.1): minting the push+pr
|
|
266
|
+
// credential VCSModule needs to raise this PR requires an MCP
|
|
267
|
+
// client. When no callTool is wired (e.g. a mock-sprint scenario
|
|
268
|
+
// that never opted into an MCP client), the sprint branch is
|
|
269
|
+
// already pushed by the withGitSync bracket -- so rather than an
|
|
270
|
+
// unconditional hard-throw that would fail every such pre-existing
|
|
271
|
+
// scenario at the very last step, this degrades to a clear,
|
|
272
|
+
// skipped-PR log and lets the sprint report its real verdict. In
|
|
273
|
+
// production callTool is always wired (bin/cli.mjs), so this branch
|
|
274
|
+
// never runs there; it exists purely so PR creation is not a hard
|
|
275
|
+
// MCP dependency for callers that legitimately have none. A genuine
|
|
276
|
+
// PR-creation FAILURE (auth, network, a real API error) still
|
|
277
|
+
// throws below -- only the callTool-absent case is degraded.
|
|
278
|
+
log(`[Publish PR Skipped] no MCP callTool available to mint a push+pr credential for member '${orchestratorMember}' -- branch '${validated.branch}' is pushed but the PR was not raised.`);
|
|
279
|
+
} else {
|
|
280
|
+
const prResult = await raiseVcsPrForMember({
|
|
281
|
+
fleetApi: fleetApiForPr,
|
|
282
|
+
command,
|
|
283
|
+
member: orchestratorMember,
|
|
284
|
+
base: validated.baseBranch,
|
|
285
|
+
head: validated.branch,
|
|
286
|
+
title: prTitle,
|
|
287
|
+
body: prBody,
|
|
288
|
+
log,
|
|
289
|
+
logPrefix: '[Publish PR]',
|
|
290
|
+
// Already resolved above via publishGitMember (a real
|
|
291
|
+
// git-capable member) for the PR-capability gate -- skip
|
|
292
|
+
// re-deriving it a second time by shelling out to
|
|
293
|
+
// orchestratorMember, which may have no git checkout of its
|
|
294
|
+
// own to read a remote from (docs/design-orchestrator-
|
|
295
|
+
// worktree-model-v2.md section 4.6: this call stays workspace-
|
|
296
|
+
// independent by design, credential-file-read + REST only).
|
|
297
|
+
remoteUrlOverride: originUrl,
|
|
298
|
+
});
|
|
299
|
+
if (!prResult.ok) {
|
|
300
|
+
if (prResult.authFailure) {
|
|
301
|
+
// apra-fleet-5co8.15: an auth failure raiseVcsPrForMember
|
|
302
|
+
// could not clear -- including one that never got past
|
|
303
|
+
// credential provisioning, e.g. a missing Azure DevOps PAT
|
|
304
|
+
// credential-store entry -- degrades the publish phase
|
|
305
|
+
// instead of aborting the sprint, same policy
|
|
306
|
+
// finalizeAbort() already applies to its own authFailure
|
|
307
|
+
// outcome (see ../abort.mjs). The branch is already pushed; only
|
|
308
|
+
// the PR itself is skipped.
|
|
309
|
+
log(`[Publish PR Skipped] could not raise a PR for branch '${validated.branch}' -> '${validated.baseBranch}' (branch is pushed) due to an unrecoverable VCS auth failure: ${prResult.error}`);
|
|
310
|
+
} else {
|
|
311
|
+
throw new CommandError(
|
|
312
|
+
`[Publish PR Failed] VCSModule create-pull-request failed for branch '${validated.branch}' -> '${validated.baseBranch}': ${prResult.error}`,
|
|
313
|
+
{ details: { branch: validated.branch, baseBranch: validated.baseBranch, error: prResult.error } }
|
|
314
|
+
);
|
|
315
|
+
}
|
|
316
|
+
} else if (prResult.alreadyExists) {
|
|
317
|
+
log(`Publish PR: a PR for branch '${validated.branch}' already exists -- treating as idempotent success.`);
|
|
318
|
+
}
|
|
319
|
+
}
|
|
320
|
+
}
|
|
321
|
+
|
|
322
|
+
return { pushed: true };
|
|
323
|
+
}
|
|
@@ -0,0 +1,232 @@
|
|
|
1
|
+
// =============================================================================
|
|
2
|
+
// PHASE MODULE: Re-Review (apra-fleet-3swo.6.8).
|
|
3
|
+
//
|
|
4
|
+
// The EIGHTH of runSprintCycle's twelve phase() boundaries -- the ONE fresh
|
|
5
|
+
// review Cycle Evaluation dispatches when the goal-priority bead count already
|
|
6
|
+
// reads 0 but no review ran THIS cycle (the Develop/Review loop was skipped
|
|
7
|
+
// because there were no ready beads). Without it the exit decision would rest
|
|
8
|
+
// on a verdict from an earlier cycle, or the loop would spin with no way to
|
|
9
|
+
// confirm completion. Like ./review.mjs it then has the ORCHESTRATOR -- never
|
|
10
|
+
// the LLM -- apply every structured transition the verdict asks for (guarded
|
|
11
|
+
// reopens, validated newTask creation) before D-pushing the beads it just
|
|
12
|
+
// mutated. Moved verbatim out of runner.js: every prompt, log line, dispatch
|
|
13
|
+
// option, validation branch and sync call is byte-identical to the inline
|
|
14
|
+
// version, so the golden transcript is unchanged. Move-only, no behaviour
|
|
15
|
+
// change.
|
|
16
|
+
//
|
|
17
|
+
// WHERE THIS PHASE STARTS AND STOPS. It is the body of Cycle Evaluation's
|
|
18
|
+
// `if (openAtGoal.length === 0 && !reviewedThisCycle)` branch, and nothing
|
|
19
|
+
// else -- from its own phase() call to the post-mutation
|
|
20
|
+
// `gitSync.syncBeadsAfter(...)` that closes it. The `if` itself stays in
|
|
21
|
+
// runner.js because it is built out of Cycle Evaluation's own freshly-read
|
|
22
|
+
// counts, exactly as ./deploy.mjs's `if (hasDeploy)` probe and ./replan.mjs's
|
|
23
|
+
// `if (eligibleReplan.length > 0)` filter stayed behind; the
|
|
24
|
+
// stillOpenVerifyIds exit gate that follows it belongs to Cycle Evaluation,
|
|
25
|
+
// not to this phase.
|
|
26
|
+
//
|
|
27
|
+
// THE GUARDED VERDICT PATH IS NOT OPTIONAL. apra-fleet-3swo.4.7 brought this
|
|
28
|
+
// site's reopenIds under the SHARED applyGuardedReopens() path from
|
|
29
|
+
// ../beads-transitions.mjs -- it was previously the only one of the three
|
|
30
|
+
// verdict sites applying reopens with NO goal-scope guard, so a below-goal
|
|
31
|
+
// DEFERRED bead named here was pulled back into a sprint that no longer
|
|
32
|
+
// targeted it. That import, and the Re-review reopenIds site it wraps, moved
|
|
33
|
+
// here INTACT: this module must never grow a private reopen loop or a private
|
|
34
|
+
// allowlist of its own (pinned by
|
|
35
|
+
// test/beads-transitions-extraction.test.mjs, which now scans runner.js,
|
|
36
|
+
// phases/review.mjs and this file as separate sources and asserts which one
|
|
37
|
+
// owns which of the three sites).
|
|
38
|
+
//
|
|
39
|
+
// EXPLICIT STATE, NOT A CLOSURE -- AND WHY THREE VALUES COME BACK. Same shape
|
|
40
|
+
// as ./review.mjs, whose newTasks half this phase mirrors line for line.
|
|
41
|
+
// `rejectedNewTasks` is an array this phase PUSHES to, so passing the array
|
|
42
|
+
// itself is exactly equivalent to the closure it replaces. The three genuinely
|
|
43
|
+
// REASSIGNED values -- `lastReviewVerdict` and `reviewedThisCycle` (which the
|
|
44
|
+
// exit decision immediately below this phase's call site reads) and
|
|
45
|
+
// `pendingRejectedNewTasks` (which trackRejectedNewTaskForResurfacing()/
|
|
46
|
+
// clearResubmittedNewTask() return a NEW list from every time) -- are passed
|
|
47
|
+
// in and returned instead.
|
|
48
|
+
//
|
|
49
|
+
// WHY SOME HELPERS ARE INJECTED RATHER THAN IMPORTED. dispatchReview,
|
|
50
|
+
// bdListScoped, goalMax, recordReopen, childIdAllocator and sprintMutexId are
|
|
51
|
+
// runSprintCycle-scoped locals, so there is nothing to import. computeChildFloor,
|
|
52
|
+
// createChildBeadWithAllocatedId, trackRejectedNewTaskForResurfacing and
|
|
53
|
+
// clearResubmittedNewTask are exported BY runner.js; importing them here would
|
|
54
|
+
// make phases/re-review.mjs <-> runner.js a circular pair for the sake of four
|
|
55
|
+
// helpers, so they come through the state argument instead -- the same rule
|
|
56
|
+
// ./review.mjs's header states. The dependencies that live in real sibling
|
|
57
|
+
// modules (applyGuardedReopens from ../beads-transitions.mjs, validateNewTask/
|
|
58
|
+
// appendRejectedFindingToParentNotes/persistNewTaskBestEffort from ../abort.mjs)
|
|
59
|
+
// are imported directly.
|
|
60
|
+
//
|
|
61
|
+
// GUARD COVERAGE: registered as 'phases/re-review.mjs' in
|
|
62
|
+
// ../guarded-modules.mjs. It took NO command() call site out of runner.js --
|
|
63
|
+
// its reopen and newTask writes reach bd through injected helpers that issue
|
|
64
|
+
// their own command() calls in the modules that already own them, exactly as
|
|
65
|
+
// ./review.mjs's do -- and NO dispatchRole() site either: the reviewer ladder
|
|
66
|
+
// runs through runner.js's shared dispatchReview() helper, which the per-round
|
|
67
|
+
// Review and Final Review phases call too. Its only repo-side effect is the
|
|
68
|
+
// shared gitSync bracket at the end. Both zero baselines are pinned rather
|
|
69
|
+
// than assumed, so a future edit that reaches for a raw command() here turns
|
|
70
|
+
// red instead of landing on an unguarded site.
|
|
71
|
+
// =============================================================================
|
|
72
|
+
|
|
73
|
+
import { applyGuardedReopens } from '../beads-transitions.mjs';
|
|
74
|
+
import {
|
|
75
|
+
validateNewTask, appendRejectedFindingToParentNotes, persistNewTaskBestEffort,
|
|
76
|
+
} from '../abort.mjs';
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* Runs the Re-Review phase: one fresh review of the CURRENT state, plus the
|
|
80
|
+
* orchestrator-applied transitions its verdict asks for.
|
|
81
|
+
*
|
|
82
|
+
* @param {object} state Explicit phase state; see this file's header.
|
|
83
|
+
* @returns {Promise<{
|
|
84
|
+
* lastReviewVerdict: string|undefined,
|
|
85
|
+
* reviewedThisCycle: boolean,
|
|
86
|
+
* pendingRejectedNewTasks: object[],
|
|
87
|
+
* }>} The three REASSIGNED values described in the header. Every other output
|
|
88
|
+
* of this phase is an in-place mutation of an array the caller still holds.
|
|
89
|
+
*/
|
|
90
|
+
export async function runReReviewPhase({
|
|
91
|
+
// Presentation + dispatch seams.
|
|
92
|
+
phase,
|
|
93
|
+
log,
|
|
94
|
+
command,
|
|
95
|
+
// Sprint identity/config.
|
|
96
|
+
cycle,
|
|
97
|
+
validated,
|
|
98
|
+
targetIssues,
|
|
99
|
+
orchestratorMember,
|
|
100
|
+
// The git/beads sync bracket this phase's post-mutation D-push goes
|
|
101
|
+
// through.
|
|
102
|
+
gitSync,
|
|
103
|
+
// Mutated in place; never reassigned by this phase (see header).
|
|
104
|
+
rejectedNewTasks,
|
|
105
|
+
// Reassigned, so passed in and returned (see header).
|
|
106
|
+
lastReviewVerdict,
|
|
107
|
+
reviewedThisCycle,
|
|
108
|
+
pendingRejectedNewTasks,
|
|
109
|
+
// runSprintCycle-scoped locals and runner.js-exported helpers, injected
|
|
110
|
+
// rather than imported (see header).
|
|
111
|
+
dispatchReview,
|
|
112
|
+
bdListScoped,
|
|
113
|
+
goalMax,
|
|
114
|
+
recordReopen,
|
|
115
|
+
childIdAllocator,
|
|
116
|
+
sprintMutexId,
|
|
117
|
+
computeChildFloor,
|
|
118
|
+
createChildBeadWithAllocatedId,
|
|
119
|
+
trackRejectedNewTaskForResurfacing,
|
|
120
|
+
clearResubmittedNewTask,
|
|
121
|
+
}) {
|
|
122
|
+
phase(`Re-Review C${cycle}`);
|
|
123
|
+
log(
|
|
124
|
+
`Cycle ${cycle}: 0 open goal-priority bead(s) but no review ran THIS cycle (Develop/Review ` +
|
|
125
|
+
`loop was skipped) -- dispatching a fresh re-review of the current state before deciding ` +
|
|
126
|
+
`whether to exit, rather than trusting a verdict from an earlier cycle.`
|
|
127
|
+
);
|
|
128
|
+
const reReviewScope = await bdListScoped('--json');
|
|
129
|
+
// apra-fleet-jfo.3: this call passed beadIds: [] unconditionally,
|
|
130
|
+
// which buildReviewerPrompt renders as "Review the work just done
|
|
131
|
+
// for the following bead id(s): ." -- no ids to review. The
|
|
132
|
+
// reviewer correctly treats that as missing required input and
|
|
133
|
+
// refuses (a CHANGES_NEEDED-shaped response with empty
|
|
134
|
+
// reopenIds/newTasks), which after one retry throws
|
|
135
|
+
// ReviewerContractViolationError and aborts the WHOLE sprint --
|
|
136
|
+
// hit live 2026-08-02 on apra-fleet-l7n-style sprints (Deploy
|
|
137
|
+
// fails on cycle 1 -> IntegTest skipped -> openAtGoal reads 0 ->
|
|
138
|
+
// this branch -> crash, before the sprint ever gets a real
|
|
139
|
+
// chance). The sprint's own root issue id(s) are always a valid,
|
|
140
|
+
// in-scope target for "review the current state" -- pass them as
|
|
141
|
+
// beadIds so the reviewer has something concrete to ground its
|
|
142
|
+
// verdict in; acceptanceCriteriaJson still carries the full scope
|
|
143
|
+
// for context.
|
|
144
|
+
const reReviewVerdict = await dispatchReview({ beadIds: targetIssues, acceptanceCriteriaJson: JSON.stringify(reReviewScope) });
|
|
145
|
+
lastReviewVerdict = reReviewVerdict.verdict;
|
|
146
|
+
reviewedThisCycle = true;
|
|
147
|
+
|
|
148
|
+
// Same orchestrator-applies-the-transition contract as the
|
|
149
|
+
// regular Develop/Review dispatch above: a re-review that
|
|
150
|
+
// reopens beads or proposes follow-up work must have those
|
|
151
|
+
// effects actually applied, not silently discarded just because
|
|
152
|
+
// this dispatch happened outside the normal Develop loop.
|
|
153
|
+
//
|
|
154
|
+
// apra-fleet-3swo.4.7: this site used to apply reopenIds with NO
|
|
155
|
+
// goal-scope guard -- the only one of the three verdict sites that
|
|
156
|
+
// did. It now goes through the same applyGuardedReopens() path as
|
|
157
|
+
// the per-round reviewer and Final Review, so a below-goal
|
|
158
|
+
// DEFERRED bead named here is skipped with the identical
|
|
159
|
+
// "deferred scope, not reopened" outcome instead of being pulled
|
|
160
|
+
// back into a sprint that no longer targets it.
|
|
161
|
+
await applyGuardedReopens({
|
|
162
|
+
entries: reReviewVerdict.reopenIds,
|
|
163
|
+
bdListScoped, goalMax, goal: validated.goal, log, command,
|
|
164
|
+
member: orchestratorMember,
|
|
165
|
+
logPrefix: 'Re-review reopenIds',
|
|
166
|
+
buildReopenCommand: ({ id }) => ({
|
|
167
|
+
cmd: `bd update ${id} --status=open`,
|
|
168
|
+
label: `Reopen ${id} per re-review verdict`,
|
|
169
|
+
}),
|
|
170
|
+
// Track per-bead reopen counts for reopen-thrash detection.
|
|
171
|
+
onReopened: ({ id }) => recordReopen(id),
|
|
172
|
+
});
|
|
173
|
+
for (const newTask of reReviewVerdict.newTasks) {
|
|
174
|
+
const validation = validateNewTask(newTask);
|
|
175
|
+
if (!validation.ok) {
|
|
176
|
+
log(`Re-review newTasks: REJECTED (not sent to bd create) -- ${validation.reason}`);
|
|
177
|
+
rejectedNewTasks.push({ cycle, reason: validation.reason, raw: newTask });
|
|
178
|
+
// Track it for resurfacing into the NEXT planning-phase
|
|
179
|
+
// dispatch too -- see trackRejectedNewTaskForResurfacing()'s
|
|
180
|
+
// doc comment.
|
|
181
|
+
pendingRejectedNewTasks = trackRejectedNewTaskForResurfacing(pendingRejectedNewTasks, {
|
|
182
|
+
title: newTask && newTask.title, description: newTask && newTask.description,
|
|
183
|
+
reason: validation.reason, cycle,
|
|
184
|
+
});
|
|
185
|
+
// Never let a rejected finding vanish -- persist it verbatim
|
|
186
|
+
// to the parent bead's notes as a fallback (non-fatal;
|
|
187
|
+
// degrades to the run log).
|
|
188
|
+
try {
|
|
189
|
+
await appendRejectedFindingToParentNotes({
|
|
190
|
+
command, member: orchestratorMember, parentId: targetIssues[0],
|
|
191
|
+
newTask, reason: validation.reason, cycle, log,
|
|
192
|
+
});
|
|
193
|
+
} catch (noteErr) {
|
|
194
|
+
log(`[fleet-sprint] rejected-finding notes fallback FAILED (non-fatal): ${noteErr.message}; finding preserved VERBATIM in this run log: ${JSON.stringify(newTask)}`);
|
|
195
|
+
}
|
|
196
|
+
continue;
|
|
197
|
+
}
|
|
198
|
+
const { title, description, priority } = validation;
|
|
199
|
+
// A bead can only have one parent -- when multiple sprint-root
|
|
200
|
+
// target issues are given, file follow-up work under the first
|
|
201
|
+
// one. `--parent` never accepts a comma-joined list; passing one
|
|
202
|
+
// silently creates an unparented/misparented bead.
|
|
203
|
+
//
|
|
204
|
+
// Same allocator-minted id path as the Develop/Review newTasks
|
|
205
|
+
// site above -- concurrent sprints must never mint the same child
|
|
206
|
+
// id under a shared parent.
|
|
207
|
+
const persisted = await persistNewTaskBestEffort({
|
|
208
|
+
command, member: orchestratorMember, parentId: targetIssues[0],
|
|
209
|
+
newTask, cycle, log, stage: 're-review',
|
|
210
|
+
createFn: async () => {
|
|
211
|
+
const floor = await computeChildFloor({ command, member: orchestratorMember, parentId: targetIssues[0], log });
|
|
212
|
+
await createChildBeadWithAllocatedId({
|
|
213
|
+
command, allocator: childIdAllocator, member: orchestratorMember,
|
|
214
|
+
title, description, priority, parentId: targetIssues[0],
|
|
215
|
+
sprintId: sprintMutexId, floor, log,
|
|
216
|
+
label: `Create follow-up task from re-review newTasks: ${title}`,
|
|
217
|
+
});
|
|
218
|
+
},
|
|
219
|
+
});
|
|
220
|
+
// Same resurface-list bookkeeping (title+description) as the
|
|
221
|
+
// Develop/Review newTasks site above.
|
|
222
|
+
if (persisted) {
|
|
223
|
+
pendingRejectedNewTasks = clearResubmittedNewTask(pendingRejectedNewTasks, { title, description });
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
// D-push the orchestrator's applied re-review reopens/newTask
|
|
228
|
+
// creates, same as the Develop/Review transition site above.
|
|
229
|
+
await gitSync.syncBeadsAfter(orchestratorMember, { pushBeads: true });
|
|
230
|
+
|
|
231
|
+
return { lastReviewVerdict, reviewedThisCycle, pendingRejectedNewTasks };
|
|
232
|
+
}
|