Files
codex/codex-rs/protocol/src/context_window_id_tests.rs
T
Ruslan Nigmatullin 340a18ed7c Preserve model-facing ID allocations in saved history (#60771)
## Why

Restoring model-facing ID sequences requires allocation ordinals alongside the rendered IDs. Responses API payloads still require string IDs.

## What changed

- Add allocation metadata to `ResponseItemId` while keeping equality, hashing, and ordering based on the rendered ID.
- Preserve optional `id_allocation` metadata in rollout items, inter-agent messages, compaction replacement history, and Guardian checkpoints. Continue accepting legacy string IDs.
- Support structured context-window allocations alongside UUIDv7 strings, validate the `window` salt on restoration, and keep request metadata IDs as strings.

## Testing

Add tests for allocation round trips, legacy ID compatibility, string-only raw response item IDs, and context-window allocation validation.

GitOrigin-RevId: ce1fd964bde9a4e7c527432be99aea87ada30169
2026-11-11 09:58:13 +00:00

17 lines
539 B
Rust

#![cfg(test)]
use super::ContextWindowId;
use codex_utils_model_facing_id::ModelFacingIdGenerator;
use pretty_assertions::assert_eq;
#[test]
fn restores_allocations_from_the_window_generator() {
let window = ContextWindowId::Generated(Box::new(
ModelFacingIdGenerator::new(/*seed*/ 0, "window").fetch_next(),
));
assert_eq!(window.validated(), Some(window));
let item = ModelFacingIdGenerator::new(/*seed*/ 0, "item").fetch_next();
assert_eq!(ContextWindowId::Generated(Box::new(item)).validated(), None);
}