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(storage): adopt tsd v1.0.0 and the tenant scope grammar for sessions
Steven Enamakel24faf256aa60
diff --git a/crates/openhuman-app/Cargo.lock b/crates/openhuman-app/Cargo.lockindex 88e7fd130d..3479210551 100644--- a/crates/openhuman-app/Cargo.lock+++ b/crates/openhuman-app/Cargo.lock@@ -608,7 +608,7 @@ dependencies = ["cap-primitives","cap-std","io-lifetimes 3.0.1",- "windows-sys 0.60.2",+ "windows-sys 0.61.2",][[package]]@@ -625,7 +625,7 @@ dependencies = ["maybe-owned","rustix 1.1.5","rustix-linux-procfs",- "windows-sys 0.60.2",+ "windows-sys 0.61.2","winx",]@@ -681,6 +681,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index"checksum = "54413ede23c2daf518f35156dfde027feb2374004d63bd497f983c8db9c0e313"dependencies = ["find-msvc-tools",+ "jobserver",+ "libc","shlex",]@@ -1247,7 +1249,7 @@ dependencies = ["libc","option-ext","redox_users 0.5.3",- "windows-sys 0.60.2",+ "windows-sys 0.59.0",][[package]]@@ -1499,7 +1501,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"checksum = "39cab71617ae0d63f51a36d69f866391735b51691dbda63cf6f96d042b63efeb"dependencies = ["libc",- "windows-sys 0.52.0",+ "windows-sys 0.59.0",][[package]]@@ -1713,7 +1715,7 @@ checksum = "94e7099f6313ecacbe1256e8ff9d617b75d1bcb16a6fddef94866d225a01a14a"dependencies = ["io-lifetimes 2.0.4","rustix 1.1.5",- "windows-sys 0.52.0",+ "windows-sys 0.59.0",][[package]]@@ -2613,7 +2615,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"checksum = "20fd6de4ccfcc187e38bc21cfa543cb5a302cb86a8b114eb7f0bf0dc9f8ac00f"dependencies = ["io-lifetimes 3.0.1",- "windows-sys 0.52.0",+ "windows-sys 0.59.0",][[package]]@@ -2851,6 +2853,16 @@ dependencies = ["syn 2.0.119",]+[[package]]+name = "jobserver"+version = "0.1.35"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "1c00acbd29eabad4a2392fa0e921c874934dbbf4194312ad20f04a0ed67a3cb3"+dependencies = [+ "getrandom 0.4.3",+ "libc",+]+[[package]]name = "js-sys"version = "0.3.105"@@ -3238,7 +3250,7 @@ dependencies = ["png 0.18.1","serde","thiserror 2.0.20",- "windows-sys 0.60.2",+ "windows-sys 0.61.2",][[package]]@@ -3341,7 +3353,7 @@ version = "0.50.3"source = "registry+https://github.com/rust-lang/crates.io-index"checksum = "7957b9740744892f114936ab4a57b3f487491bbeafaf8083688b16841a4240e5"dependencies = [- "windows-sys 0.60.2",+ "windows-sys 0.59.0",][[package]]@@ -4529,7 +4541,7 @@ dependencies = ["once_cell","socket2","tracing",- "windows-sys 0.52.0",+ "windows-sys 0.59.0",][[package]]@@ -4932,7 +4944,7 @@ dependencies = ["errno","libc","linux-raw-sys 0.4.15",- "windows-sys 0.52.0",+ "windows-sys 0.59.0",][[package]]@@ -4945,7 +4957,7 @@ dependencies = ["errno","libc","linux-raw-sys 0.12.1",- "windows-sys 0.52.0",+ "windows-sys 0.59.0",][[package]]@@ -5013,7 +5025,7 @@ dependencies = ["security-framework 3.7.0","security-framework-sys","webpki-root-certs",- "windows-sys 0.52.0",+ "windows-sys 0.59.0",][[package]]@@ -5625,7 +5637,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"checksum = "c3d1e2c7f27f8d4cb10542a02c49005dbd6e93095799d6f3be745fae9f8fedd4"dependencies = ["libc",- "windows-sys 0.60.2",+ "windows-sys 0.61.2",][[package]]@@ -6338,7 +6350,7 @@ dependencies = ["serde_with","swift-rs","thiserror 2.0.20",- "toml 1.1.6+spec-1.1.0",+ "toml 0.9.12+spec-1.1.0","url","urlpattern","uuid",@@ -6374,10 +6386,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index"checksum = "32497e9a4c7b38532efcdebeef879707aa9f794296a4f0244f6f69e9bc8574bd"dependencies = ["fastrand",- "getrandom 0.3.4",+ "getrandom 0.4.3","once_cell","rustix 1.1.5",- "windows-sys 0.52.0",+ "windows-sys 0.59.0",][[package]]@@ -6514,7 +6526,6 @@ dependencies = ["futures","serde","serde_json",- "sha2 0.11.0","tinyagents-harness","tinyagents-tasks","tinyinference-llm",@@ -6673,7 +6684,7 @@ dependencies = [[[package]]name = "tinybox-bus"-version = "0.1.35"+version = "0.1.36"dependencies = ["serde",]@@ -7068,7 +7079,7 @@ dependencies = [[[package]]name = "tinymcp-bus"-version = "0.18.6"+version = "0.18.7"dependencies = ["base64 0.23.1","schemars 1.2.2",@@ -7177,6 +7188,7 @@ name = "tinyskills-drivers"version = "0.5.1"dependencies = ["cap-std",+ "serde","serde_json","thiserror 2.0.20","tinyskills",@@ -7186,7 +7198,7 @@ dependencies = [[[package]]name = "tinystoragedrivers"-version = "0.11.0"+version = "1.0.0"dependencies = ["tinystoragedrivers-core","tinystoragedrivers-file",@@ -7196,7 +7208,7 @@ dependencies = [[[package]]name = "tinystoragedrivers-bus"-version = "0.11.0"+version = "1.0.0"dependencies = ["serde","serde_json",@@ -7205,7 +7217,7 @@ dependencies = [[[package]]name = "tinystoragedrivers-busproxy"-version = "0.11.0"+version = "1.0.0"dependencies = ["async-trait","serde",@@ -7219,7 +7231,7 @@ dependencies = [[[package]]name = "tinystoragedrivers-client"-version = "0.11.0"+version = "1.0.0"dependencies = ["async-trait","serde",@@ -7232,18 +7244,22 @@ dependencies = [[[package]]name = "tinystoragedrivers-core"-version = "0.11.0"+version = "1.0.0"dependencies = ["async-trait",+ "data-encoding","serde","serde_json",+ "sha2 0.10.9","thiserror 2.0.20","tokio",+ "ulid",+ "zstd",][[package]]name = "tinystoragedrivers-file"-version = "0.11.0"+version = "1.0.0"dependencies = ["async-trait","libc",@@ -7255,7 +7271,7 @@ dependencies = [[[package]]name = "tinystoragedrivers-secrets"-version = "0.11.0"+version = "1.0.0"dependencies = ["async-trait","atomicwrites",@@ -7278,12 +7294,14 @@ dependencies = [[[package]]name = "tinystoragedrivers-sqlite"-version = "0.11.0"+version = "1.0.0"dependencies = ["rusqlite","serde_json",+ "sha2 0.10.9","tinystoragedrivers-core","tokio",+ "zstd",][[package]]@@ -7736,7 +7754,7 @@ dependencies = ["png 0.18.1","serde","thiserror 2.0.20",- "windows-sys 0.60.2",+ "windows-sys 0.61.2",][[package]]@@ -7808,7 +7826,17 @@ checksum = "f2f6fb2847f6742cd76af783a2a2c49e9375d0a111c7bef6f71cd9e738c72d6e"dependencies = ["memoffset","tempfile",- "windows-sys 0.60.2",+ "windows-sys 0.61.2",+]++[[package]]+name = "ulid"+version = "1.2.1"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "470dbf6591da1b39d43c14523b2b469c86879a53e8b758c8e090a470fe7b1fbe"+dependencies = [+ "rand 0.9.5",+ "web-time",][[package]]@@ -8412,7 +8440,7 @@ version = "0.1.11"source = "registry+https://github.com/rust-lang/crates.io-index"checksum = "c2a7b1c03c876122aa43f3020e6c3c3ee5c05081c9a00739faf7503aeba10d22"dependencies = [- "windows-sys 0.48.0",+ "windows-sys 0.59.0",][[package]]@@ -8980,7 +9008,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"checksum = "3f3fd376f71958b862e7afb20cfe5a22830e1963462f3a17f49d82a6c1d1f42d"dependencies = ["bitflags 2.13.2",- "windows-sys 0.52.0",+ "windows-sys 0.59.0",][[package]]@@ -9323,6 +9351,34 @@ dependencies = ["simd-adler32",]+[[package]]+name = "zstd"+version = "0.13.3"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "e91ee311a569c327171651566e07972200e76fcfe2242a4fa446149a3881c08a"+dependencies = [+ "zstd-safe",+]++[[package]]+name = "zstd-safe"+version = "7.3.0"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "64d80649ab6db9d9f6f9c80a40becd948eda4714a0a5ac8c4d157a32231c7882"+dependencies = [+ "zstd-sys",+]++[[package]]+name = "zstd-sys"+version = "2.1.2+zstd.1.5.7"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "481ada9c543b2323cbb7bbdbb5249177fbf0188ed959ed2c15e4b22421c84ed3"+dependencies = [+ "cc",+ "pkg-config",+]+[[package]]name = "zvariant"version = "5.15.0"diff --git a/crates/openhuman-core/src/agent/session_store/splice_fixture.rs b/crates/openhuman-core/src/agent/session_store/splice_fixture.rsindex 51f56c2eb0..6f5a5fed4a 100644--- a/crates/openhuman-core/src/agent/session_store/splice_fixture.rs+++ b/crates/openhuman-core/src/agent/session_store/splice_fixture.rs@@ -14,7 +14,10 @@ use tinyagents_session::transcript::{TranscriptLocator, TranscriptMessage, Trans/// A fresh transcript store over the driver ports on memory (the production/// store, minus the disk), shared by cloning the `Arc`.pub(crate) fn memory_locator() -> Arc<dyn TranscriptLocator> {- DriverSessionStores::new(Arc::new(crate::storage::MemoryStorage::new()))+ DriverSessionStores::new(+ Arc::new(crate::storage::MemoryStorage::new()),+ crate::storage::Scope::local(),+ ).expect("driver session stores over memory").for_agent("fixture").transcriptsdiff --git a/crates/openhuman-core/src/agent/session_store/tenant_router_tests.rs b/crates/openhuman-core/src/agent/session_store/tenant_router_tests.rsnew file mode 100644index 0000000000..41d9efc133--- /dev/null+++ b/crates/openhuman-core/src/agent/session_store/tenant_router_tests.rs@@ -0,0 +1,49 @@+use super::*;+use crate::storage::MemoryStorage;++fn stores() -> TenantSessionStores {+ TenantSessionStores::new(Arc::new(MemoryStorage::new()), false).expect("bridge")+}++#[test]+fn an_unprofiled_key_routes_to_the_local_tenant() {+ let router = stores();+ let (provider, agent) = router.route("asha");+ assert_eq!(provider.tenant(), &Scope::local());+ assert_eq!(agent, "asha");+ assert_eq!(provider.scope_for(&agent).unwrap().as_str(), "local/agent:asha");+}++#[test]+fn a_profile_key_routes_to_the_profile_tenant() {+ let router = stores();+ let key = crate::core::runtime::session_key(&crate::core::runtime::Tenant {+ profile: Some("alice".into()),+ agent: Some("asha".into()),+ });+ let (provider, agent) = router.route(&key);+ assert_eq!(provider.tenant().as_str(), "u:alice");+ assert_eq!(provider.scope_for(&agent).unwrap().as_str(), "u:alice/agent:asha");+}++#[test]+fn escaped_keys_round_trip_to_the_same_tenant_and_agent() {+ let router = stores();+ let key = crate::core::runtime::session_key(&crate::core::runtime::Tenant {+ profile: Some("a~b%c".into()),+ agent: None,+ });+ let (provider, agent) = router.route(&key);+ assert_eq!(provider.tenant(), &crate::storage::scope_for_profile("a~b%c"));+ assert_eq!(agent, "default");+}++#[test]+fn one_provider_serves_every_agent_of_a_tenant() {+ let router = stores();+ let (first, _) = router.route("one");+ let (second, _) = router.route("two");+ assert!(Arc::ptr_eq(&first, &second));+ let (other, _) = router.route("u~two");+ assert!(!Arc::ptr_eq(&first, &other));+}diff --git a/crates/openhuman-core/src/desktop/notifications/store_documents_tests.rs b/crates/openhuman-core/src/desktop/notifications/store_documents_tests.rsindex 4ca6787f8d..ed387c0c77 100644--- a/crates/openhuman-core/src/desktop/notifications/store_documents_tests.rs+++ b/crates/openhuman-core/src/desktop/notifications/store_documents_tests.rs@@ -314,6 +314,7 @@ fn an_unparseable_raw_payload_reads_as_a_string() {id: "x".to_string(),version: tinystoragedrivers::Version::FIRST,doc: json!({ "raw_payload": "plain text", "status": "weird" }),+ meta: tinystoragedrivers::Meta::unknown(),};let read = to_notification(&stored);assert_eq!(read.raw_payload, json!("plain text"));diff --git a/crates/openhuman-core/src/mcp/host_tests.rs b/crates/openhuman-core/src/mcp/host_tests.rsindex 2a36a573d8..06573e85ad 100644--- a/crates/openhuman-core/src/mcp/host_tests.rs+++ b/crates/openhuman-core/src/mcp/host_tests.rs@@ -16,6 +16,7 @@ fn populated_server() -> HostServer {enabled: false,allowed_tools: vec!["forecast".into()],disallowed_tools: vec!["debug".into()],+ operator_trusted: false,timeout_secs: 9,auth: McpAuthConfig::BearerToken { token: "t".into() },},diff --git a/crates/openhuman-core/src/modules/storage_host_watching.rs b/crates/openhuman-core/src/modules/storage_host_watching.rsindex be7c9fe02e..eaa45908bf 100644--- a/crates/openhuman-core/src/modules/storage_host_watching.rs+++ b/crates/openhuman-core/src/modules/storage_host_watching.rs@@ -41,10 +41,6 @@ impl StorageBackend for WatchingStorage {self.inner.capabilities().with(Capability::Watch)}- fn database(&self, name: &str) -> Result<Arc<dyn StorageBackend>> {- self.inner.database(name)- }-fn for_scope(&self, scope: &Scope) -> Result<ScopedStorage> {let scoped = self.inner.for_scope(scope)?;let sender = {diff --git a/crates/openhuman-core/src/profiles/recovery_tests.rs b/crates/openhuman-core/src/profiles/recovery_tests.rsindex 0dac5e49c1..25bf39fb97 100644--- a/crates/openhuman-core/src/profiles/recovery_tests.rs+++ b/crates/openhuman-core/src/profiles/recovery_tests.rs@@ -14,7 +14,7 @@ fn profile() -> ProfileId {fn context_with_store() -> (Arc<CoreContext>, Arc<dyn SessionStoreProvider>) {let backend: Arc<dyn StorageBackend> = Arc::new(MemoryStorage::new());let provider: Arc<dyn SessionStoreProvider> = Arc::new(- tinyagents_session::DriverSessionStores::new(backend)+ tinyagents_session::DriverSessionStores::new(backend, crate::storage::Scope::local()).unwrap().recover_on_open(false),);diff --git a/crates/openhuman-core/src/storage/blob_sweep_tests.rs b/crates/openhuman-core/src/storage/blob_sweep_tests.rsindex 3707638d52..8bf1fbe0c7 100644--- a/crates/openhuman-core/src/storage/blob_sweep_tests.rs+++ b/crates/openhuman-core/src/storage/blob_sweep_tests.rs@@ -165,9 +165,6 @@ impl StorageBackend for HungSweep {) -> tinystoragedrivers::Result<tinystoragedrivers::ScopedStorage> {self.0.for_scope(scope)}- fn database(&self, name: &str) -> tinystoragedrivers::Result<Arc<dyn StorageBackend>> {- self.0.database(name)- }async fn sweep_expired_blobs(&self, _scope: &Scope) -> tinystoragedrivers::Result<u64> {std::future::pending().await}diff --git a/crates/openhuman-core/src/storage/config_tests.rs b/crates/openhuman-core/src/storage/config_tests.rsindex 373b953def..776db395f8 100644--- a/crates/openhuman-core/src/storage/config_tests.rs+++ b/crates/openhuman-core/src/storage/config_tests.rs@@ -79,7 +79,6 @@ async fn the_default_url_opens_in_directory_mode() {.await.unwrap();assert_eq!(backend.driver(), "sqlite");- // Directory mode: a named database is its own file in the directory.- backend.database("approvals").unwrap();- assert!(dir.path().join(DEFAULT_DIR).join("approvals.db").exists());+ // Directory mode: the directory holds the database file.+ assert!(dir.path().join(DEFAULT_DIR).exists());}diff --git a/crates/openhuman-core/src/storage/fenced_backend_tests.rs b/crates/openhuman-core/src/storage/fenced_backend_tests.rsindex 12a1a28bb0..450471cd67 100644--- a/crates/openhuman-core/src/storage/fenced_backend_tests.rs+++ b/crates/openhuman-core/src/storage/fenced_backend_tests.rs@@ -165,24 +165,6 @@ async fn a_renewed_grant_keeps_admitting_writes() {a.put("profile:alice", "n").await.unwrap();}-#[tokio::test]-async fn named_databases_are_fenced_too() {- let backend = shared();- let (a, b) = (Node::new("node-a", &backend), Node::new("node-b", &backend));- a.take("alice").await;- b.set_clock(TTL.as_millis() as u64 + 1);- b.take("alice").await;- let sessions = a.storage.database("sessions").unwrap();- let scoped = sessions- .for_scope(&Scope::new("alice~default").unwrap())- .unwrap();- assert!(scoped- .documents()- .put("t", "x", json!({}), Precondition::None)- .await- .is_err());-}-/// File leases (`LocalLeases`, hosts without a backend) cannot be lost while/// the process lives, so a fence over one admits writes until the holder/// releases it.@@ -371,26 +353,6 @@ async fn stream_and_blob_writes_are_driver_fenced() {assert!(scoped.blobs().put("k", b"x".to_vec(), None).await.is_err());}-/// A named database cannot see the lease record, so its writes get the-/// host check only: the race stays open there, as the module docs say.-#[tokio::test]-async fn a_named_database_falls_back_to_the_host_check() {- let backend = shared();- let (a, fence, leases) = paused_holder(&backend).await;- let scoped = a- .database("sessions")- .unwrap()- .for_scope(&Scope::new("profile:alice").unwrap())- .unwrap();- leases.armed.store(true, Ordering::SeqCst);- scoped- .documents()- .put("t", "x", json!({}), Precondition::None)- .await- .unwrap();- assert!(!fence.is_fenced());-}-/// A driver without fencing gets the host check only, and writes through.#[tokio::test]async fn a_driver_without_fencing_falls_back_to_the_host_check() {@@ -418,9 +380,6 @@ impl StorageBackend for NoFencing {fn for_scope(&self, scope: &Scope) -> Result<ScopedStorage> {self.0.for_scope(scope)}- fn database(&self, name: &str) -> Result<Arc<dyn StorageBackend>> {- self.0.database(name)- }}/// The run ledger claims team tasks with `atomic_batch_checked`. The fenceddiff --git a/crates/openhuman-core/src/storage/import/sessions_tests.rs b/crates/openhuman-core/src/storage/import/sessions_tests.rsindex 0edb5b1d1b..001f6b601d 100644--- a/crates/openhuman-core/src/storage/import/sessions_tests.rs+++ b/crates/openhuman-core/src/storage/import/sessions_tests.rs@@ -124,7 +124,7 @@ fn a_classic_workspace_moves_into_the_backend_and_its_files_are_untouched() {let outcome = reports.into_iter().next().unwrap().outcome.unwrap();assert!(matches!(outcome, Outcome::Imported { .. }), "{outcome:?}");- let provider = DriverSessionStores::new(Arc::clone(&backend)).unwrap();+ let provider = DriverSessionStores::new(Arc::clone(&backend), Scope::local()).unwrap();// The transcript landed in the orchestrator's scope, where its session// resumes it.let orchestrator = provider.try_for_agent("orchestrator").unwrap();@@ -183,7 +183,7 @@ fn a_transcript_naming_an_unknown_agent_lands_in_the_default_agent() {run_with(&backend, &config).remove(0).outcome.unwrap();- let provider = DriverSessionStores::new(Arc::clone(&backend)).unwrap();+ let provider = DriverSessionStores::new(Arc::clone(&backend), Scope::local()).unwrap();let default = provider.try_for_agent(DEFAULT_AGENT).unwrap();assert!(default.transcripts.root_for_thread("thread-9").is_some());}diff --git a/crates/openhuman-embed/tests/session_store.rs b/crates/openhuman-embed/tests/session_store.rsindex 3d0b396dc8..459aadcc2b 100644--- a/crates/openhuman-embed/tests/session_store.rs+++ b/crates/openhuman-embed/tests/session_store.rs@@ -170,7 +170,7 @@ fn a_stateless_runtime_keeps_every_conversation_in_its_session_store() {.expect("asha's storage scope").documents().query_all(- tinyagents_harness::observability::DriverStatusStore::DEFAULT_COLLECTION,+ tinyagents_harness::observability::DriverStatusStore::COLLECTION,&Default::default(),).awaitdiff --git a/tests/support/cron_policy_failure.rs b/tests/support/cron_policy_failure.rsindex 5926e2f6c7..24cde5e545 100644--- a/tests/support/cron_policy_failure.rs+++ b/tests/support/cron_policy_failure.rs@@ -78,12 +78,6 @@ impl StorageBackend for Backend {Arc::clone(inner.blobs()),))}- fn database(&self, name: &str) -> StoreResult<Arc<dyn StorageBackend>> {- Ok(Arc::new(Self {- inner: self.inner.database(name)?,- faults: Arc::clone(&self.faults),- }))- }}#[derive(Debug)]