diff --git a/epiphany-core/src/lib.rs b/epiphany-core/src/lib.rs index 151ce558..fda2294a 100644 --- a/epiphany-core/src/lib.rs +++ b/epiphany-core/src/lib.rs @@ -283,7 +283,6 @@ pub use runtime_spine::RuntimeSpineJobOptions; pub use runtime_spine::RuntimeSpineJobResultOptions; pub use runtime_spine::RuntimeSpineSessionClosureOptions; pub use runtime_spine::RuntimeSpineSessionOptions; -pub use runtime_spine::RuntimeTypedFulfillmentEvidence; pub use runtime_spine::abandon_unactivated_runtime_worker_process; pub use runtime_spine::activate_runtime_worker_process; pub use runtime_spine::bind_runtime_repository_domain; @@ -338,8 +337,8 @@ pub use runtime_spine::runtime_repo_frontier_research_lifecycle; pub use runtime_spine::runtime_requested_public_source_refs_for_worker; pub use runtime_spine::runtime_role_worker_result; pub use runtime_spine::runtime_spine_cache; -pub use runtime_spine::runtime_typed_request_attempt_exists; -pub use runtime_spine::runtime_typed_request_fulfillment; +pub(crate) use runtime_spine::runtime_typed_request_attempt_exists; +pub(crate) use runtime_spine::runtime_typed_request_fulfillment; pub use runtime_spine::runtime_worker_launch_request; pub use runtime_spine::runtime_worker_process_claim; pub use runtime_spine::runtime_worker_process_claims; @@ -347,7 +346,7 @@ pub use runtime_spine::select_and_commit_repo_frontier_planning_request; pub use runtime_spine::select_and_commit_repo_frontier_research_request; pub use runtime_spine::select_and_commit_repo_frontier_route; pub use runtime_spine::terminalize_model_pass_failure_session; -pub use runtime_worker_attempt::{RuntimeTypedRequestRef, WorkerProcessStatus}; +pub(crate) use runtime_worker_attempt::{RuntimeTypedRequestRef, WorkerProcessStatus}; pub use soul_gateway::*; pub use state_ledger::EpiphanyBranchRecord; pub use state_ledger::EpiphanyLedgerEvidenceRecord; diff --git a/epiphany-core/src/runtime_spine.rs b/epiphany-core/src/runtime_spine.rs index 3292021e..c4174800 100644 --- a/epiphany-core/src/runtime_spine.rs +++ b/epiphany-core/src/runtime_spine.rs @@ -4775,10 +4775,9 @@ pub fn runtime_role_worker_result( } #[derive(Clone, Debug, PartialEq, Eq)] -pub struct RuntimeTypedFulfillmentEvidence { +pub(crate) struct RuntimeTypedFulfillmentEvidence { pub job_id: String, pub result_id: String, - pub request_id: String, } struct ValidatedProposalModelingWorkerFulfillment { @@ -5015,7 +5014,7 @@ pub(crate) fn validate_proposal_modeling_worker_admission( Ok(()) } -pub fn runtime_typed_request_fulfillment( +pub(crate) fn runtime_typed_request_fulfillment( store_path: impl AsRef, request: RuntimeTypedRequestRef<'_>, ) -> Result> { @@ -5096,7 +5095,6 @@ pub fn runtime_typed_request_fulfillment( .fulfilled_result_id() .map(str::to_string) .expect("validated archived result"), - request_id: request_id.to_string(), })); } let matches = cache @@ -5169,7 +5167,6 @@ pub fn runtime_typed_request_fulfillment( Ok(Some(RuntimeTypedFulfillmentEvidence { job_id: result.job_id.clone(), result_id: result.result_id.clone(), - request_id: request_id.to_string(), })) } @@ -8753,7 +8750,7 @@ fn validate_coordinator_run_receipt(receipt: &EpiphanyCoordinatorRunReceipt) -> Ok(()) } -pub fn runtime_typed_request_attempt_exists( +pub(crate) fn runtime_typed_request_attempt_exists( store_path: impl AsRef, request: RuntimeTypedRequestRef<'_>, ) -> Result { diff --git a/epiphany-core/src/runtime_worker_attempt.rs b/epiphany-core/src/runtime_worker_attempt.rs index 775ed181..bb52aa2d 100644 --- a/epiphany-core/src/runtime_worker_attempt.rs +++ b/epiphany-core/src/runtime_worker_attempt.rs @@ -1,7 +1,7 @@ use anyhow::{Result, anyhow}; #[derive(Clone, Copy, Debug, Eq, PartialEq)] -pub enum WorkerProcessStatus { +pub(crate) enum WorkerProcessStatus { Claimed, Active, TerminalResult, @@ -11,7 +11,7 @@ pub enum WorkerProcessStatus { } impl WorkerProcessStatus { - pub fn parse(value: &str) -> Result { + pub(crate) fn parse(value: &str) -> Result { match value { "claimed" => Ok(Self::Claimed), "active" => Ok(Self::Active), @@ -23,7 +23,7 @@ impl WorkerProcessStatus { } } - pub fn as_str(self) -> &'static str { + pub(crate) fn as_str(self) -> &'static str { match self { Self::Claimed => "claimed", Self::Active => "active", @@ -34,28 +34,25 @@ impl WorkerProcessStatus { } } - pub fn is_live(self) -> bool { + pub(crate) fn is_live(self) -> bool { matches!(self, Self::Claimed | Self::Active) } - pub fn is_fulfilled_terminal(self) -> bool { + pub(crate) fn is_fulfilled_terminal(self) -> bool { self == Self::TerminalResult } - pub fn is_failed_terminal(self) -> bool { + pub(crate) fn is_failed_terminal(self) -> bool { matches!( self, Self::TerminalDeath | Self::TerminalUnactivated | Self::TerminalFailure ) } - pub fn is_terminal(self) -> bool { - self.is_fulfilled_terminal() || self.is_failed_terminal() - } - pub fn allows_retry(self) -> bool { + pub(crate) fn allows_retry(self) -> bool { self.is_failed_terminal() } } #[derive(Clone, Copy, Debug, Eq, PartialEq)] -pub enum RuntimeTypedRequestRef<'a> { +pub(crate) enum RuntimeTypedRequestRef<'a> { ProposalModeling(&'a str), FrontierVerdictModeling(&'a str), FrontierResearch(&'a str), @@ -65,7 +62,7 @@ pub enum RuntimeTypedRequestRef<'a> { } impl<'a> RuntimeTypedRequestRef<'a> { - pub fn request_id(self) -> &'a str { + pub(crate) fn request_id(self) -> &'a str { match self { Self::ProposalModeling(id) | Self::FrontierVerdictModeling(id) @@ -76,7 +73,7 @@ impl<'a> RuntimeTypedRequestRef<'a> { } } - pub fn kind(self) -> &'static str { + pub(crate) fn kind(self) -> &'static str { match self { Self::ProposalModeling(_) => "proposal-modeling", Self::FrontierVerdictModeling(_) => "frontier-verdict-modeling", @@ -87,7 +84,7 @@ impl<'a> RuntimeTypedRequestRef<'a> { } } - pub fn matches_launch(self, launch: &crate::EpiphanyRuntimeWorkerLaunchRequest) -> bool { + pub(crate) fn matches_launch(self, launch: &crate::EpiphanyRuntimeWorkerLaunchRequest) -> bool { match self { Self::ProposalModeling(id) => { launch.proposal_modeling_request_id.as_deref() == Some(id) @@ -113,7 +110,7 @@ impl<'a> RuntimeTypedRequestRef<'a> { } } - pub fn matches_result(self, result: &crate::EpiphanyRuntimeRoleWorkerResult) -> bool { + pub(crate) fn matches_result(self, result: &crate::EpiphanyRuntimeRoleWorkerResult) -> bool { match self { Self::ProposalModeling(id) => { result.proposal_modeling_request_id.as_deref() == Some(id) @@ -139,7 +136,7 @@ impl<'a> RuntimeTypedRequestRef<'a> { } impl crate::EpiphanyRuntimeWorkerLaunchRequest { - pub fn typed_request_ref(&self) -> Result>> { + pub(crate) fn typed_request_ref(&self) -> Result>> { let requests = [ self.proposal_modeling_request_id .as_deref() @@ -172,27 +169,3 @@ impl crate::EpiphanyRuntimeWorkerLaunchRequest { } } } - -#[cfg(test)] -mod tests { - use super::*; - - #[test] - fn status_classes_are_exhaustive_and_disjoint() -> Result<()> { - for value in [ - "claimed", - "active", - "terminal-result", - "terminal-death", - "terminal-unactivated", - "terminal-failure", - ] { - let status = WorkerProcessStatus::parse(value)?; - assert_eq!(status.as_str(), value); - assert_ne!(status.is_live(), status.is_terminal()); - assert_eq!(status.allows_retry(), status.is_failed_terminal()); - } - assert!(WorkerProcessStatus::parse("completed").is_err()); - Ok(()) - } -}