Skip to content

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

feat(storage): add configurable storage backend selection

Steven Enamakela2fa05170ff7
diff --git a/crates/openhuman-core/Cargo.toml b/crates/openhuman-core/Cargo.toml
index 2ad89995cf..d2b364913b 100644
--- a/crates/openhuman-core/Cargo.toml
+++ b/crates/openhuman-core/Cargo.toml
@@ -382,6 +382,8 @@ sentry = { version = "0.47.0", default-features = false, optional = true, featur
url = "2"
tempfile = "3"
fs2 = "0.4"
+# Streams the layout-migration archive (`storage::layout::archive`), a `.tar.zst`.
+zstd = "0.13"
# The scheduler gate's battery/AC probe (`platform::llm_gate::signals`),
# behind the `scheduler-gate` feature. CPU sampling uses `sysinfo` above.
starship-battery = { version = "0.12", optional = true }
@@ -507,8 +509,6 @@ windows-sys = { version = "0.61", features = [
tokio-tungstenite = { version = "0.29", default-features = false, features = ["connect", "handshake", "rustls-tls-webpki-roots"] }
[dev-dependencies]
-# Transcript entries are stored zstd-compressed; a persistence test reads them back.
-zstd = "0.13"
# Legacy TinyChannels provider/runtime fixtures remain available to tests only;
# production channel execution uses the TinyBus module contract above.
tinychannels = { path = "../../vendor/tinychannels", features = ["relay-websocket", "email", "lark", "whatsapp-web"] }
diff --git a/crates/openhuman-core/src/config/schema/storage.rs b/crates/openhuman-core/src/config/schema/storage.rs
index dce079703e..7edf34f76e 100644
--- a/crates/openhuman-core/src/config/schema/storage.rs
+++ b/crates/openhuman-core/src/config/schema/storage.rs
@@ -17,6 +17,9 @@
//! `journal_retention_days` (default 30, `0` = forever) is how long a finished
//! run's sealed event journal is kept ([`crate::storage::journal_maintenance`]).
//!
+//! `auto_migrate_layout` (default `false`) moves the active profile from
+//! storage layout v1 to v2 at boot ([`crate::storage::layout`]).
+//!
//! `OPENHUMAN_STORAGE_URL` overrides it (see [`crate::storage`]). This
//! section is bootstrap configuration: it is always read from the file or the
//! environment, never from storage itself.
@@ -36,6 +39,12 @@ pub struct StorageConfig {
/// maintenance sweep deletes it. `0` keeps sealed journals forever.
#[serde(default = "default_journal_retention_days")]
pub journal_retention_days: u32,
+ /// Migrate the active profile from storage layout v1 to v2 at boot, before
+ /// the database opens (`storage::layout`). Off by default: `storage.migrate`
+ /// does the same on request. A failed migration leaves the profile on v1
+ /// and retries at the next boot.
+ #[serde(default)]
+ pub auto_migrate_layout: bool,
}
/// Default for [`StorageConfig::journal_retention_days`].
@@ -50,6 +59,7 @@ impl Default for StorageConfig {
Self {
url: None,
journal_retention_days: DEFAULT_JOURNAL_RETENTION_DAYS,
+ auto_migrate_layout: false,
}
}
}
@@ -60,6 +70,7 @@ impl std::fmt::Debug for StorageConfig {
f.debug_struct("StorageConfig")
.field("url", &self.url.as_deref().map(redact_url))
.field("journal_retention_days", &self.journal_retention_days)
+ .field("auto_migrate_layout", &self.auto_migrate_layout)
.finish()
}
}
diff --git a/crates/openhuman-core/src/core/all.rs b/crates/openhuman-core/src/core/all.rs
index 75192c19d1..ff4cc62d62 100644
--- a/crates/openhuman-core/src/core/all.rs
+++ b/crates/openhuman-core/src/core/all.rs
@@ -668,6 +668,12 @@ fn build_registered_controllers() -> Vec<GroupedController> {
DomainGroup::Desktop,
crate::desktop::notifications::all_notifications_registered_controllers(),
);
+ // Storage layout v1 -> v2 migration, status and restore
+ push(
+ &mut controllers,
+ DomainGroup::Config,
+ crate::storage::layout::schemas::all_registered_controllers(),
+ );
// Mobile device pairing and management
push(
&mut controllers,
@@ -885,6 +891,9 @@ pub fn namespace_description(namespace: &str) -> Option<&'static str> {
"devices" => Some(
"Paired mobile device management — pairing channel creation, listing, and revocation.",
),
+ "storage" => Some(
+ "Storage layout: migrate a profile from layout v1 to v2, report its schema versions, restore from a migration archive.",
+ ),
"subsystems" => Some(
"Kernel subsystem slots and their bound drivers: class, health, contract version, and advertised capabilities.",
),
diff --git a/crates/openhuman-core/src/storage/mod.rs b/crates/openhuman-core/src/storage/mod.rs
index 55d3b6e700..11814b9263 100644
--- a/crates/openhuman-core/src/storage/mod.rs
+++ b/crates/openhuman-core/src/storage/mod.rs
@@ -35,6 +35,7 @@ mod host_importers;
pub mod import;
pub mod import_state;
pub mod journal_maintenance;
+pub mod layout;
pub mod lease;
mod lease_documents;
mod lease_local;