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(security): update storage schema definitions
Steven Enamakel1b2f07714a87
diff --git a/crates/openhuman-core/src/security/approval/storage_schema.rs b/crates/openhuman-core/src/security/approval/storage_schema.rsindex 4751e39c08..d00ea682f4 100644--- a/crates/openhuman-core/src/security/approval/storage_schema.rs+++ b/crates/openhuman-core/src/security/approval/storage_schema.rs@@ -13,10 +13,13 @@//! document-store driver (MongoDB) must never see as field names.use serde_json::Value;-use tinystoragedrivers::schema::{Schema, ScopeClass, SourceRecord, Step, TargetRecord};-use tinystoragedrivers::{CollectionSpec, IndexSpec, Key, Result};+use anyhow::Result;+use tinystoragedrivers::{CollectionSpec, IndexSpec, Key};-use crate::storage::schema_support::{key_of, owner, time_ms, Body};+use crate::storage::schema_support::{+ key_of, map_legacy_collection, time_ms, Body, LegacySourceRecord as SourceRecord,+ LegacyTargetRecord as TargetRecord,+};/// The v2 request collection: one document per request id.pub(super) const APPROVALS: &str = "approvals.requests";@@ -27,20 +30,12 @@ pub(super) const LEGACY_APPROVALS: &str = "approvals";/// The v1 grant collection.pub(super) const LEGACY_FLOW_TRUST: &str = "approval_flow_trust";/// The body version of both collections.-const SCHEMA: u32 = 2;--/// What the approval store keeps and the steps from the v1 collections.-#[must_use]-pub fn storage_schema() -> Schema {- let [requests, trust] = specs();- Schema::new(owner("approvals"))- .collection_with(SCHEMA, requests, ScopeClass::Tenant)- .collection_with(SCHEMA, trust, ScopeClass::Tenant)- .step(Step::new("requests_v2", APPROVALS, 1, SCHEMA, requests_v2).source(LEGACY_APPROVALS))- .step(- Step::new("flow_trust_v2", FLOW_TRUST, 1, SCHEMA, flow_trust_v2)- .source(LEGACY_FLOW_TRUST),- )+/// Converts approval legacy documents into this owner's current record shapes.+pub(crate) fn upgrade_records(+ records: Vec<crate::storage::import::Record>,+) -> Result<Vec<crate::storage::import::Record>> {+ let records = map_legacy_collection(records, LEGACY_APPROVALS, requests_v2)?;+ map_legacy_collection(records, LEGACY_FLOW_TRUST, flow_trust_v2)}/// The two v2 collections with their indexes.diff --git a/crates/openhuman-core/src/security/devices/storage_schema.rs b/crates/openhuman-core/src/security/devices/storage_schema.rsindex 7015e4750d..ab7e34bfac 100644--- a/crates/openhuman-core/src/security/devices/storage_schema.rs+++ b/crates/openhuman-core/src/security/devices/storage_schema.rs@@ -6,24 +6,25 @@//! | `paired_devices` (`created_at`, `last_seen_at` RFC 3339) | `devices.paired` (`created_ms`, `last_seen_ms`) | tenant |use serde_json::Value;-use tinystoragedrivers::schema::{Schema, ScopeClass, SourceRecord, Step, TargetRecord};-use tinystoragedrivers::{CollectionSpec, IndexSpec, Result};+use anyhow::Result;+use tinystoragedrivers::{CollectionSpec, IndexSpec};-use crate::storage::schema_support::{key_of, owner, time_ms, Body};+use crate::storage::schema_support::{+ key_of, map_legacy_collection, time_ms, Body, LegacySourceRecord as SourceRecord,+ LegacyTargetRecord as TargetRecord,+};/// The v2 collection: one document per `channel_id`.pub(super) const DEVICES: &str = "devices.paired";/// The v1 name, still written by the legacy `devices.db` importer.pub(super) const LEGACY_DEVICES: &str = "paired_devices";/// The body version of [`DEVICES`].-const SCHEMA: u32 = 2;-/// What the device store keeps: `devices.paired` and the step from the v1 rows.-#[must_use]-pub fn storage_schema() -> Schema {- Schema::new(owner("devices"))- .collection_with(SCHEMA, spec(), ScopeClass::Tenant)- .step(Step::new("paired_v2", DEVICES, 1, SCHEMA, paired_v2).source(LEGACY_DEVICES))+/// Converts legacy paired-device rows into the current owner shape.+pub(crate) fn upgrade_records(+ records: Vec<crate::storage::import::Record>,+) -> Result<Vec<crate::storage::import::Record>> {+ map_legacy_collection(records, LEGACY_DEVICES, paired_v2)}/// The v2 collection with its index.