Skip to main content

heki

The heki banner, a snake in front of a brick wall

heki (壁, Japanese for "wall") is a static checker for Python, written in Rust. It follows calls across files to find shared state changed in place, database queries in loops, and blocking calls in async code, and it enforces the boundaries your project declares. It runs alongside Ruff and your type checker (mypy, Pyright, Pyrefly, or ty), and never runs your code.

📚 Documentation · 🚀 Getting started · 📏 Rules · 📜 Contracts · 🤖 Coding agents

PyPI Python versions CI License: MIT

Highlights

  • Bugs found with no configuration
    • heki reports cached results changed in place, database queries and new clients in loops, blocking calls in async code, and locks taken again while held.
  • Default rules report only what they prove
    • Every report of the default rules on 378 packages and a holdout of 100 more was checked by hand, and none was false.
  • Fixes that keep behavior
    • heki check --fix rewrites code only when it proves that the results, the calls into other code, and the changes to shared objects stay the same.
  • A single fast binary
    • It has no Python dependencies and checks a 100,000-line project in a few seconds.
  • CI, editors, and coding agents
    • It runs in CI, in editors through its LSP server, and for coding agents as JSON. In our agent runs, it found an N+1 query that had passed the tests, Ruff, and strict mypy.
  • Optional contracts
    • Contracts in heki.toml say who may change, read, or call what, where I/O may happen, and which imports are allowed.

Quick start

$ uvx heki check     # check the project in its root, with no install and no configuration
$ uvx heki init      # write heki.toml and a Ratchet baseline, and set up coding agents if you ask

The baseline holds today's reports, so only new ones fail. Getting started reads a diagnostic and applies a fix.

Example

# app/config.py
from functools import lru_cache


@lru_cache(maxsize=64)
def base_headers(region: str) -> dict[str, str]:
    return {"Accept": "application/json", "X-Region": region}
# app/api.py
from app.config import base_headers


def request_headers(region: str, token: str) -> dict[str, str]:
    headers = base_headers(region)
    headers["Authorization"] = f"Bearer {token}"
    return headers

Each file looks fine on its own, and the types are right. But lru_cache hands the same dict to every call with the same region, and request_headers writes a token into it, so a later caller of base_headers for that region sends the token of whoever called request_headers last.

Both files pass Ruff and strict type checking (mypy, Pyright, Pyrefly, and ty). heki check reports MUT114.

heki check in a terminal reports MUT114, with no configuration, for a dict that an lru_cache function returned and another file changes in place

Contracts (optional)

Contracts are rules only your project knows, and heki enforces them through helpers and aliases. This one lets only the functions in app.store change Order.items.

[[write-owners]]
name = "order-store"
targets = ["app.models.Order.items"]
allowed-writers = ["app.store.*"]
message = "change Order.items through app.store"
fail = true

A write through a helper in another file is then reported as MUT201 (the whole example). Contracts describes all eight contract tables.

Installation and CI

Install heki with uv tool install heki, pipx install heki, or pip install heki. The prebuilt wheels for Linux, macOS, and Windows need no Rust toolchain (Installation). heki is pre-release, so pin the version in CI with uvx heki==0.14.1 check and in the pre-commit hook.

# .pre-commit-config.yaml
repos:
  - repo: https://github.com/koxudaxi/heki-pre-commit
    rev: v0.14.1
    hooks:
      - id: heki

The release notes list every change. Adopting heki covers baselines and CI, and says what stays stable until 1.0.

Where heki fits

With no configuration

If you know It gives you heki adds, with no configuration
Ruff style and syntax, one file at a time what a call does across files
mypy, Pyright, Pyrefly, ty declared types parameters typed read-only changed through helpers
Tests, profilers, monitoring problems on the paths that ran async def reaching blocking calls, queries and new clients in loops, and locks taken again while held, before the code runs
Borrowing (Rust) a shared borrow cannot change the value a shared cached result changed in place by its caller

With heki.toml

Each of these takes a contract. heki init writes the contracts it can propose from the code, commented out.

If you know It gives you heki adds, with heki.toml
tach, import-linter which module may import which writes, calls, and I/O that cross a layer even through allowed imports (a contract)
Code review, AGENTS.md rules people and agents have to remember the same rules, checked on every run (contracts)
Ownership (Rust) one owner decides who may change a value who may change, read, or call what (a contract)
Haskell IO, Effect-TS the type marks the functions that do I/O any scope you mark pure, checked for I/O through helpers without rewriting your code (a contract)

Documentation

The documentation is at heki.koxudaxi.dev, with an index for language models at llms.txt. Design philosophy says why heki works the way it does and where its name comes from, and the Changelog lists every release.

heki is licensed under the MIT license.

Metadata

Release files for heki 0.14.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 heki 0.14.1
File Size Uploaded Provenance Actions
heki-0.14.1.tar.gz 5.0 MB With provenance Details for heki-0.14.1.tar.gz

Built distributions (wheels)

