From 69d9762d81d1d62b2c5452433c90c5ae9c7baee5 Mon Sep 17 00:00:00 2001 From: Meta Vens Date: Tue, 19 May 2026 13:59:48 +0100 Subject: [PATCH] Move retrieval host seam to app-server --- epiphany-codex-bridge/src/retrieve.rs | 37 ++++++++-------- epiphany-codex-bridge/src/state.rs | 7 ++- .../epiphany_automation.rs | 6 ++- .../epiphany_mutation_routes.rs | 21 +++++++-- .../epiphany_read_routes.rs | 43 ++++++++++++------- 5 files changed, 70 insertions(+), 44 deletions(-) diff --git a/epiphany-codex-bridge/src/retrieve.rs b/epiphany-codex-bridge/src/retrieve.rs index 9e8da28b..51d946e9 100644 --- a/epiphany-codex-bridge/src/retrieve.rs +++ b/epiphany-codex-bridge/src/retrieve.rs @@ -4,7 +4,6 @@ use codex_app_server_protocol::ThreadEpiphanyRetrieveResponse; use codex_app_server_protocol::ThreadEpiphanyRetrieveResult; use codex_app_server_protocol::ThreadEpiphanyRetrieveResultKind; use codex_app_server_protocol::ThreadEpiphanyRetrieveShardSummary; -use codex_core::CodexThread; use codex_protocol::protocol::EpiphanyRetrievalState; use codex_utils_absolute_path::AbsolutePathBuf; use epiphany_core::EpiphanyRetrieveQuery; @@ -31,13 +30,15 @@ pub fn map_epiphany_retrieve_response( }) } -pub async fn index_thread_epiphany_retrieval( - thread: &CodexThread, +pub async fn index_epiphany_retrieval_for_paths( + workspace_root: PathBuf, + codex_home: PathBuf, force_full_rebuild: bool, ) -> anyhow::Result { - let index_summary = index_thread_epiphany_retrieval_state(thread, force_full_rebuild) - .await - .and_then(map_epiphany_retrieve_index_summary)?; + let index_summary = + index_epiphany_retrieval_state_for_paths(workspace_root, codex_home, force_full_rebuild) + .await + .and_then(map_epiphany_retrieve_index_summary)?; Ok(ThreadEpiphanyIndexResponse { index_summary }) } @@ -49,10 +50,10 @@ pub fn normalize_thread_epiphany_retrieve_query( normalize_epiphany_retrieve_query(query, limit, path_prefixes).map_err(str::to_string) } -pub async fn thread_epiphany_retrieval_state(thread: &CodexThread) -> EpiphanyRetrievalState { - let config = thread.config_snapshot().await; - let workspace_root = config.cwd.to_path_buf(); - let codex_home = thread.codex_home().await; +pub async fn epiphany_retrieval_state_for_paths( + workspace_root: PathBuf, + codex_home: PathBuf, +) -> EpiphanyRetrievalState { let fallback_workspace_root = workspace_root.clone(); let fallback_codex_home = codex_home.clone(); tokio::task::spawn_blocking(move || { @@ -64,13 +65,11 @@ pub async fn thread_epiphany_retrieval_state(thread: &CodexThread) -> EpiphanyRe }) } -pub async fn index_thread_epiphany_retrieval_state( - thread: &CodexThread, +pub async fn index_epiphany_retrieval_state_for_paths( + workspace_root: PathBuf, + codex_home: PathBuf, force_full_rebuild: bool, ) -> anyhow::Result { - let config = thread.config_snapshot().await; - let workspace_root = config.cwd.to_path_buf(); - let codex_home = thread.codex_home().await; tokio::task::spawn_blocking(move || { index_workspace(&workspace_root, codex_home.as_path(), force_full_rebuild) }) @@ -78,13 +77,11 @@ pub async fn index_thread_epiphany_retrieval_state( .map_err(|err| anyhow::anyhow!("epiphany index worker failed: {err}"))? } -pub async fn retrieve_thread_epiphany( - thread: &CodexThread, +pub async fn retrieve_epiphany_for_paths( + workspace_root: PathBuf, + codex_home: PathBuf, query: EpiphanyRetrieveQuery, ) -> anyhow::Result { - let config = thread.config_snapshot().await; - let workspace_root = config.cwd.to_path_buf(); - let codex_home = thread.codex_home().await; tokio::task::spawn_blocking(move || { retrieve_workspace(&workspace_root, codex_home.as_path(), query) }) diff --git a/epiphany-codex-bridge/src/state.rs b/epiphany-codex-bridge/src/state.rs index 286e7c2f..421290a9 100644 --- a/epiphany-codex-bridge/src/state.rs +++ b/epiphany-codex-bridge/src/state.rs @@ -10,7 +10,7 @@ use codex_protocol::protocol::InitialHistory; use epiphany_core::write_thread_state; use tracing::warn; -use crate::retrieve::thread_epiphany_retrieval_state; +use crate::retrieve::epiphany_retrieval_state_for_paths; pub async fn load_epiphany_state_from_rollout_path( rollout_path: &Path, @@ -35,7 +35,10 @@ pub async fn live_thread_epiphany_state(thread: &CodexThread) -> Option return, }; - let response = match index_thread_epiphany_retrieval(thread.as_ref(), force_full_rebuild) - .await + let config = thread.config_snapshot().await; + let codex_home = thread.codex_home().await; + let response = match index_epiphany_retrieval_for_paths( + config.cwd.to_path_buf(), + codex_home, + force_full_rebuild, + ) + .await { Ok(response) => response, Err(err) => { @@ -691,3 +698,9 @@ impl CodexMessageProcessor { .await; } } + +async fn thread_epiphany_retrieval_state(thread: &CodexThread) -> EpiphanyRetrievalState { + let config = thread.config_snapshot().await; + let codex_home = thread.codex_home().await; + epiphany_retrieval_state_for_paths(config.cwd.to_path_buf(), codex_home).await +} diff --git a/vendor/codex/codex-rs/app-server/src/codex_message_processor/epiphany_read_routes.rs b/vendor/codex/codex-rs/app-server/src/codex_message_processor/epiphany_read_routes.rs index 446f2d48..c8268c13 100644 --- a/vendor/codex/codex-rs/app-server/src/codex_message_processor/epiphany_read_routes.rs +++ b/vendor/codex/codex-rs/app-server/src/codex_message_processor/epiphany_read_routes.rs @@ -1,12 +1,14 @@ use codex_app_server_protocol::*; +use codex_core::CodexThread; use codex_protocol::ThreadId; +use codex_protocol::protocol::EpiphanyRetrievalState; use epiphany_codex_bridge::invalidation::epiphany_freshness_watcher_snapshot; use epiphany_codex_bridge::launch::EPIPHANY_REORIENT_LAUNCH_BINDING_ID; use epiphany_codex_bridge::launch::epiphany_role_binding_id; +use epiphany_codex_bridge::retrieve::epiphany_retrieval_state_for_paths; use epiphany_codex_bridge::retrieve::map_epiphany_retrieve_response; use epiphany_codex_bridge::retrieve::normalize_thread_epiphany_retrieve_query; -use epiphany_codex_bridge::retrieve::retrieve_thread_epiphany; -use epiphany_codex_bridge::retrieve::thread_epiphany_retrieval_state; +use epiphany_codex_bridge::retrieve::retrieve_epiphany_for_paths; use epiphany_codex_bridge::view::EpiphanyFreshnessResponseInput; use epiphany_codex_bridge::view::EpiphanyReorientResultResponseInput; use epiphany_codex_bridge::view::EpiphanyRoleResultResponseInput; @@ -440,20 +442,23 @@ impl CodexMessageProcessor { } }; - let response = match retrieve_thread_epiphany(thread.as_ref(), query) - .await - .and_then(map_epiphany_retrieve_response) - { - Ok(response) => response, - Err(err) => { - self.send_internal_error( - request_id, - format!("failed to retrieve Epiphany results for {thread_uuid}: {err}"), - ) - .await; - return; - } - }; + let config = thread.config_snapshot().await; + let codex_home = thread.codex_home().await; + let response = + match retrieve_epiphany_for_paths(config.cwd.to_path_buf(), codex_home, query) + .await + .and_then(map_epiphany_retrieve_response) + { + Ok(response) => response, + Err(err) => { + self.send_internal_error( + request_id, + format!("failed to retrieve Epiphany results for {thread_uuid}: {err}"), + ) + .await; + return; + } + }; self.outgoing.send_response(request_id, response).await; } @@ -561,3 +566,9 @@ impl CodexMessageProcessor { self.outgoing.send_response(request_id, response).await; } } + +async fn thread_epiphany_retrieval_state(thread: &CodexThread) -> EpiphanyRetrievalState { + let config = thread.config_snapshot().await; + let codex_home = thread.codex_home().await; + epiphany_retrieval_state_for_paths(config.cwd.to_path_buf(), codex_home).await +}