Skip to content

Handle concurrent workspace git operations safely #7

@chenhaot

Description

@chenhaot

Both worker.py and scheduler.py operate on the same repo checkout at workspace_dir/<repo>. The scheduler's _review_code (scheduler.py:110-112) calls clone_repo then checkout_pr_branch, while work_on_issue (worker.py:29-30) calls clone_repo then create_branch — all on the same filesystem path. If the scheduler fires while a worker task is running, they will corrupt each other's git state.

clone_repo itself is also not safe for concurrent use: it does git checkout main && git pull on an existing repo (github.py:174-179), which will fail or cause corruption if another process is mid-operation.

Fix: Use per-repo asyncio locks to serialize git operations, or use separate working directories for each operation (e.g., workspace_dir/<repo>/<branch> or git worktrees). The latter approach is more robust and allows true parallelism across different tasks.


Identified by minbot code review

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions