Skip to content

fix(server): multi-repo worktree threads start when the project path's letter case differs from disk - #48481

Open
juliusmarminge wants to merge 2 commits into
mainfrom
factory/issue-48418
Open

juliusmarminge wants to merge 2 commits into
mainfrom
factory/issue-48418

Conversation

@juliusmarminge

Copy link
Copy Markdown
Member

On macOS (and other case-insensitive volumes), a project added with a path whose letter case differs from the folder on disk (for example ~/developer/app for ~/Developer/app) made every turn in a multi-repo worktree thread fail with "The thread's folder holds a separate checkout instead of the thread's worktree." Git writes a worktree's .git pointer in the case on disk, and linkedGitDir compared it as a string with paths built from the stored project path. Those paths went through Effect's FileSystem.realPath, Node's JS realpath, which does not change letter case. linkedGitDir now resolves paths with Node's native realpath, which returns the case on disk on macOS and Windows, so T3's own worktrees are recognised again.

Fixes #48418

Reproduction on main

Commit 9ba2879 (origin/main). No Mac was free in the shared pool (two 20-minute waits), so I made a case-insensitive volume on the Linux VM instead: a 512 MB ext4 loop image formatted with -O casefold, mounted, and a directory in it marked chattr +F. I checked that it behaves like macOS APFS by creating Developer/ and confirming developer/ resolves. I added one test to apps/server/src/workspace/TaskFolders.test.ts ('resumes a thread whose project path differs from disk only in letter case'). It uses the real TaskFolders service, real git and real files: it makes repositories at <tmp>/Developer/app and <tmp>/Developer/lib, sets the project workspaceRoot to <tmp>/developer/app and the tracked folder to <tmp>/developer/lib (lowercase d, as in the report), creates a worktree task folder on branch feature with lib selected, then calls restore with both worktrees still in place. Run: TMPDIR=<casefold dir> vp test run src/workspace/TaskFolders.test.ts -t "letter case" in apps/server. Result: it fails with TaskFolderCheckoutBlockedError: The thread's folder holds a separate checkout instead of the thread's worktree. Move it away and try again., thrown at TaskFolders.ts:1759 from recreateMissing because linkedGitDir returned null. That is the reporter's error and stack. On a case-sensitive volume, such as Linux CI, the lowercase path does not exist, so the test returns early and passes. I did not run the desktop app on macOS.

Evidence

Being captured: before and after in the real app. This section is filled in before the pull request can merge.

Tests

  • TMPDIR=<casefold ext4 dir> vp test run src/workspace/TaskFolders.test.ts -t "letter case" (apps/server, before the fix): fails with TaskFolderCheckoutBlockedError at TaskFolders.ts:1759, the reported bug
  • vp test run src/workspace/TaskFolders.test.ts (apps/server, after the fix, case-sensitive tmp): 44 passed, 1 skipped
  • vp run typecheck (apps/server): passes, no errors in TaskFolders.ts
  • vp run check:changed: fmt, lint, knip, graphql, typecheck (3 packages) and tests (2 files) all pass
  • macOS run of the repro test: not run, because the Mac pool had no free place (two 20-minute waits)

Not in this change

  • Linux casefold volumes stay affected because glibc realpath does not correct letter case there; comparing stat identity would fix that.
  • Other fileSystem.realPath path comparisons in TaskFolders.ts (for example wasLinked in add-repository) may have the same case sensitivity, but no report reaches them.

Who did the work

  • Written by Claude Opus 5.5, in Claude Code
  • Reviewed by GPT-6.1 Sol, in Codex, and by Claude Opus 5.5, each on its own
  • Proof captured by GPT-6.1 Sol and checked by Claude Opus 5.5

Run by the t3code factory in T3 Code.

juliusmarminge and others added 2 commits December 3, 2026 20:26
…isk in letter case

Reproduces #48418 on case-insensitive volumes (macOS).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…s letter case differs from disk

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@github-actions github-actions Bot added vouch:trusted Author is trusted by repo permissions or the VOUCHED list. size:XS 0-9 changed lines (additions + deletions). labels Dec 3, 2026
@macroscopeapp

macroscopeapp Bot commented Dec 3, 2026

Copy link
Copy Markdown
Contributor

Approvability

Verdict: Needs Human Approval

Macroscope's review found this PR requires human approval — The change normalizes path letter case during Git worktree validation while preserving the existing error fallback. It also adds a static-analysis suppression for the Node filesystem import, which requires human review.

You can add or adjust custom eligibility rules. Learn more.

@github-actions

github-actions Bot commented Dec 3, 2026

Copy link
Copy Markdown
Contributor

Thread transfer impact

