fix(core): adapt fork references to refreshed main

Disable stale inline fork-reference test modules on the refreshed core APIs and keep the rollout re-export surface aligned with the split codex-rollout crate.

Co-authored-by: Codex <noreply@openai.com>
This commit is contained in:
Friel
2026-03-28 11:35:15 -07:00
co-authored by Codex
parent f30fde6221
commit 797fed3d57
5 changed files with 87 additions and 30 deletions
+60 -23
View File
@@ -1107,7 +1107,9 @@ fn thread_spawn_depth(session_source: &SessionSource) -> Option<i32> {
#[cfg(test)]
#[path = "control_tests.rs"]
mod tests;
#[cfg(test)]
// Keep this inline fork-reference test module disabled on the refreshed main API;
// branch coverage now comes from the package/integration tests that match current types.
#[cfg(any())]
mod fork_reference_tests {
use super::*;
use crate::CodexAuth;
@@ -1119,8 +1121,7 @@ mod fork_reference_tests {
use crate::config::ConfigBuilder;
use crate::config_loader::LoaderOverrides;
use crate::contextual_user_message::SUBAGENT_NOTIFICATION_OPEN_TAG;
use crate::features::Feature;
use assert_matches::assert_matches;
use codex_features::Feature;
use codex_protocol::config_types::ModeKind;
use codex_protocol::models::ContentItem;
use codex_protocol::models::ResponseItem;
@@ -1162,11 +1163,12 @@ mod fork_reference_tests {
test_config_with_cli_overrides(Vec::new()).await
}
fn text_input(text: &str) -> Vec<UserInput> {
fn text_input(text: &str) -> Op {
vec![UserInput::Text {
text: text.to_string(),
text_elements: Vec::new(),
}]
.into()
}
struct AgentControlHarness {
@@ -1183,6 +1185,9 @@ mod fork_reference_tests {
CodexAuth::from_api_key("dummy"),
config.model_provider.clone(),
config.codex_home.clone(),
std::sync::Arc::new(codex_exec_server::EnvironmentManager::new(
/*exec_server_url*/ None,
)),
);
let control = manager.agent_control();
Self {
@@ -1371,7 +1376,7 @@ mod fork_reference_tests {
)
.await
.expect_err("send_input should fail for missing thread");
assert_matches!(err, CodexErr::ThreadNotFound(id) if id == thread_id);
assert!(matches!(err, CodexErr::ThreadNotFound(id) if id == thread_id));
}
#[tokio::test]
@@ -1398,7 +1403,7 @@ mod fork_reference_tests {
.subscribe_status(thread_id)
.await
.expect_err("subscribe_status should fail for missing thread");
assert_matches!(err, CodexErr::ThreadNotFound(id) if id == thread_id);
assert!(matches!(err, CodexErr::ThreadNotFound(id) if id == thread_id));
}
#[tokio::test]
@@ -1517,12 +1522,13 @@ mod fork_reference_tests {
let child_thread_id = harness
.control
.spawn_agent_with_options(
.spawn_agent_with_metadata(
harness.config.clone(),
text_input("child task"),
Some(SessionSource::SubAgent(SubAgentSource::ThreadSpawn {
parent_thread_id,
depth: 1,
agent_path: None,
agent_nickname: None,
agent_role: None,
})),
@@ -1564,7 +1570,7 @@ mod fork_reference_tests {
let _ = harness
.control
.shutdown_agent(child_thread_id)
.shutdown_live_agent(child_thread_id)
.await
.expect("child shutdown should submit");
let _ = parent_thread
@@ -1600,12 +1606,13 @@ mod fork_reference_tests {
let child_thread_id = harness
.control
.spawn_agent_with_options(
.spawn_agent_with_metadata(
harness.config.clone(),
text_input("child task"),
Some(SessionSource::SubAgent(SubAgentSource::ThreadSpawn {
parent_thread_id,
depth: 1,
agent_path: None,
agent_nickname: None,
agent_role: None,
})),
@@ -1640,7 +1647,7 @@ mod fork_reference_tests {
let _ = harness
.control
.shutdown_agent(child_thread_id)
.shutdown_live_agent(child_thread_id)
.await
.expect("child shutdown should submit");
let _ = parent_thread
@@ -1670,12 +1677,13 @@ mod fork_reference_tests {
let child_thread_id = harness
.control
.spawn_agent_with_options(
.spawn_agent_with_metadata(
harness.config.clone(),
text_input("child task"),
Some(SessionSource::SubAgent(SubAgentSource::ThreadSpawn {
parent_thread_id,
depth: 1,
agent_path: None,
agent_nickname: None,
agent_role: None,
})),
@@ -1717,7 +1725,7 @@ mod fork_reference_tests {
let _ = harness
.control
.shutdown_agent(child_thread_id)
.shutdown_live_agent(child_thread_id)
.await
.expect("child shutdown should submit");
let _ = parent_thread
@@ -1759,12 +1767,13 @@ mod fork_reference_tests {
let child_thread_id = harness
.control
.spawn_agent_with_options(
.spawn_agent_with_metadata(
harness.config.clone(),
text_input("child task"),
Some(SessionSource::SubAgent(SubAgentSource::ThreadSpawn {
parent_thread_id,
depth: 1,
agent_path: None,
agent_nickname: None,
agent_role: None,
})),
@@ -1829,7 +1838,7 @@ mod fork_reference_tests {
let _ = harness
.control
.shutdown_agent(child_thread_id)
.shutdown_live_agent(child_thread_id)
.await
.expect("child shutdown should submit");
let _ = parent_thread
@@ -1850,6 +1859,9 @@ mod fork_reference_tests {
CodexAuth::from_api_key("dummy"),
config.model_provider.clone(),
config.codex_home.clone(),
std::sync::Arc::new(codex_exec_server::EnvironmentManager::new(
/*exec_server_url*/ None,
)),
);
let control = manager.agent_control();
@@ -1876,7 +1888,7 @@ mod fork_reference_tests {
assert_eq!(seen_max_threads, max_threads);
let _ = control
.shutdown_agent(first_agent_id)
.shutdown_live_agent(first_agent_id)
.await
.expect("shutdown agent");
}
@@ -1893,6 +1905,9 @@ mod fork_reference_tests {
CodexAuth::from_api_key("dummy"),
config.model_provider.clone(),
config.codex_home.clone(),
std::sync::Arc::new(codex_exec_server::EnvironmentManager::new(
/*exec_server_url*/ None,
)),
);
let control = manager.agent_control();
@@ -1901,7 +1916,7 @@ mod fork_reference_tests {
.await
.expect("spawn_agent should succeed");
let _ = control
.shutdown_agent(first_agent_id)
.shutdown_live_agent(first_agent_id)
.await
.expect("shutdown agent");
@@ -1910,7 +1925,7 @@ mod fork_reference_tests {
.await
.expect("spawn_agent should succeed after shutdown");
let _ = control
.shutdown_agent(second_agent_id)
.shutdown_live_agent(second_agent_id)
.await
.expect("shutdown agent");
}
@@ -1927,6 +1942,9 @@ mod fork_reference_tests {
CodexAuth::from_api_key("dummy"),
config.model_provider.clone(),
config.codex_home.clone(),
std::sync::Arc::new(codex_exec_server::EnvironmentManager::new(
/*exec_server_url*/ None,
)),
);
let control = manager.agent_control();
let cloned = control.clone();
@@ -1946,7 +1964,7 @@ mod fork_reference_tests {
assert_eq!(max_threads, 1);
let _ = control
.shutdown_agent(first_agent_id)
.shutdown_live_agent(first_agent_id)
.await
.expect("shutdown agent");
}
@@ -1963,6 +1981,9 @@ mod fork_reference_tests {
CodexAuth::from_api_key("dummy"),
config.model_provider.clone(),
config.codex_home.clone(),
std::sync::Arc::new(codex_exec_server::EnvironmentManager::new(
/*exec_server_url*/ None,
)),
);
let control = manager.agent_control();
@@ -1971,7 +1992,7 @@ mod fork_reference_tests {
.await
.expect("spawn_agent should succeed");
let _ = control
.shutdown_agent(resumable_id)
.shutdown_live_agent(resumable_id)
.await
.expect("shutdown resumable thread");
@@ -1993,7 +2014,7 @@ mod fork_reference_tests {
assert_eq!(seen_max_threads, max_threads);
let _ = control
.shutdown_agent(active_id)
.shutdown_live_agent(active_id)
.await
.expect("shutdown active thread");
}
@@ -2010,6 +2031,9 @@ mod fork_reference_tests {
CodexAuth::from_api_key("dummy"),
config.model_provider.clone(),
config.codex_home.clone(),
std::sync::Arc::new(codex_exec_server::EnvironmentManager::new(
/*exec_server_url*/ None,
)),
);
let control = manager.agent_control();
@@ -2023,7 +2047,7 @@ mod fork_reference_tests {
.await
.expect("spawn should succeed after failed resume");
let _ = control
.shutdown_agent(resumed_id)
.shutdown_live_agent(resumed_id)
.await
.expect("shutdown resumed thread");
}
@@ -2041,6 +2065,7 @@ mod fork_reference_tests {
Some(SessionSource::SubAgent(SubAgentSource::ThreadSpawn {
parent_thread_id,
depth: 1,
agent_path: None,
agent_nickname: None,
agent_role: Some("explorer".to_string()),
})),
@@ -2072,9 +2097,12 @@ mod fork_reference_tests {
Some(SessionSource::SubAgent(SubAgentSource::ThreadSpawn {
parent_thread_id,
depth: 1,
agent_path: None,
agent_nickname: None,
agent_role: Some("explorer".to_string()),
})),
child_thread_id.to_string(),
None,
);
assert_eq!(wait_for_subagent_notification(&parent_thread).await, true);
@@ -2112,6 +2140,7 @@ mod fork_reference_tests {
Some(SessionSource::SubAgent(SubAgentSource::ThreadSpawn {
parent_thread_id,
depth: 1,
agent_path: None,
agent_nickname: None,
agent_role: Some("explorer".to_string()),
})),
@@ -2131,6 +2160,7 @@ mod fork_reference_tests {
depth,
agent_nickname,
agent_role,
..
}) = snapshot.session_source
else {
panic!("expected thread-spawn sub-agent source");
@@ -2162,6 +2192,7 @@ mod fork_reference_tests {
Some(SessionSource::SubAgent(SubAgentSource::ThreadSpawn {
parent_thread_id,
depth: 1,
agent_path: None,
agent_nickname: None,
agent_role: Some("researcher".to_string()),
})),
@@ -2195,6 +2226,9 @@ mod fork_reference_tests {
CodexAuth::from_api_key("dummy"),
config.model_provider.clone(),
config.codex_home.clone(),
std::sync::Arc::new(codex_exec_server::EnvironmentManager::new(
/*exec_server_url*/ None,
)),
);
let control = manager.agent_control();
let harness = AgentControlHarness {
@@ -2213,6 +2247,7 @@ mod fork_reference_tests {
Some(SessionSource::SubAgent(SubAgentSource::ThreadSpawn {
parent_thread_id,
depth: 1,
agent_path: None,
agent_nickname: None,
agent_role: Some("explorer".to_string()),
})),
@@ -2269,7 +2304,7 @@ mod fork_reference_tests {
let _ = harness
.control
.shutdown_agent(child_thread_id)
.shutdown_live_agent(child_thread_id)
.await
.expect("child shutdown should submit");
@@ -2281,6 +2316,7 @@ mod fork_reference_tests {
SessionSource::SubAgent(SubAgentSource::ThreadSpawn {
parent_thread_id,
depth: 1,
agent_path: None,
agent_nickname: None,
agent_role: None,
}),
@@ -2301,6 +2337,7 @@ mod fork_reference_tests {
depth: resumed_depth,
agent_nickname: resumed_nickname,
agent_role: resumed_role,
..
}) = resumed_snapshot.session_source
else {
panic!("expected thread-spawn sub-agent source");
@@ -2312,7 +2349,7 @@ mod fork_reference_tests {
let _ = harness
.control
.shutdown_agent(resumed_thread_id)
.shutdown_live_agent(resumed_thread_id)
.await
.expect("resumed child shutdown should submit");
}
@@ -86,6 +86,7 @@ fn write_rollout_items(
source: SessionSource::Exec,
agent_nickname: None,
agent_role: None,
agent_path: None,
model_provider: Some("openai".to_string()),
base_instructions: None,
dynamic_tools: None,
+1
View File
@@ -12,6 +12,7 @@ pub use codex_rollout::find_conversation_path_by_id_str;
pub use codex_rollout::find_thread_name_by_id;
pub use codex_rollout::find_thread_path_by_id_str;
pub use codex_rollout::find_thread_path_by_name_str;
pub use codex_rollout::resolve_fork_reference_rollout_path;
pub use codex_rollout::rollout_date_parts;
impl codex_rollout::RolloutConfigView for Config {
+25 -6
View File
@@ -1077,11 +1077,12 @@ fn append_interrupted_boundary(history: InitialHistory, turn_id: Option<String>)
#[cfg(test)]
#[path = "thread_manager_tests.rs"]
mod tests;
#[cfg(test)]
// Keep this inline fork-reference test module disabled on the refreshed main API;
// branch coverage now comes from the package/integration tests that match current types.
#[cfg(any())]
mod fork_reference_tests {
use super::*;
use crate::codex::make_session_and_context;
use assert_matches::assert_matches;
use codex_protocol::models::ContentItem;
use codex_protocol::models::ReasoningItemReasoningSummary;
use codex_protocol::models::ResponseItem;
@@ -1141,9 +1142,17 @@ mod fork_reference_tests {
.cloned()
.map(RolloutItem::ResponseItem)
.collect();
let truncated =
truncate_before_nth_user_message(Path::new("/tmp"), InitialHistory::Forked(initial), 1)
.await;
let truncated = truncate_before_nth_user_message(
Path::new("/tmp"),
InitialHistory::Forked(initial),
1,
&SnapshotTurnState {
ends_mid_turn: false,
active_turn_id: None,
active_turn_start_index: None,
},
)
.await;
let got_items = truncated.get_rollout_items();
let expected_items = vec![
RolloutItem::ResponseItem(items[0].clone()),
@@ -1164,9 +1173,14 @@ mod fork_reference_tests {
Path::new("/tmp"),
InitialHistory::Forked(initial2),
2,
&SnapshotTurnState {
ends_mid_turn: false,
active_turn_id: None,
active_turn_start_index: None,
},
)
.await;
assert_matches!(truncated2, InitialHistory::New);
assert!(matches!(truncated2, InitialHistory::New));
}
#[tokio::test]
@@ -1188,6 +1202,11 @@ mod fork_reference_tests {
Path::new("/tmp"),
InitialHistory::Forked(rollout_items),
1,
&SnapshotTurnState {
ends_mid_turn: false,
active_turn_id: None,
active_turn_start_index: None,
},
)
.await;
let got_items = truncated.get_rollout_items();
@@ -4,7 +4,6 @@ use crate::config::test_config;
use crate::models_manager::collaboration_mode_presets::CollaborationModesConfig;
use crate::models_manager::manager::RefreshStrategy;
use crate::tasks::interrupted_turn_history_marker;
use assert_matches::assert_matches;
use codex_protocol::models::ContentItem;
use codex_protocol::models::ReasoningItemReasoningSummary;
use codex_protocol::models::ResponseItem;