""" MO§ES SigRank — HF/Gradio Build Small Hackathon. Operator pastes ccusage/codex output -> ingestion -> full profile + board placement. Board ranks by Net Volumetric Yield (Υ). Four raw integers drive everything. """ import gradio as gr import html as _html import math as _math import re as _re from datetime import datetime, timezone from metrics import compute, SEED from ingest import ingest_meta from theme import CSS import db try: from narrate import narrate except Exception: def narrate(name, m, klass): return f"**{klass}.**" # ---------- operator corpus (Supabase if configured, else SEED) ---------- _OPS = None def operators(force=False): """Cached board corpus. Reads from Supabase via db.load_operators() (which itself falls back to metrics.SEED if persistence is unconfigured/down). Cached so a page render isn't one REST call per board; force=True refreshes after a write so a newly-persisted row shows immediately.""" global _OPS if _OPS is None or force: _OPS = db.load_operators() return _OPS def _fmt_int(n): for u,d in (("T",1e12),("B",1e9),("M",1e6),("K",1e3)): if abs(n)>=d: return f"{n/d:.2f}{u}" return str(int(n)) def _fmt_whole(n): """One-decimal K/M/B/T — for the ledger column.""" for u,d in (("T",1e12),("B",1e9),("M",1e6),("K",1e3)): if abs(n)>=d: return f"{n/d:.1f}{u}" return str(int(n)) def _fmt_cost(c): """Adaptive $/1M: keep sub-cent values legible instead of rounding to $0.00. e.g. $0.000195 -> $0.0002 (2 sig figs) rather than $0.00.""" if c >= 1: return f"{c:,.2f}" if c >= 0.01: return f"{c:.3f}" return f"{c:.2g}" def _cost_str(m): c = m.get("avg_cost_1m") if not c: return "\u2014" mark = "~" if m.get("cost_estimated") else "" return f"{mark}${_fmt_cost(c)}" # ---------- leaderboard (HTML hero, log-scaled Υ, cost column) ---------- # column label -> metrics key, used by the "Rank by" control on the board SORT_LABELS = {"Υ yield": "yield", "SNR": "snr", "10x DEV": "dev10x", "velocity": "velocity", "leverage": "leverage", "$/1M": "avg_cost_1m"} def board_html_slim(extra=None): """3-column mini board for the Clock Your Signal tab (SNR · 10x DEV · Υ).""" ops = operators() rows = [(n, compute(*v)) for n, v in ops.items() if not (extra and n == extra[0])] if extra: rows.append(extra) ymax = max((m["yield"] for _, m in rows), default=1) or 1 rows.sort(key=lambda r: r[1]["yield"], reverse=True) out = ['
'] out.append('
' '#operator' 'SNR' '10x DEV' '\u03a5 yield
') for i, (n, m) in enumerate(rows, 1): y = m["yield"]; you = extra and n == extra[0] orders = _math.log10(ymax / y) if y > 0 else 99 barpct = max(2, 100 * (1 - orders / 5)) d = f"{m['dev10x']:.2f}" if m['dev10x'] is not None else "\u2014" rank_cls = f"mb-rank-{i}" if i <= 3 else "" rkey = rarity_class(m)[0] if you: cls = f"species-{rkey} you" row_style = "background:rgba(196,146,58,0.10);color:#E8E0CF;" elif i == 1: cls = f"species-{rkey} rank1" row_style = "background:rgba(196,146,58,0.12);color:#E8E0CF;" else: cls = f"species-{rkey}" row_style = "" ne = _html.escape(n) est_mark = "*" if m.get("cost_estimated") else "" out.append( f'
' f'{i}' f'{ne}{est_mark}' f'{m["snr"]:.3f}' f'{d}' f'' f'' f'{y:,.0f}' f'
' ) out.append('
') out.append('
\u03a5 bar is log-scaled \u00b7 volume can\'t buy rank
') return "".join(out) def board_html(extra=None, sort_key="yield"): ops = operators() # dedup: if `extra` is already persisted, replace it so it shows once + highlighted rows=[(n,compute(*v)) for n,v in ops.items() if not (extra and n==extra[0])] if extra: rows.append(extra) ymax=max((m["yield"] for _,m in rows), default=1) or 1 # Υ bar always scales to Υ asc = sort_key == "avg_cost_1m" # cheapest leads for cost rows.sort(key=lambda r:(r[1].get(sort_key) if r[1].get(sort_key) is not None else float("-inf")), reverse=not asc) out=['
'] out.append('
#' 'operator' 'SNR10x DEV' 'velocityleverage' '$/1M' '\u03a5 yield' 'ratio \u00b7 C:I:O
') for i,(n,m) in enumerate(rows,1): y=m["yield"]; you = extra and n==extra[0] orders=_math.log10(ymax/y) if y>0 else 99 barpct=max(2,100*(1-orders/5)) d=f"{m['dev10x']:.2f}" if m['dev10x'] is not None else "\u2014" rank_cls = f"mb-rank-{i}" if i <= 3 else "" rkey = rarity_class(m)[0] if you: cls = f"mb-row species-{rkey} you" elif i == 1: cls = f"mb-row species-{rkey} rank1" else: cls = f"mb-row species-{rkey}" ne = _html.escape(n) est_mark = " *" if m.get("cost_estimated") else "" out.append(f'
' f'{i}' f'{ne}{est_mark}' f'{m["snr"]:.3f}' f'{d}' f'{m["velocity"]:.2f}' f'{m["leverage"]:,.0f}\u00d7' f'{_cost_str(m)}' f'' f'{y:,.0f}' f'{round((m["raw"]["cache_create"]+m["raw"]["cache_read"])/max(m["raw"]["input"],1))}:1:{round(m["raw"]["output"]/max(m["raw"]["input"],1))}' f'
') out.append('
') out.append('
\u03a5 bar is log-scaled \u00b7 MO\u00a7ES leads the field by ~4 orders of magnitude \u00b7 $/1M blended cost (~ = list-price estimate) \u00b7 * = structural estimation \u00b7 volume can\'t buy rank
') return "".join(out) # raw token pillars: I=input O=output Cw=cache-create Cr=cache-read _METRIC_KEY = [ ("\u03a5 yield", "(Cache \u00b7 Output) / Input\u00b2", "the main efficiency score", "How well you reuse stored info (cache) to produce strong output while keeping new " "input low. Squaring input heavily penalizes wasted tokens \u2014 a high \u03a5 means you're " "getting value from smart reuse, not just throwing more data at the model."), ("SNR", "O / (I+O)", "signal-to-noise", "How much useful, meaningful output (signal) you get versus repetitive or low-value " "fluff (noise). Rewards clean, focused generations over long, rambling ones."), ("leverage", "Cr / I", "cache leverage", "How effectively you reuse previously computed results (cache-read) instead of " "recomputing from fresh input. Big \u2018free\u2019 value from smart memory \u2014 the core " "architectural signal that separates a compounding cache from a stateless pipe."), ("velocity", "O / I", "throughput", "Output produced per input token spent \u2014 single-pass processing speed."), ("10x DEV", "log\u2081\u2080(transmission \u00d7 commitment \u00d7 reuse)", "cascade velocity", "How efficiently the run chains steps together \u2014 the 10\u00d710\u00d720 cascade. The three " "factors telescope to Cr/I, so this is the cascade expressed in orders of magnitude " "(log\u2081\u2080 of leverage). Smoother chaining = higher."), ("$/1M", "blended cost / 1M tokens", "across all states", "Average cost per million tokens across input, output, and cache. Efficient " "architecture is also the cheapest. ~ = recomputed at list price."), ] def metrics_key_html(): """Collapsible legend for the board columns. Definitions match metrics.compute exactly.""" rows = "".join( f'
{n}' f'{f}' f'{a}' f'{d}
' for n, f, a, d in _METRIC_KEY ) return ( '
What do these metrics mean? ' '(tap to expand)' '
' '
Raw pillars: I input \u00b7 O output \u00b7 ' 'Cw cache-create \u00b7 Cr cache-read
' f'{rows}
' ) _STANDARD_METRICS = [ ("Total Tokens", "Input + Output", "Raw count of everything processed. Higher = more usage."), ("Input Tokens", "prompt / context", "How much you feed in \u2014 often the biggest cost driver."), ("Output Tokens", "model generation", "How much the model writes. Longer answers cost more."), ("Tokens/sec \u00b7 Latency", "speed", "How fast it runs \u2014 nothing about how well."), ("Cost ($)", "$ per 1M tokens", "Dollars from token pricing. Counts spend, not skill."), ] _SIGRANK_METRICS = [ ("\u03a5 \u2014 Upsilon", "(Cache \u00d7 Output) / Input\u00b2", "Standard just adds Input + Output. \u03a5 squares input to punish waste while rewarding reuse (cache) and real output.", "Encourages tight, smart prompts instead of long ones."), ("Signal-to-Noise (SNR)", "Out / (In + Out)", "Standard counts every output token equally. SNR separates useful signal from repetitive fluff.", "Rewards quality, not length."), ("Cache Leverage", "Cache-read / Input", "Standard ignores reuse \u2014 every call is fresh. This measures the \u2018free\u2019 work you get from remembering prior results.", "Big win for systems that avoid repeating work."), ("Cascade Velocity", "10 \u00d7 10 \u00d7 20", "Standard might just time the whole run. This tracks smooth chaining of steps (10 focused ops \u2192 10 more \u2192 20\u00d7 leverage).", "Rewards well-designed pipelines over messy long chains."), ] _COMPARE_ROWS = [ ("Focus", "How much you use", "How well you use it"), ("Penalizes", "Nothing \u2014 bigger is often \u2018better\u2019", "Wasteful inputs, fluff, poor reuse"), ("Rewards", "Volume & speed", "Efficiency, quality, smart architecture"), ("Easy to game?", "Very \u2014 just inflate prompts", "Hard \u2014 square penalty + quality checks"), ("Best for", "Billing & raw scale", "Hackathons, governance, Build Small"), ] def metrics_explainer_html(): """The full 'what the metrics mean' education: SigRank vs standard token metrics, the thermodynamic grounding, and a side-by-side comparison.""" std = "".join( f'
{n}' f'{f}
{d}
' for n, f, d in _STANDARD_METRICS) sig = "".join( f'
{n}' f'{f}
' f'
vs standard: {v}
' f'
\u2192 {r}
' for n, f, v, r in _SIGRANK_METRICS) comp = "".join( f'{a}{s}{g}' for a, s, g in _COMPARE_ROWS) return ( '
' '
Standard token metrics are an odometer \u2014 they count ' 'distance (tokens used). SigRank is a fuel-efficiency + ' 'smart-driving score \u2014 it judges how intelligently you drive.
' '
' '
Standard Token Metrics
' f'{std}
Rewards volume & scale \u2014 easy to track, easy to game ' '(this is \u201ctokenmaxxing\u201d).
' '
SigRank Metrics
' f'{sig}
Rewards efficiency, quality & architecture \u2014 the same ' 'numbers, turned into judgment.
' '
' '' '' + comp + '
AspectStandardSigRank
' '
\u25c6 Why square the input? \u2014 the thermodynamic floor
' 'The metrics are grounded in Landauer\u2019s principle: processing or erasing information ' 'carries a real, physical energy cost (on the order of kT\u00b7ln2 per bit). Tokens aren\u2019t free \u2014 ' 'every input bit you push through has a price. SigRank takes that seriously: it rewards ' 'reusing what you already computed (cache) and minimizing fresh input, the way an ' 'efficient engine minimizes wasted heat. Squaring input in \u03a5 is that penalty made concrete.
' '
Bottom line: standard metrics are great for paying the bill. ' 'SigRank adds judgment \u2014 it ranks by cleverness, not consumption. ' 'That\u2019s \u201cown your loop.\u201d
' '
') # ---------- profile ---------- def classify(m): if m["non_compounding"]: return "Non-Compounding \u00b7 stateless pipe" v,l=m["velocity"],m["leverage"] if v>=1 and l>=100: return "Cascade Matrix \u00b7 recursive processing loop" if l>=10 and v<1: return "Cache Architect \u00b7 high structural reuse" if v>=0.5 and l<2: return "Converter Loop \u00b7 single-pass processing velocity" return "Throughput Pipe \u00b7 raw metric bandwidth" def rarity_class(m): """Returns (species_key, label, trait, description). Quadrant Species Designation based on algorithmic efficiency vectors. """ v, l = m["velocity"], m["leverage"] if v >= 1 and l >= 100: return ("cascade", "CASCADE SPECIES", "Compound Cascading Loop", "Multipliers stack across all dimensions. Transmission \u00d7 Commitment \u00d7 Reuse = Leverage. " "Maintains high production velocity while driving compounding architectural feedback.") if l >= 10 and v < 1: return ("architect", "CACHE ARCHITECT", "Persistent Context Layer", "Builds high-reuse caching layers. Every token commit is read across sequential loops. " "Holds state perfectly without requiring linear transformation velocity.") if v >= 0.5: return ("converter", "CONVERTER SPECIES", "Linear Volumetric Output", "High immediate input-to-output context conversion ratio. Maximizes localized turn processing. " "Token footprint does not compound or recur inside long-term retrieval networks.") return ("throughput", "THROUGHPUT SPECIES", "Volumetric Mass Transit", "Processes massive raw token scale across standard pipelines. Focuses on total platform load. " "Optimization vector is execution bandwidth rather than persistent feedback loops.") def comp_bar_html(c): return (f'
' f'
' f'
' f'
' f'
' f'
' f'
' f'read {c["read"]:.1f}% \u00b7 create {c["create"]:.1f}% \u00b7 output {c["output"]:.1f}% \u00b7 input {c["input"]:.3f}%' f'
') def _first_sentence(text, limit=120): t = _re.sub(r"[*_`>#]", "", text or "").replace("\n", " ").strip() parts = _re.split(r"(?<=[.!?])\s", t, maxsplit=1) s = parts[0] if parts else t if len(s) > limit: s = s[:limit].rstrip() + "\u2026" return s def card_html(name, m, rank, total_ops, narration_text): archetype = classify(m).split("\u00b7")[0].strip() rkey, rlabel, passive, effect = rarity_class(m) c = m["composition"] parsing_mode = m.get("_parsing_mode", "") mode_badge = (f'
* {_html.escape(parsing_mode)}
' if parsing_mode else "") if m["transmission"] is not None: cascade = ( f'
{m["transmission"]:.1f}\u00d7trans
' f'\u2192' f'
{m["commitment"]:.1f}\u00d7commit
' f'\u2192' f'
{m["reuse"]:.1f}\u00d7reuse
' f'=' f'
{m["leverage"]:,.0f}\u00d7leverage
' ) else: cascade = '
\u2014non-compounding
' quote = _first_sentence(narration_text) return ( f'
' '
MO\u00a7ES\u2122 SIGRANK
' f'
{rlabel}
' f'
{name}
' f'
{archetype}
' f'
Passive: {passive}
' f'
{effect}
' f'{mode_badge}' f'
{m["yield"]:,.0f}
' '
net volumetric yield
' f'
#{rank} of {total_ops} operators
' f'
{cascade}
' f'{comp_bar_html(c)}' f'
{quote}
' '' '
' ) def profile_md(name, m, rank, total_ops, read=None): c=m["composition"]; r=m["raw"] d=f"{m['dev10x']:.3f}" if m['dev10x'] is not None else "\u2014 non-compounding (no cache_create)" if read is None: read = narrate(name, m, classify(m)) cav = m.get("_caveat") cav_line = f"\n\n`\u26a0 {cav}`" if cav else "" cost_note = " (list-price estimate)" if m.get("cost_estimated") else " (from ccusage)" mode = m.get("_parsing_mode") mode_line = f"\n\n`* {mode}`" if mode else "" return f"""## OPERATOR \u00b7 {name} ranked **#{rank}** of {total_ops} by \u03a5{cav_line}{mode_line} > {read} ### raw ledger (the four pillars) | | tokens | |---|---| | input | {r['input']:,} | | output | {r['output']:,} | | cache_create | {r['cache_create']:,} | | cache_read | {r['cache_read']:,} | | **total** | **{m['total']:,}** | ### board metrics | metric | value | | |---|---|---| | SNR | {m['snr']:.3f} | output share | | 10x DEV | {d} | amplification exponent | | Operating Ratio | {m['op_ratio']} | vs AA 7:2:1 | | Velocity | {m['velocity']:.3f}\u00d7 | output per input | | Leverage | {m['leverage']:,.1f}\u00d7 | reads per human token | | Efficiency | {m['efficiency']:,.1f}\u00d7 | vs AA baseline | | Avg $/1M | ${_fmt_cost(m['avg_cost_1m'])} |{cost_note} | | **\u03a5 Yield** | **{m['yield']:,.2f}** | un-gameable rank | **cascade** \u2014 {m['cascade_str']} (transmission \u00d7 commitment \u00d7 reuse) **scale V** \u2014 {m['V']:.2f} """ def _greatest_hits_html(name): """Render top sessions for this operator from session history.""" history = db.load_session_history(name, limit=5) if not history: return "" rows = [] for h in history: i = int(h.get("input", 0) or 0) o = int(h.get("output", 0) or 0) cw = int(h.get("cache_create", 0) or 0) cr = int(h.get("cache_read", 0) or 0) m = compute(i, o, cw, cr) ts = h.get("submitted_at", "") if ts: try: dt = datetime.fromisoformat(ts.replace("Z", "+00:00")) ts = dt.strftime("%Y-%m-%d %H:%M UTC") except (ValueError, TypeError): pass src = h.get("source", "") rows.append( f'{ts}{_fmt_int(m["yield"])}' f'{m["velocity"]:.2f}\u00d7{m["leverage"]:,.0f}\u00d7' f'{src}' ) return ( '
' '

Greatest Hits

' '' '' + "".join(rows) + '
when\u03a5vellevsource
' '
' ) # ---------- ingestion handler ---------- def run_ingest(blob, name, request: gr.Request): hf_user = None if request: hf_user = getattr(request, "username", None) name=(name or "you").strip()[:24] or "you" try: i,o,cw,cr,meta = ingest_meta(blob or "") except Exception as e: return ("Paste your `ccusage claude --json` output, your " "`ccusage codex --json` output, or `ccusage --json` " "for all providers. You can also paste four numbers: " "input output cache_create cache_read.\n\n" f"_parser said: {e}_"), "", "", "" if i+o+cw+cr==0: return "Got zeros \u2014 check your paste.", "", "", "" m=compute(i,o,cw,cr, cost_usd=meta.get("cost")) if meta.get("estimated"): m["_caveat"]=meta.get("caveat") if meta.get("parsing_mode"): m["_parsing_mode"] = meta["parsing_mode"] # persist only if HF-authenticated + writes configured saved=False if hf_user and db.writes_enabled(): saved=db.save_operator(name,i,o,cw,cr, cost=meta.get("cost"), source=meta.get("source","manual"), estimated=bool(meta.get("estimated")), caveat=meta.get("caveat"), hf_user=hf_user) base=operators(force=saved) rows=[(nn,compute(*vv)) for nn,vv in base.items() if nn!=name]+[(name,m)] rows.sort(key=lambda r:r[1]['yield'],reverse=True) rank=next(idx for idx,(nn,_) in enumerate(rows,1) if nn==name) read = narrate(name, m, classify(m)) save_note = "" if not hf_user: save_note = "\n\n*\u26a0 Sign in with HuggingFace to save your entry to the board. Paste-only results are a snapshot \u2014 not persisted.*" elif saved: save_note = f"\n\n*Saved to the board as **{_html.escape(name)}** at {datetime.now(timezone.utc).strftime('%Y-%m-%d %H:%M UTC')}.*" hits_html = _greatest_hits_html(name) if hf_user else "" profile = profile_md(name,m,rank,len(rows),read) + save_note return (profile, comp_bar_html(m["composition"]), card_html(name,m,rank,len(rows),read), hits_html) # ---------- interactive leaderboard helpers ---------- def resort_board(label): """Re-render the board sorted by the chosen column (the 'Rank by' control).""" return board_html(sort_key=SORT_LABELS.get(label, "yield")) def view_operator(name): """Render a corpus operator's full profile + share card + learn-from insights.""" ops = operators() if not name or name not in ops: return "", "", "" m = compute(*ops[name]) rows = sorted(((n, compute(*v)) for n, v in ops.items()), key=lambda r: r[1]["yield"], reverse=True) rank = next(i for i, (n, _) in enumerate(rows, 1) if n == name) read = narrate(name, m, classify(m)) return (profile_md(name, m, rank, len(rows), read), card_html(name, m, rank, len(rows), read), insights_html(name, m)) def insights_html(name, m): """Reader takeaways: what this operator does well + what to avoid.""" good, avoid = [], [] lev, snr, vel = m["leverage"], m["snr"], m["velocity"] if lev >= 100: good.append("Exceptional cache reuse — context is re-read, not rebuilt each turn.") elif lev >= 10: good.append("Solid cache leverage — compounding on prior work.") else: avoid.append("Low cache leverage — mostly fresh input each turn (recompute waste).") if snr >= 0.5: good.append("High signal — most tokens are model output, not prompt bloat.") else: avoid.append("Low signal-to-noise — large input vs. output; tighten prompts.") if m["non_compounding"]: avoid.append("No cache-create — stateless pipe, no architectural compounding.") else: good.append("Compounding architecture — building reusable context, not one-shotting.") if vel >= 1: good.append("Strong throughput — produces more than it consumes.") elif vel < 0.3: avoid.append("Low velocity — heavy input for little output.") g = "".join(f"
  • {x}
  • " for x in good) or "
  • " a = "".join(f"
  • {x}
  • " for x in avoid) or "
  • Nothing major — clean architecture.
  • " return (f'
    ' f'
    ✓ Doing well
    ' f'
    ✕ Watch out
    ') def operator_segments(): """Live counts: burners (spend, no reuse), builders (compounding), 10×ers (elite reuse).""" burn = build = tenx = 0 for v in operators().values(): lev = compute(*v)["leverage"] if lev < 2: burn += 1 elif lev >= 1000: tenx += 1 else: build += 1 return burn, build, tenx, burn + build + tenx # ---------- VS / compare ---------- # (label, metrics key, winner = max|min, value formatter) _CMP_ROWS = [ ("Υ yield", "yield", "max", lambda v: f"{v:,.0f}"), ("SNR", "snr", "max", lambda v: f"{v:.3f}"), ("leverage", "leverage", "max", lambda v: f"{v:,.0f}×"), ("velocity", "velocity", "max", lambda v: f"{v:.2f}×"), ("10x DEV", "dev10x", "max", lambda v: f"{v:.2f}"), ("$/1M", "avg_cost_1m", "min", lambda v: f"${_fmt_cost(v)}"), ] def compare_html(names): """Head-to-head table for 2–3 operators; best value per row gets the gold cell.""" ops = operators() names = [n for n in (names or []) if n in ops][:3] if len(names) < 2: return ('
    Pick 2–3 operators above to put them ' 'head-to-head. Winner takes each row.
    ') ms = [(n, compute(*ops[n])) for n in names] head = "".join(f'{_html.escape(n)}' for n, _ in ms) body = [] for label, key, mode, fmt in _CMP_ROWS: vals = [m.get(key) for _, m in ms] nums = [v for v in vals if v is not None] best = (max if mode == "max" else min)(nums) if nums else None cells = [] for v in vals: win = v is not None and best is not None and v == best and len(nums) > 1 cells.append(f'' f'{fmt(v) if v is not None else "—"}') body.append(f'{label}{"".join(cells)}') return (f'{head}' f'{"".join(body)}
    ' '
    Gold = leads that metric · $/1M: lower wins · ' 'Υ is the overall rank metric.
    ') # ---------- Home / landing ---------- def profile_marquee_html(): """Auto-scrolling band of operator chips (rank · name · Υ · leverage). Pure CSS loop.""" ops = operators() rows = sorted(((n, compute(*v)) for n, v in ops.items()), key=lambda r: r[1]["yield"], reverse=True) def chip(rank, n, m): rk = rarity_class(m)[0] return (f'
    ' f'#{rank}' f'{_html.escape(n)}' f'Υ {m["yield"]:,.0f}' f'{m["leverage"]:,.0f}× lev
    ') chips = "".join(chip(i, n, m) for i, (n, m) in enumerate(rows, 1)) # chips duplicated so the translateX(-50%) loop is seamless return f'
    {chips}{chips}
    ' # ---- the metric standard (green feature row) ---- # (symbol, metrics key, equation, value-format, hover description) _FEATURE_METRICS = [ ("Υ", "yield", "(Cache·Output) / Input²", "{v:,.0f}", "The efficiency score. Reused context (cache) × produced output, measured against " "fresh input squared — squaring input is why raw volume can't buy rank."), ("SNR", "snr", "Out / (In+Out)", "{v:.2f}", "Signal-to-noise. Share of the exchange that's model output vs. prompt/input. " "Higher = focused, less bloat."), ("10x", "dev10x", "log₁₀(cascade)", "{v:.2f}", "The cascade in orders of magnitude (log₁₀ of leverage) — the 10× developer multiplier."), ("$/1M", "avg_cost_1m", "blended cost / 1M", "${v}", "Blended cost per million tokens across all states. Efficient architecture is also " "the cheapest — so cost falls out of good design."), ] def _corpus_metric_values(key): vals = [compute(*v).get(key) for v in operators().values()] return sorted(x for x in vals if x is not None) def _median(vals): n = len(vals) if not n: return 0 return vals[n // 2] if n % 2 else (vals[n // 2 - 1] + vals[n // 2]) / 2 def _status_box_html(): """Live system status + segment counters — rendered as a metric box.""" burn, build, tenx, tot = operator_segments() return ( '
    ' '
    ONLINE
    ' '
    ' f'BURNERS{burn:03d}' f'BUILDERS{build:03d}' f'10×ERS{tenx:03d}' f'SIGNALS{tot:03d}' '
    ') def metric_features_html(): boxes = [] for sym, key, form, fmt, desc in _FEATURE_METRICS: vals = _corpus_metric_values(key) avg = sum(vals) / len(vals) if vals else 0 big = f"${_fmt_cost(avg)}" if key == "avg_cost_1m" else fmt.format(v=avg) boxes.append( f'
    {sym}
    ' f'
    {big}
    ' f'
    {form}
    ' f'
    {desc}
    ') boxes.insert(2, _status_box_html()) # between SNR and 10x return ('
    Introducing the new standard in ' 'AI metrics & benchmarks
    ' f'
    {"".join(boxes)}
    ' '
    field average · live counts · hover any metric for what it means
    ') # ---- real mini renders of each page (live HTML, scaled into a framed thumbnail) ---- def _top_rows(n): return sorted(((k, compute(*v)) for k, v in operators().items()), key=lambda r: r[1]["yield"], reverse=True)[:n] def _mini(cap, inner, accent): """Frame real page HTML as a browser-chrome thumbnail; CSS scales it down.""" return (f'
    ' f'
    ' f'
    {cap}
    ' f'
    {inner}
    ') def _mini_leaders(): return _mini("sigrank · leaders", board_html(), "gold") def _mini_reports(): k, m = _top_rows(1)[0] read = narrate(k, m, classify(m)) return _mini("sigrank · reports", card_html(k, m, 1, len(operators()), read), "purple") def _mini_vs(): return _mini("sigrank · vs", compare_html([k for k, _ in _top_rows(3)]), "blue") def _mini_create(): inner = ( '
    ' '
    $ ./sigrank --submit
    ' '
    paste ccusage JSON — or four numbers:
    ' '1251211 11296121 128196310 2555179769
    ' '
    ⬡ Clock My Signal
    ' '
    Υ 18,437 · CASCADE MATRIX
    ') return _mini("sigrank · create", inner, "green") _HOME_SECTIONS = [ ("Leaders", "Prove your signal", "The burn-vs-build board — who wins on architecture, not spend.", _mini_leaders, "gold"), ("Reports", "Study the field", "Pull any operator's full read. R&D — improve yourself.", _mini_reports, "purple"), ("VS", "Head-to-head", "Who's actually 10×? Who's amplifying signal — and at what cost?", _mini_vs, "blue"), ("Create", "Clock your signal", "Drop your ledger, get scored, claim your operator card.", _mini_create, "green"), ] def home_html(): boxes = "".join( f'
    {mini()}' f'
    ◢ {t}
    ' f'
    {s}
    {d}
    ' f'
    open the {t} tab →
    ' for t, s, d, mini, accent in _HOME_SECTIONS ) return f'
    {boxes}
    ' # Delegated click: clicking a Home mini switches to that tab (Gradio tabs are buttons). _TAB_CLICK_JS = """() => { document.addEventListener('click', (e) => { const box = e.target.closest('.hm-box[data-tab]'); if (!box) return; const name = (box.getAttribute('data-tab') || '').trim().toUpperCase(); const btn = [...document.querySelectorAll('.tab-container button, .tab-nav button')] .find(b => b.textContent.trim().toUpperCase() === name); if (btn) btn.click(); }); }""" def home_footer_html(): loom = "https://www.loom.com/share/edc345e2e5164e20aed3acb6436a08c3" return ( '
    ' '
    Watch the demo
    ' f'▶ Play demo video
    ' '
    Get ranked in 3 steps
    ' '
      ' '
    1. Run npx ccusage@latest claude --json
    2. ' '
    3. Open Create, paste it (or four numbers)
    4. ' '
    5. Get your Υ score + operator card
    ' '
    More
    ' 'mos2es.com' 'benchmarks' '@burnmydays on X' '
    ' ) # ---------- UI ---------- import os as _os import base64 as _base64 _ON_SPACE = bool(_os.environ.get("SPACE_ID")) # MO§ES logo (gold § in concentric rings on a dark disc), as a base64 data-URI # so it survives Gradio's HTML sanitizer (which strips inline ). _LOGO_SVG = ( "" "" "" "" "§" "" ) _LOGO_DATA_URI = "data:image/svg+xml;base64," + _base64.b64encode(_LOGO_SVG.encode("utf-8")).decode("ascii") # Ghost/"unminted" card so the right column is never an empty void on first load. CARD_PLACEHOLDER = ( '
    ' '
    MO\u00a7ES\u2122 SIGRANK
    ' '
    UNMINTED
    ' '
    Awaiting Operator\u2026
    ' '
    Signal Offline
    ' '
    0,000
    ' '
    insert token ledger to scan
    ' '
    ' ) def _build_demo(): _blocks_kw = {"title": "MO\u00a7ES SigRank"} _b = gr.Blocks(**_blocks_kw) # dynamic hero stats (don't hardcode counts that drift when the corpus changes) _ops_now = operators() _names = list(_ops_now.keys()) _ys = sorted((compute(*v)["yield"] for v in _ops_now.values()), reverse=True) _lead = (_ys[0] / _ys[1]) if len(_ys) > 1 and _ys[1] > 0 else 0.0 _burn, _build, _tenx, _tot = operator_segments() with _b: with gr.Column(elem_id="moses-hero"): gr.HTML( "
    " "
    " "
    Powered by MO\u00a7ES\u2122
    " "

    SIGRANK

    " "
    " "
    " "
    Ranking AI operators on performance, production, architecture & cost efficiency.
    " "
    " "
    Identifying Burners, Builders, and 10×ers.
    " ) # full-width live leaderboard scroller (replaces the old static stat strip) gr.HTML(profile_marquee_html()) # ---- TAB: Home (landing — metric standard + section minis + links) ---- with gr.Tab("Home"): gr.HTML(metric_features_html()) gr.HTML(home_html()) gr.HTML(home_footer_html()) # ---- TAB: Create (clock your signal \u2014 the importer) ---- with gr.Tab("Create"): gr.Markdown("### Primary path \u2014 run the local importer") gr.Markdown("Reads your usage on your own machine. **Nothing leaves your computer.** Clone it once, then run:") gr.Code(value="git clone https://github.com/Burnmydays/hf-\ncd hf-\n./sigrank", language="shell", show_label=False, elem_id="clone-code") with gr.Accordion("More options \u2014 Codex, all providers, or paste instead", open=False): gr.Markdown("""`./sigrank --codex` reads Codex usage \u00b7 `./sigrank --all` runs every provider in turn. **No terminal? Paste instead (the backup).** Run one of these, copy the JSON, drop it in the box below: ``` npx ccusage@latest claude --json ``` ``` npx ccusage@latest codex --json ``` \u26a0\ufe0f Run Claude and Codex **separately** \u2014 never bare `ccusage --json` (it merges every agent and distorts the read). No JSON? Type four numbers: `input output cache_create cache_read`. *Codex input is estimated (\\*): alone \u2192 AA 2:1 baseline; with a Claude profile \u2192 your own Claude input:output ratio.*""") gr.HTML("
    ") with gr.Row(): with gr.Column(scale=5): gr.Markdown("### Ingest a signal") if _ON_SPACE: gr.LoginButton(elem_id="hf-login-btn") else: gr.Markdown("*HuggingFace login available on the hosted Space \u2014 local mode is transient.*", elem_id="moses-foot") nm = gr.Textbox(label="operator name / handle", placeholder="your handle", max_lines=1) blob = gr.Textbox(label="ccusage JSON \u2014or\u2014 four numbers (I O C R)", lines=5, placeholder='Paste ccusage JSON here\n\nor four numbers: input output cache_create cache_read\n\nExample: 1251211 11296121 128196310 2555179769') go = gr.Button("Clock My Signal", variant="primary", elem_id="compute-btn") gr.Markdown("### Greatest hits") hits = gr.HTML() with gr.Column(scale=6): gr.Markdown("### Minted operator card") card = gr.HTML(CARD_PLACEHOLDER) gr.Markdown("*Right-click \u2192 Save image to share your architectural footprint.*", elem_id="moses-foot") prof_bar = gr.HTML() prof = gr.Markdown(elem_id="moses-profile") go.click(run_ingest, [blob, nm], [prof, prof_bar, card, hits]) gr.Examples( examples=[ ['{"totals":{"inputTokens":1251211,"outputTokens":11296121,"cacheCreationTokens":128196310,"cacheReadTokens":2555179769}}','MO\u00a7ES'], ['{"data":[{"inputTokens":58920000,"cachedInputTokens":707300000,"outputTokens":3500000,"reasoningOutputTokens":510000}]}','codex-operator'], ['1251211 11296121 128196310 2555179769', 'manual-paste'], ], inputs=[blob, nm]) gr.Markdown("### What the metrics mean") gr.HTML(metrics_explainer_html()) # ---- TAB: Leaders (the board) ---- with gr.Tab("Leaders"): rank_by = gr.Radio(list(SORT_LABELS.keys()), value="\u03a5 yield", show_label=False, elem_id="rank-by") lb = gr.HTML(board_html()) rank_by.change(resort_board, rank_by, lb) gr.Markdown("**The ledger doesn't care what you claim.** Ranked by **\u03a5 = (Cache\u00b7Output)/Input\u00b2**. The ratio column is cache:input:output (input = 1). $/1M is blended cost \u2014 efficient architecture is also the cheapest.") gr.HTML(metrics_key_html()) gr.Markdown("*Curated corpus \u00b7 pasting scores you live but isn't persisted unless you sign in \u00b7 $/1M is a list-price recompute (~) \u00b7 \\* = structural estimation.*", elem_id="moses-foot") # ---- TAB: VS (head-to-head compare) ---- with gr.Tab("VS"): gr.Markdown("### Put operators head-to-head\nSelect 2\u20133 operators. Gold cell wins each metric. **This is where architecture beats budget in plain sight.**") cmp_pick = gr.Dropdown(_names, label="Operators (pick 2\u20133)", value=None, multiselect=True, max_choices=3, elem_id="cmp-pick") cmp_out = gr.HTML(compare_html(None)) cmp_pick.change(compare_html, cmp_pick, cmp_out) # ---- TAB: Reports (operator profile inspector) ---- with gr.Tab("Reports"): gr.Markdown("### Full architectural read on any operator\nPick a name to pull their complete profile, a shareable card, and **what to learn from them**.") with gr.Row(): with gr.Column(scale=5): op_pick = gr.Dropdown(_names, label="Operator", value=None, elem_id="op-pick") op_card = gr.HTML(CARD_PLACEHOLDER) with gr.Column(scale=6): op_prof = gr.Markdown(elem_id="moses-profile") op_insights = gr.HTML() op_pick.change(view_operator, op_pick, [op_prof, op_card, op_insights]) gr.Markdown(elem_id="moses-foot", value="""Four integers in, full ledger out. Architecture is the only variable that matters. Wild corpus: tokscale.ai footprints \u00b7 MO\u00a7ES row verified ccusage \u00b7 * = structural estimation.""") _b.load(None, None, None, js=_TAB_CLICK_JS) # make Home minis clickable \u2192 tab switch return _b demo = _build_demo() if __name__ == "__main__": demo.launch(css=CSS, theme=gr.themes.Base())