agent-orchestrator icon indicating copy to clipboard operation
agent-orchestrator copied to clipboard

bug(worktree): worker git config and remotes leak into the human's main checkout (shared .git-common-dir)

Open homeshrawat opened this issue 3 months ago • 3 comments

Summary

Worker worktrees share the human's main checkout .git directory, so anything a worker writes to repo-level git state — git remote add, git config --local — lands in the human's primary working repository, not in the worker's isolated worktree.

Reproduction

From a worker worktree:

$ git -C ~/.ao/data/worktrees/<project>/<session-id> rev-parse --git-common-dir
/Users/<user>/Documents/agent-orchestrator/.git

Then, in the worker worktree:

$ git remote add fork https://github.com/<someone>/agent-orchestrator.git

And in the human's main checkout:

$ git -C ~/Documents/agent-orchestrator remote -v
fork    https://github.com/<someone>/agent-orchestrator.git (fetch)
fork    https://github.com/<someone>/agent-orchestrator.git (push)
origin  https://github.com/Untrivial-ai/agent-orchestrator.git (fetch)
origin  https://github.com/Untrivial-ai/agent-orchestrator.git (push)

The remote the worker added is now in the human's repo. Same applies to git config --local, since worktrees share config unless extensions.worktreeConfig is enabled.

Observed impact

A worker that could not push to origin forked the repository to an unrelated account and ran git remote add fork <that account>. The remote persisted in the human's main checkout after the worker session was terminated, silently pointing at a third-party fork. A subsequent git push fork from the human's own repo — by them or by another agent — would have pushed to that account.

This undercuts the isolation guarantee of per-session worktrees: file changes are isolated, but repo-level git configuration is shared and writable by every worker.

Suggested fixes

  1. Set extensions.worktreeConfig = true on the repo and have workers write config with git config --worktree, so worker-scoped settings stay worktree-local.
  2. Treat git remote add / git remote set-url in a worker as a policy-gated operation (see the guardrails issue), or scope pushes to explicit URLs instead of named remotes.
  3. On session teardown, diff repo-level git config/remotes against a snapshot taken at spawn and either revert or report worker-introduced entries.

At minimum, worker-introduced remotes should be reported at teardown rather than left silently in the human's checkout.

Environment

  • macOS (darwin 23.6.0), cursor harness worker
  • Repo at 3934bc86a

homeshrawat avatar Aug 05 '26 23:08 homeshrawat

Thanks for contributing to Agent Orchestrator.

This issue is being picked up by the current external contributor on-call pair:

  • @illegalcall
  • @somewherelostt

If someone is already working on this, please continue as usual. The on-call pair is added for visibility, tracking, and support, not to take over the work. If you need help with review, direction, reproduction, or next steps, please tag @illegalcall and @somewherelostt here.

For faster context or live questions, you can also join the AO Discord.

Join the session here: https://discord.gg/H6ZDcUXmq

Come by if you want to see what is being built, ask questions, or just hang around with the community.

somewherelostt avatar Aug 06 '26 15:08 somewherelostt

Assigned to @vanshx999

Rishet11 avatar Sep 14 '26 22:09 Rishet11

Closing: this was fixed by merged #5442 (worktree git-config isolation). The PR body's Fixes reference didn't trigger auto-close due to escaped characters; closing manually.

OrcInc avatar Sep 23 '26 21:09 OrcInc