Repository navigation
Commons news outlives a crash: the cursor moves once subscribers hold it - #592
Merged
Merged
Conversation
The commons source advanced read.json before the events it read reached any subscriber's held file, so a crash in between lost those posts (#589, from the #585 review). news() now returns the lines and the cursor it would write; the source sends them, asks the lookout whether every subscriber holds them on disk, and marks them read only on yes. The lookout writes what it holds at once for the question and answers when the writer is done; the writer keeps failed writes and tries them again, answering no while any is unwritten. Read again after a crash, an event a subscriber already holds is not held twice. Crash-injection tests abort a child process at four steps (read, in memory, on disk before the cursor, after the cursor) and check that a restarted lookout holds each post exactly once. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_013jkdGG8Kwbo2wyYcT9yURQ
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
This was referenced Nov 1, 2026
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.
Fixes the first item of #589 (from the #585 review, r4434606869):
commons::newsadvancedread.jsonbefore the events it read reached any subscriber's held file (STORE.sources/.held/BOT.json), so a crash in between lost those posts.What changes
commons::newsreturns aNews(its lines plus the cursor it would write) and no longer writes the cursor.News::mark_readwrites it withreplace_mode(fsynced, atomic).sources::own) sends the lines, then sendsSaid::Kept(oneshot)and marks the news read only when the lookout answers yes. The source channel now carriesSaid::{Event, Kept}.Service::said) handlesKeptby flushing every lookout's held file at once (not on the next tick) and answering throughheld::thenonce the writer thread is done.thenanswers false while any file is unwritten, so the cursor stays put during a disk failure.Lookout::heard_fromskips an event whose source and id it already holds (waiting, resent or on its way), so news read again after a crash is held once. Delivery is at least once. A duplicate can only happen if the process dies in the moment between the held write and the cursor write, after a note has already gone out.Tests
commons_news_outlives_a_crash_at_every_stepre-runs the test binary as a child (commons_crash_child), which runs the real commons source andService::said, and callsstd::process::abort()at four steps: read, in memory, on disk before the cursor, after the cursor. The parent then restarts a lookout from disk, reads the commons again and checks that each post is held exactly once. I checked that it fails on the old order: with the cursor written right after reading, theheardstep loses both posts.a_source_waits_for_what_lookouts_hold_to_be_writtencovers the answer, the dedupe, and a failed write answering false and then succeeding on retry.news_not_marked_read_is_read_againis the commons-level unit test.cargo test -p sonny: 851 + 2 + 24 passed.cargo clippy -p sonny --all-targetsis clean andcargo fmt --checkpasses.The docs (LOOKOUT.md, the commons paragraph) and the FEATURES.md sources row are updated. The protocol and schema are unchanged. The remaining #589 items (example scoping, shape writes off the runtime, exact integers) follow in a second PR.