Clarify Epiphany mutation route dependencies

This commit is contained in:
Meta Vens 2026-05-13 03:22:59 +01:00
commit 745436d5cc
5 changed files with 64 additions and 53 deletions

View file

@ -491,6 +491,13 @@ made its read/proposal dependencies explicit. The processor is about 10,388
lines. The remaining Epiphany wildcard route module is
`epiphany_mutation_routes.rs`; it owns the dangerous launch/accept/update/
promote/interrupt path and should be the next incision.
The twenty-second cut removed `use super::*` from `epiphany_mutation_routes.rs`
and made the launch/accept/update/promote/interrupt dependencies explicit. No
Epiphany child module under `codex_message_processor/` uses parent wildcard
visibility now; only generic Codex plugin/test modules still do. The processor
is about 10,339 lines. This is not final purity: mutation orchestration still
lives in the Codex processor and should move behind a small typed service
boundary next.
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

Binary file not shown.

View file

@ -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, 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, and state hydration. The processor is about 10,388 lines after moving runtime result adaptation and making state/automation/read-route dependencies explicit, but vendored Codex lost roughly 3.6k lines of Epiphany adapter/prompt/runtime-result ownership across the bridge extraction. This is progress, not absolution: the bridge is still Codex-facing compatibility, not the final CultNet runtime, and mutation routes still have parent wildcard visibility 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 turning `epiphany_mutation_routes` into explicit service/bridge calls without `use super::*`, then move route-independent state helpers out of the processor. The next measurable wound is parent-internal wildcard visibility and mutation orchestration inside the Codex processor, not 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, 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, and state hydration. The processor is about 10,339 lines after moving runtime result adaptation and making all Epiphany child-module dependencies explicit; only generic Codex plugin/test child modules still use parent wildcards. Vendored Codex lost roughly 3.6k lines of Epiphany adapter/prompt/runtime-result ownership across the bridge extraction. This is progress, not absolution: the bridge is still Codex-facing compatibility, not the final CultNet runtime, and mutation 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 moving Epiphany mutation orchestration behind an explicit service boundary outside `codex_message_processor.rs`, starting with launch/accept/update helper functions that can take a small typed context instead of borrowing the whole processor. Do not resume app/skill/marketplace expansion.

View file

