Skip to content

fix(server): use absolute git common dir for checkpoints through symlinked subdirectories - #14736

Open
macodev00 wants to merge 1 commit into
pingdotgg:mainfrom
macodev00:cursor/fix-symlink-checkpoint-capture-redo2-9e22
Open

macodev00 wants to merge 1 commit into
pingdotgg:mainfrom
macodev00:cursor/fix-symlink-checkpoint-capture-redo2-9e22

Conversation

@macodev00

@macodev00 macodev00 commented Oct 2, 2026 •

Copy link
Copy Markdown
Contributor

Problem

Opening a project through a symlink that points at a repository subdirectory made every turn fail checkpoint capture with exit 128. Git's relative --git-common-dir is computed from the physical working directory, and path.resolve applied .. to the symlink string, so the temporary index was created in a directory that does not exist. When that lexical path happened to exist, the index was written into a different repository. Diffs and Go back stayed unavailable for that thread.

The same join in repository path lookup could cache the missing directory, or the other repository's .git.

Accepted in #13187.

What Changed

Checkpoint capture and repository path lookup now ask Git for an absolute --git-common-dir before joining it with the project path. realPath still runs afterward so Windows 8.3 short names collapse.

The regression tests plant a decoy repository at the lexical common-dir path before the only lookup. Checkpoint capture records GIT_INDEX_FILE during the command and requires that directory to be the real .git. Repository listing calls listRefs once, on a cwd that has never been resolved, and requires decoy-only to be absent and real-only to be present. A second listRefs on the same cwd would be served from the refresh cache and would not check the decoy.

Fixes #13187

Supersedes #13223, which Macroscope marked Not approved.

Scope and approval

Server checkpoint and repository-path resolution only. No UI, contract, or provider changes.

#13187 was triaged and accepted as a server checkpoint bug: #13187 (comment)

Verification

