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
feat(oracle): open the conviction model up in a lab page
nirholas6e2a7b9ecc45
diff --git a/docs/oracle-model.md b/docs/oracle-model.mdnew file mode 100644index 000000000..0ca1e7091--- /dev/null+++ b/docs/oracle-model.md@@ -0,0 +1,415 @@+# The Oracle model, and how to run it yourself++The Oracle watches every pump.fun launch for its first ninety seconds and scores+it 0-100. This document is the whole machine: what it predicts, how it is fitted,+why its outcome labels had to be rebuilt, how a new version earns the right to+replace the live one, and how to download the weights and score launches on your+own hardware with no API key.++- **Live feed**: [/oracle](/oracle)+- **The model, rendered**: [/oracle-lab](/oracle-lab)+- **The model, raw**: [`/api/oracle/model`](/api/oracle/model)+- **npm**: `@three-ws/oracle-model`++---++## 1. What the score means++**The score line is not a percentage.** A score of 86 claims a 45% chance, not an+86% one. This trips up everyone, including us: every calibration table we+published before 2026-08-14 used `score / 100` as the prediction, which+overstated the engine's own claim by up to four times and made a working ranking+look wildly overconfident.++| Tier | Score | Claims | Observed on held-out data |+|---|---|---|---|+| Prime | 86+ | P(win) >= 45% | 46.4% (n=304) |+| Strong | 72+ | P(win) >= 25% | 39.3% (n=858) |+| Lean | 56+ | P(win) >= 12% | 23.3% (n=1,415) |+| Watch | 34+ | P(win) >= 5% | 10.4% (n=2,790) |+| Avoid | 0+ | below that | 1.8% (n=68,844) |++Those observed numbers come from 74,211 launches the model had never seen. They+are recomputed on every refit and published live at+[`/api/oracle/model?view=card`](/api/oracle/model?view=card), so the table above+can go stale but the endpoint cannot.++### Three questions, not one++Version 3 fits three heads over one shared design matrix:++| Head | Question | Base rate | Held-out AUC |+|---|---|---|---|+| `win` | Did it run, **and** is a first-sight holder still up? | 2.94% | 0.840 |+| `rug` | Is a first-sight holder down more than half? | 11.36% | 0.918 |+| `moon` | Did it run at all (graduated, or peaked 3x+)? | 9.51% | 0.892 |++The published score anchors on `win`.++That choice is the entire reason v3 exists. v2 ranked `moon`, so a coin that+spiked 3x and went to zero counted as a hit. Over the seven days to 2026-08-28,+Prime-tier coins under v2 hit that target 58.2% of the time and rugged 53.0% of+the time, with 27.8% doing both. The engine was accurate and useless: it answered+"will this move" when every reader heard "should I hold this".++### The number to watch: give-back risk++```+giveBackRisk = 1 - P(win) / P(moon)+```++Given this coin runs, how often does one like it hand the run straight back? A+launch with 80% upside and 90% give-back is not an opportunity, it is a trap, and+no single-headed score can tell the two apart. It is published on every verdict,+stored on every scored coin (`oracle_conviction.give_back_risk`), and indexed, so+the feed can be sorted by it.++---++## 2. The label problem, and why it mattered more than the model++For most of this engine's life, its outcome labels measured the price of SOL.++`deriveOutcome` decided a rug with two tests: did the coin fall to 25% or less of+its market cap at first sight, or is its market cap under $3,000.++A pump.fun bonding curve holding no real reserves is worth a fixed amount. The+launch parameters put 30 virtual SOL against 1,073,000,191 virtual tokens over a+1e9 supply:++```+30 * 1e9 / 1_073_000_191 = 27.958993 SOL+```++No coin on the curve can be worth less than that. We first see a coin inside its+opening ninety seconds, when its cap is 28-38 SOL, so **the floor is 73-99% of+the market cap at first sight** and the "fell to 25%" branch is unreachable for+almost every launch that has ever existed.++That left a hardcoded dollar threshold judging an asset with a fixed SOL price.+Measured over the ten days to 2026-08-28:++| Group | n | Under $3,000 | Minimum |+|---|---|---|---|+| labeled `rugged`, not graduated | 206,428 | 206,419 (99.996%) | $0 |+| labeled survivor, not graduated | 25,180 | 0 | exactly $3,000 |++Both groups are the same object: an empty bonding curve. 25,180 completely dead+coins were labeled survivors because SOL happened to be above roughly $107.30+when the labeler reached them. It is also why the daily rug rate sat at 90-94%+for weeks and then dropped to 55.3% on 2026-08-27, which is not a change in the+market, it is SOL crossing a line.++Everything downstream that subtracted rugs from a win rate was reading a price+feed.++### The fix++Two ratios, both taken from the **same** market-cap reading, so the SOL price+cancels out of each:++```+retained = last_market_cap_usd / ath_market_cap_usd+hold_multiple = ath_multiple * retained+```++`hold_multiple` is what a holder who bought at first sight and held would have.++```+moon = graduated OR ath_multiple >= 3+rug = NOT graduated AND hold_multiple <= 0.5+win = moon AND hold_multiple >= 1+```++Neither ratio can be moved by the price of SOL, and both backfill exactly from+columns we already stored, so the historical corpus was corrected in a single+migration with no re-fetching.++**The real rug rate is 11.4%, not 91%.** And it holds within two points across+every observation-age bucket from 60 minutes to three days, which is what a+property of the coin is supposed to do:++| Checked at | n | graduated | rug | win | moon |+|---|---|---|---|---|---|+| 60-90 min | 238,138 | 2.89% | 11.02% | 3.02% | 10.06% |+| 90-180 min | 1,215 | 2.39% | 10.45% | 2.55% | 9.22% |+| 6-24 h | 481 | 1.04% | 7.48% | 2.29% | 10.60% |+| 1-3 d | 9,228 | 1.28% | 9.27% | 1.34% | 7.49% |+| 3 d+ | 13,746 | 0.77% | 9.06% | 1.21% | 6.29% |++`label_version` marks which rule judged a row: `1` for the USD-threshold rule,+`2` for the price-independent one. **The fitter trains on version 2 only.**+Mixing them poisons two heads out of three; trained on version 1 labels, the+survival head scored an AUC of 0.484, which is worse than guessing.++There is one thing the old rule got right that the new one deliberately drops: a+coin that never moved and now sits at the empty curve is a **dud**, not a rug.+Nobody was taken, because there was nothing to take. `at_floor` records that+state exactly (the curve is within 2% of `27.958993 SOL`) and is published+separately rather than folded into the rug flag.++---++## 3. How the model is fitted++One bucketed logistic regression per head, over a shared one-hot design matrix.+Not a black box: **every weight is a per-bucket log-odds contribution published+with its sample size and the observed outcome rate behind it.**++Buckets rather than slopes, because several signals are genuinely non-monotone.+Mid-range snipe ratios and mid-range top-10 concentration both beat their own+extremes, and a linear term would fight the data at both ends. "Low+concentration" ninety seconds in usually means nobody bought.++```+score = anchors(sigmoid(intercept + sum of one bucket weight per feature))+```++The code is [`api/_lib/oracle/fit.js`](https://github.com/nirholas/three.ws/blob/main/api/_lib/oracle/fit.js),+shared by the CLI and the production cron so the terminal and the server can+never disagree about what "the model" means.++### Features drop themselves++Any feature whose runner-up bucket holds fewer than 200 rows carries no fittable+information and is dropped, by name, into the report.++Deliberately **not** a share test. `smart_money_count` is non-zero on 0.3% of+launches, and those launches win 82% of the time against a 4.55% base. A rule+that dropped rare signals would throw away the strongest thing this dataset+knows.++Two features are dropped today, and the reason is an outage rather than a+property of the market:++| Dropped | Why |+|---|---|+| `fresh_wallet_ratio` | null in 300,000 of 300,000 recent rows: nothing populates `observation.walletMeta` |+| `bubblemap_connectivity` | needs `HELIUS_API_KEY`, which is not set; 42 of 713,908 recent wallets resolve a funder |++They are named on [/oracle-lab](/oracle-lab) and in the API response instead of+silently vanishing, because a signal that stopped arriving is an outage somewhere+upstream and the model is the first place it becomes visible. **If they start+arriving, the next refit picks them up with no code change.**++A third, `coordination_score`, is kept but is close to worthless: it computes as+`bundle_score * 0.6 + (bubblemap ?? 0) * 0.4`, and with bubblemap null it is a+scaled copy of `bundle_score`. The live intel weights list the two as identical+to four decimal places.++### Smart money is fitted now, not assumed++v2 added between +0.35 and +0.75 log-odds by hand when proven wallets showed up,+because "214 proven wallets platform-wide" was too thin to fit. It is not thin+any more:++| Proven wallets in the window | n | win | rug | run |+|---|---|---|---|---|+| 0 | 296,111 | 2.85% | 11.38% | 9.29% |+| 1 | 347 | 25.65% | 2.59% | 95.39% |+| 2-3 | 351 | **54.99%** | **0.00%** | 98.86% |+| 4+ | 34 | 11.76% | 0.00% | 97.06% |++Two or three proven wallets buying inside the observation window means a 55%+survivable-win rate and zero rugs in 351 samples.++When the active model carries a fitted `smart_money_count` feature, the expert+overlay's smart-money and creator-history terms **stand down automatically**.+Counting the same evidence twice is not conservatism, it is a bug. What survives+in the overlay is only evidence the training set has no column for: whether the+proven wallets are already selling, whether any of them are tagged ruggers, and+the serial-rugger score ceiling (a product guarantee, not a probability estimate:+a dev with a graveyard behind them can never present as Strong).++---++## 4. How a new model earns the right to ship++`/api/cron/oracle-refit` runs every six hours. It loads the labeled set, fits+three heads with a time-split holdout, and then has to get past a gate that can+say no.++This part matters. An automated retrain that always ships whatever it just fitted+is not a learning loop, it is a single point of failure on a timer: one bad data+day and production is serving a model nobody looked at.++| Check | Requirement |+|---|---|+| `fit_complete` | every epoch ran; a deadline-truncated fit is under-trained, not wrong, and must not quietly ship |+| `absolute_auc` | scoring head AUC >= 0.70, incumbent or not |+| `tier_honesty` | every populated band still earns at least 70% of the probability it claims |+| `feature_set` | did not lose more than 3 features (that is a broken signal source, not learning) |+| `auc_gain` | beats the incumbent by >= 0.004 AUC, which is more than SGD ordering noise |+| `no_regression_*` | no other head fell by more than 0.01 |++The gain bar is not zero on purpose. Two fits on nearly the same data differ by a+few thousandths of AUC from shuffle ordering alone, and promoting on that noise+would rewrite the live model every six hours, making every published score a+moving target and every track record unreproducible.++Every candidate is stored either way, **including the refused ones, with the+reason**, in `oracle_model_versions`. A registry that shows only the winners is a+highlight reel, not a record.++```+GET /api/oracle/model?view=registry+```++### Where the weights live++They used to be a JSON file baked into the container at build time, so the only+thing that could refit them was a human running a script by hand. Nobody did.+Between 2026-08-09 and 2026-08-28 the model answered every question with a+92,906-row opinion while eight times that much evidence piled up behind it, and+on a current holdout it had given up six points of top-decile precision (53.7%+against 59.8% for a fresh fit).++Now:++- **`oracle_model_versions`** holds the promoted weights. `ensureActiveModel()`+ loads them with a 2-minute TTL, so a promotion is live platform-wide inside one+ scoring cycle with no deploy.+- **`api/_lib/oracle/conviction-model.json`** is the bootstrap a cold container+ boots on, and what the tests run against.+- If the database read fails, whatever model is already installed keeps scoring.+ A scoring engine that returns nothing because it could not check for a newer+ opinion is strictly worse than one using a slightly older one.++Every stored verdict records `model_version_id`, so any score on the platform can+be traced to the exact weights that produced it and recomputed offline.++---++## 5. Run it yourself++```bash+npm install @three-ws/oracle-model+```++```js+import { OracleModel } from '@three-ws/oracle-model';++const oracle = await OracleModel.fetch(); // one request, ~32KB++const v = oracle.score({+ organic_score: 0.82,+ unique_buyers: 41,+ buy_volume_sol: 26,+ snipe_ratio: 0.12,+ smart_money_count: 2,+ dev_sold: false,+ creator_launches: 3,+ creator_wins: 1,+});++console.log(v.score, v.tierLabel); // 90 Prime+console.log(v.upside, v.giveBackRisk, v.rugRisk);+```++After `fetch()` there is no network. No key, no rate limit, no telemetry. Every+signal is optional: a missing one lands in the model's fitted `null` bucket,+which carries real information (a coin nobody has sold yet is telling you+something) rather than being treated as zero.++### Show the arithmetic++```js+const { math } = oracle.explain(signals);++math.formula // 'p = 1 / (1 + exp(-(intercept + sum(term log_odds))))'+math.intercept // -3.8771+math.terms // one row per bucket, with its sample count+math.total_log_odds // add the column up by hand; you will land here+```++### Check our work++```js+const report = oracle.verify([+ { signals: { /* ... */ }, outcome: true },+ { signals: { /* ... */ }, outcome: false },+]);++report.auc // ranking quality on YOUR data+report.brier // calibration error+report.reliability // does a claim of 25% happen 25% of the time?+```++If our published numbers do not survive contact with an independent sample, this+is how you find out, and we would rather you could.++### Watch it change its mind++```js+const older = new OracleModel(docFromRegistry(42));+const newer = new OracleModel(docFromRegistry(43));++older.diff(newer).moves.slice(0, 5);+// [{ key: 'snipe_ratio/0.3-0.7', from: 0.41, to: 0.58, delta: 0.17, samples: 8102 }, ...]+```++The same diff is available server-side at+`/api/oracle/model?view=diff&from=42&to=43`.++---++## 6. API reference++### `GET /api/oracle/model`++The active model in full: card, weights, holdout, provenance.++| Query | Effect |+|---|---|+| `view=card` | just the summary: what it predicts, how well, how old, what it dropped |+| `view=registry` | every version, promoted or refused, with the decision |+| `view=diff&from=&to=` | every bucket weight that moved between two versions |+| `network=` | `mainnet` (default) or `devnet` |++Public, no auth, cached 60s at the client and 300s at the edge.++### The verdict object++| Field | Meaning |+|---|---|+| `score` | 0-100, anchored on P(win). Not a percentage. |+| `tier` / `tierLabel` | `avoid` \| `watch` \| `lean` \| `strong` \| `prime` |+| `probabilities` | raw `win`, `rug`, `moon` |+| `upside` | P(runs), 0-100 |+| `rugRisk` | P(holder down more than half), 0-100 |+| `giveBackRisk` | P(hands the run back \| it runs), 0-100 |+| `survival` | `100 - rugRisk` |+| `confidence` | share of the model's signals actually supplied |+| `reasons` | strongest evidence first, each with its bucket rate and sample count |+| `badges` | `smart-money`, `structure-flag`, `pedigree-flag`, `rug-risk`, `give-back`, `thin-data`, `momentum`, `news` |+| `predicts` | what the score claims, in words |+| `model` | version, fit time, training rows, scoring head |++---++## 7. Operations++| Task | Command |+|---|---|+| Fit and report, write nothing | `node scripts/oracle-fit.mjs` |+| Refresh the bootstrap in the image | `node scripts/oracle-fit.mjs --write` |+| Machine-readable report | `node scripts/oracle-fit.mjs --json` |+| Cap the training window | `node scripts/oracle-fit.mjs --rows 200000` |+| Trigger a refit by hand | `GET /api/cron/oracle-refit` (cron auth) |++`DATABASE_URL` lives in `.env.local`, not `.env`. The fitter reads both; it used+to read only `.env` and died with "DATABASE_URL not set", which is a large part+of why the model went nineteen days without a refit.++| Table | Holds |+|---|---|+| `oracle_training_set` | never-pruned (features, outcome) per labeled coin, with `label_version` |+| `pump_coin_outcomes` | rolling outcome labels, plus `retained` / `hold_multiple` / `at_floor` |+| `oracle_model_versions` | every fitted model, its holdout, its promotion decision |+| `oracle_conviction` | the live verdict per coin, with `rug_risk` / `upside` / `give_back_risk` / `model_version_id` |++## See also++- [Oracle: the conviction engine, end to end](/docs/oracle)+- [Coin Intelligence](/coin-intel), the observation pipeline that produces the signals+- [Oracle Lab](/oracle-lab), all of the above rendereddiff --git a/pages/oracle-lab.html b/pages/oracle-lab.htmlnew file mode 100644index 000000000..8d1b88e6e--- /dev/null+++ b/pages/oracle-lab.html@@ -0,0 +1,265 @@+<!DOCTYPE html>+<html lang="en">+<head>+ <script>/* three.ws theme boot — no-flash; runtime in /theme-switcher.js */(function(){try{var m=localStorage.getItem('twx_theme');var l=m==='auto'?(window.matchMedia&&window.matchMedia('(prefers-color-scheme: light)').matches):m==='light';document.documentElement.setAttribute('data-theme',l?'light':'dark');}catch(e){document.documentElement.setAttribute('data-theme','dark');}})();</script>+ <meta charset="UTF-8" />+ <link rel="icon" href="/favicon.ico" sizes="any" />+ <link rel="icon" type="image/svg+xml" href="/favicon.svg" />+ <link rel="apple-touch-icon" href="/apple-touch-icon.png" />+ <link rel="manifest" href="/manifest.webmanifest" />+ <meta name="viewport" content="width=device-width, initial-scale=1.0" />+ <title>Oracle Lab · three.ws</title>+ <meta name="description" content="The Oracle's conviction model, published in full: every bucket weight with the sample count behind it, held-out reliability curves, the version history of what the machine learned and when, and a live scorer you can drive by hand." />+ <link rel="canonical" href="https://three.ws/oracle-lab" />+ <meta property="og:title" content="Oracle Lab: the model, published" />+ <meta property="og:description" content="Every weight, every sample count, every version. Download the model and reproduce any score offline." />+ <meta property="og:url" content="https://three.ws/oracle-lab" />+ <meta property="og:type" content="website" />+ <meta name="twitter:card" content="summary_large_image" />+ <link rel="stylesheet" href="/style.css" />+ <link rel="stylesheet" href="/nav.css" />+ <link rel="stylesheet" href="/mobile.css" />+ <style>+ :root {+ --lab-bg: #07080c;+ --lab-panel: rgba(16, 18, 26, 0.86);+ --lab-panel-2: rgba(255, 255, 255, 0.03);+ --lab-border: rgba(255, 255, 255, 0.09);+ --lab-border-strong: rgba(255, 255, 255, 0.16);+ --lab-text: #e9ebf2;+ --lab-muted: #8a90a2;+ --lab-faint: #5c6273;+ --lab-accent: #8b5cf6;+ --lab-good: #34d399;+ --lab-bad: #f87171;+ --lab-warn: #fbbf24;+ --lab-mono: ui-monospace, SFMono-Regular, 'SF Mono', Menlo, Consolas, monospace;+ }+ html[data-theme="light"] {+ --lab-bg: #f7f8fb;+ --lab-panel: rgba(255, 255, 255, 0.92);+ --lab-panel-2: rgba(15, 18, 30, 0.03);+ --lab-border: rgba(15, 18, 30, 0.12);+ --lab-border-strong: rgba(15, 18, 30, 0.22);+ --lab-text: #12151f;+ --lab-muted: #5b6376;+ --lab-faint: #838b9d;+ }+ html, body { background: var(--lab-bg); color: var(--lab-text); }+ body { margin: 0; min-height: 100vh; font-family: var(--font-body, 'Inter', system-ui, sans-serif); }+ .wrap { max-width: 1180px; margin: 0 auto; padding: 0 20px 96px; }++ /* hero */+ .hero { padding: 56px 0 28px; border-bottom: 1px solid var(--lab-border); }+ .eyebrow { font-family: var(--lab-mono); font-size: 12px; letter-spacing: .14em; text-transform: uppercase; color: var(--lab-accent); margin: 0 0 12px; }+ .hero h1 { margin: 0 0 14px; font-size: clamp(30px, 5vw, 46px); line-height: 1.08; letter-spacing: -0.02em; }+ .hero p { margin: 0; max-width: 68ch; color: var(--lab-muted); font-size: 16.5px; line-height: 1.62; }+ .hero .lede-strong { color: var(--lab-text); }+ .hero-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 22px; }+ .btn {+ display: inline-flex; align-items: center; gap: 8px; padding: 9px 15px; border-radius: 9px;+ border: 1px solid var(--lab-border-strong); background: var(--lab-panel-2); color: var(--lab-text);+ font-size: 13.5px; font-weight: 550; text-decoration: none; cursor: pointer;+ transition: background .16s ease, border-color .16s ease, transform .16s ease;+ }+ .btn:hover { background: rgba(139, 92, 246, 0.14); border-color: var(--lab-accent); transform: translateY(-1px); }+ .btn:focus-visible { outline: 2px solid var(--lab-accent); outline-offset: 2px; }+ .btn.primary { background: var(--lab-accent); border-color: var(--lab-accent); color: #fff; }+ .btn.primary:hover { background: #7c4ff0; }++ /* generic panel */+ section.block { margin-top: 44px; }+ section.block > h2 { margin: 0 0 6px; font-size: 20px; letter-spacing: -0.01em; }+ section.block > .sub { margin: 0 0 18px; color: var(--lab-muted); font-size: 14px; max-width: 74ch; line-height: 1.6; }+ .panel { border: 1px solid var(--lab-border); border-radius: 14px; background: var(--lab-panel); padding: 18px; }++ /* stat row */+ .stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 12px; }+ .stat { border: 1px solid var(--lab-border); border-radius: 12px; background: var(--lab-panel); padding: 14px 15px; }+ .stat .k { font-size: 11.5px; text-transform: uppercase; letter-spacing: .09em; color: var(--lab-faint); }+ .stat .v { font-family: var(--lab-mono); font-size: 22px; margin-top: 6px; letter-spacing: -0.01em; }+ .stat .n { font-size: 12px; color: var(--lab-muted); margin-top: 3px; }++ /* tables */+ .tablewrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }+ table { width: 100%; border-collapse: collapse; font-size: 13.5px; }+ th, td { text-align: left; padding: 9px 12px; border-bottom: 1px solid var(--lab-border); white-space: nowrap; }+ th { font-size: 11.5px; text-transform: uppercase; letter-spacing: .08em; color: var(--lab-faint); font-weight: 600; }+ tbody tr { transition: background .12s ease; }+ tbody tr:hover { background: var(--lab-panel-2); }+ td.num, th.num { text-align: right; font-family: var(--lab-mono); font-variant-numeric: tabular-nums; }+ .pos { color: var(--lab-good); }+ .neg { color: var(--lab-bad); }+ .dim { color: var(--lab-faint); }++ /* bar in a cell */+ .bar { position: relative; height: 6px; border-radius: 3px; background: var(--lab-panel-2); min-width: 90px; overflow: hidden; }+ .bar > i { position: absolute; top: 0; bottom: 0; border-radius: 3px; transition: width .3s ease; }+ .bar > i.up { background: var(--lab-good); left: 50%; }+ .bar > i.down { background: var(--lab-bad); right: 50%; }++ /* scorer */+ .scorer { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 340px); gap: 20px; align-items: start; }+ .controls { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 14px 18px; }+ .ctl label { display: block; font-size: 12.5px; color: var(--lab-muted); margin-bottom: 6px; }+ .ctl label b { color: var(--lab-text); font-family: var(--lab-mono); font-weight: 600; float: right; }+ .ctl input[type="range"] { width: 100%; accent-color: var(--lab-accent); cursor: pointer; }+ .ctl input[type="range"]:focus-visible { outline: 2px solid var(--lab-accent); outline-offset: 3px; }+ .ctl select {+ width: 100%; padding: 7px 9px; border-radius: 8px; font-size: 13px;+ background: var(--lab-panel-2); color: var(--lab-text); border: 1px solid var(--lab-border);+ }+ .verdict { border: 1px solid var(--lab-border-strong); border-radius: 14px; background: var(--lab-panel); padding: 18px; position: sticky; top: 84px; }+ .verdict .score { font-family: var(--lab-mono); font-size: 54px; line-height: 1; letter-spacing: -0.03em; }+ .tierpill { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 650; letter-spacing: .03em; margin-left: 4px; vertical-align: middle; }+ .t-prime { background: rgba(52,211,153,.16); color: var(--lab-good); }+ .t-strong { background: rgba(52,211,153,.12); color: var(--lab-good); }+ .t-lean { background: rgba(251,191,36,.14); color: var(--lab-warn); }+ .t-watch { background: rgba(255,255,255,.08); color: var(--lab-muted); }+ .t-avoid { background: rgba(248,113,113,.14); color: var(--lab-bad); }+ .risks { display: grid; gap: 10px; margin-top: 16px; }+ .risk { display: grid; grid-template-columns: 1fr auto; gap: 4px 10px; align-items: center; font-size: 13px; }+ .risk .lbl { color: var(--lab-muted); }+ .risk .val { font-family: var(--lab-mono); font-weight: 600; }+ .risk .track { grid-column: 1 / -1; height: 5px; border-radius: 3px; background: var(--lab-panel-2); overflow: hidden; }+ .risk .track > i { display: block; height: 100%; border-radius: 3px; transition: width .28s ease; }+ .why { margin-top: 16px; border-top: 1px solid var(--lab-border); padding-top: 14px; }+ .why h4 { margin: 0 0 9px; font-size: 11.5px; text-transform: uppercase; letter-spacing: .09em; color: var(--lab-faint); }+ .why ol { margin: 0; padding: 0; list-style: none; display: grid; gap: 8px; }+ .why li { font-size: 12.5px; display: grid; grid-template-columns: 1fr auto; gap: 2px 8px; }+ .why li .t { color: var(--lab-text); }+ .why li .w { font-family: var(--lab-mono); font-size: 12px; }+ .why li .m { grid-column: 1 / -1; color: var(--lab-faint); font-size: 11.5px; }++ /* code */+ pre { margin: 0; padding: 15px 16px; border-radius: 12px; background: #0b0d14; border: 1px solid var(--lab-border); overflow-x: auto; }+ html[data-theme="light"] pre { background: #12151f; }+ code { font-family: var(--lab-mono); font-size: 12.6px; line-height: 1.65; color: #d7dbe8; }+ .tok-k { color: #c084fc; } .tok-s { color: #86efac; } .tok-c { color: #64748b; } .tok-n { color: #fbbf24; }++ /* misc */+ .note { border-left: 2px solid var(--lab-accent); padding: 2px 0 2px 14px; color: var(--lab-muted); font-size: 13.5px; line-height: 1.65; margin: 14px 0 0; }+ .note b { color: var(--lab-text); }+ .pill { display: inline-block; font-family: var(--lab-mono); font-size: 11px; padding: 2px 7px; border-radius: 5px; background: var(--lab-panel-2); border: 1px solid var(--lab-border); color: var(--lab-muted); }+ .pill.ok { color: var(--lab-good); border-color: rgba(52,211,153,.3); }+ .pill.no { color: var(--lab-bad); border-color: rgba(248,113,113,.3); }+ .skeleton { border-radius: 8px; background: linear-gradient(90deg, var(--lab-panel-2) 25%, rgba(255,255,255,.06) 50%, var(--lab-panel-2) 75%); background-size: 200% 100%; animation: sh 1.3s ease-in-out infinite; height: 14px; }+ @keyframes sh { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }+ @media (prefers-reduced-motion: reduce) { .skeleton { animation: none; } * { transition: none !important; } }+ .empty { padding: 26px 18px; text-align: center; color: var(--lab-muted); font-size: 14px; line-height: 1.6; }+ .empty b { display: block; color: var(--lab-text); font-size: 15px; margin-bottom: 6px; }+ .err { border-color: rgba(248,113,113,.35); }+ .selrow { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 14px; font-size: 13px; color: var(--lab-muted); }+ .selrow select { padding: 6px 9px; border-radius: 8px; background: var(--lab-panel-2); color: var(--lab-text); border: 1px solid var(--lab-border); font-size: 13px; }+ @media (max-width: 860px) {+ .scorer { grid-template-columns: 1fr; }+ .verdict { position: static; }+ }+ </style>+</head>+<body>+ <div id="nav-root"></div>++ <main class="wrap">+ <header class="hero">+ <p class="eyebrow">Oracle Lab</p>+ <h1>The model, published.</h1>+ <p>+ The Oracle watches every pump.fun launch for its first ninety seconds and scores it.+ <span class="lede-strong">This page is the machine that makes the score</span>, not a summary of it:+ every bucket weight with the number of labeled launches behind it, what actually happened to+ those launches, the reliability curve it earned on data it had never seen, and the full history+ of every version it has tried, including the ones that were refused.+ </p>+ <p style="margin-top:14px">+ It is a lookup table, roughly 32KB. Download it and you can reproduce any score we have ever+ published, offline, with no key.+ </p>+ <div class="hero-actions">+ <a class="btn primary" href="/api/oracle/model" target="_blank" rel="noopener">Download the model</a>+ <a class="btn" href="/docs/oracle-model">Read the docs</a>+ <a class="btn" href="/oracle">Live feed</a>+ <a class="btn" href="https://www.npmjs.com/package/@three-ws/oracle-model" target="_blank" rel="noopener">npm package</a>+ </div>+ </header>++ <section class="block" id="summary">+ <h2>What is scoring right now</h2>+ <p class="sub">The exact model this platform is using this second, with the numbers it earned on launches held out of its own training.</p>+ <div class="stats" id="stats"></div>+ <div id="predicts" class="note"></div>+ </section>++ <section class="block" id="ladder-block">+ <h2>Does each tier earn what it claims</h2>+ <p class="sub">+ The score line is not a percentage: 86 claims a 45% chance, not an 86% one. Each rung is a+ public promise about measured frequency, so here is the promise next to the measurement, on+ launches the model never saw. A model whose top band stops clearing its own claim is refused+ by the promotion gate rather than shipped.+ </p>+ <div class="panel"><div class="tablewrap"><table id="ladder"></table></div></div>+ </section>++ <section class="block" id="scorer-block">+ <h2>Drive it yourself</h2>+ <p class="sub">+ Every control below feeds the real weights, in your browser. Nothing is sent anywhere. This is+ the same arithmetic that scores the live feed.+ </p>+ <div class="scorer">+ <div class="panel">+ <div class="controls" id="controls"></div>+ </div>+ <div class="verdict" id="verdict"></div>+ </div>+ </section>++ <section class="block" id="weights-block">+ <h2>Every weight, and the evidence for it</h2>+ <p class="sub">+ One row per bucket. <b>Log-odds</b> is what that bucket adds to the score. <b>Win</b>, <b>rug</b>+ and <b>run</b> are what actually happened to the launches in it, and <b>n</b> is how many there+ were. A claim with a small n is a weak claim, and you can see which is which.+ </p>+ <div class="selrow">+ <label for="wsort">Sort by</label>+ <select id="wsort">+ <option value="impact">strongest influence</option>+ <option value="win">highest win rate</option>+ <option value="rug">highest rug rate</option>+ <option value="n">most samples</option>+ <option value="feature">feature name</option>+ </select>+ <span id="wcount" class="pill"></span>+ </div>+ <div class="panel"><div class="tablewrap"><table id="weights"></table></div></div>+ </section>++ <section class="block" id="registry-block">+ <h2>What it has learned, and when</h2>+ <p class="sub">+ The model refits every six hours and only takes over if it beats the incumbent on held-out+ ranking. Refused candidates are listed here too, with the reason: a registry that shows only the+ winners is a highlight reel, not a record.+ </p>+ <div class="panel"><div class="tablewrap"><table id="registry"></table></div></div>+ <div id="diff-block" style="margin-top:18px"></div>+ </section>++ <section class="block" id="use-block">+ <h2>Use it</h2>+ <p class="sub">Zero dependencies. Node, Deno, Bun, Workers, browser. One request, then it is local arithmetic forever.</p>+ <pre><code id="snippet"></code></pre>+ <p class="note">+ <b>verify() is the important one.</b> Feed it launches with outcomes you collected yourself and+ it re-measures our AUC, Brier score and reliability curve on your data. If our published numbers+ do not survive an independent sample, you should be able to find that out from us.+ </p>+ </section>+ </main>++ <script type="module" src="/nav.js"></script>+ <script type="module" src="/oracle-lab.js"></script>+</body>+</html>diff --git a/src/oracle-lab.js b/src/oracle-lab.jsnew file mode 100644index 000000000..b36c72fef--- /dev/null+++ b/src/oracle-lab.js@@ -0,0 +1,468 @@+// Oracle Lab: the conviction model, rendered honestly.+//+// The page has one job that everything else follows from: make it impossible to+// read a score without also seeing the evidence behind it and the sample size of+// that evidence. So every weight ships with its n, every tier claim ships with+// the rate it actually earned on held-out data, and the version history shows+// the candidates the promotion gate refused alongside the ones it accepted.+//+// The interactive scorer runs the published weights locally, in the browser,+// with the same arithmetic the server uses. That is not a demo trick: if the two+// ever disagreed, one of them would be lying about what the platform does.++const MODEL_API = '/api/oracle/model';++const $ = (id) => document.getElementById(id);+const esc = (s) => String(s).replace(/[&<>"']/g, (c) => ({ '&': '&', '<': '<', '>': '>', '"': '"', "'": ''' }[c]));+const pct = (v, digits = 1) => (v == null ? '-' : `${(100 * v).toFixed(digits)}%`);+const clamp = (n, lo = 0, hi = 100) => Math.max(lo, Math.min(hi, n));+const sigmoid = (z) => 1 / (1 + Math.exp(-z));+const num = (v) => (Number.isFinite(Number(v)) ? Number(v) : null);++/** Whole numbers with separators; the model quotes counts in the hundreds of thousands. */+const int = (v) => (v == null ? '-' : Number(v).toLocaleString());++function ago(iso) {+ if (!iso) return 'unknown';+ const ms = Date.now() - new Date(iso).getTime();+ if (!Number.isFinite(ms)) return 'unknown';+ const mins = Math.round(ms / 60000);+ if (mins < 60) return `${mins}m ago`;+ const hours = Math.round(mins / 60);+ if (hours < 48) return `${hours}h ago`;+ return `${Math.round(hours / 24)}d ago`;+}++// ── state ────────────────────────────────────────────────────────────────────+const state = {+ model: null,+ card: null,+ registry: [],+ signals: {},+ sort: 'impact',+};++// ── scoring, client side, from the published weights ────────────────────────++function bucketLabel(feature, value) {+ if (feature.categorical) return String(value ?? 'unknown');+ if (value == null) return 'null';+ const edges = feature.edges || [];+ for (let i = 0; i < edges.length; i++) {+ if (value < edges[i]) return i === 0 ? `<${edges[0]}` : `${edges[i - 1]}-${edges[i]}`;+ }+ return `>=${edges[edges.length - 1]}`;+}++function featureValue(feature, signals) {+ if (feature.categorical) return String(signals[feature.key] ?? 'unknown').toLowerCase();+ if (feature.key === 'dev_sold') {+ const raw = signals.dev_sold;+ return raw === true || raw === 1 ? 1 : raw === false || raw === 0 ? 0 : null;+ }+ return num(signals[feature.key]);+}++function scoreLocally(model, signals) {+ const heads = Object.keys(model.heads || {});+ const z = {};+ for (const h of heads) z[h] = num(model.heads[h]?.intercept) ?? 0;+ const why = [];+ let observed = 0;++ for (const feature of model.features) {+ const value = featureValue(feature, signals);+ const bucket = bucketLabel(feature, value);+ const stats = feature.buckets?.[bucket];+ if (value != null && bucket !== 'null' && bucket !== 'unknown') observed++;+ if (!stats) continue;+ for (const h of heads) z[h] += num(stats.w?.[h]) ?? 0;+ why.push({+ key: feature.key,+ bucket,+ weight: num(stats.w?.[model.score_head]) ?? 0,+ samples: stats.n ?? 0,+ rate: stats.rate || null,+ });+ }+ why.sort((a, b) => Math.abs(b.weight) - Math.abs(a.weight));++ const probabilities = {};+ for (const h of heads) probabilities[h] = sigmoid(z[h]);++ const a = model.tier_probability_anchors || {};+ const anchors = [[0, 0], [a.watch, 34], [a.lean, 56], [a.strong, 72], [a.prime, 86], [1, 100]];+ const p = probabilities[model.score_head] ?? 0;+ let score = 100;+ for (let i = 1; i < anchors.length; i++) {+ const [p0, s0] = anchors[i - 1];+ const [p1, s1] = anchors[i];+ if (p <= p1) { score = clamp(Math.round(s0 + ((p - p0) / (p1 - p0)) * (s1 - s0))); break; }+ }++ const tiers = [[86, 'prime', 'Prime'], [72, 'strong', 'Strong'], [56, 'lean', 'Lean'], [34, 'watch', 'Watch'], [0, 'avoid', 'Avoid']];+ const tier = tiers.find(([min]) => score >= min);++ const rugRisk = probabilities.rug != null ? clamp(Math.round(probabilities.rug * 100)) : null;+ const upside = probabilities.moon != null ? clamp(Math.round(probabilities.moon * 100)) : null;+ const giveBackRisk = probabilities.moon > 0 && probabilities.win != null+ ? clamp(Math.round((1 - Math.min(1, probabilities.win / probabilities.moon)) * 100))+ : null;++ return {+ score, tier: tier[1], tierLabel: tier[2], probabilities, rugRisk, upside, giveBackRisk,+ confidence: clamp(Math.round((observed / Math.max(1, model.features.length)) * 100)),+ why,+ };+}++// ── the interactive scorer ───────────────────────────────────────────────────++// One control per signal a person can reason about. Deliberately not one per+// feature: a slider for every fitted bucket would be a wall nobody touches, and+// the point of the panel is that moving something teaches you what the model+// believes. Everything omitted lands in its fitted null bucket, exactly as it+// does when the observer genuinely did not see it.+const CONTROLS = [+ { key: 'organic_score', label: 'Organic demand', min: 0, max: 1, step: 0.01, value: 0.5, fmt: (v) => v.toFixed(2) },+ { key: 'bundle_score', label: 'Bundling', min: 0, max: 1, step: 0.01, value: 0.1, fmt: (v) => v.toFixed(2) },+ { key: 'snipe_ratio', label: 'Sniped at open', min: 0, max: 1, step: 0.01, value: 0.2, fmt: (v) => v.toFixed(2) },+ { key: 'timing_entropy', label: 'Buy-timing spread', min: 0, max: 1, step: 0.01, value: 0.5, fmt: (v) => v.toFixed(2) },+ { key: 'concentration_top10', label: 'Top-10 holder share', min: 0, max: 1, step: 0.01, value: 0.6, fmt: (v) => v.toFixed(2) },+ { key: 'unique_buyers', label: 'Unique buyers', min: 0, max: 120, step: 1, value: 12, fmt: (v) => String(v) },+ { key: 'unique_sellers', label: 'Unique sellers', min: 0, max: 60, step: 1, value: 2, fmt: (v) => String(v) },+ { key: 'buy_volume_sol', label: 'Buy volume (SOL)', min: 0, max: 60, step: 0.5, value: 6, fmt: (v) => v.toFixed(1) },+ { key: 'sell_volume_sol', label: 'Sell volume (SOL)', min: 0, max: 40, step: 0.5, value: 1, fmt: (v) => v.toFixed(1) },+ { key: 'largest_buy_sol', label: 'Largest single buy (SOL)', min: 0, max: 20, step: 0.1, value: 1, fmt: (v) => v.toFixed(1) },+ { key: 'dev_buy_sol', label: 'Dev buy (SOL)', min: 0, max: 10, step: 0.05, value: 0.3, fmt: (v) => v.toFixed(2) },+ { key: 'dev_sell_sol', label: 'Dev sell (SOL)', min: 0, max: 10, step: 0.05, value: 0, fmt: (v) => v.toFixed(2) },+ { key: 'mc_sol_first_seen', label: 'Cap at first sight (SOL)', min: 27, max: 60, step: 0.5, value: 30, fmt: (v) => v.toFixed(1) },+ { key: 'smart_money_count', label: 'Proven wallets in', min: 0, max: 8, step: 1, value: 0, fmt: (v) => String(v) },+];++const SELECTS = [+ {+ key: 'dev_sold', label: 'Dev sold in the window', value: '0',+ options: [['0', 'held'], ['1', 'sold']],+ coerce: (v) => Number(v),+ },+ {+ key: 'creator_record', label: 'Creator history', value: 'unknown',+ options: [+ ['unknown', 'unknown'], ['first_launch', 'first launch'], ['repeat_no_wins', 'repeat, no graduations'],+ ['serial_no_wins', '5+ launches, none graduated'], ['has_wins', 'has graduated before'],+ ],+ },+];++function derivedSignals() {+ const s = { ...state.signals };+ // Two signals the observer computes rather than reads, mirrored here so the+ // sliders behave the way the live pipeline does.+ const buys = num(s.buy_volume_sol) ?? 0;+ const sells = num(s.sell_volume_sol) ?? 0;+ const buyers = num(s.unique_buyers) ?? 0;+ const sellers = num(s.unique_sellers) ?? 0;+ s.net_volume_sol = Number((buys - sells).toFixed(3));+ s.buy_sell_ratio = sells > 0 ? Number((buys / sells).toFixed(3)) : null;+ s.trade_count = buyers + sellers;+ s.avg_buy_sol = buyers > 0 ? Number((buys / buyers).toFixed(4)) : null;+ return s;+}++function renderControls() {+ const host = $('controls');+ host.innerHTML = '';++ for (const c of CONTROLS) {+ if (state.signals[c.key] === undefined) state.signals[c.key] = c.value;+ const wrap = document.createElement('div');+ wrap.className = 'ctl';+ const id = `ctl-${c.key}`;+ wrap.innerHTML = `<label for="${id}">${esc(c.label)}<b id="v-${esc(c.key)}">${esc(c.fmt(state.signals[c.key]))}</b></label>`;+ const input = document.createElement('input');+ input.type = 'range';+ input.id = id;+ input.min = String(c.min); input.max = String(c.max); input.step = String(c.step);+ input.value = String(state.signals[c.key]);+ input.setAttribute('aria-label', c.label);+ input.addEventListener('input', () => {+ state.signals[c.key] = Number(input.value);+ const out = document.getElementById(`v-${c.key}`);+ if (out) out.textContent = c.fmt(Number(input.value));+ renderVerdict();+ });+ wrap.appendChild(input);+ host.appendChild(wrap);+ }++ for (const s of SELECTS) {+ if (state.signals[s.key] === undefined) state.signals[s.key] = s.coerce ? s.coerce(s.value) : s.value;+ const wrap = document.createElement('div');+ wrap.className = 'ctl';+ const id = `ctl-${s.key}`;+ wrap.innerHTML = `<label for="${id}">${esc(s.label)}</label>`;+ const sel = document.createElement('select');+ sel.id = id;+ sel.innerHTML = s.options.map(([v, t]) => `<option value="${esc(v)}">${esc(t)}</option>`).join('');+ sel.value = s.value;+ sel.addEventListener('change', () => {+ state.signals[s.key] = s.coerce ? s.coerce(sel.value) : sel.value;+ renderVerdict();+ });+ wrap.appendChild(sel);+ host.appendChild(wrap);+ }+}++function riskRow(label, value, colour, hint) {+ if (value == null) return '';+ return `+ <div class="risk">+ <span class="lbl">${esc(label)}${hint ? ` <span class="dim" title="${esc(hint)}">?</span>` : ''}</span>+ <span class="val" style="color:${colour}">${value}%</span>+ <span class="track"><i style="width:${clamp(value)}%;background:${colour}"></i></span>+ </div>`;+}++function renderVerdict() {+ const host = $('verdict');+ if (!state.model) { host.innerHTML = '<div class="skeleton" style="height:120px"></div>'; return; }+ const v = scoreLocally(state.model, derivedSignals());++ const why = v.why.slice(0, 6).map((w) => `+ <li>+ <span class="t">${esc(w.key)} <span class="dim">= ${esc(w.bucket)}</span></span>+ <span class="w ${w.weight >= 0 ? 'pos' : 'neg'}">${w.weight >= 0 ? '+' : ''}${w.weight.toFixed(3)}</span>+ <span class="m">${int(w.samples)} launches: ${pct(w.rate?.win)} won, ${pct(w.rate?.rug)} rugged</span>+ </li>`).join('');++ host.innerHTML = `+ <div><span class="score">${v.score}</span><span class="tierpill t-${esc(v.tier)}">${esc(v.tierLabel)}</span></div>+ <div class="dim" style="font-size:12.5px;margin-top:6px">+ claims a ${pct(v.probabilities.win, 1)} chance of running without giving it back+ </div>+ <div class="risks">+ ${riskRow('Upside', v.upside, 'var(--lab-good)', 'Chance it graduates or peaks at 3x or more')}+ ${riskRow('Give-back risk', v.giveBackRisk, 'var(--lab-warn)', 'Given it runs, how often a coin like this hands the run straight back')}+ ${riskRow('Rug risk', v.rugRisk, 'var(--lab-bad)', 'Chance a first-sight holder ends down more than half')}+ ${riskRow('Signals supplied', v.confidence, 'var(--lab-accent)', 'How much of the model you actually gave values for')}+ </div>+ <div class="why">+ <h4>Why</h4>+ <ol>${why || '<li class="dim">no decisive evidence either way</li>'}</ol>+ </div>`;+}++// ── static sections ──────────────────────────────────────────────────────────++function renderStats() {+ const c = state.card;+ const h = c.holdout;+ const cells = [+ ['Model', `v${c.version}`, `${c.provenance?.source === 'database' ? `promotion #${c.provenance.version_id}` : 'shipped with the build'}`],+ ['Fitted', ago(c.fitted_at), new Date(c.fitted_at).toISOString().slice(0, 16).replace('T', ' ')],+ ['Trained on', int(c.training_rows), 'labeled launches'],+ ['Held-out AUC', h ? h.auc.toFixed(4) : '-', h ? `on ${int(h.n)} it never saw` : ''],+ ['Top 1% precision', h ? pct(h.precision.top1.rate, 1) : '-', h ? `${h.precision.top1.lift}x base rate` : ''],+ ['Weights', int(c.bucket_weights), `across ${c.features} signals`],+ ];+ $('stats').innerHTML = cells.map(([k, v, n]) => `+ <div class="stat"><div class="k">${esc(k)}</div><div class="v">${esc(v)}</div><div class="n">${esc(n)}</div></div>+ `).join('');++ const dropped = (c.dropped_features || []).map((d) => d.key);+ $('predicts').innerHTML = `+ <b>What the score predicts:</b> ${esc(c.predicts?.label || 'unknown')}.+ ${c.predicts?.caveat ? ` ${esc(c.predicts.caveat)}` : ''}+ ${dropped.length ? `<br><b>Dropped as uninformative:</b> ${dropped.map((d) => `<span class="pill">${esc(d)}</span>`).join(' ')}. These signals are null across the whole corpus, so the fitter refuses to invent a weight for them. If they start arriving, the next refit picks them up on its own.` : ''}`;+}++function renderLadder() {+ const rows = state.card.tier_ladder || [];+ $('ladder').innerHTML = `+ <thead><tr>+ <th>Tier</th><th class="num">Score</th><th class="num">Claims</th>+ <th class="num">Observed</th><th class="num">n</th><th>Verdict</th>+ </tr></thead>+ <tbody>${rows.map((r) => {+ const honest = r.observed != null && r.claims != null ? r.observed >= r.claims * 0.7 : null;+ return `<tr>+ <td><span class="tierpill t-${esc(r.tier)}">${esc(r.label)}</span></td>+ <td class="num">${r.min_score}+</td>+ <td class="num">${r.claims == null ? '-' : pct(r.claims, 0)}</td>+ <td class="num ${honest === false ? 'neg' : ''}">${pct(r.observed)}</td>+ <td class="num dim">${int(r.samples)}</td>+ <td>${r.samples < 100 ? '<span class="pill">thin</span>'+ : honest ? '<span class="pill ok">earns it</span>' : '<span class="pill no">falls short</span>'}</td>+ </tr>`;+ }).join('')}</tbody>`;+}++function weightRows() {+ const head = state.model.score_head;+ const rows = [];+ for (const f of state.model.features) {+ for (const [bucket, stats] of Object.entries(f.buckets || {})) {+ rows.push({+ feature: f.key, pillar: f.pillar, bucket,+ w: num(stats.w?.[head]) ?? 0,+ n: stats.n ?? 0,+ win: stats.rate?.win ?? null,+ rug: stats.rate?.rug ?? null,+ moon: stats.rate?.moon ?? null,+ });+ }+ }+ const by = {+ impact: (a, b) => Math.abs(b.w) - Math.abs(a.w),+ win: (a, b) => (b.win ?? 0) - (a.win ?? 0),+ rug: (a, b) => (b.rug ?? 0) - (a.rug ?? 0),+ n: (a, b) => b.n - a.n,+ feature: (a, b) => a.feature.localeCompare(b.feature) || a.bucket.localeCompare(b.bucket),+ };+ return rows.sort(by[state.sort] || by.impact);+}++function renderWeights() {+ const rows = weightRows();+ const maxAbs = rows.reduce((m, r) => Math.max(m, Math.abs(r.w)), 0.001);+ $('wcount').textContent = `${rows.length} buckets`;+ $('weights').innerHTML = `+ <thead><tr>+ <th>Signal</th><th>Bucket</th><th>Pillar</th>+ <th class="num">Log-odds</th><th>Influence</th>+ <th class="num">Win</th><th class="num">Rug</th><th class="num">Run</th><th class="num">n</th>+ </tr></thead>+ <tbody>${rows.map((r) => {+ const width = (Math.abs(r.w) / maxAbs) * 50;+ return `<tr>+ <td>${esc(r.feature)}</td>+ <td class="dim">${esc(r.bucket)}</td>+ <td class="dim">${esc(r.pillar)}</td>+ <td class="num ${r.w >= 0 ? 'pos' : 'neg'}">${r.w >= 0 ? '+' : ''}${r.w.toFixed(4)}</td>+ <td><span class="bar"><i class="${r.w >= 0 ? 'up' : 'down'}" style="width:${width}%"></i></span></td>+ <td class="num">${pct(r.win)}</td>+ <td class="num">${pct(r.rug)}</td>+ <td class="num">${pct(r.moon)}</td>+ <td class="num ${r.n < 200 ? 'dim' : ''}">${int(r.n)}</td>+ </tr>`;+ }).join('')}</tbody>`;+}++function renderRegistry() {+ const host = $('registry');+ if (!state.registry.length) {+ host.innerHTML = `<tbody><tr><td><div class="empty">+ <b>No refits recorded yet</b>+ The model shipped with this build is the one scoring. The refit cron runs every six hours;+ the first promotion will appear here with the numbers that earned it.+ </div></td></tr></tbody>`;+ return;+ }+ host.innerHTML = `+ <thead><tr>+ <th>#</th><th>Status</th><th>Fitted</th><th class="num">Rows</th>+ <th class="num">Win AUC</th><th class="num">Rug AUC</th><th class="num">Run AUC</th><th>Decision</th>+ </tr></thead>+ <tbody>${state.registry.map((v) => {+ const cls = v.status === 'active' ? 'ok' : v.status === 'candidate' ? 'no' : '';+ return `<tr>+ <td class="num">${v.id}</td>+ <td><span class="pill ${cls}">${esc(v.status)}</span></td>+ <td class="dim">${esc(ago(v.fitted_at))}</td>+ <td class="num">${int(v.training_rows)}</td>+ <td class="num">${v.holdout_auc?.win?.toFixed?.(4) ?? '-'}</td>+ <td class="num">${v.holdout_auc?.rug?.toFixed?.(4) ?? '-'}</td>+ <td class="num">${v.holdout_auc?.moon?.toFixed?.(4) ?? '-'}</td>+ <td style="white-space:normal;max-width:38ch" class="dim">${esc(v.decision || '')}</td>+ </tr>`;+ }).join('')}</tbody>`;++ // A diff is only meaningful once there are two versions to compare.+ if (state.registry.length >= 2) {+ const [a, b] = [state.registry[1], state.registry[0]];+ $('diff-block').innerHTML = `<p class="note">+ <b>Compare any two:</b>+ <a href="${MODEL_API}?view=diff&from=${a.id}&to=${b.id}" target="_blank" rel="noopener">+ what changed between #${a.id} and #${b.id}</a>,+ or run <code>a.diff(b)</code> locally with the npm package.+ </p>`;+ }+}++function renderSnippet() {+ const html = `<span class="tok-k">import</span> { OracleModel } <span class="tok-k">from</span> <span class="tok-s">'@three-ws/oracle-model'</span>;++<span class="tok-k">const</span> oracle = <span class="tok-k">await</span> OracleModel.fetch(); <span class="tok-c">// one request, ~32KB</span>++<span class="tok-k">const</span> v = oracle.score({+ organic_score: <span class="tok-n">0.82</span>, unique_buyers: <span class="tok-n">41</span>, buy_volume_sol: <span class="tok-n">26</span>,+ snipe_ratio: <span class="tok-n">0.12</span>, smart_money_count: <span class="tok-n">2</span>, dev_sold: <span class="tok-k">false</span>,+});++v.score <span class="tok-c">// 0-100, anchored on P(runs and holds)</span>+v.upside <span class="tok-c">// chance it runs at all</span>+v.giveBackRisk <span class="tok-c">// chance it runs and hands it straight back</span>+v.rugRisk <span class="tok-c">// chance a first-sight holder ends down 50%+</span>+v.why <span class="tok-c">// every bucket that moved it, with its sample count</span>++oracle.explain(signals).math <span class="tok-c">// add the terms up yourself</span>+oracle.performance() <span class="tok-c">// held-out AUC, Brier, reliability</span>+oracle.verify(yourSamples) <span class="tok-c">// re-measure us on YOUR data</span>`;+ $('snippet').innerHTML = html;+}++function renderError(message) {+ for (const id of ['stats', 'ladder', 'weights', 'registry', 'verdict']) {+ const host = $(id);+ if (host) host.innerHTML = '';+ }+ $('stats').innerHTML = `<div class="stat err" style="grid-column:1/-1"><div class="empty">+ <b>Could not load the model</b>+ ${esc(message)}. The model is also downloadable directly at+ <a href="${MODEL_API}">${MODEL_API}</a>, and the npm package works from a saved copy.+ </div></div>`;+}++function skeletons() {+ $('stats').innerHTML = Array.from({ length: 6 }, () => '<div class="stat"><div class="skeleton" style="width:60%"></div><div class="skeleton" style="height:22px;margin-top:10px"></div></div>').join('');+ $('verdict').innerHTML = '<div class="skeleton" style="height:150px"></div>';+}++async function load() {+ skeletons();+ try {+ const [modelRes, registryRes] = await Promise.all([+ fetch(MODEL_API, { headers: { accept: 'application/json' } }),+ fetch(`${MODEL_API}?view=registry`, { headers: { accept: 'application/json' } }).catch(() => null),+ ]);+ if (!modelRes.ok) throw new Error(`the model endpoint returned ${modelRes.status}`);+ const body = await modelRes.json();+ if (!body?.model) throw new Error('the model endpoint returned no model');+ state.model = body.model;+ state.card = body.card;++ if (registryRes?.ok) {+ const reg = await registryRes.json().catch(() => null);+ state.registry = reg?.versions || [];+ }++ renderStats();+ renderLadder();+ renderControls();+ renderVerdict();+ renderWeights();+ renderRegistry();+ renderSnippet();+ } catch (err) {+ renderError(err?.message || String(err));+ }+}++$('wsort').addEventListener('change', (e) => {+ state.sort = e.target.value;+ if (state.model) renderWeights();+});++load();