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
feat(security): persist device documents in the storage layer
Steven Enamakel96829facbee7
diff --git a/crates/openhuman-core/src/security/devices/store_documents.rs b/crates/openhuman-core/src/security/devices/store_documents.rsindex 0dc79dfdc2..f4b94b6b92 100644--- a/crates/openhuman-core/src/security/devices/store_documents.rs+++ b/crates/openhuman-core/src/security/devices/store_documents.rs@@ -1,7 +1,8 @@//! Paired devices on the `tinystoragedrivers` document port.//!-//! Used instead of `devices/devices.db` when the host configured a storage-//! backend ([`crate::storage`]); the functions in `store.rs` pick it per call.+//! Kept in the storage backend ([`crate::storage`]); the functions in+//! `store.rs` open it per call. The old `devices/devices.db` is read once by+//! the importer ([`import_source`]).//! Devices live under the current call's storage scope (the acting agent,//! `local` on a single-user host).//!@@ -18,7 +19,6 @@ use tinystoragedrivers::{CollectionSpec, Filter, IndexSpec, Precondition, Query,use crate::config::Config;use crate::security::devices::types::PairedDevice;use crate::storage::documents::{compare_and_swap, text, Repo};-use crate::storage::local::{self, ImportPlan};use crate::storage::DocumentStoreExt;pub(super) const DEVICES: &str = "paired_devices";@@ -39,17 +39,13 @@ fn collections() -> Vec<CollectionSpec> {vec![CollectionSpec::new(DEVICES).index(IndexSpec::new("by_active", ["revoked", "created_at"]))]}-/// The document store for this call: the host's configured backend or, by-/// default, the document tables in `devices.db` (the legacy table imported on-/// first open). `None` keeps the legacy table.-pub(super) fn current(config: &Config) -> Result<Option<Docs>> {- let plan = ImportPlan {- domain: DOMAIN,- tables: super::store::import::TABLES,- read: &|| super::store::import::read(config),- };- let db_path = super::store::db_path(config);- Ok(local::repo(config, &db_path, DOMAIN, collections, &plan)?.map(Docs))+/// The document store for this call: the storage backend, in the acting scope.+pub(super) fn current(config: &Config) -> Result<Docs> {+ Ok(Docs(Repo::current_for(+ &config.workspace_dir,+ DOMAIN,+ collections,+ )?))}fn to_device(stored: &Versioned<Value>) -> PairedDevice {diff --git a/crates/openhuman-core/src/storage/documents.rs b/crates/openhuman-core/src/storage/documents.rsindex 6488837a82..cec609bd7c 100644--- a/crates/openhuman-core/src/storage/documents.rs+++ b/crates/openhuman-core/src/storage/documents.rs@@ -108,6 +108,23 @@ impl Repo {Self::on(&backend, &scope, domain, collections).map(Some)}+ /// The repo for a store keyed by a workspace: the process's backend (or the+ /// workspace's own default when none is installed,+ /// [`super::local::backend_for`]) under the acting scope.+ ///+ /// # Errors+ ///+ /// When the backend cannot be had or the scope cannot be resolved (SaaS mode+ /// with no acting profile).+ pub fn current_for(+ workspace_dir: &std::path::Path,+ domain: &'static str,+ collections: fn() -> Vec<CollectionSpec>,+ ) -> Result<Self> {+ let opened = super::local::open(domain, workspace_dir)?;+ Self::on(&opened.backend, &opened.scope, domain, collections)+ }+/// The repo over `backend` under `scope`, declaring its collections once/// per process.///