Repository navigation
Description
Epic: #497 · Blocks the #1060 gate.
What happens
Every codex phase ends unable to commit. Codex's workspace-write sandbox — the driver's default (DEFAULT_SANDBOX_MODE, src/lib/workflow/drivers/codex.ts:83) — makes the workspace writable but excludes .git/, so git add and git commit both fail:
fatal: Unable to create '/Users/tony/Projects/sequant/.git/worktrees/1064-…/index.lock': Operation not permitted
Observed on the first real gate run (#1060, issue #1064): exec produced correct edits across four files, could not commit any of them, and the phase failed with exec left 5 file(s) uncommitted and made no commits. Sequant's #1032 guard auto-committed the work afterwards, which is the only reason it survived.
Verified, all at $0 via codex sandbox (no model calls)
| Setup | sandbox_mode |
Result |
|---|---|---|
| worktree | workspace-write |
fatal: … index.lock: Operation not permitted |
plain clone, .git inside the workspace |
workspace-write |
identical failure |
| plain file in the workspace | workspace-write |
writable |
worktree + writable_roots=["<main>/.git"] |
workspace-write |
works |
| worktree | danger-full-access |
works |
Note codex sandbox itself defaults to read-only, so any probe with it must pass -c 'sandbox_mode="workspace-write"' or it proves nothing.
This is not worktree-specific: a plain clone fails the same way, so it affects any project using the codex driver, not just sequant's isolation model.
Fix
Pass the repo's git dir as a writable root whenever the resolved sandbox mode is workspace-write:
codex exec … -c 'sandbox_workspace_write.writable_roots=["<git-common-dir>"]' …
git rev-parse --git-common-dir gives the right path in both cases — the local .git for a normal checkout, the main repo's .git for a worktree (where the index actually lives). Derive it from the phase cwd at spawn time.
Points worth deciding in review:
- Merge with, rather than overwrite, any
writable_rootsa user set viarun.codex.extraArgs. - Skip it under
read-only(nothing to write) and underdanger-full-access(already unrestricted). - A repo whose git dir is elsewhere entirely (
GIT_DIR, submodules) resolves through the same command, so no special case needed.
Why not the alternatives
sandboxMode: "danger-full-access"works today and is a fine local workaround, but it removes the sandbox entirely. Sequant's guard hooks were designed to run inside a sandbox, not to replace one.- Clone instead of worktree does not help — verified above,
.gitis excluded wherever it sits.
Related
#1058 (driver core) · #1060 (gate, blocked by this) · #1032 (the guard that saved the uncommitted work)
Activity
fix(#1076): pass the git dir as a codex writable root so phases can c…
fix(#1079): enable network access for codex workspace-write phases (#…
docs(codex): reference page and troubleshooting, changelog backfill, …