| … | … | @@ -911,6 +938,9 @@ const make = Effect.gen(function* () { | |
| 911 | 938 | commandId: input.commandId, | |
| 912 | 939 | threadId: candidateThreadId, | |
| 913 | 940 | expectedEmpty: true, | |
| 941 | + | ...(initialWorktreePath === null | |
🟠 High orchestration-v2/ThreadLaunchService.ts:941
A fresh launch that reuses an empty thread with an existing worktree runs its initial agent in that old checkout instead of the requested workspace. When initialWorktreePath is null, this claim omits the workspace fields, preserving the old binding; scheduleRunPreparation then treats that binding as a worktree to reuse. Clear the old binding on a fresh claim so preparation creates the requested workspace.
🚀 Reply "fix it for me" or copy this AI Prompt for your agent:
| 1 | In file @apps/server/src/orchestration-v2/ThreadLaunchService.ts around line 941: |
| 2 | |
| 3 | A fresh launch that reuses an empty thread with an existing worktree runs its initial agent in that old checkout instead of the requested workspace. When `initialWorktreePath` is `null`, this claim omits the workspace fields, preserving the old binding; `scheduleRunPreparation` then treats that binding as a worktree to reuse. Clear the old binding on a fresh claim so preparation creates the requested workspace. |
Fixed in the latest upper candidate. Fresh reuse replaces the prior concrete checkout binding for root/new-worktree requests; an unprepared null-path draft retains its branch if preparation fails. The claim also passes its observed expectedWorktreePath (including null), so another client changing the checkout between validation and claim is rejected atomically. Accepted receipt replay remains unchanged.
The two actual preparation/checkpoint regressions failed before the stale-binding fix. A third real orchestrator/SQLite concurrency regression failed with a run admitted in the other checkout; it now proves a rejected receipt, zero messages/runs/setup/outbox admission, and preservation of the second client’s binding. All 112 focused tests pass. Sanitized before/after proof. The existing draft and accepted-retry controls remain green. Git/setup are faked in this proof; no native or live-provider claim.