Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,5 @@ tmp/primary_sources/
_site/
packaging/build/
.release_gate/

!examples/phantom_mean_reversion/evidence/.protocolith/ledger.jsonl
18 changes: 18 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,24 @@

### Added

- **Example `examples/phantom_mean_reversion/`.** A published simulation study as a retrospective record: frozen protocol, two
anchors, a card, and `reproduce.py`, which re-runs the study (numpy only, about five seconds) and compares the output with the
committed results (IDENTICAL, or EQUAL within 1e-9 where floating-point rounding differs). The README states plainly what a retrospective record proves and what it does not.
- **External anchoring of the ledger head.** `protocolith anchor` (also `core.anchor_head` and the MCP tool `protocolith_anchor`)
writes an anchor statement (canonical JSON of the head; its sha256 is the `anchor_id`) to `<store>/anchors/`, and optionally
adds an RFC 3161 time-stamp (`--tsa URL`; the signature is not verified by the core, the `openssl ts -verify` command is printed),
a Wayback snapshot (`--wayback URL`), a local git tag (`--git-tag [--sign]`, never pushed) and a statement file
(`--write-head FILE`). Nothing networked or git-related happens without its option. `verify-ledger --anchors`
(`core.verify(store, anchors=True)`, `core.verify_anchors`, MCP `protocolith_verify` with `anchors`) reports
`ANCHOR_MISMATCH` (ledger rewritten), `ANCHOR_AHEAD` (truncated) and `ANCHOR_INVALID`; `summary` shows the number of
anchors and the last anchored `seq`. New error codes: `ANCHOR_MISMATCH`, `ANCHOR_AHEAD`, `ANCHOR_INVALID`,
`ANCHOR_EXISTS`, `ANCHOR_FAILED`, `NOT_A_GIT_REPO`, `EMPTY_LEDGER`, `BAD_URL`. Conformance vectors: `spec/vectors/anchors.json`.
Specification section 13 and the guide [Anchor your results](docs/guides/anchor-your-results.md).
- **`claim_check`** (`protocolith claim-check --seq N | --protocol ID`, `core.claim_check`, MCP `protocolith_claim_check`):
what may and may not be said about a record (`supported`, `may_say`, `must_not_say`, anchored, frozen before the record,
independent reproduction), from fixed templates. Specification section 14.
- **MCP prompts**: `prompts/list` and `prompts/get` with `research-agent-protocol`, instructions for an AI agent;
`initialize` advertises tools, resources and prompts. The server now has thirteen tools.
- `mypy --strict` runs in CI over `protocolith.core` (`uv run mypy`); `mypy` joins the `dev` extra.
- README badges for status, package, repository and project facts; a ledger and core issue form; a ledger demo GIF generated from a real run (`scripts/build_demo_gif.py`).

Expand Down
45 changes: 39 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@
<a href="src/protocolith/py.typed"><img alt="Typed" src="https://img.shields.io/badge/typing-py.typed-blue"></a>
<a href="pyproject.toml"><img alt="Lint: ruff" src="https://img.shields.io/badge/lint-ruff-261230"></a>
<a href="CONTRIBUTING.md"><img alt="DCO" src="https://img.shields.io/badge/DCO-signed--off-blue"></a>
<a href="docs/development/testing.md"><img alt="Type checking: mypy strict" src="https://img.shields.io/badge/mypy-strict-2a6db2"></a>
<a href="docs/development/testing.md"><img alt="Mutation score 90.7 percent" src="https://img.shields.io/badge/mutation%20score-90.7%25-brightgreen"></a>
<a href="docs/guides/anchor-your-results.md"><img alt="Anchors: git tag, Wayback, RFC 3161" src="https://img.shields.io/badge/anchors-git%20%7C%20Wayback%20%7C%20RFC%203161-8A2BE2"></a>
<a href="docs/AI_USE.md"><img alt="AI use disclosed" src="https://img.shields.io/badge/AI%20use-disclosed-lightgrey"></a>
<a href="docs/registry/evidence_index.json"><img alt="Evidence cards" src="https://img.shields.io/badge/dynamic/json?url=https%3A%2F%2Fraw.githubusercontent.com%2FProtocolith%2Fprotocolith%2Fmain%2Fdocs%2Fregistry%2Fevidence_index.json&query=%24.card_count&label=evidence%20cards&color=0A97BB"></a>
</p>
Expand Down Expand Up @@ -69,10 +72,15 @@ It does not run experiments, fetch data or judge whether a protocol is a good on
| 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 |
| 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.

<p align="center">
<img src="docs/assets/protocolith/architecture.svg" alt="Three interfaces (CLI, Python API, MCP server) call one standard-library core that writes a ledger, cards and anchors" width="760">
</p>

## Quickstart (2 minutes)

