Skip to content

bug(codex): every phase fails to commit — workspace-write excludes .git, so git add/commit are denied #1076

Closed

Description

@admarble

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_roots a user set via run.codex.extraArgs.
  • Skip it under read-only (nothing to write) and under danger-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, .git is excluded wherever it sits.

Related

#1058 (driver core) · #1060 (gate, blocked by this) · #1032 (the guard that saved the uncommitted work)

Activity

  1. added
    bug
    on Sep 16, 2026
  2. added a commit that references this issue on Sep 16, 2026
  3. added 2 commits that reference this issue on Sep 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions