Skip to content

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

feat(storage/import): add tinyflows import support

Steven Enamakelaa02555c5a4c
diff --git a/crates/openhuman-core/src/storage/import/tinyflows.rs b/crates/openhuman-core/src/storage/import/tinyflows.rs
index aacd9c5341..2a3d57c770 100644
--- a/crates/openhuman-core/src/storage/import/tinyflows.rs
+++ b/crates/openhuman-core/src/storage/import/tinyflows.rs
@@ -271,20 +271,23 @@ fn catalog_migration_ready(
.is_some_and(|entry| entry.outcome.is_ok())
}
+/// Async on purpose: [`ensure_flow_scope_ready`] runs on the storage blocking
+/// bridge, and the synchronous `Repo` helpers would re-enter it ("a future
+/// running on the blocking bridge called back into it").
#[cfg(feature = "flows")]
-fn flow_import_marker_done(backend: &Arc<dyn StorageBackend>, config: &Config) -> Result<bool> {
- let markers = Repo::on(
- backend,
- &crate::storage::tenant_scope(None),
- "storage::import",
- marker_spec,
- )?;
+async fn flow_import_marker_done(
+ backend: &Arc<dyn StorageBackend>,
+ config: &Config,
+) -> Result<bool> {
+ let scoped = backend
+ .for_scope(&crate::storage::tenant_scope(None))
+ .context("[storage::import] open the marker scope")?;
let step = marker_step(FLOWS_DOMAIN, &config.workspace_dir);
- import_state::is_done(&markers, MARKER_OWNER, &step)
+ Ok(import_state::done(&scoped, MARKER_OWNER, &step).await?)
}
#[cfg(feature = "flows")]
-pub(crate) fn legacy_flow_import_pending(
+pub(crate) async fn legacy_flow_import_pending(
backend: &Arc<dyn StorageBackend>,
config: &Config,
scope: &Scope,
@@ -292,7 +295,7 @@ pub(crate) fn legacy_flow_import_pending(
if scope != &Scope::local() || !flow_sources_present(&config.workspace_dir.join("flows")) {
return Ok(false);
}
- Ok(!flow_import_marker_done(backend, config)?)
+ Ok(!flow_import_marker_done(backend, config).await?)
}
/// Make the acting scope safe for workflow calls, retrying a failed Catalog
@@ -320,6 +323,7 @@ pub(crate) async fn ensure_flow_scope_ready(config: &Config) -> std::result::Res
}
if !fallback
&& legacy_flow_import_pending(&backend, config, &scope)
+ .await
.map_err(|error| format!("check the legacy flow import marker: {error:#}"))?
{
return Err(
diff --git a/crates/openhuman-core/src/storage/import/tinyflows_tests.rs b/crates/openhuman-core/src/storage/import/tinyflows_tests.rs
index cfc7f80370..da428887ea 100644
--- a/crates/openhuman-core/src/storage/import/tinyflows_tests.rs
+++ b/crates/openhuman-core/src/storage/import/tinyflows_tests.rs
@@ -384,12 +384,15 @@ fn an_invalid_flow_record_keeps_the_import_open_for_retry() {
panic!("retry should remain incomplete without new writes: {first:?} / {retry:?}")
}
}
- assert!(legacy_flow_import_pending(&backend, &config, &Scope::local()).unwrap());
+ assert!(legacy_flow_import_pending(&backend, &config, &Scope::local())
+ .await
+ .unwrap());
assert!(!legacy_flow_import_pending(
&backend,
&config,
&crate::storage::scope_for_profile("another-profile"),
)
+ .await
.unwrap());
assert_eq!(tree(dir.path()), before, "the legacy files were modified");
}
@@ -454,7 +457,7 @@ async fn fallback_backend_migrates_legacy_catalog_state_without_importing_files(
Some(json!({"seen": true}))
);
assert!(
- flow_import_marker_done(&backend, &config).is_ok_and(|done| !done),
+ flow_import_marker_done(&backend, &config).await.is_ok_and(|done| !done),
"the unbooted local fallback must not run the workspace-file importer"
);
assert_eq!(tree(&legacy_dir), legacy_files_before);