fix: Windows worktree creation falls back gracefully instead of using temp dirs#440
fix: Windows worktree creation falls back gracefully instead of using temp dirs#440
Conversation
931d56b to
68aa1e9
Compare
PR #440 Review — R1Tests: ✅ 2970/2970 passed The core approach is correct — 🔴 Major:
|
🔄 Re-Review Round 2No new commits since R1 (still 1 commit, last updated 2026-03-26). The R1 findings remain open. R1 Findings Status
|
🔍 Multi-Model Code Review — PR #440 (Re-Review R5, Final)Branch: Previous Findings Status
R5 Fix: Session Metadata Worktree ID Leak (3/3 consensus)All 3 reviewers independently identified that R4's fix was incomplete:
Fix: Removed the Test coverage: Both GroupShared and FullyIsolated fallback tests now assert Test Results✅ 3510/3510 tests pass (including 38 worktree strategy tests) Recommendation✅ Approve and merge — all findings addressed, critical data-loss bug fully fixed with behavioral test coverage at both group and session metadata levels. |
… temp dirs Rebased on main — dropped RepoManager.cs changes (core.longpaths, IsValidBareRepository, corruption cleanup) that were already merged. Remaining changes: - CopilotService.Organization.cs: fallback to existing worktree (TryGetExistingWorktreePath) when worktree creation fails - WorktreeStrategyTests.cs: 4 regression tests for fallback behavior - RepoManagerTests.cs: CreateFakeBareRepoSkeleton helper Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
68aa1e9 to
3a53014
Compare
… add disk validation 🔴 CRITICAL: TryGetExistingWorktreePath no longer sets group.WorktreeId. Borrowed worktrees are not owned — DeleteGroup must not destroy them. Only orchWtId is set (for session metadata), group.WorktreeId stays null. 🟡 MODERATE: Added Directory.Exists check before returning a fallback worktree path. Stale/deleted worktrees are skipped. 🟡 MODERATE: FullyIsolated test now asserts WorkingDirectory for all sessions (matching the GroupShared test pattern). 🟢 MINOR: Worker fallback logs which directory it falls back to. 🟢 MINOR: Tests use real temp dirs (disk validation works in tests). 🟢 MINOR: Missing blank line in RepoManagerTests.cs. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
TryGetExistingWorktreePath now returns only the path — the ref worktreeId parameter is removed entirely. This prevents the borrowed ID from propagating to orchWtId → session metadata (WorktreeId), which DeleteGroup collects from all sessions in a group and deletes. Without this fix, deleting a group that used a borrowed worktree would destroy a worktree owned by another group. All 3 reviewers flagged this as a remaining critical issue after the previous fix (which only protected group.WorktreeId but not session-level metadata). Tests updated to assert session metadata WorktreeId is null for borrowed worktrees, not just group.WorktreeId. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Problem
On Windows, "Implement & Challenge" multi-agent groups end up with sessions pointing to temp directories instead of proper git worktrees. This works fine on Mac.
Root Cause
CreateGroupFromPresetAsync has try/catch blocks around worktree creation that silently swallow exceptions (only Debug log). When worktree creation fails on Windows (long paths, file locking), orchWorkDir stays null, CreateSessionAsync gets null workingDirectory, and creates a temp dir.
Additionally, GroupShared strategy was falling into the wrong code path, creating -orchestrator- branches instead of -shared- branches.
Fix
Testing