mirror of
https://github.com/openai/codex.git
synced 2026-08-23 13:09:46 +00:00
codex: fix CI failure on PR #31859
This commit is contained in:
@@ -53,7 +53,9 @@ pub(crate) async fn ordinal_state_for_rollout(path: &Path) -> io::Result<Rollout
|
||||
}
|
||||
|
||||
fn ordinal_state_for_rollout_blocking(path: &Path) -> io::Result<RolloutOrdinalState> {
|
||||
let history_mode = read_history_mode(path)?;
|
||||
let Some(history_mode) = read_history_mode(path)? else {
|
||||
return Ok(RolloutOrdinalState::Legacy);
|
||||
};
|
||||
if matches!(history_mode, ThreadHistoryMode::Legacy) {
|
||||
return Ok(RolloutOrdinalState::Legacy);
|
||||
}
|
||||
@@ -82,7 +84,7 @@ fn ordinal_state_for_rollout_blocking(path: &Path) -> io::Result<RolloutOrdinalS
|
||||
})
|
||||
}
|
||||
|
||||
fn read_history_mode(path: &Path) -> io::Result<ThreadHistoryMode> {
|
||||
fn read_history_mode(path: &Path) -> io::Result<Option<ThreadHistoryMode>> {
|
||||
let reader = BufReader::new(File::open(path)?);
|
||||
for line in reader.lines() {
|
||||
let line = line?;
|
||||
@@ -101,10 +103,7 @@ fn read_history_mode(path: &Path) -> io::Result<ThreadHistoryMode> {
|
||||
path.display()
|
||||
)));
|
||||
};
|
||||
return Ok(session_meta.meta.history_mode);
|
||||
return Ok(Some(session_meta.meta.history_mode));
|
||||
}
|
||||
Err(io::Error::other(format!(
|
||||
"rollout at {} contains no records",
|
||||
path.display()
|
||||
)))
|
||||
Ok(None)
|
||||
}
|
||||
|
||||
@@ -608,6 +608,30 @@ async fn recorder_omits_ordinals_from_legacy_rollouts() -> std::io::Result<()> {
|
||||
recorder.shutdown().await
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn resumed_empty_rollout_omits_ordinals() -> std::io::Result<()> {
|
||||
let home = TempDir::new().expect("temp dir");
|
||||
let config = test_config(home.path());
|
||||
let rollout_path = home.path().join("rollout.jsonl");
|
||||
File::create(&rollout_path)?;
|
||||
|
||||
let recorder =
|
||||
RolloutRecorder::new(&config, RolloutRecorderParams::resume(rollout_path.clone())).await?;
|
||||
recorder
|
||||
.record_canonical_items(&[agent_message_item("legacy")])
|
||||
.await?;
|
||||
recorder.flush().await?;
|
||||
|
||||
let text = fs::read_to_string(rollout_path)?;
|
||||
let values = text
|
||||
.lines()
|
||||
.map(serde_json::from_str::<serde_json::Value>)
|
||||
.collect::<Result<Vec<_>, _>>()?;
|
||||
assert!(values.iter().all(|value| value.get("ordinal").is_none()));
|
||||
|
||||
recorder.shutdown().await
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn persist_reports_filesystem_error_and_retries_buffered_items() -> std::io::Result<()> {
|
||||
let home = TempDir::new().expect("temp dir");
|
||||
|
||||
Reference in New Issue
Block a user