Skip to content

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

refactor(import): update tinyflows module imports

Steven Enamakel9746a941acf7
diff --git a/crates/openhuman-core/src/storage/import/mod.rs b/crates/openhuman-core/src/storage/import/mod.rs
index ba9fa9c4cd..8badce6277 100644
--- a/crates/openhuman-core/src/storage/import/mod.rs
+++ b/crates/openhuman-core/src/storage/import/mod.rs
@@ -59,6 +59,8 @@ pub mod sessions;
#[cfg(feature = "legacy-import")]
mod snapshot;
#[cfg(feature = "legacy-import")]
+mod tinyflows_reader;
+#[cfg(feature = "legacy-import")]
pub mod tinyflows;
pub use schemas::{
diff --git a/crates/openhuman-core/src/storage/import/tinyflows.rs b/crates/openhuman-core/src/storage/import/tinyflows.rs
index 37cfd8dad9..f4482ae4b1 100644
--- a/crates/openhuman-core/src/storage/import/tinyflows.rs
+++ b/crates/openhuman-core/src/storage/import/tinyflows.rs
@@ -27,7 +27,7 @@ use std::sync::{LazyLock, Mutex, Weak};
use anyhow::{Context, Result};
-use super::{marker_spec, marker_step, Outcome, Report, MARKER_OWNER};
+use super::{MARKER_OWNER, Outcome, Report, marker_spec, marker_step};
use crate::config::Config;
use crate::storage::documents::Repo;
use crate::storage::import_state;
@@ -108,7 +108,7 @@ pub(super) fn marked(
}
/// Counts the schedule reader's legacy records and logs safe problem details.
-fn counts(domain: &str, report: &tinyflows_import::ImportReport) -> (usize, usize, usize) {
+fn counts(domain: &str, report: &super::tinyflows_reader::ImportReport) -> (usize, usize, usize) {
for problem in report.problems() {
tracing::warn!(
target: "openhuman::storage_import",
@@ -441,7 +441,7 @@ fn import_flows_after_migration(
let flow_proxy = proxy.clone();
let flow_storage = storage.clone();
let flow_totals = Arc::clone(&totals);
- tinyflows_import::read_legacy_flow_catalog(&dir, move |records| {
+ super::tinyflows_reader::read_legacy_flow_catalog(&dir, move |records| {
let proxy = flow_proxy.clone();
let storage = flow_storage.clone();
let totals = Arc::clone(&flow_totals);
@@ -464,7 +464,7 @@ fn import_flows_after_migration(
let checkpoint_proxy = proxy.clone();
let checkpoint_storage = storage.clone();
let checkpoint_totals = Arc::clone(&totals);
- tinyflows_import::read_legacy_checkpoint_batches(
+ super::tinyflows_reader::read_legacy_checkpoint_batches(
&dir.join("checkpoints.db"),
&dir.join("checkpoints"),
move |records: Vec<LegacyImportRecord>| {
@@ -534,7 +534,7 @@ pub fn import_cron(
let report = crate::storage::block_on_anyhow({
let jobs_db = jobs_db.clone();
async move {
- let legacy = tinyflows_import::read_legacy_cron(&jobs_db)
+ let legacy = super::tinyflows_reader::read_legacy_cron(&jobs_db)
.await
.context("read the legacy cron database")?;
let mut report = legacy.report;
diff --git a/crates/openhuman-core/src/storage/import/tinyflows_reader/checkpoint_reader.rs b/crates/openhuman-core/src/storage/import/tinyflows_reader/checkpoint_reader.rs
index bd4ad72e15..5da2170b74 100644
--- a/crates/openhuman-core/src/storage/import/tinyflows_reader/checkpoint_reader.rs
+++ b/crates/openhuman-core/src/storage/import/tinyflows_reader/checkpoint_reader.rs
@@ -10,8 +10,8 @@ use tinyflows_bus::catalog::{
MAX_IMPORT_RECORD_PAYLOAD_BYTES,
};
-use crate::flow_reader::BatchSender;
-use crate::legacy_db::LegacyDb;
+use super::flow_reader::BatchSender;
+use super::legacy_db::LegacyDb;
const SQLITE_PAGE_ROWS: i64 = 8;
diff --git a/crates/openhuman-core/src/storage/import/tinyflows_reader/flow_reader.rs b/crates/openhuman-core/src/storage/import/tinyflows_reader/flow_reader.rs
index 39633e5b34..803fe184c4 100644
--- a/crates/openhuman-core/src/storage/import/tinyflows_reader/flow_reader.rs
+++ b/crates/openhuman-core/src/storage/import/tinyflows_reader/flow_reader.rs
@@ -11,7 +11,7 @@ use tinyflows_bus::catalog::{
MAX_IMPORT_RECORD_PAYLOAD_BYTES,
};
-use crate::legacy_db::{LegacyDb, column_or};
+use super::legacy_db::{LegacyDb, column_or};
/// Reads legacy flow database rows and draft files as bounded ordered batches.
///
@@ -120,8 +120,8 @@ async fn page_rows<T, ToRecord, F, Fut>(
what: &'static str,
query: &str,
decode: impl Fn(
- &tinystoragedrivers_sqlite::rusqlite::Row<'_>,
- ) -> tinystoragedrivers_sqlite::rusqlite::Result<T>
+ &crate::storage::rusqlite::Row<'_>,
+ ) -> crate::storage::rusqlite::Result<T>
+ Send
+ Sync
+ 'static,
diff --git a/crates/openhuman-core/src/storage/import/tinyflows_reader/legacy_cron.rs b/crates/openhuman-core/src/storage/import/tinyflows_reader/legacy_cron.rs
index 40458eaa3a..d7d500f288 100644
--- a/crates/openhuman-core/src/storage/import/tinyflows_reader/legacy_cron.rs
+++ b/crates/openhuman-core/src/storage/import/tinyflows_reader/legacy_cron.rs
@@ -22,8 +22,8 @@ use tinyflows_bus::schedule::types::{
SessionTarget,
};
-use crate::legacy_db::{LegacyDb, column_or};
-use crate::report::ImportReport;
+use super::legacy_db::{LegacyDb, column_or};
+use super::report::ImportReport;
/// What `jobs.db` held, decoded.
#[derive(Debug, Default)]
diff --git a/crates/openhuman-core/src/storage/import/tinyflows_reader/report.rs b/crates/openhuman-core/src/storage/import/tinyflows_reader/report.rs
index 46ed8fbcaa..6d1ad224bc 100644
--- a/crates/openhuman-core/src/storage/import/tinyflows_reader/report.rs
+++ b/crates/openhuman-core/src/storage/import/tinyflows_reader/report.rs
@@ -2,10 +2,6 @@
use std::collections::BTreeMap;
-#[cfg(all(
- feature = "flow-read",
- any(feature = "flow-write", feature = "checkpoint-write")
-))]
fn legacy_kind_name(kind: tinyflows_bus::catalog::LegacyImportKind) -> &'static str {
use tinyflows_bus::catalog::LegacyImportKind as Kind;
match kind {
@@ -40,10 +36,6 @@ pub struct ImportReport {
}
impl ImportReport {
- #[cfg(all(
- feature = "flow-read",
- any(feature = "flow-write", feature = "checkpoint-write")
- ))]
pub(crate) fn merge_legacy_batch(
&mut self,
response: tinyflows_bus::catalog::ImportLegacyBatchResponse,
diff --git a/crates/openhuman-core/src/storage/import/tinyflows_tests.rs b/crates/openhuman-core/src/storage/import/tinyflows_tests.rs
index ea1acf138a..99d67b476a 100644
--- a/crates/openhuman-core/src/storage/import/tinyflows_tests.rs
+++ b/crates/openhuman-core/src/storage/import/tinyflows_tests.rs
@@ -1,14 +1,14 @@
use super::*;
use crate::cron::client::testing as cron_store;
use crate::storage::{MemoryStorage, Scope};
-use serde_json::json;
use serde_json::Value;
+use serde_json::json;
use sha2::Digest;
use std::collections::BTreeMap;
use tempfile::TempDir;
use tinyflows::engine::Checkpointer;
-use tinyflows_drivers::catalog::FlowCatalogDocuments;
use tinyflows_drivers::DriverCheckpointer;
+use tinyflows_drivers::catalog::FlowCatalogDocuments;
fn fixtures() -> PathBuf {
Path::new(env!("CARGO_MANIFEST_DIR")).join("src/storage/import/fixtures/tinyflows")
@@ -522,18 +522,22 @@ async fn catalog_and_schedule_owner_migrations_cover_existing_scopes() {
for scope in [Scope::local(), profile] {
let scoped = backend.for_scope(&scope).unwrap();
- assert!(scoped
- .documents()
- .get("flows.definitions", "missing")
- .await
- .unwrap()
- .is_none());
- assert!(scoped
- .documents()
- .get("cron.jobs", "missing")
- .await
- .unwrap()
- .is_none());
+ assert!(
+ scoped
+ .documents()
+ .get("flows.definitions", "missing")
+ .await
+ .unwrap()
+ .is_none()
+ );
+ assert!(
+ scoped
+ .documents()
+ .get("cron.jobs", "missing")
+ .await
+ .unwrap()
+ .is_none()
+ );
}
}