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
feat: enhance Solana payment handling — ensure endpoints only advertise available payment rails and improve error messaging for missing co-signing keys
nrpo1625d763ceb7
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 641dbcd80..06041f548 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -17,6 +17,7 @@ Public history for [three.ws](https://three.ws), newest first. New pages come fr- **Leak-proofing the closed-loop economy: fail-closed spend guards + an on-chain leak scanner** — The rule behind the closed-loop agent economy is simple: no dollar and no SOL ever leaves the wallets the platform controls. Until now the safeguards that enforced it were passive — a couple of configuration switches that, if flipped or forgotten, could quietly re-open spending to the outside world, and nothing actually watched the blockchain to confirm money wasn't leaving. Both gaps are now closed. Before the economy spends anything, it re-checks the three switches that keep the loop sealed — external spending off, no charity split, settlements routed only through the platform's own settlement service — and if any of them is wrong it stops spending entirely and pages operators, naming the switch that changed. Separately, a new monitor reads the chain itself every ten minutes: for each ring wallet it inspects every recent transaction and flags anything that moved value to an address the platform doesn't control — a stablecoin payment to a stranger, any non-stablecoin token leaving, an unexplained SOL debit, or a permission grant that would let someone else move funds later. Any such finding pages operators within minutes with the transaction, the counterparty, the amount, and the exact recovery steps, and is filed on the same financial-integrity board as the rest of the platform's money checks. It also tallies the network fees the wallets actually paid and cross-checks them against the books, so fees paid outside the accounting get caught too. The monitor only ever reads the chain — it never moves funds or touches keys. `[security]`- **Live Trading Theater stages rigged avatars only** — The 3D trading stage now only casts avatars that can actually perform. Any agent whose model is a static forge prop, a non-humanoid mesh, or a broken rig is quietly swapped for the platform's rigged mannequin instead of being staged as-is — which fixes the stray blob of geometry that could sprawl across the floor. Every figure on stage can now idle and react to real on-chain events. (`/theater`) `[fix]`- **Lowest fees always: self-pay settlement, a fee ceiling, and a nightly fee audit that reclaims rent** — The closed-loop agent economy now enforces its cheapest possible settlement everywhere. Payments inside the ring default to self-pay — the paying wallet covers its own one-signature network fee (about 5,000 lamports) instead of a two-signature sponsored payment (about 10,000), so the platform burns half the SOL per settlement. Sponsor mode is still available as a fallback for wallets that hold no SOL, but it is no longer the default. A hard per-payment fee ceiling now guards the floor from both sides: the payment builders are proven never to exceed it, and the payment client refuses at send time to broadcast anything whose fee configuration would cross it. A new nightly audit measures the real network fees the wallets actually paid — read straight from the blockchain, not estimated — and reports two plain numbers: the SOL burned per settlement and the SOL burned per $100 of volume moved. If either drifts above budget it pages operators. The same run reclaims the one-time account-rent deposits the ring locks up over time, safely closing only empty, non-active token accounts and returning the rent to the owner wallet. The live efficiency numbers are exposed on the ring's public net-position report. (`/api/x402-ring`) `[improvement, infra]`+- **Paid endpoints never hand you a payment rail they can't complete** — We fixed a case where paying for an endpoint on Solana could fail with a server error after you had already built and signed the payment. The platform advertises which networks an endpoint accepts; it was offering the Solana rail based on the sponsor wallet's address alone, without checking that the co-signing key needed to actually complete the payment was in place. If that key was missing, you got a 502 at the last step. Now the Solana rail is only offered when settlement can genuinely complete — the same rule the platform already applied to Base — so you never pick a rail that dead-ends. The live payment challenge and the machine-readable service catalog now agree, and if the co-signing key is missing you get a clear, retryable "temporarily unavailable" instead of a hard error. The moment the key is configured, Solana payments resume on their own with no redeploy, and the platform health board now flags this specific gap so operators can fix it fast. `[fix, security]`- **Payment audit writes now batch instead of hammering the database** — The ledger that records every x402 payment used to write one row to the database per paid request. On hot routes a slow-database spell turned that into a self-amplifying storm — dozens of simultaneous writes piling onto an already-strained database, each timing out. Those writes now queue in a fast in-memory buffer and get flushed in a single batched write every minute, so database load tracks the flush cadence, not raw request volume. Payments were never affected (the ledger is best-effort and off the payment path), but the audit trail is now durable under load and the error noise is gone. A retention sweep also keeps the ledger trimmed so dashboard reports stay fast, and the health endpoint now shows at a glance whether the autonomous spend loop is live or paused. `[fix, infra]`- **Ring economy dashboard — watch the closed loop breathe** — The self-cycled x402 ring economy now has a live operator dashboard. A per-minute settlement pulse shows the heartbeat at a glance — a spark strip where any gap is instantly visible, plus a big “minutes since last settle” number that turns green, amber, then red as the tick slows or stops. A loop diagram traces payer → endpoint → treasury → sweep with live on-chain wallet balances and floor indicators; a streaming feed shows every paid call with the buying agent, endpoint, price, and its explorer link, and flags skips and failures with their exact reason instead of dropping them silently. Fee-burn efficiency, leak-scan and reconciliation integrity, and per-endpoint coverage each get a panel. It is admin-only and clearly labels all ring volume as internal dogfooding, not organic revenue — so “it stopped working” can never again go unnoticed for days. `[feature]`- **Ring settlements stay in-house — routing made truthful, mis-config now caught** — The closed-loop agent economy is built so no third party ever touches a ring settlement — but the configuration used to say one thing while the code did another: the setup guide claimed the platform's own facilitator was 'always-on' while Solana payments still defaulted to an outside settlement service. That contradiction is gone. When the self-hosted facilitator is switched on, ring payments now settle through it by default, and an explicitly-set external facilitator is the only thing that overrides that — no other coin or user rail is affected. Just as important, a mis-configured deploy now says so loudly instead of silently sending volume elsewhere: the status and ring reports list every problem — facilitator disabled, settlement pointing at an outside service, a missing treasury or fee-payer key, a per-call price set above the per-run cap — so operators can confirm the whole envelope is correct before funding anything. A clean deploy shows an empty warnings list. `[fix, infra]`diff --git a/api/_lib/x402-paid-endpoint.js b/api/_lib/x402-paid-endpoint.jsindex f20c823ed..f41ce4692 100644--- a/api/_lib/x402-paid-endpoint.js+++ b/api/_lib/x402-paid-endpoint.js@@ -41,6 +41,7 @@ import {NETWORK_SOLANA_MAINNET,X402Error,baseSettleable,+ solanaSettleable,encodePaymentResponseHeader,permit2VariantOf,resolveResourceUrl,@@ -171,10 +172,19 @@ function buildRequirements({ priceAtomics, networks, resourceUrl, payToOverride)continue;// Solana also needs a fee payer to be co-signable — skip the network- // rather than advertise an accept the facilitator will reject.+ // rather than advertise an accept the facilitator will reject. The pay-to,+ // USDC mint and advertised sponsor PUBKEY must all be present AND settlement+ // must be fulfillable: solanaSettleable() confirms the self-facilitator can+ // actually co-sign (its X402_FEE_PAYER_SECRET_BASE58 is loaded), so a deploy+ // that advertises a sponsor it can't sign for drops Solana here instead of+ // handing the buyer an accept that 502s at settle. Self-heals when the+ // secret is set. See solanaSettleable() in x402-spec.js.if (net === NETWORK_SOLANA_MAINNET &&- (!solTo || !env.X402_FEE_PAYER_SOLANA || !env.X402_ASSET_MINT_SOLANA)+ (!solTo ||+ !env.X402_FEE_PAYER_SOLANA ||+ !env.X402_ASSET_MINT_SOLANA ||+ !solanaSettleable()))continue;if (net === NETWORK_BSC_MAINNET && (!bscTo || !env.X402_ASSET_ADDRESS_BSC)) continue;@@ -207,6 +217,26 @@ function buildRequirements({ priceAtomics, networks, resourceUrl, payToOverrideif (sibling) out.push(sibling);}if (!out.length) {+ // Distinguish a TEMPORARY settlement gap from a genuine misconfiguration.+ // If Solana was requested and is otherwise fully configured (pay-to + mint ++ // sponsor pubkey) but dropped ONLY because solanaSettleable() is false — the+ // self-facilitator's co-signing secret isn't loaded yet — this is a transient,+ // operator-fixable state, not "nothing is wired". Surface a retryable 503 with+ // an actionable message instead of a 500 that reads as a permanent config+ // error, and never after taking a payment. Self-heals when the secret is set.+ const solanaGatedOnSecret =+ networks.some((n) => resolveNetwork(n) === NETWORK_SOLANA_MAINNET) &&+ (payToOverride?.solana || env.X402_PAY_TO_SOLANA) &&+ env.X402_FEE_PAYER_SOLANA &&+ env.X402_ASSET_MINT_SOLANA &&+ !solanaSettleable();+ if (solanaGatedOnSecret) {+ throw new X402Error(+ 'settlement_unavailable',+ 'paidEndpoint: Solana settlement is temporarily unavailable — the self-facilitator co-signing key (X402_FEE_PAYER_SECRET_BASE58) is not configured. Retry once it is set.',+ 503,+ );+ }throw new X402Error('no_payto_configured','paidEndpoint: no X402_PAY_TO_* configured for any requested network',diff --git a/api/_lib/x402-spec.js b/api/_lib/x402-spec.jsindex 154398111..6f51bcf62 100644--- a/api/_lib/x402-spec.js+++ b/api/_lib/x402-spec.js@@ -170,7 +170,7 @@ export function paymentRequirements(resourceUrl, { amount } = {}) {// Solana-first platform default: the Solana accept leads so first-accept// clients and the payment modal settle on Solana unless the caller picks// another network explicitly. Base/BSC follow as alternatives.- if (env.X402_PAY_TO_SOLANA) {+ if (env.X402_PAY_TO_SOLANA && solanaSettleable()) {out.push({...common,network: NETWORK_SOLANA_MAINNET,@@ -314,6 +314,30 @@ export function baseSettleable() {return env.X402_ADVERTISE_BASE === true;}+// Is Solana (the in-house ring rail) actually settleable right now? The Solana+// mirror of baseSettleable(): never advertise a Solana accept the facilitator+// will reject AFTER the buyer has paid. Solana settlement routes via+// resolveSolanaFacilitator():+//+// • EXTERNAL facilitator (PayAI, or an explicit non-self URL) — it holds its+// own sponsor key and co-signs; we trust that path, so the accept settles.+// • Our SELF-hosted facilitator — settle co-signs sponsor-mode payments with+// X402_FEE_PAYER_SECRET_BASE58 (api/_lib/x402/self-facilitator.js). Without+// that secret loaded, EVERY sponsor-mode settle throws+// `sponsor_key_unconfigured` and the buyer eats a 502 AFTER submitting a+// signed payment — the exact production failure this gate closes (80× 502 on+// /api/x402/dance-tip, crypto-intel, three-intel in the 2026-07-03 export).+// So self-routing is settleable only when the co-signing secret is present.+//+// The 402 challenge already requires X402_FEE_PAYER_SOLANA (the advertised+// sponsor PUBKEY); this adds the matching requirement that we can actually SIGN+// for it. Self-heals the instant the secret is set — no redeploy needed.+export function solanaSettleable() {+ const route = resolveSolanaFacilitator();+ if (!route.self) return true; // external facilitator co-signs with its own key+ return !!String(process.env.X402_FEE_PAYER_SECRET_BASE58 || '').trim();+}+// Shared exact-scheme requirements builder for the hand-rolled x402 endpoints that// call send402()/verifyPayment() directly instead of going through paidEndpoint().// Emits the platform-standard accept set for a USDC price:@@ -332,7 +356,12 @@ export function baseSettleable() {export function buildExactRequirements(resourceUrl, amount = env.X402_MAX_AMOUNT_REQUIRED) {const amt = String(amount);const out = [];- if (env.X402_PAY_TO_SOLANA && env.X402_ASSET_MINT_SOLANA && env.X402_FEE_PAYER_SOLANA) {+ if (+ env.X402_PAY_TO_SOLANA &&+ env.X402_ASSET_MINT_SOLANA &&+ env.X402_FEE_PAYER_SOLANA &&+ solanaSettleable()+ ) {out.push({scheme: 'exact',network: NETWORK_SOLANA_MAINNET,diff --git a/api/_lib/x402/ring-config.js b/api/_lib/x402/ring-config.jsindex fe4da6f1d..485ad98e5 100644--- a/api/_lib/x402/ring-config.js+++ b/api/_lib/x402/ring-config.js@@ -128,6 +128,23 @@ export function validateRingConfig() {fix: 'set X402_FEE_PAYER_SOLANA to the sponsor pubkey from scripts/x402-ring-setup.mjs',});}+ // When settlement routes in-house, the sponsor SECRET must be present or every+ // sponsor-mode settle throws `sponsor_key_unconfigured` and the buyer gets a 502+ // AFTER paying. The advertising layer (solanaSettleable() in x402-spec.js) now+ // drops the Solana accept when this secret is missing, turning that 502 into a+ // clean unpayable state — but the deploy still can't earn on Solana until it is+ // set, so surface it here as an error the health board and /api/x402-status show.+ // Only meaningful when we route to our own facilitator; an external facilitator+ // co-signs with its own key.+ if (route.self && !String(process.env.X402_FEE_PAYER_SECRET_BASE58 || '').trim()) {+ findings.push({+ code: 'fee_payer_secret_missing',+ severity: 'error',+ message:+ 'X402_FEE_PAYER_SECRET_BASE58 is not set — the self-facilitator cannot co-sign sponsor-mode settlements, so the Solana accept is withheld and no Solana payment can settle in-house',+ fix: 'set X402_FEE_PAYER_SECRET_BASE58 to the sponsor secret from scripts/x402-ring-setup.mjs (must match X402_FEE_PAYER_SOLANA)',+ });+ }const priceAtomic = Number(priceFor('ring-settle', RING_SETTLE_DEFAULT_PRICE_ATOMICS));const capAtomic = volumePerRunCapAtomic();if (capAtomic > 0 && priceAtomic > capAtomic) {diff --git a/api/wk.js b/api/wk.jsindex d5c86022f..71c08a93e 100644--- a/api/wk.js+++ b/api/wk.js@@ -13,6 +13,7 @@ import {declareErc20ApprovalGasSponsoringExtension,permit2VariantOf,baseSettleable,+ solanaSettleable,NETWORK_BASE_MAINNET,NETWORK_SOLANA_MAINNET,} from './_lib/x402-spec.js';@@ -297,7 +298,11 @@ function acceptsForPrice(amountAtomics, resourceUrl) {const price = RAW_AMOUNT_TO_USDC(amountAtomics);// Solana-first platform default — the Solana accept leads so first-accept// clients and marketplaces treat it as the primary rail; Base follows.- if (env.X402_PAY_TO_SOLANA) {+ // Solana only when settlement is fulfillable — solanaSettleable() confirms the+ // self-facilitator can co-sign (its X402_FEE_PAYER_SECRET_BASE58 is loaded), so+ // the catalog never lists a Solana rail the live 402 now drops. See+ // solanaSettleable() / baseSettleable() in x402-spec.js.+ if (env.X402_PAY_TO_SOLANA && solanaSettleable()) {out.push({scheme: 'exact',network: NETWORK_SOLANA_MAINNET,@@ -442,7 +447,8 @@ async function buildAgentServiceItems(origin) {row.network === 'solana' &&row.payout_address &&env.X402_ASSET_MINT_SOLANA &&- env.X402_FEE_PAYER_SOLANA+ env.X402_FEE_PAYER_SOLANA &&+ solanaSettleable()) {accepts.push({scheme: 'exact',@@ -1263,8 +1269,10 @@ async function handleX402Discovery(req, res) {// resource it gates without walking back to the parent resource[] entry.function buildMcpAccepts(resourceUrl) {const out = [];- // Solana-first platform default — Solana leads, Base follows.- if (env.X402_PAY_TO_SOLANA) {+ // Solana-first platform default — Solana leads, Base follows. Gated on+ // solanaSettleable() so the catalog never advertises a Solana rail the live+ // 402 drops when the self-facilitator's co-signing secret is missing.+ if (env.X402_PAY_TO_SOLANA && solanaSettleable()) {out.push({scheme: 'exact',network: NETWORK_SOLANA_MAINNET,diff --git a/data/changelog.json b/data/changelog.jsonindex f711d411b..161efe8dc 100644--- a/data/changelog.json+++ b/data/changelog.json@@ -1,6 +1,15 @@{"$comment": "Curated changelog entries for three.ws — the editorial layer of the public changelog. New PAGE launches are tracked automatically via the `added` field in data/pages.json; this file is for everything else holders care about: improvements, fixes, SDK releases, trading/payments capabilities, security work. scripts/build-page-index.mjs merges both sources into CHANGELOG.md, public/changelog.json, and public/changelog.xml. Newest first. Allowed tags: feature, improvement, fix, sdk, infra, docs, security. `link` is optional and must be a live three.ws path.","entries": [+ {+ "date": "2026-07-03",+ "title": "Paid endpoints never hand you a payment rail they can't complete",+ "summary": "We fixed a case where paying for an endpoint on Solana could fail with a server error after you had already built and signed the payment. The platform advertises which networks an endpoint accepts; it was offering the Solana rail based on the sponsor wallet's address alone, without checking that the co-signing key needed to actually complete the payment was in place. If that key was missing, you got a 502 at the last step. Now the Solana rail is only offered when settlement can genuinely complete — the same rule the platform already applied to Base — so you never pick a rail that dead-ends. The live payment challenge and the machine-readable service catalog now agree, and if the co-signing key is missing you get a clear, retryable \"temporarily unavailable\" instead of a hard error. The moment the key is configured, Solana payments resume on their own with no redeploy, and the platform health board now flags this specific gap so operators can fix it fast.",+ "tags": [+ "fix",+ "security"+ ]+ },{"date": "2026-07-03","title": "The Live Trading Theater is now a dealing room, not a stage",diff --git a/packages/agent-sniper/scripts/fund-swarm.mjs b/packages/agent-sniper/scripts/fund-swarm.mjsindex 5ab018876..d49d47dba 100644--- a/packages/agent-sniper/scripts/fund-swarm.mjs+++ b/packages/agent-sniper/scripts/fund-swarm.mjs@@ -29,7 +29,7 @@ const sol = (l) => (l / LAMPORTS_PER_SOL).toFixed(4);// pull Swarm addresses from the DBprocess.env.DATABASE_URL = e.DATABASE_URL;const { sql } = await import('../../../api/_lib/db.js');-const rows = await sql`select name, meta->>'solana_address' as addr from agent_identities where name like 'Swarm %' and meta->>'solana_address' is not null order by (regexp_replace(name,'\\D','','g'))::int`;+const rows = await sql`select name, meta->>'solana_address' as addr from agent_identities where name ~ '^Swarm [0-9]+$' and meta->>'solana_address' is not null order by (regexp_replace(name,'\\D','','g'))::int`;console.log(`Swarm agents with wallets: ${rows.length}`);if (!rows.length) { console.log('none yet — run after creation/wallets exist'); process.exit(0); }diff --git a/packages/agent-sniper/scripts/ui-create-swarm.mjs b/packages/agent-sniper/scripts/ui-create-swarm.mjsindex dc63a5bbd..18496bac4 100644--- a/packages/agent-sniper/scripts/ui-create-swarm.mjs+++ b/packages/agent-sniper/scripts/ui-create-swarm.mjs@@ -49,6 +49,15 @@ async function existingSwarmNames() {} catch { return []; }}+async function existsOnDashboard(name) {+ try {+ await page.goto(`${BASE}/dashboard/agents`, { waitUntil: 'domcontentloaded', timeout: 45_000 });+ await page.waitForTimeout(3500);+ return await page.evaluate((nm) => [...document.querySelectorAll('h1,h2,h3,h4,[class*="name"],[class*="title"]')]+ .some((h) => (h.textContent || '').trim() === nm || new RegExp('^' + nm + '\\b').test((h.textContent || '').trim())), name).catch(() => false);+ } catch { return false; }+}+async function clickAdvance() {for (const sel of ['#btn-next', 'button:has-text("Continue")', 'button:has-text("Next")', 'button:has-text("Review")']) {for (const el of await page.$$(sel)) {@@ -109,8 +118,12 @@ try {process.stdout.write(`creating ${name} … `);let ok = false;for (let attempt = 1; attempt <= 2 && !ok; attempt++) {+ // before any retry, confirm it wasn't actually created (avoid duplicates)+ if (attempt > 1 && await existsOnDashboard(name)) { ok = true; break; }try { ok = await createOne(name, i - 1); } catch (e) { console.log(`(attempt ${attempt} err: ${e.message.slice(0, 60)})`); }}+ // final safety: even if UI detection missed it, don't count as fail if it exists+ if (!ok && await existsOnDashboard(name)) ok = true;if (ok) {made++;manifest.created.push({ name, at: 'created' });diff --git a/public/changelog.json b/public/changelog.jsonindex dfa644ca8..0d5f7b0e5 100644--- a/public/changelog.json+++ b/public/changelog.json@@ -1,5 +1,5 @@{- "generated_at": "2026-07-03T11:31:54.896Z",+ "generated_at": "2026-07-03T12:00:33.287Z","generated_by": "scripts/build-page-index.mjs from data/pages.json + data/changelog.json","site": {"name": "three.ws",@@ -122,6 +122,17 @@"infra"]},+ {+ "date": "2026-07-03",+ "type": "update",+ "title": "Paid endpoints never hand you a payment rail they can't complete",+ "summary": "We fixed a case where paying for an endpoint on Solana could fail with a server error after you had already built and signed the payment. The platform advertises which networks an endpoint accepts; it was offering the Solana rail based on the sponsor wallet's address alone, without checking that the co-signing key needed to actually complete the payment was in place. If that key was missing, you got a 502 at the last step. Now the Solana rail is only offered when settlement can genuinely complete — the same rule the platform already applied to Base — so you never pick a rail that dead-ends. The live payment challenge and the machine-readable service catalog now agree, and if the co-signing key is missing you get a clear, retryable \"temporarily unavailable\" instead of a hard error. The moment the key is configured, Solana payments resume on their own with no redeploy, and the platform health board now flags this specific gap so operators can fix it fast.",+ "link": null,+ "tags": [+ "fix",+ "security"+ ]+ },{"date": "2026-07-03","type": "update",diff --git a/public/changelog.xml b/public/changelog.xmlindex aba9250e1..1e92d9b8d 100644--- a/public/changelog.xml+++ b/public/changelog.xml@@ -94,6 +94,14 @@<category>improvement</category><description>The closed-loop agent economy now enforces its cheapest possible settlement everywhere. Payments inside the ring default to self-pay — the paying wallet covers its own one-signature network fee (about 5,000 lamports) instead of a two-signature sponsored payment (about 10,000), so the platform burns half the SOL per settlement. Sponsor mode is still available as a fallback for wallets that hold no SOL, but it is no longer the default. A hard per-payment fee ceiling now guards the floor from both sides: the payment builders are proven never to exceed it, and the payment client refuses at send time to broadcast anything whose fee configuration would cross it. A new nightly audit measures the real network fees the wallets actually paid — read straight from the blockchain, not estimated — and reports two plain numbers: the SOL burned per settlement and the SOL burned per $100 of volume moved. If either drifts above budget it pages operators. The same run reclaims the one-time account-rent deposits the ring locks up over time, safely closing only empty, non-active token accounts and returning the rent to the owner wallet. The live efficiency numbers are exposed on the ring's public net-position report.</description></item>+ <item>+ <title>Paid endpoints never hand you a payment rail they can't complete</title>+ <link>https://three.ws/changelog</link>+ <guid isPermaLink="false">2026-07-03:Paid endpoints never hand you a payment rail they can't complete</guid>+ <pubDate>Fri, 03 Jul 2026 12:00:00 GMT</pubDate>+ <category>fix</category>+ <description>We fixed a case where paying for an endpoint on Solana could fail with a server error after you had already built and signed the payment. The platform advertises which networks an endpoint accepts; it was offering the Solana rail based on the sponsor wallet's address alone, without checking that the co-signing key needed to actually complete the payment was in place. If that key was missing, you got a 502 at the last step. Now the Solana rail is only offered when settlement can genuinely complete — the same rule the platform already applied to Base — so you never pick a rail that dead-ends. The live payment challenge and the machine-readable service catalog now agree, and if the co-signing key is missing you get a clear, retryable "temporarily unavailable" instead of a hard error. The moment the key is configured, Solana payments resume on their own with no redeploy, and the platform health board now flags this specific gap so operators can fix it fast.</description>+ </item><item><title>Payment audit writes now batch instead of hammering the database</title><link>https://three.ws/changelog</link>diff --git a/public/features.json b/public/features.jsonindex 70b3a5756..1837e68eb 100644--- a/public/features.json+++ b/public/features.json@@ -1,5 +1,5 @@{- "generated_at": "2026-07-03T11:31:54.868Z",+ "generated_at": "2026-07-03T12:00:33.255Z","generated_by": "scripts/build-page-index.mjs from data/pages.json","site": {"name": "three.ws",diff --git a/src/theater-stage.js b/src/theater-stage.jsindex ed7d8721c..f4f7353ba 100644--- a/src/theater-stage.js+++ b/src/theater-stage.js@@ -78,18 +78,37 @@ const ALL_REACTION_CLIPS = [...new Set(Object.values(REACTIONS).flat())];// two adjacent desks match. Every entry is a rigged humanoid that drives the// canonical clips; anything that fails the rig gate still falls back to the// mannequin (rare), it just costs one repeat rather than a T-pose.-// Only standard, clean rigs whose skeleton retargets the canonical clips without-// detonating (Mixamo, Khronos CesiumMan, ReadyPlayerMe, our mannequin). Ordered-// lightest first so the most-visible front desks paint fast. Unknown-provenance-// GLBs are excluded on purpose: some pass the rest-pose gate but explode once the-// idle clip drives them (a giant blob), so we don't gamble the floor on them.+// Distinct Avaturn / Mixamo rigged HUMANS — each a different person, all carrying+// the canonical (Avaturn) skeleton so they retarget the clip library cleanly and+// never detonate. Ordered lightest first so the most-visible front desks paint+// fast. cesium-man's odd 22-bone rig (the earlier "blob") is deliberately out.const FALLBACK_RIGS = [- '/avatars/cesium-man.glb', // ~0.4 MB, classic rigged human (Khronos)- '/avatars/mannequin.glb', // ~0.2 MB, the base figure- '/avatars/xbot.glb', // ~2.9 MB, Mixamo robot — visually distinct- '/avatars/michelle.glb', // ~3.2 MB, Mixamo realistic woman+ '/avatars/cz.glb', // ~0.6 MB, Avaturn+ '/avatars/default.glb', // ~0.7 MB, Avaturn (platform default)+ '/avatars/xbot.glb', // ~2.9 MB, Mixamo+ '/avatars/michelle.glb', // ~3.2 MB, Mixamo+ '/avatars/realistic-female.glb', // ~5.7 MB, Avaturn+ '/avatars/realistic-halfbody.glb',// ~5.9 MB, Avaturn (behind a desk = fine)+ '/avatars/realistic-male.glb', // ~9.7 MB, Avaturn+ '/avatars/selfie-girl.glb', // ~11 MB, Avaturn];+// A distinct, deterministic colour per desk index (golden-angle hue walk) so that+// even two desks wearing the same fallback rig never look identical — the last+// line of defence for "no two the same" once the small rig pool repeats.+function fbHue(i) { return (i * 0.6180339887) % 1; }+function tintModel(model, hue) {+ if (hue == null) return;+ const col = new Color().setHSL(hue, 0.5, 0.56);+ model.traverse((n) => {+ if (!n.isMesh || !n.material) return;+ // Clone before recolouring — the cloned scene shares materials with the+ // cached template, so mutating in place would tint every other instance too.+ const one = (m) => { const c = m.clone(); if (c.color) c.color.copy(col); return c; };+ n.material = Array.isArray(n.material) ? n.material.map(one) : one(n.material);+ });+}+// The colour a trader's monitor flashes for each event — green on a fill, violet// on a verify/pay, amber when a safety rule refuses a buy. The resting glow is a// dim blue so a room of idle desks still reads as "screens on, market open".@@ -346,20 +365,30 @@ export function createStage({ canvas, overlay, onSelect, reducedMotion = false,return { model, anim, drivable: drivable && humanoid };}- async function addPerformer(agent, index, total, rigUrl = null) {+ async function addPerformer(agent, index, total, fallbackRig = null, tintHue = null) {if (disposed || performers.has(agent.id)) return;const slot = deskSlot(index, total);-- // Rigged avatars only. Try the resolved body first (the agent's own avatar,- // or a distinct fallback rig assigned by setRoster); if it isn't a drivable- // humanoid, swap in the mannequin rather than staging forge geometry as-is.- const url = rigUrl || agentAvatarGlb(agent);- let body = await buildBody(url, slot);+ const fbRig = fallbackRig || MANNEQUIN_GLB;++ // The agent's own rigged avatar wins ONLY when it actually drives the clips.+ // Everything else — an avatar-less agent, or a custom avatar that can't be+ // rigged (a forge mesh, which is most of them) — becomes this desk's ASSIGNED+ // fallback rig, tinted a unique colour, so no two desks ever look the same.+ const realUrl = agentAvatarGlb(agent);+ let body = realUrl !== MANNEQUIN_GLB ? await buildBody(realUrl, slot) : null;if (disposed || performers.has(agent.id)) { body?.anim?.dispose?.(); return; }- if ((!body || !body.drivable) && url !== MANNEQUIN_GLB) {+ if (!body || !body.drivable) {body?.anim?.dispose?.();- body = await buildBody(MANNEQUIN_GLB, slot);+ body = await buildBody(fbRig, slot);if (disposed || performers.has(agent.id)) { body?.anim?.dispose?.(); return; }+ if ((!body || !body.drivable) && fbRig !== MANNEQUIN_GLB) {+ body?.anim?.dispose?.();+ body = await buildBody(MANNEQUIN_GLB, slot);+ if (disposed || performers.has(agent.id)) { body?.anim?.dispose?.(); return; }+ // Only a bare mannequin gets a unique tint (so the rare fallback-of-a-+ // fallback still reads distinct); the Avaturn humans render as-is.+ if (body?.model) tintModel(body.model, tintHue);+ }}if (!body || !body.model) return;@@ -399,7 +428,7 @@ export function createStage({ canvas, overlay, onSelect, reducedMotion = false,if (drivable && !reducedMotion) anim.play('idle');- const rec = { agent, group, model, pad, shadow, deskGroup, screenMat, anim, drivable, slot, busy: false, plate: null };+ const rec = { agent, group, model, pad, shadow, deskGroup, screenMat, anim, drivable, slot, fallbackRig: fbRig, tintHue, busy: false, plate: null };rec.plate = makePlate(rec, index);performers.set(agent.id, rec);}@@ -438,18 +467,15 @@ export function createStage({ canvas, overlay, onSelect, reducedMotion = false,for (const [id, rec] of [...performers]) {if (!keep.has(id)) removePerformer(id, rec);}- // Resolve each body, giving avatar-less agents a DISTINCT fallback rig so the- // floor isn't a row of clones. A running counter (not the loop index) walks- // the pool, so only agents that actually need a fallback consume a slot —- // agents with their own avatar never collide with the rotation.- let fbN = 0;+ // Reserve a distinct fallback rig + a unique colour for every desk by index.+ // A desk uses them only if the agent's own avatar can't be rigged (which, for+ // forge avatars, is nearly always) — but reserving by index guarantees the+ // hues never collide, so no two fallback desks are identical.// Add sequentially with a micro-yield so a full room fills progressively// instead of stalling one frame on a dozen GLB clones.for (let i = 0; i < agents.length; i++) {if (disposed) return;- const base = agentAvatarGlb(agents[i]);- const rigUrl = base !== MANNEQUIN_GLB ? base : FALLBACK_RIGS[fbN++ % FALLBACK_RIGS.length];- await addPerformer(agents[i], i, agents.length, rigUrl);+ await addPerformer(agents[i], i, agents.length, FALLBACK_RIGS[i % FALLBACK_RIGS.length], fbHue(i));if ((i & 3) === 3) await new Promise((r) => setTimeout(r, 0));}}@@ -463,8 +489,13 @@ export function createStage({ canvas, overlay, onSelect, reducedMotion = false,rec.model.visible = false;try { rec.anim?.dispose?.(); } catch {}rec.drivable = false;+ // Rebuild as the MANNEQUIN (the one rig that never detonates) tinted this+ // desk's unique colour. Rebuilding as the assigned fallback rig would loop+ // forever if that rig is itself the exploder; a uniquely-tinted mannequin+ // still keeps the desk distinct from every neighbour.const body = await buildBody(MANNEQUIN_GLB, rec.slot);if (disposed || !performers.has(rec.agent.id) || !body?.model) { body?.anim?.dispose?.(); return; }+ tintModel(body.model, rec.tintHue);const old = rec.model;rec.group.remove(old);old.traverse?.((n) => { if (n.isMesh) { n.geometry?.dispose?.(); disposeMaterial(n.material); } });diff --git a/tests/api/x402-paid-endpoint-replay.test.js b/tests/api/x402-paid-endpoint-replay.test.jsindex 1806a8580..4ff20c1cf 100644--- a/tests/api/x402-paid-endpoint-replay.test.js+++ b/tests/api/x402-paid-endpoint-replay.test.js@@ -126,6 +126,10 @@ beforeEach(() => {process.env.X402_PAY_TO_BASE = PAY_TO_BASE;process.env.X402_ASSET_ADDRESS_BASE = ASSET_BASE;process.env.X402_MAX_AMOUNT_REQUIRED = '1000';+ // Opt Base into settleability so buildRequirements advertises the Base accept+ // this endpoint is built on — without it baseSettleable() drops Base and the+ // challenge 500s before the replay path under test is ever reached.+ process.env.X402_ADVERTISE_BASE = 'true';delete process.env.CDP_API_KEY_ID;delete process.env.CDP_API_KEY_SECRET;delete process.env.X402_BUILDER_CODE_APP;diff --git a/tests/api/x402-ring-config.test.js b/tests/api/x402-ring-config.test.jsindex fca712916..ccb2c4c3a 100644--- a/tests/api/x402-ring-config.test.js+++ b/tests/api/x402-ring-config.test.js@@ -32,6 +32,7 @@ function healthyRingEnv() {delete process.env.X402_FACILITATOR_URL_SOLANA;delete process.env.X402_FACILITATOR_URL;process.env.X402_FEE_PAYER_SOLANA = '2wKupLR9q6wXYppw8Gr2NvWxKBUqm4PPJKkQfoxHDBg4';+ process.env.X402_FEE_PAYER_SECRET_BASE58 = 'z'.repeat(88);process.env.X402_TREASURY_SECRET_BASE58 = 'z'.repeat(64);process.env.X402_RING_SELF_PAY = 'true';process.env.X402_PRICE_RING_SETTLE = '1000000';@@ -44,6 +45,7 @@ const RING_VARS = ['X402_FACILITATOR_URL_SOLANA','X402_FACILITATOR_URL','X402_FEE_PAYER_SOLANA',+ 'X402_FEE_PAYER_SECRET_BASE58','X402_TREASURY_SECRET_BASE58','X402_RING_SELF_PAY','X402_PRICE_RING_SETTLE',@@ -155,6 +157,23 @@ describe('validateRingConfig finding matrix', () => {expect(f.severity).toBe('error');});+ it('flags fee_payer_secret_missing (error) when self-routing without the co-signing secret', () => {+ healthyRingEnv();+ delete process.env.X402_FEE_PAYER_SECRET_BASE58;+ const f = validateRingConfig().find((x) => x.code === 'fee_payer_secret_missing');+ expect(f).toBeTruthy();+ expect(f.severity).toBe('error');+ });++ it('does NOT flag fee_payer_secret_missing when settlement routes externally', () => {+ healthyRingEnv();+ delete process.env.X402_FEE_PAYER_SECRET_BASE58;+ // An explicit external facilitator wins → route.self is false → the external+ // facilitator co-signs with its own key, so our secret is irrelevant.+ process.env.X402_FACILITATOR_URL_SOLANA = 'https://ext.example.test';+ expect(codes(validateRingConfig())).not.toContain('fee_payer_secret_missing');+ });+it('flags ring_price_exceeds_run_cap when the per-call price exceeds the per-run cap', () => {healthyRingEnv();process.env.X402_PRICE_RING_SETTLE = '5000000'; // $5.00diff --git a/tests/api/x402-spec.test.js b/tests/api/x402-spec.test.jsindex f7aaeb94d..7db8eb5db 100644--- a/tests/api/x402-spec.test.js+++ b/tests/api/x402-spec.test.js@@ -565,6 +565,67 @@ describe('baseSettleable', () => {});});+describe('solanaSettleable', () => {+ // The Solana mirror of baseSettleable(): never advertise a Solana accept the+ // facilitator will reject AFTER the buyer pays. When settlement routes to our+ // self-hosted facilitator, sponsor-mode settle co-signs with+ // X402_FEE_PAYER_SECRET_BASE58 — without it every settle throws+ // sponsor_key_unconfigured (the 80× prod 502 this gate closes). An external+ // facilitator co-signs with its own key, so the secret is irrelevant there.+ beforeEach(() => {+ delete process.env.X402_SELF_FACILITATOR_ENABLED;+ delete process.env.X402_FACILITATOR_URL_SOLANA;+ delete process.env.X402_FACILITATOR_URL;+ delete process.env.X402_FEE_PAYER_SECRET_BASE58;+ delete process.env.PUBLIC_APP_ORIGIN;+ });++ it('is true by default (external PayAI facilitator co-signs with its own key)', async () => {+ const { solanaSettleable } = await loadSpec();+ expect(solanaSettleable()).toBe(true);+ });++ it('is FALSE when self-routing without the co-signing secret (the 502 trap)', async () => {+ process.env.X402_SELF_FACILITATOR_ENABLED = 'true';+ const { solanaSettleable } = await loadSpec();+ expect(solanaSettleable()).toBe(false);+ });++ it('is true when self-routing WITH the co-signing secret present', async () => {+ process.env.X402_SELF_FACILITATOR_ENABLED = 'true';+ process.env.X402_FEE_PAYER_SECRET_BASE58 = 'z'.repeat(88);+ const { solanaSettleable } = await loadSpec();+ expect(solanaSettleable()).toBe(true);+ });++ it('is true when an explicit EXTERNAL URL wins even with the flag on and no secret', async () => {+ process.env.X402_SELF_FACILITATOR_ENABLED = 'true';+ process.env.X402_FACILITATOR_URL_SOLANA = 'https://ext.example.test';+ const { solanaSettleable } = await loadSpec();+ expect(solanaSettleable()).toBe(true);+ });++ it('withholds the Solana accept from paymentRequirements when self-routing without the secret', async () => {+ process.env.X402_SELF_FACILITATOR_ENABLED = 'true';+ const { paymentRequirements } = await loadSpec();+ const solana = paymentRequirements('https://three.ws/api/foo').filter((r) =>+ r.network.startsWith('solana:'),+ );+ expect(solana).toEqual([]);+ });++ it('advertises the Solana accept again once the secret is set (self-heals)', async () => {+ process.env.X402_SELF_FACILITATOR_ENABLED = 'true';+ process.env.X402_FEE_PAYER_SECRET_BASE58 = 'z'.repeat(88);+ const { paymentRequirements } = await loadSpec();+ const solana = paymentRequirements('https://three.ws/api/foo').filter((r) =>+ r.network.startsWith('solana:'),+ );+ expect(solana.length).toBeGreaterThanOrEqual(1);+ expect(solana[0].extra.name).toBe('USDC');+ });+});+describe('buildExactRequirements', () => {// Shared accept builder for the hand-rolled endpoints (model-check, mint-to-mesh,// vanity, vanity-verifiable, revenue-vision). Solana always leads; Base only rides