heki
🧱 heki (壁, "wall") is a static checker for Python, written in Rust. It tracks side effects and mutations across function calls.
With no configuration, it catches blocking I/O in async code, database queries and HTTP clients
in loops, and quadratic loops. You can also add rules in pyproject.toml to restrict
which functions may mutate state or reach I/O.
📚 Documentation · 🚀 Getting started · 📏 Rules
A blocking call two helpers below an async def
# app/users.py
import requests
def fetch_name(user_id: int) -> str:
return requests.get(f"https://api.example.com/users/{user_id}", timeout=5).text
def load_user(user_id: int) -> dict[str, str]:
return {"id": str(user_id), "name": fetch_name(user_id)}
# app/api.py
from app.users import load_user
async def get_user(user_id: int) -> dict[str, str]:
return load_user(user_id)
$ heki check
app/api.py:5:12: EFF101 (async-blocking-call) [error] `get_user` reaches the blocking call `requests.get` on the event loop
|
5 | return load_user(user_id)
| ^
= related: app/api.py:5:12: `get_user` calls `app.users.load_user`
= related: app/users.py:8:41: `load_user` calls `app.users.fetch_name`
= related: app/users.py:5:12: `fetch_name` calls `requests.get`
= help: offload it with `asyncio.to_thread`, or use an async client
Found 1 diagnostic(s) in 2 file(s).
A query one helper below a loop
# app/orders.py
import sqlite3
def customer_name(cursor: sqlite3.Cursor, customer_id: int) -> str:
cursor.execute("SELECT name FROM customers WHERE id = ?", (customer_id,))
return str(cursor.fetchone()[0])
def order_summaries(cursor: sqlite3.Cursor, orders: list[tuple[int, int]]) -> list[str]:
lines: list[str] = []
for order_id, customer_id in orders:
lines.append(f"#{order_id} {customer_name(cursor, customer_id)}")
return lines
$ heki check
app/orders.py:11:37: EFF103 (loop-db-query) [error] `app.orders.customer_name` runs a database query (`sqlite3.Cursor.execute`) on every loop iteration (N+1)
|
11 | lines.append(f"#{order_id} {customer_name(cursor, customer_id)}")
| ^
= related: app/orders.py:11:37: `order_summaries` calls `app.orders.customer_name`
= related: app/orders.py:5:5: `customer_name` calls `sqlite3.Cursor.execute`
= help: batch the queries, or load the data once before the loop
Found 1 diagnostic(s) in 1 file(s).
Ruff, ty, Pyrefly, pyright, and mypy report nothing for either example with their default settings.
Your own conventions, too
The checks above need no configuration. The rules of your own project, which you keep today by review, by AST scripts, or by run-time guards in tests, can be added as a few lines of it:
[[tool.heki.write-owners]]
targets = ["app.models.Order.items"]
allowed-writers = ["app.store.*"]
heki follows aliases, helpers, and subclasses, with no decorators and nothing running at run
time. The other contracts are read-owners, call-owners, readonly-returns, invalidation,
and effect-boundaries.
✨ Why heki?
Types say what values are; heki checks what code does:
- Aliases and in-place changes: which objects a function changes, through any alias, helper, or subclass.
- Contracts: who may write, read, or call what, and which code may reach I/O.
- Proven rewrites: quadratic patterns are rewritten only when the rewrite is proven, not guessed.
What code does, not what types it has
Each report shows the chain of calls that leads to the bug.
| What goes wrong | Rule |
|---|---|
A blocking call several helpers below an async def |
EFF101 |
| A database query, or a new HTTP client, on every loop iteration | EFF103, EFF102 |
An attribute that __hash__ reads, changed after the object went into a set |
MUT107 |
A Sequence / Mapping argument changed in place by a helper |
MUT110 |
Opt-in: a frozen or ReadOnly field changed in place |
MUT108 |
| Opt-in: I/O while a lock or a database transaction is held | EFF106 |
| Opt-in: a generator consumed twice | MUT106 |
Opt-in, experimental: a @cached_property left stale after another method changes what it read |
MUT101 |
Opt-in, experimental: a function reading a @cached_property that another method leaves stale |
MUT111 |
A safety net for reviews and coding agents
- The language server checks while you edit and re-checks only what an edit can affect.
heki snapshotrecords what each public function does, andMUT103reports a function that gained an effect, which a diff does not show.- Coding agents get the same checks as JSON.
Fast, quiet, and easy to adopt
- Under a second for a 200,000-line project.
- A report needs evidence: when heki cannot tell, it stays quiet.
- Configuration, suppression comments, and output formats follow Ruff, and a baseline fails CI only on new findings.
🔓 What Python leaves open
| What Python leaves open | What other languages enforce | What heki checks |
|---|---|---|
| Any code can change any object it reaches | ownership and borrowing (Rust), const / readonly |
read-only parameters and fields changed through helpers (MUT110, MUT108); write-owners / read-owners contracts (MUT201, MUT203) |
| A signature does not say what a function does | effect types, IO in the type (Haskell) |
blocking calls reached from async def, and clients and queries in loops (EFF101–EFF103); effect-boundaries (EFF201); effect snapshots (MUT103) |
| Shared mutable objects hide changes | value semantics, immutability by default | stale cached properties and hashes (MUT101, MUT107); changed shared return values (MUT202); writes an invalidation contract must announce (MUT109) |
| Dynamic dispatch blocks optimizations | static types let a compiler prove a rewrite | quadratic patterns (OPT), rewritten only when proven under CPython's semantics |
🔍 How heki differs
The difference is the model, not reaching across files: type checkers already follow types across modules. heki models effects and aliases, what code does:
| Tool | Models | heki adds |
|---|---|---|
| Ruff | syntax and style | the effects behind a call: a blocking call, a query, or a write, wherever it happens |
| ty, Pyrefly, pyright, mypy | declared types | in-place changes, through aliases and helpers, to frozen, ReadOnly, and Final fields and to Sequence / Mapping arguments |
| tach, import-linter | which modules may import which | which functions write or read a field, call a function, or reach I/O |
Their stricter settings do not close the gap. The second example above is fully annotated and
passes Ruff's annotation rules (ANN), mypy --strict, pyright's strict mode, and Pyrefly's
strict preset, yet it sends one query per order: the types are right, and what the code does
is slow.
heki leaves to these tools what they cover, and keeps doing so as they grow: use it next to them.
🔧 Rewrites proven under CPython's semantics
The OPT rules find quadratic list, dict, set, bytes, and queue patterns. heki check --fix
rewrites one only when it proves that the program behaves the same:
- it trusts no type annotation (a subclass can override
__add__); - any other reference to the object blocks an in-place update;
- evaluation order and exceptions are kept;
- builtins count only while the module does not rebind them.
The scope analysis is checked against CPython's symtable on 3.11 to 3.15, and adversarial
programs that break a naive rewrite must all be blocked on CPython. When a proof fails, the
report names the missing obligation instead of offering a fix.
🎯 Scope
- Its knowledge comes from its own analysis, a catalog of library behavior, contracts you
declare in
pyproject.toml, and type annotations, which only help it resolve calls: rewrites never trust them. - When it cannot tell, it stays quiet. Annotations, catalog entries, and contracts close the findings it misses.
- It does not model
__getattr__proxies, metaclasses, or framework machinery, and it never runs your code.
See Scope and limitations for the details.
📦 Installation
$ uv tool install heki # or: pipx install heki / pip install heki
$ uvx heki check # run without installing
🏃 Usage
$ heki check # check the project
$ heki check --diff # preview proven-safe fixes
$ heki check --fix # apply them
$ heki check --baseline heki-baseline.toml # fail only on new findings
$ heki rule EFF101 # explain a rule
$ heki server # LSP server for editors
📚 Documentation
- 🚀 Getting started - run heki on a project, read a diagnostic, apply a fix
- 🎯 Scope and limitations - what heki checks and what it leaves to other tools
- ⚙️ Configuration - rule selection, contracts, the Python version
- 📏 Rules - all 31 rules
- 🔧 Fixes and safety - how rewrites are proven safe
- 🪜 Adopting heki - Ratchet baselines, pre-commit, CI
- 🖥️ Editors (LSP) - VS Code, Neovim, and any LSP client
- 🤖 Coding agents - JSON output and agent setup
- ⌨️ CLI reference - every command and option
- 🛠️ Development - building, testing, and the gates
- 📝 Changelog
📛 Name
heki is 壁, "wall", in its Sino-Japanese (on) reading, the one used in compounds such as 防火壁 (bōkaheki, "firewall"). On its own the character is usually read kabe.
📄 License
Metadata
Release files for heki 0.1.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| heki-0.1.2.tar.gz | 1.0 MB | With provenance | Details for heki-0.1.2.tar.gz |
Built distributions (wheels)
| File | Actions Reset | |||
|---|---|---|---|---|
| heki-0.1.2-py3-none-win_amd64.whl | Python 3 | none | Windows x86-64 | Details for heki-0.1.2-py3-none-win_amd64.whl |
| heki-0.1.2-py3-none-musllinux_1_2_x86_64.whl | Python 3 | none | Linux musl 1.2+ x86-64 | Details for heki-0.1.2-py3-none-musllinux_1_2_x86_64.whl |
| heki-0.1.2-py3-none-manylinux_2_28_x86_64.whl | Python 3 | none | Linux glibc 2.28+ x86-64 | Details for heki-0.1.2-py3-none-manylinux_2_28_x86_64.whl |
| heki-0.1.2-py3-none-manylinux_2_28_aarch64.whl | Python 3 | none | Linux glibc 2.28+ ARM64 | Details for heki-0.1.2-py3-none-manylinux_2_28_aarch64.whl |
| heki-0.1.2-py3-none-macosx_11_0_arm64.whl | Python 3 | none | macOS 11.0+ ARM64 | Details for heki-0.1.2-py3-none-macosx_11_0_arm64.whl |
| heki-0.1.2-py3-none-macosx_10_12_x86_64.whl | Python 3 | none | macOS 10.12+ x86-64 | Details for heki-0.1.2-py3-none-macosx_10_12_x86_64.whl |
Total release size: 38.1 MB
Release files / heki-0.1.2.tar.gz
| Download URL | heki-0.1.2.tar.gz |
|---|---|
| Size | 1.0 MB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
7935320f8d96f3ab70ab68881b21288363b18b7e41781a76e1208b7a18c324d2
|
|
BLAKE2b-256 checksum How to use checksums |
96dc816b0e197a6b1db20c9677aa118193b6a4ecd7e3f5b3e396be137b50d339
|
| 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 20, 2026.
Transparency logRelease files / heki-0.1.2-py3-none-win_amd64.whl
| Download URL | heki-0.1.2-py3-none-win_amd64.whl |
|---|---|
| Size | 5.8 MB |
| Tags | Python 3 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
c84dcaf2913939936cb3bf9c7f447c9493cd449ad134e7aaf7f58f21a399581a
|
|
BLAKE2b-256 checksum How to use checksums |
bc7bcc7d411e192864ab70ec45a201aad4fe971e946d0b525aac217f08081032
|
| 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 20, 2026.
Transparency logRelease files / heki-0.1.2-py3-none-musllinux_1_2_x86_64.whl
| Download URL | heki-0.1.2-py3-none-musllinux_1_2_x86_64.whl |
|---|---|
| Size | 6.6 MB |
| Tags | Linux musl 1.2+ x86-64 Python 3 |
|
SHA-256 checksum How to use checksums |
f46c17ab9b4724dd285b26d2d00574c56bdc790713942596dd80c8052291ae07
|
|
BLAKE2b-256 checksum How to use checksums |
96a6b21f2e1ab581df900be55307c11150aaa269f45c04a05530e26b3d8cc41f
|
| 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 20, 2026.
Transparency logRelease files / heki-0.1.2-py3-none-manylinux_2_28_x86_64.whl
| Download URL | heki-0.1.2-py3-none-manylinux_2_28_x86_64.whl |
|---|---|
| Size | 6.4 MB |
| Tags | Linux glibc 2.28+ x86-64 Python 3 |
|
SHA-256 checksum How to use checksums |
44fcf54d2ddf4764fd6ae9988aa9df003cd6411b5aefea22c0308e977f07bddd
|
|
BLAKE2b-256 checksum How to use checksums |
a3fb11317e20e658a97486e02ebe720377c14d3b1fdb137078741e8d2a0d35cd
|
| 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 20, 2026.
Transparency logRelease files / heki-0.1.2-py3-none-manylinux_2_28_aarch64.whl
| Download URL | heki-0.1.2-py3-none-manylinux_2_28_aarch64.whl |
|---|---|
| Size | 6.2 MB |
| Tags | Linux glibc 2.28+ ARM64 Python 3 |
|
SHA-256 checksum How to use checksums |
2759e841e86357abecd38c4318072a2c53e64e73f681c40804bb7af4fdb74166
|
|
BLAKE2b-256 checksum How to use checksums |
5f875d27acf225cd77fd275e17a6c1cfc03a6b0ef91ec76c3464de4f4d92428b
|
| 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 20, 2026.
Transparency logRelease files / heki-0.1.2-py3-none-macosx_11_0_arm64.whl
| Download URL | heki-0.1.2-py3-none-macosx_11_0_arm64.whl |
|---|---|
| Size | 5.9 MB |
| Tags | Python 3 macOS 11.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
6adcbdd8fd9668fa673a447a915dd212ac6598f7bd5c35f1b5865cf5fec319fb
|
|
BLAKE2b-256 checksum How to use checksums |
f9bae3cdea3179cabd983869e05c7d7d5e8a88edc261b7947072a3aa8c587a92
|
| 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 20, 2026.
Transparency logRelease files / heki-0.1.2-py3-none-macosx_10_12_x86_64.whl
| Download URL | heki-0.1.2-py3-none-macosx_10_12_x86_64.whl |
|---|---|
| Size | 6.1 MB |
| Tags | Python 3 macOS 10.12+ x86-64 |
|
SHA-256 checksum How to use checksums |
cbd65a49547bbd427b5c04a6d1c0070eaaa80ce93250b0b3d51b0621559ce742
|
|
BLAKE2b-256 checksum How to use checksums |
cdc32653b63f2502482453c95a696e92d25faa9e8fee421c351e05ce396816ba
|
| 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 20, 2026.
Transparency logSecurity for heki 0.1.2
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.
Attestation for heki-0.1.2.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 20, 2026.
Transparency logA 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.