Skip to content

[P0] Implement bounded verify→repair self-healing loop #9

Closed

Description

@pro-utkarshM

Problem

The proposal's core innovation is an iterative verification loop that repairs failing tests until pass. Reality: core/generator.py:285-322 runs tests once, records tc.diagnosis, and never applies a fix or re-runs. 'Self-healing' is currently a no-op during generation.

Tasks

  • Add bounded loop in generator phase 3 (e.g. max_repair_iters, default 3).
  • On TEST_WRONG diagnosis: apply diagnosis.suggested_fix, regenerate test file, re-run.
  • On CODE_BUG: flag, stop repairing (do not mutate test to force pass).
  • On INTENT_WRONG: surface for intent revision (interactive) or skip (auto).
  • Track iteration count + final status in VerificationResult.

Acceptance

A deliberately-wrong generated test gets diagnosed, auto-fixed, and passes on re-run within max iters; loop terminates and is unit-tested.

Activity

  1. added this to the v0.1 completion milestone on May 25, 2026
  2. pro-utkarshM commented on Oct 15, 2026

    @pro-utkarshM
    MemberAuthor

    Done on master (code2test/core/generator.py, verify_and_fix). The loop works like this:

    1. Each generated file runs under pytest, and results are matched to individual tests.
    2. Failing tests go back to the model with their real pytest output, for up to max_fix_attempts rounds (default 2), and are re-run each time.
    3. Tests that still fail are diagnosed:
      • CODE_BUG: the test is kept with pytest.mark.xfail and the diagnosis as its reason. It is never edited to force a pass.
      • TEST_WRONG or INTENT_WRONG: the test is dropped in --auto mode. Interactive mode shows the diagnosis and lets the user decide.
    4. A whole-suite check then drops tests that fail only alongside other tests.

    This differs slightly from the plan: repairs use the pytest output directly rather than the diagnosis's suggested_fix, and diagnosis comes after repair. Repair rounds are recorded per file in .code2test/metrics.json, not in VerificationResult.

    Unit tests in tests/test_pipeline.py cover it: test_failing_test_is_repaired_using_failure_output, test_bad_import_is_repaired, test_unfixable_test_suspected_code_bug_is_kept_as_xfail, test_unfixable_wrong_test_is_dropped. Real-model runs are in research/data/.


    Generated by Claude Code

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

    P0Blocker / must fix to run

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions