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.

fix(launcher): quality-gate live launches, novelty guard, and a working cultural radar

fudjia7d5f6473a8cd
diff --git a/api/_lib/launcher-engine.js b/api/_lib/launcher-engine.js
index 63ae0e38a..96d144a3a 100644
--- a/api/_lib/launcher-engine.js
+++ b/api/_lib/launcher-engine.js
@@ -55,6 +55,15 @@ const FAIL_BREAK = 5;
// skip (operator tops up the master), never a breaker trip.
const MASTER_FEE_BUFFER_SOL = 0.01;
+// Floor on how often a dry_run scope re-picks. Each pick costs an LLM call and
+// launches nothing; at the old 60s cadence the dry-run scopes alone demanded
+// ~6× Groq's entire 100k-token/day free tier, starving the REAL launches into
+// wordlist fallback. Hourly previews cost ~1% of that. Also: how far back the
+// novelty guard remembers picks so the meme lane can't converge on one joke.
+const DRY_RUN_MIN_CADENCE_S = 3600;
+const NOVELTY_LOOKBACK_DAYS = 14;
+const NOVELTY_LIMIT = 60;
+
// FUNDING MODEL PER SCOPE. Global: the platform master wallet tops the next agent
// up per launch (launcher-funding.js). User: SELF-FUNDED — the user's own agent
// wallet pays its launch (base cost + dev buy) from SOL the user deposited to it;
@@ -385,17 +394,28 @@ async function runScopeTick(cfg) {
const userFilter = cfg.scope === 'user' ? sql`and user_id = ${cfg.user_id}` : sql``;
- // Cadence gate — only one launch attempt per target_cadence_seconds.
+ // Cadence gate — only one launch attempt per target_cadence_seconds. Two
+ // deliberate extras:
+ // · dry_run cadence is floored: a preview scope re-picking every 60s burned
+ // ~5.8k LLM calls/week on runs nobody launches, exhausting the free-LLM
+ // quota the REAL picks need. 15 min keeps the preview fresh at ~1% of the
+ // cost.
+ // · quality-gate skips count as attempts: when the LLM lane is down, retrying
+ // every tick is the same quota burn in a tighter loop — wait a cadence out.
+ const cadenceS = cfg.dry_run
+ ? Math.max(cfg.target_cadence_seconds, DRY_RUN_MIN_CADENCE_S)
+ : cfg.target_cadence_seconds;
const [last] = await sql`
select created_at from launcher_runs
where scope = ${cfg.scope} ${userFilter}
- and status in ('dry_run', 'funded', 'launched', 'confirmed')
+ and (status in ('dry_run', 'funded', 'launched', 'confirmed')
+ or (status = 'skipped' and error like 'quality gate%'))
order by created_at desc limit 1
`;
if (last) {
const elapsed = (Date.now() - new Date(last.created_at).getTime()) / 1000;
- if (elapsed < cfg.target_cadence_seconds) {
- return { scope: cfg.scope, skipped: `cadence (${Math.round(elapsed)}s/${cfg.target_cadence_seconds}s)` };
+ if (elapsed < cadenceS) {
+ return { scope: cfg.scope, skipped: `cadence (${Math.round(elapsed)}s/${cadenceS}s)` };
}
}
@@ -427,13 +447,35 @@ async function runScopeTick(cfg) {
if (!agent) return { scope: cfg.scope, skipped: 'no eligible agent this tick' };
// Decide WHAT to launch — narrative-driven (launcher-trends via pickSource).
+ // The recent pick history rides along so the LLM can't re-mint an identity
+ // it already used (the KEKWZ-189-times failure mode).
+ const recentPicks = await sql`
+ select symbol, name from launcher_runs
+ where created_at > now() - make_interval(days => ${NOVELTY_LOOKBACK_DAYS})
+ and symbol is not null
+ group by symbol, name
+ order by max(created_at) desc
+ limit ${NOVELTY_LIMIT}
+ `;
const coin = await pickSource({
mode: cfg.mode,
network: cfg.network,
categories: Array.isArray(cfg.categories) ? cfg.categories : [],
sources: Array.isArray(cfg.sources) ? cfg.sources : undefined,
+ avoid: recentPicks,
});
+ // Quality gate for LIVE scopes: a degraded pick means the LLM lane failed and
+ // pickSource fell back to wordlist filler. Dry runs may record it (it shows
+ // the operator the lane is degraded), but real SOL never mints "Neon Walrus" —
+ // unless the operator explicitly chose mode 'random'.
+ if (!cfg.dry_run && cfg.mode !== 'random' && (coin.degraded || coin.kind === 'random')) {
+ const reason = `quality gate: ${coin.degraded || 'random filler'} — no narrative-backed pick this tick`;
+ const gateRunId = await insertRun(cfg, coin, agent);
+ await setRun(gateRunId, { status: 'skipped', error: reason });
+ return { scope: cfg.scope, skipped: reason };
+ }
+
const runId = await insertRun(cfg, coin, agent);
// Dry run: chose a coin + agent, recorded it, moved nothing.
diff --git a/api/_lib/launcher-sources.js b/api/_lib/launcher-sources.js
index 5fa5a3b7a..b44c28b5d 100644
--- a/api/_lib/launcher-sources.js
+++ b/api/_lib/launcher-sources.js
@@ -115,7 +115,8 @@ const SYNTH_SYSTEM =
'(1) Never copy, reference, or imitate the name or ticker of any existing real ' +
'cryptocurrency or token — riff on the CULTURE, invent a fresh identity. ' +
'(2) name ≤ 32 chars; symbol 3-8 uppercase letters/digits, no spaces, instantly ' +
- 'readable and tickerable. (3) Playful, internet-native, culturally sharp — never ' +
+ 'readable and tickerable, and an OBVIOUS contraction of the name (a trader who ' +
+ 'sees only the ticker should guess the name). (3) Playful, internet-native, culturally sharp — never ' +
'offensive, hateful, or referencing real tragedies/victims. ' +
'(4) The description is one punchy line that makes the meme legible at a glance. ' +
'Respond with STRICT JSON only: {"name":"","symbol":"","description":""}.';
@@ -127,23 +128,48 @@ function parseCoinJson(text) {
try {
const o = JSON.parse(m[0]);
if (!o || typeof o !== 'object' || !o.name || !o.symbol) return null;
+ // Descriptions get their own hygiene — sanitizeName caps at the 32-char
+ // pump.fun NAME limit and was truncating every description mid-word.
+ const description = String(o.description || '').replace(/\s+/g, ' ').trim().slice(0, 180);
return {
name: sanitizeName(o.name),
symbol: sanitizeSymbol(o.symbol),
- description: sanitizeName(String(o.description || '')).slice(0, 180) || `${sanitizeName(o.name)} on three.ws`,
+ description: description || `${sanitizeName(o.name)} on three.ws`,
};
} catch {
return null;
}
}
+// Normalise a name/symbol for repeat detection: case- and punctuation-blind.
+function noveltyKey(s) {
+ return String(s || '').toUpperCase().replace(/[^A-Z0-9]/g, '');
+}
+
+/**
+ * True when the coin repeats an identity in the avoid list (same symbol or same
+ * normalised name). This is what stopped the meme lane re-minting "KEKWZ" 189
+ * times in a week: without memory of its own picks the model converges on the
+ * same joke every tick.
+ * @param {{name:string, symbol:string}} coin
+ * @param {Array<{name?:string, symbol?:string}>} avoid
+ */
+export function isRepeatPick(coin, avoid = []) {
+ if (!avoid.length) return false;
+ const sym = noveltyKey(coin.symbol);
+ const name = noveltyKey(coin.name);
+ return avoid.some((a) => (a.symbol && noveltyKey(a.symbol) === sym) || (a.name && noveltyKey(a.name) === name));
+}
+
/**
* Ask the LLM to coin an original token, riding the ranked live narratives when
- * supplied. Degrades to randomCoin() on any LLM failure — never throws, never
- * blocks a tick.
- * @param {{narratives?:Array<{term:string,score:number,sources:string[],kind:string}>, themes?:string[], flavor?:'trend'|'meme', triggerSource?:string}} opts
+ * supplied. `avoid` (recent picks) is fed into the prompt and enforced after
+ * parsing — a repeat gets ONE retry with the collision named, then degrades.
+ * Degrades to randomCoin() on any LLM failure — never throws, never blocks a
+ * tick. Callers that must not ship filler check `.degraded` on the result.
+ * @param {{narratives?:Array<{term:string,score:number,sources:string[],kind:string}>, themes?:string[], flavor?:'trend'|'meme', triggerSource?:string, avoid?:Array<{name?:string, symbol?:string}>}} opts
*/
-export async function synthesizeCoin({ narratives = [], themes = [], flavor = 'meme', triggerSource } = {}) {
+export async function synthesizeCoin({ narratives = [], themes = [], flavor = 'meme', triggerSource, avoid = [] } = {}) {
if (!llmConfigured()) return { ...randomCoin(), degraded: 'llm_unconfigured' };
// Prefer the ranked narratives (momentum + confirming sources) so the model
@@ -167,16 +193,30 @@ export async function synthesizeCoin({ narratives = [], themes = [], flavor = 'm
} else {
userPrompt = 'Coin ONE original, funny, internet-native memecoin from current meme culture. Make the ticker instantly memeable.';
}
+ const avoidTickers = [...new Set(avoid.map((a) => sanitizeSymbol(a.symbol || '')).filter((s) => s && s !== 'THREE3'))].slice(0, 40);
+ if (avoidTickers.length) {
+ userPrompt += `\n\nAlready launched recently — your pick must not reuse or resemble any of these tickers: ${avoidTickers.join(', ')}.`;
+ }
+
+ const attempt = async (prompt) => {
+ const out = await llmComplete({ system: SYNTH_SYSTEM, user: prompt, maxTokens: 220, timeoutMs: 12_000 });
+ return parseCoinJson(out?.text);
+ };
- let out;
+ let coin;
try {
- out = await llmComplete({ system: SYNTH_SYSTEM, user: userPrompt, maxTokens: 220, timeoutMs: 12_000 });
+ coin = await attempt(userPrompt);
+ if (coin && isRepeatPick(coin, avoid)) {
+ coin = await attempt(
+ `${userPrompt}\n\nYou already minted "${coin.name}" (${coin.symbol}). Pick a DIFFERENT current or a genuinely different angle — a fresh name and ticker.`,
+ );
+ }
} catch {
return { ...randomCoin(), degraded: 'llm_error' };
}
- const coin = parseCoinJson(out?.text);
if (!coin) return { ...randomCoin(), degraded: 'llm_unparseable' };
+ if (isRepeatPick(coin, avoid)) return { ...randomCoin(), degraded: 'repeat_pick' };
return {
kind: flavor === 'trend' ? 'trend' : 'meme',
@@ -193,29 +233,47 @@ export async function synthesizeCoin({ narratives = [], themes = [], flavor = 'm
};
}
+// Weighted-sample one of the strongest currents to LEAD the prompt. The model
+// anchors hard on whichever narrative is named first, so always sending the #1
+// term made every launch of the day ride the same theme; rotating the lead
+// across the top of the ranking gives a slate variety while staying on-signal.
+function rotateLead(narratives) {
+ if (narratives.length <= 1) return narratives;
+ const top = narratives.slice(0, 6);
+ const total = top.reduce((sum, n) => sum + Math.max(0.1, n.score), 0);
+ let roll = Math.random() * total;
+ let lead = top[top.length - 1];
+ for (const n of top) {
+ roll -= Math.max(0.1, n.score);
+ if (roll <= 0) { lead = n; break; }
+ }
+ return [lead, ...narratives.filter((n) => n !== lead)];
+}
+
// ── dispatcher ────────────────────────────────────────────────────────────────
/**
* Choose a coin for a tick given the configured mode. Hybrid prefers a live
* trend, falls back to a meme, and injects random filler when no signal exists.
* `sources` selects which narrative providers feed trend/hybrid mode (see
- * launcher-trends.js); empty ⇒ the default internal set.
- * @param {{mode:string, network?:string, categories?:string[], sources?:string[]}} cfg
+ * launcher-trends.js); empty ⇒ the default internal set. `avoid` is the recent
+ * pick history the LLM must not repeat (see synthesizeCoin).
+ * @param {{mode:string, network?:string, categories?:string[], sources?:string[], avoid?:Array<{name?:string, symbol?:string}>}} cfg
*/
-export async function pickSource({ mode, network = 'mainnet', categories = [], sources } = {}) {
+export async function pickSource({ mode, network = 'mainnet', categories = [], sources, avoid = [] } = {}) {
if (mode === 'random') return randomCoin();
- if (mode === 'meme') return synthesizeCoin({ flavor: 'meme' });
+ if (mode === 'meme') return synthesizeCoin({ flavor: 'meme', avoid });
if (mode === 'trend') {
const narratives = await gatherNarratives({ network, categories, sources });
- if (narratives.length >= 2) return synthesizeCoin({ narratives, flavor: 'trend' });
+ if (narratives.length >= 2) return synthesizeCoin({ narratives: rotateLead(narratives), flavor: 'trend', avoid });
// No live trend → still honour 'trend' intent with a meme rather than stall.
- return synthesizeCoin({ flavor: 'meme', triggerSource: 'trend-fallback' });
+ return synthesizeCoin({ flavor: 'meme', triggerSource: 'trend-fallback', avoid });
}
// hybrid (default): trend first, meme second, occasional random filler.
const narratives = await gatherNarratives({ network, categories, sources });
- if (narratives.length >= 2) return synthesizeCoin({ narratives, flavor: 'trend' });
- if (Math.random() < 0.5) return synthesizeCoin({ flavor: 'meme', triggerSource: 'hybrid' });
+ if (narratives.length >= 2) return synthesizeCoin({ narratives: rotateLead(narratives), flavor: 'trend', avoid });
+ if (Math.random() < 0.5) return synthesizeCoin({ flavor: 'meme', triggerSource: 'hybrid', avoid });
return randomCoin();
}
diff --git a/api/_lib/launcher-trends.js b/api/_lib/launcher-trends.js
index 362fba2fe..bf55e81a3 100644
--- a/api/_lib/launcher-trends.js
+++ b/api/_lib/launcher-trends.js
@@ -245,21 +245,29 @@ async function cached(key, ttl, fn) {
async function coinIntelSignals({ network, categories }) {
const out = [];
try {
+ // Gate on the venue's OBSERVED score distribution, not an absolute bar:
+ // pump.fun intel scores cluster in the single digits (24h avg ~7, p90 ~4,
+ // max ~45), so the old >= 55 threshold silenced this provider entirely.
+ // A modest junk floor + top-N by score keeps it live on quiet days and
+ // selective on hot ones.
const rows = await sql`
select category, tags, narrative, quality_score
from pump_coin_intel
where network = ${network}
and first_seen_at > now() - interval '24 hours'
- and quality_score is not null and quality_score >= 55
+ and quality_score is not null and quality_score >= 12
${categories?.length ? sql`and category = any(${categories})` : sql``}
order by quality_score desc nulls last
limit 60
`;
for (const r of rows) {
const q = Math.max(0.4, Math.min(1.4, Number(r.quality_score || 55) / 70));
+ // Categories are generic sector words ('meme', 'animal') repeated on most
+ // rows — useful direction, terrible coin themes. Emit them faint so the
+ // specific tags/narratives always outrank them.
if (r.category && r.category !== 'unknown') {
const n = normTerm(r.category);
- if (n) out.push({ term: n.toLowerCase(), weight: q * 1.2, kind: 'category' });
+ if (n) out.push({ term: n.toLowerCase(), weight: q * 0.4, kind: 'category' });
}
if (Array.isArray(r.tags)) {
for (const t of r.tags.slice(0, 5)) {
@@ -536,12 +544,23 @@ export async function rankNarratives({ network = 'mainnet', sources, categories
/** @type {Map<string, {term:string, score:number, sources:Set<string>, kind:string, kinds:Map<string,number>}>} */
const merged = new Map();
+ // A single source may emit the same term on many rows (60 intel rows all
+ // categorised 'meme'). Cap each source's total contribution per term so raw
+ // repetition inside one channel can't drown genuinely distinct narratives —
+ // cross-SOURCE agreement (the diversity boost below) is the signal, not
+ // within-source volume.
+ const PER_SOURCE_TERM_CAP = 2;
+ const contributed = new Map();
for (const { id, rows } of settled) {
const sw = SOURCE_WEIGHT[id] ?? 1;
for (const r of rows) {
const term = String(r.term || '').trim();
if (!term) continue;
- const add = (Number(r.weight) || 0.6) * sw;
+ const ck = `${id}${term}`;
+ const already = contributed.get(ck) || 0;
+ if (already >= PER_SOURCE_TERM_CAP) continue;
+ const add = Math.min((Number(r.weight) || 0.6) * sw, PER_SOURCE_TERM_CAP - already);
+ contributed.set(ck, already + add);
const cur = merged.get(term);
if (cur) {
cur.score += add;
@@ -568,9 +587,13 @@ export async function rankNarratives({ network = 'mainnet', sources, categories
let kind = m.kind;
let best = -1;
for (const [k, w] of m.kinds) if (w > best) { best = w; kind = k; }
+ // Sector words ('meme', 'animal') are confirmed by every venue precisely
+ // because they're generic — damp them below any SPECIFIC narrative so the
+ // coiner rides "erling haaland running", never "animal".
+ const kindDamp = kind === 'category' ? 0.35 : 1;
return {
term: m.term,
- score: Number((m.score * diversity).toFixed(3)),
+ score: Number((m.score * diversity * kindDamp).toFixed(3)),
sources: [...m.sources],
kind,
};
diff --git a/tests/launcher-engine.test.js b/tests/launcher-engine.test.js
index e4335c756..c9e5b088b 100644
--- a/tests/launcher-engine.test.js
+++ b/tests/launcher-engine.test.js
@@ -58,6 +58,7 @@ vi.mock('../api/_lib/avatar-wallet.js', () => ({
import { runLauncherTick } from '../api/_lib/launcher-engine.js';
import { fundAgentForLaunch } from '../api/_lib/launcher-funding.js';
+import { pickSource } from '../api/_lib/launcher-sources.js';
function makeConfig(over = {}) {
return {
@@ -109,6 +110,31 @@ describe('runLauncherTick — dry run', () => {
expect(r.symbol).toBe('TURBOTTR');
expect(fundAgentForLaunch).not.toHaveBeenCalled(); // the safety contract
});
+
+ it('floors the dry_run cadence so previews cannot burn an LLM call per minute', async () => {
+ H.configs = [makeConfig({ dry_run: true, target_cadence_seconds: 60 })];
+ // Last dry run 5 minutes ago: past the configured 60s, inside the 900s floor.
+ H.lastRun = [{ created_at: new Date(Date.now() - 5 * 60 * 1000).toISOString() }];
+ const out = await runLauncherTick();
+ expect(out.results[0].skipped).toMatch(/cadence/);
+ expect(pickSource).not.toHaveBeenCalled();
+ });
+
+ it('does not floor the cadence for live scopes', async () => {
+ H.configs = [makeConfig({ dry_run: false, target_cadence_seconds: 60 })];
+ H.lastRun = [{ created_at: new Date(Date.now() - 5 * 60 * 1000).toISOString() }];
+ const fetchMock = vi.fn(async (url) => {
+ const u = String(url);
+ if (u.includes('action=build-metadata')) return { status: 200, json: async () => ({ metadata_url: 'ipfs://meta' }) };
+ if (u.includes('action=launch-agent')) return { status: 200, json: async () => ({ mint: 'MINTlive', signature: 'sig' }) };
+ return { status: 404, json: async () => ({}) };
+ });
+ vi.stubGlobal('fetch', fetchMock);
+
+ const out = await runLauncherTick();
+ expect(out.results[0].mint).toBe('MINTlive'); // 5 min > 60s cadence ⇒ proceeds
+ vi.unstubAllGlobals();
+ });
});
describe('runLauncherTick — live', () => {
@@ -171,6 +197,40 @@ describe('runLauncherTick — live', () => {
vi.unstubAllGlobals();
});
+ it('refuses to spend on a degraded (filler) pick in live non-random mode', async () => {
+ H.configs = [makeConfig({ dry_run: false, mode: 'hybrid' })];
+ pickSource.mockResolvedValueOnce({
+ kind: 'random', name: 'Neon Walrus', symbol: 'NEONWALR',
+ description: 'filler', trigger_source: 'random', trigger_detail: {},
+ degraded: 'llm_error',
+ });
+ const fetchMock = vi.fn();
+ vi.stubGlobal('fetch', fetchMock);
+
+ const out = await runLauncherTick();
+ expect(out.results[0].skipped).toMatch(/quality gate/);
+ expect(fundAgentForLaunch).not.toHaveBeenCalled();
+ expect(fetchMock).not.toHaveBeenCalled();
+
+ vi.unstubAllGlobals();
+ });
+
+ it('still launches wordlist coins when the operator explicitly chose mode random', async () => {
+ H.configs = [makeConfig({ dry_run: false, mode: 'random' })];
+ const fetchMock = vi.fn(async (url) => {
+ const u = String(url);
+ if (u.includes('action=build-metadata')) return { status: 200, json: async () => ({ metadata_url: 'ipfs://meta' }) };
+ if (u.includes('action=launch-agent')) return { status: 200, json: async () => ({ mint: 'MINTrand', signature: 'sig' }) };
+ return { status: 404, json: async () => ({}) };
+ });
+ vi.stubGlobal('fetch', fetchMock);
+
+ const out = await runLauncherTick();
+ expect(out.results[0].mint).toBe('MINTrand');
+
+ vi.unstubAllGlobals();
+ });
+
it('records a skip (no launch) when the master balance is too low', async () => {
H.configs = [makeConfig({ dry_run: false })];
H.masterSol = 0.001; // below per_launch + buffer
diff --git a/tests/launcher-novelty.test.js b/tests/launcher-novelty.test.js
new file mode 100644
index 000000000..6f97f7325
--- /dev/null
+++ b/tests/launcher-novelty.test.js
@@ -0,0 +1,96 @@
+import { describe, it, expect, vi, beforeEach } from 'vitest';
+
+// Mock the LLM so synthesizeCoin is deterministic and network-free.
+const H = vi.hoisted(() => ({
+ configured: true,
+ responses: /** @type {string[]} */ ([]),
+ prompts: /** @type {string[]} */ ([]),
+ fail: false,
+}));
+
+vi.mock('../api/_lib/llm.js', () => ({
+ llmConfigured: () => H.configured,
+ llmComplete: vi.fn(async ({ user }) => {
+ H.prompts.push(user);
+ if (H.fail) throw new Error('all providers exhausted');
+ return { text: H.responses.shift() ?? '{"name":"Fresh Coin","symbol":"FRESH","description":"a fresh one"}' };
+ }),
+}));
+
+// gatherNarratives pulls launcher-trends (db + cache) — not under test here.
+vi.mock('../api/_lib/launcher-trends.js', () => ({
+ rankNarratives: vi.fn(async () => ({ terms: [], themes: [], top: null, providers: [] })),
+}));
+
+import { synthesizeCoin, isRepeatPick } from '../api/_lib/launcher-sources.js';
+
+beforeEach(() => {
+ H.configured = true;
+ H.responses = [];
+ H.prompts = [];
+ H.fail = false;
+});
+
+describe('isRepeatPick', () => {
+ const avoid = [{ symbol: 'KEKWZ', name: 'LurkLord' }, { symbol: 'GLAMZ', name: 'Starlet' }];
+
+ it('matches a repeated symbol case- and punctuation-blind', () => {
+ expect(isRepeatPick({ name: 'Anything', symbol: 'kekwz' }, avoid)).toBe(true);
+ expect(isRepeatPick({ name: 'Anything', symbol: 'KEK-WZ' }, avoid)).toBe(true);
+ });
+
+ it('matches a repeated name even under a new ticker', () => {
+ expect(isRepeatPick({ name: 'Lurk Lord', symbol: 'NEWTKR' }, avoid)).toBe(true);
+ });
+
+ it('passes a genuinely new identity', () => {
+ expect(isRepeatPick({ name: 'Orbit Drip', symbol: 'ODRIP' }, avoid)).toBe(false);
+ expect(isRepeatPick({ name: 'Orbit Drip', symbol: 'ODRIP' }, [])).toBe(false);
+ });
+});
+
+describe('synthesizeCoin novelty guard', () => {
+ const avoid = [{ symbol: 'KEKWZ', name: 'LurkLord' }];
+
+ it('feeds recent tickers into the prompt so the model avoids them up front', async () => {
+ await synthesizeCoin({ flavor: 'meme', avoid });
+ expect(H.prompts[0]).toContain('KEKWZ');
+ });
+
+ it('retries once when the model repeats itself, and returns the fresh retry', async () => {
+ H.responses = [
+ '{"name":"LurkLord","symbol":"KEKWZ","description":"again"}',
+ '{"name":"Orbit Drip","symbol":"ODRIP","description":"new angle"}',
+ ];
+ const coin = await synthesizeCoin({ flavor: 'meme', avoid });
+ expect(H.prompts.length).toBe(2);
+ expect(H.prompts[1]).toMatch(/already minted "LurkLord"/);
+ expect(coin.symbol).toBe('ODRIP');
+ expect(coin.degraded).toBeUndefined();
+ });
+
+ it('degrades (never returns the repeat) when the retry repeats too', async () => {
+ H.responses = [
+ '{"name":"LurkLord","symbol":"KEKWZ","description":"again"}',
+ '{"name":"Lurk Lord","symbol":"KEKWZ","description":"still again"}',
+ ];
+ const coin = await synthesizeCoin({ flavor: 'meme', avoid });
+ expect(coin.degraded).toBe('repeat_pick');
+ expect(coin.kind).toBe('random');
+ });
+
+ it('marks LLM failure as degraded so live scopes can refuse to launch filler', async () => {
+ H.fail = true;
+ const coin = await synthesizeCoin({ flavor: 'meme', avoid });
+ expect(coin.degraded).toBe('llm_error');
+ expect(coin.kind).toBe('random');
+ });
+
+ it('keeps descriptions past 32 chars (only the NAME has the pump.fun 32 cap)', async () => {
+ const desc = 'A memecoin so long-winded its description sails right past the old truncation point.';
+ H.responses = [JSON.stringify({ name: 'Windbag', symbol: 'WNDBG', description: desc })];
+ const coin = await synthesizeCoin({ flavor: 'meme' });
+ expect(coin.description).toBe(desc);
+ expect(coin.description.length).toBeGreaterThan(32);
+ });
+});