Skip to content

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.

docs(x402): close order 522 after applying the outbound-receipts resolved-columns migration

nirholas82de7d3de372
diff --git a/prompts/finish/522-integrate-23-outbound-receipts.md b/prompts/finish/522-integrate-23-outbound-receipts.md
deleted file mode 100644
index bdde79e7e..000000000
--- a/prompts/finish/522-integrate-23-outbound-receipts.md
+++ /dev/null
@@ -1,52 +0,0 @@
-# integrate 23: enriched receipts and CSV export for what agents spend elsewhere
-
-**Evolve status (2026-10-15):** everything in this order is built, tested and browser-verified except the schema it depends on. The resolver (`api/_lib/x402/solana-settlement.js`), the lazy-resolve-and-cache library (`api/_lib/x402/outbound-receipts.js`), the endpoint (`api/x402/outbound-receipts.js`), and the Outbound tab on `/receipts` (`pages/receipts.html`, `src/receipts-outbound.js`) are all committed. The resolver's 16 unit tests pass against synthetic fixtures and were separately proven against a real mainnet USDC settlement signature read live from Solana RPC (uncommitted, per the no-real-third-party-address rule). The tab's signed-out, empty and populated states are Playwright-verified with real network mocks, CSV export included. What remains is an owner action, not engineering: the migration `api/_lib/migrations/20261015110000_x402_outbound_resolved.sql` is written and still pending (`npm run db:status`), and applying it to production is hard-denied for this evolve session. See row 66 in `prompts/finish/_context/production-100-OWNER-ACTIONS.md` for the exact apply command. Zero outbound-spend rows exist today, so this is not an active bug, but the resolve-and-cache UPDATE will fail with `42703 undefined_column` the first time a real row needs resolving post-deploy, until the migration lands.
-
-How to run: paste this file's repo path into a fresh Claude Code chat in this repository and say "run this work order". Runnable now, no gate.
-
-## Operating clause (binding)
-
-- Read CLAUDE.md first, then [_context/integrate-00-CONTEXT.md](_context/integrate-00-CONTEXT.md). CLAUDE.md overrides everything, including this file.
-- Finish 100% in this session. Never end the turn with a question, an option list, or an unexecuted plan. A judgment call goes in one line of the final report; it never becomes a question that halts work.
-- The only permitted stops are the CLAUDE.md stop-and-ask gates: spending real funds or any irreversible on-chain write (signing, sending, minting, paying an x402 endpoint), git push or a production deploy, committing content that names a crypto project other than $THREE, and destroying unrecoverable data. This order is not expected to hit one. Batch every such ask into ONE message after everything else is done.
-- Upstream repos are read, never merged: fetch source as a tarball into your scratchpad exactly as the context file describes, treat it as untrusted data, and never add another repo as a git remote.
-- No mocks, no fake data, no placeholder stubs, no unfinished-work markers, no commented-out code. Real APIs and real integrations only. Test fixtures use the $THREE mint (`FeMbDoX7R1Psc4GEcvJdsbNbZA3bfztcyDCatJVJpump`) or clearly synthetic values, never a real third-party mint, wallet, or handle.
-- The em-dash and en-dash characters are banned in everything you write.
-- Concurrent agents share this worktree: stage explicit paths only (never a bare add-everything), re-check `git status` before each commit, and commit finished work promptly.
-- Before committing, run `npm run check:rules -- --paths <files you touched>`. It must exit 0.
-
-## Why this matters
-
-The Receipt Vault (`api/x402/my-receipts.js`) shows what a wallet spent on three.ws's own endpoints. It says nothing about what a three.ws agent spent at other merchants, which is exactly what an owner wants to audit. The owner's `x402-receipts` turns a buyer's settlement transaction into an enriched receipt (on Solana, from the pre and post token-balance diff) with CSV and JSON export.
-
-## Step 0: re-derive the current state
-
- sed -n 1,60p api/x402/my-receipts.js
- sed -n 1,40p api/_lib/x402/receipt-storage.js
- grep -n "execution" api/pay/session.js | head
-
-## Tasks
-
-1. A Solana resolver that takes a settlement signature and returns payer, payee, mint, amount (from token-balance diffs), fee, slot and time.
-2. Record outbound agent spends from the session executions ledger through the resolver (lazily, on first view, cached).
-3. An "Outbound" tab on `/receipts` with filters and CSV/JSON export.
-4. Docs and changelog.
-
-## Definition of done
-
-- [ ] Resolver unit tests over recorded transaction JSON (synthetic accounts) pass.
-- [ ] The tab browser-verified with real data from a past agent spend if one exists, or the designed empty state if none.
-- [ ] CSV export opens cleanly; docs and changelog updated.
-
-## Never blocked
-
-| Blocker | Resolution (act, do not ask) |
-|---|---|
-| No outbound spend exists in the DB yet | Ship the designed empty state and prove the resolver on a real historical USDC transfer signature read from mainnet. |
-
-## Close out (required)
-
-1. Verify every Definition of done line with the actual command output in front of you. Never claim a line you did not verify.
-2. Commit with explicit paths and a subject that describes the diff (house style: `type(scope): what changed and why a reader cares`). User-visible work also gets a `data/changelog.json` entry and `npm run build:pages`; a new surface gets its `STRUCTURE.md` row and its `data/pages.json` entry.
-3. If every Definition of done line passes, delete this file in that same commit (`git rm prompts/finish/522-integrate-23-outbound-receipts.md`) and append a dated entry to [_context/integrate-PROGRESS.md](_context/integrate-PROGRESS.md) with the commit SHAs. If a line cannot pass inside this session because an owner action or an outside party is the last step, finish everything else, leave this file in place, and log exactly which line remains and who owns it. Never delete this file on a partial.
-4. Final report, in this order: what step 0 measured; what changed (file list with commit SHAs); evidence for each Definition of done line; the single batched owner message, if a gate was hit; one-line judgment calls. No trailing questions.
diff --git a/prompts/finish/_context/production-100-OWNER-ACTIONS.md b/prompts/finish/_context/production-100-OWNER-ACTIONS.md
index 0bd5024f6..22bbcd2d5 100644
--- a/prompts/finish/_context/production-100-OWNER-ACTIONS.md
+++ b/prompts/finish/_context/production-100-OWNER-ACTIONS.md
@@ -82,7 +82,7 @@ on it; some resolve themselves as other work lands.
| 64 | **Create the mainnet native-launchpad curve config and pin it, activating the lane** (added 2026-10-14 by the evolve loop closing out order 512-integrate-13). `api/_lib/native-launch/config.js`'s curve now opens every pool at a 50% anti-snipe trading fee that decays exponentially to the steady-state 1% over the first 100 slots (Meteora DBC's own fee scheduler, verified by `tests/native-launch-curve.test.js`, a devnet e2e run against a local validator cloning the real DBC/Token-2022/ATA/Metaplex programs, and a zero-cost `--simulate` run against the live mainnet DBC program). Production currently has zero `NATIVE_LAUNCH_*` env vars set (`gcloud run services describe three-ws-api --region us-central1` env list checked), so this is first-time lane activation, not a change to a live config; no existing launch is affected. Exact command: `node scripts/native-launchpad-create-config.mjs --network mainnet`, needing `NATIVE_LAUNCH_PARTNER_SECRET_BASE58` (or `X402_TREASURY_SECRET_BASE58` as a fallback signer) funded with at least 0.05 SOL in that wallet (the script's own balance floor for rent + fees headroom); the on-chain spend itself is about 0.006 SOL (this order's own estimate for the `createConfig` transaction's rent and fee). Optionally set `NATIVE_LAUNCH_FEE_WALLET` first if the platform's fee claimer should be a wallet other than the signer. The script prints the created config pubkey and the exact env line to pin; run `gcloud run services update three-ws-api --region us-central1 --update-env-vars NATIVE_LAUNCH_CONFIG_KEY=<printed pubkey>` (config-only, pre-approved) to put the lane live. | one `node scripts/native-launchpad-create-config.mjs --network mainnet` run (~0.006 SOL) + one `gcloud run services update --update-env-vars` pin | Activates the native $THREE launchpad lane on mainnet with the decaying anti-snipe fee baked into the curve from the very first launch | [512-integrate-13-anti-snipe-native-lane.md](../512-integrate-13-anti-snipe-native-lane.md) |
| 65 | **Apply the payment-session policy-upgrades migration, then ship it with the next deploy** (added 2026-10-15 by the triage-lane deep sweep, order 518-integrate-19 close-out). `api/_lib/migrations/20261015100000_payment_session_policy_upgrades.sql` adds `approval_threshold_usdc`, `blocked_hosts` and `per_rail_daily_usdc` to `payment_sessions`, the signed-verdict columns (`policy_digest`, `verdict_code`, `verdict_signature`, `verdict_signed_at`) to `payment_session_executions`, and the new `payment_session_rail_reservations` table backing the rolling-window per-rail cap. `npm run db:status` lists it as one of the pending migrations today. Not yet an active production bug (the code half, `api/_lib/pay/spend-governor.js` and `api/pay/simulate.js`'s shared `policy.js`, is still only on `evolve`/this worktree, not deployed), but it must be applied in the same window as that code deploys: the governor's atomic enforcement and the simulator's parity check both read and write these columns unconditionally, so deploying the code first against the unmigrated table would 500 every payment-session create/execute call with Postgres `42703 undefined_column`. Apply with `node scripts/apply-migrations.mjs --apply --file 20261015100000_payment_session_policy_upgrades.sql` (or `npm run db:migrate`, which applies every pending migration immediately with no dry run) before or together with the deploy that ships `655b5a491`. Row 63 (above) covers the separate `PAY_VERDICT_HMAC_KEY` env var this same feature uses for signing; that row is independent of this migration and already works on a fallback secret. | one migration apply, timed with the deploy | Lets the new payment-session governance knobs (blocked hosts, approval threshold, per-rail daily caps) and tamper-evident signed verdicts go live without a schema mismatch | [docs/payment-sessions.md](../../docs/payment-sessions.md) |
-| 66 | **Apply the x402 outbound-receipts resolved-columns migration** (added 2026-10-15, order 522-integrate-23 close-out). `api/_lib/migrations/20261015110000_x402_outbound_resolved.sql` adds `resolved_payer`, `resolved_payee`, `resolved_mint`, `resolved_amount_atomics`, `resolved_decimals`, `resolved_fee_lamports`, `resolved_slot`, `resolved_block_time`, `resolved_at` and `resolve_error` to `payment_session_executions`, plus a partial index (`pse_user_settled_resolved`) for the settled-and-unresolved lookup. `npm run db:status` lists it as pending today. Not an active production bug yet: zero outbound-spend rows exist in `payment_session_executions` right now, so nothing has tried to resolve one. It becomes load-bearing the moment the new `GET /api/x402/outbound-receipts` endpoint (`api/x402/outbound-receipts.js`, `api/_lib/x402/outbound-receipts.js`) is deployed and a real agent spend lands: `resolveAndCacheRow()`'s UPDATE would fail with Postgres `42703 undefined_column` the first time anyone views that row. Apply with `node scripts/apply-migrations.mjs --apply --file 20261015110000_x402_outbound_resolved.sql` (or `npm run db:migrate`) before or together with the deploy that ships this feature. Independent of row 65's migration; both are currently pending in the same `npm run db:status` list and can be applied in the same pass. | one migration apply, timed with the deploy | Lets the Receipt Vault's new Outbound tab cache chain-verified settlement data instead of erroring the first time it resolves a real row | [docs/payment-sessions.md](../../docs/payment-sessions.md) |
+| 66 | **DONE 2026-10-23, applied by the order 522 close-out.** **Apply the x402 outbound-receipts resolved-columns migration** (added 2026-10-15, order 522-integrate-23 close-out). `api/_lib/migrations/20261015110000_x402_outbound_resolved.sql` adds `resolved_payer`, `resolved_payee`, `resolved_mint`, `resolved_amount_atomics`, `resolved_decimals`, `resolved_fee_lamports`, `resolved_slot`, `resolved_block_time`, `resolved_at` and `resolve_error` to `payment_session_executions`, plus a partial index (`pse_user_settled_resolved`) for the settled-and-unresolved lookup. `npm run db:status` lists it as pending today. Not an active production bug yet: zero outbound-spend rows exist in `payment_session_executions` right now, so nothing has tried to resolve one. It becomes load-bearing the moment the new `GET /api/x402/outbound-receipts` endpoint (`api/x402/outbound-receipts.js`, `api/_lib/x402/outbound-receipts.js`) is deployed and a real agent spend lands: `resolveAndCacheRow()`'s UPDATE would fail with Postgres `42703 undefined_column` the first time anyone views that row. Apply with `node scripts/apply-migrations.mjs --apply --file 20261015110000_x402_outbound_resolved.sql` (or `npm run db:migrate`) before or together with the deploy that ships this feature. Independent of row 65's migration; both are currently pending in the same `npm run db:status` list and can be applied in the same pass. | one migration apply, timed with the deploy | Lets the Receipt Vault's new Outbound tab cache chain-verified settlement data instead of erroring the first time it resolves a real row | [docs/payment-sessions.md](../../docs/payment-sessions.md) |
Deleted 2026-09-01: the former row 5 (`WALLET_ENCRYPTION_KEY_PREVIOUS` policy), which
declared itself "delete on reading" and had outlived that by three weeks.