Skip to main content

witness-log (Python)

Python bindings for witness-log-core and witness-log-network, built with PyO3/maturin. Same wire format as the Rust crates and the same guarantees: see the root README.md and THREAT_MODEL.md before using this for anything real. Ships type stubs (py.typed).

Install

pip install ./witness_log-0.3.5-*.whl     # wheel from the Releases page; PyPI publication pending

Until the package is on PyPI, download the wheel for your platform from the GitHub release (abi3 wheels: Linux x86_64/aarch64, macOS x86_64/arm64, Windows x86_64, Python ≥ 3.9) and pip install witness_log-*.whl; SHA256SUMS is next to them. To build from source: pip install maturin && maturin build --release in this directory.

Quickstart: an agent loop

import witness_log

log = witness_log.open("agent.jsonl")        # create, or resume if it exists

@witness_log.step(log)                       # one line per tool
def transfer_funds(amount_usd: int) -> dict:
    return {"status": "ok", "tx_id": "tx_7ac31"}

transfer_funds(250)                          # two leaves: intent, then result
log.sync()                                   # fsync when you need durability

pii = log.append_memory(b"contact: alice@example.com")
log.forget(pii)        # right-to-be-forgotten: the salt is erased from agent.jsonl.salts
                       # and a marker leaf appended; every earlier proof is unchanged.

dossier = log.to_dossier_json()              # the bundle anyone can verify offline
report = witness_log.verify_dossier_json(dossier, 0.66, log.identity_pubkey_hex())
log.close()

witness_log.open(path, identity_seed=None) creates path with a new identity (or identity_seed, 32 bytes you keep) and resumes it on every later run. The journal is two files, agent.jsonl and agent.jsonl.salts, both 0600; the first line of the journal holds the identity private key, so protect and back up both like key material. A process killed while holding the journal leaves agent.jsonl.lock; on Linux resume clears it when the recorded PID is gone, elsewhere call JournaledLog.force_unlock(path) once you are sure nothing else has it open.

Any dossier produced here verifies with the Rust CLI unmodified:

witness-log verify dossier.json --identity <hex> --directory witnesses.json

That cross-language round trip is what the wire format (spec/SPEC.md) and conformance corpus (/corpus/) exist to guarantee.

Getting WITNESSED

A dossier with no independent cosignatures verifies as unanchored (or consistent_unwitnessed with a directory). To reach witnessed, at least two witnesses with distinct operator_org values in the verifier's directory must cosign the head:

body = log.add_checkpoint_body(old_size=0)   # c2sp.org/tlog-witness request
# POST body to each witness's /add-checkpoint (urllib, requests, ...).
# 409 with a number N in the body means: retry with add_checkpoint_body(N).
dossier, accepted = log.dossier_from_responses([(witness_pubkey_hex, response_body), ...])
report = witness_log.verify_dossier_json(dossier, 0.66, log.identity_pubkey_hex(), directory_json)

integrations/mcp/witness_mcp_server.py wraps all of this as MCP tools, including submit_to_witnesses.

Running a witness

WitnessService.new(key_name, seed, state_path, open_enrollment=True) is a witness you can mount in any web framework: hand it the body of each POST /add-checkpoint and send back what it returns. Create its state once with WitnessService.create_state(path); the state file is bound to the witness key and persisted before any cosignature leaves the process. examples/live-network/py_witness.py is a complete 60-line server.

API surface

Everything is typed in python/witness_log/_core.pyi.

witness_log.open(path, identity_seed=None) JournaledLog: create or resume.
witness_log.step(log, name=None, *, record_result=True, sync=False) Decorator: intent leaf before the call, result (or error) leaf after. Sync and async.
witness_log.canonical_json(value) The byte form step hashes.
JournaledLog.create(path, seed) / .create_ephemeral(path) / .resume(path) Explicit constructors; resume returns (log, dropped_trailing_lines).
.append_intent/.append_result/.append_memory(bytes) New leaf index.
.append_handoff_sent/.append_handoff_received(state, counterparty_hex) SPEC §3.1 cross-log binding.
.forget(i) / .can_forget(i) Redaction; works for leaves from earlier sessions.
.checkpoint() / .to_dossier_json() / .leaves_json() JSON, SPEC §6 / §9 / §2.
.inclusion_proof(i) → (tree_size, root_hex, path) Check offline with verify_inclusion(...).
.add_checkpoint_body(old_size) / .dossier_from_responses(...) Witness protocol client.
.sync() / .close() / context manager Durability; releasing the lock.
JournaledLog.force_unlock(path) After a crash, when resume cannot tell the holder is gone.
WitnessLog The in-memory core (snapshots, no salt persistence).
WitnessService A tlog-witness witness.
verify_dossier_json(dossier, threshold, identity=None, directory_json=None) The CLI's verifier; report JSON with verdict, identity_pinned, internally_consistent, quorum.
verify_inclusion(leaf_hash_hex, index, tree_size, path, root_hex) RFC 6962 inclusion check.
select_diverse_witnesses(directory_json, subject_pubkey, want) Pick operator-diverse witnesses from a directory.
witness_entry_independent(...) / witness_entry_project_operated(...) Build directory entries.

Errors: WitnessLogError (base), SignatureError, ContinuityError, MalformedError; I/O failures raise OSError; bad arguments raise ValueError/TypeError. Payloads are bytes.

This crate is intentionally thin: it does not reimplement any serialization logic; every JSON shape here is the Rust crates' own serde output, so it stays in lockstep with spec/SPEC.md by construction.