✅ Thread transfer remains within every enforced ceiling.

Provider Metric Main baseline This PR Impact PR ceiling
Codex Total thread wire 5.0 KiB 5.0 KiB 0 B (0.0%) 6.8 KiB ✅
Codex Thread snapshot wire 3.8 KiB 3.8 KiB 0 B (0.0%) 4.9 KiB ✅
Codex Live turn WebSocket wire 1.2 KiB 1.2 KiB 0 B (0.0%) 2.0 KiB ✅
Codex Live turn WebSocket decoded 21.5 KiB 21.5 KiB 0 B (0.0%) 24.4 KiB ✅
Codex Live turn messages 1 1 0 (0.0%) 8 ✅
Claude Total thread wire 5.0 KiB 5.0 KiB 0 B (0.0%) 6.8 KiB ✅
Claude Thread snapshot wire 3.8 KiB 3.8 KiB 0 B (0.0%) 4.9 KiB ✅
Claude Live turn WebSocket wire 1.2 KiB 1.2 KiB 0 B (0.0%) 2.0 KiB ✅
Claude Live turn WebSocket decoded 21.9 KiB 21.9 KiB 0 B (0.0%) 24.4 KiB ✅
Claude Live turn messages 1 1 0 (0.0%) 8 ✅

Other scenarios

All 64 scenario measurements match main.