@ -11,8 +11,6 @@ use self::epiphany_mutation_routes::reorient_finding_code_refs;
use self::epiphany_mutation_routes::reorient_finding_investigation_checkpoint;
use self::epiphany_mutation_routes::reorient_finding_scratch;
use self::epiphany_mutation_routes::role_finding_summary;
use self::epiphany_state_helpers::client_visible_live_thread_epiphany_state;
use self::epiphany_state_helpers::core_state_patch_from_protocol;
use self::epiphany_state_helpers::epiphany_imagination_finding_has_reviewable_state_patch;
use self::epiphany_state_helpers::epiphany_modeling_finding_has_reviewable_state_patch;
use self::epiphany_state_helpers::live_thread_epiphany_state;
@ -179,44 +177,26 @@ use codex_app_server_protocol::ThreadEpiphanyGraphFreshnessStatus;
use codex_app_server_protocol::ThreadEpiphanyGraphQuery;
use codex_app_server_protocol::ThreadEpiphanyGraphQueryDirection;
use codex_app_server_protocol::ThreadEpiphanyGraphQueryKind;
use codex_app_server_protocol::ThreadEpiphanyIndexParams;
use codex_app_server_protocol::ThreadEpiphanyIndexResponse;
use codex_app_server_protocol::ThreadEpiphanyInvalidationInput;
use codex_app_server_protocol::ThreadEpiphanyInvalidationStatus;
use codex_app_server_protocol::ThreadEpiphanyJob;
use codex_app_server_protocol::ThreadEpiphanyJobInterruptParams;
use codex_app_server_protocol::ThreadEpiphanyJobInterruptResponse;
use codex_app_server_protocol::ThreadEpiphanyJobKind;
use codex_app_server_protocol::ThreadEpiphanyJobLaunchParams;
use codex_app_server_protocol::ThreadEpiphanyJobLaunchResponse;
use codex_app_server_protocol::ThreadEpiphanyJobStatus;
use codex_app_server_protocol::ThreadEpiphanyPressure;
use codex_app_server_protocol::ThreadEpiphanyPressureLevel;
use codex_app_server_protocol::ThreadEpiphanyPromoteParams;
use codex_app_server_protocol::ThreadEpiphanyPromoteResponse;
use codex_app_server_protocol::ThreadEpiphanyReorientAcceptParams;
use codex_app_server_protocol::ThreadEpiphanyReorientAcceptResponse;
use codex_app_server_protocol::ThreadEpiphanyReorientAction;
use codex_app_server_protocol::ThreadEpiphanyReorientCheckpointStatus;
use codex_app_server_protocol::ThreadEpiphanyReorientDecision;
use codex_app_server_protocol::ThreadEpiphanyReorientFinding;
use codex_app_server_protocol::ThreadEpiphanyReorientLaunchParams;
use codex_app_server_protocol::ThreadEpiphanyReorientLaunchResponse;
use codex_app_server_protocol::ThreadEpiphanyReorientReason;
use codex_app_server_protocol::ThreadEpiphanyReorientResultStatus;
use codex_app_server_protocol::ThreadEpiphanyReorientSource;
use codex_app_server_protocol::ThreadEpiphanyReorientStateStatus;
use codex_app_server_protocol::ThreadEpiphanyRetrievalFreshness;
use codex_app_server_protocol::ThreadEpiphanyRetrievalFreshnessStatus;
#[cfg(test)]
use codex_app_server_protocol::ThreadEpiphanyRetrieveResultKind;
use codex_app_server_protocol::ThreadEpiphanyRoleAcceptParams;
use codex_app_server_protocol::ThreadEpiphanyRoleAcceptResponse;
use codex_app_server_protocol::ThreadEpiphanyRoleFinding;
use codex_app_server_protocol::ThreadEpiphanyRoleId;
use codex_app_server_protocol::ThreadEpiphanyRoleLane;
use codex_app_server_protocol::ThreadEpiphanyRoleLaunchParams;
use codex_app_server_protocol::ThreadEpiphanyRoleLaunchResponse;
use codex_app_server_protocol::ThreadEpiphanyRoleResultStatus;
use codex_app_server_protocol::ThreadEpiphanyRoleSelfPersistenceStatus;
use codex_app_server_protocol::ThreadEpiphanyRoleStatus;
@ -226,11 +206,7 @@ use codex_app_server_protocol::ThreadEpiphanySceneSource;
use codex_app_server_protocol::ThreadEpiphanySceneStateStatus;
use codex_app_server_protocol::ThreadEpiphanySceneStatusCount;
use codex_app_server_protocol::ThreadEpiphanyStateUpdatedField;
use codex_app_server_protocol::ThreadEpiphanyStateUpdatedNotification;
use codex_app_server_protocol::ThreadEpiphanyStateUpdatedSource;
use codex_app_server_protocol::ThreadEpiphanyUpdateParams;
use codex_app_server_protocol::ThreadEpiphanyUpdatePatch;
use codex_app_server_protocol::ThreadEpiphanyUpdateResponse;
use codex_app_server_protocol::ThreadForkParams;
use codex_app_server_protocol::ThreadForkResponse;
use codex_app_server_protocol::ThreadIncrementElicitationParams;
@ -305,10 +281,6 @@ use codex_chatgpt::connectors;
use codex_config::types::McpServerTransportConfig;
use codex_core::CodexThread;
use codex_core::CodexThreadTurnContextOverrides;
use codex_core::EpiphanyJobInterruptRequest;
use codex_core::EpiphanyJobLaunchRequest;
use codex_core::EpiphanyPromotionInput;
use codex_core::EpiphanyStateUpdate;
use codex_core::ForkSnapshot;
use codex_core::NewThread;
use codex_core::RolloutRecorder;
@ -325,7 +297,6 @@ use codex_core::config::edit::ConfigEditsBuilder;
use codex_core::config_loader::CloudRequirementsLoadError;
use codex_core::config_loader::CloudRequirementsLoadErrorCode;
use codex_core::config_loader::project_trust_key;
use codex_core::evaluate_promotion;
use codex_core::exec::ExecCapturePolicy;
use codex_core::exec::ExecExpiration;
use codex_core::exec::ExecParams;
@ -406,13 +377,11 @@ use codex_protocol::protocol::ConversationStartParams;
use codex_protocol::protocol::ConversationStartTransport;
use codex_protocol::protocol::ConversationTextParams;
use codex_protocol::protocol::EpiphanyAcceptanceReceipt;
use codex_protocol::protocol::EpiphanyCodeRef;
use codex_protocol::protocol::EpiphanyEvidenceRecord;
use codex_protocol::protocol::EpiphanyInvestigationCheckpoint;
use codex_protocol::protocol::EpiphanyInvestigationDisposition;
use codex_protocol::protocol::EpiphanyRetrievalState;
use codex_protocol::protocol::EpiphanyRetrievalStatus;
use codex_protocol::protocol::EpiphanyScratchPad;
use codex_protocol::protocol::EpiphanyThreadState;
use codex_protocol::protocol::EventMsg;
use codex_protocol::protocol::GitInfo as CoreGitInfo;
@ -471,8 +440,6 @@ use epiphany_codex_bridge::coordinator::map_epiphany_crrc_recommendation;
use epiphany_codex_bridge::coordinator::map_epiphany_roles;
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;
@ -486,11 +453,8 @@ 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;
@ -498,26 +462,13 @@ use epiphany_codex_bridge::pressure::should_run_epiphany_pre_compaction_checkpoi
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::retrieve::map_epiphany_retrieve_index_summary;
use epiphany_codex_bridge::retrieve::map_epiphany_retrieve_response;
use epiphany_codex_bridge::runtime_results::latest_epiphany_runtime_link_for_binding;
use epiphany_codex_bridge::runtime_results::load_epiphany_reorient_result_from_runtime_spine_job;
use epiphany_codex_bridge::runtime_results::load_epiphany_role_result_from_runtime_spine_job;
use epiphany_codex_bridge::runtime_results::reorient_finding_runtime_job_id;
use epiphany_codex_bridge::runtime_results::reorient_finding_runtime_result_id;
use epiphany_codex_bridge::runtime_results::role_finding_runtime_job_id;
use epiphany_codex_bridge::runtime_results::role_finding_runtime_result_id;
use epiphany_codex_bridge::scene::map_epiphany_scene;
use epiphany_core::EpiphanyReorientAcceptanceFinding;
use epiphany_core::EpiphanyRoleAcceptanceFinding;
use epiphany_core::EpiphanyWorkerLaunchDocument;
use epiphany_core::build_reorient_acceptance_bundle;
use epiphany_core::build_role_acceptance_bundle;
use epiphany_core::imagination_role_state_patch_policy_errors;
use epiphany_core::modeling_role_state_patch_policy_errors;
use std::collections::HashMap;
use std::collections::HashSet;
use std::io::Error as IoError;

