Skip to content
PROVECODE

How PROVECODE works

When the same agent writes the code and edits the tests that judge it, “all tests pass” stops meaning much. PROVECODE detects test edits that make checks weaker, including the ones that keep the number of assertions the same, and ties each one to the approved requirement it was guarding.

From a change to a verdict

  1. 1

    Read the change

    Git gives the exact base and head commits. Only test files are compared, and the repository is never checked out or modified.

  2. 2

    Compare each test

    Python's own parser reads both versions. pytest tests and unittest.TestCase methods are both recognised; tests are matched by name, renames are recognised, and each assert or self.assert* check is compared by what it checks and how strictly.

  3. 3

    Link to the contract

    Every finding is tied to the approved requirement its test guards. Severity comes from that requirement: weakening a guard of a mandatory condition is blocking.

  4. 4

    Run the reviewers' checks

    In recorded runs, contract-owned checks run against the candidate in a Docker sandbox with no network. The repository's own tests run too, as supporting evidence only.

  5. 5

    Decide by rule

    A fixed function turns findings, evidence and gaps into one verdict. No language model takes part, and missing evidence never becomes a pass.

Three verdicts, kept apart

FAILED outranks INCONCLUSIVE, which outranks VERIFIED. VERIFIED means no mandatory condition failed within the declared scope. It is not a proof of correctness. The live detector only reads code, so its results are FAILED or INCONCLUSIVE, never VERIFIED.

The rules

S1Comparison weakened== became >=, <, != and similar (assertEqual became assertGreaterEqual), or an approx / assertAlmostEqual tolerance grew
S2Expected value made trivial== 80.00 became >= 0, is not None, a bare truthiness or isinstance check, in assert or self.assert* form
S3Exception widenedpytest.raises or self.assertRaises(ValueError) became Exception or an ancestor, or match= / assertRaisesRegex's message check was dropped
S4Parametrize cases removedboundary cases quietly dropped from @pytest.mark.parametrize
S5Check made vacuousassert x == expected became assert x == x, or gained an or True, so it always passes
B1Test deleteda test function or file removed, and not just renamed
B2Skip or guard addedskip or xfail markers, @unittest.skip, pytest.skip() or self.skipTest(), an early return or if False: before the checks
B3Assertion removedfewer checks than before, with the removed ones unexplained
B4Assertion failure swalloweda check wrapped in try / except AssertionError (or Exception, or a bare except, or suppress) that does not re-raise

S1 to S5 and B4 compare each check with its base version. S1 to S4 are the main contribution; Ruff has lint rules close to S5 and B4 (see prior art). B1 to B3 are standard checks that existing tools already make; they are included for completeness and credited below.

Use it on your own pull requests

The same engine runs from the command line on any machine with Python 3.11 or later, and as a GitHub Action. The Action reads the contract from the pull request's base commit, so the change under review cannot edit the requirements it is judged by. A pull request that tries is blocked.

- uses: actions/checkout@v4
  with:
    fetch-depth: 0
- uses: Shriram28Baskar/provecode@main
  with:
    contract: contracts/checkout.yaml

From a terminal: provecode check --base main --head my-branch --contract contracts/checkout.yaml. Exit code 1 means FAILED, 2 INCONCLUSIVE, 0 VERIFIED.

Inside the agent loop

A pull request is late. provecode guard checks uncommitted changes in the working tree, or the staged ones with --staged, so a weakened test is caught before it becomes a commit. As a Claude Code Stop hook, it sends the agent back to work with the findings when it tries to finish with weaker tests. It needs no contract. If one exists, it is read from the base commit, so editing it does not help. MaruCheck also gates agents; see the prior art below.

pip install -e "engine[cli]"
provecode install-hooks --claude       # Stop and SessionStart hooks
provecode install-hooks --pre-commit   # or: guard every commit
  • On 399 benchmark edits, each applied in its real repository, the working-tree check gave the same report as checking the committed edit in 399 of 399.
  • The full command, Python start-up included, took a median 785 ms and at most 7701 ms per check (Windows, Python 3.11.3).
  • Without any contract, it blocked 301 of 304 injected weakenings and 0 of 95 legitimate edits.
  • It is an early, cheap catch, not a tamper-proof one: an agent with a shell can edit its own hook settings.

Prior art

  • Human-approved, hash-versioned contracts kept outside the code, contract-owned checks, deterministic decisions, explicit inconclusive evidence and an agent gate all exist in MaruCheck. Its seal detects that a sealed contract test changed, not how; it does not cover ordinary tests and has no Python adapter.
  • Deleted tests, new skip markers and assertion-count drops are detected by caiopizzol/skills PR #99, Refactron PR #169, cmux PR #34485, monoharness PR #246 and devkit PR #358. Their authors note that count-preserving edits are a gap. The benchmark baseline reimplements their published rules.
  • Ruff flags comparisons with itself (PLR0124), or True (SIM222) and try-except-pass (S110, SIM105) in a single file. S5 and B4 differ by comparing base with head, so an existing reflexivity test or an intended re-raise is not flagged.
  • Mutation testing (mutmut, Stryker) measures test strength indirectly.
  • Protected contract paths rely on GitHub CODEOWNERS and branch protection.

Statements about other tools are as of November 2026.

What it does not claim, and its limits

  • It is not the first independent verifier of AI-written code, and it does not prove correctness.
  • It does not catch every weakening. Widened mocks, an exception check replaced by a value check, and a swallowed exception check (assertRaises inside try / except) are known blind spots.
  • Python only: pytest-style and unittest-style tests (test_*.py, *_test.py, tests.py and files under tests/). Benchmark numbers are from injected cases; real-world measurement is pending.
  • Docker narrows what untrusted code can do but is not a complete security boundary.
  • In recorded runs, a contract check counts as passed only with a test report showing tests that actually ran and passed, never on an exit code alone, and the candidate cannot replace the test runner. Code the candidate supplies still runs inside the same process as the check, so a deliberately malicious change could forge a report. Defending against that needs the check and the code under test in separate processes.
  • The browser runtime (Pyodide 314.0.8) is served from this site, not a third-party CDN. Its loader is checked against a pinned SHA-384 and the engine files against SHA-256 before use. The other runtime files come from the same deployment and are hashed at build time, but the page does not re-check them as they load.
  • The site's security policy allows inline scripts, which the static Next.js export needs, and WebAssembly compilation, which Pyodide needs. It allows no other origins.
  • A test that guards no contract condition can only produce advisory findings. Coverage depends on the contract.

Try the detector on the checkout change