Incremental commit for LLM code repair — breaks the multi-file wall
Project description
lattice-commit
Incremental commit for LLM code repair -- breaks the multi-file wall.
LLM code repair fails when bugs span multiple files. The standard edit-test-revert loop throws away successful fixes to file A when file B still has bugs. This 30-line mechanism fixes it: commit on test improvement, rollback to last committed state (not the original).
- 0% -> 100% solve rate at 2+ files (1,200+ trials)
- Works with any LLM and any test suite
- No dependencies beyond Python stdlib
Install
pip install lattice-commit
Python API
from lattice_commit import incremental_repair
result = incremental_repair(
workspace="./my_project",
test_cmd="pytest -q",
llm_fix=my_fix_function, # (filepath, content, error) -> fixed_content
max_cycles=30,
)
print(f"Solved: {result.solved}, Cycles: {result.cycles}, Commits: {result.commits}")
The llm_fix function takes a filepath, its content, and the test error output, and returns the fixed file content (or None to skip).
CLI (requires Ollama)
lattice-commit --workspace ./my_project --test-cmd "pytest -q"
lattice-commit --workspace ./my_project --majority-vote 3 # noise-resistant mode
The CLI uses a local Ollama model (default: qwen2.5-coder:7b) as the LLM fixer.
How it works
for cycle in range(max_cycles):
error = run_tests(workspace)
if no error: return SUCCESS
file, content = llm.propose_fix(error)
write(file, content)
if count_passing() > best_passing:
best_passing = current
commit() # save progress
else:
rollback() # to last commit, not original
That's it. The mechanism preserves partial progress across files. Fix file A, tests improve, commit. Now work on file B from a state where A is already fixed.
Key findings
- The wall is at 2 files, not any number of bugs. 4 bugs in 1 file: 100% bare. 2 bugs in 2 files: 0% bare.
- Model-invariant: tested on llama3.1:8b, qwen2.5-coder:7b, qwen2.5-coder:14b
- Temperature, prompt decomposition, and commit history context have no effect
- Test flakiness breaks it; majority-vote (3x test, median) restores 88%
- A 2,100-line substrate system performs identically to this 30-line version
License
MIT
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file lattice_commit-0.1.0.tar.gz.
File metadata
- Download URL: lattice_commit-0.1.0.tar.gz
- Upload date:
- Size: 7.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
967b221a0ea8256aeef944eb6d88f0c55eb94992688ca563a268d44b745c0e0b
|
|
| MD5 |
bf79c4a71b2c9579427c079ae9c21355
|
|
| BLAKE2b-256 |
5b196d10524dc40c3679ef92ab2f57c6bb76d8ae1619387da8e6286bfd3c74bd
|
File details
Details for the file lattice_commit-0.1.0-py3-none-any.whl.
File metadata
- Download URL: lattice_commit-0.1.0-py3-none-any.whl
- Upload date:
- Size: 8.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0958a5d23ecaa426ac3f9c6889b4c6ab62bbafab2bed0dc81b22f07dd7aa7694
|
|
| MD5 |
e646fdad0c1b862ddfb81ff5462b684c
|
|
| BLAKE2b-256 |
09f9fa5546e0e2ef8a5d28b28b4ac2b41aa4ae50ecb580884728c020fb1e8adc
|