Skip to content

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

refactor(import): clean up tinyflows reader module structure

Steven Enamakel42a1c9a2db99
diff --git a/crates/openhuman-core/src/storage/import/mod.rs b/crates/openhuman-core/src/storage/import/mod.rs
index 8badce6277..2cc99de865 100644
--- a/crates/openhuman-core/src/storage/import/mod.rs
+++ b/crates/openhuman-core/src/storage/import/mod.rs
@@ -48,10 +48,10 @@
//! tinyflows stores (cron jobs, the flow catalog and checkpoints) are copied
//! with `tinyflows-import`; see [`tinyflows`].
-#[cfg(feature = "legacy-import")]
-pub(crate) mod layout_status;
#[cfg(feature = "legacy-import")]
pub(crate) mod layout_db;
+#[cfg(feature = "legacy-import")]
+pub(crate) mod layout_status;
pub mod live;
mod schemas;
#[cfg(feature = "legacy-import")]
@@ -59,9 +59,9 @@ pub mod sessions;
#[cfg(feature = "legacy-import")]
mod snapshot;
#[cfg(feature = "legacy-import")]
-mod tinyflows_reader;
-#[cfg(feature = "legacy-import")]
pub mod tinyflows;
+#[cfg(feature = "legacy-import")]
+mod tinyflows_reader;
pub use schemas::{
all_session_import_controller_schemas, all_session_import_registered_controllers,
diff --git a/crates/openhuman-core/src/storage/import/mod_tests.rs b/crates/openhuman-core/src/storage/import/mod_tests.rs
index 402526212c..d3245b1453 100644
--- a/crates/openhuman-core/src/storage/import/mod_tests.rs
+++ b/crates/openhuman-core/src/storage/import/mod_tests.rs
@@ -252,16 +252,18 @@ fn processes_importing_one_workspace_at_once_import_it_once() {
.filter(|o| matches!(o, Outcome::Imported { .. }))
.count();
assert_eq!(imports, 1, "exactly one process imports: {outcomes:?}");
- assert!(outcomes
- .iter()
- .all(|o| !matches!(o, Outcome::Imported { .. })
- || matches!(
- o,
- Outcome::Imported {
- found: 20,
- written: 20
- }
- )));
+ assert!(
+ outcomes
+ .iter()
+ .all(|o| !matches!(o, Outcome::Imported { .. })
+ || matches!(
+ o,
+ Outcome::Imported {
+ found: 20,
+ written: 20
+ }
+ ))
+ );
assert!(is_done(&backend, &config, &source).unwrap());
assert_eq!(dump(&backend, &source, "devices.paired").len(), 20);
}
@@ -428,9 +430,11 @@ async fn without_an_installed_backend_the_host_import_does_nothing() {
legacy_device(&config, "chan-a", "Phone", false);
assert!(crate::storage::installed().is_none());
- assert!(run(&crate::core::runtime::DispatchCtx::unbound(), &config)
- .await
- .is_empty());
+ assert!(
+ run(&crate::core::runtime::DispatchCtx::unbound(), &config)
+ .await
+ .is_empty()
+ );
}
#[test]
diff --git a/crates/openhuman-core/src/storage/import/sessions.rs b/crates/openhuman-core/src/storage/import/sessions.rs
index c2b6d38bd8..b8724bc43a 100644
--- a/crates/openhuman-core/src/storage/import/sessions.rs
+++ b/crates/openhuman-core/src/storage/import/sessions.rs
@@ -32,12 +32,12 @@ use std::path::{Path, PathBuf};
use std::sync::Arc;
use anyhow::{Context, Result};
+use tinyagents_session::DriverSessionStores;
use tinyagents_session::legacy::{
- import_transcripts, import_turn_states, ImportCounts, LegacyDatabaseReport, QuiescentSource,
- SourceOwner,
+ ImportCounts, LegacyDatabaseReport, QuiescentSource, SourceOwner, import_transcripts,
+ import_turn_states,
};
-use tinyagents_session::transcript::{session_stem, SessionRef};
-use tinyagents_session::DriverSessionStores;
+use tinyagents_session::transcript::{SessionRef, session_stem};
use super::tinyflows::{finish, marked};
use super::{Outcome, Report, Snapshot};
diff --git a/crates/openhuman-core/src/storage/import/sessions_tests.rs b/crates/openhuman-core/src/storage/import/sessions_tests.rs
index 38e1e2bdc0..9953e4340a 100644
--- a/crates/openhuman-core/src/storage/import/sessions_tests.rs
+++ b/crates/openhuman-core/src/storage/import/sessions_tests.rs
@@ -1,6 +1,6 @@
use super::*;
-use crate::storage::rusqlite;
use crate::storage::MemoryStorage;
+use crate::storage::rusqlite;
use crate::util::classic_transcript_fixture::write_classic;
use sha2::Digest as _;
use std::collections::BTreeMap;
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 5da2170b74..94ffa9c137 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
@@ -376,7 +376,3 @@ pub(crate) fn unescape_thread_id(escaped: &str) -> Option<String> {
}
String::from_utf8(out).ok()
}
-
-#[cfg(test)]
-#[path = "checkpoint_reader_tests.rs"]
-mod tests;
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 803fe184c4..abfe4b32ef 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
@@ -119,9 +119,7 @@ async fn page_rows<T, ToRecord, F, Fut>(
db: &LegacyDb,
what: &'static str,
query: &str,
- decode: impl Fn(
- &crate::storage::rusqlite::Row<'_>,
- ) -> crate::storage::rusqlite::Result<T>
+ decode: impl Fn(&crate::storage::rusqlite::Row<'_>) -> crate::storage::rusqlite::Result<T>
+ Send
+ Sync
+ 'static,
@@ -261,7 +259,3 @@ fn record_identity(record: &LegacyImportRecord) -> Option<String> {
};
value.map(|identity| identity.chars().take(128).collect())
}
-
-#[cfg(test)]
-#[path = "flow_reader_tests.rs"]
-mod tests;
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 6d1ad224bc..356cc6eb79 100644
--- a/crates/openhuman-core/src/storage/import/tinyflows_reader/report.rs
+++ b/crates/openhuman-core/src/storage/import/tinyflows_reader/report.rs
@@ -120,7 +120,3 @@ impl ImportReport {
self.problems.is_empty()
}
}
-
-#[cfg(test)]
-#[path = "report_tests.rs"]
-mod tests;