Skip to main content

tanny

CI PyPI Python License: MIT

tanny is a static model checker for Python specifications written with temporal-typing.

temporal-typing expresses state-machine specifications—invariants, actions, preconditions, postconditions, fairness, temporal properties, and refinements—as ordinary Python type annotations. tanny parses those declarations directly from Python source without executing user code, translates each Model into TLA⁺ with Python semantics, and model-checks it in process using Manyan.

tanny is written in Rust and distributed as a self-contained CLI and Python package with no JVM dependency.

Features

  • Static source analysis: Parses Python files with Ruff's parser without importing or executing user modules.
  • Full specification coverage: Implements the temporal-typing checker specification, checking assumptions, invariants, action invariants, temporal properties under weak and strong fairness, method-body conformance, frame conditions, assertions, function contracts, deadlocks, and refinements.
  • Python-level counterexamples: Reports failing traces in terms of Python actions, arguments, and state variables.
  • In-process TLA⁺ model checking: Embeds Manyan natively with deterministic multi-worker state exploration (--workers).
  • CI-friendly output: Supports human-readable output, --quiet filtering, structured --json reports, and standard exit codes.
  • Inspectable translation: Emits the generated TLA⁺ modules and model configuration via tanny translate.

Installation

Prebuilt wheels are published to PyPI for Linux (x86_64, aarch64) and macOS (arm64, x86_64), requiring Python 3.10 or later.

Install globally with uv:

uv tool install tanny

Or run without installing:

uvx tanny check examples/

Or install into a Python environment with pip:

pip install tanny

When installed in a Python environment, tanny can also be invoked as a module:

python -m tanny check examples/

Building from source

Building from source requires a Rust toolchain (1.98 or later) and a C11 compiler for the Manyan submodule:

git clone --recursive https://github.com/soasme/tanny.git
cd tanny
cargo build --release

The compiled binary is written to target/release/tanny.

Quick Start

Run tanny check on one or more Python files or directories containing temporal_typing.Model definitions:

tanny check examples/

Example output:

PASS examples/bank_account.py::small_account_model  884 states; deposit.amount ∈ 1..3, withdraw.amount ∈ 1..3; bounded by state_constraint
FAIL examples/die_hard.py::impl_model  invariant not_solved
    1. init: small=0, big=0
    2. fill_big(): small=0, big=5
    3. pour_big_to_small(): small=3, big=2
    4. empty_small(): small=0, big=2
    5. pour_big_to_small(): small=2, big=0
    6. fill_big(): small=2, big=5
    7. pour_big_to_small(): small=3, big=4

Each Model(...) discovered in the input paths receives one verdict (PASS, FAIL, or ERROR).

Usage

tanny provides two subcommands: check and translate.

tanny check

Check every Model in the given Python files and directories:

tanny check [OPTIONS] <PATHS>...
Option Description
--root <DIR> Search <DIR> for imports before each file's own directory. May be repeated.
-m, --model <NAME> Check only models matching <NAME>. May be repeated.
--json Emit verdicts and diagnostics as JSON.
-q, --quiet Suppress PASS verdicts in text output.
--workers <N> Number of worker processes expanding states per check (default: 1).

Examples:

# Search src/ for imports when checking specs under tests/specs/
tanny check --root src/ tests/specs/

# Check a single model with 4 workers
tanny check -m impl_model --workers 4 examples/die_hard.py

# Emit machine-readable JSON output for CI
tanny check --json examples/

tanny translate

Print the TLA⁺ modules and Main.cfg configuration generated for a specific model:

tanny translate [--root <DIR>] <PATH> <MODEL>

Example:

tanny translate examples/die_hard.py impl_model

Verdicts and Exit Codes

tanny check assigns one verdict per model as defined in the checker specification:

Verdict Meaning
PASS Every obligation holds for all reachable states within the model's bounds. Prints the distinct state count, parameter domains, state constraint, and symmetry sets.
FAIL A specification obligation was violated. Prints the failure kind, failing clause or action name, detail, and a counterexample trace in Python terms.
ERROR The model could not be checked (invalid declaration, unsupported construct, vacuous initial state, or internal error). Prints a file:line diagnostic.

Failure kinds: invariant, action-invariant, property, assumption, refinement, contract, deadlock, conformance (method body violating its Action, Ensures, frame, or return-type Where), assertion (failing Python assert), and runtime (evaluation error such as out-of-range indexing).

Exit codes

Code Meaning
0 Every checked model returned PASS.
1 At least one model returned FAIL (and no model returned ERROR).
2 At least one model returned ERROR, or CLI/translation failed.

JSON output

Passing --json writes a JSON object containing verdicts and top-level diagnostics:

{
  "diagnostics": [],
  "verdicts": [
    {
      "detail": "884 states; deposit.amount ∈ 1..3, withdraw.amount ∈ 1..3; bounded by state_constraint",
      "file": "examples/bank_account.py",
      "kind": null,
      "model": "small_account_model",
      "name": null,
      "trace": [],
      "verdict": "PASS",
      "warnings": []
    }
  ]
}

Architecture

tanny is organized as a Cargo workspace with six crates:

Crate Responsibility
tanny Executable entry point; orchestrates checking and formats verdicts and traces.
tanny-cli Command-line interface definitions (check and translate).
tanny-frontend Static parser and analyzer (checker spec §1–3, §6) built on ruff_python_parser.
tanny-translate Translates Python specifications, method bodies, and models into TLA⁺ (checker spec §4–5).
manyan Safe Rust wrapper for running Manyan in process and decoding results and traces.
manyan-sys Raw FFI bindings to Manyan's C API, compiled from the crates/manyan-sys/manyan submodule.

Translation model

  • Method bodies: Lowered to pure transformations over a record holding state variables and local bindings; loops are lowered to recursive TLA⁺ operators.
  • Obligations: Invariants, action invariants, assumptions, and temporal properties map directly to TLA⁺ INVARIANT, ASSUME, and PROPERTY clauses. Operational obligations—conformance of a method body to its Action, Ensures, frame (Modifies), return-type Where, Python assert, and runtime errors—are encoded as tagged Assert checks so counterexamples identify the exact failure kind.
  • Refinements: Translated using a TLA⁺ INSTANCE of the abstract specification's module under the declared mapping, verifying initial states, steps, fairness clauses, invariants, and temporal properties individually.

Development

Clone the repository with submodules (which pin the Manyan C engine and the temporal-typing conformance suite):

git clone --recursive https://github.com/soasme/tanny.git
cd tanny

Common tasks are provided via the Makefile:

make check        # Run formatting, clippy, unit tests, and the conformance suite
make lint         # Run cargo fmt --check and cargo clippy (-D warnings)
make test         # Run cargo test --workspace
make conformance  # Run scripts/conformance.py against temporal-typing's suite and examples
make release      # Build the release binary

To run tanny through uv against the bundled examples:

uv run tanny check tests/temporal-typing/examples

Conformance suite

tanny is tested against temporal-typing's official checker conformance suite (tests/temporal-typing/tests/checker and tests/temporal-typing/examples, pinned as a Git submodule). scripts/conformance.py verifies every expected verdict and warning against tanny check --json.

See CHANGELOG.md for release history.

Documentation

  • Manual — installation, CLI reference, import resolution, verdicts, diagnostic codes, JSON schema, exit codes, and CI setup.
  • Architecture — workspace crates, front-end pipeline, Python-to-TLA⁺ translation (Py.tla, body lowering, tagged Asserts, refinements, contracts), and conformance testing.
  • Manyan Rust Crates — embedding Manyan in process from Rust via manyan and manyan-sys.
  • Checker Specification — upstream temporal-typing specification defining what a checker must accept, reject, check, and report.
  • temporal-typing — Temporal specification annotations for Python and the checker specification.
  • Manyan — Fast, embeddable TLA⁺ model checker written in C11.

License

MIT License. See LICENSE for details.

Metadata

Release files for tanny 0.2.0

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

Source distribution (sdist)

Source distribution for tanny 0.2.0
File Size Uploaded Provenance Actions
tanny-0.2.0.tar.gz 411.5 kB With provenance Details for tanny-0.2.0.tar.gz

