Promote rollout path read to store trait
This commit is contained in:
parent
11ab180406
commit
ef4f1e1a52
11 changed files with 66 additions and 65 deletions
|
|
@ -50,6 +50,7 @@ remembers doctrine; the branch remembers the blade.
|
|||
- Model/catalog routes now live in `codex_message_processor/catalog_routes.rs`: model list, collaboration-mode list, experimental feature list, and mock experimental method. The root processor is about 6,738 lines.
|
||||
- Thread administrative mutation routes now live in `codex_message_processor/thread_admin_routes.rs`: archive/unarchive, elicitation counters, set-name, memory mode, memory reset, metadata update, rollback, compact, background terminal cleanup, shell command submission, and guardian approval. The root processor is about 5,750 lines.
|
||||
- Thread read/list projection routes now live in `codex_message_processor/thread_read_routes.rs`: persisted/live thread listing, loaded-thread listing, `thread/read`, read-list filter normalization/tests, Epiphany state attachment for reads, rollout turn paging, and read-side rollout field hydration.
|
||||
- Thread-store rollout-path reads are now an explicit `ThreadStore::read_thread_by_rollout_path` capability with typed params. App-server read routes no longer downcast `Arc<dyn ThreadStore>` to `LocalThreadStore`; local and remote stores define the capability/rejection boundary, and the local rollout-path read test exercises the trait method.
|
||||
- Thread resume/fork orchestration now lives in `codex_message_processor/thread_resume_routes.rs`; it owns resume from history/rollout, running-thread resume response replay, persisted resume metadata hydration, fork response construction, and the shared thread-title attachment helper. The root processor is about 4,336 lines.
|
||||
- Running-thread resume response composition and resume override metadata helpers now live in `codex_message_processor/thread_resume_routes.rs`; root no longer owns `handle_pending_thread_resume_request`, resume mismatch collection, or persisted resume metadata merging.
|
||||
- Thread start route handling and its async lifecycle task now live in `codex_message_processor/thread_start_routes.rs`; root no longer owns `thread_start_task`.
|
||||
|
|
|
|||
Binary file not shown.
File diff suppressed because one or more lines are too long
|
|
@ -320,6 +320,7 @@ use codex_state::log_db::LogDbLayer;
|
|||
use codex_thread_store::ArchiveThreadParams as StoreArchiveThreadParams;
|
||||
use codex_thread_store::ListThreadsParams as StoreListThreadsParams;
|
||||
use codex_thread_store::LocalThreadStore;
|
||||
use codex_thread_store::ReadThreadByRolloutPathParams as StoreReadThreadByRolloutPathParams;
|
||||
use codex_thread_store::ReadThreadParams as StoreReadThreadParams;
|
||||
use codex_thread_store::RemoteThreadStore;
|
||||
use codex_thread_store::SortDirection as StoreSortDirection;
|
||||
|
|
|
|||
|
|
@ -574,31 +574,15 @@ impl CodexMessageProcessor {
|
|||
})
|
||||
.await
|
||||
.map_err(|err| conversation_summary_thread_id_read_error(conversation_id, err)),
|
||||
GetConversationSummaryParams::RolloutPath { rollout_path } => {
|
||||
let Some(local_thread_store) = self
|
||||
.thread_store
|
||||
.as_any()
|
||||
.downcast_ref::<LocalThreadStore>()
|
||||
else {
|
||||
let error = JSONRPCErrorError {
|
||||
code: INVALID_REQUEST_ERROR_CODE,
|
||||
message:
|
||||
"rollout path queries are only supported with the local thread store"
|
||||
.to_string(),
|
||||
data: None,
|
||||
};
|
||||
return self.outgoing.send_error(request_id, error).await;
|
||||
};
|
||||
|
||||
local_thread_store
|
||||
.read_thread_by_rollout_path(
|
||||
rollout_path.clone(),
|
||||
/*include_archived*/ true,
|
||||
/*include_history*/ false,
|
||||
)
|
||||
.await
|
||||
.map_err(|err| conversation_summary_rollout_path_read_error(&rollout_path, err))
|
||||
}
|
||||
GetConversationSummaryParams::RolloutPath { rollout_path } => self
|
||||
.thread_store
|
||||
.read_thread_by_rollout_path(StoreReadThreadByRolloutPathParams {
|
||||
rollout_path: rollout_path.clone(),
|
||||
include_archived: true,
|
||||
include_history: false,
|
||||
})
|
||||
.await
|
||||
.map_err(|err| conversation_summary_rollout_path_read_error(&rollout_path, err)),
|
||||
};
|
||||
|
||||
match read_result {
|
||||
|
|
|
|||
|
|
@ -24,6 +24,7 @@ pub use types::GitInfoPatch;
|
|||
pub use types::ListThreadsParams;
|
||||
pub use types::LoadThreadHistoryParams;
|
||||
pub use types::OptionalStringPatch;
|
||||
pub use types::ReadThreadByRolloutPathParams;
|
||||
pub use types::ReadThreadParams;
|
||||
pub use types::ResumeThreadRecorderParams;
|
||||
pub use types::SortDirection;
|
||||
|
|
|
|||
|
|
@ -16,6 +16,7 @@ use crate::ArchiveThreadParams;
|
|||
use crate::CreateThreadParams;
|
||||
use crate::ListThreadsParams;
|
||||
use crate::LoadThreadHistoryParams;
|
||||
use crate::ReadThreadByRolloutPathParams;
|
||||
use crate::ReadThreadParams;
|
||||
use crate::ResumeThreadRecorderParams;
|
||||
use crate::StoredThread;
|
||||
|
|
@ -38,30 +39,10 @@ impl LocalThreadStore {
|
|||
pub fn new(config: RolloutConfig) -> Self {
|
||||
Self { config }
|
||||
}
|
||||
|
||||
/// Read a local rollout-backed thread by path.
|
||||
pub async fn read_thread_by_rollout_path(
|
||||
&self,
|
||||
rollout_path: std::path::PathBuf,
|
||||
include_archived: bool,
|
||||
include_history: bool,
|
||||
) -> ThreadStoreResult<StoredThread> {
|
||||
read_thread::read_thread_by_rollout_path(
|
||||
self,
|
||||
rollout_path,
|
||||
include_archived,
|
||||
include_history,
|
||||
)
|
||||
.await
|
||||
}
|
||||
}
|
||||
|
||||
#[async_trait]
|
||||
impl ThreadStore for LocalThreadStore {
|
||||
fn as_any(&self) -> &dyn std::any::Any {
|
||||
self
|
||||
}
|
||||
|
||||
async fn create_thread(
|
||||
&self,
|
||||
_params: CreateThreadParams,
|
||||
|
|
@ -91,6 +72,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
|
||||
}
|
||||
|
|
|
|||
|
|
@ -393,14 +393,16 @@ mod tests {
|
|||
.expect("path should be under codex home")
|
||||
.to_path_buf();
|
||||
|
||||
let thread = store
|
||||
.read_thread_by_rollout_path(
|
||||
relative_path,
|
||||
/*include_archived*/ false,
|
||||
/*include_history*/ false,
|
||||
)
|
||||
.await
|
||||
.expect("read thread by rollout path");
|
||||
let thread = crate::ThreadStore::read_thread_by_rollout_path(
|
||||
&store,
|
||||
crate::ReadThreadByRolloutPathParams {
|
||||
rollout_path: relative_path,
|
||||
include_archived: false,
|
||||
include_history: false,
|
||||
},
|
||||
)
|
||||
.await
|
||||
.expect("read thread by rollout path");
|
||||
|
||||
assert_eq!(thread.thread_id, thread_id);
|
||||
assert_eq!(
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@ use crate::ArchiveThreadParams;
|
|||
use crate::CreateThreadParams;
|
||||
use crate::ListThreadsParams;
|
||||
use crate::LoadThreadHistoryParams;
|
||||
use crate::ReadThreadByRolloutPathParams;
|
||||
use crate::ReadThreadParams;
|
||||
use crate::ResumeThreadRecorderParams;
|
||||
use crate::StoredThread;
|
||||
|
|
@ -48,10 +49,6 @@ impl RemoteThreadStore {
|
|||
|
||||
#[async_trait]
|
||||
impl ThreadStore for RemoteThreadStore {
|
||||
fn as_any(&self) -> &dyn std::any::Any {
|
||||
self
|
||||
}
|
||||
|
||||
async fn create_thread(
|
||||
&self,
|
||||
_params: CreateThreadParams,
|
||||
|
|
@ -81,6 +78,15 @@ impl ThreadStore for RemoteThreadStore {
|
|||
Err(not_implemented("read_thread"))
|
||||
}
|
||||
|
||||
async fn read_thread_by_rollout_path(
|
||||
&self,
|
||||
_params: ReadThreadByRolloutPathParams,
|
||||
) -> ThreadStoreResult<StoredThread> {
|
||||
Err(ThreadStoreError::InvalidRequest {
|
||||
message: "rollout path queries are only supported by local thread stores".to_string(),
|
||||
})
|
||||
}
|
||||
|
||||
async fn list_threads(&self, params: ListThreadsParams) -> ThreadStoreResult<ThreadPage> {
|
||||
list_threads::list_threads(self, params).await
|
||||
}
|
||||
|
|
|
|||
15
vendor/codex/codex-rs/thread-store/src/store.rs
vendored
15
vendor/codex/codex-rs/thread-store/src/store.rs
vendored
|
|
@ -1,5 +1,3 @@
|
|||
use std::any::Any;
|
||||
|
||||
use async_trait::async_trait;
|
||||
|
||||
use crate::AppendThreadItemsParams;
|
||||
|
|
@ -7,6 +5,7 @@ use crate::ArchiveThreadParams;
|
|||
use crate::CreateThreadParams;
|
||||
use crate::ListThreadsParams;
|
||||
use crate::LoadThreadHistoryParams;
|
||||
use crate::ReadThreadByRolloutPathParams;
|
||||
use crate::ReadThreadParams;
|
||||
use crate::ResumeThreadRecorderParams;
|
||||
use crate::StoredThread;
|
||||
|
|
@ -18,11 +17,7 @@ use crate::UpdateThreadMetadataParams;
|
|||
|
||||
/// Storage-neutral thread persistence boundary.
|
||||
#[async_trait]
|
||||
pub trait ThreadStore: Any + Send + Sync {
|
||||
/// Return this store as [`Any`] so callers at API boundaries can reject requests that only
|
||||
/// make sense for a concrete store implementation.
|
||||
fn as_any(&self) -> &dyn Any;
|
||||
|
||||
pub trait ThreadStore: Send + Sync {
|
||||
/// Creates a new thread and returns a live recorder for future appends.
|
||||
async fn create_thread(
|
||||
&self,
|
||||
|
|
@ -47,6 +42,12 @@ pub trait ThreadStore: Any + Send + Sync {
|
|||
/// Reads a thread summary and optionally its persisted history.
|
||||
async fn read_thread(&self, params: ReadThreadParams) -> ThreadStoreResult<StoredThread>;
|
||||
|
||||
/// Reads a thread summary by rollout path when the backing store exposes local paths.
|
||||
async fn read_thread_by_rollout_path(
|
||||
&self,
|
||||
params: ReadThreadByRolloutPathParams,
|
||||
) -> ThreadStoreResult<StoredThread>;
|
||||
|
||||
/// Lists stored threads matching the supplied filters.
|
||||
async fn list_threads(&self, params: ListThreadsParams) -> ThreadStoreResult<ThreadPage>;
|
||||
|
||||
|
|
|
|||
11
vendor/codex/codex-rs/thread-store/src/types.rs
vendored
11
vendor/codex/codex-rs/thread-store/src/types.rs
vendored
|
|
@ -92,6 +92,17 @@ pub struct ReadThreadParams {
|
|||
pub include_history: bool,
|
||||
}
|
||||
|
||||
/// Parameters for reading a thread summary by local rollout path.
|
||||
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
|
||||
pub struct ReadThreadByRolloutPathParams {
|
||||
/// Rollout file path to read.
|
||||
pub rollout_path: PathBuf,
|
||||
/// Whether archived threads are eligible.
|
||||
pub include_archived: bool,
|
||||
/// Whether persisted rollout items should be included in the response.
|
||||
pub include_history: bool,
|
||||
}
|
||||
|
||||
/// The sort key to use when listing stored threads.
|
||||
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Serialize, Deserialize)]
|
||||
pub enum ThreadSortKey {
|
||||
|
|
|
|||
Reference in a new issue