Skip to content

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

refactor(storage): add collection_specs helper functions

Steven Enamakelb525b1bda47d
diff --git a/crates/openhuman-core/src/agent/orchestration/subagent_sessions/storage_schema.rs b/crates/openhuman-core/src/agent/orchestration/subagent_sessions/storage_schema.rs
index 9f386758b7..2e82e04e49 100644
--- a/crates/openhuman-core/src/agent/orchestration/subagent_sessions/storage_schema.rs
+++ b/crates/openhuman-core/src/agent/orchestration/subagent_sessions/storage_schema.rs
@@ -33,6 +33,11 @@ pub(super) fn spec() -> CollectionSpec {
CollectionSpec::new(SESSIONS)
}
+/// Collections owned by the sub-agent session host.
+pub(crate) fn collection_specs() -> Vec<CollectionSpec> {
+ vec![spec()]
+}
+
pub(super) fn legacy_collections() -> Vec<CollectionSpec> {
vec![CollectionSpec::new(LEGACY_SESSIONS)]
}
diff --git a/crates/openhuman-core/src/artifacts/storage_schema.rs b/crates/openhuman-core/src/artifacts/storage_schema.rs
index d4d189bb43..1292248d03 100644
--- a/crates/openhuman-core/src/artifacts/storage_schema.rs
+++ b/crates/openhuman-core/src/artifacts/storage_schema.rs
@@ -51,6 +51,15 @@ pub(super) fn records_spec() -> CollectionSpec {
CollectionSpec::new(RECORDS).index(IndexSpec::new("by_thread", ["thread_id", "created_ms"]))
}
+/// Collections owned by the artifact store.
+pub(crate) fn collection_specs() -> Vec<CollectionSpec> {
+ vec![
+ records_spec(),
+ CollectionSpec::new(ARGS),
+ CollectionSpec::new(VERSIONS),
+ ]
+}
+
/// A card as its stored body: its fields with `created_at` replaced by
/// `created_ms`.
///
diff --git a/crates/openhuman-core/src/desktop/notifications/storage_schema.rs b/crates/openhuman-core/src/desktop/notifications/storage_schema.rs
index d6a68178f6..06797ebb3a 100644
--- a/crates/openhuman-core/src/desktop/notifications/storage_schema.rs
+++ b/crates/openhuman-core/src/desktop/notifications/storage_schema.rs
@@ -66,6 +66,11 @@ pub(super) fn specs() -> Vec<CollectionSpec> {
]
}
+/// Collections owned by the notification store.
+pub(crate) fn collection_specs() -> Vec<CollectionSpec> {
+ specs()
+}
+
/// The v1 collections as the legacy importer declares them.
pub(super) fn legacy_collections() -> Vec<CollectionSpec> {
vec![
diff --git a/crates/openhuman-core/src/integrations/task_sources/storage_schema.rs b/crates/openhuman-core/src/integrations/task_sources/storage_schema.rs
index c752169160..33ce30bd51 100644
--- a/crates/openhuman-core/src/integrations/task_sources/storage_schema.rs
+++ b/crates/openhuman-core/src/integrations/task_sources/storage_schema.rs
@@ -42,6 +42,11 @@ pub(super) fn specs() -> [CollectionSpec; 2] {
]
}
+/// Collections owned by the task-source store.
+pub(crate) fn collection_specs() -> Vec<CollectionSpec> {
+ specs().into()
+}
+
/// The v1 collections as the legacy importer declares them.
pub(super) fn legacy_collections() -> Vec<CollectionSpec> {
vec![
diff --git a/crates/openhuman-core/src/profiles/storage_schema.rs b/crates/openhuman-core/src/profiles/storage_schema.rs
index 8682875f3b..150b0c06af 100644
--- a/crates/openhuman-core/src/profiles/storage_schema.rs
+++ b/crates/openhuman-core/src/profiles/storage_schema.rs
@@ -27,6 +27,11 @@ pub const REGISTRY_COLLECTION: &str = "profiles.registry";
pub(super) const LEGACY_REGISTRY_COLLECTION: &str = "profiles";
const SCHEMA: u32 = 2;
+/// Collections owned by the profile registry.
+pub(crate) fn collection_specs() -> Vec<CollectionSpec> {
+ vec![CollectionSpec::new(REGISTRY_COLLECTION)]
+}
+
/// What the profile registry keeps and the step from the v1 collection.
#[must_use]
pub fn storage_schema() -> Schema {
diff --git a/crates/openhuman-core/src/security/approval/storage_schema.rs b/crates/openhuman-core/src/security/approval/storage_schema.rs
index 726bf03932..4751e39c08 100644
--- a/crates/openhuman-core/src/security/approval/storage_schema.rs
+++ b/crates/openhuman-core/src/security/approval/storage_schema.rs
@@ -54,6 +54,11 @@ pub(super) fn specs() -> [CollectionSpec; 2] {
]
}
+/// Collections owned by the approval store.
+pub(crate) fn collection_specs() -> Vec<CollectionSpec> {
+ specs().into()
+}
+
/// The v1 collections as the legacy importer declares them.
pub(super) fn legacy_collections() -> Vec<CollectionSpec> {
vec![
diff --git a/crates/openhuman-core/src/security/devices/storage_schema.rs b/crates/openhuman-core/src/security/devices/storage_schema.rs
index 1f802b4e1b..7015e4750d 100644
--- a/crates/openhuman-core/src/security/devices/storage_schema.rs
+++ b/crates/openhuman-core/src/security/devices/storage_schema.rs
@@ -31,6 +31,11 @@ pub(super) fn spec() -> CollectionSpec {
CollectionSpec::new(DEVICES).index(IndexSpec::new("by_active", ["revoked", "created_ms"]))
}
+/// Collections owned by the paired-device store.
+pub(crate) fn collection_specs() -> Vec<CollectionSpec> {
+ vec![spec()]
+}
+
/// The v1 collection as the importer declares it.
pub(super) fn legacy_collections() -> Vec<CollectionSpec> {
vec![CollectionSpec::new(LEGACY_DEVICES)
diff --git a/crates/openhuman-core/src/threads/store/storage_schema.rs b/crates/openhuman-core/src/threads/store/storage_schema.rs
index 503a776bcb..188e54ebef 100644
--- a/crates/openhuman-core/src/threads/store/storage_schema.rs
+++ b/crates/openhuman-core/src/threads/store/storage_schema.rs
@@ -40,6 +40,11 @@ pub(super) fn spec() -> CollectionSpec {
CollectionSpec::new(TRANSCRIPT_KEYS)
}
+/// Collections owned by the thread host alongside TinyAgents' transcript store.
+pub(crate) fn collection_specs() -> Vec<CollectionSpec> {
+ vec![spec()]
+}
+
fn transcript_keys_v2(batch: Vec<SourceRecord>) -> Result<Vec<TargetRecord>> {
batch
.into_iter()