Repository navigation
fix(#1234): sequant run worktrees record their exact base ref; the exec guard and pre-PR rebase read it - #1242
Merged
Merged
Conversation
…per's checkout phase-executor.model-ladder/model-roles/phase-agent tests called executePhaseWithRetry with no worktreePath, so the exec change guard ran against process.cwd() and the #1032 rescue auto-committed a dirty checkout as a wip checkpoint. They now pass a throwaway repo (HEAD one commit ahead of origin/main) and assert the dispatched cwd. Entire-Checkpoint: 8c34f86c09f8
QA follow-up: a git error after mkdtempSync leaked the dir, and afterAll's cleanup on an undefined repo masked the real error. Entire-Checkpoint: 1e9886dc23d5
…ec guard and pre-PR rebase read it ensureWorktree now writes branch.<b>.sequantBaseRef (the ref it cut from); resolveBaseRef uses it verbatim when it resolves, keeping legacy sequantBase and the origin/main fallback. Before, every sequant run worktree compared against origin/main, so a --base ahead of main disabled the no-change/uncommitted guard. rebaseBeforePR rebases onto a recorded local base that matches the run's base without fetching origin/<base>. Entire-Checkpoint: adf7c75e638f
…/1234-sequant-base-ref
…o a recorded local base Real-git child-process tests for the three --base shapes and both rebaseBeforePR branches (matching local base, chain final link). The branch lookup moves into readRecordedBaseRefAtHead (execFileSync) so rebaseBeforePR's spawnSync sequence is unchanged; phase-executor.test.ts's ordered execFileSync mock answers the new key as unset. Entire-Checkpoint: 8eb42a637185
…/<base> doesn't exist QA follow-up: keying on the recorded ref skipped the fetch for a pushed --base (rebasing onto a stale local copy, dropping a teammate's commit) and missed a chain final link with a local run base. The rule is now decided by the remote: fetch as before; on failure, if origin/<base> doesn't resolve but refs/heads/<base> does, rebase onto the local branch without the warning. Entire-Checkpoint: e573183c7fab
…-ref # Conflicts: # src/lib/workflow/worktree-manager.test.ts
This was referenced Oct 16, 2026
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.
Closes #1234
What
resolveBaseRefreadbranch.<b>.sequantBase, which only the legacynew-feature.shwrites. So for everysequant runworktree, the exec guard compared againstorigin/main. When--basewas ahead of main, the base's own commits counted as "commits ahead", and thenoneanduncommittedbranches (#534 / #879 / #1032) never fired. That's why 3 of 18 stranded exec phases in the #1138 bench "passed" with their work uncommitted.phase-executor.ts:recordWorktreeBaseRefwritesbranch.<b>.sequantBaseRef.readRecordedBaseRefreads it back, but only a single-line value that resolves to a commit (git rev-parse --verify).resolveBaseReftries that key first, verbatim. It then falls back to the legacysequantBasewithorigin/prepended, which is unchanged, so a bare name is never read as a stale local branch. Last comes theorigin/mainfallback, also unchanged.worktree-manager.ts:computeWorktreeBaseRefis extracted fromensureWorktree, with identical logic.rebaseBeforePRfetchesorigin/<base>as before. If the fetch fails andorigin/<base>doesn't resolve but a local<base>branch does, it rebases onto the local branch without theCould not fetch/invalid upstreamwarnings. The decision depends on the remote, not on the recorded ref, so a pushed--baseis always fetched fresh, and a chain's final link (which recorded its predecessor) behaves the same.hasCommitsAheadOfBasegoes throughresolveBaseRef, so it picks up the recorded ref too.AC-1/AC-2 were revised in the issue body before implementation. The original "local branch unchanged when one exists" would have compared against a stale local
main.Acceptance criteria
worktree-manager.test.ts > #1234 ensureWorktree records sequantBaseRefuses real git in a child process (the feat(worktree): configurable worktree root #1199 pattern). No--baserecordsorigin/main,--base origin/remote-baserecordsorigin/remote-base, and a local--base local-baserecordslocal-base.phase-executor.integration.test.ts > exec guard with a local base ahead of main (integration, #1234):origin/main;sequantBase=mainstill resolves toorigin/main.none.worktree-manager.test.ts:local-base;--base remote-baseis still fetched and picks up a teammate's newer commit;mainstill targetsorigin/main.Verification
--base(QA reproduced a teammate's commit going missing) and still warned for a chain run with a local base. Both are fixed and covered by the two new AC-4 tests.readRecordedBaseRefAtHeadwas removed; the rebase path no longer reads the recorded ref.resolveBaseRef,rebaseBeforePR,sequantBase,Could not fetch,hasCommitsAheadOfBase,classifyExecChanges,hasExecChanges,ensureWorktree, plus every workflow, command and root test mockingchild_process), one file at a time. All pass.phase-executor.test.tsqueuesexecFileSyncresults in call order. Its mock factory now answers*.sequantBaseReflookups as unset, so the existing queued sequences stay valid, and the recorded case is covered with real git in the integration file.rebaseBeforePR's ref checks useexecFileSyncand run only when the fetch fails, sorun.test.ts's orderedspawnSyncqueue is unchanged.recordWorktreeBaseRefcall;1234 records origin/main when no --base is givenfailed (plus the other two record tests and the local-base rebase test); restored.resolveBaseRefignores the recorded exact ref;1234 resolveBaseRef uses a recorded sequantBaseRef verbatimfailed; restored.1234 uncommitted-only exec on a recorded local base fails and is WIP-committedfailed; restored.1234 pre-PR rebase onto a local-only base prints no fetch failurefailed (plus the chain-final-link local case); restored.1234 pre-PR rebase still fetches a pushed --base and picks up a teammate's commitfailed; restored.Overlap note
#1240 (#1223, in flight in another session) also edits
worktree-manager.ts, in a different area: PR title/body building. Whichever lands second merges main.🤖 Generated with Claude Code