Skip to content

fix(x402): bind quote, settlement identity, and auto-pay limit - #1468

Open
epistemedeus wants to merge 1 commit into
coinbase:mainfrom
epistemedeus:codex/x402-quote-settlement-binding
Open

fix(x402): bind quote, settlement identity, and auto-pay limit#1468
epistemedeus wants to merge 1 commit into
coinbase:mainfrom
epistemedeus:codex/x402-quote-settlement-binding

Conversation

@epistemedeus

Copy link
Copy Markdown

Description

This change makes the x402 action provider fail closed at the payment boundary:

  • The two-step flow returns an opaque, one-use quote binding for the exact inspected request and selected payment requirement.
  • Prepared retry and direct auto-pay sign only the frozen requirement. Quote drift and an over-limit maxPaymentUsdc value are rejected before the signer is invoked.
  • Paid success requires an HTTP 200 plus an official x402 settlement response with the frozen network, the wallet payer, and a family-correct EVM or SVM transaction identifier.
  • Any post-sign timeout, invalid response, or missing settlement evidence is reported as unreconciled possible spend and is never silently retried.
  • Direct auto-pay remains internally bound to its first inspected 402, but it has no separate user-confirmation handle and no recipient allowlist.
  • This validates settlement identity, not application output. Returned data is not checked against a seller outputSchema or a buyer-owned response schema.

The implementation stays on the official x402 2.7.0 client surfaces. A patch changeset and updated x402 documentation are included.

Tests

Run from typescript/agentkit on Node 22:

  • pnpm run lint
  • pnpm run format:check
  • pnpm run check
  • pnpm run build
  • Focused x402 suite: 119 tests passed
  • Deterministic exported-provider replay:
    • exact 1 USDC with maxPaymentUsdc: 1: success with exactly one signature
    • exact 2 USDC with maxPaymentUsdc: 1: rejected before signing with zero signatures
  • Hostile EVM and SVM cases cover quote drift, wrong payer, wrong network, malformed transaction identity, missing response proof, unsigned HTTP 200, and post-sign possible-spend evidence.

pnpm run test:types currently targets the absent file src/tests/types.test-d.ts; the exact same failure reproduces on the clean current main commit, so this PR does not modify that unrelated script.

No wallet, live payment, or funded chatbot was used. The tests exercise the exported action provider with deterministic wallet and HTTP seams so signer counts and settlement promotion are directly observable.

Checklist

  • Added documentation to the relevant x402 README
  • Added a changelog entry

Signed-off-by: Lucian Constantinescu <epistemedeus@gmail.com>
@cb-heimdall

Copy link
Copy Markdown

🟡 Heimdall Review Status

Requirement Status More Info
Reviews 🟡 0/1
Denominator calculation
Show calculation
1 if user is bot 0
1 if user is external 0
2 if repo is sensitive 0
From .codeflow.yml 1
Additional review requirements
Show calculation
Max 0
0
From CODEOWNERS 0
Global minimum 0
Max 1
1
1 if commit is unverified 0
Sum 1

@github-actions github-actions Bot added documentation Improvements or additions to documentation action provider New action provider typescript labels Aug 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

action provider New action provider documentation Improvements or additions to documentation typescript

Development

Successfully merging this pull request may close these issues.

2 participants