Metadata

Release files for witness-log 0.3.5

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

Source distribution (sdist)

Source distribution for witness-log 0.3.5
File Size Uploaded
witness_log-0.3.5.tar.gz 232.7 kB Details

Built distributions (wheels)

Table of built distributions (wheels) for witness-log 0.3.5
File
witness_log-0.3.5-cp39-abi3-win_amd64.whl CPython 3.9 abi3 Windows x86-64 Details
witness_log-0.3.5-cp39-abi3-musllinux_1_2_x86_64.whl CPython 3.9 abi3 Linux musl 1.2+ x86-64 Details
witness_log-0.3.5-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl CPython 3.9 abi3 Linux glibc 2.17+ x86-64 Details
witness_log-0.3.5-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl CPython 3.9 abi3 Linux glibc 2.17+ ARM64 Details
witness_log-0.3.5-cp39-abi3-macosx_11_0_arm64.whl CPython 3.9 abi3 macOS 11.0+ ARM64 Details
witness_log-0.3.5-cp39-abi3-macosx_10_12_x86_64.whl CPython 3.9 abi3 macOS 10.12+ x86-64 Details

Total release size: 4.5 MB

Release files / witness_log-0.3.5.tar.gz

Download URL witness_log-0.3.5.tar.gz
Size 232.7 kB
Tags Source
SHA-256 checksum
How to use checksums
8d2ce5014717e32575f5fd6c1e1fdd8ea4c3e42e5e5ae0671cccd4c84dadd1c5
BLAKE2b-256 checksum
How to use checksums
51a71a94173a56c2466c84e7b04b8230af0ee38087324296cb0a4328c0a6ddac
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 11, 2026.

Transparency log

Release files / witness_log-0.3.5-cp39-abi3-win_amd64.whl

Download URL witness_log-0.3.5-cp39-abi3-win_amd64.whl
Size 640.0 kB
Tags CPython 3.9 Windows x86-64 abi3
SHA-256 checksum
How to use checksums
9abf46ad8f2ebb02f121c272880340561bf9f13dfe2c07dd5baa58d3ffbfc6fb
BLAKE2b-256 checksum
How to use checksums
53de0b8fcd37d10037c5605f1595a37ffebca54e2c3a62af6ab16a786e72d35c
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 11, 2026.

Transparency log

Release files / witness_log-0.3.5-cp39-abi3-musllinux_1_2_x86_64.whl

Download URL witness_log-0.3.5-cp39-abi3-musllinux_1_2_x86_64.whl
Size 918.5 kB
Tags CPython 3.9 Linux musl 1.2+ x86-64 abi3
SHA-256 checksum
How to use checksums
3eb75009c5d27ab006e3cb8dfb8a6517897688d0be3b6a70fc1e9177b7505ec1
BLAKE2b-256 checksum
How to use checksums
75e0a96da13f3b13e1eca0d316f8b688ceee4f4196d79caa4325e73635a16b9e
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 11, 2026.

Transparency log

Release files / witness_log-0.3.5-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl

Download URL witness_log-0.3.5-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Size 705.4 kB
Tags CPython 3.9 Linux glibc 2.17+ x86-64 abi3
SHA-256 checksum
How to use checksums
34103f0d9df6a49d17e6ef418847d864de8d223f71b6610b2f2f1383720f1c90
BLAKE2b-256 checksum
How to use checksums
b511f25f1a7d390471c1025ce1d37b92755966a80066080a598f99300f6bbdee
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 11, 2026.

Transparency log

Release files / witness_log-0.3.5-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl

Download URL witness_log-0.3.5-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Size 652.3 kB
Tags CPython 3.9 Linux glibc 2.17+ ARM64 abi3
SHA-256 checksum
How to use checksums
ff30dfbd3855a1a403a501b92466de0055276e4a83e6a6330e5f9fb048a19618
BLAKE2b-256 checksum
How to use checksums
f8bba5509375533ab828dfe1eaee598df88eb0bfe487fb0672cc1d74efe30aa6
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 11, 2026.

Transparency log

Release files / witness_log-0.3.5-cp39-abi3-macosx_11_0_arm64.whl

Download URL witness_log-0.3.5-cp39-abi3-macosx_11_0_arm64.whl
Size 627.2 kB
Tags CPython 3.9 abi3 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
a735f05bc32a78e3adfafe253c61f04b345d1c321e24379d01f76f72352ac9cb
BLAKE2b-256 checksum
How to use checksums
c447dc0b6940e7d9d3ddfda6f5822d3b32bc6fbd3e65bfb5494b97df323e9a2e
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 11, 2026.

Transparency log

Release files / witness_log-0.3.5-cp39-abi3-macosx_10_12_x86_64.whl

Download URL witness_log-0.3.5-cp39-abi3-macosx_10_12_x86_64.whl
Size 676.5 kB
Tags CPython 3.9 abi3 macOS 10.12+ x86-64
SHA-256 checksum
How to use checksums
3b71c8890b678207a99a9ce638b9d8081f9489a4b269096c9f39ddf5f8e43e67
BLAKE2b-256 checksum
How to use checksums
1f43ce4b3dd9b75781c47be5152a0b5b719fc5efaea1fdacb91cb3d42a6e82ef
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 11, 2026.

Transparency log

Release history Release notifications | RSS feed

0.4.2

7 release files

0.4.1

7 release files

0.4.0

7 release files

0.3.6

7 release files

This release

0.3.5 This release

7 release files

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