signafAIde
Documentation menu

Check receipts

A check receipt is signafAIde's signed permission for one call: this agent, this tool, these arguments, this record, for 5 minutes, once. The program that runs the tool verifies it before the tool runs. An agent that calls the tool around the check, or changes an argument after the check, is refused by the tool itself, not only by the agent's own process.

Receipts need strict mode with the witness reachable: only a ruling of allow from the witness, or a person's approval of a held call (Held calls), gives one. A call that ran without a ruling (a tool set to Let it run whose witness did not answer in time, test mode, no API key) has no receipt, and a tool that requires one refuses it: Let it run lets the agent's own process run the call, never a tool that requires a receipt. The gateway does not forward such a call, and its refusal names fail: open (Let it run in the console).

How it works #

  1. The SDK makes a salted hash of the call's arguments and sends it with the strict decision. The salt never leaves the machine, except to the tool with the receipt.
  2. When the witness allows the call, it signs a receipt naming the record, the agent's key id, the tool, the arguments hash and the disclosed fields, valid 5 minutes.
  3. The SDK hands the receipt to the tool: in the same process while the wrapped function runs, or, for an MCP server, in the request's _meta under uk.co.signafaide/receipt. The gateway forwards a protected call only with a receipt that verifies, and adds it to _meta.
  4. The tool side checks the receipt with the service keys pinned in the SDK (hybrid keys need both signatures), checks that it is for its own project and env, then runs the call. It keeps each receipt it accepted until it expires, so a receipt is used once on that machine.

Your project and env #

signafAIde signs receipts for every project, free sandboxes included, so the tool side must know its own: a receipt for another project or env is refused, even with the same tool and agent names. By default the tool side uses the project and env the SDK on that machine learned for its API key. A tool in another process or on another machine names them: requires_receipt(project="prj_...", env="live"), requireReceipt(fn, { project: "prj_...", env: "live" }). A tool side that knows neither refuses every receipt and says how to name them.

Once per machine #

A receipt is used once per machine, not once everywhere: a tool served by several machines behind a load balancer can accept the same receipt once on each of them within its 5 minutes. If a call must run at most once there, share the used-receipts directory (used_dir, usedDir) between the machines, or make the call idempotent.

In a tool function #

Python, with the tool in the agent's own process:

Python
from signafaide import protect, requires_receipt

@protect
@requires_receipt
def approve_payout(amount: int, payee: str) -> str:
    ...

TypeScript:

TypeScript
import { protect, requireReceipt } from "signafaide";

const approvePayout = protect(requireReceipt(async (p: { amount: number; payee: string }) => { /* ... */ }));

protect goes outside, so the receipt it gets is handed to the function inside. Several processes that serve one tool share a directory (used_dir, usedDir) so a receipt is used once on the machine.

In an MCP server #

TypeScript
import { receiptGuard } from "signafaide";

server.tool("approve_payout", schema, receiptGuard("approve_payout", async (args, extra) => { /* ... */ }));

In Python, read the receipt with receipt_from_mcp(params) and pass it to check_receipt(receipt, tool=..., arguments=..., project=..., env=...). When the gateway adds a name prefix, the receipt names the prefixed tool; pass that name.

A self-hosted witness signs with its own keys: pass them with keys.

Refusals #

A refused call raises receipt_refused with one of these reasons:

reasonthe call
missingcame without a receipt (no ruling: Let it run without an answer, test mode, no API key)
malformedcame with a receipt that is not a receipt
not_signedhas a receipt no service key signed
other_projecthas a receipt for another project or env (or the tool side does not know its own)
other_toolhas a receipt for another tool
other_agenthas a receipt for an agent the tool does not accept
other_argumentsruns with other arguments, or other disclosed values, than the receipt names
expiredcame more than 5 minutes after the witness allowed it
reusedcame with a receipt the tool already accepted

In test mode a call with no receipt runs, as strict calls run without a ruling there. A receipt that is present is still checked.

Receipts are permissions, not evidence: they are never in an export. The ruling on the record is the evidence. The protocol is in the spec, section 12.1.