Skip to main content
Glama

physverify: confirm physics claims by running the code

tests PyPI Python DOI Docs

A suspected bug in simulation code is a claim. physverify turns it into a run against a reference written from the physics, and gives a verdict with the numbers.

The claim can come from an AI code review, a colleague, a static check or your own doubt. Reading the code again rarely settles it; a run against an exact solution, a conservation law or a convergence order does. physverify supplies those checks for numerical ODE and PDE code (order of convergence, manufactured solutions, conservation, Runge-Kutta tables, exact references, a few Monte Carlo statistics), a sandbox for running code you do not trust, and plain-language verdicts. It needs only NumPy. Current release: 0.8.0 (v0.8.0); actively developed, contributions welcome.

A claim from a review becomes a run against a reference from the physics, and the run gives a verdict: confirmed, minor, rejected or open

What confirming claims found on 100 repositories

Five AI reviewers (three Claude models, Qwen 3.8 Flash and GPT 5.6 Terra) reviewed 100 public physics repositories with one fixed prompt. Fifty had a defect reported earlier; fifty had been tested and found clean. On the clean fifty, 119 review claims were drawn and each was given a check run in the sandbox:

Of 119 claims checked on repositories tested clean: 40 changed a result, 51 were real but minor, 10 were wrong, 18 stayed open

  • 40 claims were real defects that change a result: 33 distinct defects in 19 of the 50 "clean" repositories. 32 have been reported to their maintainers.

  • 51 were real but minor (invalid input, display, docstrings, code paths the repository never uses), 10 were wrong and 18 could not be settled.

  • Nine of the ten wrong claims came from one model. Where a reading was recorded before the run (20 claims), the run changed 3 verdicts.

  • Against the 67 defects reported earlier, the reviewers named 36 to 49; physverify scan, which reads code without running it, named 11.

So AI review finds many real defects, including ones earlier testing missed, but a claim is not a finding until something runs. The counts hold for this sample only and are not a bug rate for physics code. The labels come from two automated checkers following written rules, not from people. Tables: scripts/study100.py regenerates them from the per-claim file, released with the preprint (doi:10.5281/zenodo.24224433).

Related MCP server: research-check

Confirmed by maintainers

Some defects confirmed or fixed by the projects' own maintainers after a report:

Project

What was found

Outcome

SymPy

three units differ from their exact definitions

confirmed against primary sources

Astropy

"surface tension" registered as J m² instead of J/m²

confirmed; fix in progress

PyGMT

strings with a space treated as datetimes

fixed

EinsteinPy

de Sitter scale factor on a spatial coordinate

fixed

TESPy

entropy pressure term with the wrong units

fixed

PyAstronomy

two constants modules defaulted to different unit systems (CGS and SI), so planck and other functions were wrong

fixed

qmat

Runge-Kutta schemes labelled one order too high

fixed; now uses physverify.butcher in CI

The full list has more projects and the details.

Try it

pip install physverify
physverify demo

The demo checks a correct solver (all checks pass), then the same solver with the damping 10% too large (all fail):

Error against step size: the correct solver follows the slope-2 line, the broken one levels off

New to this? Start here takes about ten minutes and includes a prompt to paste if you use an AI coding assistant.