Head 5023381cd, rebased onto current main (only GitVcsDriverCore.test.ts conflicted; both upstream's new test and the symlink test are kept). Node v24.13.1, Linux. From apps/server:

vp test run src/vcs/GitVcsDriver.test.ts src/vcs/GitVcsDriverCore.test.ts

Result: GitVcsDriver.test.ts 60 passed. GitVcsDriverCore.test.ts 113 passed, 1 failed: preserves renames, unusual paths, modes, and binary statistics, which fails the same way on unmodified upstream main in that environment, so it is not caused by this change.

Without the fix (upstream sources plus these tests), both symlink tests fail: checkpoint capture recorded GIT_INDEX_FILE under <sandbox>/.git (the decoy) instead of <sandbox>/repo/.git, and listRefs returned the decoy-only branch. With the fix both pass, as does the stable-diagnostics expectation for the absolute --git-common-dir args.

vp run --filter t3 typecheck

Result: tsc --noEmit exited 0 (last run at 7e895b123, before the rebase; the rebase only touched the test file's imports and test list).

Limitations: checked on Linux, where symlink creation is supported, so the new skipIf(!symlinksSupported) cases ran. Not checked on Windows. One pre-existing GitVcsDriverCore test failure on main in the agent environment, noted above.

UI Changes

None. Server checkpoint and repository-path resolution only.

Checklist

  • This PR is small and focused
  • I explained what changed and why
  • Before/after screenshots (none: no UI change)
  • Video for interaction changes (none: no UI change)

@github-actions github-actions Bot added vouch:unvouched PR author is not yet trusted in the VOUCHED list. size:S 10-29 changed lines (additions + deletions). labels Oct 2, 2026
macroscopeapp[bot]
macroscopeapp Bot previously approved these changes Oct 2, 2026
@macroscopeapp

macroscopeapp Bot commented Oct 2, 2026 •

Copy link
Copy Markdown
Contributor

Approvability

Verdict: Approved at 7e895b1

Macroscope's review found this PR approvable — This is a narrowly scoped server bug fix that makes Git common-directory resolution absolute for checkpoint and repository lookup paths, with targeted symlink regression tests. Ordinary repository behavior is preserved, and the PR does not alter schemas, defaults, deployment, security-sensitive code, or static-analysis configuration.

Notes:

  • Diff unchanged. Approvability was decided on eligibility alone.

No code changes detected at 5023381. Prior analysis still applies.

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

@juliusmarminge juliusmarminge added the macroscope-review Opt PRs made by unvouched contributors in for Macroscope review. Vouched contributors auto-reviews label Oct 2, 2026 — with ChatGPT Codex Connector
@macroscopeapp
macroscopeapp Bot dismissed their stale review October 2, 2026 06:37

Dismissing prior approval to re-evaluate 7e895b1

@coderabbitai

coderabbitai Bot commented Oct 2, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

Navigate logical layers of code changes, visualize relationships, and explore their blast radius.

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Repository: pingdotgg/t3code/.coderabbit.yaml
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: d0d4e5e6-9d67-43a7-8252-4988a9ea1a0d
📥 Commits

Reviewing files that changed from the base of the PR and between 7e895b1 and d220f07.

📒 Files selected for processing (3)
  • apps/server/src/vcs/GitVcsDriver.ts
  • apps/server/src/vcs/GitVcsDriverCore.test.ts
  • apps/server/src/vcs/GitVcsDriverCore.ts

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


📝 Walkthrough

Walkthrough

Git common-directory lookups now request absolute paths. Symlink-focused tests verify repository status and checkpoint capture against the real repository.

Changes

Symlinked repository path resolution

Layer / File(s) Summary
Request absolute Git common directories
apps/server/src/vcs/GitVcsDriverCore.ts, apps/server/src/vcs/GitVcsDriver.ts
The common-directory lookups request absolute paths. The error context uses the updated Git arguments.
Test repository status and checkpoint capture
apps/server/src/vcs/GitVcsDriverCore.test.ts, apps/server/src/vcs/GitVcsDriver.test.ts
Symlink-gated tests check that repository status and checkpoint capture use the real repository, not a decoy path. The diagnostics test expects the updated Git command.

Priority: ➖ Normal

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

Change: Bug fix · Severity of issue fixed: Medium

Suggested reviewers: t3dotgg

Merge Risk: ⚪ Minimal · up to d220f

No actionable merge-blocking issue is established. The symlinked-project fix appears ready for normal merge checks; compatibility with Git versions before 2.31 remains unspecified.

Architecture Summary

Architecture risk: 🔵 Low · up to d220f

The change affects 1 system.

Changed systems: apps/server

Architecture concerns
No architecture-level concerns identified.

Review details

Systems and components

  • observed — apps/server (service) was modified; 4 changed files map to changed impact.

Before / after behavior

  • observed — Modified behavior in apps/server/src/vcs/GitVcsDriver.test.ts: The test file imports symlinksSupported to gate tests that require symlink support.
  • observed — Modified behavior in apps/server/src/vcs/GitVcsDriver.test.ts: Adds a test skipped when symlinks are unsupported. It constructs a real repository, a decoy repository, and a symlink to a nested real-repository directory; confirms Git’s relative common-directory path resolves lexically to the decoy but the real common directory differs; then captures from the symlink and checks that each recorded temporary GIT_INDEX_FILE is located in the real common directory, none is placed in the decoy, and the checkpoint contains the nested file.
  • observed — Modified behavior in apps/server/src/vcs/GitVcsDriver.ts: Added an explanation that Git computes relative --git-common-dir output from its physical working directory, which can misresolve symlinked project paths.
  • observed — Modified behavior in apps/server/src/vcs/GitVcsDriver.ts: resolveGitCommonDir now passes --path-format=absolute when querying --git-common-dir; previously it queried a potentially relative path that the function resolved against cwd.
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Out of Scope Changes check ⚠️ Warning The changes since the prior review add unrelated work, including Git status and local-branch APIs in GitVcsDriver.ts, triage policy and exemption changes, CI workflow changes, database fixture guida… Remove the unrelated changes from this PR, or move them to separate PRs. Keep the changes needed for the [#13187] symlink-path fix and its regression tests.
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check ✅ Passed The PR meets the coding requirements in [#13187]. The prior reviewed head contains the absolute --git-common-dir lookup and symlink regression tests for checkpoint capture and repository-path lookup…
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 4…
Title check ✅ Passed The title clearly summarizes the main change: using an absolute Git common directory to fix checkpoint capture through symlinked subdirectories.
Description check ✅ Passed The description covers the problem, change, scope and approval, and verification. It provides focused test results and states the known failure and platform limitation.
Full details: Out of Scope Changes check

Explanation

The changes since the prior review add unrelated work, including Git status and local-branch APIs in GitVcsDriver.ts, triage policy and exemption changes, CI workflow changes, database fixture guidance, and mobile release workflow changes. These changes do not support [#13187]'s symlinked-subdirectory checkpoint fix.

  • Fix all pre-merge checks with AI
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create a new PR
  • Autopilot · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Autopilot is currently an internal CodeRabbit preview.


Comment @coderabbitai help to get the list of available commands.

@cursor
cursor Bot force-pushed the cursor/fix-symlink-checkpoint-capture-redo2-9e22 branch from 7e895b1 to d220f07 Compare October 4, 2026 06:25
…ctories

Git's relative --git-common-dir is computed from the physical working
directory. Joining it with path.resolve walked out of a symlink into a
repository subdirectory, so checkpoint capture wrote its index into a
missing directory or a different repository.

Ask for an absolute common dir in checkpoint capture and repository path
lookup. The regression tests create the decoy repository before the only
lookup, so a cached pre-decoy result cannot hide the wrong path.
@macodev00
macodev00 force-pushed the cursor/fix-symlink-checkpoint-capture-redo2-9e22 branch from d220f07 to 5023381 Compare October 4, 2026 06:36

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

macroscope-review Opt PRs made by unvouched contributors in for Macroscope review. Vouched contributors auto-reviews size:S 10-29 changed lines (additions + deletions). vouch:unvouched PR author is not yet trusted in the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Checkpoint capture fails with exit 128 on every turn when the project path is a symlink to a repository subdirectory

2 participants