From 91b4f1fe14f465ade6947a9d5a1effa77652322d Mon Sep 17 00:00:00 2001 From: Florent Tapponnier Date: Sat, 27 Jun 2026 23:35:29 +0200 Subject: [PATCH] fix(spec): dedupe results after legacy chain slug rewrite MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When a chain rename rolls through Prom while the 24h window still holds samples on the legacy label (e.g. ton → gram during the harness redeploy lag), the loader rewrote each ton row to gram but did not dedupe — so /benchmarks/l1-finality rendered Gram twice (one row per source series). Two-pass: rewrite then dedupe by canonical slug, preferring the row whose original slug already matched the canonical (current harness emit) over the alias-rewritten historical row. --- src/lib/spec.ts | 33 +++++++++++++++++++++++++++------ 1 file changed, 27 insertions(+), 6 deletions(-) diff --git a/src/lib/spec.ts b/src/lib/spec.ts index f2e13a82..1bd05c35 100644 --- a/src/lib/spec.ts +++ b/src/lib/spec.ts @@ -88,13 +88,34 @@ function overlayEditorial(stored: Benchmark, spec: Spec): Benchmark { const providerByCanonSlug = new Map( (spec.providers ?? []).map((p) => [canonicalChainSlug(p.slug), p]), ); - const reconciledResults = stored.results.map((r) => { + // Two-pass: rewrite legacy slugs to their canonical, then dedupe so a + // chain rename in flight (e.g. ton → gram) does not surface two rows + // for the same canonical until the 24h Prom window aged out the legacy + // series. When duplicates land, prefer the row whose original slug + // already matched the canonical (current harness emit) over the row + // rewritten via alias (historical samples). Stable insertion order + // preserves the leaderboard sort. + const seenSlugs = new Set(); + const reconciledResults: typeof stored.results = []; + for (const r of stored.results) { const canon = canonicalChainSlug(r.slug); - if (canon === r.slug) return r; - const specProvider = providerByCanonSlug.get(canon); - if (!specProvider) return r; - return { ...r, slug: canon, name: specProvider.name }; - }); + const isCanonical = canon === r.slug; + if (seenSlugs.has(canon)) { + if (!isCanonical) continue; + const existingIdx = reconciledResults.findIndex((x) => x.slug === canon); + if (existingIdx >= 0) reconciledResults[existingIdx] = r; + continue; + } + seenSlugs.add(canon); + if (isCanonical) { + reconciledResults.push(r); + } else { + const specProvider = providerByCanonSlug.get(canon); + reconciledResults.push( + specProvider ? { ...r, slug: canon, name: specProvider.name } : r, + ); + } + } const overlaid: Benchmark = { ...stored,