Skip to content

fix(codex): resolve linked-worktree git directories - #126

Merged
mvschwarz merged 1 commit into
mainfrom
fix/issue121-worktree-git-dirs
Sep 29, 2026
Merged

mvschwarz merged 1 commit into
mainfrom
fix/issue121-worktree-git-dirs

Conversation

@mvschwarz

@mvschwarz mvschwarz commented Sep 29, 2026 •

Copy link
Copy Markdown
Owner

Summary

Addresses #121. Codex fresh launches currently add <cwd>/.git as a writable directory even when a linked worktree stores it as a file.

  • Resolve a worktree's git directory and common git directory with git rev-parse; pass only existing directories, de-duplicated and shell-quoted.
  • Keep ordinary-repository and absent-.git behavior unchanged. Unresolvable metadata gets no extra git-directory access, rather than a file argument.
  • Leave resume/fork arguments and existing permission posture unchanged.

Thanks to @mgall-ibizdigital for the report, reproduction and suggested resolution approach. Their unpublished patch bytes are not used here.

Verification

  • Added temporary real-Git fixtures exercising the actual adapter command: ordinary repo, linked worktree with spaces, malformed metadata and existing resume behavior. The pre-fix linked-worktree control failed as expected; eight focused tests subsequently passed in the author's local run.
  • The local existing adapter suite recorded 68 passing tests and two failures due to an unavailable native SQLite binding in borrowed dependencies. Those dependencies predate the current lockfile, so this is not a claim of a green complete local suite. Hosted CI on the current lockfile is required before merge.
  • No Codex/provider launch or Linux bubblewrap end-to-end test was performed here. The Linux sandbox failure and successful alternative remain the reporter's evidence.

Draft until hosted CI and portability results have been assessed. No dependency, migration, profile or permission-mode change.

Summary by CodeRabbit

  • Bug Fixes
    • Fresh Codex launches now receive the Git metadata directories needed to work with both standard repositories and linked worktrees.
    • Resumed launches no longer receive extra Git directory access arguments.

…dir (#121)

In a linked git worktree <cwd>/.git is a file, and passing it to Codex as
--add-dir breaks the Linux sandbox for every command. The fresh launch now
resolves the git metadata directories: an ordinary repository keeps
<cwd>/.git; a .git file resolves through git rev-parse to the worktree git
dir and the common git dir (existing directories only); anything
unresolvable adds nothing. A missing .git keeps the previous argument.
Resume and fork are unchanged.

Reported with a reproduction and the suggested rev-parse approach by
mgall-ibizdigital in #121.
@coderabbitai

coderabbitai Bot commented Sep 29, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

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

Note

Currently processing new changes in this PR. This may take a few minutes, please wait...

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Advanced

Run ID: f8dc8330-175e-4aad-831e-c07ca5c74fe8

📥 Commits

Reviewing files that changed from the base of the PR and between 50e519b and bb18c3e.

📒 Files selected for processing (3)
  • packages/daemon/src/adapters/codex-runtime-adapter.ts
  • packages/daemon/src/domain/codex-git-add-dirs.ts
  • packages/daemon/test/codex-git-add-dirs.test.ts
 ______________________________________________________________________________________________________________________________________________
< Eliminate effects between unrelated things. Design components that are self-contained, independent, and have a single, well-defined purpose. >
 ----------------------------------------------------------------------------------------------------------------------------------------------
  \
   \   \
        \ /\
        ( )
      .( o ).
✨ Finishing Touches
📝 Generate docstrings
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

@mvschwarz
mvschwarz marked this pull request as ready for review September 29, 2026 08:54
@mvschwarz
mvschwarz merged commit f87a956 into main Sep 29, 2026
9 of 10 checks passed
@mvschwarz
mvschwarz deleted the fix/issue121-worktree-git-dirs branch September 29, 2026 08:57
AlephCasara pushed a commit to AlephCasara/openrig that referenced this pull request Nov 10, 2026
…dir (mvschwarz#121) (mvschwarz#126)

In a linked git worktree <cwd>/.git is a file, and passing it to Codex as
--add-dir breaks the Linux sandbox for every command. The fresh launch now
resolves the git metadata directories: an ordinary repository keeps
<cwd>/.git; a .git file resolves through git rev-parse to the worktree git
dir and the common git dir (existing directories only); anything
unresolvable adds nothing. A missing .git keeps the previous argument.
Resume and fork are unchanged.

Reported with a reproduction and the suggested rev-parse approach by
mgall-ibizdigital in mvschwarz#121.

Co-authored-by: orch-advisor <orch-advisor@openrig-build>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant