Move rollout state loading into bridge

This commit is contained in:
Meta Vens 2026-05-14 08:20:53 +01:00
commit 473ba34390
6 changed files with 32 additions and 27 deletions

View file

@ -1,5 +1,28 @@
use std::path::Path;
use codex_core::CodexThread;
use codex_core::RolloutRecorder;
use codex_core::latest_epiphany_state_from_rollout_items;
use codex_protocol::protocol::EpiphanyThreadState;
use codex_protocol::protocol::InitialHistory;
pub async fn load_epiphany_state_from_rollout_path(
rollout_path: &Path,
) -> std::result::Result<Option<EpiphanyThreadState>, String> {
let items = match RolloutRecorder::get_rollout_history(rollout_path)
.await
.map_err(|err| {
format!(
"failed to load rollout `{}` for Epiphany state: {err}",
rollout_path.display()
)
})? {
InitialHistory::New | InitialHistory::Cleared => Vec::new(),
InitialHistory::Forked(items) => items,
InitialHistory::Resumed(resumed) => resumed.history,
};
Ok(latest_epiphany_state_from_rollout_items(&items))
}
pub async fn live_thread_epiphany_state(thread: &CodexThread) -> Option<EpiphanyThreadState> {
let mut epiphany_state = thread.epiphany_state().await;

View file

@ -511,11 +511,13 @@ patch projection, role patch policy reviewability, finding summaries,
reorient acceptance scratch/checkpoint synthesis, and changed-field derivation.
It also moved completed role/reorient runtime-result loading into
`epiphany-codex-bridge/src/runtime_results.rs` and live-state projection into
`epiphany-codex-bridge/src/state.rs`. `epiphany_mutation_routes.rs` is now
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.
`epiphany-codex-bridge/src/state.rs`. `epiphany_mutation_routes.rs` was then
about 1,271 lines and `epiphany_state_helpers.rs` was down to a 19-line
rollout-state loader. A later cut moved that loader into
`epiphany-codex-bridge::state` too and deleted the vendored helper module. 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

Binary file not shown.

File diff suppressed because one or more lines are too long

View file

@ -1,11 +1,9 @@
mod epiphany_automation;
mod epiphany_mutation_routes;
mod epiphany_read_routes;
mod epiphany_state_helpers;
pub(crate) use self::epiphany_automation::maybe_run_epiphany_coordinator_automation_for_turn_boundary;
pub(crate) use self::epiphany_automation::maybe_run_epiphany_pre_compaction_checkpoint_intervention_for_token_count;
use self::epiphany_state_helpers::load_epiphany_state_from_rollout_path;
use crate::bespoke_event_handling::apply_bespoke_event_handling;
use crate::bespoke_event_handling::maybe_emit_hook_prompt_item_completed;
use crate::command_exec::CommandExecManager;
@ -316,6 +314,7 @@ use codex_utils_pty::DEFAULT_OUTPUT_BYTES_CAP;
use epiphany_codex_bridge::invalidation::EpiphanyInvalidationManager;
use epiphany_codex_bridge::invalidation::epiphany_freshness_watcher_snapshot;
use epiphany_codex_bridge::state::live_thread_epiphany_state;
use epiphany_codex_bridge::state::load_epiphany_state_from_rollout_path;
use std::collections::HashMap;
use std::collections::HashSet;
use std::io::Error as IoError;

View file

@ -1,19 +0,0 @@
use std::path::Path;
use super::read_rollout_items_from_rollout;
use codex_core::latest_epiphany_state_from_rollout_items;
use codex_protocol::protocol::EpiphanyThreadState;
pub(super) async fn load_epiphany_state_from_rollout_path(
rollout_path: &Path,
) -> std::result::Result<Option<EpiphanyThreadState>, String> {
let items = read_rollout_items_from_rollout(rollout_path)
.await
.map_err(|err| {
format!(
"failed to load rollout `{}` for Epiphany state: {err}",
rollout_path.display()
)
})?;
Ok(latest_epiphany_state_from_rollout_items(&items))
}