mirror of
https://github.com/openai/codex.git
synced 2026-11-16 06:54:36 +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:
1 parent
8f4a2c99dd
commit
4496ba3fd5
1 file changed
+4
-9
@@ -42,12 +42,8 @@ pub(super) async fn read_thread(
|
|||||||
metadata.rollout_path.as_path(),
|
metadata.rollout_path.as_path(),
|
||||||
)))
|
)))
|
||||||
&& (!params.include_history
|
&& (!params.include_history
|
||||||
|| sqlite_rollout_path_can_load_history_for_thread(
|
|| sqlite_rollout_path_can_load_history_for_thread(&metadata.rollout_path, thread_id)
|
||||||
store,
|
.await)
|
||||||
&metadata.rollout_path,
|
|
||||||
thread_id,
|
|
||||||
)
|
|
||||||
.await)
|
|
||||||
{
|
{
|
||||||
let metadata_sandbox_policy = metadata.sandbox_policy.clone();
|
let metadata_sandbox_policy = metadata.sandbox_policy.clone();
|
||||||
let mut thread = stored_thread_from_sqlite_metadata(store, metadata).await?;
|
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(
|
async fn sqlite_rollout_path_can_load_history_for_thread(
|
||||||
store: &LocalThreadStore,
|
|
||||||
path: &std::path::Path,
|
path: &std::path::Path,
|
||||||
thread_id: codex_protocol::ThreadId,
|
thread_id: codex_protocol::ThreadId,
|
||||||
) -> bool {
|
) -> 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
|
// SQLite metadata can outlive a moved/recreated rollout path. When history is
|
||||||
// requested, verify the path still resolves to the requested thread before
|
// requested, verify the path still resolves to the requested thread before
|
||||||
// trusting it as the source replay.
|
// trusting it as the source replay.
|
||||||
read_thread_from_rollout_path(store, path.to_path_buf())
|
read_session_meta_line(path)
|
||||||
.await
|
.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(
|
pub(super) async fn read_thread_by_rollout_path(
|
||||||
|
|||||||
Reference in new issue
Block a user