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.

chore(prompts): refresh order 401 to today's test:core baseline, add order 402 for live console errors

nirholasaac8e07f1f6a
diff --git a/prompts/finish/401-auto-restore-green-vitest.md b/prompts/finish/401-auto-restore-green-vitest.md
index c31aedd6f..38c8f6e0d 100644
--- a/prompts/finish/401-auto-restore-green-vitest.md
+++ b/prompts/finish/401-auto-restore-green-vitest.md
@@ -1,62 +1,52 @@
-# 401. Restore a green `npm run test:core`: 37 failing files, 74 failing tests on `main`
+# 401. Restore a green `npm run test:core`: 52 failing files, 108 failing tests on `evolve`
-**Evolve status (2026-10-08, from the order 024 retry):** the suite is green on the evolve working tree. `E2E_PORT=3107 npm test` exits 0: vitest 2194 files / 31,910 tests, 0 failed (from 34 files / 72 tests), and Playwright 262 passed, 5 skipped. The fixes landed one commit per class: D/E `821771220`, A `025a9474c` and `2cc2908d7` (`pay_quote`, because pay_and_call could never run), B `4da09d565`, C `f8af368cb` `3c21bc70e` `0cf94cb6b` `6c546e91b` `219ad4534`. Playwright: `cc84796d6` `fcbf15d47` `3ae6db5ff` `a6113184d` `958b10969` `83e77b691`; webkit system deps were installed with `sudo npx playwright install-deps webkit`. The audits pass: `audit:mcp-catalog`, `check:mcp-catalog`, `audit:guards` (85 OK). No skips were added, and there are no `/workspaces` paths left. One line is still open: at HEAD, `tests/mcp-schema.test.js` fails 3 tests until the coin-gated regenerated `public/mcp-catalog.json` is committed (OWNER-ACTIONS row 26). After that, verify `npm run test:core` at HEAD and retire this order.
-
-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. Written by the evolve scout lane on 2026-10-08 from the measurements below.
+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. Rewritten by the evolve scout lane on 2026-10-24 from a fresh measurement; the file's prior content (dated 2026-10-08) described a different failure set that order 406 already closed out (its own closing note recorded the post-fix baseline as this same 52/108, then parked two of these as follow-up without filing them). Treat everything below as the current truth and ignore any memory of this order's old content.
## 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 names a crypto project other than $THREE, and destroying unrecoverable data. This order touches none of them. Watch the coin gate on test fixtures and doc edits: if a fix needs content naming another crypto project, leave that hunk uncommitted and say so.
+- 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. Watch the coin gate on test fixtures and doc edits: if a fix needs content naming another crypto project, leave that hunk uncommitted and say so.
- No mocks of the thing under test, no fake data, no unfinished-work markers, no commented-out code, no `it.skip` / `describe.skip` / `.todo` to make a failure disappear. A test is only deleted when the code it covered was deliberately removed, and the commit message says which commit removed it.
- 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 each commit, and commit finished work promptly, one topical commit per failure class.
- Before committing, run `npm run check:rules -- --paths <files you touched>`. It must exit 0.
+- Bug fixes are test-first (CLAUDE.md): where the fix is to the CODE (not a stale test pin), confirm the existing test fails for the stated reason before changing anything, fix, then confirm it passes.
-## Why this matters (measured 2026-10-08, 17:27 UTC, `main` at `1c0fc8432`)
+## Why this matters (measured 2026-10-24, from HEAD `0674cb2ee`)
-`npm run test:core` (`vitest run`) ends:
+ npm run test:core
+ Test Files 52 failed | 2428 passed | 11 skipped (2491)
+ Tests 108 failed | 36720 passed | 229 skipped (37057)
- Test Files 37 failed | 2153 passed | 9 skipped (2199)
- Tests 74 failed | 31731 passed | 197 skipped (32002)
+`npm test` runs `vitest run && playwright test`, so every work order's "tests pass" line is unverifiable until this is green. One green suite unblocks honest verification for the whole queue.
-`npm test` runs `vitest run && playwright test`, so the Playwright stage has not run for anyone. Every work order's definition of done says "`npm test` passes" and every agent currently has to baseline the red and argue "no new failures", which is how real regressions hide. Order 400 and every later order inherit this. One green suite unblocks the honest verification line of the whole queue.
+The failures are not one bug. Grouped by what they look like (verify each with `npx vitest run <file>`; this grouping is a researched starting map, not gospel):
-The failures are not one bug. First error per file, grouped by what they look like (verify each; the grouping is a hypothesis):
+**A. One missing DB column in a test's own hand-written fixture schema (not a real migration gap).** `tests/approvals.test.js` fails all 19 of its cases with `error: column "meta" does not exist` from pglite. Root cause confirmed by reading the file: it creates its own `agent_identities` table at line 81 as `create table agent_identities (id uuid primary key, user_id uuid, name text, deleted_at timestamptz)`, with no `meta` column. `api/_lib/approvals.js:596` (added by the burner-cap policy feature, commit `e9359c74d`) does `SELECT meta FROM agent_identities WHERE id = ...` and reads `row.meta.burner_policy`. The real `agent_identities` table has had a `meta jsonb` column since migration `20260616235900_agent_identities_meta_skills.sql`; only this test's hand-rolled DDL is behind. Fix: add `meta jsonb not null default '{}'::jsonb` to the test's `create table` statement. Also grep `tests/burner-approvals.test.js` and any other file that hand-creates `agent_identities`, since the same gap likely repeats there.
-**A. Stale test doubles: the handler gained an import the test's `vi.mock` factory does not export, so the route 500s inside the test.**
-- `tests/agent-guard-endpoint.test.js` (9): `No "clientIp" export is defined on the "../api/_lib/rate-limit.js" mock`
-- `tests/api/onboarding-actions.test.js`, `tests/api/marketplace-agents-csrf.test.js`: `No "hasSessionCookie" export is defined on the "../../api/_lib/auth.js" mock` (expected 200, got 500)
-- `tests/api/security-csrf-gates.test.js`: `Cannot convert undefined to a BigInt` at `api/_lib/token/config.js:24`
-- `tests/api/x402-pay-routing.test.js`: `no dev keypair` from its `node:fs` mock
-- `tests/agent-wallet-withdraw.test.js` (4): idempotent replay answers 409, expected 200
-- `tests/api/leaderboard-rollup-cron.test.js`: `{ checked: 0 }`, expected 2
-- `tests/api/mcp-memory.test.js` (2): `forget is turned off for this connection`, expected an ownership error
-- `tests/api/forge-nim.test.js`: public https `baseUrl` override no longer accepted (likely the DNS-resolving SSRF check; commit `6bd6b4ef5` fixed the same class for BYOK fixtures)
+**B. A real, single-root-cause duplicate: `data/pages.json` declares the same path twice, four times over.** Confirmed by `grep -n` on the file: `/grok` at both line 639 and line 6520, `/docs/grok` at both 4582 and 4622, `/docs/grok-bot` at both 4590 and 4642, `/tutorials/grok-bot-recipes` at both 4634 and 7216. This single duplication cascades into at least four failing files: `tests/atlas.test.js` (route-existence check sees the dupes and reports them instead of the fixture route it expects), `tests/pages-routes.test.js` (asserts each path declared exactly once), `tests/sitemap-type.test.js` (core sitemap count off by exactly 4: 918 actual vs 914 expected, 918 > 914 confirms 4 extra entries), `tests/route-build-inputs.test.js`. Fix once: read both declarations of each duplicated path, keep whichever is the complete/correct one (compare metadata, likely one was added by a grok-campaign commit without noticing the entry already existed from an earlier commit), delete the other, and re-run all four files.
-**B. Catalogs grew and the pinned expectations did not.** `tests/api/mcp-agent.test.js` (8), `tests/api/mcp-agent-catalog.test.js`, `tests/api/mcp-agent-challenge.test.js`, `tests/api/mcp-bazaar.test.js`, `tests/api/mcp-bazaar-challenge.test.js`, `tests/agora-mcp-tools.test.js`, `tests/mcp-schema.test.js` (3: `agora_quote_register` and one more listed tool carry no input schema), `packages/home-mcp/tests/registration.test.js` (2), `tests/pump-alert-eval.test.js` (alert kinds grew). For each, decide whether the new tool or kind is intended (find its commit) and then update the pin, the challenge metadata, the published catalog and its golden files together. A tool listed without an input schema is a product defect, not a stale pin.
+**C. Safety and policy guards firing correctly; fix the code or registry, never the guard.**
+- `tests/real-funds-agreement-coverage.test.js`: `api/_mcpagent/named-services-tools.js` uses a custodial key but never calls `requireRealFundsAgreement`. This is a live money-path gate. Read the file; either wire the gate on its money-moving path, or add an `EXEMPT` entry with the stated reason no funds move. Treat this with the same care CLAUDE.md gives spend paths.
+- `tests/audit-guards.test.js`: four gate steps run but are not registered in `data/guards.json`: `check:cli-scripts`, `test:mcp-surface`, `check:well-known-skills`, `check:postman-collection`. Register them (find the pattern from an existing guard entry).
+- `tests/skill-rails.test.js`: the `a2a` rail returns 500 instead of 200 on a dry-run quote that "prices each enabled rail from one quote and moves no funds". Find the 500's real cause (likely an import or shape change in the a2a rail module) and fix the code; this is a payment-quote path, so do not loosen the assertion.
+- `tests/branding.test.js`: forbidden vendor names (`Avaturn`, likely others) appear in 5+ "user-facing" locations, including `pages/video-to-motion.html:246` (a real served page: fix the copy) and several `docs/` files the guard's own definition of "user-facing" currently reaches (`docs/ops/...`, `docs/partners/outreach-plan.md`, `docs/research/...`). For the real page, fix the copy. For the docs hits, decide per file: either the guard's scope is too broad for internal ops/research notes and should exclude them (check `scripts/` for the branding scanner and see whether other `docs/` subtrees are already excluded for the same reason), or the content genuinely should not name a competitor and needs the "Competitor X" treatment this repo already uses elsewhere. Do not silently loosen the guard without reading why it currently includes those paths.
-**C. Safety and policy guards that are firing correctly.** Fix the code or registry, never the guard.
-- `tests/real-funds-agreement-coverage.test.js` (5): four handlers use a custodial key but never call `requireRealFundsAgreement` (`api/_mcp/resources.js`, `api/agents/_id/credits.js`, `api/cli/[action].js`, `api/inference/[action].js`), and the fifth case reports a stale exemption. This is a money-path gate; read each file and either gate its money path or add an `EXEMPT` entry with the reason no funds move, and drop the stale exemption.
-- `tests/mcp-remote-annotations.test.js` (3): `agent_card_create` advertises `destructiveHint: true` against the pinned set.
-- `tests/audit-guards.test.js` (2): `scripts/check-xai-models.mjs looks like a guard but is not in data/guards.json`.
-- `tests/guard-wiring.test.js`: `docs/ops/guard-wiring.md` lacks rows for `check:community-skills` and two more guards.
-- `tests/branding.test.js` (3): a forbidden vendor brand appears in 10 user-facing locations (first: `docs/aws-builder-center-universal-retargeting.md:66`).
-- `tests/pages-routes.test.js`: `data/pages.json` declares one `/docs/...` path twice (the test prints it); `tests/atlas.test.js` and `tests/sitemap-type.test.js` (814 vs 815) likely fall with the same duplicate.
-- `tests/route-build-inputs.test.js`: two routed static pages are not emitted by the build.
-- `tests/server-404-routes.test.js`: a real tutorial no longer resolves to its article.
-- `tests/x-content.test.js`: one item in the committed X queue fails validation.
+**D. Catalogs, docs, and counters that grew without their pin.** Update every place a number or list is pinned, in the same commit as whatever shipped the growth:
+- `tests/mcp-tool-result.test.js`: a new tool's description does not match the test's `/\$[0-9]/` pricing-mention expectation. Find whether the tool is genuinely free (then exempt it the way other free tools are) or is missing its price line.
+- `tests/cron-scheduler-sync.test.js`: `README.md` and `docs/build.md` both say "145" crons; `vercel.json` now declares 147. Update both docs to 147 (or find the generator that stamps that number and rerun it).
+- `tests/notify-prefs.test.js`: category count drifted (one category added, pinned list has 11, code now has 12, or vice versa per the diff shown); update the pin.
+- `tests/x-content.test.js`: one committed X queue item needs re-review because its copy or media changed after the last review stamp; re-review it and update its review timestamp.
+- `tests/mcp-use-cases-doc.test.js`, `tests/grok-bot-doc.test.js` (4 cases), `tests/grok-page.test.js`, `tests/grok-skill-file.test.js` (2), `tests/grok-skill-md.test.js`: `docs/mcp.md` and `docs/grok-bot.md` have drifted from the live `/api/mcp-grok` tool/sample contract. Diff what the docs claim against what the code actually serves and bring the docs current (this is the `docs-freshness`/`changelog-and-docs` discipline, not a code change).
+- `tests/dashboard-api-keys-table.test.js`, `tests/api/api-keys.test.js`, `tests/api/keys-endpoint.test.js`, `tests/api/mcp-wallet-provision.test.js`, `tests/api/oauth-authorize.test.js`, `tests/api/oauth-introspect.test.js`, `tests/oauth-endpoints.test.js` (5): likely the same family (the OAuth consent screen and connector-preset scopes changed shape; one case's exact diff is already captured: the consent page's "Read your avatars" list item text no longer matches the test's literal "See your avatars" expectation). Diagnose each: decide whether the UI copy or the test string is stale and fix accordingly.
+- `tests/api/mcp-agent.test.js`, `tests/mcp-credit-plans.test.js`, `tests/mcp-spend-gate.test.js`, `tests/mcp-studio-asset-links.test.js`, `tests/x402-ring-catalog.test.js`, `tests/x402-discovery-green.test.js` (the `/api/x402/transit-delays` resource fails CDP's own schema: `/input/queryParams/route must be string`, fix the resource's declared schema), `tests/cron-forge-lane-guards.test.js`, `tests/registry-resolve-endpoint.test.js`, `tests/thumbnail-url-guard.test.js`, `tests/print-fulfillment-routing.test.js`, `tests/og-cards.test.js`, `tests/open-source-credits.test.js`, `tests/x-content-approval.test.js`, `tests/x-content-reel.test.js`, `tests/x-mention-intents.test.js`, `tests/asset-host-liveness.test.js`, `tests/directory-page-refs.test.js`, `tests/api/defi-cache-dedup.test.js`, `tests/api/developer-webhooks.test.js`, `tests/api/gpt-forge-clone.test.js`, `tests/api/launcher-claimer-cron.test.js`, `tests/api/v1-robinhood.test.js`, `tests/avatar-template-cache.test.js`, `tests/agent-guard-endpoint.test.js`, `tests/a2a-payment-hardening.test.js`: not yet triaged below the headline error. Run each with `npx vitest run <file>` and classify into A to E; most are expected to be the same B/C/D shape as the rest of this list (a catalog, schema, or policy that changed on one side without the other).
-**D. Machine-specific or time-bound tests.**
-- `tests/zz-probe.test.js` imports `/workspaces/three.ws/src/game/combat-system.js`, an absolute path from one codespace. It was committed in `fa4a242e8` as a probe; either delete it (if another test already covers `CombatSystem`) or make it resolve relative to `import.meta.url`.
-- `tests/src/usdz-pipeline.test.js` opens `/workspaces/three.ws/public/avatars/cz.glb`: same fix.
-- `tests/check-event-window.test.js`: "the configured event that ships has not already ended" (event end 2026-09-26 against today). Decide what the guard should say once an event is over (see `npm run check:event` in `gate`) and make the test date-independent with an injected clock.
-- `tests/vanity-grinder-batch.test.js`: off-GCE shard resolution returns `name-hash`, expected `unavailable`.
-- `tests/prepare-deploy-worktree.test.js`: plan mode exits 1 where 0 is expected; check whether it fails only because this machine already has a deploy worktree.
-- `tests/avatar-sdk-api.test.js`: `Failed to resolve import "../dist/index.mjs"`. The build chain creates it (`build:lib:full` then `build:avatar-sdk`); the test must either build or skip with a stated precondition the way other dist-dependent tests do (find their pattern).
+**E. Named and parked by order 406's own closing note, not yet filed anywhere else.**
+- `tests/multiplayer-server-boot.test.js`: `multiplayer/package.json` pins `@colyseus/ws-transport@^0.18.4`, which peer-requires `@colyseus/core@^0.18.5`, alongside `@colyseus/core@^0.16.24` pinned directly. The mismatch landed via a Dependabot merge (`63374bac6`). Resolve the version conflict in `multiplayer/package.json` (likely bump the direct `@colyseus/core` pin to satisfy both, or pin `@colyseus/ws-transport` back to a version compatible with `^0.16.24`; check Colyseus's own compatibility table before choosing), then `npm install` inside `multiplayer/` and re-run.
+- `tests/native-launch-curve.test.js` > "produces a rising multi-point curve": `buildCurveWithMarketCap` now returns a single-point curve for the native $THREE launch lane under `@meteora-ag/dynamic-bonding-curve-sdk` 2.0.0, where the previously-stale SDK produced multiple rising points. This is a real-money curve-shape change, not a test artifact: read the SDK's 2.0.0 changelog/source for `buildCurveWithMarketCap`, confirm whether a single-point curve is the SDK's new correct behavior for the given inputs (in which case fix the test's expectation and add a comment citing the SDK version) or a misuse of the new API on our side (in which case fix the call site). Do not paper over this one; it shapes a real token launch curve.
-**E. Real-looking logic failures.** `tests/eidon-imu-clip.test.js` (6: calibration angle is `NaN`), `tests/src/animation-canonical-support.test.js` (5: `root.updateMatrixWorld is not a function` in `src/animation-retarget.js:346`). Find whether the code or the fixture regressed; both sit on the universal-animation path CLAUDE.md calls load-bearing.
+**F. Known flaky, confirmed by order 406 (re-verify, do not just skip).** `tests/pump-live-stream.test.js`, `tests/strategy-compiler-backtest.test.js` (hits the real platform LLM, no mock, per CLAUDE.md), `tests/usage-direct-insert-timeout.test.js`. These were not in the FAIL list at this measurement, so if they fail during your run, rerun once before treating as a regression.
## Step 0: re-derive the current state
@@ -65,24 +55,24 @@ The failures are not one bug. First error per file, grouped by what they look li
grep -E "Test Files|Tests " /tmp/test-core-before.log
grep -E "^ FAIL" /tmp/test-core-before.log | sed 's/ >.*//' | sort | uniq -c | sort -rn
-Do not pipe `npm run test:core` through `tail` when you need the exit code. If the counts differ from the table above, the live list is the work; the grouping above is a starting map. Re-run a single file with `npx vitest run <file>` to see its full error, and use `git log --oneline -5 -- <file> <the module it tests>` to find which side moved.
+Do not pipe `npm run test:core` through `tail` when you need the exit code; it takes about 2.5 minutes, run it in the background and poll the log file. If the counts differ from the 52/108 above, the live list is the work; the classes above are a starting map, not a checklist to force-fit. Re-run a single file with `npx vitest run <file>` to see its full error, and use `git log --oneline -5 -- <file> <the module it tests>` to find which side moved.
## Tasks
-1. Work the classes in order A, C, E, B, D (A and C hide real 500s and safety gaps; B and D are pins and environment). For every file decide which side is wrong, the code or the test, and say so in the commit message.
-2. Class A: extend each `vi.mock` factory with the missing exports using `importOriginal` where the real module is safe to load, so the next added import does not break it again.
-3. Class C: fix the code or the registry. `tests/real-funds-agreement-coverage.test.js` gets particular care: a custodial key on a money path without `requireRealFundsAgreement` is a live gap, so gate it and add a handler test proving the gate, unless the file truly moves no funds.
-4. Class B: update every place a catalog is pinned in the same commit (tests, challenge metadata strings, golden files under `tests/` or `data/`, and `npm run audit:mcp-catalog` / `npm run check:mcp-catalog` inputs). Run those two audits after.
-5. Class D: no absolute machine paths in any test (`grep -rn "/workspaces/three.ws" tests/ packages/*/tests` must be empty afterwards); no test that depends on today's date.
-6. Class E: root-cause and fix; add the regression case that would have caught it.
+1. Work the classes in order C, A, B, E, D, F (C hides real safety and payment gaps; A and B are each one concrete root cause with an outsized blast radius; D is the long tail of pins).
+2. Class C: fix the code or the registry, never loosen an assertion to make a guard stop firing.
+3. Class A: add the missing `meta jsonb not null default '{}'::jsonb` column to every test fixture that hand-creates `agent_identities` without it (grep `create table agent_identities` across `tests/`).
+4. Class B: resolve the `data/pages.json` quadruple duplicate once; re-run `tests/atlas.test.js`, `tests/pages-routes.test.js`, `tests/sitemap-type.test.js`, `tests/route-build-inputs.test.js` together afterward.
+5. Class E: both items need a real decision (a dependency version resolution, and a domain call on a token-launch curve shape), not a quick patch. Read the cited SDK/package docs before changing either.
+6. Class D: for each untriaged file, run it alone, classify it, and fix the side that is actually wrong, updating the test and the implementation together where both drifted.
7. After each class, run `npm run test:core` and record the counts.
-8. Finally run the Playwright half that has been masked: `npx playwright test` (needs a dev server per `playwright.config.*`; use a free port, never 3000). Fix what is ours; record anything environment-bound with its exact error.
+8. Finally run the Playwright half, still masked by `npm run test:core` never getting that far: `npx playwright test` (needs a dev server per `playwright.config.*`; use a free port, never 3000). Fix what is ours; record anything environment-bound with its exact error.
## Definition of done
- [ ] `npm run test:core` exits 0 (paste the summary lines).
-- [ ] `grep -rnE "\.(skip|todo)\(" $(git diff --name-only <step-0 sha> -- tests packages) ` shows nothing added by this order.
-- [ ] `grep -rn "/workspaces/three.ws" tests/ packages/*/tests` prints nothing.
+- [ ] `grep -rnE "\.(skip|todo)\(" $(git diff --name-only <step-0 sha> -- tests packages)` shows nothing added by this order.
+- [ ] `grep -c '"path": "/grok"\|"path": "/docs/grok"\|"path": "/docs/grok-bot"\|"path": "/tutorials/grok-bot-recipes"' data/pages.json` each prints exactly 1.
- [ ] `npm run audit:mcp-catalog && npm run check:mcp-catalog && npm run audit:guards` exit 0.
- [ ] `npx playwright test` was run; its result (pass count, or each failure with its cause) is in the report.
- [ ] `npm run check:rules -- --paths <files you touched>` exits 0.
@@ -92,16 +82,17 @@ Do not pipe `npm run test:core` through `tail` when you need the exit code. If t
| Blocker | Resolution (act, do not ask) |
|---|---|
-| You cannot tell whether code or test is right | `git log -p` both; the newer intentional change wins, and the commit message records the call. If a behavior change looks accidental (a 409 where a replay should return 200), the code is wrong. |
+| You cannot tell whether code or test is right | `git log -p` both; the newer intentional change wins, and the commit message records the call. If a behavior change looks accidental (a 500 where a quote should return 200), the code is wrong. |
| A fix would touch content naming another crypto project | Make the fix, leave that hunk uncommitted, and list it in the report; evolve preserves it as a named stash for the owner. |
| Another agent fixes some of these while you work | Rebase your understanding on `git log`; re-run the suite; do not redo their work. |
| A failure needs a built artifact (`avatar-sdk/dist`, `character-studio/build`) | Build it with the repo's own script (`npm run build:lib:full && npm run build:avatar-sdk`), never by committing the artifact. |
| Playwright needs browsers that are not installed | `npx playwright install chromium`; if the network refuses, record the exact error and finish the vitest half. |
| The suite is too slow to iterate on | Iterate per file with `npx vitest run <file>`; run the full suite only at class boundaries. |
+| The native-launch-curve SDK question is genuinely ambiguous from the source alone | Write the smallest reproduction against the installed `@meteora-ag/dynamic-bonding-curve-sdk` showing the actual output for the test's exact inputs, decide from that evidence, and say which way you decided and why in the commit message. |
## 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 topical commit per class, each subject describing that diff (e.g. `test(mcp): pin the grown agent-wallet catalog and give agora_quote_register an input schema`).
+2. Commit with explicit paths, one topical commit per class, each subject describing that diff (e.g. `fix(approvals): add the meta column the burner-policy read needs to the test fixture`).
3. If every line passes, delete this file in the final commit (`git rm prompts/finish/401-auto-restore-green-vitest.md`) and append a dated entry to `prompts/finish/_context/production-100-PROGRESS.md` with the commit SHAs. If a line cannot pass, leave the file, log which line remains and why.
4. Final report, in this order: the step 0 counts; per class, what was wrong (code or test) and the commit SHA; the final counts; the Playwright result; one-line judgment calls. No trailing questions.
diff --git a/prompts/finish/402-auto-clear-live-console-errors.md b/prompts/finish/402-auto-clear-live-console-errors.md
new file mode 100644
index 000000000..516551d1a
--- /dev/null
+++ b/prompts/finish/402-auto-clear-live-console-errors.md
@@ -0,0 +1,92 @@
+# 402. Clear console errors on three.ws's highest-traffic live pages
+
+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. Written by the evolve scout lane on 2026-10-24 from a fresh unauthenticated live-page sweep of production.
+
+## 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; it edits frontend/API source in this worktree only. Fixes land here as commits; the owner's next deploy ships them, exactly like every other prepared fix in this queue.
+- No mocks, no fake data, no unfinished-work markers, no commented-out code.
+- The em-dash and en-dash characters are banned in everything you write.
+- Stage explicit paths only (never `git add -A` or `git add .`); re-check `git status` and `git diff --staged` before each commit.
+- Before committing, run `npm run check:rules -- --paths <files you touched>`. It must exit 0.
+- Bug fixes are test-first (CLAUDE.md): where a fix changes runtime behavior and the repo has a test file for that module, add or extend a test that reproduces the console error's root cause, confirm it fails first, fix, confirm it passes. Where the root cause is purely in a page's own inline script with no existing test harness for it, say so and fix directly; do not invent a new test framework for one page.
+
+## Why this matters (measured 2026-10-24, unauthenticated sweep against `https://three.ws`)
+
+`npm run audit:web` (`scripts/page-audit.mjs`) drives a real headless Chromium through every route in `data/pages.json` and records console errors, uncaught exceptions, and failed requests. A full sweep covers 980 routes across desktop and mobile and takes over an hour, so this order's own measurement is a partial desktop-viewport pass (stopped early, about 160 of 980 routes, to hand off promptly): it already surfaced 20 live pages throwing real browser console errors, several of them severe:
+
+ 🔴 /gallery (93e/0w)
+ 🔴 /monitor (84e/0w)
+ 🔴 /marketplace (58e/2w)
+ 🔴 /agents-live (52e/0w)
+ 🔴 /drive (48e/2w)
+ 🔴 /feed (38e/0w)
+ 🔴 /forge-studio (36e/0w)
+ 🔴 /characters (24e/0w)
+ 🔴 /artifact (24e/0w)
+ 🔴 /alpha-copilot (20e/0w)
+ 🔴 /classic (16e/0w)
+ 🔴 /community (14e/0w)
+ 🔴 /forged (12e/0w)
+ 🔴 / (12e/0w) ← the homepage itself
+ 🔴 /cad (7e/0w)
+ 🔴 /grok (6e/6w)
+ 🔴 /import/vroid (2e/0w)
+ 🔴 /discord-activity (2e/0w)
+ 🔴 /apps/shopify (2e/0w)
+ 🔴 /crawl (1e/0w)
+
+This is a live production defect, which the RUN-ORDER rule ranks above every unshipped fix and every new feature in this queue. The homepage carrying 12 real console errors is the single highest-leverage item in `prompts/finish/` right now: it is the first thing every new visitor's browser executes.
+
+The script itself distrusts its own parallel-sweep counts (see its header comment: on 2026-07-28, 108 of 131 reported errors turned out to be contention artifacts of running 5 pages at once) and re-verifies every error-severity finding solo, one page at a time, before writing the final report. Treat the numbers above as strong candidates, not as confirmed root causes: the pattern (many of the worst offenders are the heaviest WebGL/Three.js pages: gallery, monitor, agents-live, drive, forge-studio, characters, artifact, classic, cad) suggests a shared root cause in a 3D/rendering dependency rather than 20 unrelated bugs, which is exactly the kind of fix that is worth finding first, since it would clear most of this list in one commit.
+
+## Step 0: re-derive the current state
+
+ npm run audit:web > /tmp/audit-web-$(date +%s).log 2>&1 &
+ # takes 60-90+ minutes for the full 980-route x 2-viewport sweep; let it run in the
+ # background and keep working. It writes reports/page-audit-<timestamp>.{json,md}
+ # when done, with exact error text and a screenshot per offending route, already
+ # solo-reverified.
+ curl -s https://three.ws/api/version
+ git log --oneline -10 -- public/ src/
+
+While that runs, start on the homepage (`/`) directly, since it needs no report to justify fixing: open it in a real browser (or `npx playwright test` style script) with devtools console open, or grep its page module under `src/`/`public/` for obvious causes (a removed export still imported, a null dereference on a DOM node that does not exist on first paint, an API call with no response guard).
+
+## Tasks
+
+1. **Homepage first (`/`, 12 errors).** This is production's front door. Reproduce locally: serve the built frontend (`npm run dev` or the production build, whichever the repo's existing manual QA docs call for) and open `/` with console open. Fix every error at its root: a missing null-check, a race with an async asset load, a stale import. Do not silence a console.error call; fix what it is reporting.
+2. **Look for the shared cause across the WebGL-heavy pages before fixing them one by one.** `/gallery`, `/monitor`, `/agents-live`, `/drive`, `/forge-studio`, `/characters`, `/artifact`, `/classic`, `/cad` are all 3D/Three.js-driven pages with unusually high error counts (93, 84, 52, 48, 36, 24, 24, 16, 7). Check whether they share a module (a Three.js loader, a shared avatar/animation import, a WebGL context helper) that recently changed; `git log --oneline -20 -- src/animation-retarget.js src/glb-canonicalize.js` and any shared Three.js bootstrap file is the first place to look. If one shared regression explains most of this list, fix it once and re-run those specific routes to confirm the count drops across all of them, rather than patching each page's symptom separately.
+3. **Clear the remainder individually**, in error-count order, once the report from Step 0 has exact text and a screenshot per route: `/marketplace`, `/feed`, `/alpha-copilot`, `/community`, `/forged`, `/grok` (6 errors and 6 warnings; also check whether this is the same `data/pages.json` duplicate-path bug fixed in order 401's class B, since `/grok` is one of the duplicated paths there), `/import/vroid`, `/discord-activity`, `/apps/shopify`, `/crawl`.
+4. **After the full sweep from Step 0 finishes**, read `reports/page-audit-<newest>.md`'s "## Detail" section top to bottom; it is sorted by error count and already solo-reverified. Fix anything newly surfaced there that this partial pass did not catch (the mobile viewport was not sampled at all in this order's measurement), and confirm every route listed above now shows `0e` by re-running `npx vitest`-free direct checks or a targeted partial sweep (`node scripts/page-audit.mjs` supports auditing a subset; check its `--help` or source for a routes filter before writing a new one).
+5. If any fix touches `/grok`, `/import/vroid`, or anything that renders token/coin metadata, remember on-chain and token metadata is untrusted display data only: fixing a rendering crash is in scope, changing what gets displayed as if it were trusted input is not.
+
+## Definition of done
+
+- [ ] `/` (homepage) shows 0 console errors on a fresh load, desktop and mobile, confirmed by a direct check (not just the deferred full sweep).
+- [ ] Every route listed in "Why this matters" above re-checked individually and shows 0 console errors, OR, for any that remain non-zero, the report states the exact remaining error text and why it is out of scope (a known third-party embed, confirmed by checking it is not three.ws's own code).
+- [ ] If a shared root cause was found across the WebGL-heavy pages, it is named in the report with the single commit SHA that fixed it and the before/after error counts for at least 3 of the affected pages.
+- [ ] The full `npm run audit:web` sweep started in Step 0 has completed (or, if it is still running when this order finishes, its process ID and log path are named in the report so it is not silently orphaned); the resulting `reports/page-audit-*.md` was read and any new finding it surfaced beyond this order's partial list is either fixed or explicitly deferred to a new order with its own number.
+- [ ] `npm run check:rules -- --paths <files you touched>` exits 0.
+- [ ] `npm run test:core` was run after the fix and shows no new failures versus its state before this order started (cite both counts; if order 401 is in flight concurrently, diff against whichever baseline is current).
+
+## Never blocked
+
+| Blocker | Resolution (act, do not ask) |
+|---|---|
+| The full sweep in Step 0 is too slow to wait for | Start it in the background per Step 0 and work the homepage and the shared-cause hypothesis first; its report is a confirmation tool, not a gate on starting. |
+| A page's error only reproduces in production, not locally | Check for an env-var or auth difference (`.auth/audit-state.json` session vs none); if it truly needs production data, add the defensive null-check/guard that would prevent the crash under any data shape rather than trying to reproduce the exact production dataset locally. |
+| The shared-cause hypothesis is wrong and each page has a different bug | Fix them individually in error-count order; say in the report that the shared-cause hypothesis did not hold and why. |
+| A fix would require touching on-chain/token metadata trust boundaries | Fix the rendering crash only; do not change what untrusted metadata is allowed to trigger. Note it in the report if the two are entangled. |
+| Another agent is mid-fix on an overlapping file | Check `git log` and `git status` before editing; rebase your understanding, do not fight over the same lines. |
+| Playwright/browser tooling is not installed in this environment | `npx playwright install chromium`; if network-blocked, use the existing `npm run audit:web` script's own browser bootstrap instead of installing a second one. |
+
+## Report format
+
+1. Homepage result first (error count before/after, commit SHA).
+2. Shared-cause finding (yes/no, and the fix if yes) across the WebGL-heavy pages.
+3. Per-route results for the remainder, in the error-count order listed above.
+4. Full-sweep report path and its new findings, fixed or deferred with a reason.
+5. Final `npm run test:core` and `npm run check:rules` confirmation.
+6. One-line judgment calls, if any. No trailing questions.