diff --git a/epiphany-codex-bridge/src/coordinator.rs b/epiphany-codex-bridge/src/coordinator.rs index abfa8fa8..6fd7ed4a 100644 --- a/epiphany-codex-bridge/src/coordinator.rs +++ b/epiphany-codex-bridge/src/coordinator.rs @@ -45,6 +45,7 @@ use epiphany_core::EpiphanyRoleBoardJobStatus; use epiphany_core::EpiphanyRoleBoardLane; use epiphany_core::EpiphanyRoleBoardPlanningSummary; use epiphany_core::EpiphanyRoleFindingInterpretation as CoreEpiphanyRoleFinding; +use epiphany_core::EpiphanyRoleResultRoleId; use epiphany_core::EpiphanyTokenUsageSnapshot; use epiphany_core::coordinator_automation_action; use epiphany_core::derive_role_board; @@ -294,7 +295,7 @@ pub async fn derive_epiphany_coordinator_status( let snapshot = load_core_epiphany_role_result_snapshot( state, runtime_store_path, - ThreadEpiphanyRoleId::Modeling, + EpiphanyRoleResultRoleId::Modeling, EPIPHANY_MODELING_ROLE_BINDING_ID, ) .await; @@ -318,7 +319,7 @@ pub async fn derive_epiphany_coordinator_status( let snapshot = load_core_epiphany_role_result_snapshot( state, runtime_store_path, - ThreadEpiphanyRoleId::Verification, + EpiphanyRoleResultRoleId::Verification, EPIPHANY_VERIFICATION_ROLE_BINDING_ID, ) .await; diff --git a/epiphany-codex-bridge/src/launch.rs b/epiphany-codex-bridge/src/launch.rs index c42f7a34..26459fa9 100644 --- a/epiphany-codex-bridge/src/launch.rs +++ b/epiphany-codex-bridge/src/launch.rs @@ -3,7 +3,6 @@ use std::sync::OnceLock; use codex_app_server_protocol::ThreadEpiphanyPressureLevel; use codex_app_server_protocol::ThreadEpiphanyReorientWorkerLaunchDocument; -use codex_app_server_protocol::ThreadEpiphanyRoleId; use codex_app_server_protocol::ThreadEpiphanyRoleWorkerLaunchDocument; use codex_app_server_protocol::ThreadEpiphanyWorkerLaunchDocument; use epiphany_core::EpiphanyJobLaunchRequest; @@ -13,6 +12,7 @@ use epiphany_core::EpiphanyReorientFreshnessStatus as CoreEpiphanyReorientFreshn use epiphany_core::EpiphanyReorientPressureLevel as CoreEpiphanyReorientPressureLevel; use epiphany_core::EpiphanyReorientReason as CoreEpiphanyReorientReason; use epiphany_core::EpiphanyReorientWorkerLaunchDocument; +use epiphany_core::EpiphanyRoleResultRoleId; use epiphany_core::EpiphanyRoleWorkerLaunchDocument; use epiphany_core::EpiphanyWorkerLaunchDocument; use epiphany_state_model::EpiphanyInvestigationCheckpoint; @@ -29,59 +29,61 @@ 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 fn epiphany_role_binding_id(role_id: ThreadEpiphanyRoleId) -> Result<&'static str, String> { +pub fn epiphany_role_binding_id(role_id: EpiphanyRoleResultRoleId) -> Result<&'static str, String> { match role_id { - ThreadEpiphanyRoleId::Imagination => Ok(EPIPHANY_IMAGINATION_ROLE_BINDING_ID), - ThreadEpiphanyRoleId::Modeling => Ok(EPIPHANY_MODELING_ROLE_BINDING_ID), - ThreadEpiphanyRoleId::Verification => Ok(EPIPHANY_VERIFICATION_ROLE_BINDING_ID), - ThreadEpiphanyRoleId::Implementation => Err( + EpiphanyRoleResultRoleId::Imagination => Ok(EPIPHANY_IMAGINATION_ROLE_BINDING_ID), + EpiphanyRoleResultRoleId::Modeling => Ok(EPIPHANY_MODELING_ROLE_BINDING_ID), + EpiphanyRoleResultRoleId::Verification => Ok(EPIPHANY_VERIFICATION_ROLE_BINDING_ID), + EpiphanyRoleResultRoleId::Implementation => Err( "implementation is owned by the main coding agent; no role specialist launch template exists" .to_string(), ), - ThreadEpiphanyRoleId::Reorientation => Err( + EpiphanyRoleResultRoleId::Reorientation => Err( "reorientation uses thread/epiphany/reorientLaunch and thread/epiphany/reorientResult" .to_string(), ), } } -pub fn epiphany_role_owner(role_id: ThreadEpiphanyRoleId) -> Result<&'static str, String> { +pub fn epiphany_role_owner(role_id: EpiphanyRoleResultRoleId) -> Result<&'static str, String> { match role_id { - ThreadEpiphanyRoleId::Imagination => Ok(EPIPHANY_IMAGINATION_OWNER_ROLE), - ThreadEpiphanyRoleId::Modeling => Ok(EPIPHANY_MODELING_OWNER_ROLE), - ThreadEpiphanyRoleId::Verification => Ok(EPIPHANY_VERIFICATION_OWNER_ROLE), - ThreadEpiphanyRoleId::Implementation | ThreadEpiphanyRoleId::Reorientation => { + EpiphanyRoleResultRoleId::Imagination => Ok(EPIPHANY_IMAGINATION_OWNER_ROLE), + EpiphanyRoleResultRoleId::Modeling => Ok(EPIPHANY_MODELING_OWNER_ROLE), + EpiphanyRoleResultRoleId::Verification => Ok(EPIPHANY_VERIFICATION_OWNER_ROLE), + EpiphanyRoleResultRoleId::Implementation | EpiphanyRoleResultRoleId::Reorientation => { Err(epiphany_role_binding_id(role_id).unwrap_err()) } } } -pub fn epiphany_role_label(role_id: ThreadEpiphanyRoleId) -> &'static str { +pub fn epiphany_role_label(role_id: EpiphanyRoleResultRoleId) -> &'static str { match role_id { - ThreadEpiphanyRoleId::Implementation => "implementation", - ThreadEpiphanyRoleId::Imagination => "imagination", - ThreadEpiphanyRoleId::Modeling => "modeling", - ThreadEpiphanyRoleId::Verification => "verification", - ThreadEpiphanyRoleId::Reorientation => "reorientation", + EpiphanyRoleResultRoleId::Implementation => "implementation", + EpiphanyRoleResultRoleId::Imagination => "imagination", + EpiphanyRoleResultRoleId::Modeling => "modeling", + EpiphanyRoleResultRoleId::Verification => "verification", + EpiphanyRoleResultRoleId::Reorientation => "reorientation", } } -pub fn epiphany_role_launch_output_schema(role_id: ThreadEpiphanyRoleId) -> serde_json::Value { +pub fn epiphany_role_launch_output_schema(role_id: EpiphanyRoleResultRoleId) -> serde_json::Value { let verdict_enum = match role_id { - ThreadEpiphanyRoleId::Imagination => { + EpiphanyRoleResultRoleId::Imagination => { vec!["draft-ready", "planning-update-needed", "blocked"] } - ThreadEpiphanyRoleId::Modeling => { + EpiphanyRoleResultRoleId::Modeling => { vec![ "checkpoint-ready", "checkpoint-update-needed", "regather-needed", ] } - ThreadEpiphanyRoleId::Verification => { + EpiphanyRoleResultRoleId::Verification => { vec!["pass", "needs-review", "needs-evidence", "fail"] } - ThreadEpiphanyRoleId::Implementation | ThreadEpiphanyRoleId::Reorientation => vec![], + EpiphanyRoleResultRoleId::Implementation | EpiphanyRoleResultRoleId::Reorientation => { + vec![] + } }; let mut properties = serde_json::json!({ "roleId": { @@ -193,7 +195,7 @@ pub fn epiphany_role_launch_output_schema(role_id: ThreadEpiphanyRoleId) -> serd "nextSafeMove", "filesInspected", ]; - if role_id == ThreadEpiphanyRoleId::Imagination { + if role_id == EpiphanyRoleResultRoleId::Imagination { if let Some(map) = properties.as_object_mut() { map.insert( "statePatch".to_string(), @@ -230,7 +232,7 @@ pub fn epiphany_role_launch_output_schema(role_id: ThreadEpiphanyRoleId) -> serd ); } required.push("statePatch"); - } else if role_id == ThreadEpiphanyRoleId::Modeling { + } else if role_id == EpiphanyRoleResultRoleId::Modeling { if let Some(map) = properties.as_object_mut() { map.insert( "statePatch".to_string(), @@ -389,7 +391,7 @@ pub fn epiphany_agent_prompt_with_memory(body: &str) -> String { pub fn build_epiphany_role_launch_request( thread_id: &str, - role_id: ThreadEpiphanyRoleId, + role_id: EpiphanyRoleResultRoleId, expected_revision: Option, max_runtime_seconds: Option, state: &EpiphanyThreadState, @@ -399,22 +401,22 @@ pub fn build_epiphany_role_launch_request( let linked_subgoal_ids = epiphany_active_subgoal_ids(Some(state)); let linked_graph_node_ids = epiphany_active_graph_node_ids(Some(state)); let (scope, authority_scope, instruction) = match role_id { - ThreadEpiphanyRoleId::Imagination => ( + EpiphanyRoleResultRoleId::Imagination => ( "role-scoped planning synthesis", "epiphany.role.imagination", build_epiphany_role_launch_instruction(role_id), ), - ThreadEpiphanyRoleId::Modeling => ( + EpiphanyRoleResultRoleId::Modeling => ( "role-scoped modeling/checkpoint maintenance", "epiphany.role.modeling", build_epiphany_role_launch_instruction(role_id), ), - ThreadEpiphanyRoleId::Verification => ( + EpiphanyRoleResultRoleId::Verification => ( "role-scoped verification/review", "epiphany.role.verification", build_epiphany_role_launch_instruction(role_id), ), - ThreadEpiphanyRoleId::Implementation | ThreadEpiphanyRoleId::Reorientation => { + EpiphanyRoleResultRoleId::Implementation | EpiphanyRoleResultRoleId::Reorientation => { return Err(epiphany_role_binding_id(role_id).unwrap_err()); } }; @@ -460,13 +462,13 @@ pub fn build_epiphany_role_launch_request( }) } -fn build_epiphany_role_launch_instruction(role_id: ThreadEpiphanyRoleId) -> String { +fn build_epiphany_role_launch_instruction(role_id: EpiphanyRoleResultRoleId) -> String { let prompts = &epiphany_specialist_prompt_config().roles; let body = match role_id { - ThreadEpiphanyRoleId::Imagination => prompts.imagination.as_str(), - ThreadEpiphanyRoleId::Modeling => prompts.modeling.as_str(), - ThreadEpiphanyRoleId::Verification => prompts.verification.as_str(), - ThreadEpiphanyRoleId::Implementation | ThreadEpiphanyRoleId::Reorientation => { + EpiphanyRoleResultRoleId::Imagination => prompts.imagination.as_str(), + EpiphanyRoleResultRoleId::Modeling => prompts.modeling.as_str(), + EpiphanyRoleResultRoleId::Verification => prompts.verification.as_str(), + EpiphanyRoleResultRoleId::Implementation | EpiphanyRoleResultRoleId::Reorientation => { "Unsupported Epiphany role specialist template." } }; @@ -521,7 +523,8 @@ pub fn build_epiphany_reorient_launch_request( .collect(), decision_note: decision.note.clone(), pressure_level: reorient_pressure_level_label(decision.pressure_level).to_string(), - retrieval_status: reorient_freshness_status_label(decision.retrieval_status).to_string(), + retrieval_status: reorient_freshness_status_label(decision.retrieval_status) + .to_string(), graph_status: reorient_freshness_status_label(decision.graph_status).to_string(), watcher_status: reorient_freshness_status_label(decision.watcher_status).to_string(), checkpoint_dirty_paths: decision diff --git a/epiphany-codex-bridge/src/mutation.rs b/epiphany-codex-bridge/src/mutation.rs index 4a61312d..a84df5ea 100644 --- a/epiphany-codex-bridge/src/mutation.rs +++ b/epiphany-codex-bridge/src/mutation.rs @@ -1,4 +1,3 @@ -use codex_app_server_protocol::ThreadEpiphanyRoleId; use codex_app_server_protocol::ThreadEpiphanyStateUpdatedField; use codex_app_server_protocol::ThreadEpiphanyStateUpdatedNotification; use codex_app_server_protocol::ThreadEpiphanyStateUpdatedSource; @@ -7,6 +6,7 @@ use epiphany_core::EpiphanyReorientAcceptanceFinding; use epiphany_core::EpiphanyReorientFindingInterpretation as CoreEpiphanyReorientFinding; use epiphany_core::EpiphanyRoleAcceptanceFinding; use epiphany_core::EpiphanyRoleFindingInterpretation as CoreEpiphanyRoleFinding; +use epiphany_core::EpiphanyRoleResultRoleId; use epiphany_core::EpiphanyRoleStatePatchDocument; use epiphany_core::EpiphanyStateUpdate; use epiphany_core::EpiphanyStateUpdatedField; @@ -16,8 +16,6 @@ use epiphany_core::imagination_role_state_patch_policy_errors; use epiphany_core::modeling_role_state_patch_policy_errors; use epiphany_state_model::EpiphanyInvestigationCheckpoint; -use crate::results::map_core_role_result_role_id; - pub struct RoleAcceptanceUpdate { pub state_update: EpiphanyStateUpdate, pub applied_patch: EpiphanyRoleStatePatchDocument, @@ -192,7 +190,7 @@ pub fn modeling_role_accept_patch_errors(patch: &ThreadEpiphanyUpdatePatch) -> V pub fn build_role_acceptance_update( expected_revision: Option, - role_id: ThreadEpiphanyRoleId, + role_id: EpiphanyRoleResultRoleId, binding_id: &str, finding: &CoreEpiphanyRoleFinding, accepted_evidence_id: String, @@ -200,7 +198,7 @@ pub fn build_role_acceptance_update( accepted_at: String, ) -> Result { let mut core_patch = match role_id { - ThreadEpiphanyRoleId::Imagination => { + EpiphanyRoleResultRoleId::Imagination => { let patch = parse_core_role_finding_state_patch(finding)?; let patch_errors = imagination_role_state_patch_policy_errors(&patch); if !patch_errors.is_empty() { @@ -211,7 +209,7 @@ pub fn build_role_acceptance_update( } patch } - ThreadEpiphanyRoleId::Modeling => { + EpiphanyRoleResultRoleId::Modeling => { let patch = parse_core_role_finding_state_patch(finding)?; let patch_errors = modeling_role_state_patch_policy_errors(&patch); if !patch_errors.is_empty() { @@ -222,8 +220,8 @@ pub fn build_role_acceptance_update( } patch } - ThreadEpiphanyRoleId::Verification => EpiphanyRoleStatePatchDocument::default(), - ThreadEpiphanyRoleId::Implementation | ThreadEpiphanyRoleId::Reorientation => { + EpiphanyRoleResultRoleId::Verification => EpiphanyRoleStatePatchDocument::default(), + EpiphanyRoleResultRoleId::Implementation | EpiphanyRoleResultRoleId::Reorientation => { return Err(format!( "role {:?} cannot be accepted through roleAccept", role_id @@ -239,7 +237,7 @@ pub fn build_role_acceptance_update( let acceptance_bundle = build_role_acceptance_bundle( binding_id, EpiphanyRoleAcceptanceFinding { - role_id: map_core_role_result_role_id(role_id), + role_id, verdict: finding.verdict.clone(), summary: finding.summary.clone(), next_safe_move: finding.next_safe_move.clone(), diff --git a/epiphany-codex-bridge/src/mutation_service.rs b/epiphany-codex-bridge/src/mutation_service.rs index bf64e3f7..58748b2e 100644 --- a/epiphany-codex-bridge/src/mutation_service.rs +++ b/epiphany-codex-bridge/src/mutation_service.rs @@ -4,7 +4,6 @@ use std::path::Path; use std::path::PathBuf; use codex_app_server_protocol::ThreadEpiphanyReorientSource; -use codex_app_server_protocol::ThreadEpiphanyRoleId; use epiphany_core::EpiphanyJobInterruptRequest; use epiphany_core::EpiphanyJobInterruptResult; use epiphany_core::EpiphanyJobLaunchRequest; @@ -15,6 +14,7 @@ use epiphany_core::EpiphanyReorientDecision; use epiphany_core::EpiphanyReorientFindingInterpretation; use epiphany_core::EpiphanyReorientStateStatus; use epiphany_core::EpiphanyRoleFindingInterpretation; +use epiphany_core::EpiphanyRoleResultRoleId; use epiphany_core::EpiphanyRoleStatePatchDocument; use epiphany_core::EpiphanyStateUpdate; use epiphany_core::EpiphanyStateUpdatedField; @@ -369,7 +369,7 @@ pub async fn apply_thread_epiphany_promote( pub async fn apply_thread_epiphany_role_accept( thread: &impl EpiphanyMutationHost, - role_id: ThreadEpiphanyRoleId, + role_id: EpiphanyRoleResultRoleId, expected_revision: Option, binding_id: &str, ) -> BridgeResult { @@ -483,7 +483,7 @@ pub async fn apply_thread_epiphany_reorient_accept( pub async fn launch_thread_epiphany_role( thread: &impl EpiphanyMutationHost, thread_id: &str, - role_id: ThreadEpiphanyRoleId, + role_id: EpiphanyRoleResultRoleId, expected_revision: Option, max_runtime_seconds: Option, ) -> BridgeResult { diff --git a/epiphany-codex-bridge/src/results.rs b/epiphany-codex-bridge/src/results.rs index e2b6b052..c94d6402 100644 --- a/epiphany-codex-bridge/src/results.rs +++ b/epiphany-codex-bridge/src/results.rs @@ -98,6 +98,16 @@ pub fn map_core_role_result_role_id(role_id: ThreadEpiphanyRoleId) -> EpiphanyRo } } +pub fn map_protocol_role_result_role_id(role_id: EpiphanyRoleResultRoleId) -> ThreadEpiphanyRoleId { + match role_id { + EpiphanyRoleResultRoleId::Implementation => ThreadEpiphanyRoleId::Implementation, + EpiphanyRoleResultRoleId::Imagination => ThreadEpiphanyRoleId::Imagination, + EpiphanyRoleResultRoleId::Modeling => ThreadEpiphanyRoleId::Modeling, + EpiphanyRoleResultRoleId::Verification => ThreadEpiphanyRoleId::Verification, + EpiphanyRoleResultRoleId::Reorientation => ThreadEpiphanyRoleId::Reorientation, + } +} + fn map_protocol_role_self_persistence_review( review: CoreEpiphanyRoleSelfPersistenceReview, ) -> ThreadEpiphanyRoleSelfPersistenceReview { diff --git a/epiphany-codex-bridge/src/runtime_results.rs b/epiphany-codex-bridge/src/runtime_results.rs index f093c66f..32e54a72 100644 --- a/epiphany-codex-bridge/src/runtime_results.rs +++ b/epiphany-codex-bridge/src/runtime_results.rs @@ -1,12 +1,12 @@ use std::path::Path; use codex_app_server_protocol::ThreadEpiphanyReorientResultStatus; -use codex_app_server_protocol::ThreadEpiphanyRoleId; use codex_app_server_protocol::ThreadEpiphanyRoleResultStatus; use epiphany_core::EpiphanyCoordinatorRoleResultStatus as CoreEpiphanyCoordinatorRoleResultStatus; use epiphany_core::EpiphanyCrrcResultStatus as CoreEpiphanyCrrcResultStatus; use epiphany_core::EpiphanyReorientFindingInterpretation; use epiphany_core::EpiphanyRoleFindingInterpretation; +use epiphany_core::EpiphanyRoleResultRoleId; use epiphany_core::EpiphanyRuntimeJobSnapshot; use epiphany_core::EpiphanyRuntimeJobStatus; use epiphany_core::interpret_runtime_reorient_worker_result; @@ -19,7 +19,6 @@ use epiphany_state_model::EpiphanyThreadState; use crate::error::EpiphanyBridgeError; use crate::error::Result as BridgeResult; -use crate::results::map_core_role_result_role_id; use crate::results::render_core_reorient_result_note; use crate::results::render_core_role_result_note; @@ -40,9 +39,8 @@ pub struct EpiphanyReorientResultSnapshot { pub fn load_core_epiphany_role_result_from_runtime_spine_job( job_id: &str, runtime_store_path: Option<&Path>, - role_id: ThreadEpiphanyRoleId, + role_id: EpiphanyRoleResultRoleId, ) -> EpiphanyRoleResultSnapshot { - let core_role_id = map_core_role_result_role_id(role_id); let Some(runtime_store_path) = runtime_store_path else { return EpiphanyRoleResultSnapshot { status: CoreEpiphanyCoordinatorRoleResultStatus::Pending, @@ -77,7 +75,7 @@ pub fn load_core_epiphany_role_result_from_runtime_spine_job( let status = map_runtime_role_result_status(&snapshot); let finding = if status == CoreEpiphanyCoordinatorRoleResultStatus::Completed { match runtime_role_worker_result(runtime_store_path, job_id) { - Ok(Some(result)) => Some(interpret_runtime_role_worker_result(core_role_id, &result)), + Ok(Some(result)) => Some(interpret_runtime_role_worker_result(role_id, &result)), Ok(None) => { return EpiphanyRoleResultSnapshot { status: CoreEpiphanyCoordinatorRoleResultStatus::BackendUnavailable, @@ -102,7 +100,7 @@ pub fn load_core_epiphany_role_result_from_runtime_spine_job( } else { None }; - let note = render_core_role_result_note(core_role_id, status, finding.as_ref(), None); + let note = render_core_role_result_note(role_id, status, finding.as_ref(), None); EpiphanyRoleResultSnapshot { status, finding, @@ -276,7 +274,7 @@ pub fn map_protocol_reorient_result_status( pub async fn load_core_epiphany_role_result_snapshot( state: &EpiphanyThreadState, runtime_store_path: Option<&Path>, - role_id: ThreadEpiphanyRoleId, + role_id: EpiphanyRoleResultRoleId, binding_id: &str, ) -> EpiphanyRoleResultSnapshot { if let Some(link) = latest_epiphany_runtime_link_for_binding(state, binding_id) { @@ -308,7 +306,7 @@ pub async fn load_core_epiphany_role_result_snapshot( pub fn load_completed_core_epiphany_role_finding( runtime_store_path: Option<&Path>, state: &EpiphanyThreadState, - role_id: ThreadEpiphanyRoleId, + role_id: EpiphanyRoleResultRoleId, binding_id: &str, ) -> BridgeResult { if let Some(link) = latest_epiphany_runtime_link_for_binding(state, binding_id) { @@ -442,9 +440,9 @@ mod tests { use std::path::Path; use std::path::PathBuf; - use codex_app_server_protocol::ThreadEpiphanyRoleId; use epiphany_core::EpiphanyCoordinatorRoleResultStatus as CoreEpiphanyCoordinatorRoleResultStatus; use epiphany_core::EpiphanyCrrcResultStatus as CoreEpiphanyCrrcResultStatus; + use epiphany_core::EpiphanyRoleResultRoleId; use epiphany_core::RuntimeSpineInitOptions; use epiphany_core::RuntimeSpineJobOptions; use epiphany_core::RuntimeSpineJobResultOptions; @@ -466,7 +464,7 @@ mod tests { let result = load_core_epiphany_role_result_from_runtime_spine_job( "role-job", Some(store.as_path()), - ThreadEpiphanyRoleId::Modeling, + EpiphanyRoleResultRoleId::Modeling, ); assert_eq!( diff --git a/epiphany-codex-bridge/src/view.rs b/epiphany-codex-bridge/src/view.rs index f432020f..5a37edb1 100644 --- a/epiphany-codex-bridge/src/view.rs +++ b/epiphany-codex-bridge/src/view.rs @@ -36,6 +36,7 @@ use crate::reorient::derive_epiphany_freshness_view; use crate::reorient::derive_epiphany_reorient; use crate::reorient::map_protocol_reorient_decision; use crate::reorient::map_protocol_reorient_state_status; +use crate::results::map_core_role_result_role_id; use crate::results::map_protocol_reorient_finding; use crate::runtime_results::load_core_epiphany_reorient_result_snapshot; use crate::runtime_results::load_core_epiphany_role_result_snapshot; @@ -487,9 +488,13 @@ pub async fn map_epiphany_role_result_response( .into_iter() .find(|job| job.id == binding_id) .map(map_core_epiphany_job_view); - let result = - load_core_epiphany_role_result_snapshot(state, runtime_store_path, role_id, &binding_id) - .await; + let result = load_core_epiphany_role_result_snapshot( + state, + runtime_store_path, + map_core_role_result_role_id(role_id), + &binding_id, + ) + .await; ThreadEpiphanyRoleResultResponse { thread_id, diff --git a/notes/fresh-workspace-handoff.md b/notes/fresh-workspace-handoff.md index 004dc130..142d2b9d 100644 --- a/notes/fresh-workspace-handoff.md +++ b/notes/fresh-workspace-handoff.md @@ -62,6 +62,7 @@ remembers doctrine; the branch remembers the blade. - Role/reorient acceptance service results now carry core typed findings, and role acceptance carries a typed `EpiphanyRoleStatePatchDocument` for the applied patch. App-server mutation routes project those into `ThreadEpiphany*Finding` / `ThreadEpiphanyUpdatePatch` only for legacy accept responses. - Generic update/promote service entry points now accept typed `EpiphanyRoleStatePatchDocument` patches. Vendored app-server converts `ThreadEpiphanyUpdatePatch` request cargo before invoking the bridge, so the mutation service no longer treats the JSON-RPC patch as its native write document. - Changed-field authority is native now. `EpiphanyStateUpdatedField` lives in `epiphany-core`; bridge mutation results carry that typed enum, while app-server projects it into `ThreadEpiphanyStateUpdatedField` only for JSON-RPC responses and notifications. +- Role launch, role accept, and role-result runtime lookup now use core `EpiphanyRoleResultRoleId` inside the bridge. App-server maps `ThreadEpiphanyRoleId` at the JSON-RPC boundary and keeps it only for legacy request/response shape. - 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 cff557cd..6b382129 100644 Binary files a/state/ledgers.msgpack and b/state/ledgers.msgpack differ diff --git a/state/map.yaml b/state/map.yaml index 32256af4..9095d931 100644 --- a/state/map.yaml +++ b/state/map.yaml @@ -342,7 +342,9 @@ current_status: Changed-field authority is now native `EpiphanyStateUpdatedField` in `epiphany-core`; app-server projects it into `ThreadEpiphanyStateUpdatedField` only for legacy responses and - notifications. The bridge still depends on vendored Codex for app-server - protocol DTOs and absolute path validation, so the purification is not - done. + notifications. Role launch, role accept, and role-result runtime lookup now + use core `EpiphanyRoleResultRoleId` internally; app-server maps + `ThreadEpiphanyRoleId` at the request/response edge. 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_mutation_routes.rs b/vendor/codex/codex-rs/app-server/src/codex_message_processor/epiphany_mutation_routes.rs index ddc6b0db..7403e960 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 @@ -32,6 +32,7 @@ use epiphany_codex_bridge::mutation_service::interrupt_thread_epiphany_job; use epiphany_codex_bridge::mutation_service::launch_thread_epiphany_job; use epiphany_codex_bridge::mutation_service::launch_thread_epiphany_reorient; use epiphany_codex_bridge::mutation_service::launch_thread_epiphany_role; +use epiphany_codex_bridge::results::map_core_role_result_role_id; use epiphany_codex_bridge::results::map_protocol_reorient_finding; use epiphany_codex_bridge::results::map_protocol_role_finding; use epiphany_codex_bridge::retrieve::epiphany_retrieval_state_for_paths; @@ -108,6 +109,7 @@ impl CodexMessageProcessor { expected_revision, max_runtime_seconds, } = params; + let core_role_id = map_core_role_result_role_id(role_id); let (thread_uuid, loaded_thread) = match self.load_epiphany_thread(&request_id, &thread_id).await { @@ -118,7 +120,7 @@ impl CodexMessageProcessor { let applied = match launch_thread_epiphany_role( &host, &thread_id, - role_id, + core_role_id, expected_revision, max_runtime_seconds, ) @@ -179,8 +181,9 @@ impl CodexMessageProcessor { expected_revision, binding_id, } = params; + let core_role_id = map_core_role_result_role_id(role_id); - let default_binding_id = match epiphany_role_binding_id(role_id) { + let default_binding_id = match epiphany_role_binding_id(core_role_id) { Ok(binding_id) => binding_id, Err(message) => { self.send_invalid_request_error(request_id, message).await; @@ -195,24 +198,28 @@ impl CodexMessageProcessor { None => return, }; let host = EpiphanyCodexThreadHost::new(loaded_thread.as_ref()); - let applied = - match apply_thread_epiphany_role_accept(&host, role_id, expected_revision, &binding_id) - .await - { - Ok(applied) => applied, - Err(EpiphanyBridgeError::InvalidRequest(message)) => { - self.send_invalid_request_error(request_id, message).await; - return; - } - Err(err) => { - self.send_internal_error( - request_id, - format!("failed to apply Epiphany role finding: {err}"), - ) - .await; - return; - } - }; + let applied = match apply_thread_epiphany_role_accept( + &host, + core_role_id, + expected_revision, + &binding_id, + ) + .await + { + Ok(applied) => applied, + Err(EpiphanyBridgeError::InvalidRequest(message)) => { + self.send_invalid_request_error(request_id, message).await; + return; + } + Err(err) => { + self.send_internal_error( + request_id, + format!("failed to apply Epiphany role finding: {err}"), + ) + .await; + return; + } + }; let changed_fields = applied.changed_fields; let protocol_changed_fields = map_protocol_state_updated_fields(changed_fields.clone()); let epiphany_state = applied.epiphany_state; 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 3a3377f3..0ff5a7a7 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 @@ -10,6 +10,7 @@ use epiphany_codex_bridge::cultnet::EpiphanySurfaceSource; use epiphany_codex_bridge::invalidation::epiphany_freshness_watcher_snapshot; use epiphany_codex_bridge::launch::EPIPHANY_REORIENT_LAUNCH_BINDING_ID; use epiphany_codex_bridge::launch::epiphany_role_binding_id; +use epiphany_codex_bridge::results::map_core_role_result_role_id; use epiphany_codex_bridge::retrieve::epiphany_retrieval_state_for_paths; use epiphany_codex_bridge::retrieve::map_epiphany_retrieve_response; use epiphany_codex_bridge::retrieve::normalize_thread_epiphany_retrieve_query; @@ -19,13 +20,13 @@ use epiphany_codex_bridge::view::EpiphanyReorientResultResponseInput; use epiphany_codex_bridge::view::EpiphanyRoleResultResponseInput; use epiphany_codex_bridge::view::EpiphanyViewResponseInput; use epiphany_codex_bridge::view::default_epiphany_view_lenses; +use epiphany_codex_bridge::view::derive_epiphany_freshness_surface; use epiphany_codex_bridge::view::epiphany_view_needs_jobs; 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_epiphany_context_response; use epiphany_codex_bridge::view::map_epiphany_distill_response; -use epiphany_codex_bridge::view::derive_epiphany_freshness_surface; use epiphany_codex_bridge::view::map_epiphany_graph_query_response; use epiphany_codex_bridge::view::map_epiphany_propose_response; use epiphany_codex_bridge::view::map_epiphany_reorient_result_response; @@ -157,10 +158,11 @@ impl CodexMessageProcessor { role_id, binding_id, } = params; + let core_role_id = map_core_role_result_role_id(role_id); let binding_id = match binding_id { Some(binding_id) => binding_id, - None => match epiphany_role_binding_id(role_id) { + None => match epiphany_role_binding_id(core_role_id) { Ok(binding_id) => binding_id.to_string(), Err(message) => { self.send_invalid_request_error(request_id, message).await; @@ -196,7 +198,7 @@ impl CodexMessageProcessor { ThreadEpiphanyRolesSource::Stored }; - if let Err(message) = epiphany_role_binding_id(role_id) { + if let Err(message) = epiphany_role_binding_id(core_role_id) { self.send_invalid_request_error(request_id, message).await; return; } @@ -615,12 +617,8 @@ fn thread_epiphany_freshness_response_from_surface( EpiphanyGraphFreshnessStatus::Missing => { ThreadEpiphanyGraphFreshnessStatus::Missing } - EpiphanyGraphFreshnessStatus::Ready => { - ThreadEpiphanyGraphFreshnessStatus::Ready - } - EpiphanyGraphFreshnessStatus::Stale => { - ThreadEpiphanyGraphFreshnessStatus::Stale - } + EpiphanyGraphFreshnessStatus::Ready => ThreadEpiphanyGraphFreshnessStatus::Ready, + EpiphanyGraphFreshnessStatus::Stale => ThreadEpiphanyGraphFreshnessStatus::Stale, }, graph_freshness: surface.graph.graph_freshness, checkpoint_id: surface.graph.checkpoint_id, @@ -635,12 +633,8 @@ fn thread_epiphany_freshness_response_from_surface( EpiphanyInvalidationStatus::Unavailable => { ThreadEpiphanyInvalidationStatus::Unavailable } - EpiphanyInvalidationStatus::Clean => { - ThreadEpiphanyInvalidationStatus::Clean - } - EpiphanyInvalidationStatus::Changed => { - ThreadEpiphanyInvalidationStatus::Changed - } + EpiphanyInvalidationStatus::Clean => ThreadEpiphanyInvalidationStatus::Clean, + EpiphanyInvalidationStatus::Changed => ThreadEpiphanyInvalidationStatus::Changed, }, watched_root: surface.watcher.watched_root, observed_at_unix_seconds: surface.watcher.observed_at_unix_seconds,