Skip to main content

Lattice Commit

A git-native checkpoint layer for test-gated AI code repair.

Lattice Commit wraps an LLM repair loop with a simple rule: commit only when the test signal improves, and reset when it does not. The goal is to preserve partial progress across multi-file fixes instead of throwing away a good change because another bug still fails.

This repository is the project home for the published package: the research extract, examples, tests, and the distribution layer. The package itself is on PyPI: pip install lattice-commit.

Status

  • Open-source package: alpha — lattice-commit 0.1.0 on PyPI, 0.1.1 staged here
  • Core behavior: git commits for improvements, git reset --hard HEAD for regressions
  • Safety default: refuses to run unless the workspace is a clean git repository root
  • Audit trail: JSONL run logs under .git/lattice-commit/runs/
  • Evidence: synthetic multi-file repair benchmark, 986+ trials
  • Next evidence target: real-repo validation and reproducible benchmark bundle

The failure mode

The motivating benchmark studied a one-file-at-a-time edit/test/revert loop. In that setup, the bare loop solved one-file bug sets but failed when fixes had to accumulate across multiple files: a failed later test run reverted earlier useful work. Lattice Commit changes the state boundary from "all-or-nothing per cycle" to "keep monotone test improvements."

Scenario Bare loop Lattice Commit
Bugs isolated in one file Solved in benchmark Solved in benchmark
Fixes required across 2+ files Failed in benchmark Solved in benchmark

The current claim is deliberately scoped: this demonstrates a structural failure mode in the tested loop. It is not yet a universal claim about every coding agent, repository, model, or test runner.

Install

pip install lattice-commit

Use it

Python library

from lattice_commit import incremental_repair

result = incremental_repair(
    workspace="./my_project",
    test_cmd=["python", "-m", "pytest", "-q"],
    llm_fix=my_fix_function,
    max_cycles=30,
)

print(result)
print(result.run_log)

The callback signature is:

def my_fix_function(filepath, content, error_output):
    return complete_replacement_content_or_none

CLI with Ollama

lattice-commit --workspace ./my_project --test-cmd "python -m pytest -q"
lattice-commit --workspace ./my_project --test-cmd "python -m pytest -q" --majority-vote 3

The CLI uses a local Ollama model by default. It expects a clean git repo and prints the run-log path after completion.

Safety model

Lattice Commit now uses real git operations:

  • It verifies workspace is the repo root.
  • It refuses dirty or untracked files unless --allow-dirty / allow_dirty=True is passed.
  • It creates commits with messages like lattice-commit: checkpoint cycle 3.
  • It stages only the selected repair file for each checkpoint.
  • It rolls back non-improving edits with git reset --hard HEAD plus git clean -fd.
  • It records lifecycle events in .git/lattice-commit/runs/*.jsonl.

Run it on a branch or throwaway clone until the behavior has been validated on your project.

Research

The public research extract is in PAPER.md. It describes the synthetic multi-file wall result and the boundary-mechanism framing. Claims in this repo should stay inside the evidence boundary:

  • OK: "986+ synthetic trials"
  • OK: "tested on llama3.1:8b, qwen2.5-coder:7b, and qwen2.5-coder:14b"
  • OK: "commit-on-improvement fixed the tested one-file-proposal loop"
  • Avoid: "works with any LLM and any test suite"
  • Avoid: "all major coding agents silently throw away good fixes"
  • Avoid: "production SaaS features are already shipped"

Development priorities

  1. Publish a reproducible benchmark bundle.
  2. Validate the mechanism on real repositories with known multi-file bugs.
  3. Improve test-result parsing beyond pytest-style output.
  4. Add a dry-run/report mode before editing files.
  5. Ship one honest integration recipe that has been exercised end to end.

Files

License

MIT

Metadata

Release files for lattice-commit 0.1.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for lattice-commit 0.1.1
File Size Uploaded
lattice_commit-0.1.1.tar.gz 32.0 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for lattice-commit 0.1.1
File Interpreter ABI Platform
lattice_commit-0.1.1-py3-none-any.whl Python 3 none any Details

Total release size: 47.8 kB

Release files / lattice_commit-0.1.1.tar.gz

Download URL lattice_commit-0.1.1.tar.gz
Size 32.0 kB
Tags Source
SHA-256 checksum
How to use checksums
1f70cb1e6a26480e82eaa6a69c065ccec1d97e60e3cc6e59322e776cab365a84
BLAKE2b-256 checksum
How to use checksums
37db0e35165f53d299af7627eada2de874959b15bd4a1f70d50c2368c3761299
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.14.3

Release files / lattice_commit-0.1.1-py3-none-any.whl

Download URL lattice_commit-0.1.1-py3-none-any.whl
Size 15.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
13f75a87db00ca3f6e21a061b7461628c2a9919273d146a484e2f9a4395c0bad
BLAKE2b-256 checksum
How to use checksums
1b8a46b5802e69f9f7cda27241dd5a51680c38d9ededf824e0046d97da28e54a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.14.3

Release history Release notifications | RSS feed

This release

0.1.1 This release

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page