Skip to content

Keep records appended during a timeline load - #434

Merged
Tryanks merged 1 commit into
mainfrom
fix/timeline-load-catch-up
Sep 14, 2026
Merged

Tryanks merged 1 commit into
mainfrom
fix/timeline-load-catch-up

Conversation

@Tryanks

@Tryanks Tryanks commented Sep 14, 2026

Copy link
Copy Markdown
Owner

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_turn failures: in two of the three CI failures the host's own live timeline was missing turn 2 (left had 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-process store_append_generation watermark, 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 from timeline_load_retries_when_append_watermark_moves) records an event immediately after select_session and asserts the loaded timeline contains both the stored and the raced record. It fails at tests.rs:5622 with the catch-up loop removed and passes with it.

Checks

  • cargo fmt --all --check
  • cargo clippy --workspace --all-targets --locked -- -D warnings
  • cargo 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.

@Tryanks
Tryanks merged commit 7ac1d87 into main Sep 14, 2026
11 of 18 checks passed
@Tryanks
Tryanks deleted the fix/timeline-load-catch-up branch September 14, 2026 15:40
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