Skip to content

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

test(storage): use sqlite backend and clarify stale lease setup

Steven Enamakelec643b75c7a4
diff --git a/crates/openhuman-core/src/modules/storage_host_bus_tests.rs b/crates/openhuman-core/src/modules/storage_host_bus_tests.rs
index 2b29927dc8..48a19d9784 100644
--- a/crates/openhuman-core/src/modules/storage_host_bus_tests.rs
+++ b/crates/openhuman-core/src/modules/storage_host_bus_tests.rs
@@ -53,8 +53,8 @@ async fn a_module_write_under_a_stale_lease_is_fenced_by_the_host() {
use std::sync::atomic::{AtomicU64, Ordering};
use std::time::Duration;
- let shared: Arc<dyn StorageBackend> =
- Arc::new(tinystoragedrivers_testkit::MemoryBackend::new());
+ let shared_fixture = crate::storage::test_support::sqlite_backend().unwrap();
+ let shared: Arc<dyn StorageBackend> = Arc::clone(&shared_fixture.backend);
let clock = Arc::new(AtomicU64::new(0));
let reading = Arc::clone(&clock);
let fences = Arc::new(FenceRegistry::new(move || reading.load(Ordering::SeqCst)));
diff --git a/crates/openhuman-core/src/modules/storage_import_tinymcp_tests.rs b/crates/openhuman-core/src/modules/storage_import_tinymcp_tests.rs
index ae9aadb16f..5e8b32851c 100644
--- a/crates/openhuman-core/src/modules/storage_import_tinymcp_tests.rs
+++ b/crates/openhuman-core/src/modules/storage_import_tinymcp_tests.rs
@@ -252,7 +252,7 @@ async fn an_unreadable_file_writes_no_marker_so_the_next_start_retries() {
&file,
b"this is not a sqlite database at all, just text padding",
)
- .unwrap();
+ .unwrap_or_else(|error| panic!("captured import claim failed: {error:#}"));
let rig = rig();
assert!(import(&rig, dir.path()).await.is_err());
let done = crate::storage::import_state::host_import_done(
@@ -331,17 +331,21 @@ async fn an_import_cannot_recapture_a_reopened_profiles_new_fence() {
let old_profile = host.open(&id).await.unwrap();
let old_context = Arc::clone(old_profile.context());
- let old_turn = old_context.derive_with(crate::core::runtime::ContextOverlay::new(
- crate::config::Config::default(),
- DomainSet::full(),
- Default::default(),
- ));
drop(old_profile);
assert!(host.release(&id).await.unwrap());
let current_profile = host.open(&id).await.unwrap();
let current_context = Arc::clone(current_profile.context());
assert!(!Arc::ptr_eq(&old_context, &current_context));
+ // A stale turn context cannot keep the profile lease alive while the test
+ // reopens the profile. Recreate it from the retired context to verify that
+ // import capture still cannot borrow the reopened profile's fence.
+ let old_turn = old_context.derive_with(crate::core::runtime::ContextOverlay::new(
+ crate::config::Config::default(),
+ DomainSet::full(),
+ Default::default(),
+ ));
+
let module_scope = crate::storage::scope_for_module(Some(id.as_str()), MODULE_ID).unwrap();
let stale = super::super::storage_import_support::capture_profile_module_storage(
&host,