diff --git a/epiphany-codex-bridge/src/pressure.rs b/epiphany-codex-bridge/src/pressure.rs index b115aacf..fcfc4dfd 100644 --- a/epiphany-codex-bridge/src/pressure.rs +++ b/epiphany-codex-bridge/src/pressure.rs @@ -7,6 +7,7 @@ use epiphany_core::EpiphanyPressure; use epiphany_core::EpiphanyPressureBasis as CoreEpiphanyPressureBasis; use epiphany_core::EpiphanyPressureLevel as CoreEpiphanyPressureLevel; use epiphany_core::EpiphanyPressureStatus as CoreEpiphanyPressureStatus; +use epiphany_core::EpiphanyTokenUsageSnapshot; use epiphany_core::derive_pressure_view; use crate::launch::epiphany_agent_prompt_with_memory; @@ -14,7 +15,13 @@ use crate::launch::epiphany_specialist_prompt_config; use crate::launch::pressure_level_label; pub fn map_epiphany_pressure(info: Option<&CoreTokenUsageInfo>) -> ThreadEpiphanyPressure { - map_core_epiphany_pressure(derive_pressure_view(info)) + let snapshot = info.map(|info| EpiphanyTokenUsageSnapshot { + total_tokens: info.total_token_usage.total_tokens, + last_turn_tokens: info.last_token_usage.total_tokens, + model_context_window: info.model_context_window, + model_auto_compact_token_limit: info.model_auto_compact_token_limit, + }); + map_core_epiphany_pressure(derive_pressure_view(snapshot.as_ref())) } fn map_core_epiphany_pressure(pressure: EpiphanyPressure) -> ThreadEpiphanyPressure { diff --git a/epiphany-core/Cargo.toml b/epiphany-core/Cargo.toml index ad727b08..63d6b7e8 100644 --- a/epiphany-core/Cargo.toml +++ b/epiphany-core/Cargo.toml @@ -14,7 +14,6 @@ anyhow = "1" bm25 = "2.3.2" chrono = "0.4.44" codex-file-search = { path = "../vendor/codex/codex-rs/file-search" } -codex-protocol = { path = "../vendor/codex/codex-rs/protocol" } cultcache-rs = { path = "../vendor/cultcache-rs" } cultnet-rs = { path = "../vendor/cultnet-rs" } epiphany-openai-adapter = { path = "../epiphany-openai-adapter" } diff --git a/epiphany-core/src/lib.rs b/epiphany-core/src/lib.rs index 6a342595..c8398927 100644 --- a/epiphany-core/src/lib.rs +++ b/epiphany-core/src/lib.rs @@ -5,7 +5,6 @@ mod promotion; mod prompt; mod proposal; mod retrieval; -mod rollout; mod runtime_spine; mod state_ledger; mod state_update; @@ -89,7 +88,6 @@ pub use retrieval::EpiphanyRetrieveResultKind; pub use retrieval::index_workspace; pub use retrieval::retrieval_state_for_workspace; pub use retrieval::retrieve_workspace; -pub use rollout::latest_epiphany_state_from_rollout_items; pub use runtime_spine::EpiphanyRuntimeEvent; pub use runtime_spine::EpiphanyRuntimeIdentity; pub use runtime_spine::EpiphanyRuntimeJob; @@ -241,6 +239,7 @@ pub use surfaces::EpiphanySceneSource; pub use surfaces::EpiphanySceneStateStatus; pub use surfaces::EpiphanySceneStatusCount; pub use surfaces::EpiphanySceneSubgoal; +pub use surfaces::EpiphanyTokenUsageSnapshot; pub use surfaces::EpiphanyWorkerLaunchDocument; pub use surfaces::REORIENT_WORKER_OUTPUT_CONTRACT_ID; pub use surfaces::ROLE_WORKER_OUTPUT_CONTRACT_ID; diff --git a/epiphany-core/src/prompt.rs b/epiphany-core/src/prompt.rs index cc420dc9..765585d6 100644 --- a/epiphany-core/src/prompt.rs +++ b/epiphany-core/src/prompt.rs @@ -798,7 +798,6 @@ fn push_omitted_count(lines: &mut Vec, total: usize, shown: usize, label #[cfg(test)] mod tests { use super::render_epiphany_state; - use codex_protocol::config_types::ModeKind; use epiphany_state_model::EpiphanyChurnState; use epiphany_state_model::EpiphanyCodeRef; use epiphany_state_model::EpiphanyGraph; @@ -809,6 +808,7 @@ mod tests { use epiphany_state_model::EpiphanyGraphs; use epiphany_state_model::EpiphanyInvestigationCheckpoint; use epiphany_state_model::EpiphanyInvestigationDisposition; + use epiphany_state_model::EpiphanyModeKind; use epiphany_state_model::EpiphanyModeState; use epiphany_state_model::EpiphanyThreadState; use std::path::PathBuf; @@ -918,7 +918,7 @@ mod tests { }), mode: Some(EpiphanyModeState { name: "epiphany".to_string(), - kind: Some(ModeKind::Default), + kind: Some(EpiphanyModeKind::Default), }), ..Default::default() }; diff --git a/epiphany-core/src/surfaces/mod.rs b/epiphany-core/src/surfaces/mod.rs index 0bf132d2..e0ee7fcf 100644 --- a/epiphany-core/src/surfaces/mod.rs +++ b/epiphany-core/src/surfaces/mod.rs @@ -71,6 +71,7 @@ pub use pressure::EpiphanyPressure; pub use pressure::EpiphanyPressureBasis; pub use pressure::EpiphanyPressureLevel; pub use pressure::EpiphanyPressureStatus; +pub use pressure::EpiphanyTokenUsageSnapshot; pub use pressure::derive_pressure_view; pub use reorient::EpiphanyReorientAction; pub use reorient::EpiphanyReorientCheckpointStatus; diff --git a/epiphany-core/src/surfaces/pressure.rs b/epiphany-core/src/surfaces/pressure.rs index 95d73a6a..fa145671 100644 --- a/epiphany-core/src/surfaces/pressure.rs +++ b/epiphany-core/src/surfaces/pressure.rs @@ -1,9 +1,15 @@ -use codex_protocol::protocol::TokenUsageInfo; - const EPIPHANY_PRESSURE_ELEVATED_PER_MILLE: u32 = 650; const EPIPHANY_PRESSURE_PREPARE_COMPACTION_PER_MILLE: u32 = 800; const EPIPHANY_PRESSURE_CRITICAL_PER_MILLE: u32 = 950; +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +pub struct EpiphanyTokenUsageSnapshot { + pub total_tokens: i64, + pub last_turn_tokens: i64, + pub model_context_window: Option, + pub model_auto_compact_token_limit: Option, +} + #[derive(Debug, Clone, PartialEq, Eq)] pub struct EpiphanyPressure { pub status: EpiphanyPressureStatus, @@ -40,7 +46,7 @@ pub enum EpiphanyPressureBasis { ModelContextWindow, } -pub fn derive_pressure_view(info: Option<&TokenUsageInfo>) -> EpiphanyPressure { +pub fn derive_pressure_view(info: Option<&EpiphanyTokenUsageSnapshot>) -> EpiphanyPressure { let Some(info) = info else { return EpiphanyPressure { status: EpiphanyPressureStatus::Unknown, @@ -56,8 +62,8 @@ pub fn derive_pressure_view(info: Option<&TokenUsageInfo>) -> EpiphanyPressure { }; }; - let used_tokens = info.last_token_usage.total_tokens.max(0); - if used_tokens == 0 && info.total_token_usage.total_tokens > 0 { + let used_tokens = info.last_turn_tokens.max(0); + if used_tokens == 0 && info.total_tokens > 0 { return EpiphanyPressure { status: EpiphanyPressureStatus::Unknown, level: EpiphanyPressureLevel::Unknown, @@ -141,29 +147,16 @@ pub fn derive_pressure_view(info: Option<&TokenUsageInfo>) -> EpiphanyPressure { #[cfg(test)] mod tests { use super::*; - use codex_protocol::protocol::TokenUsage; fn token_usage_info( total_tokens: i64, last_tokens: i64, model_context_window: Option, model_auto_compact_token_limit: Option, - ) -> TokenUsageInfo { - TokenUsageInfo { - total_token_usage: TokenUsage { - input_tokens: 0, - cached_input_tokens: 0, - output_tokens: 0, - reasoning_output_tokens: 0, - total_tokens, - }, - last_token_usage: TokenUsage { - input_tokens: 0, - cached_input_tokens: 0, - output_tokens: 0, - reasoning_output_tokens: 0, - total_tokens: last_tokens, - }, + ) -> EpiphanyTokenUsageSnapshot { + EpiphanyTokenUsageSnapshot { + total_tokens, + last_turn_tokens: last_tokens, model_context_window, model_auto_compact_token_limit, } diff --git a/notes/fresh-workspace-handoff.md b/notes/fresh-workspace-handoff.md index 5cb9938e..29cc1b6b 100644 --- a/notes/fresh-workspace-handoff.md +++ b/notes/fresh-workspace-handoff.md @@ -36,7 +36,7 @@ remembers doctrine; the branch remembers the blade. - The active foundation directive is now `notes/codex-starvation-and-cultnet-liberation-plan.md`. The previous Codex app-server control-plane rebuild made Epiphany less rotten inside Codex, but that is not the destination. Epiphany must become a native CultCache/CultNet runtime. Codex is a compatibility reliquary for OpenAI subscription auth and model transport, not the host brain. - `notes/codex-auth-spine-inventory.md` is the source-grounded keeper list for that reliquary: retain `codex-login` credential storage/refresh, `codex-model-provider` auth resolution, the model-transport subset of `codex-core::client`, and the narrow model-catalog subset of `models-manager`; do not treat Codex app-server, apps, skills, marketplace, plugin UX, MCP OAuth handlers, or collaboration-mode surfaces as auth-spine machinery. - Edge JSON is allowed for schema description, hostile ingress before immediate typed parsing, sealed forensic artifacts, or named quarantine experiments. When both subsystems are ours, runtime data must remain typed CultCache documents and move over CultNet typed contracts. Generic `serde_json::Value` in worker launch/result/selfPatch/runtime flow is contamination until classified and replaced. -- Durable Epiphany state types now live in root crate `epiphany-state-model`. `codex-protocol` re-exports them only so old rollout/API callers keep compiling; do not add new durable `Epiphany*` state structs under `vendor/codex`. `epiphany-core` imports the native model directly. The remaining `epiphany-core` dependency on `codex-protocol` is now limited to Codex rollout/event reconstruction and token-pressure input, and that is the next wound to cut. +- Durable Epiphany state types now live in root crate `epiphany-state-model`. `codex-protocol` re-exports them only so old rollout/API callers keep compiling; do not add new durable `Epiphany*` state structs under `vendor/codex`. `epiphany-core` imports the native model directly and no longer depends on `codex-protocol`. Pressure derives from native `EpiphanyTokenUsageSnapshot`; Codex token telemetry is mapped at the bridge. Codex rollout/event reconstruction now lives in `codex-core::epiphany_rollout`, where the Codex `RolloutItem` / `EventMsg` types belong. The remaining direct vendored Codex dependency in `epiphany-core` is `codex-file-search`. - The May 2026 foundation migration in `notes/epiphany-ideal-architecture-rebuild-plan.md` is complete enough to defend. Read `notes/epiphany-architectural-teardown.md` before touching Epiphany control-plane code, but do not treat it as an open-ended excuse to keep shaving the altar. The rebuild moved scene projection, freshness derivation, pressure policy, targeted context shards, bounded graph traversal, job/progress view derivation, planning view derivation, reorientation resume/regather verdict policy, pure CRRC recommendation policy, fixed-lane coordinator decision policy, role-board projection policy, role/reorient result interpretation, role self-persistence review policy, and role/reorient acceptance bundle policy into `epiphany-core`; typed acceptance receipts replaced summary-string identity for live accept paths, runtime links are dual-written on launch, and result read-back now prefers runtime links. - Read `notes/epiphany-ideal-architecture-rebuild-plan.md` immediately after the teardown. It defines the smallest coherent replacement architecture: durable `EpiphanyState`, runtime-spine-owned `RuntimeState`, separate role memory/heartbeat state, `epiphany-core` as policy owner, app-server as adapter, Aquarium as reflector, typed acceptance receipts, and derived view lenses instead of a protocol verb zoo. - Do not continue Aquarium UI, bridge, Face, or dogfood expansion until the teardown has a source-grounded cleanup slice plan. Epiphany is the foundation; patches on patches are not a purification rite, they are how the altar becomes load-bearing garbage. @@ -737,14 +737,14 @@ 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: remove the remaining -`epiphany-core` dependency on `codex-protocol` by extracting or relocating the -Codex rollout adapter and token-pressure input, then keep starving the old model -turn path out of `thread/epiphany/*` JSON-RPC and `codex_message_processor.rs`. -Success is Epiphany calling the model adapter from its own CultCache/CultNet -runtime boundary while Codex survives only as subscription auth/model routing. -Do not resume Rider, Unity, Aquarium, Face, dogfood, planning, app, skill, -marketplace, or bridge expansion until this organ is being cut cleanly. +Continue with the actual whale-carcass cut: remove or isolate the last direct +vendored Codex dependency in `epiphany-core`, currently `codex-file-search`, +then keep starving the old model turn path out of `thread/epiphany/*` JSON-RPC +and `codex_message_processor.rs`. Success is Epiphany calling the model adapter +from its own CultCache/CultNet runtime boundary while Codex survives only as +subscription auth/model routing. Do not resume Rider, Unity, Aquarium, Face, +dogfood, planning, app, skill, marketplace, or bridge expansion until this +organ is being cut cleanly. The Phase 6 freshness slice is landed. It exposes read-only `thread/epiphany/freshness` from live retrieval summaries plus graph diff --git a/state/ledgers.msgpack b/state/ledgers.msgpack index 9e984b45..777af474 100644 Binary files a/state/ledgers.msgpack and b/state/ledgers.msgpack differ diff --git a/state/map.yaml b/state/map.yaml index d7cd0815..b4d21149 100644 --- a/state/map.yaml +++ b/state/map.yaml @@ -279,5 +279,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, twenty-four processor/foundation cuts, a real physical extraction in `epiphany-codex-bridge`, a root `epiphany-state-model` crate for durable Epiphany state, a source-grounded Codex auth spine inventory, the native `epiphany-openai-adapter` document boundary, a buildable Codex auth/model wrapper in `epiphany-openai-codex-spine`, the first native runtime caller in `epiphany-openai-runtime`, native heartbeat launch planning/job opening in `epiphany-core`, native state-update contract/validation/application in `epiphany-core`, and the route-facing mutation/view/coordinator projection services in `epiphany-codex-bridge`. `codex-protocol` no longer defines the durable `Epiphany*` state structs; it re-exports the native model for legacy rollout/API compatibility while `epiphany-core` imports the native model directly. The bridge owns Codex-facing Epiphany adapters for scene, jobs, context/planning/graph query, retrieval/indexing projection, result projection, runtime-spine result adaptation, launch/prompt doctrine, mutation document mechanics, mutation service update/promote/role-accept/reorient-accept/role-launch/reorient-launch/job-launch/job-interrupt application, live-state projection, pressure/pre-compaction rendering, freshness/reorientation projection, CRRC/coordinator/role-board projection, full `thread/epiphany/view` response construction, freshness/context/graph-query response construction, role/reorient result response construction, distill/propose patch-response construction, coordinator status/view construction, 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, JSON-RPC response shaping, watcher registration/snapshotting, and notification emission, but its root no longer imports the evacuated Epiphany policy/protocol registry. `epiphany_read_routes.rs` is about 579 lines after the full view and read-response extractions; `epiphany_mutation_routes.rs` is about 691 lines after the route-load/notification helper cut and index projection move; `epiphany_state_helpers.rs` is down to a 19-line rollout-state loader; and `codex_thread.rs` is about 1,425 lines after state-update law moved native. `epiphany-openai-adapter` defines CultCache `DatabaseEntry` request/event/receipt/auth-status documents with no Codex app-server or generic JSON dependency. `epiphany-openai-codex-spine` owns all direct Codex auth/model-transport imports for the native OpenAI path: it exposes `default_codex_home` and `auth_manager`, projects `AuthManager` / `CodexAuth` into typed `EpiphanyOpenAiAdapterStatus`, maps typed `EpiphanyOpenAiModelRequest` into Codex API `ResponsesApiRequest`, resolves auth/provider through keeper Codex crates, opens HTTP Responses streams through `codex-api`, maps deltas / completion into typed stream events and receipts, and no longer directly depends on `codex-app-server-protocol` just to name auth mode. `epiphany-openai-runtime` no longer depends directly on `codex-login`; it writes OpenAI status/request/stream-event/receipt records plus runtime sessions/jobs/results/events into `epiphany-core::runtime_spine_cache`, can emit the assistant text artifact for legacy result consumers, is now the default executor for startup-only repo birth specialists, and now has `run-worker` to load a durable `EpiphanyRuntimeWorkerLaunchRequest`, call the typed OpenAI runtime through the spine, persist typed `EpiphanyRuntimeRoleWorkerResult` / `EpiphanyRuntimeReorientWorkerResult` documents, and complete the original heartbeat/specialist runtime job without Codex worker execution; `codex exec` survives only as explicit fallback in repo-birth startup. `epiphany-mvp-coordinator` now invokes `epiphany-openai-runtime run-worker` for launched runtime job ids and no longer creates a second coordinator-owned shadow runtime job/result as a compensator. `epiphany-core::plan_runtime_spine_heartbeat_launch` validates launch contracts/conflicts and projects durable job bindings/runtime links; `epiphany-core::open_runtime_spine_heartbeat_job` owns the initialize-runtime/ensure-session/create-job sequence and now persists `EpiphanyRuntimeWorkerLaunchRequest` CultCache records keyed by runtime job id, with indexed kind/contract fields plus MessagePack-encoded typed launch documents instead of discarding work intent after queue receipt creation; `roleResult` and `reorientResult` now prefer typed worker result documents and fall back only to generic job summaries for older receipts; `epiphany-core::EpiphanyStateUpdate`, `epiphany_state_update_validation_errors`, and `apply_epiphany_state_update` own state-update document shape and mutation law while `codex-core` calls them for compatibility. Vendored `CodexThread::epiphany_launch_job` is now mostly revision check, persistence validation, launch request handoff, and rollout/session writeback for the compatibility route. Vendored `codex-core` no longer has `epiphany_distillation`, `epiphany_promotion`, `epiphany_proposal`, `epiphany_retrieval`, or `epiphany_rollout` husk modules; it re-exports native surfaces from `epiphany-core` directly, and the only rollout adapter left is the real host seam that supplies Codex's turn-boundary predicate. `epiphany-core` still depends on `codex-protocol` for Codex rollout/event reconstruction and `TokenUsageInfo` pressure input; those are the next ownership wounds. `epiphany-runtime-spine` advertises OpenAI adapter status/model-request/stream-event/receipt CultNet schemas and mutation contracts, so the native caller now has a real storage route instead of only JSON-RPC. MCP itself is correctly JSON at its protocol edge; the target is typed Epiphany intent/result/receipt wrappers around MCP, not replacing MCP JSON. The current OpenAI spine still pulls `codex-api` and a large transport dependency stack, so its next cut is dependency starvation after richer live callers move. - next_action: Cut the remaining `epiphany-core` dependency on `codex-protocol` by extracting or relocating the Codex rollout adapter and token-pressure input, then continue moving coordinator/runtime execution and operator surfaces off app-server JSON-RPC. + summary: The Codex starvation pass has five typing receipts, twenty-five processor/foundation cuts, a real physical extraction in `epiphany-codex-bridge`, a root `epiphany-state-model` crate for durable Epiphany state, a source-grounded Codex auth spine inventory, the native `epiphany-openai-adapter` document boundary, a buildable Codex auth/model wrapper in `epiphany-openai-codex-spine`, the first native runtime caller in `epiphany-openai-runtime`, native heartbeat launch planning/job opening in `epiphany-core`, native state-update contract/validation/application in `epiphany-core`, and the route-facing mutation/view/coordinator projection services in `epiphany-codex-bridge`. `codex-protocol` no longer defines the durable `Epiphany*` state structs; it re-exports the native model for legacy rollout/API compatibility while `epiphany-core` imports the native model directly. `epiphany-core` also no longer depends on `codex-protocol`: pressure derivation now accepts native `EpiphanyTokenUsageSnapshot`, and Codex rollout replay moved to `codex-core::epiphany_rollout`, where the Codex `RolloutItem` / `EventMsg` types actually belong. The bridge owns Codex-facing Epiphany adapters for scene, jobs, context/planning/graph query, retrieval/indexing projection, result projection, runtime-spine result adaptation, launch/prompt doctrine, mutation document mechanics, mutation service update/promote/role-accept/reorient-accept/role-launch/reorient-launch/job-launch/job-interrupt application, live-state projection, pressure/pre-compaction rendering, freshness/reorientation projection, CRRC/coordinator/role-board projection, full `thread/epiphany/view` response construction, freshness/context/graph-query response construction, role/reorient result response construction, distill/propose patch-response construction, coordinator status/view construction, 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, JSON-RPC response shaping, watcher registration/snapshotting, and notification emission, but its root no longer imports the evacuated Epiphany policy/protocol registry. `epiphany_read_routes.rs` is about 579 lines after the full view and read-response extractions; `epiphany_mutation_routes.rs` is about 691 lines after the route-load/notification helper cut and index projection move; `epiphany_state_helpers.rs` is down to a 19-line rollout-state loader; and `codex_thread.rs` is about 1,425 lines after state-update law moved native. `epiphany-openai-adapter` defines CultCache `DatabaseEntry` request/event/receipt/auth-status documents with no Codex app-server or generic JSON dependency. `epiphany-openai-codex-spine` owns all direct Codex auth/model-transport imports for the native OpenAI path: it exposes `default_codex_home` and `auth_manager`, projects `AuthManager` / `CodexAuth` into typed `EpiphanyOpenAiAdapterStatus`, maps typed `EpiphanyOpenAiModelRequest` into Codex API `ResponsesApiRequest`, resolves auth/provider through keeper Codex crates, opens HTTP Responses streams through `codex-api`, maps deltas / completion into typed stream events and receipts, and no longer directly depends on `codex-app-server-protocol` just to name auth mode. `epiphany-openai-runtime` no longer depends directly on `codex-login`; it writes OpenAI status/request/stream-event/receipt records plus runtime sessions/jobs/results/events into `epiphany-core::runtime_spine_cache`, can emit the assistant text artifact for legacy result consumers, is now the default executor for startup-only repo birth specialists, and now has `run-worker` to load a durable `EpiphanyRuntimeWorkerLaunchRequest`, call the typed OpenAI runtime through the spine, persist typed `EpiphanyRuntimeRoleWorkerResult` / `EpiphanyRuntimeReorientWorkerResult` documents, and complete the original heartbeat/specialist runtime job without Codex worker execution; `codex exec` survives only as explicit fallback in repo-birth startup. `epiphany-mvp-coordinator` now invokes `epiphany-openai-runtime run-worker` for launched runtime job ids and no longer creates a second coordinator-owned shadow runtime job/result as a compensator. `epiphany-core::plan_runtime_spine_heartbeat_launch` validates launch contracts/conflicts and projects durable job bindings/runtime links; `epiphany-core::open_runtime_spine_heartbeat_job` owns the initialize-runtime/ensure-session/create-job sequence and now persists `EpiphanyRuntimeWorkerLaunchRequest` CultCache records keyed by runtime job id, with indexed kind/contract fields plus MessagePack-encoded typed launch documents instead of discarding work intent after queue receipt creation; `roleResult` and `reorientResult` now prefer typed worker result documents and fall back only to generic job summaries for older receipts; `epiphany-core::EpiphanyStateUpdate`, `epiphany_state_update_validation_errors`, and `apply_epiphany_state_update` own state-update document shape and mutation law while `codex-core` calls them for compatibility. Vendored `CodexThread::epiphany_launch_job` is now mostly revision check, persistence validation, launch request handoff, and rollout/session writeback for the compatibility route. Vendored `codex-core` no longer has `epiphany_distillation`, `epiphany_promotion`, `epiphany_proposal`, or `epiphany_retrieval` husk modules; it re-exports native surfaces from `epiphany-core` directly, and now owns only the real Codex rollout adapter because it is a host seam. The remaining direct Codex dependency in `epiphany-core` is `codex-file-search`, an exact-search adapter that should be replaced or isolated behind a native retrieval crate next. `epiphany-runtime-spine` advertises OpenAI adapter status/model-request/stream-event/receipt CultNet schemas and mutation contracts, so the native caller now has a real storage route instead of only JSON-RPC. MCP itself is correctly JSON at its protocol edge; the target is typed Epiphany intent/result/receipt wrappers around MCP, not replacing MCP JSON. The current OpenAI spine still pulls `codex-api` and a large transport dependency stack, so its next cut is dependency starvation after richer live callers move. + next_action: Cut or isolate the remaining `epiphany-core` dependency on vendored `codex-file-search`, then continue moving coordinator/runtime execution and operator surfaces off app-server JSON-RPC. diff --git a/vendor/codex/codex-rs/Cargo.lock b/vendor/codex/codex-rs/Cargo.lock index 8a891e00..7023c00f 100644 --- a/vendor/codex/codex-rs/Cargo.lock +++ b/vendor/codex/codex-rs/Cargo.lock @@ -5245,7 +5245,6 @@ dependencies = [ "bm25", "chrono", "codex-file-search", - "codex-protocol", "cultcache-rs", "cultnet-rs", "epiphany-openai-adapter", diff --git a/vendor/codex/codex-rs/core/src/context/epiphany_state_instructions.rs b/vendor/codex/codex-rs/core/src/context/epiphany_state_instructions.rs index acfb2c92..1966e32e 100644 --- a/vendor/codex/codex-rs/core/src/context/epiphany_state_instructions.rs +++ b/vendor/codex/codex-rs/core/src/context/epiphany_state_instructions.rs @@ -30,7 +30,6 @@ impl ContextualUserFragment for EpiphanyStateInstructions { mod tests { use super::EpiphanyStateInstructions; use crate::context::ContextualUserFragment; - use codex_protocol::config_types::ModeKind; use codex_protocol::protocol::EpiphanyChurnState; use codex_protocol::protocol::EpiphanyCodeRef; use codex_protocol::protocol::EpiphanyGraph; @@ -39,6 +38,7 @@ mod tests { use codex_protocol::protocol::EpiphanyGraphFrontier; use codex_protocol::protocol::EpiphanyGraphNode; use codex_protocol::protocol::EpiphanyGraphs; + use codex_protocol::protocol::EpiphanyModeKind; use codex_protocol::protocol::EpiphanyModeState; use codex_protocol::protocol::EpiphanyThreadState; use std::path::PathBuf; @@ -127,7 +127,7 @@ mod tests { }), mode: Some(EpiphanyModeState { name: "epiphany".to_string(), - kind: Some(ModeKind::Default), + kind: Some(EpiphanyModeKind::Default), }), ..Default::default() }; diff --git a/epiphany-core/src/rollout.rs b/vendor/codex/codex-rs/core/src/epiphany_rollout.rs similarity index 97% rename from epiphany-core/src/rollout.rs rename to vendor/codex/codex-rs/core/src/epiphany_rollout.rs index 05f0c3e0..f61f0e12 100644 --- a/epiphany-core/src/rollout.rs +++ b/vendor/codex/codex-rs/core/src/epiphany_rollout.rs @@ -1,7 +1,8 @@ +use crate::context_manager; use codex_protocol::models::ResponseItem; +use codex_protocol::protocol::EpiphanyThreadState; use codex_protocol::protocol::EventMsg; use codex_protocol::protocol::RolloutItem; -use epiphany_state_model::EpiphanyThreadState; #[derive(Debug, Default)] struct ActiveEpiphanyReplaySegment { @@ -153,20 +154,26 @@ where epiphany_state } +pub fn latest_epiphany_state_from_codex_rollout_items( + rollout_items: &[RolloutItem], +) -> Option { + latest_epiphany_state_from_rollout_items(rollout_items, context_manager::is_user_turn_boundary) +} + #[cfg(test)] mod tests { use super::latest_epiphany_state_from_rollout_items; use codex_protocol::models::ContentItem; use codex_protocol::models::ResponseItem; use codex_protocol::protocol::CompactedItem; + use codex_protocol::protocol::EpiphanyStateItem; + use codex_protocol::protocol::EpiphanyThreadState; use codex_protocol::protocol::EventMsg; use codex_protocol::protocol::RolloutItem; use codex_protocol::protocol::ThreadRolledBackEvent; use codex_protocol::protocol::TurnCompleteEvent; use codex_protocol::protocol::TurnStartedEvent; use codex_protocol::protocol::UserMessageEvent; - use epiphany_state_model::EpiphanyStateItem; - use epiphany_state_model::EpiphanyThreadState; fn simple_is_user_turn_boundary(item: &ResponseItem) -> bool { matches!( diff --git a/vendor/codex/codex-rs/core/src/lib.rs b/vendor/codex/codex-rs/core/src/lib.rs index eabe4e8b..fa285281 100644 --- a/vendor/codex/codex-rs/core/src/lib.rs +++ b/vendor/codex/codex-rs/core/src/lib.rs @@ -22,6 +22,7 @@ pub use codex_thread::CodexThreadTurnContextOverrides; pub use codex_thread::EpiphanyJobInterruptRequest; pub use codex_thread::EpiphanyJobLaunchRequest; pub use codex_thread::ThreadConfigSnapshot; +mod epiphany_rollout; pub use epiphany_core::EPIPHANY_RETRIEVAL_DEFAULT_LIMIT; pub use epiphany_core::EPIPHANY_RETRIEVAL_MAX_LIMIT; pub use epiphany_core::EpiphanyDistillInput; @@ -38,17 +39,9 @@ pub use epiphany_core::EpiphanyStateUpdate; pub use epiphany_core::distill_observation; pub use epiphany_core::evaluate_promotion; pub use epiphany_core::propose_map_update; +pub use epiphany_rollout::latest_epiphany_state_from_codex_rollout_items as latest_epiphany_state_from_rollout_items; mod agent; -pub fn latest_epiphany_state_from_rollout_items( - rollout_items: &[codex_protocol::protocol::RolloutItem], -) -> Option { - epiphany_core::latest_epiphany_state_from_rollout_items( - rollout_items, - context_manager::is_user_turn_boundary, - ) -} - mod codex_delegate; mod command_canonicalization; mod commit_attribution; diff --git a/vendor/codex/codex-rs/core/src/session/tests.rs b/vendor/codex/codex-rs/core/src/session/tests.rs index d8f4db50..f32f93eb 100644 --- a/vendor/codex/codex-rs/core/src/session/tests.rs +++ b/vendor/codex/codex-rs/core/src/session/tests.rs @@ -95,6 +95,7 @@ use codex_protocol::protocol::EpiphanyGraphLink; use codex_protocol::protocol::EpiphanyGraphNode; use codex_protocol::protocol::EpiphanyGraphs; use codex_protocol::protocol::EpiphanyInvariant; +use codex_protocol::protocol::EpiphanyModeKind; use codex_protocol::protocol::EpiphanyModeState; use codex_protocol::protocol::EpiphanyObservation; use codex_protocol::protocol::EpiphanyScratchPad; @@ -417,7 +418,7 @@ fn sample_epiphany_state_for_prompt() -> EpiphanyThreadState { retrieval: None, mode: Some(EpiphanyModeState { name: "epiphany".to_string(), - kind: Some(ModeKind::Default), + kind: Some(EpiphanyModeKind::Default), }), planning: Default::default(), last_updated_turn_id: Some("phase2-turn".to_string()),