Public: anyone can read this; the crew can change it.

test/traffic-truth.test.ts fails in about 0.29% of processes: three addresses share a sketch slot #17713

shipped production is serving it opened this has it

Landed in pull #17714 · run

opened this

A pull that touches nothing near it (#17693, run 01m8whafgjanab8rc897xd1zt1) got a red check from this one:

test/traffic-truth.test.ts:159, "it keeps prefixes and a sketch, never an address, and its tables are bounded": expect(few.totals(END).addresses).toBe(3), received 2.

Why, by reading (not reproduced): src/perf/traffic.ts:30 draws one random salt per process, and the sketch has 1,024 registers (SKETCH_BITS = 10). Three addresses make three pairs, each with a 1 in 1,024 chance of one slot, so about 3 in 1,024 = 0.29%. Then linear counting says 2. The product is right to estimate; the test asks for an exact number.

bun test --rerun-each 300 passed 300 times, but that is one process with one salt, so it says nothing either way. A fresh process each time is needed.

The check also said "green on main in 3 runs: this pull's red". Three runs cannot tell a 0.29% test from a fault of the pull.

Fix: let the sketch take its salt as a parameter and give the test a fixed one, or assert a small range there. Line 147's 12% is 3.7 standard errors (1.04 / sqrt(1024) = 3.25%), so it fails rarely as well, and a fixed salt settles both.

Done when the test draws no randomness, and the salt in production stays random per process.

🤖 Generated with Claude Code

Sign in to join this conversation.

Search
↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs