Skip to main content

receipt-gate

Agents say "done". This checks.

An agent reporting completion is not evidence of completion. receipt-gate sits between the claim and the record: the claim is held until an independent adapter observes the promised state in reality.

Why this exists. Per-step reliability multiplies. At 85% per step, a 10-step workflow finishes end to end about 20% of the time. The usual answer is retries, checkpoints and idempotency keys. Those protect you from doing a thing twice. They do not establish that the thing happened at all.

The gate is on the sentence, not on the action.

What it does

  • A promise names one observable future state, a deadline, a damage ceiling, and which adapter will check it.
  • A capability proxy opens only the actions that promise authorises, one call at a time, and returns the exact boundary when it refuses.
  • A receipt adapter observes that state again, from a source that is not the agent's own report.
  • The speech gate holds done — and any unrelated new promise — until the open promise is settled.
  • What does not match is kept as a remainder: the exact gap, what can no longer be treated as finished, what authority is left, and who may accept, cancel or reassign it.

Four terminal states, and they do not mix: fulfilled, cancelled_by_owner, impossible_in_scope, handed_over. Handed over is not fulfilled.

What it does not do

It gives the agent no goal, no legitimacy and no authority. It does not make a bad promise good — if the owner picked the wrong target, the gap will be measured against the wrong target. It only refuses to let the distance between stated and happened stay invisible.

No scoring, no leaderboard, no model in the loop. An adapter re-reads state; it does not have an opinion.

Install

Python 3.10+, standard library only, no dependencies.

git clone https://github.com/adekvatologiy/receipt-gate
cd receipt-gate
python -m examples.first_ride

Thirty lines

from receipt_gate import Ledger, Promise, SpeechGate, ManifestAdapter, Held

ledger = Ledger("ledger.jsonl")          # append-only, hash-chained
gate = SpeechGate(ledger)

promise = Promise(
    deal_id="D-1",
    promise_id="P-1",
    holder="agent-1",
    promised_state="manifest.json matches a fresh read of the sources",
    receipt_adapter="manifest+sha256",   # named before acting
    authority=["read:sources", "write:manifest.json"],
    damage_ceiling=["write:sources/*", "delete:*", "rename:*"],
    owner="result-owner",
)
gate.open_promise(promise)

# ... the agent works, then says it finished ...

try:
    gate.claim_done("P-1")
except Held as exc:
    print(exc)        # 'done' needs a fresh receipt from 'manifest+sha256';
                      # a report by the holder is not one

adapter = ManifestAdapter("manifest.json", sources)
adapter.before = adapter.snapshot()      # taken before the ride

settlement = gate.claim_done("P-1", adapter.observe())
print(settlement.state)                  # fulfilled — or a remainder is written
if settlement.remainder:
    print(settlement.remainder.gap)      # the exact fact that did not match

The first ride

The example is deliberately boring and completely checkable: build a manifest of seven immutable source files with size and SHA-256, under a damage ceiling of "no source may be written, renamed or deleted". A separate validator re-reads all seven afterwards and compares.

Four agents run against the same promise:

agent what happens
honest writes a correct manifest, receipt matches, promise settles
claiming writes nothing, says it finished — held, no receipt
sloppy one stale digest — remainder with the exact mismatch, debt stays open
reckless tries to touch a protected source — refused with the ceiling that refused it

A manifest can also be internally consistent and still fail: the adapter compares against the state recorded before the ride, so a source edited behind the gate is seen even when the manifest agrees with the new bytes.

As an MCP server

RECEIPT_GATE_LEDGER=./ledger.jsonl RECEIPT_GATE_ROOT=. receipt-gate

Ten tools over stdio, and the surface is the construction rather than a way around it. claim_done is held every time, because a tool call by the holder is a report by the holder; the reply names the adapter that can answer instead. settle runs that adapter and returns what it saw.

