From 6086c8a7c3ab822d5e3693a23593e536fbf69094 Mon Sep 17 00:00:00 2001 From: Meta Vens Date: Wed, 20 May 2026 10:06:16 +0100 Subject: [PATCH] Move patch request mapping to app server --- epiphany-codex-bridge/src/mutation.rs | 24 -------------- notes/fresh-workspace-handoff.md | 1 + state/ledgers.msgpack | Bin 142341 -> 142601 bytes state/map.yaml | 3 ++ .../epiphany_mutation_routes.rs | 30 ++++++++++++++++-- 5 files changed, 31 insertions(+), 27 deletions(-) diff --git a/epiphany-codex-bridge/src/mutation.rs b/epiphany-codex-bridge/src/mutation.rs index 1081f1a0..a8b6fbb9 100644 --- a/epiphany-codex-bridge/src/mutation.rs +++ b/epiphany-codex-bridge/src/mutation.rs @@ -42,30 +42,6 @@ pub fn parse_core_role_finding_state_patch( .ok_or_else(|| "completed role finding did not include a reviewable statePatch".to_string()) } -pub fn core_state_patch_from_protocol( - patch: &ThreadEpiphanyUpdatePatch, -) -> EpiphanyRoleStatePatchDocument { - EpiphanyRoleStatePatchDocument { - objective: patch.objective.clone(), - active_subgoal_id: patch.active_subgoal_id.clone(), - subgoals: patch.subgoals.clone(), - invariants: patch.invariants.clone(), - graphs: patch.graphs.clone(), - graph_frontier: patch.graph_frontier.clone(), - graph_checkpoint: patch.graph_checkpoint.clone(), - scratch: patch.scratch.clone(), - investigation_checkpoint: patch.investigation_checkpoint.clone(), - job_bindings: patch.job_bindings.clone(), - acceptance_receipts: patch.acceptance_receipts.clone(), - runtime_links: patch.runtime_links.clone(), - observations: patch.observations.clone(), - evidence: patch.evidence.clone(), - churn: patch.churn.clone(), - mode: patch.mode.clone(), - planning: patch.planning.clone(), - } -} - pub fn protocol_patch_from_core( patch: EpiphanyRoleStatePatchDocument, ) -> ThreadEpiphanyUpdatePatch { diff --git a/notes/fresh-workspace-handoff.md b/notes/fresh-workspace-handoff.md index f44f4a00..dec8e7b7 100644 --- a/notes/fresh-workspace-handoff.md +++ b/notes/fresh-workspace-handoff.md @@ -80,6 +80,7 @@ remembers doctrine; the branch remembers the blade. - 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. +- Generic update/promote patch conversion also belongs to app-server. `ThreadEpiphanyUpdatePatch` is converted to core `EpiphanyRoleStatePatchDocument` before mutation service calls; bridge mutation keeps legacy response patch projection only. - 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 74ae6b23005d61a048e8f6760e1495b50ff70a32..46820251c26cc5f5ab53d7cc9ec57e49cd75475d 100644 GIT binary patch delta 205 zcmZp@!O?k(V}df1&iRe1g^Y{~nx`|iPiJJ@KAn*%QcHBoP9p;&GhG8yT_b}K14}Cd zQ!7)8$% `EpiphanyJobLaunchRequest`); 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 75755b23..6d23560b 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::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; use epiphany_codex_bridge::mutation::protocol_patch_from_core; @@ -39,6 +38,7 @@ 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::EpiphanyRoleStatePatchDocument; use epiphany_core::EpiphanyRoleWorkerLaunchDocument; use epiphany_core::EpiphanyWorkerLaunchDocument; use std::sync::Arc; @@ -482,7 +482,7 @@ impl CodexMessageProcessor { }; let host = EpiphanyCodexThreadHost::new(thread.as_ref()); - let core_patch = core_state_patch_from_protocol(&patch); + let core_patch = thread_epiphany_update_patch_to_core(&patch); let applied = match apply_thread_epiphany_promote( &host, expected_revision, @@ -562,7 +562,7 @@ impl CodexMessageProcessor { }; let host = EpiphanyCodexThreadHost::new(thread.as_ref()); - let core_patch = core_state_patch_from_protocol(&patch); + let core_patch = thread_epiphany_update_patch_to_core(&patch); let applied = match apply_thread_epiphany_update(&host, expected_revision, core_patch).await { Ok(applied) => applied, @@ -811,6 +811,30 @@ fn thread_epiphany_worker_launch_document_to_core( } } +fn thread_epiphany_update_patch_to_core( + patch: &ThreadEpiphanyUpdatePatch, +) -> EpiphanyRoleStatePatchDocument { + EpiphanyRoleStatePatchDocument { + objective: patch.objective.clone(), + active_subgoal_id: patch.active_subgoal_id.clone(), + subgoals: patch.subgoals.clone(), + invariants: patch.invariants.clone(), + graphs: patch.graphs.clone(), + graph_frontier: patch.graph_frontier.clone(), + graph_checkpoint: patch.graph_checkpoint.clone(), + scratch: patch.scratch.clone(), + investigation_checkpoint: patch.investigation_checkpoint.clone(), + job_bindings: patch.job_bindings.clone(), + acceptance_receipts: patch.acceptance_receipts.clone(), + runtime_links: patch.runtime_links.clone(), + observations: patch.observations.clone(), + evidence: patch.evidence.clone(), + churn: patch.churn.clone(), + mode: patch.mode.clone(), + planning: patch.planning.clone(), + } +} + fn thread_epiphany_role_worker_launch_document_to_core( document: ThreadEpiphanyRoleWorkerLaunchDocument, ) -> EpiphanyRoleWorkerLaunchDocument {