From e404c10537693c609fbcfcc9d48b822e0bb98f3b Mon Sep 17 00:00:00 2001 From: Meta Vens Date: Mon, 17 Aug 2026 22:00:55 +0200 Subject: [PATCH] Unify Modeling continuation actions --- .../src/bin/epiphany-mvp-coordinator.rs | 4 +- epiphany-core/src/bin/epiphany-mvp-status.rs | 4 +- epiphany-core/src/current_work.rs | 58 ++++++++----------- epiphany-core/src/resident_self.rs | 20 +++---- epiphany-core/src/surfaces/coordinator.rs | 10 ++-- .../src/surfaces/coordinator_contract.rs | 6 +- 6 files changed, 47 insertions(+), 55 deletions(-) diff --git a/epiphany-core/src/bin/epiphany-mvp-coordinator.rs b/epiphany-core/src/bin/epiphany-mvp-coordinator.rs index 6f00d14d..b871523b 100644 --- a/epiphany-core/src/bin/epiphany-mvp-coordinator.rs +++ b/epiphany-core/src/bin/epiphany-mvp-coordinator.rs @@ -513,7 +513,7 @@ fn run_coordinator(args: &Args) -> Result { let current = epiphany_core::project_current_work(&runtime_store)? .proposal_modeling .filter(|work| { - work.action == epiphany_core::EpiphanyProposalModelingContinuationAction::Launch + work.action == epiphany_core::EpiphanyModelingContinuationAction::Launch }) .ok_or_else(|| anyhow!("proposal Modeling request is not launchable"))?; if current.request.request_id != request_id { @@ -1055,7 +1055,7 @@ fn run_coordinator(args: &Args) -> Result { .proposal_modeling .filter(|work| { work.action - == epiphany_core::EpiphanyProposalModelingContinuationAction::Launch + == epiphany_core::EpiphanyModelingContinuationAction::Launch }) .ok_or_else(|| anyhow!("proposal Modeling work is not launchable"))?; if current.request.request_id != request_id { diff --git a/epiphany-core/src/bin/epiphany-mvp-status.rs b/epiphany-core/src/bin/epiphany-mvp-status.rs index 7d3f9cea..0dc5902e 100644 --- a/epiphany-core/src/bin/epiphany-mvp-status.rs +++ b/epiphany-core/src/bin/epiphany-mvp-status.rs @@ -552,7 +552,7 @@ fn run_native_status(args: &Args, include_auxiliary_status: bool) -> Result Result, - pub body_modeling_action: Option, + pub body_modeling_action: Option, pub research_continuation_action: Option, pub frontier_planning_stage: RepoFrontierPlanningLifecycleStage, pub proposal_modeling: Option, @@ -28,7 +28,7 @@ pub struct EpiphanyCurrentWorkProjection { #[derive(Clone, Copy, Debug, PartialEq, Eq, Serialize, Deserialize)] #[serde(rename_all = "camelCase")] -pub enum EpiphanyProposalModelingContinuationAction { +pub enum EpiphanyModelingContinuationAction { Launch, Wait, Review, @@ -37,18 +37,10 @@ pub enum EpiphanyProposalModelingContinuationAction { #[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)] pub struct EpiphanyProposalModelingWorkProjection { pub request: RepoFrontierProposalModelingRequest, - pub action: EpiphanyProposalModelingContinuationAction, + pub action: EpiphanyModelingContinuationAction, pub job_id: Option, } -#[derive(Clone, Copy, Debug, PartialEq, Eq, Serialize, Deserialize)] -#[serde(rename_all = "camelCase")] -pub enum EpiphanyBodyModelingContinuationAction { - Launch, - Wait, - Review, -} - #[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)] pub struct EpiphanyBodyModelingWorkProjection { pub work_id: String, @@ -307,7 +299,7 @@ pub fn project_current_work(store_path: impl AsRef) -> Result { let action = body_modeling_continuation_action(&cache, &work.work_id)?; ( - (action == EpiphanyBodyModelingContinuationAction::Launch).then_some(work), + (action == EpiphanyModelingContinuationAction::Launch).then_some(work), Some(action), ) } @@ -336,7 +328,7 @@ pub fn project_current_work(store_path: impl AsRef) -> Result Result { +) -> Result { let mut bindings = cache .get_all::()? .into_iter() @@ -344,26 +336,26 @@ fn body_modeling_continuation_action( .collect::>(); bindings.sort_by_key(|binding| binding.attempt_ordinal); let Some(binding) = bindings.last() else { - return Ok(EpiphanyBodyModelingContinuationAction::Launch); + return Ok(EpiphanyModelingContinuationAction::Launch); }; let job = cache .get::(&binding.job_id)? .ok_or_else(|| anyhow!("Body Modeling launch binding lost its runtime job"))?; Ok(match job.status { crate::EpiphanyRuntimeJobStatus::Failed | crate::EpiphanyRuntimeJobStatus::Cancelled => { - EpiphanyBodyModelingContinuationAction::Launch + EpiphanyModelingContinuationAction::Launch } crate::EpiphanyRuntimeJobStatus::Completed => { if cache .get::(&binding.job_id)? .is_some() { - EpiphanyBodyModelingContinuationAction::Review + EpiphanyModelingContinuationAction::Review } else { - EpiphanyBodyModelingContinuationAction::Wait + EpiphanyModelingContinuationAction::Wait } } - _ => EpiphanyBodyModelingContinuationAction::Wait, + _ => EpiphanyModelingContinuationAction::Wait, }) } @@ -392,7 +384,7 @@ fn current_proposal_modeling_work( let Some(binding) = request_bindings.last() else { return Ok(Some(EpiphanyProposalModelingWorkProjection { request, - action: EpiphanyProposalModelingContinuationAction::Launch, + action: EpiphanyModelingContinuationAction::Launch, job_id: None, })); }; @@ -421,16 +413,16 @@ fn current_proposal_modeling_work( let action = match job.status { crate::EpiphanyRuntimeJobStatus::Failed | crate::EpiphanyRuntimeJobStatus::Cancelled => { - EpiphanyProposalModelingContinuationAction::Launch + EpiphanyModelingContinuationAction::Launch } crate::EpiphanyRuntimeJobStatus::Completed if result.is_some() => { crate::runtime_spine::validate_proposal_modeling_worker_fulfillment( cache, result.as_ref().expect("checked terminal result"), )?; - EpiphanyProposalModelingContinuationAction::Review + EpiphanyModelingContinuationAction::Review } - _ => EpiphanyProposalModelingContinuationAction::Wait, + _ => EpiphanyModelingContinuationAction::Wait, }; return Ok(Some(EpiphanyProposalModelingWorkProjection { request, @@ -444,7 +436,7 @@ fn current_proposal_modeling_work( pub fn body_modeling_continuation_action_for_job( store_path: impl AsRef, job_id: &str, -) -> Result> { +) -> Result> { let mut cache = crate::runtime_spine_cache(store_path)?; cache.pull_all_backing_stores()?; let bindings = cache @@ -475,7 +467,7 @@ pub fn body_modeling_continuation_action_for_job( pub fn current_body_modeling_review_job_id(store_path: impl AsRef) -> Result> { let store_path = store_path.as_ref(); if crate::project_current_work(store_path)?.body_modeling_action - != Some(EpiphanyBodyModelingContinuationAction::Review) + != Some(EpiphanyModelingContinuationAction::Review) { return Ok(None); } @@ -494,7 +486,7 @@ pub fn current_body_modeling_review_job_id(store_path: impl AsRef) -> Resu pub fn proposal_modeling_continuation_action_for_job( store_path: impl AsRef, job_id: &str, -) -> Result> { +) -> Result> { Ok(project_current_work(store_path)? .proposal_modeling .filter(|work| work.job_id.as_deref() == Some(job_id)) @@ -506,7 +498,7 @@ pub fn current_proposal_modeling_review_job_id( ) -> Result> { Ok(project_current_work(store_path)? .proposal_modeling - .filter(|work| work.action == EpiphanyProposalModelingContinuationAction::Review) + .filter(|work| work.action == EpiphanyModelingContinuationAction::Review) .and_then(|work| work.job_id)) } @@ -839,7 +831,7 @@ pub fn launch_current_proposal_modeling_work( } let work = project_current_work(store_path)? .proposal_modeling - .filter(|work| work.action == EpiphanyProposalModelingContinuationAction::Launch) + .filter(|work| work.action == EpiphanyModelingContinuationAction::Launch) .ok_or_else(|| anyhow!("Mind has no launchable proposal Modeling work"))?; let mut cache = crate::runtime_spine_cache(store_path)?; cache.pull_all_backing_stores()?; @@ -1230,7 +1222,7 @@ mod tests { assert_eq!(current_work.body_modeling, Some(projected_work.clone())); assert_eq!( current_work.body_modeling_action, - Some(EpiphanyBodyModelingContinuationAction::Launch) + Some(EpiphanyModelingContinuationAction::Launch) ); assert_eq!( current_work.mind_projection_digest, @@ -1260,7 +1252,7 @@ mod tests { assert!(scheduled_work.body_modeling.is_none()); assert_eq!( scheduled_work.body_modeling_action, - Some(EpiphanyBodyModelingContinuationAction::Wait) + Some(EpiphanyModelingContinuationAction::Wait) ); assert!(crate::resident_self_body_modeling_pressure(&store, 2)?.is_none()); let mut scheduled_cache = crate::runtime_spine_cache(&store)?; @@ -1360,7 +1352,7 @@ mod tests { cache.put(&job.job_id, &job)?; assert_eq!( project_current_work(&store)?.body_modeling_action, - Some(EpiphanyBodyModelingContinuationAction::Review) + Some(EpiphanyModelingContinuationAction::Review) ); let continuation = crate::EpiphanyCoordinatorRunReceipt { schema_version: crate::COORDINATOR_RUN_RECEIPT_SCHEMA_VERSION.into(), @@ -1440,7 +1432,7 @@ mod tests { assert_eq!(proposal_work.request, request); assert_eq!( proposal_work.action, - EpiphanyProposalModelingContinuationAction::Launch + EpiphanyModelingContinuationAction::Launch ); let racers = (0..2) .map(|_| { @@ -1483,7 +1475,7 @@ mod tests { .proposal_modeling .expect("launched proposal remains current") .action, - EpiphanyProposalModelingContinuationAction::Wait + EpiphanyModelingContinuationAction::Wait ); assert!( launch_current_proposal_modeling_work( @@ -1645,7 +1637,7 @@ mod tests { .proposal_modeling .expect("terminal proposal remains current until admission") .action, - EpiphanyProposalModelingContinuationAction::Review + EpiphanyModelingContinuationAction::Review ); let proposal_commit = accept_proposal_modeling_result( &store, diff --git a/epiphany-core/src/resident_self.rs b/epiphany-core/src/resident_self.rs index 5ad71646..d1574b26 100644 --- a/epiphany-core/src/resident_self.rs +++ b/epiphany-core/src/resident_self.rs @@ -1210,7 +1210,7 @@ pub fn ingest_resident_self_domain_pressure( // the next one on a later ingestion cycle. if let Some(selection) = crate::project_current_work(runtime_store)? .proposal_modeling - .filter(|work| work.action == crate::EpiphanyProposalModelingContinuationAction::Launch) + .filter(|work| work.action == crate::EpiphanyModelingContinuationAction::Launch) .map(|work| work.request) { inserted += usize::from(enqueue_resident_self_pressure_idempotent( @@ -1358,11 +1358,11 @@ pub(crate) fn resident_self_safe_continuation_action( crate::body_modeling_continuation_action_for_job(runtime_store, job_id)? { return Ok(match action { - crate::EpiphanyBodyModelingContinuationAction::Launch => { + crate::EpiphanyModelingContinuationAction::Launch => { Some("launchModeling".to_string()) } - crate::EpiphanyBodyModelingContinuationAction::Wait => None, - crate::EpiphanyBodyModelingContinuationAction::Review => { + crate::EpiphanyModelingContinuationAction::Wait => None, + crate::EpiphanyModelingContinuationAction::Review => { Some("reviewModelingResult".to_string()) } }); @@ -1371,11 +1371,11 @@ pub(crate) fn resident_self_safe_continuation_action( crate::proposal_modeling_continuation_action_for_job(runtime_store, job_id)? { return Ok(match action { - crate::EpiphanyProposalModelingContinuationAction::Launch => { + crate::EpiphanyModelingContinuationAction::Launch => { Some("launchModeling".to_string()) } - crate::EpiphanyProposalModelingContinuationAction::Wait => None, - crate::EpiphanyProposalModelingContinuationAction::Review => { + crate::EpiphanyModelingContinuationAction::Wait => None, + crate::EpiphanyModelingContinuationAction::Review => { Some("reviewModelingResult".to_string()) } }); @@ -1521,13 +1521,13 @@ fn resident_self_failed_receipt_typed_continuation_action( Ok( match crate::proposal_modeling_continuation_action_for_job(runtime_store, &evidence.job_id)? { - Some(crate::EpiphanyProposalModelingContinuationAction::Review) => { + Some(crate::EpiphanyModelingContinuationAction::Review) => { Some("reviewModelingResult".to_string()) } - Some(crate::EpiphanyProposalModelingContinuationAction::Launch) => { + Some(crate::EpiphanyModelingContinuationAction::Launch) => { Some("launchModeling".to_string()) } - Some(crate::EpiphanyProposalModelingContinuationAction::Wait) | None => None, + Some(crate::EpiphanyModelingContinuationAction::Wait) | None => None, }, ) } diff --git a/epiphany-core/src/surfaces/coordinator.rs b/epiphany-core/src/surfaces/coordinator.rs index d129b0b0..e79bde1e 100644 --- a/epiphany-core/src/surfaces/coordinator.rs +++ b/epiphany-core/src/surfaces/coordinator.rs @@ -1,7 +1,7 @@ use epiphany_core::EpiphanyCrrcAction; use epiphany_core::EpiphanyCrrcSceneAction; use epiphany_core::EpiphanyCrrcStateStatus; -use epiphany_core::EpiphanyProposalModelingContinuationAction; +use epiphany_core::EpiphanyModelingContinuationAction; use epiphany_core::EpiphanyReorientFindingInterpretation; use epiphany_core::EpiphanyRoleBoardLane; use epiphany_core::EpiphanyRoleFindingInterpretation; @@ -699,7 +699,7 @@ pub fn recommend_coordinator_action( if let Some(action) = input.proposal_modeling_action { return match action { - EpiphanyProposalModelingContinuationAction::Launch => build( + EpiphanyModelingContinuationAction::Launch => build( EpiphanyCoordinatorAction::LaunchModeling, Some(EpiphanyCoordinatorRoleId::Modeling), Some(EpiphanyCoordinatorSceneAction::RoleLaunch), @@ -707,7 +707,7 @@ pub fn recommend_coordinator_action( true, "The oldest unresolved proposal request is ready for its exact Modeling attempt.", ), - EpiphanyProposalModelingContinuationAction::Wait => build( + EpiphanyModelingContinuationAction::Wait => build( EpiphanyCoordinatorAction::WaitForModelingResult, Some(EpiphanyCoordinatorRoleId::Modeling), Some(EpiphanyCoordinatorSceneAction::RoleResult), @@ -715,7 +715,7 @@ pub fn recommend_coordinator_action( false, "The exact proposal Modeling attempt is still running.", ), - EpiphanyProposalModelingContinuationAction::Review => build( + EpiphanyModelingContinuationAction::Review => build( EpiphanyCoordinatorAction::ReviewModelingResult, Some(EpiphanyCoordinatorRoleId::Modeling), Some(EpiphanyCoordinatorSceneAction::RoleResult), @@ -1489,7 +1489,7 @@ mod tests { fn selected_user_proposal_preempts_generic_regather() { let decision = recommend_coordinator_action(EpiphanyCoordinatorInput { recommendation: recommendation(EpiphanyCrrcAction::RegatherManually), - proposal_modeling_action: Some(EpiphanyProposalModelingContinuationAction::Launch), + proposal_modeling_action: Some(EpiphanyModelingContinuationAction::Launch), ..input() }); assert_eq!(decision.action, EpiphanyCoordinatorAction::LaunchModeling); diff --git a/epiphany-core/src/surfaces/coordinator_contract.rs b/epiphany-core/src/surfaces/coordinator_contract.rs index 3155b1fe..4c7e3517 100644 --- a/epiphany-core/src/surfaces/coordinator_contract.rs +++ b/epiphany-core/src/surfaces/coordinator_contract.rs @@ -6,7 +6,7 @@ use super::EpiphanyPressure; use super::EpiphanyPressureLevel; use super::EpiphanyReorientAction; use super::EpiphanyRoleBoardLane; -use crate::EpiphanyProposalModelingContinuationAction; +use crate::EpiphanyModelingContinuationAction; use crate::RepoFrontierPlanningLifecycleStage; use crate::RepoFrontierResearchContinuationAction; use serde::{Deserialize, Serialize}; @@ -167,7 +167,7 @@ pub struct EpiphanyCoordinatorInput { /// lifecycle. Self may advance it, but only Mind's result can decide adoption. pub frontier_planning_stage: RepoFrontierPlanningLifecycleStage, /// Exact current action for the oldest unresolved proposal Modeling request. - pub proposal_modeling_action: Option, + pub proposal_modeling_action: Option, pub body_modeling_work_ready: bool, pub body_modeling_review_ready: bool, } @@ -220,7 +220,7 @@ pub struct EpiphanyCoordinatorStatusInput { pub hands_frontier_ready: bool, pub research_continuation_action: Option, pub frontier_planning_stage: RepoFrontierPlanningLifecycleStage, - pub proposal_modeling_action: Option, + pub proposal_modeling_action: Option, pub body_modeling_work_ready: bool, pub body_modeling_review_ready: bool, }