Keep records appended during a timeline load - #434
Merged
Merged
Conversation
This was referenced Sep 14, 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.
Behaviour
Opening or re-adopting a session inserts the resident with an empty timeline and folds its JSONL on a background task. Events recorded while that fold is in flight were applied to the resident's timeline and then overwritten when the fold landed. The retry-on-watermark loop re-read the file up to four times, but the store writer is asynchronous, so a slow runner could exhaust the attempts and "apply the last fold" without those events. This is the host-side half of the
session_replica_matches_live_timeline_for_synthetic_turnfailures: in two of the three CI failures the host's own live timeline was missing turn 2 (lefthad one turn) while the store had recorded it.The loader now folds from the session's in-memory record cache when one exists (that cache is the complete log once a session has appended in this process; it is only created by
record_event_at), otherwise from disk, and on completion applies any records appended past the folded count. The per-processstore_append_generationwatermark, the attempt counter and the retry are removed; the per-session load generation still discards superseded loads.Test contract
timeline_load_keeps_records_appended_during_the_fold(renamed fromtimeline_load_retries_when_append_watermark_moves) records an event immediately afterselect_sessionand asserts the loaded timeline contains both the stored and the raced record. It fails attests.rs:5622with the catch-up loop removed and passes with it.Checks
cargo fmt --all --checkcargo clippy --workspace --all-targets --locked -- -D warningscargo test -p tcode-runtime --locked(167 + 3 passed)This does not by itself explain the store-side shape of the flake (replica holding only turn 2); a tracing draft (#433) is running on CI to capture that sequence, and any store change will be a separate PR.