# tdd-repair smoke verification — 2026-06-22

End-to-end verification of `plugins/ruflo-testgen/scripts/tdd-repair/tdd-repair.mjs`
+ `mcp__claude-flow__testgen_tdd_repair`.

## Setup

```js
// /tmp/tdd-repair-smoke/add.mjs — INTENTIONALLY BUGGY
export function add(a, b) {
  return a - b;        // bug: should be a + b
}
```

```js
// /tmp/tdd-repair-smoke/add.test.mjs
import { test, expect } from 'vitest';
import { add } from './add.mjs';
test('add(2, 3) === 5',   () => { expect(add(2, 3)).toBe(5);   });
test('add(10, 7) === 17', () => { expect(add(10, 7)).toBe(17); });
```

## Pre-repair

```
$ npx vitest run add.test.mjs
Test Files  1 failed (1)
     Tests  2 failed (2)
```

## Invocation

```bash
node plugins/ruflo-testgen/scripts/tdd-repair/tdd-repair.mjs \
  --repo /tmp/tdd-repair-smoke \
  --test add.test.mjs \
  --test-command "npx vitest run add.test.mjs" \
  --confirm
```

Headless `claude -p` spawned with `--allowedTools Read,Edit,Bash`,
`--max-budget-usd 5.00`, `--permission-mode acceptEdits`, `--model haiku`.

## Post-repair

```js
// add.mjs — AFTER tdd-repair
export function add(a, b) {
  return a + b;        // fixed
}
```

```
$ npx vitest run add.test.mjs
Test Files  1 passed (1)
     Tests  2 passed (2)
```

## Receipts

```json
{
  "success": true,
  "data": {
    "repaired": true,
    "attemptsTaken": 1,
    "mode": "test-driven",
    "before": { "passed": false, "exitCode": 1 },
    "after":  { "passed": true,  "exitCode": 0, "durationMs": 367 }
  }
}
```

## What this proves

- Pre-flight rejects already-passing tests (verified separately by re-running on the fixed source — exits 2 with `test-already-passes`).
- Headless `claude -p` invocation with capability-restricted toolset works.
- The test's exit code IS the fitness function — no LLM-as-judge, no separate scorer.
- The wrapper preserves the user's `--test-command` verbatim, so any test runner that exits non-zero on failure works (vitest, jest, pytest, go test, cargo test, etc.).

## What this does NOT prove

- Real-world repair success rate on novel bugs (this is a known-trivial bug).
- Behavior on multi-file refactors.
- Cost on harder bugs (Haiku at $0 for this trivial fix; real bugs land $0.10–$2.00 in expected range).
- SWE-Bench Lite end-to-end (requires Docker; out of scope for this smoke).

Next validation step (deferred): once Docker is available, drive against MicroSWE-5
(5 astropy SWE-Bench Lite instances) and persist per-instance receipts.