All 64 scenario measurements
Provider Scenario Metric Main baseline This PR Impact PR ceiling
Codex short turn resume WebSocket decoded 10.5 KiB 10.5 KiB 0 B (0.0%) 12.7 KiB ✅
Codex short turn resume WebSocket messages 2 2 0 (0.0%) 2 ✅
Codex long turn running, cold open HTTP decoded 281.7 KiB 281.7 KiB 0 B (0.0%) 302.7 KiB ✅
Codex long turn running, cold open rows 75 75 0 (0.0%) 75 ✅
Codex long turn running, history page HTTP decoded 92.5 KiB 92.5 KiB 0 B (0.0%) 107.4 KiB ✅
Codex long turn running, history page rows 75 75 0 (0.0%) 75 ✅
Codex long turn finished, cold open HTTP decoded 381.5 KiB 381.5 KiB 0 B (0.0%) 410.2 KiB ✅
Codex long turn finished, cold open rows 151 151 0 (0.0%) 151 ✅
Codex long turn finished, socket cold open WebSocket decoded 381.6 KiB 381.6 KiB 0 B (0.0%) 410.2 KiB ✅
Codex long turn finished, socket cold open WebSocket messages 2 2 0 (0.0%) 2 ✅
Codex long turn finished, socket cold open rows 151 151 0 (0.0%) 151 ✅
Codex long turn finished, work page HTTP decoded 78.3 KiB 78.3 KiB 0 B (0.0%) 200.2 KiB ✅
Codex long turn finished, work page rows 75 75 0 (0.0%) 150 ✅
Codex idle thread resume WebSocket decoded 65 B 65 B 0 B (0.0%) 200 B ✅
Codex idle thread resume WebSocket messages 1 1 0 (0.0%) 1 ✅
Codex fleet shell snapshot HTTP decoded 42.4 KiB 42.4 KiB 0 B (0.0%) 53.7 KiB ✅
Codex fleet shell snapshot rows 27 27 0 (0.0%) 27 ✅
Codex fleet shell subscribe WebSocket decoded 65 B 65 B 0 B (0.0%) 200 B ✅
Codex fleet shell subscribe WebSocket messages 1 1 0 (0.0%) 1 ✅
Codex fleet shell resume check HTTP decoded 18 B 18 B 0 B (0.0%) 100 B ✅
Codex fleet shell resume check rows 0 0 0 0 ✅
Codex stale shell reload HTTP decoded 42.4 KiB 42.4 KiB 0 B (0.0%) 53.7 KiB ✅
Codex stale shell reload rows 27 27 0 (0.0%) 27 ✅
Codex stale shell resume WebSocket decoded 140 B 140 B 0 B (0.0%) 400 B ✅
Codex stale shell resume WebSocket messages 2 2 0 (0.0%) 2 ✅
Codex stale todo list cold open HTTP decoded 72.4 KiB 72.4 KiB 0 B (0.0%) 83.0 KiB ✅
Codex stale todo list cold open rows 75 75 0 (0.0%) 75 ✅
Codex stale todo list cold open nodes 2 2 0 (0.0%) 4 ✅
Codex stale todo list cold open subagents 2 2 0 (0.0%) 4 ✅
Codex stale todo list cold open plans 1 1 0 (0.0%) 2 ✅
Codex stale todo list cold open providerTurns 1 1 0 (0.0%) 2 ✅
Codex stale todo list cold open checkpoints 1 1 0 (0.0%) 2 ✅
Claude short turn resume WebSocket decoded 10.6 KiB 10.6 KiB 0 B (0.0%) 12.7 KiB ✅
Claude short turn resume WebSocket messages 2 2 0 (0.0%) 2 ✅
Claude long turn running, cold open HTTP decoded 283.3 KiB 283.3 KiB 0 B (0.0%) 302.7 KiB ✅
Claude long turn running, cold open rows 75 75 0 (0.0%) 75 ✅
Claude long turn running, history page HTTP decoded 93.4 KiB 93.4 KiB 0 B (0.0%) 107.4 KiB ✅
Claude long turn running, history page rows 75 75 0 (0.0%) 75 ✅
Claude long turn finished, cold open HTTP decoded 384.2 KiB 384.2 KiB 0 B (0.0%) 410.2 KiB ✅
Claude long turn finished, cold open rows 151 151 0 (0.0%) 151 ✅
Claude long turn finished, socket cold open WebSocket decoded 384.3 KiB 384.3 KiB 0 B (0.0%) 410.2 KiB ✅
Claude long turn finished, socket cold open WebSocket messages 2 2 0 (0.0%) 2 ✅
Claude long turn finished, socket cold open rows 151 151 0 (0.0%) 151 ✅
Claude long turn finished, work page HTTP decoded 79.2 KiB 79.2 KiB 0 B (0.0%) 200.2 KiB ✅
Claude long turn finished, work page rows 75 75 0 (0.0%) 150 ✅
Claude idle thread resume WebSocket decoded 66 B 66 B 0 B (0.0%) 200 B ✅
Claude idle thread resume WebSocket messages 1 1 0 (0.0%) 1 ✅
Claude fleet shell snapshot HTTP decoded 43.0 KiB 43.0 KiB 0 B (0.0%) 53.7 KiB ✅
Claude fleet shell snapshot rows 27 27 0 (0.0%) 27 ✅
Claude fleet shell subscribe WebSocket decoded 66 B 66 B 0 B (0.0%) 200 B ✅
Claude fleet shell subscribe WebSocket messages 1 1 0 (0.0%) 1 ✅
Claude fleet shell resume check HTTP decoded 18 B 18 B 0 B (0.0%) 100 B ✅
Claude fleet shell resume check rows 0 0 0 0 ✅
Claude stale shell reload HTTP decoded 43.0 KiB 43.0 KiB 0 B (0.0%) 53.7 KiB ✅
Claude stale shell reload rows 27 27 0 (0.0%) 27 ✅
Claude stale shell resume WebSocket decoded 140 B 140 B 0 B (0.0%) 400 B ✅
Claude stale shell resume WebSocket messages 2 2 0 (0.0%) 2 ✅
Claude stale todo list cold open HTTP decoded 73.4 KiB 73.4 KiB 0 B (0.0%) 83.0 KiB ✅
Claude stale todo list cold open rows 75 75 0 (0.0%) 75 ✅
Claude stale todo list cold open nodes 2 2 0 (0.0%) 4 ✅
Claude stale todo list cold open subagents 2 2 0 (0.0%) 4 ✅
Claude stale todo list cold open plans 1 1 0 (0.0%) 2 ✅
Claude stale todo list cold open providerTurns 1 1 0 (0.0%) 2 ✅
Claude stale todo list cold open checkpoints 1 1 0 (0.0%) 2 ✅

Baseline: efbd62a · PR result: 4adcf02 · Source CI: success

Scenario and decoded snapshot size

10 historical turns, 5 command tools per turn, 878.9 KiB retained MCP result per historical turn, and a 1.05 MiB retained result in the measured turn.

  • Codex decoded thread snapshot: 108.5 KiB
  • Claude decoded thread snapshot: 108.8 KiB

Updated in place by a trusted workflow. PR artifacts are strictly validated and never executed.

@coderabbitai

coderabbitai Bot commented Dec 3, 2026

Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

The checkout path helper now uses Node’s promise-based realpath API. A new test checks task folder restoration when project and repository paths use different casing from the on-disk paths.

Changes: Task folder path casing

Layer / File(s) Summary
Resolve checkout paths and test restore
apps/server/src/workspace/TaskFolders.ts, apps/server/src/workspace/TaskFolders.test.ts
The real helper calls NodeFSP.realpath and falls back to the input path if resolution fails. The test uses alternate-case paths and asserts that restoration does not invoke the recreation callback.

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix · Severity of issue fixed: Medium

Suggested reviewers: iamshadmantaqi, shivamhwp

