Skip to content

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

fix(profiles): install persistent test backend during cron admission

Steven Enamakel4cd78b10bb62
diff --git a/crates/openhuman-core/src/profiles/host.rs b/crates/openhuman-core/src/profiles/host.rs
index 06b5b949ac..b6dcd910b8 100644
--- a/crates/openhuman-core/src/profiles/host.rs
+++ b/crates/openhuman-core/src/profiles/host.rs
@@ -305,25 +305,6 @@ impl ProfileHost {
let mut config = self
.serving_config(&layout, id)
.map_err(OpenError::Storage)?;
- // A profile context carries a write fence that depends on atomic
- // storage conditions. The default testkit backend intentionally
- // lacks them, so mirror the production SQLite default in profile
- // tests unless a backend was installed by the test.
- #[cfg(all(test, feature = "storage-sqlite"))]
- if crate::storage::installed().is_none() {
- crate::storage::local::use_persistent_default_for_test(&config.workspace_dir);
- }
- #[cfg(all(test, feature = "storage-sqlite"))]
- {
- let backend = crate::storage::local::backend_for(&config.workspace_dir)
- .expect("profile test backend opens");
- eprintln!(
- "profile test backend installed={} capabilities={:?} workspace={}",
- crate::storage::installed().is_some(),
- backend.capabilities(),
- config.workspace_dir.display()
- );
- }
if let Some(capabilities) = &self.capabilities {
capabilities.configure(&mut config);
}
diff --git a/crates/openhuman-core/src/profiles/lifecycle.rs b/crates/openhuman-core/src/profiles/lifecycle.rs
index cb30f8a793..5028272e71 100644
--- a/crates/openhuman-core/src/profiles/lifecycle.rs
+++ b/crates/openhuman-core/src/profiles/lifecycle.rs
@@ -45,6 +45,13 @@ pub(super) async fn reconcile_cron_admission(
id: &ProfileId,
backend: Option<&Arc<dyn crate::storage::StorageBackend>>,
) -> Result<(), String> {
+ // A profile's fenced cron writes require atomic storage conditions. The
+ // default unit-test backend intentionally lacks them, so use the same
+ // persistent SQLite default as production when no host backend is set.
+ #[cfg(all(test, feature = "storage-sqlite"))]
+ if backend.is_none() && crate::storage::installed().is_none() {
+ crate::storage::local::use_persistent_default_for_test(&config.workspace_dir);
+ }
let profile_scope = crate::storage::scope_for_profile(id.as_str());
let scope = match backend {
Some(backend) => crate::cron::documents_port::DocScope::on_backend(