Preserve thread-local model ID state across replay and compaction (#60942)

## What changed

- Initialize item and context-window ID generators per thread, reuse the stored window on resume, and give history reconstruction a separate item generator.
- Recover item ordinals from checkpoint replacement history, guardian history, and retained context without lowering the cursor established by earlier records.
- Stamp compaction resume metadata with the next item ordinal in append order, tracking the cursor in local and in-memory thread stores.

## Testing

Extend the history ordinal test to verify that a checkpoint records the cursor at its position in a batch, excluding later allocations.

GitOrigin-RevId: 7121b747a039dc5477235078702137d1ff74e789
This commit is contained in:
Ruslan Nigmatullin
2026-11-12 00:27:01 +00:00
committed by copyberry
parent c93732887e
commit 77cbcdb4a6
19 changed files with 227 additions and 112 deletions
+2 -2
View File
@@ -1,9 +1,9 @@
//! Response item ID generation shared by sessions and their consumers.
//! Response item ID allocation for a thread and its consumers.
use crate::ResponseItemId;
use std::sync::Arc;
/// Generates response item IDs from a type prefix for an owning session. Clones share the same callable.
/// Generates IDs for an item kind. Clones share the owning thread's sequence.
pub type ItemIdGenerator = Arc<dyn Fn(&str) -> ResponseItemId + Send + Sync>;
#[cfg(test)]