Skip to content

Codex sandbox still blocks git commits in managed worktrees (live miss of #847) #1160

Closed

Description

@currentbits

Live incident (2026-09-09)

Codex thread 37c370d1-024b-4ca7-812e-24beabfe17e5 (GPT-6 Astra) implemented #935 (failed thread-notes saves discard the typed draft). Worker 9c1d4991-c4c9-473b-94ba-0119bbbf7610 finished on branch coder/fork-failed-thread-notes-saves-discard-t-9c1d49 at 3b54764e. The user approved thread_merge.

Two Codex sandbox / landing failures then happened in the same run. This is a live miss of closed #847, not a new product area.

1. git add / git commit still fail under workspace-write

After the merge landed in the wrong tree (below), Codex applied the notes-save patch in the session checkout, ran the eight notes tests plus typecheck, and then could not commit:

These local changes remain uncommitted because the sandbox blocks Git index writes.

That is the same linked-worktree failure #847 already described. A Solenta managed worktree's .git file points outside cwd:

cwd:
/Users/willem/Library/Application Support/Solenta/worktrees/<threadId>

.git:
gitdir: /Users/willem/code/coder/.git/worktrees/<threadId>

git rev-parse --git-common-dir:
/Users/willem/code/coder/.git

codex exec --sandbox workspace-write only allows writes in cwd. git add / git commit need to create index.lock in the resolved gitdir, which is under the host repo. Historical error from the original #847 draft:

fatal: Unable to create
'/Users/willem/code/coder/.git/worktrees/<id>/index.lock':
Operation not permitted

#847 is plan:done. electron/codexWorkspaceWrite.js emits sandbox_workspace_write.writable_roots for that gitdir plus shared objects / refs / logs, and electron/test/codex.test.js asserts the flag is on the argv. A live Codex session on 2026-09-09 still could not write the index.

Likely remaining holes (do not assume which without a repro):

  • The running app never passed writable_roots (cwd used for the flag was the project checkout, not the linked worktree).
  • The flag is present but Codex still denies index.lock (seatbelt / TOML quoting / incomplete roots).
  • Permission mode mapped to read-only (plan) so codexWorkspaceWriteArgs returned [].

2. Same session: thread_merge committed onto coder-release-build main

Codex reported:

The merge tool landed be1b6006 on main in coder-release-build, rather than the current branch.

Confirmed on disk after the run:

checkout HEAD branch
~/code/coder-release-build be1b6006 main
~/code/coder 9fc8645a coder/notes-save-reject-935
Solenta worktree for this follow-up thread b1b499b9 coder/fork-failed-thread-notes-saves-discard-t-03fc27

thread_merge is supposed to land on the lead's worktree branch, or on the project checkout's current branch only when the lead has no managed worktree (electron/orchServer.js: intoPath = self.worktreePath || projectOf(self)?.path). Landing on ~/code/coder-release-build main means the merge destination was the configured project checkout, not the session the user was looking at.

This is the same class of cwd / worktreePath mismatch that would also skip writable_roots (those roots are computed from thread.worktreePath || project.path). Related history: #614 (workers landing onto main with no user say, already gated), #786 (stale coder-release-build main).

Current orchServer.js requires expectedPath + expectedBranch and refuses a mismatch. The live merge still wrote be1b6006 onto that main, so either the running build did not yet enforce those fields, or Codex passed the project checkout / main as the approved destination while its own cwd was elsewhere.

Impact

Expected

  • In a Solenta-managed linked worktree, Codex workspace-write can git add, git commit, and git status until clean.
  • writable_roots is computed from the same cwd Codex exec actually uses, including Application Support/Solenta/worktrees/<threadId>.
  • thread_merge lands on that session's worktree and current branch, or refuses, and never silently commits onto ~/code/coder-release-build main.
  • A regression test actually runs git commit inside the sandbox (argv inspection for writable_roots was not enough).

Related

Activity

  1. added
    plan:todo
    plan:doing
    plan:done
    and removed
    plan:todo
    plan:doing
    on Sep 9, 2026
  2. currentbits commented on Sep 9, 2026

    @currentbits
    OwnerAuthor

    Fixed on coder/fork-failed-thread-notes-saves-discard-t-03fc27 at 07aab234.

    Codex workspace-write carves .git / gitdir: out as read-only under cwd. codexWorkspaceWritableRoots now always grants this checkout's gitdir (standalone included) plus linked-worktree objects/refs/logs. Live codex sandbox test outside /tmp: git add fails without those roots, git add+commit succeed with them (macOS Codex 0.153.4).

    thread_merge destination mismatch (expectedPath / expectedBranch) was already in this tree; orch-merge tests still pass. packed-refs.lock in the common dir root still EPERM; commit succeeds via loose refs.

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

    plan:done

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions