Files
codex/codex-rs/protocol/src/item_id_generator.rs
T
Ruslan Nigmatullin 77cbcdb4a6 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
2026-11-12 00:27:01 +00:00

13 lines
439 B
Rust

//! Response item ID allocation for a thread and its consumers.
use crate::ResponseItemId;
use std::sync::Arc;
/// 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)]
pub(super) fn uuid_v7_item_id_generator_for_test() -> ItemIdGenerator {
Arc::new(|prefix| ResponseItemId::with_suffix(prefix, uuid::Uuid::now_v7()))
}