From a0d775d588588334502b9cf836612d87128d75b0 Mon Sep 17 00:00:00 2001 From: Friel Date: Mon, 4 May 2026 09:46:59 +0000 Subject: [PATCH] test: apply fork truncation to materialized history --- codex-rs/core/tests/suite/fork_thread.rs | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/codex-rs/core/tests/suite/fork_thread.rs b/codex-rs/core/tests/suite/fork_thread.rs index ec0c5baa23..655e03016c 100644 --- a/codex-rs/core/tests/suite/fork_thread.rs +++ b/codex-rs/core/tests/suite/fork_thread.rs @@ -127,8 +127,9 @@ async fn fork_thread_twice_drops_to_first_message() { serde_json::to_value(&expected_after_first).unwrap() ); - // Fork again with n=0. Because fork1 has no new user turn after its - // compact reference, this should preserve the same materialized history. + // Fork again with n=0. The first fork's raw rollout only contains a + // ForkReference, but truncation still applies to the materialized history + // referenced by that item. let NewThread { thread: codex_fork2, .. @@ -145,7 +146,12 @@ async fn fork_thread_twice_drops_to_first_message() { let fork2_path = codex_fork2.rollout_path().expect("rollout path"); // GetHistory on fork2 flushed; the file is ready. - let expected_after_second = fork1_items.clone(); + let fork1_user_inputs = find_user_input_positions(&fork1_items); + let cut2 = fork1_user_inputs + .first() + .copied() + .unwrap_or(fork1_items.len()); + let expected_after_second = fork1_items[..cut2].to_vec(); let fork2_raw_items = read_rollout_items(&fork2_path); assert!( fork2_raw_items