diff --git a/epiphany-core/src/bin/epiphany-mvp-coordinator.rs b/epiphany-core/src/bin/epiphany-mvp-coordinator.rs index 659c2aac..1fb0e320 100644 --- a/epiphany-core/src/bin/epiphany-mvp-coordinator.rs +++ b/epiphany-core/src/bin/epiphany-mvp-coordinator.rs @@ -740,9 +740,11 @@ fn run_coordinator(args: &Args) -> Result { "reviewResearchResult" | "reviewModelingResult" | "reviewVerificationResult" => { let role_id = role_id_for_coordinator_action(&action) .ok_or_else(|| anyhow!("unsupported review action {action}"))?; + let current_work = epiphany_core::project_current_work(&runtime_store)?; if role_id == "research" - && let Some(job_id) = - epiphany_core::current_frontier_research_review_job_id(&runtime_store)? + && current_work.research.stage + == epiphany_core::RepoFrontierResearchLifecycleStage::ResultReady + && let Some(job_id) = current_work.research.worker_job_id.as_deref() { let result = epiphany_core::runtime_role_worker_result(&runtime_store, &job_id)? @@ -778,10 +780,10 @@ fn run_coordinator(args: &Args) -> Result { continue; } if role_id == "verification" - && let Some(job_id) = - epiphany_core::current_frontier_verification_review_job_id( - &runtime_store, - )? + && let Some(job_id) = current_work + .verification + .as_ref() + .and_then(|work| work.attempt.review_job_id()) { let result = epiphany_core::runtime_role_worker_result(&runtime_store, &job_id)? @@ -817,8 +819,10 @@ fn run_coordinator(args: &Args) -> Result { continue; } if role_id == "modeling" - && let Some(job_id) = - epiphany_core::current_proposal_modeling_review_job_id(&runtime_store)? + && let Some(job_id) = current_work + .proposal_modeling + .as_ref() + .and_then(|work| work.attempt.review_job_id()) { let result = epiphany_core::runtime_role_worker_result(&runtime_store, &job_id)? @@ -854,8 +858,10 @@ fn run_coordinator(args: &Args) -> Result { continue; } if role_id == "modeling" - && let Some(job_id) = - epiphany_core::current_body_modeling_review_job_id(&runtime_store)? + && let Some(job_id) = current_work + .body_modeling + .as_ref() + .and_then(|work| work.attempt.review_job_id()) { let result = epiphany_core::runtime_role_worker_result(&runtime_store, &job_id)? @@ -891,10 +897,10 @@ fn run_coordinator(args: &Args) -> Result { continue; } if role_id == "modeling" - && let Some(job_id) = - epiphany_core::current_frontier_verdict_modeling_review_job_id( - &runtime_store, - )? + && let Some(job_id) = current_work + .frontier_verdict_modeling + .as_ref() + .and_then(|work| work.attempt.review_job_id()) { let result = epiphany_core::runtime_role_worker_result(&runtime_store, &job_id)? diff --git a/epiphany-core/src/current_work.rs b/epiphany-core/src/current_work.rs index c0b56fe6..1e654a51 100644 --- a/epiphany-core/src/current_work.rs +++ b/epiphany-core/src/current_work.rs @@ -86,6 +86,14 @@ pub struct EpiphanyAgentPassAttemptProjection { pub job_id: Option, } +impl EpiphanyAgentPassAttemptProjection { + pub fn review_job_id(&self) -> Option<&str> { + (self.action == EpiphanyAgentPassContinuationAction::Review) + .then_some(self.job_id.as_deref()) + .flatten() + } +} + #[derive(Clone, Debug, PartialEq, Eq, DatabaseEntry)] #[cultcache( type = "epiphany.mind.agent_pass_admission_refusal.v1", @@ -1049,53 +1057,6 @@ fn current_proposal_modeling_work( Ok(None) } -pub fn current_body_modeling_review_job_id(store_path: impl AsRef) -> Result> { - Ok(crate::project_current_work(store_path)? - .body_modeling - .filter(|work| work.attempt.action == EpiphanyAgentPassContinuationAction::Review) - .and_then(|work| work.attempt.job_id)) -} - -pub fn current_proposal_modeling_review_job_id( - store_path: impl AsRef, -) -> Result> { - Ok(project_current_work(store_path)? - .proposal_modeling - .filter(|work| work.attempt.action == EpiphanyAgentPassContinuationAction::Review) - .and_then(|work| work.attempt.job_id)) -} - -pub fn current_frontier_verdict_modeling_review_job_id( - store_path: impl AsRef, -) -> Result> { - Ok(project_current_work(store_path)? - .frontier_verdict_modeling - .filter(|work| work.attempt.action == EpiphanyAgentPassContinuationAction::Review) - .and_then(|work| work.attempt.job_id)) -} - -pub fn current_frontier_research_review_job_id( - store_path: impl AsRef, -) -> Result> { - let mut cache = crate::runtime_spine_cache(store_path)?; - cache.pull_all_backing_stores()?; - let lifecycle = crate::runtime_spine::repo_frontier_research_lifecycle(&cache)?; - Ok( - (lifecycle.stage == crate::RepoFrontierResearchLifecycleStage::ResultReady) - .then_some(lifecycle.worker_job_id) - .flatten(), - ) -} - -pub fn current_frontier_verification_review_job_id( - store_path: impl AsRef, -) -> Result> { - Ok(project_current_work(store_path)? - .verification - .filter(|work| work.attempt.action == EpiphanyAgentPassContinuationAction::Review) - .and_then(|work| work.attempt.job_id)) -} - pub(crate) fn frontier_planning_attempt_ordinal(request_id: &str, job_id: &str) -> Result { let prefix = format!("frontier-planning-{request_id}-attempt-"); job_id