Manager.refresh (internal/worktree/worktree.go) checks out the task's branch without Force before hard-resetting to base. If a prior attempt left uncommitted local changes in the worktree — a killed container, or a stage that edits files before ever reaching a commit — go-git's default checkout (MergeReset mode) can refuse to reconcile them, even when HEAD is already on the correct branch and the target commit hasn't moved.
That failure was then compounded by the fallback: the code assumed any checkout failure meant "the branch doesn't exist yet in this worktree" and retried with Create: true, which fails differently (and much more confusingly) since the branch does exist:
checkout branch feat/1000000000000000-fix-github-issue-514-telegram-response-formatting-concatenat:
a branch named "refs/heads/feat/1000000000000000-fix-github-issue-514-telegram-response-formatting-concatenat" already exists
Evidence
Reproduced directly against the actual broken worktree on a live deployment: git status showed a modified tracked file and an untracked file left over from an interrupted attempt, HEAD already correctly on the task branch. Retrying the task hit exactly the error above and parked again with the same unhelpful message, on every retry, since nothing about the state changes between attempts.
Fix
Add Force: true to both checkout attempts in refresh. This is safe unconditionally: refresh hard-resets to the base commit a few lines later regardless of what checkout leaves behind, so there is no scenario where discarding the working tree's local state here is wrong.
Regression test: TestPrepareRecoversFromADirtyWorktreeOnRetry reproduces the exact production error (modified tracked file + untracked file, branch already checked out) and confirms retry now succeeds and correctly restores the tracked file to its base content.
Imported from beads archie-core-1786756970855-1-72466b33 · GitHub #523 · type bug · priority P1 · created 2026-08-15 · closed 2026-08-15
## Problem
`Manager.refresh` (`internal/worktree/worktree.go`) checks out the task's branch without `Force` before hard-resetting to base. If a prior attempt left uncommitted local changes in the worktree — a killed container, or a stage that edits files before ever reaching a commit — go-git's default checkout (`MergeReset` mode) can refuse to reconcile them, even when HEAD is already on the correct branch and the target commit hasn't moved.
That failure was then compounded by the fallback: the code assumed any checkout failure meant "the branch doesn't exist yet in this worktree" and retried with `Create: true`, which fails differently (and much more confusingly) since the branch *does* exist:
```
checkout branch feat/1000000000000000-fix-github-issue-514-telegram-response-formatting-concatenat:
a branch named "refs/heads/feat/1000000000000000-fix-github-issue-514-telegram-response-formatting-concatenat" already exists
```
## Evidence
Reproduced directly against the actual broken worktree on a live deployment: `git status` showed a modified tracked file and an untracked file left over from an interrupted attempt, HEAD already correctly on the task branch. Retrying the task hit exactly the error above and parked again with the same unhelpful message, on every retry, since nothing about the state changes between attempts.
## Fix
Add `Force: true` to both checkout attempts in `refresh`. This is safe unconditionally: `refresh` hard-resets to the base commit a few lines later regardless of what checkout leaves behind, so there is no scenario where discarding the working tree's local state here is wrong.
Regression test: `TestPrepareRecoversFromADirtyWorktreeOnRetry` reproduces the exact production error (modified tracked file + untracked file, branch already checked out) and confirms retry now succeeds and correctly restores the tracked file to its base content.
---
_Imported from beads `archie-core-1786756970855-1-72466b33` · GitHub #523 · type bug · priority P1 · created 2026-08-15 · closed 2026-08-15_
sam
added the highbug labels 2026-10-27 13:38:34 +00:00
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
Problem
Manager.refresh(internal/worktree/worktree.go) checks out the task's branch withoutForcebefore hard-resetting to base. If a prior attempt left uncommitted local changes in the worktree — a killed container, or a stage that edits files before ever reaching a commit — go-git's default checkout (MergeResetmode) can refuse to reconcile them, even when HEAD is already on the correct branch and the target commit hasn't moved.That failure was then compounded by the fallback: the code assumed any checkout failure meant "the branch doesn't exist yet in this worktree" and retried with
Create: true, which fails differently (and much more confusingly) since the branch does exist:Evidence
Reproduced directly against the actual broken worktree on a live deployment:
git statusshowed a modified tracked file and an untracked file left over from an interrupted attempt, HEAD already correctly on the task branch. Retrying the task hit exactly the error above and parked again with the same unhelpful message, on every retry, since nothing about the state changes between attempts.Fix
Add
Force: trueto both checkout attempts inrefresh. This is safe unconditionally:refreshhard-resets to the base commit a few lines later regardless of what checkout leaves behind, so there is no scenario where discarding the working tree's local state here is wrong.Regression test:
TestPrepareRecoversFromADirtyWorktreeOnRetryreproduces the exact production error (modified tracked file + untracked file, branch already checked out) and confirms retry now succeeds and correctly restores the tracked file to its base content.Imported from beads
archie-core-1786756970855-1-72466b33· GitHub #523 · type bug · priority P1 · created 2026-08-15 · closed 2026-08-15