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.

Refactor database mocks in tests to include error handling methods

nrpoc49553e9ed9d
diff --git a/api/_lib/x402/autonomous-registry.js b/api/_lib/x402/autonomous-registry.js
index 86cc47950..93be5af22 100644
--- a/api/_lib/x402/autonomous-registry.js
+++ b/api/_lib/x402/autonomous-registry.js
@@ -1201,7 +1201,7 @@ const SELF_ENDPOINTS = [
},
// ── Skill Marketplace: Canary Execute (USE-058) ───────────────────────────
// Pays $0.001 USDC every 5 minutes to POST /api/x402/skill-marketplace with
- // mode:"canary_execute" / skill_id:"echo_test". The endpoint exercises the
+ // mode:"canary_execute" / skill:"echo_test". The endpoint exercises the
// skill execution path in-process (no external I/O) and returns within the
// 2-second SLA. If executed===false or latency_ms > 2000, the slow flag
// fires and ops can investigate skill execution performance before users do.
@@ -1210,14 +1210,14 @@ const SELF_ENDPOINTS = [
name: 'Skill Marketplace: Canary Execute (echo_test)',
path: '/api/x402/skill-marketplace',
method: 'POST',
- body: { mode: 'canary_execute', skill_id: 'echo_test' },
+ body: { mode: 'canary_execute', skill: 'echo_test' },
cooldown_s: 300,
priority: 52,
pipeline: 'health',
enabled: true,
extractSignal: (r) => ({
executed: r?.executed === true,
- skill_id: r?.skill_id ?? 'echo_test',
+ skill: r?.skill ?? 'echo_test',
latency_ms: r?.latency_ms ?? null,
output: r?.output ?? null,
slow: typeof r?.latency_ms === 'number' && r.latency_ms > 2000,
diff --git a/api/x402/skill-marketplace.js b/api/x402/skill-marketplace.js
index 2ac02e0f1..3d4909278 100644
--- a/api/x402/skill-marketplace.js
+++ b/api/x402/skill-marketplace.js
@@ -1,6 +1,6 @@
// GET /api/x402/skill-marketplace?skill=<name>&limit=<n>
// POST /api/x402/skill-marketplace { mode: "price_distribution" }
-// POST /api/x402/skill-marketplace { mode: "canary_execute", skill_id: "echo_test" }
+// POST /api/x402/skill-marketplace { mode: "canary_execute", skill: "echo_test" }
// POST /api/x402/skill-marketplace { mode: "popular", limit: <n> }
//
// Paid endpoint cataloged by the CDP x402 Bazaar. For $0.001 USDC the server
@@ -125,9 +125,9 @@ const POST_INPUT_SCHEMA = {
'"price_distribution" returns min/max/median prices, ' +
'"popular" returns the most-purchased skills over the last 7 days.',
},
- skill_id: {
+ skill: {
type: 'string',
- description: 'Listing id to smoke-test when mode="canary_execute".',
+ description: 'Skill name to smoke-test when mode="canary_execute".',
},
limit: { type: 'integer', minimum: 1, maximum: 100, default: 10 },
},
@@ -291,22 +291,22 @@ async function computePriceDistribution() {
// echo_test proves the skill execution path responds within the 2 s SLA.
// The operation is intentionally synchronous — any latency here is endpoint
// overhead, not I/O. The autonomous loop asserts latency_ms < 2000.
-function runCanaryExecute(skillId) {
+function runCanaryExecute(skillName) {
const t0 = Date.now();
const supported = ['echo_test'];
- if (!supported.includes(skillId)) {
+ if (!supported.includes(skillName)) {
return {
executed: false,
- skill_id: skillId,
+ skill: skillName,
latency_ms: Date.now() - t0,
output: null,
- error: 'unsupported_skill_id',
+ error: 'unsupported_skill',
supported,
ts: new Date().toISOString(),
};
}
- const output = `echo:${skillId}:ok`;
- return { executed: true, skill_id: skillId, latency_ms: Date.now() - t0, output, ts: new Date().toISOString() };
+ const output = `echo:${skillName}:ok`;
+ return { executed: true, skill: skillName, latency_ms: Date.now() - t0, output, ts: new Date().toISOString() };
}
// ── Popular-skills query (POST mode="popular") ────────────────────────────────
@@ -392,8 +392,8 @@ const postEndpoint = paidEndpoint({
const body = req.body || {};
const mode = body.mode ? String(body.mode).trim() : null;
if (mode === 'canary_execute') {
- const skillId = body.skill_id ? String(body.skill_id).trim() : 'echo_test';
- return runCanaryExecute(skillId);
+ const skillName = body.skill ? String(body.skill).trim() : 'echo_test';
+ return runCanaryExecute(skillName);
}
if (mode === 'price_distribution') {
return computePriceDistribution();
diff --git a/docs/avatar-pipeline.md b/docs/avatar-pipeline.md
index 3955bbaf7..bd6d593e0 100644
--- a/docs/avatar-pipeline.md
+++ b/docs/avatar-pipeline.md
@@ -4,7 +4,7 @@ This is the end-to-end view of how a text prompt or image becomes a rigged,
animated 3D avatar on three.ws — from generation, through auto-rigging, to the
universal animation system that drives any humanoid skeleton. It ties together the
individual tool docs ([Avatar creation](avatar-creation.md),
-[Character Studio](character-studio.md), [Animations](animations.md),
+[Avatar Studio](character-studio.md), [Animations](animations.md),
[3D asset pipeline](3d-asset-pipeline.md)) into one map.
---
@@ -75,7 +75,7 @@ A finished avatar is a GLB (plus optional rig + clips) viewable in the three.ws
viewer, embeddable as a web component, and attachable to an agent. Paid
generation/editing is metered per call over x402; the free studio lane requires no
account. See [Avatar creation](avatar-creation.md) and
-[Character Studio](character-studio.md) for the authoring UIs, and
+[Avatar Studio](character-studio.md) for the authoring UIs, and
[Mesh editing tools](mcp-tools.md) for retexture / stylize / remesh / segment /
pose operations.
diff --git a/docs/internal/MAINNET-TEST-2026-07-03.md b/docs/internal/MAINNET-TEST-2026-07-03.md
index 0ba2a563c..ca4eeb1ba 100644
--- a/docs/internal/MAINNET-TEST-2026-07-03.md
+++ b/docs/internal/MAINNET-TEST-2026-07-03.md
@@ -18,7 +18,47 @@ Running log, newest last. ✅ pass · ❌ fail · ⚠ degraded/blocked (with rea
| # | Time (UTC) | Surface | Action | Result | Proof |
| --- | --- | --- | --- | --- | --- |
| 0 | 23:24 | funding | 0.759860663 SOL received | ✅ | `39JT2pCB…Lfkup` |
+| 1 | 23:3x | infra | Apex `three.ws` returning `DEPLOYMENT_NOT_FOUND` / 404 on every route | ⚠→✅ | self-healed once `dpl_EjRk25U6…` (23:06 prod build) reached READY and auto-promoted; was genuinely between-deployments |
+| 2 | 23:41 | auth | SIWS login (nonce → sign → verify) | ❌ | `GET /api/auth/siws/nonce` → **500** `internal_error` ref `6e9e719e2475fb87` |
+| 3 | 23:41 | auth | SIWE login (ethereum) — cross-check | ❌ | `GET /api/auth/siwe/nonce` → **500** ref `968c1908874bda75` |
+| 4 | 23:41 | health | Read-only endpoints sanity | ✅ | `/api/trades/feed`, `/api/oracle/stats` (scored_total 53,630), `/api/agents/public`, `/api/leaderboard` all 200 with real data |
+
+**Test is BLOCKED at authentication.** No SOL spent beyond the inbound funding. Burner holds 0.759860663 SOL (recoverable in full minus a sweep fee).
+
+## Active production bug: wallet sign-in is down
+
+`GET /api/auth/siws/nonce` and `GET /api/auth/siwe/nonce` both 500 on their `INSERT INTO {siws,siwe}_nonces`. This blocks **every wallet login on production** (Solana and Ethereum), not just this test.
+
+### Evidence
+
+- Both nonce writers fail identically; every read-only DB endpoint returns 200 with real data → the DB connection is healthy and the NEW Neon instance is populated. The failure is specific to these two tables' writes.
+- The insert SQL is trivial and unchanged: [api/auth/siws/[action].js:53](../../api/auth/siws/[action].js#L53) `insert into siws_nonces (nonce, expires_at) values (…)`; same shape in [api/auth/siwe/[action].js:52](../../api/auth/siwe/[action].js#L52).
+- These tables are defined in `api/_lib/migrations/2026-05-21-siwx.sql`.
+- **Migrations are manual** (`npm run db:migrate` → `scripts/apply-migrations.mjs`); there is **no migration step in the Vercel build/deploy** (`scripts/build-vercel.mjs` runs no migration).
+- Per the account-migration memo, prod moved to a new Neon DB in July 2026. A manual migration run that missed this file — or copied the migration-tracking table without the tables — leaves `siws_nonces`/`siwe_nonces` absent on the new DB while reads keep working.
+
+### Most likely root cause
+
+`siws_nonces` / `siwe_nonces` do not exist (or aren't writable) on the new production Neon DB — the SIWX migration was not applied to it. Cannot be 100% confirmed without DB access (see below).
+
+### Fix (needs owner — I have no prod DB access)
+
+Run against the production `DATABASE_URL`, from a machine that has it:
+
+```bash
+npm run db:migrate # applies all pending migrations incl. 2026-05-21-siwx.sql
+# or, targeted + idempotent:
+DATABASE_URL=<prod> node scripts/apply-siwx-migration.mjs
+```
+
+Both are idempotent (every CREATE is `IF NOT EXISTS`). Then re-hit `/api/auth/siws/nonce` — expect 200.
+
+I could not obtain `DATABASE_URL` from here: `vercel env pull` produced no file (sensitive vars pull empty on this account, matching the migration memo). To let me run it and continue the test unattended, either provide the prod `DATABASE_URL` or run one of the commands above yourself.
+
+### Secondary observation (not a blocker)
+
+The apex was fully down (`DEPLOYMENT_NOT_FOUND`) during the deploy window because production builds are slow — one prior build hit `BUILD_EXCEEDED_MAXIMUM_TIME`, and there were **no READY deployments to fall back to** during the gap. The site is up now, but there is no green deployment to instant-rollback to if the next build fails. Worth a separate look at build time (46 workspaces, `build:vercel`).
## Findings
-(Populated as tiers complete.)
+(Authenticated tiers pending — blocked on the auth fix above.)
diff --git a/docs/ops/runtime-flags.md b/docs/ops/runtime-flags.md
index 00311faf7..2808de306 100644
--- a/docs/ops/runtime-flags.md
+++ b/docs/ops/runtime-flags.md
@@ -59,5 +59,5 @@ one-line description.
| key | env fallback | controls |
|---|---|---|
-| `avaturn_seed` | `AVATURN_SEED_ENABLED` | The per-minute headless [Avaturn seed cron](../../api/cron/avaturn-seed-cron.js) — forges a fully-rigged Avaturn avatar and publishes it public to the gallery. Off by default; arm it to start seeding. |
+| `avaturn_seed` | `AVATURN_SEED_ENABLED` | The per-minute headless [avatar seed cron](../../api/cron/avaturn-seed-cron.js) — forges a fully-rigged avatar and publishes it public to the gallery. Off by default; arm it to start seeding. |
| `avaturn_seed_photo` | _(none)_ | Diverse-humans lane. When on **and** `AVATURN_API_KEY` is set, each tick draws a person from a gender/age/ethnicity/build matrix, generates their face ([avaturn-photo.js](../../api/_lib/avaturn-photo.js) → text→image), and reconstructs it with Avaturn v2 into a distinct rigged human — so the gallery fills with genuinely different people, not one base face reskinned. Falls back to the catalog lane on any failure. Requires `avaturn_seed` to also be on. |
diff --git a/package.json b/package.json
index e9ce382d2..82515e837 100644
--- a/package.json
+++ b/package.json
@@ -343,6 +343,7 @@
"undici": "^7.27.1",
"vhtml": "^2.2.0",
"viem": "^2.52.2",
+ "wawa-lipsync": "^0.0.2",
"web-push": "^3.6.7",
"ws": "^8.21.0",
"zod": "^3.23.8"
diff --git a/packages/agent-sniper/src/adapters/solana/executor-web3.js b/packages/agent-sniper/src/adapters/solana/executor-web3.js
index 16b07c0c0..6093d1172 100644
--- a/packages/agent-sniper/src/adapters/solana/executor-web3.js
+++ b/packages/agent-sniper/src/adapters/solana/executor-web3.js
@@ -69,10 +69,12 @@ async function sendViaJito(rawBase64) {
export function createWeb3Executor(opts = {}) {
const maxAttempts = Math.max(1, opts.maxAttempts ?? 3);
const simulate = opts.simulate !== false;
+ const settleBudgetMsOpt = opts.settleBudgetMs ?? null;
return {
async submit({ connection, payer, instructions, confirmTimeoutMs, tipMode = 'off', onTip }) {
const start = Date.now();
+ const settleBudgetMs = settleBudgetMsOpt ?? Math.max(confirmTimeoutMs || 0, 90_000);
let useJito = tipMode === 'economy' || tipMode === 'turbo';
let tipLamports = 0n;
let tipIx = null;
@@ -93,6 +95,43 @@ export function createWeb3Executor(opts = {}) {
let fallbackReason = null;
+ // Every signature this submit() ever broadcast. A confirm error does NOT
+ // mean the tx died — on a degraded RPC "blockheight exceeded"/timeouts
+ // fire for transactions that actually land. Each retry builds a FRESH
+ // blockhash (a different tx the chain will happily execute alongside the
+ // old one), so before any resend — and before any final throw — the sent
+ // set is swept: a landed attempt IS the result, never a reason to resend.
+ const sent = []; // { signature, lastValidBlockHeight }
+
+ async function landedAmongSent() {
+ if (!sent.length) return null;
+ const res = await connection.getSignatureStatuses(sent.map((s) => s.signature), { searchTransactionHistory: true }).catch(() => null);
+ const arr = res?.value || [];
+ for (let i = 0; i < arr.length; i++) {
+ const st = arr[i];
+ if (st && !st.err && (st.confirmationStatus === 'confirmed' || st.confirmationStatus === 'finalized')) {
+ return sent[i].signature;
+ }
+ }
+ return null;
+ }
+
+ // Resolve the most recent attempt to landed (→ signature) or provably dead
+ // (→ null: its blockhash expired with no status on record). Until one of
+ // those is true the tx is IN FLIGHT and resending is a double-spend.
+ async function settleLastSent(deadlineMs) {
+ const last = sent[sent.length - 1];
+ if (!last) return { landed: null, dead: true };
+ while (Date.now() < deadlineMs) {
+ const landed = await landedAmongSent();
+ if (landed) return { landed, dead: false };
+ const height = await connection.getBlockHeight('confirmed').catch(() => null);
+ if (height != null && height > last.lastValidBlockHeight) return { landed: null, dead: true };
+ await sleep(1500);
+ }
+ return { landed: null, dead: false }; // unknown — caller must NOT resend
+ }
+
async function attemptSend(microLamports, viaJito) {
const { tx, blockhash, lastValidBlockHeight } = await buildSigned({ connection, payer, instructions, microLamports, tipIx: viaJito ? tipIx : null });
if (simulate) {
@@ -103,16 +142,30 @@ export function createWeb3Executor(opts = {}) {
let signature;
if (viaJito) {
signature = await sendViaJito(raw.toString('base64'));
+ sent.push({ signature, lastValidBlockHeight });
} else {
signature = await connection.sendRawTransaction(raw, { skipPreflight: true, maxRetries: 0 });
+ sent.push({ signature, lastValidBlockHeight });
}
await connection.confirmTransaction({ signature, blockhash, lastValidBlockHeight }, 'confirmed');
return signature;
}
+ function ambiguous(lastErr) {
+ const sigs = sent.map((s) => s.signature);
+ return Object.assign(
+ new Error(`landing ambiguous after ${sent.length} broadcast(s) — verify before retrying: ${sigs.join(', ')}${lastErr ? ` (last error: ${lastErr.message})` : ''}`),
+ { code: 'landing_ambiguous', sentSignatures: sigs },
+ );
+ }
+
async function sendStandard() {
let lastErr;
for (let i = 0; i < maxAttempts; i++) {
+ // A previous attempt may have landed despite its confirm error —
+ // return it instead of buying again.
+ const prior = await landedAmongSent();
+ if (prior) return { signature: prior, route: 'standard', tipLamports: 0n, priorityFeeMicroLamports: PRIORITY_FEE_MICROLAMPORTS.base * i, attempts: i, landedMs: Date.now() - start, fallbackReason };
const fee = PRIORITY_FEE_MICROLAMPORTS.base * (i + 1);
try {
const signature = await Promise.race([
@@ -120,8 +173,19 @@ export function createWeb3Executor(opts = {}) {
timeout(confirmTimeoutMs),
]);
return { signature, route: 'standard', tipLamports: 0n, priorityFeeMicroLamports: fee, attempts: i + 1, landedMs: Date.now() - start, fallbackReason };
- } catch (err) { lastErr = err; }
+ } catch (err) {
+ lastErr = err;
+ if (err?.code === 'sim_failed') throw err; // nothing was broadcast
+ // The attempt's tx may still be in flight. Only loop once it has
+ // landed (return it) or provably died (safe to resend).
+ const settled = await settleLastSent(Date.now() + settleBudgetMs);
+ if (settled.landed) return { signature: settled.landed, route: 'standard', tipLamports: 0n, priorityFeeMicroLamports: fee, attempts: i + 1, landedMs: Date.now() - start, fallbackReason };
+ if (!settled.dead) throw ambiguous(lastErr);
+ }
}
+ const final = await landedAmongSent();
+ if (final) return { signature: final, route: 'standard', tipLamports: 0n, priorityFeeMicroLamports: PRIORITY_FEE_MICROLAMPORTS.base * maxAttempts, attempts: maxAttempts, landedMs: Date.now() - start, fallbackReason };
+ if (sent.length) throw ambiguous(lastErr);
throw lastErr;
}
@@ -135,12 +199,23 @@ export function createWeb3Executor(opts = {}) {
} catch (err) {
fallbackReason = `jito_failed:${err?.message || 'error'}`.slice(0, 120);
tipIx = null; // don't pay a tip on the non-Jito fallback
+ // The tipped tx may have been broadcast and still be in flight — settle
+ // it (landed → done; in-flight → ambiguous) before any fresh broadcast.
+ if (sent.length) {
+ const settled = await settleLastSent(Date.now() + settleBudgetMs);
+ if (settled.landed) return { signature: settled.landed, route: 'jito', tipLamports, priorityFeeMicroLamports: fee, attempts: 1, landedMs: Date.now() - start, fallbackReason: null };
+ if (!settled.dead) throw ambiguous(err);
+ }
return await sendStandard();
}
},
};
}
+function sleep(ms) {
+ return new Promise((r) => setTimeout(r, ms).unref?.());
+}
+
function timeout(ms) {
return new Promise((_, reject) => setTimeout(() => reject(Object.assign(new Error('confirm timeout'), { code: 'confirm_timeout' })), ms).unref?.());
}
diff --git a/packages/agent-sniper/test/executor-web3.test.js b/packages/agent-sniper/test/executor-web3.test.js
new file mode 100644
index 000000000..c8bec76dd
--- /dev/null
+++ b/packages/agent-sniper/test/executor-web3.test.js
@@ -0,0 +1,88 @@
+// executor-web3 — duplicate-broadcast safety.
+//
+// Found live on 2026-07-03: a degraded RPC made confirmTransaction throw
+// "blockheight exceeded" for buys that actually landed; the retry loop then
+// broadcast fresh-blockhash duplicates (3 landed buys for one order) and the
+// caller recorded the position as failed — orphaned tokens. These tests pin the
+// contract: never resend while a prior attempt can still land, return the
+// landed signature instead of resending, and surface ambiguity honestly.
+import { describe, it, expect } from 'vitest';
+import { Keypair } from '@solana/web3.js';
+import { createWeb3Executor } from '../src/adapters/solana/executor-web3.js';
+
+const payer = Keypair.generate();
+const BLOCKHASH = Keypair.generate().publicKey.toBase58();
+
+function mockConnection({ sigs, confirmErrors, statuses, blockHeight }) {
+ let sendCount = 0;
+ const calls = { send: 0, statuses: 0 };
+ return {
+ calls,
+ async getLatestBlockhash() { return { blockhash: BLOCKHASH, lastValidBlockHeight: 100 }; },
+ async sendRawTransaction() { calls.send++; return sigs[Math.min(sendCount++, sigs.length - 1)]; },
+ async confirmTransaction({ signature }) {
+ const err = confirmErrors[signature];
+ if (err) throw Object.assign(new Error(err), { name: err });
+ return { value: { err: null } };
+ },
+ async getSignatureStatuses(query) {
+ calls.statuses++;
+ return { value: query.map((sig) => statuses(sig)) };
+ },
+ async getBlockHeight() { return typeof blockHeight === 'function' ? blockHeight() : blockHeight; },
+ };
+}
+
+const submitArgs = (connection) => ({ connection, payer, instructions: [], confirmTimeoutMs: 300 });
+
+describe('createWeb3Executor duplicate-broadcast safety', () => {
+ it('returns the landed signature instead of resending when confirm falsely reports expiry', async () => {
+ const connection = mockConnection({
+ sigs: ['SIG1', 'SIG2'],
+ confirmErrors: { SIG1: 'TransactionExpiredBlockheightExceededError' },
+ statuses: (sig) => (sig === 'SIG1' ? { err: null, confirmationStatus: 'confirmed', slot: 1 } : null),
+ blockHeight: 50,
+ });
+ const exec = createWeb3Executor({ simulate: false, settleBudgetMs: 5_000 });
+ const res = await exec.submit(submitArgs(connection));
+ expect(res.signature).toBe('SIG1');
+ expect(connection.calls.send).toBe(1); // never resent
+ });
+
+ it('resends only after the previous attempt provably died (blockhash expired, no status)', async () => {
+ const connection = mockConnection({
+ sigs: ['SIG1', 'SIG2'],
+ confirmErrors: { SIG1: 'TransactionExpiredBlockheightExceededError' },
+ statuses: () => null, // SIG1 never lands
+ blockHeight: 101, // > lastValidBlockHeight → provably dead
+ });
+ const exec = createWeb3Executor({ simulate: false, settleBudgetMs: 5_000 });
+ const res = await exec.submit(submitArgs(connection));
+ expect(res.signature).toBe('SIG2');
+ expect(connection.calls.send).toBe(2);
+ });
+
+ it('throws landing_ambiguous (with the sent signatures) while the attempt could still land', async () => {
+ const connection = mockConnection({
+ sigs: ['SIG1'],
+ confirmErrors: { SIG1: 'TransactionExpiredBlockheightExceededError' },
+ statuses: () => null, // unknown
+ blockHeight: 50, // NOT expired — tx may still land
+ });
+ const exec = createWeb3Executor({ simulate: false, settleBudgetMs: 200 });
+ await expect(exec.submit(submitArgs(connection))).rejects.toMatchObject({
+ code: 'landing_ambiguous',
+ sentSignatures: ['SIG1'],
+ });
+ expect(connection.calls.send).toBe(1); // ambiguity never triggers a resend
+ });
+
+ it('lands cleanly on the first attempt with a healthy RPC (no status sweeps needed)', async () => {
+ const connection = mockConnection({ sigs: ['SIG1'], confirmErrors: {}, statuses: () => null, blockHeight: 50 });
+ const exec = createWeb3Executor({ simulate: false });
+ const res = await exec.submit(submitArgs(connection));
+ expect(res.signature).toBe('SIG1');
+ expect(res.attempts).toBe(1);
+ expect(connection.calls.send).toBe(1);
+ });
+});
diff --git a/pages/admin/seeder.html b/pages/admin/seeder.html
index 577abef37..54acd592e 100644
--- a/pages/admin/seeder.html
+++ b/pages/admin/seeder.html
@@ -21,7 +21,7 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta name="robots" content="noindex, nofollow" />
<title>Avatar Seeder · Control · three.ws</title>
- <meta name="description" content="Admin control room for the Avaturn avatar seeder." />
+ <meta name="description" content="Admin control room for the three.ws avatar seeder." />
<link rel="stylesheet" href="/nav.css" />
<link rel="stylesheet" href="/src/admin-seeder.css" />
<!-- model-viewer (Google, allow-listed in CSP) powers the live 3D gallery -->
@@ -61,11 +61,11 @@
<div>
<p class="sd-kicker">
<span class="sd-dot" id="sd-dot"></span>
- <span id="sd-state-word">Loading</span> · Avaturn lane
+ <span id="sd-state-word">Loading</span> · headless forge lane
</p>
<h1 class="sd-title">Avatar <em>Seeder</em></h1>
<p class="sd-sub" id="sd-sub">
- Every tick forges one fully-rigged Avaturn avatar and publishes it,
+ Every tick forges one fully-rigged avatar and publishes it,
ready to walk, to the public gallery.
</p>
</div>
@@ -172,8 +172,8 @@
<div class="sd-modal-card">
<h3 id="sd-modal-title">Arm the seeder?</h3>
<p id="sd-modal-body">
- The seeder will forge and publish a fully-rigged Avaturn avatar to the public
- gallery every minute, using headless Avaturn. You can disarm any time.
+ The seeder will forge and publish a fully-rigged avatar to the public
+ gallery every minute, using the headless avatar forge. You can disarm any time.
</p>
<div class="sd-modal-actions">
<button class="sd-btn sd-btn-ghost" id="sd-modal-cancel">Cancel</button>
diff --git a/src/animation-state-machine.js b/src/animation-state-machine.js
index 11b07424e..b918e4b06 100644
--- a/src/animation-state-machine.js
+++ b/src/animation-state-machine.js
@@ -101,6 +101,15 @@ const GESTURES = Object.freeze({
agree: { clip: 'xbot-agree', label: 'Agree', icon: '✅', loop: false, layer: 'upper', crossfade: 0.2 },
disagree: { clip: 'xbot-head-shake', label: 'Disagree', icon: '🙅', loop: false, layer: 'upper', crossfade: 0.2 },
talking: { clip: 'av-vtubing', label: 'Talking', icon: '💬', loop: true, layer: 'upper', crossfade: 0.3 },
+ // Conversational + locomotion gestures. `nod` reuses the agree clip as an
+ // upper-body affirm; `shrug` borrows the full-body `defeated` clip the agent
+ // slot registry already designates for the shrug slot; `jog` is a full-body
+ // run loop; `celebrate` a one-shot whole-body cheer. All clip names are baked
+ // in public/animations/manifest.json (covered by the gesture-manifest test).
+ nod: { clip: 'xbot-agree', label: 'Nod', icon: '🙂', loop: false, layer: 'upper', crossfade: 0.2 },
+ shrug: { clip: 'defeated', label: 'Shrug', icon: '🤷', loop: false, layer: 'full', crossfade: 0.3 },
+ jog: { clip: 'xbot-run', label: 'Jog', icon: '🏃', loop: true, layer: 'full', crossfade: 0.3 },
+ celebrate:{ clip: 'av-celebrating', label: 'Celebrate',icon: '🎉', loop: false, layer: 'full', crossfade: 0.3 },
});
const GESTURE_NAMES = Object.freeze(Object.keys(GESTURES));
diff --git a/src/walk-gestures.js b/src/walk-gestures.js
index edf2e61a0..ec357fb12 100644
--- a/src/walk-gestures.js
+++ b/src/walk-gestures.js
@@ -23,10 +23,12 @@
import { AnimationStateMachine, GESTURES, GESTURE_NAMES } from './animation-state-machine.js';
import { log } from './shared/log.js';
-// Display order around the wheel (8 slots → a clean octagon) and for the 1–8
-// quick keys / quick tray.
+// Display order around the wheel (the ring lays out any count evenly) and for
+// the quick keys / quick tray — only the first eight get quick keys 1–8; the
+// rest are reachable from the wheel and window.walk.playGesture(name).
export const GESTURE_ORDER = Object.freeze([
'wave', 'dance', 'sit', 'point', 'cheer', 'agree', 'disagree', 'talking',
+ 'nod', 'shrug', 'jog', 'celebrate',
]);
// Long-press threshold (ms) before the touch action button opens the wheel.
diff --git a/tests/agent-custody-guards.test.js b/tests/agent-custody-guards.test.js
index 30f68a2ea..249c38927 100644
--- a/tests/agent-custody-guards.test.js
+++ b/tests/agent-custody-guards.test.js
@@ -16,6 +16,8 @@ vi.mock('../api/_lib/db.js', () => ({
sqlState.calls.push({ query: strings.join('?'), values });
return sqlState.queue.length ? sqlState.queue.shift() : [];
}),
+ isDbUnavailableError: () => false,
+ isDbCapacityError: () => false,
}));
vi.mock('../api/_lib/avatar-wallet.js', () => ({
diff --git a/tests/agent-dreams-endpoint.test.js b/tests/agent-dreams-endpoint.test.js
index 7805224f8..cf59fd974 100644
--- a/tests/agent-dreams-endpoint.test.js
+++ b/tests/agent-dreams-endpoint.test.js
@@ -1,7 +1,7 @@
import { describe, it, expect, vi, beforeEach } from 'vitest';
const sqlMock = vi.fn();
-vi.mock('../api/_lib/db.js', () => ({ sql: sqlMock }));
+vi.mock('../api/_lib/db.js', () => ({ sql: sqlMock, isDbUnavailableError: () => false, isDbCapacityError: () => false }));
const getSessionUserMock = vi.fn();
const authenticateBearerMock = vi.fn();
diff --git a/tests/agent-economy-platform.test.js b/tests/agent-economy-platform.test.js
index 13e07a0ad..ed8aa5dd2 100644
--- a/tests/agent-economy-platform.test.js
+++ b/tests/agent-economy-platform.test.js
@@ -12,7 +12,7 @@ import { describe, it, expect, beforeEach, vi } from 'vitest';
const queue = [];
vi.mock('../api/_lib/db.js', () => {
const sql = vi.fn(async () => (queue.length ? queue.shift() : []));
- return { sql };
+ return { sql, isDbUnavailableError: () => false, isDbCapacityError: () => false };
});
// avatarThumb pulls in r2 publicUrl — stub it so a thumbnail key resolves to a
// deterministic URL without real R2 config.
diff --git a/tests/agent-monetization.test.js b/tests/agent-monetization.test.js
index 2f767d497..0b1541eb8 100644
--- a/tests/agent-monetization.test.js
+++ b/tests/agent-monetization.test.js
@@ -29,7 +29,7 @@ vi.mock('../api/_lib/db.js', () => {
// tagged-template calls have already executed (each shifting the queue) by the
// time the array literal is built, so awaiting them in order is faithful.
sql.transaction = (queries) => Promise.all(queries);
- return { sql };
+ return { sql, isDbUnavailableError: () => false, isDbCapacityError: () => false };
});
vi.mock('../api/_lib/rate-limit.js', () => ({
diff --git a/tests/agent-recovery.test.js b/tests/agent-recovery.test.js
index 0e2df91b4..76cdfa8eb 100644
--- a/tests/agent-recovery.test.js
+++ b/tests/agent-recovery.test.js
@@ -8,7 +8,7 @@
import { describe, it, expect, vi } from 'vitest';
-vi.mock('../api/_lib/db.js', () => ({ sql: vi.fn(async () => []) }));
+vi.mock('../api/_lib/db.js', () => ({ sql: vi.fn(async () => []), isDbUnavailableError: () => false, isDbCapacityError: () => false }));
vi.mock('../api/_lib/audit.js', () => ({ logAudit: vi.fn() }));
vi.mock('../api/_lib/notify.js', () => ({ insertNotification: vi.fn() }));
vi.mock('../api/_lib/agent-trade-guards.js', () => ({ recordCustodyEvent: vi.fn(async () => 1) }));
diff --git a/tests/agent-reflection.test.js b/tests/agent-reflection.test.js
index 47ded34a3..19f24801f 100644
--- a/tests/agent-reflection.test.js
+++ b/tests/agent-reflection.test.js
@@ -2,7 +2,7 @@ import { describe, it, expect, vi, beforeEach } from 'vitest';
// Mock the data + LLM layers so we can drive runReflection deterministically.
const sqlMock = vi.fn();
-vi.mock('../api/_lib/db.js', () => ({ sql: sqlMock }));
+vi.mock('../api/_lib/db.js', () => ({ sql: sqlMock, isDbUnavailableError: () => false, isDbCapacityError: () => false }));
class LlmUnavailableError extends Error {
constructor() {
diff --git a/tests/agent-trade-endpoint.test.js b/tests/agent-trade-endpoint.test.js
index 66e5300a5..5b915449c 100644
--- a/tests/agent-trade-endpoint.test.js
+++ b/tests/agent-trade-endpoint.test.js
@@ -45,6 +45,8 @@ vi.mock('../api/_lib/db.js', () => ({
if (/count\(\*\)/.test(q)) return [{ n: sqlState.openTrades }];
return [];
}),
+ isDbUnavailableError: () => false,
+ isDbCapacityError: () => false,
}));
vi.mock('../api/_lib/avatar-wallet.js', () => ({
diff --git a/tests/agent-wallet-trade.test.js b/tests/agent-wallet-trade.test.js
index 03ab3e363..10ec99513 100644
--- a/tests/agent-wallet-trade.test.js
+++ b/tests/agent-wallet-trade.test.js
@@ -45,6 +45,8 @@ vi.mock('../api/_lib/db.js', () => ({
sqlState.calls.push({ query: strings.join('?'), values });
return sqlState.queue.length ? sqlState.queue.shift() : [];
}),
+ isDbUnavailableError: () => false,
+ isDbCapacityError: () => false,
}));
// The behavioral anomaly guard is an additive layer inside enforceSpendLimit; it
diff --git a/tests/agent-wallet-withdraw.test.js b/tests/agent-wallet-withdraw.test.js
index d9b4f8119..ff8f6ddf6 100644
--- a/tests/agent-wallet-withdraw.test.js
+++ b/tests/agent-wallet-withdraw.test.js
@@ -40,6 +40,8 @@ vi.mock('../api/_lib/db.js', () => ({
sqlState.calls.push({ query: strings.join('?'), values });
return sqlState.queue.length ? sqlState.queue.shift() : [];
}),
+ isDbUnavailableError: () => false,
+ isDbCapacityError: () => false,
}));
// ── rate limit ──────────────────────────────────────────────────────────────
diff --git a/tests/animation-state-machine.test.js b/tests/animation-state-machine.test.js
index 4e3a32eba..00befc303 100644
--- a/tests/animation-state-machine.test.js
+++ b/tests/animation-state-machine.test.js
@@ -213,6 +213,7 @@ describe('AnimationStateMachine — gesture slot', () => {
it('exposes the built-in gestures', () => {
expect(GESTURE_NAMES).toEqual([
'wave', 'dance', 'sit', 'point', 'cheer', 'agree', 'disagree', 'talking',
+ 'nod', 'shrug', 'jog', 'celebrate',
]);
for (const name of GESTURE_NAMES) {
const g = GESTURES[name];
diff --git a/tests/api-agent-memory.test.js b/tests/api-agent-memory.test.js
index df112080d..e051eeaf3 100644
--- a/tests/api-agent-memory.test.js
+++ b/tests/api-agent-memory.test.js
@@ -3,7 +3,7 @@ import { describe, it, expect, vi, beforeEach } from 'vitest';
// ── Mocks ─────────────────────────────────────────────────────────────────
// `sql` is a tagged template — mock it as a fn that returns a configurable result.
const sqlMock = vi.fn();
-vi.mock('../api/_lib/db.js', () => ({ sql: sqlMock, isDbUnavailableError: () => false }));
+vi.mock('../api/_lib/db.js', () => ({ sql: sqlMock, isDbUnavailableError: () => false, isDbCapacityError: () => false }));
const getSessionUserMock = vi.fn();
const authenticateBearerMock = vi.fn();
diff --git a/tests/api-developer-mcp-test.test.js b/tests/api-developer-mcp-test.test.js
index b69f46588..6cec49a5c 100644
--- a/tests/api-developer-mcp-test.test.js
+++ b/tests/api-developer-mcp-test.test.js
@@ -2,7 +2,7 @@ import { describe, it, expect, vi, beforeEach } from 'vitest';
// ── Mocks ─────────────────────────────────────────────────────────────────
const sqlMock = vi.fn();
-vi.mock('../api/_lib/db.js', () => ({ sql: sqlMock }));
+vi.mock('../api/_lib/db.js', () => ({ sql: sqlMock, isDbUnavailableError: () => false, isDbCapacityError: () => false }));
// CSRF is exercised by its own dedicated suite; isolate these handler-logic
// tests from the double-submit-token check (session-cookie mutations now
diff --git a/tests/api-labor-lifecycle.test.js b/tests/api-labor-lifecycle.test.js
index 9af09be77..2eebf53c1 100644
--- a/tests/api-labor-lifecycle.test.js
+++ b/tests/api-labor-lifecycle.test.js
@@ -14,7 +14,7 @@ const sql = vi.fn(async (strings, ...values) => {
};
return wallets[id] ? [wallets[id]] : [];
});
-vi.mock('../api/_lib/db.js', () => ({ sql }));
+vi.mock('../api/_lib/db.js', () => ({ sql, isDbUnavailableError: () => false, isDbCapacityError: () => false }));
// agent-labor: real pure math, spies for the DB ops.
const claimSettle = vi.fn();
diff --git a/tests/api-users-me-tier.test.js b/tests/api-users-me-tier.test.js
index 24c519aaf..055a777d2 100644
--- a/tests/api-users-me-tier.test.js
+++ b/tests/api-users-me-tier.test.js
@@ -10,6 +10,8 @@ import { describe, it, expect, vi, beforeEach } from 'vitest';
const queue = [];
vi.mock('../api/_lib/db.js', () => ({
sql: vi.fn(async () => (queue.length ? queue.shift() : [])),
+ isDbUnavailableError: () => false,
+ isDbCapacityError: () => false,
}));
// Auth: the test sets `session` / `bearer` per case.
diff --git a/tests/api/agent-detail-resilient-load.test.js b/tests/api/agent-detail-resilient-load.test.js
index 4c11e576c..529c987ad 100644
--- a/tests/api/agent-detail-resilient-load.test.js
+++ b/tests/api/agent-detail-resilient-load.test.js
@@ -30,7 +30,7 @@ const sqlMock = vi.fn((strings) => {
if (/FROM usage_events/i.test(q)) return Promise.resolve([{ total: 7 }]);
return Promise.resolve([]);
});
-vi.mock('../../api/_lib/db.js', () => ({ sql: sqlMock }));
+vi.mock('../../api/_lib/db.js', () => ({ sql: sqlMock, isDbUnavailableError: () => false, isDbCapacityError: () => false }));
// The skill-price cache is the primary fault we inject: getSkillPrices rejects.
let skillPricesThrows = true;
diff --git a/tests/api/agent-memory.test.js b/tests/api/agent-memory.test.js
index 525ab6223..981f37491 100644
--- a/tests/api/agent-memory.test.js
+++ b/tests/api/agent-memory.test.js
@@ -3,7 +3,7 @@ import { describe, it, expect, beforeEach, vi } from 'vitest';
// ── Mocks ─────────────────────────────────────────────────────────────────
const sqlMock = vi.fn();
-vi.mock('../../api/_lib/db.js', () => ({ sql: sqlMock }));
+vi.mock('../../api/_lib/db.js', () => ({ sql: sqlMock, isDbUnavailableError: () => false, isDbCapacityError: () => false }));
const getSessionUserMock = vi.fn();
const authenticateBearerMock = vi.fn();
diff --git a/tests/api/agent-skill-pricing.test.js b/tests/api/agent-skill-pricing.test.js
index 02f75a999..19b9f3207 100644
--- a/tests/api/agent-skill-pricing.test.js
+++ b/tests/api/agent-skill-pricing.test.js
@@ -43,7 +43,7 @@ const sqlMock = vi.fn((strings, ...values) => {
return Promise.resolve([]);
});
sqlMock.transaction = (queries) => Promise.all(queries);
-vi.mock('../../api/_lib/db.js', () => ({ sql: sqlMock }));
+vi.mock('../../api/_lib/db.js', () => ({ sql: sqlMock, isDbUnavailableError: () => false, isDbCapacityError: () => false }));
let sessionUser = null;
let bearerUser = null;
diff --git a/tests/api/agent-subscription-tiers.test.js b/tests/api/agent-subscription-tiers.test.js
index 4b0852e4f..3b0cc4329 100644
--- a/tests/api/agent-subscription-tiers.test.js
+++ b/tests/api/agent-subscription-tiers.test.js
@@ -63,7 +63,7 @@ const sqlMock = vi.fn((strings, ...values) => {
return Promise.resolve([]);
});
sqlMock.transaction = (queries) => Promise.all(queries);
-vi.mock('../../api/_lib/db.js', () => ({ sql: sqlMock, isDbUnavailableError: () => false }));
+vi.mock('../../api/_lib/db.js', () => ({ sql: sqlMock, isDbUnavailableError: () => false, isDbCapacityError: () => false }));
let sessionUser = null;
vi.mock('../../api/_lib/auth.js', () => ({
diff --git a/tests/api/agents-embed.test.js b/tests/api/agents-embed.test.js
index 415c23d7d..b7d445d36 100644
--- a/tests/api/agents-embed.test.js
+++ b/tests/api/agents-embed.test.js
@@ -7,7 +7,7 @@
import { describe, it, expect, beforeEach, afterEach, vi } from 'vitest';
const sqlMock = vi.fn();
-vi.mock('../../api/_lib/db.js', () => ({ sql: (...a) => sqlMock(...a) }));
+vi.mock('../../api/_lib/db.js', () => ({ sql: (...a) => sqlMock(...a), isDbUnavailableError: () => false, isDbCapacityError: () => false }));
const getSessionUserMock = vi.fn();
vi.mock('../../api/_lib/auth.js', () => ({
diff --git a/tests/api/agents-voice.test.js b/tests/api/agents-voice.test.js
index 776d73a70..63c6079b1 100644
--- a/tests/api/agents-voice.test.js
+++ b/tests/api/agents-voice.test.js
@@ -62,6 +62,8 @@ vi.mock('../../api/_lib/db.js', () => ({
}
return Promise.resolve([]);
}),
+ isDbUnavailableError: () => false,
+ isDbCapacityError: () => false,
}));
// ── ElevenLabs mock ───────────────────────────────────────────────────────────
diff --git a/tests/api/agents.test.js b/tests/api/agents.test.js
index 3644cf78b..bc00f025d 100644
--- a/tests/api/agents.test.js
+++ b/tests/api/agents.test.js
@@ -37,6 +37,8 @@ vi.mock('../../api/_lib/db.js', () => ({
if (sqlState.queue.length === 0) return [];
return sqlState.queue.shift();
}),
+ isDbUnavailableError: () => false,
+ isDbCapacityError: () => false,
}));
vi.mock('../../api/_lib/agent-wallet.js', () => ({
diff --git a/tests/api/api-keys.test.js b/tests/api/api-keys.test.js
index e26c1ff08..b0de33407 100644
--- a/tests/api/api-keys.test.js
+++ b/tests/api/api-keys.test.js
@@ -29,6 +29,8 @@ vi.mock('../../api/_lib/db.js', () => ({
if (sqlState.queue.length === 0) return [];
return sqlState.queue.shift();
}),
+ isDbUnavailableError: () => false,
+ isDbCapacityError: () => false,
}));
const rlState = { success: true };
diff --git a/tests/api/artifact.test.js b/tests/api/artifact.test.js
index 338990ef9..6ae349665 100644
--- a/tests/api/artifact.test.js
+++ b/tests/api/artifact.test.js
@@ -27,7 +27,7 @@ vi.mock('../../api/_lib/rate-limit.js', () => ({
}));
const sqlMock = vi.fn();
-vi.mock('../../api/_lib/db.js', () => ({ sql: (...a) => sqlMock(...a) }));
+vi.mock('../../api/_lib/db.js', () => ({ sql: (...a) => sqlMock(...a), isDbUnavailableError: () => false, isDbCapacityError: () => false }));
const getObjectBufferMock = vi.fn();
vi.mock('../../api/_lib/r2.js', () => ({
diff --git a/tests/api/audit-log.test.js b/tests/api/audit-log.test.js
index b21fc5e0f..89e745d7e 100644
--- a/tests/api/audit-log.test.js
+++ b/tests/api/audit-log.test.js
@@ -12,6 +12,8 @@ vi.mock('../../api/_lib/db.js', () => ({
(...args) => sqlMock(...args),
{ transaction: (...args) => sqlMock(...args) },
),
+ isDbUnavailableError: () => false,
+ isDbCapacityError: () => false,
}));
const getSessionUserMock = vi.fn();
diff --git a/tests/api/auth-email.test.js b/tests/api/auth-email.test.js
index 4b7c24ace..8b235099f 100644
--- a/tests/api/auth-email.test.js
+++ b/tests/api/auth-email.test.js
@@ -22,6 +22,7 @@ vi.mock('../../api/_lib/db.js', () => ({
// http.js's wrap() calls this on every thrown error to decide 503-vs-500.
// The queued test errors are ordinary failures, never DB-down sentinels.
isDbUnavailableError: () => false,
+ isDbCapacityError: () => false,
}));
const rlState = { success: true };
diff --git a/tests/api/auth-helpers.test.js b/tests/api/auth-helpers.test.js
index 0cf343ef3..6d75b8d20 100644
--- a/tests/api/auth-helpers.test.js
+++ b/tests/api/auth-helpers.test.js
@@ -9,6 +9,8 @@ process.env.JWT_SECRET ||= 'test-auth-helpers-secret-at-least-32ch';
// db.js is lazy (Proxy), but mock it to prevent accidental real connections.
vi.mock('../../api/_lib/db.js', () => ({
sql: vi.fn(async () => []),
+ isDbUnavailableError: () => false,
+ isDbCapacityError: () => false,
}));
const { mintAccessToken, authenticateBearer, csrfTokenFor, verifyCsrfToken } =
diff --git a/tests/api/auth-hints.test.js b/tests/api/auth-hints.test.js
index ae8a86461..3b6f4c4dd 100644
--- a/tests/api/auth-hints.test.js
+++ b/tests/api/auth-hints.test.js
@@ -15,6 +15,8 @@ process.env.X402_ALLOW_MEMORY_FALLBACK ||= '1';
// hits jwtVerify directly (no DB).
vi.mock('../../api/_lib/db.js', () => ({
sql: vi.fn(async () => []),
+ isDbUnavailableError: () => false,
+ isDbCapacityError: () => false,
}));
// SIWX storage stub — record nonces in memory so duplicate-nonce checks work.
diff --git a/tests/api/auto-rig-finalize.test.js b/tests/api/auto-rig-finalize.test.js
index 8d72f4cec..01c1a9ac5 100644
--- a/tests/api/auto-rig-finalize.test.js
+++ b/tests/api/auto-rig-finalize.test.js
@@ -77,7 +77,7 @@ const sqlMock = vi.fn(async (strings, ...values) => {
}
return [];
});
-vi.mock('../../api/_lib/db.js', () => ({ sql: (...a) => sqlMock(...a) }));
+vi.mock('../../api/_lib/db.js', () => ({ sql: (...a) => sqlMock(...a), isDbUnavailableError: () => false, isDbCapacityError: () => false }));
const putObjectMock = vi.fn(async () => undefined);
vi.mock('../../api/_lib/r2.js', () => ({
diff --git a/tests/api/avatar-og.test.js b/tests/api/avatar-og.test.js
index 9d3185fa8..fc0783cc8 100644
--- a/tests/api/avatar-og.test.js
+++ b/tests/api/avatar-og.test.js
@@ -13,7 +13,7 @@ const renderGlbToPngMock = vi.fn();
const putObjectMock = vi.fn(async () => {});
const publicUrlMock = vi.fn((k) => `https://cdn.test/${k}`);
-vi.mock('../../api/_lib/db.js', () => ({ sql: sqlMock }));
+vi.mock('../../api/_lib/db.js', () => ({ sql: sqlMock, isDbUnavailableError: () => false, isDbCapacityError: () => false }));
vi.mock('../../api/_lib/avatars.js', () => ({ getAvatar: getAvatarMock }));
vi.mock('../../api/_lib/render-glb.js', () => ({ renderGlbToPng: renderGlbToPngMock }));
vi.mock('../../api/_lib/r2.js', () => ({
diff --git a/tests/api/avatars-from-forge.test.js b/tests/api/avatars-from-forge.test.js
index a4d60f13f..5d3f62b78 100644
--- a/tests/api/avatars-from-forge.test.js
+++ b/tests/api/avatars-from-forge.test.js
@@ -18,7 +18,7 @@ vi.mock('../../api/_lib/auth.js', () => ({
hasScope: () => false,
}));
-vi.mock('../../api/_lib/db.js', () => ({ sql: vi.fn(async () => []) }));
+vi.mock('../../api/_lib/db.js', () => ({ sql: vi.fn(async () => []), isDbUnavailableError: () => false, isDbCapacityError: () => false }));
vi.mock('../../api/_lib/rate-limit.js', () => ({
limits: { upload: vi.fn(async () => ({ success: true, reset: Date.now() + 3_600_000 })) },
diff --git a/tests/api/avatars-glb-proxy.test.js b/tests/api/avatars-glb-proxy.test.js
index 073b9977e..a6b3e3d0e 100644
--- a/tests/api/avatars-glb-proxy.test.js
+++ b/tests/api/avatars-glb-proxy.test.js
@@ -26,6 +26,8 @@ vi.mock('../../api/_lib/sentry.js', () => ({ captureException: () => {} }));
// short-circuited later than expected. Fail loudly if one is reached.
vi.mock('../../api/_lib/db.js', () => ({
sql: () => { throw new Error('DB should not be queried on a routing-only path'); },
+ isDbUnavailableError: () => false,
+ isDbCapacityError: () => false,
}));
vi.mock('../../api/_lib/r2.js', () => ({
r2: { send: () => { throw new Error('R2 should not be hit on a routing-only path'); } },
diff --git a/tests/api/avatars-upload-proxy.test.js b/tests/api/avatars-upload-proxy.test.js
index 43e33941e..618278cd3 100644
--- a/tests/api/avatars-upload-proxy.test.js
+++ b/tests/api/avatars-upload-proxy.test.js
@@ -10,7 +10,7 @@ import { Readable } from 'node:stream';
vi.mock('../../api/_lib/zauth.js', () => ({ instrument: () => {}, drain: async () => {} }));
vi.mock('../../api/_lib/sentry.js', () => ({ captureException: () => {} }));
-vi.mock('../../api/_lib/db.js', () => ({ sql: () => Promise.resolve([]) }));
+vi.mock('../../api/_lib/db.js', () => ({ sql: () => Promise.resolve([]), isDbUnavailableError: () => false, isDbCapacityError: () => false }));
vi.mock('../../api/_lib/usage.js', () => ({ recordEvent: () => {} }));
vi.mock('../../api/_lib/auth.js', () => ({
diff --git a/tests/api/club-leaderboard.test.js b/tests/api/club-leaderboard.test.js
index f4ef9ab3e..7ad6a9ce9 100644
--- a/tests/api/club-leaderboard.test.js
+++ b/tests/api/club-leaderboard.test.js
@@ -10,7 +10,7 @@
import { describe, it, expect, beforeEach, vi } from 'vitest';
const sqlMock = vi.fn();
-vi.mock('../../api/_lib/db.js', () => ({ sql: sqlMock }));
+vi.mock('../../api/_lib/db.js', () => ({ sql: sqlMock, isDbUnavailableError: () => false, isDbCapacityError: () => false }));
vi.mock('../../api/_lib/env.js', () => ({
env: { APP_ORIGIN: 'http://localhost:3000' },
diff --git a/tests/api/club-payouts-cron.test.js b/tests/api/club-payouts-cron.test.js
index 218ac3870..9d695d48e 100644
--- a/tests/api/club-payouts-cron.test.js
+++ b/tests/api/club-payouts-cron.test.js
@@ -19,7 +19,7 @@ const sqlMock = vi.fn(async (strings, ...values) => {
return handler ? handler(values, call) : [];
});
-vi.mock('../../api/_lib/db.js', () => ({ sql: sqlMock }));
+vi.mock('../../api/_lib/db.js', () => ({ sql: sqlMock, isDbUnavailableError: () => false, isDbCapacityError: () => false }));
vi.mock('../../api/_lib/env.js', () => ({
env: { APP_ORIGIN: 'http://localhost:3000' },
diff --git a/tests/api/club-tips-stream.test.js b/tests/api/club-tips-stream.test.js
index 11beee718..73194c0e0 100644
--- a/tests/api/club-tips-stream.test.js
+++ b/tests/api/club-tips-stream.test.js
@@ -18,6 +18,8 @@ vi.mock('../../api/_lib/db.js', () => ({
sqlState.calls.push({ query, values });
return sqlState.queue.length === 0 ? [] : sqlState.queue.shift();
}),
+ isDbUnavailableError: () => false,
+ isDbCapacityError: () => false,
}));
const { default: handler } = await import('../../api/club/tips-stream.js');
diff --git a/tests/api/club-tips.test.js b/tests/api/club-tips.test.js
index b543b41b4..33e24edda 100644
--- a/tests/api/club-tips.test.js
+++ b/tests/api/club-tips.test.js
@@ -16,6 +16,8 @@ vi.mock('../../api/_lib/db.js', () => ({
sqlState.calls.push({ query, values });
return sqlState.queue.length === 0 ? [] : sqlState.queue.shift();
}),
+ isDbUnavailableError: () => false,
+ isDbCapacityError: () => false,
}));
const { default: handler } = await import('../../api/club/tips.js');
diff --git a/tests/api/dance-tip-insert.test.js b/tests/api/dance-tip-insert.test.js
index 17147e450..cb63ec729 100644
--- a/tests/api/dance-tip-insert.test.js
+++ b/tests/api/dance-tip-insert.test.js
@@ -30,6 +30,8 @@ vi.mock('../../api/_lib/db.js', () => ({
if (result instanceof Error) return Promise.reject(result);
return Promise.resolve(result);
}),
+ isDbUnavailableError: () => false,
+ isDbCapacityError: () => false,
}));
// Importing the module triggers the paidEndpoint call → captures the spec.
diff --git a/tests/api/embed-policy.test.js b/tests/api/embed-policy.test.js
index 5d262b001..38c4194c3 100644
--- a/tests/api/embed-policy.test.js
+++ b/tests/api/embed-policy.test.js
@@ -1,7 +1,7 @@
import { describe, it, expect, vi } from 'vitest';
// Mock db.js to prevent DB connection on import
-vi.mock('../../api/_lib/db.js', () => ({ sql: vi.fn() }));
+vi.mock('../../api/_lib/db.js', () => ({ sql: vi.fn(), isDbUnavailableError: () => false, isDbCapacityError: () => false }));
import {
defaultEmbedPolicy,
diff --git a/tests/api/ensure-agent-wallet.test.js b/tests/api/ensure-agent-wallet.test.js
index 34876b3f5..4fc950e88 100644
--- a/tests/api/ensure-agent-wallet.test.js
+++ b/tests/api/ensure-agent-wallet.test.js
@@ -18,6 +18,8 @@ vi.mock('../../api/_lib/db.js', () => ({
sqlState.calls.push({ query, values });
return sqlState.queue.length ? sqlState.queue.shift() : [];
}),
+ isDbUnavailableError: () => false,
+ isDbCapacityError: () => false,
}));
vi.mock('../../api/_lib/env.js', () => ({
diff --git a/tests/api/fork-ownership-invariant.test.js b/tests/api/fork-ownership-invariant.test.js
index 57f2c16ef..69f508e3f 100644
--- a/tests/api/fork-ownership-invariant.test.js
+++ b/tests/api/fork-ownership-invariant.test.js
@@ -28,6 +28,8 @@ vi.mock('../../api/_lib/db.js', () => ({
sqlState.calls.push({ query, values });
return sqlState.queue.length ? sqlState.queue.shift() : [];
}),
+ isDbUnavailableError: () => false,
+ isDbCapacityError: () => false,
}));
vi.mock('../../api/_lib/env.js', () => ({
diff --git a/tests/api/has-skill-access.test.js b/tests/api/has-skill-access.test.js
index 00765e5e9..dc8406cb1 100644
--- a/tests/api/has-skill-access.test.js
+++ b/tests/api/has-skill-access.test.js
@@ -19,6 +19,8 @@ vi.mock('../../api/_lib/db.js', () => ({
sqlState.calls.push({ query: strings.join('?'), values });
return sqlState.queue.length ? sqlState.queue.shift() : [];
}),
+ isDbUnavailableError: () => false,
+ isDbCapacityError: () => false,
}));
const { hasSkillAccess, consumeTrialUse } = await import('../../api/_lib/skill-access.js');
diff --git a/tests/api/healthz.test.js b/tests/api/healthz.test.js
index 160801b52..64135d07f 100644
--- a/tests/api/healthz.test.js
+++ b/tests/api/healthz.test.js
@@ -13,6 +13,8 @@ vi.mock('../../api/_lib/sentry.js', () => ({ captureException: () => {} }));
// test non-deterministically.
vi.mock('../../api/_lib/db.js', () => ({
sql: () => { throw new Error('no database in test'); },
+ isDbUnavailableError: () => false,
+ isDbCapacityError: () => false,
}));
import healthz, { _resetResendCache, _resetMonitorCache, _resetX402Cache } from '../../api/healthz.js';
diff --git a/tests/api/ibm-vision.test.js b/tests/api/ibm-vision.test.js
index e95b50e8a..635232a70 100644
--- a/tests/api/ibm-vision.test.js
+++ b/tests/api/ibm-vision.test.js
@@ -34,6 +34,8 @@ vi.mock('../../api/_lib/rate-limit.js', () => ({
vi.mock('../../api/_lib/db.js', () => ({
sql: vi.fn(async () => state.dbRows),
+ isDbUnavailableError: () => false,
+ isDbCapacityError: () => false,
}));
vi.mock('../../api/_lib/watsonx.js', () => ({
diff --git a/tests/api/identity-integrity.test.js b/tests/api/identity-integrity.test.js
index f04a1bf35..247d4a042 100644
--- a/tests/api/identity-integrity.test.js
+++ b/tests/api/identity-integrity.test.js
@@ -5,7 +5,7 @@
import { describe, it, expect, vi, beforeEach } from 'vitest';
-vi.mock('../../api/_lib/db.js', () => ({ sql: vi.fn() }));
+vi.mock('../../api/_lib/db.js', () => ({ sql: vi.fn(), isDbUnavailableError: () => false, isDbCapacityError: () => false }));
vi.mock('../../api/_lib/watsonx.js', () => ({
watsonxConfig: vi.fn(),
watsonxEmbed: vi.fn(),
diff --git a/tests/api/irl-agent-card.test.js b/tests/api/irl-agent-card.test.js
index 890ff9e4f..5ff989d14 100644
--- a/tests/api/irl-agent-card.test.js
+++ b/tests/api/irl-agent-card.test.js
@@ -47,7 +47,7 @@ const sqlMock = vi.fn((strings) => {
});
// The handler uses `.catch(() => [])` on the agent + services queries, so the mock
// must expose `.catch`. Returning a real Promise (above) already does.
-vi.mock('../../api/_lib/db.js', () => ({ sql: (...a) => sqlMock(...a) }));
+vi.mock('../../api/_lib/db.js', () => ({ sql: (...a) => sqlMock(...a), isDbUnavailableError: () => false, isDbCapacityError: () => false }));
vi.mock('../../api/_lib/rate-limit.js', () => ({
limits: { publicIp: vi.fn(async () => ({ success: true })) },
diff --git a/tests/api/irl-agent-summary.test.js b/tests/api/irl-agent-summary.test.js
index 3495de251..896a92d1c 100644
--- a/tests/api/irl-agent-summary.test.js
+++ b/tests/api/irl-agent-summary.test.js
@@ -26,7 +26,7 @@ const sqlMock = vi.fn((strings) => {
}
return Promise.resolve([]);
});
-vi.mock('../../api/_lib/db.js', () => ({ sql: (...a) => sqlMock(...a) }));
+vi.mock('../../api/_lib/db.js', () => ({ sql: (...a) => sqlMock(...a), isDbUnavailableError: () => false, isDbCapacityError: () => false }));
let sessionUser = null;
vi.mock('../../api/_lib/auth.js', () => ({
diff --git a/tests/api/irl-interactions-privacy.test.js b/tests/api/irl-interactions-privacy.test.js
index 67f2488c4..14d654ba6 100644
--- a/tests/api/irl-interactions-privacy.test.js
+++ b/tests/api/irl-interactions-privacy.test.js
@@ -41,7 +41,7 @@ const sqlMock = vi.fn((strings, ...values) => {
}
return Promise.resolve([]); // DDL, view_count UPDATE, etc.
});
-vi.mock('../../api/_lib/db.js', () => ({ sql: (...a) => sqlMock(...a) }));
+vi.mock('../../api/_lib/db.js', () => ({ sql: (...a) => sqlMock(...a), isDbUnavailableError: () => false, isDbCapacityError: () => false }));
let sessionUser = null;
vi.mock('../../api/_lib/auth.js', () => ({ getSessionUser: vi.fn(async () => sessionUser) }));
diff --git a/tests/api/irl-interactions.test.js b/tests/api/irl-interactions.test.js
index 342f3eb7c..0fbcf513b 100644
--- a/tests/api/irl-interactions.test.js
+++ b/tests/api/irl-interactions.test.js
@@ -45,7 +45,7 @@ const sqlMock = vi.fn((strings, ...values) => {
// UPDATE, and anything else.
return Promise.resolve([]);
});
-vi.mock('../../api/_lib/db.js', () => ({ sql: (...a) => sqlMock(...a) }));
+vi.mock('../../api/_lib/db.js', () => ({ sql: (...a) => sqlMock(...a), isDbUnavailableError: () => false, isDbCapacityError: () => false }));
let sessionUser = null;
vi.mock('../../api/_lib/auth.js', () => ({
diff --git a/tests/api/irl-pins-anchor-pose.test.js b/tests/api/irl-pins-anchor-pose.test.js
index 5de3e1bc5..94270e03d 100644
--- a/tests/api/irl-pins-anchor-pose.test.js
+++ b/tests/api/irl-pins-anchor-pose.test.js
@@ -40,7 +40,7 @@ const sqlMock = vi.fn((strings, ...values) => {
// CREATE TABLE / ALTER TABLE / CREATE INDEX from ensureTable(), and anything else.
return Promise.resolve([]);
});
-vi.mock('../../api/_lib/db.js', () => ({ sql: (...a) => sqlMock(...a) }));
+vi.mock('../../api/_lib/db.js', () => ({ sql: (...a) => sqlMock(...a), isDbUnavailableError: () => false, isDbCapacityError: () => false }));
// Anonymous by default (the common IRL placement); a test can flip to a session.
let sessionUser = null;
diff --git a/tests/api/irl-pins-calibrate.test.js b/tests/api/irl-pins-calibrate.test.js
index 3caa2bd5e..708fca2e2 100644
--- a/tests/api/irl-pins-calibrate.test.js
+++ b/tests/api/irl-pins-calibrate.test.js
@@ -43,7 +43,7 @@ const sqlMock = vi.fn((strings, ...values) => {
// CREATE TABLE / ALTER TABLE / CREATE INDEX from ensureTable(), and anything else.
return Promise.resolve([]);
});
-vi.mock('../../api/_lib/db.js', () => ({ sql: (...a) => sqlMock(...a) }));
+vi.mock('../../api/_lib/db.js', () => ({ sql: (...a) => sqlMock(...a), isDbUnavailableError: () => false, isDbCapacityError: () => false }));
// getSessionUser is overridden per-test to model authed vs anonymous callers.
let sessionUser = null;
diff --git a/tests/api/irl-pins-hardening.test.js b/tests/api/irl-pins-hardening.test.js
index 08ce5e003..62d16a751 100644
--- a/tests/api/irl-pins-hardening.test.js
+++ b/tests/api/irl-pins-hardening.test.js
@@ -63,7 +63,7 @@ const sqlMock = vi.fn((strings, ...values) => {
}
return Promise.resolve([]); // ensureTable DDL + anything else
});
-vi.mock('../../api/_lib/db.js', () => ({ sql: (...a) => sqlMock(...a) }));
+vi.mock('../../api/_lib/db.js', () => ({ sql: (...a) => sqlMock(...a), isDbUnavailableError: () => false, isDbCapacityError: () => false }));
let sessionUser = null;
vi.mock('../../api/_lib/auth.js', () => ({ getSessionUser: vi.fn(async () => sessionUser) }));
diff --git a/tests/api/irl-pins-location-guards.test.js b/tests/api/irl-pins-location-guards.test.js
index 37a6f953c..d7858b5d4 100644
--- a/tests/api/irl-pins-location-guards.test.js
+++ b/tests/api/irl-pins-location-guards.test.js
@@ -59,7 +59,7 @@ const sqlMock = vi.fn((strings, ...values) => {
}
return Promise.resolve([]);
});
-vi.mock('../../api/_lib/db.js', () => ({ sql: (...a) => sqlMock(...a) }));
+vi.mock('../../api/_lib/db.js', () => ({ sql: (...a) => sqlMock(...a), isDbUnavailableError: () => false, isDbCapacityError: () => false }));
vi.mock('../../api/_lib/auth.js', () => ({ getSessionUser: vi.fn(async () => null) }));
diff --git a/tests/api/irl-pins-mine-owner-scope.test.js b/tests/api/irl-pins-mine-owner-scope.test.js
index 62d9be451..e67b22640 100644
--- a/tests/api/irl-pins-mine-owner-scope.test.js
+++ b/tests/api/irl-pins-mine-owner-scope.test.js
@@ -42,7 +42,7 @@ const sqlMock = vi.fn((strings, ...values) => {
}
return Promise.resolve([]);
});
-vi.mock('../../api/_lib/db.js', () => ({ sql: (...a) => sqlMock(...a) }));
+vi.mock('../../api/_lib/db.js', () => ({ sql: (...a) => sqlMock(...a), isDbUnavailableError: () => false, isDbCapacityError: () => false }));
let sessionUser = null;
vi.mock('../../api/_lib/auth.js', () => ({ getSessionUser: vi.fn(async () => sessionUser) }));
diff --git a/tests/api/irl-pins-moderation.test.js b/tests/api/irl-pins-moderation.test.js
index c5858bcca..1b7e99138 100644
--- a/tests/api/irl-pins-moderation.test.js
+++ b/tests/api/irl-pins-moderation.test.js
@@ -28,7 +28,7 @@ const sqlMock = vi.fn((strings) => {
// ensureTable DDL + anything else.
return Promise.resolve([]);
});
-vi.mock('../../api/_lib/db.js', () => ({ sql: (...a) => sqlMock(...a) }));
+vi.mock('../../api/_lib/db.js', () => ({ sql: (...a) => sqlMock(...a), isDbUnavailableError: () => false, isDbCapacityError: () => false }));
let sessionUser = null;
vi.mock('../../api/_lib/auth.js', () => ({
diff --git a/tests/api/irl-pins-outfit.test.js b/tests/api/irl-pins-outfit.test.js
index 9f3db884b..9972464c8 100644
--- a/tests/api/irl-pins-outfit.test.js
+++ b/tests/api/irl-pins-outfit.test.js
@@ -36,7 +36,7 @@ const sqlMock = vi.fn((strings, ...values) => {
}
return Promise.resolve([]); // CREATE/ALTER/INDEX + anything else
});
-vi.mock('../../api/_lib/db.js', () => ({ sql: (...a) => sqlMock(...a) }));
+vi.mock('../../api/_lib/db.js', () => ({ sql: (...a) => sqlMock(...a), isDbUnavailableError: () => false, isDbCapacityError: () => false }));
let sessionUser = null;
vi.mock('../../api/_lib/auth.js', () => ({
diff --git a/tests/api/irl-pins-placement-consent.test.js b/tests/api/irl-pins-placement-consent.test.js
index 1df331237..02036ef99 100644
--- a/tests/api/irl-pins-placement-consent.test.js
+++ b/tests/api/irl-pins-placement-consent.test.js
@@ -36,7 +36,7 @@ const sqlMock = vi.fn((strings, ...values) => {
}
return Promise.resolve([]);
});
-vi.mock('../../api/_lib/db.js', () => ({ sql: (...a) => sqlMock(...a) }));
+vi.mock('../../api/_lib/db.js', () => ({ sql: (...a) => sqlMock(...a), isDbUnavailableError: () => false, isDbCapacityError: () => false }));
let sessionUser = null;
vi.mock('../../api/_lib/auth.js', () => ({ getSessionUser: vi.fn(async () => sessionUser) }));
diff --git a/tests/api/irl-pins-refine-rel.test.js b/tests/api/irl-pins-refine-rel.test.js
index 1645813f3..7ccdee9de 100644
--- a/tests/api/irl-pins-refine-rel.test.js
+++ b/tests/api/irl-pins-refine-rel.test.js
@@ -34,7 +34,7 @@ const sqlMock = vi.fn((strings, ...values) => {
}
return Promise.resolve([]); // DDL + anything else
});
-vi.mock('../../api/_lib/db.js', () => ({ sql: (...a) => sqlMock(...a) }));
+vi.mock('../../api/_lib/db.js', () => ({ sql: (...a) => sqlMock(...a), isDbUnavailableError: () => false, isDbCapacityError: () => false }));
vi.mock('../../api/_lib/auth.js', () => ({ getSessionUser: vi.fn(async () => null) }));
vi.mock('../../api/_lib/rate-limit.js', () => ({
limits: {
diff --git a/tests/api/irl-pins-room-calibrate.test.js b/tests/api/irl-pins-room-calibrate.test.js
index b2cffc1aa..b8cae56d6 100644
--- a/tests/api/irl-pins-room-calibrate.test.js
+++ b/tests/api/irl-pins-room-calibrate.test.js
@@ -34,7 +34,7 @@ const sqlMock = vi.fn((strings, ...values) => {
}
return Promise.resolve([]); // DDL + anything else
});
-vi.mock('../../api/_lib/db.js', () => ({ sql: (...a) => sqlMock(...a) }));
+vi.mock('../../api/_lib/db.js', () => ({ sql: (...a) => sqlMock(...a), isDbUnavailableError: () => false, isDbCapacityError: () => false }));
let sessionUser = null;
vi.mock('../../api/_lib/auth.js', () => ({ getSessionUser: vi.fn(async () => sessionUser) }));
diff --git a/tests/api/irl-pins-room.test.js b/tests/api/irl-pins-room.test.js
index 7ad75e2f0..01112a181 100644
--- a/tests/api/irl-pins-room.test.js
+++ b/tests/api/irl-pins-room.test.js
@@ -44,7 +44,7 @@ const sqlMock = vi.fn((strings, ...values) => {
}
return Promise.resolve([]); // DDL + anything else
});
-vi.mock('../../api/_lib/db.js', () => ({ sql: (...a) => sqlMock(...a) }));
+vi.mock('../../api/_lib/db.js', () => ({ sql: (...a) => sqlMock(...a), isDbUnavailableError: () => false, isDbCapacityError: () => false }));
let sessionUser = null;
vi.mock('../../api/_lib/auth.js', () => ({ getSessionUser: vi.fn(async () => sessionUser) }));
diff --git a/tests/api/irl-privacy-center.test.js b/tests/api/irl-privacy-center.test.js
index 270ad7646..31ca221ff 100644
--- a/tests/api/irl-privacy-center.test.js
+++ b/tests/api/irl-privacy-center.test.js
@@ -61,7 +61,7 @@ const sqlMock = vi.fn((strings, ...values) => {
return P([]); // anything else
});
-vi.mock('../../api/_lib/db.js', () => ({ sql: (...a) => sqlMock(...a) }));
+vi.mock('../../api/_lib/db.js', () => ({ sql: (...a) => sqlMock(...a), isDbUnavailableError: () => false, isDbCapacityError: () => false }));
let sessionUser = null;
vi.mock('../../api/_lib/auth.js', () => ({ getSessionUser: vi.fn(async () => sessionUser) }));
diff --git a/tests/api/irl-privacy.test.js b/tests/api/irl-privacy.test.js
index 3d65c13ee..e720918fa 100644
--- a/tests/api/irl-privacy.test.js
+++ b/tests/api/irl-privacy.test.js
@@ -53,7 +53,7 @@ const sqlMock = vi.fn((strings, ...values) => {
}
return Promise.resolve([]); // DDL + anything else
});
-vi.mock('../../api/_lib/db.js', () => ({ sql: (...a) => sqlMock(...a) }));
+vi.mock('../../api/_lib/db.js', () => ({ sql: (...a) => sqlMock(...a), isDbUnavailableError: () => false, isDbCapacityError: () => false }));
let sessionUser = null;
vi.mock('../../api/_lib/auth.js', () => ({ getSessionUser: vi.fn(async () => sessionUser) }));
diff --git a/tests/api/irl-reap-cron.test.js b/tests/api/irl-reap-cron.test.js
index c8b278a3b..18030a233 100644
--- a/tests/api/irl-reap-cron.test.js
+++ b/tests/api/irl-reap-cron.test.js
@@ -10,7 +10,7 @@
import { describe, it, expect, beforeEach, vi } from 'vitest';
const sqlMock = vi.fn();
-vi.mock('../../api/_lib/db.js', () => ({ sql: sqlMock }));
+vi.mock('../../api/_lib/db.js', () => ({ sql: sqlMock, isDbUnavailableError: () => false, isDbCapacityError: () => false }));
vi.mock('../../api/_lib/env.js', () => ({ env: {} }));
vi.mock('../../api/_lib/sentry.js', () => ({ captureException: vi.fn() }));
vi.mock('../../api/_lib/alerts.js', () => ({ sendOpsAlert: vi.fn() }));
diff --git a/tests/api/irl-report.test.js b/tests/api/irl-report.test.js
index aab443714..586348de4 100644
--- a/tests/api/irl-report.test.js
+++ b/tests/api/irl-report.test.js
@@ -43,7 +43,7 @@ const sqlMock = vi.fn((strings, ...values) => {
// ensureTable DDL, anything else.
return Promise.resolve([]);
});
-vi.mock('../../api/_lib/db.js', () => ({ sql: (...a) => sqlMock(...a) }));
+vi.mock('../../api/_lib/db.js', () => ({ sql: (...a) => sqlMock(...a), isDbUnavailableError: () => false, isDbCapacityError: () => false }));
let sessionUser = null;
vi.mock('../../api/_lib/auth.js', () => ({
diff --git a/tests/api/irl-sweep-detection.test.js b/tests/api/irl-sweep-detection.test.js
index 3190cdcea..f3331688e 100644
--- a/tests/api/irl-sweep-detection.test.js
+++ b/tests/api/irl-sweep-detection.test.js
@@ -25,7 +25,7 @@ const alertSpy = vi.fn(async () => {});
vi.mock('../../api/_lib/alerts.js', () => ({ sendOpsAlert: (...a) => alertSpy(...a) }));
// Minimal stubs so importing the handler module doesn't touch real infra.
-vi.mock('../../api/_lib/db.js', () => ({ sql: vi.fn(async () => []) }));
+vi.mock('../../api/_lib/db.js', () => ({ sql: vi.fn(async () => []), isDbUnavailableError: () => false, isDbCapacityError: () => false }));
vi.mock('../../api/_lib/auth.js', () => ({ getSessionUser: vi.fn(async () => null) }));
vi.mock('../../api/_lib/rate-limit.js', () => ({
limits: { publicIp: vi.fn(async () => ({ success: true })) },
diff --git a/tests/api/marketplace-agent-detail-prices.test.js b/tests/api/marketplace-agent-detail-prices.test.js
index 808b03447..fed6b1595 100644
--- a/tests/api/marketplace-agent-detail-prices.test.js
+++ b/tests/api/marketplace-agent-detail-prices.test.js
@@ -27,7 +27,7 @@ const sqlMock = vi.fn((strings) => {
if (/FROM agent_identities/i.test(q)) return Promise.resolve(agentRow ? [agentRow] : []);
return Promise.resolve([]);
});
-vi.mock('../../api/_lib/db.js', () => ({ sql: sqlMock }));
+vi.mock('../../api/_lib/db.js', () => ({ sql: sqlMock, isDbUnavailableError: () => false, isDbCapacityError: () => false }));
// Anonymous viewer: every auth probe returns null.
vi.mock('../../api/_lib/auth.js', () => ({
diff --git a/tests/api/marketplace-agent-detail-subscriptions.test.js b/tests/api/marketplace-agent-detail-subscriptions.test.js
index 12973f7a9..04329327e 100644
--- a/tests/api/marketplace-agent-detail-subscriptions.test.js
+++ b/tests/api/marketplace-agent-detail-subscriptions.test.js
@@ -54,7 +54,7 @@ const sqlMock = vi.fn((strings) => {
}
return Promise.resolve([]);
});
-vi.mock('../../api/_lib/db.js', () => ({ sql: sqlMock }));
+vi.mock('../../api/_lib/db.js', () => ({ sql: sqlMock, isDbUnavailableError: () => false, isDbCapacityError: () => false }));
// Signed-in viewer for every probe.
vi.mock('../../api/_lib/auth.js', () => ({
diff --git a/tests/api/mcp-avatar-persist.test.js b/tests/api/mcp-avatar-persist.test.js
index baa0c9b0d..c7e0ffa74 100644
--- a/tests/api/mcp-avatar-persist.test.js
+++ b/tests/api/mcp-avatar-persist.test.js
@@ -26,7 +26,7 @@ vi.mock('../../api/_lib/ssrf-guard.js', async (importOriginal) => {
});
// ── DB (no Postgres in unit tests) ──────────────────────────────────────────
-vi.mock('../../api/_lib/db.js', () => ({ sql: vi.fn(async () => []) }));
+vi.mock('../../api/_lib/db.js', () => ({ sql: vi.fn(async () => []), isDbUnavailableError: () => false, isDbCapacityError: () => false }));
// ── Rate limits ─────────────────────────────────────────────────────────────
vi.mock('../../api/_lib/rate-limit.js', () => ({
diff --git a/tests/api/mcp-embed.test.js b/tests/api/mcp-embed.test.js
index 25879e1df..f725c866e 100644
--- a/tests/api/mcp-embed.test.js
+++ b/tests/api/mcp-embed.test.js
@@ -25,6 +25,8 @@ vi.mock('../../api/_lib/db.js', () => ({
sqlState.calls.push({ query: Array.isArray(strings) ? strings.join('?') : String(strings), values });
return sqlState.queue.length ? sqlState.queue.shift() : [];
}),
+ isDbUnavailableError: () => false,
+ isDbCapacityError: () => false,
}));
// ── Rate limits ──────────────────────────────────────────────────────────────
diff --git a/tests/api/mcp-memory.test.js b/tests/api/mcp-memory.test.js
index 9e76a01e5..f7be4dff4 100644
--- a/tests/api/mcp-memory.test.js
+++ b/tests/api/mcp-memory.test.js
@@ -28,6 +28,8 @@ vi.mock('../../api/_lib/db.js', () => ({
sqlState.calls.push({ query: strings.join('?'), values });
return sqlState.queue.length ? sqlState.queue.shift() : [];
}),
+ isDbUnavailableError: () => false,
+ isDbCapacityError: () => false,
}));
// ── Rate limits ───────────────────────────────────────────────────────────
diff --git a/tests/api/mcp-register-agent.test.js b/tests/api/mcp-register-agent.test.js
index a124c9cf2..54cebcc60 100644
--- a/tests/api/mcp-register-agent.test.js
+++ b/tests/api/mcp-register-agent.test.js
@@ -12,6 +12,8 @@ vi.mock('../../api/_lib/db.js', () => ({
sqlState.calls.push({ query: strings.join('?'), values });
return sqlState.queue.length ? sqlState.queue.shift() : [];
}),
+ isDbUnavailableError: () => false,
+ isDbCapacityError: () => false,
}));
// ── Rate limits ───────────────────────────────────────────────────────────────
diff --git a/tests/api/mcp-wallet-provision.test.js b/tests/api/mcp-wallet-provision.test.js
index 64b765cd9..b53e1eab5 100644
--- a/tests/api/mcp-wallet-provision.test.js
+++ b/tests/api/mcp-wallet-provision.test.js
@@ -18,6 +18,8 @@ vi.mock('../../api/_lib/db.js', () => ({
if (q.includes('agent_identities')) return dbState.agentRow ? [dbState.agentRow] : [];
return [];
}),
+ isDbUnavailableError: () => false,
+ isDbCapacityError: () => false,
}));
// ── Wallet custody layer ─────────────────────────────────────────────────────
diff --git a/tests/api/mcp.test.js b/tests/api/mcp.test.js
index 807b5a4c1..b4a5ecf02 100644
--- a/tests/api/mcp.test.js
+++ b/tests/api/mcp.test.js
@@ -27,6 +27,7 @@ vi.mock('../../api/_lib/db.js', () => ({
return sqlState.queue.length ? sqlState.queue.shift() : [];
}),
isDbUnavailableError: () => false,
+ isDbCapacityError: () => false,
}));
// ── Rate limits ───────────────────────────────────────────────────────────
diff --git a/tests/api/monetization-service.test.js b/tests/api/monetization-service.test.js
index 199722e92..0b4cec4f7 100644
--- a/tests/api/monetization-service.test.js
+++ b/tests/api/monetization-service.test.js
@@ -54,7 +54,7 @@ sqlMock.transaction = vi.fn((queries) => Promise.all(queries));
// Mock db.js so importing the service never reaches Neon/env config — the
// service's own queries run through the injected sqlMock instead.
-vi.mock('../../api/_lib/db.js', () => ({ sql: sqlMock }));
+vi.mock('../../api/_lib/db.js', () => ({ sql: sqlMock, isDbUnavailableError: () => false, isDbCapacityError: () => false }));
// ── Mock the lower-level helpers the service orchestrates ─────────────────────
const purchaseConfirm = {
diff --git a/tests/api/nft-gate.test.js b/tests/api/nft-gate.test.js
index c624b36dd..ae0220839 100644
--- a/tests/api/nft-gate.test.js
+++ b/tests/api/nft-gate.test.js
@@ -11,7 +11,7 @@ import { describe, it, expect, vi, beforeEach, afterEach } from 'vitest';
// ── Counting SQL stub for getUserSolanaWallets ───────────────────────────────
let walletRows = [];
const sql = vi.fn(async () => walletRows);
-vi.mock('../../api/_lib/db.js', () => ({ sql }));
+vi.mock('../../api/_lib/db.js', () => ({ sql, isDbUnavailableError: () => false, isDbCapacityError: () => false }));
const {
isValidSolanaAddress,
diff --git a/tests/api/oauth-authorize.test.js b/tests/api/oauth-authorize.test.js
index 3e577cc80..5e9df13d8 100644
--- a/tests/api/oauth-authorize.test.js
+++ b/tests/api/oauth-authorize.test.js
@@ -35,6 +35,8 @@ vi.mock('../../api/_lib/db.js', () => ({
if (sqlState.queue.length === 0) return [];
return sqlState.queue.shift();
}),
+ isDbUnavailableError: () => false,
+ isDbCapacityError: () => false,
}));
vi.mock('../../api/_lib/crypto.js', () => ({
diff --git a/tests/api/oauth-introspect.test.js b/tests/api/oauth-introspect.test.js
index f20fa7280..480df881b 100644
--- a/tests/api/oauth-introspect.test.js
+++ b/tests/api/oauth-introspect.test.js
@@ -19,6 +19,8 @@ vi.mock('../../api/_lib/db.js', () => ({
if (next instanceof Error) throw next;
return next;
}),
+ isDbUnavailableError: () => false,
+ isDbCapacityError: () => false,
}));
vi.mock('../../api/_lib/rate-limit.js', () => ({
diff --git a/tests/api/oauth-token.test.js b/tests/api/oauth-token.test.js
index d3b9f39f5..537c6f13e 100644
--- a/tests/api/oauth-token.test.js
+++ b/tests/api/oauth-token.test.js
@@ -20,6 +20,8 @@ vi.mock('../../api/_lib/db.js', () => ({
if (next instanceof Error) throw next;
return next;
}),
+ isDbUnavailableError: () => false,
+ isDbCapacityError: () => false,
}));
const rlState = { success: true };
diff --git a/tests/api/pay-by-name-resolve.test.js b/tests/api/pay-by-name-resolve.test.js
index a4326ea14..3dd1abaf4 100644
--- a/tests/api/pay-by-name-resolve.test.js
+++ b/tests/api/pay-by-name-resolve.test.js
@@ -6,7 +6,7 @@
import { describe, it, expect, vi, beforeEach, beforeAll } from 'vitest';
const sqlMock = vi.fn();
-vi.mock('../../api/_lib/db.js', () => ({ sql: (...a) => sqlMock(...a) }));
+vi.mock('../../api/_lib/db.js', () => ({ sql: (...a) => sqlMock(...a), isDbUnavailableError: () => false, isDbCapacityError: () => false }));
vi.mock('../../api/_lib/rate-limit.js', () => ({
limits: { authIp: vi.fn(async () => ({ success: true })) },
diff --git a/tests/api/persona.test.js b/tests/api/persona.test.js
index e7fa78986..2d40d5d73 100644
--- a/tests/api/persona.test.js
+++ b/tests/api/persona.test.js
@@ -22,6 +22,8 @@ vi.mock('../../api/_lib/db.js', () => ({
if (sqlState.queue.length === 0) return [];
return sqlState.queue.shift();
}),
+ isDbUnavailableError: () => false,
+ isDbCapacityError: () => false,
}));
vi.mock('../../api/_lib/r2.js', () => ({
diff --git a/tests/api/pump.test.js b/tests/api/pump.test.js
index 55043dc18..b3c7f9f86 100644
--- a/tests/api/pump.test.js
+++ b/tests/api/pump.test.js
@@ -21,6 +21,8 @@ vi.mock('../../api/_lib/db.js', () => ({
if (sqlState.queue.length === 0) return [];
return sqlState.queue.shift();
}),
+ isDbUnavailableError: () => false,
+ isDbCapacityError: () => false,
}));
vi.mock('../../api/_lib/rate-limit.js', () => ({
diff --git a/tests/api/purchase-as-agent.test.js b/tests/api/purchase-as-agent.test.js
index 8500e18ef..3892c3fe8 100644
--- a/tests/api/purchase-as-agent.test.js
+++ b/tests/api/purchase-as-agent.test.js
@@ -30,6 +30,7 @@ vi.mock('../../api/_lib/db.js', () => ({
// http.js wrap() classifies thrown errors via this helper; the on-chain
// failures these tests exercise are never DB-unavailable, so return false.
isDbUnavailableError: () => false,
+ isDbCapacityError: () => false,
}));
const rlState = { success: true };
diff --git a/tests/api/reconstruct-finalize.test.js b/tests/api/reconstruct-finalize.test.js
index 1617b7bbc..14d00939c 100644
--- a/tests/api/reconstruct-finalize.test.js
+++ b/tests/api/reconstruct-finalize.test.js
@@ -6,7 +6,7 @@ import { describe, it, expect, vi, beforeEach } from 'vitest';
// ── mocks ──────────────────────────────────────────────────────────────────
const sqlMock = vi.fn(async () => []);
-vi.mock('../../api/_lib/db.js', () => ({ sql: (...args) => sqlMock(...args) }));
+vi.mock('../../api/_lib/db.js', () => ({ sql: (...args) => sqlMock(...args), isDbUnavailableError: () => false, isDbCapacityError: () => false }));
const putObjectMock = vi.fn(async () => undefined);
const publicUrlMock = vi.fn((key) => `https://cdn.test/${key}`);
diff --git a/tests/api/reputation-store-recompute.test.js b/tests/api/reputation-store-recompute.test.js
index 90031f3f9..79ba7daea 100644
--- a/tests/api/reputation-store-recompute.test.js
+++ b/tests/api/reputation-store-recompute.test.js
@@ -15,6 +15,7 @@ import { describe, it, expect, vi, beforeEach } from 'vitest';
vi.mock('../../api/_lib/db.js', () => ({
sql: vi.fn(async () => []),
isDbUnavailableError: () => false,
+ isDbCapacityError: () => false,
}));
const getAgentReputation = vi.fn();
diff --git a/tests/api/resolve-recipient.test.js b/tests/api/resolve-recipient.test.js
index d631d4cd6..20f22268a 100644
--- a/tests/api/resolve-recipient.test.js
+++ b/tests/api/resolve-recipient.test.js
@@ -15,6 +15,8 @@ vi.mock('../../api/_lib/db.js', () => ({
calls.push({ q, values });
return state.hit ? [state.hit] : [];
}),
+ isDbUnavailableError: () => false,
+ isDbCapacityError: () => false,
}));
const { resolveRecipient } = await import('../../api/_lib/resolve-recipient.js');
diff --git a/tests/api/saml.test.js b/tests/api/saml.test.js
index 37d2a05c6..2d650c02f 100644
--- a/tests/api/saml.test.js
+++ b/tests/api/saml.test.js
@@ -9,6 +9,8 @@ process.env.JWT_SECRET ||= 'test-saml-secret-at-least-32-characters';
vi.mock('../../api/_lib/db.js', () => ({
sql: vi.fn(async () => []),
+ isDbUnavailableError: () => false,
+ isDbCapacityError: () => false,
}));
const saml = await import('../../api/_lib/saml.js');
diff --git a/tests/api/security-csrf-gates.test.js b/tests/api/security-csrf-gates.test.js
index 063208f1d..d9464cde9 100644
--- a/tests/api/security-csrf-gates.test.js
+++ b/tests/api/security-csrf-gates.test.js
@@ -85,6 +85,8 @@ vi.mock('../../api/_lib/db.js', () => ({
}),
},
),
+ isDbUnavailableError: () => false,
+ isDbCapacityError: () => false,
}));
vi.mock('../../api/_lib/rate-limit.js', () => ({
diff --git a/tests/api/siwe-handler.test.js b/tests/api/siwe-handler.test.js
index 1dbbfc5eb..5de75ed0e 100644
--- a/tests/api/siwe-handler.test.js
+++ b/tests/api/siwe-handler.test.js
@@ -19,6 +19,8 @@ vi.mock('../../api/_lib/db.js', () => ({
if (next instanceof Error) throw next;
return next;
}),
+ isDbUnavailableError: () => false,
+ isDbCapacityError: () => false,
}));
const rlState = { success: true };
diff --git a/tests/api/skill-access-grant-on-confirm.test.js b/tests/api/skill-access-grant-on-confirm.test.js
index cc19e2d1d..efdbfcbdf 100644
--- a/tests/api/skill-access-grant-on-confirm.test.js
+++ b/tests/api/skill-access-grant-on-confirm.test.js
@@ -35,6 +35,8 @@ vi.mock('../../api/_lib/db.js', () => ({
if (/update\s+skill_purchases\s+set\s+tx_signature/i.test(q)) return [{ id: PUR.id }];
return [];
}),
+ isDbUnavailableError: () => false,
+ isDbCapacityError: () => false,
}));
const evmState = { result: { status: 'match', from: '0xPAYER' } };
diff --git a/tests/api/skill-access-nft.test.js b/tests/api/skill-access-nft.test.js
index 0b453729d..f0909e04d 100644
--- a/tests/api/skill-access-nft.test.js
+++ b/tests/api/skill-access-nft.test.js
@@ -9,7 +9,7 @@ import { describe, it, expect, vi, beforeEach } from 'vitest';
let priceRow; // the row returned by the first SELECT in hasSkillAccess
const sql = vi.fn(async () => (priceRow ? [priceRow] : []));
-vi.mock('../../api/_lib/db.js', () => ({ sql }));
+vi.mock('../../api/_lib/db.js', () => ({ sql, isDbUnavailableError: () => false, isDbCapacityError: () => false }));
const userHoldsCollection = vi.fn();
vi.mock('../../api/_lib/nft-gate.js', () => ({ userHoldsCollection }));
diff --git a/tests/api/skill-access.test.js b/tests/api/skill-access.test.js
index cd99d9f5c..3dc63db36 100644
--- a/tests/api/skill-access.test.js
+++ b/tests/api/skill-access.test.js
@@ -19,6 +19,8 @@ vi.mock('../../api/_lib/db.js', () => ({
if (sqlState.queue.length === 0) return [];
return sqlState.queue.shift();
}),
+ isDbUnavailableError: () => false,
+ isDbCapacityError: () => false,
}));
const rlState = { success: true };
diff --git a/tests/api/skill-gift-confirm.test.js b/tests/api/skill-gift-confirm.test.js
index 5fab8c24d..9b405b425 100644
--- a/tests/api/skill-gift-confirm.test.js
+++ b/tests/api/skill-gift-confirm.test.js
@@ -25,6 +25,8 @@ vi.mock('../../api/_lib/db.js', () => ({
if (/update\s+skill_purchases\s+set\s+tx_signature/i.test(q)) return [{ id: PUR.id }];
return [];
}),
+ isDbUnavailableError: () => false,
+ isDbCapacityError: () => false,
}));
vi.mock('../../api/_lib/evm-payment-verify.js', () => ({
diff --git a/tests/api/skill-gift-service.test.js b/tests/api/skill-gift-service.test.js
index 7c4058da0..b1e0c0ba2 100644
--- a/tests/api/skill-gift-service.test.js
+++ b/tests/api/skill-gift-service.test.js
@@ -32,7 +32,7 @@ const sqlMock = vi.fn((strings, ...values) => {
return Promise.resolve(respond(q));
});
sqlMock.transaction = vi.fn((queries) => Promise.all(queries));
-vi.mock('../../api/_lib/db.js', () => ({ sql: sqlMock }));
+vi.mock('../../api/_lib/db.js', () => ({ sql: sqlMock, isDbUnavailableError: () => false, isDbCapacityError: () => false }));
const purchaseConfirm = {
confirmSkillPurchase: vi.fn(async () => ({ status: 'confirmed', tx_signature: 'SIG' })),
diff --git a/tests/api/skill-mint.test.js b/tests/api/skill-mint.test.js
index 0916c90f3..b28006297 100644
--- a/tests/api/skill-mint.test.js
+++ b/tests/api/skill-mint.test.js
@@ -20,6 +20,7 @@ vi.mock('../../api/_lib/db.js', () => ({
return sqlState.queue.shift();
}),
isDbUnavailableError: () => false,
+ isDbCapacityError: () => false,
}));
const rlState = { success: true };
diff --git a/tests/api/skill-price-cache.test.js b/tests/api/skill-price-cache.test.js
index c679dcac8..50f2a5058 100644
--- a/tests/api/skill-price-cache.test.js
+++ b/tests/api/skill-price-cache.test.js
@@ -34,7 +34,7 @@ const sql = vi.fn(async (_strings, ...values) => {
dbHits.set(agentId, (dbHits.get(agentId) || 0) + 1);
return pricesByAgent.get(agentId) ?? [];
});
-vi.mock('../../api/_lib/db.js', () => ({ sql }));
+vi.mock('../../api/_lib/db.js', () => ({ sql, isDbUnavailableError: () => false, isDbCapacityError: () => false }));
const { getSkillPrices, getSkillPrice, invalidateSkillPriceCache, skillPriceMap } = await import(
'../../api/_lib/skill-price-cache.js'
diff --git a/tests/api/solana-airdrop.test.js b/tests/api/solana-airdrop.test.js
index c5b291ebe..de89209db 100644
--- a/tests/api/solana-airdrop.test.js
+++ b/tests/api/solana-airdrop.test.js
@@ -14,6 +14,8 @@ vi.mock('../../api/_lib/auth.js', () => ({
const sqlState = { queue: [] };
vi.mock('../../api/_lib/db.js', () => ({
sql: vi.fn(async () => (sqlState.queue.length ? sqlState.queue.shift() : [])),
+ isDbUnavailableError: () => false,
+ isDbCapacityError: () => false,
}));
vi.mock('../../api/_lib/rate-limit.js', () => ({
diff --git a/tests/api/solana-register-prep.test.js b/tests/api/solana-register-prep.test.js
index 28d1ae3f9..9c1049752 100644
--- a/tests/api/solana-register-prep.test.js
+++ b/tests/api/solana-register-prep.test.js
@@ -18,6 +18,8 @@ vi.mock('../../api/_lib/db.js', () => ({
if (sqlState.queue.length === 0) return [];
return sqlState.queue.shift();
}),
+ isDbUnavailableError: () => false,
+ isDbCapacityError: () => false,
}));
vi.mock('../../api/_lib/rate-limit.js', () => ({
diff --git a/tests/api/solana-wallet-balance.test.js b/tests/api/solana-wallet-balance.test.js
index a40243157..aa42fcb61 100644
--- a/tests/api/solana-wallet-balance.test.js
+++ b/tests/api/solana-wallet-balance.test.js
@@ -26,6 +26,8 @@ vi.mock('../../api/_lib/auth.js', () => ({
const sqlState = { queue: [] };
vi.mock('../../api/_lib/db.js', () => ({
sql: vi.fn(async () => (sqlState.queue.length ? sqlState.queue.shift() : [])),
+ isDbUnavailableError: () => false,
+ isDbCapacityError: () => false,
}));
vi.mock('../../api/_lib/rate-limit.js', () => ({
diff --git a/tests/api/solana-wallet-import.test.js b/tests/api/solana-wallet-import.test.js
index 411d380cd..d2b8b80be 100644
--- a/tests/api/solana-wallet-import.test.js
+++ b/tests/api/solana-wallet-import.test.js
@@ -18,6 +18,8 @@ vi.mock('../../api/_lib/db.js', () => ({
if (sqlState.queue.length === 0) return [];
return sqlState.queue.shift();
}),
+ isDbUnavailableError: () => false,
+ isDbCapacityError: () => false,
}));
vi.mock('../../api/_lib/rate-limit.js', () => ({
diff --git a/tests/api/three-holders-snapshot.test.js b/tests/api/three-holders-snapshot.test.js
index 124cded94..9a1fcd435 100644
--- a/tests/api/three-holders-snapshot.test.js
+++ b/tests/api/three-holders-snapshot.test.js
@@ -7,7 +7,7 @@
import { describe, it, expect, vi, beforeEach } from 'vitest';
const h = { sql: vi.fn() };
-vi.mock('../../api/_lib/db.js', () => ({ sql: (...a) => h.sql(...a) }));
+vi.mock('../../api/_lib/db.js', () => ({ sql: (...a) => h.sql(...a), isDbUnavailableError: () => false, isDbCapacityError: () => false }));
vi.mock('../../api/_lib/coin/holders.js', () => ({ fetchHolderBalances: vi.fn() }));
vi.mock('../../api/_lib/token/config.js', () => ({ TOKEN_MINT: 'THREEsynthetic1111111111111111111111111111' }));
diff --git a/tests/api/threews-subdomain-availability.test.js b/tests/api/threews-subdomain-availability.test.js
index be398c206..90c86b5f5 100644
--- a/tests/api/threews-subdomain-availability.test.js
+++ b/tests/api/threews-subdomain-availability.test.js
@@ -10,7 +10,7 @@
import { describe, it, expect, vi, beforeEach, beforeAll } from 'vitest';
const sqlMock = vi.fn();
-vi.mock('../../api/_lib/db.js', () => ({ sql: (...a) => sqlMock(...a) }));
+vi.mock('../../api/_lib/db.js', () => ({ sql: (...a) => sqlMock(...a), isDbUnavailableError: () => false, isDbCapacityError: () => false }));
vi.mock('../../api/_lib/rate-limit.js', () => ({
limits: { authIp: vi.fn(async () => ({ success: true })) },
diff --git a/tests/api/transaction-history.test.js b/tests/api/transaction-history.test.js
index ee777f8be..2363b75de 100644
--- a/tests/api/transaction-history.test.js
+++ b/tests/api/transaction-history.test.js
@@ -21,7 +21,7 @@ const sqlMock = vi.fn((strings, ...values) => {
if (/'seller'::text AS role/.test(q)) return Promise.resolve(sellerRows);
return Promise.resolve([]);
});
-vi.mock('../../api/_lib/db.js', () => ({ sql: sqlMock }));
+vi.mock('../../api/_lib/db.js', () => ({ sql: sqlMock, isDbUnavailableError: () => false, isDbCapacityError: () => false }));
let sessionUser = null;
let bearerUser = null;
diff --git a/tests/api/uptime-status.test.js b/tests/api/uptime-status.test.js
index e2096b446..a3536e64f 100644
--- a/tests/api/uptime-status.test.js
+++ b/tests/api/uptime-status.test.js
@@ -23,6 +23,14 @@ vi.mock('../../api/_lib/alerts.js', () => ({
sendOpsAlert: (...args) => sendOpsAlert(...args),
}));
+// Internal subsystem health (db/ring/world checks) is covered by its own suite
+// (tests/subsystem-health.test.js). Mock it healthy here so this file stays a
+// deterministic test of the reachability pipeline: probes, storage shape,
+// aggregation math, and target alerting.
+vi.mock('../../api/_lib/ops/subsystem-health.js', () => ({
+ gatherSubsystemHealth: vi.fn(async () => ({ status: 'ok', degraded: [], subsystems: [] })),
+}));
+
vi.mock('../../api/_lib/rate-limit.js', () => ({
limits: { publicIp: vi.fn(async () => ({ success: true })) },
clientIp: vi.fn(() => '127.0.0.1'),
diff --git a/tests/api/users-by-subdomain.test.js b/tests/api/users-by-subdomain.test.js
index c3de587ed..450da1666 100644
--- a/tests/api/users-by-subdomain.test.js
+++ b/tests/api/users-by-subdomain.test.js
@@ -5,7 +5,7 @@
import { describe, it, expect, vi, beforeEach, beforeAll } from 'vitest';
const sqlMock = vi.fn();
-vi.mock('../../api/_lib/db.js', () => ({ sql: (...a) => sqlMock(...a) }));
+vi.mock('../../api/_lib/db.js', () => ({ sql: (...a) => sqlMock(...a), isDbUnavailableError: () => false, isDbCapacityError: () => false }));
vi.mock('../../api/_lib/rate-limit.js', () => ({
limits: { snsResolve: vi.fn(async () => ({ success: true })) },
diff --git a/tests/api/webhooks-replicate.test.js b/tests/api/webhooks-replicate.test.js
index c7ac8b24f..cc563d5e5 100644
--- a/tests/api/webhooks-replicate.test.js
+++ b/tests/api/webhooks-replicate.test.js
@@ -41,7 +41,7 @@ const sqlMock = vi.fn(async (strings, ...values) => {
}
return [];
});
-vi.mock('../../api/_lib/db.js', () => ({ sql: sqlMock }));
+vi.mock('../../api/_lib/db.js', () => ({ sql: sqlMock, isDbUnavailableError: () => false, isDbCapacityError: () => false }));
const putObjectMock = vi.fn(async () => undefined);
vi.mock('../../api/_lib/r2.js', () => ({ putObject: putObjectMock }));
diff --git a/tests/api/widget-knowledge-embedder.test.js b/tests/api/widget-knowledge-embedder.test.js
index f0bfe2689..cb0575da0 100644
--- a/tests/api/widget-knowledge-embedder.test.js
+++ b/tests/api/widget-knowledge-embedder.test.js
@@ -20,7 +20,7 @@ const sqlMock = vi.fn((strings, ...params) => {
return Promise.resolve(next ?? []);
});
sqlMock.transaction = vi.fn(async (queries) => Promise.all(queries));
-vi.mock('../../api/_lib/db.js', () => ({ sql: sqlMock }));
+vi.mock('../../api/_lib/db.js', () => ({ sql: sqlMock, isDbUnavailableError: () => false, isDbCapacityError: () => false }));
// Mutable embedding-provider state each test configures.
const mockEmbedState = {
diff --git a/tests/api/widgets.test.js b/tests/api/widgets.test.js
index 406750892..23d0234ef 100644
--- a/tests/api/widgets.test.js
+++ b/tests/api/widgets.test.js
@@ -23,7 +23,7 @@ const sqlMock = vi.fn(() => {
return Promise.resolve(next);
});
-vi.mock('../../api/_lib/db.js', () => ({ sql: sqlMock, isDbUnavailableError: () => false }));
+vi.mock('../../api/_lib/db.js', () => ({ sql: sqlMock, isDbUnavailableError: () => false, isDbCapacityError: () => false }));
const authState = {
session: null,
diff --git a/tests/api/world-lines.test.js b/tests/api/world-lines.test.js
index 3a2edda20..ff0be95da 100644
--- a/tests/api/world-lines.test.js
+++ b/tests/api/world-lines.test.js
@@ -121,7 +121,7 @@ const fakeSql = vi.fn(async (strings, ...values) => {
return [];
});
-vi.mock('../../api/_lib/db.js', () => ({ sql: fakeSql }));
+vi.mock('../../api/_lib/db.js', () => ({ sql: fakeSql, isDbUnavailableError: () => false, isDbCapacityError: () => false }));
vi.mock('../../api/_lib/env.js', () => ({ env: {} }));
vi.mock('../../api/_lib/sentry.js', () => ({ captureException: vi.fn() }));
vi.mock('../../api/_lib/alerts.js', () => ({ sendOpsAlert: vi.fn() }));
diff --git a/tests/api/x402-cosmetic-pricing-audit.test.js b/tests/api/x402-cosmetic-pricing-audit.test.js
index c0ce184f4..49e69bf6b 100644
--- a/tests/api/x402-cosmetic-pricing-audit.test.js
+++ b/tests/api/x402-cosmetic-pricing-audit.test.js
@@ -58,7 +58,7 @@ let payX402Impl = async () => ({
const payX402 = vi.fn((...a) => payX402Impl(...a));
const bootstrapSolanaContext = vi.fn(async () => ({ buyer: {}, conn: {}, blockhash: 'bh', mintInfo: { decimals: 6 } }));
-vi.mock('../../api/_lib/db.js', () => ({ sql: (...a) => sql(...a) }));
+vi.mock('../../api/_lib/db.js', () => ({ sql: (...a) => sql(...a), isDbUnavailableError: () => false, isDbCapacityError: () => false }));
vi.mock('../../api/_lib/env.js', () => ({
env: { APP_ORIGIN: 'https://three.ws', X402_ASSET_MINT_SOLANA: 'USDCmint', SOLANA_RPC_URL: 'http://rpc' },
}));
diff --git a/tests/api/x402-pay-by-name.test.js b/tests/api/x402-pay-by-name.test.js
index 4d52ab639..32c2cb4b5 100644
--- a/tests/api/x402-pay-by-name.test.js
+++ b/tests/api/x402-pay-by-name.test.js
@@ -6,7 +6,7 @@
import { describe, it, expect, vi, beforeEach, beforeAll } from 'vitest';
const sqlMock = vi.fn();
-vi.mock('../../api/_lib/db.js', () => ({ sql: (...a) => sqlMock(...a) }));
+vi.mock('../../api/_lib/db.js', () => ({ sql: (...a) => sqlMock(...a), isDbUnavailableError: () => false, isDbCapacityError: () => false }));
const snsResolveMock = vi.fn();
vi.mock('@bonfida/spl-name-service', () => ({
diff --git a/tests/api/x402-pay-feed-degraded.test.js b/tests/api/x402-pay-feed-degraded.test.js
index fdb924fde..034efb322 100644
--- a/tests/api/x402-pay-feed-degraded.test.js
+++ b/tests/api/x402-pay-feed-degraded.test.js
@@ -32,7 +32,7 @@ vi.mock('../../api/_lib/usage.js', () => ({
logger: () => ({ info: vi.fn(), warn: warnMock, error: vi.fn() }),
recordEvent: vi.fn(),
}));
-vi.mock('../../api/_lib/db.js', () => ({ sql: vi.fn(async () => []) }));
+vi.mock('../../api/_lib/db.js', () => ({ sql: vi.fn(async () => []), isDbUnavailableError: () => false, isDbCapacityError: () => false }));
// A Redis client that is present (so readFeed takes the Redis branch) but whose
// every command rejects the way a WRONGPASS-authenticated Upstash client does.
diff --git a/tests/api/x402-pay-routing.test.js b/tests/api/x402-pay-routing.test.js
index accc9b120..36172b9c6 100644
--- a/tests/api/x402-pay-routing.test.js
+++ b/tests/api/x402-pay-routing.test.js
@@ -32,7 +32,7 @@ vi.mock('../../api/_lib/usage.js', () => ({
}));
vi.mock('../../api/_lib/redis.js', () => ({ getRedis: () => null }));
-vi.mock('../../api/_lib/db.js', () => ({ sql: vi.fn(async () => []) }));
+vi.mock('../../api/_lib/db.js', () => ({ sql: vi.fn(async () => []), isDbUnavailableError: () => false, isDbCapacityError: () => false }));
// No shared platform wallet configured + no dev keypair file → loadAgentKeypair()
// throws config-missing, which is the deterministic outcome we assert for the
diff --git a/tests/api/x402-scene-capture-processor.test.js b/tests/api/x402-scene-capture-processor.test.js
index 42c72fe1f..4ad608ab1 100644
--- a/tests/api/x402-scene-capture-processor.test.js
+++ b/tests/api/x402-scene-capture-processor.test.js
@@ -43,7 +43,7 @@ let providerThrows = false;
const payX402 = vi.fn();
-vi.mock('../../api/_lib/db.js', () => ({ sql: (...a) => sql(...a) }));
+vi.mock('../../api/_lib/db.js', () => ({ sql: (...a) => sql(...a), isDbUnavailableError: () => false, isDbCapacityError: () => false }));
vi.mock('../../api/_lib/ssrf.js', () => ({
assertPublicHttpsUrl: vi.fn(async (u) => u),
SsrfError: class SsrfError extends Error {},
diff --git a/tests/app-flags.test.js b/tests/app-flags.test.js
index d8f397e4e..2651628bc 100644
--- a/tests/app-flags.test.js
+++ b/tests/app-flags.test.js
@@ -19,7 +19,7 @@ vi.mock('../api/_lib/db.js', () => {
sqlCalls.push({ query, values });
return sqlHandler(query, values) ?? [];
});
- return { sql };
+ return { sql, isDbUnavailableError: () => false, isDbCapacityError: () => false };
});
const { getFlag, isFlagEnabled, setFlag, listFlags, __clearFlagCache } = await import('../api/_lib/flags.js');
diff --git a/tests/auto-rig-completion.test.js b/tests/auto-rig-completion.test.js
index 8b6348451..1839ab36b 100644
Binary files a/tests/auto-rig-completion.test.js and b/tests/auto-rig-completion.test.js differ
diff --git a/tests/auto-rig-gates.test.js b/tests/auto-rig-gates.test.js
index 1ba73cf3a..2030f6fc8 100644
--- a/tests/auto-rig-gates.test.js
+++ b/tests/auto-rig-gates.test.js
@@ -22,7 +22,7 @@ const sql = vi.fn(async (strings, ...vals) => {
if (/from avatar_regen_jobs/i.test(q)) return sqlState.inFlight; // the select; insert uses "into"
return [];
});
-vi.mock('../api/_lib/db.js', () => ({ sql: (...a) => sql(...a) }));
+vi.mock('../api/_lib/db.js', () => ({ sql: (...a) => sql(...a), isDbUnavailableError: () => false, isDbCapacityError: () => false }));
// Provider: rerig-capable, with a spy on submit.
const submit = vi.fn(async () => ({ extJobId: 'ext-job-123' }));
diff --git a/tests/auto-rig-ssrf.test.js b/tests/auto-rig-ssrf.test.js
index fc97ec323..423177f77 100644
--- a/tests/auto-rig-ssrf.test.js
+++ b/tests/auto-rig-ssrf.test.js
@@ -53,7 +53,7 @@ const sqlMock = vi.fn(async (strings, ...values) => {
}
return [];
});
-vi.mock('../api/_lib/db.js', () => ({ sql: (...a) => sqlMock(...a) }));
+vi.mock('../api/_lib/db.js', () => ({ sql: (...a) => sqlMock(...a), isDbUnavailableError: () => false, isDbCapacityError: () => false }));
// Auth: an authenticated session user for the poll handler.
vi.mock('../api/_lib/auth.js', () => ({
diff --git a/tests/autopilot.test.js b/tests/autopilot.test.js
index f5290c8fd..238c85a7d 100644
--- a/tests/autopilot.test.js
+++ b/tests/autopilot.test.js
@@ -2,7 +2,7 @@ import { describe, it, expect, vi, beforeEach } from 'vitest';
// Mock the data + heavy infra layers so the pure logic is testable in isolation.
const sqlMock = vi.fn();
-vi.mock('../api/_lib/db.js', () => ({ sql: sqlMock }));
+vi.mock('../api/_lib/db.js', () => ({ sql: sqlMock, isDbUnavailableError: () => false, isDbCapacityError: () => false }));
const llmConfiguredMock = vi.fn(() => false);
const llmCompleteMock = vi.fn();
diff --git a/tests/branding-allowlist.json b/tests/branding-allowlist.json
index f392aa5d7..6f4e0a021 100644
--- a/tests/branding-allowlist.json
+++ b/tests/branding-allowlist.json
@@ -383,5 +383,15 @@
"pattern": "characterstudio-docs",
"file": "docs/character-studio.md",
"reason": "Required MIT upstream attribution — link to the upstream CharacterStudio asset-authoring docs (m3-org.github.io/characterstudio-docs); preserved so contributors can find the original vertex/UV conventions."
+ },
+ {
+ "pattern": "Mixamo, Avaturn, Unreal",
+ "file": "docs/avatar-pipeline.md",
+ "reason": "Factual list of third-party rig-name conventions glb-canonicalize.js recognizes (Mixamo, Avaturn, Unreal, VRM, Daz, MakeHuman, ...) — interoperability documentation, not brand promotion."
+ },
+ {
+ "pattern": "avaturn_seed",
+ "file": "docs/ops/runtime-flags.md",
+ "reason": "Literal runtime flag key `avaturn_seed` (with its `AVATURN_SEED_ENABLED` env fallback and avaturn-seed-cron.js path) in ops code samples and the flags table — technical identifiers, not user-facing brand copy."
}
]
diff --git a/tests/conversational-wallet-intent.test.js b/tests/conversational-wallet-intent.test.js
index e6ed4deac..4578b30d1 100644
--- a/tests/conversational-wallet-intent.test.js
+++ b/tests/conversational-wallet-intent.test.js
@@ -13,7 +13,7 @@ const THREE = 'FeMbDoX7R1Psc4GEcvJdsbNbZA3bfztcyDCatJVJpump';
// Stub the heavy server-only imports so importing the handler module is cheap and
// side-effect-free. The pure functions under test don't call any of them.
-vi.mock('../api/_lib/db.js', () => ({ sql: vi.fn(async () => []) }));
+vi.mock('../api/_lib/db.js', () => ({ sql: vi.fn(async () => []), isDbUnavailableError: () => false, isDbCapacityError: () => false }));
vi.mock('../api/_lib/auth.js', () => ({
getSessionUser: vi.fn(), authenticateBearer: vi.fn(), extractBearer: vi.fn(),
}));
diff --git a/tests/cosmetics-economy.test.js b/tests/cosmetics-economy.test.js
index bfe68edbc..d28ec03e1 100644
--- a/tests/cosmetics-economy.test.js
+++ b/tests/cosmetics-economy.test.js
@@ -25,6 +25,8 @@ vi.mock('../api/_lib/db.js', () => ({
const h = sqlHandlers.shift();
return Promise.resolve(h ? h(text, values) : []);
},
+ isDbUnavailableError: () => false,
+ isDbCapacityError: () => false,
}));
const transferMock = vi.fn();
diff --git a/tests/creator-pricing-rules-isolation.test.js b/tests/creator-pricing-rules-isolation.test.js
index cabd477c2..eaccd69c8 100644
--- a/tests/creator-pricing-rules-isolation.test.js
+++ b/tests/creator-pricing-rules-isolation.test.js
@@ -19,7 +19,7 @@ vi.mock('../api/_lib/db.js', () => {
sqlState.calls.push({ query: Array.isArray(strings) ? strings.join('?') : String(strings), values });
return sqlState.queue.length ? sqlState.queue.shift() : [];
});
- return { sql };
+ return { sql, isDbUnavailableError: () => false, isDbCapacityError: () => false };
});
vi.mock('../api/_lib/rate-limit.js', () => ({
diff --git a/tests/credits.test.js b/tests/credits.test.js
index 9db0343a2..1698d3433 100644
--- a/tests/credits.test.js
+++ b/tests/credits.test.js
@@ -19,6 +19,8 @@ vi.mock('../api/_lib/db.js', () => ({
const next = db.queue.length ? db.queue.shift() : [];
return next instanceof Error ? Promise.reject(next) : Promise.resolve(next);
},
+ isDbUnavailableError: () => false,
+ isDbCapacityError: () => false,
}));
vi.mock('../api/_lib/three-tier.js', () => ({
diff --git a/tests/forge-consumption-payment.test.js b/tests/forge-consumption-payment.test.js
index 904563081..4edf6baef 100644
--- a/tests/forge-consumption-payment.test.js
+++ b/tests/forge-consumption-payment.test.js
@@ -18,7 +18,7 @@ import { describe, it, expect, vi, beforeEach } from 'vitest';
const queue = [];
vi.mock('../api/_lib/db.js', () => {
const sql = vi.fn(async () => (queue.length ? queue.shift() : []));
- return { sql };
+ return { sql, isDbUnavailableError: () => false, isDbCapacityError: () => false };
});
import {
diff --git a/tests/forge-high-payment.test.js b/tests/forge-high-payment.test.js
index c19b1b0c1..d60180a85 100644
--- a/tests/forge-high-payment.test.js
+++ b/tests/forge-high-payment.test.js
@@ -15,7 +15,7 @@ import { describe, it, expect, vi, beforeEach } from 'vitest';
const queue = [];
vi.mock('../api/_lib/db.js', () => {
const sql = vi.fn(async () => (queue.length ? queue.shift() : []));
- return { sql };
+ return { sql, isDbUnavailableError: () => false, isDbCapacityError: () => false };
});
import {
diff --git a/tests/genome-breed.test.js b/tests/genome-breed.test.js
index 5e9daca9b..85d7d8cd1 100644
--- a/tests/genome-breed.test.js
+++ b/tests/genome-breed.test.js
@@ -45,7 +45,7 @@ vi.mock('../api/_lib/db.js', () => {
return state.sqlQueue.length ? state.sqlQueue.shift() : [];
});
sql.transaction = (qs) => Promise.all(qs);
- return { sql };
+ return { sql, isDbUnavailableError: () => false, isDbCapacityError: () => false };
});
vi.mock('../api/_lib/agent-wallet.js', () => ({
diff --git a/tests/launch-mark-enforcement.test.js b/tests/launch-mark-enforcement.test.js
index fe23463b3..57743a868 100644
--- a/tests/launch-mark-enforcement.test.js
+++ b/tests/launch-mark-enforcement.test.js
@@ -32,6 +32,8 @@ vi.mock('../api/_lib/db.js', () => ({
if (sqlState.queue.length === 0) return [];
return sqlState.queue.shift();
}),
+ isDbUnavailableError: () => false,
+ isDbCapacityError: () => false,
}));
// ── Rate limit ────────────────────────────────────────────────────────────────
diff --git a/tests/launcher-engine.test.js b/tests/launcher-engine.test.js
index ac37e4341..7c46c1bb7 100644
--- a/tests/launcher-engine.test.js
+++ b/tests/launcher-engine.test.js
@@ -28,7 +28,7 @@ vi.mock('../api/_lib/db.js', () => {
: [];
return Promise.resolve(rows);
};
- return { sql, isDbUnavailableError: () => false };
+ return { sql, isDbUnavailableError: () => false, isDbCapacityError: () => false };
});
vi.mock('../api/_lib/launcher-funding.js', () => ({
diff --git a/tests/launcher-owner-allowlist.test.js b/tests/launcher-owner-allowlist.test.js
index 862ca301e..ced1a8531 100644
--- a/tests/launcher-owner-allowlist.test.js
+++ b/tests/launcher-owner-allowlist.test.js
@@ -4,7 +4,7 @@ import { describe, it, expect, afterEach } from 'vitest';
// stub the DB the same lightweight way the engine test does — we only exercise the
// pure env-parsing helper here, never a query.
import { vi } from 'vitest';
-vi.mock('../api/_lib/db.js', () => ({ sql: () => Promise.resolve([]), isDbUnavailableError: () => false }));
+vi.mock('../api/_lib/db.js', () => ({ sql: () => Promise.resolve([]), isDbUnavailableError: () => false, isDbCapacityError: () => false }));
vi.mock('../api/_lib/launcher-funding.js', () => ({
masterBalanceSol: vi.fn(), dailySpentSol: vi.fn(), fundAgentForLaunch: vi.fn(),
}));
diff --git a/tests/launcher-trends-endpoint.test.js b/tests/launcher-trends-endpoint.test.js
index da5743a45..82bf747ce 100644
--- a/tests/launcher-trends-endpoint.test.js
+++ b/tests/launcher-trends-endpoint.test.js
@@ -32,6 +32,8 @@ vi.mock('../api/_lib/db.js', () => ({
sql: () => Promise.resolve([
{ name: 'Drool Lord', symbol: 'DROOL', mint: 'MINT111', kind: 'trend', trigger_source: 'knowyourmeme', trigger_detail: { top_narrative: 'drooling cat' }, created_at: '2026-06-27T00:00:00Z' },
]),
+ isDbUnavailableError: () => false,
+ isDbCapacityError: () => false,
}));
import handler from '../api/launcher/trends.js';
diff --git a/tests/memory-endpoints.test.js b/tests/memory-endpoints.test.js
index 7ae86c354..d609f2d6c 100644
--- a/tests/memory-endpoints.test.js
+++ b/tests/memory-endpoints.test.js
@@ -1,7 +1,7 @@
import { describe, it, expect, vi, beforeEach } from 'vitest';
const sqlMock = vi.fn();
-vi.mock('../api/_lib/db.js', () => ({ sql: sqlMock }));
+vi.mock('../api/_lib/db.js', () => ({ sql: sqlMock, isDbUnavailableError: () => false, isDbCapacityError: () => false }));
const getSessionUserMock = vi.fn();
const authenticateBearerMock = vi.fn();
diff --git a/tests/memory-store.test.js b/tests/memory-store.test.js
index e529be9f0..89f0fcdbb 100644
--- a/tests/memory-store.test.js
+++ b/tests/memory-store.test.js
@@ -3,7 +3,7 @@ import { describe, it, expect, vi, beforeEach } from 'vitest';
// ── Mocks ─────────────────────────────────────────────────────────────────
// `sql` is a tagged template — mock it as a fn returning queued FIFO results.
const sqlMock = vi.fn();
-vi.mock('../api/_lib/db.js', () => ({ sql: sqlMock }));
+vi.mock('../api/_lib/db.js', () => ({ sql: sqlMock, isDbUnavailableError: () => false, isDbCapacityError: () => false }));
// Control embedding configuration / vectors per test.
const embeddingsConfigured = vi.fn(() => true);
diff --git a/tests/metering.test.js b/tests/metering.test.js
index a436d0325..000fc208b 100644
--- a/tests/metering.test.js
+++ b/tests/metering.test.js
@@ -10,7 +10,7 @@ import { describe, it, expect, vi, beforeEach } from 'vitest';
const queue = [];
vi.mock('../api/_lib/db.js', () => {
const sql = vi.fn(async () => (queue.length ? queue.shift() : []));
- return { sql };
+ return { sql, isDbUnavailableError: () => false, isDbCapacityError: () => false };
});
import { recordUsage, rollupInvoice, getReceipt, atomicsToUsd } from '../api/_lib/metering.js';
diff --git a/tests/monetization-service.test.js b/tests/monetization-service.test.js
index 3f578f6e3..b3c4726ef 100644
--- a/tests/monetization-service.test.js
+++ b/tests/monetization-service.test.js
@@ -48,7 +48,7 @@ vi.mock('../api/_lib/db.js', () => {
return sqlState.queue.length ? sqlState.queue.shift() : [];
});
sql.transaction = (queries) => Promise.all(queries);
- return { sql, isDbUnavailableError: () => false };
+ return { sql, isDbUnavailableError: () => false, isDbCapacityError: () => false };
});
vi.mock('../api/_lib/rate-limit.js', () => ({
diff --git a/tests/oracle/sources-assemble.test.js b/tests/oracle/sources-assemble.test.js
index 9eb10eeba..3397de127 100644
--- a/tests/oracle/sources-assemble.test.js
+++ b/tests/oracle/sources-assemble.test.js
@@ -12,6 +12,8 @@ import { describe, it, expect, vi, beforeEach } from 'vitest';
const sqlMock = vi.fn();
vi.mock('../../api/_lib/db.js', () => ({
sql: (...args) => sqlMock(...args),
+ isDbUnavailableError: () => false,
+ isDbCapacityError: () => false,
}));
const { assembleIntel } = await import('../../api/_lib/oracle/sources.js');
diff --git a/tests/public/x402-modal-dom.test.js b/tests/public/x402-modal-dom.test.js
index 15ea2c367..1f35bec44 100644
--- a/tests/public/x402-modal-dom.test.js
+++ b/tests/public/x402-modal-dom.test.js
@@ -55,6 +55,11 @@ describe('x402 payment modal — trust + a11y', () => {
window.phantom = { solana: { isPhantom: true } };
global.fetch = vi.fn(async () => stub402());
global.requestAnimationFrame = (cb) => setTimeout(() => cb(Date.now()), 0);
+ // The real-funds risk acknowledgment gates the pay flow before any
+ // signing/balance work. Its module import falls back to confirm() under
+ // jsdom; accept it so the flow under test (modal states) is reachable.
+ // The gate itself is covered by its own suite.
+ vi.stubGlobal('confirm', vi.fn(() => true));
});
afterEach(() => {
diff --git a/tests/pump-live-stream.test.js b/tests/pump-live-stream.test.js
index 208c8d92d..2310f75de 100644
--- a/tests/pump-live-stream.test.js
+++ b/tests/pump-live-stream.test.js
@@ -13,7 +13,7 @@ vi.mock('../api/_lib/env.js', () => ({
// Heavy Solana SDK imports not needed for this handler — stub them out.
vi.mock('../api/_lib/pump.js', () => ({}));
-vi.mock('../api/_lib/db.js', () => ({ sql: vi.fn() }));
+vi.mock('../api/_lib/db.js', () => ({ sql: vi.fn(), isDbUnavailableError: () => false, isDbCapacityError: () => false }));
vi.mock('../api/_lib/auth.js', () => ({
getSessionUser: vi.fn(async () => null),
authenticateBearer: vi.fn(async () => null),
diff --git a/tests/pumpfun-signals.test.js b/tests/pumpfun-signals.test.js
index af9fec501..39041a04b 100644
--- a/tests/pumpfun-signals.test.js
+++ b/tests/pumpfun-signals.test.js
@@ -14,7 +14,7 @@ const h = vi.hoisted(() => ({
state: { botEnabled: true },
}));
-vi.mock('../api/_lib/db.js', () => ({ sql: (...a) => h.sql(...a) }));
+vi.mock('../api/_lib/db.js', () => ({ sql: (...a) => h.sql(...a), isDbUnavailableError: () => false, isDbCapacityError: () => false }));
vi.mock('../api/_lib/pumpfun-mcp.js', () => ({
pumpfunMcp: {
recentClaims: (...a) => h.recentClaims(...a),
diff --git a/tests/pumpfun-ws-feed.test.js b/tests/pumpfun-ws-feed.test.js
index 8c9c0e9a9..ff595f944 100644
--- a/tests/pumpfun-ws-feed.test.js
+++ b/tests/pumpfun-ws-feed.test.js
@@ -11,7 +11,7 @@ import { describe, it, expect, vi, beforeEach, afterEach } from 'vitest';
const sqlCalls = [];
const sqlMock = vi.fn(async (...a) => { sqlCalls.push(a); return []; });
-vi.mock('../api/_lib/db.js', () => ({ sql: sqlMock }));
+vi.mock('../api/_lib/db.js', () => ({ sql: sqlMock, isDbUnavailableError: () => false, isDbCapacityError: () => false }));
vi.mock('../api/_lib/env.js', () => ({
env: { DATABASE_URL: 'postgres://test', APP_ORIGIN: 'http://test' },
diff --git a/tests/pumpfun-ws-trades.test.js b/tests/pumpfun-ws-trades.test.js
index f12b2d46d..08ae0fbae 100644
--- a/tests/pumpfun-ws-trades.test.js
+++ b/tests/pumpfun-ws-trades.test.js
@@ -23,7 +23,7 @@ class FakeWS {
FakeWS.instances = [];
vi.mock('ws', () => ({ default: FakeWS }));
-vi.mock('../api/_lib/db.js', () => ({ sql: vi.fn(async () => []) }));
+vi.mock('../api/_lib/db.js', () => ({ sql: vi.fn(async () => []), isDbUnavailableError: () => false, isDbCapacityError: () => false }));
vi.mock('../api/_lib/env.js', () => ({
env: { DATABASE_URL: 'postgres://test', APP_ORIGIN: 'http://test' },
}));
diff --git a/tests/reasoning-ledger.test.js b/tests/reasoning-ledger.test.js
index ef3ad32ff..54533a874 100644
--- a/tests/reasoning-ledger.test.js
+++ b/tests/reasoning-ledger.test.js
@@ -65,7 +65,7 @@ const h = vi.hoisted(() => {
return { store, fakeSql };
});
-vi.mock('../api/_lib/db.js', () => ({ sql: h.fakeSql, sqlValues: () => {} }));
+vi.mock('../api/_lib/db.js', () => ({ sql: h.fakeSql, sqlValues: () => {}, isDbUnavailableError: () => false, isDbCapacityError: () => false }));
import {
genesisHash, canonicalizeEntry, computeEntryHash, buildChain, verifyChain,
diff --git a/tests/rewards-ledger.test.js b/tests/rewards-ledger.test.js
index 55250b503..c5271589e 100644
--- a/tests/rewards-ledger.test.js
+++ b/tests/rewards-ledger.test.js
@@ -8,7 +8,7 @@ import { describe, it, expect, vi, beforeEach } from 'vitest';
const queue = [];
vi.mock('../api/_lib/db.js', () => {
const sql = vi.fn(async () => (queue.length ? queue.shift() : []));
- return { sql };
+ return { sql, isDbUnavailableError: () => false, isDbCapacityError: () => false };
});
// payments.js also imports these; stub so the module loads without a live RPC.
vi.mock('../api/_lib/solana/connection.js', () => ({ solanaConnection: vi.fn() }));
diff --git a/tests/seed-skills.test.mjs b/tests/seed-skills.test.mjs
index 23e33bae7..9735323dd 100644
--- a/tests/seed-skills.test.mjs
+++ b/tests/seed-skills.test.mjs
@@ -6,6 +6,8 @@ vi.mock('../api/_lib/db.js', () => ({
json: (v) => v,
end: vi.fn(async () => {}),
}),
+ isDbUnavailableError: () => false,
+ isDbCapacityError: () => false,
}));
// Paths are relative to this file (tests/), so ../src/ → src/ at repo root.
diff --git a/tests/sniper-safety-guards.test.js b/tests/sniper-safety-guards.test.js
index 167bc9024..ec7240440 100644
--- a/tests/sniper-safety-guards.test.js
+++ b/tests/sniper-safety-guards.test.js
@@ -16,7 +16,7 @@ vi.mock('../api/_lib/db.js', () => {
}
return Promise.resolve([]);
};
- return { sql, LAMPORTS_PER_SOL: 1_000_000_000 };
+ return { sql, LAMPORTS_PER_SOL: 1_000_000_000, isDbUnavailableError: () => false, isDbCapacityError: () => false };
});
import { parseAgentIds } from '../workers/agent-sniper/config.js';
diff --git a/tests/solana-trade-guards.test.js b/tests/solana-trade-guards.test.js
index 8bf555f4b..b4774a68e 100644
--- a/tests/solana-trade-guards.test.js
+++ b/tests/solana-trade-guards.test.js
@@ -23,6 +23,8 @@ vi.mock('../api/_lib/db.js', () => ({
if (/sum\(usd\)/.test(q)) return [{ usd: 0 }];
return [];
}),
+ isDbUnavailableError: () => false,
+ isDbCapacityError: () => false,
}));
const authState = { session: { id: 'owner-1' } };
diff --git a/tests/token-layer.test.js b/tests/token-layer.test.js
index 471901d2e..270791041 100644
--- a/tests/token-layer.test.js
+++ b/tests/token-layer.test.js
@@ -19,7 +19,7 @@ vi.mock('../api/_lib/db.js', () => {
const queue = [];
const sql = vi.fn(async () => (queue.length ? queue.shift() : []));
sql.__queue = queue;
- return { sql };
+ return { sql, isDbUnavailableError: () => false, isDbCapacityError: () => false };
});
// Module-level variable controlled per test so the Connection mock (a real
diff --git a/tests/trading-experiment-e2e.test.js b/tests/trading-experiment-e2e.test.js
index e07a73b4a..3e61c690f 100644
--- a/tests/trading-experiment-e2e.test.js
+++ b/tests/trading-experiment-e2e.test.js
@@ -34,11 +34,17 @@ describe('entry gate — 10k–100k mcap, socials, no serial launchers', () => {
it('ACCEPTS a $50k mint with socials', () => {
expect(scoreMint(goodMint(), STRAT).pass).toBe(true);
});
+ // The mcap-band reasons carry the observed value for the decision journal
+ // (e.g. "mc_below_min:5000<10000") — assert on the reason code, not the payload.
it('REJECTS below $10k (mc_below_min)', () => {
- expect(scoreMint(goodMint({ market_cap_usd: 5_000 }), STRAT).reasons).toContain('mc_below_min');
+ expect(scoreMint(goodMint({ market_cap_usd: 5_000 }), STRAT).reasons).toContainEqual(
+ expect.stringMatching(/^mc_below_min\b/),
+ );
});
it('REJECTS above $100k (mc_above_max)', () => {
- expect(scoreMint(goodMint({ market_cap_usd: 150_000 }), STRAT).reasons).toContain('mc_above_max');
+ expect(scoreMint(goodMint({ market_cap_usd: 150_000 }), STRAT).reasons).toContainEqual(
+ expect.stringMatching(/^mc_above_max\b/),
+ );
});
it('REJECTS a no-socials launch', () => {
expect(scoreMint(goodMint({ twitter: null }), STRAT).reasons).toContain('no_socials');
diff --git a/tests/treasury-autopilot.test.js b/tests/treasury-autopilot.test.js
index aa2846954..2b3dedf14 100644
--- a/tests/treasury-autopilot.test.js
+++ b/tests/treasury-autopilot.test.js
@@ -23,6 +23,8 @@ vi.mock('../api/_lib/db.js', () => ({
sqlState.calls.push({ query: strings.join('?'), values });
return sqlState.queue.length ? sqlState.queue.shift() : [];
}),
+ isDbUnavailableError: () => false,
+ isDbCapacityError: () => false,
}));
const walletState = { price: 150, balances: { sol: 0, usdc: 0 }, priceThrows: false };
diff --git a/tests/usage-direct-insert-timeout.test.js b/tests/usage-direct-insert-timeout.test.js
index b9bfa8a21..0c6a4485d 100644
--- a/tests/usage-direct-insert-timeout.test.js
+++ b/tests/usage-direct-insert-timeout.test.js
@@ -19,6 +19,8 @@ vi.mock('../api/_lib/qstash.js', () => ({
// (the failure mode db-retry's deadline exists to abandon).
vi.mock('../api/_lib/db.js', () => ({
sql: () => new Promise(() => {}),
+ isDbUnavailableError: () => false,
+ isDbCapacityError: () => false,
}));
import { recordEvent } from '../api/_lib/usage.js';
diff --git a/tests/walk-gestures.test.js b/tests/walk-gestures.test.js
index 215705e0c..d893faf18 100644
--- a/tests/walk-gestures.test.js
+++ b/tests/walk-gestures.test.js
@@ -26,22 +26,22 @@ describe('walk-gestures — clip availability', () => {
}
});
- it('loop gestures are the held ones (dance, sit, talking)', () => {
+ it('loop gestures are the held ones (dance, jog, sit, talking)', () => {
const looping = GESTURE_NAMES.filter((n) => GESTURES[n].loop);
- expect(looping.sort()).toEqual(['dance', 'sit', 'talking']);
+ expect(looping.sort()).toEqual(['dance', 'jog', 'sit', 'talking']);
});
- it('full-body gestures (sit, dance) take over the base layer; the rest overlay', () => {
+ it('full-body gestures (celebrate, dance, jog, shrug, sit) take over the base layer; the rest overlay', () => {
const full = GESTURE_NAMES.filter((n) => GESTURES[n].layer === 'full');
- expect(full.sort()).toEqual(['dance', 'sit']);
+ expect(full.sort()).toEqual(['celebrate', 'dance', 'jog', 'shrug', 'sit']);
const upper = GESTURE_NAMES.filter((n) => GESTURES[n].layer === 'upper');
- expect(upper).toEqual(['wave', 'point', 'cheer', 'agree', 'disagree', 'talking']);
+ expect(upper).toEqual(['wave', 'point', 'cheer', 'agree', 'disagree', 'talking', 'nod']);
});
});
describe('walk-gestures — wheel order', () => {
- it('GESTURE_ORDER lists all eight gestures exactly once', () => {
- expect(GESTURE_ORDER.length).toBe(8);
+ it('GESTURE_ORDER lists every gesture exactly once (first eight = quick keys 1–8)', () => {
+ expect(GESTURE_ORDER.length).toBe(GESTURE_NAMES.length);
expect([...GESTURE_ORDER].sort()).toEqual([...GESTURE_NAMES].sort());
});
diff --git a/tests/wallet-anomaly-guard.test.js b/tests/wallet-anomaly-guard.test.js
index 17f1ca8f6..a25d0fd72 100644
--- a/tests/wallet-anomaly-guard.test.js
+++ b/tests/wallet-anomaly-guard.test.js
@@ -27,6 +27,8 @@ vi.mock('../api/_lib/db.js', () => ({
if (q.includes('INSERT INTO agent_anomaly_events')) return [{ id: '99' }];
return [];
}),
+ isDbUnavailableError: () => false,
+ isDbCapacityError: () => false,
}));
const notifySpy = vi.fn(() => ({ id: 'n1' }));
diff --git a/tests/wallet-capabilities.test.js b/tests/wallet-capabilities.test.js
index a88a5b0ed..2b295a062 100644
--- a/tests/wallet-capabilities.test.js
+++ b/tests/wallet-capabilities.test.js
@@ -21,7 +21,7 @@ import { describe, it, expect, beforeAll, vi } from 'vitest';
// No DB is touched by the predicates under test; mock it so the import chain never
// reaches for a real connection.
-vi.mock('../api/_lib/db.js', () => ({ sql: vi.fn(async () => []) }));
+vi.mock('../api/_lib/db.js', () => ({ sql: vi.fn(async () => []), isDbUnavailableError: () => false, isDbCapacityError: () => false }));
import {
normalizeCapabilityInput, signGrant, verifyGrant, canonicalScope,
diff --git a/tests/wallet-intents.test.js b/tests/wallet-intents.test.js
index 58352c560..af180db39 100644
--- a/tests/wallet-intents.test.js
+++ b/tests/wallet-intents.test.js
@@ -18,7 +18,7 @@ import { describe, it, expect, vi } from 'vitest';
const THREE = 'FeMbDoX7R1Psc4GEcvJdsbNbZA3bfztcyDCatJVJpump';
const ADDR = '7xKXtg2CW87d97TXJSDpbD5jBkheTqA83TZRuJosgAsU';
-vi.mock('../api/_lib/db.js', () => ({ sql: vi.fn(async () => []) }));
+vi.mock('../api/_lib/db.js', () => ({ sql: vi.fn(async () => []), isDbUnavailableError: () => false, isDbCapacityError: () => false }));
vi.mock('../api/_lib/avatar-wallet.js', () => ({
solUsdPrice: vi.fn(async () => 150), sendSol: vi.fn(async () => 'sig'), explorerTxUrl: vi.fn(() => 'https://x'),
}));
diff --git a/tests/x402-audit-buffer.test.js b/tests/x402-audit-buffer.test.js
index 4b56ccf67..a9e694124 100644
--- a/tests/x402-audit-buffer.test.js
+++ b/tests/x402-audit-buffer.test.js
@@ -33,7 +33,7 @@ vi.mock('../api/_lib/redis.js', () => ({
getRedis: () => fakeRedis,
isRedisAuthError: () => false,
}));
-vi.mock('../api/_lib/db.js', () => ({ sql: (...args) => sqlImpl(...args) }));
+vi.mock('../api/_lib/db.js', () => ({ sql: (...args) => sqlImpl(...args), isDbUnavailableError: () => false, isDbCapacityError: () => false }));
// Pass-through retry wrapper so the direct-insert path actually calls sql.
vi.mock('../api/_lib/db-retry.js', () => ({ withDbRetry: (run) => run() }));
diff --git a/tests/x402-charity-split-audit.run.test.js b/tests/x402-charity-split-audit.run.test.js
index c59397032..ad43f274f 100644
--- a/tests/x402-charity-split-audit.run.test.js
+++ b/tests/x402-charity-split-audit.run.test.js
@@ -56,7 +56,7 @@ function fakeSql(strings, ...vals) {
}
return Promise.resolve([]); // CREATE TABLE / ALTER / INDEX
}
-vi.mock('../api/_lib/db.js', () => ({ sql: (s, ...v) => fakeSql(s, ...v) }));
+vi.mock('../api/_lib/db.js', () => ({ sql: (s, ...v) => fakeSql(s, ...v), isDbUnavailableError: () => false, isDbCapacityError: () => false }));
// ── Mock checkout + dance-tip endpoints ──────────────────────────────────────
function solanaAccept() {
diff --git a/tests/x402-ring-leak-classify.test.js b/tests/x402-ring-leak-classify.test.js
index 657c54afe..cde366bdd 100644
--- a/tests/x402-ring-leak-classify.test.js
+++ b/tests/x402-ring-leak-classify.test.js
@@ -21,6 +21,8 @@ vi.mock('../api/_lib/db.js', () => ({
sqlCalls.push({ text: strings.join('?'), values });
return sqlQueue.length ? sqlQueue.shift() : [];
}),
+ isDbUnavailableError: () => false,
+ isDbCapacityError: () => false,
}));
vi.mock('../api/_lib/alerts.js', () => ({ sendOpsAlert: vi.fn(async () => {}) }));
diff --git a/tests/x402-thumbnail-regen.test.js b/tests/x402-thumbnail-regen.test.js
index d42220770..6bc400765 100644
--- a/tests/x402-thumbnail-regen.test.js
+++ b/tests/x402-thumbnail-regen.test.js
@@ -29,7 +29,7 @@ vi.mock('../api/_lib/db.js', () => {
}
return [];
});
- return { sql };
+ return { sql, isDbUnavailableError: () => false, isDbCapacityError: () => false };
});
// ── mock payment client ─────────────────────────────────────────────────────