Repository navigation
Conversation
… one already at it First creation with no local branch now resolves its start ref through resolveBranchStartRef (the #1380 resolver, generalized), so a pushed PR branch keeps its commits and upstream. A remote branch already merged into the base (merge commit or squash) or deleted from the remote is not resurrected. A stale, clean worktree whose HEAD equals origin/<branch> is reused rather than recreated on every run. Local git only; no gh call on the reuse path. ADR-0014. Entire-Checkpoint: b604f8946770
QA: resolveBranchStartRef matched git's English 'couldn't find remote ref'; under a German locale git prints 'Konnte Remote-Referenz … nicht finden', so a stale tracking ref for a deleted unmerged branch was reused. Run that fetch with LC_ALL=C. Entire-Checkpoint: 301cb7bc9394
admarble
added a commit
that referenced
this pull request
Oct 16, 2026
…tree-first-creation-on-a-fresh-machine-ign
admarble
deleted the
feature/1405-fix-worktree-first-creation-on-a-fresh-machine-ign
branch
October 16, 2026 13:31
admarble
added a commit
that referenced
this pull request
Oct 16, 2026
…rifting (#1467) * fix(#1409): scope content drift and its remedy to the recorded install scope A skills-only install (init --manifest-only + sync --only skills) counted every hook, agent, scripts/dev file and settings.json it never installed as drift, and its remedy (sync --force) overwrote the constitution. The manifest now records the install scope in an optional groups field owned by src/lib/manifest.ts; drift and the remedy (sync --only skills --force) are scoped to it. A manifest without the field is a full install. ADR-0014. Entire-Checkpoint: afbcf3d7b9ec * docs(#1409): renumber the install-scope ADR to 0015 #1405's PR (#1468) also adds an ADR-0014; it is on the graph's critical path and keeps the number. Entire-Checkpoint: 49f1b32b29bc
This was referenced Oct 17, 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.
Summary
With no local
<branch>,ensureWorktreeused to cut a new branch from the base even whenorigin/<branch>already held the PR's commits. So the first run on a fresh machine, a fresh clone, or a cloud session started over. Also, a worktree recreated fromorigin/<branch>(#1380) was still behind the base, so every later run deleted it and recreated it.resolveBranchStartRefis the one function both paths use, first creation and stale recreate. It returnsorigin/<branch>when the remote has the branch and the branch isn't merged into the base, and the base otherwise. A merge commit counts as merged (the branch is an ancestor of the base), and so does a squash (merging the branch leaves the base's tree). The function fetches the branch first, and a remote that reports it deleted makes a leftover tracking ref count as absent. It uses localgitonly, with noghcall (test: state.test.ts idempotency and state-utils discoverUntrackedWorktrees cases fail under full-suite load, pass alone #1322's lesson, graph OQ-2).origin/<branch>with upstream tracking.origin/<branch>is reused. The pre-PR rebase (bug(qa): the qa phase rebases an already-pushed branch onto main, forcing a force-push to land it #1069) brings in the base.docs/adr/0014-start-worktree-from-unmerged-remote-branch.md), plus a CHANGELOGFixedentry.Runner fix after QA (AC_MET_BUT_NOT_A_PLUS)
QA found that the deleted-remote-branch check matched git's English
couldn't find remote ref. Reproduced on macOS: underLC_ALL=de_DE.UTF-8, git printsSchwerwiegend: Konnte Remote-Referenz … nicht finden., so a stale tracking ref for a branch deleted unmerged would be used again. 7c7b7d6 runs that fetch withLC_ALL=Cand adds a German-locale test. The test is vacuous on a git with no translations installed, but it is real on this machine (see the mutation below).AC mapping
1405 AC-1 first creation on a fresh machine starts from origin/<branch>: HEAD contains all oforigin/<branch>, and the upstream andsequantBaseRefare set. Mutation below1405 AC-2 a worktree recreated from origin/<branch> is reused by the next call: the second call reuses the same path and HEAD while still more than 5 commits behindmainorigin/main.the reuse path makes no gh callputs aghstub on PATH and asserts it is never invokedRunner check:
npx vitest run src/lib/workflow/worktree-manager.test.ts -t "1405|1380"gave 12/12 passed. Full-suite evidence is CI's.Mutation verification
recreateFrom = startRefso the branch is cut from the base again; only1405 AC-1 first creation on a fresh machine starts from origin/<branch>failed; restored.LC_ALL: "C"from the fetch's env; only1405 AC-3 a deleted remote branch is detected under a non-English localefailed; restored.Runner note: on the stale-recreate path, the
recreateFrom = startRefassignment (worktree-manager.ts:1056) is now redundant. Dropping it fails no test, because once the stale worktree is removed, the first-creation block resolvesorigin/<branch>again. The behaviour is the same, at the cost of a secondgit fetchon a recreate.Follow-ups
templates/scripts/new-feature.sh(the shell worktree path) has the same first-creation defect: it checks onlyrefs/heads/<branch>and cuts-b <branch> origin/<base>. Raised with the owner; not in this issue's file scope.Fixes #1405
🤖 Generated with Claude Code