From 1a469e88e9bee1ddb381dc245b74703ec89456cf Mon Sep 17 00:00:00 2001 From: Meta Vens Date: Wed, 13 May 2026 03:49:57 +0100 Subject: [PATCH] Move Epiphany state update projection to bridge --- epiphany-codex-bridge/src/mutation.rs | 27 +++++++ notes/fresh-workspace-handoff.md | 9 ++- state/ledgers.msgpack | Bin 78282 -> 78678 bytes state/map.yaml | 4 +- .../epiphany_mutation_routes.rs | 68 ++---------------- 5 files changed, 41 insertions(+), 67 deletions(-) diff --git a/epiphany-codex-bridge/src/mutation.rs b/epiphany-codex-bridge/src/mutation.rs index 39a1adbc..6e9dd821 100644 --- a/epiphany-codex-bridge/src/mutation.rs +++ b/epiphany-codex-bridge/src/mutation.rs @@ -5,6 +5,7 @@ use codex_app_server_protocol::ThreadEpiphanyRoleFinding; use codex_app_server_protocol::ThreadEpiphanyRoleId; use codex_app_server_protocol::ThreadEpiphanyStateUpdatedField; use codex_app_server_protocol::ThreadEpiphanyUpdatePatch; +use codex_core::EpiphanyStateUpdate; use codex_protocol::protocol::EpiphanyCodeRef; use codex_protocol::protocol::EpiphanyInvestigationCheckpoint; use codex_protocol::protocol::EpiphanyInvestigationDisposition; @@ -76,6 +77,32 @@ pub fn core_state_patch_from_protocol( } } +pub fn state_update_from_thread_patch( + expected_revision: Option, + patch: ThreadEpiphanyUpdatePatch, +) -> EpiphanyStateUpdate { + EpiphanyStateUpdate { + expected_revision, + objective: patch.objective, + active_subgoal_id: patch.active_subgoal_id, + subgoals: patch.subgoals, + invariants: patch.invariants, + graphs: patch.graphs, + graph_frontier: patch.graph_frontier, + graph_checkpoint: patch.graph_checkpoint, + scratch: patch.scratch, + investigation_checkpoint: patch.investigation_checkpoint, + job_bindings: patch.job_bindings, + acceptance_receipts: patch.acceptance_receipts, + runtime_links: patch.runtime_links, + observations: patch.observations, + evidence: patch.evidence, + churn: patch.churn, + mode: patch.mode, + planning: patch.planning, + } +} + pub fn imagination_role_accept_patch_errors(patch: &ThreadEpiphanyUpdatePatch) -> Vec { imagination_role_state_patch_policy_errors(&core_state_patch_from_protocol(patch)) } diff --git a/notes/fresh-workspace-handoff.md b/notes/fresh-workspace-handoff.md index 456645a5..f86b3297 100644 --- a/notes/fresh-workspace-handoff.md +++ b/notes/fresh-workspace-handoff.md @@ -523,15 +523,18 @@ accept delegates scratch/checkpoint/evidence bundle construction the same way. `epiphany_mutation_routes.rs` is about 1,143 lines. The route still performs Codex thread lookup, revisioned state writes, and JSON-RPC responses, but no longer owns the acceptance document contract. +The twenty-sixth cut moved protocol `ThreadEpiphanyUpdatePatch` to core +`EpiphanyStateUpdate` projection into `epiphany-codex-bridge/src/mutation.rs`. +Role accept, promote, and update routes no longer hand-copy every patch field +into a core update struct. `epiphany_mutation_routes.rs` is about 1,087 lines. 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: carve remaining route-level mutation -orchestration into explicit typed bridge/service calls, starting with generic -update/promote patch-to-state-update construction and launch response/ -notification shaping. Success is a +orchestration into explicit typed bridge/service calls, starting with launch +response/notification shaping and interrupt result projection. 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 diff --git a/state/ledgers.msgpack b/state/ledgers.msgpack index 7342a6fa1f29aef6126f93c7f12aac336872fc6a..de86d152e3c2d1889bed1242cd75faabb67a2508 100644 GIT binary patch delta 195 zcmX^0nC03tmI=yC#xfgKr!g{~ZQjGUeGen!5B=#128<%imR2T{AI{KXzQyP<{h}(P z*z~phjN;R!`5AenOY#+x^NUgyTnjP_G7|GDgG&-iQbP+;faG*jeMa5s=M5P7J*^dr z@^exhlao^mO7shg@^kY`QuRy0s(>=3C8@;-%TkLf q6$%ndk~0+2GE;L>^rjzFVw9O~ugA#EY+zwNJ>QTqj1}lQ%P0UPDndN~ delta 37 tcmccijOEm0mI=yCh7&fbPGe*|)4Ydq`yNKdANtcBj2Q)4&8$oeqW~pB4Nd?6 diff --git a/state/map.yaml b/state/map.yaml index 480910c5..b85620b6 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, 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, runtime-spine result adaptation, launch/prompt doctrine, mutation document mechanics, live-state projection, 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 and mutation orchestration. The processor is about 10,339 lines, `epiphany_mutation_routes.rs` is about 1,143 lines, and `epiphany_state_helpers.rs` is down to a 19-line rollout-state loader after moving typed mutation helpers, reviewability checks, completed runtime-result acceptance loading, live-state projection, launched-job fallback projection, and role/reorient acceptance update bundle construction out to the bridge. This is progress, not absolution: the bridge is still Codex-facing compatibility, not the final CultNet runtime, and route-level launch/update/promote/interrupt orchestration still lives inside 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 carving remaining route-level mutation orchestration into explicit outside-vendor service calls, starting with generic update/promote patch-to-state-update construction and launch response/notification shaping. Do not resume app/skill/marketplace expansion. + 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, runtime-spine result adaptation, launch/prompt doctrine, mutation document mechanics, live-state projection, 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 and mutation orchestration. The processor is about 10,339 lines, `epiphany_mutation_routes.rs` is about 1,087 lines, and `epiphany_state_helpers.rs` is down to a 19-line rollout-state loader after moving typed mutation helpers, reviewability checks, completed runtime-result acceptance loading, live-state projection, launched-job fallback projection, role/reorient acceptance update bundle construction, and protocol patch-to-core state-update projection out to the bridge. This is progress, not absolution: the bridge is still Codex-facing compatibility, not the final CultNet runtime, and route-level launch/update/promote/interrupt orchestration still lives inside 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 carving remaining route-level mutation orchestration into explicit outside-vendor service calls, starting with launch response/notification shaping and interrupt result projection. Do not resume app/skill/marketplace expansion. 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 e2d690dd..9e6c1560 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 @@ -23,6 +23,7 @@ use epiphany_codex_bridge::mutation::build_role_acceptance_update; use epiphany_codex_bridge::mutation::epiphany_job_launch_changed_fields; use epiphany_codex_bridge::mutation::epiphany_promote_changed_fields; use epiphany_codex_bridge::mutation::epiphany_update_patch_changed_fields; +use epiphany_codex_bridge::mutation::state_update_from_thread_patch; use epiphany_codex_bridge::mutation::thread_epiphany_patch_has_state_replacements; use epiphany_codex_bridge::pressure::map_epiphany_pressure; use epiphany_codex_bridge::reorient::map_epiphany_freshness; @@ -266,26 +267,7 @@ impl CodexMessageProcessor { let applied_patch = patch.clone(); let epiphany_state = match loaded_thread - .epiphany_update_state(EpiphanyStateUpdate { - expected_revision, - objective: patch.objective, - active_subgoal_id: patch.active_subgoal_id, - subgoals: patch.subgoals, - invariants: patch.invariants, - graphs: patch.graphs, - graph_frontier: patch.graph_frontier, - graph_checkpoint: patch.graph_checkpoint, - scratch: patch.scratch, - investigation_checkpoint: patch.investigation_checkpoint, - job_bindings: patch.job_bindings, - acceptance_receipts: patch.acceptance_receipts, - runtime_links: patch.runtime_links, - observations: patch.observations, - evidence: patch.evidence, - churn: patch.churn, - mode: patch.mode, - planning: patch.planning, - }) + .epiphany_update_state(state_update_from_thread_patch(expected_revision, patch)) .await { Ok(state) => { @@ -782,28 +764,9 @@ impl CodexMessageProcessor { } let changed_fields = epiphany_promote_changed_fields(&patch); - let mut evidence = patch.evidence; - evidence.push(verifier_evidence); - let update = EpiphanyStateUpdate { - expected_revision, - objective: patch.objective, - active_subgoal_id: patch.active_subgoal_id, - subgoals: patch.subgoals, - invariants: patch.invariants, - graphs: patch.graphs, - graph_frontier: patch.graph_frontier, - graph_checkpoint: patch.graph_checkpoint, - scratch: patch.scratch, - investigation_checkpoint: patch.investigation_checkpoint, - job_bindings: patch.job_bindings, - acceptance_receipts: patch.acceptance_receipts, - runtime_links: patch.runtime_links, - observations: patch.observations, - evidence, - churn: patch.churn, - mode: patch.mode, - planning: patch.planning, - }; + let mut patch = patch; + patch.evidence.push(verifier_evidence); + let update = state_update_from_thread_patch(expected_revision, patch); let epiphany_state = match thread.epiphany_update_state(update).await { Ok(epiphany_state) => epiphany_state, Err(CodexErr::InvalidRequest(message)) => { @@ -876,26 +839,7 @@ impl CodexMessageProcessor { }; let changed_fields = epiphany_update_patch_changed_fields(&patch); - let update = EpiphanyStateUpdate { - expected_revision, - objective: patch.objective, - active_subgoal_id: patch.active_subgoal_id, - subgoals: patch.subgoals, - invariants: patch.invariants, - graphs: patch.graphs, - graph_frontier: patch.graph_frontier, - graph_checkpoint: patch.graph_checkpoint, - scratch: patch.scratch, - investigation_checkpoint: patch.investigation_checkpoint, - job_bindings: patch.job_bindings, - acceptance_receipts: patch.acceptance_receipts, - runtime_links: patch.runtime_links, - observations: patch.observations, - evidence: patch.evidence, - churn: patch.churn, - mode: patch.mode, - planning: patch.planning, - }; + let update = state_update_from_thread_patch(expected_revision, patch); let epiphany_state = match thread.epiphany_update_state(update).await { Ok(epiphany_state) => epiphany_state, Err(CodexErr::InvalidRequest(message)) => {