The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.
Rust agent-orchestrationai-agentsai-assistantdesktopllmlocal-firstmcppersonal-aiprivacyrustsecond-braintauri
refactor(import): clean up import statements and structure
Steven Enamakelf289d2980be1
diff --git a/crates/openhuman-core/src/storage/import/layout_db_tests.rs b/crates/openhuman-core/src/storage/import/layout_db_tests.rsindex 607816cccc..ff291263fa 100644--- a/crates/openhuman-core/src/storage/import/layout_db_tests.rs+++ b/crates/openhuman-core/src/storage/import/layout_db_tests.rs@@ -1,6 +1,6 @@use super::*;use crate::storage::layout::test_fixtures::{fixture_docs, v1_profile};-use crate::storage::layout::{legacy, Target};+use crate::storage::layout::{Target, legacy};use tempfile::TempDir;#[test]diff --git a/crates/openhuman-core/src/storage/import/mod.rs b/crates/openhuman-core/src/storage/import/mod.rsindex 94f0989d04..5d8f5e2b69 100644--- a/crates/openhuman-core/src/storage/import/mod.rs+++ b/crates/openhuman-core/src/storage/import/mod.rs@@ -52,11 +52,13 @@pub(crate) mod layout_db;#[cfg(feature = "legacy-import")]pub(crate) mod layout_status;-#[cfg(feature = "legacy-import")]-pub mod scope_move;pub mod live;mod schemas;#[cfg(feature = "legacy-import")]+pub mod scope_move;+#[cfg(feature = "legacy-import")]+pub(crate) mod session_db;+#[cfg(feature = "legacy-import")]pub mod sessions;#[cfg(feature = "legacy-import")]mod snapshot;@@ -75,20 +77,20 @@ use std::sync::Arc;use anyhow::Result;#[cfg(feature = "legacy-import")]-use anyhow::{anyhow, Context};+use anyhow::{Context, anyhow};#[cfg(feature = "legacy-import")]use sha2::Digest;use tinystoragedrivers::CollectionSpec;#[cfg(feature = "legacy-import")]use tinystoragedrivers::{ErrorKind, Precondition, WriteOptions};+use super::StorageBackend;#[cfg(feature = "legacy-import")]use super::block_on;#[cfg(feature = "legacy-import")]use super::documents::Repo;#[cfg(feature = "legacy-import")]use super::rusqlite;-use super::StorageBackend;use crate::config::Config;#[cfg(feature = "legacy-import")]use rusqlite::Connection;diff --git a/crates/openhuman-core/src/storage/import/mod_tests.rs b/crates/openhuman-core/src/storage/import/mod_tests.rsindex 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/schemas.rs b/crates/openhuman-core/src/storage/import/schemas.rsindex 66cb2187fe..b3114aff7c 100644--- a/crates/openhuman-core/src/storage/import/schemas.rs+++ b/crates/openhuman-core/src/storage/import/schemas.rs@@ -3,10 +3,10 @@use crate::core::runtime::DispatchCtx;use serde::Deserialize;-use serde_json::{json, Map, Value};+use serde_json::{Map, Value, json};-use crate::core::all::{ControllerFuture, RegisteredController};use crate::core::Outcome;+use crate::core::all::{ControllerFuture, RegisteredController};use crate::core::{ControllerSchema, FieldSchema, TypeSchema};#[derive(Debug, Deserialize, Default)]diff --git a/crates/openhuman-core/src/storage/import/session_db.rs b/crates/openhuman-core/src/storage/import/session_db.rsnew file mode 100644index 0000000000..60728246b0--- /dev/null+++ b/crates/openhuman-core/src/storage/import/session_db.rs@@ -0,0 +1,515 @@+//! Read-only decoder for the historical `session_db/sessions.db` schema.+//!+//! The legacy database belongs to the host migration boundary. This module+//! reads a consistent scratch snapshot and returns the current TinyAgents+//! record types; it does not open or mutate owner storage.++use std::path::Path;++use anyhow::{Context, Result, bail};+use serde::de::DeserializeOwned;+use serde_json::{Map, Number, Value, json};+use tinyagents_session::run_ledger::tool_effects::{ToolEffectRow, ToolEffectStatus};+use tinyagents_session::run_ledger::{+ AgentRun, AgentTeam, AgentTeamMember, AgentTeamTask, RunEvent, RunTelemetry, WorkflowRun,+};+use tinyagents_session::{SessionMessage, SessionRecord, SessionToolCall};++use crate::storage::rusqlite::{self, types::ValueRef};++/// Typed rows from the historical session database, in deterministic source+/// order. The owner import operation performs the destination preflight and+/// checked batch write.+#[derive(Debug, Default)]+pub(crate) struct SessionDatabase {+ pub sessions: Vec<SessionRecord>,+ pub messages: Vec<SessionMessage>,+ pub tool_calls: Vec<SessionToolCall>,+ pub agent_runs: Vec<AgentRun>,+ pub telemetry: Vec<RunTelemetry>,+ pub events: Vec<RunEvent>,+ pub workflows: Vec<WorkflowRun>,+ pub teams: Vec<AgentTeam>,+ pub members: Vec<AgentTeamMember>,+ pub tasks: Vec<AgentTeamTask>,+ pub tool_effects: Vec<ToolEffectRow>,+}++#[derive(Clone, Copy)]+enum Decode {+ Plain,+ JsonOrEmpty,+ OptionalJson,+ JsonArray,+}++#[derive(Clone, Copy)]+struct Field {+ column: &'static str,+ output: &'static str,+ fallback: &'static str,+ decode: Decode,+}++const fn field(column: &'static str, fallback: &'static str) -> Field {+ Field {+ column,+ output: column,+ fallback,+ decode: Decode::Plain,+ }+}++const fn renamed(+ column: &'static str,+ output: &'static str,+ fallback: &'static str,+ decode: Decode,+) -> Field {+ Field {+ column,+ output,+ fallback,+ decode,+ }+}++impl SessionDatabase {+ /// Reads all supported historical tables from a consistent scratch+ /// snapshot. Missing tables are empty; a database with none of the+ /// recognized tables is rejected.+ pub(crate) fn read(path: &Path) -> Result<Self> {+ let connection = rusqlite::Connection::open_with_flags(+ path,+ rusqlite::OpenFlags::SQLITE_OPEN_READ_ONLY | rusqlite::OpenFlags::SQLITE_OPEN_NO_MUTEX,+ )+ .with_context(|| {+ format!(+ "open session database snapshot {} read-only",+ path.display()+ )+ })?;+ let known = [+ "sessions",+ "session_messages",+ "agent_runs",+ "workflow_runs",+ "agent_teams",+ "tool_effects",+ ];+ if !known+ .iter()+ .map(|table| table_exists(&connection, table))+ .collect::<Result<Vec<_>>>()?+ .into_iter()+ .any(|exists| exists)+ {+ bail!("source has none of the classic session database tables");+ }++ Ok(Self {+ sessions: read_records(+ &connection,+ "sessions",+ "started_at, id",+ &[+ field("id", "NULL"),+ field("agent_definition_id", "''"),+ field("agent_definition_name", "''"),+ field("session_key", "''"),+ field("parent_session_id", "NULL"),+ field("thread_id", "NULL"),+ field("source_channel", "NULL"),+ field("status", "'running'"),+ field("model", "NULL"),+ field("turn_count", "0"),+ field("input_tokens", "0"),+ field("output_tokens", "0"),+ field("cached_input_tokens", "0"),+ field("cost_usd", "0.0"),+ field("transcript_path", "NULL"),+ field("started_at", "NULL"),+ field("ended_at", "NULL"),+ ],+ )?,+ messages: read_records(+ &connection,+ "session_messages",+ "id",+ &[+ field("id", "NULL"),+ field("session_id", "NULL"),+ field("role", "''"),+ field("content", "''"),+ field("reasoning_content", "NULL"),+ field("model", "NULL"),+ field("input_tokens", "NULL"),+ field("output_tokens", "NULL"),+ field("cost_usd", "NULL"),+ field("created_at", "NULL"),+ ],+ )?,+ tool_calls: read_records(+ &connection,+ "session_tool_calls",+ "id",+ &[+ field("id", "NULL"),+ field("session_id", "NULL"),+ field("message_id", "NULL"),+ field("tool_name", "''"),+ field("tool_input", "NULL"),+ field("tool_output", "NULL"),+ field("status", "'pending'"),+ field("duration_ms", "NULL"),+ field("created_at", "NULL"),+ ],+ )?,+ agent_runs: read_records(+ &connection,+ "agent_runs",+ "id",+ &[+ field("id", "NULL"),+ field("kind", "''"),+ field("parent_run_id", "NULL"),+ field("parent_thread_id", "NULL"),+ field("agent_id", "NULL"),+ field("status", "''"),+ field("prompt_ref", "NULL"),+ field("worker_thread_id", "NULL"),+ field("checkpoint_path", "NULL"),+ renamed(+ "checkpoint_json",+ "checkpoint",+ "NULL",+ Decode::OptionalJson,+ ),+ field("summary", "NULL"),+ field("error", "NULL"),+ renamed("metadata_json", "metadata", "'{}'", Decode::JsonOrEmpty),+ field("started_at", "NULL"),+ field("updated_at", "NULL"),+ field("completed_at", "NULL"),+ ],+ )?,+ telemetry: read_records(+ &connection,+ "run_telemetry",+ "run_id",+ &[+ field("run_id", "NULL"),+ field("input_tokens", "0"),+ field("output_tokens", "0"),+ field("cached_input_tokens", "0"),+ field("cost_usd", "0.0"),+ field("elapsed_ms", "NULL"),+ field("tool_count", "0"),+ field("model", "NULL"),+ field("provider", "NULL"),+ field("error", "NULL"),+ field("updated_at", "NULL"),+ ],+ )?,+ events: read_records(+ &connection,+ "run_events",+ "run_id, sequence",+ &[+ field("run_id", "NULL"),+ field("sequence", "NULL"),+ field("event_type", "''"),+ renamed("payload_json", "payload", "'{}'", Decode::JsonOrEmpty),+ renamed("timestamp", "timestamp", "NULL", Decode::Plain),+ ],+ )?,+ workflows: read_records(+ &connection,+ "workflow_runs",+ "id",+ &[+ field("id", "NULL"),+ field("definition_id", "''"),+ field("parent_thread_id", "NULL"),+ renamed("input_json", "input", "'{}'", Decode::JsonOrEmpty),+ renamed(+ "phase_states_json",+ "phase_states",+ "'{}'",+ Decode::JsonOrEmpty,+ ),+ renamed(+ "child_run_ids_json",+ "child_run_ids",+ "'[]'",+ Decode::JsonArray,+ ),+ field("status", "''"),+ field("summary", "NULL"),+ field("started_at", "NULL"),+ field("updated_at", "NULL"),+ field("completed_at", "NULL"),+ field("revision", "0"),+ field("lease_owner", "NULL"),+ field("lease_expires_at", "NULL"),+ ],+ )?,+ teams: read_records(+ &connection,+ "agent_teams",+ "id",+ &[+ field("id", "NULL"),+ field("parent_thread_id", "NULL"),+ field("lead_agent_id", "''"),+ field("status", "''"),+ field("summary", "NULL"),+ field("created_at", "NULL"),+ field("updated_at", "NULL"),+ field("closed_at", "NULL"),+ ],+ )?,+ members: read_records(+ &connection,+ "agent_team_members",+ "id",+ &[+ field("id", "NULL"),+ field("team_id", "NULL"),+ field("name", "''"),+ field("agent_id", "NULL"),+ field("member_status", "''"),+ field("current_task_id", "NULL"),+ field("worker_thread_id", "NULL"),+ field("run_id", "NULL"),+ field("created_at", "NULL"),+ field("updated_at", "NULL"),+ ],+ )?,+ tasks: read_records(+ &connection,+ "agent_team_tasks",+ "id",+ &[+ field("id", "NULL"),+ field("team_id", "NULL"),+ field("title", "''"),+ field("objective", "NULL"),+ field("status", "''"),+ field("owner_member_id", "NULL"),+ field("claimed_by_member_id", "NULL"),+ field("claim_token", "NULL"),+ renamed("depends_on_json", "depends_on", "'[]'", Decode::JsonArray),+ field("gate_status", "'pending'"),+ field("gate_reason", "NULL"),+ renamed("evidence_json", "evidence", "'[]'", Decode::JsonArray),+ field("source_run_id", "NULL"),+ field("order_index", "0"),+ field("created_at", "NULL"),+ field("updated_at", "NULL"),+ ],+ )?,+ tool_effects: read_tool_effects(&connection)?,+ })+ }+}++fn read_records<T: DeserializeOwned>(+ connection: &rusqlite::Connection,+ table: &str,+ order_by: &str,+ fields: &[Field],+) -> Result<Vec<T>> {+ if !table_exists(connection, table)? {+ return Ok(Vec::new());+ }+ let columns = table_columns(connection, table)?;+ let select = fields+ .iter()+ .map(|field| {+ let expression = if columns.contains(field.column) {+ format!("\"{}\"", field.column)+ } else {+ field.fallback.to_owned()+ };+ format!("{expression} AS \"{}\"", field.output)+ })+ .collect::<Vec<_>>()+ .join(", ");+ let sql = format!("SELECT {select} FROM \"{table}\" ORDER BY {order_by}");+ let mut statement = connection+ .prepare(&sql)+ .with_context(|| format!("prepare legacy {table} read"))?;+ let mut rows = statement+ .query([])+ .with_context(|| format!("query legacy {table}"))?;+ let mut records = Vec::new();+ while let Some(row) = rows+ .next()+ .with_context(|| format!("read legacy {table}"))?+ {+ let mut object = Map::new();+ for (index, field) in fields.iter().enumerate() {+ let value = sql_value(row.get_ref(index)?)?;+ object.insert(field.output.to_owned(), decode_value(value, field.decode));+ }+ normalize_legacy_status(table, &mut object)?;+ let record: T = serde_json::from_value(Value::Object(object))+ .with_context(|| format!("decode legacy {table} row"))?;+ records.push(record);+ }+ Ok(records)+}++fn read_tool_effects(connection: &rusqlite::Connection) -> Result<Vec<ToolEffectRow>> {+ #[derive(serde::Deserialize)]+ struct RawEffect {+ run_id: String,+ call_id: String,+ tool: String,+ status: String,+ idempotency_key: Option<String>,+ effect_summary: Option<String>,+ started_at: chrono::DateTime<chrono::Utc>,+ settled_at: Option<chrono::DateTime<chrono::Utc>>,+ }++ read_records::<RawEffect>(+ connection,+ "tool_effects",+ "run_id, call_id",+ &[+ field("run_id", "NULL"),+ field("call_id", "NULL"),+ field("tool", "''"),+ field("status", "'started'"),+ field("idempotency_key", "NULL"),+ field("effect_summary", "NULL"),+ field("started_at", "NULL"),+ field("settled_at", "NULL"),+ ],+ )?+ .into_iter()+ .map(|row| {+ let status = ToolEffectStatus::parse(&row.status);+ Ok(ToolEffectRow {+ run_id: row.run_id,+ call_id: row.call_id,+ tool: row.tool,+ status,+ idempotency_key: row.idempotency_key,+ effect_summary: row.effect_summary,+ started_at: row.started_at,+ settled_at: row.settled_at,+ })+ })+ .collect()+}++fn decode_value(value: Value, decode: Decode) -> Value {+ match decode {+ Decode::Plain => value,+ Decode::JsonOrEmpty => value+ .as_str()+ .and_then(|raw| serde_json::from_str(raw).ok())+ .unwrap_or_else(|| json!({})),+ Decode::OptionalJson => value+ .as_str()+ .and_then(|raw| serde_json::from_str(raw).ok())+ .unwrap_or(Value::Null),+ Decode::JsonArray => value+ .as_str()+ .and_then(|raw| serde_json::from_str(raw).ok())+ .filter(Value::is_array)+ .unwrap_or_else(|| json!([])),+ }+}++fn normalize_legacy_status(table: &str, row: &mut Map<String, Value>) -> Result<()> {+ let Some(Value::String(status)) = row.get_mut("status") else {+ return Ok(());+ };+ let valid = match table {+ "sessions" => &["running", "completed", "failed", "interrupted"][..],+ "agent_runs" => &[+ "pending",+ "running",+ "awaiting_user",+ "paused",+ "completed",+ "failed",+ "cancelled",+ "interrupted",+ ][..],+ "workflow_runs" => &[+ "pending",+ "running",+ "completed",+ "failed",+ "cancelled",+ "interrupted",+ ][..],+ "agent_teams" => &["active", "closed"][..],+ "agent_team_members" => &["pending", "active", "idle", "stopped"][..],+ "agent_team_tasks" => &["todo", "ready", "in_progress", "blocked", "done"][..],+ _ => return Ok(()),+ };+ if valid.contains(&status.as_str()) {+ return Ok(());+ }+ match table {+ "sessions" => *status = "running".to_owned(),+ "workflow_runs" => *status = "pending".to_owned(),+ "agent_teams" => *status = "active".to_owned(),+ "agent_team_members" => *status = "pending".to_owned(),+ "agent_team_tasks" => *status = "todo".to_owned(),+ "agent_runs" => bail!("unknown legacy agent-run status `{status}`"),+ _ => {}+ }+ Ok(())+}++fn sql_value(value: ValueRef<'_>) -> Result<Value> {+ Ok(match value {+ ValueRef::Null => Value::Null,+ ValueRef::Integer(value) => Value::Number(Number::from(value)),+ ValueRef::Real(value) => Number::from_f64(value)+ .map(Value::Number)+ .context("legacy SQLite value is not a finite number")?,+ ValueRef::Text(value) => Value::String(+ std::str::from_utf8(value)+ .context("legacy SQLite text is not UTF-8")?+ .to_owned(),+ ),+ ValueRef::Blob(_) => bail!("unexpected binary value in legacy session row"),+ })+}++fn table_exists(connection: &rusqlite::Connection, table: &str) -> Result<bool> {+ connection+ .query_row(+ "SELECT EXISTS(SELECT 1 FROM sqlite_master WHERE type = 'table' AND name = ?1)",+ [table],+ |row| row.get(0),+ )+ .with_context(|| format!("inspect legacy table `{table}`"))+}++fn table_columns(+ connection: &rusqlite::Connection,+ table: &str,+) -> Result<std::collections::HashSet<String>> {+ let mut statement = connection+ .prepare(&format!("PRAGMA table_info(\"{table}\")"))+ .with_context(|| format!("inspect legacy `{table}` columns"))?;+ let columns = statement+ .query_map([], |row| row.get::<_, String>(1))+ .with_context(|| format!("read legacy `{table}` columns"))?+ .collect::<rusqlite::Result<std::collections::HashSet<_>>>()+ .with_context(|| format!("collect legacy `{table}` columns"))?;+ Ok(columns)+}++#[cfg(test)]+#[path = "session_db_tests.rs"]+mod tests;diff --git a/crates/openhuman-core/src/storage/import/session_db_tests.rs b/crates/openhuman-core/src/storage/import/session_db_tests.rsnew file mode 100644index 0000000000..46f0ca3b4f--- /dev/null+++ b/crates/openhuman-core/src/storage/import/session_db_tests.rs@@ -0,0 +1,132 @@+use super::*;++use std::path::Path;++use crate::storage::rusqlite::{Connection, params};++fn classic_session_file(path: &Path) {+ let connection = Connection::open(path).unwrap();+ connection+ .execute_batch(+ "CREATE TABLE sessions (+ id TEXT PRIMARY KEY,+ agent_definition_id TEXT NOT NULL,+ agent_definition_name TEXT NOT NULL,+ session_key TEXT NOT NULL,+ status TEXT NOT NULL,+ turn_count INTEGER NOT NULL,+ input_tokens INTEGER NOT NULL,+ output_tokens INTEGER NOT NULL,+ cached_input_tokens INTEGER NOT NULL,+ cost_usd REAL NOT NULL,+ started_at TEXT NOT NULL+ );+ CREATE TABLE session_messages (+ id INTEGER PRIMARY KEY,+ session_id TEXT NOT NULL,+ role TEXT NOT NULL,+ content TEXT NOT NULL,+ created_at TEXT NOT NULL+ );+ CREATE TABLE session_tool_calls (+ id INTEGER PRIMARY KEY,+ session_id TEXT NOT NULL,+ message_id INTEGER,+ tool_name TEXT NOT NULL,+ status TEXT NOT NULL,+ created_at TEXT NOT NULL+ );",+ )+ .unwrap();+ connection+ .execute(+ "INSERT INTO sessions VALUES (?1, ?2, ?3, ?4, ?5, ?6, ?7, ?8, ?9, ?10, ?11)",+ params![+ "session-1",+ "agent-a",+ "Agent A",+ "thread-1",+ "unknown-old-status",+ 3,+ 10,+ 20,+ 4,+ 0.125,+ "2025-01-02T03:04:05Z"+ ],+ )+ .unwrap();+ connection+ .execute(+ "INSERT INTO session_messages VALUES (?1, ?2, ?3, ?4, ?5)",+ params![+ 41,+ "session-1",+ "assistant",+ "preserved answer",+ "2025-01-02T03:05:06Z"+ ],+ )+ .unwrap();+ connection+ .execute(+ "INSERT INTO session_tool_calls VALUES (?1, ?2, ?3, ?4, ?5, ?6)",+ params![+ 73,+ "session-1",+ 41,+ "search",+ "completed",+ "2025-01-02T03:05:07Z"+ ],+ )+ .unwrap();+}++#[test]+fn reads_classic_rows_with_original_ids_timestamps_and_old_column_defaults() {+ let dir = tempfile::tempdir().unwrap();+ let path = dir.path().join("sessions.db");+ classic_session_file(&path);++ let rows = SessionDatabase::read(&path).unwrap();++ assert_eq!(rows.sessions.len(), 1);+ assert_eq!(rows.sessions[0].id, "session-1");+ assert_eq!(rows.sessions[0].status.as_str(), "running");+ assert_eq!(rows.sessions[0].turn_count, 3);+ assert_eq!(rows.sessions[0].input_tokens, 10);+ assert_eq!(+ rows.sessions[0].started_at.to_rfc3339(),+ "2025-01-02T03:04:05+00:00"+ );+ assert_eq!(rows.messages.len(), 1);+ assert_eq!(rows.messages[0].id, 41);+ assert_eq!(rows.messages[0].content, "preserved answer");+ assert_eq!(rows.messages[0].reasoning_content, None);+ assert_eq!(+ rows.messages[0].created_at.to_rfc3339(),+ "2025-01-02T03:05:06+00:00"+ );+ assert_eq!(rows.tool_calls.len(), 1);+ assert_eq!(rows.tool_calls[0].id, 73);+ assert_eq!(rows.tool_calls[0].message_id, Some(41));+}++#[test]+fn rejects_a_database_without_classic_session_tables() {+ let dir = tempfile::tempdir().unwrap();+ let path = dir.path().join("unrelated.db");+ Connection::open(&path)+ .unwrap()+ .execute_batch("CREATE TABLE unrelated (id TEXT PRIMARY KEY);")+ .unwrap();++ let error = SessionDatabase::read(&path).unwrap_err();++ assert!(+ error+ .to_string()+ .contains("none of the classic session database tables")+ );+}diff --git a/crates/openhuman-core/src/storage/import/sessions.rs b/crates/openhuman-core/src/storage/import/sessions.rsindex 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.rsindex 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.rs b/crates/openhuman-core/src/storage/import/tinyflows.rsindex 3ba4d579ce..80c16b6f4b 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;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.rsindex 3989529f1c..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@@ -11,7 +11,7 @@ use tinyflows_bus::catalog::{MAX_IMPORT_RECORD_PAYLOAD_BYTES,};-use super::legacy_db::{column_or, LegacyDb};+use super::legacy_db::{LegacyDb, column_or};/// Reads legacy flow database rows and draft files as bounded ordered batches.///@@ -120,9 +120,9 @@ async fn page_rows<T, ToRecord, F, Fut>(what: &'static str,query: &str,decode: impl Fn(&crate::storage::rusqlite::Row<'_>) -> crate::storage::rusqlite::Result<T>- + Send- + Sync- + 'static,+ + Send+ + Sync+ + 'static,to_record: ToRecord,batches: &mut BatchSender,send: &mut F,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.rsindex b949b6f755..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@@ -14,7 +14,7 @@use std::collections::HashSet;use std::path::Path;-use anyhow::{anyhow, Context, Result};+use anyhow::{Context, Result, anyhow};use chrono::{DateTime, Utc};use std::collections::HashMap;use tinyflows_bus::schedule::types::{@@ -22,7 +22,7 @@ use tinyflows_bus::schedule::types::{SessionTarget,};-use super::legacy_db::{column_or, LegacyDb};+use super::legacy_db::{LegacyDb, column_or};use super::report::ImportReport;/// What `jobs.db` held, decoded.diff --git a/crates/openhuman-core/src/storage/import/tinyflows_tests.rs b/crates/openhuman-core/src/storage/import/tinyflows_tests.rsindex 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()+ );}}