bug(worktree): worker git config and remotes leak into the human's main checkout (shared .git-common-dir)
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
- Set
extensions.worktreeConfig = trueon the repo and have workers write config withgit config --worktree, so worker-scoped settings stay worktree-local. - Treat
git remote add/git remote set-urlin a worker as a policy-gated operation (see the guardrails issue), or scope pushes to explicit URLs instead of named remotes. - 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
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.
Assigned to @vanshx999
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.