feat: Implement Git worktree-like functionality for multi-agent systems #90
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
This PR implements Git worktree-like functionality for ProllyTree's VersionedKvStore, solving the critical race condition problem in multi-agent systems where multiple instances compete for the same Git repository resources.
Problem Solved
Multiple
VersionedKvStore
instances pointing to the same Git repository would compete for:HEAD
filerefs/heads/
branch referencesThis created race conditions and data corruption in concurrent multi-agent scenarios.
Solution
Implemented a worktree system similar to
git worktree add
that provides:Key Features
🏗️ Core Architecture
🐍 Python Integration
PyWorktreeManager
andPyWorktreeVersionedKvStore
classesVersionedKvStore
Python API🔒 Safety & Isolation
Files Changed
Implementation (1,359+ lines added)
src/git/worktree.rs
: Core worktree implementation (622 lines)src/python.rs
: Python bindings (+202 lines)Cargo.toml
: Added uuid dependencysrc/git/mod.rs
: Export worktree typesTesting & Documentation
python/tests/test_worktree_integration.py
: Comprehensive integration testsdocs/WORKTREE_IMPLEMENTATION.md
: Complete architecture documentationtests/README.md
: Test organization documentationCLAUDE.md
: Usage commands and examplesTest Results
✅ Rust Tests (84/84 passing)
✅ Python Tests (100% passing)
Usage Examples
Multi-Agent Python Pattern
Rust API
Architecture Impact
Before (Race Conditions) ❌
After (Isolated Worktrees) ✅
Performance Characteristics
Breaking Changes
None. This is purely additive functionality that doesn't affect existing APIs.
Migration Path
Existing code continues to work unchanged. Teams can opt-in to worktree functionality for multi-agent scenarios where race condition prevention is needed.
Integration with Multi-Agent Systems
This implementation provides the foundation for safe multi-agent operations:
Future Enhancements
Potential production improvements:
🤖 Generated with Claude Code