second-desk-provenance
Official# Second Desk Provenance
Every fact ships with its receipt: a signed capsule that ties a record to the source extract it came from, so a stranger can check the claim mechanically instead of trusting the seller.
I sell data. Every dataset I ship rests on the same request: believe me. Believe the count, believe the date, believe the row came from the register I say it came from. That request does not scale, and it should not have to be made. Provenance is the engine I built to stop making it. When a record is captured, Provenance seals it into a capsule: the record, where it came from, the hash of the exact source extract it was taken from, and the time it was retrieved, signed with an Ed25519 key whose public half anyone can hold. From that moment the claim checks itself. A buyer recomputes the hashes, checks the signature, and gets a verdict with the full evidence trail. No account with me, no call home, no trust required.
The capsules also chain. Every attestation appends to one chain, each entry linked to the one before it, and every day the chain folds into a signed root artifact that a static page can carry and a mirror can copy byte for byte. That is the part that cannot be backfilled: a root published today proves the records existed today, in this order, in this form. Quietly changing a record later, or quietly moving its date, breaks the chain in a place anyone can point to.
Version 2 makes the capsule the single envelope for everything, not just data records. One capsule shape carries four record types. A FACT is a data record with its source. An OBLIGATION is a dated duty with its due date: the register rows of the countdown engine that tracks what falls due, for whom, and what it costs to miss. A SOURCE is an entry describing where a dataset lives: the source map rows, holder, contents, access, cadence, scale with the basis the scale rests on, and the legal note the entry is held under. An EXPERIENCE is a lesson or an event with its outcome, written by a person or by an AI: the builds, predictions, and results of the operation itself. Every version 2 capsule also carries a link to the author previous capsule, sealed inside the body, so each author capsules form a personal chain inside the chain, and a link that was swapped or removed fails verification against it. Version 1 capsules keep verifying under their own rules; every one of them reads as a FACT capsule whose author link is its chain position.
The gate is three things, and all three are built. The spec is open: FORMAT.md defines the format field by field, states at its top that the format belongs to no company, and is written so a stranger can implement from it alone. The export is real: one command writes out everything an author has sealed, every capsule in chain order in the open format, plus the author public key and the daily roots covering them, as one portable bundle, with a count and a fold over the capsule ids so a capsule dropped later is detectable. And the verifier stands alone: one self contained Python file in standalone/, standard library only, that reads a capsule or a bundle and returns the verdict and the evidence trail with no server and none of this code tree. If I vanished tomorrow, the proofs would still stand and still travel.
The numbers up front, all of them from the test record in this repo: eight tools across two doors (an MCP server and a REST service, one core). Eighty six tests, all passing, including the tamper suite where planted attacks must fail: an altered record, a swapped date, a capsule forged under a stranger key, an extract that does not match, a chain entry removed, a chain entry altered, a daily root backdated, a record type swapped on a sealed capsule, an author link replaced with another capsule id, an author link removed, an obligation due date moved, and an export bundle with one capsule silently dropped. The gate tests run the standalone verifier from a different directory, with none of this package importable, against a fresh capsule, a tampered capsule, a version 1 capsule, and an export bundle, and it lands on the same verdicts. The signing code is Ed25519 in pure Python and it reproduces the RFC 8032 test vector exactly. And the worked example runs on real records: five rows from my court records dataset, attested, sealed into a daily root, and verified end to end.
## Tools
| Tool | What it does |
| --- | --- |
| attest_record | Wraps one record in a signed capsule: the record, its record type (FACT, OBLIGATION, SOURCE, or EXPERIENCE), its source reference, the hashes of the source extracts it rests on, and the retrieval timestamp. Seals the unified version 2 envelope by default. Appends to the chain when one is configured, and seals the author link from the chain itself. |
| verify_capsule | Recomputes every hash, checks the signature, checks the signer against a trusted key when you supply one, checks the chain link when a chain is supplied, and checks the author link against the author chain. Reports the record type with the verdict and the full evidence trail in one response. |
| verify_feed_sample | Verifies a batch of records from one feed against their capsules and extracts, one verdict per record plus a summary count. Feed samples carry FACT capsules only. |
| capsule_inspect | Reads a capsule in one pass: its record type, the payload fields it covers, its source, its hashes, its timestamps, its signer, its author link, its chain link. Verifies nothing. |
| export_author | Writes out everything one author has sealed: every capsule by that author key, in chain order, in the open format, plus the author public key and the daily roots covering them, as one portable bundle with a count and a fold that make a dropped capsule detectable. |
| chain_status | Reports the chain state: entry count, the dates covered, the head entry, and the root artifacts on file. |
| chain_verify | Verifies the whole chain: every entry link, every capsule in it, and every daily root artifact. A removed entry, an altered entry, and a backdated root all fail here. |
| chain_seal_day | Folds one day of the chain into its signed root artifact, ready to publish unchanged. |
The REST service exposes the same operations over HTTP (attest, verify, verify sample, inspect, capsule lookup by id, chain status, chain verify, seal day, export), bound to localhost by default. The verify response is the complete verdict object, evidence trail included, in one response: it is the response a public verify page renders.
The format is a contract, not an implementation detail: FORMAT.md defines the capsule in both versions, the chain entry, the daily root, and the export bundle field by field. INTEGRATION.md is the exact contract the writers follow: the feeds for FACT capsules, the countdown register for OBLIGATION capsules, the source map for SOURCE capsules, and the operation itself for EXPERIENCE capsules.
## Setup
You need Python on the machine. I test on Python 3.12. The server is Python standard library only: nothing to install.
1. Make a signing key. The private half stays on your machine, outside any repo, with owner only permissions. The public half is made to be published.
```
PYTHONPATH=server/src python3 -m provenance keygen ~/.second-desk-provenance
```
2. Point your MCP client at the server, with the key and the chain in the environment:
```json
{
"mcpServers": {
"provenance": {
"command": "python3",
"args": ["-m", "provenance"],
"env": {
"PYTHONPATH": "/path/to/provenance/server/src",
"PROVENANCE_SIGNING_KEY": "/home/you/.second-desk-provenance/signing-key.json",
"PROVENANCE_CHAIN": "/home/you/provenance-chain.jsonl",
"PROVENANCE_ROOTS": "/home/you/provenance-roots"
}
}
}
}
```
3. Attest at capture time, verify anywhere, seal the day after it closes in UTC with chain_seal_day, and publish the root artifact unchanged.
To run the REST service instead: PYTHONPATH=server/src python3 -m provenance rest (it binds 127.0.0.1, port 8791, unless PROVENANCE_REST_HOST and PROVENANCE_REST_PORT say otherwise).
If you would rather run it in a container, the Dockerfile in this repo builds the same stdio server.
## Examples
The worked example in examples/ reads five real rows from the Court Records Search sample store, attests them, seals the day, and verifies everything. Its output, from the run recorded in TEST-EVIDENCE.md:
```
Records read from the sample store: 5
attested docket 5641305 as capsule 828aaa314cf0069d (sequence 1)
...
Daily root for 2026-12-01: 3e545d570463f372fe5c7d92b8e8006f6fda80453ec0a18fcbb87a48bf06afa7
First capsule verdict: VERIFIED
check structure True
check record_hash True
check extract_hash True
check capsule_id True
check signature True
check signer_trust True
check chain_link True
Feed sample: 5 of 5 verified
Chain verdict: VERIFIED (5 entries, capsules {"VERIFIED": 5, "FAILED": 0, "INVALID": 0})
Worked example result: ALL VERIFIED
```
And the production chain is already running. It started on December 1, 2026, with the same five court records as its first entries, under signer key id c3a0999a09b8f2b7. The first daily root hash is 28d5697819dcf042cb0200d6b422204468848a77805f171324b4802ba2e48ae1, and the artifact sits in chain/roots/2026-12-01.json in this repo, next to the chain file itself. The public key is in keys/seconddesk-provenance.pub.json. Anyone can verify that root today, and every root after it chains back to this one. That is the point of starting now: yesterday root cannot be made tomorrow.
The chain now holds nine entries. The first five are the version 1 fact capsules the root was sealed over; the root covers exactly the sequence range it declares, entries 1 through 5, and it has not been touched since it was sealed. Entries 6 through 9 are version 2 EXPERIENCE capsules seeded the same night: the Glama dummy key failure and its fix, the Bulwark build, the Citadel build, and the Provenance build itself, each resting on the build record it came from, hashed the same way a fact rests on its source. Version 1 and version 2 entries sit in one chain, under one key, and the whole chain verifies end to end. The seed script is examples/seed_experience_capsules.py; the extracts the seeds rest on are snapshotted in examples/seed-extracts/, so their hashes still check after the living evidence files grow.
## Limits
Know the limits before you rely on it. A capsule proves the record matches the source extracts captured at the time stamped on it, and that it sits where its author chain says it sits. It does not prove the source itself was right. If the register was wrong, the capsule faithfully proves you copied the register. And it does not prove that the lesson in an experience record is true, only that its author wrote it, signed it, and has not quietly rewritten it since. Verification is only as strong as the trusted key: a signature proves a capsule matches the key inside it, and only checking that key against the published key proves whose capsule it is, which is why the signer_trust check reports not checked when no trusted key is supplied, instead of quietly passing. A check whose input was not supplied, like the extract check on a capsule verified without its extract, is reported as not checked in the same response, never as passed. The chain proves order and existence from the day it started; it says nothing about records captured before it existed, and nothing in this repo backdates a claim into it. The daily root protects history only once it is published somewhere the signer cannot rewrite, so publish it, and mirror it. Pure Python Ed25519 signs a capsule in tens of milliseconds, which is plenty for record attestation and the wrong tool for signing a million rows a minute. The MCP server speaks stdio; the REST service is a plain HTTP service on localhost by default, and putting it on a public address with attestation open means anyone can ask your key to sign, so attest behind your own gate or not at all.
## License
MIT. The code is open; what a purchase buys is the finished package, the setup help, and the support.
TDQS
Scored across 8 tools
Each tool targets a distinct action and scope: attest (create), inspect (read-only), verify_capsule (single), verify_feed_sample (batch), chain_verify (whole chain), chain_status (report), chain_seal_day (seal), export_author (bundle). The cluster of verify_* tools could momentarily be confused, but the descriptions clearly bound single-capsule vs batch vs whole-chain verification, and capsule_inspect explicitly contrasts itself with verify_capsule.
The set mixes verb_noun (verify_capsule, attest_record, export_author, verify_feed_sample) with noun_verb (capsule_inspect, chain_status, chain_verify, chain_seal_day). Names remain readable and domain words (capsule, chain, verify) are reused sensibly, but the ordering convention is not predictable.
Eight tools map cleanly onto the lifecycle of a provenance chain: create, inspect, verify at three granularities, seal a day, report status, and export. Nothing looks redundant or missing for the stated scope.
Create, read, verify, chain-seal, status, and portable export are all covered, giving a full provenance lifecycle with no dead ends in the happy path. Minor gaps exist around revocation/key management and there is no general query/list tool beyond export_author, but these are workarounds rather than blockers.