From 157f1f086407cff628901a01da0e6810669b0672 Mon Sep 17 00:00:00 2001 From: Meta Vens Date: Wed, 20 May 2026 09:57:34 +0100 Subject: [PATCH] Move context request mapping to app server --- epiphany-codex-bridge/src/context.rs | 56 ---------------- notes/fresh-workspace-handoff.md | 1 + state/ledgers.msgpack | Bin 141579 -> 141843 bytes state/map.yaml | 5 +- .../epiphany_read_routes.rs | 62 ++++++++++++++++-- 5 files changed, 63 insertions(+), 61 deletions(-) diff --git a/epiphany-codex-bridge/src/context.rs b/epiphany-codex-bridge/src/context.rs index e7eb8405..e92f8a07 100644 --- a/epiphany-codex-bridge/src/context.rs +++ b/epiphany-codex-bridge/src/context.rs @@ -1,11 +1,7 @@ use codex_app_server_protocol::ThreadEpiphanyContext; use codex_app_server_protocol::ThreadEpiphanyContextMissing; -use codex_app_server_protocol::ThreadEpiphanyContextParams; use codex_app_server_protocol::ThreadEpiphanyContextStateStatus; use codex_app_server_protocol::ThreadEpiphanyGraphContext; -use codex_app_server_protocol::ThreadEpiphanyGraphQuery; -use codex_app_server_protocol::ThreadEpiphanyGraphQueryDirection; -use codex_app_server_protocol::ThreadEpiphanyGraphQueryKind; use codex_app_server_protocol::ThreadEpiphanyGraphQueryMatched; use codex_app_server_protocol::ThreadEpiphanyGraphQueryMissing; use codex_app_server_protocol::ThreadEpiphanyPlanningSummary; @@ -16,8 +12,6 @@ use epiphany_core::EpiphanyContextStateStatus as CoreEpiphanyContextStateStatus; use epiphany_core::EpiphanyContextView; use epiphany_core::EpiphanyGraphContext as CoreEpiphanyGraphContext; use epiphany_core::EpiphanyGraphQuery as CoreEpiphanyGraphQuery; -use epiphany_core::EpiphanyGraphQueryDirection as CoreEpiphanyGraphQueryDirection; -use epiphany_core::EpiphanyGraphQueryKind as CoreEpiphanyGraphQueryKind; use epiphany_core::EpiphanyGraphQueryMatched as CoreEpiphanyGraphQueryMatched; use epiphany_core::EpiphanyGraphQueryMissing as CoreEpiphanyGraphQueryMissing; use epiphany_core::EpiphanyGraphQueryView; @@ -44,19 +38,6 @@ pub fn map_epiphany_context( map_core_epiphany_context_view(derive_context(state, params)) } -pub fn map_core_epiphany_context_params( - params: &ThreadEpiphanyContextParams, -) -> CoreEpiphanyContextParams { - CoreEpiphanyContextParams { - graph_node_ids: params.graph_node_ids.clone(), - graph_edge_ids: params.graph_edge_ids.clone(), - observation_ids: params.observation_ids.clone(), - evidence_ids: params.evidence_ids.clone(), - include_active_frontier: params.include_active_frontier, - include_linked_evidence: params.include_linked_evidence, - } -} - fn map_core_epiphany_context_view( view: EpiphanyContextView, ) -> ( @@ -177,43 +158,6 @@ pub fn map_epiphany_graph_query( map_core_epiphany_graph_query_view(derive_graph_query(state, query)) } -pub fn map_core_epiphany_graph_query(query: &ThreadEpiphanyGraphQuery) -> CoreEpiphanyGraphQuery { - CoreEpiphanyGraphQuery { - kind: map_core_epiphany_graph_query_kind(query.kind), - node_ids: query.node_ids.clone(), - edge_ids: query.edge_ids.clone(), - paths: query.paths.clone(), - symbols: query.symbols.clone(), - edge_kinds: query.edge_kinds.clone(), - direction: query.direction.map(map_core_epiphany_graph_query_direction), - depth: query.depth, - include_links: query.include_links, - } -} - -fn map_core_epiphany_graph_query_kind( - kind: ThreadEpiphanyGraphQueryKind, -) -> CoreEpiphanyGraphQueryKind { - match kind { - ThreadEpiphanyGraphQueryKind::Node => CoreEpiphanyGraphQueryKind::Node, - ThreadEpiphanyGraphQueryKind::Path => CoreEpiphanyGraphQueryKind::Path, - ThreadEpiphanyGraphQueryKind::FrontierNeighborhood => { - CoreEpiphanyGraphQueryKind::FrontierNeighborhood - } - ThreadEpiphanyGraphQueryKind::Neighbors => CoreEpiphanyGraphQueryKind::Neighbors, - } -} - -fn map_core_epiphany_graph_query_direction( - direction: ThreadEpiphanyGraphQueryDirection, -) -> CoreEpiphanyGraphQueryDirection { - match direction { - ThreadEpiphanyGraphQueryDirection::Incoming => CoreEpiphanyGraphQueryDirection::Incoming, - ThreadEpiphanyGraphQueryDirection::Outgoing => CoreEpiphanyGraphQueryDirection::Outgoing, - ThreadEpiphanyGraphQueryDirection::Both => CoreEpiphanyGraphQueryDirection::Both, - } -} - fn map_core_epiphany_graph_query_view( view: EpiphanyGraphQueryView, ) -> ( diff --git a/notes/fresh-workspace-handoff.md b/notes/fresh-workspace-handoff.md index 133e904a..f9c9d608 100644 --- a/notes/fresh-workspace-handoff.md +++ b/notes/fresh-workspace-handoff.md @@ -77,6 +77,7 @@ remembers doctrine; the branch remembers the blade. - Coordinator judgment is no longer bridge-owned. `epiphany-core` now exposes `EpiphanyCoordinatorStatusInput` -> `EpiphanyCoordinatorStatus`; the bridge gathers runtime snapshots and accepted-finding facts, then core derives source signals and the coordinator decision. Reorient worker launch composition is also core-owned through `EpiphanyReorientLaunchRequestInput` -> `EpiphanyJobLaunchRequest`; bridge supplies the prompt instruction plus retained compatibility binding/owner constants and performs the host launch side effect. - Coordinator finding signals are also core-owned. `derive_coordinator_finding_signals` derives modeling/verification/reorient accepted, reviewable, coverage, verdict, and evidence sequencing facts from typed findings plus `EpiphanyThreadState`; the bridge now loads snapshots/state and projects legacy JSON-RPC responses instead of keeping a duplicate acceptance tribunal. - View lens selector semantics are core-owned now. `EpiphanyViewLens`, default view lenses, and lens dependency planning live in `epiphany-core`; app-server converts JSON-RPC lens params to core selectors and asks core which jobs/pressure/runtime/reorientation facts must be loaded. +- Context and graph-query request conversion now belongs to the app-server JSON-RPC wall. `epiphany-codex-bridge::context` receives core `EpiphanyContextParams` / `EpiphanyGraphQuery` and only projects core context/query views back into legacy response DTOs. - MCP remains JSON because MCP is a JSON protocol. The latest processor cut only moved MCP refresh/OAuth/status/resource/tool-call route handling into `codex_message_processor/mcp_routes.rs`, reducing the root processor to about 8,977 lines; it did not claim MCP payloads are CultNet or make MCP an Epiphany-owned runtime contract. - Codex account auth route handling remains in vendored Codex but now lives in `codex_message_processor/auth_routes.rs`: API-key login, ChatGPT browser/device-code/external-token login, logout, auth status, account, rate limits, and add-credits nudge handling. This preserves Codex ownership of subscription auth while cutting the root processor to about 8,094 lines. - One-off command execution and command stream write/resize/terminate route handling now live in `codex_message_processor/command_routes.rs`; `CommandExecManager` remains the lifecycle owner, while the root processor is about 7,800 lines. diff --git a/state/ledgers.msgpack b/state/ledgers.msgpack index 6e79a0de04839017119e1ac12dcc81bcb9a87230..bcd58bae7d39f89a1fcc844930ac2ca526d61a81 100644 GIT binary patch delta 219 zcmeCa#4-5_#{^|2&6^ul3mF;bHcw}4pU%j*eL5pky!vz=AtpW+3oBFe$qSxIE8V;q zlv-GtT3n(~o|u!PkX%|~rI1)qpj(_;RF+z#ke6RR-A|H9Lc%#euOzjiBp|UUF}GMD zF)u|SB%>%bF=e`;IFm3-W?o7DbU|?@>FGP=n1my(6_ScFQ_@ovk|DZ)#wg_E=cNM; z%rDO?Rw#m4sau?xlB(bp?C+-=6yU4?bVgC7LN3tu%)E5HEk*`LX1WHZx<&>e1|a8J I8JI@_0A}w=L;wH) delta 52 zcmbPyg`@it#{^|2jf)#q3mF;bG*4%2pU%j*eL5pkyt?QXBLgEdT?12HBZCkF3oBD& ID^sH=0M(xlhX4Qo diff --git a/state/map.yaml b/state/map.yaml index 634db3d8..155d4c1f 100644 --- a/state/map.yaml +++ b/state/map.yaml @@ -381,7 +381,10 @@ current_status: sequencing facts are no longer bridge helper law. View lens selector semantics also moved into core: `EpiphanyViewLens`, default lens selection, and lens dependency planning now decide which host facts app-server/bridge - need to load before legacy response projection. Reorient worker launch-request/document + need to load before legacy response projection. Context and graph-query + request DTO conversion moved to the app-server JSON-RPC wall, so the bridge + receives core `EpiphanyContextParams` / `EpiphanyGraphQuery` documents + instead of owning request-side protocol mapping. Reorient worker launch-request/document composition also moved behind a typed core seam (`EpiphanyReorientLaunchRequestInput` -> `EpiphanyJobLaunchRequest`); bridge supplies only the prompt instruction and retained compatibility 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 955411f1..b3e2e7f6 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 @@ -2,8 +2,6 @@ use codex_app_server_protocol::*; use codex_core::CodexThread; use codex_protocol::ThreadId; use codex_protocol::protocol::EpiphanyRetrievalState; -use epiphany_codex_bridge::context::map_core_epiphany_context_params; -use epiphany_codex_bridge::context::map_core_epiphany_graph_query; use epiphany_codex_bridge::cultnet::EpiphanyFreshnessSurface; use epiphany_codex_bridge::cultnet::EpiphanyGraphFreshnessStatus; use epiphany_codex_bridge::cultnet::EpiphanyInvalidationStatus; @@ -31,6 +29,10 @@ use epiphany_codex_bridge::view::map_epiphany_propose_response; use epiphany_codex_bridge::view::map_epiphany_reorient_result_response; use epiphany_codex_bridge::view::map_epiphany_role_result_response; use epiphany_codex_bridge::view::map_epiphany_view_response; +use epiphany_core::EpiphanyContextParams; +use epiphany_core::EpiphanyGraphQuery; +use epiphany_core::EpiphanyGraphQueryDirection; +use epiphany_core::EpiphanyGraphQueryKind; use epiphany_core::default_epiphany_view_lenses; use epiphany_core::epiphany_view_needs_jobs; use epiphany_core::epiphany_view_needs_pressure; @@ -313,7 +315,7 @@ impl CodexMessageProcessor { } }; - let core_params = map_core_epiphany_context_params(¶ms); + let core_params = thread_epiphany_context_params_to_core(¶ms); let response = map_epiphany_context_response( thread_id, loaded, @@ -351,7 +353,7 @@ impl CodexMessageProcessor { } }; - let core_query = map_core_epiphany_graph_query(¶ms.query); + let core_query = thread_epiphany_graph_query_to_core(¶ms.query); let response = map_epiphany_graph_query_response( thread_id, loaded, @@ -584,6 +586,58 @@ impl CodexMessageProcessor { } } +fn thread_epiphany_context_params_to_core( + params: &ThreadEpiphanyContextParams, +) -> EpiphanyContextParams { + EpiphanyContextParams { + graph_node_ids: params.graph_node_ids.clone(), + graph_edge_ids: params.graph_edge_ids.clone(), + observation_ids: params.observation_ids.clone(), + evidence_ids: params.evidence_ids.clone(), + include_active_frontier: params.include_active_frontier, + include_linked_evidence: params.include_linked_evidence, + } +} + +fn thread_epiphany_graph_query_to_core(query: &ThreadEpiphanyGraphQuery) -> EpiphanyGraphQuery { + EpiphanyGraphQuery { + kind: thread_epiphany_graph_query_kind_to_core(query.kind), + node_ids: query.node_ids.clone(), + edge_ids: query.edge_ids.clone(), + paths: query.paths.clone(), + symbols: query.symbols.clone(), + edge_kinds: query.edge_kinds.clone(), + direction: query + .direction + .map(thread_epiphany_graph_query_direction_to_core), + depth: query.depth, + include_links: query.include_links, + } +} + +fn thread_epiphany_graph_query_kind_to_core( + kind: ThreadEpiphanyGraphQueryKind, +) -> EpiphanyGraphQueryKind { + match kind { + ThreadEpiphanyGraphQueryKind::Node => EpiphanyGraphQueryKind::Node, + ThreadEpiphanyGraphQueryKind::Path => EpiphanyGraphQueryKind::Path, + ThreadEpiphanyGraphQueryKind::FrontierNeighborhood => { + EpiphanyGraphQueryKind::FrontierNeighborhood + } + ThreadEpiphanyGraphQueryKind::Neighbors => EpiphanyGraphQueryKind::Neighbors, + } +} + +fn thread_epiphany_graph_query_direction_to_core( + direction: ThreadEpiphanyGraphQueryDirection, +) -> EpiphanyGraphQueryDirection { + match direction { + ThreadEpiphanyGraphQueryDirection::Incoming => EpiphanyGraphQueryDirection::Incoming, + ThreadEpiphanyGraphQueryDirection::Outgoing => EpiphanyGraphQueryDirection::Outgoing, + ThreadEpiphanyGraphQueryDirection::Both => EpiphanyGraphQueryDirection::Both, + } +} + fn thread_epiphany_freshness_response_from_surface( surface: EpiphanyFreshnessSurface, ) -> ThreadEpiphanyFreshnessResponse {