View file

@ -1,4 +1,57 @@
use super::*;
use std::path::PathBuf;
use chrono::SecondsFormat;
use chrono::Utc;
use codex_app_server_protocol::*;
use codex_core::CodexThread;
use codex_core::EpiphanyJobInterruptRequest;
use codex_core::EpiphanyJobLaunchRequest;
use codex_core::EpiphanyPromotionInput;
use codex_core::EpiphanyStateUpdate;
use codex_core::evaluate_promotion;
use codex_protocol::ThreadId;
use codex_protocol::error::CodexErr;
use codex_protocol::error::Result as CodexResult;
use codex_protocol::protocol::EpiphanyCodeRef;
use codex_protocol::protocol::EpiphanyInvestigationCheckpoint;
use codex_protocol::protocol::EpiphanyInvestigationDisposition;
use codex_protocol::protocol::EpiphanyScratchPad;
use codex_protocol::protocol::EpiphanyThreadState;
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_REORIENT_LAUNCH_BINDING_ID;
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_role_binding_id;
use epiphany_codex_bridge::launch::epiphany_role_label;
use epiphany_codex_bridge::launch::map_core_worker_launch_document;
use epiphany_codex_bridge::pressure::map_epiphany_pressure;
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::retrieve::map_epiphany_retrieve_index_summary;
use epiphany_codex_bridge::runtime_results::latest_epiphany_runtime_link_for_binding;
use epiphany_codex_bridge::runtime_results::load_epiphany_reorient_result_from_runtime_spine_job;
use epiphany_codex_bridge::runtime_results::load_epiphany_role_result_from_runtime_spine_job;
use epiphany_codex_bridge::runtime_results::reorient_finding_runtime_job_id;
use epiphany_codex_bridge::runtime_results::reorient_finding_runtime_result_id;
use epiphany_codex_bridge::runtime_results::role_finding_runtime_job_id;
use epiphany_codex_bridge::runtime_results::role_finding_runtime_result_id;
use epiphany_core::EpiphanyReorientAcceptanceFinding;
use epiphany_core::EpiphanyRoleAcceptanceFinding;
use epiphany_core::build_reorient_acceptance_bundle;
use epiphany_core::build_role_acceptance_bundle;
use epiphany_core::imagination_role_state_patch_policy_errors;
use epiphany_core::modeling_role_state_patch_policy_errors;
use uuid::Uuid;
use super::CodexMessageProcessor;
use super::ConnectionRequestId;
use super::ThreadReadViewError;
use super::epiphany_freshness_watcher_snapshot;
use super::epiphany_state_helpers::client_visible_live_thread_epiphany_state;
use super::epiphany_state_helpers::core_state_patch_from_protocol;
impl CodexMessageProcessor {
pub(super) async fn thread_epiphany_role_launch(
@ -1310,7 +1363,7 @@ async fn load_completed_epiphany_role_finding(
fn parse_role_finding_state_patch(
finding: &ThreadEpiphanyRoleFinding,
) -> Result<ThreadEpiphanyUpdatePatch, String> {
) -> std::result::Result<ThreadEpiphanyUpdatePatch, String> {
finding
.state_patch
.clone()