carlos / platform Public

Flaky: TestMeterCountsAndDrains visitors estimate (internal/analytics) closed

internal/analytics/meter_test.go:70 TestMeterCountsAndDrains failed on CI for branch design-agent-login-link at 712d2543 (the branch does not touch internal/analytics; main a0133a50 passed):

meter_test.go:70: visitors ≈ 2, got 1.00

It passed 100/100 locally (go test ./internal/analytics -run TestMeterCountsAndDrains -count=20 x5), so this looks probabilistic: two distinct visitors counted as one, likely the sketch's per-process salt or hash occasionally colliding the two test visitors into one register. CI run: https://amadan.net/carlos/platform/-/ci/712d25438128e2531d5e385a4adbe2c89710b5f2

Fix direction (for whoever owns analytics): seed the visitor salt deterministically in tests, or assert with visitors chosen to land in different registers. Re-run on the branch in progress; not fixing it there (out of scope).

Root cause: random day salt + 2,048 HLL registers; the two test visitors share a register ~1 in 2,048 runs and the linear-counting estimate reads 1.00. Fix on branch fix-meter-visitors-flake (a397de39): test pins an all-zero salt (registers 713 vs 653) with a guard that fails loudly on a collision; RED reproduced with a colliding salt, GREEN 500/500. Census clean.