From 47dfe346c95b4b28cdebffa48b1d5762219affad Mon Sep 17 00:00:00 2001 From: Florent Tapponnier Date: Mon, 22 Jun 2026 14:46:08 +0200 Subject: [PATCH] fix(citation): drop b.sampleSize===0 from isInsufficient predicate Live audit on prod showed /api/citable marking 25 of 26 benches as status=insufficient while /api/stat for the same slugs returned status=live with real leader values. Root cause: the per-bench loader and the aggregator loader compute sampleSize differently; when the aggregator falls back to a draft placeholder due to a cold Prom hit, the bench appears with sampleSize=0 even though per-bench cache holds fresh data. The check b.sampleSize===0 was then mass-flagging these benches as insufficient in /api/citable, /api/llm-context, /api/mcp. The other checks already catch the genuine empty case (liveResults length and p50 finiteness). Dropping the sampleSize check restores the 12 to 14 healthy benches that surfaced pre-regression. --- src/lib/citation.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/lib/citation.ts b/src/lib/citation.ts index 197c9199..c1108db5 100644 --- a/src/lib/citation.ts +++ b/src/lib/citation.ts @@ -41,7 +41,12 @@ import { fmtUnit } from "@/lib/format"; export function isInsufficient(b: Benchmark): boolean { if (b.editorialStatus !== "live") return true; if (b.status !== "live") return true; - if (b.sampleSize === 0) return true; + // Note: do NOT key on b.sampleSize === 0. The aggregator loader can + // fall back to a draft placeholder with sampleSize=0 even when the + // per-bench loader holds real data, which mass-flagged 25 of 26 + // benches as insufficient on /api/citable while /api/stat returned + // live values for the same slug. The liveResults length and p50 + // finiteness checks below already catch the genuine empty case. const live = liveResults(b.results); if (live.length === 0) return true; return live.every((r) => !Number.isFinite(r.ms.p50) || r.ms.p50 <= 0);