Skip to content

Managed worktrees cannot run git add or git commit because their Git metadata is read-only #847

Closed

Description

@currentbits

Problem

The managed worktree itself is writable, but its .git file points to linked
worktree metadata beneath the primary checkout:

cwd:
/Users/willem/Library/Application Support/Solenta/worktrees/15ff9829-4446-44ad-92a2-c4e14e991e05

.git:
gitdir: /Users/willem/code/coder/.git/worktrees/15ff9829-4446-44ad-92a2-c4e14e991e05

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

The sandbox grants write access to the visible worktree but only read access to
its .git entry. Git needs narrow write access to the resolved gitdir and
common object/ref storage.

Attempting to commit the approved design specification failed at the first
write:

fatal: Unable to create
'/Users/willem/code/coder/.git/worktrees/15ff9829-4446-44ad-92a2-c4e14e991e05/index.lock':
Operation not permitted

Solenta later created an automatic coder-checkpoint outside the agent
sandbox. That preserves the diff, but it does not satisfy workflows that
require the agent to make a named commit, hand a commit to another worker, or
finish a branch deliberately.

Impact

  • Agents can edit code but cannot stage or commit it.
  • Skills that require a design/spec commit cannot complete their workflow.
  • Worker-to-worker handoffs using git show <branch>:<path> are blocked.
  • Normal branch completion, merge preparation, and commit verification cannot
    be performed by the session that authored the change.
  • The error appears late, after useful work has already been produced.

Expected behavior

A managed worktree must support ordinary Git operations for its own branch
without granting write access to another worktree or to unrelated files in the
primary checkout.

Suggested fix direction

  • Resolve the worktree's gitdir and git-common-dir before constructing the
    sandbox profile.
  • Grant the minimum Git write paths needed for this worktree's index, locks,
    refs/logs, and object creation.
  • Prefer a narrow Git-operation broker if granting common object-store access
    directly would make the sandbox boundary too broad.
  • Preflight the permission during session startup and report a named degraded
    mode before edits begin.

Acceptance criteria

  • Start an agent in a Solenta-managed linked worktree.
  • Create one file, then run git add, git commit, and git status from the
    agent session.
  • The commit succeeds and the worktree becomes clean.
  • The agent can read its resulting commit with git show.
  • The sandbox still prevents mutation of another worktree's index, HEAD, and
    worktree-specific refs.
  • An integration test uses a real linked-worktree .git pointer; testing only
    a standalone repository is insufficient.


Found while planning live speech-to-text in thread 15ff9829-4446-44ad-92a2-c4e14e991e05 on 2026-09-03. Draft: docs/issue-drafts/2026-09-03-solenta-session-blockers.md.

Activity

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

    @currentbits
    OwnerAuthor

    Implemented on this branch: for Codex workspace-write, Solenta now passes extra sandbox_workspace_write.writable_roots for a linked worktree:

    • this worktree's gitdir (<main>/.git/worktrees/<id>) so index.lock works
    • shared objects, refs, and logs so git commit can write the object and the branch

    The whole common dir is not granted, so a sibling worktree's index/HEAD stay outside the sandbox. Standalone checkouts (.git inside cwd) get no extra roots.

    See electron/codexWorkspaceWrite.js, wired from runner.js and workflow.js.

  3. added
    plan:done
    and removed
    plan:doing
    on Sep 6, 2026
  4. currentbits commented on Sep 6, 2026

    @currentbits
    OwnerAuthor

    Landed. Codex workspace-write now passes sandbox_workspace_write.writable_roots for a linked worktree gitdir plus shared objects/refs/logs (not the whole common dir, not sibling worktrees). Standalone .git-in-cwd needs nothing extra. Independent of the #848 GitHub proxy.

    Source was checkpoint 24745755 on coder/users-willem-library-application-support-b73e11, which never reached origin/main; the later #848 GitHub-proxy rewrite kept only network_access. Restored onto that helper in 118418c6. runner.js and workflow.js pass cwd. Regression: electron/test/codex-workspace-write.test.js and the runner case in electron/test/codex.test.js.

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