Skip to content

feat(integrity): per-bench expected_n + sample-health badge - #628

Merged
Flotapponnier merged 1 commit into
devfrom
feat/lowsample-badge
Jun 22, 2026
Merged

feat(integrity): per-bench expected_n + sample-health badge#628
Flotapponnier merged 1 commit into
devfrom
feat/lowsample-badge

Conversation

@Flotapponnier

Copy link
Copy Markdown
Collaborator

Bench pages currently rank providers based on sample counts that
vary from 3 to 1500+ per provider depending on the bench cadence,
without surfacing the confidence level. The methodology page
advertises n >= 1000 which is misleading on low-cadence benches
like oracle-deviation (3 to 4 samples per provider) and perp-funding
(3 samples per venue by design).

This change introduces a per-bench expected_n declared in the YAML
spec. The page computes health = actual / expected_n per provider
and badges rows below 50 percent of expected as "low sample" or
hides rankings below 10 percent as "insufficient". The bench-wide
aggregate (median of per-provider healths) also propagates to
/api/citable, /api/stat and the headline sentence so an "insufficient"
field stops asserting a winner in machine-readable feeds.

YAML field is optional. Benches without expected_n declared behave
as before (no badge, no hide).

YAMLs touched with expected_n:

  • oracle-deviation: 4 (source count per pair, sample_size query
    counts distinct sources not data points)
  • perp-funding: 3 (BTC + ETH + SOL asset series per venue; the
    sample_size query counts distinct asset series)
  • aggregator-head-lag: 50000 (~5760 per chain-region cell, 9 cells
    per provider summed by the sample_size query)
  • bridge-quote-latency: 3000 (4 routes x 3 amounts x 12 sweeps/hour
    x 24h is ~3456, conservative)
  • bridge-fee: 1000 (4 routes filtered to amount_usd=300 x 12/hour
    x 24h is ~1152, conservative)

YAMLs left WITHOUT expected_n (cadence is heterogeneous or the
sample_size semantics differ per provider, no honest single value):

  • validator-yield (Solana reports ~200, Hyperliquid ~30)
  • l1-finality (cadence varies per chain: WS continuous vs 10s
    poll, blocks per chain differ by 1-2 orders of magnitude)
  • l2-block-time (block cadence ranges from Arbitrum 250ms to zk
    rollup bursts of 6-30s)
  • network-fees (no sample_size query declared)
  • gas-estimation (cadence per oracle differs)
  • stablecoin-peg (CEX 5s tickers vs Curve 12s on-chain mixed)
  • buyback-audit (7d window, sample count not meaningful per scrape)
  • network-coverage (12h freshness, dimension count not data points)
  • metadata-coverage / nft-collection-metadata / wallet-labels-coverage
    (coverage benches, sample_size is dimension count)
  • rpc-capabilities (capability flags, no time-series sample count)
  • hyperliquid-frontends + hip3-deployers (per-builder gauges,
    builder count not data point count)
  • pm-* benches (cadence varies per provider)
  • token-deployment-cost (per-chain attempt)
  • polymarket-resolution-delay (event-driven, not periodic)
  • perp-fees (per-asset per-venue, count varies by support)
  • stablecoin-peg-usdt-anchored (mirrors stablecoin-peg)

Thresholds chosen: 0.5 (healthy), 0.1 (insufficient). See
src/lib/sample-health.ts.

Test plan:

  • pnpm validate (31 specs valid)
  • pnpm typecheck
  • pnpm lint
  • bun test src/lib (105/105 pass, includes the new
    sample-health.test.ts)
  • pnpm build
  • Visit /benchmarks/oracle-deviation on the staging Preview URL:
    expect XRP/ADA/DOGE to read as healthy (3/4 = 75 percent) but the
    badge surfaces once sources drop to 1 of 4.
  • Visit /benchmarks/aggregator-head-lag: expect no badge
    (healthy across all 3 providers).
  • Hit /api/citable for oracle-deviation, perp-funding: expect
    dataConfidence + expectedN fields in the JSON.

@Flotapponnier
Flotapponnier merged commit bfd5087 into devJun 22, 2026
1 check passed
@Flotapponnier
Flotapponnier deleted the feat/lowsample-badge branch June 22, 2026 09:16
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant

@Flotapponnier