diff --git a/notes/fresh-workspace-handoff.md b/notes/fresh-workspace-handoff.md index 5b966a4e..76430b69 100644 --- a/notes/fresh-workspace-handoff.md +++ b/notes/fresh-workspace-handoff.md @@ -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 diff --git a/notes/json-contamination-ledger.md b/notes/json-contamination-ledger.md index 398bbd66..d35500d1 100644 --- a/notes/json-contamination-ledger.md +++ b/notes/json-contamination-ledger.md @@ -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. diff --git a/state/ledgers.msgpack b/state/ledgers.msgpack index 65def2d3..9a2852e2 100644 Binary files a/state/ledgers.msgpack and b/state/ledgers.msgpack differ diff --git a/state/map.yaml b/state/map.yaml index 01b9e2af..1e094e84 100644 --- a/state/map.yaml +++ b/state/map.yaml @@ -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. diff --git a/vendor/codex/codex-rs/app-server/src/codex_message_processor.rs b/vendor/codex/codex-rs/app-server/src/codex_message_processor.rs index 5ea0cdf2..864e4f6e 100644 --- a/vendor/codex/codex-rs/app-server/src/codex_message_processor.rs +++ b/vendor/codex/codex-rs/app-server/src/codex_message_processor.rs @@ -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 { - 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 { - 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 { diff --git a/vendor/codex/codex-rs/app-server/src/epiphany_retrieve.rs b/vendor/codex/codex-rs/app-server/src/epiphany_retrieve.rs new file mode 100644 index 00000000..317a7c33 --- /dev/null +++ b/vendor/codex/codex-rs/app-server/src/epiphany_retrieve.rs @@ -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 { + 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 { + 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, + } +} diff --git a/vendor/codex/codex-rs/app-server/src/lib.rs b/vendor/codex/codex-rs/app-server/src/lib.rs index b560d1f9..3f509062 100644 --- a/vendor/codex/codex-rs/app-server/src/lib.rs +++ b/vendor/codex/codex-rs/app-server/src/lib.rs @@ -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;