Live demo: https://provecode.vercel.app
Status: beta, v0.2.1. Maintenance is paused for a while: issues are read, but replies may be slow. Real-world precision is not yet measured, so a false-alarm report or a missed-weakening report is the most useful contribution.
Tests passed. The 20% cap is gone.
When the same AI agent writes the code and edits the tests that judge it, "all tests pass" stops meaning much. PROVECODE catches the test edits that make a broken change look green. That includes the count-preserving ones, which assertion-counting tools miss. Each edit it catches is tied to the approved requirement that the test was guarding.
# tests/test_pricing.py: one assertion before, one after
- assert apply_discount(100, 0.50) == 80.00
+ assert apply_discount(100, 0.50) >= 0An assertion counter sees no change here. PROVECODE reports:
- S2, blocking. An equality was replaced by a trivial bound, on the test that guards contract condition C1: discount is capped at 20%.
- The reviewers' own check
chk-capfails against the candidate in a no-network Docker sandbox, even though the repository's own tests pass.
The verdict is FAILED.
Tier A, held-out split: 44 injected weakenings and 6 legitimate edits in 6 real repositories. Experimental, injected cases; not real-world performance.
| Held-out | PROVECODE | Count-based baseline (reimplementation) |
|---|---|---|
| Count-preserving weakenings caught | 36/37 (97%, 95% CI 86% to 100%) | 7/37 (19%, 95% CI 9% to 34%) |
| All weakenings caught | 43/44 (98%, 95% CI 88% to 100%) | 14/44 (32%, 95% CI 20% to 47%) |
| Count-reducing weakenings caught | 7/7 (100%, 95% CI 65% to 100%) | 7/7 (100%, 95% CI 65% to 100%) |
| Legitimate edits blocked (PROVECODE) / flagged (baseline) | 0/6 (0%, 95% CI 0% to 39%) | 1/6 (17%, 95% CI 3% to 56%) |
F1 (count-preserving recall above the baseline) is supported on Tier A (exact McNemar p = 3.7e-09).
W17–W19 (tautologies, swallowed assertions, or True) were blind spots by design. Rules S5 and B4, added after those results were seen, now catch 17 of 18, so Tier A recall on them is not an unbiased estimate; Tier A-b below is the fresh test of those rules.
Tier A-u (unittest-style tests, ADR 0009), held-out split: 28 injected weakenings and 12 legitimate edits in 5 other real repositories, frozen before the detector change. Experimental, injected cases; not real-world performance.
| Held-out (Tier A-u) | PROVECODE | Count-based baseline (reimplementation) |
|---|---|---|
| Count-preserving weakenings caught | 20/21 (95%, 95% CI 77% to 99%) | 3/21 (14%, 95% CI 5% to 35%) |
| All weakenings caught | 27/28 (96%, 95% CI 82% to 99%) | 10/28 (36%, 95% CI 21% to 54%) |
| Count-reducing weakenings caught | 7/7 (100%, 95% CI 65% to 100%) | 7/7 (100%, 95% CI 65% to 100%) |
| Legitimate edits blocked (PROVECODE) / flagged (baseline) | 0/12 (0%, 95% CI 0% to 24%) | 1/12 (8%, 95% CI 1% to 35%) |
The same blind spots in unittest form (U13–U14) are now caught in 11 of 12, with the same caveat.
Tier A-b (vacuous and swallowed checks, ADR 0011), held-out split: 22 injected weakenings and 8 legitimate near-misses in 7 further repositories, frozen before the S5/B4 rule code. Experimental, injected cases; the patterns mirror the rules' stated targets, so this shows the rules work as specified, not real-world recall.
| Held-out (Tier A-b) | PROVECODE | Count-based baseline (reimplementation) |
|---|---|---|
| Weakenings caught | 22/22 (100%, 95% CI 85% to 100%) | 0/22 (0%, 95% CI 0% to 15%) |
| Legitimate edits flagged | 0/8 (0%, 95% CI 0% to 32%) | 0/8 (0%, 95% CI 0% to 32%) |
Tier H (harness and test-body weakenings, ADR 0012), held-out split: 47 injected weakenings and 26 legitimate near-misses in 9 further repositories (conftest hooks, pytest config, CI workflows, coverage, dependencies, shadowing modules, and test bodies), frozen before the H1-H7/T1-T5 rule code. Experimental, injected cases; the patterns mirror the rules' stated targets, so this shows the rules work as specified, not real-world recall.
| Held-out (Tier H) | PROVECODE | PROVECODE before ADR 0012 | "Harness file touched" | Count-based baseline |
|---|---|---|---|---|
| Weakenings caught | 44/47 (94%, 95% CI 83% to 98%) | 0/47 (0%, 95% CI 0% to 8%) | 37/47 (79%, 95% CI 65% to 88%) | 0/47 (0%, 95% CI 0% to 8%) |
| Harness weakenings caught | 34/37 (92%, 95% CI 79% to 97%) | 0/37 (0%, 95% CI 0% to 9%) | 37/37 (100%, 95% CI 91% to 100%) | 0/37 (0%, 95% CI 0% to 9%) |
| Test-body weakenings caught | 10/10 (100%, 95% CI 72% to 100%) | 0/10 (0%, 95% CI 0% to 28%) | 0/10 (0%, 95% CI 0% to 28%) | 0/10 (0%, 95% CI 0% to 28%) |
| Legitimate edits flagged | 0/26 (0%, 95% CI 0% to 13%) | 0/26 (0%, 95% CI 0% to 13%) | 19/26 (73%, 95% CI 54% to 86%) | 0/26 (0%, 95% CI 0% to 13%) |
| Browser parity: Pyodide 314.0.8 (Python 3.14.2) matches CPython 3.11 on 642 of 642 cases (Tier A: 168, Tier A-u: 132, Tier A-b: 99, Tier H: 243). |
Full benchmark, method and limitations: the site's Benchmark page, or artifacts/benchmark/tierA.json.
| Semantic weakening rules | S1 comparison weakened (== → >=; approx, abs(a - b) < t or math.isclose looser than default). S2 expected value made trivial (== 80 → >= 0, is not None, len(…) == 2). S3 exception widened (a broader class, or another one added), or match= dropped. S4 parametrize cases removed, or the decorator dropped. S5 check made vacuous (A == A, … or True, assert True, assert (x, "msg")). assert a and b is judged per conjunct. |
| Standard rules (prior art, credited) | B1 test deleted (renames, and moves to another test file in the same change, are recognised). B2 skip, xfail, importorskip or an early-exit guard added (including for _ in []:). B3 assertion removed. B4 assertion failure swallowed (try/except AssertionError: pass, suppress); Ruff has related single-file lints. |
| Test-body rules (ADR 0012) | T1 inputs changed while the asserted value stayed the same. T2 a check delegated to an in-file helper that can never fail, or a helper hollowed out. T3 the function under test monkeypatched or mocked in its own test. T4 a loop or parametrize list emptied or cut down. T5 an exception check replaced by a value check. T1, T3 and T5 are warnings only until their real-world flag rate is reviewed. |
| Harness rules (ADR 0012) | H1 a conftest.py hook that decides outcomes or collection (the published SWE-bench pytest_runtest_makereport exploit), collect_ignore, a process exit, tampering with pytest internals, or an autouse fixture patching the package under test. H2 plugin loading changed. H3 .pth / sitecustomize.py, or a module shadowing the stdlib, pytest or the package under test. H4 test selection narrowed in pytest config in any directory (-k, -m, --deselect, testpaths, python_files, a new higher-precedence or closer config file, filterwarnings = error removed). H5 CI or tox weakened (|| true, continue-on-error, if: false, a tox - prefix, a test step removed or narrowed, paths-ignore over source). H6 coverage weakened. H7 a test dependency removed or pinned down. H1 and H3 block with or without a contract. |
| Contracts | YAML, versioned and human-approved, with a SHA-256 content hash. Tampered or unapproved contracts are rejected. A candidate that edits the contract path is blocked. |
| Verdicts | FAILED > INCONCLUSIVE > VERIFIED, decided by a pure function with no LLM. Missing evidence never becomes a pass, and static analysis alone never yields VERIFIED. |
| Recorded runs | Contract-owned checks and the repo's tests run in Docker: --network none, read-only, non-root, all capabilities dropped, with memory, CPU, process and time limits. Every report carries its SHAs, contract hash and image digest. |
| Live in the browser | The same engine runs in Pyodide in a Web Worker, served from the site itself. Code typed into the page is only parsed, never imported or executed, and analysis is stopped after 2 s. |
Status: beta (0.2.1). It works without any configuration, but real-world precision is not yet measured, so expect some false alarms and please report them. Python projects using pytest or unittest only. Needs Python 3.11 or later and git.
-
Install (from GitHub; the
v0.2.1tag):uv tool install "provecode[cli] @ git+https://github.com/Shriram28Baskar/provecode@v0.2.1#subdirectory=engine" # or with pipx: pipx install "provecode[cli] @ git+https://github.com/Shriram28Baskar/provecode@v0.2.1#subdirectory=engine" # or, in a virtual environment: pip install "provecode[cli] @ git+https://github.com/Shriram28Baskar/provecode@v0.2.1#subdirectory=engine"
-
Check your uncommitted changes before you commit:
provecode guard # exit 0 = ok, exit 1 = blocked, with each finding's before and after provecode guard --staged # only what the next commit contains
-
Gate your coding agent (Claude Code):
provecode install-hooks --claude. When the agent tries to finish with weakened tests, it is told what it weakened and asked to restore it. -
Gate pull requests (GitHub Action). Without a contract, any test-weakening finding fails the check:
# .github/workflows/provecode.yml on: pull_request permissions: contents: read jobs: provecode: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 with: fetch-depth: 0 - uses: Shriram28Baskar/provecode@v0.2.1
See it on a real repository: provecode-action-demo. The PR that loosens the discount-cap test fails the check, and an honest refactor passes it. The repository's own tests pass on both.
-
Or block weakening commits with the pre-commit framework (
.pre-commit-config.yaml):repos: - repo: https://github.com/Shriram28Baskar/provecode rev: v0.2.1 hooks: - id: provecode
When it blocks. Each finding names a rule (S2, B3, H4, ...), the test or file, and the exact lines before and after. If the change is a deliberate requirement change (a test removed on purpose, an expected value changed), say so in review: the finding is a prompt for a human decision, not proof of a bug. If you think a finding is wrong, please report the false alarm. To switch the local hooks off: provecode install-hooks --claude --uninstall. For a stricter, requirement-linked verdict, add an approved contract (below).
Requires Python 3.11 or later and git. Docker is needed only for record.
python -m venv .venv && . .venv/bin/activate # Windows: .venv\Scripts\activate
pip install -e "engine[dev]"
python demo/build_demo.py # deterministic demo repo in demo/.build/checkout
provecode check --repo demo/.build/checkout --base main --head candidate-weakened \
--contract demo/contracts/checkout.v1.yaml # FAILED, exit 1
provecode check --repo demo/.build/checkout --base main --head candidate-legit \
--contract demo/contracts/checkout.v2.yaml --contract-base demo/contracts/checkout.v1.yaml
# INCONCLUSIVE, exit 2 (static only)- Exit codes:
0VERIFIED,1FAILED,2INCONCLUSIVE,3usage or internal error. - Outputs: add
--json report.json --md report.mdto write the report files. - Contracts:
provecode approve <contract.yaml> --by <name>records an approval over the contract's current hash.
provecode rerun --repo . --base main --head HEAD --image provecode-run:local
provecode check --repo . --base main --head HEAD --execute --image provecode-run:local # same, no contract neededThree sealed runs answer one question: does the change still pass the tests that were trusted before it?
Tested on 7 pinned real repositories with the 0.2.0 engine: all VERIFIED, after one network failure during dependency download, which correctly gave INCONCLUSIVE and passed when retried. A sealed run adds about 9–25 s to pytest's own time, plus a one-off dependency download per base. Details and every attempt: ADR 0013, docs/research/data/rerun_real_repos.json.
- A runs base code with base tests: the reference.
- B runs head code with the base tests and harness: the trusted result. Head-only conftests, test modules,
.pthandsitecustomize.pyfiles are removed first. - C runs head code with head tests: what CI would say.
A base test that passes in A and fails in B is reported with its cause:
- X2, the harness hides it (the test is unchanged);
- X3, the test was deleted;
- X4, a weakened test hides it;
- X5, the expectation was edited. With no contract, this alone gives INCONCLUSIVE, never FAILED: the base tests cannot tell an intended behaviour change from a regression, so approve it in a contract;
- X6, an ordinary regression.
Base tests the change stopped collecting are X1.
How the runs are sealed:
- Dependencies come from the base tree only, as wheels.
- Test containers have no network, a read-only root, no capabilities and resource limits.
- Plugin autoloading is off, and only base-declared plugins load.
- A and B run twice, and a disagreement makes a test flaky, never failed.
With no contract, the base tests are the contract (ADR 0013). Contract-owned checks can call the candidate through provecode.isolate, so candidate code never runs in the process that judges it.
# .github/workflows/provecode.yml in your repository
on: pull_request
permissions:
contents: read
jobs:
provecode:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: Shriram28Baskar/provecode@v0.2.1 # or pin to a commit SHA
with:
contract: contracts/checkout.yaml # optional; read from the PR's base commit, so the PR cannot edit it- Failing the PR: without a contract, any test-weakening finding fails the check (
block-on: weakening). With a contract, a FAILED verdict fails it (block-on: failed); setblock-on: weakeningto also fail on ungraded findings, orfail-on-inconclusive: "true"to fail on INCONCLUSIVE. - Where the report appears: the Markdown report is written to the job summary.
- Static only: the Action runs static analysis and never executes PR code.
- Protecting the contract: pair it with CODEOWNERS and branch protection on
contracts/.
provecode guard checks uncommitted test changes, from the working tree or the index. It catches a weakening before it becomes a commit or a PR. It uses the same engine and rules as check, and writes nothing to the repository.
provecode guard # working tree vs HEAD; exit 1 blocks
provecode guard --staged # the index, i.e. what the next commit would contain-
One-command setup:
provecode install-hooks --claude # .claude/settings.local.json (add --shared for settings.json) provecode install-hooks --pre-commit # git pre-commit hook running guard --staged
Existing settings are merged, never overwritten, and a second run changes nothing.
--uninstallremoves only what it added. -
Zero configuration. It works without a contract: any S1–S5, B1–B4, T1–T5 or H1–H7 finding blocks (
--block-on weakening, the default). If.provecode/contract.yamlexists, it is read from the base commit, so editing it in the working tree cannot relax it, and the edit itself blocks. Use--block-on failedto block only on contract-graded FAILED. -
Pre-commit (
.pre-commit-config.yaml). The simplest form isrepo: https://github.com/Shriram28Baskar/provecodewithrev: v0.2.1andid: provecode(step 5 above); pre-commit installs PROVECODE into its own environment. Ifprovecodeis already installed, a local hook avoids that install:repos: - repo: local hooks: - id: provecode name: provecode guard (test weakening) entry: provecode guard --staged language: system pass_filenames: false always_run: true
-
Claude Code (
.claude/settings.json;provecodemust be on the hook'sPATH):{ "hooks": { "SessionStart": [{ "hooks": [{ "type": "command", "command": "provecode guard --hook claude-session-start" }] }], "Stop": [{ "hooks": [{ "type": "command", "command": "provecode guard --hook claude-stop", "timeout": 60 }] }] } }When Claude tries to finish with weakened tests, the Stop hook blocks it. Claude gets the findings, with before and after, as the reason to keep working, and you get a one-line warning. The session's starting commit is recorded outside the repository, so a weakening Claude commits during the session is still caught.
Checked in real headless Claude Code sessions (
docs/research/scripts/claude_hook_e2e.py, one run per scenario). Told to weaken a pytest or a unittest assertion, the agent was blocked (S2, then S3) and restored the test byte for byte. A legitimate expected-value fix and a time-pressured feature fix were not blocked. See ADR 0010. -
Not tamper-proof. An agent with a shell can edit hook settings. The local gate is the early, cheap catch; the PR check, with the contract read outside the candidate, is the enforcement point. Hooks fail open on errors and say so (ADR 0010).
pip install -e "engine[dev]"
python -m pytest engine/tests benchmark/test_benchmark.py # engine and benchmark tests
python -m benchmark.regenerate --check # rebuild Tiers A, A-u and A-b from pinned commits; byte-for-byte compare
python -m benchmark.guard_eval # guard vs commit mode on every case, plus guard latency
python -m benchmark.record_demo # recorded Docker runs (FAILED and VERIFIED)
cd web && npm ci && npm run parity # Pyodide vs CPython on every case
npm run build # site; fails if an artifact doesn't match the manifest
node scripts/serve.mjs & # serves out/ with the production headers
node scripts/e2e.mjs # the demo story in ChromeCI runs the tests on Python 3.11 and 3.13. It also checks the Tier A regeneration byte for byte, the Pyodide parity, the site build and the end-to-end story. The site build fails if any artifact it renders doesn't match artifacts/manifest.json.
| Path | Contents |
|---|---|
engine/ |
The provecode package. The core (analyzer, limits, contract, decide, report, pipeline) is standard library only, and a CI scan forbids exec, eval and LLM imports. git, exec, guard and cli hold the host-specific parts. |
benchmark/ |
Tier A pattern list, pinned sources, case generator, count-based baseline, regenerate, parity |
demo/ |
The checkout scenario: deterministic repo builder, contracts v1 and v2, contract-owned checks |
docker/ |
The recorded-run image, with its base pinned by digest |
artifacts/ |
Generated reports, benchmark results, presets and the manifest. Never edited by hand. |
web/ |
The Next.js static site and the Pyodide worker |
docs/ |
Competitive audit, PRD, architecture, build spec, research report, ADRs 0001–0014 |
spike/ |
The Gate 0 feasibility spike, paused by ADR 0007. Never imported by product code. |
These are kept current. Each is a way to make a broken change look green that PROVECODE does not see today.
- Weakenings in production code. Special-casing the inputs the tests use, or overloading
__eq__so comparisons always pass. Only an independent, executed check (a contract-owned check, or the base branch's tests in a sealed run) can catch these, and that run is not built yet (brief Phase 2). - Dynamic test generation. Tests produced at run time (custom collectors,
pytest_generate_testscomputing cases from data files,load_tests) are analyzed only as far as their source shows. Changes to the data files they read are not analyzed. - Helpers in other files. T2 resolves helpers in the same file only. A check that moves into an imported helper is reported as an
unresolved_helpergap, never as a pass. - CI outside GitHub Actions and tox.
.github/workflows/*.ymlandtox.ini[testenv]commands are read (ADR 0014). GitLab CI, Azure Pipelines,noxfile.pyand Makefiles are not. - Conditions only a run can judge. A
skipifwhose condition is always true without being a constant (sys.version_info < (9,)), or a test madeasync defwith no async plugin installed. - Subdirectory configs in the trusted re-run. Static H4 reads pytest config in any directory (ADR 0014), but the run-B overlay still copies base config files only at the root.
- Indirect test commands. A workflow step that runs tests through a script (
run: scripts/test) is not recognised as a test step. - What the trusted tests never checked. No rule can detect a weakening of a behaviour that no test guarded in the first place.
- Languages other than Python.
- Python only: pytest-style and unittest-style tests.
- Real-world precision: not yet measured. Tier A, A-u, A-b and H cases are injected. Real-world recall (Tier B) and precision (Tier C) need owner labels. How often PROVECODE fires on real, mostly human, commits is measured, as a flag rate rather than precision, in
docs/research/landscape-2026-11.md§1.10 anddocs/research/data/real_history_scan_v2.json(ADR 0012); every flagged commit awaits an owner label (docs/research/scripts/label.py). Reports of false alarms and missed weakenings from real use are welcome. - One author wrote the patterns, the cases and the detector. The patterns and split were committed before the detector; the commit order is recorded in
tierA.json. - The baseline is a reimplementation of published rules, not the original tools.
- VERIFIED means no mandatory condition failed within the declared scope. It is not a proof of correctness.
- Docker is not a complete security boundary. A contract check passes only with a JUnit report of tests that actually ran, and the candidate cannot shadow the runner. Contract-owned checks reach the candidate only through
provecode.isolate, in a child process, so candidate code cannot patch the pytest process that judges them (ADR 0013). Inrerun's runs B and C, the candidate's code and the base tests necessarily share a process, so deliberately malicious code could still forge run B's result; seedocs/04-threat-model.md. - Prior art: MaruCheck already has approved, hashed contracts, contract-owned checks, deterministic decisions and inconclusive evidence. Existing count-based detectors catch deletions and skips. PROVECODE's contribution is the semantic, count-preserving rules and the benchmark (see
docs/00-competitive-audit.md).