Use it on your own code

  • Suspected bugs from a review (yours or an AI's): write each claim down, pick a reference that does not come from the code, and run the smallest test that tells the two answers apart. Checking an AI code review walks through it with examples.

  • An ODE solver: physverify init verify_solver.py --solver mysolver --order 4 writes a spec; fill in the equations (from the physics, not from your code) and run physverify run verify_solver.py.

  • Errors you already have: check_order(hs, errors, expected=2) gives PASS, FAIL or INCONCLUSIVE with a reason.

  • A Runge-Kutta table: check_tableau(A, b, c, claimed=3) from physverify.butcher checks order, stage order and stability from the coefficients alone.

  • Code you have not read yet: physverify scan PATH reads the source, runs nothing, and flags a fixed set of patterns (Runge-Kutta tables below their stated order, grid spacings that do not match their grid, near-miss constants, removed NumPy/SciPy features, undefined names, unit tables with the wrong dimension). A clean scan means only that those patterns were not found. scan is kept working but no longer gets new rules; the work now goes into confirming claims.

Code from other people runs only in the sandbox (no network, read-only repository).

Run it in CI

A failed check fails the job, like a broken unit test (CI guide):

      - uses: rcgiri-physics/physverify@v0.8.0
        with:
          specs: tests/verify_*.py

Getting started · Recipes · What a PASS means · Troubleshooting · API

Use it from an AI assistant (MCP)

physverify mcp is a local MCP server with two tools: run_checks runs a project's verify_*.py specs, and confirm_claim judges one suspected defect (confirm). Install physverify, then add this to your client's MCP settings (Claude Desktop, Cursor, Windsurf, Cline, Qoder and others; VS Code, Codex CLI and Claude Code are in the guide):

{
  "mcpServers": {
    "physverify": { "command": "physverify", "args": ["mcp"] }
  }
}

The tools run your project's Python code on your computer, so use them on projects you trust. The server is in the official MCP registry as io.github.rcgiri-physics/physverify.

Other evidence

  • Seeded bugs: of 37 bugs added one at a time to five small solvers, the checks flagged 35 (plain "compare with one answer" tests: 27), with no false alarms. The same person wrote the bugs and the checks, so this shows the tool works as designed, not how it does on other code. python scripts/reproduce_all.py regenerates the tables.

  • Earlier corpus testing (October 2026): of the first 74 defects reported to authors, 14 were found by a physverify check as such, 11 by running the code at all, and the rest by the reference in each repository's test script or by reading; the ledger lists them by ID. Details: results.

Limits

Works best for ODEs; PDEs only in 1D so far. Your code needs a way to add a source term, or a small wrapper that can itself be wrong. A PASS means these checks found nothing wrong; it does not prove the simulation correct, and it is only as independent as the reference you wrote: see What a PASS means.

Contributing, citing, licence

Help is welcome: a trial report on your own solver, seeded bugs written by someone other than the author, adapters, documentation. See CONTRIBUTING.md, the code of conduct, SUPPORT.md, SECURITY.md on running untrusted code, and AGENTS.md for AI assistants. To cite, use doi:10.5281/zenodo.23534512 or CITATION.cff. Changes: CHANGELOG.md; plans: ROADMAP.md. The methods are standard and other tools do parts of this, some better (NodePy for Runge-Kutta analysis); see related work and credits. MIT licence, copyright (c) 2026 Ram Chandra Giri.

Available Tools

2 tools
confirm_claimA

Judge one suspected defect with physverify confirm. Takes a claim file that defines CLAIM, control() and checks() with a reference written from the physics (docs/confirm.md), runs it in a fresh process and returns the verdict: confirmed, rejected or not decidable, with the reason and each check's status and message. Appends the result to a ledger file. Runs the code, so it needs trusted=true or the sandbox (PHYSVERIFY_REPO set).

Inputs: claim (required), ledger, timeout, trusted, +1 more.

run_checksA

Run physverify verification checks (manufactured solutions, order of convergence, invariants, limits, exactness) on physics simulation code. Takes spec files that define checks(); with no specs given, finds verify_*.py files under project. Returns a JSON report: per check family, label, status (PASS, EXACT, FAIL, INCONCLUSIVE, ERROR, SKIP), message, observed and expected order, step sizes and errors.

Inputs: specs, project, timeout.

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    TDQS

    A3.9/5.0

    Scored across 2 tools

    Disambiguation4/5

    run_checks is a broad verification sweep over discovered verify_*.py specs, while confirm_claim adjudicates a single suspected defect from a CLAIM file and writes to a ledger, so purposes are mostly separable. They share the underlying checks() machinery and both report check statuses, which could cause some hesitation about which to call for a one-off verification.

    Naming Consistency5/5

    Both tools follow the same verb_noun snake_case pattern (run_checks, confirm_claim) and the verbs accurately reflect their actions. No mixing of conventions.

    Tool Count3/5

    Only two tools for what is a fairly rich verification domain, which feels thin even for a focused CLI wrapper. The pair covers the batch and single-claim workflows but leaves little room for auxiliary operations.

    Completeness3/5

    Core lifecycle of run-specs-then-confirm-defect is present, but the surface is missing useful operations such as listing/discovering available spec or claim files, reading the accumulated ledger, or validating spec syntax before execution. The write-only ledger is a dead end for an agent.

    Maintenance

    ActivityMaintained
    ResponsivenessNo recent community issues

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      Not graded
      quality
      C
      maintenance
      Enables coding agents to deterministically audit test files for fake or fragile tests (no assertions, tautological or swallowed assertions, focused/skipped tests, fixed sleeps, real network calls) and to run the project's actual test runner, treating an exit-0 run with zero tests as a failure and flagging changed source files that lack test coverage.
      51 npm
      MIT