Open-source platform for 3D AI agents. Turn text or a photo into a rigged, animated GLB avatar, give it an LLM brain, memory and a wallet, and embed it anywhere with one web component. Remote MCP server, x402 payments, Three.js, browser-native.
JavaScript 3d-generationai-agentsanimationavatardigital-humangenerative-aiglbgltfimage-to-3dllmmcpmcp-servermodel-context-protocolsolanatext-to-3dthreejsweb-componentswebglwebxrx402
fix(x402): stop the fee budget that paces our own traffic from refusing a paying customer
ni3ac5d701b68ffc
diff --git a/api/_lib/x402/self-facilitator.js b/api/_lib/x402/self-facilitator.jsindex 8c961c022..f0f68f601 100644--- a/api/_lib/x402/self-facilitator.js+++ b/api/_lib/x402/self-facilitator.js@@ -872,6 +872,7 @@ export async function settleRingPayment({try {meterVerdict = await feeMeter({feeWalletB58: decoded.feePayer,+ buyerB58: decoded.payer,solLamports,estFeeLamports,selfPay,diff --git a/api/_lib/x402/wallet-fee-meter.js b/api/_lib/x402/wallet-fee-meter.jsindex a919d9569..6309ab2f9 100644--- a/api/_lib/x402/wallet-fee-meter.js+++ b/api/_lib/x402/wallet-fee-meter.js@@ -8,8 +8,15 @@// Scope: ONLY platform-controlled wallets (ringAllowedAddresses) are governed.// An external organic buyer self-paying through our facilitator spends its own// SOL — refusing its settle would be refusing revenue, so unknown wallets are-// always admitted. Every failure mode in here fails OPEN: the settle path's-// hard SOL floor remains the real protection; the meter is pacing.+// always admitted. The same holds for an organic buyer in SPONSOR mode: the fee+// wallet is ours and governed, but the payment is a customer's. The daily budget+// exists to pace our own autonomous traffic, and on 2026-09-21 it refused a+// visitor's $THREE cover charge at the Club door with `fee_runway_exhausted`+// because the ring had already spent the morning's slice. A buyer who is not a+// platform wallet is therefore admitted past the budget (their fee is still+// recorded against it, so our own traffic yields to them, not the reverse).+// Every failure mode in here fails OPEN: the settle path's hard SOL floor+// remains the real protection; the meter is pacing.//// Spent-today reads sum `x402_self_facilitator_log.fee_lamports` per fee_payer// (migration 20260728120000) with a short in-process cache, and each settled@@ -217,9 +224,13 @@ function effectiveBudgetLamports(solLamports, cfg, now = Date.now()) {export function facilitatorFeeMeter({ config } = {}) {const cfg = config || walletFeeGovernorConfig();if (!cfg.enabled) return null;- return async ({ feeWalletB58, solLamports, estFeeLamports }) => {+ return async ({ feeWalletB58, solLamports, estFeeLamports, buyerB58 = null }) => {const allowed = await governedWallets();if (!allowed || !allowed.has(feeWalletB58)) return { ok: true, reason: null };+ // A known buyer outside the platform's own wallets is a paying customer:+ // never pace revenue. An unknown buyer stays governed, so a caller that+ // does not say who is paying cannot use this to skip the budget.+ if (buyerB58 && !allowed.has(buyerB58)) return { ok: true, reason: null, organic: true };const spent = await spentTodayLamports(feeWalletB58, cfg.spentCacheMs);const budget = effectiveBudgetLamports(solLamports, cfg);diff --git a/data/changelog.json b/data/changelog.jsonindex 4e94fa74d..aaa6cdc4e 100644--- a/data/changelog.json+++ b/data/changelog.json@@ -28623,6 +28623,15 @@"fix"],"link": "/tour-builder"+ },+ {+ "date": "2026-09-21",+ "title": "Paying at the Club door no longer fails when our own traffic has been busy",+ "summary": "Some visitors paying the Club cover approved the payment in their wallet and then saw it fail at the last step with an internal error. The cause was on our side. We cover the small Solana network fee on your payment, and a safety limit that spreads our own automated payments across the day was also being applied to customers, so once our background traffic had used the morning's share, a real payment was turned away. Customers are now exempt from that limit: if you are paying, the payment goes through, and our own traffic waits instead. Nothing was charged on a failed attempt. Separately, when a wallet refuses to open its approval window, the payment window now says plainly that nothing was signed or charged and what to try next, instead of repeating the wallet's own wording.",+ "tags": [+ "fix"+ ],+ "link": "/club"}]}diff --git a/docs/x402-ring-economy.md b/docs/x402-ring-economy.mdindex 7d226eed2..029fd2078 100644--- a/docs/x402-ring-economy.md+++ b/docs/x402-ring-economy.md@@ -98,6 +98,15 @@ decision logic inwith `fee_runway_exhausted:<spent>+<next>><budget>` *before* co-sign orbroadcast, whatever pipeline initiated it. Funding is the throttle for thewhole wallet: top it up and every tenant speeds up together.+- **Customers are never paced.** The budget exists to pace the platform's own+ autonomous traffic. The settle path passes the buyer (`buyerB58`, the transfer+ authority) to the meter, and a buyer outside the controlled-wallet set is+ admitted even when the budget is spent; only the hard SOL floor can refuse+ them. Their fee is still recorded against the day, so ring traffic yields to+ customers and not the reverse. Before 2026-09-21 a sponsored customer payment+ drew on the same paced slice as the ring, and a visitor paying the Club cover+ in $THREE was refused `fee_runway_exhausted` mid-morning. A settle that does+ not name its buyer stays governed.- **The refusal is a 503, not a 502.** `settlePayment()` maps it to`settlement_unavailable` (503), the same retryable answer the sponsor SOLfloor gets, because both are the platform pausing on purpose rather thandiff --git a/public/x402.js b/public/x402.jsindex 657f4ff5e..c21cf5b2a 100644--- a/public/x402.js+++ b/public/x402.js@@ -2281,6 +2281,13 @@ function friendlyError(err) {) {return 'cancelled in wallet';}+ // Some wallets refuse to open their approval window at all and answer with+ // their own wording ("The app's signature request cannot be shown due to+ // invalid formatting"). Shown raw it reads as a fault in the buyer's payment.+ // Nothing was signed, so nothing was charged: say that, and what to try.+ if (/signature request cannot be shown|cannot be (shown|displayed) due to/i.test(msg)) {+ return 'Your wallet could not display this payment request, so nothing was signed or charged. Unlock or update the wallet and retry, or pay with the other token.';+ }// Upstream throttles (e.g. a generator's create-prediction rate limit) often// arrive as raw provider text that names the merchant's internal billing or// credit state. Never relay that to the buyer: the payment isn't settled untildiff --git a/tests/x402-wallet-fee-meter.test.js b/tests/x402-wallet-fee-meter.test.jsindex 51f9c6fc1..e6f19a099 100644--- a/tests/x402-wallet-fee-meter.test.js+++ b/tests/x402-wallet-fee-meter.test.js@@ -269,6 +269,36 @@ describe('controlled-wallet scoping', () => {});});+describe('a paying customer on a sponsored settle', () => {+ // The Club door, 2026-09-21: the governed fee wallet had spent its morning+ // slice on ring traffic, and a visitor paying the cover in $THREE was refused+ // with fee_runway_exhausted. The fee wallet is ours; the money is theirs.+ it('admits a buyer who is not a platform wallet even when the budget is spent', async () => {+ h.sql.mockResolvedValue([{ spent: '4440443' }]);+ const v = await meter()({+ feeWalletB58: GOV, buyerB58: ORGANIC, solLamports: SOL_FOR_1M_BUDGET, estFeeLamports: 2_084_080,+ });+ expect(v.ok).toBe(true);+ expect(v.organic).toBe(true);+ expect(h.sendOpsAlert).not.toHaveBeenCalled();+ });++ it('still paces the ring: a platform wallet buying from itself is refused over budget', async () => {+ h.sql.mockResolvedValue([{ spent: '4440443' }]);+ const v = await meter()({+ feeWalletB58: GOV, buyerB58: GOV2, solLamports: SOL_FOR_1M_BUDGET, estFeeLamports: 5_000,+ });+ expect(v.ok).toBe(false);+ expect(v.reason).toMatch(/^fee_runway_exhausted:/);+ });++ it('an unnamed buyer stays governed, so omitting the buyer cannot skip the budget', async () => {+ h.sql.mockResolvedValue([{ spent: '4440443' }]);+ const v = await call(meter());+ expect(v.ok).toBe(false);+ });+});+describe('recordSettledFee post-settle accounting', () => {it('debits the cached spend so a burst inside one window counts, without a DB round-trip', async () => {const fn = meter();