Files
codex/codex-rs/rollout/src/rollout_file_name_tests.rs
Owen Linandcopyberry 4ef836f883 Distinguish rollout IDs from thread IDs (#38127)
## Why

`thread/revert` preserves a thread ID while creating a new immutable rollout. Rollout persistence and filesystem fallback therefore need to distinguish the logical thread from each physical history file.

## What changed

- Add a `RolloutId` alias and canonical filename parsing for both ordinary rollouts and reverted rollouts with a distinct rollout ID.
- Allow the recorder to create a replacement rollout without changing the thread ID, and add lookup by either the stable thread ID or an exact rollout ID.
- Index history references and compression safety checks by rollout ID so multiple rollouts for one thread remain distinct.
- Preserve the rollout path selected in SQLite when filesystem repair encounters another rollout for the same thread.

## Testing

Add coverage for filename round trips, replacement rollout metadata, thread and rollout lookup, reference indexing, compression, and database path preservation.

GitOrigin-RevId: 14b1d0b4a9432b341a1307afc0abadd507e7ae7d
2026-08-12 05:20:32 +00:00

30 lines
1.1 KiB
Rust

use codex_protocol::ThreadId;
use pretty_assertions::assert_eq;
use time::macros::datetime;
use super::RolloutFileName;
#[test]
fn canonical_rollout_file_names_round_trip() {
let timestamp = datetime!(2026-08-11 18:42:07 UTC);
let thread_id =
ThreadId::from_string("019ff1a2-b3c4-7d5e-8f60-112233445566").expect("valid thread id");
let rollout_id =
ThreadId::from_string("019ff1a2-b3c4-7d5e-8f60-667788990011").expect("valid rollout id");
for (file_name, expected) in [
(
RolloutFileName::new(timestamp, thread_id, thread_id),
"rollout-2026-08-11T18-42-07-019ff1a2-b3c4-7d5e-8f60-112233445566.jsonl",
),
(
RolloutFileName::new(timestamp, thread_id, rollout_id),
"rollout-2026-08-11T18-42-07-019ff1a2-b3c4-7d5e-8f60-112233445566_019ff1a2-b3c4-7d5e-8f60-667788990011.jsonl",
),
] {
let rendered = file_name.render().expect("timestamp should format");
assert_eq!(rendered, expected);
assert_eq!(RolloutFileName::parse(&rendered), Some(file_name));
}
}