Repository navigation
Commit 52c861a
Never map a Solana confirmation timeout to regenerate/pay-again (#109)
## Summary
Python mirror of agentscore/node-commerce#105. Fixes a live
double-charge on the Solana MPP rail.
pympp verifies a transaction-payload credential by broadcasting it
(funds move, a signature is minted) then awaiting confirmation in the
same synchronous verify() call, with a fixed timeout not exposed to
callers. Under load that window can expire before the network surfaces
confirmation, even on a healthy production RPC (verified: Helius
getHealth ok in ~70ms during the failure), so verify() raises on a
transfer that may already have landed. `_handle_mppx` mapped every
unclassified pympp failure to `payment_proof_invalid` +
`regenerate_payment_credential`, so the merchant told the agent to pay
again for money that already left the wallet. Observed live 2026-08-12
on the hosted stores: an on-chain balance delta with no service
delivered and a regenerate 402 in hand.
`classify_mppx_failure` now recognizes the confirmation-timeout reason
and returns `payment_pending_confirmation` (HTTP 504, `action:
check_settlement_before_retry`) with a message telling the buyer to
verify settlement before retrying. 504 rather than 402 is deliberate:
x402/MPP clients version-route on status and a 402 auto-triggers a
re-pay retry, which is the double-charge this guards. A confirmation
timeout cannot be reliably distinguished from never-landed, so the
response surfaces the ambiguity rather than asserting success or
failure.
## Type of change
- [x] Bug fix (no breaking change)
- [ ] New feature (no breaking change)
- [ ] Breaking change (existing callers must update)
- [ ] Docs, tests, or internal maintenance only
## Public API
No signature changes. Behavior change on one error path: a Solana MPP
settle whose confirmation times out now returns HTTP 504
`payment_pending_confirmation` instead of 402 `payment_proof_invalid` /
`regenerate_payment_credential`. Callers that branched on that 402 to
auto-repay should treat 504 as submitted-but-unconfirmed and not blindly
resubmit.
## Test plan
ruff check + format, ty clean, full suite 1844 passing. New tests: the
classifier returns 504 `payment_pending_confirmation` (never 402, never
`regenerate_payment_credential`) with a do-not-double-pay message on
both the plain and status-recovery-failed variants.
## Checklist
- [x] Tests cover the new behavior, and the suite passes locally
- [x] Lint, format, and type checks pass
- [x] Docs and README examples updated if the public surface changed
- [x] No secrets, credentials, or personal data in the diff or the tests
Co-authored-by: Claude Fable 5 <noreply@anthropic.com>1 parent 5655b1e commit 52c861a
2 files changed
Lines changed: 70 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
41 | 41 | | |
42 | 42 | | |
43 | 43 | | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
44 | 80 | | |
45 | 81 | | |
46 | 82 | | |
47 | | - | |
| 83 | + | |
48 | 84 | | |
49 | 85 | | |
50 | 86 | | |
| |||
54 | 90 | | |
55 | 91 | | |
56 | 92 | | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
57 | 97 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
37 | 37 | | |
38 | 38 | | |
39 | 39 | | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
0 commit comments