-
Notifications
You must be signed in to change notification settings - Fork 258
fix: prevent merge conflicts and improve parallel agent isolation #132
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
fix: prevent merge conflicts and improve parallel agent isolation #132
Conversation
- Add robust file filtering to exclude .ralphy, progress.txt, and nul from agent commits - Remove contradictory prompt instruction for updating progress.txt - Add DEFAULT_IGNORED list to sandbox creation to prevent infrastructure file copying
|
@BasselBlal is attempting to deploy a commit to the Goshen Labs Team on Vercel. A member of the Team first needs to authorize it. |
Greptile OverviewGreptile SummaryThis PR successfully addresses parallel agent isolation by preventing infrastructure file conflicts through centralized ignore patterns and a robust two-phase git staging process. Key Improvements
ArchitectureThe filtering logic is applied consistently across three critical points:
The two-phase staging approach (Phase 1: explicit filtered files, Phase 2: untracked files from Confidence Score: 4/5
Important Files Changed
Sequence DiagramsequenceDiagram
participant Runner as Main Runner
participant Agent as Parallel Agent
participant Sandbox as Sandbox (sandbox.ts)
participant Git as Git Operations (sandbox-git.ts)
participant Filter as File Filter (parallel.ts)
Runner->>Agent: Execute task in parallel
Agent->>Sandbox: createSandbox(originalDir, sandboxDir)
Sandbox->>Sandbox: Filter items using DEFAULT_IGNORED
Sandbox->>Sandbox: isIgnored(item, DEFAULT_IGNORED, isDir)
Sandbox->>Sandbox: Symlink dependencies (node_modules, .git)
Sandbox->>Sandbox: Copy source files recursively
Note over Sandbox: .ralphy/ directory excluded from sandbox
Sandbox-->>Agent: Sandbox created with isolation
Agent->>Agent: Execute task modifications
Note over Agent: progress.txt instruction removed
Agent->>Filter: getModifiedFiles(worktreeDir, workDir)
Filter->>Filter: Compare file timestamps
Filter-->>Agent: Return modified files list
Agent->>Filter: Filter files using DEFAULT_IGNORED
loop For each modified file
Filter->>Filter: Check directory patterns (e.g., ".ralphy/")
Filter->>Filter: Check basename patterns (e.g., "nul", "*.log")
Filter->>Filter: matchesPattern(baseName, pattern)
end
Note over Filter: Infrastructure files filtered out
Filter-->>Agent: Return filtered files
Agent->>Git: commitSandboxChanges(filteredFiles)
Git->>Git: Create new branch
Git->>Git: Copy filtered files to original dir
Note over Git: Phase 1: Stage explicitly filtered files
Git->>Git: safeGitAdd(git, filesToStage)
Git->>Git: Batch files (20 per batch)
Git->>Git: Filter via git check-ignore
Git->>Git: Retry on index.lock contention
Note over Git: Phase 2: Catch additional files
Git->>Git: git status (find untracked/modified)
loop For each untracked file
Git->>Git: Check against DEFAULT_IGNORED
Git->>Git: Filter infrastructure files
end
Git->>Git: safeGitAdd(git, additionalFiles)
Note over Git: Handles composer/npm installs in symlinked dirs
Git->>Git: git commit
Git->>Git: Return to original branch
Git-->>Agent: Commit successful
Agent-->>Runner: Task completed with branch
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
3 files reviewed, 2 comments
Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
3 files reviewed, 1 comment
Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
3 files reviewed, 1 comment
Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
3 files reviewed, 2 comments
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
3 files reviewed, 2 comments
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
3 files reviewed, 3 comments
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
3 files reviewed, 1 comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
3 files reviewed, 1 comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
3 files reviewed, 2 comments
Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
3 files reviewed, 4 comments
Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
3 files reviewed, 1 comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
3 files reviewed, 2 comments
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
3 files reviewed, 1 comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
3 files reviewed, 2 comments
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
5 files reviewed, 1 comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
3 files reviewed, 2 comments
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
3 files reviewed, 1 comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
3 files reviewed, 1 comment
Additional Comments (1)
Prompt To Fix With AIThis is a comment left during a code review.
Path: cli/src/execution/sandbox-git.ts
Line: 127:127
Comment:
logging `modifiedFiles.length` instead of `filesToAdd.length` - reports incorrect count when some files were filtered by `.gitignore`
```suggestion
logDebug(`Agent ${agentNum}: Committed ${filesToAdd.length} files to ${branchName}`);
```
How can I resolve this? If you propose a fix, please make it concise. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
2 files reviewed, 2 comments
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
5 files reviewed, 1 comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
3 files reviewed, 1 comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
3 files reviewed, 2 comments
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
3 files reviewed, 1 comment
|
I really appreciate the project and hope this gets accepted! |
Change: Implemented robust "Safe Commit" logic using Git's magic pathspecs (git add . ":!.ralphy/progress.txt") to replace fragile file filtering. Why it fixes the issue: Atomicity: Instead of adding files one-by-one (which fails on ignored files) or adding all and then resetting (which is race-prone), this command performs a single atomic operation. It stages everything while excluding the progress log in one nanosecond. Prevents "Dirty Checkout" Errors: By using git add ., we ensure absolute coverage of all agent-generated files (lockfiles, vendor updates, build artifacts). This leaves the working directory 100% clean, solving the "Local changes would be overwritten by checkout" crash. Conflict Prevention: Explicitly excluding .ralphy/progress.txt ensures that local runner logs are never committed to the agent's branch, preventing merge conflicts when integrating parallel work. Graceful Fallback: Added a fallback mechanism that reverts to standard behavior (logging as debug) if the git client is too old to support pathspecs.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
2 files reviewed, 2 comments
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
3 files reviewed, 2 comments
Description:
This PR improves the reliability of parallel agent execution by strictly isolating infrastructure files, preventing merge conflicts, and handling all file changes robustly. It simplifies the commit logic to ensure clean working directories and data integrity.
Key Changes:
src/execution/parallel.ts:DEFAULT_IGNOREDlist fromsandbox.ts..ralphy(entire folder), matching sandbox creation logic.src/execution/sandbox-git.ts:safeGitAddhelper:ENAMETOOLONGerrors on Windows.git check-ignoreto prevent errors fromgit adding ignored files (e.g..env,.turbo).index.lockcontention to handle high-concurrency parallel execution.git status, providing redundancy against missed files.git add .approach was fragile, and standardgit addcrashed on large file sets or locked repos. The new robust approach guarantees data integrity even under heavy parallel load.src/execution/sandbox.ts:DEFAULT_IGNOREDto include the entire.ralphydirectory and improvedmatchesPatternregex escaping..ralphyfolder (config is loaded by the runner), preventing infrastructure pollution. Added comprehensive unit tests (sandbox.test.ts).src/execution/prompt.ts:progress.txt.Result:
Parallel execution now runs cleanly without merge conflicts or "dirty checkout" errors. Infrastructure files are fully isolated, and the commit strategy ensures zero data loss for agent-generated files (including package manager artifacts) while respecting isolation boundaries.