diff --git a/epiphany-codex-bridge/src/jobs.rs b/epiphany-codex-bridge/src/jobs.rs index b9a2e8c8..a514fed8 100644 --- a/epiphany-codex-bridge/src/jobs.rs +++ b/epiphany-codex-bridge/src/jobs.rs @@ -52,6 +52,37 @@ pub fn map_core_epiphany_job_kind(kind: CoreEpiphanyJobKind) -> ThreadEpiphanyJo } } +pub fn map_launched_epiphany_job( + state: &EpiphanyThreadState, + binding_id: &str, + launcher_job_id: &str, + backend_job_id: &str, + fallback_kind: CoreEpiphanyJobKind, + fallback_scope: &str, +) -> ThreadEpiphanyJob { + map_epiphany_jobs(Some(state), None) + .into_iter() + .find(|job| job.id == binding_id) + .unwrap_or_else(|| ThreadEpiphanyJob { + id: binding_id.to_string(), + kind: map_core_epiphany_job_kind(fallback_kind), + scope: fallback_scope.to_string(), + owner_role: "epiphany-harness".to_string(), + launcher_job_id: Some(launcher_job_id.to_string()), + authority_scope: None, + backend_job_id: Some(backend_job_id.to_string()), + status: ThreadEpiphanyJobStatus::Pending, + items_processed: None, + items_total: None, + progress_note: None, + last_checkpoint_at_unix_seconds: None, + blocking_reason: None, + active_thread_ids: Vec::new(), + linked_subgoal_ids: Vec::new(), + linked_graph_node_ids: Vec::new(), + }) +} + fn map_core_epiphany_job_status(status: CoreEpiphanyJobStatus) -> ThreadEpiphanyJobStatus { match status { CoreEpiphanyJobStatus::Idle => ThreadEpiphanyJobStatus::Idle, diff --git a/notes/fresh-workspace-handoff.md b/notes/fresh-workspace-handoff.md index d65568b0..7caeba95 100644 --- a/notes/fresh-workspace-handoff.md +++ b/notes/fresh-workspace-handoff.md @@ -509,6 +509,12 @@ about 1,271 lines and `epiphany_state_helpers.rs` is down to a 19-line rollout-state loader. This is a real authority cut, but not a sufficient carcass cut: route-level launch/accept/update/promote/interrupt orchestration still lives in vendored Codex. +The twenty-fourth cut moved launched-job fallback projection into +`epiphany-codex-bridge/src/jobs.rs`, so role launch and generic job launch no +longer hand-build duplicate `ThreadEpiphanyJob` fallback structs inside +`epiphany_mutation_routes.rs`. The route module is about 1,245 lines. Small +cut, real smell: duplicate projection authority belonged with the job adapter, +not in each JSON-RPC launch handler. 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 diff --git a/state/ledgers.msgpack b/state/ledgers.msgpack index af8738a1..3a6e7b40 100644 Binary files a/state/ledgers.msgpack and b/state/ledgers.msgpack differ diff --git a/state/map.yaml b/state/map.yaml index badb3f95..8a3e869b 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,271 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, and live-state 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/accept/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. + 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,245 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, and launched-job fallback 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/accept/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 route-level mutation orchestration into explicit outside-vendor service calls, starting with launch response/notification construction and acceptance update bundles that can take small typed inputs instead of borrowing `CodexMessageProcessor`. 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 68d4c596..8daceb22 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 @@ -8,9 +8,10 @@ use codex_core::EpiphanyStateUpdate; use codex_core::evaluate_promotion; use codex_protocol::ThreadId; use codex_protocol::error::CodexErr; +use codex_protocol::protocol::EpiphanyJobKind as CoreEpiphanyJobKind; 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::jobs::map_launched_epiphany_job; 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; @@ -106,7 +107,6 @@ impl CodexMessageProcessor { return; } }; - let binding_id = launch_request.binding_id.clone(); let changed_fields = epiphany_job_launch_changed_fields(); let launched = match loaded_thread.epiphany_launch_job(launch_request).await { Ok(launched) => launched, @@ -129,27 +129,14 @@ impl CodexMessageProcessor { launched.epiphany_state, ) .await; - let job = map_epiphany_jobs(Some(&epiphany_state), None) - .into_iter() - .find(|job| job.id == binding_id) - .unwrap_or_else(|| ThreadEpiphanyJob { - id: launched.binding_id.clone(), - kind: ThreadEpiphanyJobKind::Specialist, - scope: "missing launched role projection".to_string(), - owner_role: "epiphany-harness".to_string(), - launcher_job_id: Some(launched.launcher_job_id.clone()), - authority_scope: None, - backend_job_id: Some(launched.backend_job_id.clone()), - status: ThreadEpiphanyJobStatus::Pending, - items_processed: None, - items_total: None, - progress_note: None, - last_checkpoint_at_unix_seconds: None, - blocking_reason: None, - active_thread_ids: Vec::new(), - linked_subgoal_ids: Vec::new(), - linked_graph_node_ids: Vec::new(), - }); + let job = map_launched_epiphany_job( + &epiphany_state, + launched.binding_id.as_str(), + launched.launcher_job_id.as_str(), + launched.backend_job_id.as_str(), + CoreEpiphanyJobKind::Specialist, + "missing launched role projection", + ); self.outgoing .send_response( @@ -1126,27 +1113,14 @@ impl CodexMessageProcessor { let epiphany_state = client_visible_live_thread_epiphany_state(thread.as_ref(), launched.epiphany_state) .await; - let job = map_epiphany_jobs(Some(&epiphany_state), None) - .into_iter() - .find(|job| job.id == binding_id) - .unwrap_or_else(|| ThreadEpiphanyJob { - id: launched.binding_id.clone(), - kind: map_core_epiphany_job_kind(kind), - scope: "missing launched job projection".to_string(), - owner_role: "epiphany-harness".to_string(), - launcher_job_id: Some(launched.launcher_job_id.clone()), - authority_scope: None, - backend_job_id: Some(launched.backend_job_id.clone()), - status: ThreadEpiphanyJobStatus::Pending, - items_processed: None, - items_total: None, - progress_note: None, - last_checkpoint_at_unix_seconds: None, - blocking_reason: None, - active_thread_ids: Vec::new(), - linked_subgoal_ids: Vec::new(), - linked_graph_node_ids: Vec::new(), - }); + let job = map_launched_epiphany_job( + &epiphany_state, + launched.binding_id.as_str(), + launched.launcher_job_id.as_str(), + launched.backend_job_id.as_str(), + kind, + "missing launched job projection", + ); self.outgoing .send_response(