Extract Epiphany retrieve projection

This commit is contained in:
Meta Vens 2026-05-13 01:19:21 +01:00
commit 03d769653f
7 changed files with 85 additions and 76 deletions

View file

@ -423,7 +423,9 @@ to about 19,462 lines. The seventh cut moved jobs projection into
`vendor/codex/codex-rs/app-server/src/epiphany_jobs.rs`, taking the processor to
about 19,377 lines. This is progress, not absolution: handlers,
roles/coordinator mappers, route orchestration, accept policy plumbing, and
tests still keep too much Epiphany inside Codex.
tests still keep too much Epiphany inside Codex. The eighth cut moved retrieve
projection into `vendor/codex/codex-rs/app-server/src/epiphany_retrieve.rs`,
taking the processor to about 19,307 lines.
Also: MCP itself is allowed to be JSON. The target is not "replace MCP JSON";
the target is an Epiphany-owned boundary that speaks typed Epiphany

View file

@ -62,6 +62,6 @@ Rule: JSON is allowed at external schema/wire boundaries. Inside Epiphany, live
3. Done: replace role `statePatch` JSON with typed map/planning/graph patch documents. `EpiphanyRoleFindingInterpretation` now carries `EpiphanyRoleStatePatchDocument`; app-server maps it to the legacy protocol patch without JSON round-tripping.
4. Done: replace runtime job result JSON projections. Runtime-spine results now project through typed role/reorient interpreters instead of `runtime_job_result_to_role_json` and `runtime_job_result_to_reorient_json`.
5. Done: replace app-server launch protocol `input_json` / `output_schema_json` with typed launch documents and `output_contract_id`.
6. Continue the whale-carcass cut: the first cuts moved Epiphany launch doctrine and protocol-to-core launch document mapping into `epiphany_launch.rs`, role/reorient result projection into `epiphany_results.rs`, scene projection into `epiphany_scene.rs`, freshness/reorientation mapping into `epiphany_reorient.rs`, context/planning/graph-query projection into `epiphany_context.rs`, and jobs projection into `epiphany_jobs.rs`, reducing `codex_message_processor.rs` from about 21,263 to 19,377 lines. Next move roles/coordinator projection mappers, route handlers, and policy-shaped code out of the processor; success means the processor keeps shrinking and ownership gets clearer, not merely better typed.
6. Continue the whale-carcass cut: the first cuts moved Epiphany launch doctrine and protocol-to-core launch document mapping into `epiphany_launch.rs`, role/reorient result projection into `epiphany_results.rs`, scene projection into `epiphany_scene.rs`, freshness/reorientation mapping into `epiphany_reorient.rs`, context/planning/graph-query projection into `epiphany_context.rs`, jobs projection into `epiphany_jobs.rs`, and retrieve projection into `epiphany_retrieve.rs`, reducing `codex_message_processor.rs` from about 21,263 to 19,307 lines. Next move roles/coordinator projection mappers, route handlers, and policy-shaped code out of the processor; success means the processor keeps shrinking and ownership gets clearer, not merely better typed.
7. Seal MCP payloads behind an Epiphany boundary that speaks typed Epiphany documents internally and MCP JSON externally.
8. Audit heartbeat cognition values and either type them or explicitly expire them.

Binary file not shown.

View file

@ -278,5 +278,5 @@ rejected_paths:
reason: making Epiphany cleaner inside Codex still preserves the wrong organ; Codex must be starved down to OpenAI subscription auth/model transport, while Epiphany data and subsystem communication move to typed CultCache/CultNet.
current_status:
summary: The Codex starvation pass has five typing receipts plus seven real carcass cuts: Epiphany launch doctrine/prompt/builders and protocol-to-core launch document mapping moved into `vendor/codex/codex-rs/app-server/src/epiphany_launch.rs`, role/reorient result projection/note rendering moved into `vendor/codex/codex-rs/app-server/src/epiphany_results.rs`, scene projection moved into `vendor/codex/codex-rs/app-server/src/epiphany_scene.rs`, freshness/reorientation input mapping moved into `vendor/codex/codex-rs/app-server/src/epiphany_reorient.rs`, context/planning/graph-query projection moved into `vendor/codex/codex-rs/app-server/src/epiphany_context.rs`, and jobs projection moved into `vendor/codex/codex-rs/app-server/src/epiphany_jobs.rs`. The processor is down from about 21,263 lines to 19,377 lines. This is progress, not absolution: route handlers, roles/coordinator mappers, accept policy plumbing, and tests still keep too much Epiphany inside Codex. MCP itself is correctly JSON at its protocol edge; the target is typed Epiphany intent/result/receipt wrappers around MCP, not replacing MCP JSON.
summary: The Codex starvation pass has five typing receipts plus eight real carcass cuts: Epiphany launch doctrine/prompt/builders and protocol-to-core launch document mapping moved into `vendor/codex/codex-rs/app-server/src/epiphany_launch.rs`, role/reorient result projection/note rendering moved into `vendor/codex/codex-rs/app-server/src/epiphany_results.rs`, scene projection moved into `vendor/codex/codex-rs/app-server/src/epiphany_scene.rs`, freshness/reorientation input mapping moved into `vendor/codex/codex-rs/app-server/src/epiphany_reorient.rs`, context/planning/graph-query projection moved into `vendor/codex/codex-rs/app-server/src/epiphany_context.rs`, jobs projection moved into `vendor/codex/codex-rs/app-server/src/epiphany_jobs.rs`, and retrieve projection moved into `vendor/codex/codex-rs/app-server/src/epiphany_retrieve.rs`. The processor is down from about 21,263 lines to 19,307 lines. This is progress, not absolution: route handlers, roles/coordinator mappers, accept policy plumbing, and tests still keep too much Epiphany inside Codex. MCP itself is correctly JSON at its protocol edge; the target is typed Epiphany intent/result/receipt wrappers around MCP, not replacing MCP JSON.
next_action: Continue the actual whale-carcass cut: extract Epiphany roles/coordinator projection mappers and then route handlers out of `codex_message_processor.rs` into Epiphany-owned app-server modules, moving logic further into `epiphany-core` whenever it owns real policy. Success metric remains a visibly smaller processor and clearer ownership, not merely typed payloads.