Built distributions (wheels)

Table of built distributions (wheels) for tanny 0.2.0
File Actions
tanny-0.2.0-py3-none-manylinux_2_28_x86_64.whl Python 3 none Linux glibc 2.28+ x86-64 Details for tanny-0.2.0-py3-none-manylinux_2_28_x86_64.whl
tanny-0.2.0-py3-none-manylinux_2_28_aarch64.whl Python 3 none Linux glibc 2.28+ ARM64 Details for tanny-0.2.0-py3-none-manylinux_2_28_aarch64.whl
tanny-0.2.0-py3-none-macosx_11_0_x86_64.whl Python 3 none macOS 11.0+ x86-64 Details for tanny-0.2.0-py3-none-macosx_11_0_x86_64.whl
tanny-0.2.0-py3-none-macosx_11_0_arm64.whl Python 3 none macOS 11.0+ ARM64 Details for tanny-0.2.0-py3-none-macosx_11_0_arm64.whl

Total release size: 8.2 MB

Release files / tanny-0.2.0.tar.gz

Download URL tanny-0.2.0.tar.gz
Size 411.5 kB
Tags Source
SHA-256 checksum
How to use checksums
1e30cf2cb07304f322b13b2ded7f4e4cab29784e40bdf70b0afec27a1469868c
BLAKE2b-256 checksum
How to use checksums
e98638101fcf8ee75dae2179c0fa4e8b0a3c83f92ef33f7f73c914ba0d2ae1a8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 30, 2026.

Transparency log

Release files / tanny-0.2.0-py3-none-manylinux_2_28_x86_64.whl

Download URL tanny-0.2.0-py3-none-manylinux_2_28_x86_64.whl
Size 2.0 MB
Tags Linux glibc 2.28+ x86-64 Python 3
SHA-256 checksum
How to use checksums
3d13a4088bc13c43efc6af6932dda8a6ef55e790e660149b99eb30ad6be6aa59
BLAKE2b-256 checksum
How to use checksums
252f6b5da8a11bfccd03109eca42ce8cb866cc521bfe3329614d6a2461941f3e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 30, 2026.

Transparency log

Release files / tanny-0.2.0-py3-none-manylinux_2_28_aarch64.whl

Download URL tanny-0.2.0-py3-none-manylinux_2_28_aarch64.whl
Size 1.9 MB
Tags Linux glibc 2.28+ ARM64 Python 3
SHA-256 checksum
How to use checksums
22c073b863a770801c90b831ffa979af4f946edb8d370f809ea0c8d95b04414c
BLAKE2b-256 checksum
How to use checksums
a80b70db8717a77c494b46f74191d96048f8dd9ee61e850e36056b6785de94ae
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 30, 2026.

Transparency log

Release files / tanny-0.2.0-py3-none-macosx_11_0_x86_64.whl

Download URL tanny-0.2.0-py3-none-macosx_11_0_x86_64.whl
Size 2.0 MB
Tags Python 3 macOS 11.0+ x86-64
SHA-256 checksum
How to use checksums
fed245ef0a71095df78688f985a6939bab2593eb593e131fbd3734f64821797d
BLAKE2b-256 checksum
How to use checksums
a8433aabc9decdde8762f4802f9f3bed534090dae89e14fff84b443d95a3f7cc
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 30, 2026.

Transparency log

Release files / tanny-0.2.0-py3-none-macosx_11_0_arm64.whl

Download URL tanny-0.2.0-py3-none-macosx_11_0_arm64.whl
Size 1.9 MB
Tags Python 3 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
d15326bba97f7bb107513155d22f09c948b9ca095ca3e4bf7607d3f564e43edc
BLAKE2b-256 checksum
How to use checksums
9098733df8c51a9b4e8431cc38b686e26684d46f186a6fd0f627c6387ff9e7df
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 30, 2026.

Transparency log

Security for tanny 0.2.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

All 5 files in this release have been uploaded with provenance metadata.

Select from 5 files

Attestation for tanny-0.2.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 30, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.2.0 This release

5 release files Full provenance

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