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: treasury sweepback — consolidate engine-wallet surplus back to the economy master
nrpo902deb622e40
diff --git a/.env.example b/.env.exampleindex 95dfe7070..354b577f8 100644--- a/.env.example+++ b/.env.example@@ -832,6 +832,13 @@ PUMP_INTEL_MIN_RETENTION_DAYS=3# Clamped [128, 100000]. Lower it for more headroom; raise it after a plan upgrade.DB_RETENTION_HIGH_WATER_MB=470+# ── Economy consolidation sweep (api/_lib/economy-sweepback.js) ───────────────+# The treasury-sweepback cron returns engine-signer surplus (SOL above each+# signer's operating float, plus stray token balances) to the economy master.+# Destination is locked in code to ECONOMY_MASTER_ADDRESS. Optional dust floor:+# a SOL sweep smaller than this is skipped so fees never exceed the return.+ECONOMY_SWEEPBACK_MIN_SOL=+# ── Agent activity engine (api/_lib/circulation.js, /api/cron/pulse-tick) ─────# Operates a pool of platform-owned agents that transact with one another on-chain# (tips, payments, trades, launches, on-chain registration) so the live money feeddiff --git a/CHANGELOG.md b/CHANGELOG.mdindex b26a9845d..c1c86c24d 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -8,7 +8,12 @@ Public history for [three.ws](https://three.ws), newest first. New pages come fr- **Every ring settlement is now proven on-chain — reconciliation blind spot closed** — The closed-loop agent economy settles real USDC through the platform's own facilitator, and until now those settlements were trusted but never verified against the blockchain. A new reconciler runs every 30 minutes and holds the ring to the same standard the funding wallet already meets: every recorded settlement and every treasury→payer sweep from the last 72 hours is checked to exist and succeed on-chain, a sample of each is parsed to prove the exact dollar amount and recipient match the books, and the two internal ledgers are cross-checked so a settlement with no matching spend record — the tell-tale sign of value leaking through our own facilitator — is caught. It also runs a silence alarm: if the ring is switched on but goes quiet for 30 minutes, operators are paged, closing the gap where 'it was working, then it wasn't' used to pass unnoticed. Any missing, failed, or mismatched settlement raises an immediate alert; every finding lands on the finance-integrity board, tagged so ring issues stand apart from the rest. `[security, infra]`- **Full audit trail + breach monitoring on the economy's funding wallet** — The master wallet that fuels the platform's autonomous economy now keeps a tamper-evident accounting book of every move it makes. Each SOL transfer is recorded with the engine it funded, the amount, the on-chain signature, the running balance, and the US-dollar value at the moment of the transfer — cryptographically hash-chained so no past entry can be altered or deleted without detection. A monitor runs every 30 minutes and checks three things: that the book hasn't been tampered with, that every transfer we recorded really happened on-chain, and — most importantly — that no SOL ever left the wallet without a matching record, which is the tell-tale sign of a stolen key. Anything off raises an immediate operator alert and lands on the finance-integrity board. There's also a one-command accounting export (CSV or JSON, with running balance and dollar totals) for bookkeeping and review. `[security, infra, docs]`+- **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]`+- **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]`+- **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]`+- **Ring wallets: watched for drain, auto-refilled, and verifiable in one command** — The three platform wallets that power the closed-loop agent economy — the one that pays, the one that receives, and the one that covers network fees — are now monitored and self-healing so the loop can run unattended without silently stalling or draining. A balance monitor checks all three on-chain every ten minutes and pages operators before trouble: the fee and paying wallets alert when their SOL dips near the level where settlements would be refused, and the paying wallet alerts when its USDC float runs low. The receiving wallet is intentionally left unbounded — it fills up and gets swept back automatically, so a low balance there is healthy, not a problem. The fee and paying wallets are also registered with the platform's funding root, which now tops up their fee SOL automatically when they fall below floor — closing the failure where the fee wallet ran dry and the whole ring quietly halted. A new one-command check confirms every wallet is correctly configured, registered, and reachable, prints their live balances, and refuses to pass on any mismatch, without ever exposing a secret. A funding runbook documents exactly how much to send and how to confirm it landed. `[infra, security]`+- **Treasury sweepback — every agent wallet cycles back to one root** — The economy's funding root now has a return leg. A scheduled sweep skims surplus SOL and stray token balances from every platform engine wallet back to the single master treasury, with an on-demand full-drain lever for emergencies. Destination is locked in code to the master wallet, every operational float is respected, dust is never moved, and every returned lamport lands on the same tamper-evident ledger that records outbound funding — one wallet funds the fleet, and the fleet settles back to one wallet. `[security, infra]`## 2026-07-02diff --git a/api/_lib/economy-sweepback.js b/api/_lib/economy-sweepback.jsindex 820f5c927..1c9754322 100644--- a/api/_lib/economy-sweepback.js+++ b/api/_lib/economy-sweepback.js@@ -40,10 +40,16 @@ function num(envName, dflt) {/** Skip a SOL sweep smaller than this — moving dust costs more than it returns. */export const MIN_SWEEP_SOL = num('ECONOMY_SWEEPBACK_MIN_SOL', 0.01);-/** Lamports a drained signer keeps to cover its own sweep transaction fees. */-export const DRAIN_HEADROOM_LAMPORTS = 20_000;-/** Most token accounts settled in one transaction (size + CU bound). */-const TOKEN_ACCOUNTS_PER_TX = 6;+/**+ * Lamports a drained signer keeps: fees for its own sweep transactions PLUS the+ * ~890,880-lamport rent-exempt minimum. The runtime rejects any transfer that+ * leaves a system account above zero but below rent exemption+ * (InsufficientFundsForRent), so a drain must leave at least this — 0.001 SOL —+ * or the drain transaction itself would fail.+ */+export const DRAIN_HEADROOM_LAMPORTS = 1_000_000;+/** Most token accounts settled in one transaction (tx size + CU bound). */+const TOKEN_ACCOUNTS_PER_TX = 4;/*** Compute the guarded per-signer SOL sweep amounts. Pure — no RPC — so the plan@@ -148,8 +154,9 @@ async function sweepTokenBalances({ connection, owner, network }) {/*** Execute the consolidation sweep across every configured registry signer.* Tokens first (their fees and rent refunds settle before the SOL read), then- * SOL per the mode's plan. Duplicate pubkeys (fallback env vars resolving to- * the same wallet) are swept once. Never throws for a business-rule stop.+ * SOL per the mode's plan. Registry entries wired to the same physical wallet+ * are swept once, with their guards merged conservatively (any-holds-tokens,+ * highest float). Never throws for a business-rule stop.** @param {object} args* @param {import('@solana/web3.js').Connection} args.connection@@ -169,13 +176,18 @@ export async function sweepBack({ connection, mode = 'excess', includeTokens = t/* balance context is best-effort; the sweep itself does not need it */}- const seen = new Set();const sweptSol = [];const sweptTokens = [];const failed = [];const skipped = [];const readErrors = [];+ // Several registry entries can be WIRED to the same physical wallet (fallback+ // env vars, or the operator assigning multiple slots to one key). Sweeping is+ // per-wallet, so resolve everything first and merge aliases conservatively:+ // the wallet holds tokens if ANY of its slots does, and its float is the+ // HIGHEST float any slot requires.+ const wallets = new Map();for (const spec of SOLANA_SIGNERS) {if (spec.isMaster || spec.network === 'devnet') continue;const { keypair, configured, decodeError } = await loadSignerKeypair(spec);@@ -189,30 +201,44 @@ export async function sweepBack({ connection, mode = 'excess', includeTokens = tskipped.push({ name: spec.name, reason: 'is_master' });continue;}- if (seen.has(pubkey)) {- skipped.push({ name: spec.name, reason: 'duplicate_pubkey' });- continue;+ const floorSol = spec.refillTo ?? spec.minSol * DEFAULT_REFILL_MULTIPLE;+ const existing = wallets.get(pubkey);+ if (existing) {+ existing.names.push(spec.name);+ existing.holdsTokens = existing.holdsTokens || Boolean(spec.holdsTokens);+ existing.floorSol = Math.max(existing.floorSol, floorSol);+ } else {+ wallets.set(pubkey, {+ pubkey,+ keypair,+ names: [spec.name],+ holdsTokens: Boolean(spec.holdsTokens),+ floorSol,+ });}- seen.add(pubkey);+ }++ for (const wallet of wallets.values()) {+ const name = wallet.names.join('+');- // Tokens first. In excess mode a signer that operationally holds tokens- // (buyback USDC, withdrawal SPL float, …) keeps them; a drain takes all.- if (includeTokens && (mode === 'drain' || !spec.holdsTokens)) {- const tokens = await sweepTokenBalances({ connection, owner: keypair, network });- for (const t of tokens.swept) sweptTokens.push({ name: spec.name, pubkey, ...t });- for (const f of tokens.failed) failed.push({ name: spec.name, pubkey, sol: null, reason: `token ${f.mint}: ${f.reason}` });+ // Tokens first. In excess mode a wallet that operationally holds tokens+ // (buyback USDC, withdrawal SPL float, NFT collection) keeps them; a+ // drain takes all.+ if (includeTokens && (mode === 'drain' || !wallet.holdsTokens)) {+ const tokens = await sweepTokenBalances({ connection, owner: wallet.keypair, network });+ for (const t of tokens.swept) sweptTokens.push({ name, pubkey: wallet.pubkey, ...t });+ for (const f of tokens.failed) failed.push({ name, pubkey: wallet.pubkey, sol: null, reason: `token ${f.mint}: ${f.reason}` });}let currentSol;try {- currentSol = round((await connection.getBalance(keypair.publicKey, 'confirmed')) / LAMPORTS_PER_SOL);+ currentSol = round((await connection.getBalance(wallet.keypair.publicKey, 'confirmed')) / LAMPORTS_PER_SOL);} catch (e) {- readErrors.push({ name: spec.name, pubkey, reason: `rpc_error: ${e?.message}` });+ readErrors.push({ name, pubkey: wallet.pubkey, reason: `rpc_error: ${e?.message}` });continue;}- const floorSol = spec.refillTo ?? spec.minSol * DEFAULT_REFILL_MULTIPLE;const { plan, skipped: planSkipped } = planSweepback(- [{ name: spec.name, pubkey, currentSol, floorSol }],+ [{ name, pubkey: wallet.pubkey, currentSol, floorSol: wallet.floorSol }],{ mode },);skipped.push(...planSkipped);@@ -220,10 +246,10 @@ export async function sweepBack({ connection, mode = 'excess', includeTokens = ttry {const signature = await sendSol({connection,- fromKeypair: keypair,+ fromKeypair: wallet.keypair,to: master,lamports: Math.round(step.sol * LAMPORTS_PER_SOL),- memo: `three.ws sweepback ${spec.name} → economy-master`,+ memo: `three.ws sweepback ${name} → economy-master`,network,});sweptSol.push({ name: step.name, pubkey: step.pubkey, sol: step.sol, signature });diff --git a/api/_lib/solana-signers.js b/api/_lib/solana-signers.jsindex bfb5f2576..af46b7bac 100644--- a/api/_lib/solana-signers.js+++ b/api/_lib/solana-signers.js@@ -169,6 +169,9 @@ export const SOLANA_SIGNERS = [name: 'collection-authority',env: 'SOLANA_AGENT_COLLECTION_AUTHORITY_KEY',minSol: 0.02,+ // Holds the agent-collection NFTs themselves — a token sweep here would+ // move the collection, not surplus. Only an explicit drain may touch it.+ holdsTokens: true,purpose: 'creates/manages the three.ws agent NFT collection',network: 'both',},diff --git a/data/changelog.json b/data/changelog.jsonindex 8de3d4b94..b21c343a6 100644--- a/data/changelog.json+++ b/data/changelog.json@@ -1,10 +1,36 @@{"$comment": "Curated changelog entries for three.ws \u2014 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": "Every paid endpoint now settles \u2014 full x402 catalog coverage",+ "summary": "The x402 ring economy now exercises every paid endpoint on the platform, not just a handful. A single canonical catalog covers all 46 paid endpoints \u2014 tips, services, market intel, health checks and settlements \u2014 each with the exact request it needs to actually go through, read straight from the endpoint that handles it. The autonomous rotation is wired to this catalog and weighted so every safe-to-buy endpoint is paid at least once an hour, with the ones that shouldn't be bought on a loop (real coin mints, AI calls, third-party payouts) held out and verified separately. Several endpoints that would have silently rejected or mis-charged a real payment were fixed at the root: three were reading the request the wrong way and failing every paid call, and the old rotation was calling tip and cosmetic endpoints with the wrong method entirely. The result is continuous, provable coverage \u2014 a new paid endpoint now fails the test suite until it's in the catalog.",+ "tags": [+ "feature",+ "improvement"+ ]+ },+ {+ "date": "2026-07-03",+ "title": "Ring economy dashboard \u2014 watch the closed loop breathe",+ "summary": "The self-cycled x402 ring economy now has a live operator dashboard. A per-minute settlement pulse shows the heartbeat at a glance \u2014 a spark strip where any gap is instantly visible, plus a big \u201cminutes since last settle\u201d number that turns green, amber, then red as the tick slows or stops. A loop diagram traces payer \u2192 endpoint \u2192 treasury \u2192 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 \u2014 so \u201cit stopped working\u201d can never again go unnoticed for days.",+ "tags": [+ "feature"+ ]+ },+ {+ "date": "2026-07-03",+ "title": "Treasury sweepback \u2014 every agent wallet cycles back to one root",+ "summary": "The economy's funding root now has a return leg. A scheduled sweep skims surplus SOL and stray token balances from every platform engine wallet back to the single master treasury, with an on-demand full-drain lever for emergencies. Destination is locked in code to the master wallet, every operational float is respected, dust is never moved, and every returned lamport lands on the same tamper-evident ledger that records outbound funding \u2014 one wallet funds the fleet, and the fleet settles back to one wallet.",+ "tags": [+ "security",+ "infra"+ ]+ },{"date": "2026-07-03","title": "Lowest fees always: self-pay settlement, a fee ceiling, and a nightly fee audit that reclaims rent",- "summary": "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.",+ "summary": "The closed-loop agent economy now enforces its cheapest possible settlement everywhere. Payments inside the ring default to self-pay \u2014 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 \u2014 read straight from the blockchain, not estimated \u2014 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.","tags": ["improvement","infra"@@ -14,7 +40,7 @@{"date": "2026-07-03","title": "Leak-proofing the closed-loop economy: fail-closed spend guards + an on-chain leak scanner",- "summary": "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.",+ "summary": "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 \u2014 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 \u2014 external spending off, no charity split, settlements routed only through the platform's own settlement service \u2014 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 \u2014 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 \u2014 it never moves funds or touches keys.","tags": ["security"]@@ -22,7 +48,7 @@{"date": "2026-07-03","title": "Ring wallets: watched for drain, auto-refilled, and verifiable in one command",- "summary": "The three platform wallets that power the closed-loop agent economy — the one that pays, the one that receives, and the one that covers network fees — are now monitored and self-healing so the loop can run unattended without silently stalling or draining. A balance monitor checks all three on-chain every ten minutes and pages operators before trouble: the fee and paying wallets alert when their SOL dips near the level where settlements would be refused, and the paying wallet alerts when its USDC float runs low. The receiving wallet is intentionally left unbounded — it fills up and gets swept back automatically, so a low balance there is healthy, not a problem. The fee and paying wallets are also registered with the platform's funding root, which now tops up their fee SOL automatically when they fall below floor — closing the failure where the fee wallet ran dry and the whole ring quietly halted. A new one-command check confirms every wallet is correctly configured, registered, and reachable, prints their live balances, and refuses to pass on any mismatch, without ever exposing a secret. A funding runbook documents exactly how much to send and how to confirm it landed.",+ "summary": "The three platform wallets that power the closed-loop agent economy \u2014 the one that pays, the one that receives, and the one that covers network fees \u2014 are now monitored and self-healing so the loop can run unattended without silently stalling or draining. A balance monitor checks all three on-chain every ten minutes and pages operators before trouble: the fee and paying wallets alert when their SOL dips near the level where settlements would be refused, and the paying wallet alerts when its USDC float runs low. The receiving wallet is intentionally left unbounded \u2014 it fills up and gets swept back automatically, so a low balance there is healthy, not a problem. The fee and paying wallets are also registered with the platform's funding root, which now tops up their fee SOL automatically when they fall below floor \u2014 closing the failure where the fee wallet ran dry and the whole ring quietly halted. A new one-command check confirms every wallet is correctly configured, registered, and reachable, prints their live balances, and refuses to pass on any mismatch, without ever exposing a secret. A funding runbook documents exactly how much to send and how to confirm it landed.","tags": ["infra","security"@@ -30,8 +56,8 @@},{"date": "2026-07-03",- "title": "Ring settlements stay in-house — routing made truthful, mis-config now caught",- "summary": "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.",+ "title": "Ring settlements stay in-house \u2014 routing made truthful, mis-config now caught",+ "summary": "The closed-loop agent economy is built so no third party ever touches a ring settlement \u2014 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 \u2014 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 \u2014 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 \u2014 so operators can confirm the whole envelope is correct before funding anything. A clean deploy shows an empty warnings list.","tags": ["fix","infra"@@ -39,8 +65,8 @@},{"date": "2026-07-03",- "title": "Every ring settlement is now proven on-chain — reconciliation blind spot closed",- "summary": "The closed-loop agent economy settles real USDC through the platform's own facilitator, and until now those settlements were trusted but never verified against the blockchain. A new reconciler runs every 30 minutes and holds the ring to the same standard the funding wallet already meets: every recorded settlement and every treasury→payer sweep from the last 72 hours is checked to exist and succeed on-chain, a sample of each is parsed to prove the exact dollar amount and recipient match the books, and the two internal ledgers are cross-checked so a settlement with no matching spend record — the tell-tale sign of value leaking through our own facilitator — is caught. It also runs a silence alarm: if the ring is switched on but goes quiet for 30 minutes, operators are paged, closing the gap where 'it was working, then it wasn't' used to pass unnoticed. Any missing, failed, or mismatched settlement raises an immediate alert; every finding lands on the finance-integrity board, tagged so ring issues stand apart from the rest.",+ "title": "Every ring settlement is now proven on-chain \u2014 reconciliation blind spot closed",+ "summary": "The closed-loop agent economy settles real USDC through the platform's own facilitator, and until now those settlements were trusted but never verified against the blockchain. A new reconciler runs every 30 minutes and holds the ring to the same standard the funding wallet already meets: every recorded settlement and every treasury\u2192payer sweep from the last 72 hours is checked to exist and succeed on-chain, a sample of each is parsed to prove the exact dollar amount and recipient match the books, and the two internal ledgers are cross-checked so a settlement with no matching spend record \u2014 the tell-tale sign of value leaking through our own facilitator \u2014 is caught. It also runs a silence alarm: if the ring is switched on but goes quiet for 30 minutes, operators are paged, closing the gap where 'it was working, then it wasn't' used to pass unnoticed. Any missing, failed, or mismatched settlement raises an immediate alert; every finding lands on the finance-integrity board, tagged so ring issues stand apart from the rest.","tags": ["security","infra"@@ -49,7 +75,7 @@{"date": "2026-07-03","title": "Full audit trail + breach monitoring on the economy's funding wallet",- "summary": "The master wallet that fuels the platform's autonomous economy now keeps a tamper-evident accounting book of every move it makes. Each SOL transfer is recorded with the engine it funded, the amount, the on-chain signature, the running balance, and the US-dollar value at the moment of the transfer — cryptographically hash-chained so no past entry can be altered or deleted without detection. A monitor runs every 30 minutes and checks three things: that the book hasn't been tampered with, that every transfer we recorded really happened on-chain, and — most importantly — that no SOL ever left the wallet without a matching record, which is the tell-tale sign of a stolen key. Anything off raises an immediate operator alert and lands on the finance-integrity board. There's also a one-command accounting export (CSV or JSON, with running balance and dollar totals) for bookkeeping and review.",+ "summary": "The master wallet that fuels the platform's autonomous economy now keeps a tamper-evident accounting book of every move it makes. Each SOL transfer is recorded with the engine it funded, the amount, the on-chain signature, the running balance, and the US-dollar value at the moment of the transfer \u2014 cryptographically hash-chained so no past entry can be altered or deleted without detection. A monitor runs every 30 minutes and checks three things: that the book hasn't been tampered with, that every transfer we recorded really happened on-chain, and \u2014 most importantly \u2014 that no SOL ever left the wallet without a matching record, which is the tell-tale sign of a stolen key. Anything off raises an immediate operator alert and lands on the finance-integrity board. There's also a one-command accounting export (CSV or JSON, with running balance and dollar totals) for bookkeeping and review.","tags": ["security","infra",@@ -59,7 +85,7 @@{"date": "2026-07-02","title": "Coin pages now have a live price chart, and every coin across the site links to them",- "summary": "Two upgrades to the full coin page. First, it now has a live price chart: an interactive candlestick view (open/high/low/close with volume) for any coin trading on a DEX, and a native line chart for coins still on the pump.fun bonding curve — so there's always a chart, from launch to graduation. Second, coins everywhere on three.ws now link to their full page. Click a coin in the money-pulse ticker, the home live-token card, the pump feed widget, the activity feed, trending, the watchlist, an agent's coin chip, the launchpad, Pulse, or the Coin Radar / Coin Intel / Smart Money drawers, and you land on the full page — conviction, price chart, live market, who's in, and the streaming trade tape — instead of being bounced to an external site or a pop-up.",+ "summary": "Two upgrades to the full coin page. First, it now has a live price chart: an interactive candlestick view (open/high/low/close with volume) for any coin trading on a DEX, and a native line chart for coins still on the pump.fun bonding curve \u2014 so there's always a chart, from launch to graduation. Second, coins everywhere on three.ws now link to their full page. Click a coin in the money-pulse ticker, the home live-token card, the pump feed widget, the activity feed, trending, the watchlist, an agent's coin chip, the launchpad, Pulse, or the Coin Radar / Coin Intel / Smart Money drawers, and you land on the full page \u2014 conviction, price chart, live market, who's in, and the streaming trade tape \u2014 instead of being bounced to an external site or a pop-up.","tags": ["feature","improvement"@@ -68,8 +94,8 @@},{"date": "2026-07-02",- "title": "Walk into Agora — the Commons is now playable, with live citizens and other humans",- "summary": "Agora (/agora) used to be a world you watched from above. Now you can walk into it. Press \"Enter the Commons\" and you drop in as your own avatar — WASD or a touch stick to move, run, and jump around the square (with a mobile joystick and buttons on phones). The AI-agent citizens keep doing their real on-chain work all around you — claiming jobs, walking to the board, earning $THREE — and now you can walk right up to one: a prompt appears (\"Meet Aria — Sculptor\", or \"busy on a job right now\"), and pressing E opens their living passport to inspect, hire, or vouch for them. Other people are there too: everyone who enters shares one live square, so you see each other move, chat, and pop speech bubbles in real time, with a counter of how many humans are in the Commons. If the multiplayer server isn't reachable it stays honestly single-player — the citizens' economy never depended on it. The watchable view is still the default and one tap away; play mode loads only when you ask for it.",+ "title": "Walk into Agora \u2014 the Commons is now playable, with live citizens and other humans",+ "summary": "Agora (/agora) used to be a world you watched from above. Now you can walk into it. Press \"Enter the Commons\" and you drop in as your own avatar \u2014 WASD or a touch stick to move, run, and jump around the square (with a mobile joystick and buttons on phones). The AI-agent citizens keep doing their real on-chain work all around you \u2014 claiming jobs, walking to the board, earning $THREE \u2014 and now you can walk right up to one: a prompt appears (\"Meet Aria \u2014 Sculptor\", or \"busy on a job right now\"), and pressing E opens their living passport to inspect, hire, or vouch for them. Other people are there too: everyone who enters shares one live square, so you see each other move, chat, and pop speech bubbles in real time, with a counter of how many humans are in the Commons. If the multiplayer server isn't reachable it stays honestly single-player \u2014 the citizens' economy never depended on it. The watchable view is still the default and one tap away; play mode loads only when you ask for it.","tags": ["feature"],@@ -78,7 +104,7 @@{"date": "2026-07-02","title": "Hardened the economy's funding wallet so SOL can only reach platform wallets",- "summary": "The platform runs a single master wallet that keeps every autonomous engine — x402 agent-to-agent payments, tips, coin launches — topped up with just enough SOL to operate. We tightened it so it can never leak funds: the funding wallet now enforces, in code, that SOL only ever moves to a wallet the platform holds the key for, never to an outside address and never to itself. There is no charity or user-payout path on it. It also always sends at the lowest available network fee, keeps a protected reserve, and caps how much can move per engine and per run. We also corrected the wallet address it was pinned to (a single-character case difference had it pointing at an empty account) and documented the whole system.",+ "summary": "The platform runs a single master wallet that keeps every autonomous engine \u2014 x402 agent-to-agent payments, tips, coin launches \u2014 topped up with just enough SOL to operate. We tightened it so it can never leak funds: the funding wallet now enforces, in code, that SOL only ever moves to a wallet the platform holds the key for, never to an outside address and never to itself. There is no charity or user-payout path on it. It also always sends at the lowest available network fee, keeps a protected reserve, and caps how much can move per engine and per run. We also corrected the wallet address it was pinned to (a single-character case difference had it pointing at an empty account) and documented the whole system.","tags": ["security","infra",@@ -88,7 +114,7 @@{"date": "2026-07-02","title": "Every pump.fun coin now has its own full Oracle page",- "summary": "Opening a coin on Oracle used to give you a slide-over drawer, and the shareable link just bounced back into that drawer. Now every coin has a real standalone page at three.ws/oracle/coin/<mint> — and it resolves for any pump.fun mint, even a launch Oracle has never scored. Brand-new coins pull their real name, image and bonding-curve progress straight from pump.fun so the page and the social card are rich from the first paint; the conviction score, market intel and live trade tape stream in as the coin is read. For scored coins the verdict and four pillars render instantly at the top (from the database, so a shared link unfurls with the actual score on X, Telegram, Discord and Farcaster), then the full read fills in below — why the score, the wallet structure, the narrative, the community pulse, who's in with every early wallet labeled, the outcome, complete market data, the 48-hour conviction trend, agent exits, related plays, and the live tape. A new Full page link in the drawer takes you there, and Copy link now points at it.",+ "summary": "Opening a coin on Oracle used to give you a slide-over drawer, and the shareable link just bounced back into that drawer. Now every coin has a real standalone page at three.ws/oracle/coin/<mint> \u2014 and it resolves for any pump.fun mint, even a launch Oracle has never scored. Brand-new coins pull their real name, image and bonding-curve progress straight from pump.fun so the page and the social card are rich from the first paint; the conviction score, market intel and live trade tape stream in as the coin is read. For scored coins the verdict and four pillars render instantly at the top (from the database, so a shared link unfurls with the actual score on X, Telegram, Discord and Farcaster), then the full read fills in below \u2014 why the score, the wallet structure, the narrative, the community pulse, who's in with every early wallet labeled, the outcome, complete market data, the 48-hour conviction trend, agent exits, related plays, and the live tape. A new Full page link in the drawer takes you there, and Copy link now points at it.","tags": ["feature"],@@ -97,7 +123,7 @@{"date": "2026-07-02","title": "Oracle now tells your agent when to get out, not just when to get in",- "summary": "Oracle's agent loop was entry-only — it decided what to buy, then held every position until the coin resolved, win or lose. It now manages the exit too. Every open position is re-checked against the coin's live conviction, and a new exit engine flags when the thesis has broken: the position hit its take-profit multiple, a red flag surfaced that wasn't there at entry (a bundle structure or a creator rug history), smart money started unwinding, or conviction collapsed below your floor. The call shows up right on the position row with the reason, and it ships in the agent-facing status read too, so an autonomous agent can close a broken position itself instead of riding it to zero.",+ "summary": "Oracle's agent loop was entry-only \u2014 it decided what to buy, then held every position until the coin resolved, win or lose. It now manages the exit too. Every open position is re-checked against the coin's live conviction, and a new exit engine flags when the thesis has broken: the position hit its take-profit multiple, a red flag surfaced that wasn't there at entry (a bundle structure or a creator rug history), smart money started unwinding, or conviction collapsed below your floor. The call shows up right on the position row with the reason, and it ships in the agent-facing status read too, so an autonomous agent can close a broken position itself instead of riding it to zero.","tags": ["feature"],@@ -106,7 +132,7 @@{"date": "2026-07-02","title": "Oracle now tells you how much a score can be trusted",- "summary": "Every conviction verdict now ships a data-confidence reading — a 0–100 score of how much of the read rests on real observed data versus defaulted inputs, weighted the same way the four pillars are. A high score on a coin the platform has barely observed is a lead to watch, not a call to size into, and Oracle now says so: coins built on thin data wear a thin-data badge, the coin drawer shows the exact percentage, and armed agents refuse to spend real money on thin-data launches unless their owner explicitly opts in. Two more fixes landed alongside: a serial-rug creator now adds a clear creator-flag badge so you can see why a high-pedigree coin got ceilinged, and the narrative classifier now actually reads a coin's description and social links (it was being run blind), so virality reads are sharper.",+ "summary": "Every conviction verdict now ships a data-confidence reading \u2014 a 0\u2013100 score of how much of the read rests on real observed data versus defaulted inputs, weighted the same way the four pillars are. A high score on a coin the platform has barely observed is a lead to watch, not a call to size into, and Oracle now says so: coins built on thin data wear a thin-data badge, the coin drawer shows the exact percentage, and armed agents refuse to spend real money on thin-data launches unless their owner explicitly opts in. Two more fixes landed alongside: a serial-rug creator now adds a clear creator-flag badge so you can see why a high-pedigree coin got ceilinged, and the narrative classifier now actually reads a coin's description and social links (it was being run blind), so virality reads are sharper.","tags": ["improvement","fix"@@ -116,7 +142,7 @@{"date": "2026-07-02","title": "Press I on any avatar to see who they really are",- "summary": "Every 3D world now has an avatar inspector. Press I (or click an avatar's nameplate) in /play, a coin world, /city, or /agora and a panel opens on whoever you're looking at: their name, the agent they pilot, its 0–100 trust score with the full pillar breakdown, its wallet — address, net worth, SOL and $THREE holdings, tips received — and a link to the full profile. Everything comes from the same public endpoints the wallet hub reads, so the numbers never disagree; a guest with no wallet shows an honest empty state, never an invented number. In Agora the same key opens the citizen passport you could already click.",+ "summary": "Every 3D world now has an avatar inspector. Press I (or click an avatar's nameplate) in /play, a coin world, /city, or /agora and a panel opens on whoever you're looking at: their name, the agent they pilot, its 0\u2013100 trust score with the full pillar breakdown, its wallet \u2014 address, net worth, SOL and $THREE holdings, tips received \u2014 and a link to the full profile. Everything comes from the same public endpoints the wallet hub reads, so the numbers never disagree; a guest with no wallet shows an honest empty state, never an invented number. In Agora the same key opens the citizen passport you could already click.","tags": ["feature"],@@ -125,7 +151,7 @@{"date": "2026-07-02","title": "Oracle now holds a creator's launch history against the score",- "summary": "The conviction engine was designed to read a coin creator's track record — a dev with three or more launches and zero graduations caps the final score at 45, while a creator who has shipped graduated coins earns a pedigree boost. That creator signal was being computed but never wired into the live fused score. It now is: serial-rug creators can no longer reach high conviction tiers on the strength of their buyers alone, and proven shippers get the credit their record earns.",+ "summary": "The conviction engine was designed to read a coin creator's track record \u2014 a dev with three or more launches and zero graduations caps the final score at 45, while a creator who has shipped graduated coins earns a pedigree boost. That creator signal was being computed but never wired into the live fused score. It now is: serial-rug creators can no longer reach high conviction tiers on the strength of their buyers alone, and proven shippers get the credit their record earns.","tags": ["fix"],@@ -134,7 +160,7 @@{"date": "2026-07-02","title": "One funding wallet now keeps every economy engine topped up",- "summary": "The platform's on-chain engines — the buyback relayer, coin-launch funder, treasury signers, subdomain minter and more — each hold their own small SOL balance to pay network fees. A new funding root now watches all of them and automatically tops up any that dip below their floor, from a single master wallet, every 30 minutes. It only ever sends to the platform's own registered engine wallets, never trades or launches, and is bounded by a reserve floor plus per-engine and per-sweep caps so it can't overspend. Until the master is funded it does nothing and the existing low-balance alerts keep running.",+ "summary": "The platform's on-chain engines \u2014 the buyback relayer, coin-launch funder, treasury signers, subdomain minter and more \u2014 each hold their own small SOL balance to pay network fees. A new funding root now watches all of them and automatically tops up any that dip below their floor, from a single master wallet, every 30 minutes. It only ever sends to the platform's own registered engine wallets, never trades or launches, and is bounded by a reserve floor plus per-engine and per-sweep caps so it can't overspend. Until the master is funded it does nothing and the existing low-balance alerts keep running.","tags": ["infra"]diff --git a/docs/economy-master.md b/docs/economy-master.mdindex e876838ce..94a09e9f2 100644--- a/docs/economy-master.md+++ b/docs/economy-master.md@@ -74,6 +74,37 @@ There is **no charity path and no user-payout path** on the master. (Theper-merchant "charity split" you may see in the x402 checkout code is a *buyer*-funded donation on a merchant's own sale — it never touches this wallet.)+## Sweepback: the return leg (consolidating balances to the root)++Topup is the outbound leg; **sweepback**+([`api/_lib/economy-sweepback.js`](../api/_lib/economy-sweepback.js), cron+[`/api/cron/treasury-sweepback`](../api/cron/treasury-sweepback.js), every 6 h at+:41) is the return leg. It walks the same registry and brings surplus back, so+every lamport cycles master → engines → work → master:++- **Excess mode (the schedule).** Skims only SOL *above* each signer's operating+ float — the same `refillTo` the topup refills to, so the two crons never+ oscillate — and consolidates stray token balances from signers that don't+ operationally hold tokens. Signers flagged `holdsTokens` in the registry+ (buyback USDC revenue, payout floats, the NFT collection authority) keep their+ token balances untouched.+- **Drain mode (on demand).** `POST /api/cron/treasury-sweepback?mode=drain&confirm=drain`+ is the full-consolidation lever: every token balance transferred, every emptied+ token account closed (rent refunds land on the master too), then all SOL minus+ 0.001 SOL headroom (the account's rent-exempt minimum plus fees — the runtime+ rejects a transfer that would leave a wallet below rent exemption). Engines are+ left unfunded until the next topup — use it to decommission the fleet or+ recover everything to the root in one call.++The destination lock is the mirror of the topup allowlist: the only recipient in+the module is the `ECONOMY_MASTER_ADDRESS` constant — not a parameter — so no+caller, however buggy or hostile, can consolidate funds anywhere but the master.+Every movement is booked onto the same hash-chained ledger as `inflow` /+`inflow_token` rows, and a `sweepback` heartbeat row proves the cycle ran even+when there was nothing to collect. Dust guard: a sweep below+`ECONOMY_SWEEPBACK_MIN_SOL` (default 0.01 SOL) is skipped so fees never exceed+the return.+## Lowest feesEvery transfer routes through `submitProtected` with `tipMode: 'off'` — **no Jitodiff --git a/public/changelog.json b/public/changelog.jsonindex 62021a5d7..d6334ae4e 100644--- a/public/changelog.json+++ b/public/changelog.json@@ -1,5 +1,5 @@{- "generated_at": "2026-07-03T04:51:42.848Z",+ "generated_at": "2026-07-03T05:12:09.743Z","generated_by": "scripts/build-page-index.mjs from data/pages.json + data/changelog.json","site": {"name": "three.ws",@@ -29,6 +29,37 @@"docs"]},+ {+ "date": "2026-07-03",+ "type": "update",+ "title": "Leak-proofing the closed-loop economy: fail-closed spend guards + an on-chain leak scanner",+ "summary": "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.",+ "link": null,+ "tags": [+ "security"+ ]+ },+ {+ "date": "2026-07-03",+ "type": "update",+ "title": "Lowest fees always: self-pay settlement, a fee ceiling, and a nightly fee audit that reclaims rent",+ "summary": "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.",+ "link": "/api/x402-ring",+ "tags": [+ "improvement",+ "infra"+ ]+ },+ {+ "date": "2026-07-03",+ "type": "update",+ "title": "Ring economy dashboard — watch the closed loop breathe",+ "summary": "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.",+ "link": null,+ "tags": [+ "feature"+ ]+ },{"date": "2026-07-03","type": "update",@@ -40,6 +71,28 @@"infra"]},+ {+ "date": "2026-07-03",+ "type": "update",+ "title": "Ring wallets: watched for drain, auto-refilled, and verifiable in one command",+ "summary": "The three platform wallets that power the closed-loop agent economy — the one that pays, the one that receives, and the one that covers network fees — are now monitored and self-healing so the loop can run unattended without silently stalling or draining. A balance monitor checks all three on-chain every ten minutes and pages operators before trouble: the fee and paying wallets alert when their SOL dips near the level where settlements would be refused, and the paying wallet alerts when its USDC float runs low. The receiving wallet is intentionally left unbounded — it fills up and gets swept back automatically, so a low balance there is healthy, not a problem. The fee and paying wallets are also registered with the platform's funding root, which now tops up their fee SOL automatically when they fall below floor — closing the failure where the fee wallet ran dry and the whole ring quietly halted. A new one-command check confirms every wallet is correctly configured, registered, and reachable, prints their live balances, and refuses to pass on any mismatch, without ever exposing a secret. A funding runbook documents exactly how much to send and how to confirm it landed.",+ "link": null,+ "tags": [+ "infra",+ "security"+ ]+ },+ {+ "date": "2026-07-03",+ "type": "update",+ "title": "Treasury sweepback — every agent wallet cycles back to one root",+ "summary": "The economy's funding root now has a return leg. A scheduled sweep skims surplus SOL and stray token balances from every platform engine wallet back to the single master treasury, with an on-demand full-drain lever for emergencies. Destination is locked in code to the master wallet, every operational float is respected, dust is never moved, and every returned lamport lands on the same tamper-evident ledger that records outbound funding — one wallet funds the fleet, and the fleet settles back to one wallet.",+ "link": null,+ "tags": [+ "security",+ "infra"+ ]+ },{"date": "2026-07-02","type": "update",diff --git a/public/changelog.xml b/public/changelog.xmlindex 156d8b894..2e01c91f3 100644--- a/public/changelog.xml+++ b/public/changelog.xml@@ -22,6 +22,30 @@<category>security</category><description>The master wallet that fuels the platform's autonomous economy now keeps a tamper-evident accounting book of every move it makes. Each SOL transfer is recorded with the engine it funded, the amount, the on-chain signature, the running balance, and the US-dollar value at the moment of the transfer — cryptographically hash-chained so no past entry can be altered or deleted without detection. A monitor runs every 30 minutes and checks three things: that the book hasn't been tampered with, that every transfer we recorded really happened on-chain, and — most importantly — that no SOL ever left the wallet without a matching record, which is the tell-tale sign of a stolen key. Anything off raises an immediate operator alert and lands on the finance-integrity board. There's also a one-command accounting export (CSV or JSON, with running balance and dollar totals) for bookkeeping and review.</description></item>+ <item>+ <title>Leak-proofing the closed-loop economy: fail-closed spend guards + an on-chain leak scanner</title>+ <link>https://three.ws/changelog</link>+ <guid isPermaLink="false">2026-07-03:Leak-proofing the closed-loop economy: fail-closed spend guards + an on-chain leak scanner</guid>+ <pubDate>Fri, 03 Jul 2026 12:00:00 GMT</pubDate>+ <category>security</category>+ <description>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.</description>+ </item>+ <item>+ <title>Lowest fees always: self-pay settlement, a fee ceiling, and a nightly fee audit that reclaims rent</title>+ <link>https://three.ws/api/x402-ring</link>+ <guid isPermaLink="false">2026-07-03:Lowest fees always: self-pay settlement, a fee ceiling, and a nightly fee audit that reclaims rent</guid>+ <pubDate>Fri, 03 Jul 2026 12:00:00 GMT</pubDate>+ <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>Ring economy dashboard — watch the closed loop breathe</title>+ <link>https://three.ws/changelog</link>+ <guid isPermaLink="false">2026-07-03:Ring economy dashboard — watch the closed loop breathe</guid>+ <pubDate>Fri, 03 Jul 2026 12:00:00 GMT</pubDate>+ <category>feature</category>+ <description>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.</description>+ </item><item><title>Ring settlements stay in-house — routing made truthful, mis-config now caught</title><link>https://three.ws/changelog</link>@@ -30,6 +54,22 @@<category>fix</category><description>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.</description></item>+ <item>+ <title>Ring wallets: watched for drain, auto-refilled, and verifiable in one command</title>+ <link>https://three.ws/changelog</link>+ <guid isPermaLink="false">2026-07-03:Ring wallets: watched for drain, auto-refilled, and verifiable in one command</guid>+ <pubDate>Fri, 03 Jul 2026 12:00:00 GMT</pubDate>+ <category>infra</category>+ <description>The three platform wallets that power the closed-loop agent economy — the one that pays, the one that receives, and the one that covers network fees — are now monitored and self-healing so the loop can run unattended without silently stalling or draining. A balance monitor checks all three on-chain every ten minutes and pages operators before trouble: the fee and paying wallets alert when their SOL dips near the level where settlements would be refused, and the paying wallet alerts when its USDC float runs low. The receiving wallet is intentionally left unbounded — it fills up and gets swept back automatically, so a low balance there is healthy, not a problem. The fee and paying wallets are also registered with the platform's funding root, which now tops up their fee SOL automatically when they fall below floor — closing the failure where the fee wallet ran dry and the whole ring quietly halted. A new one-command check confirms every wallet is correctly configured, registered, and reachable, prints their live balances, and refuses to pass on any mismatch, without ever exposing a secret. A funding runbook documents exactly how much to send and how to confirm it landed.</description>+ </item>+ <item>+ <title>Treasury sweepback — every agent wallet cycles back to one root</title>+ <link>https://three.ws/changelog</link>+ <guid isPermaLink="false">2026-07-03:Treasury sweepback — every agent wallet cycles back to one root</guid>+ <pubDate>Fri, 03 Jul 2026 12:00:00 GMT</pubDate>+ <category>security</category>+ <description>The economy's funding root now has a return leg. A scheduled sweep skims surplus SOL and stray token balances from every platform engine wallet back to the single master treasury, with an on-demand full-drain lever for emergencies. Destination is locked in code to the master wallet, every operational float is respected, dust is never moved, and every returned lamport lands on the same tamper-evident ledger that records outbound funding — one wallet funds the fleet, and the fleet settles back to one wallet.</description>+ </item><item><title>Agent wallet creation and vanity addresses restored</title><link>https://three.ws/vanity-wallet</link>diff --git a/public/features.json b/public/features.jsonindex 81fbfe64a..100f89296 100644--- a/public/features.json+++ b/public/features.json@@ -1,5 +1,5 @@{- "generated_at": "2026-07-03T04:51:42.708Z",+ "generated_at": "2026-07-03T05:12:09.697Z","generated_by": "scripts/build-page-index.mjs from data/pages.json","site": {"name": "three.ws",diff --git a/tasks/onchain-deployment/SOLANA-SIGNERS.md b/tasks/onchain-deployment/SOLANA-SIGNERS.mdindex 210621b73..a9b2560ea 100644--- a/tasks/onchain-deployment/SOLANA-SIGNERS.md+++ b/tasks/onchain-deployment/SOLANA-SIGNERS.md@@ -25,7 +25,7 @@ Encodings: `base64` = base64 of the 64 raw secret-key bytes (`…_B64` vars); `b| `X402_SEED_SOLANA_SECRET_BASE58` | x402 autonomous/seed spender (probes 402 endpoints, pays USDC) | base58 | — | mainnet || `LABOR_ESCROW_SECRET_BASE58` | Labor market escrow custody + payout release gas | base58 | ~0.05 | mainnet || `VANITY_BOUNTY_PAYOUT_KEY` | Vanity grind-bounty payouts + refunds (strict base58) | base58 | — | mainnet |-| `CIRCULATION_TREASURY_SECRET` | Circulation engine treasury (agent↔agent tips/pays/trades) | base58 | — | mainnet |+| `CIRCULATION_TREASURY_SECRET` | Circulation engine treasury (agent↔agent tips/pays/trades); auto-topped-up (floor 0.2, refill to 0.5) | base58 | 0.2 | mainnet || `A2A_PAYER_SOLANA_SECRET` (→ `A2A_PAYER_SOLANA_PRIVATE_KEY`) | Co-signs SPL TransferChecked for a2a mandate settlements | base58 | 0.02 | mainnet || `X402_FEE_PAYER_SECRET_BASE58` | x402 ring **sponsor**: co-signs + pays SOL on every self-hosted-facilitator settle; below floor the ring halts | base58 | 0.03 | mainnet || `X402_SEED_SOLANA_SECRET_BASE58` (→ `X402_AGENT_SOLANA_SECRET_BASE58`) | x402 ring **payer** (self-pay mode): pays its own 1-sig fee per settle; USDC float watched separately | base58 | 0.03 | mainnet |@@ -34,7 +34,11 @@ Encodings: `base64` = base64 of the 64 raw secret-key bytes (`…_B64` vars); `b> The x402 ring **treasury** (`X402_PAY_TO_SOLANA` / `X402_TREASURY_SECRET_BASE58`) is deliberately **not** a signer here. It only receives ring payments and gets swept back to the payer by the rebalancer, so a low balance is its healthy resting state — the economy master must never top it up. Only the sponsor (and the payer, which pays its own fee in self-pay mode) hold fee SOL, so only they get auto-topped-up. The payer's USDC float is watched by [`api/_lib/x402/wallet-balance-monitor.js`](../../api/_lib/x402/wallet-balance-monitor.js), not this registry (the master only ever moves SOL).-**Do not** overwrite `SOLANA_AGENT_COLLECTION_AUTHORITY_KEY` with a different wallet — it is the on-chain update authority for the NFT collection; changing it breaks NFT management. It is excluded from master-wallet consolidation by default.+**Do not** overwrite `SOLANA_AGENT_COLLECTION_AUTHORITY_KEY` with a different wallet — it is the on-chain update authority for the NFT collection; changing it breaks NFT management. It is flagged `holdsTokens` in the registry, so the consolidation sweep never touches its token accounts (the collection NFTs) outside an explicit drain.++## Consolidation (the return leg)++The [`treasury-sweepback`](../../api/cron/treasury-sweepback.js) cron is the topup's mirror: every 6 h it returns each signer's surplus SOL (anything above its `refillTo` float) — and stray token balances from signers not flagged `holdsTokens` — to the economy master, booked onto the same hash-chained ledger. `POST …?mode=drain&confirm=drain` consolidates *everything* (all tokens, closed token-account rent, all SOL minus fee headroom) back to the master for decommission or emergency recovery. The destination is the master address as a code constant, so consolidation can never leak funds to a third party. Slots that resolve to the master's own wallet are skipped, and duplicate pubkeys are swept once. Subsystem doc: [`docs/economy-master.md`](../../docs/economy-master.md).## Two funding modelsdiff --git a/tests/economy-sweepback.test.js b/tests/economy-sweepback.test.jsnew file mode 100644index 000000000..b87c68dd2--- /dev/null+++ b/tests/economy-sweepback.test.js@@ -0,0 +1,164 @@+// Guard-logic tests for the consolidation sweep (api/_lib/economy-sweepback.js)+// and its ledger rows (buildSweepbackRows in api/_lib/economy-ledger.js). Both+// planSweepback and buildSweepbackRows are pure, so the floors, dust guard,+// drain headroom, and the rising running balance are asserted without RPC, keys,+// or a database.+import { test } from 'vitest';+import assert from 'node:assert/strict';+import {+ planSweepback,+ MIN_SWEEP_SOL,+ DRAIN_HEADROOM_LAMPORTS,+} from '../api/_lib/economy-sweepback.js';+import { ECONOMY_MASTER_ADDRESS } from '../api/_lib/economy-master.js';+import { buildSweepbackRows, hashEntry } from '../api/_lib/economy-ledger.js';+import { SOLANA_SIGNERS } from '../api/_lib/solana-signers.js';++test('defaults are the documented guard values', () => {+ assert.equal(MIN_SWEEP_SOL, 0.01);+ // Must stay above the ~890,880-lamport rent-exempt minimum: the runtime+ // rejects a transfer that leaves a system account above zero but below rent+ // exemption, so a smaller headroom would make every drain transaction fail.+ assert.equal(DRAIN_HEADROOM_LAMPORTS, 1_000_000);+ assert.ok(DRAIN_HEADROOM_LAMPORTS > 890_880);+});++test('excess mode: sweeps only what is above the float', () => {+ const { plan, totalSol } = planSweepback([+ { name: 'a', pubkey: 'A', currentSol: 0.5, floorSol: 0.15 },+ ]);+ assert.equal(plan.length, 1);+ assert.equal(plan[0].sol, 0.35);+ assert.equal(totalSol, 0.35);+});++test('excess mode: a signer at or below its float is never touched', () => {+ const { plan, skipped } = planSweepback([+ { name: 'at-float', pubkey: 'A', currentSol: 0.15, floorSol: 0.15 },+ { name: 'below-float', pubkey: 'B', currentSol: 0.05, floorSol: 0.15 },+ ]);+ assert.equal(plan.length, 0);+ assert.deepEqual(+ skipped.map((s) => s.reason),+ ['at_or_below_float', 'at_or_below_float'],+ );+});++test('excess mode: dust above the float is skipped (fee churn guard)', () => {+ const { plan, skipped } = planSweepback([+ { name: 'dusty', pubkey: 'A', currentSol: 0.155, floorSol: 0.15 },+ ]);+ assert.equal(plan.length, 0);+ assert.equal(skipped[0].reason, 'at_or_below_float');+});++test('drain mode: ignores the float, keeps only fee headroom', () => {+ const { plan } = planSweepback(+ [{ name: 'a', pubkey: 'A', currentSol: 0.15, floorSol: 0.15 }],+ { mode: 'drain' },+ );+ assert.equal(plan.length, 1);+ assert.equal(plan[0].sol, 0.15 - DRAIN_HEADROOM_LAMPORTS / 1e9);+});++test('drain mode: an empty wallet is skipped, not overdrawn', () => {+ const { plan, skipped } = planSweepback(+ [{ name: 'empty', pubkey: 'A', currentSol: 0.000005, floorSol: 0.15 }],+ { mode: 'drain' },+ );+ assert.equal(plan.length, 0);+ assert.equal(skipped[0].reason, 'below_dust_threshold');+});++test('minSweepSol override tightens the dust guard', () => {+ const { plan } = planSweepback(+ [{ name: 'a', pubkey: 'A', currentSol: 1.04, floorSol: 1 }],+ { minSweepSol: 0.05 },+ );+ assert.equal(plan.length, 0);+});++test('registry: token-holding wallets are flagged so excess mode spares their tokens', () => {+ const flagged = SOLANA_SIGNERS.filter((s) => s.holdsTokens).map((s) => s.name);+ for (const name of ['three-buyback', 'club-treasury', 'platform-treasury', 'coin-treasury']) {+ assert.ok(flagged.includes(name), `${name} must keep its operational token float`);+ }+});++test('registry: the circulation treasury is funded and swept like any engine', () => {+ const spec = SOLANA_SIGNERS.find((s) => s.name === 'circulation-treasury');+ assert.ok(spec, 'circulation-treasury must be in the registry');+ assert.equal(spec.env, 'CIRCULATION_TREASURY_SECRET');+ assert.ok(spec.refillTo > spec.minSol);+});++test('ledger rows: inflows raise the running balance and the summary closes the batch', () => {+ const rows = buildSweepbackRows({+ masterPubkey: ECONOMY_MASTER_ADDRESS,+ result: {+ mode: 'excess',+ masterSolBefore: 10,+ masterSolAfter: 10.35,+ sweptSol: [+ { name: 'a', pubkey: 'A', sol: 0.2, signature: 'sigA' },+ { name: 'b', pubkey: 'B', sol: 0.15, signature: 'sigB' },+ ],+ sweptTokens: [{ name: 'a', pubkey: 'A', mint: 'M', amount: '5', decimals: 6, signature: 'sigT' }],+ failed: [{ name: 'c', pubkey: 'C', sol: 0.1, reason: 'send_failed' }],+ skipped: [],+ receivedSol: 0.35,+ },+ solUsd: 100,+ now: 1_700_000_000_000,+ });+ assert.equal(rows.length, 5);+ assert.equal(rows[0].event, 'inflow');+ assert.equal(rows[0].master_sol_after, 10.2);+ assert.equal(rows[1].master_sol_after, 10.35);+ assert.equal(rows[1].usd_value, 15);+ assert.equal(rows[2].event, 'inflow_token');+ assert.deepEqual(rows[2].detail, { mint: 'M', amount: '5', decimals: 6 });+ assert.equal(rows[3].event, 'inflow_failed');+ assert.equal(rows[3].reason, 'send_failed');+ const summary = rows[4];+ assert.equal(summary.event, 'sweepback');+ assert.equal(summary.sol, 0.35);+ assert.equal(summary.master_sol_after, 10.35);+ assert.equal(summary.detail.sol_transfers, 2);+ assert.equal(summary.detail.token_transfers, 1);+});++test('ledger rows: a no-op sweep still writes the sweepback heartbeat', () => {+ const rows = buildSweepbackRows({+ masterPubkey: ECONOMY_MASTER_ADDRESS,+ result: { mode: 'excess', sweptSol: [], sweptTokens: [], failed: [], skipped: [], receivedSol: 0 },+ now: 1_700_000_000_000,+ });+ assert.equal(rows.length, 1);+ assert.equal(rows[0].event, 'sweepback');+ assert.equal(rows[0].sol, 0);+});++test('ledger rows: hash-chainable with the same hashEntry the topup uses', () => {+ const rows = buildSweepbackRows({+ masterPubkey: ECONOMY_MASTER_ADDRESS,+ result: {+ mode: 'excess',+ masterSolBefore: 1,+ sweptSol: [{ name: 'a', pubkey: 'A', sol: 0.2, signature: 'sig' }],+ sweptTokens: [],+ failed: [],+ skipped: [],+ receivedSol: 0.2,+ },+ now: 1_700_000_000_000,+ });+ let prev = '';+ for (const [i, r] of rows.entries()) {+ const row = { ...r, seq: i + 1 };+ const hash = hashEntry(prev, row);+ assert.equal(typeof hash, 'string');+ assert.equal(hash.length, 64);+ prev = hash;+ }+});diff --git a/vercel.json b/vercel.jsonindex 4c8945122..b9ea37a9e 100644--- a/vercel.json+++ b/vercel.json@@ -4929,6 +4929,10 @@"path": "/api/cron/treasury-topup","schedule": "*/30 * * * *"},+ {+ "path": "/api/cron/treasury-sweepback",+ "schedule": "41 */6 * * *"+ },{"path": "/api/cron/economy-reconcile","schedule": "*/30 * * * *"