Metadata-Version: 2.4
Name: lattice-commit
Version: 0.1.0
Summary: Incremental commit for LLM code repair — breaks the multi-file wall
Project-URL: Homepage, https://pypi.org/project/lattice-commit/
Author: Abiogenic
License: MIT
License-File: LICENSE
Keywords: automated-repair,code-repair,incremental-commit,llm,testing
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Topic :: Software Development :: Quality Assurance
Classifier: Topic :: Software Development :: Testing
Requires-Python: >=3.10
Description-Content-Type: text/markdown

# 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

```python
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)

```bash
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

```python
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
