Skip to content

The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.

chore: files changed crates/openhuman-core/src/memory/import_tests.rs,crates/openhuman-core/src/memo

Steven Enamakelad017dfc3737
diff --git a/crates/openhuman-core/src/memory/import_tests.rs b/crates/openhuman-core/src/memory/import_tests.rs
index dcdc93f54c..9440ce74b0 100644
--- a/crates/openhuman-core/src/memory/import_tests.rs
+++ b/crates/openhuman-core/src/memory/import_tests.rs
@@ -1,5 +1,5 @@
use super::*;
-use crate::memory::test_fixtures::config_in;
+use crate::memory::test_fixtures::{bind_reference, config_in};
#[test]
fn the_state_file_round_trips_through_the_atomic_store() {
@@ -214,3 +214,35 @@ fn a_store_with_no_legacy_files_counts_nothing() {
let tmp = tempfile::tempdir().unwrap();
assert!(tinymemory_integrations::import::count_legacy(tmp.path()).is_none());
}
+
+#[tokio::test]
+async fn resume_with_live_import_slot_does_not_claim_a_new_run() {
+ let tmp = tempfile::tempdir().unwrap();
+ let config = config_in(&tmp);
+ bind_reference(&config);
+ let mut file = ImportFile::default();
+ file.state.phase = ImportPhase::Running;
+ let store = FileCheckpointStore::new(&config.workspace_dir);
+ store.save(&file).unwrap();
+ let guard = crate::memory::run_slots::reserve(
+ &crate::memory::run_slots::IMPORT,
+ &config.workspace_dir,
+ &[
+ &crate::memory::run_slots::BACKFILL,
+ &crate::memory::run_slots::MIGRATION,
+ ],
+ )
+ .expect("the live import owns the slot");
+
+ let resumed = resume_interrupted_with(
+ &crate::core::runtime::DispatchCtx::ambient(),
+ &config,
+ Arc::new(|| false),
+ Arc::new(|_: &Config| true),
+ )
+ .await;
+
+ assert_eq!(store.load(), file, "a live run leaves its checkpoint alone");
+ assert!(!resumed, "no new run was scheduled");
+ drop(guard);
+}
diff --git a/crates/openhuman-core/src/memory/layout_migration/ops_tests.rs b/crates/openhuman-core/src/memory/layout_migration/ops_tests.rs
index 4ad50224e1..7d712aaddc 100644
--- a/crates/openhuman-core/src/memory/layout_migration/ops_tests.rs
+++ b/crates/openhuman-core/src/memory/layout_migration/ops_tests.rs
@@ -267,3 +267,42 @@ async fn run_acts_under_the_handed_context_not_the_active_one() {
assert!(Arc::ptr_eq(context, &handed));
}
}
+
+fn pause_import_for_credits(config: &Config) {
+ use tinymemory_integrations::import::{CheckpointStore, ImportFile, ImportPhase};
+
+ let mut file = ImportFile::default();
+ file.state.phase = ImportPhase::Error;
+ file.paused_for_credits = true;
+ crate::memory::import::FileCheckpointStore::new(&config.workspace_dir)
+ .save(&file)
+ .unwrap();
+}
+
+#[tokio::test]
+async fn a_credit_paused_import_blocks_migration_start_and_tick() {
+ let start_tmp = tempfile::tempdir().unwrap();
+ let start_config = crate::memory::test_fixtures::config_in(&start_tmp);
+ let start_host = Arc::new(FakeHost::with(1, &start_config).await);
+ pause_import_for_credits(&start_config);
+ assert!(crate::memory::import::in_progress(&start_config));
+ assert!(!start(
+ &crate::core::runtime::DispatchCtx::ambient(),
+ start_config.clone(),
+ start_host,
+ Trigger::Auto,
+ never()
+ ));
+
+ let tick_tmp = tempfile::tempdir().unwrap();
+ let tick_config = crate::memory::test_fixtures::config_in(&tick_tmp);
+ let tick_host = Arc::new(FakeHost::with(1, &tick_config).await);
+ pause_import_for_credits(&tick_config);
+ assert!(crate::memory::import::in_progress(&tick_config));
+ assert!(!tick(
+ &crate::core::runtime::DispatchCtx::ambient(),
+ &tick_config,
+ tick_host,
+ never()
+ ));
+}