diff --git a/epiphany-core/src/lib.rs b/epiphany-core/src/lib.rs index 5c45f8ad..72e0f422 100644 --- a/epiphany-core/src/lib.rs +++ b/epiphany-core/src/lib.rs @@ -288,9 +288,6 @@ 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::archive_completed_model_session; -pub use runtime_spine::archive_failed_runtime_worker_attempt; -pub use runtime_spine::archive_fulfilled_runtime_worker_attempt; pub use runtime_spine::bind_runtime_repository_domain; pub use runtime_spine::bind_runtime_to_swarm; pub use runtime_spine::canonical_repo_frontier_plan_candidate_id; diff --git a/epiphany-core/src/runtime_spine.rs b/epiphany-core/src/runtime_spine.rs index 9f046c8c..791dd2d0 100644 --- a/epiphany-core/src/runtime_spine.rs +++ b/epiphany-core/src/runtime_spine.rs @@ -2063,16 +2063,6 @@ pub(crate) fn validate_terminal_tool_execution_family( Ok(()) } -pub fn archive_completed_model_session( - store_path: impl AsRef, - session_id: &str, - archived_at: &str, -) -> Result { - archive_completed_model_session_with_before_commit(store_path, session_id, archived_at, || { - Ok(()) - }) -} - pub fn retain_completed_runtime_sessions( store_path: impl AsRef, retain_recent: usize, @@ -2121,15 +2111,11 @@ pub fn retain_completed_runtime_sessions( Ok(archived) } -fn archive_completed_model_session_with_before_commit( +fn archive_completed_model_session( store_path: impl AsRef, session_id: &str, archived_at: &str, - before_commit: F, -) -> Result -where - F: FnOnce() -> Result<()>, -{ +) -> Result { validate_non_empty(session_id, "archived runtime session id")?; chrono::DateTime::parse_from_rfc3339(archived_at) .map_err(|error| anyhow!("runtime session archive timestamp is invalid: {error}"))?; @@ -2574,7 +2560,6 @@ where decision_context_ids: decision_context_ids.into_iter().collect(), }; let (replacement, _) = cache.prepare_entry(session_id, &archive)?; - before_commit()?; if !runtime_spine_backing_store(store_path)?.replace_and_delete_if_snapshot_unchanged( &snapshot, vec![replacement], @@ -9318,38 +9303,6 @@ pub fn runtime_typed_request_attempt_exists( .any(|launch| request.matches_launch(launch))) } -pub fn archive_failed_runtime_worker_attempt( - store_path: impl AsRef, - job_id: &str, - live_resident_request_ids: &BTreeSet, - archived_at: &str, -) -> Result { - archive_runtime_worker_attempt( - store_path, - job_id, - live_resident_request_ids, - archived_at, - false, - || Ok(()), - ) -} - -pub fn archive_fulfilled_runtime_worker_attempt( - store_path: impl AsRef, - job_id: &str, - live_resident_request_ids: &BTreeSet, - archived_at: &str, -) -> Result { - archive_runtime_worker_attempt( - store_path, - job_id, - live_resident_request_ids, - archived_at, - true, - || Ok(()), - ) -} - fn validate_archivable_typed_worker_launch( cache: &CultCache, launch: &EpiphanyRuntimeWorkerLaunchRequest, @@ -9572,17 +9525,13 @@ fn validate_archivable_typed_worker_launch( Ok(()) } -fn archive_runtime_worker_attempt( +fn archive_runtime_worker_attempt( store_path: impl AsRef, job_id: &str, live_resident_request_ids: &BTreeSet, archived_at: &str, fulfilled: bool, - before_commit: F, -) -> Result -where - F: FnOnce() -> Result<()>, -{ +) -> Result { validate_non_empty(job_id, "archived worker attempt job id")?; chrono::DateTime::parse_from_rfc3339(archived_at) .map_err(|error| anyhow!("worker attempt archive timestamp is invalid: {error}"))?; @@ -9822,7 +9771,6 @@ where }; tombstone.validate_decision_record(fulfilled)?; let replacement = cache.prepare_entry(job_id, &tombstone)?.0; - before_commit()?; if !runtime_spine_backing_store(store_path)?.replace_and_delete_if_snapshot_unchanged( &snapshot, vec![replacement], @@ -9895,11 +9843,12 @@ pub fn retain_failed_runtime_worker_attempts( .into_iter() .skip(retain_recent.max(1)) .map(|claim| { - archive_failed_runtime_worker_attempt( + archive_runtime_worker_attempt( store_path, &claim.job_id, live_resident_request_ids, archived_at, + false, ) }) .collect() @@ -9972,11 +9921,12 @@ pub fn retain_fulfilled_runtime_worker_attempts( .into_iter() .skip(retain_recent.max(1)) .map(|claim| { - archive_fulfilled_runtime_worker_attempt( + archive_runtime_worker_attempt( store_path, &claim.job_id, live_resident_request_ids, archived_at, + true, ) }) .collect() @@ -10060,29 +10010,6 @@ pub fn open_coordinator_run( objective: &str, started_at: &str, ) -> Result { - open_coordinator_run_with_before_commit( - store_path, - session_id, - thread_id, - resident_launch_digest, - objective, - started_at, - || Ok(()), - ) -} - -fn open_coordinator_run_with_before_commit( - store_path: impl AsRef, - session_id: &str, - thread_id: &str, - resident_launch_digest: Option<&str>, - objective: &str, - started_at: &str, - before_commit: F, -) -> Result -where - F: FnOnce() -> Result<()>, -{ validate_non_empty(session_id, "coordinator run session id")?; validate_non_empty(thread_id, "coordinator run thread id")?; validate_non_empty(objective, "coordinator run objective")?; @@ -10130,7 +10057,6 @@ where }; let snapshot = cache.snapshot_envelopes(); let replacements = vec![cache.prepare_entry(session_id, &session)?.0]; - before_commit()?; if !runtime_spine_backing_store(store_path)? .replace_and_append_if_snapshot_unchanged(&snapshot, replacements)? { @@ -10141,13 +10067,6 @@ where Ok(session) } -pub fn finalize_coordinator_run( - store_path: impl AsRef, - receipt: &EpiphanyCoordinatorRunReceipt, -) -> Result { - finalize_coordinator_run_with_before_commit(store_path, receipt, || Ok(())) -} - fn coordinator_death_recovery_summary(recovery: &EpiphanyCoordinatorDeathRecovery) -> String { format!( "Continuity terminalized coordinator session after exact process observation {:?}{}.", @@ -10159,19 +10078,6 @@ fn coordinator_death_recovery_summary(recovery: &EpiphanyCoordinatorDeathRecover ) } -pub(crate) fn recover_coordinator_run_after_exact_process_death( - store_path: impl AsRef, - recovery: &EpiphanyCoordinatorDeathRecovery, - expected_objective: &str, -) -> Result { - recover_coordinator_run_after_exact_process_death_with_before_commit( - store_path, - recovery, - expected_objective, - || Ok(()), - ) -} - pub(crate) fn coordinator_run_incarnation_is_absent( store_path: impl AsRef, thread_id: &str, @@ -10199,15 +10105,11 @@ pub(crate) fn coordinator_run_incarnation_is_absent( .any(|recovery| recovery.session_id == session_id)) } -fn recover_coordinator_run_after_exact_process_death_with_before_commit( +pub(crate) fn recover_coordinator_run_after_exact_process_death( store_path: impl AsRef, recovery: &EpiphanyCoordinatorDeathRecovery, expected_objective: &str, - before_commit: F, -) -> Result -where - F: FnOnce() -> Result<()>, -{ +) -> Result { validate_non_empty(expected_objective, "recovered coordinator objective")?; if recovery.schema_version != COORDINATOR_DEATH_RECOVERY_SCHEMA_VERSION || recovery.recovery_id != format!("coordinator-death-recovery-{}", recovery.session_id) @@ -10290,7 +10192,6 @@ where cache.prepare_entry(&session.session_id, &session)?.0, cache.prepare_entry(&recovery.recovery_id, recovery)?.0, ]; - before_commit()?; if !runtime_spine_backing_store(store_path)? .replace_and_append_if_snapshot_unchanged(&snapshot, replacements)? { @@ -10301,14 +10202,10 @@ where Ok(session) } -fn finalize_coordinator_run_with_before_commit( +pub fn finalize_coordinator_run( store_path: impl AsRef, receipt: &EpiphanyCoordinatorRunReceipt, - before_commit: F, -) -> Result -where - F: FnOnce() -> Result<()>, -{ +) -> Result { validate_coordinator_run_receipt(receipt)?; if receipt.session_id != coordinator_run_session_id( @@ -10378,7 +10275,6 @@ where cache.prepare_entry(&session.session_id, &session)?.0, cache.prepare_entry(&receipt.receipt_id, receipt)?.0, ]; - before_commit()?; if !runtime_spine_backing_store(store_path)? .compare_and_swap_batch(&[expected_session], replacements)? {