Skip to main content

Protocolith

Records, verifies and issues trial records.

tests codeql docs OpenSSF Scorecard OpenSSF Best Practices

PyPI Python versions PyPI wheel License: Apache-2.0 DOI

GitHub release Last commit Stars Open issues Discussions Top language

Core coverage 100 percent Runtime dependencies: none Platforms MCP server Typed Lint: ruff DCO Type checking: mypy strict Mutation score 90.7 percent Anchors: git tag, Wayback, RFC 3161 AI use disclosed Evidence cards

Animation: why a result is hard to check, then freeze, record, verify, anchor and publish only what you choose, with the hash chain catching an edited or cut-off ledger

Why

A result is easy to believe and hard to check when the protocol was written after the run, the history can be edited silently, or a failed run quietly disappears. Protocolith keeps a small local record that makes those three things visible: what was fixed beforehand, what happened, and whether the history still adds up.

It does not run experiments, fetch data or judge whether a protocol is a good one. It is a ledger with rules.

What it does

Stage Command What is stored
1. Freeze a protocol before the run protocolith freeze protocol.json The protocol and its SHA-256
2. Record the outcome against that protocol protocolith record record.json Status, outcome, source hashes, claim boundary
3. Verify the hash-chained history protocolith verify-ledger Nothing; it reports rule violations (R1 to R11)
4. Issue a card from a verified record protocolith issue SEQ A JSON and SVG card, plus an issue entry
6. Disclose a view of the ledger protocolith disclose --policy FILE A public file: each entry in full, as a summary, or hidden
5. Anchor the head outside your disk protocolith anchor An anchor statement; optional git tag, Wayback or RFC 3161 time-stamp

Everything lives in one append-only file, .protocolith/ledger.jsonl, one canonical JSON line per entry. Each line contains the hash of the line before it. The core uses only the Python standard library.

Three interfaces (CLI, Python API, MCP server) call one standard-library core that writes a ledger, cards and anchors

Quickstart (2 minutes)

You need the repository checkout with its environment active (see Install). The example files are in examples/quickstart/: protocol.json, record.json and the source results.txt.

source .venv/bin/activate          # Windows: .venv\Scripts\activate
mkdir demo && cd demo
cp ../examples/quickstart/protocol.json ../examples/quickstart/record.json ../examples/quickstart/results.txt .
protocolith freeze protocol.json
protocolith record record.json
protocolith verify-ledger
protocolith issue 1
protocolith log
protocolith head

Real output of one run (hashes and times differ in yours, because the entries contain the time):

$ protocolith freeze protocol.json
frozen QUICKSTART_D001 1 seq=0 hash=5bbd5c8c75437c20d77415469374ac990993803c1c9deed91ff6adf2f74714b2 protocol_sha256=802a1675aef8623a44d79272ca50c036ffc7c2d2ecd267ca440afdb19948369f
$ protocolith record record.json
recorded run-1 PASSED_UNDER_PROTOCOL seq=1 hash=...
$ protocolith verify-ledger
OK entries=2 head seq=1 hash=...
$ protocolith issue 1
issued record seq=1 card_sha256=...
.protocolith/cards/PLITH-QUICKSTART_D001-<date>-000001.json
.protocolith/cards/PLITH-QUICKSTART_D001-<date>-000001.svg
$ protocolith log
0 freeze <time> 5bbd5c8c7543 QUICKSTART_D001 1
1 record <time> e6fdb7f2c7f6 run-1 PASSED_UNDER_PROTOCOL
2 issue <time> 7e991c8d63f3 record_seq=1
$ protocolith head
seq=2 hash=7e991c8d63f3f661894015c450b41cdb3809af305af4f562f8224466314eecd7

The protocol_sha256 printed by freeze is already written into record.json; a record that names a hash that was not frozen earlier is rejected (UNKNOWN_PROTOCOL). To see verification fail, change one character in .protocolith/ledger.jsonl and run protocolith verify-ledger again: it prints the violated rules and exits with 1.

Exit codes: 0 ok, 1 the stored ledger does not verify, 2 the operation was rejected and nothing was written, 3 I/O or environment error. --json prints canonical JSON for every command. These steps are run by tests/test_readme_examples.py.

Query the ledger

