Skip to content

test(mcp): the repeat-reads A/B and timing tests stop flaking - #56

Merged
HackPoint merged 4 commits into
mainfrom
agents/test-timing-and-ab-flake
Oct 13, 2026
Merged

HackPoint merged 4 commits into
mainfrom
agents/test-timing-and-ab-flake

Conversation

@HackPoint

Copy link
Copy Markdown
Owner

What

Two tests in crates/lumen-mcp/tests/repeat_reads.rs fail without anything being wrong in the product. Test-only change; no product code.

A/B split (ab_withholds_the_answer_from_control_files_and_records_what_it_would_have_done): it read 16 files and needed at least 3 in each arm. The arm is a function of the path, and the paths are new on every run (temp dirs), so with 16 fair coin flips one side gets fewer than 3 in 274 of 65,536 outcomes: it fails 0.42% of runs for any code.

Timing (a_repeat_costs_no_more_time_than_a_first_read): it ran 40 reads with repeat reads off, then 40 with them on, and compared the two totals against 1.5 x off + 1 s. A load spike lands on one arm only, and one stalled read can decide the result. It failed in a local gate at machine load 77.

Change

  • A/B: reads files until each arm has four (cap 200; a fair split gets there in about 8-10), and asserts that every file's answer matches its arm, using lumen_core::repeat::treated(Mode::Ab, path), the function the product uses: a treated file gets the "Unchanged since" answer, a control file the outline. The test now fails when the split is wrong, not when it is uneven.
  • Timing: two rigs, one with repeat reads off and one on, read alternately read by read; compares medians with on_median < 2 x off_median + 25 ms. Load lands on both alike, and one stalled read moves no median.

Evidence

  • A/B before: 0.418% of runs (2 x (1 + 16 + 120) / 65,536). After: it fails only if 200 fair flips leave one side with fewer than 4, which is below 10^-50.
  • Mutation, A/B: forcing every file to the treated arm fails the new assertion.
  • Mutation, timing: a 400 ms sleep on the repeat path fails it (0.7002 s against 0.2716 s a read, at machine load about 50).
  • Margin against load: the on/off median ratio measured 1.07-1.18 at moderate load and 1.43 at the worst moment seen (load about 123), against the 2x + 25 ms bound.

Gate

Local gate green: fmt, clippy -D warnings on the workspace with all targets, workspace tests with RUSTFLAGS=-D warnings, frontend build and tests with thresholds, e2e (read path, ingest path, decision metering), sidecars, Tauri crate tests and clippy, hook e2e.

Not run locally, because only a test file changed: the debug app build, install verify, the full MSRV build. cargo check -p lumen-mcp --tests --locked on 1.94.0 passes; CI's MSRV job runs the full build.

No issue was opened for this flake; say if you want one.

HackPoint and others added 4 commits October 12, 2026 15:06
…timing test alternates its arms and compares medians

The A/B test read 16 files and needed three in each arm, which fails 0.4% of runs because the arm
comes from the path and the paths are new every run. It now takes files until each arm has four,
and checks that the arm a file lands in is the arm the read was answered as.

The timing test ran all reads of one arm, then all of the other, so a load spike hit one arm only,
and a single stalled read decided the result. It now alternates the arms read by read and compares
medians. A repeat path that costs 400 ms more a read still fails it.
@HackPoint
HackPoint merged commit cc55130 into main Oct 13, 2026
17 checks passed
@HackPoint
HackPoint deleted the agents/test-timing-and-ab-flake branch October 13, 2026 07:00
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