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.
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file themis_policy-0.2.0.tar.gz.
File metadata
- Download URL: themis_policy-0.2.0.tar.gz
- Upload date:
- Size: 17.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6a75db237d01c9ce95ed6982998cdd67db612ec06f04f75da84a3626249bec27
|
|
| MD5 |
13a095b4273c4d66efb718e18994427a
|
|
| BLAKE2b-256 |
a1a91038e332df2d51c80efa7e5c6a7d8e1cc4a596a939b07142a39ce88f82e3
|
Provenance
The following attestation bundles were made for themis_policy-0.2.0.tar.gz:
Publisher:
publish-pypi.yml on Adam-Camp-King/Themis
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
themis_policy-0.2.0.tar.gz -
Subject digest:
6a75db237d01c9ce95ed6982998cdd67db612ec06f04f75da84a3626249bec27 - Sigstore transparency entry: 2762269928
- Sigstore integration time:
-
Permalink:
Adam-Camp-King/Themis@8f2046874c63419d4c8efa746a20725333ed23a3 -
Branch / Tag:
refs/tags/v0.2.0 - Owner: https://github.com/Adam-Camp-King
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-pypi.yml@8f2046874c63419d4c8efa746a20725333ed23a3 -
Trigger Event:
push
-
Statement type:
File details
Details for the file themis_policy-0.2.0-py3-none-any.whl.
File metadata
- Download URL: themis_policy-0.2.0-py3-none-any.whl
- Upload date:
- Size: 19.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f589c7dd9df445daed36cc2f630a92199c2f5e31721e58d24775bd15f742d17c
|
|
| MD5 |
a62228fe011b9efb1bf29dc1012d84f8
|
|
| BLAKE2b-256 |
db522cc3dc076943616253633006c87bb2ee7a1fae610bff6fac32e6d802eeb0
|
Provenance
The following attestation bundles were made for themis_policy-0.2.0-py3-none-any.whl:
Publisher:
publish-pypi.yml on Adam-Camp-King/Themis
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
themis_policy-0.2.0-py3-none-any.whl -
Subject digest:
f589c7dd9df445daed36cc2f630a92199c2f5e31721e58d24775bd15f742d17c - Sigstore transparency entry: 2762270025
- Sigstore integration time:
-
Permalink:
Adam-Camp-King/Themis@8f2046874c63419d4c8efa746a20725333ed23a3 -
Branch / Tag:
refs/tags/v0.2.0 - Owner: https://github.com/Adam-Camp-King
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-pypi.yml@8f2046874c63419d4c8efa746a20725333ed23a3 -
Trigger Event:
push
-
Statement type: