diff --git a/epiphany-codex-bridge/src/coordinator.rs b/epiphany-codex-bridge/src/coordinator.rs index b0344ac2..42dbd0b5 100644 --- a/epiphany-codex-bridge/src/coordinator.rs +++ b/epiphany-codex-bridge/src/coordinator.rs @@ -4,11 +4,9 @@ use codex_app_server_protocol::ThreadEpiphanyCrrcAction; use codex_app_server_protocol::ThreadEpiphanyCrrcRecommendation; use codex_app_server_protocol::ThreadEpiphanyJob; use codex_app_server_protocol::ThreadEpiphanyReorientAction; -use codex_app_server_protocol::ThreadEpiphanyReorientResultStatus; use codex_app_server_protocol::ThreadEpiphanyReorientStateStatus; use codex_app_server_protocol::ThreadEpiphanyRoleId; use codex_app_server_protocol::ThreadEpiphanyRoleLane; -use codex_app_server_protocol::ThreadEpiphanyRoleResultStatus; use codex_app_server_protocol::ThreadEpiphanyRoleStatus; use codex_app_server_protocol::ThreadEpiphanyRolesSource; use codex_app_server_protocol::ThreadEpiphanySceneAction; @@ -66,6 +64,8 @@ use crate::launch::build_epiphany_reorient_launch_request; use crate::launch::render_epiphany_coordinator_note; use crate::pressure::derive_epiphany_pressure; use crate::protocol_edge::protocol_job_from_surface; +use crate::protocol_edge::protocol_reorient_result_status; +use crate::protocol_edge::protocol_role_result_status; use crate::reorient::EpiphanyFreshnessWatcherSnapshot; use crate::reorient::derive_epiphany_freshness_view; use crate::reorient::derive_epiphany_reorient; @@ -123,13 +123,9 @@ fn map_protocol_coordinator_source_signals( should_prepare_compaction: signals.should_prepare_compaction, reorient_action: map_protocol_reorient_action(signals.reorient_action), crrc_action: map_protocol_crrc_action(signals.crrc_action), - modeling_result_status: map_protocol_coordinator_role_result_status( - signals.modeling_result_status, - ), - verification_result_status: map_protocol_coordinator_role_result_status( - signals.verification_result_status, - ), - reorient_result_status: map_protocol_crrc_result_status(signals.reorient_result_status), + modeling_result_status: protocol_role_result_status(signals.modeling_result_status), + verification_result_status: protocol_role_result_status(signals.verification_result_status), + reorient_result_status: protocol_reorient_result_status(signals.reorient_result_status), } } @@ -164,30 +160,6 @@ fn map_protocol_reorient_action( } } -fn map_protocol_crrc_result_status( - status: CoreEpiphanyCrrcResultStatus, -) -> ThreadEpiphanyReorientResultStatus { - match status { - CoreEpiphanyCrrcResultStatus::MissingState => { - ThreadEpiphanyReorientResultStatus::MissingState - } - CoreEpiphanyCrrcResultStatus::MissingBinding => { - ThreadEpiphanyReorientResultStatus::MissingBinding - } - CoreEpiphanyCrrcResultStatus::BackendUnavailable => { - ThreadEpiphanyReorientResultStatus::BackendUnavailable - } - CoreEpiphanyCrrcResultStatus::BackendMissing => { - ThreadEpiphanyReorientResultStatus::BackendMissing - } - CoreEpiphanyCrrcResultStatus::Pending => ThreadEpiphanyReorientResultStatus::Pending, - CoreEpiphanyCrrcResultStatus::Running => ThreadEpiphanyReorientResultStatus::Running, - CoreEpiphanyCrrcResultStatus::Completed => ThreadEpiphanyReorientResultStatus::Completed, - CoreEpiphanyCrrcResultStatus::Failed => ThreadEpiphanyReorientResultStatus::Failed, - CoreEpiphanyCrrcResultStatus::Cancelled => ThreadEpiphanyReorientResultStatus::Cancelled, - } -} - pub fn map_protocol_crrc_action(action: CoreEpiphanyCrrcAction) -> ThreadEpiphanyCrrcAction { match action { CoreEpiphanyCrrcAction::Continue => ThreadEpiphanyCrrcAction::Continue, @@ -494,34 +466,6 @@ fn map_protocol_coordinator_role_id( } } -fn map_protocol_coordinator_role_result_status( - status: CoreEpiphanyCoordinatorRoleResultStatus, -) -> ThreadEpiphanyRoleResultStatus { - match status { - CoreEpiphanyCoordinatorRoleResultStatus::MissingState => { - ThreadEpiphanyRoleResultStatus::MissingState - } - CoreEpiphanyCoordinatorRoleResultStatus::MissingBinding => { - ThreadEpiphanyRoleResultStatus::MissingBinding - } - CoreEpiphanyCoordinatorRoleResultStatus::BackendUnavailable => { - ThreadEpiphanyRoleResultStatus::BackendUnavailable - } - CoreEpiphanyCoordinatorRoleResultStatus::BackendMissing => { - ThreadEpiphanyRoleResultStatus::BackendMissing - } - CoreEpiphanyCoordinatorRoleResultStatus::Pending => ThreadEpiphanyRoleResultStatus::Pending, - CoreEpiphanyCoordinatorRoleResultStatus::Running => ThreadEpiphanyRoleResultStatus::Running, - CoreEpiphanyCoordinatorRoleResultStatus::Completed => { - ThreadEpiphanyRoleResultStatus::Completed - } - CoreEpiphanyCoordinatorRoleResultStatus::Failed => ThreadEpiphanyRoleResultStatus::Failed, - CoreEpiphanyCoordinatorRoleResultStatus::Cancelled => { - ThreadEpiphanyRoleResultStatus::Cancelled - } - } -} - fn map_protocol_coordinator_scene_action( action: CoreEpiphanyCoordinatorSceneAction, ) -> ThreadEpiphanySceneAction { diff --git a/epiphany-codex-bridge/src/protocol_edge.rs b/epiphany-codex-bridge/src/protocol_edge.rs index ca40f64d..8bc8ef45 100644 --- a/epiphany-codex-bridge/src/protocol_edge.rs +++ b/epiphany-codex-bridge/src/protocol_edge.rs @@ -32,16 +32,20 @@ use codex_app_server_protocol::ThreadEpiphanyReorientAction; use codex_app_server_protocol::ThreadEpiphanyReorientCheckpointStatus; use codex_app_server_protocol::ThreadEpiphanyReorientDecision; use codex_app_server_protocol::ThreadEpiphanyReorientReason; +use codex_app_server_protocol::ThreadEpiphanyReorientResultStatus; use codex_app_server_protocol::ThreadEpiphanyReorientSource; use codex_app_server_protocol::ThreadEpiphanyReorientStateStatus; use codex_app_server_protocol::ThreadEpiphanyReorientWorkerLaunchDocument; use codex_app_server_protocol::ThreadEpiphanyRetrievalFreshness; use codex_app_server_protocol::ThreadEpiphanyRetrievalFreshnessStatus; +use codex_app_server_protocol::ThreadEpiphanyRoleResultStatus; use codex_app_server_protocol::ThreadEpiphanyRoleWorkerLaunchDocument; use codex_app_server_protocol::ThreadEpiphanyUpdatePatch; use codex_app_server_protocol::ThreadEpiphanyViewLens; use codex_app_server_protocol::ThreadEpiphanyWorkerLaunchDocument; use epiphany_core::EpiphanyContextParams; +use epiphany_core::EpiphanyCoordinatorRoleResultStatus; +use epiphany_core::EpiphanyCrrcResultStatus; use epiphany_core::EpiphanyDistillInput; use epiphany_core::EpiphanyGraphQuery; use epiphany_core::EpiphanyGraphQueryDirection; @@ -338,6 +342,52 @@ pub fn protocol_reorient_decision( } } +pub fn protocol_role_result_status( + status: EpiphanyCoordinatorRoleResultStatus, +) -> ThreadEpiphanyRoleResultStatus { + match status { + EpiphanyCoordinatorRoleResultStatus::MissingState => { + ThreadEpiphanyRoleResultStatus::MissingState + } + EpiphanyCoordinatorRoleResultStatus::MissingBinding => { + ThreadEpiphanyRoleResultStatus::MissingBinding + } + EpiphanyCoordinatorRoleResultStatus::BackendUnavailable => { + ThreadEpiphanyRoleResultStatus::BackendUnavailable + } + EpiphanyCoordinatorRoleResultStatus::BackendMissing => { + ThreadEpiphanyRoleResultStatus::BackendMissing + } + EpiphanyCoordinatorRoleResultStatus::Pending => ThreadEpiphanyRoleResultStatus::Pending, + EpiphanyCoordinatorRoleResultStatus::Running => ThreadEpiphanyRoleResultStatus::Running, + EpiphanyCoordinatorRoleResultStatus::Completed => ThreadEpiphanyRoleResultStatus::Completed, + EpiphanyCoordinatorRoleResultStatus::Failed => ThreadEpiphanyRoleResultStatus::Failed, + EpiphanyCoordinatorRoleResultStatus::Cancelled => ThreadEpiphanyRoleResultStatus::Cancelled, + } +} + +pub fn protocol_reorient_result_status( + status: EpiphanyCrrcResultStatus, +) -> ThreadEpiphanyReorientResultStatus { + match status { + EpiphanyCrrcResultStatus::MissingState => ThreadEpiphanyReorientResultStatus::MissingState, + EpiphanyCrrcResultStatus::MissingBinding => { + ThreadEpiphanyReorientResultStatus::MissingBinding + } + EpiphanyCrrcResultStatus::BackendUnavailable => { + ThreadEpiphanyReorientResultStatus::BackendUnavailable + } + EpiphanyCrrcResultStatus::BackendMissing => { + ThreadEpiphanyReorientResultStatus::BackendMissing + } + EpiphanyCrrcResultStatus::Pending => ThreadEpiphanyReorientResultStatus::Pending, + EpiphanyCrrcResultStatus::Running => ThreadEpiphanyReorientResultStatus::Running, + EpiphanyCrrcResultStatus::Completed => ThreadEpiphanyReorientResultStatus::Completed, + EpiphanyCrrcResultStatus::Failed => ThreadEpiphanyReorientResultStatus::Failed, + EpiphanyCrrcResultStatus::Cancelled => ThreadEpiphanyReorientResultStatus::Cancelled, + } +} + fn protocol_view_lens_to_core(lens: ThreadEpiphanyViewLens) -> EpiphanyViewLens { match lens { ThreadEpiphanyViewLens::Scene => EpiphanyViewLens::Scene, diff --git a/epiphany-codex-bridge/src/runtime_results.rs b/epiphany-codex-bridge/src/runtime_results.rs index 32e54a72..a587fd47 100644 --- a/epiphany-codex-bridge/src/runtime_results.rs +++ b/epiphany-codex-bridge/src/runtime_results.rs @@ -1,7 +1,5 @@ use std::path::Path; -use codex_app_server_protocol::ThreadEpiphanyReorientResultStatus; -use codex_app_server_protocol::ThreadEpiphanyRoleResultStatus; use epiphany_core::EpiphanyCoordinatorRoleResultStatus as CoreEpiphanyCoordinatorRoleResultStatus; use epiphany_core::EpiphanyCrrcResultStatus as CoreEpiphanyCrrcResultStatus; use epiphany_core::EpiphanyReorientFindingInterpretation; @@ -219,58 +217,6 @@ fn map_runtime_reorient_result_status( } } -pub fn map_protocol_role_result_status( - status: CoreEpiphanyCoordinatorRoleResultStatus, -) -> ThreadEpiphanyRoleResultStatus { - match status { - CoreEpiphanyCoordinatorRoleResultStatus::MissingState => { - ThreadEpiphanyRoleResultStatus::MissingState - } - CoreEpiphanyCoordinatorRoleResultStatus::MissingBinding => { - ThreadEpiphanyRoleResultStatus::MissingBinding - } - CoreEpiphanyCoordinatorRoleResultStatus::BackendUnavailable => { - ThreadEpiphanyRoleResultStatus::BackendUnavailable - } - CoreEpiphanyCoordinatorRoleResultStatus::BackendMissing => { - ThreadEpiphanyRoleResultStatus::BackendMissing - } - CoreEpiphanyCoordinatorRoleResultStatus::Pending => ThreadEpiphanyRoleResultStatus::Pending, - CoreEpiphanyCoordinatorRoleResultStatus::Running => ThreadEpiphanyRoleResultStatus::Running, - CoreEpiphanyCoordinatorRoleResultStatus::Completed => { - ThreadEpiphanyRoleResultStatus::Completed - } - CoreEpiphanyCoordinatorRoleResultStatus::Failed => ThreadEpiphanyRoleResultStatus::Failed, - CoreEpiphanyCoordinatorRoleResultStatus::Cancelled => { - ThreadEpiphanyRoleResultStatus::Cancelled - } - } -} - -pub fn map_protocol_reorient_result_status( - status: CoreEpiphanyCrrcResultStatus, -) -> ThreadEpiphanyReorientResultStatus { - match status { - CoreEpiphanyCrrcResultStatus::MissingState => { - ThreadEpiphanyReorientResultStatus::MissingState - } - CoreEpiphanyCrrcResultStatus::MissingBinding => { - ThreadEpiphanyReorientResultStatus::MissingBinding - } - CoreEpiphanyCrrcResultStatus::BackendUnavailable => { - ThreadEpiphanyReorientResultStatus::BackendUnavailable - } - CoreEpiphanyCrrcResultStatus::BackendMissing => { - ThreadEpiphanyReorientResultStatus::BackendMissing - } - CoreEpiphanyCrrcResultStatus::Pending => ThreadEpiphanyReorientResultStatus::Pending, - CoreEpiphanyCrrcResultStatus::Running => ThreadEpiphanyReorientResultStatus::Running, - CoreEpiphanyCrrcResultStatus::Completed => ThreadEpiphanyReorientResultStatus::Completed, - CoreEpiphanyCrrcResultStatus::Failed => ThreadEpiphanyReorientResultStatus::Failed, - CoreEpiphanyCrrcResultStatus::Cancelled => ThreadEpiphanyReorientResultStatus::Cancelled, - } -} - pub async fn load_core_epiphany_role_result_snapshot( state: &EpiphanyThreadState, runtime_store_path: Option<&Path>, diff --git a/epiphany-codex-bridge/src/view.rs b/epiphany-codex-bridge/src/view.rs index b8cde76f..02c0a6bc 100644 --- a/epiphany-codex-bridge/src/view.rs +++ b/epiphany-codex-bridge/src/view.rs @@ -36,6 +36,8 @@ use crate::launch::EPIPHANY_REORIENT_LAUNCH_BINDING_ID; use crate::pressure::derive_epiphany_pressure; use crate::pressure::map_epiphany_pressure; use crate::protocol_edge::protocol_job_from_surface; +use crate::protocol_edge::protocol_reorient_result_status; +use crate::protocol_edge::protocol_role_result_status; use crate::reorient::EpiphanyFreshnessWatcherSnapshot; use crate::reorient::derive_epiphany_freshness_view; use crate::reorient::derive_epiphany_reorient; @@ -45,8 +47,6 @@ use crate::results::map_protocol_reorient_finding; use crate::results::map_protocol_role_result_role_id; use crate::runtime_results::load_core_epiphany_reorient_result_snapshot; use crate::runtime_results::load_core_epiphany_role_result_snapshot; -use crate::runtime_results::map_protocol_reorient_result_status; -use crate::runtime_results::map_protocol_role_result_status; use crate::scene::map_core_epiphany_scene_action; use crate::scene::map_epiphany_scene; @@ -220,7 +220,7 @@ pub async fn map_epiphany_view_response( note: "Reorient result was not requested.".to_string(), } }; - let reorient_result_status = map_protocol_reorient_result_status(reorient_result.status); + let reorient_result_status = protocol_reorient_result_status(reorient_result.status); let reorient_finding = reorient_result .finding .clone() @@ -482,7 +482,7 @@ pub async fn map_epiphany_role_result_response( state_status: ThreadEpiphanyReorientStateStatus::Ready, state_revision: Some(state.revision), binding_id, - status: map_protocol_role_result_status(result.status), + status: protocol_role_result_status(result.status), job, finding: result .finding @@ -538,7 +538,7 @@ pub async fn map_epiphany_reorient_result_response( state_status: ThreadEpiphanyReorientStateStatus::Ready, state_revision: Some(state.revision), binding_id, - status: map_protocol_reorient_result_status(result.status), + status: protocol_reorient_result_status(result.status), job, finding: result.finding.map(map_protocol_reorient_finding), note: result.note, diff --git a/notes/fresh-workspace-handoff.md b/notes/fresh-workspace-handoff.md index 8f54525d..bdd795db 100644 --- a/notes/fresh-workspace-handoff.md +++ b/notes/fresh-workspace-handoff.md @@ -81,6 +81,7 @@ remembers doctrine; the branch remembers the blade. - Context, graph-query, distill, generic job-launch document, and generic update/promote patch request cargo now enters bridge as core `EpiphanyContextParams`, `EpiphanyGraphQuery`, `EpiphanyDistillInput`, `EpiphanyWorkerLaunchDocument`, and `EpiphanyRoleStatePatchDocument`. - Freshness/job/reorient response projection also belongs to the bridge edge now. Vendored app-server no longer keeps local helpers for `EpiphanyFreshnessSurface`, `EpiphanyJobView`, `EpiphanySurfaceSource`, or reorient decision/status enum projection; it gathers host facts, invokes bridge/core services, and sends the Codex JSON-RPC response. - Job projection has one mapper now. `epiphany-codex-bridge::jobs` derives typed `EpiphanyJobView` and no longer imports app-server protocol DTOs; `protocol_edge::protocol_job_from_surface` is the only `EpiphanyJobView` -> `ThreadEpiphanyJob` conversion path. +- Runtime result loading is typed-only now. Role/reorient result status projection moved out of `runtime_results` and duplicate coordinator helpers into `protocol_edge`, so view and coordinator response builders share one Codex JSON-RPC status mapper. - 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 92143291..b373dec7 100644 Binary files a/state/ledgers.msgpack and b/state/ledgers.msgpack differ diff --git a/state/map.yaml b/state/map.yaml index eee2c572..af07fec4 100644 --- a/state/map.yaml +++ b/state/map.yaml @@ -402,6 +402,10 @@ current_status: has been collapsed too: `jobs.rs` derives typed `EpiphanyJobView` only, and `protocol_edge::protocol_job_from_surface` is the single `EpiphanyJobView` -> `ThreadEpiphanyJob` mapper. + Runtime result loading is now typed-only at its module boundary: + role/reorient result status projection moved from `runtime_results` and + duplicate coordinator helpers into `protocol_edge`, so coordinator/view + response builders share the same Codex JSON-RPC status mapper. The bridge still depends on vendored Codex for app-server protocol DTOs and absolute path validation, so the purification is not done. next_action: Continue Codex starvation and CultNet liberation by cutting bridge-internal response/projection authority. Prioritize the next coordinator/view seam that still composes policy-shaped facts instead of merely loading host facts and projecting core surfaces; keep MCP/OpenAI JSON only at their true protocol/text edges. Do not add compatibility adapters unless they protect a named ownership invariant.