You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 833ed99
Browse filesBrowse the repository at this point in the historyBrowse files
fix(sessions): preserve turns persisted after a response's recorded boundary
previous_response_id compaction covers the server side history through one
response only, but the replacement classified everything in the snapshot as
the compacted baseline. When another run appended its turn between that
response's persisted batch and the late snapshot, the prefix and generation
checks saw no rewrite and the replacement dropped the newer turn.
The runner now persists each response's batch through a session hook that
records the exact local item count in the same locked region as the append,
pairing the response id with its ownership boundary. run_compaction reads
the recorded boundary under the lock and preserves every item past it, so
turns appended after the batch survive no matter when the snapshot happens.
Without a recorded boundary, direct calls and input mode keep the snapshot
length as the boundary, since their compaction input is captured under the
same lock as the snapshot. clear_session and pop_item drop recorded
boundaries the same way they already invalidate the caches, so a destroyed
history can never feed a stale count into a replacement.
A successful replacement translates the surviving boundaries instead of
clearing them, shifting each count past the rewritten prefix onto the new
history, so overlapping previous_response_id compactions still preserve the
turns past their own boundaries. A boundary that ended inside the rewritten
prefix has no counterpart afterwards; it is kept as a tombstone and a later
compaction keyed on it skips its replacement, because falling back to its
snapshot would classify newer turns and the earlier summary into its
baseline and drop them. Resumed pending session writes route through the
same hook when the resume itself performs the append and a response id is
known, so those batches record boundaries too.
The new regressions drive the exact orderings from review: a turn persisted
between a response's batch and its late snapshot survives that response's
replacement, a second compaction lands on its translated boundary after an
overlapping replacement and keeps the newer turn, and a compaction whose
recorded prefix was rewritten away skips instead of dropping the newer turn
and the earlier summary. Without the source change each ordering loses
items.
0 commit comments