Skip to main content
Pre-release

This release is a pre-release and may not be stable for production use.

tenbri (Python)

Python bindings for Tenbri. Audit trail for AI agents: every decision signed, chained and provable. The same Rust core as the tenbri CLI and tenbrid, as an abi3 wheel for Python 3.10 and later.

pip install --pre tenbri

Quick start

import tenbri

tenbri.init()  # TENBRI_STREAM, TENBRI_AGENT...: see below


@tenbri.decision("issue_refund", target="stripe:{charge}", policy="policy:refund@14")
def refund(charge: str, amount: int) -> None:
    if amount > 500:
        raise tenbri.Refused("over the ceiling")  # recorded as refused
    ...  # issue the refund

Each call of refund is a decision: its intent is durable before the function runs (if it cannot be written, the function does not run), then its outcome follows: ok, refused when it raises tenbri.Refused, error for any other exception (which propagates), unknown when cancelled. Sync and async functions alike.

  • target and subject are templates of the function's arguments ("stripe:{charge}", "{order.id}") or functions of them; policy ("ref@version") is the rule that allowed it; inputs pins what the decision relied on, (ref, version, content) tuples or a function of the arguments returning them, by keyed digest.
  • Who acts: principal=, else the innermost with tenbri.agent("agent:billing"):, else init(agent=...). Nothing is guessed: with none, the call raises.
  • With an agent framework, one more line records every tool call: tenbri.instrument_claude_agent_sdk(), tenbri.instrument_openai_agents() or tenbri.instrument_langchain() (install tenbri-claude-agent-sdk, tenbri-openai-agents or tenbri-langgraph).

init() opens the process's default stream, creating it and its keys on first use, and closes it (flushing) at exit; with tenbri.init(...): scopes it to a block. Creating a stream (here or with Tenbri.open(..., create=True)) records its pin in <keys>/pins, as tenbri init does, so tenbri verify <stream> on this machine needs no --key. Every argument defaults to an environment variable:

Argument Variable
stream TENBRI_STREAM A directory, file://..., s3://bucket/prefix or r2://bucket/prefix
keys TENBRI_KEYS The keys directory, apart from the stream; default ~/.config/tenbri/keys
agent TENBRI_AGENT Who acts when nothing narrower says: agent:support
approver TENBRI_APPROVER Who answers the frameworks' approval prompts: person:alice
schema TENBRI_SCHEMA The action schemas; default ./tenbri.toml when there is one
fail_open Run actions, unrecorded and with a warning, when their intent cannot be written. Default: block them

Input digests are keyed by the stream's local key store (per subject, so erasing a subject's key leaves its digests unconfirmable): no secret in code. digest_key= keys them yourself instead.

Advanced: the stream itself

init() and @decision are built on this; use it to hold several streams, or to see every call.

from tenbri import Refused, Tenbri

# A directory, file://..., s3://bucket/prefix or r2://bucket/prefix. create=True makes the stream
# and its keys (in $TENBRI_KEYS, else ~/.config/tenbri/keys) when there is none.
log = Tenbri.open("./audit/support", create=True)
print("pin this:", log.fingerprint)

with log.run("agent:support-assistant") as run:
    # Reads are pinned to the next decision's inputs, with a keyed digest of what was read.
    run.read("policy:refund", "14", b"refunds under 50 EUR are automatic")
    # The intent is durable before the block runs; the outcome follows: ok, refused or error.
    with run.decision("issue_refund", "stripe:ch_123"):
        pass  # issue the refund here; raise Refused(...) when your policy says no

report = log.verify(log.fingerprint)
print(report.ok, report.entries)
for m in log.query(inputs=["policy:refund@14"]):
    print(m.verification, m.entry["action"])
log.close()

log.decision is also a decorator; target may be computed from the arguments:

@log.decision("issue_refund", target=lambda charge, amount: f"stripe:{charge}", principal="agent:billing")
def refund(charge: str, amount: int) -> None: ...

With asyncio, AsyncTenbri has the same methods as coroutines, async with decisions and decorators of async functions. Nothing blocks the event loop, and concurrent appends share one group commit.

from tenbri import AsyncTenbri