Table of built distributions (wheels) for heki 0.14.1
File Actions
heki-0.14.1-py3-none-win_amd64.whl Python 3 none Windows x86-64 Details for heki-0.14.1-py3-none-win_amd64.whl
heki-0.14.1-py3-none-musllinux_1_2_x86_64.whl Python 3 none Linux musl 1.2+ x86-64 Details for heki-0.14.1-py3-none-musllinux_1_2_x86_64.whl
heki-0.14.1-py3-none-manylinux_2_28_x86_64.whl Python 3 none Linux glibc 2.28+ x86-64 Details for heki-0.14.1-py3-none-manylinux_2_28_x86_64.whl
heki-0.14.1-py3-none-manylinux_2_28_aarch64.whl Python 3 none Linux glibc 2.28+ ARM64 Details for heki-0.14.1-py3-none-manylinux_2_28_aarch64.whl
heki-0.14.1-py3-none-macosx_11_0_arm64.whl Python 3 none macOS 11.0+ ARM64 Details for heki-0.14.1-py3-none-macosx_11_0_arm64.whl
heki-0.14.1-py3-none-macosx_10_12_x86_64.whl Python 3 none macOS 10.12+ x86-64 Details for heki-0.14.1-py3-none-macosx_10_12_x86_64.whl

Total release size: 99.6 MB

Release files / heki-0.14.1.tar.gz

Download URL heki-0.14.1.tar.gz
Size 5.0 MB
Tags Source
SHA-256 checksum
How to use checksums
f57d91fb850408a2f68fe1ea7849a5edf6298f53070b491be3aea922d4f8eda5
BLAKE2b-256 checksum
How to use checksums
2a7b878823662dd64873abf8183df27da0c9841c1e28f73bb71092e9085ac803
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 / heki-0.14.1-py3-none-win_amd64.whl

Download URL heki-0.14.1-py3-none-win_amd64.whl
Size 15.0 MB
Tags Python 3 Windows x86-64
SHA-256 checksum
How to use checksums
49cf45915c26fe2e25dab00448500118b9b5dcee98bce8fcdf90247b4500dd9b
BLAKE2b-256 checksum
How to use checksums
36da5aabedbeabd0b44da19ab88bdd3679e38fe3775f43160fd11a3be05f2b57
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 / heki-0.14.1-py3-none-musllinux_1_2_x86_64.whl

Download URL heki-0.14.1-py3-none-musllinux_1_2_x86_64.whl
Size 16.8 MB
Tags Linux musl 1.2+ x86-64 Python 3
SHA-256 checksum
How to use checksums
90ddce1cf58e6d9e0e8aa2d2004f7e0ee056b3f6b1d29445f1be5cd740d6e4d7
BLAKE2b-256 checksum
How to use checksums
bddf93370ac8ec951983c4e7ae1be1854bd5e0474f4781bf575c8e770083090f
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 / heki-0.14.1-py3-none-manylinux_2_28_x86_64.whl

Download URL heki-0.14.1-py3-none-manylinux_2_28_x86_64.whl
Size 16.2 MB
Tags Linux glibc 2.28+ x86-64 Python 3
SHA-256 checksum
How to use checksums
42630d5bbf60b6e6c9bb09f513495a3818ac3125c8192be517482c61b7b10ca3
BLAKE2b-256 checksum
How to use checksums
75db252baa7dffafb2b6af2dd859d8626ab734f1bf3bbb48726c587e1827abbd
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 / heki-0.14.1-py3-none-manylinux_2_28_aarch64.whl

Download URL heki-0.14.1-py3-none-manylinux_2_28_aarch64.whl
Size 15.7 MB
Tags Linux glibc 2.28+ ARM64 Python 3
SHA-256 checksum
How to use checksums
c241afa054f7d21bf1a963d4962539e7a4ce81ae9117e6d9348b1e5c0d153b93
BLAKE2b-256 checksum
How to use checksums
7d9990ff5f43bb5f2785cf9b4390cf4dcef4b2c276662ccb9c81550a1328632a
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 / heki-0.14.1-py3-none-macosx_11_0_arm64.whl

Download URL heki-0.14.1-py3-none-macosx_11_0_arm64.whl
Size 15.0 MB
Tags Python 3 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
e5889b01327665da173ce4a7f0dfa9475c6c99554c84a03ea1c1b88f7bf20aa7
BLAKE2b-256 checksum
How to use checksums
ca934fdf67e45f8d51047535c111d25e7002d3650ce0d872c8fe99394df318bc
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 / heki-0.14.1-py3-none-macosx_10_12_x86_64.whl

Download URL heki-0.14.1-py3-none-macosx_10_12_x86_64.whl
Size 15.8 MB
Tags Python 3 macOS 10.12+ x86-64
SHA-256 checksum
How to use checksums
0d00dd907f921452b630595c45c3ebdd86ecb32827208910125f8af047fdb384
BLAKE2b-256 checksum
How to use checksums
eef33dfea79e27e36222a38d558206a16c79cf5995c268ede724070fbecb4c8d
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 heki 0.14.1

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 7 files in this release have been uploaded with provenance metadata.

Select from 7 files

Attestation for heki-0.14.1.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.

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