Migrate fork and resume reads to thread store (#18900)

- Route cold thread/resume and thread/fork source loading through
ThreadStore reads instead of direct rollout path operations
- Keep lookups that explicitly specify a rollout-path using the local
thread store methods but return an invalid-request error for remote
ThreadStore configurations
- Add some additional unit tests for code path coverage
This commit is contained in:
Tom authored and GitHub committed 2026-04-24 13:51:37 -07:00
1 parent 13e0ec1614
commit 0a9b559c0b
18 files changed
+966 -410

No files matched your search

+59
View File
@@ -27,6 +27,7 @@ use crate::ArchiveThreadParams;
use crate::CreateThreadParams;
use crate::ListThreadsParams;
use crate::LoadThreadHistoryParams;
use crate::ReadThreadByRolloutPathParams;
use crate::ReadThreadParams;
use crate::ResumeThreadParams;
use crate::StoredThread;
@@ -207,6 +208,19 @@ impl ThreadStore for LocalThreadStore {
read_thread::read_thread(self, params).await
}
async fn read_thread_by_rollout_path(
&self,
params: ReadThreadByRolloutPathParams,
) -> ThreadStoreResult<StoredThread> {
read_thread::read_thread_by_rollout_path(
self,
params.rollout_path,
params.include_archived,
params.include_history,
)
.await
}
async fn list_threads(&self, params: ListThreadsParams) -> ThreadStoreResult<ThreadPage> {
list_threads::list_threads(self, params).await
}
@@ -508,6 +522,51 @@ mod tests {
}));
}
#[tokio::test]
async fn read_thread_by_rollout_path_includes_history() {
let home = TempDir::new().expect("temp dir");
let store = LocalThreadStore::new(test_config(home.path()));
let thread_id = ThreadId::default();
store
.create_thread(create_thread_params(thread_id))
.await
.expect("create thread");
store
.append_items(AppendThreadItemsParams {
thread_id,
items: vec![user_message_item("path read")],
})
.await
.expect("append item");
store.flush_thread(thread_id).await.expect("flush thread");
let rollout_path = store
.live_rollout_path(thread_id)
.await
.expect("load rollout path");
let thread = store
.read_thread_by_rollout_path(
rollout_path,
/*include_archived*/ true,
/*include_history*/ true,
)
.await
.expect("read thread by rollout path");
assert_eq!(thread.thread_id, thread_id);
assert_eq!(
thread
.history
.expect("history")
.items
.into_iter()
.filter(|item| matches!(item, RolloutItem::EventMsg(EventMsg::UserMessage(_))))
.count(),
1
);
}
fn create_thread_params(thread_id: ThreadId) -> CreateThreadParams {
CreateThreadParams {
thread_id,