mirror of
https://github.com/openai/codex.git
synced 2026-10-19 17:28:46 +00:00
Use session metadata to validate thread history paths (#38033)
## What changed Validate a SQLite thread's rollout path by reading its `SessionMetaLine` and comparing the recorded thread ID directly. This avoids constructing a `StoredThread` solely to decide whether the path can supply the requested history. GitOrigin-RevId: 8eb1e329514cefc056e44ab4a76d58ff50314a97
This commit is contained in:
committed by
copyberry
parent
8f4a2c99dd
commit
4496ba3fd5
@@ -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(
|
||||
|
||||
Reference in New Issue
Block a user