Skip to content

Commit c539b7f

Browse files
manojmallickclaude
andcommitted
feat(proof): auto-sync official numbers from sigmap core (ISR daily)
fetchOfficial() pulls benchmarks/latest.json from the core repo (the same source sigmap.io renders from) at build + revalidates daily; the hardcoded OFFICIAL is now just the fallback. /benchmark and /demo derive their headline metrics, official section, caption, and caveats from the live fetch, so when the core team bumps the benchmark (e.g. v9.0) the demo updates within a day — no redeploy, no hand-editing. Falls back gracefully if the fetch fails. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent 2454bb3 commit c539b7f

3 files changed

Lines changed: 138 additions & 53 deletions

File tree

src/app/benchmark/page.tsx

Lines changed: 22 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
import type { Metadata } from "next";
22
import Link from "next/link";
33
import {
4-
HEADLINE,
5-
OFFICIAL,
4+
fetchOfficial,
5+
headlineFrom,
6+
caveatsFrom,
67
OFFICIAL_URL,
78
SCALE,
89
BY_LANGUAGE,
910
TASKS,
1011
AGENT,
11-
CAVEATS,
1212
METHODOLOGY_URL,
1313
} from "@/lib/benchmark-data";
1414

@@ -18,9 +18,15 @@ export const metadata: Metadata = {
1818
"The official SigMap benchmark: 87.8% retrieval hit@5 (vs 13.6% baseline), 97% token reduction, 67.8% task success across 21 repos / 90 tasks — plus an independent 405-repo reproduction. Reproducible, no LLM API.",
1919
};
2020

21+
// Re-pull the official numbers from the core repo about once a day (ISR).
22+
export const revalidate = 86_400;
23+
2124
const nf = new Intl.NumberFormat("en-US");
2225

23-
export default function BenchmarkPage() {
26+
export default async function BenchmarkPage() {
27+
const official = await fetchOfficial();
28+
const headline = headlineFrom(official);
29+
const caveats = caveatsFrom(official);
2430
return (
2531
<main className="mx-auto max-w-4xl px-6 py-16">
2632
{/* Hero */}
@@ -46,7 +52,7 @@ export default function BenchmarkPage() {
4652
</p>
4753

4854
<dl className="grid grid-cols-1 gap-3 sm:grid-cols-3">
49-
{HEADLINE.map((m) => (
55+
{headline.map((m) => (
5056
<div
5157
key={m.label}
5258
className="rounded-lg border border-zinc-200 p-4 dark:border-zinc-800"
@@ -72,12 +78,12 @@ export default function BenchmarkPage() {
7278
{/* Official benchmark — the canonical sigmap.io numbers */}
7379
<section className="mb-14 space-y-4">
7480
<h2 className="text-lg font-bold tracking-tight">
75-
1 · The official SigMap benchmark ({OFFICIAL.reposToken} repos,{" "}
76-
{OFFICIAL.tasks} tasks)
81+
1 · The official SigMap benchmark ({official.reposToken} repos,{" "}
82+
{official.tasks} tasks)
7783
</h2>
7884
<p className="text-sm text-zinc-600 dark:text-zinc-400">
7985
These are the canonical numbers from the SigMap core repo
80-
(<code>benchmarks/latest.json</code>, {OFFICIAL.version}) — the same
86+
(<code>benchmarks/latest.json</code>, {official.version}) — the same
8187
figures published on{" "}
8288
<a
8389
href={OFFICIAL_URL}
@@ -91,10 +97,10 @@ export default function BenchmarkPage() {
9197
</p>
9298
<div className="grid grid-cols-2 gap-3 sm:grid-cols-4">
9399
{[
94-
{ v: `${OFFICIAL.hitAt5Pct}%`, l: `hit@5 (vs ${OFFICIAL.baselineHitAt5Pct}% baseline)` },
95-
{ v: `${OFFICIAL.retrievalLiftX}×`, l: "retrieval lift" },
96-
{ v: `${OFFICIAL.tokenReductionPct}%`, l: "token reduction" },
97-
{ v: `${OFFICIAL.taskSuccessPct}%`, l: `task success (vs ${OFFICIAL.baselineTaskSuccessPct}%)` },
100+
{ v: `${official.hitAt5Pct}%`, l: `hit@5 (vs ${official.baselineHitAt5Pct}% baseline)` },
101+
{ v: `${official.retrievalLiftX}×`, l: "retrieval lift" },
102+
{ v: `${official.tokenReductionPct}%`, l: "token reduction" },
103+
{ v: `${official.taskSuccessPct}%`, l: `task success (vs ${official.baselineTaskSuccessPct}%)` },
98104
].map((s) => (
99105
<div
100106
key={s.l}
@@ -108,8 +114,8 @@ export default function BenchmarkPage() {
108114
))}
109115
</div>
110116
<p className="text-xs text-zinc-500">
111-
Also: {OFFICIAL.promptReductionPct}% fewer prompts per task (
112-
{OFFICIAL.baselinePromptsPerTask}{OFFICIAL.promptsPerTask}). No LLM
117+
Also: {official.promptReductionPct}% fewer prompts per task (
118+
{official.baselinePromptsPerTask}{official.promptsPerTask}). No LLM
113119
API in the measurement — fully reproducible.
114120
</p>
115121
</section>
@@ -125,7 +131,7 @@ export default function BenchmarkPage() {
125131
{nf.format(SCALE.tokensAfter)} tokens, a{" "}
126132
<strong>{SCALE.overallReductionPct}%</strong> overall reduction
127133
({SCALE.avgReductionPct}% average per repo). That&apos;s consistent with
128-
the official {OFFICIAL.tokenReductionPct}% at ~19× the scale.{" "}
134+
the official {official.tokenReductionPct}% at ~19× the scale.{" "}
129135
{SCALE.reposExcluded} repos use languages SigMap doesn&apos;t yet parse
130136
and are excluded.
131137
</p>
@@ -257,7 +263,7 @@ export default function BenchmarkPage() {
257263
What these numbers don&apos;t say
258264
</h2>
259265
<ul className="space-y-2 text-xs text-zinc-600 dark:text-zinc-400">
260-
{CAVEATS.map((c) => (
266+
{caveats.map((c) => (
261267
<li key={c} className="flex gap-2">
262268
<span className="text-zinc-400"></span>
263269
<span>{c}</span>

src/app/demo/page.tsx

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,20 +4,16 @@ import { DemoClient } from "@/components/DemoClient";
44
import { CopyCommand } from "@/components/CopyCommand";
55
import { FeatureGrid } from "@/components/FeatureGrid";
66
import { LiveStats } from "@/components/LiveStats";
7+
import { fetchOfficial } from "@/lib/benchmark-data";
78

89
export const metadata: Metadata = {
910
title: "SigMap Demo — verified context for AI coding agents",
1011
description:
1112
"Paste a GitHub repo. SigMap extracts verified signatures and ranks the files that matter — feeding AI coding agents the right context with up to ~97% fewer tokens.",
1213
};
1314

14-
// SigMap's published benchmark figures (sigmap.io).
15-
const METRICS = [
16-
{ value: "97%", label: "fewer tokens" },
17-
{ value: "87.8%", label: "hit@5 retrieval" },
18-
{ value: "67.8%", label: "task success" },
19-
{ value: "6.5×", label: "retrieval lift" },
20-
];
15+
// Re-pull the official numbers from the core repo about once a day (ISR).
16+
export const revalidate = 86_400;
2117

2218
const STEPS = [
2319
{
@@ -37,7 +33,14 @@ const STEPS = [
3733
},
3834
];
3935

40-
export default function DemoPage() {
36+
export default async function DemoPage() {
37+
const o = await fetchOfficial();
38+
const METRICS = [
39+
{ value: `${o.tokenReductionPct}%`, label: "fewer tokens" },
40+
{ value: `${o.hitAt5Pct}%`, label: "hit@5 retrieval" },
41+
{ value: `${o.taskSuccessPct}%`, label: "task success" },
42+
{ value: `${o.retrievalLiftX}×`, label: "retrieval lift" },
43+
];
4144
return (
4245
<main className="mx-auto max-w-4xl px-6 py-16">
4346
<header className="mb-12 space-y-5">
@@ -109,7 +112,8 @@ export default function DemoPage() {
109112
))}
110113
</dl>
111114
<p className="text-xs text-zinc-400">
112-
SigMap v8.9 benchmark · 21 repos · 90 tasks · sigmap.io
115+
SigMap {o.version} benchmark · {o.reposToken} repos · {o.tasks} tasks ·
116+
sigmap.io
113117
</p>
114118
</header>
115119

src/lib/benchmark-data.ts

Lines changed: 103 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,36 @@
11
/**
22
* Benchmark results, baked as static data (no API cost to render).
33
*
4-
* The OFFICIAL numbers mirror the SigMap source of truth — `benchmarks/latest.json`
5-
* in the core repo (synced to sigmap.io). The SCALE / TASKS / AGENT blocks are our
6-
* own independent, larger reproductions, kept consistent with the official figures.
4+
* The OFFICIAL numbers are pulled at build/ISR time from the SigMap core repo's
5+
* `benchmarks/latest.json` (the same source sigmap.io renders from), so the demo
6+
* stays in sync automatically. The hardcoded OFFICIAL below is the fallback if
7+
* the fetch fails. SCALE / TASKS / AGENT are our own independent reproductions.
78
*/
89

910
export const METHODOLOGY_URL =
1011
"https://github.com/manojmallick/sigmap-benchmark-suite";
1112
export const OFFICIAL_URL = "https://sigmap.io/guide/benchmark.html";
13+
const RAW_LATEST_URL =
14+
"https://raw.githubusercontent.com/manojmallick/sigmap/main/benchmarks/latest.json";
1215

13-
/**
14-
* Official SigMap benchmark — the canonical numbers from the core repo's
15-
* `benchmarks/latest.json` (id sigmap-v8.9-main), the same figures shown on
16-
* sigmap.io. Generated from the benchmark suite, never hand-typed there.
17-
*/
18-
export const OFFICIAL = {
16+
export interface Official {
17+
version: string;
18+
reposToken: number;
19+
reposRetrieval: number;
20+
tasks: number;
21+
hitAt5Pct: number;
22+
baselineHitAt5Pct: number;
23+
retrievalLiftX: number;
24+
tokenReductionPct: number;
25+
taskSuccessPct: number;
26+
baselineTaskSuccessPct: number;
27+
promptsPerTask: number;
28+
baselinePromptsPerTask: number;
29+
promptReductionPct: number;
30+
}
31+
32+
/** Fallback / default — mirrors sigmap-v8.9-main; overridden by the live fetch. */
33+
export const OFFICIAL: Official = {
1934
version: "v8.9",
2035
reposToken: 21,
2136
reposRetrieval: 18,
@@ -29,19 +44,78 @@ export const OFFICIAL = {
2944
promptsPerTask: 1.44,
3045
baselinePromptsPerTask: 2.84,
3146
promptReductionPct: 49.2,
32-
} as const;
47+
};
48+
49+
const round1 = (n: number) => Math.round(n * 10) / 10;
50+
/** Accept a fraction (0.878) or an already-percent value (97). */
51+
const asPct = (x: unknown, fallback: number) =>
52+
typeof x === "number" ? round1(x <= 1 ? x * 100 : x) : fallback;
53+
const num = (x: unknown, fallback: number) =>
54+
typeof x === "number" ? x : fallback;
55+
56+
interface LatestJson {
57+
benchmark_id?: string;
58+
repos_token?: number;
59+
repos_retrieval?: number;
60+
tasks?: number;
61+
metrics?: {
62+
hit_at_5?: number;
63+
baseline_hit_at_5?: number;
64+
retrieval_lift?: number;
65+
overall_token_reduction_pct?: number;
66+
task_success_proxy_pct?: number;
67+
prompts_per_task?: number;
68+
baseline_prompts_per_task?: number;
69+
prompt_reduction_pct?: number;
70+
};
71+
}
3372

34-
/** Headline numbers — the official SigMap benchmark (matches sigmap.io). */
35-
export const HEADLINE = [
36-
{ value: "97%", label: "fewer tokens", sub: "official · 21 repos" },
37-
{ value: "87.8%", label: "retrieval hit@5", sub: "vs 13.6% baseline · 6.5× lift" },
38-
{ value: "67.8%", label: "task success", sub: "vs 10% without context" },
39-
] as const;
73+
/**
74+
* Fetch the official numbers from the core repo (ISR-cached ~daily). Falls back
75+
* to the hardcoded OFFICIAL on any error, so the page never breaks.
76+
*/
77+
export async function fetchOfficial(): Promise<Official> {
78+
try {
79+
const res = await fetch(RAW_LATEST_URL, { next: { revalidate: 86_400 } });
80+
if (!res.ok) return OFFICIAL;
81+
const j = (await res.json()) as LatestJson;
82+
const m = j.metrics ?? {};
83+
const ver = String(j.benchmark_id ?? "").match(/v[\d.]+/)?.[0];
84+
return {
85+
version: ver ?? OFFICIAL.version,
86+
reposToken: num(j.repos_token, OFFICIAL.reposToken),
87+
reposRetrieval: num(j.repos_retrieval, OFFICIAL.reposRetrieval),
88+
tasks: num(j.tasks, OFFICIAL.tasks),
89+
hitAt5Pct: asPct(m.hit_at_5, OFFICIAL.hitAt5Pct),
90+
baselineHitAt5Pct: asPct(m.baseline_hit_at_5, OFFICIAL.baselineHitAt5Pct),
91+
retrievalLiftX: num(m.retrieval_lift, OFFICIAL.retrievalLiftX),
92+
tokenReductionPct: asPct(m.overall_token_reduction_pct, OFFICIAL.tokenReductionPct),
93+
taskSuccessPct: asPct(m.task_success_proxy_pct, OFFICIAL.taskSuccessPct),
94+
baselineTaskSuccessPct: OFFICIAL.baselineTaskSuccessPct,
95+
promptsPerTask: num(m.prompts_per_task, OFFICIAL.promptsPerTask),
96+
baselinePromptsPerTask: num(m.baseline_prompts_per_task, OFFICIAL.baselinePromptsPerTask),
97+
promptReductionPct: asPct(m.prompt_reduction_pct, OFFICIAL.promptReductionPct),
98+
};
99+
} catch {
100+
return OFFICIAL;
101+
}
102+
}
103+
104+
/** Headline cards from the official numbers (matches sigmap.io). */
105+
export function headlineFrom(o: Official) {
106+
return [
107+
{ value: `${o.tokenReductionPct}%`, label: "fewer tokens", sub: `official · ${o.reposToken} repos` },
108+
{ value: `${o.hitAt5Pct}%`, label: "retrieval hit@5", sub: `vs ${o.baselineHitAt5Pct}% baseline · ${o.retrievalLiftX}× lift` },
109+
{ value: `${o.taskSuccessPct}%`, label: "task success", sub: `vs ${o.baselineTaskSuccessPct}% without context` },
110+
];
111+
}
112+
113+
/** Static headline from the fallback — used by the OG card (build-time only). */
114+
export const HEADLINE = headlineFrom(OFFICIAL);
40115

41116
/**
42-
* Independent extended reproduction — we ran whole-repo extraction 19× larger
43-
* than the official set (405 repos) to stress-test the token-reduction claim.
44-
* 98.7% overall is consistent with the official 97%.
117+
* Independent extended reproduction — whole-repo extraction 19× larger than the
118+
* official set (405 repos). 98.7% overall is consistent with the official 97%.
45119
*/
46120
export const SCALE = {
47121
reposProcessed: 405,
@@ -84,13 +158,12 @@ export const TASKS = {
84158
tokensAfter: 45_866,
85159
costBefore: 1.7261,
86160
costAfter: 0.0179,
87-
retrievalPct: 62.7, // right file in top-5 on this broad set (harder than the curated 18)
161+
retrievalPct: 62.7,
88162
} as const;
89163

90164
/**
91165
* Agent A/B — does the token saving make a real agent (Devin) faster? Honest
92-
* answer after a 3-rep A/B: no robust wall-clock difference (within noise). An
93-
* early single run looked like a big win, but that was n=1 noise.
166+
* answer after a 3-rep A/B: no robust wall-clock difference (within noise).
94167
*/
95168
export const AGENT = {
96169
reps: 3,
@@ -101,9 +174,11 @@ export const AGENT = {
101174
} as const;
102175

103176
/** Honest caveats — shown on the page so the numbers are trustworthy. */
104-
export const CAVEATS = [
105-
`The headline figures are the official SigMap benchmark (${OFFICIAL.version}, ${OFFICIAL.reposToken} repos, ${OFFICIAL.tasks} tasks) — synced from the core repo, same as sigmap.io.`,
106-
"The 405-repo run is our own independent stress test; 84 use languages SigMap doesn't yet parse (Clojure/Lua/C/C++/Haskell) and are excluded, not hidden.",
107-
"Retrieval on the broad 405-repo set is lower than the official 87.8% — a wider, messier corpus is harder than the curated benchmark set.",
108-
"We did NOT find a reproducible agent wall-clock speedup: a 3-rep Devin A/B came out within noise (8.4 vs 8.0 min). Token/cost savings are deterministic; agent-speed is still open.",
109-
];
177+
export function caveatsFrom(o: Official): string[] {
178+
return [
179+
`The headline figures are the official SigMap benchmark (${o.version}, ${o.reposToken} repos, ${o.tasks} tasks) — pulled live from the core repo, same as sigmap.io.`,
180+
"The 405-repo run is our own independent stress test; 84 use languages SigMap doesn't yet parse (Clojure/Lua/C/C++/Haskell) and are excluded, not hidden.",
181+
`Retrieval on the broad 405-repo set is lower than the official ${o.hitAt5Pct}% — a wider, messier corpus is harder than the curated benchmark set.`,
182+
"We did NOT find a reproducible agent wall-clock speedup: a 3-rep Devin A/B came out within noise (8.4 vs 8.0 min). Token/cost savings are deterministic; agent-speed is still open.",
183+
];
184+
}

0 commit comments

Comments
 (0)