Skip to content

fix: prevent merge conflicts and improve parallel agent isolation#132

Open
BasselBlal wants to merge 41 commits into
michaelshimeles:mainfrom
BasselBlal:fix/parallel-execution-reliability
Open

fix: prevent merge conflicts and improve parallel agent isolation#132
BasselBlal wants to merge 41 commits into
michaelshimeles:mainfrom
BasselBlal:fix/parallel-execution-reliability

Conversation

@BasselBlal
Copy link
Copy Markdown
Contributor

@BasselBlal BasselBlal commented Jan 28, 2026

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:

  1. src/execution/parallel.ts:

    • Fix: Refactored runtime file filtering to use the centralized DEFAULT_IGNORED list from sandbox.ts.
    • Reason: Replaces ad-hoc path checks with a robust, case-insensitive logic that correctly filters broad patterns like .ralphy (entire folder), matching sandbox creation logic.
  2. src/execution/sandbox-git.ts:

    • Fix: Replaced catch-all git staging with a two-phase staging process using a hardened safeGitAdd helper:
      1. Batching: Processes files in chunks of 20 to prevent ENAMETOOLONG errors on Windows.
      2. Ignore Filtering: Pre-checks files with git check-ignore to prevent errors from git adding ignored files (e.g. .env, .turbo).
      3. Retries: Automatically retries on index.lock contention to handle high-concurrency parallel execution.
      4. Two-Phase Strategy: First stages explicitly tracked files, then catches untracked files (e.g. composer installs) via git status, providing redundancy against missed files.
    • Reason: The previous git add . approach was fragile, and standard git add crashed on large file sets or locked repos. The new robust approach guarantees data integrity even under heavy parallel load.
  3. src/execution/sandbox.ts:

    • Fix: Added DEFAULT_IGNORED to include the entire .ralphy directory and improved matchesPattern regex escaping.
    • Reason: Agents do not need access to the .ralphy folder (config is loaded by the runner), preventing infrastructure pollution. Added comprehensive unit tests (sandbox.test.ts).
  4. src/execution/prompt.ts:

    • Fix: Removed instructions to update progress.txt.
    • Reason: Eliminates race conditions where agents attempted to modify the runner's tracking file.

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.

Loading
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.

2 participants