Skip to content

Measure generated test quality, evaluate on two libraries with two models, add research paper - #20

Merged
pro-utkarshM merged 13 commits into
masterfrom
claude/amazing-johnson-ehm81c
Oct 15, 2026
Merged

pro-utkarshM merged 13 commits into
masterfrom
claude/amazing-johnson-ehm81c

Conversation

@pro-utkarshM

@pro-utkarshM pro-utkarshM commented Oct 15, 2026 •

Copy link
Copy Markdown
Member

Summary

This PR adds measurement of Code2Test against the MVP targets in docs/proposal.md, evaluates it on two open-source libraries with two models, fixes what those runs exposed, and adds an arXiv-ready paper with its data. v1 is scoped to Python.

Results (final runs, one per library and model)

Measure inflection, Flash inflection, M3 TinyDB, Flash TinyDB, M3 Target
Components with passing tests 100% (13/13) 100% (13/13) 96% (25/26) 96% (25/26) 70%
Tests passing before any repair 96% (196/205) 85% (147/172) 87% (411/471) 99% (294/297) 80%
Written suite in code2test verify 408/408 326/326 530/531 (1 skipped) 432/432
Mutation score (whole suite) 59% (47/80) 73% (58/80) 78% (62/80) 76% (61/80)
Diagnosis accuracy, known-cause failures 97% (29/30) 100% 100% 100% 75%

Models: MiniMax MiniMax-M3.1-Flash-Preview (Flash) and MiniMax-M3 (M3). Every run met all three targets. Half of inflection's sampled mutants fall in _irregular, which the Flash run tested only by counting inserted rules; most TinyDB survivors change string literals.

What changed

Measurement

  • code2test test --auto records acceptance rate, first-run pass rate, repairs, xfails, drops and reused components in .code2test/metrics.json.
  • New code2test benchmark: mutation score (each single-site mutant against the whole generated suite, plus the mutated component's own tests), and diagnosis accuracy on failures of known cause. Sources are restored byte-exactly, including after SIGTERM or a killed run.

Fixes found with a real model

  • Related project API (signatures only) and module imports in the prompt; up to 16k characters of source.
  • Doubly escaped code repaired only when that makes it compile.
  • Tests run from a temporary directory and must use tmp_path, so they cannot write into the user's repository.
  • Collection errors, per-test syntax errors and skipped tests handled correctly in verification and metrics.
  • 401/403/404 from the model provider stop the run.

Research (research/)

  • paper/: LaTeX paper (tool and experience report), figure, bibliography, Makefile for the PDF and the arXiv bundle. Measured numbers come from generated macros.
  • data/: per run, the generated test suite, inferred intents, metrics, benchmark output and verify log.
  • scripts/: reproduce the runs and regenerate the data and macros.

Docs

  • README rewritten; results from the final runs; quickstart and architecture match the tool.

Test plan

  • pytest: 111 passed
  • Real-model runs on inflection and TinyDB with both models, with verify and benchmark (numbers above)
  • Paper builds without warnings; the arXiv bundle compiles standalone

🤖 Generated with Claude Code

https://claude.ai/code/session_01VGBhCd3VqGRk2KLZg1Tqu2

…curacy)

Every 'code2test test' run now records acceptance rate, first-run pass
rate, repairs, xfails and drops (.code2test/metrics.json) and shows them
against the MVP targets from docs/proposal.md.

'code2test benchmark' measures generated test quality: it injects
single-site mutants into tested functions (always restoring the source)
and reports the share the tests catch, and it scores the diagnosis agent
on failures with known causes (mutated code -> CODE_BUG, deliberately
broken expected values -> TEST_WRONG).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01VGBhCd3VqGRk2KLZg1Tqu2
- Prompts show up to 16k chars of source (was 6k) plus the bodiless API
  of the component's module and the project modules it imports, and ask
  the model to trace expected values instead of guessing. Found on TinyDB:
  the model built TinyDB(storage=MemoryStorage()) without seeing the API.
- Agents allow 3 output retries (MiniMax sometimes needs a second try
  at valid structured output); generation errors name the component.
- Logs show the actual error line instead of pytest's 'collection failure'.
- Benchmark mutations no longer leave tell-tale '_mutated'/'_wrong'
  markers, and diagnosis cases are sampled across all killed mutants.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01VGBhCd3VqGRk2KLZg1Tqu2
…irs start

Real-model runs on TinyDB showed fixtures with literal \" and \n mixed
into multi-line code, which failed every test in the file on the first run.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01VGBhCd3VqGRk2KLZg1Tqu2

@greptile-apps greptile-apps Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Your trial has ended. Reactivate Greptile to resume code reviews.

… TinyDB

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01VGBhCd3VqGRk2KLZg1Tqu2
No emojis or marketing language; one clear structure (requirements,
installation, model choice, quick start, how it works, command reference,
files written, results, limitations, development). Removes claims the
code does not support (integration test suggestions, editing tests in
the prompt, coverage reports) and a link to a missing document.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01VGBhCd3VqGRk2KLZg1Tqu2
Benchmark:
- Restore mutated sources byte for byte (CRLF files were rewritten) and
  keep an on-disk backup per mutant; files a killed run left mutated are
  restored on the next run, and SIGTERM/SIGHUP now run the restore.
- Don't mutate type annotations (unkillable mutants lowered the score).
- TEST_WRONG probes keep the rest of the file (sibling helpers/fixtures)
  and only count when the changed assertion is what fails.
- A failed diagnosis call is unscored instead of counting as TEST_WRONG;
  an unreachable model keeps the mutation results.
- CODE_BUG cases only when the mutated line is within the source the
  diagnosis agent sees (now 16k chars, was 2k).
- All test files of a component run against its mutants; components
  outside the repo are skipped; --timeout applies to the baseline run;
  per-cause counts exclude unscored cases; empty-string asserts skipped.

Metrics:
- Unchanged re-runs count already-verified components instead of
  reporting 0% acceptance; low-confidence skips are reported separately.
- Skipped tests don't count as passing; acceptance needs a real pass.
- One syntax error no longer hides the first-run result of the other
  tests in its file.
- Rates are n/a, not 0%, when nothing was generated; xfail and passing
  counts follow tests dropped by the whole-suite check.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01VGBhCd3VqGRk2KLZg1Tqu2
…README corrections

The linked docs described Jest/JUnit generation, a template engine, a
sandboxed verifier and Python 3.9, none of which match the code. README:
Google key model selection, --dry-run still calls the model, test file
name for package __init__ modules.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01VGBhCd3VqGRk2KLZg1Tqu2
A TinyDB run left a 'some/path' file in the project: an unrepaired
generated test wrote a relative path. pytest now runs from a throwaway
working directory with --rootdir at the repository (imports, config and
test ids unchanged), and the prompt asks for tmp_path for any file the
code creates.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01VGBhCd3VqGRk2KLZg1Tqu2
Standard mutation testing runs the full suite. Running only the mutated
component's own tests undercounted kills, e.g. inflection's _irregular()
runs at import and its bugs break pluralize/singularize tests: 32 of 34
'survivors' in one run. The per-component number is still reported as a
secondary metric, and only own-test failures become diagnosis cases.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01VGBhCd3VqGRk2KLZg1Tqu2
research/paper: LaTeX source of the paper (tool and experience report),
TikZ pipeline figure, verified bibliography, and a Makefile that builds
the PDF and the arXiv bundle (with main.bbl, since arXiv does not run
BibTeX). Every measured number comes from results.tex, which
collect_results.py generates from the run data; abstract.txt is the
plain-text abstract for the arXiv form.

research/data: for each of the four runs (inflection and TinyDB, MiniMax
Flash and M3) the generated test suite, inferred intents (and whether
the model re-inferred them), run metrics, benchmark output and verify
log. data/development holds the earlier runs cited for run-to-run
variance.

research/scripts: run_experiments.sh reproduces the runs;
collect_results.py builds data/, results.tex and abstract.txt, computing
rates from counts and rounding half up.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01VGBhCd3VqGRk2KLZg1Tqu2
…aper

The results table now shows all four final runs (two libraries, two
models) and explains where the suites are weak. The quickstart sample
output matches the final inflection run, and docs/real_model_run.md is
marked as a record of the first development runs.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01VGBhCd3VqGRk2KLZg1Tqu2
@pro-utkarshM pro-utkarshM changed the title Measure generated test quality; prove it on TinyDB; Python-only v1 Measure generated test quality, evaluate on two libraries with two models, add research paper Oct 15, 2026
@pro-utkarshM
pro-utkarshM merged commit 0bff7c7 into master Oct 15, 2026
2 checks passed
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.

2 participants