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. 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.0b2

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.0b2
File Size Uploaded Provenance
tenbri-0.1.0b2.tar.gz 162.1 kB With provenance Details

Built distributions (wheels)

Table of built distributions (wheels) for tenbri 0.1.0b2
File
tenbri-0.1.0b2-cp310-abi3-win_amd64.whl CPython 3.10 abi3 Windows x86-64 Details
tenbri-0.1.0b2-cp310-abi3-musllinux_1_2_x86_64.whl CPython 3.10 abi3 Linux musl 1.2+ x86-64 Details
tenbri-0.1.0b2-cp310-abi3-musllinux_1_2_aarch64.whl CPython 3.10 abi3 Linux musl 1.2+ ARM64 Details
tenbri-0.1.0b2-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.0b2-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl CPython 3.10 abi3 Linux glibc 2.17+ ARM64 Details
tenbri-0.1.0b2-cp310-abi3-macosx_11_0_arm64.whl CPython 3.10 abi3 macOS 11.0+ ARM64 Details
tenbri-0.1.0b2-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.0b2.tar.gz

Download URL tenbri-0.1.0b2.tar.gz
Size 162.1 kB
Tags Source
SHA-256 checksum
How to use checksums
78a72a7e782143b7f870548b42c3496470948bf47d77d31a3971d18994c61711
BLAKE2b-256 checksum
How to use checksums
c3d8e29a7027e557facdb9649fe3d2b5d80ceb2131a233cbbcde9120d03d1459
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 Oct 20, 2026.

Transparency log

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

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

Transparency log

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

Download URL tenbri-0.1.0b2-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
04d08dd13fa3a1af5247aa5decc52c0825cf63f3a053ffdfecf8bc4bcd611ea7
BLAKE2b-256 checksum
How to use checksums
6c57408ba3182a74f1468cc94da6d272fddac9a5efc3bcbfca52f985d2f91e41
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 Oct 20, 2026.

Transparency log

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

Download URL tenbri-0.1.0b2-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
e74525a6399099043ded0239134bbc115e1bd690d2d9758157cb0bfa804b0027
BLAKE2b-256 checksum
How to use checksums
07e0bb70b1f72dc995aa8e38f0896ad29189e4d6d198288fb245e8eb34a9501b
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 Oct 20, 2026.

Transparency log

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

Download URL tenbri-0.1.0b2-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
9077d06661138db2cffaa250423fa8f7d9617c2031b37aa5784fcc7f2cbbd0fe
BLAKE2b-256 checksum
How to use checksums
45af3394b058d0f073105d73edab183b6d668ceeecf6f2335436d900afafd514
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 Oct 20, 2026.

Transparency log

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

Download URL tenbri-0.1.0b2-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
13cf5d5fded5b008bf679e3132b09a340eae3b5607f8deb79b9930a234539029
BLAKE2b-256 checksum
How to use checksums
a22eac9ac267fde86b857397618d8e938d8d7a997867f9af6e00ab939dae9632
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 Oct 20, 2026.

Transparency log

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

Download URL tenbri-0.1.0b2-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
04b00b5def48f82c05cf8d9049d1e90b439d9e7934090b905bb654eb029dbb62
BLAKE2b-256 checksum
How to use checksums
3b3feb56a94d684ba20c6214f559686e4e06f38698cc7365f255cd85d9595b38
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 Oct 20, 2026.

Transparency log

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

Download URL tenbri-0.1.0b2-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
c1dfa42b67b9b5ed3317e149869222416053de968a8ba8c6a5f5f5d8f532328c
BLAKE2b-256 checksum
How to use checksums
abd722c0f422fe2ea3ea15cc32fcec3523c8d78cde96690148817793ce665f22
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 Oct 20, 2026.

Transparency log

Security for tenbri 0.1.0b2

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.0b2.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