themis-policy
Python reference implementation of Themis RFC v0 — a policy kernel for
LLM agents that act on production systems. Four primitives — locks,
drafts, scopes, audit — composed by one engine into a single
decision per attempted action: allow, deny, redirect, or
require_approval.
Byte-compatible with themis-policy
(TypeScript): both pass the same conformance vectors.
from themis import (
PolicyEngine, DefaultLockPolicy, DefaultScopePolicy, DefaultDraftPolicy,
Requestor, Action, PolicyContext, ConsoleSink, is_deny,
)
engine = PolicyEngine(audit_sink=ConsoleSink())
engine.add_policy(DefaultLockPolicy())
engine.add_policy(DefaultScopePolicy())
engine.add_policy(DefaultDraftPolicy())
decision = engine.evaluate(PolicyContext(
requestor=Requestor(id="key_1", kind="api_key", tenant_id=7, scopes=("pages:read",)),
action=Action(verb="pages.update", resource_type="page", tenant_id=7, resource_id=42,
required_scope="pages:write"),
now=0, correlation_id="req-123",
))
if is_deny(decision):
print(decision.reason) # missing_scope
The engine is synchronous (every core policy is pure CPU); evaluate_async
exists for callers already inside an event loop. Stores (LockStore,
DraftStore) are ports you implement against your persistence; audit sinks
receive one event per evaluation and may never fail an evaluation.
Install: pip install themis-policy (Python 3.11+, no dependencies).
Tests: pip install -e '.[test]' && pytest.
Apache-2.0 — see the repository LICENSE.
Release files for themis-policy 0.2.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| themis_policy-0.2.1.tar.gz | 17.5 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| themis_policy-0.2.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 37.3 kB
Release files / themis_policy-0.2.1.tar.gz
| Download URL | themis_policy-0.2.1.tar.gz |
|---|---|
| Size | 17.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
7f1b29a9053eb296aa8fcb6acbdbeb711077bc8c3b62a372224c9e6868213700
|
|
BLAKE2b-256 checksum How to use checksums |
ba41eefb6935ed67aa92cca1ab206931244695b8413e805a3c5629542bbe05fc
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
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 Sep 25, 2026.
Transparency logRelease files / themis_policy-0.2.1-py3-none-any.whl
| Download URL | themis_policy-0.2.1-py3-none-any.whl |
|---|---|
| Size | 19.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
9268eea891abe664c8b9ed98eec85cf3b6e55d47f4e743b1877866c7dd57d073
|
|
BLAKE2b-256 checksum How to use checksums |
ee558ddbf7af11eecb857579a1461a80b2772ded0ee8d8f0dd8a2bfb43cc2950
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
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 Sep 25, 2026.
Transparency log