From 71a5d6fb43128c9c29d8a6578ec44606a9b4e023 Mon Sep 17 00:00:00 2001 From: Meta Vens Date: Wed, 13 May 2026 03:07:24 +0100 Subject: [PATCH] Extract Epiphany Codex bridge crate --- epiphany-codex-bridge/Cargo.toml | 21 +++ .../src/context.rs | 6 +- .../src/coordinator.rs | 58 ++++---- .../src/jobs.rs | 6 +- .../src/launch.rs | 96 ++++++------- epiphany-codex-bridge/src/lib.rs | 9 ++ .../src/pressure.rs | 12 +- .../src/prompts/epiphany_specialists.toml | 0 .../src/reorient.rs | 19 ++- .../src/results.rs | 14 +- .../src/retrieve.rs | 4 +- .../src/scene.rs | 9 +- notes/fresh-workspace-handoff.md | 27 +++- state/ledgers.msgpack | Bin 75826 -> 76125 bytes state/map.yaml | 4 +- vendor/codex/codex-rs/app-server/Cargo.toml | 1 + .../app-server/src/codex_message_processor.rs | 126 ++++++++++-------- .../epiphany_automation.rs | 2 +- .../epiphany_mutation_routes.rs | 2 +- .../epiphany_read_routes.rs | 18 ++- .../processor_tests.rs | 26 +++- vendor/codex/codex-rs/app-server/src/lib.rs | 9 -- 22 files changed, 271 insertions(+), 198 deletions(-) create mode 100644 epiphany-codex-bridge/Cargo.toml rename vendor/codex/codex-rs/app-server/src/epiphany_context.rs => epiphany-codex-bridge/src/context.rs (98%) rename vendor/codex/codex-rs/app-server/src/epiphany_coordinator.rs => epiphany-codex-bridge/src/coordinator.rs (95%) rename vendor/codex/codex-rs/app-server/src/epiphany_jobs.rs => epiphany-codex-bridge/src/jobs.rs (95%) rename vendor/codex/codex-rs/app-server/src/epiphany_launch.rs => epiphany-codex-bridge/src/launch.rs (91%) create mode 100644 epiphany-codex-bridge/src/lib.rs rename vendor/codex/codex-rs/app-server/src/epiphany_pressure.rs => epiphany-codex-bridge/src/pressure.rs (88%) rename {vendor/codex/codex-rs/app-server => epiphany-codex-bridge}/src/prompts/epiphany_specialists.toml (100%) rename vendor/codex/codex-rs/app-server/src/epiphany_reorient.rs => epiphany-codex-bridge/src/reorient.rs (97%) rename vendor/codex/codex-rs/app-server/src/epiphany_results.rs => epiphany-codex-bridge/src/results.rs (97%) rename vendor/codex/codex-rs/app-server/src/epiphany_retrieve.rs => epiphany-codex-bridge/src/retrieve.rs (96%) rename vendor/codex/codex-rs/app-server/src/epiphany_scene.rs => epiphany-codex-bridge/src/scene.rs (97%) diff --git a/epiphany-codex-bridge/Cargo.toml b/epiphany-codex-bridge/Cargo.toml new file mode 100644 index 00000000..5cc369f7 --- /dev/null +++ b/epiphany-codex-bridge/Cargo.toml @@ -0,0 +1,21 @@ +[package] +name = "epiphany-codex-bridge" +version = "0.1.0" +edition = "2024" +publish = false +license-file = "../LICENSE" + +[lib] +name = "epiphany_codex_bridge" +path = "src/lib.rs" + +[dependencies] +anyhow = "1" +codex-app-server-protocol = { path = "../vendor/codex/codex-rs/app-server-protocol" } +codex-core = { path = "../vendor/codex/codex-rs/core" } +codex-protocol = { path = "../vendor/codex/codex-rs/protocol" } +codex-utils-absolute-path = { path = "../vendor/codex/codex-rs/utils/absolute-path" } +epiphany-core = { path = "../epiphany-core" } +serde_json = "1" +serde = { version = "1", features = ["derive"] } +toml = "0.9" diff --git a/vendor/codex/codex-rs/app-server/src/epiphany_context.rs b/epiphany-codex-bridge/src/context.rs similarity index 98% rename from vendor/codex/codex-rs/app-server/src/epiphany_context.rs rename to epiphany-codex-bridge/src/context.rs index 1d7a6ffe..11223c56 100644 --- a/vendor/codex/codex-rs/app-server/src/epiphany_context.rs +++ b/epiphany-codex-bridge/src/context.rs @@ -32,7 +32,7 @@ use epiphany_core::derive_context; use epiphany_core::derive_graph_query; use epiphany_core::derive_planning_view; -pub(super) fn map_epiphany_context( +pub fn map_epiphany_context( state: Option<&EpiphanyThreadState>, params: &ThreadEpiphanyContextParams, ) -> ( @@ -111,7 +111,7 @@ fn map_core_epiphany_context_missing( } } -pub(super) fn map_epiphany_planning( +pub fn map_epiphany_planning( state: Option<&EpiphanyThreadState>, ) -> ( ThreadEpiphanyContextStateStatus, @@ -159,7 +159,7 @@ fn map_core_epiphany_planning_summary( } } -pub(super) fn map_epiphany_graph_query( +pub fn map_epiphany_graph_query( state: Option<&EpiphanyThreadState>, query: &ThreadEpiphanyGraphQuery, ) -> ( diff --git a/vendor/codex/codex-rs/app-server/src/epiphany_coordinator.rs b/epiphany-codex-bridge/src/coordinator.rs similarity index 95% rename from vendor/codex/codex-rs/app-server/src/epiphany_coordinator.rs rename to epiphany-codex-bridge/src/coordinator.rs index 97aefb0d..7eb05d1c 100644 --- a/vendor/codex/codex-rs/app-server/src/epiphany_coordinator.rs +++ b/epiphany-codex-bridge/src/coordinator.rs @@ -50,16 +50,16 @@ use epiphany_core::recommend_crrc_action; use epiphany_core::render_role_board_note; use epiphany_core::select_coordinator_automation_action; -use crate::epiphany_launch::EPIPHANY_IMAGINATION_OWNER_ROLE; -use crate::epiphany_launch::EPIPHANY_IMAGINATION_ROLE_BINDING_ID; -use crate::epiphany_launch::EPIPHANY_MODELING_ROLE_BINDING_ID; -use crate::epiphany_launch::EPIPHANY_REORIENT_OWNER_ROLE; -use crate::epiphany_launch::EPIPHANY_VERIFICATION_ROLE_BINDING_ID; -use crate::epiphany_launch::epiphany_role_label; +use crate::launch::EPIPHANY_IMAGINATION_OWNER_ROLE; +use crate::launch::EPIPHANY_IMAGINATION_ROLE_BINDING_ID; +use crate::launch::EPIPHANY_MODELING_ROLE_BINDING_ID; +use crate::launch::EPIPHANY_REORIENT_OWNER_ROLE; +use crate::launch::EPIPHANY_VERIFICATION_ROLE_BINDING_ID; +use crate::launch::epiphany_role_label; use std::collections::HashSet; -pub(super) fn map_epiphany_crrc_recommendation( +pub fn map_epiphany_crrc_recommendation( loaded: bool, state_status: ThreadEpiphanyReorientStateStatus, pressure: &ThreadEpiphanyPressure, @@ -165,23 +165,23 @@ fn map_core_crrc_recommendation( } } -pub(super) struct EpiphanyCoordinatorDecision { - pub(super) action: ThreadEpiphanyCoordinatorAction, - pub(super) target_role: Option, - pub(super) recommended_scene_action: Option, - pub(super) requires_review: bool, - pub(super) can_auto_run: bool, - pub(super) reason: String, +pub struct EpiphanyCoordinatorDecision { + pub action: ThreadEpiphanyCoordinatorAction, + pub target_role: Option, + pub recommended_scene_action: Option, + pub requires_review: bool, + pub can_auto_run: bool, + pub reason: String, } #[derive(Debug, Clone, Copy, PartialEq, Eq)] -pub(super) enum EpiphanyCoordinatorAutomationAction { +pub enum EpiphanyCoordinatorAutomationAction { None, CompactRehydrateReorient, LaunchReorientWorker, } -pub(super) fn map_epiphany_coordinator_automation_action( +pub fn map_epiphany_coordinator_automation_action( decision: &EpiphanyCoordinatorDecision, ) -> EpiphanyCoordinatorAutomationAction { map_protocol_coordinator_automation_action(coordinator_automation_action( @@ -189,7 +189,7 @@ pub(super) fn map_epiphany_coordinator_automation_action( )) } -pub(super) fn select_epiphany_coordinator_automation_action( +pub fn select_epiphany_coordinator_automation_action( decision: &EpiphanyCoordinatorDecision, force_checkpoint_compaction: bool, ) -> EpiphanyCoordinatorAutomationAction { @@ -199,7 +199,7 @@ pub(super) fn select_epiphany_coordinator_automation_action( )) } -pub(super) fn map_epiphany_coordinator( +pub fn map_epiphany_coordinator( state_status: ThreadEpiphanyReorientStateStatus, checkpoint_present: bool, pressure: &ThreadEpiphanyPressure, @@ -540,7 +540,7 @@ fn map_protocol_coordinator_automation_action( } } -pub(super) fn epiphany_reorient_finding_already_accepted( +pub fn epiphany_reorient_finding_already_accepted( state: &EpiphanyThreadState, finding: &ThreadEpiphanyReorientFinding, ) -> bool { @@ -557,14 +557,14 @@ pub(super) fn epiphany_reorient_finding_already_accepted( false } -pub(super) fn epiphany_role_finding_already_accepted( +pub fn epiphany_role_finding_already_accepted( state: &EpiphanyThreadState, finding: &ThreadEpiphanyRoleFinding, ) -> bool { epiphany_role_finding_accepted_index(state, finding).is_some() } -pub(super) fn epiphany_role_finding_accepted_evidence_id( +pub fn epiphany_role_finding_accepted_evidence_id( state: &EpiphanyThreadState, finding: &ThreadEpiphanyRoleFinding, ) -> Option { @@ -572,7 +572,7 @@ pub(super) fn epiphany_role_finding_accepted_evidence_id( .and_then(|receipt| receipt.accepted_evidence_id.clone()) } -pub(super) fn epiphany_verification_finding_covers_current_modeling( +pub fn epiphany_verification_finding_covers_current_modeling( state: &EpiphanyThreadState, modeling_result_accepted: bool, modeling_finding: Option<&ThreadEpiphanyRoleFinding>, @@ -602,7 +602,7 @@ pub(super) fn epiphany_verification_finding_covers_current_modeling( .any(|id| modeling_evidence_ids.contains(id)) } -pub(super) fn role_finding_accepted_after( +pub fn role_finding_accepted_after( state: &EpiphanyThreadState, later: Option<&ThreadEpiphanyRoleFinding>, earlier: Option<&ThreadEpiphanyRoleFinding>, @@ -622,7 +622,7 @@ pub(super) fn role_finding_accepted_after( later_index < earlier_index } -pub(super) fn implementation_evidence_after_role_finding( +pub fn implementation_evidence_after_role_finding( state: &EpiphanyThreadState, earlier: Option<&ThreadEpiphanyRoleFinding>, ) -> bool { @@ -639,7 +639,7 @@ pub(super) fn implementation_evidence_after_role_finding( .is_some_and(|(_, evidence)| evidence.status == "ok") } -pub(super) fn epiphany_role_finding_cites_implementation_evidence( +pub fn epiphany_role_finding_cites_implementation_evidence( state: &EpiphanyThreadState, finding: Option<&ThreadEpiphanyRoleFinding>, ) -> bool { @@ -705,7 +705,7 @@ fn epiphany_role_finding_acceptance_receipt_index( }) } -pub(super) fn epiphany_verification_finding_allows_implementation( +pub fn epiphany_verification_finding_allows_implementation( finding: &ThreadEpiphanyRoleFinding, ) -> bool { finding.role_id == ThreadEpiphanyRoleId::Verification @@ -715,7 +715,7 @@ pub(super) fn epiphany_verification_finding_allows_implementation( .is_some_and(|verdict| verdict.eq_ignore_ascii_case("pass")) } -pub(super) fn epiphany_verification_finding_needs_evidence( +pub fn epiphany_verification_finding_needs_evidence( finding: &ThreadEpiphanyRoleFinding, ) -> bool { finding.role_id == ThreadEpiphanyRoleId::Verification @@ -733,7 +733,7 @@ fn reorient_finding_runtime_result_id(finding: &ThreadEpiphanyReorientFinding) - finding.runtime_result_id.clone() } -pub(super) fn map_epiphany_roles( +pub fn map_epiphany_roles( state: Option<&EpiphanyThreadState>, jobs: &[ThreadEpiphanyJob], decision: &ThreadEpiphanyReorientDecision, @@ -899,7 +899,7 @@ fn map_protocol_coordinator_role_status( } } -pub(super) fn render_epiphany_roles_note( +pub fn render_epiphany_roles_note( roles: &[ThreadEpiphanyRoleLane], state_status: ThreadEpiphanyReorientStateStatus, recommendation: ThreadEpiphanyCrrcAction, diff --git a/vendor/codex/codex-rs/app-server/src/epiphany_jobs.rs b/epiphany-codex-bridge/src/jobs.rs similarity index 95% rename from vendor/codex/codex-rs/app-server/src/epiphany_jobs.rs rename to epiphany-codex-bridge/src/jobs.rs index 11535cb1..b9a2e8c8 100644 --- a/vendor/codex/codex-rs/app-server/src/epiphany_jobs.rs +++ b/epiphany-codex-bridge/src/jobs.rs @@ -9,7 +9,7 @@ use epiphany_core::EpiphanyJobView; use epiphany_core::EpiphanyJobsInput; use epiphany_core::derive_jobs; -pub(super) fn map_epiphany_jobs( +pub fn map_epiphany_jobs( state: Option<&EpiphanyThreadState>, retrieval_override: Option<&EpiphanyRetrievalState>, ) -> Vec { @@ -43,7 +43,7 @@ fn map_core_epiphany_job_view(job: EpiphanyJobView) -> ThreadEpiphanyJob { } } -pub(super) fn map_core_epiphany_job_kind(kind: CoreEpiphanyJobKind) -> ThreadEpiphanyJobKind { +pub fn map_core_epiphany_job_kind(kind: CoreEpiphanyJobKind) -> ThreadEpiphanyJobKind { match kind { CoreEpiphanyJobKind::Indexing => ThreadEpiphanyJobKind::Indexing, CoreEpiphanyJobKind::Remap => ThreadEpiphanyJobKind::Remap, @@ -66,7 +66,7 @@ fn map_core_epiphany_job_status(status: CoreEpiphanyJobStatus) -> ThreadEpiphany } } -pub(super) fn epiphany_blocked_state_job( +pub fn epiphany_blocked_state_job( id: &str, kind: ThreadEpiphanyJobKind, scope: &str, diff --git a/vendor/codex/codex-rs/app-server/src/epiphany_launch.rs b/epiphany-codex-bridge/src/launch.rs similarity index 91% rename from vendor/codex/codex-rs/app-server/src/epiphany_launch.rs rename to epiphany-codex-bridge/src/launch.rs index be7d89ad..689b30a7 100644 --- a/vendor/codex/codex-rs/app-server/src/epiphany_launch.rs +++ b/epiphany-codex-bridge/src/launch.rs @@ -21,16 +21,16 @@ use epiphany_core::EpiphanyReorientWorkerLaunchDocument; use epiphany_core::EpiphanyRoleWorkerLaunchDocument; use epiphany_core::EpiphanyWorkerLaunchDocument; -pub(super) const EPIPHANY_IMAGINATION_ROLE_BINDING_ID: &str = "planning-synthesis-worker"; -pub(super) const EPIPHANY_IMAGINATION_OWNER_ROLE: &str = "epiphany-imagination"; -pub(super) const EPIPHANY_MODELING_ROLE_BINDING_ID: &str = "modeling-checkpoint-worker"; -pub(super) const EPIPHANY_MODELING_OWNER_ROLE: &str = "epiphany-modeler"; -pub(super) const EPIPHANY_VERIFICATION_ROLE_BINDING_ID: &str = "verification-review-worker"; -pub(super) const EPIPHANY_VERIFICATION_OWNER_ROLE: &str = "epiphany-verifier"; -pub(super) const EPIPHANY_REORIENT_LAUNCH_BINDING_ID: &str = "reorient-worker"; -pub(super) const EPIPHANY_REORIENT_OWNER_ROLE: &str = "epiphany-reorient"; +pub const EPIPHANY_IMAGINATION_ROLE_BINDING_ID: &str = "planning-synthesis-worker"; +pub const EPIPHANY_IMAGINATION_OWNER_ROLE: &str = "epiphany-imagination"; +pub const EPIPHANY_MODELING_ROLE_BINDING_ID: &str = "modeling-checkpoint-worker"; +pub const EPIPHANY_MODELING_OWNER_ROLE: &str = "epiphany-modeler"; +pub const EPIPHANY_VERIFICATION_ROLE_BINDING_ID: &str = "verification-review-worker"; +pub const EPIPHANY_VERIFICATION_OWNER_ROLE: &str = "epiphany-verifier"; +pub const EPIPHANY_REORIENT_LAUNCH_BINDING_ID: &str = "reorient-worker"; +pub const EPIPHANY_REORIENT_OWNER_ROLE: &str = "epiphany-reorient"; -pub(super) fn epiphany_role_binding_id( +pub fn epiphany_role_binding_id( role_id: ThreadEpiphanyRoleId, ) -> Result<&'static str, String> { match role_id { @@ -48,7 +48,7 @@ pub(super) fn epiphany_role_binding_id( } } -pub(super) fn epiphany_role_owner(role_id: ThreadEpiphanyRoleId) -> Result<&'static str, String> { +pub fn epiphany_role_owner(role_id: ThreadEpiphanyRoleId) -> Result<&'static str, String> { match role_id { ThreadEpiphanyRoleId::Imagination => Ok(EPIPHANY_IMAGINATION_OWNER_ROLE), ThreadEpiphanyRoleId::Modeling => Ok(EPIPHANY_MODELING_OWNER_ROLE), @@ -59,7 +59,7 @@ pub(super) fn epiphany_role_owner(role_id: ThreadEpiphanyRoleId) -> Result<&'sta } } -pub(super) fn epiphany_role_label(role_id: ThreadEpiphanyRoleId) -> &'static str { +pub fn epiphany_role_label(role_id: ThreadEpiphanyRoleId) -> &'static str { match role_id { ThreadEpiphanyRoleId::Implementation => "implementation", ThreadEpiphanyRoleId::Imagination => "imagination", @@ -69,7 +69,7 @@ pub(super) fn epiphany_role_label(role_id: ThreadEpiphanyRoleId) -> &'static str } } -pub(super) fn epiphany_role_launch_output_schema( +pub fn epiphany_role_launch_output_schema( role_id: ThreadEpiphanyRoleId, ) -> serde_json::Value { let verdict_enum = match role_id { @@ -276,7 +276,7 @@ pub(super) fn epiphany_role_launch_output_schema( }) } -pub(super) fn epiphany_reorient_launch_output_schema() -> serde_json::Value { +pub fn epiphany_reorient_launch_output_schema() -> serde_json::Value { serde_json::json!({ "type": "object", "properties": { @@ -316,60 +316,60 @@ pub(super) fn epiphany_reorient_launch_output_schema() -> serde_json::Value { const EPIPHANY_SPECIALIST_PROMPTS_TOML: &str = include_str!("prompts/epiphany_specialists.toml"); #[derive(Debug, serde::Deserialize)] -pub(super) struct EpiphanySpecialistPromptConfig { - pub(super) shared: EpiphanySharedPromptConfig, - pub(super) roles: EpiphanyRolePromptConfig, +pub struct EpiphanySpecialistPromptConfig { + pub shared: EpiphanySharedPromptConfig, + pub roles: EpiphanyRolePromptConfig, // Parsed here so the bundled prompt config fails fast even though the GUI runner consumes it. #[allow(dead_code)] - pub(super) implementation: EpiphanyImplementationPromptConfig, - pub(super) reorientation: EpiphanyReorientationPromptConfig, - pub(super) coordinator: EpiphanyCoordinatorPromptConfig, - pub(super) crrc: EpiphanyCrrcPromptConfig, + pub implementation: EpiphanyImplementationPromptConfig, + pub reorientation: EpiphanyReorientationPromptConfig, + pub coordinator: EpiphanyCoordinatorPromptConfig, + pub crrc: EpiphanyCrrcPromptConfig, } #[derive(Debug, serde::Deserialize)] -pub(super) struct EpiphanySharedPromptConfig { - pub(super) persistent_memory: String, +pub struct EpiphanySharedPromptConfig { + pub persistent_memory: String, } #[derive(Debug, serde::Deserialize)] -pub(super) struct EpiphanyRolePromptConfig { - pub(super) imagination: String, - pub(super) modeling: String, - pub(super) verification: String, +pub struct EpiphanyRolePromptConfig { + pub imagination: String, + pub modeling: String, + pub verification: String, #[allow(dead_code)] - pub(super) research: String, + pub research: String, #[allow(dead_code)] - pub(super) repo_personality: String, + pub repo_personality: String, #[allow(dead_code)] - pub(super) repo_memory: String, + pub repo_memory: String, #[allow(dead_code)] - pub(super) face: String, + pub face: String, } #[derive(Debug, serde::Deserialize)] -pub(super) struct EpiphanyImplementationPromptConfig { +pub struct EpiphanyImplementationPromptConfig { #[allow(dead_code)] - pub(super) continue_template: String, + pub continue_template: String, } #[derive(Debug, serde::Deserialize)] -pub(super) struct EpiphanyReorientationPromptConfig { - pub(super) resume: String, - pub(super) regather: String, +pub struct EpiphanyReorientationPromptConfig { + pub resume: String, + pub regather: String, } #[derive(Debug, serde::Deserialize)] -pub(super) struct EpiphanyCoordinatorPromptConfig { - pub(super) note_template: String, +pub struct EpiphanyCoordinatorPromptConfig { + pub note_template: String, } #[derive(Debug, serde::Deserialize)] -pub(super) struct EpiphanyCrrcPromptConfig { - pub(super) pre_compaction_checkpoint_intervention: String, +pub struct EpiphanyCrrcPromptConfig { + pub pre_compaction_checkpoint_intervention: String, } -pub(super) fn epiphany_specialist_prompt_config() -> &'static EpiphanySpecialistPromptConfig { +pub fn epiphany_specialist_prompt_config() -> &'static EpiphanySpecialistPromptConfig { static CONFIG: OnceLock = OnceLock::new(); CONFIG.get_or_init(|| { toml::from_str(EPIPHANY_SPECIALIST_PROMPTS_TOML) @@ -377,7 +377,7 @@ pub(super) fn epiphany_specialist_prompt_config() -> &'static EpiphanySpecialist }) } -pub(super) fn epiphany_agent_prompt_with_memory(body: &str) -> String { +pub fn epiphany_agent_prompt_with_memory(body: &str) -> String { let memory = epiphany_specialist_prompt_config() .shared .persistent_memory @@ -392,7 +392,7 @@ pub(super) fn epiphany_agent_prompt_with_memory(body: &str) -> String { } } -pub(super) fn build_epiphany_role_launch_request( +pub fn build_epiphany_role_launch_request( thread_id: &str, role_id: ThreadEpiphanyRoleId, expected_revision: Option, @@ -478,7 +478,7 @@ fn build_epiphany_role_launch_instruction(role_id: ThreadEpiphanyRoleId) -> Stri epiphany_agent_prompt_with_memory(body) } -pub(super) fn build_epiphany_reorient_launch_request( +pub fn build_epiphany_reorient_launch_request( thread_id: &str, expected_revision: Option, max_runtime_seconds: Option, @@ -570,7 +570,7 @@ pub(super) fn build_epiphany_reorient_launch_request( } } -pub(super) fn build_epiphany_reorient_launch_instruction( +pub fn build_epiphany_reorient_launch_instruction( action: ThreadEpiphanyReorientAction, ) -> String { let prompts = &epiphany_specialist_prompt_config().reorientation; @@ -581,7 +581,7 @@ pub(super) fn build_epiphany_reorient_launch_instruction( epiphany_agent_prompt_with_memory(body) } -pub(super) fn map_core_worker_launch_document( +pub fn map_core_worker_launch_document( document: ThreadEpiphanyWorkerLaunchDocument, ) -> EpiphanyWorkerLaunchDocument { match document { @@ -653,7 +653,7 @@ fn map_core_reorient_worker_launch_document( } } -pub(super) fn render_epiphany_coordinator_note( +pub fn render_epiphany_coordinator_note( crrc_action: codex_app_server_protocol::ThreadEpiphanyCrrcAction, pressure_level: ThreadEpiphanyPressureLevel, modeling_result_status: codex_app_server_protocol::ThreadEpiphanyRoleResultStatus, @@ -685,7 +685,7 @@ pub(super) fn render_epiphany_coordinator_note( .replace("{coordinator_action}", &format!("{coordinator_action:?}")) } -pub(super) fn unique_strings(values: impl IntoIterator) -> Vec { +pub fn unique_strings(values: impl IntoIterator) -> Vec { let mut unique = Vec::new(); extend_unique_strings(&mut unique, values); unique @@ -746,7 +746,7 @@ fn reorient_reason_label(reason: ThreadEpiphanyReorientReason) -> &'static str { } } -pub(super) fn pressure_level_label(level: ThreadEpiphanyPressureLevel) -> &'static str { +pub fn pressure_level_label(level: ThreadEpiphanyPressureLevel) -> &'static str { match level { ThreadEpiphanyPressureLevel::Unknown => "unknown", ThreadEpiphanyPressureLevel::Low => "low", diff --git a/epiphany-codex-bridge/src/lib.rs b/epiphany-codex-bridge/src/lib.rs new file mode 100644 index 00000000..5f7ee356 --- /dev/null +++ b/epiphany-codex-bridge/src/lib.rs @@ -0,0 +1,9 @@ +pub mod context; +pub mod coordinator; +pub mod jobs; +pub mod launch; +pub mod pressure; +pub mod reorient; +pub mod retrieve; +pub mod results; +pub mod scene; diff --git a/vendor/codex/codex-rs/app-server/src/epiphany_pressure.rs b/epiphany-codex-bridge/src/pressure.rs similarity index 88% rename from vendor/codex/codex-rs/app-server/src/epiphany_pressure.rs rename to epiphany-codex-bridge/src/pressure.rs index 700431c9..b115aacf 100644 --- a/vendor/codex/codex-rs/app-server/src/epiphany_pressure.rs +++ b/epiphany-codex-bridge/src/pressure.rs @@ -9,11 +9,11 @@ use epiphany_core::EpiphanyPressureLevel as CoreEpiphanyPressureLevel; use epiphany_core::EpiphanyPressureStatus as CoreEpiphanyPressureStatus; use epiphany_core::derive_pressure_view; -use crate::epiphany_launch::epiphany_agent_prompt_with_memory; -use crate::epiphany_launch::epiphany_specialist_prompt_config; -use crate::epiphany_launch::pressure_level_label; +use crate::launch::epiphany_agent_prompt_with_memory; +use crate::launch::epiphany_specialist_prompt_config; +use crate::launch::pressure_level_label; -pub(super) fn map_epiphany_pressure(info: Option<&CoreTokenUsageInfo>) -> ThreadEpiphanyPressure { +pub fn map_epiphany_pressure(info: Option<&CoreTokenUsageInfo>) -> ThreadEpiphanyPressure { map_core_epiphany_pressure(derive_pressure_view(info)) } @@ -49,13 +49,13 @@ fn map_core_epiphany_pressure(pressure: EpiphanyPressure) -> ThreadEpiphanyPress } } -pub(super) fn should_run_epiphany_pre_compaction_checkpoint_intervention( +pub fn should_run_epiphany_pre_compaction_checkpoint_intervention( pressure: &ThreadEpiphanyPressure, ) -> bool { pressure.status == ThreadEpiphanyPressureStatus::Ready && pressure.should_prepare_compaction } -pub(super) fn render_epiphany_pre_compaction_checkpoint_intervention( +pub fn render_epiphany_pre_compaction_checkpoint_intervention( pressure: &ThreadEpiphanyPressure, ) -> String { let usage = match ( diff --git a/vendor/codex/codex-rs/app-server/src/prompts/epiphany_specialists.toml b/epiphany-codex-bridge/src/prompts/epiphany_specialists.toml similarity index 100% rename from vendor/codex/codex-rs/app-server/src/prompts/epiphany_specialists.toml rename to epiphany-codex-bridge/src/prompts/epiphany_specialists.toml diff --git a/vendor/codex/codex-rs/app-server/src/epiphany_reorient.rs b/epiphany-codex-bridge/src/reorient.rs similarity index 97% rename from vendor/codex/codex-rs/app-server/src/epiphany_reorient.rs rename to epiphany-codex-bridge/src/reorient.rs index 1f7eee74..6966f9c6 100644 --- a/vendor/codex/codex-rs/app-server/src/epiphany_reorient.rs +++ b/epiphany-codex-bridge/src/reorient.rs @@ -31,13 +31,20 @@ use epiphany_core::EpiphanyRetrievalFreshness as CoreEpiphanyRetrievalFreshness; use epiphany_core::EpiphanyRetrievalFreshnessStatus as CoreEpiphanyRetrievalFreshnessStatus; use epiphany_core::derive_freshness; use epiphany_core::recommend_reorientation; +use std::path::Path; +use std::path::PathBuf; -use crate::epiphany_invalidation::EpiphanyInvalidationSnapshot; +pub struct EpiphanyFreshnessWatcherSnapshot<'a> { + pub available: bool, + pub workspace_root: Option<&'a Path>, + pub observed_at_unix_seconds: Option, + pub changed_paths: &'a [PathBuf], +} -pub(super) fn map_epiphany_freshness( +pub fn map_epiphany_freshness( state: Option<&EpiphanyThreadState>, retrieval_override: Option<&EpiphanyRetrievalState>, - watcher_snapshot: Option<&EpiphanyInvalidationSnapshot>, + watcher_snapshot: Option>, ) -> ( Option, ThreadEpiphanyRetrievalFreshness, @@ -46,9 +53,9 @@ pub(super) fn map_epiphany_freshness( ) { let watcher = watcher_snapshot.map(|snapshot| EpiphanyFreshnessWatcherInput { available: snapshot.available, - workspace_root: snapshot.workspace_root.as_deref(), + workspace_root: snapshot.workspace_root, observed_at_unix_seconds: snapshot.observed_at_unix_seconds, - changed_paths: snapshot.changed_paths.as_slice(), + changed_paths: snapshot.changed_paths, }); let freshness = derive_freshness(EpiphanyFreshnessInput { state, @@ -146,7 +153,7 @@ fn map_core_epiphany_invalidation_input( } } -pub(super) fn map_epiphany_reorient( +pub fn map_epiphany_reorient( state: Option<&EpiphanyThreadState>, pressure: &ThreadEpiphanyPressure, retrieval: &ThreadEpiphanyRetrievalFreshness, diff --git a/vendor/codex/codex-rs/app-server/src/epiphany_results.rs b/epiphany-codex-bridge/src/results.rs similarity index 97% rename from vendor/codex/codex-rs/app-server/src/epiphany_results.rs rename to epiphany-codex-bridge/src/results.rs index abca6898..e7b63771 100644 --- a/vendor/codex/codex-rs/app-server/src/epiphany_results.rs +++ b/epiphany-codex-bridge/src/results.rs @@ -15,7 +15,7 @@ use epiphany_core::EpiphanyRoleStatePatchDocument; use epiphany_core::interpret_reorient_finding; use epiphany_core::interpret_role_finding; -pub(super) fn map_epiphany_reorient_finding( +pub fn map_epiphany_reorient_finding( raw_result: serde_json::Value, job_error: Option, item_error: Option, @@ -27,7 +27,7 @@ pub(super) fn map_epiphany_reorient_finding( )) } -pub(super) fn map_protocol_reorient_finding( +pub fn map_protocol_reorient_finding( finding: EpiphanyReorientFindingInterpretation, ) -> ThreadEpiphanyReorientFinding { ThreadEpiphanyReorientFinding { @@ -46,7 +46,7 @@ pub(super) fn map_protocol_reorient_finding( } } -pub(super) fn map_epiphany_role_finding( +pub fn map_epiphany_role_finding( role_id: ThreadEpiphanyRoleId, raw_result: serde_json::Value, job_error: Option, @@ -62,7 +62,7 @@ pub(super) fn map_epiphany_role_finding( map_protocol_role_finding(role_id, finding) } -pub(super) fn map_protocol_role_finding( +pub fn map_protocol_role_finding( role_id: ThreadEpiphanyRoleId, finding: EpiphanyRoleFindingInterpretation, ) -> ThreadEpiphanyRoleFinding { @@ -118,7 +118,7 @@ fn map_protocol_update_patch(patch: EpiphanyRoleStatePatchDocument) -> ThreadEpi } } -pub(super) fn map_core_role_result_role_id( +pub fn map_core_role_result_role_id( role_id: ThreadEpiphanyRoleId, ) -> EpiphanyRoleResultRoleId { match role_id { @@ -151,7 +151,7 @@ fn map_protocol_role_self_persistence_review( } } -pub(super) fn render_epiphany_role_result_note( +pub fn render_epiphany_role_result_note( role_id: ThreadEpiphanyRoleId, status: ThreadEpiphanyRoleResultStatus, finding: Option<&ThreadEpiphanyRoleFinding>, @@ -240,7 +240,7 @@ fn render_epiphany_self_persistence_note( } } -pub(super) fn render_epiphany_reorient_result_note( +pub fn render_epiphany_reorient_result_note( status: ThreadEpiphanyReorientResultStatus, finding: Option<&ThreadEpiphanyReorientFinding>, item_error: Option<&str>, diff --git a/vendor/codex/codex-rs/app-server/src/epiphany_retrieve.rs b/epiphany-codex-bridge/src/retrieve.rs similarity index 96% rename from vendor/codex/codex-rs/app-server/src/epiphany_retrieve.rs rename to epiphany-codex-bridge/src/retrieve.rs index 317a7c33..6cdf3fec 100644 --- a/vendor/codex/codex-rs/app-server/src/epiphany_retrieve.rs +++ b/epiphany-codex-bridge/src/retrieve.rs @@ -9,7 +9,7 @@ use codex_core::EpiphanyRetrieveResultKind as CoreEpiphanyRetrieveResultKind; use codex_protocol::protocol::EpiphanyRetrievalState; use codex_utils_absolute_path::AbsolutePathBuf; -pub(super) fn map_epiphany_retrieve_response( +pub fn map_epiphany_retrieve_response( response: CoreEpiphanyRetrieveResponse, ) -> anyhow::Result { Ok(ThreadEpiphanyRetrieveResponse { @@ -23,7 +23,7 @@ pub(super) fn map_epiphany_retrieve_response( }) } -pub(super) fn map_epiphany_retrieve_index_summary( +pub fn map_epiphany_retrieve_index_summary( summary: EpiphanyRetrievalState, ) -> anyhow::Result { Ok(ThreadEpiphanyRetrieveIndexSummary { diff --git a/vendor/codex/codex-rs/app-server/src/epiphany_scene.rs b/epiphany-codex-bridge/src/scene.rs similarity index 97% rename from vendor/codex/codex-rs/app-server/src/epiphany_scene.rs rename to epiphany-codex-bridge/src/scene.rs index 3a7411a4..3e9fa8a5 100644 --- a/vendor/codex/codex-rs/app-server/src/epiphany_scene.rs +++ b/epiphany-codex-bridge/src/scene.rs @@ -26,16 +26,15 @@ use epiphany_core::EpiphanySceneStatusCount as CoreEpiphanySceneStatusCount; use epiphany_core::EpiphanySceneSubgoal as CoreEpiphanySceneSubgoal; use epiphany_core::derive_scene; -use crate::epiphany_launch::EPIPHANY_REORIENT_LAUNCH_BINDING_ID; - -pub(super) fn map_epiphany_scene( +pub fn map_epiphany_scene( state: Option<&EpiphanyThreadState>, loaded: bool, + reorient_binding_id: &str, ) -> ThreadEpiphanyScene { map_core_epiphany_scene(derive_scene(EpiphanySceneInput { state, loaded, - reorient_binding_id: EPIPHANY_REORIENT_LAUNCH_BINDING_ID, + reorient_binding_id, })) } @@ -78,7 +77,7 @@ fn map_core_epiphany_scene(scene: CoreEpiphanyScene) -> ThreadEpiphanyScene { } } -pub(super) fn map_core_epiphany_scene_action( +pub fn map_core_epiphany_scene_action( action: CoreEpiphanySceneAction, ) -> ThreadEpiphanySceneAction { match action { diff --git a/notes/fresh-workspace-handoff.md b/notes/fresh-workspace-handoff.md index 55ce82a6..34278e41 100644 --- a/notes/fresh-workspace-handoff.md +++ b/notes/fresh-workspace-handoff.md @@ -462,19 +462,32 @@ The seventeenth cut moved live-state hydration, state-patch conversion, reviewability checks, and rollout-state loading into `vendor/codex/codex-rs/app-server/src/codex_message_processor/epiphany_state_helpers.rs`, taking the processor to about 10,433 lines. +The eighteenth cut stopped pretending that "less code in the processor" was the +same as "less Epiphany in vendored Codex." A new outside-vendor crate, +`epiphany-codex-bridge`, now owns the Codex-facing Epiphany adapters for scene, +jobs, context/planning/graph query, retrieval, result projection, +launch/prompt doctrine, pressure/pre-compaction rendering, +freshness/reorientation projection, CRRC/coordinator/role-board projection, and +acceptance/evidence signal helpers. The specialist prompt TOML moved with the +launch spine. Vendored app-server now retains only `epiphany_invalidation.rs` +as a root Epiphany module because watcher lifecycle is still app-server +machinery. This pass removed roughly 3.3k lines of Epiphany-owned adapter/prompt +code from `vendor/codex`, but `codex_message_processor.rs` is still about +10,445 lines and still owns route dispatch, mutation orchestration, +runtime-result loading, state hydration, and child modules with parent +visibility. 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 intent/result/receipt documents internally and normal MCP JSON-RPC externally. Continue with the actual whale-carcass cut: replace child-module parent -visibility with explicit typed service boundaries and move remaining Epiphany -prompt/state/runtime helpers out of -`codex_message_processor.rs` into Epiphany-owned app-server modules, moving -logic further into `epiphany-core` whenever it owns real policy. Success is a -visibly smaller `codex_message_processor.rs`, not merely nicer payload names. Do -not resume Rider, Unity, Aquarium, Face, dogfood, planning, app, skill, -marketplace, or bridge expansion until this organ is being cut cleanly. +visibility with explicit typed bridge/service calls, then move route-independent +state/runtime helpers out of `codex_message_processor.rs`. Success is a visibly +smaller processor and less mutation authority in Codex, not merely nicer payload +names or another adapter reliquary. Do not resume Rider, Unity, Aquarium, Face, +dogfood, planning, app, skill, marketplace, or bridge expansion until this organ +is being cut cleanly. The Phase 6 freshness slice is landed. It exposes read-only `thread/epiphany/freshness` from live retrieval summaries plus graph diff --git a/state/ledgers.msgpack b/state/ledgers.msgpack index 7e7ced5b314ad331c348542f9c644aecfad80a9a..1d8f5e3b02046a5f9fb875c0e61afc4fce0b38d7 100644 GIT binary patch delta 260 zcmYL^u}T9$6h#>c_ExqJLKKCGlZ{$LJINndS^3;~CWD)K!_3QWQYqvI1i^fVBG{y{ zu(A<5i}Zd*f-BhHd(OSjpN-{L5{zV z2=v#}`7iA%Iy)f9BMO~Boms0e1f3|Brxd|+1vf+?0sCUQ2A5bki{jV=CWy@Pzoynh dHFO2d-*#1dyM6bPne14bBi-qqoBEr%SOFYrU8Mj3 delta 49 zcmcb6iDlCTmI=yC>OVHBPGe*|(!7Up`yNKd1U0dSEk*`LX1WHZx`xIf1_oB9=2j+_ FQ2^9J5DfqT diff --git a/state/map.yaml b/state/map.yaml index 5b1ee487..d7c7de91 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 seventeen real ownership 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`, retrieve projection moved into `vendor/codex/codex-rs/app-server/src/epiphany_retrieve.rs`, pressure/pre-compaction checkpoint projection moved into `vendor/codex/codex-rs/app-server/src/epiphany_pressure.rs`, CRRC/coordinator/role-board projection plus acceptance/evidence signal helpers moved into `vendor/codex/codex-rs/app-server/src/epiphany_coordinator.rs`, the Epiphany JSON-RPC route-handler cluster moved under `vendor/codex/codex-rs/app-server/src/codex_message_processor/`, that cluster split into read/proposal routes versus mutation/launch/accept/index routes, mutation support helpers moved into `epiphany_mutation_routes.rs`, runtime-spine result snapshot/adaptation helpers moved into `epiphany_runtime_results.rs`, coordinator automation/pre-compaction intervention orchestration moved into `epiphany_automation.rs`, state hydration/patch helpers moved into `epiphany_state_helpers.rs`, and the old processor test tail moved into `processor_tests.rs`. The processor is down from about 21,263 lines to 10,433 lines. This is progress, not absolution: the route/automation modules still have parent-internal visibility and mutation authority still lives in the Codex adapter layer. 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: replace child-module parent visibility with explicit typed service boundaries and keep moving remaining Epiphany imports/dispatch out of `codex_message_processor.rs` where they do not belong. Success metric remains a visibly smaller processor and clearer ownership, not merely typed payloads. + summary: The Codex starvation pass has five typing receipts, seventeen processor cuts, and now a real physical extraction: `epiphany-codex-bridge` lives outside `vendor/codex` and owns the Codex-facing Epiphany adapters for scene, jobs, context/planning/graph query, retrieval, result projection, launch/prompt doctrine, pressure/pre-compaction rendering, freshness/reorientation projection, CRRC/coordinator/role-board projection, and acceptance/evidence signal helpers. Vendored app-server now retains only `epiphany_invalidation.rs` as a root Epiphany module because watcher lifecycle is still app-server machinery; `codex_message_processor.rs` still contains route dispatch, mutation orchestration, runtime-result loading, state hydration, and child modules with parent visibility. The processor is about 10,445 lines after adding the watcher DTO bridge, but vendored Codex lost roughly 3.3k lines of Epiphany adapter/prompt ownership in this pass. This is progress, not absolution: the bridge is still Codex-facing compatibility, not the final CultNet runtime, and route/mutation authority still lives too close to the Codex processor. 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 Codex starvation by turning the `codex_message_processor` child route modules into explicit bridge/service calls, then move route-independent state/runtime helpers out of the processor. The next measurable wound is parent-internal `use super::*` and mutation orchestration inside the Codex processor, not app/skill/marketplace expansion. diff --git a/vendor/codex/codex-rs/app-server/Cargo.toml b/vendor/codex/codex-rs/app-server/Cargo.toml index ac387938..91b6979b 100644 --- a/vendor/codex/codex-rs/app-server/Cargo.toml +++ b/vendor/codex/codex-rs/app-server/Cargo.toml @@ -64,6 +64,7 @@ codex-utils-json-to-toml = { workspace = true } codex-utils-rustls-provider = { workspace = true } chrono = { workspace = true } epiphany-core = { path = "../../../../epiphany-core" } +epiphany-codex-bridge = { path = "../../../../epiphany-codex-bridge" } clap = { workspace = true, features = ["derive"] } constant_time_eq = { workspace = true } futures = { workspace = true } 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 89320c1b..4263c24a 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 @@ -35,65 +35,8 @@ use crate::bespoke_event_handling::maybe_emit_hook_prompt_item_completed; use crate::command_exec::CommandExecManager; use crate::command_exec::StartCommandExecParams; use crate::config_manager::ConfigManager; -use crate::epiphany_context::map_epiphany_context; -use crate::epiphany_context::map_epiphany_graph_query; -use crate::epiphany_context::map_epiphany_planning; -use crate::epiphany_coordinator::EpiphanyCoordinatorAutomationAction; -use crate::epiphany_coordinator::EpiphanyCoordinatorDecision; -use crate::epiphany_coordinator::epiphany_reorient_finding_already_accepted; -use crate::epiphany_coordinator::epiphany_role_finding_accepted_evidence_id; -use crate::epiphany_coordinator::epiphany_role_finding_already_accepted; -use crate::epiphany_coordinator::epiphany_role_finding_cites_implementation_evidence; -use crate::epiphany_coordinator::epiphany_verification_finding_allows_implementation; -use crate::epiphany_coordinator::epiphany_verification_finding_covers_current_modeling; -use crate::epiphany_coordinator::epiphany_verification_finding_needs_evidence; -use crate::epiphany_coordinator::implementation_evidence_after_role_finding; -use crate::epiphany_coordinator::map_epiphany_coordinator; -use crate::epiphany_coordinator::map_epiphany_coordinator_automation_action; -use crate::epiphany_coordinator::map_epiphany_crrc_recommendation; -use crate::epiphany_coordinator::map_epiphany_roles; -use crate::epiphany_coordinator::render_epiphany_roles_note; -use crate::epiphany_coordinator::role_finding_accepted_after; -use crate::epiphany_coordinator::select_epiphany_coordinator_automation_action; use crate::epiphany_invalidation::EpiphanyInvalidationManager; use crate::epiphany_invalidation::EpiphanyInvalidationSnapshot; -use crate::epiphany_jobs::epiphany_blocked_state_job; -use crate::epiphany_jobs::map_core_epiphany_job_kind; -use crate::epiphany_jobs::map_epiphany_jobs; -use crate::epiphany_launch::EPIPHANY_IMAGINATION_OWNER_ROLE; -use crate::epiphany_launch::EPIPHANY_IMAGINATION_ROLE_BINDING_ID; -use crate::epiphany_launch::EPIPHANY_MODELING_OWNER_ROLE; -use crate::epiphany_launch::EPIPHANY_MODELING_ROLE_BINDING_ID; -use crate::epiphany_launch::EPIPHANY_REORIENT_LAUNCH_BINDING_ID; -use crate::epiphany_launch::EPIPHANY_REORIENT_OWNER_ROLE; -use crate::epiphany_launch::EPIPHANY_VERIFICATION_OWNER_ROLE; -use crate::epiphany_launch::EPIPHANY_VERIFICATION_ROLE_BINDING_ID; -use crate::epiphany_launch::build_epiphany_reorient_launch_instruction; -use crate::epiphany_launch::build_epiphany_reorient_launch_request; -use crate::epiphany_launch::build_epiphany_role_launch_request; -use crate::epiphany_launch::epiphany_reorient_launch_output_schema; -use crate::epiphany_launch::epiphany_role_binding_id; -use crate::epiphany_launch::epiphany_role_label; -use crate::epiphany_launch::epiphany_role_launch_output_schema; -use crate::epiphany_launch::epiphany_specialist_prompt_config; -use crate::epiphany_launch::map_core_worker_launch_document; -use crate::epiphany_launch::render_epiphany_coordinator_note; -use crate::epiphany_pressure::map_epiphany_pressure; -use crate::epiphany_pressure::render_epiphany_pre_compaction_checkpoint_intervention; -use crate::epiphany_pressure::should_run_epiphany_pre_compaction_checkpoint_intervention; -use crate::epiphany_reorient::map_epiphany_freshness; -use crate::epiphany_reorient::map_epiphany_reorient; -use crate::epiphany_results::map_core_role_result_role_id; -use crate::epiphany_results::map_epiphany_reorient_finding; -use crate::epiphany_results::map_epiphany_role_finding; -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; use crate::error_code::INTERNAL_ERROR_CODE; use crate::error_code::INVALID_PARAMS_ERROR_CODE; @@ -559,6 +502,64 @@ use codex_thread_store::ThreadStoreError; use codex_thread_store::UpdateThreadMetadataParams as StoreUpdateThreadMetadataParams; use codex_utils_absolute_path::AbsolutePathBuf; use codex_utils_pty::DEFAULT_OUTPUT_BYTES_CAP; +use epiphany_codex_bridge::context::map_epiphany_context; +use epiphany_codex_bridge::context::map_epiphany_graph_query; +use epiphany_codex_bridge::context::map_epiphany_planning; +use epiphany_codex_bridge::coordinator::EpiphanyCoordinatorAutomationAction; +use epiphany_codex_bridge::coordinator::EpiphanyCoordinatorDecision; +use epiphany_codex_bridge::coordinator::epiphany_reorient_finding_already_accepted; +use epiphany_codex_bridge::coordinator::epiphany_role_finding_accepted_evidence_id; +use epiphany_codex_bridge::coordinator::epiphany_role_finding_already_accepted; +use epiphany_codex_bridge::coordinator::epiphany_role_finding_cites_implementation_evidence; +use epiphany_codex_bridge::coordinator::epiphany_verification_finding_allows_implementation; +use epiphany_codex_bridge::coordinator::epiphany_verification_finding_covers_current_modeling; +use epiphany_codex_bridge::coordinator::epiphany_verification_finding_needs_evidence; +use epiphany_codex_bridge::coordinator::implementation_evidence_after_role_finding; +use epiphany_codex_bridge::coordinator::map_epiphany_coordinator; +use epiphany_codex_bridge::coordinator::map_epiphany_coordinator_automation_action; +use epiphany_codex_bridge::coordinator::map_epiphany_crrc_recommendation; +use epiphany_codex_bridge::coordinator::map_epiphany_roles; +use epiphany_codex_bridge::coordinator::render_epiphany_roles_note; +use epiphany_codex_bridge::coordinator::role_finding_accepted_after; +use epiphany_codex_bridge::coordinator::select_epiphany_coordinator_automation_action; +use epiphany_codex_bridge::jobs::epiphany_blocked_state_job; +use epiphany_codex_bridge::jobs::map_core_epiphany_job_kind; +use epiphany_codex_bridge::jobs::map_epiphany_jobs; +use epiphany_codex_bridge::launch::EPIPHANY_IMAGINATION_OWNER_ROLE; +use epiphany_codex_bridge::launch::EPIPHANY_IMAGINATION_ROLE_BINDING_ID; +use epiphany_codex_bridge::launch::EPIPHANY_MODELING_OWNER_ROLE; +use epiphany_codex_bridge::launch::EPIPHANY_MODELING_ROLE_BINDING_ID; +use epiphany_codex_bridge::launch::EPIPHANY_REORIENT_LAUNCH_BINDING_ID; +use epiphany_codex_bridge::launch::EPIPHANY_REORIENT_OWNER_ROLE; +use epiphany_codex_bridge::launch::EPIPHANY_VERIFICATION_OWNER_ROLE; +use epiphany_codex_bridge::launch::EPIPHANY_VERIFICATION_ROLE_BINDING_ID; +use epiphany_codex_bridge::launch::build_epiphany_reorient_launch_instruction; +use epiphany_codex_bridge::launch::build_epiphany_reorient_launch_request; +use epiphany_codex_bridge::launch::build_epiphany_role_launch_request; +use epiphany_codex_bridge::launch::epiphany_reorient_launch_output_schema; +use epiphany_codex_bridge::launch::epiphany_role_binding_id; +use epiphany_codex_bridge::launch::epiphany_role_label; +use epiphany_codex_bridge::launch::epiphany_role_launch_output_schema; +use epiphany_codex_bridge::launch::epiphany_specialist_prompt_config; +use epiphany_codex_bridge::launch::map_core_worker_launch_document; +use epiphany_codex_bridge::launch::render_epiphany_coordinator_note; +use epiphany_codex_bridge::pressure::map_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::reorient::EpiphanyFreshnessWatcherSnapshot; +use epiphany_codex_bridge::reorient::map_epiphany_freshness; +use epiphany_codex_bridge::reorient::map_epiphany_reorient; +use epiphany_codex_bridge::results::map_core_role_result_role_id; +use epiphany_codex_bridge::results::map_epiphany_reorient_finding; +use epiphany_codex_bridge::results::map_epiphany_role_finding; +use epiphany_codex_bridge::results::map_protocol_reorient_finding; +use epiphany_codex_bridge::results::map_protocol_role_finding; +use epiphany_codex_bridge::results::render_epiphany_reorient_result_note; +use epiphany_codex_bridge::results::render_epiphany_role_result_note; +use epiphany_codex_bridge::retrieve::map_epiphany_retrieve_index_summary; +use epiphany_codex_bridge::retrieve::map_epiphany_retrieve_response; +use epiphany_codex_bridge::scene::map_core_epiphany_scene_action; +use epiphany_codex_bridge::scene::map_epiphany_scene; use epiphany_core::EpiphanyReorientAcceptanceFinding; use epiphany_core::EpiphanyRoleAcceptanceFinding; use epiphany_core::EpiphanyRoleStatePatchDocument; @@ -597,6 +598,17 @@ use tracing::info; use tracing::warn; use uuid::Uuid; +fn epiphany_freshness_watcher_snapshot( + snapshot: &EpiphanyInvalidationSnapshot, +) -> EpiphanyFreshnessWatcherSnapshot<'_> { + EpiphanyFreshnessWatcherSnapshot { + available: snapshot.available, + workspace_root: snapshot.workspace_root.as_ref().map(|path| path.as_path()), + observed_at_unix_seconds: snapshot.observed_at_unix_seconds, + changed_paths: snapshot.changed_paths.as_slice(), + } +} + #[cfg(test)] use codex_app_server_protocol::ServerRequest; 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 a6c722b0..bc97ec0d 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 @@ -26,7 +26,7 @@ pub(crate) async fn maybe_run_epiphany_coordinator_automation_for_turn_boundary( let (_state_revision, retrieval, graph, watcher) = map_epiphany_freshness( Some(&state), Some(&retrieval_override), - Some(&watcher_snapshot), + Some(epiphany_freshness_watcher_snapshot(&watcher_snapshot)), ); let pressure = map_epiphany_pressure(token_usage_info.as_ref()); let (state_status, reorient_decision) = 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 590f6e4e..4055d84d 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 @@ -437,7 +437,7 @@ impl CodexMessageProcessor { let (state_revision, retrieval, graph, watcher) = map_epiphany_freshness( thread.epiphany_state.as_ref(), Some(&retrieval_override), - Some(&watcher_snapshot), + Some(epiphany_freshness_watcher_snapshot(&watcher_snapshot)), ); let pressure = map_epiphany_pressure(token_usage_info.as_ref()); let (state_status, decision) = map_epiphany_reorient( 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 38363bd7..1d042de3 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 @@ -104,7 +104,9 @@ impl CodexMessageProcessor { map_epiphany_freshness( thread.epiphany_state.as_ref(), retrieval_override.as_ref(), - watcher_snapshot.as_ref(), + watcher_snapshot + .as_ref() + .map(epiphany_freshness_watcher_snapshot), ) }); let (state_revision, reorient_state_status, reorient_decision) = @@ -361,9 +363,13 @@ impl CodexMessageProcessor { let response = ThreadEpiphanyViewResponse { thread_id: thread_id.clone(), - scene: lenses - .contains(&ThreadEpiphanyViewLens::Scene) - .then(|| map_epiphany_scene(thread.epiphany_state.as_ref(), loaded)), + scene: lenses.contains(&ThreadEpiphanyViewLens::Scene).then(|| { + map_epiphany_scene( + thread.epiphany_state.as_ref(), + loaded, + EPIPHANY_REORIENT_LAUNCH_BINDING_ID, + ) + }), jobs: if lenses.contains(&ThreadEpiphanyViewLens::Jobs) { jobs.clone() } else { @@ -634,7 +640,9 @@ impl CodexMessageProcessor { let (state_revision, retrieval, graph, watcher) = map_epiphany_freshness( thread.epiphany_state.as_ref(), retrieval_override.as_ref(), - watcher_snapshot.as_ref(), + watcher_snapshot + .as_ref() + .map(epiphany_freshness_watcher_snapshot), ); let response = ThreadEpiphanyFreshnessResponse { thread_id, diff --git a/vendor/codex/codex-rs/app-server/src/codex_message_processor/processor_tests.rs b/vendor/codex/codex-rs/app-server/src/codex_message_processor/processor_tests.rs index 57d25473..308e53e9 100644 --- a/vendor/codex/codex-rs/app-server/src/codex_message_processor/processor_tests.rs +++ b/vendor/codex/codex-rs/app-server/src/codex_message_processor/processor_tests.rs @@ -1163,6 +1163,7 @@ fn map_epiphany_scene_projects_client_reflection_without_mutation_shape() { ..Default::default() }), true, + EPIPHANY_REORIENT_LAUNCH_BINDING_ID, ); assert_eq!(scene.state_status, ThreadEpiphanySceneStateStatus::Ready); @@ -1230,7 +1231,7 @@ fn map_epiphany_scene_projects_client_reflection_without_mutation_shape() { #[test] fn map_epiphany_scene_handles_missing_state_without_write_actions() { - let scene = map_epiphany_scene(None, false); + let scene = map_epiphany_scene(None, false, EPIPHANY_REORIENT_LAUNCH_BINDING_ID); assert_eq!(scene.state_status, ThreadEpiphanySceneStateStatus::Missing); assert_eq!(scene.source, ThreadEpiphanySceneSource::Stored); @@ -1323,8 +1324,11 @@ fn map_epiphany_freshness_marks_graph_and_retrieval_stale() { changed_paths: vec![PathBuf::from("src/router.rs")], }; - let (state_revision, retrieval, graph, watcher) = - map_epiphany_freshness(Some(&state), Some(&retrieval), Some(&watcher_snapshot)); + let (state_revision, retrieval, graph, watcher) = map_epiphany_freshness( + Some(&state), + Some(&retrieval), + Some(epiphany_freshness_watcher_snapshot(&watcher_snapshot)), + ); assert_eq!(state_revision, Some(7)); assert_eq!( @@ -1359,7 +1363,11 @@ fn map_epiphany_freshness_reports_clean_watcher_when_no_changes_were_seen() { changed_paths: Vec::new(), }; - let (_, _, _, watcher) = map_epiphany_freshness(None, None, Some(&watcher_snapshot)); + let (_, _, _, watcher) = map_epiphany_freshness( + None, + None, + Some(epiphany_freshness_watcher_snapshot(&watcher_snapshot)), + ); assert_eq!(watcher.status, ThreadEpiphanyInvalidationStatus::Clean); assert_eq!(watcher.changed_path_count, 0); @@ -1400,7 +1408,11 @@ fn map_epiphany_freshness_reports_unmatched_changed_paths_without_inventing_node changed_paths: vec![PathBuf::from("src/other.rs")], }; - let (_, _, _, watcher) = map_epiphany_freshness(Some(&state), None, Some(&watcher_snapshot)); + let (_, _, _, watcher) = map_epiphany_freshness( + Some(&state), + None, + Some(epiphany_freshness_watcher_snapshot(&watcher_snapshot)), + ); assert_eq!(watcher.status, ThreadEpiphanyInvalidationStatus::Changed); assert!(watcher.graph_node_ids.is_empty()); @@ -1662,7 +1674,7 @@ fn map_epiphany_scene_latest_records_preserve_newest_first_order() { ..Default::default() }; - let scene = map_epiphany_scene(Some(&state), true); + let scene = map_epiphany_scene(Some(&state), true, EPIPHANY_REORIENT_LAUNCH_BINDING_ID); let observation_ids: Vec<_> = scene .observations .latest @@ -1699,7 +1711,7 @@ fn map_epiphany_scene_exposes_reorient_result_when_binding_exists() { ..Default::default() }; - let scene = map_epiphany_scene(Some(&state), true); + let scene = map_epiphany_scene(Some(&state), true, EPIPHANY_REORIENT_LAUNCH_BINDING_ID); assert!( scene diff --git a/vendor/codex/codex-rs/app-server/src/lib.rs b/vendor/codex/codex-rs/app-server/src/lib.rs index 8437bc6d..0e972ffa 100644 --- a/vendor/codex/codex-rs/app-server/src/lib.rs +++ b/vendor/codex/codex-rs/app-server/src/lib.rs @@ -75,16 +75,7 @@ mod config_manager; mod config_manager_service; mod device_key_api; mod dynamic_tools; -mod epiphany_context; -mod epiphany_coordinator; mod epiphany_invalidation; -mod epiphany_jobs; -mod epiphany_launch; -mod epiphany_pressure; -mod epiphany_reorient; -mod epiphany_results; -mod epiphany_retrieve; -mod epiphany_scene; mod error_code; mod external_agent_config_api; mod filters;