fix(core): auto-unarchive archived sessions on id lookup#12481
fix(core): auto-unarchive archived sessions on id lookup#12481friel-openai wants to merge 1 commit intoopenai:mainfrom
Conversation
Restore archived rollout files back into sessions when resolving a thread by id. This lets resume, fork, and resume_agent paths that rely on find_thread_path_by_id_str recover archived sessions automatically instead of reporting them missing. Also adds a regression test covering archived->sessions restoration and lookup behavior.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: fe31d1a911
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| .join(day); | ||
| tokio::fs::create_dir_all(&restored_dir).await?; | ||
| let restored_path = restored_dir.join(&file_name); | ||
| match tokio::fs::rename(&archived_path, &restored_path).await { |
There was a problem hiding this comment.
Validate archived path and id before unarchiving
try_unarchive_thread_path_by_id_str renames whatever path lookup returns, but it never checks that the source is actually under archived_sessions or that the filename ends with the requested thread id. Because DB lookup in find_thread_path_by_id_str_in_subdir accepts any existing rollout_path, a stale/corrupt row can move an unrelated file and then mark the wrong thread unarchived.
Useful? React with 👍 / 👎.
Restore archived rollout files back into sessions when resolving a thread by id. This lets resume, fork, and resume_agent paths that rely on find_thread_path_by_id_str recover archived sessions automatically instead of reporting them missing.
Also adds a regression test covering archived->sessions restoration and lookup behavior.