Repository navigation
feat(#1380): ensureWorktree "recreating fresh" rebuilds a PR branch from base and drops its commits; qa re-run reviews the wrong tree - #1403
Merged
admarble merged 6 commits intoOct 10, 2026
Conversation
…pping its commits Entire-Checkpoint: cf3f53d5ba35
Entire-Checkpoint: 618f17e1b6ae
…rktree-recreating-fresh-rebuilds-a-pr-bran # Conflicts: # docs/adr/README.md
Entire-Checkpoint: bcad89a4c34d
This was referenced Oct 10, 2026
…main) Entire-Checkpoint: 322216e661ca
…rktree-recreating-fresh-rebuilds-a-pr-bran
admarble
deleted the
feature/1380-ensureworktree-recreating-fresh-rebuilds-a-pr-bran
branch
October 10, 2026 15:24
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
When a PR's worktree was more than 5 commits behind base and had nothing uncommitted or unpushed,
ensureWorktreedeleted the local branch and cut a new one from base, ignoringorigin/<branch>. A qa re-run then reviewed base without the PR's commits.Now:
resolveRecreateStartReffetches the branch and picksorigin/<branch>when the remote has it, otherwise the run's base ref.merge-base --is-ancestor). If it doesn't (an offline fetch, or a local-only branch with commits of its own), sequant prints a warning in the existing "commits behind" style and keeps the worktree.git worktree add -B <branch> <path> origin/<branch>, so the branch keeps its commits and its upstream tracking.sequantBaseRef) stays the run's base, notorigin/<branch>.ADR-0013 records the design choice. It was numbered 0011 in the exec, then renumbered: 0011 is taken by open PR #1370, and 0012 merged in #1392.
Fixes #1380
Acceptance criteria
origin/<branch>with all its commits.worktree-manager.test.ts›1380 AC-1, which the runner extended to assert thatbranch.<b>.remote/mergestill track the PR branch.origin/<branch>, recreate cuts from the base as before, for a local-only branch whose HEAD is on base (1380 AC-2 recreates a local-only branch…). A local-only branch with commits of its own is kept, as onmain(1380 AC-2 keeps a local-only branch…, added by the runner). The spec and QA said ensureWorktree "recreating fresh" rebuilds a PR branch from base and drops its commits; qa re-run reviews the wrong tree #1380's guard changed this case. It doesn't: with the guard disabled the test still passes, and it passes againstmain'sworktree-manager.ts, because the existinghasUnpushedCommitscheck ("Keeping existing worktree with WIP commits") already keeps it. AC-2's text was clarified on ensureWorktree "recreating fresh" rebuilds a PR branch from base and drops its commits; qa re-run reviews the wrong tree #1380 to match.1380 AC-3).main@afc37bd0. The recreate uses the run's resolved base throughcomputeWorktreeBaseRef(baseBranch, …), the same valueResolvedRun.baseBranchfeeds, and records it (1380 AC-4).Mutation-verified: AC-1 — recreate path changed to
worktree add -B <branch> <path> <baseRef>(base instead oforigin/<branch>);src/lib/workflow/worktree-manager.test.ts > #1380 ensureWorktree recreate keeps the branch's commits > 1380 AC-1 recreates a pushed branch from origin/<branch>, keeping its commitsfailed alone (1 of 4); restored.Mutation-verified: AC-3 — containment guard disabled (
if (false && contained.status !== 0));src/lib/workflow/worktree-manager.test.ts > #1380 ensureWorktree recreate keeps the branch's commits > 1380 AC-3 keeps the worktree when the start ref lacks the branch's commitsfailed alone; restored.Mutation-verified: AC-4 —
recordWorktreeBaseRefgivenrecreateFrom ?? baseRef;src/lib/workflow/worktree-manager.test.ts > #1380 ensureWorktree recreate keeps the branch's commits > 1380 AC-4 records the run's base, not origin/<branch>, after a recreatefailed alone; restored.Follow-up ledger
origin/<branch>exists but there's no local branch, plus the QAdocumentfinding that a recreated worktree gets recreated again on every run: filed as fix(worktree): first creation on a fresh machine ignores origin/<branch>, and a recreated PR worktree is recreated again on every run (#1380 follow-up) #1405.<base>but counted againstorigin/<base>(the bug(exec): sequant run worktrees never record sequantBase, so the zero-diff/uncommitted guard compares against origin/main and a --base ahead of main disables it #1234/fix(run): --base creates the worktree from the branch but opens the PR against the repo default branch #1386 class): filed as fix(worktree): a non-default bare --base is cut from local <base> but counted against origin/<base> (#1380 follow-up, #1234/#1386 class) #1406.6cac0deb).Runner verification (graph-2026-10-freeze, wave 2)
main(797c1076) and resolved the ADR index conflict.worktree-manager.test.tsandbatch-executor.test.ts: 211 passed.tsc --noEmitis clean.git diff --name-only origin/main...HEAD | grep -E '^(plugin|\.claude/skills|templates/skills)/'is empty.🤖 Generated with Claude Code