From e7a76662a38e59bbc575879bdb07450978360162 Mon Sep 17 00:00:00 2001
From: Revinand
Date: Tue, 17 Nov 2026 14:37:12 +0100
Subject: [PATCH 01/14] test: capture 2.7.2 goldens for the x402 challenge,
facilitator payload, well-known and doctor
---
tests/integration/baseline-goldens.test.ts | 511 ++++++++++++++++++
.../goldens/2.7.2/doctor-multi.json | 119 ++++
.../goldens/2.7.2/doctor-single.json | 114 ++++
.../goldens/2.7.2/facilitator-settle.json | 43 ++
.../goldens/2.7.2/facilitator-verify.json | 43 ++
.../goldens/2.7.2/well-known-multi.json | 310 +++++++++++
.../goldens/2.7.2/well-known-single.json | 287 ++++++++++
.../goldens/2.7.2/x402-challenge-multi.json | 36 ++
.../goldens/2.7.2/x402-challenge-single.json | 23 +
9 files changed, 1486 insertions(+)
create mode 100644 tests/integration/baseline-goldens.test.ts
create mode 100644 tests/integration/goldens/2.7.2/doctor-multi.json
create mode 100644 tests/integration/goldens/2.7.2/doctor-single.json
create mode 100644 tests/integration/goldens/2.7.2/facilitator-settle.json
create mode 100644 tests/integration/goldens/2.7.2/facilitator-verify.json
create mode 100644 tests/integration/goldens/2.7.2/well-known-multi.json
create mode 100644 tests/integration/goldens/2.7.2/well-known-single.json
create mode 100644 tests/integration/goldens/2.7.2/x402-challenge-multi.json
create mode 100644 tests/integration/goldens/2.7.2/x402-challenge-single.json
diff --git a/tests/integration/baseline-goldens.test.ts b/tests/integration/baseline-goldens.test.ts
new file mode 100644
index 0000000..3b1251a
--- /dev/null
+++ b/tests/integration/baseline-goldens.test.ts
@@ -0,0 +1,511 @@
+/**
+ * 2.7.2 baseline for x402 challenges over HTTP, MCP and A2A, remote facilitator
+ * request bodies, the well-known document and a healthy `doctor --json` report.
+ *
+ * Keep challenge and facilitator request bytes unchanged when 2.8.0 options are
+ * disabled. If a change alters a golden, update its file in the same commit and
+ * explain why.
+ *
+ * The gateway uses the provider and adapter setup from `runGateway`. One loopback
+ * server fakes the JSON-RPC nodes, remote facilitator and merchant backend.
+ */
+import { createServer, type IncomingMessage, type Server } from 'node:http';
+import type { AddressInfo } from 'node:net';
+import { Client } from '@modelcontextprotocol/sdk/client/index.js';
+import { StreamableHTTPClientTransport } from '@modelcontextprotocol/sdk/client/streamableHttp.js';
+import type { Transport } from '@modelcontextprotocol/sdk/shared/transport.js';
+import { privateKeyToAccount } from 'viem/accounts';
+import { afterAll, beforeAll, describe, expect, it } from 'vitest';
+import { createAp2AuthorizationProvider } from '../../src/authorization/ap2';
+import { printDoctorReport, runDoctor } from '../../src/cli/commands/doctor';
+import { type GatewayConfig, parseConfig } from '../../src/config';
+import { NOOP_LOGGER, PAYMENT_HEADER, PAYMENT_REQUIRED_HEADER } from '../../src/core';
+import { createGateway } from '../../src/gateway';
+import { createConfiguredPaymentProviders } from '../../src/gateway/payment-providers';
+import { createPaymentProof } from '../../src/payments/x402/client';
+import { createA2aAdapter } from '../../src/protocols/a2a';
+import { A2A_X402_EXTENSION_URI } from '../../src/protocols/a2a/x402-extension';
+import { createAcpAdapter } from '../../src/protocols/acp';
+import { createMcpAdapter } from '../../src/protocols/mcp';
+import { createSqliteReceiptStore } from '../../src/storage/receipts';
+import { PACKAGE_VERSION } from '../../src/version';
+import { createParties } from '../unit/authorization-ap2/fixtures';
+import { createCapturingIo } from '../unit/cli/fixtures';
+
+process.env['NODE_ENV'] = 'test';
+
+const BASE_SEPOLIA = 'eip155:84532';
+const ARBITRUM_SEPOLIA = 'eip155:421614';
+const PAY_TO = '0x1111111111111111111111111111111111111111';
+// Anvil account 2. LOCAL DEVELOPMENT ONLY - DO NOT FUND
+const BUYER_KEY = '0x5de4111afa1a4b94908f83103eb1f1706367c2e68ca870fc3fb9a804cdab365a' as const;
+const BUYER = privateKeyToAccount(BUYER_KEY).address;
+// A fixed nonce and validity window keep the signature and payment payload deterministic
+const NONCE = `0x${'42'.repeat(32)}` as const;
+const VALID_BEFORE = 4_102_444_800;
+const TX = `0x${'ab'.repeat(32)}`;
+const GOLDEN = './goldens/2.7.2';
+
+// Capture raw facilitator request bodies by route
+const facilitatorBodies: Record = { verify: [], settle: [] };
+let upstream: Server;
+let upstreamUrl = '';
+
+async function readBody(req: IncomingMessage): Promise {
+ const chunks: Buffer[] = [];
+ for await (const chunk of req) chunks.push(chunk as Buffer);
+ return Buffer.concat(chunks).toString('utf8');
+}
+
+// Use the chain ID from the RPC path and report code at any address.
+// Return 6 for eth_call to satisfy the token decimals health check.
+function rpcResult(chainId: number, method: string): unknown {
+ if (method === 'eth_chainId') return `0x${chainId.toString(16)}`;
+ if (method === 'eth_getCode') return '0x6080';
+ if (method === 'eth_call') return `0x${'6'.padStart(64, '0')}`;
+ return undefined;
+}
+
+function startUpstream(): Promise {
+ upstream = createServer(async (req, res) => {
+ const body = await readBody(req);
+ const path = req.url ?? '';
+ const reply = (value: unknown) => {
+ res.writeHead(200, { 'content-type': 'application/json' });
+ res.end(JSON.stringify(value));
+ };
+ const rpc = /^\/rpc\/(\d+)$/.exec(path);
+ if (rpc) {
+ const { id, method } = JSON.parse(body) as { id: number; method: string };
+ const result = rpcResult(Number(rpc[1]), method);
+ reply(
+ result === undefined
+ ? { jsonrpc: '2.0', id, error: { code: -32601, message: `no ${method}` } }
+ : { jsonrpc: '2.0', id, result },
+ );
+ return;
+ }
+ if (path === '/facilitator/supported') {
+ reply({
+ kinds: [BASE_SEPOLIA, ARBITRUM_SEPOLIA].map((network) => ({
+ x402Version: 2,
+ scheme: 'exact',
+ network,
+ })),
+ extensions: [],
+ signers: {},
+ });
+ return;
+ }
+ if (path === '/facilitator/verify') {
+ facilitatorBodies['verify']?.push(body);
+ reply({ isValid: true, payer: BUYER });
+ return;
+ }
+ if (path === '/facilitator/settle') {
+ facilitatorBodies['settle']?.push(body);
+ reply({ success: true, transaction: TX, network: BASE_SEPOLIA, payer: BUYER });
+ return;
+ }
+ if (path.startsWith('/backend/')) {
+ reply({ ok: true });
+ return;
+ }
+ res.writeHead(404).end();
+ });
+ return new Promise((resolve) =>
+ upstream.listen(0, '127.0.0.1', () => {
+ upstreamUrl = `http://127.0.0.1:${(upstream.address() as AddressInfo).port}`;
+ resolve();
+ }),
+ );
+}
+
+const pathInput = {
+ type: 'object',
+ properties: { checkout_session_id: { type: 'string' } },
+ required: ['checkout_session_id'],
+ additionalProperties: false,
+};
+const bodyInput = { type: 'object', additionalProperties: true };
+
+// Define a free checkout operation exposed only through ACP
+function acpResource(method: string, path: string, withPath: boolean, withBody: boolean) {
+ return {
+ name: `ACP ${method} ${path}`,
+ input: {
+ type: 'object',
+ properties: {
+ ...(withPath ? { path: pathInput } : {}),
+ ...(withBody ? { body: bodyInput } : {}),
+ },
+ required: withPath ? ['path'] : ['body'],
+ additionalProperties: false,
+ },
+ backend: {
+ type: 'http',
+ method,
+ url: `${upstreamUrl}/backend${path}`,
+ inputBindings: {
+ ...(withPath ? { path: 'path' } : {}),
+ ...(withBody ? { body: 'body' } : {}),
+ },
+ },
+ pricing: { type: 'free' },
+ expose: ['acp'],
+ };
+}
+
+// Configure HTTP, MCP, A2A and ACP with x402, MPP and AP2 using the 2.7.2 config format
+async function goldenConfig(x402: Record): Promise {
+ const parties = await createParties();
+ const session = '/checkout_sessions/{checkout_session_id}';
+ return parseConfig(
+ {
+ version: 1,
+ merchant: {
+ id: 'golden-store',
+ name: 'Golden Store',
+ publicBaseUrl: 'https://gateway.example',
+ },
+ server: { port: 8080, host: '127.0.0.1' },
+ storage: { receipts: { driver: 'sqlite', path: ':memory:' } },
+ protocols: {
+ http: { enabled: true },
+ mcp: { enabled: true, mountPath: '/mcp' },
+ a2a: { enabled: true, mountPath: '/a2a' },
+ acp: {
+ enabled: true,
+ mountPath: '/acp',
+ auth: { type: 'bearer', token: 'golden-acp-token' },
+ idempotency: { retentionHours: 24 },
+ checkout: {
+ operations: {
+ createCheckoutSession: 'acp_create',
+ updateCheckoutSession: 'acp_update',
+ getCheckoutSession: 'acp_get',
+ completeCheckoutSession: 'acp_complete',
+ cancelCheckoutSession: 'acp_cancel',
+ },
+ },
+ },
+ },
+ resources: {
+ market_report: {
+ name: 'Market Report',
+ description: 'Latest market analysis for a symbol.',
+ input: {
+ type: 'object',
+ properties: { symbol: { type: 'string' } },
+ required: ['symbol'],
+ additionalProperties: false,
+ },
+ backend: { type: 'http', method: 'GET', url: `${upstreamUrl}/backend/report` },
+ pricing: { type: 'fixed', amount: '0.01', currency: 'USDC' },
+ expose: ['http', 'mcp', 'a2a'],
+ payments: ['x402'],
+ },
+ // Require AP2 on a resource so doctor doesn't warn that AP2 is unused
+ ap2_report: {
+ name: 'Mandated Report',
+ input: { type: 'object', properties: {}, additionalProperties: false },
+ backend: { type: 'http', method: 'GET', url: `${upstreamUrl}/backend/ap2-report` },
+ pricing: { type: 'fixed', amount: '0.02', currency: 'USDC' },
+ expose: ['http'],
+ payments: ['x402'],
+ authorization: { required: ['ap2'] },
+ },
+ mpp_report: {
+ name: 'MPP Report',
+ input: { type: 'object', properties: {}, additionalProperties: false },
+ backend: { type: 'http', method: 'GET', url: `${upstreamUrl}/backend/mpp-report` },
+ pricing: { type: 'fixed', amount: '0.01', currency: 'USDC' },
+ expose: ['http'],
+ payments: ['mpp'],
+ },
+ acp_create: acpResource('POST', '/checkout_sessions', false, true),
+ acp_update: acpResource('POST', session, true, true),
+ acp_get: acpResource('GET', session, true, false),
+ acp_complete: acpResource('POST', `${session}/complete`, true, true),
+ acp_cancel: acpResource('POST', `${session}/cancel`, true, true),
+ },
+ payments: {
+ x402: {
+ enabled: true,
+ facilitator: { mode: 'remote', url: `${upstreamUrl}/facilitator` },
+ maxTimeoutSeconds: 120,
+ ...x402,
+ },
+ mpp: {
+ enabled: true,
+ network: BASE_SEPOLIA,
+ rpcUrl: `${upstreamUrl}/rpc/84532`,
+ asset: '0x036CbD53842c5426634e7929541eC2318f3dCF7e',
+ assetName: 'USDC',
+ assetVersion: '2',
+ recipient: PAY_TO,
+ realm: 'gateway.example',
+ challengeSecret: 'golden-mpp-challenge-secret-'.padEnd(32, 'x'),
+ facilitator: { mode: 'remote', url: `${upstreamUrl}/facilitator` },
+ },
+ },
+ authorization: {
+ ap2: {
+ enabled: true,
+ specVersion: '0.2.0',
+ mode: 'direct',
+ trust: {
+ mandateIssuers: parties.mandateIssuers,
+ checkoutIssuers: parties.checkoutIssuers,
+ },
+ },
+ },
+ },
+ {},
+ );
+}
+
+function singleOffer(): Record {
+ return { network: BASE_SEPOLIA, rpcUrl: `${upstreamUrl}/rpc/84532`, payTo: PAY_TO };
+}
+
+function multiOffer(): Record {
+ return {
+ options: [
+ { network: BASE_SEPOLIA, payTo: PAY_TO },
+ { network: ARBITRUM_SEPOLIA, payTo: PAY_TO, assetTransferMethod: 'permit2' },
+ ],
+ networks: {
+ [BASE_SEPOLIA]: { rpcUrl: `${upstreamUrl}/rpc/84532` },
+ [ARBITRUM_SEPOLIA]: { rpcUrl: `${upstreamUrl}/rpc/421614` },
+ },
+ };
+}
+
+interface Running {
+ readonly url: string;
+ readonly config: GatewayConfig;
+ close(): Promise;
+}
+
+// Wire the store, providers and adapters as in `runGateway`, without signal handlers
+async function startGateway(config: GatewayConfig): Promise {
+ const store = createSqliteReceiptStore({ path: ':memory:' });
+ await store.init();
+ const paymentProviders = await createConfiguredPaymentProviders(config.payments, NOOP_LOGGER);
+ const ap2 = config.authorization?.ap2;
+ const authorizationProviders = ap2?.enabled
+ ? [createAp2AuthorizationProvider({ config: ap2, logger: NOOP_LOGGER, store })]
+ : [];
+ const { mcp, a2a, acp } = config.protocols;
+ if (!acp.enabled) throw new Error('the golden config enables ACP');
+ const gateway = await createGateway({
+ config: { ...config, server: { ...config.server, port: 0 } },
+ store,
+ paymentProviders,
+ authorizationProviders,
+ protocolAdapters: [
+ createMcpAdapter({ mountPath: mcp.mountPath }),
+ createA2aAdapter({ mountPath: a2a.mountPath, agentName: config.merchant.name, store }),
+ createAcpAdapter({
+ mountPath: acp.mountPath,
+ token: acp.auth.token,
+ operations: acp.checkout.operations,
+ idempotency: acp.idempotency,
+ store,
+ }),
+ ],
+ logger: NOOP_LOGGER,
+ });
+ const { url } = await gateway.listen();
+ return {
+ url,
+ config,
+ async close() {
+ await gateway.close();
+ for (const provider of authorizationProviders) provider.close();
+ await store.close();
+ },
+ };
+}
+
+// Require the captured bytes to match compact or two-space-indented JSON.
+// Normalize loopback URLs, the package version and ISO timestamps for stable snapshots.
+function golden(raw: string, gatewayUrl: string): string {
+ const parsed: unknown = JSON.parse(raw);
+ const pretty = JSON.stringify(parsed, null, 2);
+ expect([JSON.stringify(parsed), pretty]).toContain(raw);
+ return `${pretty}\n`
+ .replaceAll(upstreamUrl, 'http://upstream.invalid')
+ .replaceAll(gatewayUrl, 'http://gateway.invalid')
+ .replaceAll(PACKAGE_VERSION, '')
+ .replaceAll(/"\d{4}-\d\d-\d\dT\d\d:\d\d:\d\d\.\d{3}Z"/g, '""');
+}
+
+// Snapshot discovery and require a healthy `doctor --json` report from the gateway
+async function expectDiscoveryGoldens(running: Running, suffix: string): Promise {
+ const res = await fetch(`${running.url}/.well-known/agent-commerce`);
+ expect(res.status).toBe(200);
+ await expect(golden(await res.text(), running.url)).toMatchFileSnapshot(
+ `${GOLDEN}/well-known-${suffix}.json`,
+ );
+
+ const report = await runDoctor(
+ { gatewayUrl: running.url },
+ {
+ loadConfig: async () => running.config,
+ fillEnvFromManifest: (env) => ({ env, filled: [], manifestFound: false }),
+ hasChainDeployScript: () => false,
+ },
+ );
+ expect(report.exitCode).toBe(0);
+ expect(report.score.passed).toBe(report.score.total);
+ const io = createCapturingIo();
+ printDoctorReport(report, io, true);
+ await expect(golden(io.out.join('\n'), running.url)).toMatchFileSnapshot(
+ `${GOLDEN}/doctor-${suffix}.json`,
+ );
+}
+
+async function challengeHeader(url: string): Promise {
+ const res = await fetch(`${url}/api/resources/market_report/invoke`, {
+ method: 'POST',
+ headers: { 'content-type': 'application/json' },
+ body: JSON.stringify({ symbol: 'ETH' }),
+ });
+ expect(res.status).toBe(402);
+ const header = res.headers.get(PAYMENT_REQUIRED_HEADER);
+ if (header === null) throw new Error('no PAYMENT-REQUIRED header');
+ return Buffer.from(header, 'base64').toString('utf8');
+}
+
+beforeAll(startUpstream);
+afterAll(() => new Promise((resolve) => upstream.close(() => resolve())));
+
+describe('2.7.2 goldens: single x402 offer, every protocol, MPP and AP2', () => {
+ let running: Running;
+
+ beforeAll(async () => {
+ running = await startGateway(await goldenConfig(singleOffer()));
+ });
+ afterAll(() => running?.close());
+
+ it('the challenge in PAYMENT-REQUIRED, and the same document on MCP and A2A', async () => {
+ const raw = await challengeHeader(running.url);
+ await expect(golden(raw, running.url)).toMatchFileSnapshot(
+ `${GOLDEN}/x402-challenge-single.json`,
+ );
+ const envelope = JSON.parse(raw) as Record;
+
+ const client = new Client({ name: 'golden-client', version: '0.0.0-test' });
+ await client.connect(
+ new StreamableHTTPClientTransport(new URL(`${running.url}/mcp`)) as Transport,
+ );
+ const mcp = (await client.callTool({
+ name: 'market_report',
+ arguments: { symbol: 'ETH' },
+ })) as { isError?: boolean; structuredContent?: Record };
+ await client.close();
+ expect(mcp.isError).toBe(true);
+ for (const key of Object.keys(envelope)) {
+ expect(mcp.structuredContent?.[key]).toEqual(envelope[key]);
+ }
+
+ const a2a = await fetch(`${running.url}/a2a`, {
+ method: 'POST',
+ headers: {
+ 'content-type': 'application/json',
+ 'a2a-version': '1.0',
+ 'a2a-extensions': A2A_X402_EXTENSION_URI,
+ },
+ body: JSON.stringify({
+ jsonrpc: '2.0',
+ id: 'golden',
+ method: 'SendMessage',
+ params: {
+ message: {
+ role: 'ROLE_USER',
+ messageId: 'msg-golden',
+ parts: [
+ {
+ data: { resource: 'market_report', input: { symbol: 'ETH' } },
+ mediaType: 'application/json',
+ },
+ ],
+ },
+ },
+ }),
+ });
+ const { task } = (
+ (await a2a.json()) as {
+ result: { task: { status: { message: { metadata: Record } } } };
+ }
+ ).result;
+ expect(task.status.message.metadata['x402.payment.required']).toEqual(envelope);
+ });
+
+ it('the verify and settle bodies a remote facilitator receives', async () => {
+ const envelope = JSON.parse(await challengeHeader(running.url)) as {
+ resource: unknown;
+ accepts: Record[];
+ };
+ const offer = envelope.accepts[0];
+ if (offer === undefined) throw new Error('no offer');
+ // Include the buyer's resource echo and extension to check that the gateway
+ // strips both before forwarding the payment payload to the facilitator
+ const signed = await createPaymentProof({
+ buyerPrivateKey: BUYER_KEY,
+ accepts: offer,
+ extensions: { bazaar: { info: { input: { type: 'http', method: 'GET' } } } },
+ overrides: { nonce: NONCE, validBefore: VALID_BEFORE },
+ });
+ const proof = Buffer.from(
+ JSON.stringify({
+ resource: envelope.resource,
+ ...JSON.parse(Buffer.from(signed, 'base64').toString('utf8')),
+ }),
+ ).toString('base64');
+ facilitatorBodies['verify'] = [];
+ facilitatorBodies['settle'] = [];
+
+ const paid = await fetch(`${running.url}/api/resources/market_report/invoke`, {
+ method: 'POST',
+ headers: { 'content-type': 'application/json', [PAYMENT_HEADER]: proof },
+ body: JSON.stringify({ symbol: 'ETH' }),
+ });
+ expect(paid.status).toBe(200);
+
+ const [verify] = facilitatorBodies['verify'] ?? [];
+ const [settle] = facilitatorBodies['settle'] ?? [];
+ expect(facilitatorBodies['verify']).toHaveLength(1);
+ expect(facilitatorBodies['settle']).toHaveLength(1);
+ await expect(golden(verify as string, running.url)).toMatchFileSnapshot(
+ `${GOLDEN}/facilitator-verify.json`,
+ );
+ await expect(golden(settle as string, running.url)).toMatchFileSnapshot(
+ `${GOLDEN}/facilitator-settle.json`,
+ );
+ });
+
+ it('the well-known document and a healthy doctor --json report', () =>
+ expectDiscoveryGoldens(running, 'single'));
+});
+
+describe('2.7.2 goldens: two x402 offers', () => {
+ let running: Running;
+
+ beforeAll(async () => {
+ running = await startGateway(await goldenConfig(multiOffer()));
+ });
+ afterAll(() => running?.close());
+
+ it('the challenge in PAYMENT-REQUIRED', async () => {
+ const raw = await challengeHeader(running.url);
+ await expect(golden(raw, running.url)).toMatchFileSnapshot(
+ `${GOLDEN}/x402-challenge-multi.json`,
+ );
+ });
+
+ it('the well-known document and a healthy doctor --json report', () =>
+ expectDiscoveryGoldens(running, 'multi'));
+});
diff --git a/tests/integration/goldens/2.7.2/doctor-multi.json b/tests/integration/goldens/2.7.2/doctor-multi.json
new file mode 100644
index 0000000..564c6e7
--- /dev/null
+++ b/tests/integration/goldens/2.7.2/doctor-multi.json
@@ -0,0 +1,119 @@
+{
+ "checks": [
+ {
+ "name": "Config",
+ "status": "PASS",
+ "detail": "valid: 8 resource(s), merchant \"Golden Store\""
+ },
+ {
+ "name": "Gateway",
+ "status": "PASS",
+ "detail": "healthy and ready at http://gateway.invalid"
+ },
+ {
+ "name": "Backend",
+ "status": "PASS",
+ "detail": "7/7 backend host(s) reachable"
+ },
+ {
+ "name": "Protocols",
+ "status": "PASS",
+ "detail": "http=on mcp=on (/mcp) a2a=on (/a2a) acp=on (/acp)"
+ },
+ {
+ "name": "A2A",
+ "status": "PASS",
+ "detail": "experimental · spec 1.0.1 · protocol 1.0 · binding JSONRPC · mount /a2a · card /.well-known/agent-card.json"
+ },
+ {
+ "name": "A2A unsupported",
+ "status": "INFO",
+ "detail": "SendStreamingMessage, GetTask, ListTasks, CancelTask, SubscribeToTask, CreateTaskPushNotificationConfig, GetTaskPushNotificationConfig, ListTaskPushNotificationConfigs, DeleteTaskPushNotificationConfig, GetExtendedAgentCard, HTTP+JSON/REST binding, gRPC binding, SSE, long-running task persistence, task resumption other than an x402 extension payment, push notifications, multi-turn conversational continuation, authenticated extended agent cards, A2A authentication schemes, artifact types beyond Agent Commerce outcome data, x402 extension payments across gateway instances"
+ },
+ {
+ "name": "ACP",
+ "status": "PASS",
+ "detail": "experimental · spec 2026-04-17 · API-Version 2026-04-17 · service checkout · mount /acp · discovery /.well-known/acp.json"
+ },
+ {
+ "name": "ACP auth",
+ "status": "PASS",
+ "detail": "bearer token configured (16 characters, not shown)"
+ },
+ {
+ "name": "ACP idempotency",
+ "status": "PASS",
+ "detail": "claims in the receipt database (retention 24h)"
+ },
+ {
+ "name": "ACP checkout mapping",
+ "status": "PASS",
+ "detail": "5 operations mapped to free acp-exposed resources (acp_create, acp_update, acp_get, acp_complete, acp_cancel)"
+ },
+ {
+ "name": "ACP unsupported",
+ "status": "INFO",
+ "detail": "carts service, feed service, standalone orders service, delegate_payment, delegate_authentication, ACP MCP transport binding, webhooks, outbound merchant-to-agent delivery, ACP client role, Signature header verification, Timestamp replay-window verification, discount extension, general ACP extension framework, multiple ACP API versions, seller-backed payment handler integration"
+ },
+ {
+ "name": "AP2",
+ "status": "PASS",
+ "detail": "experimental · spec 0.2.0 · mode direct · mandate.checkout.1 · profile agent-commerce/ap2/checkout/v1 · clock skew 60s · mandate aud optional · mandate exp optional"
+ },
+ {
+ "name": "AP2 trust",
+ "status": "PASS",
+ "detail": "mandate issuers: https://trusted-surface.example (1 key) · checkout issuers: https://merchant.example (1 key)"
+ },
+ {
+ "name": "AP2 replay store",
+ "status": "PASS",
+ "detail": "mandate holds in the receipt database"
+ },
+ {
+ "name": "AP2 resources",
+ "status": "PASS",
+ "detail": "ap2_report"
+ },
+ {
+ "name": "AP2 unsupported",
+ "status": "INFO",
+ "detail": "autonomous mode, open checkout mandates (mandate.checkout.open.1), payment mandates (mandate.payment.1), spending constraint evaluation, cnf-bound agent keys, user credential delegation (OpenID4VP), delegation chains and key-binding JWTs, JWKS and any key discovery by URL (jku, x5u), issuer metadata fetching, key rotation without a config change, signature algorithms other than ES256, digest algorithms other than sha-256, mandate issuance, checkout receipts, AP2 over the ACP checkout adapter"
+ },
+ {
+ "name": "Payments",
+ "status": "PASS",
+ "detail": "x402 v2 (scheme=exact) enabled - TESTNET, 2 options: Base Sepolia (eip155:84532) to 0x1111…1111; Arbitrum Sepolia (eip155:421614) to 0x1111…1111, facilitator=remote (auth=none), paymentFlow=authorization"
+ },
+ {
+ "name": "Payments (offers)",
+ "status": "PASS",
+ "detail": "2 offer(s) pass their health checks"
+ },
+ {
+ "name": "Payments (MPP)",
+ "status": "PASS",
+ "detail": "MPP charge/evm/authorization enabled - TESTNET on Base Sepolia (eip155:84532), asset=USDC 0x036C…CF7e, recipient=0x1111…1111, facilitator=remote (auth=none), paymentFlow=upfront, spec draft-httpauth-payment-01@806fdb8, mppx 0.13.1"
+ },
+ {
+ "name": "Storage",
+ "status": "PASS",
+ "detail": "sqlite schema v5 writable; receipts=0"
+ },
+ {
+ "name": "Transactions",
+ "status": "PASS",
+ "detail": "none unresolved"
+ },
+ {
+ "name": "Protocol versions",
+ "status": "PASS",
+ "detail": "reported by gateway /.well-known/agent-commerce"
+ }
+ ],
+ "score": {
+ "passed": 19,
+ "total": 19
+ },
+ "exitCode": 0
+}
diff --git a/tests/integration/goldens/2.7.2/doctor-single.json b/tests/integration/goldens/2.7.2/doctor-single.json
new file mode 100644
index 0000000..2901a3d
--- /dev/null
+++ b/tests/integration/goldens/2.7.2/doctor-single.json
@@ -0,0 +1,114 @@
+{
+ "checks": [
+ {
+ "name": "Config",
+ "status": "PASS",
+ "detail": "valid: 8 resource(s), merchant \"Golden Store\""
+ },
+ {
+ "name": "Gateway",
+ "status": "PASS",
+ "detail": "healthy and ready at http://gateway.invalid"
+ },
+ {
+ "name": "Backend",
+ "status": "PASS",
+ "detail": "7/7 backend host(s) reachable"
+ },
+ {
+ "name": "Protocols",
+ "status": "PASS",
+ "detail": "http=on mcp=on (/mcp) a2a=on (/a2a) acp=on (/acp)"
+ },
+ {
+ "name": "A2A",
+ "status": "PASS",
+ "detail": "experimental · spec 1.0.1 · protocol 1.0 · binding JSONRPC · mount /a2a · card /.well-known/agent-card.json"
+ },
+ {
+ "name": "A2A unsupported",
+ "status": "INFO",
+ "detail": "SendStreamingMessage, GetTask, ListTasks, CancelTask, SubscribeToTask, CreateTaskPushNotificationConfig, GetTaskPushNotificationConfig, ListTaskPushNotificationConfigs, DeleteTaskPushNotificationConfig, GetExtendedAgentCard, HTTP+JSON/REST binding, gRPC binding, SSE, long-running task persistence, task resumption other than an x402 extension payment, push notifications, multi-turn conversational continuation, authenticated extended agent cards, A2A authentication schemes, artifact types beyond Agent Commerce outcome data, x402 extension payments across gateway instances"
+ },
+ {
+ "name": "ACP",
+ "status": "PASS",
+ "detail": "experimental · spec 2026-04-17 · API-Version 2026-04-17 · service checkout · mount /acp · discovery /.well-known/acp.json"
+ },
+ {
+ "name": "ACP auth",
+ "status": "PASS",
+ "detail": "bearer token configured (16 characters, not shown)"
+ },
+ {
+ "name": "ACP idempotency",
+ "status": "PASS",
+ "detail": "claims in the receipt database (retention 24h)"
+ },
+ {
+ "name": "ACP checkout mapping",
+ "status": "PASS",
+ "detail": "5 operations mapped to free acp-exposed resources (acp_create, acp_update, acp_get, acp_complete, acp_cancel)"
+ },
+ {
+ "name": "ACP unsupported",
+ "status": "INFO",
+ "detail": "carts service, feed service, standalone orders service, delegate_payment, delegate_authentication, ACP MCP transport binding, webhooks, outbound merchant-to-agent delivery, ACP client role, Signature header verification, Timestamp replay-window verification, discount extension, general ACP extension framework, multiple ACP API versions, seller-backed payment handler integration"
+ },
+ {
+ "name": "AP2",
+ "status": "PASS",
+ "detail": "experimental · spec 0.2.0 · mode direct · mandate.checkout.1 · profile agent-commerce/ap2/checkout/v1 · clock skew 60s · mandate aud optional · mandate exp optional"
+ },
+ {
+ "name": "AP2 trust",
+ "status": "PASS",
+ "detail": "mandate issuers: https://trusted-surface.example (1 key) · checkout issuers: https://merchant.example (1 key)"
+ },
+ {
+ "name": "AP2 replay store",
+ "status": "PASS",
+ "detail": "mandate holds in the receipt database"
+ },
+ {
+ "name": "AP2 resources",
+ "status": "PASS",
+ "detail": "ap2_report"
+ },
+ {
+ "name": "AP2 unsupported",
+ "status": "INFO",
+ "detail": "autonomous mode, open checkout mandates (mandate.checkout.open.1), payment mandates (mandate.payment.1), spending constraint evaluation, cnf-bound agent keys, user credential delegation (OpenID4VP), delegation chains and key-binding JWTs, JWKS and any key discovery by URL (jku, x5u), issuer metadata fetching, key rotation without a config change, signature algorithms other than ES256, digest algorithms other than sha-256, mandate issuance, checkout receipts, AP2 over the ACP checkout adapter"
+ },
+ {
+ "name": "Payments",
+ "status": "PASS",
+ "detail": "x402 v2 (scheme=exact) enabled - TESTNET on Base Sepolia (eip155:84532), destination=0x1111…1111, facilitator=remote (auth=none), paymentFlow=authorization"
+ },
+ {
+ "name": "Payments (MPP)",
+ "status": "PASS",
+ "detail": "MPP charge/evm/authorization enabled - TESTNET on Base Sepolia (eip155:84532), asset=USDC 0x036C…CF7e, recipient=0x1111…1111, facilitator=remote (auth=none), paymentFlow=upfront, spec draft-httpauth-payment-01@806fdb8, mppx 0.13.1"
+ },
+ {
+ "name": "Storage",
+ "status": "PASS",
+ "detail": "sqlite schema v5 writable; receipts=0"
+ },
+ {
+ "name": "Transactions",
+ "status": "PASS",
+ "detail": "none unresolved"
+ },
+ {
+ "name": "Protocol versions",
+ "status": "PASS",
+ "detail": "reported by gateway /.well-known/agent-commerce"
+ }
+ ],
+ "score": {
+ "passed": 18,
+ "total": 18
+ },
+ "exitCode": 0
+}
diff --git a/tests/integration/goldens/2.7.2/facilitator-settle.json b/tests/integration/goldens/2.7.2/facilitator-settle.json
new file mode 100644
index 0000000..110c5af
--- /dev/null
+++ b/tests/integration/goldens/2.7.2/facilitator-settle.json
@@ -0,0 +1,43 @@
+{
+ "x402Version": 2,
+ "paymentPayload": {
+ "x402Version": 2,
+ "accepted": {
+ "scheme": "exact",
+ "network": "eip155:84532",
+ "amount": "10000",
+ "asset": "0x036CbD53842c5426634e7929541eC2318f3dCF7e",
+ "payTo": "0x1111111111111111111111111111111111111111",
+ "maxTimeoutSeconds": 120,
+ "extra": {
+ "name": "USDC",
+ "version": "2",
+ "assetTransferMethod": "eip3009"
+ }
+ },
+ "payload": {
+ "signature": "0x9e9124b0cb5f5b7037329a7cad609711ab9658f109b68d5854fb3486884ee5ad6eb4e4551632800337f21ef4d29752fe5016eda7d3376438a1c27b4da5a261091c",
+ "authorization": {
+ "from": "0x3C44CdDdB6a900fa2b585dd299e03d12FA4293BC",
+ "to": "0x1111111111111111111111111111111111111111",
+ "value": "10000",
+ "validAfter": "0",
+ "validBefore": "4102444800",
+ "nonce": "0x4242424242424242424242424242424242424242424242424242424242424242"
+ }
+ }
+ },
+ "paymentRequirements": {
+ "scheme": "exact",
+ "network": "eip155:84532",
+ "asset": "0x036CbD53842c5426634e7929541eC2318f3dCF7e",
+ "amount": "10000",
+ "payTo": "0x1111111111111111111111111111111111111111",
+ "maxTimeoutSeconds": 120,
+ "extra": {
+ "name": "USDC",
+ "version": "2",
+ "assetTransferMethod": "eip3009"
+ }
+ }
+}
diff --git a/tests/integration/goldens/2.7.2/facilitator-verify.json b/tests/integration/goldens/2.7.2/facilitator-verify.json
new file mode 100644
index 0000000..110c5af
--- /dev/null
+++ b/tests/integration/goldens/2.7.2/facilitator-verify.json
@@ -0,0 +1,43 @@
+{
+ "x402Version": 2,
+ "paymentPayload": {
+ "x402Version": 2,
+ "accepted": {
+ "scheme": "exact",
+ "network": "eip155:84532",
+ "amount": "10000",
+ "asset": "0x036CbD53842c5426634e7929541eC2318f3dCF7e",
+ "payTo": "0x1111111111111111111111111111111111111111",
+ "maxTimeoutSeconds": 120,
+ "extra": {
+ "name": "USDC",
+ "version": "2",
+ "assetTransferMethod": "eip3009"
+ }
+ },
+ "payload": {
+ "signature": "0x9e9124b0cb5f5b7037329a7cad609711ab9658f109b68d5854fb3486884ee5ad6eb4e4551632800337f21ef4d29752fe5016eda7d3376438a1c27b4da5a261091c",
+ "authorization": {
+ "from": "0x3C44CdDdB6a900fa2b585dd299e03d12FA4293BC",
+ "to": "0x1111111111111111111111111111111111111111",
+ "value": "10000",
+ "validAfter": "0",
+ "validBefore": "4102444800",
+ "nonce": "0x4242424242424242424242424242424242424242424242424242424242424242"
+ }
+ }
+ },
+ "paymentRequirements": {
+ "scheme": "exact",
+ "network": "eip155:84532",
+ "asset": "0x036CbD53842c5426634e7929541eC2318f3dCF7e",
+ "amount": "10000",
+ "payTo": "0x1111111111111111111111111111111111111111",
+ "maxTimeoutSeconds": 120,
+ "extra": {
+ "name": "USDC",
+ "version": "2",
+ "assetTransferMethod": "eip3009"
+ }
+ }
+}
diff --git a/tests/integration/goldens/2.7.2/well-known-multi.json b/tests/integration/goldens/2.7.2/well-known-multi.json
new file mode 100644
index 0000000..9a3415e
--- /dev/null
+++ b/tests/integration/goldens/2.7.2/well-known-multi.json
@@ -0,0 +1,310 @@
+{
+ "gateway": {
+ "implementationVersion": "",
+ "supportedSpec": "agent-commerce/v1.0.0"
+ },
+ "merchant": {
+ "id": "golden-store",
+ "name": "Golden Store",
+ "publicBaseUrl": "https://gateway.example"
+ },
+ "protocols": {
+ "http": {
+ "enabled": true
+ },
+ "mcp": {
+ "enabled": true,
+ "mountPath": "/mcp"
+ },
+ "a2a": {
+ "enabled": true,
+ "mountPath": "/a2a"
+ },
+ "acp": {
+ "enabled": true,
+ "mountPath": "/acp"
+ }
+ },
+ "adapters": [
+ {
+ "name": "mcp",
+ "kind": "protocol",
+ "implementationVersion": "",
+ "supportedSpec": "2026-07-28, 2025-11-25",
+ "capabilities": [
+ "tools/list",
+ "tools/call"
+ ],
+ "status": "stable",
+ "unsupported": [
+ "resources",
+ "prompts",
+ "sampling",
+ "completions",
+ "elicitation",
+ "roots",
+ "logging",
+ "notifications/tools/list_changed",
+ "tasks",
+ "dns-rebinding-protection",
+ "authorization",
+ "sessions",
+ "subscriptions",
+ "pagination",
+ "HTTP+SSE transport",
+ "MPP payment-required as JSON-RPC error -32042",
+ "MPP verification failure as JSON-RPC error -32043"
+ ],
+ "health": {
+ "status": "pass",
+ "checkedAt": ""
+ }
+ },
+ {
+ "name": "a2a",
+ "kind": "protocol",
+ "implementationVersion": "",
+ "supportedSpec": "1.0.1",
+ "capabilities": [
+ "agent-card",
+ "jsonrpc",
+ "SendMessage",
+ "x402-extension"
+ ],
+ "status": "experimental",
+ "unsupported": [
+ "SendStreamingMessage",
+ "GetTask",
+ "ListTasks",
+ "CancelTask",
+ "SubscribeToTask",
+ "CreateTaskPushNotificationConfig",
+ "GetTaskPushNotificationConfig",
+ "ListTaskPushNotificationConfigs",
+ "DeleteTaskPushNotificationConfig",
+ "GetExtendedAgentCard",
+ "HTTP+JSON/REST binding",
+ "gRPC binding",
+ "SSE",
+ "long-running task persistence",
+ "task resumption other than an x402 extension payment",
+ "push notifications",
+ "multi-turn conversational continuation",
+ "authenticated extended agent cards",
+ "A2A authentication schemes",
+ "artifact types beyond Agent Commerce outcome data",
+ "x402 extension payments across gateway instances"
+ ],
+ "health": {
+ "status": "pass",
+ "checkedAt": ""
+ }
+ },
+ {
+ "name": "acp",
+ "kind": "protocol",
+ "implementationVersion": "",
+ "supportedSpec": "2026-04-17",
+ "capabilities": [
+ "rest transport",
+ "well-known discovery",
+ "bearer authentication",
+ "API-Version enforcement",
+ "request header forwarding to the merchant",
+ "checkout service",
+ "createCheckoutSession",
+ "updateCheckoutSession",
+ "getCheckoutSession",
+ "completeCheckoutSession",
+ "cancelCheckoutSession"
+ ],
+ "status": "experimental",
+ "unsupported": [
+ "carts service",
+ "feed service",
+ "standalone orders service",
+ "delegate_payment",
+ "delegate_authentication",
+ "ACP MCP transport binding",
+ "webhooks",
+ "outbound merchant-to-agent delivery",
+ "ACP client role",
+ "Signature header verification",
+ "Timestamp replay-window verification",
+ "discount extension",
+ "general ACP extension framework",
+ "multiple ACP API versions",
+ "seller-backed payment handler integration"
+ ],
+ "health": {
+ "status": "pass",
+ "checkedAt": ""
+ }
+ }
+ ],
+ "paymentProviders": [
+ {
+ "name": "x402",
+ "kind": "payment",
+ "implementationVersion": "",
+ "supportedSpec": "x402/v2 scheme=exact family=eip155",
+ "capabilities": [
+ "exact-evm",
+ "remote-facilitator",
+ "eip-3009",
+ "permit2",
+ "caip-2",
+ "mode=testnet",
+ "authorization-flow",
+ "upfront-flow",
+ "multiple-offers"
+ ],
+ "status": "stable",
+ "unsupported": [
+ "permit2 gas sponsoring extensions",
+ "upto scheme",
+ "batch-settlement scheme",
+ "auth-capture scheme"
+ ]
+ },
+ {
+ "name": "mpp",
+ "kind": "payment",
+ "implementationVersion": "",
+ "supportedSpec": "mpp/draft-httpauth-payment-01 intent=charge method=evm",
+ "capabilities": [
+ "intent=charge",
+ "method=evm",
+ "credential=authorization",
+ "eip-3009",
+ "network=eip155:31337",
+ "network=eip155:84532",
+ "network=eip155:8453",
+ "asset=USDC",
+ "verify-before-settle",
+ "authorization-flow",
+ "upfront-flow",
+ "payment-receipt",
+ "challenge-digest-binding"
+ ],
+ "status": "experimental",
+ "unsupported": [
+ "methods other than evm",
+ "credential=permit2",
+ "credential=transaction",
+ "credential=hash",
+ "splits",
+ "intent=subscription",
+ "evm sessions",
+ "discovery extension"
+ ]
+ }
+ ],
+ "authorizationProviders": [
+ {
+ "name": "ap2",
+ "kind": "authorization",
+ "implementationVersion": "",
+ "supportedSpec": "ap2/v0.2.0 mode=direct",
+ "capabilities": [
+ "direct-mode",
+ "trusted-agent-provider",
+ "mandate.checkout.1",
+ "sd-jwt-presentation",
+ "ES256",
+ "sha-256",
+ "static-inline-trust",
+ "merchant-checkout-jwt-binding",
+ "agent-commerce/ap2/checkout/v1",
+ "purchase-binding",
+ "replay-defence"
+ ],
+ "status": "experimental",
+ "unsupported": [
+ "autonomous mode",
+ "open checkout mandates (mandate.checkout.open.1)",
+ "payment mandates (mandate.payment.1)",
+ "spending constraint evaluation",
+ "cnf-bound agent keys",
+ "user credential delegation (OpenID4VP)",
+ "delegation chains and key-binding JWTs",
+ "JWKS and any key discovery by URL (jku, x5u)",
+ "issuer metadata fetching",
+ "key rotation without a config change",
+ "signature algorithms other than ES256",
+ "digest algorithms other than sha-256",
+ "mandate issuance",
+ "checkout receipts",
+ "AP2 over the ACP checkout adapter"
+ ]
+ }
+ ],
+ "store": {
+ "name": "sqlite-receipt-store",
+ "kind": "storage",
+ "implementationVersion": "",
+ "supportedSpec": "sqlite-schema-v5",
+ "capabilities": [
+ "receipts",
+ "events",
+ "payment-attempts",
+ "transactions",
+ "idempotency-keys",
+ "authorization-holds",
+ "pending-tasks"
+ ],
+ "status": "stable"
+ },
+ "payments": {
+ "x402": {
+ "enabled": true,
+ "network": "eip155:84532",
+ "asset": "0x036CbD53842c5426634e7929541eC2318f3dCF7e",
+ "assetName": "USDC",
+ "assetVersion": "2",
+ "assetDecimals": 6,
+ "payTo": "0x1111111111111111111111111111111111111111",
+ "maxTimeoutSeconds": 120,
+ "facilitator": {
+ "mode": "remote"
+ },
+ "mode": "testnet",
+ "paymentFlow": "authorization",
+ "options": [
+ {
+ "network": "eip155:84532",
+ "asset": "0x036CbD53842c5426634e7929541eC2318f3dCF7e",
+ "assetName": "USDC",
+ "assetVersion": "2",
+ "assetDecimals": 6,
+ "payTo": "0x1111111111111111111111111111111111111111",
+ "status": "pass"
+ },
+ {
+ "network": "eip155:421614",
+ "asset": "0x75faf114eafb1BDbe2F0316DF893fd58CE46AA4d",
+ "assetName": "USD Coin",
+ "assetVersion": "2",
+ "assetDecimals": 6,
+ "payTo": "0x1111111111111111111111111111111111111111",
+ "assetTransferMethod": "permit2",
+ "status": "pass"
+ }
+ ]
+ },
+ "mpp": {
+ "enabled": true,
+ "network": "eip155:84532",
+ "asset": "0x036CbD53842c5426634e7929541eC2318f3dCF7e",
+ "assetName": "USDC",
+ "assetVersion": "2",
+ "assetDecimals": 6,
+ "recipient": "0x1111111111111111111111111111111111111111",
+ "facilitator": {
+ "mode": "remote"
+ },
+ "mode": "testnet",
+ "paymentFlow": "upfront"
+ }
+ }
+}
diff --git a/tests/integration/goldens/2.7.2/well-known-single.json b/tests/integration/goldens/2.7.2/well-known-single.json
new file mode 100644
index 0000000..e64b53f
--- /dev/null
+++ b/tests/integration/goldens/2.7.2/well-known-single.json
@@ -0,0 +1,287 @@
+{
+ "gateway": {
+ "implementationVersion": "",
+ "supportedSpec": "agent-commerce/v1.0.0"
+ },
+ "merchant": {
+ "id": "golden-store",
+ "name": "Golden Store",
+ "publicBaseUrl": "https://gateway.example"
+ },
+ "protocols": {
+ "http": {
+ "enabled": true
+ },
+ "mcp": {
+ "enabled": true,
+ "mountPath": "/mcp"
+ },
+ "a2a": {
+ "enabled": true,
+ "mountPath": "/a2a"
+ },
+ "acp": {
+ "enabled": true,
+ "mountPath": "/acp"
+ }
+ },
+ "adapters": [
+ {
+ "name": "mcp",
+ "kind": "protocol",
+ "implementationVersion": "",
+ "supportedSpec": "2026-07-28, 2025-11-25",
+ "capabilities": [
+ "tools/list",
+ "tools/call"
+ ],
+ "status": "stable",
+ "unsupported": [
+ "resources",
+ "prompts",
+ "sampling",
+ "completions",
+ "elicitation",
+ "roots",
+ "logging",
+ "notifications/tools/list_changed",
+ "tasks",
+ "dns-rebinding-protection",
+ "authorization",
+ "sessions",
+ "subscriptions",
+ "pagination",
+ "HTTP+SSE transport",
+ "MPP payment-required as JSON-RPC error -32042",
+ "MPP verification failure as JSON-RPC error -32043"
+ ],
+ "health": {
+ "status": "pass",
+ "checkedAt": ""
+ }
+ },
+ {
+ "name": "a2a",
+ "kind": "protocol",
+ "implementationVersion": "",
+ "supportedSpec": "1.0.1",
+ "capabilities": [
+ "agent-card",
+ "jsonrpc",
+ "SendMessage",
+ "x402-extension"
+ ],
+ "status": "experimental",
+ "unsupported": [
+ "SendStreamingMessage",
+ "GetTask",
+ "ListTasks",
+ "CancelTask",
+ "SubscribeToTask",
+ "CreateTaskPushNotificationConfig",
+ "GetTaskPushNotificationConfig",
+ "ListTaskPushNotificationConfigs",
+ "DeleteTaskPushNotificationConfig",
+ "GetExtendedAgentCard",
+ "HTTP+JSON/REST binding",
+ "gRPC binding",
+ "SSE",
+ "long-running task persistence",
+ "task resumption other than an x402 extension payment",
+ "push notifications",
+ "multi-turn conversational continuation",
+ "authenticated extended agent cards",
+ "A2A authentication schemes",
+ "artifact types beyond Agent Commerce outcome data",
+ "x402 extension payments across gateway instances"
+ ],
+ "health": {
+ "status": "pass",
+ "checkedAt": ""
+ }
+ },
+ {
+ "name": "acp",
+ "kind": "protocol",
+ "implementationVersion": "",
+ "supportedSpec": "2026-04-17",
+ "capabilities": [
+ "rest transport",
+ "well-known discovery",
+ "bearer authentication",
+ "API-Version enforcement",
+ "request header forwarding to the merchant",
+ "checkout service",
+ "createCheckoutSession",
+ "updateCheckoutSession",
+ "getCheckoutSession",
+ "completeCheckoutSession",
+ "cancelCheckoutSession"
+ ],
+ "status": "experimental",
+ "unsupported": [
+ "carts service",
+ "feed service",
+ "standalone orders service",
+ "delegate_payment",
+ "delegate_authentication",
+ "ACP MCP transport binding",
+ "webhooks",
+ "outbound merchant-to-agent delivery",
+ "ACP client role",
+ "Signature header verification",
+ "Timestamp replay-window verification",
+ "discount extension",
+ "general ACP extension framework",
+ "multiple ACP API versions",
+ "seller-backed payment handler integration"
+ ],
+ "health": {
+ "status": "pass",
+ "checkedAt": ""
+ }
+ }
+ ],
+ "paymentProviders": [
+ {
+ "name": "x402",
+ "kind": "payment",
+ "implementationVersion": "",
+ "supportedSpec": "x402/v2 scheme=exact family=eip155",
+ "capabilities": [
+ "exact-evm",
+ "remote-facilitator",
+ "eip-3009",
+ "caip-2",
+ "mode=testnet",
+ "authorization-flow",
+ "upfront-flow"
+ ],
+ "status": "stable",
+ "unsupported": [
+ "permit2 gas sponsoring extensions",
+ "upto scheme",
+ "batch-settlement scheme",
+ "auth-capture scheme"
+ ]
+ },
+ {
+ "name": "mpp",
+ "kind": "payment",
+ "implementationVersion": "",
+ "supportedSpec": "mpp/draft-httpauth-payment-01 intent=charge method=evm",
+ "capabilities": [
+ "intent=charge",
+ "method=evm",
+ "credential=authorization",
+ "eip-3009",
+ "network=eip155:31337",
+ "network=eip155:84532",
+ "network=eip155:8453",
+ "asset=USDC",
+ "verify-before-settle",
+ "authorization-flow",
+ "upfront-flow",
+ "payment-receipt",
+ "challenge-digest-binding"
+ ],
+ "status": "experimental",
+ "unsupported": [
+ "methods other than evm",
+ "credential=permit2",
+ "credential=transaction",
+ "credential=hash",
+ "splits",
+ "intent=subscription",
+ "evm sessions",
+ "discovery extension"
+ ]
+ }
+ ],
+ "authorizationProviders": [
+ {
+ "name": "ap2",
+ "kind": "authorization",
+ "implementationVersion": "",
+ "supportedSpec": "ap2/v0.2.0 mode=direct",
+ "capabilities": [
+ "direct-mode",
+ "trusted-agent-provider",
+ "mandate.checkout.1",
+ "sd-jwt-presentation",
+ "ES256",
+ "sha-256",
+ "static-inline-trust",
+ "merchant-checkout-jwt-binding",
+ "agent-commerce/ap2/checkout/v1",
+ "purchase-binding",
+ "replay-defence"
+ ],
+ "status": "experimental",
+ "unsupported": [
+ "autonomous mode",
+ "open checkout mandates (mandate.checkout.open.1)",
+ "payment mandates (mandate.payment.1)",
+ "spending constraint evaluation",
+ "cnf-bound agent keys",
+ "user credential delegation (OpenID4VP)",
+ "delegation chains and key-binding JWTs",
+ "JWKS and any key discovery by URL (jku, x5u)",
+ "issuer metadata fetching",
+ "key rotation without a config change",
+ "signature algorithms other than ES256",
+ "digest algorithms other than sha-256",
+ "mandate issuance",
+ "checkout receipts",
+ "AP2 over the ACP checkout adapter"
+ ]
+ }
+ ],
+ "store": {
+ "name": "sqlite-receipt-store",
+ "kind": "storage",
+ "implementationVersion": "",
+ "supportedSpec": "sqlite-schema-v5",
+ "capabilities": [
+ "receipts",
+ "events",
+ "payment-attempts",
+ "transactions",
+ "idempotency-keys",
+ "authorization-holds",
+ "pending-tasks"
+ ],
+ "status": "stable"
+ },
+ "payments": {
+ "x402": {
+ "enabled": true,
+ "network": "eip155:84532",
+ "asset": "0x036CbD53842c5426634e7929541eC2318f3dCF7e",
+ "assetName": "USDC",
+ "assetVersion": "2",
+ "assetDecimals": 6,
+ "payTo": "0x1111111111111111111111111111111111111111",
+ "maxTimeoutSeconds": 120,
+ "facilitator": {
+ "mode": "remote"
+ },
+ "mode": "testnet",
+ "paymentFlow": "authorization"
+ },
+ "mpp": {
+ "enabled": true,
+ "network": "eip155:84532",
+ "asset": "0x036CbD53842c5426634e7929541eC2318f3dCF7e",
+ "assetName": "USDC",
+ "assetVersion": "2",
+ "assetDecimals": 6,
+ "recipient": "0x1111111111111111111111111111111111111111",
+ "facilitator": {
+ "mode": "remote"
+ },
+ "mode": "testnet",
+ "paymentFlow": "upfront"
+ }
+ }
+}
diff --git a/tests/integration/goldens/2.7.2/x402-challenge-multi.json b/tests/integration/goldens/2.7.2/x402-challenge-multi.json
new file mode 100644
index 0000000..d4d6a49
--- /dev/null
+++ b/tests/integration/goldens/2.7.2/x402-challenge-multi.json
@@ -0,0 +1,36 @@
+{
+ "x402Version": 2,
+ "resource": {
+ "url": "resource://agent-commerce/resources/market_report",
+ "description": "Latest market analysis for a symbol.",
+ "mimeType": "application/json"
+ },
+ "accepts": [
+ {
+ "scheme": "exact",
+ "network": "eip155:84532",
+ "asset": "0x036CbD53842c5426634e7929541eC2318f3dCF7e",
+ "amount": "10000",
+ "payTo": "0x1111111111111111111111111111111111111111",
+ "maxTimeoutSeconds": 120,
+ "extra": {
+ "name": "USDC",
+ "version": "2",
+ "assetTransferMethod": "eip3009"
+ }
+ },
+ {
+ "scheme": "exact",
+ "network": "eip155:421614",
+ "asset": "0x75faf114eafb1BDbe2F0316DF893fd58CE46AA4d",
+ "amount": "10000",
+ "payTo": "0x1111111111111111111111111111111111111111",
+ "maxTimeoutSeconds": 120,
+ "extra": {
+ "name": "USD Coin",
+ "version": "2",
+ "assetTransferMethod": "permit2"
+ }
+ }
+ ]
+}
diff --git a/tests/integration/goldens/2.7.2/x402-challenge-single.json b/tests/integration/goldens/2.7.2/x402-challenge-single.json
new file mode 100644
index 0000000..a5ddbcd
--- /dev/null
+++ b/tests/integration/goldens/2.7.2/x402-challenge-single.json
@@ -0,0 +1,23 @@
+{
+ "x402Version": 2,
+ "resource": {
+ "url": "resource://agent-commerce/eip155%3A84532/0x1111111111111111111111111111111111111111/resources/market_report",
+ "description": "Latest market analysis for a symbol.",
+ "mimeType": "application/json"
+ },
+ "accepts": [
+ {
+ "scheme": "exact",
+ "network": "eip155:84532",
+ "asset": "0x036CbD53842c5426634e7929541eC2318f3dCF7e",
+ "amount": "10000",
+ "payTo": "0x1111111111111111111111111111111111111111",
+ "maxTimeoutSeconds": 120,
+ "extra": {
+ "name": "USDC",
+ "version": "2",
+ "assetTransferMethod": "eip3009"
+ }
+ }
+ ]
+}
From d5bc013a399873526d3ec7155360454a34e5388f Mon Sep 17 00:00:00 2001
From: Revinand
Date: Tue, 17 Nov 2026 15:07:28 +0100
Subject: [PATCH 02/14] feat(core): add the request surface and health
reachability to the contract
---
docs/contract-surface.txt | 2 +
docs/contracts.md | 8 ++++
src/core/domain/common.ts | 5 +++
src/core/domain/payment.ts | 6 +++
src/core/execution/pipeline/admission.ts | 1 +
tests/unit/core/execution/pipeline.test.ts | 49 +++++++++++++++++++++-
6 files changed, 70 insertions(+), 1 deletion(-)
diff --git a/docs/contract-surface.txt b/docs/contract-surface.txt
index b1d3943..dbc4685 100644
--- a/docs/contract-surface.txt
+++ b/docs/contract-surface.txt
@@ -23,6 +23,7 @@ interface AdapterHealth {
interface AdapterHealthComponent {
readonly name: string;
readonly status: "pass" | "warn" | "fail";
+ readonly undetermined?: "unreachable";
}
interface AdapterHttpRoute {
@@ -373,6 +374,7 @@ interface PaymentContext {
readonly currency: string;
readonly input?: unknown;
readonly metadata?: Readonly>;
+ readonly protocol?: ProtocolName;
readonly requestId: string;
readonly requestedAt: string;
readonly resource: CommerceResource;
diff --git a/docs/contracts.md b/docs/contracts.md
index 53edf38..9c2978c 100644
--- a/docs/contracts.md
+++ b/docs/contracts.md
@@ -299,6 +299,14 @@ persistence must not fail the commerce flow.
Omitting the override keeps the code's default.
- These fields and methods are experimental and may change in a minor
release. The 3.0.0 migration plan makes `getIdempotencyKey` required.
+- 2.8.0 adds two optional, experimental fields that may change in a minor
+ release. Existing 2.7 providers and adapters need no changes.
+ - `PaymentContext.protocol` identifies the request's protocol. On each
+ `createRequirement` call, the pipeline copies it from
+ `CanonicalRequest.protocol`. Providers can ignore it.
+ - `AdapterHealthComponent.undetermined` uses `'unreachable'` for a probe
+ that received no response. When set, `status` does not describe the
+ target's health. Without the field, `status` retains its 2.7 meaning.
### Protocols and gateway
diff --git a/src/core/domain/common.ts b/src/core/domain/common.ts
index 995feba..9f00aad 100644
--- a/src/core/domain/common.ts
+++ b/src/core/domain/common.ts
@@ -78,6 +78,11 @@ export interface AdapterHealth {
export interface AdapterHealthComponent {
readonly name: string;
readonly status: 'pass' | 'warn' | 'fail';
+ /**
+ * Marks a probe that received no response; `status` does not describe the
+ * target's health in this case. Experimental: may change in a minor release.
+ */
+ readonly undetermined?: 'unreachable';
}
/** Describes an adapter's supported surface for diagnostics */
diff --git a/src/core/domain/payment.ts b/src/core/domain/payment.ts
index e94097e..12fe195 100644
--- a/src/core/domain/payment.ts
+++ b/src/core/domain/payment.ts
@@ -11,6 +11,7 @@ import type {
DecimalAmount,
IsoTimestamp,
PaymentMethodName,
+ ProtocolName,
} from './common';
import type { PaymentAttempt } from './receipt';
import type { CommerceResource } from './resource';
@@ -122,6 +123,11 @@ export interface PaymentContext {
* challenge to the input but must not send it to a third party.
*/
readonly input?: unknown;
+ /**
+ * The request's protocol, set by the pipeline on each createRequirement call.
+ * Experimental: may change in a minor release.
+ */
+ readonly protocol?: ProtocolName;
readonly metadata?: Readonly>;
}
diff --git a/src/core/execution/pipeline/admission.ts b/src/core/execution/pipeline/admission.ts
index cb4aea7..daf88d9 100644
--- a/src/core/execution/pipeline/admission.ts
+++ b/src/core/execution/pipeline/admission.ts
@@ -92,6 +92,7 @@ export function createPaymentAdmission(
currency: pricing.currency,
requestedAt: options.clock.nowIso(),
input: validInput,
+ protocol: request.protocol,
// Transport facts a rail may bind into its challenge, such as a body digest
...(request.metadata !== undefined ? { metadata: request.metadata } : {}),
});
diff --git a/tests/unit/core/execution/pipeline.test.ts b/tests/unit/core/execution/pipeline.test.ts
index e571351..3f81f7d 100644
--- a/tests/unit/core/execution/pipeline.test.ts
+++ b/tests/unit/core/execution/pipeline.test.ts
@@ -1,5 +1,10 @@
import { describe, expect, it } from 'vitest';
-import type { EventSink, PaymentAttempt, ReceiptStore } from '../../../../src/core';
+import {
+ type EventSink,
+ type PaymentAttempt,
+ PROTOCOL_NAMES,
+ type ReceiptStore,
+} from '../../../../src/core';
import type { CommerceEvent, CommerceEventType } from '../../../../src/core/domain/event';
import type {
CanonicalRequest,
@@ -240,6 +245,48 @@ describe('createExecutionPipeline', () => {
expect(inputs).toEqual([{ city: 'Paris' }]);
});
+ it('passes the request surface to createRequirement on every protocol', async () => {
+ const resource = makeResource({
+ id: 'res-1',
+ pricing: { type: 'fixed', amount: '0.01', currency: 'USDC' },
+ paymentMethods: ['x402'],
+ exposedVia: PROTOCOL_NAMES,
+ });
+ const seen: unknown[] = [];
+ const provider = createFakePaymentProvider({
+ createRequirement: async (ctx) => {
+ seen.push(ctx.protocol);
+ return {
+ id: 'r',
+ requestId: ctx.requestId,
+ resourceId: ctx.resource.id,
+ provider: 'x402',
+ amount: ctx.amount,
+ currency: ctx.currency,
+ challenge: { provider: 'x402', version: '1', accepts: [] },
+ };
+ },
+ });
+ const store = createFakeStore();
+ const pipeline = createExecutionPipeline({
+ resources: createResourceRegistry([resource]),
+ paymentProviders: [provider],
+ store,
+ backend: createFakeBackendExecutor(),
+ events: store,
+ logger: createCapturingLogger(),
+ clock: createFakeClock(),
+ ids: createFakeIdGenerator(),
+ });
+
+ for (const protocol of PROTOCOL_NAMES) {
+ const outcome = await pipeline.execute(makeRequest({ protocol }));
+ expect(outcome.kind).toBe('payment-required');
+ }
+
+ expect(seen).toEqual(PROTOCOL_NAMES);
+ });
+
it('throws INPUT_INVALID for input that fails the resource schema', async () => {
const resource = makeResource({
id: 'res-1',
From a261587fad5f02a0ab37be6cf3f22717a08bcf20 Mon Sep 17 00:00:00 2001
From: Revinand
Date: Tue, 17 Nov 2026 15:52:51 +0100
Subject: [PATCH 03/14] feat: read support claims from one record per profile
---
docs/contributing-adapters.md | 12 +-
docs/protocols/ap2.md | 4 +-
docs/protocols/mpp.md | 2 +-
scripts/support-record.ts | 161 +++++++++++++
src/authorization/ap2/descriptor.ts | 40 +---
src/cli/commands/doctor/ap2.ts | 11 +-
src/cli/commands/doctor/payments.ts | 8 +-
src/cli/commands/doctor/protocols.ts | 16 +-
src/gateway/well-known.ts | 8 +-
src/payments/mpp/descriptor.ts | 25 +--
src/payments/x402/provider/index.ts | 11 +-
src/protocols/a2a/descriptor.ts | 42 ++--
src/protocols/acp/descriptor.ts | 42 +---
src/protocols/mcp/descriptor.ts | 39 +---
src/support/a2a.json | 88 ++++++++
src/support/acp.json | 89 ++++++++
src/support/ap2.json | 88 ++++++++
src/support/claims.ts | 34 +++
src/support/http.json | 15 ++
src/support/mcp.json | 68 ++++++
src/support/mpp.json | 130 +++++++++++
src/support/x402.json | 127 +++++++++++
.../goldens/2.7.2/doctor-multi.json | 4 +-
.../goldens/2.7.2/doctor-single.json | 4 +-
.../goldens/2.7.2/well-known-multi.json | 18 +-
.../goldens/2.7.2/well-known-single.json | 18 +-
tests/integration/support-record.test.ts | 212 ++++++++++++++++++
tests/mainnet/x402.smoke.test.ts | 10 +-
tests/unit/deploy/deploy.test.ts | 17 ++
tests/unit/payments-mpp/profile.test.ts | 11 +
30 files changed, 1170 insertions(+), 184 deletions(-)
create mode 100644 scripts/support-record.ts
create mode 100644 src/support/a2a.json
create mode 100644 src/support/acp.json
create mode 100644 src/support/ap2.json
create mode 100644 src/support/claims.ts
create mode 100644 src/support/http.json
create mode 100644 src/support/mcp.json
create mode 100644 src/support/mpp.json
create mode 100644 src/support/x402.json
create mode 100644 tests/integration/support-record.test.ts
diff --git a/docs/contributing-adapters.md b/docs/contributing-adapters.md
index ab4733e..c0a7cb0 100644
--- a/docs/contributing-adapters.md
+++ b/docs/contributing-adapters.md
@@ -31,9 +31,9 @@ A new name crosses the public contract and runtime wiring. After approval:
5. If it has distinct optional dependencies, add the narrow subpath, build
entry, package export, optional peer and the real-package check in
`tests/unit/cli/packaging.test.ts`.
-6. Add its descriptor, discovery and `doctor` output. Update the frozen
- contract and conformance coverage, and add a page under `docs/protocols/`
- that [protocols.md](protocols.md) lists.
+6. Add a support record under `src/support/`, a descriptor, and discovery and
+ `doctor` output. Update the frozen contract and conformance coverage. Add a
+ page under `docs/protocols/` and list it in [protocols.md](protocols.md).
## Protocol adapters
@@ -95,9 +95,9 @@ validation, authorization, payment, backend execution and receipts.
carriers from headers.
- Keep handler failures inside the adapter and report health through
`health()`.
-- Pin `descriptor.supportedSpec`, list real `capabilities` and `unsupported`
- features, and keep `status: experimental` until conformance coverage supports
- promotion.
+- Pin `descriptor.supportedSpec` and list implemented `capabilities`. Derive
+ `status` and `unsupported` from the adapter's record in `src/support/`.
+ Keep the adapter `experimental` until conformance coverage supports promotion.
### Adapter review checklist
diff --git a/docs/protocols/ap2.md b/docs/protocols/ap2.md
index c6490cb..d50b3ab 100644
--- a/docs/protocols/ap2.md
+++ b/docs/protocols/ap2.md
@@ -381,8 +381,8 @@ does not close authorization providers.
## Not implemented
-`src/authorization/ap2/descriptor.ts` is authoritative for the unsupported list
-published through discovery and `doctor`. The broader implementation limits are:
+Discovery and `doctor` read the unsupported list from `src/support/ap2.json`.
+The broader implementation limits are:
- autonomous mode and open Checkout Mandates (`mandate.checkout.open.1`)
- Payment Mandates (`mandate.payment.1`)
diff --git a/docs/protocols/mpp.md b/docs/protocols/mpp.md
index 1b06a19..af4e824 100644
--- a/docs/protocols/mpp.md
+++ b/docs/protocols/mpp.md
@@ -61,7 +61,7 @@ issuing challenges over plain HTTP.
Base mainnet deployments must satisfy the
[mainnet guardrails](../configuration.md#mainnet-guardrails).
-Unsupported variants are listed in `src/payments/mpp/descriptor.ts`: non-EVM
+Unsupported variants are listed in `src/support/mpp.json`: non-EVM
methods, Permit2/transaction/hash credentials, splits, subscriptions, EVM
sessions and the discovery extension.
diff --git a/scripts/support-record.ts b/scripts/support-record.ts
new file mode 100644
index 0000000..61ab54e
--- /dev/null
+++ b/scripts/support-record.ts
@@ -0,0 +1,161 @@
+/**
+ * Validate the support records under `src/support/`, one per shipped profile.
+ * Each record states the revision, subset, exclusions, deviations and evidence
+ * its status covers. Descriptors and `doctor` trust these files at runtime.
+ * This schema runs in tests and tooling and is excluded from the published
+ * package.
+ */
+import { readFileSync } from 'node:fs';
+import { join } from 'node:path';
+import { z } from 'zod';
+
+export const SUPPORT_RECORD_NAMES = ['http', 'mcp', 'a2a', 'acp', 'x402', 'mpp', 'ap2'] as const;
+
+export const REPO_ROOT = join(import.meta.dirname, '..');
+
+const text = z.string().min(1);
+
+const SpecSchema = z.strictObject({
+ // Revision identifiers for comparison with code
+ revisions: z.array(text).min(1),
+ // Display text for the pinned revision
+ display: text,
+ source: z.strictObject({ repo: text, commit: z.string().regex(/^[0-9a-f]{40}$/) }),
+ // Whether upstream calls the pinned revision stable; null when unspecified
+ stable: z.boolean().nullable(),
+ // Upstream's own words on the revision's status
+ statement: text,
+ // The date `statement` was read
+ checked: z.iso.date(),
+});
+
+const SupportRecordSchema = z
+ .strictObject({
+ name: z.enum(SUPPORT_RECORD_NAMES),
+ kind: z.enum(['protocol', 'payment', 'authorization']),
+ title: text,
+ status: z.enum(['supported', 'experimental']),
+ // The profile's role as a transport, payment rail or authorization method
+ role: text,
+ subset: text,
+ spec: SpecSchema.optional(),
+ // Package names; version pins live in package.json
+ packages: z.array(z.strictObject({ name: text, use: z.enum(['runtime', 'test']) })),
+ // Vendored schemas and fixtures
+ artifacts: z.array(z.strictObject({ path: text, revision: text })),
+ // Descriptor capabilities, each with its own status
+ features: z.array(
+ z.strictObject({
+ name: text,
+ status: z.enum(['supported', 'experimental', 'partial']),
+ spec: SpecSchema.optional(),
+ }),
+ ),
+ // `name` is the string the descriptor publishes in `unsupported`
+ exclusions: z.array(
+ z.strictObject({ name: text, note: text.optional(), feature: text.optional() }),
+ ),
+ deviations: z.array(
+ z.strictObject({
+ summary: text,
+ // The specification and section the behavior departs from
+ spec: text,
+ upstream: text.optional(),
+ tests: z.array(text).min(1),
+ }),
+ ),
+ // Payment records: the surface, rail and authorization covered by the evidence
+ combinations: z
+ .array(
+ z.strictObject({
+ surface: z.enum(['http', 'mcp', 'a2a']),
+ method: z.enum(['x402', 'mpp']),
+ authorization: z.literal('ap2').optional(),
+ level: z.enum(['e2e', 'integration', 'testnet', 'mainnet']),
+ evidence: text,
+ }),
+ )
+ .optional(),
+ conformance: z
+ .strictObject({
+ suite: text,
+ tests: z.array(text).min(1),
+ skipped: z.array(
+ z.strictObject({
+ test: text,
+ reason: text,
+ spec: text.optional(),
+ upstream: text.optional(),
+ }),
+ ),
+ })
+ .optional(),
+ // Known MUST-level gaps against the pinned revision
+ gaps: z.array(
+ z.strictObject({ requirement: text, state: z.enum(['open', 'closed', 'excluded']) }),
+ ),
+ docs: z.array(text).min(1),
+ })
+ .superRefine((record, ctx) => {
+ const duplicates = (names: readonly string[]) =>
+ names.filter((name, index) => names.indexOf(name) !== index);
+ const features = record.features.map((feature) => feature.name);
+ for (const name of duplicates(features)) {
+ ctx.addIssue({ code: 'custom', path: ['features'], message: `duplicate feature "${name}"` });
+ }
+ for (const name of duplicates(record.exclusions.map((exclusion) => exclusion.name))) {
+ ctx.addIssue({
+ code: 'custom',
+ path: ['exclusions'],
+ message: `duplicate exclusion "${name}"`,
+ });
+ }
+ for (const exclusion of record.exclusions) {
+ if (exclusion.feature !== undefined && !features.includes(exclusion.feature)) {
+ ctx.addIssue({
+ code: 'custom',
+ path: ['exclusions'],
+ message: `exclusion "${exclusion.name}" names unknown feature "${exclusion.feature}"`,
+ });
+ }
+ }
+ if (record.combinations !== undefined && record.kind !== 'payment') {
+ ctx.addIssue({
+ code: 'custom',
+ path: ['combinations'],
+ message: 'only a payment record lists tested combinations',
+ });
+ }
+ });
+
+export type SupportRecord = z.infer;
+export type SupportRecordName = (typeof SUPPORT_RECORD_NAMES)[number];
+
+export function supportRecordPath(name: SupportRecordName): string {
+ return join(REPO_ROOT, 'src/support', `${name}.json`);
+}
+
+/** Read and validate a record; schema errors include the file path and validation details */
+export function readSupportRecord(name: SupportRecordName): SupportRecord {
+ const path = supportRecordPath(name);
+ const parsed = SupportRecordSchema.safeParse(JSON.parse(readFileSync(path, 'utf8')));
+ if (!parsed.success) {
+ throw new Error(`src/support/${name}.json: ${z.prettifyError(parsed.error)}`);
+ }
+ if (parsed.data.name !== name) {
+ throw new Error(`src/support/${name}.json: name is "${parsed.data.name}", not "${name}"`);
+ }
+ return parsed.data;
+}
+
+/** Evidence and documentation paths to check for existence */
+export function citedPaths(record: SupportRecord): string[] {
+ return [
+ ...record.artifacts.map((artifact) => artifact.path),
+ ...(record.combinations ?? []).map((combination) => combination.evidence),
+ ...(record.conformance?.tests ?? []),
+ ...(record.conformance?.skipped ?? []).map((skipped) => skipped.test),
+ ...record.deviations.flatMap((deviation) => deviation.tests),
+ ...record.docs,
+ ];
+}
diff --git a/src/authorization/ap2/descriptor.ts b/src/authorization/ap2/descriptor.ts
index 31f78a9..414e0ef 100644
--- a/src/authorization/ap2/descriptor.ts
+++ b/src/authorization/ap2/descriptor.ts
@@ -1,10 +1,8 @@
-/**
- * Adapter self-description.
- *
- * Imports nothing but core types and the pins, so `doctor` can report AP2
- * without pulling `jose` or `@sd-jwt/core` into the CLI bundle.
- */
+// AP2 pins and support metadata for diagnostics, without loading the optional
+// `jose` or `@sd-jwt/core` peers
import type { AdapterDescriptor } from '../../core';
+import record from '../../support/ap2.json' with { type: 'json' };
+import { descriptorStatus, exclusionNames } from '../../support/claims';
import {
AP2_CHECKOUT_MANDATE_VCT,
AP2_CHECKOUT_PROFILE,
@@ -29,32 +27,10 @@ export const AP2_CAPABILITIES: readonly string[] = [
];
/**
- * Major AP2 features this provider does not support, published in its
- * descriptor and printed by `doctor`, so no client assumes full protocol
- * support
+ * Unsupported AP2 features from the support record, published in the descriptor
+ * and printed by `doctor` to show the limits of protocol support
*/
-export const AP2_UNSUPPORTED: readonly string[] = [
- // Mandate kinds. Open mandates are refused: see AP2_CHECKOUT_MANDATE_VCT
- 'autonomous mode',
- 'open checkout mandates (mandate.checkout.open.1)',
- 'payment mandates (mandate.payment.1)',
- 'spending constraint evaluation',
- 'cnf-bound agent keys',
- // Delegation models other than a trusted agent provider
- 'user credential delegation (OpenID4VP)',
- 'delegation chains and key-binding JWTs',
- // Key handling. Every key is written into config by an operator
- 'JWKS and any key discovery by URL (jku, x5u)',
- 'issuer metadata fetching',
- 'key rotation without a config change',
- // Algorithms
- 'signature algorithms other than ES256',
- 'digest algorithms other than sha-256',
- // Roles this gateway does not play
- 'mandate issuance',
- 'checkout receipts',
- 'AP2 over the ACP checkout adapter',
-];
+export const AP2_UNSUPPORTED: readonly string[] = exclusionNames(record);
export function buildAp2Descriptor(implementationVersion: string): AdapterDescriptor {
return {
@@ -63,7 +39,7 @@ export function buildAp2Descriptor(implementationVersion: string): AdapterDescri
implementationVersion,
supportedSpec: `ap2/v${AP2_SPEC_VERSION} mode=direct`,
capabilities: AP2_CAPABILITIES,
- status: 'experimental',
+ status: descriptorStatus(record),
unsupported: AP2_UNSUPPORTED,
};
}
diff --git a/src/cli/commands/doctor/ap2.ts b/src/cli/commands/doctor/ap2.ts
index edf3821..6336d15 100644
--- a/src/cli/commands/doctor/ap2.ts
+++ b/src/cli/commands/doctor/ap2.ts
@@ -1,13 +1,14 @@
// AP2 checks: settings, trust lists, the replay store and the gated resources
-// Constants and a descriptor only: the AP2 provider would pull the optional
-// peers `jose`, `@sd-jwt/core` and `canonicalize` into the CLI bundle
+// Read AP2 constants and support metadata directly to keep the optional peers
+// `jose`, `@sd-jwt/core` and `canonicalize` out of the static CLI imports
import {
AP2_CHECKOUT_MANDATE_VCT,
AP2_CHECKOUT_PROFILE,
AP2_SPEC_VERSION,
} from '../../../authorization/ap2/constants';
-import { AP2_UNSUPPORTED } from '../../../authorization/ap2/descriptor';
+import ap2Record from '../../../support/ap2.json' with { type: 'json' };
+import { exclusionNames } from '../../../support/claims';
import type { GatewayConfig } from '../../lib/config-client';
import { type LegacyState, legacyStoreCheck } from './storage';
import type { DoctorCheck } from './types';
@@ -39,7 +40,7 @@ export function ap2Checks(config: GatewayConfig | undefined, legacy: LegacyState
checks.push({
name: 'AP2',
status: 'PASS',
- detail: `experimental · spec ${AP2_SPEC_VERSION} · mode ${ap2.mode} · ${AP2_CHECKOUT_MANDATE_VCT} · profile ${AP2_CHECKOUT_PROFILE} · clock skew ${ap2.clockSkewSeconds}s · mandate aud ${ap2.requireMandateAudience === true ? 'required' : 'optional'} · mandate exp ${ap2.requireMandateExpiry === true ? 'required' : 'optional'}`,
+ detail: `${ap2Record.status} · spec ${AP2_SPEC_VERSION} · mode ${ap2.mode} · ${AP2_CHECKOUT_MANDATE_VCT} · profile ${AP2_CHECKOUT_PROFILE} · clock skew ${ap2.clockSkewSeconds}s · mandate aud ${ap2.requireMandateAudience === true ? 'required' : 'optional'} · mandate exp ${ap2.requireMandateExpiry === true ? 'required' : 'optional'}`,
});
// Two lists, reported separately: signing the merchant's checkout
@@ -77,7 +78,7 @@ export function ap2Checks(config: GatewayConfig | undefined, legacy: LegacyState
checks.push({
name: 'AP2 unsupported',
status: 'INFO',
- detail: AP2_UNSUPPORTED.join(', '),
+ detail: exclusionNames(ap2Record).join(', '),
});
}
return checks;
diff --git a/src/cli/commands/doctor/payments.ts b/src/cli/commands/doctor/payments.ts
index 51ce656..c8f6515 100644
--- a/src/cli/commands/doctor/payments.ts
+++ b/src/cli/commands/doctor/payments.ts
@@ -18,11 +18,15 @@ import {
resolveDeploymentMode,
} from '../../../payments/x402/networks';
import { X402_DEFAULT_PAYMENT_FLOW } from '../../../payments/x402/payment-flow';
+import { featureStatus } from '../../../support/claims';
+import x402Record from '../../../support/x402.json' with { type: 'json' };
import type { GatewayConfig } from '../../lib/config-client';
import { PLACEHOLDER_ASSET_ADDRESS } from '../../lib/init-config';
import { maskMiddle } from '../../lib/mask';
import type { DoctorCheck, WellKnownResult } from './types';
+const QUOTE_STATUS = featureStatus(x402Record, 'erc-8409-quotes');
+
// The rail's settlement order and how many resources override it
function describePaymentFlow(
rail: {
@@ -399,7 +403,7 @@ function quoteCheck(
? {
name,
status: 'INFO',
- detail: `ERC-8409 quotes enabled (experimental)${localIssuer !== undefined ? `, issuer=${localIssuer} from the local key` : ''}; the gateway's issuer could not be read`,
+ detail: `ERC-8409 quotes enabled (${QUOTE_STATUS})${localIssuer !== undefined ? `, issuer=${localIssuer} from the local key` : ''}; the gateway's issuer could not be read`,
}
: undefined;
}
@@ -431,7 +435,7 @@ function quoteCheck(
return {
name,
status: 'PASS',
- detail: `ERC-8409 quotes (experimental) - issuer=${issuer}${local === undefined ? ' as the gateway publishes it (viem could not be loaded to check it against the local key)' : ''}, requestScheme=${quote.requestScheme}, extension=${quote.extension}`,
+ detail: `ERC-8409 quotes (${QUOTE_STATUS}) - issuer=${issuer}${local === undefined ? ' as the gateway publishes it (viem could not be loaded to check it against the local key)' : ''}, requestScheme=${quote.requestScheme}, extension=${quote.extension}`,
};
}
diff --git a/src/cli/commands/doctor/protocols.ts b/src/cli/commands/doctor/protocols.ts
index 790ba6d..dff2337 100644
--- a/src/cli/commands/doctor/protocols.ts
+++ b/src/cli/commands/doctor/protocols.ts
@@ -1,19 +1,21 @@
// Protocol checks: what is enabled, and the A2A and ACP specifics
-// Narrow modules, not the protocol barrels: the CLI must pull in no protocol SDK
+// Read protocol constants and support metadata directly to keep protocol SDKs
+// out of the static CLI imports
import {
A2A_AGENT_CARD_PATH,
A2A_PROTOCOL_BINDING,
A2A_PROTOCOL_VERSION,
A2A_SPEC_VERSION,
} from '../../../protocols/a2a/constants';
-import { A2A_UNSUPPORTED } from '../../../protocols/a2a/descriptor';
import {
ACP_API_VERSION,
ACP_SPEC_VERSION,
ACP_WELL_KNOWN_PATH,
} from '../../../protocols/acp/constants';
-import { ACP_UNSUPPORTED } from '../../../protocols/acp/descriptor';
+import a2aRecord from '../../../support/a2a.json' with { type: 'json' };
+import acpRecord from '../../../support/acp.json' with { type: 'json' };
+import { exclusionNames } from '../../../support/claims';
import type { GatewayConfig } from '../../lib/config-client';
import { type LegacyState, legacyStoreCheck } from './storage';
import type { DoctorCheck, WellKnownResult } from './types';
@@ -89,14 +91,14 @@ export function protocolChecks(
checks.push({
name: 'A2A',
status: 'PASS',
- detail: `experimental · spec ${A2A_SPEC_VERSION} · protocol ${A2A_PROTOCOL_VERSION} · binding ${A2A_PROTOCOL_BINDING} · mount ${config.protocols.a2a.mountPath} · card ${A2A_AGENT_CARD_PATH}`,
+ detail: `${a2aRecord.status} · spec ${A2A_SPEC_VERSION} · protocol ${A2A_PROTOCOL_VERSION} · binding ${A2A_PROTOCOL_BINDING} · mount ${config.protocols.a2a.mountPath} · card ${A2A_AGENT_CARD_PATH}`,
});
// Listed in full, as are ACP's and AP2's below: a count does not tell an
// operator whether the one feature their client needs is missing
checks.push({
name: 'A2A unsupported',
status: 'INFO',
- detail: A2A_UNSUPPORTED.join(', '),
+ detail: exclusionNames(a2aRecord).join(', '),
});
}
@@ -112,7 +114,7 @@ export function protocolChecks(
checks.push({
name: 'ACP',
status: 'PASS',
- detail: `experimental · spec ${ACP_SPEC_VERSION} · API-Version ${ACP_API_VERSION} · service checkout · mount ${acp.mountPath} · discovery ${ACP_WELL_KNOWN_PATH}`,
+ detail: `${acpRecord.status} · spec ${ACP_SPEC_VERSION} · API-Version ${ACP_API_VERSION} · service checkout · mount ${acp.mountPath} · discovery ${ACP_WELL_KNOWN_PATH}`,
});
// Whether a token is configured and its length, never the token. Config
@@ -138,7 +140,7 @@ export function protocolChecks(
checks.push({
name: 'ACP unsupported',
status: 'INFO',
- detail: ACP_UNSUPPORTED.join(', '),
+ detail: exclusionNames(acpRecord).join(', '),
});
}
return checks;
diff --git a/src/gateway/well-known.ts b/src/gateway/well-known.ts
index 965c1e8..2eb14ea 100644
--- a/src/gateway/well-known.ts
+++ b/src/gateway/well-known.ts
@@ -29,6 +29,8 @@ import {
import { x402OfferName } from '../payments/x402/options';
import { X402_DEFAULT_PAYMENT_FLOW, type X402PaymentFlow } from '../payments/x402/payment-flow';
import type { X402PaymentProvider } from '../payments/x402/provider/types';
+import { type FeatureStatus, featureStatus } from '../support/claims';
+import x402Record from '../support/x402.json' with { type: 'json' };
import { PACKAGE_VERSION } from '../version';
import type { ProbedAdapter, ProbedProvider } from './readiness';
@@ -36,6 +38,8 @@ import type { ProbedAdapter, ProbedProvider } from './readiness';
// negotiates against, which changes only when that contract does
const GATEWAY_SUPPORTED_SPEC = 'agent-commerce/v1.0.0';
+const QUOTE_STATUS = featureStatus(x402Record, 'erc-8409-quotes');
+
/**
* The protocol block as published, not as configured.
*
@@ -133,7 +137,7 @@ export interface WellKnownX402Quote {
readonly requestScheme: string;
/** The key in `PaymentRequired.extensions` that carries the quotes */
readonly extension: string;
- readonly status: 'experimental';
+ readonly status: FeatureStatus;
}
export interface BuildWellKnownOptions {
@@ -204,7 +208,7 @@ function publicQuote(providers: readonly PaymentProvider[]): WellKnownX402Quote
| undefined;
if (x402?.quote === undefined) return undefined;
const { issuer, requestScheme, extension } = x402.quote;
- return { issuer, requestScheme, extension, status: 'experimental' };
+ return { issuer, requestScheme, extension, status: QUOTE_STATUS };
}
export function buildWellKnownDocument(options: BuildWellKnownOptions): WellKnownDocument {
diff --git a/src/payments/mpp/descriptor.ts b/src/payments/mpp/descriptor.ts
index cb07d18..a701c11 100644
--- a/src/payments/mpp/descriptor.ts
+++ b/src/payments/mpp/descriptor.ts
@@ -1,12 +1,15 @@
/**
* Describes the MPP profile and its unsupported variants.
*
- * The protocol name alone cannot identify a compatible intent, method and
- * extension set, so the descriptor lists both the target and its gaps.
+ * The descriptor identifies the intent, method, extensions and unsupported
+ * variants needed to assess compatibility. Status and unsupported variants
+ * come from `src/support/mpp.json`.
*
* Importing the descriptor does not load `mppx`.
*/
import type { AdapterDescriptor } from '../../core/public-types';
+import { descriptorStatus, exclusionNames } from '../../support/claims';
+import record from '../../support/mpp.json' with { type: 'json' };
import { PACKAGE_VERSION } from '../../version';
import { MPP_NETWORKS, MPP_PROFILE, MPP_SUPPORTED_SPEC } from './constants';
@@ -29,20 +32,6 @@ export const MPP_DESCRIPTOR: AdapterDescriptor = {
// HTTP request bodies only; MCP and A2A carry the proof in the body
'challenge-digest-binding',
],
- // The pinned specs are drafts and mppx is pre-1.0; the wire format may change
- status: 'experimental',
- unsupported: [
- // Name other methods as a class instead of maintaining a second list
- 'methods other than evm',
- // This profile supports only the EIP-3009 `authorization` credential
- 'credential=permit2',
- 'credential=transaction',
- 'credential=hash',
- // The draft allows splits only with permit2 credentials
- 'splits',
- 'intent=subscription',
- // A separate EVM draft, not an option of charge
- 'evm sessions',
- 'discovery extension',
- ],
+ status: descriptorStatus(record),
+ unsupported: exclusionNames(record),
};
diff --git a/src/payments/x402/provider/index.ts b/src/payments/x402/provider/index.ts
index 2aacc1a..7fccb9a 100644
--- a/src/payments/x402/provider/index.ts
+++ b/src/payments/x402/provider/index.ts
@@ -12,6 +12,8 @@
*/
import type { AdapterDescriptor } from '../../../core';
import { CommerceError, NOOP_LOGGER, systemClock } from '../../../core';
+import { descriptorStatus, exclusionNames } from '../../../support/claims';
+import record from '../../../support/x402.json' with { type: 'json' };
import { PACKAGE_VERSION } from '../../../version';
import { DEFAULT_IDS, DEFAULT_MAX_TIMEOUT_SECONDS, X402_VERSION } from './constants';
import {
@@ -112,13 +114,8 @@ export function createX402PaymentProvider(
...(severalOffers ? ['multiple-offers'] : []),
...(quotes ? ['erc-8409-quotes'] : []),
],
- status: 'stable',
- unsupported: [
- 'permit2 gas sponsoring extensions',
- 'upto scheme',
- 'batch-settlement scheme',
- 'auth-capture scheme',
- ],
+ status: descriptorStatus(record),
+ unsupported: exclusionNames(record),
};
// Loaded only with an offer of their family, so no deployment needs the
diff --git a/src/protocols/a2a/descriptor.ts b/src/protocols/a2a/descriptor.ts
index 47be8c7..c66b9f7 100644
--- a/src/protocols/a2a/descriptor.ts
+++ b/src/protocols/a2a/descriptor.ts
@@ -1,13 +1,13 @@
/**
- * Adapter self-description.
- *
- * `supportedSpec` is the A2A specification revision (`1.0.1`), never the
- * negotiation version (`1.0`) and never this package's version. Status is
- * `experimental` while the adapter lacks the features in the unsupported list
- * below; an entry leaves that list only when its feature is implemented.
+ * `supportedSpec` pins the A2A specification revision (`1.0.1`). Negotiation
+ * uses `1.0`; the package version is independent. Status and unsupported
+ * features come from `src/support/a2a.json`. Remove an unsupported entry only
+ * after implementing its feature.
*/
import type { AdapterDescriptor } from '../../core';
-import { A2A_SPEC_VERSION, A2A_UNSUPPORTED_METHODS } from './constants';
+import record from '../../support/a2a.json' with { type: 'json' };
+import { descriptorStatus, exclusionNames } from '../../support/claims';
+import { A2A_SPEC_VERSION } from './constants';
// What this adapter implements
const A2A_CAPABILITIES: readonly string[] = [
@@ -19,28 +19,12 @@ const A2A_CAPABILITIES: readonly string[] = [
];
/**
- * Major A2A features this adapter does not implement, served on
- * `/.well-known/agent-commerce` and printed by `doctor`, so no client assumes
- * full protocol support
+ * Unsupported A2A features, published at `/.well-known/agent-commerce` and
+ * printed by `doctor` to show the limits of protocol support.
+ * The support record also lists the `A2A_UNSUPPORTED_METHODS` refused by the
+ * transport.
*/
-export const A2A_UNSUPPORTED: readonly string[] = [
- // Methods, as the protocol names them; the transport refuses the same list
- ...A2A_UNSUPPORTED_METHODS,
- // Transports other than the one binding served
- 'HTTP+JSON/REST binding',
- 'gRPC binding',
- // Behaviors
- 'SSE',
- 'long-running task persistence',
- 'task resumption other than an x402 extension payment',
- 'push notifications',
- 'multi-turn conversational continuation',
- 'authenticated extended agent cards',
- 'A2A authentication schemes',
- 'artifact types beyond Agent Commerce outcome data',
- // Instances with separate receipt stores cannot resume each other's tasks
- 'x402 extension payments across gateway instances',
-];
+export const A2A_UNSUPPORTED: readonly string[] = exclusionNames(record);
export function buildDescriptor(implementationVersion: string): AdapterDescriptor {
return {
@@ -49,7 +33,7 @@ export function buildDescriptor(implementationVersion: string): AdapterDescripto
implementationVersion,
supportedSpec: A2A_SPEC_VERSION,
capabilities: A2A_CAPABILITIES,
- status: 'experimental',
+ status: descriptorStatus(record),
unsupported: A2A_UNSUPPORTED,
};
}
diff --git a/src/protocols/acp/descriptor.ts b/src/protocols/acp/descriptor.ts
index 02f43bc..ff3e05a 100644
--- a/src/protocols/acp/descriptor.ts
+++ b/src/protocols/acp/descriptor.ts
@@ -1,12 +1,11 @@
/**
- * Adapter self-description.
- *
- * `supportedSpec` is the pinned ACP snapshot, never this package's version.
- * Status is `experimental` while the adapter lacks the features in the
- * unsupported list below; an entry leaves that list only when its feature is
- * implemented.
+ * `supportedSpec` pins the ACP snapshot independently of the package version.
+ * Status and unsupported features come from `src/support/acp.json`.
+ * Remove an unsupported entry only after implementing its feature.
*/
import type { AdapterDescriptor } from '../../core';
+import record from '../../support/acp.json' with { type: 'json' };
+import { descriptorStatus, exclusionNames } from '../../support/claims';
import { ACP_CHECKOUT_OPERATIONS, ACP_SPEC_VERSION } from './constants';
// What this adapter implements
@@ -22,32 +21,11 @@ const ACP_CAPABILITIES: readonly string[] = [
];
/**
- * Major ACP features this adapter does not implement, served on
- * `/.well-known/agent-commerce` and printed by `doctor`, so no client assumes
- * full protocol support
+ * Unsupported ACP features from the support record, published at
+ * `/.well-known/agent-commerce` and printed by `doctor` to show the limits of
+ * protocol support
*/
-export const ACP_UNSUPPORTED: readonly string[] = [
- // Services this seller does not implement, named as ACP names them. The
- // discovery document advertises `checkout` alone, and these are the reason.
- 'carts service',
- 'feed service',
- 'standalone orders service',
- 'delegate_payment',
- 'delegate_authentication',
- // Bindings and delivery directions
- 'ACP MCP transport binding',
- 'webhooks',
- 'outbound merchant-to-agent delivery',
- 'ACP client role',
- // Request authentication beyond the bearer token
- 'Signature header verification',
- 'Timestamp replay-window verification',
- // Extensions, versioning and payment handlers
- 'discount extension',
- 'general ACP extension framework',
- 'multiple ACP API versions',
- 'seller-backed payment handler integration',
-];
+export const ACP_UNSUPPORTED: readonly string[] = exclusionNames(record);
export function buildDescriptor(implementationVersion: string): AdapterDescriptor {
return {
@@ -56,7 +34,7 @@ export function buildDescriptor(implementationVersion: string): AdapterDescripto
implementationVersion,
supportedSpec: ACP_SPEC_VERSION,
capabilities: ACP_CAPABILITIES,
- status: 'experimental',
+ status: descriptorStatus(record),
unsupported: ACP_UNSUPPORTED,
};
}
diff --git a/src/protocols/mcp/descriptor.ts b/src/protocols/mcp/descriptor.ts
index dd8e542..90d7ddd 100644
--- a/src/protocols/mcp/descriptor.ts
+++ b/src/protocols/mcp/descriptor.ts
@@ -1,10 +1,12 @@
/**
- * Adapter self-description. `supportedSpec` lists the modern revision and
- * the newest 2025-era revision. The SDK's legacy fallback also accepts older
- * 2025-era revisions.
+ * `supportedSpec` lists the modern revision and the newest 2025-era revision.
+ * The SDK's legacy fallback also accepts older revisions, back to 2024-10-07.
+ * Tests do not negotiate that oldest revision.
*/
import { LATEST_PROTOCOL_VERSION } from '@modelcontextprotocol/server';
import type { AdapterDescriptor } from '../../core';
+import { descriptorStatus, exclusionNames } from '../../support/claims';
+import record from '../../support/mcp.json' with { type: 'json' };
import { MCP_MODERN_PROTOCOL_REVISION } from './constants';
// List the modern revision followed by the SDK's latest legacy revision
@@ -14,33 +16,10 @@ const MCP_SUPPORTED_SPEC = `${MCP_MODERN_PROTOCOL_REVISION}, ${LATEST_PROTOCOL_V
const MCP_CAPABILITIES: readonly string[] = ['tools/list', 'tools/call'];
/**
- * MCP surfaces this adapter does not implement, listed so its descriptor never
- * implies blanket protocol compatibility.
- *
- * `dns-rebinding-protection` is delegated rather than missing: the gateway's
- * `onRequest` hook validates Host and Origin for `/mcp` (see adapter.ts), and
- * the adapter provides none on its own.
+ * Unsupported MCP surfaces from the support record, published in the descriptor
+ * to show the limits of protocol support
*/
-export const MCP_UNSUPPORTED: readonly string[] = [
- 'resources',
- 'prompts',
- 'sampling',
- 'completions',
- 'elicitation',
- 'roots',
- 'logging',
- 'notifications/tools/list_changed',
- 'tasks',
- 'dns-rebinding-protection',
- 'authorization',
- 'sessions',
- 'subscriptions',
- 'pagination',
- 'HTTP+SSE transport',
- // mppx reads challenges and refusals from tool-result `_meta`.
- 'MPP payment-required as JSON-RPC error -32042',
- 'MPP verification failure as JSON-RPC error -32043',
-];
+export const MCP_UNSUPPORTED: readonly string[] = exclusionNames(record);
export function buildDescriptor(implementationVersion: string): AdapterDescriptor {
return {
@@ -49,7 +28,7 @@ export function buildDescriptor(implementationVersion: string): AdapterDescripto
implementationVersion,
supportedSpec: MCP_SUPPORTED_SPEC,
capabilities: MCP_CAPABILITIES,
- status: 'stable',
+ status: descriptorStatus(record),
unsupported: MCP_UNSUPPORTED,
};
}
diff --git a/src/support/a2a.json b/src/support/a2a.json
new file mode 100644
index 0000000..2694f53
--- /dev/null
+++ b/src/support/a2a.json
@@ -0,0 +1,88 @@
+{
+ "name": "a2a",
+ "kind": "protocol",
+ "title": "A2A",
+ "status": "experimental",
+ "role": "Transport that carries x402 and MPP payments in SendMessage, including through the x402 extension.",
+ "subset": "Agent Card, `SendMessage`, paid flow and the x402 extension",
+ "spec": {
+ "revisions": ["1.0.1"],
+ "display": "v1.0.1; negotiation `1.0`; `JSONRPC` binding",
+ "source": {
+ "repo": "a2aproject/A2A",
+ "commit": "3303592588e388e62e0f69f701af531d2f4e3991"
+ },
+ "stable": true,
+ "statement": "the first stable, production-ready version",
+ "checked": "2026-11-17"
+ },
+ "packages": [{ "name": "@a2a-js/sdk", "use": "test" }],
+ "artifacts": [],
+ "features": [
+ { "name": "agent-card", "status": "experimental" },
+ { "name": "jsonrpc", "status": "experimental" },
+ { "name": "SendMessage", "status": "experimental" },
+ { "name": "x402-extension", "status": "experimental" }
+ ],
+ "exclusions": [
+ { "name": "SendStreamingMessage" },
+ { "name": "GetTask" },
+ { "name": "ListTasks" },
+ { "name": "CancelTask" },
+ { "name": "SubscribeToTask" },
+ { "name": "CreateTaskPushNotificationConfig" },
+ { "name": "GetTaskPushNotificationConfig" },
+ { "name": "ListTaskPushNotificationConfigs" },
+ { "name": "DeleteTaskPushNotificationConfig" },
+ { "name": "GetExtendedAgentCard" },
+ { "name": "HTTP+JSON/REST binding" },
+ { "name": "gRPC binding" },
+ { "name": "SSE" },
+ { "name": "long-running task persistence" },
+ { "name": "task resumption other than an x402 extension payment" },
+ { "name": "push notifications" },
+ { "name": "multi-turn conversational continuation" },
+ { "name": "text parts" },
+ { "name": "file and URL parts (including inline bytes)" },
+ { "name": "multi-part messages" },
+ { "name": "message roles other than ROLE_USER" },
+ { "name": "authenticated extended agent cards" },
+ { "name": "A2A authentication schemes" },
+ { "name": "artifact types beyond Agent Commerce outcome data" },
+ {
+ "name": "x402 extension payments across gateway instances",
+ "note": "Instances with separate receipt stores cannot resume each other's tasks."
+ }
+ ],
+ "deviations": [],
+ "conformance": {
+ "suite": "Our tests against the A2A 1.0.1 specification; the A2A TCK has not been run.",
+ "tests": [
+ "tests/conformance/a2a/agent-card.test.ts",
+ "tests/conformance/a2a/errors.test.ts",
+ "tests/conformance/a2a/free-resource.test.ts",
+ "tests/conformance/a2a/paid-resource.test.ts",
+ "tests/conformance/a2a/protocol-version.test.ts"
+ ],
+ "skipped": []
+ },
+ "gaps": [
+ {
+ "requirement": "§3.1: GetTask, ListTasks and CancelTask, which every agent implements",
+ "state": "open"
+ },
+ {
+ "requirement": "§3.2.2: returnImmediately as well as the blocking default",
+ "state": "open"
+ },
+ {
+ "requirement": "§3.3.2: validate all input parameters, including tenant and configuration",
+ "state": "open"
+ },
+ {
+ "requirement": "§7.1: encrypted communication in production; merchant.publicBaseUrl accepts http",
+ "state": "open"
+ }
+ ],
+ "docs": ["docs/protocols/a2a.md"]
+}
diff --git a/src/support/acp.json b/src/support/acp.json
new file mode 100644
index 0000000..ec0cd0e
--- /dev/null
+++ b/src/support/acp.json
@@ -0,0 +1,89 @@
+{
+ "name": "acp",
+ "kind": "protocol",
+ "title": "ACP",
+ "status": "experimental",
+ "role": "Checkout API that forwards checkout operations to the merchant, whose payment handler receives payment_data. Gateway checkout routes are free and carry no x402 or MPP payment.",
+ "subset": "discovery and the five checkout operations",
+ "spec": {
+ "revisions": ["2026-04-17"],
+ "display": "stable snapshot `2026-04-17`; REST binding",
+ "source": {
+ "repo": "agentic-commerce-protocol/agentic-commerce-protocol",
+ "commit": "6b828681206f1f98a3faba978610ced66770d2ae"
+ },
+ "stable": false,
+ "statement": "currently in `beta`",
+ "checked": "2026-11-17"
+ },
+ "packages": [],
+ "artifacts": [
+ {
+ "path": "src/protocols/acp/spec/2026-04-17/schema.agentic_checkout.json",
+ "revision": "6b828681206f1f98a3faba978610ced66770d2ae"
+ },
+ {
+ "path": "tests/fixtures/acp/2026-04-17",
+ "revision": "6b828681206f1f98a3faba978610ced66770d2ae"
+ }
+ ],
+ "features": [
+ { "name": "rest transport", "status": "experimental" },
+ { "name": "well-known discovery", "status": "experimental" },
+ { "name": "bearer authentication", "status": "experimental" },
+ { "name": "API-Version enforcement", "status": "experimental" },
+ { "name": "request header forwarding to the merchant", "status": "experimental" },
+ { "name": "checkout service", "status": "experimental" },
+ { "name": "createCheckoutSession", "status": "experimental" },
+ { "name": "updateCheckoutSession", "status": "experimental" },
+ { "name": "getCheckoutSession", "status": "experimental" },
+ { "name": "completeCheckoutSession", "status": "experimental" },
+ { "name": "cancelCheckoutSession", "status": "experimental" }
+ ],
+ "exclusions": [
+ {
+ "name": "carts service",
+ "note": "The discovery document advertises only the checkout service."
+ },
+ { "name": "feed service" },
+ { "name": "standalone orders service" },
+ { "name": "delegate_payment" },
+ { "name": "delegate_authentication" },
+ { "name": "ACP MCP transport binding" },
+ { "name": "webhooks", "note": "The merchant backend sends ACP order webhooks itself." },
+ { "name": "outbound merchant-to-agent delivery" },
+ { "name": "ACP client role" },
+ {
+ "name": "Signature header verification",
+ "note": "The adapter forwards the header to the merchant unverified."
+ },
+ {
+ "name": "Timestamp replay-window verification",
+ "note": "The adapter forwards the header to the merchant unverified."
+ },
+ { "name": "discount extension" },
+ { "name": "general ACP extension framework" },
+ { "name": "multiple ACP API versions" },
+ { "name": "seller-backed payment handler integration" }
+ ],
+ "deviations": [
+ {
+ "summary": "After a merchant 5xx, retrying the same Idempotency-Key returns 409 idempotency_unresolved unless protocols.acp.idempotency.merchantIdempotent is true. The merchant may have acted, so another execution could duplicate the order.",
+ "spec": "ACP RFC §6.5",
+ "tests": ["tests/conformance/acp/idempotency.test.ts", "tests/conformance/acp/errors.test.ts"]
+ }
+ ],
+ "conformance": {
+ "suite": "Our tests against the vendored schema and official examples; ACP publishes no conformance suite.",
+ "tests": [
+ "tests/conformance/acp/checkout.test.ts",
+ "tests/conformance/acp/errors.test.ts",
+ "tests/conformance/acp/idempotency.test.ts",
+ "tests/conformance/acp/protocol.test.ts",
+ "tests/conformance/acp/snapshot.test.ts"
+ ],
+ "skipped": []
+ },
+ "gaps": [],
+ "docs": ["docs/protocols/acp.md"]
+}
diff --git a/src/support/ap2.json b/src/support/ap2.json
new file mode 100644
index 0000000..cb00fc7
--- /dev/null
+++ b/src/support/ap2.json
@@ -0,0 +1,88 @@
+{
+ "name": "ap2",
+ "kind": "authorization",
+ "title": "AP2",
+ "status": "experimental",
+ "role": "Authorization method, not a payment rail: a paid resource can require a verified mandate in addition to its x402 or MPP payment, never instead of it.",
+ "subset": "closed Checkout Mandate verification before settlement",
+ "spec": {
+ "revisions": ["v0.2.0"],
+ "display": "v0.2.0, tag 2026-04-28, commit `b4587ac`; Direct mode",
+ "source": {
+ "repo": "google-agentic-commerce/AP2",
+ "commit": "b4587ac1d055888a73b4b21750973cffba961793"
+ },
+ "stable": false,
+ "statement": "Standardization of the specification will continue within the Agentic Authentication Technical and Payments Technical Working Groups in FIDO",
+ "checked": "2026-11-17"
+ },
+ "packages": [
+ { "name": "jose", "use": "runtime" },
+ { "name": "@sd-jwt/core", "use": "runtime" },
+ { "name": "canonicalize", "use": "runtime" }
+ ],
+ "artifacts": [
+ {
+ "path": "tests/fixtures/ap2/v0.2.0",
+ "revision": "b4587ac1d055888a73b4b21750973cffba961793"
+ }
+ ],
+ "features": [
+ { "name": "direct-mode", "status": "experimental" },
+ { "name": "trusted-agent-provider", "status": "experimental" },
+ { "name": "mandate.checkout.1", "status": "experimental" },
+ { "name": "sd-jwt-presentation", "status": "experimental" },
+ { "name": "ES256", "status": "experimental" },
+ { "name": "sha-256", "status": "experimental" },
+ { "name": "static-inline-trust", "status": "experimental" },
+ { "name": "merchant-checkout-jwt-binding", "status": "experimental" },
+ { "name": "agent-commerce/ap2/checkout/v1", "status": "experimental" },
+ { "name": "purchase-binding", "status": "experimental" },
+ { "name": "replay-defence", "status": "experimental" }
+ ],
+ "exclusions": [
+ { "name": "autonomous mode" },
+ {
+ "name": "open checkout mandates (mandate.checkout.open.1)",
+ "note": "Rejected because the provider does not evaluate spending constraints."
+ },
+ { "name": "payment mandates (mandate.payment.1)" },
+ { "name": "spending constraint evaluation" },
+ { "name": "cnf-bound agent keys" },
+ { "name": "user credential delegation (OpenID4VP)" },
+ { "name": "delegation chains and key-binding JWTs" },
+ {
+ "name": "JWKS and any key discovery by URL (jku, x5u)",
+ "note": "Operators supply all keys in config."
+ },
+ { "name": "issuer metadata fetching" },
+ { "name": "remote revocation" },
+ { "name": "key rotation without a config change" },
+ { "name": "signature algorithms other than ES256" },
+ { "name": "digest algorithms other than sha-256" },
+ { "name": "mandate issuance" },
+ { "name": "checkout receipts" },
+ {
+ "name": "AP2 transport adapter or /.well-known/ap2",
+ "note": "HTTP, MCP and A2A carry the mandate in the gateway's own carriers; AP2 v0.2.0 defines none."
+ },
+ { "name": "AP2 as a payment rail" },
+ { "name": "AP2 over the ACP checkout adapter" }
+ ],
+ "deviations": [],
+ "conformance": {
+ "suite": "Tests using mandates minted by the AP2 v0.2.0 reference SDK, plus end-to-end refusal cases.",
+ "tests": [
+ "tests/unit/authorization-ap2/sdk-vectors.test.ts",
+ "tests/integration/ap2-x402-conformance.test.ts"
+ ],
+ "skipped": []
+ },
+ "gaps": [
+ {
+ "requirement": "Return a Checkout Receipt once the merchant has accepted or rejected a Checkout Mandate",
+ "state": "open"
+ }
+ ],
+ "docs": ["docs/protocols/ap2.md"]
+}
diff --git a/src/support/claims.ts b/src/support/claims.ts
new file mode 100644
index 0000000..7589252
--- /dev/null
+++ b/src/support/claims.ts
@@ -0,0 +1,34 @@
+/**
+ * Read support status, feature status and exclusion names for descriptors,
+ * discovery and `doctor`, without loading external packages.
+ * `scripts/support-record.ts` validates records in tests and tooling; runtime
+ * readers trust them.
+ */
+import { CommerceError } from '../core/errors';
+
+/** The fields of a support record that runtime code reads */
+export interface SupportClaims {
+ readonly status: string;
+ readonly features: readonly { readonly name: string; readonly status: string }[];
+ readonly exclusions: readonly { readonly name: string }[];
+}
+
+export type FeatureStatus = 'supported' | 'experimental' | 'partial';
+
+/** Maps `supported` to `stable` without changing the descriptor's status union */
+export function descriptorStatus(record: SupportClaims): 'stable' | 'experimental' {
+ return record.status === 'supported' ? 'stable' : 'experimental';
+}
+
+/** The strings a descriptor publishes in `unsupported` */
+export function exclusionNames(record: SupportClaims): readonly string[] {
+ return record.exclusions.map((exclusion) => exclusion.name);
+}
+
+export function featureStatus(record: SupportClaims, name: string): FeatureStatus {
+ const feature = record.features.find((candidate) => candidate.name === name);
+ if (feature === undefined) {
+ throw new CommerceError('INTERNAL_ERROR', `support record has no feature "${name}"`);
+ }
+ return feature.status as FeatureStatus;
+}
diff --git a/src/support/http.json b/src/support/http.json
new file mode 100644
index 0000000..f14cca7
--- /dev/null
+++ b/src/support/http.json
@@ -0,0 +1,15 @@
+{
+ "name": "http",
+ "kind": "protocol",
+ "title": "HTTP",
+ "status": "supported",
+ "role": "Transport that carries x402 and MPP payments on each resource's invoke route.",
+ "subset": "resource routes and rail-specific payment headers",
+ "packages": [],
+ "artifacts": [],
+ "features": [],
+ "exclusions": [],
+ "deviations": [],
+ "gaps": [],
+ "docs": ["docs/protocols/http.md"]
+}
diff --git a/src/support/mcp.json b/src/support/mcp.json
new file mode 100644
index 0000000..effa603
--- /dev/null
+++ b/src/support/mcp.json
@@ -0,0 +1,68 @@
+{
+ "name": "mcp",
+ "kind": "protocol",
+ "title": "MCP",
+ "status": "supported",
+ "role": "Transport that carries x402 and MPP payments in tool calls.",
+ "subset": "tool discovery, invocation, payment-required and error mapping",
+ "spec": {
+ "revisions": ["2026-07-28", "2025-11-25"],
+ "display": "MCP `2026-07-28` and `2025-11-25`",
+ "source": {
+ "repo": "modelcontextprotocol/modelcontextprotocol",
+ "commit": "05aeb07b2db0c02adc4813a7c09f208ca8774152"
+ },
+ "stable": true,
+ "statement": "Current: the current protocol version, which is ready for use and may continue to receive backwards compatible changes",
+ "checked": "2026-11-17"
+ },
+ "packages": [
+ { "name": "@modelcontextprotocol/server", "use": "runtime" },
+ { "name": "@modelcontextprotocol/client", "use": "test" },
+ { "name": "@modelcontextprotocol/sdk", "use": "test" }
+ ],
+ "artifacts": [],
+ "features": [
+ { "name": "tools/list", "status": "supported" },
+ { "name": "tools/call", "status": "supported" }
+ ],
+ "exclusions": [
+ { "name": "resources" },
+ { "name": "prompts" },
+ { "name": "sampling" },
+ { "name": "completions" },
+ { "name": "elicitation" },
+ { "name": "roots" },
+ { "name": "logging" },
+ { "name": "notifications/tools/list_changed" },
+ { "name": "tasks" },
+ {
+ "name": "dns-rebinding-protection",
+ "note": "The adapter relies on the gateway's onRequest hook to validate Host and Origin for the MCP mount."
+ },
+ { "name": "authorization" },
+ { "name": "sessions" },
+ { "name": "subscriptions" },
+ { "name": "pagination" },
+ { "name": "HTTP+SSE transport" },
+ {
+ "name": "MPP payment-required as JSON-RPC error -32042",
+ "note": "mppx reads challenges from the tool result's _meta."
+ },
+ {
+ "name": "MPP verification failure as JSON-RPC error -32043",
+ "note": "mppx reads refusals from the tool result's _meta."
+ }
+ ],
+ "deviations": [],
+ "conformance": {
+ "suite": "Specification tests through the v1 and v2 SDK clients.",
+ "tests": [
+ "tests/conformance/mcp/mcp-conformance.test.ts",
+ "tests/conformance/mcp/modern-era.test.ts"
+ ],
+ "skipped": []
+ },
+ "gaps": [],
+ "docs": ["docs/protocols/mcp.md"]
+}
diff --git a/src/support/mpp.json b/src/support/mpp.json
new file mode 100644
index 0000000..ec0525c
--- /dev/null
+++ b/src/support/mpp.json
@@ -0,0 +1,130 @@
+{
+ "name": "mpp",
+ "kind": "payment",
+ "title": "MPP",
+ "status": "experimental",
+ "role": "Payment rail, carried by HTTP, MCP and A2A.",
+ "subset": "`charge`/`evm`/EIP-3009 over HTTP, MCP and A2A",
+ "spec": {
+ "revisions": [
+ "draft-httpauth-payment-01",
+ "draft-payment-intent-charge-00",
+ "draft-evm-charge-00"
+ ],
+ "display": "drafts at `tempoxyz/mpp-specs@806fdb8`",
+ "source": {
+ "repo": "tempoxyz/mpp-specs",
+ "commit": "806fdb8b8c92cda5c84b8660558921b6bbeef7e0"
+ },
+ "stable": false,
+ "statement": "Internet-Drafts are draft documents valid for a maximum of six months and may be updated, replaced, or obsoleted by other documents at any time.",
+ "checked": "2026-11-17"
+ },
+ "packages": [{ "name": "mppx", "use": "runtime" }],
+ "artifacts": [],
+ "features": [
+ { "name": "intent=charge", "status": "experimental" },
+ { "name": "method=evm", "status": "experimental" },
+ { "name": "credential=authorization", "status": "experimental" },
+ { "name": "eip-3009", "status": "experimental" },
+ { "name": "network=eip155:31337", "status": "experimental" },
+ { "name": "network=eip155:84532", "status": "experimental" },
+ { "name": "network=eip155:8453", "status": "experimental" },
+ { "name": "asset=USDC", "status": "experimental" },
+ { "name": "verify-before-settle", "status": "experimental" },
+ { "name": "authorization-flow", "status": "experimental" },
+ { "name": "upfront-flow", "status": "experimental" },
+ { "name": "payment-receipt", "status": "experimental" },
+ { "name": "challenge-digest-binding", "status": "experimental" }
+ ],
+ "exclusions": [
+ { "name": "methods other than evm" },
+ {
+ "name": "credential=permit2",
+ "note": "The profile accepts only the EIP-3009 authorization credential."
+ },
+ { "name": "credential=transaction" },
+ { "name": "credential=hash" },
+ { "name": "splits", "note": "The draft allows splits only with permit2 credentials." },
+ { "name": "intent=subscription" },
+ { "name": "evm sessions", "note": "A separate EVM draft, not an option of charge." },
+ { "name": "discovery extension" }
+ ],
+ "deviations": [
+ {
+ "summary": "The EIP-3009 nonce is keccak256 of JSON.stringify([id, realm]), as mppx 0.13 derives it, not of abi.encodePacked(id, realm); a credential using the draft's nonce fails with wrong_nonce.",
+ "spec": "draft-evm-charge-00",
+ "tests": ["tests/unit/payments-mpp/provider.test.ts"]
+ },
+ {
+ "summary": "Over MCP, payment errors are tool results with isError and the challenges in _meta, not the JSON-RPC errors the draft maps them to (-32042, -32043, -32602 and -32603).",
+ "spec": "draft-payment-transport-mcp-00",
+ "tests": ["tests/integration/mcp-payment-bindings.test.ts"]
+ },
+ {
+ "summary": "An unpaid request that gets a 402 also stores a resource.requested event beside the challenge.",
+ "spec": "draft-httpauth-payment-01 §11.4",
+ "tests": ["tests/unit/core/execution/pipeline.test.ts"]
+ },
+ {
+ "summary": "A credential whose attempt is reserved or settlement-uncertain gets 409 without a fresh challenge, because a second challenge could lead to a second payment.",
+ "spec": "draft-httpauth-payment-01 §4.2; draft-evm-charge-00",
+ "tests": ["tests/integration/mpp-carriers.test.ts"]
+ },
+ {
+ "summary": "With paymentFlow: authorization, the backend runs before the transfer, which the charge intent counts as partial access before payment. The default, upfront, settles first.",
+ "spec": "draft-payment-intent-charge-00",
+ "tests": ["tests/e2e/payment/mpp-settlement.e2e.test.ts"]
+ }
+ ],
+ "combinations": [
+ {
+ "surface": "http",
+ "method": "mpp",
+ "level": "e2e",
+ "evidence": "tests/e2e/payment/mpp-settlement.e2e.test.ts"
+ },
+ {
+ "surface": "http",
+ "method": "mpp",
+ "authorization": "ap2",
+ "level": "e2e",
+ "evidence": "tests/e2e/authorization/ap2-mpp.e2e.test.ts"
+ },
+ {
+ "surface": "mcp",
+ "method": "mpp",
+ "level": "integration",
+ "evidence": "tests/integration/mcp-payment-bindings.test.ts"
+ },
+ {
+ "surface": "a2a",
+ "method": "mpp",
+ "level": "integration",
+ "evidence": "tests/integration/mpp-carriers.test.ts"
+ },
+ {
+ "surface": "http",
+ "method": "mpp",
+ "level": "testnet",
+ "evidence": "tests/testnet/mpp-base-sepolia.smoke.test.ts"
+ },
+ {
+ "surface": "http",
+ "method": "mpp",
+ "level": "mainnet",
+ "evidence": "tests/mainnet/mpp-base.smoke.test.ts"
+ }
+ ],
+ "gaps": [
+ {
+ "requirement": "Each challenge id is single-use (charge intent); two payers can each settle against one challenge",
+ "state": "open"
+ },
+ {
+ "requirement": "Payment-Receipt only after an on-chain receipt with a matching Transfer log; the gateway trusts the facilitator's settle result",
+ "state": "open"
+ }
+ ],
+ "docs": ["docs/protocols/mpp.md"]
+}
diff --git a/src/support/x402.json b/src/support/x402.json
new file mode 100644
index 0000000..5776fcd
--- /dev/null
+++ b/src/support/x402.json
@@ -0,0 +1,127 @@
+{
+ "name": "x402",
+ "kind": "payment",
+ "title": "x402",
+ "status": "supported",
+ "role": "Payment rail, carried by HTTP, MCP and A2A.",
+ "subset": "`exact` on EVM through EIP-3009 or Permit2, on Solana, and on NEAR (partial): challenge, verification, settlement and replay binding",
+ "spec": {
+ "revisions": ["v2"],
+ "display": "x402 v2",
+ "source": {
+ "repo": "x402-foundation/x402",
+ "commit": "51a0664c2b7826e3cb02595481eb6848a1b11815"
+ },
+ "stable": null,
+ "statement": "Protocol Version: 2",
+ "checked": "2026-11-17"
+ },
+ "packages": [
+ { "name": "@x402/core", "use": "runtime" },
+ { "name": "@x402/evm", "use": "runtime" },
+ { "name": "@x402/svm", "use": "runtime" },
+ { "name": "@x402/near", "use": "runtime" },
+ { "name": "@x402/mcp", "use": "test" }
+ ],
+ "artifacts": [],
+ "features": [
+ { "name": "exact-evm", "status": "supported" },
+ { "name": "exact-svm", "status": "supported" },
+ { "name": "exact-near", "status": "partial" },
+ { "name": "local-facilitator", "status": "supported" },
+ { "name": "remote-facilitator", "status": "supported" },
+ { "name": "eip-3009", "status": "supported" },
+ { "name": "permit2", "status": "supported" },
+ { "name": "caip-2", "status": "supported" },
+ { "name": "mode=local", "status": "supported" },
+ { "name": "mode=testnet", "status": "supported" },
+ { "name": "mode=mainnet", "status": "supported" },
+ { "name": "authorization-flow", "status": "supported" },
+ { "name": "upfront-flow", "status": "supported" },
+ { "name": "multiple-offers", "status": "partial" },
+ {
+ "name": "erc-8409-quotes",
+ "status": "experimental",
+ "spec": {
+ "revisions": ["0ee33230"],
+ "display": "draft `SergeevDmitry/ERCs@0ee33230`",
+ "source": {
+ "repo": "SergeevDmitry/ERCs",
+ "commit": "0ee33230ca9f9f41a714382552a47cd860465ca7"
+ },
+ "stable": false,
+ "statement": "status: Draft",
+ "checked": "2026-11-17"
+ }
+ }
+ ],
+ "exclusions": [
+ { "name": "permit2 gas sponsoring extensions" },
+ { "name": "upto scheme" },
+ { "name": "batch-settlement scheme" },
+ { "name": "auth-capture scheme" },
+ {
+ "name": "x402 v1",
+ "note": "A payload declaring an x402Version other than 2 is refused as invalid_x402_version on every carrier."
+ },
+ { "name": "payer-bound quotes", "feature": "erc-8409-quotes" },
+ {
+ "name": "contract quote issuers (ERC-1271, ERC-6492, EIP-7702 delegates)",
+ "feature": "erc-8409-quotes"
+ },
+ {
+ "name": "quote consumption, single-use enforcement or revocation",
+ "feature": "erc-8409-quotes"
+ },
+ { "name": "quote client nonces", "feature": "erc-8409-quotes" },
+ { "name": "quotes for MPP, Solana or NEAR", "feature": "erc-8409-quotes" },
+ {
+ "name": "signed receipts and the x402 offer-receipt extension",
+ "feature": "erc-8409-quotes"
+ },
+ { "name": "remote quote signers and KMS", "feature": "erc-8409-quotes" },
+ { "name": "per-resource quote toggles", "feature": "erc-8409-quotes" }
+ ],
+ "deviations": [],
+ "combinations": [
+ {
+ "surface": "http",
+ "method": "x402",
+ "level": "e2e",
+ "evidence": "tests/e2e/payment/x402-settlement.e2e.test.ts"
+ },
+ {
+ "surface": "a2a",
+ "method": "x402",
+ "level": "e2e",
+ "evidence": "tests/e2e/payment/x402-settlement.e2e.test.ts"
+ },
+ {
+ "surface": "http",
+ "method": "x402",
+ "authorization": "ap2",
+ "level": "e2e",
+ "evidence": "tests/e2e/authorization/ap2-x402.e2e.test.ts"
+ },
+ {
+ "surface": "mcp",
+ "method": "x402",
+ "level": "integration",
+ "evidence": "tests/integration/mcp-payment-bindings.test.ts"
+ },
+ {
+ "surface": "http",
+ "method": "x402",
+ "level": "testnet",
+ "evidence": "tests/testnet/x402.smoke.test.ts"
+ },
+ {
+ "surface": "http",
+ "method": "x402",
+ "level": "mainnet",
+ "evidence": "tests/mainnet/x402.smoke.test.ts"
+ }
+ ],
+ "gaps": [],
+ "docs": ["docs/protocols/x402.md"]
+}
diff --git a/tests/integration/goldens/2.7.2/doctor-multi.json b/tests/integration/goldens/2.7.2/doctor-multi.json
index 564c6e7..0c1d718 100644
--- a/tests/integration/goldens/2.7.2/doctor-multi.json
+++ b/tests/integration/goldens/2.7.2/doctor-multi.json
@@ -28,7 +28,7 @@
{
"name": "A2A unsupported",
"status": "INFO",
- "detail": "SendStreamingMessage, GetTask, ListTasks, CancelTask, SubscribeToTask, CreateTaskPushNotificationConfig, GetTaskPushNotificationConfig, ListTaskPushNotificationConfigs, DeleteTaskPushNotificationConfig, GetExtendedAgentCard, HTTP+JSON/REST binding, gRPC binding, SSE, long-running task persistence, task resumption other than an x402 extension payment, push notifications, multi-turn conversational continuation, authenticated extended agent cards, A2A authentication schemes, artifact types beyond Agent Commerce outcome data, x402 extension payments across gateway instances"
+ "detail": "SendStreamingMessage, GetTask, ListTasks, CancelTask, SubscribeToTask, CreateTaskPushNotificationConfig, GetTaskPushNotificationConfig, ListTaskPushNotificationConfigs, DeleteTaskPushNotificationConfig, GetExtendedAgentCard, HTTP+JSON/REST binding, gRPC binding, SSE, long-running task persistence, task resumption other than an x402 extension payment, push notifications, multi-turn conversational continuation, text parts, file and URL parts (including inline bytes), multi-part messages, message roles other than ROLE_USER, authenticated extended agent cards, A2A authentication schemes, artifact types beyond Agent Commerce outcome data, x402 extension payments across gateway instances"
},
{
"name": "ACP",
@@ -78,7 +78,7 @@
{
"name": "AP2 unsupported",
"status": "INFO",
- "detail": "autonomous mode, open checkout mandates (mandate.checkout.open.1), payment mandates (mandate.payment.1), spending constraint evaluation, cnf-bound agent keys, user credential delegation (OpenID4VP), delegation chains and key-binding JWTs, JWKS and any key discovery by URL (jku, x5u), issuer metadata fetching, key rotation without a config change, signature algorithms other than ES256, digest algorithms other than sha-256, mandate issuance, checkout receipts, AP2 over the ACP checkout adapter"
+ "detail": "autonomous mode, open checkout mandates (mandate.checkout.open.1), payment mandates (mandate.payment.1), spending constraint evaluation, cnf-bound agent keys, user credential delegation (OpenID4VP), delegation chains and key-binding JWTs, JWKS and any key discovery by URL (jku, x5u), issuer metadata fetching, remote revocation, key rotation without a config change, signature algorithms other than ES256, digest algorithms other than sha-256, mandate issuance, checkout receipts, AP2 transport adapter or /.well-known/ap2, AP2 as a payment rail, AP2 over the ACP checkout adapter"
},
{
"name": "Payments",
diff --git a/tests/integration/goldens/2.7.2/doctor-single.json b/tests/integration/goldens/2.7.2/doctor-single.json
index 2901a3d..d02f3e6 100644
--- a/tests/integration/goldens/2.7.2/doctor-single.json
+++ b/tests/integration/goldens/2.7.2/doctor-single.json
@@ -28,7 +28,7 @@
{
"name": "A2A unsupported",
"status": "INFO",
- "detail": "SendStreamingMessage, GetTask, ListTasks, CancelTask, SubscribeToTask, CreateTaskPushNotificationConfig, GetTaskPushNotificationConfig, ListTaskPushNotificationConfigs, DeleteTaskPushNotificationConfig, GetExtendedAgentCard, HTTP+JSON/REST binding, gRPC binding, SSE, long-running task persistence, task resumption other than an x402 extension payment, push notifications, multi-turn conversational continuation, authenticated extended agent cards, A2A authentication schemes, artifact types beyond Agent Commerce outcome data, x402 extension payments across gateway instances"
+ "detail": "SendStreamingMessage, GetTask, ListTasks, CancelTask, SubscribeToTask, CreateTaskPushNotificationConfig, GetTaskPushNotificationConfig, ListTaskPushNotificationConfigs, DeleteTaskPushNotificationConfig, GetExtendedAgentCard, HTTP+JSON/REST binding, gRPC binding, SSE, long-running task persistence, task resumption other than an x402 extension payment, push notifications, multi-turn conversational continuation, text parts, file and URL parts (including inline bytes), multi-part messages, message roles other than ROLE_USER, authenticated extended agent cards, A2A authentication schemes, artifact types beyond Agent Commerce outcome data, x402 extension payments across gateway instances"
},
{
"name": "ACP",
@@ -78,7 +78,7 @@
{
"name": "AP2 unsupported",
"status": "INFO",
- "detail": "autonomous mode, open checkout mandates (mandate.checkout.open.1), payment mandates (mandate.payment.1), spending constraint evaluation, cnf-bound agent keys, user credential delegation (OpenID4VP), delegation chains and key-binding JWTs, JWKS and any key discovery by URL (jku, x5u), issuer metadata fetching, key rotation without a config change, signature algorithms other than ES256, digest algorithms other than sha-256, mandate issuance, checkout receipts, AP2 over the ACP checkout adapter"
+ "detail": "autonomous mode, open checkout mandates (mandate.checkout.open.1), payment mandates (mandate.payment.1), spending constraint evaluation, cnf-bound agent keys, user credential delegation (OpenID4VP), delegation chains and key-binding JWTs, JWKS and any key discovery by URL (jku, x5u), issuer metadata fetching, remote revocation, key rotation without a config change, signature algorithms other than ES256, digest algorithms other than sha-256, mandate issuance, checkout receipts, AP2 transport adapter or /.well-known/ap2, AP2 as a payment rail, AP2 over the ACP checkout adapter"
},
{
"name": "Payments",
diff --git a/tests/integration/goldens/2.7.2/well-known-multi.json b/tests/integration/goldens/2.7.2/well-known-multi.json
index 9a3415e..7462b21 100644
--- a/tests/integration/goldens/2.7.2/well-known-multi.json
+++ b/tests/integration/goldens/2.7.2/well-known-multi.json
@@ -90,6 +90,10 @@
"task resumption other than an x402 extension payment",
"push notifications",
"multi-turn conversational continuation",
+ "text parts",
+ "file and URL parts (including inline bytes)",
+ "multi-part messages",
+ "message roles other than ROLE_USER",
"authenticated extended agent cards",
"A2A authentication schemes",
"artifact types beyond Agent Commerce outcome data",
@@ -164,7 +168,16 @@
"permit2 gas sponsoring extensions",
"upto scheme",
"batch-settlement scheme",
- "auth-capture scheme"
+ "auth-capture scheme",
+ "x402 v1",
+ "payer-bound quotes",
+ "contract quote issuers (ERC-1271, ERC-6492, EIP-7702 delegates)",
+ "quote consumption, single-use enforcement or revocation",
+ "quote client nonces",
+ "quotes for MPP, Solana or NEAR",
+ "signed receipts and the x402 offer-receipt extension",
+ "remote quote signers and KMS",
+ "per-resource quote toggles"
]
},
{
@@ -230,11 +243,14 @@
"delegation chains and key-binding JWTs",
"JWKS and any key discovery by URL (jku, x5u)",
"issuer metadata fetching",
+ "remote revocation",
"key rotation without a config change",
"signature algorithms other than ES256",
"digest algorithms other than sha-256",
"mandate issuance",
"checkout receipts",
+ "AP2 transport adapter or /.well-known/ap2",
+ "AP2 as a payment rail",
"AP2 over the ACP checkout adapter"
]
}
diff --git a/tests/integration/goldens/2.7.2/well-known-single.json b/tests/integration/goldens/2.7.2/well-known-single.json
index e64b53f..277a502 100644
--- a/tests/integration/goldens/2.7.2/well-known-single.json
+++ b/tests/integration/goldens/2.7.2/well-known-single.json
@@ -90,6 +90,10 @@
"task resumption other than an x402 extension payment",
"push notifications",
"multi-turn conversational continuation",
+ "text parts",
+ "file and URL parts (including inline bytes)",
+ "multi-part messages",
+ "message roles other than ROLE_USER",
"authenticated extended agent cards",
"A2A authentication schemes",
"artifact types beyond Agent Commerce outcome data",
@@ -162,7 +166,16 @@
"permit2 gas sponsoring extensions",
"upto scheme",
"batch-settlement scheme",
- "auth-capture scheme"
+ "auth-capture scheme",
+ "x402 v1",
+ "payer-bound quotes",
+ "contract quote issuers (ERC-1271, ERC-6492, EIP-7702 delegates)",
+ "quote consumption, single-use enforcement or revocation",
+ "quote client nonces",
+ "quotes for MPP, Solana or NEAR",
+ "signed receipts and the x402 offer-receipt extension",
+ "remote quote signers and KMS",
+ "per-resource quote toggles"
]
},
{
@@ -228,11 +241,14 @@
"delegation chains and key-binding JWTs",
"JWKS and any key discovery by URL (jku, x5u)",
"issuer metadata fetching",
+ "remote revocation",
"key rotation without a config change",
"signature algorithms other than ES256",
"digest algorithms other than sha-256",
"mandate issuance",
"checkout receipts",
+ "AP2 transport adapter or /.well-known/ap2",
+ "AP2 as a payment rail",
"AP2 over the ACP checkout adapter"
]
}
diff --git a/tests/integration/support-record.test.ts b/tests/integration/support-record.test.ts
new file mode 100644
index 0000000..481fdf4
--- /dev/null
+++ b/tests/integration/support-record.test.ts
@@ -0,0 +1,212 @@
+/**
+ * Check support records against the descriptors that publish their claims.
+ * Descriptors derive status and unsupported features from the records; these
+ * tests also compare capabilities and revisions with their values in code.
+ */
+import { existsSync, readdirSync } from 'node:fs';
+import { join } from 'node:path';
+import { LATEST_PROTOCOL_VERSION } from '@modelcontextprotocol/server';
+import { describe, expect, expectTypeOf, it } from 'vitest';
+import {
+ citedPaths,
+ REPO_ROOT,
+ readSupportRecord,
+ SUPPORT_RECORD_NAMES,
+ type SupportRecord,
+ type SupportRecordName,
+} from '../../scripts/support-record';
+import { AP2_CAPABILITIES, AP2_UNSUPPORTED } from '../../src/ap2';
+import { AP2_SPEC_VERSION } from '../../src/authorization/ap2/constants';
+import { buildAp2Descriptor } from '../../src/authorization/ap2/descriptor';
+import { parseConfig } from '../../src/config';
+import { type AdapterDescriptor, NOOP_LOGGER } from '../../src/core';
+import { createConfiguredPaymentProviders } from '../../src/gateway/payment-providers';
+import { MPP_DESCRIPTOR } from '../../src/mpp';
+import { MPP_SPEC_COMMIT, MPP_SPEC_DRAFTS } from '../../src/payments/mpp/constants';
+import { X402_VERSION } from '../../src/payments/x402/provider/constants';
+import { A2A_SPEC_VERSION, A2A_UNSUPPORTED_METHODS } from '../../src/protocols/a2a/constants';
+import { buildDescriptor as buildA2aDescriptor } from '../../src/protocols/a2a/descriptor';
+import { ACP_SPEC_VERSION } from '../../src/protocols/acp/constants';
+import { buildDescriptor as buildAcpDescriptor } from '../../src/protocols/acp/descriptor';
+import { MCP_MODERN_PROTOCOL_REVISION } from '../../src/protocols/mcp/constants';
+import { buildDescriptor as buildMcpDescriptor } from '../../src/protocols/mcp/descriptor';
+
+const records = Object.fromEntries(
+ SUPPORT_RECORD_NAMES.map((name) => [name, readSupportRecord(name)]),
+) as Record;
+
+const featureNames = (record: SupportRecord) => record.features.map((feature) => feature.name);
+const exclusionNames = (record: SupportRecord) => record.exclusions.map((entry) => entry.name);
+const descriptorStatus = (record: SupportRecord) =>
+ record.status === 'supported' ? 'stable' : 'experimental';
+
+describe('support records', () => {
+ it('holds exactly one valid record per shipped profile, each named after its file', () => {
+ const files = readdirSync(join(REPO_ROOT, 'src/support'))
+ .filter((file) => file.endsWith('.json'))
+ .map((file) => file.slice(0, -'.json'.length))
+ .sort();
+ expect(files).toEqual([...SUPPORT_RECORD_NAMES].sort());
+ for (const name of SUPPORT_RECORD_NAMES) expect(records[name].name).toBe(name);
+ });
+
+ it('cites only evidence and documentation files that exist', () => {
+ const missing = SUPPORT_RECORD_NAMES.flatMap((name) =>
+ citedPaths(records[name])
+ .filter((path) => !existsSync(join(REPO_ROOT, path)))
+ .map((path) => `src/support/${name}.json: ${path}`),
+ );
+ expect(missing).toEqual([]);
+ });
+
+ it('lists tested combinations on the payment records only', () => {
+ expect(SUPPORT_RECORD_NAMES.filter((name) => records[name].combinations !== undefined)).toEqual(
+ ['x402', 'mpp'],
+ );
+ });
+});
+
+describe('descriptors publish their record', () => {
+ const cases: [SupportRecordName, AdapterDescriptor][] = [
+ ['mcp', buildMcpDescriptor('test')],
+ ['a2a', buildA2aDescriptor('test')],
+ ['acp', buildAcpDescriptor('test')],
+ ['ap2', buildAp2Descriptor('test')],
+ ['mpp', MPP_DESCRIPTOR],
+ ];
+
+ it.each(cases)('%s: status, unsupported, capabilities and revision', (name, descriptor) => {
+ const record = records[name];
+ expect(descriptor.status).toBe(descriptorStatus(record));
+ expect(descriptor.unsupported).toEqual(exclusionNames(record));
+ expect(descriptor.capabilities).toEqual(featureNames(record));
+ expect(descriptor.supportedSpec).toContain(record.spec?.revisions[0]);
+ });
+
+ it('a2a: the record excludes every method the transport refuses', () => {
+ expect(exclusionNames(records.a2a)).toEqual(
+ expect.arrayContaining([...A2A_UNSUPPORTED_METHODS]),
+ );
+ });
+});
+
+// LOCAL DEVELOPMENT ONLY - DO NOT FUND: Anvil accounts 1 and 3
+const LOCAL_SIGNER = '0x59c6995e998f97a5a0044966f0945389dc9e86dae88c7a8412f4603b6b78690d';
+const QUOTE_SIGNER = '0x7c852118294e51e653712a81e05800f419141751be58f605c371e15141b007a6';
+const MERCHANT = '0x1111111111111111111111111111111111111111';
+const REMOTE = { mode: 'remote', url: 'https://facilitator.example', auth: { type: 'none' } };
+
+// These configurations collectively enable every recorded x402 capability
+const X402_MATRIX: Record> = {
+ 'local chain, in-process facilitator': {
+ network: 'eip155:31337',
+ rpcUrl: 'http://127.0.0.1:8545',
+ asset: '0x5FbDB2315678afecb367f032d93F642f64180aa3',
+ assetName: 'MockUSDC',
+ assetVersion: '2',
+ assetDecimals: 6,
+ payTo: MERCHANT,
+ facilitator: { mode: 'local', signerPrivateKey: LOCAL_SIGNER },
+ },
+ 'public testnets, several offers and families, quotes': {
+ networks: {
+ 'eip155:84532': { rpcUrl: 'https://base-sepolia.example' },
+ 'eip155:421614': { rpcUrl: 'https://arbitrum-sepolia.example' },
+ 'solana:EtWTRABZaYq6iMfeYKouRu166VU2xqa1': { rpcUrl: 'https://solana-devnet.example' },
+ 'near:testnet': { rpcUrl: 'https://near-testnet.example' },
+ },
+ options: [
+ { network: 'eip155:84532', payTo: MERCHANT },
+ { network: 'eip155:421614', payTo: MERCHANT, assetTransferMethod: 'permit2' },
+ {
+ network: 'solana:EtWTRABZaYq6iMfeYKouRu166VU2xqa1',
+ payTo: '9WzDXwBbmkg8ZTbNMqUxvQRAyrZzDsGYdLVL9zYtAWWM',
+ },
+ { network: 'near:testnet', payTo: 'merchant.testnet' },
+ ],
+ facilitator: REMOTE,
+ quote: { enabled: true, signerPrivateKey: QUOTE_SIGNER },
+ },
+ 'Base mainnet': {
+ network: 'eip155:8453',
+ rpcUrl: 'https://base-mainnet.example',
+ payTo: MERCHANT,
+ facilitator: REMOTE,
+ allowMainnet: true,
+ allowUnauthenticatedFacilitator: true,
+ },
+};
+
+async function x402Descriptor(x402: Record): Promise {
+ const config = parseConfig(
+ {
+ version: 1,
+ merchant: { id: 'shop', name: 'Shop', publicBaseUrl: 'https://shop.example' },
+ server: { port: 8080, host: '127.0.0.1' },
+ storage: { receipts: { driver: 'sqlite', path: ':memory:' } },
+ protocols: { http: { enabled: true }, mcp: { enabled: false, mountPath: '/mcp' } },
+ resources: {
+ report: {
+ name: 'Report',
+ backend: { type: 'http', method: 'GET', url: 'http://localhost:3000/report' },
+ pricing: { type: 'fixed', amount: '0.01', currency: 'USDC' },
+ expose: ['http'],
+ payments: ['x402'],
+ },
+ },
+ payments: { x402: { enabled: true, maxTimeoutSeconds: 120, ...x402 } },
+ },
+ {},
+ );
+ const [provider] = await createConfiguredPaymentProviders(config.payments, NOOP_LOGGER);
+ if (provider === undefined) throw new Error('no x402 provider was built');
+ return provider.descriptor;
+}
+
+describe('x402 descriptor across the configuration matrix', () => {
+ it('claims only recorded features, and the matrix reaches all of them', async () => {
+ const record = records.x402;
+ const seen = new Set();
+ for (const [label, x402] of Object.entries(X402_MATRIX)) {
+ const descriptor = await x402Descriptor(x402);
+ expect(featureNames(record), label).toEqual(
+ expect.arrayContaining([...descriptor.capabilities]),
+ );
+ expect(descriptor.status, label).toBe(descriptorStatus(record));
+ expect(descriptor.unsupported, label).toEqual(exclusionNames(record));
+ expect(descriptor.supportedSpec, label).toContain(record.spec?.revisions[0]);
+ for (const capability of descriptor.capabilities) seen.add(capability);
+ }
+ expect([...seen].sort()).toEqual(featureNames(record).sort());
+ });
+});
+
+describe('revisions the records restate from code', () => {
+ it('mcp: the modern revision and the SDK latest legacy one', () => {
+ expect(records.mcp.spec?.revisions).toEqual([
+ MCP_MODERN_PROTOCOL_REVISION,
+ LATEST_PROTOCOL_VERSION,
+ ]);
+ });
+
+ it('a2a, acp, ap2 and x402: the pinned revision', () => {
+ expect(records.a2a.spec?.revisions).toEqual([A2A_SPEC_VERSION]);
+ expect(records.acp.spec?.revisions).toEqual([ACP_SPEC_VERSION]);
+ expect(records.ap2.spec?.revisions).toEqual([`v${AP2_SPEC_VERSION}`]);
+ expect(records.x402.spec?.revisions).toEqual([`v${X402_VERSION}`]);
+ });
+
+ it('mpp: the three pinned drafts and their commit', () => {
+ expect(records.mpp.spec?.revisions).toEqual(Object.values(MPP_SPEC_DRAFTS));
+ expect(records.mpp.spec?.source.commit).toBe(MPP_SPEC_COMMIT);
+ });
+});
+
+describe('published exports derived from a record keep their 2.7 types', () => {
+ it('AP2_UNSUPPORTED, AP2_CAPABILITIES and MPP_DESCRIPTOR', () => {
+ // Checked by tsc: a JSON import would otherwise widen or narrow these
+ expectTypeOf(AP2_UNSUPPORTED).toEqualTypeOf();
+ expectTypeOf(AP2_CAPABILITIES).toEqualTypeOf();
+ expectTypeOf(MPP_DESCRIPTOR).toEqualTypeOf();
+ });
+});
diff --git a/tests/mainnet/x402.smoke.test.ts b/tests/mainnet/x402.smoke.test.ts
index 7f6d816..a3da695 100644
--- a/tests/mainnet/x402.smoke.test.ts
+++ b/tests/mainnet/x402.smoke.test.ts
@@ -2,11 +2,11 @@
* x402 settlement on mainnets. **This spends real money.**
*
* Only `npm run test:mainnet` runs it, never CI. Nothing runs unless
- * `X402_SMOKE_TARGETS` names allowlisted targets (`base`, `base-permit2`, `solana`) and
- * `ALLOW_X402_MAINNET=true` is set; each target also needs a funded buyer, a
- * merchant address and an explicit facilitator. The run stops before signing
- * anything when it would exceed its spend cap. The harness lives in
- * tests/fixtures/x402/smoke.
+ * `X402_SMOKE_TARGETS` names allowlisted targets (`base`, `base-permit2`,
+ * `solana`, `near`) and `ALLOW_X402_MAINNET=true` is set. Each target needs a
+ * funded buyer, a merchant address and an explicit facilitator; NEAR can use a
+ * relayer instead. The run stops before signing anything that would exceed
+ * its spend cap. The harness lives in tests/fixtures/x402/smoke.
*/
import { defineSmokeSuite } from '../fixtures/x402/smoke/suite';
diff --git a/tests/unit/deploy/deploy.test.ts b/tests/unit/deploy/deploy.test.ts
index 8d78b0e..12f3f20 100644
--- a/tests/unit/deploy/deploy.test.ts
+++ b/tests/unit/deploy/deploy.test.ts
@@ -122,4 +122,21 @@ describe('deploy/', () => {
expect(version, name).toBe(pkg.peerDependencies[name as string]);
}
});
+
+ it("CI's clean consumer install pins the optional peers package.json declares", () => {
+ const workflow = readFileSync(join(REPO_ROOT, '.github/workflows/ci.yml'), 'utf8');
+ const installs = [...workflow.matchAll(/^\s+npm install ((?:@?[\w./-]+@\d\S* ?)+)$/gm)];
+ expect(installs).toHaveLength(1);
+ const pins = (installs[0]?.[1] ?? '').split(' ').map((spec) => {
+ const at = spec.lastIndexOf('@');
+ return [spec.slice(0, at), spec.slice(at + 1)] as const;
+ });
+ expect(pins.map(([name]) => name)).toEqual([
+ '@modelcontextprotocol/server',
+ '@x402/core',
+ '@x402/evm',
+ 'viem',
+ ]);
+ for (const [name, version] of pins) expect(version, name).toBe(pkg.peerDependencies[name]);
+ });
});
diff --git a/tests/unit/payments-mpp/profile.test.ts b/tests/unit/payments-mpp/profile.test.ts
index 5b09640..ec3cb7a 100644
--- a/tests/unit/payments-mpp/profile.test.ts
+++ b/tests/unit/payments-mpp/profile.test.ts
@@ -29,6 +29,17 @@ describe('pinned MPP profile', () => {
expect(installed.version).toBe(MPPX_VERSION);
});
+ it('pins the mppx version package.json declares, as a peer and for development', () => {
+ // The installed copy can lag package.json until the next install
+ const pkg = JSON.parse(
+ readFileSync(new URL('../../../package.json', import.meta.url), 'utf8'),
+ ) as Record<'peerDependencies' | 'devDependencies', Record>;
+ expect([pkg.peerDependencies['mppx'], pkg.devDependencies['mppx']]).toEqual([
+ MPPX_VERSION,
+ MPPX_VERSION,
+ ]);
+ });
+
it('records a full upstream commit, not a branch or a short sha', () => {
expect(MPP_SPEC_COMMIT).toMatch(/^[0-9a-f]{40}$/);
});
From 1a6d1a0760b96994f61676c9b97aa370b32134ed Mon Sep 17 00:00:00 2001
From: Revinand
Date: Wed, 18 Nov 2026 14:17:17 +0100
Subject: [PATCH 04/14] feat: generate support tables and fail on drift
---
README.md | 32 +-
docs/contributing-adapters.md | 10 +-
docs/protocols.md | 75 +++-
docs/protocols/a2a.md | 52 ++-
docs/protocols/acp.md | 53 ++-
docs/protocols/ap2.md | 59 ++-
docs/protocols/mcp.md | 44 +-
docs/protocols/mpp.md | 61 ++-
docs/protocols/x402.md | 57 ++-
package.json | 1 +
scripts/support-record.ts | 519 ++++++++++++++++++++++-
src/support/a2a.json | 2 +-
src/support/acp.json | 4 +-
src/support/mcp.json | 6 +-
src/support/mpp.json | 12 +-
src/support/x402.json | 7 +-
tests/integration/support-record.test.ts | 197 ++++++++-
17 files changed, 1079 insertions(+), 112 deletions(-)
diff --git a/README.md b/README.md
index ad9f36d..fc75434 100644
--- a/README.md
+++ b/README.md
@@ -8,12 +8,14 @@
+
+
## What it is, in ten seconds
@@ -303,17 +305,22 @@ See [docs/configuration.md](docs/configuration.md).
## Protocol support
-| Protocol | Status | Pinned revision |
-| ------------ | ------------ | ------------------------------------------------------------------------------------------------------------ |
-| **HTTP** | Supported | native routes |
-| **MCP** | Supported | `2026-07-28` and `2025-11-25`, `@modelcontextprotocol/server@2.3.0` |
-| **x402** | Supported | x402 v2 (`@x402/core`, `@x402/evm`, `@x402/svm`, `@x402/near`), scheme `exact`, EVM and Solana; NEAR partial |
-| **MPP** | Experimental | `mppx@0.13.1`, `charge` + `evm` + EIP-3009, USDC on Base Sepolia and Base |
-| **A2A** | Experimental | A2A v1.0.1, binding `JSONRPC`, method `SendMessage`, x402 extension |
-| **ACP** | Experimental | ACP `2026-04-17`, REST checkout + discovery |
-| **AP2** | Experimental | AP2 `v0.2.0`, Direct Checkout Mandate verification |
-| **ERC-8409** | Experimental | draft `SergeevDmitry/ERCs@0ee33230`: signed quotes on x402 EVM offers |
-| UCP | Planned | no implementation |
+
+
+| Protocol | Status | Pinned revision | Implemented subset |
+| ------------ | ------------ | ----------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------ |
+| **HTTP** | Supported | native | resource routes and rail-specific payment headers |
+| **MCP** | Supported | MCP `2026-07-28` and `2025-11-25`; `@modelcontextprotocol/server@2.3.0` | tool discovery, invocation, payment-required and error mapping |
+| **x402** | Supported | x402 v2; `@x402/core@2.30.0`, `@x402/evm@2.30.0`, `@x402/svm@2.30.0`, `@x402/near@2.30.0` | `exact` on EVM through EIP-3009 or Permit2, on Solana, and on NEAR (partial): challenge, verification, settlement and replay binding |
+| **MPP** | Experimental | drafts at `tempoxyz/mpp-specs@806fdb8`; `mppx@0.13.1` | `charge`/`evm`/EIP-3009 with USDC on Base Sepolia and Base, over HTTP, MCP and A2A |
+| **A2A** | Experimental | v1.0.1; negotiation `1.0`; `JSONRPC` binding | Agent Card, `SendMessage`, paid flow and the x402 extension |
+| **ACP** | Experimental | stable snapshot `2026-04-17`; REST binding | discovery and the five checkout operations |
+| **AP2** | Experimental | v0.2.0, tag 2026-04-28, commit `b4587ac`; Direct mode; `jose@6.2.12`, `@sd-jwt/core@0.20.1`, `canonicalize@5.0.0` | closed Checkout Mandate verification before settlement |
+| **ERC-8409** | Experimental | draft `SergeevDmitry/ERCs@0ee33230` | signed quotes on x402 EVM offers; issuer published in `/.well-known/agent-commerce` |
+
+
+
+UCP is planned and has no implementation.
[AP2](docs/protocols/ap2.md) is an authorization method, not a transport. It verifies a
mandate before a paid resource settles; the gateway does not issue the mandate
@@ -339,6 +346,9 @@ MPP, A2A, ACP, AP2, ERC-8409 quotes, `agent-commerce import openapi`,
2.6.0, the `idempotency` resource settings with the store and provider methods
added in 2.7.0, and the `./testing` entry.
+A profile moves from experimental to supported only when it meets the
+[promotion criteria](docs/protocols.md#promotion-criteria).
+
The journal's `Transaction` type, `ReceiptStore` journal methods and
`/api/transactions` response shape are supported. The `transactionId` fields,
`receiptCommitted` and flags accepted by `reconcile` and `resolve` are also
diff --git a/docs/contributing-adapters.md b/docs/contributing-adapters.md
index c0a7cb0..fa309ca 100644
--- a/docs/contributing-adapters.md
+++ b/docs/contributing-adapters.md
@@ -31,9 +31,13 @@ A new name crosses the public contract and runtime wiring. After approval:
5. If it has distinct optional dependencies, add the narrow subpath, build
entry, package export, optional peer and the real-package check in
`tests/unit/cli/packaging.test.ts`.
-6. Add a support record under `src/support/`, a descriptor, and discovery and
- `doctor` output. Update the frozen contract and conformance coverage. Add a
- page under `docs/protocols/` and list it in [protocols.md](protocols.md).
+6. Add a support record under `src/support/` and its name to
+ `SUPPORT_RECORD_NAMES` in `scripts/support-record.ts`. Add a descriptor,
+ and discovery and `doctor` output. Update the frozen contract and
+ conformance coverage. Add a page under `docs/protocols/` with the region
+ markers its record needs, list it in [protocols.md](protocols.md), and run
+ `npm run support:write`. `tests/integration/support-record.test.ts` names
+ any region that is missing or out of date.
## Protocol adapters
diff --git a/docs/protocols.md b/docs/protocols.md
index e64e7a9..d75f726 100644
--- a/docs/protocols.md
+++ b/docs/protocols.md
@@ -5,20 +5,23 @@ subset. Each protocol's page describes that subset in detail.
## Support matrix
-| Protocol | Status | Revision | Implemented subset |
-| ------------ | ------------ | ----------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------ |
-| **HTTP** | Supported | native | resource routes and rail-specific payment headers |
-| **MCP** | Supported | MCP `2026-07-28` and `2025-11-25` through `@modelcontextprotocol/server@2.3.0` | tool discovery, invocation, payment-required and error mapping |
-| **x402** | Supported | x402 v2, `@x402/core@2.30.0`, `@x402/evm@2.30.0`, `@x402/svm@2.30.0`, `@x402/near@2.30.0` | `exact` on EVM through EIP-3009 or Permit2, on Solana, and on NEAR (partial): challenge, verification, settlement and replay binding |
-| **A2A** | Experimental | v1.0.1; negotiation `1.0`; `JSONRPC` binding | Agent Card, `SendMessage`, paid flow and the x402 extension |
-| **ACP** | Experimental | stable snapshot `2026-04-17`; REST binding | discovery and the five checkout operations |
-| **AP2** | Experimental | v0.2.0, tag 2026-04-28, commit `b4587ac`; Direct mode | closed Checkout Mandate verification before settlement |
-| **MPP** | Experimental | drafts at `tempoxyz/mpp-specs@806fdb8`; `mppx@0.13.1` | `charge`/`evm`/EIP-3009 over HTTP, MCP and A2A |
-| **ERC-8409** | Experimental | draft `SergeevDmitry/ERCs@0ee33230` | signed quotes on x402 EVM offers; issuer published in `/.well-known/agent-commerce` |
-| UCP | Planned | - | no implementation |
+
+
+| Protocol | Status | Role | Revision | Implemented subset |
+| ------------ | ------------ | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------ |
+| **HTTP** | Supported | Transport that carries x402 and MPP payments on each resource's invoke route. | native | resource routes and rail-specific payment headers |
+| **MCP** | Supported | Transport that carries x402 and MPP payments in tool calls. | MCP `2026-07-28` and `2025-11-25`; `@modelcontextprotocol/server@2.3.0` | tool discovery, invocation, payment-required and error mapping |
+| **x402** | Supported | Payment rail, carried by HTTP, MCP and A2A. | x402 v2; `@x402/core@2.30.0`, `@x402/evm@2.30.0`, `@x402/svm@2.30.0`, `@x402/near@2.30.0` | `exact` on EVM through EIP-3009 or Permit2, on Solana, and on NEAR (partial): challenge, verification, settlement and replay binding |
+| **MPP** | Experimental | Payment rail, carried by HTTP, MCP and A2A. | drafts at `tempoxyz/mpp-specs@806fdb8`; `mppx@0.13.1` | `charge`/`evm`/EIP-3009 with USDC on Base Sepolia and Base, over HTTP, MCP and A2A |
+| **A2A** | Experimental | Transport that carries x402 and MPP payments in `SendMessage`, including through the x402 extension. | v1.0.1; negotiation `1.0`; `JSONRPC` binding | Agent Card, `SendMessage`, paid flow and the x402 extension |
+| **ACP** | Experimental | Checkout API that forwards checkout operations to the merchant, whose payment handler receives `payment_data`. Gateway checkout routes are free and carry no x402 or MPP payment. | stable snapshot `2026-04-17`; REST binding | discovery and the five checkout operations |
+| **AP2** | Experimental | Authorization method, not a payment rail: a paid resource can require a verified mandate in addition to its x402 or MPP payment, never instead of it. | v0.2.0, tag 2026-04-28, commit `b4587ac`; Direct mode; `jose@6.2.12`, `@sd-jwt/core@0.20.1`, `canonicalize@5.0.0` | closed Checkout Mandate verification before settlement |
+| **ERC-8409** | Experimental | x402 feature: EIP-712 signed quotes on the EVM offers of a challenge. | draft `SergeevDmitry/ERCs@0ee33230` | signed quotes on x402 EVM offers; issuer published in `/.well-known/agent-commerce` |
+
+
Experimental components are disabled unless configured and support only the
-subsets their pages describe. Planned means there is no adapter or endpoint.
+subsets their pages describe. UCP is planned and has no implementation.
AP2 is an authorization method, not a transport or payment rail. It appears in
`authorizationProviders` in gateway discovery and has no AP2-specific mount or
@@ -32,6 +35,54 @@ and providers, including `supportedSpec`, `capabilities`, `unsupported` and
`status`. When enabled, A2A, ACP and AP2 also print their detailed unsupported
lists in `agent-commerce doctor`.
+## Tested combinations
+
+Each row names the test that covers a rail over a surface. E2E rows settle on
+a local Anvil chain. Integration rows mock the facilitator and run no chain.
+Public testnet and mainnet rows are smoke tests that spend funds and run only
+on the wallet holder's machine, never in CI.
+
+
+
+| Rail | Surface | Authorization | Tested at | Test |
+| ---- | ------- | ------------- | --------------------- | ------------------------------------------------ |
+| x402 | HTTP | - | E2E, local chain | `tests/e2e/payment/x402-settlement.e2e.test.ts` |
+| x402 | A2A | - | E2E, local chain | `tests/e2e/payment/x402-settlement.e2e.test.ts` |
+| x402 | HTTP | AP2 | E2E, local chain | `tests/e2e/authorization/ap2-x402.e2e.test.ts` |
+| x402 | MCP | - | integration, no chain | `tests/integration/mcp-payment-bindings.test.ts` |
+| x402 | HTTP | - | public testnet | `tests/testnet/x402.smoke.test.ts` |
+| x402 | HTTP | - | mainnet | `tests/mainnet/x402.smoke.test.ts` |
+| MPP | HTTP | - | E2E, local chain | `tests/e2e/payment/mpp-settlement.e2e.test.ts` |
+| MPP | HTTP | AP2 | E2E, local chain | `tests/e2e/authorization/ap2-mpp.e2e.test.ts` |
+| MPP | MCP | - | integration, no chain | `tests/integration/mcp-payment-bindings.test.ts` |
+| MPP | A2A | - | integration, no chain | `tests/integration/mpp-carriers.test.ts` |
+| MPP | HTTP | - | public testnet | `tests/testnet/mpp-base-sepolia.smoke.test.ts` |
+| MPP | HTTP | - | mainnet | `tests/mainnet/mpp-base.smoke.test.ts` |
+
+
+
+## Promotion criteria
+
+A profile moves from experimental to supported when all four criteria hold.
+Each reads fields of the profile's record in `src/support/`:
+
+1. Upstream declares the pinned revision stable (`spec.stable`).
+2. Every MUST-level gap against that revision is closed, or the profile
+ excludes the feature and lists it (`gaps`, `exclusions`).
+3. Conformance evidence exists: the upstream suite where there is one,
+ otherwise our tests against the specification's requirements and examples
+ (`conformance`). Every MUST test that runs passes, and each skipped test is
+ named with its reason. A test that fails only because it contradicts the
+ specification, or assumes an input mode the profile does not declare, is
+ recorded the same way, with the specification section and the upstream
+ report.
+4. Operational docs exist, with crash and replay coverage (`docs`,
+ `combinations`).
+
+"Supported" covers the recorded subset, never the whole specification. HTTP,
+MCP and x402 were supported before 2.8.0 introduced these criteria, and keep
+that status. Upstream does not label x402 v2 stable, and its record says so.
+
## Protocol pages
- [HTTP surface](protocols/http.md): routes, and the payment headers each rail
diff --git a/docs/protocols/a2a.md b/docs/protocols/a2a.md
index 2462668..4d31f54 100644
--- a/docs/protocols/a2a.md
+++ b/docs/protocols/a2a.md
@@ -184,13 +184,55 @@ without an `id` returns `-32600` without running. Each A2A error carries a
`google.rpc.ErrorInfo` in `error.data`, with a reason such as
`VERSION_NOT_SUPPORTED` and the domain `a2a-protocol.org`.
+## Pins
+
+
+
+| Pin | Value |
+| ------------------------ | ------------------------------------------------------------------------------------------------------------ |
+| Pinned revision | v1.0.1; negotiation `1.0`; `JSONRPC` binding |
+| Upstream source | [`a2aproject/A2A@33035925`](https://github.com/a2aproject/A2A/tree/3303592588e388e62e0f69f701af531d2f4e3991) |
+| Declared stable upstream | yes |
+| Upstream wording | "the first stable, production-ready version" (read 2026-11-17) |
+| `@a2a-js/sdk` | `1.3.0`, tests only |
+
+
+
## A2A exclusions
-Unsupported methods are `SendStreamingMessage`, `GetTask`, `ListTasks`,
-`CancelTask`, `SubscribeToTask`, the four task-push-notification-config
-methods and `GetExtendedAgentCard`. The adapter also excludes REST and gRPC
-bindings, SSE, long-running tasks, push delivery, multi-turn continuation,
-authenticated extended cards, A2A authentication and other artifact types.
+The A2A descriptor in `GET /.well-known/agent-commerce` lists these names in
+`unsupported`, and `agent-commerce doctor` prints them when A2A is enabled:
+
+
+
+- `SendStreamingMessage`
+- `GetTask`
+- `ListTasks`
+- `CancelTask`
+- `SubscribeToTask`
+- `CreateTaskPushNotificationConfig`
+- `GetTaskPushNotificationConfig`
+- `ListTaskPushNotificationConfigs`
+- `DeleteTaskPushNotificationConfig`
+- `GetExtendedAgentCard`
+- `HTTP+JSON/REST binding`
+- `gRPC binding`
+- `SSE`
+- `long-running task persistence`
+- `task resumption other than an x402 extension payment`
+- `push notifications`
+- `multi-turn conversational continuation`
+- `text parts`
+- `file and URL parts (including inline bytes)`
+- `multi-part messages`
+- `message roles other than ROLE_USER`
+- `authenticated extended agent cards`
+- `A2A authentication schemes`
+- `artifact types beyond Agent Commerce outcome data`
+- `x402 extension payments across gateway instances`: Instances with separate receipt stores cannot resume each other's tasks.
+
+
+
Only pending x402 payment tasks can be stored and resumed.
The A2A adapter accepts `_payment` but does not verify or settle payments
diff --git a/docs/protocols/acp.md b/docs/protocols/acp.md
index 264e35b..a618ec2 100644
--- a/docs/protocols/acp.md
+++ b/docs/protocols/acp.md
@@ -222,12 +222,57 @@ Discovery is public while ACP is enabled and uses
locale and intervention metadata appears only when configured. Tokens, backend
URLs, resource ids and database paths are excluded.
+## Pins
+
+
+
+| Pin | Value |
+| ---------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
+| Pinned revision | stable snapshot `2026-04-17`; REST binding |
+| Upstream source | [`agentic-commerce-protocol/agentic-commerce-protocol@6b828681`](https://github.com/agentic-commerce-protocol/agentic-commerce-protocol/tree/6b828681206f1f98a3faba978610ced66770d2ae) |
+| Declared stable upstream | no |
+| Upstream wording | "currently in `beta`" (read 2026-11-17) |
+| `src/protocols/acp/spec/2026-04-17/schema.agentic_checkout.json` | vendored from `6b828681` |
+| `tests/fixtures/acp/2026-04-17` | vendored from `6b828681` |
+
+
+
+## Deviations
+
+Each entry names the section of the pinned revision the gateway departs from
+and the tests that hold the behavior.
+
+
+
+- **ACP RFC §6.5**: After a merchant 5xx, retrying the same `Idempotency-Key` returns 409 `idempotency_unresolved` unless `protocols.acp.idempotency.merchantIdempotent` is true. The merchant may have acted, so another execution could duplicate the order. Tests: `tests/conformance/acp/idempotency.test.ts`, `tests/conformance/acp/errors.test.ts`.
+
+
+
## ACP exclusions
-The adapter excludes carts, feed and standalone orders; delegated payment and
-authentication; the ACP MCP binding; webhooks and outbound delivery; the client
-role; `Signature` and `Timestamp` verification; discounts and the general
-extension framework; seller-backed payment handlers; and other ACP versions.
+The ACP descriptor in `GET /.well-known/agent-commerce` lists these names in
+`unsupported`, and `agent-commerce doctor` prints them when ACP is enabled:
+
+
+
+- `carts service`: The discovery document advertises only the checkout service.
+- `feed service`
+- `standalone orders service`
+- `delegate_payment`
+- `delegate_authentication`
+- `ACP MCP transport binding`
+- `webhooks`: The merchant backend sends ACP order webhooks itself.
+- `outbound merchant-to-agent delivery`
+- `ACP client role`
+- `Signature header verification`: The adapter forwards the header to the merchant unverified.
+- `Timestamp replay-window verification`: The adapter forwards the header to the merchant unverified.
+- `discount extension`
+- `general ACP extension framework`
+- `multiple ACP API versions`
+- `seller-backed payment handler integration`
+
+
+
A `Signature` header does not replace bearer authentication.
No ACP SDK ships. Conformance tests use the vendored official schema and examples.
diff --git a/docs/protocols/ap2.md b/docs/protocols/ap2.md
index d50b3ab..22f294d 100644
--- a/docs/protocols/ap2.md
+++ b/docs/protocols/ap2.md
@@ -379,25 +379,50 @@ Whoever creates an AP2 provider must call `close()`. The application
composition root does so after `gateway.close()`; `createGateway()` itself
does not close authorization providers.
+## Pins
+
+
+
+| Pin | Value |
+| --------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------- |
+| Pinned revision | v0.2.0, tag 2026-04-28, commit `b4587ac`; Direct mode |
+| Upstream source | [`google-agentic-commerce/AP2@b4587ac1`](https://github.com/google-agentic-commerce/AP2/tree/b4587ac1d055888a73b4b21750973cffba961793) |
+| Declared stable upstream | no |
+| Upstream wording | "Standardization of the specification will continue within the Agentic Authentication Technical and Payments Technical Working Groups in FIDO" (read 2026-11-17) |
+| `jose` | `6.2.12`, optional peer |
+| `@sd-jwt/core` | `0.20.1`, optional peer |
+| `canonicalize` | `5.0.0`, optional peer |
+| `tests/fixtures/ap2/v0.2.0` | vendored from `b4587ac1` |
+
+
+
## Not implemented
-Discovery and `doctor` read the unsupported list from `src/support/ap2.json`.
-The broader implementation limits are:
-
-- autonomous mode and open Checkout Mandates (`mandate.checkout.open.1`)
-- Payment Mandates (`mandate.payment.1`)
-- spending-constraint evaluation
-- `cnf`-bound agent keys, delegation chains and key-binding JWTs
-- User Credential delegation through OpenID4VP
-- JWKS, issuer metadata, remote key discovery or remote revocation
-- key rotation without a config change
-- signatures other than ES256 or digests other than SHA-256
-- mandate issuance or signed AP2 Checkout Receipts
-- an AP2 transport adapter or `/.well-known/ap2`
-- AP2 as a payment rail
-- AP2 over ACP
-
-Open mandates are refused because their spending constraints are not evaluated.
+The AP2 descriptor in `GET /.well-known/agent-commerce` lists these names in
+`unsupported`, and `agent-commerce doctor` prints them when AP2 is enabled:
+
+
+
+- `autonomous mode`
+- `open checkout mandates (mandate.checkout.open.1)`: Rejected because the provider does not evaluate spending constraints.
+- `payment mandates (mandate.payment.1)`
+- `spending constraint evaluation`
+- `cnf-bound agent keys`
+- `user credential delegation (OpenID4VP)`
+- `delegation chains and key-binding JWTs`
+- `JWKS and any key discovery by URL (jku, x5u)`: Operators supply all keys in config.
+- `issuer metadata fetching`
+- `remote revocation`
+- `key rotation without a config change`
+- `signature algorithms other than ES256`
+- `digest algorithms other than sha-256`
+- `mandate issuance`
+- `checkout receipts`
+- `AP2 transport adapter or /.well-known/ap2`: HTTP, MCP and A2A carry the mandate in the gateway's own carriers; AP2 v0.2.0 defines none.
+- `AP2 as a payment rail`
+- `AP2 over the ACP checkout adapter`
+
+
## Code map
diff --git a/docs/protocols/mcp.md b/docs/protocols/mcp.md
index 5f031b4..2f30030 100644
--- a/docs/protocols/mcp.md
+++ b/docs/protocols/mcp.md
@@ -115,12 +115,48 @@ For payment-required and error results, `content[0].text` is a JSON copy of
`structuredContent`; `content[1].text` is a sentence for readers. Unexpected
exception messages and stack traces are omitted.
+## Pins
+
+
+
+| Pin | Value |
+| ------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
+| Pinned revision | MCP `2026-07-28` and `2025-11-25` |
+| Upstream source | [`modelcontextprotocol/modelcontextprotocol@05aeb07b`](https://github.com/modelcontextprotocol/modelcontextprotocol/tree/05aeb07b2db0c02adc4813a7c09f208ca8774152) |
+| Declared stable upstream | yes |
+| Upstream wording | "Current: the current protocol version, which is ready for use and may continue to receive backwards compatible changes" (read 2026-11-17) |
+| `@modelcontextprotocol/server` | `2.3.0`, optional peer |
+| `@modelcontextprotocol/client` | `2.3.0`, tests only |
+| `@modelcontextprotocol/sdk` | `1.32.0`, tests only |
+
+
+
## MCP exclusions
-The adapter does not implement MCP resources, prompts, sampling, completions,
-elicitation, roots, logging, tasks or tool-list-change notifications. It has
-no MCP authorization, sessions, subscriptions, pagination or HTTP+SSE transport.
-The gateway, rather than the MCP adapter, enforces Host and Origin checks.
+The MCP descriptor in `GET /.well-known/agent-commerce` lists these names in
+`unsupported`:
+
+
+
+- `resources`
+- `prompts`
+- `sampling`
+- `completions`
+- `elicitation`
+- `roots`
+- `logging`
+- `notifications/tools/list_changed`
+- `tasks`
+- `dns-rebinding-protection`: The adapter relies on the gateway's `onRequest` hook to validate Host and Origin for the MCP mount.
+- `authorization`
+- `sessions`
+- `subscriptions`
+- `pagination`
+- `HTTP+SSE transport`
+- `MPP payment-required as JSON-RPC error -32042`: mppx reads challenges from the tool result's `_meta`.
+- `MPP verification failure as JSON-RPC error -32043`: mppx reads refusals from the tool result's `_meta`.
+
+
The MCP adapter maps payment carriers and results. It does not verify or
settle payments or call merchant backends.
diff --git a/docs/protocols/mpp.md b/docs/protocols/mpp.md
index af4e824..283d1d4 100644
--- a/docs/protocols/mpp.md
+++ b/docs/protocols/mpp.md
@@ -4,11 +4,11 @@
The gateway targets `draft-httpauth-payment-01`,
`draft-payment-intent-charge-00`, and `draft-evm-charge-00` at
-`tempoxyz/mpp-specs@806fdb8`. It pins the pre-1.0 `mppx@0.13.1` as an
-optional peer. For EIP-3009, the gateway follows `mppx`: it hashes
-`JSON.stringify([id, realm])` with keccak256 to derive the nonce. The EVM
-draft instead hashes `abi.encodePacked(id, realm)`. Credentials using the
-draft nonce, including those produced by `mppx` 0.12 or earlier, fail
+`tempoxyz/mpp-specs@806fdb8`. It uses the pre-1.0 `mppx`, an optional peer
+pinned to the version under [Pins](#pins). For EIP-3009, the gateway follows
+`mppx`: it hashes `JSON.stringify([id, realm])` with keccak256 to derive the
+nonce. The EVM draft instead hashes `abi.encodePacked(id, realm)`. Credentials
+using the draft nonce, including those produced by `mppx` 0.12 or earlier, fail
verification with `wrong_nonce`.
Later drafts or `mppx` releases may change the wire format again, so MPP
@@ -61,10 +61,6 @@ issuing challenges over plain HTTP.
Base mainnet deployments must satisfy the
[mainnet guardrails](../configuration.md#mainnet-guardrails).
-Unsupported variants are listed in `src/support/mpp.json`: non-EVM
-methods, Permit2/transaction/hash credentials, splits, subscriptions, EVM
-sessions and the discovery extension.
-
## Idempotency-Key
Experimental and disabled by default. On a resource with
@@ -102,3 +98,50 @@ another payer returns 422 `Unprocessable Content`, following section 2.7 of
usable stored response.
[http.md](http.md) lists the redelivery headers.
+
+## Pins
+
+
+
+| Pin | Value |
+| ------------------------ | -------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
+| Pinned revision | drafts at `tempoxyz/mpp-specs@806fdb8` |
+| Upstream source | [`tempoxyz/mpp-specs@806fdb8b`](https://github.com/tempoxyz/mpp-specs/tree/806fdb8b8c92cda5c84b8660558921b6bbeef7e0) |
+| Declared stable upstream | no |
+| Upstream wording | "Internet-Drafts are draft documents valid for a maximum of six months and may be updated, replaced, or obsoleted by other documents at any time." (read 2026-11-17) |
+| `mppx` | `0.13.1`, optional peer |
+
+
+
+## Deviations
+
+Each entry names the section of the pinned revision the gateway departs from
+and the tests that hold the behavior.
+
+
+
+- **draft-evm-charge-00**: The EIP-3009 nonce is keccak256 of `JSON.stringify([id, realm])`, as `mppx` 0.13 derives it, not of `abi.encodePacked(id, realm)`; a credential using the draft's nonce fails with `wrong_nonce`. Tests: `tests/unit/payments-mpp/provider.test.ts`.
+- **draft-payment-transport-mcp-00**: Over MCP, payment errors are tool results with `isError` and the challenges in `_meta`, not the JSON-RPC errors the draft maps them to (-32042, -32043, -32602 and -32603). Tests: `tests/integration/mcp-payment-bindings.test.ts`.
+- **draft-httpauth-payment-01 §11.4**: An unpaid request that gets a 402 also stores a `resource.requested` event beside the challenge. Tests: `tests/unit/core/execution/pipeline.test.ts`.
+- **draft-httpauth-payment-01 §4.2; draft-evm-charge-00**: A credential whose attempt is reserved or settlement-uncertain gets 409 without a fresh challenge, because a second challenge could lead to a second payment. Tests: `tests/integration/mpp-carriers.test.ts`.
+- **draft-payment-intent-charge-00**: With `paymentFlow: authorization`, the backend runs before the transfer, which the charge intent counts as partial access before payment. The default, `upfront`, settles first. Tests: `tests/e2e/payment/mpp-settlement.e2e.test.ts`.
+
+
+
+## MPP exclusions
+
+The MPP descriptor in `GET /.well-known/agent-commerce` lists these names in
+`unsupported`:
+
+
+
+- `methods other than evm`
+- `credential=permit2`: The profile accepts only the EIP-3009 authorization credential.
+- `credential=transaction`
+- `credential=hash`
+- `splits`: The draft allows splits only with `permit2` credentials.
+- `intent=subscription`
+- `evm sessions`: A separate EVM draft, not an option of charge.
+- `discovery extension`
+
+
diff --git a/docs/protocols/x402.md b/docs/protocols/x402.md
index 16f7aee..2acc1f5 100644
--- a/docs/protocols/x402.md
+++ b/docs/protocols/x402.md
@@ -268,10 +268,21 @@ ERC-8409 requires transport bindings to define the following:
the payment deadline with `validUntil`. Quote expiry does not cancel a
submitted payment.
-Not implemented: payer-bound quotes; contract issuers (ERC-1271, ERC-6492,
-EIP-7702 delegates); quote consumption, single-use enforcement or revocation;
-client nonces; quotes for MPP, Solana or NEAR; signed receipts and x402's
-`offer-receipt` extension; remote signers and KMS; per-resource toggles.
+The x402 descriptor lists these quote exclusions in `unsupported` whether or
+not quotes are enabled:
+
+
+
+- `payer-bound quotes`
+- `contract quote issuers (ERC-1271, ERC-6492, EIP-7702 delegates)`
+- `quote consumption, single-use enforcement or revocation`
+- `quote client nonces`
+- `quotes for MPP, Solana or NEAR`
+- `signed receipts and the x402 offer-receipt extension`
+- `remote quote signers and KMS`
+- `per-resource quote toggles`
+
+
## Support matrix
@@ -291,3 +302,41 @@ README lists their transactions.
Every public-network x402 payment was signed by the x402 SDK's own client for
its family. Other wallets and clients have not been tested.
+
+## Pins
+
+
+
+| Pin | Value |
+| --------------------------------- | ------------------------------------------------------------------------------------------------------------------------ |
+| Pinned revision | x402 v2 |
+| Upstream source | [`x402-foundation/x402@51a0664c`](https://github.com/x402-foundation/x402/tree/51a0664c2b7826e3cb02595481eb6848a1b11815) |
+| Declared stable upstream | not stated |
+| Upstream wording | "Protocol Version: 2" (read 2026-11-17) |
+| ERC-8409 pinned revision | draft `SergeevDmitry/ERCs@0ee33230` |
+| ERC-8409 upstream source | [`SergeevDmitry/ERCs@0ee33230`](https://github.com/SergeevDmitry/ERCs/tree/0ee33230ca9f9f41a714382552a47cd860465ca7) |
+| ERC-8409 declared stable upstream | no |
+| ERC-8409 upstream wording | "status: Draft" (read 2026-11-17) |
+| `@x402/core` | `2.30.0`, optional peer |
+| `@x402/evm` | `2.30.0`, optional peer |
+| `@x402/svm` | `2.30.0`, optional peer |
+| `@x402/near` | `2.30.0`, optional peer |
+| `@x402/mcp` | `2.30.0`, tests only |
+
+
+
+## x402 exclusions
+
+The x402 descriptor in `GET /.well-known/agent-commerce` lists these names in
+`unsupported`, followed by the
+[ERC-8409 quote exclusions](#erc-8409-signed-quotes):
+
+
+
+- `permit2 gas sponsoring extensions`
+- `upto scheme`
+- `batch-settlement scheme`
+- `auth-capture scheme`
+- `x402 v1`: A payload declaring an `x402Version` other than 2 is refused as `invalid_x402_version` on every carrier.
+
+
diff --git a/package.json b/package.json
index 1752aae..966f8bf 100644
--- a/package.json
+++ b/package.json
@@ -90,6 +90,7 @@
"test:mainnet": "vitest run --config vitest.mainnet.config.ts",
"check:contract": "node scripts/contract-surface.mjs",
"check:metadata": "node scripts/check-package-metadata.mjs",
+ "support:write": "tsx scripts/support-record.ts --write",
"verify": "npm run check:contract && npm run lint && npm run typecheck && npm test",
"agent-commerce": "tsx src/cli/index.ts",
"doctor": "tsx src/cli/index.ts doctor",
diff --git a/scripts/support-record.ts b/scripts/support-record.ts
index 61ab54e..8947888 100644
--- a/scripts/support-record.ts
+++ b/scripts/support-record.ts
@@ -1,15 +1,22 @@
/**
- * Validate the support records under `src/support/`, one per shipped profile.
- * Each record states the revision, subset, exclusions, deviations and evidence
- * its status covers. Descriptors and `doctor` trust these files at runtime.
- * This schema runs in tests and tooling and is excluded from the published
- * package.
+ * Validate the support records under `src/support/`, one per shipped profile,
+ * and render the docs regions generated from them. Each record states the
+ * revision, subset, exclusions, deviations and evidence its status covers.
+ * Descriptors and `doctor` trust these files at runtime. This schema runs in
+ * tests and tooling and is excluded from the published package.
+ *
+ * npm run support:write rewrite every generated region from the records
+ *
+ * `tests/integration/support-record.test.ts` fails on any drift and names the
+ * file, the region and the record.
*/
-import { readFileSync } from 'node:fs';
-import { join } from 'node:path';
+import { existsSync, readFileSync, writeFileSync } from 'node:fs';
+import { join, resolve } from 'node:path';
+import { fileURLToPath } from 'node:url';
import { z } from 'zod';
-export const SUPPORT_RECORD_NAMES = ['http', 'mcp', 'a2a', 'acp', 'x402', 'mpp', 'ap2'] as const;
+// Also the order every generated table lists the profiles in
+export const SUPPORT_RECORD_NAMES = ['http', 'mcp', 'x402', 'mpp', 'a2a', 'acp', 'ap2'] as const;
export const REPO_ROOT = join(import.meta.dirname, '..');
@@ -48,7 +55,11 @@ const SupportRecordSchema = z
z.strictObject({
name: text,
status: z.enum(['supported', 'experimental', 'partial']),
+ // A feature with its own spec gets its own matrix row, under `title`
spec: SpecSchema.optional(),
+ title: text.optional(),
+ role: text.optional(),
+ subset: text.optional(),
}),
),
// `name` is the string the descriptor publishes in `unsupported`
@@ -119,6 +130,16 @@ const SupportRecordSchema = z
});
}
}
+ for (const feature of record.features) {
+ const row = [feature.title, feature.role, feature.subset];
+ if ((feature.spec !== undefined) !== row.every((field) => field !== undefined)) {
+ ctx.addIssue({
+ code: 'custom',
+ path: ['features'],
+ message: `feature "${feature.name}" needs title, role and subset exactly when it has a spec`,
+ });
+ }
+ }
if (record.combinations !== undefined && record.kind !== 'payment') {
ctx.addIssue({
code: 'custom',
@@ -148,14 +169,482 @@ export function readSupportRecord(name: SupportRecordName): SupportRecord {
return parsed.data;
}
-/** Evidence and documentation paths to check for existence */
+/** Evidence and documentation paths to check for existence, each once */
export function citedPaths(record: SupportRecord): string[] {
return [
- ...record.artifacts.map((artifact) => artifact.path),
- ...(record.combinations ?? []).map((combination) => combination.evidence),
- ...(record.conformance?.tests ?? []),
- ...(record.conformance?.skipped ?? []).map((skipped) => skipped.test),
- ...record.deviations.flatMap((deviation) => deviation.tests),
- ...record.docs,
+ ...new Set([
+ ...record.artifacts.map((artifact) => artifact.path),
+ ...(record.combinations ?? []).map((combination) => combination.evidence),
+ ...(record.conformance?.tests ?? []),
+ ...(record.conformance?.skipped ?? []).map((skipped) => skipped.test),
+ ...record.deviations.flatMap((deviation) => deviation.tests),
+ ...record.docs,
+ ]),
+ ];
+}
+
+export interface PackageManifest {
+ readonly dependencies?: Readonly>;
+ readonly devDependencies?: Readonly>;
+ readonly peerDependencies?: Readonly>;
+}
+
+/** Everything the drift check reads, injectable so tests can mutate a copy */
+export interface SupportTree {
+ readonly records: readonly SupportRecord[];
+ readonly manifest: PackageManifest;
+ /** Undefined when the file does not exist */
+ readonly read: (path: string) => string | undefined;
+ readonly exists: (path: string) => boolean;
+}
+
+export function readSupportTree(): SupportTree {
+ return {
+ records: SUPPORT_RECORD_NAMES.map(readSupportRecord),
+ manifest: JSON.parse(readFileSync(join(REPO_ROOT, 'package.json'), 'utf8')) as PackageManifest,
+ read: (path) => {
+ const full = join(REPO_ROOT, path);
+ return existsSync(full) ? readFileSync(full, 'utf8') : undefined;
+ },
+ exists: (path) => existsSync(join(REPO_ROOT, path)),
+ };
+}
+
+// Rendering
+
+const STATUS_WORD = { supported: 'Supported', experimental: 'Experimental', partial: 'Partial' };
+
+// Supported badges keep each project's color; experimental ones share one
+const BADGE_COLOR: Readonly> = { mcp: '6b4fbb', x402: '0052ff' };
+const SUPPORTED_BADGE = '2ea44f';
+const EXPERIMENTAL_BADGE = 'f0a30a';
+
+const SURFACE_TITLE = { http: 'HTTP', mcp: 'MCP', a2a: 'A2A' };
+const LEVEL_TITLE = {
+ e2e: 'E2E, local chain',
+ integration: 'integration, no chain',
+ testnet: 'public testnet',
+ mainnet: 'mainnet',
+};
+
+// A Markdown table with every column padded to its widest cell
+function table(header: readonly string[], body: readonly (readonly string[])[]): string {
+ const rows = body.map((row) => row.map((cell) => cell.replaceAll('|', '\\|')));
+ const widths = header.map((cell, column) =>
+ Math.max(3, cell.length, ...rows.map((row) => (row[column] ?? '').length)),
+ );
+ const line = (cells: readonly string[]) =>
+ `| ${cells.map((cell, column) => cell.padEnd(widths[column] ?? 0)).join(' | ')} |`;
+ return [line(header), line(widths.map((width) => '-'.repeat(width))), ...rows.map(line)].join(
+ '\n',
+ );
+}
+
+// A Markdown block between region markers, set off by blank lines
+const block = (text: string) => `\n${text}\n\n`;
+
+type Spec = NonNullable;
+type Package = SupportRecord['packages'][number];
+
+function packageVersion(manifest: PackageManifest, pkg: Package): string | undefined {
+ return pkg.use === 'test'
+ ? manifest.devDependencies?.[pkg.name]
+ : (manifest.peerDependencies?.[pkg.name] ?? manifest.dependencies?.[pkg.name]);
+}
+
+const pinned = (manifest: PackageManifest, pkg: Package) =>
+ `\`${pkg.name}@${packageVersion(manifest, pkg) ?? 'missing'}\``;
+
+function revisionCell(record: SupportRecord, manifest: PackageManifest): string {
+ const runtime = record.packages.filter((pkg) => pkg.use === 'runtime');
+ const packages = runtime.map((pkg) => pinned(manifest, pkg)).join(', ');
+ const display = record.spec?.display ?? 'native';
+ return packages === '' ? display : `${display}; ${packages}`;
+}
+
+interface MatrixRow {
+ readonly title: string;
+ readonly status: string;
+ readonly role: string;
+ readonly revision: string;
+ readonly subset: string;
+}
+
+// One row per record, then one per feature that has its own spec
+function matrixRows(records: readonly SupportRecord[], manifest: PackageManifest): MatrixRow[] {
+ return [
+ ...records.map((record) => ({
+ title: record.title,
+ status: STATUS_WORD[record.status],
+ role: record.role,
+ revision: revisionCell(record, manifest),
+ subset: record.subset,
+ })),
+ ...records.flatMap((record) =>
+ record.features.flatMap((feature) =>
+ feature.spec === undefined
+ ? []
+ : [
+ {
+ title: feature.title ?? feature.name,
+ status: STATUS_WORD[feature.status],
+ role: feature.role ?? '',
+ revision: feature.spec.display,
+ subset: feature.subset ?? '',
+ },
+ ],
+ ),
+ ),
];
}
+
+function badges(records: readonly SupportRecord[]): string {
+ return records
+ .filter((record) => record.spec !== undefined)
+ .map((record) => {
+ const color =
+ record.status === 'experimental'
+ ? EXPERIMENTAL_BADGE
+ : (BADGE_COLOR[record.name] ?? SUPPORTED_BADGE);
+ const label = record.title.replaceAll('-', '--');
+ return `
\n`;
+ })
+ .join('');
+}
+
+function specRows(spec: Spec, prefix: string): string[][] {
+ const commit = spec.source.commit;
+ const stable = spec.stable === null ? 'not stated' : spec.stable ? 'yes' : 'no';
+ return [
+ [`${prefix}pinned revision`, spec.display],
+ [
+ `${prefix}upstream source`,
+ `[\`${spec.source.repo}@${commit.slice(0, 8)}\`](https://github.com/${spec.source.repo}/tree/${commit})`,
+ ],
+ [`${prefix}declared stable upstream`, stable],
+ [`${prefix}upstream wording`, `"${spec.statement}" (read ${spec.checked})`],
+ ];
+}
+
+function pins(record: SupportRecord, manifest: PackageManifest): string {
+ const use = (pkg: Package) => {
+ if (pkg.use === 'test') return 'tests only';
+ return manifest.peerDependencies?.[pkg.name] !== undefined ? 'optional peer' : 'dependency';
+ };
+ const rows = [
+ ...(record.spec === undefined ? [] : specRows(record.spec, '')),
+ ...record.features.flatMap((feature) =>
+ feature.spec === undefined ? [] : specRows(feature.spec, `${feature.title} `),
+ ),
+ ...record.packages.map((pkg) => [
+ `\`${pkg.name}\``,
+ `\`${packageVersion(manifest, pkg) ?? 'missing'}\`, ${use(pkg)}`,
+ ]),
+ ...record.artifacts.map((artifact) => [
+ `\`${artifact.path}\``,
+ `vendored from \`${artifact.revision.slice(0, 8)}\``,
+ ]),
+ ];
+ // Capitalize the first word of each label that is not a package or a path
+ const label = (cell: string) =>
+ cell.startsWith('`') ? cell : `${cell.charAt(0).toUpperCase()}${cell.slice(1)}`;
+ return table(
+ ['Pin', 'Value'],
+ rows.map(([name = '', value = '']) => [label(name), value]),
+ );
+}
+
+function exclusionList(exclusions: SupportRecord['exclusions']): string {
+ return exclusions
+ .map(
+ (exclusion) =>
+ `- \`${exclusion.name}\`${exclusion.note === undefined ? '' : `: ${exclusion.note}`}`,
+ )
+ .join('\n');
+}
+
+function deviationList(record: SupportRecord): string {
+ return record.deviations
+ .map((deviation) => {
+ const tests = deviation.tests.map((test) => `\`${test}\``).join(', ');
+ const upstream =
+ deviation.upstream === undefined ? '' : ` Reported upstream: ${deviation.upstream}.`;
+ return `- **${deviation.spec}**: ${deviation.summary}${upstream} Tests: ${tests}.`;
+ })
+ .join('\n');
+}
+
+function combinations(records: readonly SupportRecord[]): string {
+ const rows = records.flatMap((record) =>
+ (record.combinations ?? []).map((combination) => [
+ record.title,
+ SURFACE_TITLE[combination.surface],
+ combination.authorization === undefined ? '-' : 'AP2',
+ LEVEL_TITLE[combination.level],
+ `\`${combination.evidence}\``,
+ ]),
+ );
+ return table(['Rail', 'Surface', 'Authorization', 'Tested at', 'Test'], rows);
+}
+
+export interface RenderedRegion {
+ readonly body: string;
+ /** What the region is generated from, named in a drift report */
+ readonly source: string;
+}
+
+/** Every generated region, by repository path and region id */
+export function renderRegions(
+ records: readonly SupportRecord[],
+ manifest: PackageManifest,
+): Map> {
+ const all = 'src/support/*.json and package.json';
+ const matrix = matrixRows(records, manifest);
+ const regions = new Map>([
+ [
+ 'README.md',
+ new Map([
+ ['badges', { body: badges(records), source: 'src/support/*.json' }],
+ [
+ 'matrix',
+ {
+ body: block(
+ table(
+ ['Protocol', 'Status', 'Pinned revision', 'Implemented subset'],
+ matrix.map((row) => [`**${row.title}**`, row.status, row.revision, row.subset]),
+ ),
+ ),
+ source: all,
+ },
+ ],
+ ]),
+ ],
+ [
+ 'docs/protocols.md',
+ new Map([
+ [
+ 'matrix',
+ {
+ body: block(
+ table(
+ ['Protocol', 'Status', 'Role', 'Revision', 'Implemented subset'],
+ matrix.map((row) => [
+ `**${row.title}**`,
+ row.status,
+ row.role,
+ row.revision,
+ row.subset,
+ ]),
+ ),
+ ),
+ source: all,
+ },
+ ],
+ ['combinations', { body: block(combinations(records)), source: 'src/support/*.json' }],
+ ]),
+ ],
+ ]);
+ for (const record of records) {
+ const source = `src/support/${record.name}.json`;
+ const page = new Map();
+ if (record.spec !== undefined || record.packages.length > 0 || record.artifacts.length > 0) {
+ page.set('pins', {
+ body: block(pins(record, manifest)),
+ source: `${source} and package.json`,
+ });
+ }
+ const untagged = record.exclusions.filter((exclusion) => exclusion.feature === undefined);
+ if (untagged.length > 0) {
+ page.set('exclusions', { body: block(exclusionList(untagged)), source });
+ }
+ for (const feature of new Set(record.exclusions.flatMap((e) => e.feature ?? []))) {
+ const tagged = record.exclusions.filter((exclusion) => exclusion.feature === feature);
+ page.set(`exclusions:${feature}`, { body: block(exclusionList(tagged)), source });
+ }
+ if (record.deviations.length > 0) {
+ page.set('deviations', { body: block(deviationList(record)), source });
+ }
+ if (page.size > 0) regions.set(`docs/protocols/${record.name}.md`, page);
+ }
+ return regions;
+}
+
+// Regions in a file
+
+const REGION =
+ /^([ \t]*)\n([\s\S]*?)^[ \t]*/gm;
+
+interface FoundRegion {
+ readonly id: string;
+ readonly body: string;
+}
+
+function findRegions(content: string): FoundRegion[] {
+ return [...content.matchAll(REGION)].map((match) => ({
+ id: match[2] ?? '',
+ body: match[3] ?? '',
+ }));
+}
+
+function replaceRegions(content: string, rendered: ReadonlyMap): string {
+ return content.replace(REGION, (whole, indent: string, id: string) => {
+ const region = rendered.get(id);
+ if (region === undefined) return whole;
+ return `${indent}\n${region.body}${indent}`;
+ });
+}
+
+// The drift check
+
+const titleNamed = (text: string, title: string) =>
+ new RegExp(`(^|[^\\w-])${title.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')}(?![\\w-])`).test(text);
+
+// Hand-written sentences that name the experimental profiles
+const STATUS_SENTENCES = [
+ {
+ path: 'README.md',
+ place: 'Versioning sentence',
+ find: (content: string) => /### Versioning\n\n([\s\S]*?)\n\n/.exec(content)?.[1],
+ },
+ {
+ path: 'plugins/agent-commerce-gateway/skills/agent-commerce/SKILL.md',
+ place: '"exist but are experimental" sentence',
+ find: (content: string) => /[^.]*exist but are experimental[^.]*\./.exec(content)?.[0],
+ },
+];
+
+// x402 route table rows, by the start of the route, and the feature each row states
+const X402_ROUTES: readonly [string, string][] = [
+ ['EIP-3009 ', 'eip-3009'],
+ ['Permit2 ', 'permit2'],
+ ['Solana', 'exact-svm'],
+ ['NEAR', 'exact-near'],
+];
+
+function handWrittenProblems(tree: SupportTree): string[] {
+ const problems: string[] = [];
+ const experimental = tree.records.filter((record) => record.status === 'experimental');
+ for (const sentence of STATUS_SENTENCES) {
+ const text = sentence.find(tree.read(sentence.path) ?? '');
+ if (text === undefined) {
+ problems.push(`${sentence.path}: ${sentence.place} not found`);
+ continue;
+ }
+ for (const record of tree.records) {
+ const named = titleNamed(text, record.title);
+ if (named !== experimental.includes(record)) {
+ problems.push(
+ `${sentence.path}: the ${sentence.place} ${named ? 'names' : 'omits'} ${record.title}, which src/support/${record.name}.json records as ${record.status}`,
+ );
+ }
+ }
+ }
+ for (const record of tree.records) {
+ const path = `docs/protocols/${record.name}.md`;
+ const marked = (tree.read(path) ?? '').includes('**Experimental.**');
+ if (marked !== (record.status === 'experimental')) {
+ problems.push(
+ `${path}: ${marked ? 'says' : 'does not say'} **Experimental.**, but src/support/${record.name}.json records ${record.status}`,
+ );
+ }
+ }
+ const x402 = tree.records.find((record) => record.name === 'x402');
+ const routes = /## Support matrix\n[\s\S]*?\n(\|[\s\S]*?)\n\n/.exec(
+ tree.read('docs/protocols/x402.md') ?? '',
+ )?.[1];
+ for (const [prefix, featureName] of X402_ROUTES) {
+ const feature = x402?.features.find((candidate) => candidate.name === featureName);
+ const rows = (routes ?? '')
+ .split('\n')
+ .map((line) => line.split('|').map((cell) => cell.trim()))
+ .filter((cells) => cells[1]?.startsWith(prefix));
+ if (rows.length === 0) {
+ problems.push(`docs/protocols/x402.md: no support matrix row starts with "${prefix.trim()}"`);
+ }
+ for (const cells of rows) {
+ if (cells[2] !== feature?.status) {
+ problems.push(
+ `docs/protocols/x402.md: the "${cells[1]}" row says ${cells[2]}, but src/support/x402.json records ${featureName} as ${feature?.status}`,
+ );
+ }
+ }
+ }
+ return problems;
+}
+
+/** Every disagreement between the records, package.json and the docs, each naming its place */
+export function supportProblems(tree: SupportTree): string[] {
+ const problems: string[] = [];
+ const { manifest } = tree;
+ for (const record of tree.records) {
+ const source = `src/support/${record.name}.json`;
+ for (const pkg of record.packages) {
+ const runtime = manifest.peerDependencies?.[pkg.name] ?? manifest.dependencies?.[pkg.name];
+ const declared =
+ pkg.use === 'runtime'
+ ? runtime !== undefined
+ : manifest.devDependencies?.[pkg.name] !== undefined && runtime === undefined;
+ if (!declared) {
+ problems.push(
+ `${source}: package ${pkg.name} (${pkg.use}) is not in package.json ${pkg.use === 'runtime' ? 'dependencies or peerDependencies' : 'devDependencies alone'}`,
+ );
+ }
+ }
+ for (const path of citedPaths(record)) {
+ if (!tree.exists(path)) problems.push(`${source}: cites ${path}, which does not exist`);
+ }
+ }
+ for (const [path, regions] of renderRegions(tree.records, manifest)) {
+ const content = tree.read(path);
+ if (content === undefined) {
+ problems.push(`${path}: missing, but support regions are generated into it`);
+ continue;
+ }
+ const found = findRegions(content);
+ for (const [id, region] of regions) {
+ const matches = found.filter((candidate) => candidate.id === id);
+ if (matches.length !== 1) {
+ problems.push(`${path}: region "${id}" appears ${matches.length} times, not once`);
+ } else if (matches[0]?.body !== region.body) {
+ problems.push(
+ `${path}: region "${id}" differs from ${region.source}; run npm run support:write`,
+ );
+ }
+ }
+ for (const region of found) {
+ if (!regions.has(region.id)) problems.push(`${path}: unknown region "${region.id}"`);
+ }
+ }
+ return [...problems, ...handWrittenProblems(tree)];
+}
+
+/** The new content of each file whose generated regions are out of date */
+export function regionUpdates(tree: SupportTree): Map {
+ const updates = new Map();
+ for (const [path, regions] of renderRegions(tree.records, tree.manifest)) {
+ const content = tree.read(path);
+ if (content === undefined) throw new Error(`${path}: missing`);
+ const ids = new Set(findRegions(content).map((region) => region.id));
+ const absent = [...regions.keys()].filter((id) => !ids.has(id));
+ if (absent.length > 0) {
+ throw new Error(`${path}: add the markers for region(s) ${absent.join(', ')} first`);
+ }
+ const next = replaceRegions(content, regions);
+ if (next !== content) updates.set(path, next);
+ }
+ return updates;
+}
+
+if (process.argv[1] !== undefined && resolve(process.argv[1]) === fileURLToPath(import.meta.url)) {
+ if (!process.argv.includes('--write')) {
+ console.error('usage: tsx scripts/support-record.ts --write');
+ process.exit(2);
+ }
+ const updates = regionUpdates(readSupportTree());
+ for (const [path, content] of updates) writeFileSync(join(REPO_ROOT, path), content);
+ console.log(
+ updates.size === 0
+ ? 'support regions: unchanged'
+ : `support regions: rewrote ${[...updates.keys()].join(', ')}`,
+ );
+}
diff --git a/src/support/a2a.json b/src/support/a2a.json
index 2694f53..db12234 100644
--- a/src/support/a2a.json
+++ b/src/support/a2a.json
@@ -3,7 +3,7 @@
"kind": "protocol",
"title": "A2A",
"status": "experimental",
- "role": "Transport that carries x402 and MPP payments in SendMessage, including through the x402 extension.",
+ "role": "Transport that carries x402 and MPP payments in `SendMessage`, including through the x402 extension.",
"subset": "Agent Card, `SendMessage`, paid flow and the x402 extension",
"spec": {
"revisions": ["1.0.1"],
diff --git a/src/support/acp.json b/src/support/acp.json
index ec0cd0e..299dcdb 100644
--- a/src/support/acp.json
+++ b/src/support/acp.json
@@ -3,7 +3,7 @@
"kind": "protocol",
"title": "ACP",
"status": "experimental",
- "role": "Checkout API that forwards checkout operations to the merchant, whose payment handler receives payment_data. Gateway checkout routes are free and carry no x402 or MPP payment.",
+ "role": "Checkout API that forwards checkout operations to the merchant, whose payment handler receives `payment_data`. Gateway checkout routes are free and carry no x402 or MPP payment.",
"subset": "discovery and the five checkout operations",
"spec": {
"revisions": ["2026-04-17"],
@@ -68,7 +68,7 @@
],
"deviations": [
{
- "summary": "After a merchant 5xx, retrying the same Idempotency-Key returns 409 idempotency_unresolved unless protocols.acp.idempotency.merchantIdempotent is true. The merchant may have acted, so another execution could duplicate the order.",
+ "summary": "After a merchant 5xx, retrying the same `Idempotency-Key` returns 409 `idempotency_unresolved` unless `protocols.acp.idempotency.merchantIdempotent` is true. The merchant may have acted, so another execution could duplicate the order.",
"spec": "ACP RFC §6.5",
"tests": ["tests/conformance/acp/idempotency.test.ts", "tests/conformance/acp/errors.test.ts"]
}
diff --git a/src/support/mcp.json b/src/support/mcp.json
index effa603..f436fdb 100644
--- a/src/support/mcp.json
+++ b/src/support/mcp.json
@@ -38,7 +38,7 @@
{ "name": "tasks" },
{
"name": "dns-rebinding-protection",
- "note": "The adapter relies on the gateway's onRequest hook to validate Host and Origin for the MCP mount."
+ "note": "The adapter relies on the gateway's `onRequest` hook to validate Host and Origin for the MCP mount."
},
{ "name": "authorization" },
{ "name": "sessions" },
@@ -47,11 +47,11 @@
{ "name": "HTTP+SSE transport" },
{
"name": "MPP payment-required as JSON-RPC error -32042",
- "note": "mppx reads challenges from the tool result's _meta."
+ "note": "mppx reads challenges from the tool result's `_meta`."
},
{
"name": "MPP verification failure as JSON-RPC error -32043",
- "note": "mppx reads refusals from the tool result's _meta."
+ "note": "mppx reads refusals from the tool result's `_meta`."
}
],
"deviations": [],
diff --git a/src/support/mpp.json b/src/support/mpp.json
index ec0525c..e97ed9f 100644
--- a/src/support/mpp.json
+++ b/src/support/mpp.json
@@ -4,7 +4,7 @@
"title": "MPP",
"status": "experimental",
"role": "Payment rail, carried by HTTP, MCP and A2A.",
- "subset": "`charge`/`evm`/EIP-3009 over HTTP, MCP and A2A",
+ "subset": "`charge`/`evm`/EIP-3009 with USDC on Base Sepolia and Base, over HTTP, MCP and A2A",
"spec": {
"revisions": [
"draft-httpauth-payment-01",
@@ -45,24 +45,24 @@
},
{ "name": "credential=transaction" },
{ "name": "credential=hash" },
- { "name": "splits", "note": "The draft allows splits only with permit2 credentials." },
+ { "name": "splits", "note": "The draft allows splits only with `permit2` credentials." },
{ "name": "intent=subscription" },
{ "name": "evm sessions", "note": "A separate EVM draft, not an option of charge." },
{ "name": "discovery extension" }
],
"deviations": [
{
- "summary": "The EIP-3009 nonce is keccak256 of JSON.stringify([id, realm]), as mppx 0.13 derives it, not of abi.encodePacked(id, realm); a credential using the draft's nonce fails with wrong_nonce.",
+ "summary": "The EIP-3009 nonce is keccak256 of `JSON.stringify([id, realm])`, as `mppx` 0.13 derives it, not of `abi.encodePacked(id, realm)`; a credential using the draft's nonce fails with `wrong_nonce`.",
"spec": "draft-evm-charge-00",
"tests": ["tests/unit/payments-mpp/provider.test.ts"]
},
{
- "summary": "Over MCP, payment errors are tool results with isError and the challenges in _meta, not the JSON-RPC errors the draft maps them to (-32042, -32043, -32602 and -32603).",
+ "summary": "Over MCP, payment errors are tool results with `isError` and the challenges in `_meta`, not the JSON-RPC errors the draft maps them to (-32042, -32043, -32602 and -32603).",
"spec": "draft-payment-transport-mcp-00",
"tests": ["tests/integration/mcp-payment-bindings.test.ts"]
},
{
- "summary": "An unpaid request that gets a 402 also stores a resource.requested event beside the challenge.",
+ "summary": "An unpaid request that gets a 402 also stores a `resource.requested` event beside the challenge.",
"spec": "draft-httpauth-payment-01 §11.4",
"tests": ["tests/unit/core/execution/pipeline.test.ts"]
},
@@ -72,7 +72,7 @@
"tests": ["tests/integration/mpp-carriers.test.ts"]
},
{
- "summary": "With paymentFlow: authorization, the backend runs before the transfer, which the charge intent counts as partial access before payment. The default, upfront, settles first.",
+ "summary": "With `paymentFlow: authorization`, the backend runs before the transfer, which the charge intent counts as partial access before payment. The default, `upfront`, settles first.",
"spec": "draft-payment-intent-charge-00",
"tests": ["tests/e2e/payment/mpp-settlement.e2e.test.ts"]
}
diff --git a/src/support/x402.json b/src/support/x402.json
index 5776fcd..46c3433 100644
--- a/src/support/x402.json
+++ b/src/support/x402.json
@@ -52,7 +52,10 @@
"stable": false,
"statement": "status: Draft",
"checked": "2026-11-17"
- }
+ },
+ "title": "ERC-8409",
+ "role": "x402 feature: EIP-712 signed quotes on the EVM offers of a challenge.",
+ "subset": "signed quotes on x402 EVM offers; issuer published in `/.well-known/agent-commerce`"
}
],
"exclusions": [
@@ -62,7 +65,7 @@
{ "name": "auth-capture scheme" },
{
"name": "x402 v1",
- "note": "A payload declaring an x402Version other than 2 is refused as invalid_x402_version on every carrier."
+ "note": "A payload declaring an `x402Version` other than 2 is refused as `invalid_x402_version` on every carrier."
},
{ "name": "payer-bound quotes", "feature": "erc-8409-quotes" },
{
diff --git a/tests/integration/support-record.test.ts b/tests/integration/support-record.test.ts
index 481fdf4..eece327 100644
--- a/tests/integration/support-record.test.ts
+++ b/tests/integration/support-record.test.ts
@@ -1,19 +1,24 @@
/**
- * Check support records against the descriptors that publish their claims.
- * Descriptors derive status and unsupported features from the records; these
- * tests also compare capabilities and revisions with their values in code.
+ * Check support records against the descriptors that publish their claims and
+ * the docs generated from them. Descriptors derive status and unsupported
+ * features from the records; these tests also compare capabilities and
+ * revisions with their values in code.
*/
-import { existsSync, readdirSync } from 'node:fs';
+import { readdirSync } from 'node:fs';
import { join } from 'node:path';
import { LATEST_PROTOCOL_VERSION } from '@modelcontextprotocol/server';
import { describe, expect, expectTypeOf, it } from 'vitest';
import {
- citedPaths,
+ type PackageManifest,
REPO_ROOT,
readSupportRecord,
+ readSupportTree,
+ regionUpdates,
SUPPORT_RECORD_NAMES,
type SupportRecord,
type SupportRecordName,
+ type SupportTree,
+ supportProblems,
} from '../../scripts/support-record';
import { AP2_CAPABILITIES, AP2_UNSUPPORTED } from '../../src/ap2';
import { AP2_SPEC_VERSION } from '../../src/authorization/ap2/constants';
@@ -50,15 +55,6 @@ describe('support records', () => {
for (const name of SUPPORT_RECORD_NAMES) expect(records[name].name).toBe(name);
});
- it('cites only evidence and documentation files that exist', () => {
- const missing = SUPPORT_RECORD_NAMES.flatMap((name) =>
- citedPaths(records[name])
- .filter((path) => !existsSync(join(REPO_ROOT, path)))
- .map((path) => `src/support/${name}.json: ${path}`),
- );
- expect(missing).toEqual([]);
- });
-
it('lists tested combinations on the payment records only', () => {
expect(SUPPORT_RECORD_NAMES.filter((name) => records[name].combinations !== undefined)).toEqual(
['x402', 'mpp'],
@@ -210,3 +206,176 @@ describe('published exports derived from a record keep their 2.7 types', () => {
expectTypeOf(MPP_DESCRIPTOR).toEqualTypeOf();
});
});
+
+describe('drift between the records, package.json and the docs', () => {
+ const tree = readSupportTree();
+
+ // A writable copy of package.json's dependency sections
+ type Manifest = { -readonly [K in keyof PackageManifest]-?: Record };
+
+ interface Change {
+ readonly records?: (records: SupportRecord[]) => void;
+ readonly manifest?: (manifest: Manifest) => void;
+ readonly edit?: Readonly string>>;
+ readonly deleted?: string;
+ }
+
+ // The real tree with one change, made on copies
+ function changed(change: Change): SupportTree {
+ const mutated = structuredClone(tree.records) as SupportRecord[];
+ const manifest = structuredClone(tree.manifest) as Manifest;
+ change.records?.(mutated);
+ change.manifest?.(manifest);
+ return {
+ records: mutated,
+ manifest,
+ read: (path) => {
+ const content = tree.read(path);
+ const edit = change.edit?.[path];
+ return content === undefined || edit === undefined ? content : edit(content);
+ },
+ exists: (path) => path !== change.deleted && tree.exists(path),
+ };
+ }
+
+ const record = (records: SupportRecord[], name: SupportRecordName) => {
+ const found = records.find((candidate) => candidate.name === name);
+ if (found === undefined) throw new Error(`no ${name} record`);
+ return found;
+ };
+
+ const stale = (path: string, region: string, source: string) =>
+ `${path}: region "${region}" differs from ${source}; run npm run support:write`;
+ const ALL = 'src/support/*.json and package.json';
+
+ it('finds none on the real tree, and --write would change no file', () => {
+ expect(supportProblems(tree)).toEqual([]);
+ expect([...regionUpdates(tree).keys()]).toEqual([]);
+ });
+
+ const HAND_EDIT: Change = {
+ edit: {
+ 'README.md': (content) =>
+ content.replace('| **MPP** | Experimental', '| **MPP** | Supported '),
+ },
+ };
+ const MARKERS_REMOVED: Change = {
+ edit: {
+ 'docs/protocols/mcp.md': (content) =>
+ content.replace(
+ /[\s\S]*?/,
+ '',
+ ),
+ },
+ };
+
+ const cases: [string, Change, string[]][] = [
+ [
+ 'a package version bumped in package.json',
+ {
+ manifest: (manifest) => {
+ manifest.peerDependencies.mppx = '0.13.2';
+ },
+ },
+ [
+ stale('README.md', 'matrix', ALL),
+ stale('docs/protocols.md', 'matrix', ALL),
+ stale('docs/protocols/mpp.md', 'pins', 'src/support/mpp.json and package.json'),
+ ],
+ ],
+ [
+ 'a recorded package missing from package.json',
+ {
+ manifest: (manifest) => {
+ delete manifest.peerDependencies['@sd-jwt/core'];
+ delete manifest.devDependencies['@sd-jwt/core'];
+ },
+ },
+ [
+ 'src/support/ap2.json: package @sd-jwt/core (runtime) is not in package.json dependencies or peerDependencies',
+ stale('README.md', 'matrix', ALL),
+ stale('docs/protocols.md', 'matrix', ALL),
+ stale('docs/protocols/ap2.md', 'pins', 'src/support/ap2.json and package.json'),
+ ],
+ ],
+ [
+ 'an exclusion added to a record',
+ { records: (records) => void record(records, 'acp').exclusions.push({ name: 'carts' }) },
+ [stale('docs/protocols/acp.md', 'exclusions', 'src/support/acp.json')],
+ ],
+ [
+ 'an experimental profile recorded as supported',
+ {
+ records: (records) => {
+ record(records, 'a2a').status = 'supported';
+ },
+ },
+ [
+ stale('README.md', 'badges', 'src/support/*.json'),
+ stale('README.md', 'matrix', ALL),
+ stale('docs/protocols.md', 'matrix', ALL),
+ 'README.md: the Versioning sentence names A2A, which src/support/a2a.json records as supported',
+ 'plugins/agent-commerce-gateway/skills/agent-commerce/SKILL.md: the "exist but are experimental" sentence names A2A, which src/support/a2a.json records as supported',
+ 'docs/protocols/a2a.md: says **Experimental.**, but src/support/a2a.json records supported',
+ ],
+ ],
+ ['a hand edit inside a generated region', HAND_EDIT, [stale('README.md', 'matrix', ALL)]],
+ [
+ 'a deleted evidence file',
+ { deleted: 'tests/e2e/payment/x402-settlement.e2e.test.ts' },
+ [
+ 'src/support/x402.json: cites tests/e2e/payment/x402-settlement.e2e.test.ts, which does not exist',
+ ],
+ ],
+ [
+ 'an experimental profile missing from the Versioning sentence',
+ {
+ edit: {
+ 'README.md': (content) => content.replace('MPP, A2A, ACP, AP2,', 'A2A, ACP, AP2,'),
+ },
+ },
+ [
+ 'README.md: the Versioning sentence omits MPP, which src/support/mpp.json records as experimental',
+ ],
+ ],
+ [
+ 'an x402 route row whose status differs from its feature',
+ {
+ edit: {
+ 'docs/protocols/x402.md': (content) =>
+ content.replace(/(\| NEAR +\| )partial/, '$1supported'),
+ },
+ },
+ [
+ 'docs/protocols/x402.md: the "NEAR" row says supported, but src/support/x402.json records exact-near as partial',
+ ],
+ ],
+ [
+ 'a region whose markers were removed',
+ MARKERS_REMOVED,
+ ['docs/protocols/mcp.md: region "pins" appears 0 times, not once'],
+ ],
+ ];
+
+ it.each(cases)('names the place of %s', (_, change, expected) => {
+ expect(supportProblems(changed(change))).toEqual(expected);
+ });
+
+ it('escapes a pipe inside a generated table cell', () => {
+ const piped = changed({
+ records: (records) => {
+ record(records, 'acp').subset = 'checkout | discovery';
+ },
+ });
+ expect(regionUpdates(piped).get('docs/protocols.md')).toContain('checkout \\| discovery');
+ });
+
+ it('--write restores a hand-edited region and refuses a file with missing markers', () => {
+ expect(regionUpdates(changed(HAND_EDIT))).toEqual(
+ new Map([['README.md', tree.read('README.md')]]),
+ );
+ expect(() => regionUpdates(changed(MARKERS_REMOVED))).toThrow(
+ 'docs/protocols/mcp.md: add the markers for region(s) pins first',
+ );
+ });
+});
From 9f51e8d4913752a3d50df6315a44e7f452121422 Mon Sep 17 00:00:00 2001
From: Revinand
Date: Wed, 18 Nov 2026 16:04:57 +0100
Subject: [PATCH 05/14] feat(cli): mark doctor results that could not be
determined
---
README.md | 16 +-
docs/contracts.md | 11 +
docs/security.md | 3 +
.../references/troubleshooting.md | 27 +-
src/cli/commands/doctor/ap2.ts | 4 +-
src/cli/commands/doctor/index.ts | 75 ++-
src/cli/commands/doctor/payments.ts | 44 +-
src/cli/commands/doctor/protocols.ts | 26 +-
src/cli/commands/doctor/report.ts | 3 +-
src/cli/commands/doctor/secrets.ts | 42 ++
src/cli/commands/doctor/storage.ts | 9 +-
src/cli/commands/doctor/types.ts | 30 +-
src/cli/lib/config-client.ts | 7 +
src/cli/lib/http.ts | 16 +-
src/config/env.ts | 44 ++
src/config/index.ts | 5 +-
src/config/load.ts | 13 +-
src/core/no-answer.ts | 34 ++
src/gateway/well-known.ts | 58 +-
src/payments/x402/facilitator.ts | 19 +-
src/payments/x402/provider/health.ts | 38 +-
tests/integration/doctor-certainty.test.ts | 317 +++++++++++
.../goldens/2.7.2/doctor-multi.json | 9 +-
.../goldens/2.7.2/doctor-single.json | 14 +-
.../goldens/2.7.2/well-known-multi.json | 3 +-
.../goldens/2.7.2/well-known-single.json | 6 +-
tests/integration/mpp-config.test.ts | 19 +-
tests/unit/cli/doctor-certainty.test.ts | 496 ++++++++++++++++++
tests/unit/cli/doctor.test.ts | 13 +-
tests/unit/cli/fixtures.ts | 11 +-
tests/unit/cli/lib.test.ts | 29 +-
tests/unit/config/env.test.ts | 52 +-
tests/unit/config/load.test.ts | 23 +-
tests/unit/core/no-answer.test.ts | 66 +++
tests/unit/gateway/helpers.ts | 14 +-
tests/unit/gateway/server.test.ts | 82 +++
.../facilitator-isolation.test.ts | 2 +
.../provider-health-mocked.test.ts | 112 +++-
38 files changed, 1678 insertions(+), 114 deletions(-)
create mode 100644 src/cli/commands/doctor/secrets.ts
create mode 100644 src/core/no-answer.ts
create mode 100644 tests/integration/doctor-certainty.test.ts
create mode 100644 tests/unit/cli/doctor-certainty.test.ts
create mode 100644 tests/unit/core/no-answer.test.ts
diff --git a/README.md b/README.md
index fc75434..5e0e576 100644
--- a/README.md
+++ b/README.md
@@ -504,6 +504,7 @@ spend real USDC when their opt-ins and credentials are present.
$ npm run agent-commerce -- doctor --config config-demo.yaml
PASS Config valid: 2 resource(s), merchant "Demo Data Store" (using local chain manifest .deploy/local.json for X402_ASSET, X402_ASSET_NAME, X402_ASSET_VERSION, X402_ASSET_DECIMALS, MERCHANT_WALLET, X402_FACILITATOR_PRIVATE_KEY)
+PASS Secrets 6 set (MERCHANT_WALLET, X402_ASSET, X402_ASSET_DECIMALS, X402_ASSET_NAME, X402_ASSET_VERSION, X402_FACILITATOR_PRIVATE_KEY); 8 defaulted (ADMIN_TOKEN, DASHBOARD_ORIGIN, GATEWAY_PORT, GATEWAY_PUBLIC_BASE_URL, MERCHANT_API_BASE_URL, RECEIPT_STORE_PATH, X402_NETWORK, X402_RPC_URL)
PASS Gateway healthy and ready at http://127.0.0.1:8080
PASS Backend 2/2 backend host(s) reachable
PASS Protocols http=on mcp=on (/mcp) a2a=off acp=off
@@ -511,12 +512,13 @@ INFO A2A disabled
INFO ACP disabled
INFO AP2 disabled
PASS Payments x402 v2 (scheme=exact) enabled - LOCAL dev chain (eip155:31337), destination=0x7099…79C8, facilitator=local (in-process), paymentFlow=authorization
+PASS Payments (offers) 1 offer(s) pass their health checks
INFO Payments (MPP) MPP not configured
PASS Storage sqlite schema v5 writable; receipts=2
PASS Transactions none unresolved
PASS Protocol versions reported by gateway /.well-known/agent-commerce
-Score: 8/8 checks passed
+Score: 10/10 checks passed
```
`doctor` compares live settlement terms with local config for each rail and
@@ -524,6 +526,18 @@ resource: offer order, network, token, payee and transfer method, plus decimals
and payment flows when published. Mismatches fail the check. It also names
failing offers when health is published; reasons appear in gateway debug logs.
+`Secrets` lists each config placeholder (`${VAR}`) as missing, set or
+defaulted. Config loading stops at the first missing variable; this check
+reports them all. It fails if any are missing and prints names only, never
+values or defaults.
+
+A check that cannot reach a verdict carries `undetermined`: `unreachable`
+for known transport failures, such as refused or reset connections, timeouts
+or temporary DNS failures; `skipped` when a prerequisite fails. Unresolvable
+hostnames and TLS errors leave the check unmarked.
+Text output appends `[not determined: ]`. The marker does not affect
+status, score or exit code; an unreachable gateway still fails its check.
+
Exits non-zero if anything fails. `--json` for machines.
### `agent-commerce reconcile`
diff --git a/docs/contracts.md b/docs/contracts.md
index 9c2978c..a286c33 100644
--- a/docs/contracts.md
+++ b/docs/contracts.md
@@ -457,6 +457,17 @@ persistence must not fail the commerce flow.
as they become idle and resolves after requests and adapters have finished.
In 2.5, adapters stopped first and could close a store still in use by a
request.
+- 2.8.0: x402 health marks an offer's component with `undetermined: 'unreachable'`
+ for recognized transport failures, including refused, reset or timed-out
+ connections, temporary DNS failures and request timeouts. Unresolvable
+ hostnames, TLS or certificate errors, JSON-RPC errors, non-2xx responses and
+ reverts leave the component unmarked. MPP uses the same provider to report its
+ offer's health.
+ - `/.well-known` adds `status` and `undetermined` to a single-offer
+ `payments.x402` block and to `payments.mpp`, and `undetermined` to each
+ offer in `options` and `resourceOptions`.
+ - `doctor` reads them for `Payments (offers)` and the new
+ `Payments (MPP offers)` check.
### Authorization and AP2
diff --git a/docs/security.md b/docs/security.md
index c8f65e5..6f6e369 100644
--- a/docs/security.md
+++ b/docs/security.md
@@ -573,6 +573,9 @@ real funds.
| **the payment proof header as a bearer credential** | with matching input and any required mandate, `PAYMENT-SIGNATURE` retrieves the stored response until retention ends. Keep it out of proxy, APM and access logs; the gateway's logger redacts it | `tests/integration/payment-retries.test.ts` ("redelivers an exact resend, marked as a replay, without a second charge"), `tests/unit/gateway/logger.test.ts` ("redacts every wire header that carries a credential or a proof") |
| **a retention window outside 1 to 8760 hours** | config load refuses it, and a pipeline built without config throws `CONFIG_INVALID` before any payment work | `tests/unit/config/schema.test.ts` ("refuses a retention of %s hours as too long", "refuses a retention of %s", "accepts the longest retention, one year"), `tests/unit/core/execution/pipeline-retry.test.ts` ("refuses a retention of %s hours before any provider call", "accepts a retention of one year") |
| **an A2A in-flight refusal that tells the client to resend on the consumed task** | the failed task reports `retryable: false` with no `retryAfterSeconds`; the client starts a new task with the same payment `id` | `tests/unit/protocols-a2a/payment-resume.test.ts` ("does not tell the client to retry an in-flight payment id on the consumed task") |
+| **`doctor` reporting a misconfigured RPC or facilitator as unreachable** | marks an offer `unreachable` for recognized transport failures, including refused or reset connections, temporary DNS failures and timeouts. Unresolvable hostnames, TLS and certificate errors, JSON-RPC errors, non-2xx responses, reverts, unparseable bodies, missing peers and unrecognized errors fail without this marker | `tests/unit/core/no-answer.test.ts` ("is false for %s"), `tests/unit/payments-x402/provider-health-mocked.test.ts` ("leaves the %s unmarked after %s"), `tests/integration/doctor-certainty.test.ts` ("%s: %s FAILs unmarked when %s") |
+| **`doctor` reporting a gateway that answered as unreachable** | marks `Gateway` `unreachable` for recognized transport failures, including refused or reset connections and timeouts. Unresolvable hostnames, ports rejected by fetch, non-2xx `/health` responses and Host refusals fail unmarked; checks that need the discovery document are `skipped`. Responses with unusable document content leave those checks unmarked | `tests/unit/cli/doctor-certainty.test.ts` ("when %s", "says a gateway that answered non-2xx is unhealthy, not unreachable"), `tests/integration/doctor-certainty.test.ts` ("leaves Gateway unmarked, and says why, when fetch refuses the port") |
+| **the `doctor` Secrets check printing a value or a default** | reports placeholder names in text and JSON, never variable values or defaults | `tests/unit/cli/doctor-certainty.test.ts` ("FAILs naming every missing variable, and prints no value or default"), `tests/unit/config/env.test.ts` ("returns names only: no value and no default") |
A facilitator verdict is a returned result. The SDK throws when a remote
`/verify` answers with a non-2xx status; the binding turns that throw back into
diff --git a/plugins/agent-commerce-gateway/skills/agent-commerce/references/troubleshooting.md b/plugins/agent-commerce-gateway/skills/agent-commerce/references/troubleshooting.md
index 80e0d51..061fb01 100644
--- a/plugins/agent-commerce-gateway/skills/agent-commerce/references/troubleshooting.md
+++ b/plugins/agent-commerce-gateway/skills/agent-commerce/references/troubleshooting.md
@@ -77,12 +77,21 @@ before retrying; the gateway does not refund the payment automatically.
otherwise it is 0, even with warnings. For L2, also require a passing `Gateway`
check and report warnings.
-| Check | Not passing means |
-| ---------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
-| `Config` | `validate` would fail; fix that first |
-| `Gateway` | `FAIL`: `/health` is unreachable or returns a non-2xx status. Check the URL derived from `server.host` and `server.port`, or pass `--gateway `. `WARN`: `/health` passed but `/ready` did not; inspect `/ready` for store, adapter or provider failures |
-| `Backend` | No HTTP response from some or all distinct configured URLs. Probes use GET without backend headers or a body, substitute `demo-check` for path parameters and accept any HTTP status as reachable. Check the API and `MERCHANT_API_BASE_URL`; a PASS does not verify the configured operation |
-| `Protocols` | The gateway's `/.well-known/agent-commerce` is unreachable |
-| `Payments`, `Payments (MPP)` | The running gateway's live offers or MPP setting differ from the config, usually because it runs an older config. Restart it |
-| `Payments (offers)` | `FAIL`: an offer's health check fails; `WARN`: one is degraded. Causes include an unreachable RPC or facilitator, or a missing Solana, NEAR or CDP peer. Inspect `/ready`; the gateway logs each reason at debug level |
-| `Storage` | `WARN`: no receipts file at `storage.receipts.path` yet, or the running gateway uses another path. `FAIL`: the file cannot be opened |
+A check that cannot reach a verdict carries `undetermined`: `unreachable`
+for a recognized transport failure, or `skipped` when a prerequisite fails.
+For an `unreachable` `Gateway` or `Backend`, check the service, its address and
+network access. An unmarked failure naming `ENOTFOUND`, a certificate or
+`bad port` calls for checking DNS, TLS configuration and the URL. For a
+`skipped` check, fix the failing `Config` or `Gateway` first. Text output
+appends `[not determined: ]`.
+
+| Check | Not passing means |
+| -------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
+| `Config` | `validate` would fail; fix that first |
+| `Secrets` | `FAIL`: a `${VAR}` placeholder in the config is unset; the detail lists all missing names, never values. Set them in the environment or in a file passed with `--env-file` |
+| `Gateway` | `FAIL`: `/health` could not be checked or returned a non-2xx status. The `unreachable` marker identifies recognized transport failures. Check the URL derived from `server.host` and `server.port`, or pass `--gateway `. `WARN`: `/health` passed but `/ready` did not; inspect `/ready` for store, adapter or provider failures |
+| `Backend` | No HTTP response from some or all distinct configured URLs. Probes use GET without backend headers or a body, substitute `demo-check` for path parameters and accept any HTTP status as reachable. Check the API and `MERCHANT_API_BASE_URL`; a PASS does not verify the configured operation |
+| `Protocols` | The gateway's `/.well-known/agent-commerce` gave no answer or a non-2xx status |
+| `Payments`, `Payments (MPP)` | The running gateway's live offers or MPP setting differ from the config, usually because it runs an older config. Restart it |
+| `Payments (offers)`, `Payments (MPP offers)` | `FAIL`: an offer's health check fails; `WARN`: one is degraded. `unreachable` means every failing or degraded offer has a recognized RPC or facilitator transport failure. Unmarked failures can indicate a bad response, a hostname that does not resolve, a TLS error, or a missing Solana, NEAR or CDP peer. Inspect `/ready`; the gateway logs each reason at debug level |
+| `Storage` | `WARN`: no receipts file at `storage.receipts.path` yet, or the running gateway uses another path. `FAIL`: the file cannot be opened |
diff --git a/src/cli/commands/doctor/ap2.ts b/src/cli/commands/doctor/ap2.ts
index 6336d15..810c1b2 100644
--- a/src/cli/commands/doctor/ap2.ts
+++ b/src/cli/commands/doctor/ap2.ts
@@ -11,7 +11,7 @@ import ap2Record from '../../../support/ap2.json' with { type: 'json' };
import { exclusionNames } from '../../../support/claims';
import type { GatewayConfig } from '../../lib/config-client';
import { type LegacyState, legacyStoreCheck } from './storage';
-import type { DoctorCheck } from './types';
+import { type DoctorCheck, SKIPPED_CONFIG_INVALID } from './types';
// Issuer ids and how many keys each carries. Never a key
function describeIssuers(
@@ -33,7 +33,7 @@ export function ap2Checks(config: GatewayConfig | undefined, legacy: LegacyState
// issuer ids and key counts appear.
const ap2 = config?.authorization?.ap2;
if (config === undefined) {
- checks.push({ name: 'AP2', status: 'WARN', detail: 'skipped: config invalid' });
+ checks.push({ name: 'AP2', status: 'WARN', ...SKIPPED_CONFIG_INVALID });
} else if (ap2 === undefined || !ap2.enabled) {
checks.push({ name: 'AP2', status: 'INFO', detail: 'disabled' });
} else {
diff --git a/src/cli/commands/doctor/index.ts b/src/cli/commands/doctor/index.ts
index bf1a479..ae978f9 100644
--- a/src/cli/commands/doctor/index.ts
+++ b/src/cli/commands/doctor/index.ts
@@ -5,7 +5,11 @@ import {
createSqliteReceiptStore,
openSqliteReceiptStoreReadOnly,
} from '../../../storage/receipts';
-import { type GatewayConfig, loadConfigDynamic } from '../../lib/config-client';
+import {
+ type GatewayConfig,
+ loadConfigDynamic,
+ readConfigFileDynamic,
+} from '../../lib/config-client';
import { fetchJson } from '../../lib/http';
import {
fillEnvFromLocalChainManifest,
@@ -17,8 +21,18 @@ import { readVersionReport } from '../../lib/versions';
import { ap2Checks } from './ap2';
import { paymentChecks } from './payments';
import { protocolChecks } from './protocols';
+import { secretsCheck } from './secrets';
import { storageChecks } from './storage';
-import type { CheckStatus, DoctorCheck, DoctorDeps, DoctorOptions, DoctorReport } from './types';
+import {
+ type CheckStatus,
+ type DoctorCheck,
+ type DoctorDeps,
+ type DoctorOptions,
+ type DoctorReport,
+ SKIPPED_CONFIG_INVALID,
+ type Undetermined,
+ undeterminedField,
+} from './types';
const CHECK_TIMEOUT_MS = 1500;
@@ -101,22 +115,39 @@ export async function runDoctor(
});
}
+ // Skip Secrets when an injected loader has no reader; the default could read
+ // a different config
+ const readConfigFile =
+ deps.readConfigFile ?? (deps.loadConfig === undefined ? readConfigFileDynamic : undefined);
+ if (readConfigFile !== undefined) {
+ checks.push(await secretsCheck(readConfigFile, options.configPath, env));
+ }
+
const gatewayUrl = deriveGatewayUrl(options.gatewayUrl, config);
- // 2. Gateway
+ // 2. Gateway. Status 0 means the request threw; `noAnswer` identifies a known
+ // transport failure. Hostname and TLS errors remain unmarked.
const health = await fetchJson(fetchImpl, `${gatewayUrl}/health`, CHECK_TIMEOUT_MS);
let gatewayUp = false;
+ // Why the checks that read the well-known document have no live data
+ let liveCause: Undetermined | undefined;
if (!health.ok) {
+ liveCause = health.noAnswer ? 'unreachable' : 'skipped';
checks.push({
name: 'Gateway',
status: 'FAIL',
- detail: `unreachable at ${gatewayUrl} (${health.error ?? `HTTP ${health.status}`})`,
+ detail:
+ health.status === 0
+ ? `unreachable at ${gatewayUrl} (${health.error ?? 'no answer'})`
+ : `unhealthy at ${gatewayUrl} (HTTP ${health.status})`,
+ ...undeterminedField(health.noAnswer ? 'unreachable' : undefined),
});
} else {
const ready = await fetchJson(fetchImpl, `${gatewayUrl}/ready`, CHECK_TIMEOUT_MS);
// Doctor sends no Origin header, so a 403 from /ready means the Host was
// rejected. GET /health skips the Host check used by other routes.
if (ready.status === 403) {
+ liveCause = 'skipped';
checks.push({
name: 'Gateway',
status: 'FAIL',
@@ -131,6 +162,7 @@ export async function runDoctor(
name: 'Gateway',
status: 'WARN',
detail: `healthy but not ready at ${gatewayUrl} (${ready.error ?? `HTTP ${ready.status}`})`,
+ ...undeterminedField(ready.noAnswer ? 'unreachable' : undefined),
},
);
}
@@ -138,7 +170,7 @@ export async function runDoctor(
// 3. Backend(s)
if (config === undefined) {
- checks.push({ name: 'Backend', status: 'WARN', detail: 'skipped: config invalid' });
+ checks.push({ name: 'Backend', status: 'WARN', ...SKIPPED_CONFIG_INVALID });
} else if (config.resources.length === 0) {
checks.push({ name: 'Backend', status: 'INFO', detail: 'no resources configured' });
} else {
@@ -147,13 +179,19 @@ export async function runDoctor(
const results = await Promise.all(
urls.map((url) => fetchJson(fetchImpl, url, CHECK_TIMEOUT_MS)),
);
- const reachable = results.filter((r) => r.status !== 0).length;
+ // Any HTTP response establishes reachability. Mark unreachable only when all
+ // requests that threw have recognized transport failures.
+ const unreached = results.filter((r) => r.status === 0);
+ const reachable = urls.length - unreached.length;
const status: CheckStatus =
reachable === urls.length ? 'PASS' : reachable === 0 ? 'FAIL' : 'WARN';
checks.push({
name: 'Backend',
status,
detail: `${reachable}/${urls.length} backend host(s) reachable`,
+ ...undeterminedField(
+ unreached.length > 0 && unreached.every((r) => r.noAnswer) ? 'unreachable' : undefined,
+ ),
});
}
@@ -165,14 +203,23 @@ export async function runDoctor(
CHECK_TIMEOUT_MS,
)
: undefined;
+ // Clear the marker after any document response, even if its content is unusable
+ if (wellKnown !== undefined) liveCause = wellKnown.noAnswer ? 'unreachable' : undefined;
// 5-7. Protocols, AP2, payments and storage. Read import records first so
// protocol and AP2 checks can report the status of deprecated store keys.
const storage = await storageChecks(config, createStore);
- checks.push(...protocolChecks(config, wellKnown, storage.legacy));
+ checks.push(...protocolChecks(config, wellKnown, storage.legacy, liveCause));
checks.push(...ap2Checks(config, storage.legacy));
checks.push(
- ...(await paymentChecks(config, wellKnown, gatewayUrl, chainDeploy, deps.loadViemAccounts)),
+ ...(await paymentChecks(
+ config,
+ wellKnown,
+ gatewayUrl,
+ chainDeploy,
+ deps.loadViemAccounts,
+ liveCause,
+ )),
);
checks.push(...storage.checks);
@@ -188,7 +235,8 @@ export async function runDoctor(
checks.push({
name: 'Protocol versions',
status: 'INFO',
- detail: `gateway unreachable; local pins: ${local.pinned.map((p) => `${p.name}@${p.version}`).join(', ')}`,
+ detail: `${liveCause === 'unreachable' ? 'gateway unreachable' : 'gateway versions unavailable'}; local pins: ${local.pinned.map((p) => `${p.name}@${p.version}`).join(', ')}`,
+ ...undeterminedField(liveCause),
});
}
@@ -200,4 +248,11 @@ export async function runDoctor(
}
export { printDoctorReport } from './report';
-export type { CheckStatus, DoctorCheck, DoctorDeps, DoctorOptions, DoctorReport } from './types';
+export type {
+ CheckStatus,
+ DoctorCheck,
+ DoctorDeps,
+ DoctorOptions,
+ DoctorReport,
+ Undetermined,
+} from './types';
diff --git a/src/cli/commands/doctor/payments.ts b/src/cli/commands/doctor/payments.ts
index c8f6515..e452d29 100644
--- a/src/cli/commands/doctor/payments.ts
+++ b/src/cli/commands/doctor/payments.ts
@@ -23,7 +23,13 @@ import x402Record from '../../../support/x402.json' with { type: 'json' };
import type { GatewayConfig } from '../../lib/config-client';
import { PLACEHOLDER_ASSET_ADDRESS } from '../../lib/init-config';
import { maskMiddle } from '../../lib/mask';
-import type { DoctorCheck, WellKnownResult } from './types';
+import {
+ type DoctorCheck,
+ SKIPPED_CONFIG_INVALID,
+ type Undetermined,
+ undeterminedField,
+ type WellKnownResult,
+} from './types';
const QUOTE_STATUS = featureStatus(x402Record, 'erc-8409-quotes');
@@ -51,6 +57,8 @@ interface RailOffer {
readonly assetTransferMethod?: string;
/** The live offer's health status, when the gateway publishes it */
readonly status?: string;
+ // Set when the gateway reports the offer's probe as unreachable
+ readonly undetermined?: 'unreachable';
}
// A rail's terms, as configured or as the running gateway publishes them
@@ -67,7 +75,7 @@ interface RailTerms {
type LiveRailResult = RailTerms | 'disabled' | undefined;
function readOffer(rec: Record, rail: 'x402' | 'mpp'): RailOffer | undefined {
- const { asset, network, assetDecimals, assetTransferMethod, status } = rec;
+ const { asset, network, assetDecimals, assetTransferMethod, status, undetermined } = rec;
const payTo = rec[rail === 'mpp' ? 'recipient' : 'payTo'];
if (typeof asset !== 'string' || typeof network !== 'string' || typeof payTo !== 'string') {
return undefined;
@@ -79,6 +87,7 @@ function readOffer(rec: Record, rail: 'x402' | 'mpp'): RailOffe
...(typeof assetDecimals === 'number' ? { assetDecimals } : {}),
...(typeof assetTransferMethod === 'string' ? { assetTransferMethod } : {}),
...(typeof status === 'string' ? { status } : {}),
+ ...(undetermined === 'unreachable' ? { undetermined } : {}),
};
}
@@ -292,6 +301,7 @@ function railOffer(option: {
function offerHealthCheck(
live: RailTerms,
named: (network: string) => string,
+ name: string,
): DoctorCheck | undefined {
const all = [...live.offers, ...Object.values(live.resourceOffers ?? {}).flat()];
const offers = [
@@ -312,7 +322,7 @@ function offerHealthCheck(
.join('; ');
if (failing.length === 0 && degraded.length === 0) {
return {
- name: 'Payments (offers)',
+ name,
status: 'PASS',
detail: `${reported.length} offer(s) pass their health checks`,
};
@@ -321,10 +331,13 @@ function offerHealthCheck(
...(failing.length > 0 ? [`failing: ${describe(failing)}`] : []),
...(degraded.length > 0 ? [`degraded: ${describe(degraded)}`] : []),
];
+ // Keep the aggregate unmarked if any failing or degraded offer is unmarked
+ const unanswered = [...failing, ...degraded].every((offer) => offer.undetermined !== undefined);
return {
- name: 'Payments (offers)',
+ name,
status: failing.length > 0 ? 'FAIL' : 'WARN',
detail: `${problems.join('; ')}. The gateway logs each reason at debug level`,
+ ...undeterminedField(unanswered ? 'unreachable' : undefined),
};
}
@@ -384,6 +397,7 @@ function quoteCheck(
body: Record | undefined,
gatewayUrl: string,
stale: string,
+ liveCause: Undetermined | undefined,
): DoctorCheck | undefined {
const name = 'Payments (quotes)';
if (enabled && local === 'invalid') {
@@ -404,6 +418,7 @@ function quoteCheck(
name,
status: 'INFO',
detail: `ERC-8409 quotes enabled (${QUOTE_STATUS})${localIssuer !== undefined ? `, issuer=${localIssuer} from the local key` : ''}; the gateway's issuer could not be read`,
+ ...undeterminedField(liveCause),
}
: undefined;
}
@@ -447,13 +462,17 @@ export async function paymentChecks(
chainDeploy = false,
// Load this optional peer only when local x402 quote signing is enabled
loadAccounts: LoadViemAccounts = () => import('viem/accounts'),
+ // Why the well-known document was not obtained; absent after a response
+ liveCause?: Undetermined,
): Promise {
const checks: DoctorCheck[] = [];
// Suggest the repository deployment script only when the caller found it
const stale = `; the gateway may be running against an older deployment - restart it${chainDeploy ? ' or re-run chain:deploy' : ''}`;
// 6. Payments
const x402 = config?.payments.x402;
- if (x402 === undefined || !x402.enabled) {
+ if (config === undefined) {
+ checks.push({ name: 'Payments', status: 'INFO', ...SKIPPED_CONFIG_INVALID });
+ } else if (x402 === undefined || !x402.enabled) {
checks.push({ name: 'Payments', status: 'INFO', detail: 'x402 not configured' });
} else {
const options = x402.options ?? [x402];
@@ -501,6 +520,7 @@ export async function paymentChecks(
name: 'Payments',
status: 'INFO',
detail: `${summary} (gateway's live settlement config could not be verified)`,
+ ...undeterminedField(liveCause),
});
} else {
const configured: RailTerms = {
@@ -523,7 +543,7 @@ export async function paymentChecks(
? { name: 'Payments', status: 'PASS', detail: summary }
: { name: 'Payments', status: 'FAIL', detail: `${mismatch}${stale}` },
);
- const offerHealth = offerHealthCheck(live, named);
+ const offerHealth = offerHealthCheck(live, named, 'Payments (offers)');
if (offerHealth !== undefined) checks.push(offerHealth);
}
const quotes = quoteCheck(
@@ -535,6 +555,7 @@ export async function paymentChecks(
wellKnown?.ok ? wellKnown.body : undefined,
gatewayUrl,
stale,
+ liveCause,
);
if (quotes !== undefined) checks.push(quotes);
if (mode === 'mainnet') {
@@ -550,7 +571,9 @@ export async function paymentChecks(
}
}
const mpp = config?.payments.mpp;
- if (mpp === undefined || !mpp.enabled) {
+ if (config === undefined) {
+ checks.push({ name: 'Payments (MPP)', status: 'INFO', ...SKIPPED_CONFIG_INVALID });
+ } else if (mpp === undefined || !mpp.enabled) {
checks.push({ name: 'Payments (MPP)', status: 'INFO', detail: 'MPP not configured' });
} else {
const { mode, where, via } = describeSettlement(mpp.network, mpp.facilitator);
@@ -586,6 +609,7 @@ export async function paymentChecks(
name: 'Payments (MPP)',
status: 'INFO',
detail: `${summary} (live MPP settlement config unavailable for comparison)`,
+ ...undeterminedField(liveCause),
});
} else {
const mismatch = findRailMismatch(configured, live, 'recipient');
@@ -594,6 +618,12 @@ export async function paymentChecks(
? { name: 'Payments (MPP)', status: 'PASS', detail: summary }
: { name: 'Payments (MPP)', status: 'FAIL', detail: `${mismatch}${stale}` },
);
+ const offerHealth = offerHealthCheck(
+ live,
+ (network) => `${findX402Network(network)?.displayName ?? 'unknown network'} (${network})`,
+ 'Payments (MPP offers)',
+ );
+ if (offerHealth !== undefined) checks.push(offerHealth);
}
if (mode === 'mainnet') {
checks.push(
diff --git a/src/cli/commands/doctor/protocols.ts b/src/cli/commands/doctor/protocols.ts
index dff2337..6f533e0 100644
--- a/src/cli/commands/doctor/protocols.ts
+++ b/src/cli/commands/doctor/protocols.ts
@@ -18,7 +18,13 @@ import acpRecord from '../../../support/acp.json' with { type: 'json' };
import { exclusionNames } from '../../../support/claims';
import type { GatewayConfig } from '../../lib/config-client';
import { type LegacyState, legacyStoreCheck } from './storage';
-import type { DoctorCheck, WellKnownResult } from './types';
+import {
+ type DoctorCheck,
+ SKIPPED_CONFIG_INVALID,
+ type Undetermined,
+ undeterminedField,
+ type WellKnownResult,
+} from './types';
/**
* The resource mapped to each checkout operation, re-checked against the rules
@@ -64,13 +70,23 @@ export function protocolChecks(
config: GatewayConfig | undefined,
wellKnown: WellKnownResult | undefined,
legacy: LegacyState,
+ // Why the well-known document was not obtained; absent after a response
+ liveCause?: Undetermined,
): DoctorCheck[] {
const checks: DoctorCheck[] = [];
// 5. Protocols
if (config === undefined) {
- checks.push({ name: 'Protocols', status: 'WARN', detail: 'skipped: config invalid' });
+ checks.push({ name: 'Protocols', status: 'WARN', ...SKIPPED_CONFIG_INVALID });
} else if (wellKnown === undefined || !wellKnown.ok) {
- checks.push({ name: 'Protocols', status: 'FAIL', detail: 'well-known document unreachable' });
+ checks.push({
+ name: 'Protocols',
+ status: 'FAIL',
+ detail:
+ wellKnown === undefined || wellKnown.status === 0
+ ? 'well-known document unreachable'
+ : `well-known document unavailable (HTTP ${wellKnown.status})`,
+ ...undeterminedField(liveCause),
+ });
} else {
const mcpMountPath = config.protocols.mcp.enabled ? config.protocols.mcp.mountPath : undefined;
const a2aMountPath = config.protocols.a2a.enabled ? config.protocols.a2a.mountPath : undefined;
@@ -84,7 +100,7 @@ export function protocolChecks(
// 5b. A2A specifics, from the pins rather than the live gateway. The spec
// revision and the negotiation version look alike, so each is named.
if (config === undefined) {
- checks.push({ name: 'A2A', status: 'WARN', detail: 'skipped: config invalid' });
+ checks.push({ name: 'A2A', status: 'WARN', ...SKIPPED_CONFIG_INVALID });
} else if (!config.protocols.a2a.enabled) {
checks.push({ name: 'A2A', status: 'INFO', detail: 'disabled' });
} else {
@@ -106,7 +122,7 @@ export function protocolChecks(
// the bearer token, the idempotency path and the operation mapping. This
// report prints the path and the mapping, never the token.
if (config === undefined) {
- checks.push({ name: 'ACP', status: 'WARN', detail: 'skipped: config invalid' });
+ checks.push({ name: 'ACP', status: 'WARN', ...SKIPPED_CONFIG_INVALID });
} else if (!config.protocols.acp.enabled) {
checks.push({ name: 'ACP', status: 'INFO', detail: 'disabled' });
} else {
diff --git a/src/cli/commands/doctor/report.ts b/src/cli/commands/doctor/report.ts
index f192026..879878c 100644
--- a/src/cli/commands/doctor/report.ts
+++ b/src/cli/commands/doctor/report.ts
@@ -23,7 +23,8 @@ export function printDoctorReport(report: DoctorReport, io: Io, json: boolean):
}
for (const check of report.checks) {
const label = statusColor(check.status, check.status.padEnd(5));
- io.stdout(`${label} ${check.name.padEnd(20)} ${check.detail}`);
+ const mark = check.undetermined !== undefined ? ` [not determined: ${check.undetermined}]` : '';
+ io.stdout(`${label} ${check.name.padEnd(20)} ${check.detail}${mark}`);
}
io.stdout('');
io.stdout(`Score: ${report.score.passed}/${report.score.total} checks passed`);
diff --git a/src/cli/commands/doctor/secrets.ts b/src/cli/commands/doctor/secrets.ts
new file mode 100644
index 0000000..d2e9c3b
--- /dev/null
+++ b/src/cli/commands/doctor/secrets.ts
@@ -0,0 +1,42 @@
+// Secrets: every `${VAR}` placeholder in the raw config, by name and never by value
+
+import { listEnvPlaceholders } from '../../../config/env';
+import type { ConfigFileReader } from '../../lib/config-client';
+import type { DoctorCheck } from './types';
+
+/**
+ * List all missing config variables; config loading stops at the first.
+ * Return names only, since values and defaults may contain credentials.
+ */
+export async function secretsCheck(
+ read: ConfigFileReader,
+ path: string | undefined,
+ env: NodeJS.ProcessEnv,
+): Promise {
+ let raw: unknown;
+ try {
+ raw = await read({ ...(path !== undefined ? { path } : {}), env });
+ } catch {
+ // The Config check reports why
+ return {
+ name: 'Secrets',
+ status: 'WARN',
+ detail: 'skipped: config file unreadable',
+ undetermined: 'skipped',
+ };
+ }
+ const { missing, set, defaulted } = listEnvPlaceholders(raw, env);
+ const groups = [
+ ...(missing.length > 0 ? [`${missing.length} missing (${missing.join(', ')})`] : []),
+ ...(set.length > 0 ? [`${set.length} set (${set.join(', ')})`] : []),
+ ...(defaulted.length > 0 ? [`${defaulted.length} defaulted (${defaulted.join(', ')})`] : []),
+ ];
+ if (groups.length === 0) {
+ return { name: 'Secrets', status: 'INFO', detail: 'config reads no environment variable' };
+ }
+ return {
+ name: 'Secrets',
+ status: missing.length > 0 ? 'FAIL' : 'PASS',
+ detail: groups.join('; '),
+ };
+}
diff --git a/src/cli/commands/doctor/storage.ts b/src/cli/commands/doctor/storage.ts
index 65f5855..2a4bde3 100644
--- a/src/cli/commands/doctor/storage.ts
+++ b/src/cli/commands/doctor/storage.ts
@@ -10,7 +10,12 @@ import {
type SqliteReceiptStoreSummary,
} from '../../../storage/receipts';
import type { GatewayConfig } from '../../lib/config-client';
-import type { CheckStatus, DoctorCheck, DoctorStore } from './types';
+import {
+ type CheckStatus,
+ type DoctorCheck,
+ type DoctorStore,
+ SKIPPED_CONFIG_INVALID,
+} from './types';
// Whether an existing file is writable, without creating one
function isWritableFile(path: string): boolean {
@@ -141,7 +146,7 @@ export async function storageChecks(
// 7. Storage
if (config === undefined) {
return {
- checks: [{ name: 'Storage', status: 'WARN', detail: 'skipped: config invalid' }],
+ checks: [{ name: 'Storage', status: 'WARN', ...SKIPPED_CONFIG_INVALID }],
legacy: undefined,
};
}
diff --git a/src/cli/commands/doctor/types.ts b/src/cli/commands/doctor/types.ts
index dee5636..6824522 100644
--- a/src/cli/commands/doctor/types.ts
+++ b/src/cli/commands/doctor/types.ts
@@ -1,17 +1,26 @@
// The report doctor builds, and what a caller can inject
import type { ReceiptStore } from '../../../core';
import type { SqliteReceiptStore } from '../../../storage/receipts';
-import type { ConfigLoader } from '../../lib/config-client';
+import type { ConfigFileReader, ConfigLoader } from '../../lib/config-client';
import type { FetchJsonResult, FetchLike } from '../../lib/http';
import type { ManifestEnvFill } from '../../lib/manifest-env';
import type { LoadViemAccounts } from './payments';
export type CheckStatus = 'PASS' | 'WARN' | 'FAIL' | 'INFO';
+/**
+ * Why a check could not reach a verdict: `unreachable` for a recognized
+ * transport failure, or `skipped` for a failed prerequisite. The marker does
+ * not affect the check's status, the score or the exit code.
+ */
+export type Undetermined = 'unreachable' | 'skipped';
+
export interface DoctorCheck {
readonly name: string;
readonly status: CheckStatus;
readonly detail: string;
+ /** Absent on a result that is a verdict */
+ readonly undetermined?: Undetermined;
}
export interface DoctorReport {
@@ -31,6 +40,12 @@ export type DoctorStore = ReceiptStore & { readonly summary?: SqliteReceiptStore
export interface DoctorDeps {
readonly fetchImpl?: FetchLike;
readonly loadConfig?: ConfigLoader;
+ /**
+ * Reads raw config for the Secrets check. The default reader is used only
+ * when neither this reader nor `loadConfig` is injected; an injected loader
+ * without a reader skips the check.
+ */
+ readonly readConfigFile?: ConfigFileReader;
readonly createStore?: (path: string) => DoctorStore;
readonly fillEnvFromManifest?: (env: NodeJS.ProcessEnv) => ManifestEnvFill;
readonly hasChainDeployScript?: () => boolean;
@@ -38,3 +53,16 @@ export interface DoctorDeps {
}
export type WellKnownResult = FetchJsonResult>;
+
+/** Returns `{ undetermined }` when a reason is given, otherwise an empty object */
+export function undeterminedField(reason: Undetermined | undefined): {
+ readonly undetermined?: Undetermined;
+} {
+ return reason !== undefined ? { undetermined: reason } : {};
+}
+
+/** The fields of a check that did not run because config failed to load */
+export const SKIPPED_CONFIG_INVALID = {
+ detail: 'skipped: config invalid',
+ undetermined: 'skipped',
+} as const;
diff --git a/src/cli/lib/config-client.ts b/src/cli/lib/config-client.ts
index 9030882..aa2ff9e 100644
--- a/src/cli/lib/config-client.ts
+++ b/src/cli/lib/config-client.ts
@@ -16,6 +16,9 @@ export interface LoadConfigOptions {
export type ConfigLoader = (options?: LoadConfigOptions) => Promise;
+/** Reads the loader's raw config before environment substitution and validation */
+export type ConfigFileReader = (options?: LoadConfigOptions) => Promise;
+
/** Validates an already-built raw config object, without touching the disk */
export type ConfigParser = (raw: unknown, env?: NodeJS.ProcessEnv) => Promise;
@@ -34,6 +37,10 @@ export async function loadConfigDynamic(options: LoadConfigOptions = {}): Promis
return (await importConfig()).loadConfig(options);
}
+export async function readConfigFileDynamic(options: LoadConfigOptions = {}): Promise {
+ return (await importConfig()).readConfigFile(options);
+}
+
/** Validates a raw config object in memory; `init` uses it to validate before writing */
export async function parseConfigDynamic(
raw: unknown,
diff --git a/src/cli/lib/http.ts b/src/cli/lib/http.ts
index 6b23ff5..584f6bb 100644
--- a/src/cli/lib/http.ts
+++ b/src/cli/lib/http.ts
@@ -1,3 +1,5 @@
+import { gotNoAnswer } from '../../core/no-answer';
+
/**
* Fetch with a timeout, for `doctor`. `fetchImpl` is injected so tests can
* pass a fake `fetch` and never touch the network.
@@ -6,9 +8,12 @@ export type FetchLike = typeof fetch;
export interface FetchJsonResult {
readonly ok: boolean;
+ /** The HTTP status, or 0 when the request threw */
readonly status: number;
readonly body?: T;
readonly error?: string;
+ /** Present when `gotNoAnswer` recognizes a transport failure */
+ readonly noAnswer?: true;
}
export async function fetchJson(
@@ -30,7 +35,16 @@ export async function fetchJson(
return {
ok: false,
status: 0,
- error: err instanceof Error ? err.message : 'unknown fetch error',
+ error: errorText(err),
+ ...(gotNoAnswer(err) ? { noAnswer: true as const } : {}),
};
}
}
+
+// Include a nested cause's message to explain undici's generic "fetch failed"
+function errorText(err: unknown): string {
+ if (!(err instanceof Error)) return 'unknown fetch error';
+ let root = err;
+ for (let depth = 0; depth < 10 && root.cause instanceof Error; depth++) root = root.cause;
+ return root === err ? err.message : `${err.message}: ${root.message}`;
+}
diff --git a/src/config/env.ts b/src/config/env.ts
index ed6cde7..9728a49 100644
--- a/src/config/env.ts
+++ b/src/config/env.ts
@@ -47,6 +47,50 @@ export function substituteEnv(value: unknown, env: NodeJS.ProcessEnv, path = '$'
return value;
}
+/** Sorted placeholder names from raw config, grouped by how they resolve in the environment */
+export interface EnvPlaceholders {
+ /** `${VAR}` with `VAR` unset; config loading stops at the first missing variable */
+ readonly missing: readonly string[];
+ /** `${VAR:-default}` with `VAR` unset or empty */
+ readonly defaulted: readonly string[];
+ readonly set: readonly string[];
+}
+
+/**
+ * Collect recognized placeholder names without validating template syntax;
+ * config loading reports unsupported templates. Each name appears once, using
+ * the most severe state: missing, then defaulted, then set. Return names only,
+ * never values or defaults.
+ */
+export function listEnvPlaceholders(raw: unknown, env: NodeJS.ProcessEnv): EnvPlaceholders {
+ // 0 set, 1 defaulted, 2 missing: a higher number is worse
+ const worst = new Map();
+ const visit = (value: unknown): void => {
+ if (typeof value === 'string') {
+ for (const [, name = '', hasDefault] of value.matchAll(PLACEHOLDER_PATTERN)) {
+ const envValue = env[name];
+ const state =
+ hasDefault !== undefined
+ ? envValue === undefined || envValue === ''
+ ? 1
+ : 0
+ : envValue === undefined
+ ? 2
+ : 0;
+ worst.set(name, Math.max(state, worst.get(name) ?? 0));
+ }
+ } else if (Array.isArray(value)) {
+ value.forEach(visit);
+ } else if (isRecord(value)) {
+ Object.values(value).forEach(visit);
+ }
+ };
+ visit(raw);
+ const names = [...worst.keys()].sort();
+ const named = (state: number) => names.filter((name) => worst.get(name) === state);
+ return { missing: named(2), defaulted: named(1), set: named(0) };
+}
+
function substituteString(value: string, env: NodeJS.ProcessEnv, path: string): string {
assertTemplateIsSupported(value, path);
return substituteOnce(value, env, path);
diff --git a/src/config/index.ts b/src/config/index.ts
index da4bf04..622595a 100644
--- a/src/config/index.ts
+++ b/src/config/index.ts
@@ -1,7 +1,8 @@
// `config.yaml` schema, loader and environment substitution
-export { substituteEnv } from './env';
+export type { EnvPlaceholders } from './env';
+export { listEnvPlaceholders, substituteEnv } from './env';
export type { LoadConfigOptions } from './load';
-export { loadConfig } from './load';
+export { loadConfig, readConfigFile } from './load';
export type { GatewayConfig } from './schema';
export { parseConfig } from './schema';
diff --git a/src/config/load.ts b/src/config/load.ts
index fc773b1..90019df 100644
--- a/src/config/load.ts
+++ b/src/config/load.ts
@@ -18,6 +18,14 @@ export interface LoadConfigOptions {
}
export async function loadConfig(options: LoadConfigOptions = {}): Promise {
+ return parseConfig(await readConfigFile(options), options.env ?? process.env);
+}
+
+/**
+ * Read the same file as `loadConfig`, returning parsed YAML before environment
+ * substitution and config validation. File and YAML errors match `loadConfig`.
+ */
+export async function readConfigFile(options: LoadConfigOptions = {}): Promise {
const env = options.env ?? process.env;
const cwd = options.cwd ?? process.cwd();
const configPath = resolveConfigPath(options.path, env, cwd);
@@ -32,9 +40,8 @@ export async function loadConfig(options: LoadConfigOptions = {}): Promise>;
/** Absent unless the x402 provider signs ERC-8409 quotes */
readonly quote?: WellKnownX402Quote;
- };
+ } & OfferHealth;
/** Public settlement fields; excludes the challenge secret and facilitator credentials */
readonly mpp?: {
readonly enabled: boolean;
@@ -111,12 +111,23 @@ export interface WellKnownDocument {
readonly paymentFlow: X402PaymentFlow;
/** Resources that set their own flow, by id; absent when none does */
readonly resourcePaymentFlows?: Readonly>;
- };
+ } & OfferHealth;
};
}
+/**
+ * Public probe results for one offer, without diagnostic detail. On a rail
+ * block, these fields describe its own offer and appear only when `options`
+ * is absent.
+ */
+export interface OfferHealth {
+ readonly status?: AdapterHealth['status'];
+ /** Marks an unreachable probe; `status` does not describe the offer's health */
+ readonly undetermined?: 'unreachable';
+}
+
/** One x402 offer's public terms */
-export interface WellKnownX402Offer {
+export interface WellKnownX402Offer extends OfferHealth {
readonly network: string;
readonly asset: string;
readonly assetName?: string;
@@ -124,8 +135,6 @@ export interface WellKnownX402Offer {
readonly assetDecimals: number;
readonly payTo: string;
readonly assetTransferMethod?: 'permit2';
- /** Last reported health status, excluding diagnostic detail */
- readonly status?: AdapterHealth['status'];
}
/**
@@ -172,14 +181,25 @@ function publicProtocols(protocols: GatewayConfig['protocols']): WellKnownProtoc
};
}
+// Find the offer's probe by its x402 component name; return no fields if absent
+function offerHealth(
+ health: AdapterHealth | undefined,
+ offer: { readonly network: string; readonly asset: string; readonly payTo: string },
+): OfferHealth {
+ const name = x402OfferName(offer);
+ const component = health?.components?.find((candidate) => candidate.name === name);
+ if (component === undefined) return {};
+ const { status, undetermined } = component;
+ return { status, ...(undetermined !== undefined ? { undetermined } : {}) };
+}
+
// Allowlist public offer fields: RPC URLs can contain API keys
function publicOffer(
option: X402OptionConfig,
- statuses: ReadonlyMap,
+ health: AdapterHealth | undefined,
): WellKnownX402Offer {
const { network, asset, assetName, assetVersion, assetDecimals, payTo, assetTransferMethod } =
option;
- const status = statuses.get(x402OfferName(option));
return {
network,
asset,
@@ -188,7 +208,7 @@ function publicOffer(
assetDecimals,
payTo,
...(assetTransferMethod !== undefined ? { assetTransferMethod } : {}),
- ...(status !== undefined ? { status } : {}),
+ ...offerHealth(health, option),
};
}
@@ -218,10 +238,10 @@ export function buildWellKnownDocument(options: BuildWellKnownOptions): WellKnow
}));
const { x402, mpp } = options.config.payments;
- const x402Health = options.paymentHealth?.find((probed) => probed.name === 'x402')?.health;
- const offerStatuses = new Map(
- (x402Health?.components ?? []).map((component) => [component.name, component.status]),
- );
+ const probed = (name: string) =>
+ options.paymentHealth?.find((provider) => provider.name === name)?.health;
+ const x402Health = probed('x402');
+ const x402Options = x402?.options !== undefined && x402.options.length > 1 ? x402.options : [];
const quote = publicQuote(options.paymentProviders);
return {
@@ -258,15 +278,15 @@ export function buildWellKnownDocument(options: BuildWellKnownOptions): WellKnow
),
paymentFlow: x402.paymentFlow ?? X402_DEFAULT_PAYMENT_FLOW,
...flowOverrides(x402.resourcePaymentFlows),
- ...(x402.options !== undefined && x402.options.length > 1
- ? { options: x402.options.map((option) => publicOffer(option, offerStatuses)) }
- : {}),
+ ...(x402Options.length > 0
+ ? { options: x402Options.map((option) => publicOffer(option, x402Health)) }
+ : offerHealth(x402Health, x402)),
...(x402.resourceOptions !== undefined
? {
resourceOptions: Object.fromEntries(
Object.entries(x402.resourceOptions).map(([id, list]) => [
id,
- list.map((option) => publicOffer(option, offerStatuses)),
+ list.map((option) => publicOffer(option, x402Health)),
]),
),
}
@@ -289,6 +309,12 @@ export function buildWellKnownDocument(options: BuildWellKnownOptions): WellKnow
mode: resolveDeploymentMode(requireX402Network(mpp.network, 'payments.mpp.network')),
paymentFlow: mpp.paymentFlow ?? MPP_DEFAULT_PAYMENT_FLOW,
...flowOverrides(mpp.resourcePaymentFlows),
+ // MPP settles through an x402 provider, which names the offer
+ ...offerHealth(probed('mpp'), {
+ network: mpp.network,
+ asset: mpp.asset,
+ payTo: mpp.recipient,
+ }),
},
}
: {}),
diff --git a/src/payments/x402/facilitator.ts b/src/payments/x402/facilitator.ts
index 8cc1ea5..e9dfcaa 100644
--- a/src/payments/x402/facilitator.ts
+++ b/src/payments/x402/facilitator.ts
@@ -185,19 +185,18 @@ export function createRemoteFacilitatorBinding(
// The SDK bounds each attempt but not its retry waits. `Promise.race` keeps
// a handler on the abandoned call, so its later rejection is not unhandled.
+// The `TimeoutError` cause lets health() classify the deadline as unreachable.
function withDeadline(call: Promise, ms: number): Promise {
let timer: NodeJS.Timeout | undefined;
const deadline = new Promise((_, reject) => {
- timer = setTimeout(
- () =>
- reject(
- new CommerceError(
- 'PAYMENT_PROVIDER_UNAVAILABLE',
- `x402 provider: facilitator /supported did not answer within ${ms / 1000} s`,
- ),
- ),
- ms,
- );
+ timer = setTimeout(() => {
+ const message = `x402 provider: facilitator /supported did not answer within ${ms / 1000} s`;
+ reject(
+ new CommerceError('PAYMENT_PROVIDER_UNAVAILABLE', message, {
+ cause: new DOMException(message, 'TimeoutError'),
+ }),
+ );
+ }, ms);
timer.unref();
});
return Promise.race([call, deadline]).finally(() => clearTimeout(timer));
diff --git a/src/payments/x402/provider/health.ts b/src/payments/x402/provider/health.ts
index 4803d83..19791d7 100644
--- a/src/payments/x402/provider/health.ts
+++ b/src/payments/x402/provider/health.ts
@@ -6,6 +6,7 @@ import { erc20Abi } from 'viem';
import { type AdapterHealth, CommerceError } from '../../../core';
import { redactedErrorText } from '../../../core/errors';
import { isRecord } from '../../../core/is-record';
+import { gotNoAnswer } from '../../../core/no-answer';
import { normalizeAddress } from '../addresses';
import type { createLocalPublicClient } from '../chain';
import type { FacilitatorBinding } from '../facilitator';
@@ -281,27 +282,37 @@ export function createHealthCheck(ctx: ProviderContext): () => Promise
- offerHealth(offer, kinds).catch((err: unknown) => ({
- status: 'fail' as const,
- detail: `x402 health check failed: ${redactedErrorText(err)}`,
- })),
+ offerHealth(offer, kinds).catch(
+ (err: unknown): OfferResult => ({
+ status: 'fail',
+ detail: `x402 health check failed: ${redactedErrorText(err)}`,
+ // The SDK throws its own timeout error from `/supported`
+ ...(gotNoAnswer(err, ['FacilitatorTimeoutError'])
+ ? { undetermined: 'unreachable' }
+ : {}),
+ }),
+ ),
),
);
const failed = results.some((result) => result.status === 'fail');
const details = offers.flatMap((offer, index) => {
- const result = results[index] as (typeof results)[number];
+ const result = results[index] as OfferResult;
if (failed && result.status !== 'fail') return [];
return [offers.length === 1 ? result.detail : `${x402OfferName(offer)}: ${result.detail}`];
});
return {
status: failed ? 'fail' : 'pass',
detail: details.join('; '),
- components: offers.map((offer, index) => ({
- name: x402OfferName(offer),
- status: (results[index] as (typeof results)[number]).status,
- })),
+ components: offers.map((offer, index) => {
+ const { status, undetermined } = results[index] as OfferResult;
+ return {
+ name: x402OfferName(offer),
+ status,
+ ...(undetermined !== undefined ? { undetermined } : {}),
+ };
+ }),
checkedAt,
durationMs: clock.monotonicMs() - startedAt,
};
@@ -338,6 +349,13 @@ export function createHealthCheck(ctx: ProviderContext): () => Promise {
+ upstream = createServer((req, res) => {
+ const chunks: Buffer[] = [];
+ req.on('data', (chunk: Buffer) => chunks.push(chunk));
+ req.on('end', () => {
+ const path = req.url ?? '';
+ const reply = (value: unknown, status = 200) => {
+ res.writeHead(status, { 'content-type': 'application/json' });
+ res.end(JSON.stringify(value));
+ };
+ const rpc = /^\/rpc\/(\w+)$/.exec(path);
+ if (rpc) {
+ const { id, method } = JSON.parse(Buffer.concat(chunks).toString('utf8')) as {
+ id: number;
+ method: string;
+ };
+ const chainId = Number(rpc[1]);
+ const result =
+ method === 'eth_chainId'
+ ? `0x${chainId.toString(16)}`
+ : method === 'eth_getCode'
+ ? '0x6080'
+ : method === 'eth_call'
+ ? `0x${'6'.padStart(64, '0')}`
+ : undefined;
+ reply(
+ Number.isNaN(chainId) || result === undefined
+ ? { jsonrpc: '2.0', id, error: { code: -32601, message: `no ${method}` } }
+ : { jsonrpc: '2.0', id, result },
+ );
+ return;
+ }
+ if (path === '/facilitator/supported') {
+ reply({
+ kinds: [BASE_SEPOLIA, ARBITRUM_SEPOLIA].map((network) => ({
+ x402Version: 2,
+ scheme: 'exact',
+ network,
+ })),
+ extensions: [],
+ signers: {},
+ });
+ return;
+ }
+ if (path === '/denied/supported') {
+ reply({ error: 'unauthorized' }, 401);
+ return;
+ }
+ if (path.startsWith('/backend/')) {
+ reply({ ok: true });
+ return;
+ }
+ res.writeHead(404).end();
+ });
+ });
+ return new Promise((resolve) =>
+ upstream.listen(0, '127.0.0.1', () => {
+ upstreamUrl = `http://127.0.0.1:${(upstream.address() as AddressInfo).port}`;
+ resolve();
+ }),
+ );
+}
+
+interface Targets {
+ readonly rpc?: string;
+ readonly facilitator?: string;
+ readonly backend?: string;
+}
+
+// One paid resource on the given rail; every target defaults to the healthy upstream
+function config(rail: 'x402' | 'x402-multi' | 'mpp', targets: Targets = {}): GatewayConfig {
+ const rpc = targets.rpc ?? `${upstreamUrl}/rpc/84532`;
+ const facilitator = { mode: 'remote', url: targets.facilitator ?? `${upstreamUrl}/facilitator` };
+ const x402 =
+ rail === 'x402'
+ ? { network: BASE_SEPOLIA, rpcUrl: rpc, payTo: PAY_TO }
+ : {
+ options: [
+ { network: BASE_SEPOLIA, payTo: PAY_TO },
+ { network: ARBITRUM_SEPOLIA, payTo: PAY_TO },
+ ],
+ networks: {
+ [BASE_SEPOLIA]: { rpcUrl: rpc },
+ [ARBITRUM_SEPOLIA]: { rpcUrl: `${upstreamUrl}/rpc/421614` },
+ },
+ };
+ return parseConfig(
+ {
+ version: 1,
+ merchant: { id: 'certainty', name: 'Certainty', publicBaseUrl: 'https://gateway.example' },
+ server: { port: 8080, host: '127.0.0.1' },
+ storage: { receipts: { driver: 'sqlite', path: ':memory:' } },
+ protocols: { http: { enabled: true }, mcp: { enabled: false, mountPath: '/mcp' } },
+ resources: {
+ report: {
+ name: 'Report',
+ input: { type: 'object', properties: {}, additionalProperties: false },
+ backend: {
+ type: 'http',
+ method: 'GET',
+ url: `${targets.backend ?? upstreamUrl}/backend/r`,
+ },
+ pricing: { type: 'fixed', amount: '0.01', currency: 'USDC' },
+ expose: ['http'],
+ payments: [rail === 'mpp' ? 'mpp' : 'x402'],
+ },
+ },
+ payments:
+ rail === 'mpp'
+ ? {
+ mpp: {
+ enabled: true,
+ network: BASE_SEPOLIA,
+ rpcUrl: rpc,
+ asset: USDC,
+ assetName: 'USDC',
+ assetVersion: '2',
+ recipient: PAY_TO,
+ realm: 'gateway.example',
+ challengeSecret: 'certainty-mpp-challenge-secret-'.padEnd(32, 'x'),
+ facilitator,
+ },
+ }
+ : { x402: { enabled: true, facilitator, maxTimeoutSeconds: 120, ...x402 } },
+ },
+ {},
+ );
+}
+
+let gateway: GatewayInstance | undefined;
+
+// Start a gateway with configured payment providers, then run doctor against it
+async function doctor(gatewayConfig: GatewayConfig): Promise