diff --git a/epiphany-codex-bridge/src/launch.rs b/epiphany-codex-bridge/src/launch.rs index cb7688f5..7ae6599d 100644 --- a/epiphany-codex-bridge/src/launch.rs +++ b/epiphany-codex-bridge/src/launch.rs @@ -1,8 +1,5 @@ use std::sync::OnceLock; -use codex_app_server_protocol::ThreadEpiphanyReorientWorkerLaunchDocument; -use codex_app_server_protocol::ThreadEpiphanyRoleWorkerLaunchDocument; -use codex_app_server_protocol::ThreadEpiphanyWorkerLaunchDocument; use epiphany_core::EpiphanyCoordinatorAction as CoreEpiphanyCoordinatorAction; use epiphany_core::EpiphanyCoordinatorRoleResultStatus as CoreEpiphanyCoordinatorRoleResultStatus; use epiphany_core::EpiphanyCrrcAction as CoreEpiphanyCrrcAction; @@ -12,7 +9,6 @@ use epiphany_core::EpiphanyPressureLevel as CoreEpiphanyPressureLevel; use epiphany_core::EpiphanyReorientAction as CoreEpiphanyReorientAction; use epiphany_core::EpiphanyReorientDecision as CoreEpiphanyReorientDecision; use epiphany_core::EpiphanyReorientLaunchRequestInput; -use epiphany_core::EpiphanyReorientWorkerLaunchDocument; use epiphany_core::EpiphanyRoleResultRoleId; use epiphany_core::EpiphanyRoleWorkerLaunchDocument; use epiphany_core::EpiphanyWorkerLaunchDocument; @@ -507,21 +503,6 @@ pub fn build_epiphany_reorient_launch_instruction(action: CoreEpiphanyReorientAc epiphany_agent_prompt_with_memory(body) } -pub fn map_core_worker_launch_document( - document: ThreadEpiphanyWorkerLaunchDocument, -) -> EpiphanyWorkerLaunchDocument { - match document { - ThreadEpiphanyWorkerLaunchDocument::Role(document) => { - EpiphanyWorkerLaunchDocument::Role(map_core_role_worker_launch_document(document)) - } - ThreadEpiphanyWorkerLaunchDocument::Reorient(document) => { - EpiphanyWorkerLaunchDocument::Reorient(map_core_reorient_worker_launch_document( - document, - )) - } - } -} - pub fn build_epiphany_job_launch_request( expected_revision: Option, binding_id: String, @@ -552,63 +533,6 @@ pub fn build_epiphany_job_launch_request( } } -fn map_core_role_worker_launch_document( - document: ThreadEpiphanyRoleWorkerLaunchDocument, -) -> EpiphanyRoleWorkerLaunchDocument { - EpiphanyRoleWorkerLaunchDocument { - thread_id: document.thread_id, - role_id: document.role_id, - state_revision: document.state_revision, - objective: document.objective, - active_subgoal_id: document.active_subgoal_id, - active_subgoals: document.active_subgoals, - active_graph_node_ids: document.active_graph_node_ids, - investigation_checkpoint: document.investigation_checkpoint, - scratch: document.scratch, - invariants: document.invariants, - graphs: document.graphs, - recent_evidence: document.recent_evidence, - recent_observations: document.recent_observations, - graph_frontier: document.graph_frontier, - graph_checkpoint: document.graph_checkpoint, - planning: document.planning, - churn: document.churn, - } -} - -fn map_core_reorient_worker_launch_document( - document: ThreadEpiphanyReorientWorkerLaunchDocument, -) -> EpiphanyReorientWorkerLaunchDocument { - EpiphanyReorientWorkerLaunchDocument { - thread_id: document.thread_id, - mode: document.mode, - checkpoint_id: document.checkpoint_id, - checkpoint_kind: document.checkpoint_kind, - checkpoint_disposition: document.checkpoint_disposition, - checkpoint_focus: document.checkpoint_focus, - checkpoint_summary: document.checkpoint_summary, - checkpoint_next_action: document.checkpoint_next_action, - checkpoint_open_questions: document.checkpoint_open_questions, - checkpoint_evidence_ids: document.checkpoint_evidence_ids, - checkpoint_code_refs: document.checkpoint_code_refs, - decision_reasons: document.decision_reasons, - decision_note: document.decision_note, - pressure_level: document.pressure_level, - retrieval_status: document.retrieval_status, - graph_status: document.graph_status, - watcher_status: document.watcher_status, - checkpoint_dirty_paths: document.checkpoint_dirty_paths, - checkpoint_changed_paths: document.checkpoint_changed_paths, - scratch: document.scratch, - graphs: document.graphs, - recent_evidence: document.recent_evidence, - recent_observations: document.recent_observations, - active_frontier_node_ids: document.active_frontier_node_ids, - linked_subgoal_ids: document.linked_subgoal_ids, - linked_graph_node_ids: document.linked_graph_node_ids, - } -} - pub fn render_epiphany_coordinator_note( crrc_action: CoreEpiphanyCrrcAction, pressure_level: CoreEpiphanyPressureLevel, diff --git a/notes/fresh-workspace-handoff.md b/notes/fresh-workspace-handoff.md index e6a28b2e..f44f4a00 100644 --- a/notes/fresh-workspace-handoff.md +++ b/notes/fresh-workspace-handoff.md @@ -79,6 +79,7 @@ remembers doctrine; the branch remembers the blade. - View lens selector semantics are core-owned now. `EpiphanyViewLens`, default view lenses, and lens dependency planning live in `epiphany-core`; app-server converts JSON-RPC lens params to core selectors and asks core which jobs/pressure/runtime/reorientation facts must be loaded. - Context and graph-query request conversion now belongs to the app-server JSON-RPC wall. `epiphany-codex-bridge::context` receives core `EpiphanyContextParams` / `EpiphanyGraphQuery` and only projects core context/query views back into legacy response DTOs. - Distill request conversion also belongs to the app-server wall. The bridge distill response builder consumes core `EpiphanyDistillInput`; `ThreadEpiphanyDistillParams` should not re-enter bridge policy. +- Generic job-launch document conversion also belongs to app-server. `ThreadEpiphanyWorkerLaunchDocument` is converted to core `EpiphanyWorkerLaunchDocument` before bridge launch/mutation law runs. - 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 b14eb6b5..74ae6b23 100644 Binary files a/state/ledgers.msgpack and b/state/ledgers.msgpack differ diff --git a/state/map.yaml b/state/map.yaml index 4925dfeb..8794a81d 100644 --- a/state/map.yaml +++ b/state/map.yaml @@ -386,7 +386,10 @@ current_status: receives core `EpiphanyContextParams` / `EpiphanyGraphQuery` documents instead of owning request-side protocol mapping. Distill request DTO conversion also moved to the app-server wall; bridge distill response - construction receives core `EpiphanyDistillInput`. Reorient worker launch-request/document + construction receives core `EpiphanyDistillInput`. Generic job launch + document conversion moved to app-server too; bridge launch receives core + `EpiphanyWorkerLaunchDocument` instead of protocol worker launch cargo. + Reorient worker launch-request/document composition also moved behind a typed core seam (`EpiphanyReorientLaunchRequestInput` -> `EpiphanyJobLaunchRequest`); bridge supplies only the prompt instruction and retained compatibility 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 5f52b817..75755b23 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 @@ -20,7 +20,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::launch::map_core_worker_launch_document; use epiphany_codex_bridge::mutation::core_state_patch_from_protocol; use epiphany_codex_bridge::mutation::epiphany_state_updated_notification; use epiphany_codex_bridge::mutation::map_protocol_state_updated_fields; @@ -39,6 +38,9 @@ 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; use epiphany_codex_bridge::retrieve::index_epiphany_retrieval_for_paths; +use epiphany_core::EpiphanyReorientWorkerLaunchDocument; +use epiphany_core::EpiphanyRoleWorkerLaunchDocument; +use epiphany_core::EpiphanyWorkerLaunchDocument; use std::sync::Arc; use super::CodexMessageProcessor; @@ -623,7 +625,7 @@ impl CodexMessageProcessor { }; let host = EpiphanyCodexThreadHost::new(thread.as_ref()); - let core_launch_document = map_core_worker_launch_document(launch_document); + let core_launch_document = thread_epiphany_worker_launch_document_to_core(launch_document); let applied = match launch_thread_epiphany_job( &host, build_epiphany_job_launch_request( @@ -794,6 +796,78 @@ fn thread_epiphany_job_from_surface( } } +fn thread_epiphany_worker_launch_document_to_core( + document: ThreadEpiphanyWorkerLaunchDocument, +) -> EpiphanyWorkerLaunchDocument { + match document { + ThreadEpiphanyWorkerLaunchDocument::Role(document) => EpiphanyWorkerLaunchDocument::Role( + thread_epiphany_role_worker_launch_document_to_core(document), + ), + ThreadEpiphanyWorkerLaunchDocument::Reorient(document) => { + EpiphanyWorkerLaunchDocument::Reorient( + thread_epiphany_reorient_worker_launch_document_to_core(document), + ) + } + } +} + +fn thread_epiphany_role_worker_launch_document_to_core( + document: ThreadEpiphanyRoleWorkerLaunchDocument, +) -> EpiphanyRoleWorkerLaunchDocument { + EpiphanyRoleWorkerLaunchDocument { + thread_id: document.thread_id, + role_id: document.role_id, + state_revision: document.state_revision, + objective: document.objective, + active_subgoal_id: document.active_subgoal_id, + active_subgoals: document.active_subgoals, + active_graph_node_ids: document.active_graph_node_ids, + investigation_checkpoint: document.investigation_checkpoint, + scratch: document.scratch, + invariants: document.invariants, + graphs: document.graphs, + recent_evidence: document.recent_evidence, + recent_observations: document.recent_observations, + graph_frontier: document.graph_frontier, + graph_checkpoint: document.graph_checkpoint, + planning: document.planning, + churn: document.churn, + } +} + +fn thread_epiphany_reorient_worker_launch_document_to_core( + document: ThreadEpiphanyReorientWorkerLaunchDocument, +) -> EpiphanyReorientWorkerLaunchDocument { + EpiphanyReorientWorkerLaunchDocument { + thread_id: document.thread_id, + mode: document.mode, + checkpoint_id: document.checkpoint_id, + checkpoint_kind: document.checkpoint_kind, + checkpoint_disposition: document.checkpoint_disposition, + checkpoint_focus: document.checkpoint_focus, + checkpoint_summary: document.checkpoint_summary, + checkpoint_next_action: document.checkpoint_next_action, + checkpoint_open_questions: document.checkpoint_open_questions, + checkpoint_evidence_ids: document.checkpoint_evidence_ids, + checkpoint_code_refs: document.checkpoint_code_refs, + decision_reasons: document.decision_reasons, + decision_note: document.decision_note, + pressure_level: document.pressure_level, + retrieval_status: document.retrieval_status, + graph_status: document.graph_status, + watcher_status: document.watcher_status, + checkpoint_dirty_paths: document.checkpoint_dirty_paths, + checkpoint_changed_paths: document.checkpoint_changed_paths, + scratch: document.scratch, + graphs: document.graphs, + recent_evidence: document.recent_evidence, + recent_observations: document.recent_observations, + active_frontier_node_ids: document.active_frontier_node_ids, + linked_subgoal_ids: document.linked_subgoal_ids, + linked_graph_node_ids: document.linked_graph_node_ids, + } +} + fn thread_epiphany_reorient_state_status( status: EpiphanyReorientStateStatus, ) -> ThreadEpiphanyReorientStateStatus {