You need the repository checkout with its environment active (see [Install](#install)). The example files are in
Expand Down Expand Up @@ -163,13 +171,36 @@ protocolith atlas --out atlas.html # the local ledger
protocolith atlas --cards docs/evidence_cards --out site/
```

## 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](docs/guides/anchor-your-results.md).

<p align="center">
<img src="docs/assets/protocolith/anchor-demo.gif" alt="Terminal recording: the last ledger entry is removed, plain verify-ledger still passes, verify-ledger --anchors fails with ANCHOR_AHEAD" width="760">
</p>

## Example: a published study as a record

[`examples/phantom_mean_reversion/`](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.

<p align="center">
<img src="docs/assets/protocolith/phantom-chart.svg" alt="Bar chart: booked Sharpe 4.4 to 14.8 against tradable Sharpe near zero, for five windows" width="640">
</p>

## MCP client configuration

`protocolith mcp` is a stdio server with eleven tools (`protocolith_summary`, `protocolith_log`, `protocolith_show`,
`protocolith_schema`, `protocolith_capture`, `protocolith_atlas`, `protocolith_freeze`, `protocolith_record`,
`protocolith_deviation`, `protocolith_verify`, `protocolith_issue`) and read-only resources (`protocolith://summary`, `protocolith://ledger`,
`protocolith://schema/<name>`), so an agent can discover the formats itself. It uses no network and writes only
inside the store, apart from the atlas page that `protocolith_atlas` writes inside the working directory. Add it to an MCP client:
`protocolith mcp` is a stdio server with thirteen tools (`protocolith_summary`, `protocolith_log`, `protocolith_show`,
`protocolith_schema`, `protocolith_capture`, `protocolith_atlas`, `protocolith_claim_check`, `protocolith_anchor`, `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 that `protocolith_atlas` writes inside the working directory. Add it to an MCP client:

```json
{
Expand Down Expand Up @@ -240,7 +271,9 @@ All take `--store DIR` (or `PROTOCOLITH_STORE`; default `.protocolith`) and, exc
- **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](docs/guides/anchoring-the-head.md).
See [anchoring the head](docs/guides/anchoring-the-head.md). `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](docs/guides/anchor-your-results.md).
- It does not show that a protocol is sound, that data is true, or that a result generalises.

## Earlier name and unrelated works
Expand Down
22 changes: 22 additions & 0 deletions docs/CLI.md
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,28 @@ Verify the ledger (rules R1 to R11).
- `--store STORE` — Store directory (env PROTOCOLITH_STORE, default .protocolith).
- `--json` — Print the result as canonical JSON.
- `--expect-head SEQ:HASH` — Also require the entry at SEQ to have this hash (detects a removed tail); else HEAD_MISMATCH, exit 1.
- `--anchors` — Also check every anchor in the store: ANCHOR_MISMATCH (rewritten), ANCHOR_AHEAD (truncated), exit 1.

## `protocolith anchor`

Anchor the ledger head: a local anchor file, and optionally a time-stamp, an archive copy or a git tag.

- `--store STORE` — Store directory (env PROTOCOLITH_STORE, default .protocolith).
- `--json` — Print the result as canonical JSON.
- `--tsa URL` — Also get an RFC 3161 time-stamp (a network request; the signature is not verified here).
- `--wayback URL` — Ask the Wayback Machine to save URL, where you published the statement.
- `--git-tag` — Create the git tag anchor/SEQ-HASH12 in this repository (never pushed).
- `--sign` — Sign the git tag (needs --git-tag and a configured key).
- `--write-head FILE` — Write the anchor statement to FILE to publish or archive it.

## `protocolith claim-check`

State what the ledger supports about a record (what may and may not be said).

- `--store STORE` — Store directory (env PROTOCOLITH_STORE, default .protocolith).
- `--json` — Print the result as canonical JSON.
- `--seq N` — The record at ledger seq N.
- `--protocol ID` — The latest record of this protocol_id.

## `protocolith issue`

Expand Down
27 changes: 14 additions & 13 deletions docs/assets/protocolith/README_ASSETS.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,22 @@ FILES (bytes)
concept_c.svg 7011
contact_sheet.svg 109897
demo.gif 415254
favicon.svg 422
logo-dark.svg 2311
logo-mark-512.png 4421
logo-mark.svg 1359
logo.svg 2312
social-preview.png 21448
social-preview.svg 23661
favicon.svg 1805
logo-dark.svg 6446
logo-mark-512.png 49461
logo-mark-dark.svg 5511
logo-mark.svg 5511
logo.svg 6446
social-preview.png 53522
social-preview.svg 27839
workflow.gif 92014

All SVGs are pure vector with outlined text (no external fonts, no raster) and carry <title> and <desc>.
Wordmark "Protocolith": own monoline geometric letterforms (stroked paths, no font involved).
Tagline and contact-sheet labels: outlined from Source Sans Pro (SIL OFL 1.1, embedding outlines permitted).
Palette (chosen concept B): stone blue #1F3A5F (light) / #3E6BA8 (dark), facet #3B5E8F / #5B8AC9,
hash ticks amber #E8B04A / #F0B545, ink #17202B, light text #EEF2F6, dark ground #0E141B.
Text contrast (WCAG): ink on white 16.4:1, light text on dark 16.5:1, tagline #B4BFCB on dark 9.9:1.
CURRENT LOGO (concept E, chosen 2026-11-18): an isometric monolith with an amber P carved in its left face, standing on four
strata slabs, one slab per ledger layer; the slab edges carry hash-like ticks (heights from the first hex digits of
SHA-256("protocolith")), the amber rule along the top edge marks the ledger head. Generated by scripts/build_logo.py
(plain SVG, no fonts for the mark; the wordmark paths come from the earlier lockup). favicon.svg is a simplified version
(two slabs, no ticks). logo-mark-512.png is rendered from logo-mark.svg. Earlier concepts A, B and C are kept below.


CONCEPTS
A Monolith: faceted slab, carved dashed lines read as protocol steps, last step amber.
Expand Down
Binary file added docs/assets/protocolith/anchor-demo.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
33 changes: 33 additions & 0 deletions docs/assets/protocolith/architecture.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Loading