diff --git a/epiphany-codex-bridge/src/mutation.rs b/epiphany-codex-bridge/src/mutation.rs index f7d98581..9d5430f9 100644 --- a/epiphany-codex-bridge/src/mutation.rs +++ b/epiphany-codex-bridge/src/mutation.rs @@ -1,6 +1,3 @@ -use codex_app_server_protocol::ThreadEpiphanyStateUpdatedField; -use codex_app_server_protocol::ThreadEpiphanyStateUpdatedNotification; -use codex_app_server_protocol::ThreadEpiphanyStateUpdatedSource; use epiphany_core::EpiphanyReorientAcceptanceFinding; use epiphany_core::EpiphanyReorientFindingInterpretation as CoreEpiphanyReorientFinding; use epiphany_core::EpiphanyRoleAcceptanceFinding; @@ -67,63 +64,6 @@ pub fn state_update_from_core_patch( } } -pub fn epiphany_state_updated_notification( - thread_id: String, - source: ThreadEpiphanyStateUpdatedSource, - revision: u64, - changed_fields: Vec, - epiphany_state: epiphany_state_model::EpiphanyThreadState, -) -> ThreadEpiphanyStateUpdatedNotification { - ThreadEpiphanyStateUpdatedNotification { - thread_id, - source, - revision, - changed_fields: map_protocol_state_updated_fields(changed_fields), - epiphany_state, - } -} - -pub fn map_protocol_state_updated_fields( - fields: Vec, -) -> Vec { - fields - .into_iter() - .map(map_protocol_state_updated_field) - .collect() -} - -pub fn map_protocol_state_updated_field( - field: EpiphanyStateUpdatedField, -) -> ThreadEpiphanyStateUpdatedField { - match field { - EpiphanyStateUpdatedField::Objective => ThreadEpiphanyStateUpdatedField::Objective, - EpiphanyStateUpdatedField::ActiveSubgoalId => { - ThreadEpiphanyStateUpdatedField::ActiveSubgoalId - } - EpiphanyStateUpdatedField::Subgoals => ThreadEpiphanyStateUpdatedField::Subgoals, - EpiphanyStateUpdatedField::Invariants => ThreadEpiphanyStateUpdatedField::Invariants, - EpiphanyStateUpdatedField::Graphs => ThreadEpiphanyStateUpdatedField::Graphs, - EpiphanyStateUpdatedField::GraphFrontier => ThreadEpiphanyStateUpdatedField::GraphFrontier, - EpiphanyStateUpdatedField::GraphCheckpoint => { - ThreadEpiphanyStateUpdatedField::GraphCheckpoint - } - EpiphanyStateUpdatedField::Scratch => ThreadEpiphanyStateUpdatedField::Scratch, - EpiphanyStateUpdatedField::InvestigationCheckpoint => { - ThreadEpiphanyStateUpdatedField::InvestigationCheckpoint - } - EpiphanyStateUpdatedField::JobBindings => ThreadEpiphanyStateUpdatedField::JobBindings, - EpiphanyStateUpdatedField::AcceptanceReceipts => { - ThreadEpiphanyStateUpdatedField::AcceptanceReceipts - } - EpiphanyStateUpdatedField::RuntimeLinks => ThreadEpiphanyStateUpdatedField::RuntimeLinks, - EpiphanyStateUpdatedField::Observations => ThreadEpiphanyStateUpdatedField::Observations, - EpiphanyStateUpdatedField::Evidence => ThreadEpiphanyStateUpdatedField::Evidence, - EpiphanyStateUpdatedField::Churn => ThreadEpiphanyStateUpdatedField::Churn, - EpiphanyStateUpdatedField::Mode => ThreadEpiphanyStateUpdatedField::Mode, - EpiphanyStateUpdatedField::Planning => ThreadEpiphanyStateUpdatedField::Planning, - } -} - pub fn build_role_acceptance_update( expected_revision: Option, role_id: EpiphanyRoleResultRoleId, diff --git a/epiphany-codex-bridge/src/protocol_edge.rs b/epiphany-codex-bridge/src/protocol_edge.rs index 75f8f2c0..937da68b 100644 --- a/epiphany-codex-bridge/src/protocol_edge.rs +++ b/epiphany-codex-bridge/src/protocol_edge.rs @@ -48,6 +48,9 @@ use codex_app_server_protocol::ThreadEpiphanyRoleResultStatus; use codex_app_server_protocol::ThreadEpiphanyRoleSelfPersistenceReview; use codex_app_server_protocol::ThreadEpiphanyRoleSelfPersistenceStatus; use codex_app_server_protocol::ThreadEpiphanyRoleWorkerLaunchDocument; +use codex_app_server_protocol::ThreadEpiphanyStateUpdatedField; +use codex_app_server_protocol::ThreadEpiphanyStateUpdatedNotification; +use codex_app_server_protocol::ThreadEpiphanyStateUpdatedSource; use codex_app_server_protocol::ThreadEpiphanyUpdatePatch; use codex_app_server_protocol::ThreadEpiphanyViewLens; use codex_app_server_protocol::ThreadEpiphanyWorkerLaunchDocument; @@ -70,6 +73,7 @@ use epiphany_core::EpiphanyRoleSelfPersistenceReview; use epiphany_core::EpiphanyRoleSelfPersistenceStatus; use epiphany_core::EpiphanyRoleStatePatchDocument; use epiphany_core::EpiphanyRoleWorkerLaunchDocument; +use epiphany_core::EpiphanyStateUpdatedField; use epiphany_core::EpiphanyViewLens; use epiphany_core::EpiphanyWorkerLaunchDocument; use epiphany_core::default_epiphany_view_lenses; @@ -77,6 +81,7 @@ use epiphany_core::epiphany_view_needs_jobs; use epiphany_core::epiphany_view_needs_pressure; use epiphany_core::epiphany_view_needs_reorientation_inputs; use epiphany_core::epiphany_view_needs_runtime_store; +use epiphany_state_model::EpiphanyThreadState; pub fn default_core_epiphany_view_lenses() -> Vec { default_epiphany_view_lenses() @@ -287,6 +292,63 @@ pub fn protocol_role_finding( } } +pub fn protocol_state_updated_notification( + thread_id: String, + source: ThreadEpiphanyStateUpdatedSource, + revision: u64, + changed_fields: Vec, + epiphany_state: EpiphanyThreadState, +) -> ThreadEpiphanyStateUpdatedNotification { + ThreadEpiphanyStateUpdatedNotification { + thread_id, + source, + revision, + changed_fields: protocol_state_updated_fields(changed_fields), + epiphany_state, + } +} + +pub fn protocol_state_updated_fields( + fields: Vec, +) -> Vec { + fields + .into_iter() + .map(protocol_state_updated_field) + .collect() +} + +pub fn protocol_state_updated_field( + field: EpiphanyStateUpdatedField, +) -> ThreadEpiphanyStateUpdatedField { + match field { + EpiphanyStateUpdatedField::Objective => ThreadEpiphanyStateUpdatedField::Objective, + EpiphanyStateUpdatedField::ActiveSubgoalId => { + ThreadEpiphanyStateUpdatedField::ActiveSubgoalId + } + EpiphanyStateUpdatedField::Subgoals => ThreadEpiphanyStateUpdatedField::Subgoals, + EpiphanyStateUpdatedField::Invariants => ThreadEpiphanyStateUpdatedField::Invariants, + EpiphanyStateUpdatedField::Graphs => ThreadEpiphanyStateUpdatedField::Graphs, + EpiphanyStateUpdatedField::GraphFrontier => ThreadEpiphanyStateUpdatedField::GraphFrontier, + EpiphanyStateUpdatedField::GraphCheckpoint => { + ThreadEpiphanyStateUpdatedField::GraphCheckpoint + } + EpiphanyStateUpdatedField::Scratch => ThreadEpiphanyStateUpdatedField::Scratch, + EpiphanyStateUpdatedField::InvestigationCheckpoint => { + ThreadEpiphanyStateUpdatedField::InvestigationCheckpoint + } + EpiphanyStateUpdatedField::JobBindings => ThreadEpiphanyStateUpdatedField::JobBindings, + EpiphanyStateUpdatedField::AcceptanceReceipts => { + ThreadEpiphanyStateUpdatedField::AcceptanceReceipts + } + EpiphanyStateUpdatedField::RuntimeLinks => ThreadEpiphanyStateUpdatedField::RuntimeLinks, + EpiphanyStateUpdatedField::Observations => ThreadEpiphanyStateUpdatedField::Observations, + EpiphanyStateUpdatedField::Evidence => ThreadEpiphanyStateUpdatedField::Evidence, + EpiphanyStateUpdatedField::Churn => ThreadEpiphanyStateUpdatedField::Churn, + EpiphanyStateUpdatedField::Mode => ThreadEpiphanyStateUpdatedField::Mode, + EpiphanyStateUpdatedField::Planning => ThreadEpiphanyStateUpdatedField::Planning, + } +} + pub fn protocol_freshness_response_from_surface( surface: EpiphanyFreshnessSurface, ) -> ThreadEpiphanyFreshnessResponse { diff --git a/notes/fresh-workspace-handoff.md b/notes/fresh-workspace-handoff.md index 4abf58c7..37c3d678 100644 --- a/notes/fresh-workspace-handoff.md +++ b/notes/fresh-workspace-handoff.md @@ -85,6 +85,7 @@ remembers doctrine; the branch remembers the blade. - Pressure projection is centralized too. `pressure.rs` derives typed `EpiphanyPressure`, coordinator consumes typed pressure signals, and `protocol_edge` owns the `ThreadEpiphanyPressure*` DTO mapping. - Reorientation derivation is typed-only too. `reorient.rs` no longer imports app-server protocol DTOs and no longer exposes the unused freshness DTO tuple; view/coordinator response builders call `protocol_edge` for reorient state/decision projection. - Result projection moved to the edge. `results.rs` now renders typed result notes only; `protocol_edge` owns role-id request conversion plus role/reorient finding and state-patch projection for Codex JSON-RPC responses. +- State-updated notification projection moved to the edge as well. `mutation.rs` now owns typed mutation/acceptance mechanics without importing app-server protocol 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 67059169..c5aeac9f 100644 Binary files a/state/ledgers.msgpack and b/state/ledgers.msgpack differ diff --git a/state/map.yaml b/state/map.yaml index 2b1a7c81..793fae21 100644 --- a/state/map.yaml +++ b/state/map.yaml @@ -418,6 +418,9 @@ current_status: `results.rs` renders typed result notes only, while `protocol_edge` owns role-id request conversion plus role/reorient finding and state-patch projection for Codex JSON-RPC responses. + State-updated notification projection also moved to `protocol_edge`: + `mutation.rs` now owns typed mutation and acceptance mechanics without + importing Codex app-server protocol DTOs. 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. diff --git a/vendor/codex/codex-rs/app-server/src/codex_message_processor/epiphany_automation.rs b/vendor/codex/codex-rs/app-server/src/codex_message_processor/epiphany_automation.rs index 03608ad1..0378b5cb 100644 --- a/vendor/codex/codex-rs/app-server/src/codex_message_processor/epiphany_automation.rs +++ b/vendor/codex/codex-rs/app-server/src/codex_message_processor/epiphany_automation.rs @@ -1,7 +1,6 @@ use std::sync::Arc; use codex_app_server_protocol::ServerNotification; -use codex_app_server_protocol::ThreadEpiphanyStateUpdatedNotification; use codex_app_server_protocol::ThreadEpiphanyStateUpdatedSource; use codex_core::CodexThread; use codex_core::SteerInputError; @@ -15,11 +14,11 @@ use epiphany_codex_bridge::coordinator::select_epiphany_coordinator_automation; use epiphany_codex_bridge::invalidation::EpiphanyInvalidationManager; use epiphany_codex_bridge::invalidation::epiphany_freshness_watcher_snapshot; use epiphany_codex_bridge::mutation::epiphany_job_launch_changed_fields; -use epiphany_codex_bridge::mutation::map_protocol_state_updated_fields; use epiphany_codex_bridge::mutation_service::launch_epiphany_job_on_thread; use epiphany_codex_bridge::pressure::derive_epiphany_pressure; use epiphany_codex_bridge::pressure::render_epiphany_pre_compaction_checkpoint_intervention; use epiphany_codex_bridge::pressure::should_run_epiphany_pre_compaction_checkpoint_intervention; +use epiphany_codex_bridge::protocol_edge::protocol_state_updated_notification; use epiphany_codex_bridge::retrieve::epiphany_retrieval_state_for_paths; use tokio::sync::Mutex; use tracing::warn; @@ -95,15 +94,13 @@ pub(crate) async fn maybe_run_epiphany_coordinator_automation_for_turn_boundary( .await; outgoing .send_server_notification(ServerNotification::ThreadEpiphanyStateUpdated( - ThreadEpiphanyStateUpdatedNotification { - thread_id: thread_id_text, - source: ThreadEpiphanyStateUpdatedSource::JobLaunch, - revision: epiphany_state.revision, - changed_fields: map_protocol_state_updated_fields( - epiphany_job_launch_changed_fields(), - ), + protocol_state_updated_notification( + thread_id_text, + ThreadEpiphanyStateUpdatedSource::JobLaunch, + epiphany_state.revision, + epiphany_job_launch_changed_fields(), epiphany_state, - }, + ), )) .await; } diff --git a/vendor/codex/codex-rs/app-server/src/codex_message_processor/epiphany_mutation_routes.rs b/vendor/codex/codex-rs/app-server/src/codex_message_processor/epiphany_mutation_routes.rs index 0f3d5fcd..8ecfaf55 100644 --- a/vendor/codex/codex-rs/app-server/src/codex_message_processor/epiphany_mutation_routes.rs +++ b/vendor/codex/codex-rs/app-server/src/codex_message_processor/epiphany_mutation_routes.rs @@ -9,8 +9,6 @@ use epiphany_codex_bridge::invalidation::epiphany_freshness_watcher_snapshot; use epiphany_codex_bridge::launch::EPIPHANY_REORIENT_LAUNCH_BINDING_ID; use epiphany_codex_bridge::launch::build_epiphany_job_launch_request; use epiphany_codex_bridge::launch::epiphany_role_binding_id; -use epiphany_codex_bridge::mutation::epiphany_state_updated_notification; -use epiphany_codex_bridge::mutation::map_protocol_state_updated_fields; use epiphany_codex_bridge::mutation_service::EpiphanyThreadPromoteApplied; use epiphany_codex_bridge::mutation_service::apply_thread_epiphany_promote; use epiphany_codex_bridge::mutation_service::apply_thread_epiphany_reorient_accept; @@ -28,6 +26,8 @@ use epiphany_codex_bridge::protocol_edge::protocol_reorient_source; use epiphany_codex_bridge::protocol_edge::protocol_reorient_state_status; use epiphany_codex_bridge::protocol_edge::protocol_role_finding; use epiphany_codex_bridge::protocol_edge::protocol_role_id_to_core; +use epiphany_codex_bridge::protocol_edge::protocol_state_updated_fields; +use epiphany_codex_bridge::protocol_edge::protocol_state_updated_notification; use epiphany_codex_bridge::protocol_edge::protocol_update_patch_to_core; use epiphany_codex_bridge::protocol_edge::protocol_worker_launch_document_to_core; use epiphany_codex_bridge::retrieve::epiphany_retrieval_state_for_paths; @@ -82,7 +82,7 @@ impl CodexMessageProcessor { ) { self.outgoing .send_server_notification(ServerNotification::ThreadEpiphanyStateUpdated( - epiphany_state_updated_notification( + protocol_state_updated_notification( thread_uuid.to_string(), source, epiphany_state.revision, @@ -136,7 +136,7 @@ impl CodexMessageProcessor { } }; let changed_fields = applied.changed_fields; - let protocol_changed_fields = map_protocol_state_updated_fields(changed_fields.clone()); + let protocol_changed_fields = protocol_state_updated_fields(changed_fields.clone()); let epiphany_state = applied.epiphany_state; self.outgoing @@ -216,7 +216,7 @@ impl CodexMessageProcessor { } }; let changed_fields = applied.changed_fields; - let protocol_changed_fields = map_protocol_state_updated_fields(changed_fields.clone()); + let protocol_changed_fields = protocol_state_updated_fields(changed_fields.clone()); let epiphany_state = applied.epiphany_state; self.outgoing @@ -314,7 +314,7 @@ impl CodexMessageProcessor { } }; let changed_fields = applied.changed_fields; - let protocol_changed_fields = map_protocol_state_updated_fields(changed_fields.clone()); + let protocol_changed_fields = protocol_state_updated_fields(changed_fields.clone()); let epiphany_state = applied.epiphany_state; self.outgoing @@ -390,7 +390,7 @@ impl CodexMessageProcessor { } }; let changed_fields = applied.changed_fields; - let protocol_changed_fields = map_protocol_state_updated_fields(changed_fields.clone()); + let protocol_changed_fields = protocol_state_updated_fields(changed_fields.clone()); let epiphany_state = applied.epiphany_state; self.outgoing @@ -516,7 +516,7 @@ impl CodexMessageProcessor { } }; let changed_fields = applied.changed_fields; - let protocol_changed_fields = map_protocol_state_updated_fields(changed_fields.clone()); + let protocol_changed_fields = protocol_state_updated_fields(changed_fields.clone()); let epiphany_state = applied.epiphany_state; let response = ThreadEpiphanyPromoteResponse { accepted: true, @@ -571,7 +571,7 @@ impl CodexMessageProcessor { } }; let changed_fields = applied.changed_fields; - let protocol_changed_fields = map_protocol_state_updated_fields(changed_fields.clone()); + let protocol_changed_fields = protocol_state_updated_fields(changed_fields.clone()); let epiphany_state = applied.epiphany_state; let response = ThreadEpiphanyUpdateResponse { revision: applied.revision, @@ -653,7 +653,7 @@ impl CodexMessageProcessor { } }; let changed_fields = applied.changed_fields; - let protocol_changed_fields = map_protocol_state_updated_fields(changed_fields.clone()); + let protocol_changed_fields = protocol_state_updated_fields(changed_fields.clone()); let epiphany_state = applied.epiphany_state; self.outgoing @@ -721,7 +721,7 @@ impl CodexMessageProcessor { } }; let changed_fields = applied.changed_fields; - let protocol_changed_fields = map_protocol_state_updated_fields(changed_fields.clone()); + let protocol_changed_fields = protocol_state_updated_fields(changed_fields.clone()); let epiphany_state = applied.epiphany_state; self.outgoing