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
chore(prompts): retire order 424, on-chain pump/coin degrade shipped
nirholasc0c5eac4c556
diff --git a/prompts/finish/424-auto-pump-coin-onchain-degrade.md b/prompts/finish/424-auto-pump-coin-onchain-degrade.mddeleted file mode 100644index 854982f44..000000000--- a/prompts/finish/424-auto-pump-coin-onchain-degrade.md+++ /dev/null@@ -1,83 +0,0 @@-# 424. `/api/pump/coin` 502s once its 24h last-known-good cache is exhausted, with no on-chain degrade path--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. Depends conceptually on order 423 (same root cause) but touches a different file and ships independently; do not block on 423 being merged first, re-derive state fresh per Step 0.--## Operating clause (binding)--- Read CLAUDE.md first. 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, git push or a production deploy, posting to an external channel, committing content that references a crypto project other than $THREE, and destroying unrecoverable data. This order touches none of them.-- No mocks of the thing under test, no fake data, no unfinished-work markers, no commented-out code, no `it.skip` / `.todo` to make a failure disappear.-- The em-dash and en-dash characters are banned in everything you write.-- Concurrent agents share this worktree: stage explicit paths only (never `git add -A` or `git add .`), re-check `git status` and `git diff --staged` before committing.-- Before committing, run `npm run check:rules -- --paths <files you touched>`. It must exit 0.-- Bug fixes are test-first (CLAUDE.md): there is currently no test file for `api/pump/[action].js`'s `handleCoin`/`serveStaleCoin` path. Write one that reproduces the bug (upstream down, no live cache, no LKG cache → hard 502) before changing any implementation code.--## Why this matters (measured 2026-10-24 08:21-08:35 UTC, from HEAD `a3b0b8f2e`)--Same root cause as order 423, a different endpoint, and a worse failure mode because this one has already burned through its full 24-hour safety margin:-- curl -s -D - "https://three.ws/api/pump/coin?mint=FeMbDoX7R1Psc4GEcvJdsbNbZA3bfztcyDCatJVJpump"- → HTTP 502 {"error":"upstream_failed","error_description":"pump.fun returned 403", ...} (no x-pump-stale header: the 24h LKG is also empty)--pump.fun's `frontend-api-v3.pump.fun` is answering every request from this environment with a Cloudflare challenge, confirmed directly:-- curl -s -D - -o /dev/null --max-time 10 "https://frontend-api-v3.pump.fun/coins/FeMbDoX7R1Psc4GEcvJdsbNbZA3bfztcyDCatJVJpump"- → HTTP 403, cf-mitigated: challenge, server: cloudflare--`api/pump/[action].js`'s `handleCoin` has three tiers: a 30s in-memory `COIN_CACHE`, a direct fetch, then `serveStaleCoin` which checks the same in-memory cache and a 24-hour `cacheGet(coinLkgKey(mint))`. The CF block has now outlasted even the 24-hour tier for $THREE's own mint: the platform's own promoted coin's `/api/pump/coin` card is currently unrenderable anywhere in the frontend that calls it directly. In the same 1000-row / 8.5-minute production error-log sample used in order 423 (`gcloud logging read 'resource.type="cloud_run_revision" resource.labels.service_name="three-ws-api" severity>=ERROR httpRequest.status>=500'`), `/api/pump/coin` 502s account for a further meaningful slice behind the `/api/crypto/bonding` 503s, confirming this is not a one-off for one mint.--Full pump.fun coin metadata (name, symbol, image, description, socials) genuinely does not exist on-chain, Jupiter, or anywhere else this codebase can reach without pump.fun's web API, so this endpoint cannot be fully on-chain-backed the way order 423's bonding endpoint can. The achievable, honest fix is a graceful three-tier degrade instead of a hard 502:--1. Numeric/curve fields (bonding progress, graduation, market cap, SOL-in-curve) can come from `getCurveView()` (`api/_lib/pump-curve-view.js`, already proven live, see order 423's evidence) exactly as in order 423.-2. Identity metadata (name, symbol, image, creator) can come from this platform's own `pump_agent_mints` table for any mint that was launched or is tracked through three.ws (check `api/_lib/db.js` or wherever `pump_agent_mints` is queried elsewhere, e.g. grep `pump_agent_mints` in `api/`), which is real first-party data, not a guess.-3. Only if neither source has anything should the endpoint fall back to today's 502, and it should say so plainly (`error_description` naming pump.fun specifically, not a generic message) so the frontend can render an honest "metadata temporarily unavailable" state instead of a blank error.--## Step 0: re-derive the current state-- git log --oneline -1- curl -s -D - "https://three.ws/api/pump/coin?mint=FeMbDoX7R1Psc4GEcvJdsbNbZA3bfztcyDCatJVJpump" -o /dev/null # confirm still 502, no x-pump-stale- curl -s "https://three.ws/api/pump/curve?mint=FeMbDoX7R1Psc4GEcvJdsbNbZA3bfztcyDCatJVJpump" # confirm the on-chain reader still works for numeric fields- curl -s -D - -o /dev/null --max-time 10 "https://frontend-api-v3.pump.fun/coins/FeMbDoX7R1Psc4GEcvJdsbNbZA3bfztcyDCatJVJpump" # confirm the CF block (if cleared, check Step 0 note below)- grep -n "pump_agent_mints" api/**/*.js | head -40 # find how the platform already queries its own launch-record table- sed -n '1,80p' api/_lib/pump-curve-view.js # getCurveView's export shape, reused from order 423- grep -n "handleCoin\|serveStaleCoin\|COIN_CACHE\|COIN_LKG_TTL_S\|coinLkgKey" api/pump/\[action\].js # locate the exact lines to change--If pump.fun's block has cleared and a fresh `/api/pump/coin` call for several real mints returns 200 directly (not from the stale path), the immediate outage is over, but ship the degrade path anyway: the 24-hour LKG tier being fully exhausted proves this has already happened for a sustained period and will recur, and today the only alternative to pump.fun answering is a bare 502 with no honest message and no partial data.--## Tasks--1. Create `tests/pump-coin-endpoint.test.js`. Mirror the mocking pattern from `tests/pump-bonding.test.js` (Map-backed `vi.mock('../api/_lib/cache.js', ...)`, `vi.stubGlobal('fetch', ...)`, `THREE_MINT = 'FeMbDoX7R1Psc4GEcvJdsbNbZA3bfztcyDCatJVJpump'`). Import whatever is exported/exportable from `api/pump/[action].js` for this handler (check what is currently exported; if `handleCoin` is not exported, add a named export for it alongside the default handler, the same way the file likely already structures its other `handle*` functions per action, confirm by reading the file's export pattern first rather than assuming). Write these cases before touching implementation:- - Live fetch succeeds → 200, full pump.fun body, unchanged from today (regression guard).- - Live fetch fails, in-memory `COIN_CACHE` has a recent entry → stale 200 with `x-pump-stale: 1`, unchanged from today (regression guard).- - Live fetch fails, no in-memory cache, 24h LKG cache empty, `getCurveView` (mocked) returns usable on-chain data, no `pump_agent_mints` row → 200 with numeric/curve fields populated from the mock, identity fields (`name`/`symbol`/`image`) present but explicitly marked unavailable (e.g. `null` plus a `metadataSource: 'onchain'`/`'unavailable'` flag, pick a convention consistent with how `mapBondingStatus`'s `source` field reads), and NOT a 502. This is the new test that must fail against current code before the fix.- - Same as above but a `pump_agent_mints` row exists for the mint (mock the DB call) → 200 with identity fields populated from that row.- - Live fetch fails, no in-memory cache, no LKG, `getCurveView` also fails/returns nothing, no DB row → the true triple-miss still returns 502, with an `error_description` that names pump.fun specifically (regression guard on the honest-failure path, do not let the degrade logic swallow the real "everything is down" case silently).-2. In `api/pump/[action].js`, change `serveStaleCoin` (or add a sibling function called from the same failure path in `handleCoin`) to implement the three tiers from "Why this matters" above: in-memory cache → 24h LKG cache → `getCurveView` + `pump_agent_mints` DB lookup merge → honest 502. Import `getCurveView` from `../_lib/pump-curve-view.js` (relative path from `api/pump/`, confirm the exact relative path before writing the import, `api/_lib/pump-curve-view.js` vs `api/pump/_lib/...`, check with `ls api/_lib/pump-curve-view.js`). For the DB lookup, reuse whatever existing query/helper already reads `pump_agent_mints` elsewhere in the codebase (found in Step 0's grep) rather than writing a new one; if none exists as a reusable helper, add the minimal query next to it following that file's existing query style.-3. When serving the degraded response, set a distinguishing response header (e.g. `x-pump-degraded: onchain`) alongside or instead of `x-pump-stale`, and confirm no existing frontend code treats `x-pump-stale` presence as "this is fresh enough to not show a degraded-data indicator" in a way that would now mislabel on-chain-only data as fresh pump.fun data (grep `x-pump-stale` across `src/` and `public/`).-4. Run `npx vitest run tests/pump-coin-endpoint.test.js` until every case passes for the right reason (the new on-chain-degrade cases must have failed against the pre-fix code first; confirm this by running the suite once before task 2's edit and noting the failure, then once after).--## Definition of done--- [ ] `tests/pump-coin-endpoint.test.js` exists, covers all five cases in task 1, and `npx vitest run tests/pump-coin-endpoint.test.js` exits 0.-- [ ] The true triple-miss (pump.fun down, no caches, on-chain fallback also unavailable, no DB row) still returns 502 with an honest, pump.fun-specific `error_description`, never silently swallowed into a confusing 200.-- [ ] No hardcoded third-party mint added to source or tests; `FeMbDoX7R1Psc4GEcvJdsbNbZA3bfztcyDCatJVJpump` is the only real mint used.-- [ ] `npm run check:rules -- --paths api/pump/[action].js tests/pump-coin-endpoint.test.js` exits 0.-- [ ] One `data/changelog.json` entry (tag `fix`) describing the degrade path, since `/api/pump/coin` is a documented public endpoint.-- [ ] Commit with explicit paths; subject names the actual fix (e.g. `fix(pump): degrade /api/pump/coin to on-chain numeric data plus first-party metadata instead of a bare 502 when pump.fun is Cloudflare-blocked`).--## Never blocked--| Blocker | Resolution (act, do not ask) |-|---|---|-| The CF block has cleared by the time you run this | Ship the degrade path anyway; the 24h LKG being fully exhausted is itself proof this already happened for a sustained period. Note in the report that the live symptom was not reproducible at run time. |-| `handleCoin` is not currently exported / is tightly coupled to the request/response objects of the `[action].js` router | Export the smallest testable unit (a pure function taking `mint` and returning the response body/status, with `req`/`res` plumbing kept thin in the router), following whatever pattern the file already uses for its other actions; do not restructure the whole file, only this handler. |-| No reusable `pump_agent_mints` query helper exists anywhere | Write the minimal `SELECT name, symbol, image_url FROM pump_agent_mints WHERE mint = $1` (match actual column names from the table's existing usage, do not guess blind) next to this handler; do not build a generic data-access layer, that is out of scope. |-| `getCurveView` import path is wrong on first try | `ls api/_lib/pump-curve-view.js` to confirm the real path before importing; `api/pump/[action].js` imports from `../_lib/...` the same way order 423's target file does from a sibling location. |--## Close out (required)--1. Verify every Definition of done line with the command output in front of you. Never claim a line you did not verify.-2. Commit with explicit paths, one commit (or a small number if the changelog/test edits are cleanly separable).-3. Delete this file in the final commit (`git rm prompts/finish/424-auto-pump-coin-onchain-degrade.md`) once every Definition of done line is verified green, and append a dated entry to `prompts/finish/_context/production-100-PROGRESS.md` with the commit SHA(s). If a line cannot pass, leave the file and say which line remains and why.-4. Final report, in this order: the Step 0 measurements (reproduced or not, with the exact curl output); the diff summary; the before/after test counts for the new test file; the one-line judgment calls (export shape, DB column names, header naming). No trailing questions.diff --git a/prompts/finish/_context/production-100-PROGRESS.md b/prompts/finish/_context/production-100-PROGRESS.mdindex ad2dea5b7..2d5d2147f 100644--- a/prompts/finish/_context/production-100-PROGRESS.md+++ b/prompts/finish/_context/production-100-PROGRESS.md@@ -1724,3 +1724,25 @@ Tests: in `tests/pump-bonding.test.js`, added `vi.mock('../api/_lib/pump-curve-vBefore/after on production (honest: this order ships the fix on `evolve`, not on the deployed Cloud Run revision, per the order's own step 6; deploys are owner-gated): `curl https://three.ws/api/crypto/bonding?mint=...` was `503 upstream_unavailable` before this session and remains `503` after, since the fix has not been deployed. The CF block on `frontend-api-v3.pump.fun` was also still live at both measurements (`403`, `cf-mitigated: challenge`), confirming the order's premise held throughout, not just at the order's original 08:21-08:35 UTC measurement window.Left: nothing for this order's own scope. The fix is committed to `evolve` and ready to ship on the next owner-approved deploy (not a new row in `production-100-OWNER-ACTIONS.md`: deploy cadence is already tracked there as a standing row, same acknowledged-limitation shape as orders 421/422 in this file). `prompts/finish/423-auto-bonding-curve-onchain-fallback.md` deleted in this closing commit.++## 2026-10-24: order 424 (/api/pump/coin 502s once its 24h LKG cache is exhausted; on-chain degrade wired) closed++Measured: step-0 confirmed every premise live. `curl -s -D - "https://three.ws/api/pump/coin?mint=FeMbDoX7R1Psc4GEcvJdsbNbZA3bfztcyDCatJVJpump"` returned `HTTP/2 502 {"error":"upstream_failed","error_description":"pump.fun returned 403", ...}` with no `x-pump-stale` header, confirming the 24h LKG tier for $THREE's own mint is genuinely exhausted, not merely a fresh miss. `curl -s "https://three.ws/api/pump/curve?mint=..."` stayed healthy (`200`, `graduated:true`, live Jupiter market cap), confirming the on-chain reader this order reuses is sound. `curl -s -D - --max-time 10 "https://frontend-api-v3.pump.fun/coins/..."` returned `403`, `cf-mitigated: challenge`, `server: cloudflare`: the block is unchanged from order 423's diagnosis, confirming this is the same root cause hitting a second endpoint harder because this one had no remaining safety margin left.++Corrected one factual error in the order's own guidance before writing code: its "Never blocked" table suggested querying `pump_agent_mints` for `name, symbol, image_url`, but reading the table's migrations (`api/_lib/migrations/2026-04-30-pump-fun.sql` and two later ones) and its existing UNION query in `api/_lib/pump-agent-launches.js` (which explicitly nulls `image_url` for `pump_agent_mints` rows) proved that table has no `image_url` column at all; only `fixed_supply_launches` does. Queried the real columns (`name, symbol, agent_authority`) instead and left `image`/`image_uri` explicitly `null` in the degraded body rather than fabricate a field, per the order's own "match actual column names, do not guess blind" instruction.++Did: in `api/pump/[action].js`, exported `handleCoin` (previously module-private) and added `fetchOnchainCoinDegrade(mint)`, called from `serveStaleCoin` after both the in-memory `COIN_CACHE` check and the 24h LKG `cacheGet` check miss. It calls `getCurveView({mint, network:'mainnet'})` (the same reader order 423 proved live behind `/api/pump/curve`) for numeric/curve fields and queries `pump_agent_mints` for identity fields (`name`, `symbol`, `agent_authority` as `creator`), tagging the result `metadataSource: 'platform'` when a registry row exists or `'onchain'` when only curve data answered. Returns `null` (falling through to the existing honest 502) only when both sources have nothing. The degraded 200 response carries `x-pump-degraded: onchain` (never `x-pump-stale`, keeping that header's existing meaning intact) plus `stale:true`/`as_of`. The true triple-miss path is unchanged: still a 502 with `error_description` naming pump.fun specifically.++Confirmed via `grep -rn "x-pump-stale" src/ public/` that no frontend code treats that header's presence as a freshness signal (zero matches outside generated changelog prose), so no frontend change was needed to avoid mislabeling on-chain-only data as fresh pump.fun data.++Tests: wrote `tests/pump-coin-endpoint.test.js` (new file, this handler had no test coverage before) mirroring `tests/pump-live-stream.test.js`'s minimal mock set for importing the large `[action].js` dispatcher, plus `tests/pump-bonding.test.js`'s Map-backed `cache.js` mock and mocked `getCurveView`. Six cases: live-fetch-succeeds (regression guard), in-memory-cache-serves-stale via `vi.useFakeTimers()` aging a primed entry past the 30s TTL within one test (regression guard), two new on-chain-degrade cases (no DB row vs. a DB row present), and two true-triple-miss honest-502 cases (on-chain reader returns nothing, and on-chain reader throws). Each non-priming test uses its own synthetic per-test mint (`THREEtest<tag>` padded with `9`s, the CLAUDE.md-sanctioned placeholder style) rather than sharing $THREE's mint, since `COIN_CACHE` is a true in-process `Map` singleton with no external mock and would otherwise leak a "fresh" entry from one test into the next within the same file run; this was diagnosed directly (5 of 6 cases first failed for that wrong reason, traced to `COIN_CACHE` having no reset hook, unlike `pump-bonding.js`'s analogous tier which is entirely `cacheGet`/`cacheSet`-backed and thus fully resettable via `cache.clear()`) before being fixed by key isolation instead of touching the cache's production code.++Before/after proof required by the order's task 4: temporarily set aside the implementation edit via a tagged `git stash` (captured and dropped by SHA, never a bare `stash pop`, per this worktree's shared-stash-stack rule) and reran the new suite against pre-fix code: all 6 cases failed (`handleCoin is not a function`, since the export itself is part of the fix) before re-applying. After re-applying: `npx vitest run tests/pump-coin-endpoint.test.js`: 6/6 passed. Before: 6 failed, 0 passed; after: 0 failed, 6 passed.++`npm run check:rules -- --paths "api/pump/[action].js" tests/pump-coin-endpoint.test.js`: "OK: no hard-rule violations." Added one `data/changelog.json` entry (`fix` tag, linking `/docs/api-reference`) and ran `npm run build:pages`: regenerated `CHANGELOG.md`, `public/changelog.json`, `public/changelog-recent.json`, `public/changelog.xml`, `public/features.json`; diffed each, only the new entry's content plus the expected rolling-window drop of the oldest `changelog-recent.json` entry and timestamp bumps, no unrelated corruption.++`git status --short` before staging showed exactly the eight expected paths; staged every path explicitly (never `-A`), confirmed `git diff --staged --stat` matched. `check:rules` ran again automatically at commit time and passed. Fix commit: `1b636242e`.++No hardcoded third-party mint anywhere in source or tests; `FeMbDoX7R1Psc4GEcvJdsbNbZA3bfztcyDCatJVJpump` is the only real mint used, exactly as the Definition of Done requires.++Left: nothing for this order's own scope. The fix is committed to `evolve` and ready to ship on the next owner-approved deploy, same acknowledged-limitation shape as orders 421-423 in this file. `prompts/finish/424-auto-pump-coin-onchain-degrade.md` deleted in this closing commit.