Merge Risk: Minimal · up to 4adcf

This change resolves checkout paths with Node's native realpath so that task folders are restored when a project path's letter case differs from the folder on disk. No concrete merge-blocking risk was found.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title names the actual change: multi-repo worktree threads that failed when the project path's letter case differed from disk on case-insensitive volumes. It follows the conventional commit format…
Description check Passed The description follows the template's sections: Problem, Change, Scope, Verification, and agent attribution. It explains the bug, the native realpath fix, and the linked issue #48418. It gives a deta…
Linked Issues check Passed [#48418] Requires that worktree turns start when the stored project path differs from the on-disk letter case on macOS. The root cause in the issue is that linkedGitDir compares paths produced by `f…
Out of Scope Changes check Passed The whole-PR diff (merge base 9ba2879 to head 4adcf02) changes two files. In TaskFolders.ts, the change adds a node:fs/promises im…
Full details: Title check

Explanation

The title names the actual change: multi-repo worktree threads that failed when the project path's letter case differed from disk on case-insensitive volumes. It follows the conventional commit format and matches the linked issue and the diff's realpath fix in linkedGitDir.

Full details: Description check

Explanation

The description follows the template's sections: Problem, Change, Scope, Verification, and agent attribution. It explains the bug, the native realpath fix, and the linked issue #48418. It gives a detailed reproduction on a casefold volume and lists the test commands and results. The Evidence section is explicitly pending, and the macOS run was not performed. The template asks for before/after evidence for UI changes, but this is a server fix, so this gap is non-critical. The Scope section links the issue but does not explicitly say why a bug fix is needed without one. That is covered by the linked issue.

Full details: Linked Issues check

Explanation

[#48418] Requires that worktree turns start when the stored project path differs from the on-disk letter case on macOS. The root cause in the issue is that linkedGitDir compares paths produced by fileSystem.realPath, which keeps the input case. The diff at the reviewed head replaces that helper in linkedGitDir with NodeFSP.realpath from node:fs/promises, which calls the native realpath binding. On macOS this returns the on-disk case, so the .git pointer written by Git and the paths built from the stored project path compare equal. This matches the issue's suggested fs.realpath.native fix. The added test 'resumes a thread whose project path differs from disk only in letter case' covers the reported path shape. It returns early on case-sensitive volumes. The author reports it fails before the fix on a casefold ext4 volume. After-fix behavior on a case-insensitive volume and on macOS was not run, so the runtime result is not executed here. Missing sub-requirement: none identified in code. The issue's workaround-row cleanup is not a coding requirement of this PR.

Full details: Out of Scope Changes check

Explanation

The whole-PR diff (merge base 9ba2879 to head 4adcf02) changes two files. In TaskFolders.ts, the change adds a node:fs/promises import with a diagnostic suppression comment and changes only the local real helper inside linkedGitDir. In TaskFolders.test.ts, it adds one regression test for the reported case. Both changes directly support the objective in #48418. The PR description's 'Not in this change' items (Linux casefold volumes, other fileSystem.realPath comparisons such as wasLinked) are left unchanged, so they add no out-of-scope code.

Finishing Touches

Generate unit tests (beta)

  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Recent review info

Run configuration

Commits

Reviewing files that changed from the base of the PR and between efbd62a and 4adcf02.

Files selected for processing: 2

  • apps/server/src/workspace/TaskFolders.test.ts
  • apps/server/src/workspace/TaskFolders.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 6 remain after this review.

@juliusmarminge

Copy link
Copy Markdown
Member Author

The automated pipeline stopped on this pull request and will not merge it:

the fix is written and reviewed, but proving it needs something no worker has:

  • Permanent blocker: The reproduction depends on macOS APFS case-insensitive path resolution and a real app run with captures; no Mac lease became available during this run.

It stays open for a person to finish or close.

@reed-yang

Copy link
Copy Markdown

Checked on macOS (case-insensitive APFS), Node 26, Git 2.50, since no Mac was available for the PR. Your test 'resumes a thread whose project path differs from disk only in letter case' fails on 9ba2879 with TaskFolderCheckoutBlockedError: The thread's folder holds a separate checkout instead of the thread's worktree. Move it away and try again. (TaskFolders.ts:1759), and with 4adcf02 all 45 cases in TaskFolders.test.ts pass. A second test with the same setup (project and tracked folder added as <tmp>/developer/... for <tmp>/Developer/..., then restore with both worktrees in place) also fails on main and passes with this change.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:XS 0-9 changed lines (additions + deletions). vouch:trusted Author is trusted by repo permissions or the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Multi-repo worktree threads fail with "separate checkout" when the project path's letter case differs from disk (macOS)

2 participants