async with await AsyncTenbri.open("s3://acme-audit/tenbri/support") as log:
    intent = await log.intent(action={"type": "reply_ticket"}, principal="agent:support")
    await log.outcome(intent, "ok")
  • Low level: log.intent(draft, **fields), log.outcome(intent, status, **fields) and log.append(entry) take format v1 drafts as dicts and return entries as stored.
  • Idempotent retries: give a draft an id (tenbri.new_id()); appending the same entry again returns the original. Every write error carries the id it was writing.
  • Errors are typed, one per stable code shared with tenbrid: TenbriError and its subclasses (StoreUnavailableError is TENBRI_STORE_UNAVAILABLE, ...), with .code, .reason (the format's error code) and .id.
  • Read-only: without the stream's keys, a stream opens read-only; verify and query work, writes raise NoSessionKeyError.
  • verify(key) is only ok against a pinned key: without one it shows that the stream agrees with its own genesis key, which proves nothing about who wrote it.

Metadata

Release files for tenbri 0.1.0b4

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

Source distribution (sdist)

Source distribution for tenbri 0.1.0b4
File Size Uploaded Provenance
tenbri-0.1.0b4.tar.gz 163.6 kB With provenance Details

Built distributions (wheels)

Table of built distributions (wheels) for tenbri 0.1.0b4
File
tenbri-0.1.0b4-cp310-abi3-win_amd64.whl CPython 3.10 abi3 Windows x86-64 Details
tenbri-0.1.0b4-cp310-abi3-musllinux_1_2_x86_64.whl CPython 3.10 abi3 Linux musl 1.2+ x86-64 Details
tenbri-0.1.0b4-cp310-abi3-musllinux_1_2_aarch64.whl CPython 3.10 abi3 Linux musl 1.2+ ARM64 Details
tenbri-0.1.0b4-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl CPython 3.10 abi3 Linux glibc 2.17+ x86-64 Details
tenbri-0.1.0b4-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl CPython 3.10 abi3 Linux glibc 2.17+ ARM64 Details
tenbri-0.1.0b4-cp310-abi3-macosx_11_0_arm64.whl CPython 3.10 abi3 macOS 11.0+ ARM64 Details
tenbri-0.1.0b4-cp310-abi3-macosx_10_12_x86_64.whl CPython 3.10 abi3 macOS 10.12+ x86-64 Details

Total release size: 29.8 MB

Release files / tenbri-0.1.0b4.tar.gz

Download URL tenbri-0.1.0b4.tar.gz
Size 163.6 kB
Tags Source
SHA-256 checksum
How to use checksums
2a910734b8b09ec511cbae4a759e8b310a1866aae19283ace73935c824fd4463
BLAKE2b-256 checksum
How to use checksums
a4f91f507c5d273e07766ef33b5248006b2318cfff54a0fc9c1897a9effa6330
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 Oct 20, 2026.

Transparency log

Release files / tenbri-0.1.0b4-cp310-abi3-win_amd64.whl

Download URL tenbri-0.1.0b4-cp310-abi3-win_amd64.whl
Size 4.2 MB
Tags CPython 3.10 Windows x86-64 abi3
SHA-256 checksum
How to use checksums
e181e4541a233f03ac46f6c6110901fd60c033f71f2704978cdb62b0294ac34e
BLAKE2b-256 checksum
How to use checksums
bb1f2971fe42e481d60b75dd7145a827b3f071c112277eaee84548dc76ea3ce5
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 Oct 20, 2026.

Transparency log

Release files / tenbri-0.1.0b4-cp310-abi3-musllinux_1_2_x86_64.whl

Download URL tenbri-0.1.0b4-cp310-abi3-musllinux_1_2_x86_64.whl
Size 4.7 MB
Tags CPython 3.10 Linux musl 1.2+ x86-64 abi3
SHA-256 checksum
How to use checksums
23ace9c5ac33e81b5e4602c95c7d94fe96fb8aeb50ad8168a812b785c33eb41a
BLAKE2b-256 checksum
How to use checksums
1a797e55d5d8c97a4bf6ab6ed8dead771ce8925238598f98cda781378a23df87
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 Oct 20, 2026.

Transparency log

Release files / tenbri-0.1.0b4-cp310-abi3-musllinux_1_2_aarch64.whl

Download URL tenbri-0.1.0b4-cp310-abi3-musllinux_1_2_aarch64.whl
Size 4.4 MB
Tags CPython 3.10 Linux musl 1.2+ ARM64 abi3
SHA-256 checksum
How to use checksums
3945896c1448058f42acc127a6dc48b39c042396c56dca67d679879295f8fe4e
BLAKE2b-256 checksum
How to use checksums
85681d6bcb24bbfd06b4b1d42d37218745b24563be9cbe5821d4f8d9633d5f09
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 Oct 20, 2026.

Transparency log

Release files / tenbri-0.1.0b4-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl

Download URL tenbri-0.1.0b4-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Size 4.4 MB
Tags CPython 3.10 Linux glibc 2.17+ x86-64 abi3
SHA-256 checksum
How to use checksums
a16f7829141eed4d3571cc19cb1c0a4a7aa76279df390f246275ac246156c17b
BLAKE2b-256 checksum
How to use checksums
5893824fb52e670eb5a7e1b9609bb262fb96bb650843b93db74e05a4c380a6b7
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 Oct 20, 2026.

Transparency log

Release files / tenbri-0.1.0b4-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl

Download URL tenbri-0.1.0b4-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Size 4.2 MB
Tags CPython 3.10 Linux glibc 2.17+ ARM64 abi3
SHA-256 checksum
How to use checksums
783f0767de4f044879df202fe308fba8a6e45b1fd919214b7b2d1e0f4a3fed58
BLAKE2b-256 checksum
How to use checksums
c0118787c8455a533e05dddc2ec066355a6d2a3fc56a06477221cc62e6abe3ce
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 Oct 20, 2026.

Transparency log

Release files / tenbri-0.1.0b4-cp310-abi3-macosx_11_0_arm64.whl

Download URL tenbri-0.1.0b4-cp310-abi3-macosx_11_0_arm64.whl
Size 3.5 MB
Tags CPython 3.10 abi3 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
d907f9938ae6b38d7aa07c3787ec6085dce4b7206672343a67e8d864a51decab
BLAKE2b-256 checksum
How to use checksums
87ffe780de690438d9e6d19cea46431588d924319ba9ced3e166b5e40109bae9
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 Oct 20, 2026.

Transparency log

Release files / tenbri-0.1.0b4-cp310-abi3-macosx_10_12_x86_64.whl

Download URL tenbri-0.1.0b4-cp310-abi3-macosx_10_12_x86_64.whl
Size 4.3 MB
Tags CPython 3.10 abi3 macOS 10.12+ x86-64
SHA-256 checksum
How to use checksums
109c06d79a17eb4a08fcc49cf93ed92f1a72fce101228d37f9f808d048186ff5
BLAKE2b-256 checksum
How to use checksums
776712d5d8a0294f39ef494c5ad2ebbf69e25c98fa948d88dea65d196d137685
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 Oct 20, 2026.

Transparency log

Security for tenbri 0.1.0b4

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

Select from 8 files

Attestation for tenbri-0.1.0b4.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 Oct 20, 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.

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