@agent-custody/receipts 0.11.0 → 0.13.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -10,7 +10,7 @@ Two producers, one receipt format, one verifier.
10
10
  Anyone holding the public keys can verify a receipt offline. The agent is not trusted. The layer around it is, and the receipt says exactly how far that trust extends, starting with who issued it. What the receipt file carries of a call is a choice per tool: a field can be withheld as a commitment or encrypted under your key, and the verifier recomputes the digests when it is shown the values.
11
11
 
12
12
  - [Reference](https://docs.agent-custody.dev/reference/): every function, endpoint, MCP tool, and command with its request and response
13
- - [Tutorials](docs/tutorials.md): thirty-four runnable examples, one per aspect of the code, all executed by the test suite
13
+ - [Tutorials](docs/tutorials.md): thirty-five runnable examples, one per aspect of the code, all executed by the test suite
14
14
  - [Financial operations](docs/financial-operations.md): durable operation ids, provider idempotency keys, atomic daily budget reservations, and reconciliation receipts for uncertain outcomes
15
15
  - [The gateway console](docs/console.md): an admin service for the person who runs a gateway: config, tools, receipts with a verdict each, a policy editor that replays recorded calls before it saves, grant revocation, and an audit trail
16
16
  - [Configuring the gateway](docs/configuration.md): who may use which tools and where the tools live, a worked example with two agents, the Docker image, and `agent-custody check` to validate a config before it starts
@@ -22,7 +22,10 @@ Anyone holding the public keys can verify a receipt offline. The agent is not tr
22
22
  - [Verifying a receipt](docs/verification.md): what each check means and what a verified receipt does and does not prove
23
23
  - [What the evidence satisfies](docs/compliance.md): the receipts, packs, and certificates mapped to SOC 2, ISO 27001, the EU AI Act, and UK GDPR, with what none of them claims
24
24
  - [Anchoring the log on a chain](docs/anchoring.md): the log's checkpoints committed to Ethereum mainnet, or another EVM chain the installation picks, from a published address, what that proves and what it does not, running the anchor, and `log-check` against the chain
25
+ - [Completeness](docs/completeness.md): an auditor's read-only key lists the provider's objects and matches each to a verified receipt, so an action taken outside the gateway shows up
26
+ - [Payment mandates and agent identity](docs/mandates.md): the design for fitting grants and receipts to Google's AP2 mandates, Visa's Trusted Agent Protocol and Mastercard Agent Pay; not yet built
25
27
  - [Threat model](docs/threat-model.md): every party who could make a receipt false, the move, what stops it, and whether that is a property of the evidence or of the deployment; and what is not defended
28
+ - [Aligning with IETF SCITT](docs/scitt.md): the receipt as a SCITT signed statement, the log as a transparency service, our RFC 9162 proofs as COSE Receipts (RFC 9942), what differs and the options for each, an agent-action profile, and the steps toward the working group
26
29
 
27
30
  ## Getting started
28
31
 
@@ -190,7 +193,7 @@ Every field carries a provenance label. This is the design decision that matters
190
193
  bun install # from the repository root, once for the workspace
191
194
  cd packages/receipts
192
195
  node scripts/demo.ts # gateway: keys, grant, policy, four tool calls, verification, a tampering attempt; then the SDK wrapping the same tool
193
- node examples/01-keys-and-signing.ts # first of thirty-four step-by-step examples, see docs/tutorials.md
196
+ node examples/01-keys-and-signing.ts # first of thirty-five step-by-step examples, see docs/tutorials.md
194
197
  bun run test # this package; `bun run test` at the root runs every package
195
198
  ```
196
199
 
@@ -249,6 +252,7 @@ src/log-export.ts a tenant's export of their own log, self-checked, as a log fi
249
252
  src/witness.ts the witness: countersigns the log's checkpoints from another operator's machine, or refuses with an alarm
250
253
  src/anchor.ts the anchor: commits a Merkle root over new checkpoints to a chain, or refuses with an alarm; checks a record against JSON-RPC
251
254
  src/anchor-evm.ts the anchor's transactions on Ethereum or another EVM chain, through the optional dependency viem
255
+ src/completeness.ts completeness from the provider's side: the provider's own list, matched against verified receipts
252
256
  src/signer.ts the signer: the log's key in its own process, the key document verifiers fetch
253
257
  src/checkpoints.ts signed heads published on a schedule, to files and to Postgres
254
258
  src/log-store.ts the log server's backends: the file, and Postgres with tenants, hashed tokens, one writer per tenant, rate limits
@@ -279,7 +283,7 @@ src/retention.ts pruning the log: leaves become their hashes, bundles are remo
279
283
  src/index.ts the package's public surface; adapters are exported on ./sdk/<framework> subpaths
280
284
  tsconfig.build.json emits dist/ (JavaScript plus declarations) for consumers; the repo itself runs the .ts directly
281
285
  scripts/ fake Stripe upstream (signs its results with --key), a second fake upstream, fixture builders for gateway and SDK, the replay builder (`replay.ts`: example 27 and state example 07 as a folder of receipts and public keys anyone can verify with the published packages), demo
282
- examples/ thirty-four runnable tutorials, plus examples/languages/: Python, Go, Java, and Rust clients of the sidecar, run by the test suite, one per aspect; each is run by the test suite
286
+ examples/ thirty-five runnable tutorials, plus examples/languages/: Python, Go, Java, and Rust clients of the sidecar, run by the test suite, one per aspect; each is run by the test suite
283
287
  test/ unit tests per module, end-to-end gateway test, SDK and hook tests,
284
288
  adapter tests against the real packages, and a test that runs every policy in docs/policies.md
285
289
  docs/ tutorials, usage (gateway), codex-recovery (live demo), approvals, sdk, policies, verification
@@ -336,13 +340,14 @@ The design is two producers feeding one verifier. The SDK is the top of the funn
336
340
  - The [state review console](../state/README.md#explain-one-action): search receipts by transaction, customer, agent or time, read the ten answers, and hand over a portable HTML/JSON case whose signatures, authorizations and inclusion proofs can be verified offline.
337
341
  - A log outage after an ordinary call (issue #149): the signed receipt waits in `receipts/outbox/` and the gateway appends it when the log is back, the agent gets the real outcome marked `log-pending`, `GET /health` counts the pending receipts, and `requirePrecommit` refuses a remote log with an empty `precommit`. The [failure table](docs/usage.md#when-the-log-fails) gives each case.
338
342
  - The anchor (issue #176): `agent-custody anchor` proves each new checkpoint extends the last one it anchored, then commits a Merkle root over them in one transaction from its address to itself, on Ethereum by default or on Base, Arbitrum, Optimism, Polygon, or any EVM chain by id (`--chain`), with a fee cap sized per chain. It publishes each log's record and inclusion proof, sends nothing for an idle log, skips a run above a fee cap, and never has two transactions in flight. Every transaction covers every watched log, and a transaction counts only once its block is finalized, following reorgs. `log-check --anchor-url` checks the record against one or more JSON-RPC endpoints, requires the log id the verifier pinned and the address's newest transaction, and checks the log's head against the anchored checkpoint, so a rewritten or rolled-back tree is caught from the chain alone ([anchoring](docs/anchoring.md), example 33).
343
+ - Completeness from the provider's side (issue #178): `agent-custody completeness` lists Stripe's refunds, payouts, or transfers over a window with the auditor's own read-only key, and matches each to a verified receipt by the provider's object id. It reports actions with no receipt, receipts the provider does not have, amount, currency, and beneficiary mismatches, calls forwarded without an outcome receipt, and receipts it cannot match ([completeness](docs/completeness.md), example 35).
339
344
 
340
345
  **Next, in the order it pays off**
341
346
 
342
347
  The first three close the gap between a log the operator cannot rewrite and a record the operator cannot shape.
343
348
 
344
349
  1. Run the anchor for log.agent-custody.dev on mainnet: a funded key held only by the anchor service on the host, its records served beside the checkpoints, its address and each tenant's log id published in the welcome sheet and on the security page, and the monitor checking it. The code is done. [Issue #176](https://github.com/svayatta/agent-custody/issues/176).
345
- 2. Completeness from the provider's side: an auditor's read-only key lists Stripe's refunds, then GitHub's actions, and matches each one to a receipt. That catches what no gateway can see, an action taken outside it. [Issue #178](https://github.com/svayatta/agent-custody/issues/178).
350
+ 2. Completeness beyond Stripe: the same check over GitHub's actions, and over on-chain transfers out of an agent's wallet, where the chain itself lists every transfer. [Issue #178](https://github.com/svayatta/agent-custody/issues/178).
346
351
  3. A TEE gateway: a confidential container with a reproducible, attested build, the signing key generated and kept in the enclave, TLS ending inside it, and both verifiers checking the path from the receipt key, through the attestation, to the release. It replaces the TEE-hosted signer planned before. [Issue #179](https://github.com/svayatta/agent-custody/issues/179).
347
352
  4. Run the witness for log.agent-custody.dev on a machine and under an account that is not ours, and require it in the welcome sheet. The code is done; what it needs is a second operator. [Issue #116](https://github.com/svayatta/agent-custody/issues/116).
348
353
  5. Post-quantum signatures: ML-DSA beside Ed25519 in the same DSSE envelope, hybrid by default when a PQ key is present, in every signed artefact and in the browser verifier. [Issue #11](https://github.com/svayatta/agent-custody/issues/11).
package/dist/cli.js CHANGED
@@ -16,6 +16,7 @@ import { connectSigner, fetchLogKeys, localSigner, serveSigner } from "./signer.
16
16
  import { fetchWitnessKeys, Witness } from "./witness.js";
17
17
  import { checkLog, formatLogCheck } from "./log-check.js";
18
18
  import { Anchor, ANCHOR_CHAINS, resolveAnchorChain } from "./anchor.js";
19
+ import { checkCompleteness, formatCompleteness, stripeSource } from "./completeness.js";
19
20
  import { evmChain } from "./anchor-evm.js";
20
21
  import { serveHttp } from "./gateway-http.js";
21
22
  import { serveA2a } from "./a2a.js";
@@ -93,6 +94,12 @@ const USAGE = `agent-custody <command>
93
94
  log --file <log.jsonl> --key <log.key> [--port 8787] [--host 127.0.0.1] [--token-env <NAME>] reference log server
94
95
  verify <bundle.json> --issuer-key <pub> [--principal-key <pub>] [--approval-key <pub>] [--log-key <pub> | --log-url <url>] [--log-id <id>] [--require-strict] [--upstream-key <pub>] [--stripe-secret-env NAME] [--github-secret-env NAME] [--log <log.jsonl>] [--disclose <file>] [--capture-key-env NAME] [--json]
95
96
  policy simulate --policy <proposed.cedar> --receipts <dir> --issuer-key <pub>... [--principal-key <pub>]... [--approval-key <pub>]... [--log-key <pub>]... [--json] [--out <file>]
97
+ completeness --receipts <dir> --issuer-key <pub>... [--principal-key <pub>]... [--log-key <pub>]... [--log <log.jsonl>] [--log-id <id>]
98
+ --provider stripe --object refunds|payouts|transfers --key-env NAME --tool <name>... --since <ISO> --until <ISO>
99
+ [--id-path id] [--amount-field amount] [--currency-field currency] [--beneficiary <arg>=<field>]... [--json]
100
+ for an auditor: lists the provider's objects in the window with a read-only key, and
101
+ matches each to a verified receipt by the provider's object id; reports actions with no
102
+ receipt, receipts the provider does not have, and mismatched amounts; exits 1 unless complete
96
103
  replay verified local receipts against a proposed policy using their recorded inputs;
97
104
  --out saves the full JSON report. Exits 1 when any call could not be evaluated.
98
105
  log ... --db-env NAME the same server over Postgres: tenants and tokens from the database, one writer per tenant,
@@ -746,6 +753,70 @@ async function main(argv) {
746
753
  console.log(values.json ? JSON.stringify(result, null, 2) : formatReport(result));
747
754
  return result.ok ? 0 : 1;
748
755
  }
756
+ case "completeness": {
757
+ const { values } = parseArgs({
758
+ args: rest,
759
+ options: {
760
+ receipts: { type: "string" },
761
+ "issuer-key": { type: "string", multiple: true },
762
+ "principal-key": { type: "string", multiple: true },
763
+ "approval-key": { type: "string", multiple: true },
764
+ "log-key": { type: "string", multiple: true },
765
+ log: { type: "string" },
766
+ "log-id": { type: "string" },
767
+ provider: { type: "string" },
768
+ object: { type: "string", default: "refunds" },
769
+ "key-env": { type: "string" },
770
+ tool: { type: "string", multiple: true },
771
+ since: { type: "string" },
772
+ until: { type: "string" },
773
+ "id-path": { type: "string" },
774
+ "amount-field": { type: "string" },
775
+ "currency-field": { type: "string" },
776
+ beneficiary: { type: "string", multiple: true },
777
+ json: { type: "boolean", default: false },
778
+ },
779
+ });
780
+ if (!values.receipts || !values["issuer-key"]?.length || !values["key-env"] || !values.tool?.length || !values.since || !values.until)
781
+ throw new Error("completeness needs --receipts, --issuer-key, --provider stripe, --key-env, --tool, --since and --until");
782
+ if (values.provider !== "stripe")
783
+ throw new Error(`completeness supports --provider stripe; got "${values.provider ?? ""}"`);
784
+ const objects = ["refunds", "payouts", "transfers"];
785
+ if (!objects.includes(values.object))
786
+ throw new Error(`--object is one of ${objects.join(", ")}; got "${values.object}"`);
787
+ const sinceMs = Date.parse(values.since);
788
+ const untilMs = Date.parse(values.until);
789
+ if (!Number.isFinite(sinceMs) || !Number.isFinite(untilMs) || untilMs <= sinceMs)
790
+ throw new Error("--since and --until must be ISO times, --until after --since");
791
+ const beneficiary = {};
792
+ for (const pair of values.beneficiary ?? []) {
793
+ const at = pair.indexOf("=");
794
+ if (at < 1 || at === pair.length - 1)
795
+ throw new Error(`--beneficiary takes <argument>=<provider field>; got "${pair}"`);
796
+ beneficiary[pair.slice(0, at)] = pair.slice(at + 1);
797
+ }
798
+ const report = await checkCompleteness({
799
+ receiptsDir: values.receipts,
800
+ verify: {
801
+ issuerKeys: values["issuer-key"].map(loadPublicKey),
802
+ principalKeys: (values["principal-key"] ?? []).map(loadPublicKey),
803
+ ...(values["approval-key"] ? { approvalKeys: values["approval-key"].map(loadPublicKey) } : {}),
804
+ ...(values["log-key"] ? { logKeys: values["log-key"].map(loadPublicKey) } : {}),
805
+ ...(values.log ? { logFile: values.log } : {}),
806
+ ...(values["log-id"] ? { logId: values["log-id"] } : {}),
807
+ },
808
+ source: stripeSource({ secretKey: secretFrom(values["key-env"]), object: values.object }),
809
+ tools: values.tool,
810
+ sinceMs,
811
+ untilMs,
812
+ ...(values["id-path"] ? { idPath: values["id-path"] } : {}),
813
+ ...(values["amount-field"] ? { amountField: values["amount-field"] } : {}),
814
+ ...(values["currency-field"] ? { currencyField: values["currency-field"] } : {}),
815
+ ...(Object.keys(beneficiary).length ? { beneficiary } : {}),
816
+ });
817
+ console.log(values.json ? JSON.stringify(report, null, 2) : formatCompleteness(report));
818
+ return report.complete ? 0 : 1;
819
+ }
749
820
  case "policy": {
750
821
  const [subcommand, ...args] = rest;
751
822
  if (subcommand !== "simulate")
@@ -0,0 +1,106 @@
1
+ import { type VerifyOptions } from "./verify.ts";
2
+ /** One provider object, reduced to what the comparison reads. */
3
+ export interface ProviderObject {
4
+ id: string;
5
+ /** when the provider created it, as epoch milliseconds */
6
+ createdMs: number;
7
+ amount?: number;
8
+ currency?: string;
9
+ /** the provider's own object, for beneficiary fields */
10
+ raw: Record<string, unknown>;
11
+ }
12
+ export interface ProviderSource {
13
+ /** for reports, e.g. "stripe refunds" */
14
+ name: string;
15
+ list(sinceMs: number, untilMs: number): AsyncIterable<ProviderObject>;
16
+ }
17
+ export type StripeObject = "refunds" | "payouts" | "transfers";
18
+ export interface StripeSourceOptions {
19
+ /** a read-only (restricted) key; from the environment, never a flag */
20
+ secretKey: string;
21
+ object: StripeObject;
22
+ baseUrl?: string;
23
+ fetch?: typeof fetch;
24
+ }
25
+ /** Lists Stripe objects created in the window, every page, with `created[gte]` and `created[lt]`. */
26
+ export declare function stripeSource(o: StripeSourceOptions): ProviderSource;
27
+ export interface CompletenessOptions {
28
+ /** the auditor's copy of the receipts directory */
29
+ receiptsDir: string;
30
+ /** how each receipt is verified; only receipts that verify are matched */
31
+ verify: VerifyOptions;
32
+ source: ProviderSource;
33
+ /** the tools whose executed calls create provider objects, e.g. ["stripe.refund"] */
34
+ tools: string[];
35
+ sinceMs: number;
36
+ untilMs: number;
37
+ /** where the provider's object id sits in the JSON of the result's first text item; default "id" */
38
+ idPath?: string;
39
+ /** the call argument that holds the amount in minor units; default "amount" */
40
+ amountField?: string;
41
+ /** the call argument that holds the currency; default "currency", compared case-insensitively when both sides have one */
42
+ currencyField?: string;
43
+ /** call argument → provider field pairs that must be equal, e.g. { charge: "charge" } */
44
+ beneficiary?: Record<string, string>;
45
+ /**
46
+ * provider objects are listed this far either side of the window, so a receipt signed just inside the window still
47
+ * finds an object the provider created just outside it; default fifteen minutes
48
+ */
49
+ marginMs?: number;
50
+ }
51
+ export interface CompletenessReport {
52
+ provider: string;
53
+ tools: string[];
54
+ window: {
55
+ since: string;
56
+ until: string;
57
+ };
58
+ receiptsRead: number;
59
+ matched: {
60
+ receiptId: string;
61
+ providerId: string;
62
+ }[];
63
+ /** provider objects in the window with no verified receipt: actions taken outside the gateway */
64
+ providerOnly: {
65
+ providerId: string;
66
+ created: string;
67
+ amount?: number;
68
+ currency?: string;
69
+ }[];
70
+ /** executed receipts in the window whose provider object the provider does not have */
71
+ receiptOnly: {
72
+ receiptId: string;
73
+ providerId: string;
74
+ timestamp: string;
75
+ }[];
76
+ mismatches: {
77
+ receiptId: string;
78
+ providerId: string;
79
+ field: string;
80
+ receipt: unknown;
81
+ provider: unknown;
82
+ }[];
83
+ /** provider objects that more than one verified receipt names: one action recorded twice, or receipts that disagree */
84
+ duplicates: {
85
+ providerId: string;
86
+ receiptIds: string[];
87
+ }[];
88
+ /** receipt files that did not verify, and so were not matched */
89
+ unverified: {
90
+ file: string;
91
+ failing: string[];
92
+ }[];
93
+ /** verified, executed receipts whose provider id cannot be read */
94
+ unmatchable: {
95
+ receiptId: string;
96
+ reason: string;
97
+ }[];
98
+ /** calls committed before they were forwarded whose outcome receipt is missing: each may be a provider object above */
99
+ forwardedWithoutOutcome: {
100
+ receiptId: string;
101
+ tool: string;
102
+ }[];
103
+ complete: boolean;
104
+ }
105
+ export declare function checkCompleteness(o: CompletenessOptions): Promise<CompletenessReport>;
106
+ export declare function formatCompleteness(r: CompletenessReport): string;
@@ -0,0 +1,240 @@
1
+ // Completeness from the provider's side. Receipts prove what went through the gateway; nothing on the gateway's side
2
+ // can see an action that never did. An auditor with a read-only key of their own lists the provider's objects over a
3
+ // window and matches each one to a verified receipt by the provider's object id, which the receipt's result carries.
4
+ // A provider object with no receipt is an action taken outside the gateway; a receipt with no provider object is an
5
+ // action the provider does not have. Nothing here writes, retries, or calls the provider for anything but a list.
6
+ import { readdirSync, readFileSync } from "node:fs";
7
+ import { join } from "node:path";
8
+ import { isCommitment, REST } from "./capture.js";
9
+ import { verifyOrphanAuthorization } from "./simulate.js";
10
+ import { verifyBundle } from "./verify.js";
11
+ /** Lists Stripe objects created in the window, every page, with `created[gte]` and `created[lt]`. */
12
+ export function stripeSource(o) {
13
+ const f = o.fetch ?? fetch;
14
+ const base = o.baseUrl ?? "https://api.stripe.com/";
15
+ return {
16
+ name: `stripe ${o.object}`,
17
+ async *list(sinceMs, untilMs) {
18
+ let after;
19
+ for (;;) {
20
+ const url = new URL(`v1/${o.object}`, base);
21
+ url.searchParams.set("limit", "100");
22
+ url.searchParams.set("created[gte]", String(Math.floor(sinceMs / 1000)));
23
+ url.searchParams.set("created[lt]", String(Math.ceil(untilMs / 1000)));
24
+ if (after)
25
+ url.searchParams.set("starting_after", after);
26
+ const res = await f(url, { headers: { authorization: `Bearer ${o.secretKey}` }, signal: AbortSignal.timeout(15_000) });
27
+ if (!res.ok)
28
+ throw new Error(`stripe ${o.object}: HTTP ${res.status}`);
29
+ const page = (await res.json());
30
+ const data = Array.isArray(page.data) ? page.data : [];
31
+ for (const obj of data) {
32
+ if (typeof obj.id !== "string" || typeof obj.created !== "number")
33
+ throw new Error(`stripe ${o.object}: an object without an id or a created time`);
34
+ yield {
35
+ id: obj.id,
36
+ createdMs: obj.created * 1000,
37
+ ...(typeof obj.amount === "number" ? { amount: obj.amount } : {}),
38
+ ...(typeof obj.currency === "string" ? { currency: obj.currency } : {}),
39
+ raw: obj,
40
+ };
41
+ }
42
+ if (!page.has_more || data.length === 0)
43
+ return;
44
+ after = data[data.length - 1].id;
45
+ }
46
+ },
47
+ };
48
+ }
49
+ const AUTHORIZATION = ".authorization.json";
50
+ const iso = (ms) => new Date(ms).toISOString();
51
+ function at(value, path) {
52
+ let v = value;
53
+ for (const part of path.split(".")) {
54
+ if (!v || typeof v !== "object" || !Object.hasOwn(v, part))
55
+ return undefined;
56
+ v = v[part];
57
+ }
58
+ return v;
59
+ }
60
+ /** The provider object id that an executed call's result carries, or why it cannot be read. */
61
+ function providerIdOf(p, idPath) {
62
+ const result = p.execution.result;
63
+ if (isCommitment(result))
64
+ return { reason: "the result is withheld under a capture rule; the provider's object id cannot be read from the receipt" };
65
+ const r = result;
66
+ // a `$rest` commitment may hold only unrelated fields: the content is withheld only when it is not kept in clear
67
+ if (r && !Object.hasOwn(r, "content") && isCommitment(r[REST]))
68
+ return { reason: "the result content is withheld under a capture rule; the provider's object id cannot be read from the receipt" };
69
+ const content = r?.content;
70
+ const first = Array.isArray(content) ? content[0] : undefined;
71
+ if (isCommitment(content) || isCommitment(first))
72
+ return { reason: "the result content is withheld under a capture rule; the provider's object id cannot be read from the receipt" };
73
+ const text = first?.text;
74
+ if (isCommitment(text))
75
+ return { reason: "the result content is withheld under a capture rule; the provider's object id cannot be read from the receipt" };
76
+ if (typeof text !== "string")
77
+ return { reason: "the result carries no text to read the provider's object id from" };
78
+ let parsed;
79
+ try {
80
+ parsed = JSON.parse(text);
81
+ }
82
+ catch {
83
+ return { reason: "the result's text is not JSON" };
84
+ }
85
+ const id = at(parsed, idPath);
86
+ return typeof id === "string" && id.length ? { id } : { reason: `the result has no string at "${idPath}"` };
87
+ }
88
+ /** A call argument, or that a capture rule withholds it: listed fields stay in clear beside one `$rest` commitment. */
89
+ function argOf(args, field) {
90
+ if (Object.hasOwn(args, field))
91
+ return isCommitment(args[field]) ? { withheld: true } : { value: args[field] };
92
+ return isCommitment(args[REST]) ? { withheld: true } : { value: undefined };
93
+ }
94
+ export async function checkCompleteness(o) {
95
+ const idPath = o.idPath ?? "id";
96
+ const amountField = o.amountField ?? "amount";
97
+ const currencyField = o.currencyField ?? "currency";
98
+ const margin = o.marginMs ?? 15 * 60_000;
99
+ const tools = new Set(o.tools);
100
+ const inWindow = (ms) => ms >= o.sinceMs && ms < o.untilMs;
101
+ const report = {
102
+ provider: o.source.name,
103
+ tools: [...o.tools],
104
+ window: { since: iso(o.sinceMs), until: iso(o.untilMs) },
105
+ receiptsRead: 0,
106
+ matched: [],
107
+ providerOnly: [],
108
+ receiptOnly: [],
109
+ mismatches: [],
110
+ duplicates: [],
111
+ unverified: [],
112
+ unmatchable: [],
113
+ forwardedWithoutOutcome: [],
114
+ complete: false,
115
+ };
116
+ const names = readdirSync(o.receiptsDir, { withFileTypes: true }).filter((e) => (e.isFile() || e.isSymbolicLink()) && e.name.endsWith(".json")).map((e) => e.name).sort();
117
+ const outcomes = new Set();
118
+ const byProviderId = new Map();
119
+ for (const name of names) {
120
+ if (name.endsWith(AUTHORIZATION))
121
+ continue;
122
+ report.receiptsRead++;
123
+ let result;
124
+ try {
125
+ result = verifyBundle(JSON.parse(readFileSync(join(o.receiptsDir, name), "utf8")), o.verify);
126
+ }
127
+ catch (e) {
128
+ report.unverified.push({ file: name, failing: [e instanceof Error ? e.message : String(e)] });
129
+ continue;
130
+ }
131
+ if (!result.ok || !result.statement) {
132
+ report.unverified.push({ file: name, failing: result.checks.filter((c) => !c.ok).map((c) => c.name) });
133
+ continue;
134
+ }
135
+ const p = result.statement.predicate;
136
+ // the gateway names each file by its receipt id: a valid receipt under another name could stand in for a missing outcome
137
+ if (name !== `${p.receiptId}.json`) {
138
+ report.unverified.push({ file: name, failing: [`the file name does not match the signed receipt id ${p.receiptId}`] });
139
+ continue;
140
+ }
141
+ outcomes.add(p.receiptId);
142
+ if (!tools.has(p.tool.name) || p.reconciliation || p.execution.status !== "executed")
143
+ continue;
144
+ const id = providerIdOf(p, idPath);
145
+ if ("reason" in id) {
146
+ if (inWindow(Date.parse(p.timestamp)))
147
+ report.unmatchable.push({ receiptId: p.receiptId, reason: id.reason });
148
+ continue;
149
+ }
150
+ byProviderId.set(id.id, [...(byProviderId.get(id.id) ?? []), p]);
151
+ }
152
+ for (const name of names) {
153
+ if (!name.endsWith(AUTHORIZATION))
154
+ continue;
155
+ // committed and forwarded, then nothing: the provider may hold an object this report cannot tie to a receipt
156
+ let auth;
157
+ try {
158
+ auth = verifyOrphanAuthorization(JSON.parse(readFileSync(join(o.receiptsDir, name), "utf8")), o.verify.issuerKeys, o.verify.logKeys ?? []);
159
+ }
160
+ catch (e) {
161
+ report.unverified.push({ file: name, failing: [e instanceof Error ? e.message : String(e)] });
162
+ continue;
163
+ }
164
+ if (name !== `${auth.receiptId}${AUTHORIZATION}`)
165
+ report.unverified.push({ file: name, failing: [`the file name does not match the signed receipt id ${auth.receiptId}`] });
166
+ if (outcomes.has(auth.receiptId) || !tools.has(auth.tool.name) || !inWindow(Date.parse(auth.timestamp)))
167
+ continue;
168
+ report.forwardedWithoutOutcome.push({ receiptId: auth.receiptId, tool: auth.tool.name });
169
+ }
170
+ const seen = new Set();
171
+ for await (const obj of o.source.list(o.sinceMs - margin, o.untilMs + margin)) {
172
+ seen.add(obj.id);
173
+ const receipts = byProviderId.get(obj.id) ?? [];
174
+ // the margin finds a receipt across the window's edge; it does not widen the period reported on
175
+ const inScope = inWindow(obj.createdMs) || receipts.some((p) => inWindow(Date.parse(p.timestamp)));
176
+ if (!inScope)
177
+ continue;
178
+ if (!receipts.length) {
179
+ report.providerOnly.push({ providerId: obj.id, created: iso(obj.createdMs), ...(obj.amount !== undefined ? { amount: obj.amount } : {}), ...(obj.currency !== undefined ? { currency: obj.currency } : {}) });
180
+ continue;
181
+ }
182
+ if (receipts.length > 1)
183
+ report.duplicates.push({ providerId: obj.id, receiptIds: receipts.map((p) => p.receiptId) });
184
+ for (const p of receipts) {
185
+ report.matched.push({ receiptId: p.receiptId, providerId: obj.id });
186
+ const args = p.request.args;
187
+ const withheld = (arg) => report.unmatchable.push({ receiptId: p.receiptId, reason: `the argument "${arg}" is withheld under a capture rule, so it cannot be compared` });
188
+ const amount = argOf(args, amountField);
189
+ if ("withheld" in amount) {
190
+ if (obj.amount !== undefined)
191
+ withheld(amountField);
192
+ }
193
+ else if (obj.amount !== undefined && amount.value !== obj.amount)
194
+ report.mismatches.push({ receiptId: p.receiptId, providerId: obj.id, field: "amount", receipt: amount.value, provider: obj.amount });
195
+ const currency = argOf(args, currencyField);
196
+ if ("withheld" in currency) {
197
+ if (obj.currency !== undefined)
198
+ withheld(currencyField);
199
+ }
200
+ else if (typeof currency.value === "string" && obj.currency !== undefined && currency.value.toLowerCase() !== obj.currency.toLowerCase())
201
+ report.mismatches.push({ receiptId: p.receiptId, providerId: obj.id, field: "currency", receipt: currency.value, provider: obj.currency });
202
+ for (const [arg, field] of Object.entries(o.beneficiary ?? {})) {
203
+ const value = argOf(args, arg);
204
+ if ("withheld" in value || value.value === undefined) {
205
+ report.unmatchable.push({ receiptId: p.receiptId, reason: `the beneficiary argument "${arg}" is missing or withheld, so it cannot be compared` });
206
+ continue;
207
+ }
208
+ const provider = at(obj.raw, field);
209
+ if (String(value.value) !== String(provider))
210
+ report.mismatches.push({ receiptId: p.receiptId, providerId: obj.id, field: arg, receipt: value.value, provider });
211
+ }
212
+ }
213
+ }
214
+ for (const [providerId, receipts] of byProviderId) {
215
+ if (seen.has(providerId))
216
+ continue;
217
+ for (const p of receipts)
218
+ if (inWindow(Date.parse(p.timestamp)))
219
+ report.receiptOnly.push({ receiptId: p.receiptId, providerId, timestamp: p.timestamp });
220
+ }
221
+ report.matched.sort((a, b) => a.receiptId.localeCompare(b.receiptId));
222
+ report.complete = [report.providerOnly, report.receiptOnly, report.mismatches, report.duplicates, report.unverified, report.unmatchable, report.forwardedWithoutOutcome].every((l) => l.length === 0);
223
+ return report;
224
+ }
225
+ export function formatCompleteness(r) {
226
+ const lines = [`${r.provider} for ${r.tools.join(", ")}, ${r.window.since} to ${r.window.until}: ${r.receiptsRead} receipt(s) read, ${r.matched.length} matched`];
227
+ const section = (title, rows) => {
228
+ if (rows.length)
229
+ lines.push("", `${title} (${rows.length})`, ...rows.map((row) => ` ${row}`));
230
+ };
231
+ section("PROVIDER ACTIONS WITH NO RECEIPT", r.providerOnly.map((x) => `${x.providerId} created ${x.created}${x.amount !== undefined ? ` amount ${x.amount}${x.currency ? ` ${x.currency}` : ""}` : ""}`));
232
+ section("RECEIPTS THE PROVIDER DOES NOT HAVE", r.receiptOnly.map((x) => `${x.receiptId} names ${x.providerId}, signed ${x.timestamp}`));
233
+ section("MISMATCHES", r.mismatches.map((x) => `${x.receiptId} / ${x.providerId}: ${x.field} is ${JSON.stringify(x.receipt)} in the receipt, ${JSON.stringify(x.provider)} at the provider`));
234
+ section("ONE PROVIDER OBJECT, SEVERAL RECEIPTS", r.duplicates.map((x) => `${x.providerId} is named by ${x.receiptIds.join(", ")}`));
235
+ section("FORWARDED WITHOUT AN OUTCOME RECEIPT", r.forwardedWithoutOutcome.map((x) => `${x.receiptId} (${x.tool}): committed and forwarded, no receipt of the outcome`));
236
+ section("UNMATCHABLE", r.unmatchable.map((x) => `${x.receiptId}: ${x.reason}`));
237
+ section("NOT VERIFIED, NOT MATCHED", r.unverified.map((x) => `${x.file}: ${x.failing.join("; ")}`));
238
+ lines.push("", r.complete ? "RESULT: COMPLETE" : "RESULT: INCOMPLETE");
239
+ return lines.join("\n");
240
+ }
package/dist/index.d.ts CHANGED
@@ -26,6 +26,8 @@ export { bothCheckpoints, dirCheckpoints, postgresCheckpoints } from "./checkpoi
26
26
  export { adminRoutes, welcomeSheet } from "./log-admin.ts";
27
27
  export { fetchWitnessKeys, Witness } from "./witness.ts";
28
28
  export { Anchor, ANCHOR_CHAINS, anchorCalldata, anchorLeaf, checkAnchorRecord, resolveAnchorChain } from "./anchor.ts";
29
+ export { checkCompleteness, formatCompleteness, stripeSource } from "./completeness.ts";
30
+ export type { CompletenessOptions, CompletenessReport, ProviderObject, ProviderSource, StripeObject, StripeSourceOptions } from "./completeness.ts";
29
31
  export type { AnchorChain, AnchorCheck, AnchorCheckOptions, AnchorOptions, AnchorRecord, AnchorRun, AnchorTenantOutcome, AnchorTxOutcome } from "./anchor.ts";
30
32
  export { evmChain } from "./anchor-evm.ts";
31
33
  export type { EvmChainOptions } from "./anchor-evm.ts";
package/dist/index.js CHANGED
@@ -18,6 +18,7 @@ export { bothCheckpoints, dirCheckpoints, postgresCheckpoints } from "./checkpoi
18
18
  export { adminRoutes, welcomeSheet } from "./log-admin.js";
19
19
  export { fetchWitnessKeys, Witness } from "./witness.js";
20
20
  export { Anchor, ANCHOR_CHAINS, anchorCalldata, anchorLeaf, checkAnchorRecord, resolveAnchorChain } from "./anchor.js";
21
+ export { checkCompleteness, formatCompleteness, stripeSource } from "./completeness.js";
21
22
  export { evmChain } from "./anchor-evm.js";
22
23
  export { checkLog, formatLogCheck } from "./log-check.js";
23
24
  export * from "./config.js";
@@ -0,0 +1,59 @@
1
+ # Completeness: matching the provider's records against the receipts
2
+
3
+ A verified receipt proves what went through the gateway. Nothing on the gateway's side can see an action that never went through it: whoever holds the Stripe key can issue a refund straight through Stripe's API. The provider's own record is the only place that action shows. `agent-custody completeness` lets an auditor check it, with a read-only key of their own.
4
+
5
+ ## What it reports
6
+
7
+ For a window and a set of tools, it lists the provider's objects and matches each to a verified receipt by the provider's object id, which the receipt's result carries.
8
+
9
+ | section | meaning | what to do |
10
+ | --- | --- | --- |
11
+ | provider actions with no receipt | an object the provider created in the window that no verified receipt names | the finding this command exists for: an action taken outside the gateway, or by a gateway whose receipts you were not given |
12
+ | receipts the provider does not have | an executed receipt in the window whose object the provider has no record of | a receipt for something that did not happen at the provider, or an object in another account or mode |
13
+ | mismatches | a matched pair whose amount, currency (ignoring case), or a beneficiary field differs | the receipt and the provider disagree about what happened |
14
+ | one provider object, several receipts | more than one verified receipt names the same provider object; each is still compared with it | one action recorded twice, or receipts that contradict each other |
15
+ | forwarded without an outcome receipt | a call committed to the log before it was forwarded (`precommit`) whose outcome receipt is missing | the gateway stopped after forwarding; this explains a provider object that has no receipt, without guessing which one |
16
+ | unmatchable | a verified, executed receipt whose provider id cannot be read, or whose amount, currency, or beneficiary argument cannot be compared, because a capture rule withholds it | match it by hand against the values disclosed with `agent-custody reveal` |
17
+ | not verified | a receipt file that failed verification, or a valid receipt or authorization stored under a name that is not its signed receipt id | it is not matched, so its provider object shows as having no receipt |
18
+
19
+ The result is `COMPLETE` only when every section but the matches is empty, and the command exits 1 otherwise.
20
+
21
+ Only receipts that verify against the keys you give are matched. A forged or edited receipt file cannot cover for a provider action, because it fails verification and its object then appears as having no receipt. Denied, withheld, and failed calls are not expected to have a provider object, and reconciliation receipts are skipped, because the original receipt is the one that names the object.
22
+
23
+ The provider is listed fifteen minutes either side of the window (`marginMs` in code), so a receipt signed just inside the window still finds an object created just outside it. The margin does not widen the period reported on: a pair is reported only when its receipt or its object falls inside the window, and a call forwarded without an outcome only when its authorization was signed inside it.
24
+
25
+ An authorization is tied to its outcome by the receipt id both of them sign, never by the file name. A valid receipt copied under the name of a missing outcome therefore hides nothing: it is reported as not verified, and the call is still listed as forwarded without an outcome.
26
+
27
+ ## Running it
28
+
29
+ ```bash
30
+ export STRIPE_AUDIT_KEY=rk_live_... # a restricted key with read access to refunds, held by the auditor
31
+ agent-custody completeness --receipts ./receipts --issuer-key gateway.pub --principal-key principal.pub \
32
+ --log log.jsonl --provider stripe --object refunds --key-env STRIPE_AUDIT_KEY \
33
+ --tool stripe.refund --since 2026-10-01T00:00:00Z --until 2026-11-01T00:00:00Z
34
+ ```
35
+
36
+ | flag | default | meaning |
37
+ | --- | --- | --- |
38
+ | `--receipts <dir>` | | the auditor's copy of the receipts directory, authorization files included |
39
+ | `--issuer-key`, `--principal-key`, `--approval-key`, `--log-key`, `--log`, `--log-id` | | how each receipt is verified, as for `verify` |
40
+ | `--provider stripe` | | the provider; Stripe is the only one so far |
41
+ | `--object` | `refunds` | `refunds`, `payouts`, or `transfers` |
42
+ | `--key-env NAME` | | the environment variable holding the read-only key; never a flag value |
43
+ | `--tool <name>` | | each tool whose executed calls create provider objects; repeatable |
44
+ | `--since`, `--until` | | the window, ISO times; `--until` is exclusive |
45
+ | `--id-path` | `id` | where the provider's object id sits in the JSON of the result's first text item; Stripe's own response uses `id` |
46
+ | `--amount-field`, `--currency-field` | `amount`, `currency` | the call arguments compared with the provider's amount and currency |
47
+ | `--beneficiary <arg>=<field>` | | a call argument that must equal a provider field, such as `charge=charge` or `customer_id=metadata.customer_id`; repeatable |
48
+ | `--json` | | the full report as JSON |
49
+
50
+ Use a restricted Stripe key with read-only access to the objects you check. The command only lists objects: it never creates, retries, or reconciles anything. The operator's `reconcile` command is a different thing: it settles one financial operation through the gateway and writes a receipt.
51
+
52
+ ## Limits
53
+
54
+ - **The receipts you were given.** The check proves completeness against those receipts. A second gateway, or a second receipts directory, that issued receipts you were not handed shows up as provider actions with no receipt, which is the correct finding.
55
+ - **One provider account and mode per run.** Test-mode and live-mode objects are separate lists.
56
+ - **The id must be readable.** A capture rule that withholds the result content also withholds the object id inside it, and such receipts are reported as unmatchable, never as matched or missing. A rule that keeps `content` in clear (`result: { mode: "digest", clear: ["content"] }`) leaves the id readable. Likewise, keep the amount, currency, and beneficiary arguments in clear, or those comparisons are reported as unmatchable. Reading values from disclosures is still to come.
57
+ - **Stripe first.** Other providers, and on-chain transfers from an agent's wallet, are `ProviderSource` implementations still to come.
58
+
59
+ In code, `checkCompleteness({ receiptsDir, verify, source, tools, sinceMs, untilMs })` returns the report, `stripeSource({ secretKey, object })` lists Stripe objects, and `formatCompleteness(report)` prints it. Example 35 runs the whole check against a stand-in for Stripe's list API.
@@ -0,0 +1,82 @@
1
+ # Payment mandates and agent identity: AP2, Visa TAP, Mastercard Agent Pay
2
+
3
+ Design, not yet built. It tracks issues #185 and #186: fitting the grant and the receipt to the payment networks' standards, so that the networks define the authority and agent-custody keeps the evidence of what was done under it.
4
+
5
+ Sources read on 26 October 2026: AP2 v0.2 ([google-agentic-commerce/AP2](https://github.com/google-agentic-commerce/AP2), `docs/ap2/specification.md` and `agent_authorization.md`), and Visa's Trusted Agent Protocol ([visa/trusted-agent-protocol](https://github.com/visa/trusted-agent-protocol)). Mastercard Agent Pay has no public specification that we could find; what follows on it comes from secondary sources.
6
+
7
+ ## What AP2 v0.2 defines
8
+
9
+ - **Mandates are SD-JWT verifiable credentials.** A `vct` claim names the type and version: `mandate.checkout.1`, `mandate.payment.1`, and the open variants `mandate.checkout.open.1` and `mandate.payment.open.1`.
10
+ - An **open** mandate carries `constraints` and the agent's key in `cnf` (RFC 7800).
11
+ - A **closed** mandate is bound to one transaction by the agent's key-binding JWT.
12
+ - Verifiers always receive a closed mandate, sometimes with the open mandate it came from.
13
+ - **Two modes.** In human-present mode, the user signs the closed mandate directly. In human-not-present mode, the user signs an open mandate and the agent signs the closed one under its constraints.
14
+ - **Payment constraints:** recurrence, allowed payees, allowed instruments, allowed payment initiation service providers, an amount range, a budget, the checkout reference, and an execution date. An unknown constraint fails.
15
+ - **Mandate receipts.** Every verifier returns a signed Mandate Receipt JWT on acceptance *and* on rejection: `iss` (the verifier), `result` (`success` or `error`), `reference` (a hash of the mandate it received, computed like `sd_hash`), and, on an error, an `error` code (`invalid_credential`, `unresolved_constraint`, `invalid_mandate`, `mandates_not_supported`) with an optional `error_description`. In the autonomous flow, an agent may not present another open mandate until the previous one has a rejection receipt.
16
+ - **Not only payments.** `agent_authorization.md` is a general framework: new mandate types and constraint types MAY be defined, named with an rDNS prefix.
17
+ - **What AP2 leaves open: dispute evidence.** The mandates and receipts "provide a non-repudiable picture of the transaction", but *retention and retrieval are outside the scope of this specification*. That gap is exactly agent-custody's job.
18
+
19
+ ## How agent-custody maps onto it
20
+
21
+ | AP2 | agent-custody today | What changes |
22
+ |---|---|---|
23
+ | Open mandate, user-signed, with `cnf` = the agent's key and `constraints` | Grant: principal-signed DSSE, with `agentKey`, `scopes`, and a time window | Accept an open AP2 mandate as a grant. Define our own mandate type for non-payment tools, so a grant can be issued as an AP2 SD-JWT VC. |
24
+ | Closed mandate, user-signed (human present) | Payload-bound approval: principal-side keys sign the exact tool, arguments, amount and beneficiary | Accept a closed AP2 payment mandate as the approval for a payment tool. |
25
+ | Closed mandate, agent-signed under an open mandate (human not present) | A call checked against the grant and the Cedar policy | The gateway verifies the chain and evaluates every constraint before the policy runs. A failed constraint is a denial with a receipt, and an AP2 rejection receipt goes back to the agent. |
26
+ | Verifier | The gateway | The gateway becomes an AP2 verifier for the actions it gates. |
27
+ | Mandate Receipt JWT (`iss`, `result`, `reference`) | The signed receipt | Each receipt carries the mandate's `reference` and the outcome. For every mandate presented, whether accepted or rejected, the gateway also returns a standard Mandate Receipt JWT, so an AP2 party reads our answer in its own format. |
28
+ | Dispute evidence, retention out of scope | The transparency log, chain anchoring, retention, the verifiers | The mandate chain and its receipts are logged and anchored, and are retrievable by `transaction_id`. |
29
+ | One open mandate presented at a time | Single-use approvals (`usedDir`) | Track open-mandate presentations the same way, for recurrence and budget constraints. |
30
+
31
+ **The line for the deck:** AP2 defines who authorised what; agent-custody proves what was then done with it, and keeps the proof where nobody can change it.
32
+
33
+ ## Visa Trusted Agent Protocol
34
+
35
+ TAP is an identity layer between an agent and a merchant.
36
+ - The agent signs each HTTP request with RFC 9421 message signatures, bound to the merchant's domain and the operation, with a timestamp and a nonce.
37
+ - Merchants verify the key against Visa's directory.
38
+ - It doesn't move money and doesn't carry a mandate.
39
+
40
+ The fit is at the gateway's outbound side. The gateway already sits between the agent and the merchant. With the agent's TAP key held by the gateway, ideally in the TEE (#179), it signs the outbound request, and the receipt records the signature parameters. The merchant then sees a trusted agent, and the receipt shows exactly which request carried that identity.
41
+
42
+ ## Mastercard Agent Pay
43
+
44
+ Reported to work through agentic tokens: MDES tokens scoped to an agent, a merchant and a consent policy, with spending limits held by the issuer. No public specification was found. Until one exists, the plan is limited to recording the token reference and its scope in the receipt, as a fact the gateway observed.
45
+
46
+ ## Plan, in order
47
+
48
+ 1. **Record AP2 mandates in receipts.**
49
+ - Verify an SD-JWT VC mandate chain (ES256 and RFC 7800 `cnf`), with issuer keys pinned in the gateway config.
50
+ - Evaluate the payment constraints.
51
+ - Record the `vct`, the `reference`, each constraint's result, and the issuer's key id in the receipt.
52
+ - Under a capture rule, undisclosed claims stay out, and the disclosed ones are treated like arguments.
53
+ - This needs vectors, and both verifiers (`src/verify.ts` and `site/verifier/verify-web.ts`) change together.
54
+ 2. **Return Mandate Receipts, on acceptance and on rejection.** For every mandate presented with a call, the gateway returns an AP2 Mandate Receipt JWT in `_meta`, bound to the agent-custody receipt id, including when the mandate is refused. A rejection is what lets an AP2 agent retry, fall back, or present its next open mandate, so a refusal must never produce only our own denial receipt.
55
+
56
+ | Gateway outcome | `result` | `error` |
57
+ | --- | --- | --- |
58
+ | Chain and constraints verify, and the call is allowed | `success` | |
59
+ | The SD-JWT, its key binding or the chain fails, the issuer isn't trusted, or the mandate has expired | `error` | `invalid_credential` |
60
+ | An unknown constraint type, or a constraint the gateway can't evaluate | `error` | `unresolved_constraint` |
61
+ | Constraints evaluate false, or the mandate doesn't cover this tool or these arguments | `error` | `invalid_mandate` |
62
+ | The tool has no mandate configuration, or the presented `vct` isn't supported | `error` | `mandates_not_supported` |
63
+
64
+ - **Authorization, not outcome.** The JWT's `result` is the authorization decision only. Whether the tool then ran, failed, or was withheld, and how a payment later settles, are recorded in the agent-custody receipt (`execution`, `operation`, `reconciliation`), never in the mandate receipt.
65
+ - **Logged.** The mandate receipt's digest is recorded in our receipt, so the rejection evidence is logged too.
66
+ - **No leaks.** `error_description` never carries a withheld value or a policy's internal reason.
67
+ - **One mandate in flight.** An open mandate counts as in flight from its presentation until its receipt, whichever the result.
68
+ 3. **An agent-custody mandate type for tools.**
69
+ - Name: `dev.agent-custody.mandate.tool.1`.
70
+ - Constraints: allowed tools, an argument range, an amount range, payees, and a window.
71
+ - A principal can then issue an AP2-format open mandate in place of a DSSE grant, and the gateway accepts both.
72
+ 4. **The TAP signer.** RFC 9421 signatures on outbound requests to configured merchants, with the key held by the gateway, and the signature parameters recorded in the receipt.
73
+ 5. **Dispute retrieval.** Look a receipt up by AP2 `transaction_id`, and produce an evidence pack with the mandate chain, the AP2 receipts, our receipt, the inclusion proof and the anchor.
74
+
75
+ ## Open questions
76
+
77
+ - **SD-JWT implementation.** Use an existing library (the OpenWallet Foundation's `@sd-jwt/*`), or write a small verifier ourselves, the way the rest of the verifier is dependency-light? The browser verifier needs it too.
78
+ - **Delegation chains.** AP2 uses the Delegate SD-JWT draft for chains, which is not yet stable. Pin to the draft revision that AP2 v0.2's reference implementation uses, and test against its fixtures.
79
+ - **Keys.** Mandates are ES256, while our receipts are Ed25519. The gateway verifies ES256 and keeps signing with Ed25519, so no format change is needed. ML-DSA (#11) is unaffected.
80
+ - **Privacy.** A mandate's undisclosed claims must never reach a receipt in clear. Disclosed payee and instrument details follow the capture rule, and the capture canary test gets a mandate path.
81
+ - **A refusal by the gateway's own policy.** If the mandate verifies but the operator's Cedar policy, an approval rule, or strict mode refuses the call, which code applies? `invalid_mandate` would wrongly blame the mandate. Our recommendation is a namespaced code, `dev.agent-custody.policy_denied`, with a short public reason, if AP2 allows codes beyond the four it defines. Otherwise `invalid_mandate`, with the cause in `error_description`. Confirm with the AP2 maintainers.
82
+ - **Which party we are.** In AP2 terms the gateway is a verifier for the actions it gates, not a Credential Provider or a Network. Say so in the docs, so nobody reads agent-custody as a payment network component.
package/docs/scitt.md ADDED
@@ -0,0 +1,186 @@
1
+ # Aligning with IETF SCITT
2
+
3
+ SCITT (Supply Chain Integrity, Transparency, and Trust) is the IETF's standard for transparency services. An issuer signs a statement, a transparency service registers it in an append-only log and returns a signed proof called a receipt, and a relying party checks both offline. That is the shape of agent-custody too. This page maps our receipt and our log onto SCITT: what lines up exactly, what differs, the options for each difference, what an agent-action profile would contain, and the steps that would bring one to the working group. It is step 3 of [issue #185](https://github.com/svayatta/agent-custody/issues/185). Nothing here changes the format yet. [The receipt specification](../../../site/receipt/v0.2.md) and [the log API](../../../site/reference/log-api.md) are what this page compares against.
4
+
5
+ The documents were read on 26 October 2026, from the IETF datatracker. Three of the drafts that issue #185 names were published as RFCs this summer. Cite the RFCs from now on, not the drafts.
6
+
7
+ | document | revision and status | what we take from it |
8
+ | --- | --- | --- |
9
+ | SCITT architecture | [RFC 9943](https://www.rfc-editor.org/rfc/rfc9943), June 2026, Proposed Standard; published from [draft-ietf-scitt-architecture-22](https://datatracker.ietf.org/doc/draft-ietf-scitt-architecture/22/) | the roles, Signed Statements, Registration, Transparent Statements |
10
+ | COSE Receipts (the "Merkle tree proofs" draft) | [RFC 9942](https://www.rfc-editor.org/rfc/rfc9942), June 2026, Proposed Standard; published from [draft-ietf-cose-merkle-tree-proofs-18](https://datatracker.ietf.org/doc/draft-ietf-cose-merkle-tree-proofs/18/) | receipts as COSE_Sign1, the `RFC9162_SHA256` verifiable data structure, inclusion and consistency proofs |
11
+ | COSE Hash Envelope | [RFC 9995](https://www.rfc-editor.org/rfc/rfc9995), July 2026, Proposed Standard; published from [draft-ietf-cose-hash-envelope-10](https://datatracker.ietf.org/doc/draft-ietf-cose-hash-envelope/10/) | signing a digest of a statement, so a log can register it without seeing it |
12
+ | SCITT Reference APIs (SCRAPI) | [draft-ietf-scitt-scrapi-11](https://datatracker.ietf.org/doc/draft-ietf-scitt-scrapi/11/), in the RFC Editor queue, expires 28 December 2026 | the HTTP API: register a statement, resolve a receipt, discover keys |
13
+ | Fully-specified algorithms for JOSE and COSE | [RFC 9864](https://www.rfc-editor.org/rfc/rfc9864), October 2025 | the COSE algorithm `Ed25519` (-19), which replaces the polymorphic `EdDSA` (-8) |
14
+ | SCITT charter | [charter-ietf-scitt-01](https://datatracker.ietf.org/doc/charter-ietf-scitt/) | scope: building blocks for software supply chains |
15
+
16
+ ## In short
17
+
18
+ - **Our inclusion proof is already a SCITT inclusion proof.** We hash with RFC 6962 and prove with RFC 9162, sections 2.1.3 and 2.1.4. RFC 9942 registers exactly that structure as `RFC9162_SHA256` (value 1). The proof `{ leafIndex, treeSize, hashes }` carries the same three values as RFC 9942's `[tree_size, leaf_index, inclusion_path]`, in another order and encoding. The one exception is a tree of one leaf, below.
19
+ - **Our signatures and envelopes are not SCITT's.** SCITT requires COSE_Sign1 in CBOR, with an issuer and subject in a protected CWT Claims header. We sign DSSE envelopes over canonical JSON. Ed25519 is not the problem: COSE has it as -19.
20
+ - **Our log is not yet a transparency service.** It authenticates the client, but it does not verify the issuer's signature, keep trust anchors, or publish its registration policy in its own log. RFC 9943 requires all three.
21
+ - **Recommendation.** Issue each receipt in a second encoding, a COSE_Sign1 hash envelope over the same statement bytes. Teach the hosted log SCRAPI and the mandatory registration checks. Then write the agent-action profile as the rules that sit on top: what goes in the protected header, what a registration policy checks, and how the authorization, receipt, and reconciliation statements relate. Keep DSSE as the primary format until the v1.0 decision in step 1 of issue #185.
22
+ - **The field is crowded.** At least five individual drafts already profile SCITT for agent actions, two of them updated in October 2026, and four more extend one of them. The [next steps](#next-steps) start from them rather than from a blank draft.
23
+
24
+ ## The roles
25
+
26
+ | SCITT (RFC 9943, section 3) | agent-custody | notes |
27
+ | --- | --- | --- |
28
+ | Issuer | the gateway (`issuer.kind: "gateway"`) or the SDK (`issuer.kind: "sdk"`) | SCITT does not separate an issuer that enforces from one that self-reports. A profile must, because it is the first thing our verifier reads. |
29
+ | Signed Statement | the receipt envelope and the authorization statement, both signed by the issuer; also the delegation grant, the human approval, and the upstream attestation, each signed by another party | today the receipt embeds the other envelopes rather than registering them |
30
+ | Statement | the in-toto Statement v1 with `predicateType` `https://agent-custody.dev/receipt/v0.2` | RFC 9943, section 6, lists in-toto among the expected payload formats, so the payload can stay as it is |
31
+ | Subject (`sub`) | the in-toto subject name, `tool-call:<tool>:<receiptId>` | the authorization statement has the same subject as the receipt that follows it, which is what `sub` is for: grouping statements about one artifact |
32
+ | Artifact | one tool call | |
33
+ | Transparency Service | the log: a log file, `agent-custody log`, or the hosted log at log.agent-custody.dev | multi-tenant through `/t/<tenant>/`. RFC 9943, section 5.1, suggests one issuer identity per tenant, which our `log` id already is. |
34
+ | Receipt | the pair of a signed tree head and an inclusion proof, `treeHead` and `inclusion` in the bundle | one COSE_Sign1 in SCITT; two objects for us. See below. |
35
+ | Transparent Statement | the receipt bundle | SCITT puts the receipts in the statement's unprotected header (label 394). We put them beside the envelope. |
36
+ | Registration Policy | the tenant's bearer token, the rate limit, the monthly quota, and `hashOnly` | none of this is published as a statement in the log, and none of it is checked against the statement |
37
+ | Relying Party, Auditor | `verify`, `audit`, `log-check`, the browser verifier, the witness | |
38
+
39
+ ## The receipt as a Signed Statement
40
+
41
+ What a COSE encoding of the same receipt would carry, header by header.
42
+
43
+ | COSE_Sign1 part (RFC 9943, figure 3) | value for an agent-custody receipt | where it comes from today |
44
+ | --- | --- | --- |
45
+ | tag | 18 (COSE_Sign1) | |
46
+ | `alg` (1) | -19, `Ed25519` ([RFC 9864](https://www.rfc-editor.org/rfc/rfc9864), section 2.2) | Ed25519, implied by the keyid |
47
+ | `kid` (4) | the 32 bytes of our keyid, the SHA-256 of the key's SPKI DER | `signatures[0].keyid`, hex |
48
+ | CWT Claims (15), `iss` (1) | a URI naming the issuer: the gateway operator's, or the SDK host's | **missing.** We identify issuers by key only. A gateway publishes no identity document. |
49
+ | CWT Claims (15), `sub` (2) | the in-toto subject name | `subject[0].name` |
50
+ | CWT Claims (15), `iat` (6) | the receipt's `timestamp` as seconds since the epoch | `predicate.timestamp` |
51
+ | `typ` (16) | `application/scitt-statement+cose`, registered by RFC 9943, section 10.1 | |
52
+ | `payload_hash_alg` (258) | -16, SHA-256 ([RFC 9995](https://www.rfc-editor.org/rfc/rfc9995)) | in a hash envelope only |
53
+ | `payload_preimage_content_type` (259) | `application/vnd.in-toto+json` | the DSSE `payloadType` |
54
+ | `payload_location` (260) | optional: where the receipt file can be fetched by someone allowed to | |
55
+ | issuer kind | `gateway` or `sdk`, in the protected header so that a registration policy can read it | `predicate.issuer.kind`, in the payload. Needs a header label or CWT claim of its own. |
56
+ | payload | the SHA-256 of the canonical statement (hash envelope), or the canonical statement itself | the DSSE `payload` |
57
+ | unprotected header | empty when registered (RFC 9943, section 6.3); receipts (394) once registered | |
58
+
59
+ The statement bytes do not change. The same canonical JSON is signed twice, once under the DSSE pre-authentication encoding and once under the COSE `Sig_structure`. A verifier that reads COSE checks the second signature and then runs our checks on the payload. A verifier that reads DSSE does what it does today.
60
+
61
+ The hash envelope is the variant that matters for us. The hosted log is hash-only, and strict mode requires that: the log sees a leaf hash and never the receipt. With RFC 9995, a transparency service still verifies the issuer's signature, because the signature is over the digest. It learns the headers: `iss`, `sub`, `iat`, and the issuer kind. So **`sub` must not name the tool when the log may not learn it.** A profile should make `sub` the receipt id alone, `urn:uuid:<receiptId>`, and keep the tool name in the payload, where a capture rule governs it. RFC 9942, section 6.2, requires a privacy analysis of every mandatory header.
62
+
63
+ ## The log as a transparency service
64
+
65
+ What RFC 9943 requires of a transparency service, and where the log stands.
66
+
67
+ | requirement | RFC 9943 | the log today | to close it |
68
+ | --- | --- | --- | --- |
69
+ | produce COSE Receipts | 5.1 | signed DSSE tree heads and JSON inclusion proofs | emit a COSE Receipt of inclusion beside them |
70
+ | verify the issuer's signature at registration | 5.1.1.1, 6.3 | no: `POST /append` checks the bearer token and nothing in the leaf | verify against the tenant's trust anchors; a hash-only leaf cannot be checked, a hash envelope can |
71
+ | keep trust anchors | 5.1.1.1 | no issuer keys are registered with the log | a list of issuer keyids per tenant, managed through the portal |
72
+ | publish the registration policy and trust anchors as Signed Statements in the log | 5.1.1.1 | no | log them as the tenant's first leaves, and log every change |
73
+ | apply the policy most recently committed | 5.1.1 | policy is configuration | follows from the row above |
74
+ | reproducible registration for auditors | 5.1.1.2 | an auditor can rebuild the tree but not re-run a check, because no check is made | follows from the rows above |
75
+ | append-only, non-equivocation, replayability | 5.1.3 | RFC 9162 tree, consistency proofs, checkpoints on a second host, the witness, the anchor | already met; the witness and the anchor go beyond what SCITT asks |
76
+ | unprotected header emptied before inclusion | 6.3 | the leaf is the whole canonical envelope | define the leaf as the COSE_Sign1 with an empty unprotected header |
77
+ | a receipt for every registered statement, on request | 6.3 | inclusion is returned on append; a later proof needs the tenant's token and a client that rebuilds it | `GET /entries/<id>`, SCRAPI section 2.4 |
78
+ | register | [SCRAPI](https://datatracker.ietf.org/doc/draft-ietf-scitt-scrapi/11/) section 2.3, `POST /entries` with `application/cose` | `POST /append` with JSON | add `POST /entries`, returning 201 with the receipt or 202 with a location |
79
+ | key discovery | SCRAPI section 2.1, `/.well-known/scitt-keys`, a COSE Key Set | `/.well-known/agent-custody-log.json`, JSON with PEM keys | serve both, from the same keys: OKP keys, curve Ed25519 (6), kid set |
80
+ | errors | SCRAPI section 2, Concise Problem Details in CBOR | JSON `{ error }` | on the SCRAPI routes only |
81
+
82
+ SCITT needs the leaf to be defined, and RFC 9942 does not define it. Its verifier applies the proof "to the bytes of a candidate entry" and leaves the entry to the transparency service. Our leaf is the canonical JSON of the DSSE envelope. A COSE leaf would be the encoded COSE_Sign1 with an empty unprotected header. [draft-gruszka-scitt-statement-identification-02](https://datatracker.ietf.org/doc/draft-gruszka-scitt-statement-identification/02/) collects the open questions about how a statement is identified, and the profile should answer them for agent actions.
83
+
84
+ ## Inclusion proofs and COSE Receipts
85
+
86
+ The two proofs carry the same values.
87
+
88
+ | ours | RFC 9942, section 5.2 |
89
+ | --- | --- |
90
+ | `inclusion.treeSize` | `tree_size` |
91
+ | `inclusion.leafIndex` | `leaf_index` |
92
+ | `inclusion.hashes`, hex strings | `inclusion_path`, byte strings, same order |
93
+ | the leaf hash, `SHA-256(0x00 ‖ leaf)` | the same; RFC 9162 |
94
+ | `rootHash` in the tree head payload | the receipt's detached payload, the Merkle tree hash at `tree_size`, recomputed by the verifier |
95
+ | the tree head's signature, by the log's key or the issuer's | the receipt's COSE_Sign1 signature |
96
+ | `log` in the tree head | the receipt's `iss` |
97
+ | `timestamp` in the tree head | a CWT claim in the receipt's protected header, such as `iat` |
98
+
99
+ Three differences are worth recording.
100
+
101
+ 1. **A tree of one leaf.** RFC 9942's CDDL requires at least one hash in an inclusion path, `inclusion_path: [ + bstr ]`. The first leaf of a log has an empty path, as the bundle example in the specification shows: `{ "leafIndex": 0, "treeSize": 1, "hashes": [] }`. Consistency paths have the same limit, `[ + bstr ]`, and RFC 9162 makes the proof between two equal sizes empty. Our log produces both: the first receipt of every tenant, and the heartbeat checkpoint that re-signs a quiet log at the size it already had. Ask the working group whether `+` was meant to exclude these cases; if not, raise an erratum. Until it is settled, the profile must say what to do: emit no receipt at size one, or relax the CDDL.
102
+ 2. **Where the signature sits.** Our tree head is signed once per size and serves every receipt under it. A COSE Receipt signs the root together with its protected header. RFC 9943, section 6, requires `iss` and `sub` in that header, and its example receipt repeats the statement's subject. So a COSE Receipt is signed once per subject. The log signs heads on request, so the cost is a signature per append, which it pays already. But a receipt can no longer be checked by matching its tree head to a published checkpoint byte for byte. It has to be checked by root and size.
103
+ 3. **Order of checks.** RFC 9942 verifies the proof first and the signature second, over the root the proof yields. Our verifier checks the tree head's signature and then recomputes the root from the proof. The result is the same. The vectors should include a bundle that fails in each order.
104
+
105
+ ## Checkpoints, consistency, and witnesses
106
+
107
+ A checkpoint is a signed tree head at a size. `GET /consistency` returns an unsigned RFC 9162 consistency proof between two sizes. RFC 9942, section 5.3, defines a **Receipt of Consistency**: a COSE_Sign1 whose detached payload is the newer root, with the proof in the unprotected header. A checkpoint together with the proof from the previous checkpoint is that receipt. The log can serve it as a second form of `GET /checkpoints` and lose nothing.
108
+
109
+ A witness countersigns by adding its signature to the checkpoint's DSSE envelope, which DSSE allows. COSE_Sign1 has one signer. The nearest SCITT construction is a second receipt from a second service, which RFC 9943, section 5, allows. A witness does not register statements, though, so it is not a transparency service. Two options:
110
+ - the witness issues its own Receipt of Consistency over the checkpoint it checked, and a verifier that requires the witness requires that receipt;
111
+ - the profile defines the countersigned checkpoint as a COSE_Sign (several signers) rather than a COSE_Sign1.
112
+
113
+ The first needs no new structure. Prefer it.
114
+
115
+ [draft-mih-scitt-checkpointed-local-log-02](https://datatracker.ietf.org/doc/draft-mih-scitt-checkpointed-local-log/02/) carries a producer's own checkpoints as Signed Statements and registers them with independent transparency services. That fits an SDK that keeps a local log file. It uses a Merkle Mountain Range ([draft-bryce-cose-receipts-mmr-profile-03](https://datatracker.ietf.org/doc/draft-bryce-cose-receipts-mmr-profile/03/)) rather than RFC 9162, so it is a pattern to borrow, not a format to adopt.
116
+
117
+ ## Chain anchoring
118
+
119
+ SCITT has nothing to say about anchoring. RFC 9943 leaves the security of each data structure to its own specification (section 5.1.3) and allows adjacent services beside a transparency service (section 5.1.4). The anchor is one. It commits checkpoints to an EVM chain as an RFC 9162 tree of checkpoint leaves; [anchoring](anchoring.md) is the guide. [draft-fassbender-scitt-time-anchor-08](https://datatracker.ietf.org/doc/draft-fassbender-scitt-time-anchor/08/), an independent-stream draft, does the same for Bitcoin through OpenTimestamps and also needs no change to SCITT.
120
+
121
+ Options:
122
+ - **nothing**: anchoring stays an adjacent service, described in an informative appendix of the profile;
123
+ - **an anchor record as a Signed Statement**, issued by the anchor's key and registered like any other statement, so that a relying party can find the anchor through the log;
124
+ - **a new verifiable data structure** in RFC 9942's registry, for "an RFC 9162 tree whose root is in a transaction". This would need a profile of its own and expert review, and it buys nothing that the first option lacks.
125
+
126
+ Choose the first option now. Consider the second once anyone outside agent-custody asks for it.
127
+
128
+ ## What differs, and the options for each
129
+
130
+ | difference | an alternative COSE encoding | a profile | nothing | recommendation |
131
+ | --- | --- | --- | --- | --- |
132
+ | DSSE, not COSE_Sign1 | issue each receipt twice: DSSE as now, plus a COSE_Sign1 hash envelope over the same statement bytes | a profile that admits a DSSE statement as the payload of a COSE_Sign1 (signed twice, nested) or as a "bare" presentation beside the enveloped one, as [draft-noa-scitt-ai-agent-receipt-01](https://datatracker.ietf.org/doc/draft-noa-scitt-ai-agent-receipt/01/) does | stay DSSE-only and claim alignment with the data structure alone | **encoding.** RFC 9943 accepts only COSE_Sign1 as a Signed Statement, so the DSSE form cannot be registered with another vendor's service. One statement and two signatures is the smallest change. |
133
+ | JSON, not CBOR | the statement stays canonical JSON; only the envelope is CBOR | | | nothing to decide: a COSE payload can be any bytes, and the preimage content type names them |
134
+ | Ed25519 | `alg` -19 | the profile makes -19 mandatory to implement and rejects -8 | | **encoding**, -19. One key signing under two formats is a reuse that RFC 9943, section 9.4, asks issuers to avoid. The two signed structures cannot be mistaken for each other (DSSE's begins `DSSEv1`, COSE's is a CBOR array that begins `Signature1`), so the profile should argue this in its security considerations rather than require a second key. |
135
+ | keyid, not a named issuer | `kid` from our keyid | the profile requires `iss` as a URI and says how the key behind it is found | | **profile.** It needs an issuer key document for gateways like the log's, which we do not have. |
136
+ | our tree heads | a COSE Receipt of inclusion beside the DSSE tree head | | | **encoding.** The values are the same, and the size-one case goes to the working group. |
137
+ | checkpoints and consistency proofs | Receipts of Consistency | | | **encoding** |
138
+ | witness countersignatures | a witness Receipt of Consistency | | keep DSSE countersignatures | **encoding**, and keep DSSE countersignatures alongside |
139
+ | chain anchoring | | an informative appendix | | **nothing** normative |
140
+ | a log that does not check the issuer | | the profile's registration policy | | **implement** the mandatory checks; it is a requirement of RFC 9943, not an option |
141
+ | a hash-only log | the hash envelope | the profile requires the hash envelope for logs the issuer does not run | | **profile** |
142
+
143
+ ## An agent-action profile
144
+
145
+ What an agent-custody profile of SCITT would contain, section by section.
146
+
147
+ 1. **Scope and roles.** One tool call is one artifact. Issuers are enforcing gateways and self-reporting SDKs. The transparency service is a log the issuer may or may not run. Relying parties are auditors who hold public keys only.
148
+ 2. **Signed Statements.** COSE_Sign1, tagged. `alg` -19 mandatory to implement. `kid` is the SHA-256 of the SPKI. CWT claims `iss` and `sub`, with `sub` as `urn:uuid:<receiptId>`, and `iat`. `typ`. The issuer kind is a protected header. The payload is a hash envelope over an in-toto Statement v1, or the statement itself where the service may read it.
149
+ 3. **Statement types**, one `predicateType` each, related by `sub`: the authorization (before the call), the receipt (after it), the reconciliation (the provider's terminal outcome, naming the original), the delegation grant (signed by the principal), the human approval (signed by approvers), and the upstream attestation (signed by the tool). For each, which fields a verifier reads, with their provenance labels: `attested`, `observed`, and `claimed`. The labels are what makes the evidence honest, and no other draft has them in this form.
150
+ 4. **Registration policy.** Issuer keyids per tenant as trust anchors, published in the log. Required protected headers. An optional strict claim. The rule that a receipt referring to an authorization is refused unless that authorization was registered earlier in the same log. Today our verifier checks the order; with this rule, the service enforces it.
151
+ 5. **Receipts.** `RFC9162_SHA256`, inclusion mandatory and consistency recommended. How the first leaf of a log is handled. Receipts of Consistency for checkpoints, and for witnesses.
152
+ 6. **Verification.** The verification steps of the specification, in order, mapped onto COSE verification and payload checks. How a verifier reports a check passed "as committed" when a capture rule withholds a value.
153
+ 7. **Privacy considerations.** Capture rules and salted commitments. What the headers reveal to the service (RFC 9942, section 6.2). What the tree size reveals: a per-tenant log leaks the tenant's call count (RFC 9942, section 6.1).
154
+ 8. **Security considerations.** An SDK receipt is self-reported. One key under two formats. What SCITT does not give: completeness. An issuer can leave a call unregistered (RFC 9943, section 9.3); strict mode and provider-side completeness ([issue #178](https://github.com/svayatta/agent-custody/issues/178)) are our answers. The threat model in [threat-model.md](threat-model.md).
155
+ 9. **Appendices.** Anchoring, informative. Conformance vectors in both encodings. The mapping to DSSE for existing receipts.
156
+
157
+ ## Other agent-action drafts
158
+
159
+ None of these is a working group document. All are individual submissions, and the charter scopes the group to software supply chains. Whether the group takes on any agent profile is a charter question for the chairs, not one a better draft answers. Each row is from the draft's abstract, and from its text where noted.
160
+
161
+ | draft | what it records | overlap with ours |
162
+ | --- | --- | --- |
163
+ | [draft-noa-scitt-ai-agent-receipt-01](https://datatracker.ietf.org/doc/draft-noa-scitt-ai-agent-receipt/01/), August 2026 | a signed action receipt over canonical JSON, hash-chained, bare or in a COSE_Sign1 | closest in encoding: its text requires `alg` -19 and rejects -8, uses JCS ([RFC 8785](https://www.rfc-editor.org/rfc/rfc8785)), and defines bare and enveloped forms |
164
+ | [draft-mih-scitt-agent-action-capsule-05](https://datatracker.ietf.org/doc/draft-mih-scitt-agent-action-capsule/05/), September 2026, with [selective disclosure](https://datatracker.ietf.org/doc/draft-mih-scitt-agent-action-capsule-sel-disc/00/), [provenance binding](https://datatracker.ietf.org/doc/draft-rampalli-scitt-capsule-provenance-binding/00/), and two companion drafts | one record per action on every verdict, refusals included; an attempt is distinct from an observed result | our `denied` and `withheld` receipts, `execution.upstream`, and `consumed` |
165
+ | [draft-munoz-scitt-permit-profile-01](https://datatracker.ietf.org/doc/draft-munoz-scitt-permit-profile/01/), July 2026 | a pre-execution authorization bound to the canonical request, paired with a closure record | our authorization statement and precommit |
166
+ | [draft-emirdag-scitt-ai-agent-execution-01](https://datatracker.ietf.org/doc/draft-emirdag-scitt-ai-agent-execution/01/), October 2026 | operator as issuer, an independent evidence custodian as service, sequence completeness, redaction receipts, compliance mappings | our roles, and [compliance.md](compliance.md) |
167
+ | [draft-thaha-scitt-agent-execution-evidence-00](https://datatracker.ietf.org/doc/draft-thaha-scitt-agent-execution-evidence/00/), October 2026 | agent identity and capabilities bound to a hash-chained record of calls; admission records across operators | the delegation grant, and receipts for agent-to-agent calls |
168
+ | [draft-jangra-scitt-digest-evidence-00](https://datatracker.ietf.org/doc/draft-jangra-scitt-digest-evidence/00/), October 2026 | an RFC 9162 log of salted digests only, with completeness chains, selective disclosure, and spot checks | our hash-only log and capture rules |
169
+ | [draft-kamimura-scitt-refusal-events-04](https://datatracker.ietf.org/doc/draft-kamimura-scitt-refusal-events/04/), October 2026 | a claim set for AI content refusals | narrower: content refusals, not tool calls |
170
+ | [draft-mih-sokolov-scitt-payload-binding-06](https://datatracker.ietf.org/doc/draft-mih-sokolov-scitt-payload-binding/06/), October 2026 | declared canonicalization, a derived identifier, and digest references, using RFC 9995 | how our canonical JSON and digests would be declared |
171
+
172
+ ## Next steps
173
+
174
+ Nothing has been posted to the IETF. Each step below is for the maintainers to decide, and the first four need no one outside the project.
175
+
176
+ 1. **Read the closest drafts in full**: the noa, capsule, and permit drafts first. For each, record what it requires that we cannot meet and what we have that it lacks, in a reply on issue #185. Then decide whether to co-author with one of them or write our own. Our contribution is distinct in three places: provenance labels, an authorization that the service orders before its receipt, and a bridge from DSSE and in-toto. A sixth profile that overlaps the other five on everything else will not be adopted.
177
+ 2. **Build the COSE encoding in code before writing a draft.** Add a COSE_Sign1 hash envelope beside the DSSE envelope in `src/receipt.ts`, verify it in `src/verify.ts` and the browser verifier, and add vectors in both encodings. Then add `POST /entries`, `GET /entries/<id>`, and `/.well-known/scitt-keys` to the log, with issuer verification against per-tenant trust anchors. A profile that has running code and vectors gets read.
178
+ 3. **Settle the open points in the v1.0 specification** (step 1 of issue #185): `sub` as the receipt id alone; an `iss` URI and the gateway's identity document; the issuer-kind header; the leaf of a COSE entry; what happens at tree size one.
179
+ 4. **Interoperate.** Register a receipt with an existing SCITT service that implements SCRAPI, and verify its receipt with our verifier. Verify one of our COSE receipts with someone else's SCITT verifier. Record which implementations were used.
180
+ 5. **Ask before submitting.** On the scitt@ietf.org list: whether the inclusion-path CDDL in RFC 9942 was meant to exclude a tree of one leaf; and whether the chairs see agent-action profiles inside the charter, and if not, where they would go. The list's archive is public, so a message there is publication. It needs the maintainers' sign-off and wording.
181
+ 6. **The individual draft.** `draft-<author>-scitt-agent-custody-profile-00` (the name is an assumption), in kramdown-rfc, with the sections above and the vectors as an appendix. The Internet-Draft cutoff for IETF 127 is 2 November 2026. That is too soon for steps 1 to 4. Aim for IETF 128 in Kuala Lumpur, which starts 6 March 2027, and for discussion on the list before then.
182
+ 7. **The hackathon.** IETF 127's hackathon is on 14 and 15 November 2026 in San Francisco. Its wiki already lists a SCITT time-anchor project. The SCITT session is on Wednesday 18 November, from 16:30 to 17:30 Pacific time. Attending, remotely or in person, is worth it to meet the authors of the drafts above. A project of our own fits IETF 128's hackathon, once step 4 has a result.
183
+
184
+ ## Not done here
185
+
186
+ This page changes no code and no format. It does not decide between DSSE and COSE for v1.0; that is step 1 of issue #185. It claims no conformance to SCITT, and none should be claimed until step 2 is built and step 4 has been run against an implementation we did not write.
@@ -53,6 +53,7 @@ Each row names the attacker, the move, the defence, and whether the defence is a
53
53
  | Rewrite a receipt after the fact | The receipt's envelope is signed by the gateway key, which the operator holds, so the signature alone does not stop this. What stops it is the log: the leaf hash of the original envelope is in a tree whose head the log signed, and a rewritten receipt has a different hash with no inclusion proof. | evidence, with a remote log; deployment, with a local log the operator can rewrite |
54
54
  | Drop a receipt | The log's tree only grows, and consistency proofs between any two heads show nothing was removed. A receipt the operator never logged never existed as evidence, which is the point of `precommit` for consequential calls: the authorization leaf goes in before the action. [Strict mode](usage.md#strict-mode) does that for every call, with a remote hash-only log and no outbox, and its receipts say so, so a verifier can require it; a modified gateway can still claim strict mode. | evidence for logged receipts; withheld calls for pre-committed tools, and for every call under strict mode |
55
55
  | Forge a receipt for an action that never happened | Nothing in the log stops the operator logging a fabricated receipt; the log commits to existence, not truth. What limits it: the upstream's signature over the result when the upstream signs, provider attestations where the provider delivers them, and the principal's signature on the grant. A forged receipt for a signing upstream fails its `upstream` checks. | evidence, where the upstream signs; otherwise the operator's word |
56
+ | Act outside the gateway with the provider's own credentials | Nothing on the gateway's side sees it. `agent-custody completeness` lists the provider's objects with the auditor's own read-only key and reports each one that no verified receipt names; a forged receipt file fails verification and cannot cover for it. | evidence, for a provider that lists its objects (Stripe today) |
56
57
  | Replace the policy and claim a different one decided | The receipt carries the sha256 of the policy text; a verifier with the policy file can check it, and a policy change is a different digest in every later receipt. | evidence |
57
58
  | Produce a second, cleaner history | With a remote log, both histories would need heads signed by the log's key at the same size with different roots; the checkpoints host and the witness make that detectable. With a local log, a copy taken earlier by someone else is the only defence. | evidence with a witnessed remote log |
58
59
  | Erase what an agent believed | `forget` erases the value and leaves a digest keyed by a forget key held outside the ledger, so the erasure is provable without the value. A forget with `none` leaves nothing and the custody pack says so. | evidence |
package/docs/tutorials.md CHANGED
@@ -44,6 +44,7 @@ Suggested reading order is the numbering. Output lands in `examples-out/`, which
44
44
  | 32 | the gateway console | [32-console.ts](../examples/32-console.ts) | a gateway that has made two receipts, and its operator's console: a token on every route, the receipts with a verdict each, a stricter policy replayed against the recorded calls before it is saved, the save recorded with the old version kept and a stale edit refused, and a grant inspected, revoked, and then refused by the gateway | `src/console.ts`, `src/console-page.ts` |
45
45
  | 33 | anchoring the log on a chain | [33-chain-anchor.ts](../examples/33-chain-anchor.ts) | a log publishes a checkpoint, the anchor commits it to a stand-in chain in one transaction, and `log-check` passes against the chain; the operator swaps in a rewritten log under the same key and log id, and `log-check` fails it from the chain alone |
46
46
  | 34 | strict mode | [34-strict-mode.ts](../examples/34-strict-mode.ts) | `check` lists what strict mode would refuse; a local log and a log that is not hash-only are refused at startup; behind a hash-only log with a pinned key, a read is precommitted and its receipt says `issuer.strict`; `requireStrict` accepts it and refuses an ordinary receipt; with the log down the call is not forwarded and the outbox stays empty | `src/config.ts`, `src/gateway.ts`, `src/check.ts`, `src/verify.ts` |
47
+ | 35 | completeness from the provider's side | [35-completeness.ts](../examples/35-completeness.ts) | two refunds through the gateway and a third issued straight through the provider; the auditor lists the provider's refunds with a read-only key, matches two to verified receipts, and reports the third as an action with no receipt |
47
48
 
48
49
  ## How policies are defined, in one paragraph
49
50
 
@@ -55,6 +56,7 @@ A policy is a Cedar file. The gateway turns each tool call into a Cedar request:
55
56
  - [codex-recovery.md](codex-recovery.md): the opt-in live Codex support incident, operator-reviewed recovery, and its offline state example
56
57
  - [approvals.md](approvals.md): exact-action signatures, two-person thresholds, consumption, and privacy limits
57
58
  - [console.md](console.md): the admin console: run it, what each tab does, how it is protected, and its limits
59
+ - [completeness.md](completeness.md): matching the provider's own records against verified receipts, to find actions taken outside the gateway
58
60
  - [anchoring.md](anchoring.md): the log's checkpoints on Ethereum: what an anchor proves, running it, and checking a log against the chain
59
61
  - [financial-operations.md](financial-operations.md): payment retries, budget reservations, provider contract, and operator reconciliation
60
62
  - [sdk.md](sdk.md): the interceptor and every adapter
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agent-custody/receipts",
3
- "version": "0.11.0",
3
+ "version": "0.13.0",
4
4
  "mcpName": "io.github.svayatta/agent-custody",
5
5
  "description": "Chain of custody for AI agents: signed, independently verifiable receipts for tool calls. MCP gateway + Cedar policy + Merkle transparency log",
6
6
  "license": "Apache-2.0",