Repository navigation
Conversation
ApprovabilityVerdict: Approved at Macroscope's review found this PR approvable — This is a narrowly scoped server bug fix that interrupts an existing background rename only when cancelled worktree cleanup is removing the worktree, with normal launches unchanged. A deterministic regression test covers the race without introducing new production capability or configuration. Notes:
No code changes detected at You can add or adjust custom eligibility rules. Learn more. |
Dismissing prior approval to re-evaluate 7082440
… its worktree The background branch rename runs in the service-lifetime preparation scope, so cancelling worktree setup did not stop it. When the rename landed after the cleanup it recorded the removed worktree on the thread again, which made "cancels tracked setup before provider work is released" fail intermittently. Cleanup now interrupts the rename first. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The rename is held open until after the cancel, so the test fails on every run without the fix instead of only when the rename happens to land late. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
7082440 to
e637841
Compare
|
Independent confirmation from a downstream fork on Windows (Node 24.13.0).
So the fix here matches what we needed. We are carrying the same patch until this merges. Posted by Claude (AI) on behalf of @AdEx-Partners-DE; no human reviewed this comment. |
…e-before-setup-cancel # Conflicts: # apps/server/src/orchestration-v2/ThreadLaunchService.ts
That fix is independent of SQLite read blocking and is carried by pingdotgg#18443. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Problem
When a thread launches into a new worktree,
ThreadLaunchServicerenames the temporaryt3/<hash>branch in a background fiber forked into the service-lifetime preparation scope. If worktree setup is then cancelled, cleanup removes the worktree and clears it from the thread, but the rename fiber keeps running. When it lands it dispatchesthread.metadata.updatewith the removedworktreePath, so the thread points at a worktree that no longer exists. On main this showed up as an intermittentThreadLaunchService.test.ts > cancels tracked setup before provider work is releasedfailure (expected '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/repo-worktrees/feature' to equal null), and any added latency on the launch commit path makes it common.A very small, focused fix for an obvious bug (CONTRIBUTING.md): one defect, one function, plus a regression test.
Change
Keep the rename fiber and interrupt it (which waits for it to stop) as the first step of the cleanup branch that removes the worktree, before the worktree is removed and forgotten. Main's current cleanup rule (#19102) is kept as is: the worktree is removed only when
(cancelled && !runReleased) || !workspaceRecorded, so a run already released to the provider keeps both its worktree and its rename, and successful launches are untouched.Verification
Head
d45b8984cc(maindff750b1b8merged; the conflict with #19102'srunReleasedcleanup was resolved by keeping main's condition and adding the interrupt inside it).vp test run apps/server/src/orchestration-v2/ThreadLaunchService.test.ts: 73 passed.stops an in-flight branch rename when tracked setup is cancelled(the cancelled setup's branch rename kept running: expected false to be true). The test holds branch-name generation open withDeferreds (no sleeps or polling), cancels, then releases it.vp run typecheck(apps/server) clean;vp linton the two files: one pre-existing optional-chaining warning in the test file.Claude Opus 5.5 (Claude Code). Merge with main: Claude Opus 5.5 (Claude Code) via T3 Code; review GPT-6.1 Sol.
🤖 Generated with Claude Code