protocolith summary                  # what was done and which results are honest, in one call
protocolith log --status BLOCKED_SOURCE
protocolith show 1

See Query the ledger quickly.

Python API

from pathlib import Path

from protocolith import core

store = core.Store(".protocolith")
core.freeze(store, core.decode(Path("protocol.json").read_bytes()))
core.record(store, core.decode(Path("record.json").read_bytes()))

verdict = core.verify(store)
print(verdict.ok, verdict.count)          # True 2

result = core.issue(store, 1)
print(result["json_path"])
print(core.head(store))                   # {'count': 3, 'hash': '...', 'seq': 2}

Errors are exceptions with a stable code (core.InputError, core.EnvError, core.VerificationFailed). See the Python API guide.

Atlas: browse the experiments

protocolith atlas builds one self-contained HTML page (inline CSS and JavaScript, no network, works from file://) from the local ledger or a directory of evidence cards: summary tiles, a status chart and monthly timeline, search, filters, a sortable paged table and a detail drawer with permalinks. Languages other than English come only from files you supply. See the atlas guide.

Tour of the atlas: overview with filters and charts, then a full record, a summary and a hidden record

protocolith atlas --out atlas.html            # the local ledger
protocolith atlas --cards docs/evidence_cards --out site/

Publish what you choose: full, summary or hidden

A researcher may keep thousands of entries and publish a few. protocolith disclose --policy policy.json writes a view of the ledger in which each entry is shown in full, as a summary or hidden (only its place and hash). The chain stays intact, so a reader sees how many entries exist and that none was dropped; the owner can reveal a hidden entry later and anyone checks it. protocolith atlas --policy policy.json builds the matching browsable page. See the guide and the example.

Eight ledger entries pass through a policy; the published view shows each in full, as a summary or hidden, and the chain stays linked

Terminal recording: disclose with a policy, verify, reveal a hidden entry, then a dropped entry is caught

Anchor the head, and catch a cut-off ledger

A ledger is a file its owner writes, so plain verification cannot notice that the last entries were removed. An anchor puts the head somewhere you cannot edit alone; verify-ledger --anchors then catches a rewrite (ANCHOR_MISMATCH) or a truncation (ANCHOR_AHEAD). One 32-byte head covers every earlier entry, so ten thousand experiments need one anchor, not ten thousand uploads. Details: anchor your results.

Terminal recording: the last ledger entry is removed, plain verify-ledger still passes, verify-ledger --anchors fails with ANCHOR_AHEAD

Example: a published study as a record

examples/phantom_mean_reversion/ holds a simulation study (rolling hedge ratios make a spread backtest look profitable on random walks) as a frozen protocol, two anchors and a card. python3 reproduce.py re-runs it in about five seconds and compares the output with the committed results (identical bytes here, equal to within rounding on other platforms). It is a retrospective record, and its README says what that does and does not prove.

Bar chart: booked Sharpe 4.4 to 14.8 against tradable Sharpe near zero, for five windows

MCP client configuration

protocolith mcp is a stdio server with fifteen tools (protocolith_summary, protocolith_log, protocolith_show, protocolith_schema, protocolith_capture, protocolith_atlas, protocolith_claim_check, protocolith_anchor, protocolith_disclose, protocolith_verify_disclosure, protocolith_freeze, protocolith_record, protocolith_deviation, protocolith_verify, protocolith_issue) read-only resources (protocolith://summary, protocolith://ledger, protocolith://schema/<name>) and the prompt research-agent-protocol, so an agent can discover the formats and the rules itself; protocolith_claim_check tells it what it may and may not say about a result. It uses the network only when protocolith_anchor is given a time-stamp URL, and writes only inside the store, apart from the atlas page and the disclosure file that protocolith_atlas and protocolith_disclose write inside the working directory. Add it to an MCP client:

{
  "mcpServers": {
    "protocolith": {
      "command": "protocolith",
      "args": ["mcp", "--store", "/path/to/project/.protocolith"]
    }
  }
}

See Use Protocolith from an AI agent and the MCP reference.

Install

From source today (Python 3.11 to 3.15; uv recommended):

git clone https://github.com/protocolith/protocolith.git
cd protocolith
uv sync
uv run protocolith --version      # or: source .venv/bin/activate

pip install protocolith installs the current release from PyPI (since 0.6.0). The package has no required dependencies.

Platforms

macOS, Linux and Windows, Python 3.11 to 3.15, headless (no display, no network, no daemon). Appends are protected by an advisory file lock (fcntl on POSIX, msvcrt on Windows) and are flushed with fsync.

Commands

Command Purpose
freeze FILE [--supersedes SHA256] Freeze a protocol (a new version supersedes the old one)
record FILE Record a run outcome
deviation FILE Record a deviation from a frozen protocol
verify-ledger [--expect-head SEQ:HASH] Check rules R1 to R11, and optionally an anchored head
issue SEQ [--out DIR] Issue the card of a record
summary [--protocol ID] Verdict, head, counts and a per-protocol table in one call
log [--protocol ID] [--type T] [--status S] [--tail N] / head List (filtered) entries / print the last seq and hash
show SEQ One entry with its protocol context
capture [--file PATH ...] [--env] JSON fragment with environment and input file hashes for a record outcome
schema [NAME] JSON Schema of the input bodies and the entry
init Create an empty store (safe to repeat)
repair --truncate-partial-tail Remove a partial last line left by a crash
mcp Run the MCP server on stdio

All take --store DIR (or PROTOCOLITH_STORE; default .protocolith) and, except mcp, --json. The alias plith runs the same program. Full list, including the older card commands: docs/CLI.md.

Documentation

What Protocolith does not prove

  • Internal consistency and ordering only. A valid ledger shows that every entry follows the rules and that no entry was changed or reordered without breaking the chain.
  • No wall-clock proof. Timestamps are written by the machine that appends; the ledger only guarantees they never decrease. It does not show that an entry was made at the time it states.
  • No protection against replacing a whole ledger. Someone who can rewrite the file can write a new, valid one, or cut off its end. Publish or anchor the output of protocolith head somewhere you do not control alone (for example a signed git tag), then check against it with protocolith verify-ledger --expect-head SEQ:HASH. See anchoring the head. protocolith anchor automates this (a local anchor file, and optionally an RFC 3161 time-stamp, a Wayback snapshot or a git tag), and verify-ledger --anchors detects a rewritten or truncated ledger: see anchor your results.
  • It does not show that a protocol is sound, that data is true, or that a result generalises.

Earlier name and unrelated works

The project was published as ClaimBound Evidence until 0.5.0 and was renamed because unrelated works use a similar name. It is not a fork of or affiliated with them, and it makes no claim of priority. See RELATED_WORK_AND_INDEPENDENCE.md.

Contributing, security, license

Metadata

Release files for protocolith 0.7.0

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

Source distribution (sdist)

Source distribution for protocolith 0.7.0
File Size Uploaded Provenance Actions
protocolith-0.7.0.tar.gz 151.5 kB With provenance Details for protocolith-0.7.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for protocolith 0.7.0
File Interpreter ABI Platform Actions
protocolith-0.7.0-py3-none-any.whl Python 3 none any Details for protocolith-0.7.0-py3-none-any.whl

Total release size: 320.0 kB

Release files / protocolith-0.7.0.tar.gz

Download URL protocolith-0.7.0.tar.gz
Size 151.5 kB
Tags Source
SHA-256 checksum
How to use checksums
6302248d520f576eabef074d4dc484f920e9c8939345c267a2376d690a630c7a
BLAKE2b-256 checksum
How to use checksums
dd93325e2f224cc1abfde658bcbe23d5042cdace8cfa8a39ac6ee3bf99456c76
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 Nov 18, 2026.

Transparency log

Release files / protocolith-0.7.0-py3-none-any.whl

Download URL protocolith-0.7.0-py3-none-any.whl
Size 168.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
b949f6eca44813426189c360c545b672aec009f72af2a9ad83b30049f1508d32
BLAKE2b-256 checksum
How to use checksums
b37fb86fd31b6e4a4badd7ab6504c21017b4a5655c925fc1a13da809e2cbdbe4
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 Nov 18, 2026.

Transparency log

Security for protocolith 0.7.0

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

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for protocolith-0.7.0.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 Nov 18, 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.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.7.0 This release

2 release files Full provenance

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