feat: Add git worktree isolation for concurrent issue handling#3
Open
roger704 wants to merge 1 commit intocoleam00:mainfrom
Open
feat: Add git worktree isolation for concurrent issue handling#3roger704 wants to merge 1 commit intocoleam00:mainfrom
roger704 wants to merge 1 commit intocoleam00:mainfrom
Conversation
Problem: When handling multiple GitHub issues concurrently, they all share the same workspace directory. This causes conflicts when: - Issue coleam00#1 creates a branch and makes changes - Issue coleam00#2 arrives and triggers git cleanup - Issue coleam00#1's uncommitted work is destroyed Solution: Each issue/PR now gets its own isolated git worktree: - /workspace/REPO/ # Base repo (shared git history) - /workspace/REPO-issue-29/ # Worktree for issue #29 - /workspace/REPO-issue-26/ # Worktree for issue #26 Features added: 1. **Worktree per issue** - getOrCreateWorktree() creates isolated worktrees 2. **Retry logic** - 3 attempts with exponential backoff for transient failures 3. **Base repo check** - Detects missing repo after container restart 4. **Always update cwd** - Session always uses correct worktree path 5. **Auto cleanup** - Worktrees cleaned on PR merge/issue close 6. **Stale cleanup** - Worktrees older than 7 days are automatically removed Benefits: - Concurrent work on multiple issues without interference - Disk-efficient (worktrees share git history) - Handles container restarts gracefully - Self-cleaning to prevent disk exhaustion
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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 adds git worktree isolation to allow concurrent handling of multiple GitHub issues without workspace conflicts.
Problem
When handling multiple GitHub issues concurrently, they all share the same workspace directory (
/workspace/REPO/). This causes conflicts:This is especially problematic for agents that take time to complete tasks.
Solution
Each issue/PR now gets its own isolated git worktree:
Features Added
getOrCreateWorktree()creates isolated worktreesBenefits
Changes
getOrCreateCodebaseForRepo()to accept optionalissueNumberparametergetOrCreateWorktree()with retry logiccleanupWorktree()andcleanupStaleWorktrees()closedevents to trigger cleanupcwdto current worktree pathTesting
Tested in production with concurrent issue handling: