Git checkpoints for test-gated AI code repair.
Lattice Commit wraps a one-file-at-a-time LLM repair loop with a simple boundary: commit when tests improve, reset when they do not. The goal is to preserve partial progress across multi-file fixes.
The Scoped Claim
In a synthetic Python benchmark, the bare edit/test/revert loop solved one-file bug sets and failed when required fixes crossed file boundaries. Commit-on-improvement preserved useful intermediate fixes in that tested loop.
| Benchmark setup | Bare loop | With checkpoints |
|---|---|---|
| Fixes contained in one file | Solved | Solved |
| Fixes required across 2+ files | Failed | Solved |
This is not yet a production guarantee. It is an alpha mechanism with synthetic evidence. Real-repo validation and a public reproducibility bundle are the next development milestones.
The Mechanism
best_passing = count_passing_tests()
for cycle in range(max_cycles):
fix = llm.propose_fix(test_output)
apply(fix)
current = count_passing_tests()
if current > best_passing:
git_commit("lattice-commit: checkpoint")
best_passing = current
else:
git_reset_hard_head()
Install
pip install lattice-commit
CLI usage with a local Ollama-backed fixer:
lattice-commit --workspace ./your_repo --test-cmd "python -m pytest -q"
Python API:
from lattice_commit import incremental_repair
result = incremental_repair(
workspace="./your_repo",
test_cmd=["python", "-m", "pytest", "-q"],
llm_fix=your_fix_function,
max_cycles=20,
)
print(result)
print(result.run_log)
Safety Defaults
By default, the workspace must be a clean git repository root.
Improving selected-file changes become git commits with `lattice-commit:` messages.
Non-improving edits are rolled back with `git reset --hard HEAD` plus `git clean -fd`.
JSONL events are written under `.git/lattice-commit/runs/`.
Roadmap
- Publish the reproducible benchmark bundle.
- Validate on real repositories with known multi-file bugs.
- Add broader test-output parsers beyond pytest-style output.
- Build dry-run/report mode before edits.
- Test one integration recipe end to end before calling it supported.