Repository navigation
test: assert bearings snapshot local-read overlap from peak reads in flight - #73
Merged
doitdigital0495 merged 2 commits intoOct 13, 2026
Merged
Conversation
…all clock The large-local snapshot test compared whole seconds of wall clock between a serialized and a concurrent run, and a loaded CI runner flaked it (serial 6s vs concurrent 5s) because second-granularity rounding plus composition noise ate the whole margin. The fake no-mistakes now stamps each one-second read's start and end in milliseconds, and the assertions bound the read spans themselves: the serialized baseline must span at least four of its five seconds, the concurrent reads must all fit inside two and a half, and at least two saved seconds must show up between them. The spans exclude the snapshot's composition overhead by construction and the delayed reads carry no CPU work, so host load has nothing left to hide in, while reads serialized again span the same five seconds as the baseline and fail.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Intent
tests/fm-bearings-snapshot.test.sh around line 3132 compares serial against concurrent wall-clock time at one-second resolution. It flaked on a loaded CI runner (serial 6s against concurrent 5s) in PR 45 run 36748883535. Make the assertion robust.
What Changed
tests/fm-bearings-snapshot.test.sh: the large local snapshot test no longer compares serial and concurrent runs by whole-second wall clock. That check flaked on a loaded runner. The fakeno-mistakesnow writes astart/endline with a millisecond timestamp around each delayed one-secondaxi statusread intoFAKE_NM_READ_LOG. It gets milliseconds fromEPOCHREALTIMEfirst, thendate +%s%N, then whole seconds.fake_read_log_overlaphelper: it replays the log in timestamp order (on a tied timestamp, anendsorts before astart) and prints the start count, end count and peak number of reads in flight. A missing log counts as zero reads.fm-bearings.v1projection matches between the two runs is unchanged.🤖 Generated with Claude Code
Risk Assessment
✅ Low: The change only touches a test. It replaces the whole-second wall-clock comparison with a peak-in-flight overlap metric taken from millisecond start/end stamps, which host load cannot fake. It also requires exactly 5 starts and 5 ends in both runs, closing the round-1 findings (review-1 load stagger, review-2 missing end stamps, review-3 redundant saved_ms bound). The end-before-start tie sort keeps the serial peak at 1 even if the stamp falls back to whole seconds.
Testing
Each run used a temporary single-test copy of the suite, so only the changed test ran; the full suite was not run. The test passed 3 of 3 times idle and 3 of 3 times under heavy CPU load (load average about 48 on 10 cpus). A mutant that serializes the concurrent reads fails with "concurrent local reads did not overlap (peak 1 in flight)". The overlap helper also gives the right summaries for a missing log, serial reads that touch at the same stamp, and a read cut short; these cases fail the 5-start/5-end check or count touching reads as no overlap. The original CI flake did not reproduce locally: the base-commit test also passed 3 of 3 times under the same load, so the evidence shows the new assertion is robust and still catches regressions, but there is no local before/after flake. There is no UI surface, so no screenshots were taken. All temporary files were removed.
Evidence: Idle runs of the target test (3x pass)
Source: Idle runs of the target test (3x pass)
Evidence: Serialized-reads mutant is caught
Source: Serialized-reads mutant is caught
not ok - concurrent local reads did not overlap (peak 1 in flight) EXIT=1Evidence: New and base test under heavy CPU load
Source: New and base test under heavy CPU load
Evidence: Overlap helper edge cases
Source: Overlap helper edge cases
missing log -> 0 0 0 touching serial reads -> 2 2 1 read killed mid-sleep -> 2 1 2Pipeline
Updates from git push no-mistakes
✅ **intent** - passed
✅ No issues found.
✅ **Rebase** - passed
✅ No issues found.
🔧 **Review** - 3 issues found → auto-fixed ✅
tests/fm-bearings-snapshot.test.sh:3217- Residual load flake in the newparallel_span_ms -le 2500bound. The span runs from the first read's start to the last read's end, so it still includes the start stagger between the five jobs.snapshot_tasks_parallel(bin/fm-fleet-snapshot.sh:660-689) forks each job as a subshell, and each job does its own pre-read work before it callsno-mistakes axi status. On the runner that flaked, composition overhead was about 4s (concurrent wall clock 5s against about 1s of reads), so a start stagger above 1.5s is plausible and the test fails again. The comment at 3178-3180 ('leaving host load nothing to hide in') overclaims for the same reason. Suggested fix: use a load-independent overlap metric from the same log. For example, have awk report the peak number of reads in flight (sort the start/end events by timestamp and track the count), then assert peak >= 2 for the concurrent run and peak == 1 for the serial run. This still fails when the reads are serialized, and it makes the 2500ms and 2000ms wall-time bounds unnecessary. Same-invariant sites: line 3215 (serial >= 4000, safe because the sleeps are sequential) and line 3220 (saved_ms >= 2000, which inherits the stagger sensitivity of the 2500ms bound).tests/fm-bearings-snapshot.test.sh:3099-fake_read_log_spanvalidates only the count of 'start' lines; 'end' lines are never counted. If a read is killed mid-sleep (a snapshot bound or timeout), its end stamp is missing, somaxcan fall belowmin. That gives a short or negative span that passes the-le 2500and saved_ms checks. Suggested fix: count end lines too and require 5 starts and 5 ends (or print both counts and assert each is 5 at line 3213).tests/fm-bearings-snapshot.test.sh:3219- Thesaved_ms >= 2000check at line 3220 is redundant with the other bounds when timing is at millisecond resolution: five sequential 1s sleeps give a serial span of at least 5000ms, so passing parallel <= 2500 already implies saved_ms >= 2500. The check adds a third assertion and failure message without adding coverage. Suggested fix: drop it, or drop it as part of switching to the peak-in-flight metric.🔧 Fix applied.
✅ Re-checked - no issues remain.
tests/fm-bearings-snapshot.test.sh- The original CI flake (serial 6s against concurrent 5s) did not reproduce locally. The base-commit test also passed 3 of 3 times under the same heavy load. The robustness claim therefore rests on the load-independent overlap metric, not on a local fail-before, pass-after reproduction.bash tests/zz-tmp-overlap-only.test.sh(temporary copy that runs only test_large_local_snapshot_overlaps_local_reads_without_projection_drift) x3 on an idle hostbash tests/zz-tmp-overlap-serialized.test.sh: mutant that sets FM_SNAPSHOT_LOCAL_READ_CONCURRENCY=8 to 1 for the concurrent run, so the reads are serialized againNew target test x3 and base-commit (3f115f3) target test x3, all under 30 busy-loop CPU hogs on 10 cpus (load average about 48)Ran fake_read_log_overlap on crafted logs: missing log, serial reads that touch at the same stamp, and a read killed mid-sleepRemoved the temporary tests/zz-tmp-* files; the worktree is clean✅ **Document** - passed
✅ No issues found.
✅ **Lint** - passed
✅ No issues found.
✅ **Push** - passed
✅ No issues found.