Skip to content

Heal candidates in parallel in the pytest plugin #72

Description

@Johin2

Problem

The pytest plugin heals candidates one at a time:

https://github.com/Johin2/self-heal/blob/main/src/self_heal/pytest_plugin.py#L127-L131

Each candidate is an independent, network-bound LLM round-trip, often several attempts deep. A suite with eight @pytest.mark.heal failures pays all eight sequentially, so a run that could take one round-trip's wall clock takes eight. This is the difference between --heal being something you run on every red suite and something you run when you have a coffee break.

Proposal

Run candidates concurrently with a bounded worker pool.

  • --heal-workers N (default something conservative like 4, 1 restores today's behavior).
  • Use threads: the work is I/O-bound on the provider, and the existing async proposer paths can be driven from a thread pool without restructuring the loop.
  • Keep terminal output deterministic by buffering each candidate's report and flushing in the original candidate order, not completion order.

Acceptance criteria

  • Candidates are healed concurrently up to the worker limit.
  • Reported output ordering is identical to the sequential run.
  • --heal-apply writes are serialized; two candidates in the same file must not race on the patch.
  • A failure in one candidate cannot abort the others.
  • --heal-workers 1 is byte-identical to current behavior.

Notes

The apply-path serialization matters more than it looks: with #58 landed, two failing methods in one class are two candidates pointing at the same file.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requestpytest-pluginRelated to the pytest plugin (@pytest.mark.heal, --heal flag)

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions