Skip to content

a success rate printed to two decimals off 68 observations - #2775

Merged
Flotapponnier merged 1 commit into
mainfrom
fix/success-precision
Oct 2, 2026
Merged

Flotapponnier merged 1 commit into
mainfrom
fix/success-precision

Conversation

@Flotapponnier

Copy link
Copy Markdown
Collaborator

Found while answering Aurora's Alex Shevchenko, who asks what share of bridge swaps fail and get refunded. Our answer was four providers all reading 100.00%.

The problem

Every ledger prints its success column as toFixed(2). On the bridge execution benches that is two decimals — resolution to a hundredth of a point — from samples of 68 to 95 executions a week, whose finest possible step is 1/68, about 1.5 points.

The column distinguished nothing while looking authoritative, and nothing on the page let a reader tell 100% of 68 from 100% of 68,000.

The fix

Decimals follow the sample. The useful precision of a rate from n observations is log10(n) digits, less the two the percentage scale already carries, capped at the two this ledger has always shown.

bench sample before after
bridge near-intents 68 100.00% 100%
bridge lifi 93 100.00% 100%
bridge relay 74 98.65% 99%
aggregator head-lag 2,863 99.44% 99.44% (unchanged)

The 30-second probe benches keep what they earned; only figures that were never supported lose anything.

The cell now carries what the percentage rests on:

No failure observed in 68 measurements. A sample this size cannot distinguish a rate above 98.5%.

because "100%" reads as "cannot fail", and 68 observations cannot establish anything above 98.5%. Where something did fail, it gives the count.

An unknown sample size keeps two decimals: coarsening a figure whose sample we cannot see would be asserting an imprecision we have not established.

Why it is in lib/

So it can be tested without rendering, and because the rule should apply anywhere else a rate meets a sample. 8 tests cover the bridge case, the probe case, the climb, the unknown sample, and that 100% of 68 and 100% of 68,000 no longer read identically.

tsc clean, 422 tests pass, pnpm validate passes, lint 0 errors.

Related: #2774 fixed the polling asymmetry that made Near Intents read 36.7 s against ~1 s.

Every ledger printed its success column as toFixed(2), so the four bridge
execution providers all read "100.00%": two decimals, implying resolution to a
hundredth of a point, from samples of 68 to 95 executions a week whose finest
possible step is 1/68, about 1.5 points. The column distinguished nothing
while looking authoritative, and nothing on the page let a reader tell 100% of
68 from 100% of 68,000.

Decimals now follow the sample. The useful precision of a rate from n
observations is log10(n) digits less the two the percentage scale already
carries, capped at the two this ledger has always shown:

  68 executions   100.00%  ->  100%
  93 executions   100.00%  ->  100%
  74 executions    98.65%  ->   99%
  2,863 probes     99.44%  ->   99.44%   (unchanged, it earned them)

The 30-second probe benches keep what they had; only the figures that were
never supported lose anything.

The cell also carries what the percentage rests on. Where nothing failed it
names the ceiling the sample can support, because "100%" reads as "cannot
fail" and 68 observations cannot establish anything above 98.5%. Where
something failed it gives the count.

An unknown sample size keeps two decimals: coarsening a figure whose sample we
cannot see would be asserting an imprecision we have not established.

The rule lives in src/lib/sample-precision.ts so it can be tested without
rendering, and because it should apply anywhere else a rate meets a sample.
@Flotapponnier
Flotapponnier merged commit 847240b into main Oct 2, 2026
2 checks passed
Sign up for free to 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