Open-source platform for 3D AI agents. Turn text or a photo into a rigged, animated GLB avatar, give it an LLM brain, memory and a wallet, and embed it anywhere with one web component. Remote MCP server, x402 payments, Three.js, browser-native.
JavaScript 3d-generationai-agentsanimationavatardigital-humangenerative-aiglbgltfimage-to-3dllmmcpmcp-servermodel-context-protocolsolanatext-to-3dthreejsweb-componentswebglwebxrx402
fix(oracle): unblock the outcome labeler and make the training set survive retention
nirholase174fd24a1ab
diff --git a/api/_lib/migrations/20260809120000_oracle_training_set.sql b/api/_lib/migrations/20260809120000_oracle_training_set.sqlnew file mode 100644index 000000000..e2e89e2ea--- /dev/null+++ b/api/_lib/migrations/20260809120000_oracle_training_set.sql@@ -0,0 +1,53 @@+-- Oracle training set: a permanent snapshot of (launch-time features, outcome)+-- per labeled coin. pump_coin_intel and pump_coin_outcomes are firehose tables+-- pruned by db-retention on a ~14-day window, which silently deletes the ground+-- truth the Oracle learns from. This table is the durable copy: one compact row+-- per labeled coin, written at label time by the intel learner and NEVER pruned+-- (it is deliberately absent from db-retention's FIREHOSE_SATELLITES list; at+-- one small row per coin it grows ~30k rows/day, a few MB/month).+create table if not exists oracle_training_set (+ mint text not null,+ network text not null default 'mainnet',+ -- Launch-time signals exactly as pump_coin_intel.signals held them when the+ -- outcome was judged (organic_score, bundle_score, snipe_ratio,+ -- timing_entropy, concentration_*, unique_buyers, dev_buy_sol,+ -- mc_sol_first_seen, buy/sell volumes, ...).+ features jsonb not null default '{}'::jsonb,+ category text,+ -- Creator track record AS OF label time (wallet_reputation drifts later).+ creator_launches int,+ creator_wins int,+ creator_dump_rate real,+ -- Ground truth.+ outcome text not null,+ graduated boolean,+ rugged boolean,+ ath_multiple double precision,+ first_seen_at timestamptz,+ labeled_at timestamptz not null default now(),+ primary key (mint, network)+);++create index if not exists oracle_training_set_outcome_idx+ on oracle_training_set (network, outcome);+create index if not exists oracle_training_set_first_seen_idx+ on oracle_training_set (network, first_seen_at);++-- Backfill every already-labeled coin still inside the retention window before+-- the pruner reaches it. Idempotent: conflict rows are left as first written.+insert into oracle_training_set (+ mint, network, features, category,+ creator_launches, creator_wins, creator_dump_rate,+ outcome, graduated, rugged, ath_multiple, first_seen_at, labeled_at+)+select+ i.mint, i.network, coalesce(i.signals, '{}'::jsonb), i.category,+ wr.creator_count, wr.creator_wins, wr.dump_rate,+ o.outcome, o.graduated, o.rugged, o.ath_multiple, i.first_seen_at,+ coalesce(o.labeled_at, now())+from pump_coin_intel i+join pump_coin_outcomes o on o.mint = i.mint+left join wallet_reputation wr+ on wr.wallet = i.creator and wr.network = i.network+where o.outcome is not null and o.outcome <> 'unknown'+on conflict (mint, network) do nothing;diff --git a/api/cron/intel-learn.js b/api/cron/intel-learn.jsindex 824ec5b75..06b3f83cf 100644--- a/api/cron/intel-learn.js+++ b/api/cron/intel-learn.js@@ -27,8 +27,12 @@ export default wrapCron(async (req, res) => {const started = Date.now();// Label coins observed ≥ 60 min ago (enough time for a verdict to form) that- // have no outcome yet. Bounded per run; the cadence catches up over time.- const { labeled } = await labelOutcomes({ network: NETWORK, limit: 100, minAgeMinutes: 60 });+ // have no outcome yet. The budget must OUTRUN the firehose: ~30k new coins/day+ // against this cron's 96 runs/day means anything under ~350/run falls behind+ // forever (the serial 100/run era ended with an 11-day labeling blackout and a+ // 370k backlog). 1500/run ≈ 144k/day: catches up a backlog in days, then+ // idles cheaply (the query returns only unlabeled coins).+ const { labeled } = await labelOutcomes({ network: NETWORK, limit: 1500, minAgeMinutes: 60 });// Retrain once there's enough labeled history. Skips quietly below the floor.// The sample ceiling keeps the training query's memory bounded (the signalsdiff --git a/workers/agent-sniper/intel/learn.js b/workers/agent-sniper/intel/learn.jsindex 8e89bb383..8122c2604 100644--- a/workers/agent-sniper/intel/learn.js+++ b/workers/agent-sniper/intel/learn.js@@ -229,39 +229,80 @@ export function deriveOutcome(coin, mcSolFirstSeen) {return { outcome, graduated, rugged, ath_multiple, last_market_cap_usd: usdMc, ath_market_cap_usd: athUsd };}+// How many pump.fun coin lookups run at once inside labelOutcomes. The coin API+// tolerates modest parallelism fine; 8 keeps a 500-coin batch under ~30s instead+// of the serial ~8 minutes that let the labeler drown in the firehose (labels+// stopped entirely for 11 days in Aug 2026 because inflow outpaced a serial,+// 100-per-15-min loop).+const LABEL_CONCURRENCY = 8;+/*** Label coins observed ≥ minAgeMinutes ago that have no outcome yet.+ *+ * Throughput is load-bearing: the firehose adds ~30k coins/day and every one of+ * them needs a verdict for the Oracle/intel learners to have ground truth.+ * Lookups run LABEL_CONCURRENCY at a time and results land in batched upserts.+ * Each labeled coin is also snapshotted into oracle_training_set, the durable+ * (never-pruned) copy of (launch-time features, outcome) that survives the+ * db-retention window pump_coin_intel/pump_coin_outcomes live under.+ *+ * A deadline bounds the wall clock (the coin API can degrade to per-call+ * timeouts); whatever isn't reached this run is picked up by the next.+ ** @returns {Promise<{ labeled: number }>}*/-export async function labelOutcomes({ network = 'mainnet', limit = 100, minAgeMinutes = 60 } = {}) {+export async function labelOutcomes({ network = 'mainnet', limit = 100, minAgeMinutes = 60, deadlineMs = 180_000 } = {}) {const sql = await getSql();if (!sql) return { labeled: 0 };+ const startedAt = Date.now();const rows = await sql`- select i.mint, i.signals+ select i.mint, i.signals, i.category, i.first_seen_at,+ wr.creator_count, wr.creator_wins, wr.dump_ratefrom pump_coin_intel ileft join pump_coin_outcomes o on o.mint = i.mint+ left join wallet_reputation wr on wr.wallet = i.creator and wr.network = i.networkwhere i.network = ${network}and o.mint is nulland i.first_seen_at <= now() - (${minAgeMinutes} || ' minutes')::intervalorder by i.first_seen_at asc- limit ${Math.max(1, Math.min(500, limit | 0))}+ limit ${Math.max(1, Math.min(2000, limit | 0))}`;+ // Fetch pump.fun state concurrently in fixed-size waves.+ const results = [];+ for (let i = 0; i < rows.length; i += LABEL_CONCURRENCY) {+ if (Date.now() - startedAt > deadlineMs) break;+ const wave = rows.slice(i, i + LABEL_CONCURRENCY);+ const coins = await Promise.all(wave.map((row) => fetchCoin(row.mint)));+ for (let j = 0; j < wave.length; j++) {+ const row = wave[j];+ const mcSol = Number(row.signals?.mc_sol_first_seen) || 0;+ results.push({ row, o: deriveOutcome(coins[j], mcSol) });+ }+ }+let labeled = 0;- for (const row of rows) {- const mcSol = Number(row.signals?.mc_sol_first_seen) || 0;- const coin = await fetchCoin(row.mint);- const o = deriveOutcome(coin, mcSol);+ const BATCH = 50;+ for (let i = 0; i < results.length; i += BATCH) {+ const batch = results.slice(i, i + BATCH);try {await sql`insert into pump_coin_outcomes (mint, graduated, rugged, ath_market_cap_usd, ath_multiple,last_market_cap_usd, outcome- ) values (- ${row.mint}, ${o.graduated}, ${o.rugged}, ${o.ath_market_cap_usd},- ${o.ath_multiple}, ${o.last_market_cap_usd}, ${o.outcome})+ select u.mint, u.graduated, u.rugged, u.ath_market_cap_usd,+ u.ath_multiple, u.last_market_cap_usd, u.outcome+ from unnest(+ ${batch.map((b) => b.row.mint)}::text[],+ ${batch.map((b) => b.o.graduated)}::boolean[],+ ${batch.map((b) => b.o.rugged)}::boolean[],+ ${batch.map((b) => b.o.ath_market_cap_usd)}::double precision[],+ ${batch.map((b) => b.o.ath_multiple)}::double precision[],+ ${batch.map((b) => b.o.last_market_cap_usd)}::double precision[],+ ${batch.map((b) => b.o.outcome)}::text[]+ ) as u(mint, graduated, rugged, ath_market_cap_usd, ath_multiple, last_market_cap_usd, outcome)on conflict (mint) do update setgraduated = excluded.graduated, rugged = excluded.rugged,ath_market_cap_usd = excluded.ath_market_cap_usd,@@ -269,9 +310,43 @@ export async function labelOutcomes({ network = 'mainnet', limit = 100, minAgeMilast_market_cap_usd = excluded.last_market_cap_usd,outcome = excluded.outcome, labeled_at = now()`;- labeled++;+ labeled += batch.length;+ } catch (err) {+ console.warn('[coin-intel] label outcome batch failed:', err?.message);+ continue;+ }++ // Durable training snapshot: only for coins with a real verdict.+ const judged = batch.filter((b) => b.o.outcome && b.o.outcome !== 'unknown');+ if (!judged.length) continue;+ try {+ await sql`+ insert into oracle_training_set (+ mint, network, features, category,+ creator_launches, creator_wins, creator_dump_rate,+ outcome, graduated, rugged, ath_multiple, first_seen_at+ )+ select u.mint, ${network}, u.features::jsonb, u.category,+ u.creator_launches, u.creator_wins, u.creator_dump_rate,+ u.outcome, u.graduated, u.rugged, u.ath_multiple, u.first_seen_at+ from unnest(+ ${judged.map((b) => b.row.mint)}::text[],+ ${judged.map((b) => JSON.stringify(b.row.signals || {}))}::text[],+ ${judged.map((b) => b.row.category)}::text[],+ ${judged.map((b) => b.row.creator_count)}::int[],+ ${judged.map((b) => b.row.creator_wins)}::int[],+ ${judged.map((b) => b.row.dump_rate)}::real[],+ ${judged.map((b) => b.o.outcome)}::text[],+ ${judged.map((b) => b.o.graduated)}::boolean[],+ ${judged.map((b) => b.o.rugged)}::boolean[],+ ${judged.map((b) => b.o.ath_multiple)}::double precision[],+ ${judged.map((b) => b.row.first_seen_at)}::timestamptz[]+ ) as u(mint, features, category, creator_launches, creator_wins, creator_dump_rate,+ outcome, graduated, rugged, ath_multiple, first_seen_at)+ on conflict (mint, network) do nothing+ `;} catch (err) {- console.warn('[coin-intel] label outcome failed:', err?.message);+ console.warn('[coin-intel] training snapshot batch failed:', err?.message);}}return { labeled };