Repository navigation
fix(faults): cut the i2c dmesg window by kernel timestamp - #12
Merged
Merged
Conversation
Co-authored-by: Cursor <cursoragent@cursor.com>
A line-count slice drops lines once the kernel ring buffer is full. Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
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.
What and why
i2c_sensor_nackwrote admesg.txtthat held 0 or 1 lines and differed between runs of the same seeds (found in #11). Brief:docs/tasks/sprint4-i2c-dmesg-window.md.Cause. The window was cut by line count (
_dmesg()[len(before):]). The kernel log is a fixed-size ring buffer, so once it is full, old lines are evicted as new ones arrive and a count slice drops lines. A WSL2 VM shares one log with Docker Desktop, so it fills in a long session.Fix.
dmesg_new_lines(before, after)insrc/orbitlog/faults/linux.pycuts the window by the monotonic[seconds.microseconds]timestamp. It handles equal timestamps and continuation lines. The live test now asserts thatdmesg.txtholds thei2c-stub: Virtual chip at <decoy>line, which would have caught this.Also in this PR: the Sprint 4 title is marked approved in
docs/plan.md, anddocs/linux-fault-hosts.mdrecords a second finding. WSL2 mounts its own modules disk over/lib/modules/<kernel>on start, so the copiedi2c-*.kofiles vanish after a WSL restart and the copy anddepmod -astep must be repeated. This also corrects the setup I documented in #11.How it was verified (real output)
Host:
Linux Benweru 6.6.87.2-microsoft-standard-WSL2 #1 SMP PREEMPT_DYNAMIC Thu Jun 5 18:30:46 UTC 2025 x86_64.Cause reproduced with a probe that takes both slices from the same before/after snapshots, using 4000 labelled test lines to fill the ring (oldest kept: line 1816). Count slice versus timestamp slice, after the flood:
On a fresh VM (548 lines) the two methods agreed (
by_count=2 by_ts=2), so the bug needs a full ring.Real fault, ring full and churning (a thread writes labelled test lines to
/dev/kmsgwhile the fault runs, as other host activity would), 8 seeds each, as root withORBITLOG_ENABLE_I2C_STUB=1:The extra lines in the second run are the test noise: the window is a time slice and keeps whatever else the kernel logged.
pytest -m linux_i2cwith the stronger assertion, in WSL2:1 passed, 90 deselected in 0.37s.make test: Windows72 passed, 4 skipped, 15 deselected in 4.97s. WSL2:75 passed, 1 skipped, 15 deselected in 2.52s. The new tests cover normal growth, eviction at constant length, equal timestamps, continuation lines, and empty input.Known issues
orbitlog-test-floodororbitlog-test-churn, only exists until the VM restarts, and never enters a dataset.