tool what it does
open_promise records one observable state, the authority, the ceiling, and the adapter with its own parameters
request_capability one action, for one call — or the exact boundary that refused it
record_action spends a grant; a second use is refused against the ledger
claim_done held, every time, with the adapter named
settle runs the adapter; returns fulfilled or a remainder with four facts
cancel_by_owner · impossible_in_scope · hand_over the other three terminal states
open_debts · verify_ledger what the deal still holds; whether the chain is intact

Two things differ here from the in-process library, and both follow from the protocol:

  • The adapter's own parameters are fixed when the promise is opened and written to the ledger, so a later call cannot redirect the reading. In the library the caller builds the adapter at settlement time. This is stricter than SPEC.md 0.1 requires and is a candidate for 0.2.
  • Grants live on the ledger, not in memory. MCP 2026-07-28 is stateless and restarts the process between calls; a right that evaporates with a process is not a right. Open promises are read back from the ledger for the same reason, so the debts survive a restart.

Protocol: MCP 2026-07-28 — server/discover, per-request _meta, resultType, ttlMs/cacheScope — with the legacy initialize handshake answered for clients still on 2025-11-25 or 2025-06-18. server.json is ready for the official registry.

Adapters

Three are included, and each attests only what its own source observes.

adapter attests
manifest+sha256 a manifest parses, matches a fresh read, protected sources unchanged
command+exit_code a command ran in a clean directory, its exit code, optionally a string in the output
owner_acceptance the result owner accepted one named version digest

Writing an adapter is work. A promise no adapter can answer is the failure this is built to make visible.

Specification

SPEC.md is versioned separately — five records, four terminal states, three escrowed rights, and the rule about what an adapter may attest. It can be reimplemented in another language without reading this code.

Status

Version 0.2. Spec 0.1 — the code and the specification carry their own numbers, and 0.2 added the MCP server without changing the specification. The five parts and the server work, and 43 tests cover them. Not yet: a durable-execution adapter, and language bindings beyond Python.

Three things worth breaking:

  1. Is there a case where "the adapter re-reads state" collapses back into trusting the agent?
  2. Composite promises currently split or carry several receipts. Is there a cleaner rule?
  3. The failure mode expected but not yet produced: agents learning to write narrow, easily-settled promises. What would catch that early?

Provenance

PROVENANCE.md says where the construction came from, what is owed to whom, and the three things asked of anyone who carries it further. None of it is enforceable; it is there because a technical record that hides its own origin is worth less than one that states it.

Licence

MIT for the code. See LICENSE. Copyright Shcherbina Vadim, 2026.

Metadata

Release files for receipt-gate 0.2.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 receipt-gate 0.2.0
File Size Uploaded Provenance Actions
receipt_gate-0.2.0.tar.gz 31.4 kB With provenance Details for receipt_gate-0.2.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for receipt-gate 0.2.0
File Interpreter ABI Platform Actions
receipt_gate-0.2.0-py3-none-any.whl Python 3 none any Details for receipt_gate-0.2.0-py3-none-any.whl

Total release size: 58.0 kB

Release files / receipt_gate-0.2.0.tar.gz

Download URL receipt_gate-0.2.0.tar.gz
Size 31.4 kB
Tags Source
SHA-256 checksum
How to use checksums
b9fa41d43793fd0a8fb553dfa8af4d1faf69ee372b547b7061aea4773dc254e4
BLAKE2b-256 checksum
How to use checksums
da9e0624518d31b19921c91191e37f5c343a2c8e056823a88d0e4708b1bd7f13
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 23, 2026.

Transparency log

Release files / receipt_gate-0.2.0-py3-none-any.whl

Download URL receipt_gate-0.2.0-py3-none-any.whl
Size 26.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
e5bc6da16119d62344f1bfe9ffab0830e76882a060aee68757092c500968f2d1
BLAKE2b-256 checksum
How to use checksums
58701d212358644a4c5be5b7ceb10c6e4f10b5cbbc9bf85448994cf4a6f5c838
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 23, 2026.

Transparency log

Security for receipt-gate 0.2.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 receipt_gate-0.2.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 23, 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.2.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