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 #17714

opened this in answer to

Merged 11h ago, live in production

The traffic sketch test no longer draws a random salt, so it can't fail from a three-address slot collision any more. createTrafficLedger in src/perf/traffic.ts now takes an optional salt. With no argument it uses the per-process random salt, so production behaves as before.

Notes

opened this

The traffic sketch test no longer draws a random salt, so it can't fail from a three-address slot collision any more.

createTrafficLedger in src/perf/traffic.ts now takes an optional salt. With no argument it uses the per-process random salt, so production behaves as before. sketchAdd receives the salt instead of reading the module constant.

In test/traffic-truth.test.ts, both ledgers in "it keeps prefixes and a sketch, never an address…" use a fixed salt of 1. That settles the exact addresses count of 3 at line 159. It also settles the 12% tolerance at line 147, so the assertions themselves are unchanged. Because the sketch is deterministic with that salt, the test can't flake from a hash collision.

Checks: test/traffic-truth.test.ts passes (8 tests), bun x tsc --noEmit is clean, and bun scripts/gate.ts --fix changed nothing. I did not run the full suite. I did not run scripts/similar.ts, and no new function was added, so nothing was reused.

Not done: I did not add a test that production still draws its salt at random. Nothing in this change touches that draw, so the default is unchanged. The commit says "No door" because this is a test-only seam with no page, action, route or tool change.

Closes #17713

commented

test/traffic-history.test.ts no longer depends on chance: it now builds its ledgers with a fixed salt, so the addresses: 2 assertion can't hit the 1-in-1000 slot collision. The same flake was still in that test after the first fix.

  • What changed: createTrafficLedger(1) at lines 69, 105, 115 and 163. Only line 69 asserts an exact address count. I fixed the other three anyway so nothing in the file depends on a random salt. The trafficHistory(...) calls that build a throwaway ledger (lines 92 and 100) still use the random salt, because they assert no address count. Production code is untouched.
  • Checks: traffic-history and traffic-truth pass together, 16 tests, on three runs in a row. tsc --noEmit is clean and the gate passes.
  • Gate note: the gate flags a comment line over 100 columns in src/perf/traffic.ts and test/traffic-truth.test.ts. Both are outside this change, and the gate says the nightly rewrap handles them on main.
  • Left out: I did not add a test that sweeps salts to prove the estimate is exact. It would only re-test the sketch.

There's no page change, so there's no review block.

Sign in to join this conversation.

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

Keyboard shortcuts

Docs