Skip to content

Replace git worktrees with local clones for complete agent isolation#153

Merged
that-github-user merged 1 commit intomainfrom
fix-136-clone-isolation
Mar 29, 2026
Merged

Replace git worktrees with local clones for complete agent isolation#153
that-github-user merged 1 commit intomainfrom
fix-136-clone-isolation

Conversation

@that-github-user
Copy link
Copy Markdown
Owner

Summary

Replace git worktree add with git clone (local, hardlinks) for agent isolation.

Root cause: Agents discover the main repo via .git pointer files and run destructive git worktree commands. All mitigations (locks, backups, gc.auto=0, prompt constraints) failed.

Fix: Local clones have fully independent .git directories. No shared metadata. No path to main repo. Near-zero disk overhead via hardlinks.

Verified: 3/3 Opus agents on our own repo captured diffs successfully. Zero ENOENT errors. 89% convergence.

Change type

  • Bug fix

How to test

npm test  # 250 tests pass
thinktank run --attempts 3 --model opus -t "npm test" "review README.md"
# All agents should show file changes — no getDiff errors

Breaking changes

  • Internal: worktree-based isolation replaced with clone-based. No user-facing changes.

🤖 Generated with Claude Code

Root cause: agents with Bash access discover the main repo via worktree
.git pointer files, then run git worktree commands that destroy other
agents' metadata. Locks, backups, gc.auto=0, and prompt constraints
all failed because agents are creative at finding the main repo.

Fix: use plain git clone instead of git worktree add. Local clones use
hardlinks (near-zero extra disk), have fully independent .git directories,
and share no metadata with the main repo or other clones. An agent can
rm -rf .git, git init, or run any git command without affecting anything
outside its own clone.

Verified: 3/3 Opus agents on our own repo captured diffs successfully.
Zero ENOENT errors. 89% convergence. The getDiff bug is fixed.

Research: evaluated --shared (alternates risk), --dissociate (unnecessary
overhead), worktree hybrid (complexity). Plain local clone wins on all
axes: isolation, speed (0.1s), disk (hardlinks), and simplicity.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@that-github-user that-github-user merged commit 9620988 into main Mar 29, 2026
4 checks passed
@that-github-user that-github-user deleted the fix-136-clone-isolation branch March 29, 2026 19:19
that-github-user pushed a commit that referenced this pull request Mar 29, 2026
…ments'

We switched from worktrees to clones in #153 but the user-facing
messages still said 'worktrees'.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
that-github-user added a commit that referenced this pull request Mar 29, 2026
…ments' (#158)

We switched from worktrees to clones in #153 but the user-facing
messages still said 'worktrees'.

Co-authored-by: unknown <that-github-user@github.com>
Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant