Repository navigation
fix(#1076): pass the git dir as a codex writable root so phases can commit - #1077
Merged
Merged
Conversation
…ommit codex's workspace-write sandbox makes the workspace writable but excludes .git/, so every git add and git commit a phase ran was denied with 'Unable to create ….index.lock: Operation not permitted'. The first #1060 gate run produced correct edits across four files and ended with 'made no commits'. Not worktree-specific: a plain clone whose .git sits inside the workspace fails the same way. buildCodexArgs now resolves the git dir with rev-parse --git-common-dir, which answers the main repo's .git from inside a worktree (where the index lives) and the ordinary .git elsewhere, and passes it as a writable root under workspace-write only. Verified against the real sandbox: the exact override the driver computes turns ADD_FAILED into ADD_OK in the #1064 gate worktree. Entire-Checkpoint: 5b02f175c9a6
This was referenced Sep 18, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #1076.
Summary
Codex's
workspace-writesandbox makes the workspace writable but excludes.git/, so everygit add/git commita phase ran was denied:The first #1060 gate run hit exactly this — exec produced correct edits across four files and failed with "made no commits" (sequant's #1032 guard auto-committed the work afterwards, which is the only reason it survived).
buildCodexArgsnow resolves the repo's git dir and passes it as a writable root when the resolved sandbox mode isworkspace-write:git rev-parse --git-common-diris the right question: from inside a worktree it answers the main repo's.git, which is where the index lives; in an ordinary checkout it answers the local.git. One command, both cases. Relative answers are resolved against cwd, because a sandbox policy has no notion of a working directory.read-onlyhas nothing to write anddanger-full-accessis already unrestricted, so neither is touched. A non-git cwd leaves the sandbox exactly as codex configured it rather than failing the phase.Why not
danger-full-accessIt works, and it was the obvious workaround, but it removes the sandbox entirely. Sequant's guard hooks were designed to run inside a sandbox, not to replace one. This keeps the sandbox and opens one directory.
"Use a clone instead of a worktree" was also considered and measured to not work: a plain clone whose
.gitsits inside the workspace fails identically, because the exclusion follows.gitwherever it is.Verification
Beyond the unit assertions, the override the driver computes was fed to the real sandbox against the #1064 gate worktree:
Without the override, the same command prints the
index.lockfatal andADD_FAILED. All of this is $0 —codex sandboxmakes no model call. (It does default to read-only, so any probe with it must pass-c 'sandbox_mode="workspace-write"'or it proves nothing; that default is what made my first analysis on #1060 wrong.)Six tests in a new
codex.sandbox.integration.test.ts, against real repos and a realgit worktreerather than a stubbedexecFileSync— the entire question is which absolute path git keeps the index under, which a mock would only restate.Mutation-verified: AC — replaced the
sandboxMode === "workspace-write"guard withfalse; exactly1076 names the repo's own .git for an ordinary checkoutand1076 names the MAIN repo's .git from inside a worktree, where the index livesfailed, the other 41 tests in both codex files passed; restored.Test plan
npm run buildnpm run lintnpm test— 319 files, 6439 passed, 0 failed, 1 expected fail, 3 skippedUnblocks the #1060 gate re-run, which never reached G-4, G-5 or G-6.