diff --git a/epiphany-codex-bridge/src/view.rs b/epiphany-codex-bridge/src/view.rs index cb589f9d..578ab067 100644 --- a/epiphany-codex-bridge/src/view.rs +++ b/epiphany-codex-bridge/src/view.rs @@ -46,42 +46,86 @@ use crate::runtime_results::map_protocol_role_result_status; use crate::scene::map_core_epiphany_scene_action; use crate::scene::map_epiphany_scene; -pub fn default_epiphany_view_lenses() -> Vec { +#[derive(Clone, Copy, Debug, PartialEq, Eq)] +pub enum EpiphanyViewLens { + Scene, + Jobs, + Roles, + Planning, + Pressure, + Reorient, + Crrc, + Coordinator, +} + +pub fn default_epiphany_view_lenses() -> Vec { vec![ - ThreadEpiphanyViewLens::Scene, - ThreadEpiphanyViewLens::Jobs, - ThreadEpiphanyViewLens::Roles, - ThreadEpiphanyViewLens::Planning, - ThreadEpiphanyViewLens::Pressure, - ThreadEpiphanyViewLens::Reorient, - ThreadEpiphanyViewLens::Crrc, - ThreadEpiphanyViewLens::Coordinator, + EpiphanyViewLens::Scene, + EpiphanyViewLens::Jobs, + EpiphanyViewLens::Roles, + EpiphanyViewLens::Planning, + EpiphanyViewLens::Pressure, + EpiphanyViewLens::Reorient, + EpiphanyViewLens::Crrc, + EpiphanyViewLens::Coordinator, ] } -pub fn epiphany_view_needs_jobs(lenses: &[ThreadEpiphanyViewLens]) -> bool { - lenses.contains(&ThreadEpiphanyViewLens::Jobs) - || lenses.contains(&ThreadEpiphanyViewLens::Roles) - || lenses.contains(&ThreadEpiphanyViewLens::Crrc) - || lenses.contains(&ThreadEpiphanyViewLens::Coordinator) +pub fn map_core_epiphany_view_lenses(lenses: Vec) -> Vec { + lenses + .into_iter() + .map(map_core_epiphany_view_lens) + .collect() } -pub fn epiphany_view_needs_reorientation_inputs(lenses: &[ThreadEpiphanyViewLens]) -> bool { - lenses.contains(&ThreadEpiphanyViewLens::Roles) - || lenses.contains(&ThreadEpiphanyViewLens::Reorient) - || lenses.contains(&ThreadEpiphanyViewLens::Crrc) - || lenses.contains(&ThreadEpiphanyViewLens::Coordinator) +fn map_core_epiphany_view_lens(lens: ThreadEpiphanyViewLens) -> EpiphanyViewLens { + match lens { + ThreadEpiphanyViewLens::Scene => EpiphanyViewLens::Scene, + ThreadEpiphanyViewLens::Jobs => EpiphanyViewLens::Jobs, + ThreadEpiphanyViewLens::Roles => EpiphanyViewLens::Roles, + ThreadEpiphanyViewLens::Planning => EpiphanyViewLens::Planning, + ThreadEpiphanyViewLens::Pressure => EpiphanyViewLens::Pressure, + ThreadEpiphanyViewLens::Reorient => EpiphanyViewLens::Reorient, + ThreadEpiphanyViewLens::Crrc => EpiphanyViewLens::Crrc, + ThreadEpiphanyViewLens::Coordinator => EpiphanyViewLens::Coordinator, + } } -pub fn epiphany_view_needs_pressure(lenses: &[ThreadEpiphanyViewLens]) -> bool { - lenses.contains(&ThreadEpiphanyViewLens::Pressure) - || epiphany_view_needs_reorientation_inputs(lenses) +fn map_protocol_epiphany_view_lens(lens: EpiphanyViewLens) -> ThreadEpiphanyViewLens { + match lens { + EpiphanyViewLens::Scene => ThreadEpiphanyViewLens::Scene, + EpiphanyViewLens::Jobs => ThreadEpiphanyViewLens::Jobs, + EpiphanyViewLens::Roles => ThreadEpiphanyViewLens::Roles, + EpiphanyViewLens::Planning => ThreadEpiphanyViewLens::Planning, + EpiphanyViewLens::Pressure => ThreadEpiphanyViewLens::Pressure, + EpiphanyViewLens::Reorient => ThreadEpiphanyViewLens::Reorient, + EpiphanyViewLens::Crrc => ThreadEpiphanyViewLens::Crrc, + EpiphanyViewLens::Coordinator => ThreadEpiphanyViewLens::Coordinator, + } } -pub fn epiphany_view_needs_runtime_store(lenses: &[ThreadEpiphanyViewLens]) -> bool { - lenses.contains(&ThreadEpiphanyViewLens::Roles) - || lenses.contains(&ThreadEpiphanyViewLens::Crrc) - || lenses.contains(&ThreadEpiphanyViewLens::Coordinator) +pub fn epiphany_view_needs_jobs(lenses: &[EpiphanyViewLens]) -> bool { + lenses.contains(&EpiphanyViewLens::Jobs) + || lenses.contains(&EpiphanyViewLens::Roles) + || lenses.contains(&EpiphanyViewLens::Crrc) + || lenses.contains(&EpiphanyViewLens::Coordinator) +} + +pub fn epiphany_view_needs_reorientation_inputs(lenses: &[EpiphanyViewLens]) -> bool { + lenses.contains(&EpiphanyViewLens::Roles) + || lenses.contains(&EpiphanyViewLens::Reorient) + || lenses.contains(&EpiphanyViewLens::Crrc) + || lenses.contains(&EpiphanyViewLens::Coordinator) +} + +pub fn epiphany_view_needs_pressure(lenses: &[EpiphanyViewLens]) -> bool { + lenses.contains(&EpiphanyViewLens::Pressure) || epiphany_view_needs_reorientation_inputs(lenses) +} + +pub fn epiphany_view_needs_runtime_store(lenses: &[EpiphanyViewLens]) -> bool { + lenses.contains(&EpiphanyViewLens::Roles) + || lenses.contains(&EpiphanyViewLens::Crrc) + || lenses.contains(&EpiphanyViewLens::Coordinator) } pub struct EpiphanyFreshnessResponseInput<'a> { @@ -162,7 +206,7 @@ pub fn map_epiphany_graph_query_response( pub struct EpiphanyViewResponseInput<'a> { pub thread_id: String, - pub lenses: Vec, + pub lenses: Vec, pub loaded: bool, pub state: Option<&'a EpiphanyThreadState>, pub retrieval_override: Option<&'a EpiphanyRetrievalState>, @@ -225,8 +269,8 @@ pub async fn map_epiphany_view_response( .find(|job| job.id == EPIPHANY_REORIENT_LAUNCH_BINDING_ID) .cloned(); let reorient_result = if runtime_store_path.is_some() - || lenses.contains(&ThreadEpiphanyViewLens::Crrc) - || lenses.contains(&ThreadEpiphanyViewLens::Coordinator) + || lenses.contains(&EpiphanyViewLens::Crrc) + || lenses.contains(&EpiphanyViewLens::Coordinator) { load_core_epiphany_reorient_result_snapshot( state, @@ -286,7 +330,7 @@ pub async fn map_epiphany_view_response( } else { None }; - let coordinator_response = if lenses.contains(&ThreadEpiphanyViewLens::Coordinator) { + let coordinator_response = if lenses.contains(&EpiphanyViewLens::Coordinator) { if let (Some(core_pressure), Some(recommendation), Some(roles)) = ( core_pressure.as_ref(), recommendation.as_ref(), @@ -324,9 +368,9 @@ pub async fn map_epiphany_view_response( ThreadEpiphanyViewResponse { thread_id: thread_id.clone(), scene: lenses - .contains(&ThreadEpiphanyViewLens::Scene) + .contains(&EpiphanyViewLens::Scene) .then(|| map_epiphany_scene(state, loaded, EPIPHANY_REORIENT_LAUNCH_BINDING_ID)), - jobs: if lenses.contains(&ThreadEpiphanyViewLens::Jobs) { + jobs: if lenses.contains(&EpiphanyViewLens::Jobs) { jobs.iter() .cloned() .map(map_core_epiphany_job_view) @@ -334,7 +378,7 @@ pub async fn map_epiphany_view_response( } else { Vec::new() }, - roles: lenses.contains(&ThreadEpiphanyViewLens::Roles).then(|| { + roles: lenses.contains(&EpiphanyViewLens::Roles).then(|| { let role_board = roles.clone(); let protocol_roles = role_board .as_ref() @@ -363,7 +407,7 @@ pub async fn map_epiphany_view_response( roles: protocol_roles, } }), - planning: lenses.contains(&ThreadEpiphanyViewLens::Planning).then(|| { + planning: lenses.contains(&EpiphanyViewLens::Planning).then(|| { let (state_status, state_revision, planning, summary) = map_epiphany_planning(state); ThreadEpiphanyViewPlanning { thread_id: thread_id.clone(), @@ -379,11 +423,11 @@ pub async fn map_epiphany_view_response( } }), pressure: lenses - .contains(&ThreadEpiphanyViewLens::Pressure) + .contains(&EpiphanyViewLens::Pressure) .then(|| pressure.clone()) .flatten(), reorient: lenses - .contains(&ThreadEpiphanyViewLens::Reorient) + .contains(&EpiphanyViewLens::Reorient) .then(|| { reorient_decision .clone() @@ -401,7 +445,7 @@ pub async fn map_epiphany_view_response( }) .flatten(), crrc: lenses - .contains(&ThreadEpiphanyViewLens::Crrc) + .contains(&EpiphanyViewLens::Crrc) .then(|| { let pressure = pressure.clone()?; let decision = reorient_decision.clone()?; @@ -443,7 +487,10 @@ pub async fn map_epiphany_view_response( }) .flatten(), coordinator: coordinator_response, - lenses, + lenses: lenses + .into_iter() + .map(map_protocol_epiphany_view_lens) + .collect(), } } diff --git a/notes/fresh-workspace-handoff.md b/notes/fresh-workspace-handoff.md index 2992a4b7..7f90d0be 100644 --- a/notes/fresh-workspace-handoff.md +++ b/notes/fresh-workspace-handoff.md @@ -71,6 +71,7 @@ remembers doctrine; the branch remembers the blade. - Distill response assembly now consumes core `EpiphanyDistillInput`; `ThreadEpiphanyDistillParams` is converted before bridge policy invocation. - Role/reorient result response inputs now use core `EpiphanySurfaceSource`; `ThreadEpiphanyRolesSource` / `ThreadEpiphanyReorientSource` are response projection only. - Changed-field derivation now inspects typed `EpiphanyRoleStatePatchDocument` directly. The bridge no longer converts typed patches back into `ThreadEpiphanyUpdatePatch` merely to calculate changed fields. +- View-lens orchestration now uses bridge-native `EpiphanyViewLens` selectors. App-server converts `ThreadEpiphanyViewLens` at the request wall, and the bridge maps back only for the legacy response echo. - 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 19748e15..7ab30195 100644 Binary files a/state/ledgers.msgpack and b/state/ledgers.msgpack differ diff --git a/state/map.yaml b/state/map.yaml index f2b2cfe7..cfea8604 100644 --- a/state/map.yaml +++ b/state/map.yaml @@ -364,6 +364,9 @@ current_status: created only during response projection. Changed-field derivation now inspects typed `EpiphanyRoleStatePatchDocument` directly instead of converting patches back through `ThreadEpiphanyUpdatePatch` projection. + View-lens orchestration now uses bridge-native `EpiphanyViewLens` selectors; + app-server converts `ThreadEpiphanyViewLens` at the request wall and the + bridge maps back only for the legacy response `lenses` echo. 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 `ThreadEpiphany*` authority. Prioritize role-result/reorient-result DTO coupling next: derive typed CultNet surfaces first, push JSON-RPC projection into app-server, and keep MCP/OpenAI JSON only at their true protocol/text edges. Do not add compatibility adapters unless they protect a named ownership invariant. 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 5d0da264..ea2a408d 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 @@ -28,6 +28,7 @@ use epiphany_codex_bridge::view::epiphany_view_needs_pressure; use epiphany_codex_bridge::view::epiphany_view_needs_reorientation_inputs; use epiphany_codex_bridge::view::epiphany_view_needs_runtime_store; use epiphany_codex_bridge::view::map_core_epiphany_distill_input; +use epiphany_codex_bridge::view::map_core_epiphany_view_lenses; use epiphany_codex_bridge::view::map_epiphany_context_response; use epiphany_codex_bridge::view::map_epiphany_distill_response; use epiphany_codex_bridge::view::map_epiphany_graph_query_response; @@ -52,7 +53,7 @@ impl CodexMessageProcessor { let lenses = if lenses.is_empty() { default_epiphany_view_lenses() } else { - lenses + map_core_epiphany_view_lenses(lenses) }; let thread_uuid = match ThreadId::from_string(&thread_id) {