View file

@ -40,6 +40,8 @@ use crate::epiphany_results::map_protocol_reorient_finding;
use crate::epiphany_results::map_protocol_role_finding;
use crate::epiphany_results::render_epiphany_reorient_result_note;
use crate::epiphany_results::render_epiphany_role_result_note;
use crate::epiphany_retrieve::map_epiphany_retrieve_index_summary;
use crate::epiphany_retrieve::map_epiphany_retrieve_response;
use crate::epiphany_scene::map_core_epiphany_scene_action;
use crate::epiphany_scene::map_epiphany_scene;
use crate::error_code::INPUT_TOO_LARGE_ERROR_CODE;
@ -241,12 +243,9 @@ use codex_app_server_protocol::ThreadEpiphanyReorientSource;
use codex_app_server_protocol::ThreadEpiphanyReorientStateStatus;
use codex_app_server_protocol::ThreadEpiphanyRetrievalFreshness;
use codex_app_server_protocol::ThreadEpiphanyRetrievalFreshnessStatus;
use codex_app_server_protocol::ThreadEpiphanyRetrieveIndexSummary;
use codex_app_server_protocol::ThreadEpiphanyRetrieveParams;
use codex_app_server_protocol::ThreadEpiphanyRetrieveResponse;
use codex_app_server_protocol::ThreadEpiphanyRetrieveResult;
#[cfg(test)]
use codex_app_server_protocol::ThreadEpiphanyRetrieveResultKind;
use codex_app_server_protocol::ThreadEpiphanyRetrieveShardSummary;
use codex_app_server_protocol::ThreadEpiphanyRoleAcceptParams;
use codex_app_server_protocol::ThreadEpiphanyRoleAcceptResponse;
use codex_app_server_protocol::ThreadEpiphanyRoleFinding;
@ -361,9 +360,6 @@ use codex_core::EpiphanyJobLaunchRequest;
use codex_core::EpiphanyMapProposalInput;
use codex_core::EpiphanyPromotionInput;
use codex_core::EpiphanyRetrieveQuery;
use codex_core::EpiphanyRetrieveResponse as CoreEpiphanyRetrieveResponse;
use codex_core::EpiphanyRetrieveResult as CoreEpiphanyRetrieveResult;
use codex_core::EpiphanyRetrieveResultKind as CoreEpiphanyRetrieveResultKind;
use codex_core::EpiphanyStateUpdate;
use codex_core::ForkSnapshot;
use codex_core::NewThread;
@ -14160,72 +14156,6 @@ fn thread_epiphany_patch_has_state_replacements(patch: &ThreadEpiphanyUpdatePatc
|| patch.planning.is_some()
}
fn map_epiphany_retrieve_response(
response: CoreEpiphanyRetrieveResponse,
) -> anyhow::Result<ThreadEpiphanyRetrieveResponse> {
Ok(ThreadEpiphanyRetrieveResponse {
query: response.query,
index_summary: map_epiphany_retrieve_index_summary(response.index_summary)?,
results: response
.results
.into_iter()
.map(map_epiphany_retrieve_result)
.collect(),
})
}
fn map_epiphany_retrieve_index_summary(
summary: codex_protocol::protocol::EpiphanyRetrievalState,
) -> anyhow::Result<ThreadEpiphanyRetrieveIndexSummary> {
Ok(ThreadEpiphanyRetrieveIndexSummary {
workspace_root: AbsolutePathBuf::from_absolute_path(summary.workspace_root)
.map_err(anyhow::Error::from)?,
index_revision: summary.index_revision,
status: summary.status,
semantic_available: summary.semantic_available,
last_indexed_at_unix_seconds: summary.last_indexed_at_unix_seconds,
indexed_file_count: summary.indexed_file_count,
indexed_chunk_count: summary.indexed_chunk_count,
shards: summary
.shards
.into_iter()
.map(|shard| ThreadEpiphanyRetrieveShardSummary {
shard_id: shard.shard_id,
path_prefix: shard.path_prefix,
indexed_file_count: shard.indexed_file_count,
indexed_chunk_count: shard.indexed_chunk_count,
status: shard.status,
exact_available: shard.exact_available,
semantic_available: shard.semantic_available,
})
.collect(),
dirty_paths: summary.dirty_paths,
})
}
fn map_epiphany_retrieve_result(
result: CoreEpiphanyRetrieveResult,
) -> ThreadEpiphanyRetrieveResult {
ThreadEpiphanyRetrieveResult {
kind: match result.kind {
CoreEpiphanyRetrieveResultKind::ExactFile => {
ThreadEpiphanyRetrieveResultKind::ExactFile
}
CoreEpiphanyRetrieveResultKind::ExactDirectory => {
ThreadEpiphanyRetrieveResultKind::ExactDirectory
}
CoreEpiphanyRetrieveResultKind::SemanticChunk => {
ThreadEpiphanyRetrieveResultKind::SemanticChunk
}
},
path: result.path,
score: result.score,
line_start: result.line_start,
line_end: result.line_end,
excerpt: result.excerpt,
}
}
fn epiphany_update_patch_changed_fields(
patch: &ThreadEpiphanyUpdatePatch,
) -> Vec<ThreadEpiphanyStateUpdatedField> {

View file

@ -0,0 +1,76 @@
use codex_app_server_protocol::ThreadEpiphanyRetrieveIndexSummary;
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::EpiphanyRetrieveResponse as CoreEpiphanyRetrieveResponse;
use codex_core::EpiphanyRetrieveResult as CoreEpiphanyRetrieveResult;
use codex_core::EpiphanyRetrieveResultKind as CoreEpiphanyRetrieveResultKind;
use codex_protocol::protocol::EpiphanyRetrievalState;
use codex_utils_absolute_path::AbsolutePathBuf;
pub(super) fn map_epiphany_retrieve_response(
response: CoreEpiphanyRetrieveResponse,
) -> anyhow::Result<ThreadEpiphanyRetrieveResponse> {
Ok(ThreadEpiphanyRetrieveResponse {
query: response.query,
index_summary: map_epiphany_retrieve_index_summary(response.index_summary)?,
results: response
.results
.into_iter()
.map(map_epiphany_retrieve_result)
.collect(),
})
}
pub(super) fn map_epiphany_retrieve_index_summary(
summary: EpiphanyRetrievalState,
) -> anyhow::Result<ThreadEpiphanyRetrieveIndexSummary> {
Ok(ThreadEpiphanyRetrieveIndexSummary {
workspace_root: AbsolutePathBuf::from_absolute_path(summary.workspace_root)
.map_err(anyhow::Error::from)?,
index_revision: summary.index_revision,
status: summary.status,
semantic_available: summary.semantic_available,
last_indexed_at_unix_seconds: summary.last_indexed_at_unix_seconds,
indexed_file_count: summary.indexed_file_count,
indexed_chunk_count: summary.indexed_chunk_count,
shards: summary
.shards
.into_iter()
.map(|shard| ThreadEpiphanyRetrieveShardSummary {
shard_id: shard.shard_id,
path_prefix: shard.path_prefix,
indexed_file_count: shard.indexed_file_count,
indexed_chunk_count: shard.indexed_chunk_count,
status: shard.status,
exact_available: shard.exact_available,
semantic_available: shard.semantic_available,
})
.collect(),
dirty_paths: summary.dirty_paths,
})
}
fn map_epiphany_retrieve_result(
result: CoreEpiphanyRetrieveResult,
) -> ThreadEpiphanyRetrieveResult {
ThreadEpiphanyRetrieveResult {
kind: match result.kind {
CoreEpiphanyRetrieveResultKind::ExactFile => {
ThreadEpiphanyRetrieveResultKind::ExactFile
}
CoreEpiphanyRetrieveResultKind::ExactDirectory => {
ThreadEpiphanyRetrieveResultKind::ExactDirectory
}
CoreEpiphanyRetrieveResultKind::SemanticChunk => {
ThreadEpiphanyRetrieveResultKind::SemanticChunk
}
},
path: result.path,
score: result.score,
line_start: result.line_start,
line_end: result.line_end,
excerpt: result.excerpt,
}
}

View file

@ -81,6 +81,7 @@ mod epiphany_jobs;
mod epiphany_launch;
mod epiphany_reorient;
mod epiphany_results;
mod epiphany_retrieve;
mod epiphany_scene;
mod error_code;
mod external_agent_config_api;