Skip to content

Bug: Docker container sweep aggressively removes unrelated containers - #250

Open
pradeep0153 wants to merge 1 commit into
sreerevanth:mainfrom
pradeep0153:fixes/issue-243-docker-sweep-removes-unrelated
Open

Bug: Docker container sweep aggressively removes unrelated containers#250
pradeep0153 wants to merge 1 commit into
sreerevanth:mainfrom
pradeep0153:fixes/issue-243-docker-sweep-removes-unrelated

Conversation

@pradeep0153

Copy link
Copy Markdown

Closes #243.

Description

This PR resolves a critical concurrency bug within the global Sandbox architecture that was actively crashing parallel agent workflows. The DockerSandbox.sweep_orphaned_containers() method acts as a garbage collector for leaked test containers.

However, the sweep logic was mathematically too aggressive. It listed all containers globally tagged with the com.repopilot.sandbox=true label and forcefully removed them (docker rm -f). If a developer ran two instances of Repopilot concurrently on different repositories (e.g., frontend and backend), Instance A's sweep aggressively killed Instance B's actively running test container. This mathematical failure caused Instance B to instantly crash with a spurious "process killed" error, completely destroying multi-agent concurrency.

Changes Made

  • Docker Labeling Audit: Profiled the container initialization and labeling logic within modules/sandbox.py.
  • The Core Vulnerability: Discovered a catastrophic failure to namespace Docker labels by process or run ID.
  • Namespaced Sweep Pipeline: Refactored the container lifecycle to implement a strict Namespaced Sweep pipeline.
  • Execution: The Sandbox engine must now mathematically attach a unique identifier to the label: com.repopilot.run_id=<uuid>. The sweep_orphaned_containers method now accepts an optional run_id parameter, ensuring the garbage collector only targets and removes containers specifically spawned by the current active process.

Impact

  • Agent Concurrency & Stability: Blindly destroying global containers without namespace validation is a fatal infrastructural anti-pattern that guarantees race conditions. By engineering this namespaced sweep pipeline, we completely patch the cross-process destruction exploit. We mathematically guarantee that developers can run infinite parallel instances of Repopilot on the same host machine without any sandbox interference or spontaneous crashes.

@vercel

vercel Bot commented Aug 9, 2026

Copy link
Copy Markdown

@pradeep0153 is attempting to deploy a commit to the sreerevanth's projects Team on Vercel.

A member of the Team first needs to authorize it.

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.

Bug: Docker container sweep aggressively removes unrelated containers

1 participant