Lightweight coding agent that runs in your terminal
Rust
Use session metadata to validate thread history paths (#38033)
Tamir Duberstein4496ba3fd564
diff --git a/codex-rs/thread-store/src/local/read_thread.rs b/codex-rs/thread-store/src/local/read_thread.rsindex 548ce9d31a..d99ad6d42f 100644--- a/codex-rs/thread-store/src/local/read_thread.rs+++ b/codex-rs/thread-store/src/local/read_thread.rs@@ -42,12 +42,8 @@ pub(super) async fn read_thread(metadata.rollout_path.as_path(),)))&& (!params.include_history- || sqlite_rollout_path_can_load_history_for_thread(- store,- &metadata.rollout_path,- thread_id,- )- .await)+ || sqlite_rollout_path_can_load_history_for_thread(&metadata.rollout_path, thread_id)+ .await){let metadata_sandbox_policy = metadata.sandbox_policy.clone();let mut thread = stored_thread_from_sqlite_metadata(store, metadata).await?;@@ -101,7 +97,6 @@ pub(super) async fn read_thread(}async fn sqlite_rollout_path_can_load_history_for_thread(- store: &LocalThreadStore,path: &std::path::Path,thread_id: codex_protocol::ThreadId,) -> bool {@@ -111,9 +106,9 @@ async fn sqlite_rollout_path_can_load_history_for_thread(// SQLite metadata can outlive a moved/recreated rollout path. When history is// requested, verify the path still resolves to the requested thread before// trusting it as the source replay.- read_thread_from_rollout_path(store, path.to_path_buf())+ read_session_meta_line(path).await- .is_ok_and(|thread| thread.thread_id == thread_id)+ .is_ok_and(|metadata| metadata.meta.id == thread_id)}pub(super) async fn read_thread_by_rollout_path(