codex: fix CI failure on PR #31859

This commit is contained in:
Owen Lin
2026-07-09 21:55:48 -07:00
parent 3b1fd5bb1c
commit 660395c47d
2 changed files with 30 additions and 7 deletions

View File

@@ -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)
}

View File

@@ -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");