Add safe push workflow for PR review workers#288
Conversation
Root cause of wrong-remote pushes: - Workers used 'git fetch origin pull/<N>/head:pr-<N>' which creates a branch with NO tracking info. Subsequent 'git push' defaulted to origin, silently pushing to PureWeen/PolyPilot even for fork PRs. - Workers also used 'git rebase + --force-with-lease' which is unnecessary when using merge. Fix: - .squad/routing.md: updated Fix Process to use 'gh pr checkout <N>' (sets correct tracking) and 'git merge origin/main' (no force push needed) - .squad/decisions.md: explicit rules against force push and manual fetch - push-to-pr.sh: script that derives correct remote from gh pr view metadata and pushes without --force, with pre-push safety checks Verified: 'gh pr checkout' correctly sets tracking to fork remote for PR #280 (vitek-karas) and to origin for same-repo PRs like #247 (PureWeen). Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
The push safety rules in decisions.md are sufficient. Squad files are now repo-agnostic so they can be reused across any repository. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…ee recovery, add push script - Move pre-push verification before git push in routing.md step 6 to match decisions.md rule 4 (was contradictory: push-first vs verify-first) - Replace undefined <owner-remote> placeholder with concrete discovery commands using gh pr view + git remote -v; document that gh pr checkout registers the fork owner's login as the remote name - Add worktree conflict recovery note to step 1 (gh pr checkout -b fallback) - Add .squad/push-to-pr.sh: safe push script that validates branch match, finds the correct remote, pushes, and verifies via SHA comparison Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Fixes applied (review findings)Four issues from the multi-model review have been addressed in commit d5338f7: Fix 1 — Contradictory push verification order (5/5 models) Fix 2 — Undefined <owner-remote>\ in fallback path (5/5 models) Fix 3 — Worktree conflict recovery (4/5 models) Fix 4 — Missing \push-to-pr.sh\ (4/5 models) |
Problem
PR review workers were pushing to the wrong remote (e.g., pushing to
origin/PureWeenwhen the PR comes from a fork likevitek-karas), and using--force-with-leaseafter rebasing unnecessarily.Root Cause (verified by testing)
Workers were using manual checkout:
This creates a branch with no tracking info (
Remote: NONE,Merge: NONE). When the worker then runsgit pushorgit push origin, git defaults toorigin(PureWeen/PolyPilot) — even if the PR came from a fork.In contrast,
gh pr checkout <N>correctly sets up tracking:Remote: origin,Merge: refs/heads/copilot/build-notification-and-timers✅Remote: vitek-karas,Merge: refs/heads/Add-a-way-to-specify-polypilot-clone-root-7299✅The second problem was
git rebase origin/main+--force-with-lease, which requires force pushing. Usinggit merge origin/mainadds a merge commit instead — no force push needed.Changes
push-to-pr.shA shell script that:
gh pr viewto find the correct owner and branch--force.squad/routing.mdUpdated Fix Process replacing rebase+force-push with merge+safe-push, with clear explanation of why
gh pr checkoutis required..squad/decisions.mdExplicit shared rules:
gh pr checkout(not manual fetch)push-to-pr.shfor all PR pushes.squad/team.mdTeam definition file (required for squad directory to be recognized by PolyPilot's squad discovery).