Skip to main content
Glama
receipt-gate

receipt-gate

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.

Related MCP server: blackout-mcp

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.

Available Tools

10 tools
cancel_by_ownerRelease a promise as its ownerB
Idempotent

The result owner releases the promise, naming a version. This is a terminal state of its own and stands apart from a failed fulfilment.

Inputs: owner (required), promise_id (required), version. Returns: state, fulfilled, remainder, promise_id, +1 more

claim_doneClaim completionC
Idempotent

Say the promise is finished. Held every time: a tool call by the holder is a report by the holder. The reply names the adapter that can answer instead. Call settle to have it read.

Inputs: promise_id (required).

hand_overHand a remainder to a new holderC

Pass the remainder on under a new promise linked to the earlier imprint. Taking a remainder makes nobody the author of the earlier promise, and handed over is not fulfilled.

Inputs: new_holder (required), promise_id (required), new_promise_id (required), authority, +1 more. Returns: state, fulfilled, remainder, promise_id, +1 more

impossible_in_scopeRecord impossibility and keep the boundaryC
Idempotent

Keep a receipt of impossibility together with the authority boundary that made it impossible. A terminal state of its own, standing apart from a false success.

Inputs: boundary (required), promise_id (required). Returns: state, fulfilled, remainder, promise_id, +1 more

open_debtsList open promisesC
Read-only

The promises a deal still holds, read from the ledger.

Inputs: deal_id. Returns: deal_id, open_promises

open_promiseOpen a promiseA

Record one observable future state, the authority needed for it, what may not change while acting, and the adapter that will check it. The adapter's own parameters are fixed here and written to the ledger, so the reading cannot be redirected afterwards. A promise no adapter can answer is refused at this point.

Inputs: holder (required), deal_id (required), authority (required), promise_id (required), +6 more.

record_actionSpend a capabilityA

Record that a granted action was taken. A token is good for one call; a second use is refused against the ledger.

Inputs: token (required), result.

request_capabilityRequest one capabilityB

Ask for one action inside the promise. Granted for a single call, or refused with the exact boundary that refused it — the authority it falls outside, or the damage-ceiling rule it would cross.

Inputs: action (required), promise_id (required), target.

settleSettle against a receiptA
Idempotent

Run the adapter the promise named and put what it saw beside what was promised. A match settles the promise and returns the escrowed rights. Anything else is kept as a remainder: the exact gap, what can no longer be treated as done, the authority still available, and who may accept, cancel, hand over or change it.

Inputs: promise_id (required). Returns: state, fulfilled, remainder, promise_id, +1 more

verify_ledgerVerify the ledger chainA
Read-only

Walk the hash chain and report whether it is intact. A break names which of the three it is: a gap in the sequence, a broken link, or an edited record.

Returns: head, intact, reason, records

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    TDQS

    B3.2/5.0

    Scored across 10 tools

    Disambiguation4/5

    Most tools have clearly distinct targets: open_promise, record_action, open_debts, and verify_ledger do not overlap. The main friction is the claim_done/settle pair, where claim_done is deliberately a no-op that redirects to settle, and the three terminal states (cancel_by_owner, impossible_in_scope, hand_over) require careful reading to separate, though their descriptions do distinguish them.

    Naming Consistency4/5

    Nearly all tools use snake_case with a verb-object shape (request_capability, open_promise, record_action, cancel_by_owner, verify_ledger). Settle is a bare verb and impossible_in_scope is an adjective phrase, which are minor deviations, and 'open' means different things in open_promise vs open_debts.

    Tool Count5/5

    Ten tools is well within the ideal band and each maps to a distinct phase of the promise lifecycle: request, open, act, report, settle, cancel, fail, hand over, list, audit. No filler tools and no obvious need to split or merge.

    Completeness4/5

    The lifecycle is well covered from capability request through settlement, cancellation, impossibility, handover, and hash-chain audit. The gap is read-side: there is no get_promise or get_remainder to inspect a single promise, its actions, or a remainder's details outside of a settle reply, and open_debts is scoped only to a deal.

    Maintenance

    ActivityMaintained
    ResponsivenessNo recent community issues

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      Not graded
      quality
      B
      maintenance
      Enables agents to route goals across multiple independent APIs, enforce constraints, reject invalid evidence, and return verified outcomes with tamper-evident receipts.
      MIT
    • A
      license
      Not graded
      quality
      B
      maintenance
      Gives any MCP agent exactly-once side effects: each action is recorded with a stable operation ID before it runs, so a crashed or restarted agent reconciles against the target's receipts instead of repeating work, and unknown outcomes escalate to a human rather than being retried. Completion is declared by a deterministic verifier reading the target's own state, not by the agent's own claim of success.
      27 npm
      MIT
    • A
      license
      Not graded
      quality
      B
      maintenance
      Enforces verifiable authorization, budgets, approvals, and audit trails between an agent and merchant/payment MCP servers, so that the legality of an entire transaction — not just a single call — is checked before money moves. Adds default-deny policy, two-phase budget reserve/commit, action-bound approvals, transaction guards against double-charging or unpaid fulfillment, result sanitization, and tamper-evident hash-chain evidence.
      2
      MIT
    • A
      license
      Not graded
      quality
      C
      maintenance
      Enables host coding agents to conduct evidence-first exploratory testing, adversarial review, reproduction, and resumable reporting through immutable job contracts, action budgets, checkpointed ledgers, integrity-checked artifacts, and optional origin-restricted browser automation.
      MIT