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
Merge remote-tracking branch 'upstream/main' into epic-8131-440-host-storage
Steven Enamakelec6352b5fb16
diff --cc crates/openhuman-core/src/inbound/results.rsindex 0000000000,c9e0cc3d02..ecbb0e2093mode 000000,100644..100644--- a/crates/openhuman-core/src/inbound/results.rs+++ b/crates/openhuman-core/src/inbound/results.rs@@@ -1,0 -1,403 +1,396 @@@+ //! What a pinned source's turns produced, on the `tinystoragedrivers`+ //! document port.+ //!+ //! A turn of a pinned source ([`super::pinned`]) is recorded `running` before+ //! its agent runs and `completed` (with the agent's final text) or `failed`+ //! (with the error) when it ends. The pusher reads them over+ //! `inbound.results` and acknowledges each with `inbound.result_ack`; an+ //! acknowledged result is no longer listed, and every result is pruned once+ //! it is older than its source's `result_ttl_days`.+ //!+ //! | Collection | Document id | Holds |+ //! | --- | --- | --- |+ //! | `inbound.results` | `Key::of([turn_id])` | one turn: its source, key, agent, events, status, text or error, and the message it ran with |+ //!+ //! Domain events only wake a subscriber; the text is read here, never carried+ //! on the bus.++ use serde::{Deserialize, Serialize};+ use serde_json::Value;-use tinystoragedrivers::schema::{Schema, ScopeClass};+ use tinystoragedrivers::{CollectionSpec, ErrorKind, Filter, IndexSpec, Precondition, Query, Sort};++ use crate::config::Config;+ use crate::storage::documents::{compare_and_swap, Repo};-use crate::storage::schema_support::{key_of, owner};++use crate::storage::schema_support::key_of;+ use crate::storage::DocumentStoreExt;++ /// The results collection.+ pub const RESULTS: &str = "inbound.results";+ const DOMAIN: &str = "inbound::results";-const SCHEMA: u32 = 1;++ /// What the inbound host keeps: the results of pinned sources' turns.-#[must_use]-pub fn storage_schema() -> Schema {- Schema::new(owner("inbound")).collection_with(SCHEMA, spec(), ScopeClass::Tenant)++pub fn collection_specs() -> Vec<CollectionSpec> {++ vec![spec()]+ }++ fn spec() -> CollectionSpec {+ CollectionSpec::new(RESULTS)+ .index(IndexSpec::new("by_status", ["status", "created_ms"]))+ .index(IndexSpec::new("by_source", ["source", "created_ms"]))+ }+-fn specs() -> Vec<CollectionSpec> {- vec![spec()]-}-+ /// Where a turn stands.+ #[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]+ #[serde(rename_all = "snake_case")]+ pub enum ResultStatus {+ /// The agent is running (or a previous process stopped while it was).+ Running,+ /// The agent answered; `text` holds its final reply.+ Completed,+ /// The agent failed for good; `error` says why.+ Failed,+ }++ impl ResultStatus {+ fn as_str(self) -> &'static str {+ match self {+ Self::Running => "running",+ Self::Completed => "completed",+ Self::Failed => "failed",+ }+ }+ }++ /// One turn's result, as `inbound.results` returns it.+ #[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]+ pub struct InboundResult {+ /// The queues' turn id.+ pub turn_id: String,+ /// The configured source.+ pub source: String,+ /// The key its events were batched by.+ pub key: String,+ /// The pinned agent that ran.+ pub agent_id: String,+ /// Where the turn stands.+ pub status: ResultStatus,+ /// The agent's final text, once completed.+ #[serde(default, skip_serializing_if = "Option::is_none")]+ pub text: Option<String>,+ /// Why it failed.+ #[serde(default, skip_serializing_if = "Option::is_none")]+ pub error: Option<String>,+ /// The source's ids of the events the turn carried, in order.+ pub event_ids: Vec<String>,+ /// The events the prompt-injection guard kept out of the agent's prompt.+ #[serde(default)]+ pub blocked: Vec<BlockedEvent>,+ /// When the turn was first started, Unix epoch milliseconds.+ pub created_ms: u64,+ /// When it completed or failed.+ #[serde(default, skip_serializing_if = "Option::is_none")]+ pub completed_ms: Option<u64>,+ }++ /// An event the prompt-injection guard kept out of a turn's prompt.+ #[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]+ pub struct BlockedEvent {+ /// The source's id of the event.+ pub event_id: String,+ /// The guard's verdict and rule codes (`blocked: instruction_override`);+ /// never the event's text.+ pub reason: String,+ }++ /// A result as stored: the wire form, the message the agent was given (so a+ /// run a previous process left unfinished can be run again) and whether the+ /// pusher acknowledged it.+ #[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]+ pub struct Stored {+ /// The wire form.+ #[serde(flatten)]+ pub result: InboundResult,+ /// The message the agent runs with.+ pub message: String,+ /// The pusher acknowledged the result.+ #[serde(default)]+ pub acked: bool,+ }++ impl Stored {+ /// A turn about to run.+ #[must_use]+ pub fn running(+ turn_id: &str,+ source: &str,+ key: &str,+ agent_id: &str,+ event_ids: Vec<String>,+ message: &str,+ created_ms: u64,+ ) -> Self {+ Self {+ result: InboundResult {+ turn_id: turn_id.to_owned(),+ source: source.to_owned(),+ key: key.to_owned(),+ agent_id: agent_id.to_owned(),+ status: ResultStatus::Running,+ text: None,+ error: None,+ event_ids,+ blocked: Vec::new(),+ created_ms,+ completed_ms: None,+ },+ message: message.to_owned(),+ acked: false,+ }+ }+ }++ impl Stored {+ /// With `blocked` recorded as kept out of the prompt.+ #[must_use]+ pub fn with_blocked(mut self, blocked: Vec<BlockedEvent>) -> Self {+ self.result.blocked = blocked;+ self+ }+ }++ /// Which results `inbound.results` lists.+ #[derive(Debug, Clone, PartialEq, Eq)]+ pub struct ResultQuery {+ /// Only this source's.+ pub source: Option<String>,+ /// Only those started at or after this time.+ pub since_ms: Option<u64>,+ /// Only those with this status.+ pub status: Option<ResultStatus>,+ /// At most this many.+ pub limit: usize,+ }++ impl Default for ResultQuery {+ fn default() -> Self {+ Self {+ source: None,+ since_ms: None,+ status: None,+ limit: 50,+ }+ }+ }++ fn decode(doc: &Value) -> Option<Stored> {+ serde_json::from_value(doc.clone())+ .map_err(|error| {+ tracing::warn!(%error, "[inbound::results] skipping an unreadable result");+ })+ .ok()+ }++ fn encode(stored: &Stored) -> anyhow::Result<Value> {+ Ok(serde_json::to_value(stored)?)+ }++ /// The results store over one scoped document handle.+ #[derive(Clone)]+ pub struct Results(Repo);++ impl Results {+ /// The store for `config`'s workspace, in the acting scope.+ ///+ /// # Errors+ ///+ /// The storage backend or scope cannot be opened.+ pub fn open(config: &Config) -> anyhow::Result<Self> {+ Ok(Self(Repo::current_for(+ &config.workspace_dir,+ DOMAIN,- specs,++ collection_specs,+ )?))+ }++ #[cfg(test)]+ pub(crate) fn over(scoped: &crate::storage::ScopedStorage) -> Self {+ Self(Repo::over(scoped, DOMAIN, specs))+ }++ /// Record `stored` unless its turn is already recorded; either way, the+ /// record as it stands.+ ///+ /// # Errors+ ///+ /// The backend failed.+ pub fn start(&self, stored: &Stored) -> anyhow::Result<Stored> {+ let id = key_of(&stored.result.turn_id)?;+ let doc = encode(stored)?;+ let fresh = stored.clone();+ self.0.run(|docs| async move {+ match docs.put(RESULTS, &id, doc, Precondition::Absent).await {+ Ok(_) => Ok(fresh),+ Err(error) if error.kind() == ErrorKind::Conflict => Ok(docs+ .get(RESULTS, &id)+ .await?+ .and_then(|found| decode(&found.doc))+ .unwrap_or(fresh)),+ Err(error) => Err(error),+ }+ })+ }++ /// The record of `turn_id`.+ ///+ /// # Errors+ ///+ /// The backend failed.+ pub fn get(&self, turn_id: &str) -> anyhow::Result<Option<Stored>> {+ let id = key_of(turn_id)?;+ self.0.run(|docs| async move {+ Ok(docs+ .get(RESULTS, &id)+ .await?+ .and_then(|found| decode(&found.doc)))+ })+ }++ /// End `turn_id` with the agent's text or its error, at `now_ms`; `None`+ /// when it was never started.+ ///+ /// # Errors+ ///+ /// The backend failed.+ pub fn finish(+ &self,+ turn_id: &str,+ outcome: Result<String, String>,+ now_ms: u64,+ ) -> anyhow::Result<Option<Stored>> {+ let id = key_of(turn_id)?;+ self.0.run(|docs| async move {+ let written = compare_and_swap(&docs, RESULTS, &id, |doc| {+ let mut stored = decode(doc)?;+ match &outcome {+ Ok(text) => {+ stored.result.status = ResultStatus::Completed;+ stored.result.text = Some(text.clone());+ stored.result.error = None;+ }+ Err(error) => {+ stored.result.status = ResultStatus::Failed;+ stored.result.error = Some(error.clone());+ }+ }+ stored.result.completed_ms = Some(now_ms);+ serde_json::to_value(stored).ok()+ })+ .await?;+ Ok(written.and_then(|found| decode(&found.doc)))+ })+ }++ /// Unacknowledged results matching `query`, oldest first.+ ///+ /// # Errors+ ///+ /// The backend failed.+ pub fn list(&self, query: &ResultQuery) -> anyhow::Result<Vec<InboundResult>> {+ if query.limit == 0 {+ return Ok(Vec::new());+ }+ let filter = [+ Some(Filter::eq("acked", false)),+ query.source.as_deref().map(|s| Filter::eq("source", s)),+ query.since_ms.map(|ms| Filter::gte("created_ms", ms)),+ query.status.map(|s| Filter::eq("status", s.as_str())),+ ]+ .into_iter()+ .flatten()+ .reduce(Filter::and)+ .unwrap_or(Filter::All);+ let query = Query::filter(filter)+ .sort(Sort::asc("created_ms"))+ .limit(query.limit);+ self.0.run(|docs| async move {+ Ok(docs+ .query(RESULTS, &query)+ .await?+ .items+ .iter()+ .filter_map(|found| decode(&found.doc))+ .map(|stored| stored.result)+ .collect())+ })+ }++ /// Every turn still recorded `running`, oldest first.+ ///+ /// # Errors+ ///+ /// The backend failed.+ pub fn running(&self) -> anyhow::Result<Vec<Stored>> {+ let query = Query::filter(Filter::eq("status", ResultStatus::Running.as_str()))+ .sort(Sort::asc("created_ms"));+ self.0.run(|docs| async move {+ Ok(docs+ .query_all(RESULTS, &query)+ .await?+ .iter()+ .filter_map(|found| decode(&found.doc))+ .collect())+ })+ }++ /// Acknowledge `turn_id`'s result; `false` when there is none.+ ///+ /// # Errors+ ///+ /// The backend failed.+ pub fn ack(&self, turn_id: &str) -> anyhow::Result<bool> {+ let id = key_of(turn_id)?;+ self.0.run(|docs| async move {+ let written = compare_and_swap(&docs, RESULTS, &id, |doc| {+ let mut next = doc.clone();+ next["acked"] = Value::Bool(true);+ Some(next)+ })+ .await?;+ Ok(written.is_some())+ })+ }++ /// Delete every result older at `now_ms` than its source's TTL+ /// (`ttl_ms(source)`). Returns how many.+ ///+ /// # Errors+ ///+ /// The backend failed.+ pub fn prune(+ &self,+ now_ms: u64,+ ttl_ms: impl Fn(&str) -> u64 + Send + 'static,+ ) -> anyhow::Result<usize> {+ self.0.run(|docs| async move {+ let mut pruned = 0;+ for found in docs.query_all(RESULTS, &Query::all()).await? {+ let Some(stored) = decode(&found.doc) else {+ continue;+ };+ let age = now_ms.saturating_sub(stored.result.created_ms);+ if age > ttl_ms(&stored.result.source) {+ match docs.delete(RESULTS, &found.id, found.unchanged()).await {+ Ok(_) => pruned += 1,+ Err(error) if error.kind() == ErrorKind::Conflict => {}+ Err(error) => return Err(error),+ }+ }+ }+ Ok(pruned)+ })+ }+ }++ #[cfg(test)]+ #[path = "results_tests.rs"]+ mod tests;diff --cc crates/openhuman-core/src/inbound/settings.rsindex a00ab649ae,52bb4ee28f..e6261b5017--- a/crates/openhuman-core/src/inbound/settings.rs+++ b/crates/openhuman-core/src/inbound/settings.rs@@@ -13,11 -13,12 +13,12 @@@ use std::sync::{Arc, RwLock}use serde_json::{json, Value};use tinyeventqueues_bus::storage::{SHIPPED_PIPELINE_JSON, SHIPPED_QUEUES_JSON};use tinyeventqueues_bus::{Lane, PipelineConfig};-use tinystoragedrivers::queue::QueueManifest;use tinystoragedrivers::QueueConfig;+ use crate::config::schema::InboundConfig;use crate::config::Config;use crate::modules::storage_grant_schemas::QueueGrant;+use crate::modules::storage_queue_manifest::QueueManifest;/// The `[components]` switch that owns the inbound event queues.pub const COMPONENT: &str = "eventqueues";diff --cc crates/openhuman-core/src/memory/tools_queue_failure_tests.rsindex 78f8e38bc7,78f8e38bc7..8e91a3ba9d--- a/crates/openhuman-core/src/memory/tools_queue_failure_tests.rs+++ b/crates/openhuman-core/src/memory/tools_queue_failure_tests.rs@@@ -1,5 -1,5 +1,5 @@@use super::MemoryTool;--use crate::memory::test_fixtures::{bind_reference, config_in};++use crate::memory::test_fixtures::{bind_reference, config_in, RefusingEngine};use tinytools::Tool;#[tokio::test]@@@ -25,3 -25,3 +25,19 @@@ async fn write_queue_filesystem_failure);assert!(result.text().contains("UNAVAILABLE"), "{}", result.text());}++++#[tokio::test]++async fn learning_is_durably_queued_even_when_the_backend_refuses_writes() {++ let tmp = tempfile::tempdir().unwrap();++ let config = config_in(&tmp);++ RefusingEngine::out_of_credits().bind(&config);++ let tool = MemoryTool::new(std::sync::Arc::new(config.clone()));++ let result = tool++ .execute(serde_json::json!({"action":"learn","text":"Prefers tea"}))++ .await++ .unwrap();++ assert!(!result.is_error, "{}", result.text());++ let value: serde_json::Value = serde_json::from_str(&result.text()).unwrap();++ assert_eq!(value["status"], "queued; not yet saved to memory");++ assert_eq!(super::tool_writes::drain(&config).await, 0);++}diff --cc crates/openhuman-core/src/memory/tools_tests.rsindex 4006bfce81,b7e5d3db39..0e52532f01--- a/crates/openhuman-core/src/memory/tools_tests.rs+++ b/crates/openhuman-core/src/memory/tools_tests.rs@@@ -714,19 -735,19 +735,3 @@@ async fn refers_to_reaches_the_engine_i]);}----#[tokio::test]--async fn learning_is_durably_queued_even_when_the_backend_refuses_writes() {-- let tmp = tempfile::tempdir().unwrap();-- let config = config_in(&tmp);-- crate::memory::test_fixtures::RefusingEngine::out_of_credits().bind(&config);-- let tool = MemoryTool::new(Arc::new(config.clone()));-- let result = tool-- .execute(json!({"action":"learn","text":"Prefers tea"}))-- .await-- .unwrap();-- assert!(!result.is_error, "{}", result.text());-- let value: Value = serde_json::from_str(&result.text()).unwrap();-- assert_eq!(value["status"], "queued; not yet saved to memory");-- assert_eq!(super::super::tool_writes::drain(&config).await, 0);--}diff --cc crates/openhuman-core/src/storage/schema.rsindex 9f4b332820,50d4b0ea71..647da79f78--- a/crates/openhuman-core/src/storage/schema.rs+++ b/crates/openhuman-core/src/storage/schema.rs@@@ -1,111 -1,116 +1,114 @@@-//! The composed storage schema: every owner's `storage_schema()` in one-//! [`Registry`].+//! The host's composed v2 owner collection declarations.//!-//! Each crate that stores records declares what it stores (collections,-//! streams, blob prefixes, and the v1 -> v2 steps that bring older data-//! forward). The host composes them once, `prepare`s the backend from the-//! result, migrates every scope ([`super::boot`]) and generates each module's-//! storage grant from the module-scoped items-//! ([`crate::modules::storage_grants`]). Composition refuses a name outside its-//! owner's prefix, a name claimed twice, a version that goes down and a step-//! gap, so a collision between two owners fails here, at boot and in-//! `scripts/ci/check-storage-schema.mjs`, never at a first write.-//!-//! Module owners come from their `*-bus` contract crates (optional `storage` feature),-//! never from the implementation libraries. Owners whose crate is gated off in a build are absent from its registry, as-//! their data is.+//! Owner crates expose pure `CollectionSpec` values. The host prepares those+//! declarations on each known scope before installing module grants; the+//! owner remains responsible for its own record shapes and migrations.++use std::collections::BTreeMap;-use std::sync::OnceLock;+use tinystoragedrivers::CollectionSpec;-use tinystoragedrivers::schema::{Item, Registry, Schema, ScopeClass};+use super::StorageError;++/// Every collection this build links, with duplicate declarations merged and+/// validated before any backend is touched.+pub fn owner_collections() -> Result<Vec<CollectionSpec>, StorageError> {+ let mut collections = BTreeMap::<String, CollectionSpec>::new();+ for spec in declared_collections() {+ if let Some(existing) = collections.get(&spec.name) {+ let merged = existing.merge(&spec)?;+ collections.insert(spec.name.clone(), merged);+ } else {+ spec.validate()?;+ collections.insert(spec.name.clone(), spec);+ }+ }+ Ok(collections.into_values().collect())+}++fn declared_collections() -> Vec<CollectionSpec> {+ let mut collections = Vec::new();+ collections.extend(tinyagents_harness::storage::collections());+ collections.extend(tinyagents_session::port::collections());+ collections.extend(tinyagents_graph::storage::collections());+ collections.extend(tinyagents_tasks::collections());+ collections.extend(crate::security::approval::collection_specs());+ collections.extend(crate::security::devices::collection_specs());+ collections.extend(crate::desktop::notifications::collection_specs());+ collections.extend(crate::integrations::task_sources::collection_specs());+ collections.extend(crate::artifacts::collection_specs());+ collections.extend(crate::platform::cost::collection_specs());+ collections.extend(crate::config::schema::config_storage_collections());+ collections.extend(crate::profiles::collection_specs());+ collections.extend(crate::threads::store::collection_specs());+ collections.extend(crate::agent::orchestration::subagent_sessions::collection_specs());+ collections.extend(super::agents::collection_specs());+ collections.extend(super::journal_maintenance::collection_specs());-/// Every owner's schema that this build links.-pub fn owner_schemas() -> Vec<Schema> {- let mut schemas = vec![- tinyagents_harness::storage_schema(),- tinyagents_session::storage_schema(),- tinyagents_session::ledger_storage_schema(),- tinyagents_session::history_storage_schema(),- tinyagents_session::conversations_storage_schema(),- tinyagents_graph::storage_schema(),- tinyagents_tasks::storage_schema(),- crate::security::approval::storage_schema(),- crate::security::devices::storage_schema(),- crate::desktop::notifications::storage_schema(),- crate::integrations::task_sources::storage_schema(),- crate::artifacts::storage_schema(),- crate::platform::cost::storage_schema(),- crate::config::schema::config_storage_schema(),- crate::profiles::storage_schema(),- crate::threads::store::storage_schema(),- crate::agent::orchestration::subagent_sessions::storage_schema(),- super::agents::storage_schema(),- ];#[cfg(feature = "skills")]- schemas.push(tinyskills_drivers::storage_schema());+ collections.extend(tinyskills_drivers::collections());#[cfg(feature = "modules")]{- schemas.push(tinymcp_bus::storage::storage_schema());- schemas.push(tinychannels_bus::storage::storage_schema());- schemas.push(tinyconnectors_bus::storage::storage_schema());- schemas.push(tinybox_bus::storage::storage_schema());- schemas.push(tinyjuice_bus::storage::storage_schema());+ collections.extend(tinymcp_bus::storage::collection_specs());+ collections.extend(tinychannels_bus::storage::collections());+ collections.extend(tinyconnectors_bus::storage::collections());+ collections.extend([+ CollectionSpec::new("box.boxes"),+ CollectionSpec::new("box.jail_index"),+ ]);+ collections.extend(tinyjuice_bus::storage::collections());}#[cfg(feature = "web3")]- schemas.push(tinywallet_bus::storage::storage_schema());+ collections.extend(tinywallet_bus::storage::collections());#[cfg(feature = "tinymemes")]- schemas.push(tinymemes_bus::storage::storage_schema());+ collections.extend(tinymemes_bus::storage::collections());#[cfg(feature = "inbound-queues")]- collections.extend(tinyeventqueues_bus::storage::collection_specs());+ {- schemas.push(tinyeventqueues_bus::storage::storage_schema());- schemas.push(crate::inbound::results::storage_schema());++ collections.extend(tinyeventqueues_bus::storage::collection_specs());++ collections.extend(crate::inbound::results::collection_specs());+ }- schemas-}-/// The registry composed from [`owner_schemas`].-///-/// # Errors-///-/// The composition error naming the owner and item at fault. A build that-/// links two owners claiming one name never gets this far in CI.-pub fn registry() -> Result<&'static Registry, super::StorageError> {- static REGISTRY: OnceLock<Result<Registry, String>> = OnceLock::new();- REGISTRY- .get_or_init(|| Registry::compose(owner_schemas()).map_err(|error| error.to_string()))- .as_ref()- .map_err(|message| super::StorageError::invalid_input(message.clone()))+ collections}-/// The module-scoped declarations of owner `owner`, for the module's grant:-/// `(collections, stream names, blob prefixes, secret prefixes)`.-pub fn module_items(owner: &str) -> ModuleItems {- let mut items = ModuleItems::default();- for schema in owner_schemas()- .into_iter()- .filter(|schema| schema.owner.as_str() == owner)- {- for item in schema.items {- if item.scope() != ScopeClass::Module {- continue;- }- match item {- Item::Collection { spec, .. } => items.collections.push(spec),- Item::Stream { name, .. } => items.streams.push(name),- Item::Blobs { prefix, .. } => items.blobs.push(prefix),- Item::Secrets { prefix, .. } => items.secrets.push(prefix),- }+/// Collections declared by one loadable module owner.+pub fn module_collections(owner: &str) -> Vec<CollectionSpec> {+ #[cfg(feature = "modules")]+ match owner {+ "mcp" => return module_owned_collections(tinymcp_bus::storage::collection_specs()),+ "channels" => return module_owned_collections(tinychannels_bus::storage::collections()),+ "connectors" => {+ return module_owned_collections(tinyconnectors_bus::storage::collections());+ }+ "box" => {+ return module_owned_collections(vec![+ CollectionSpec::new("box.boxes"),+ CollectionSpec::new("box.jail_index"),+ ]);}+ "juice" => return module_owned_collections(tinyjuice_bus::storage::collections()),+ _ => {}+ }+ #[cfg(feature = "web3")]+ if owner == "wallet" {+ return module_owned_collections(tinywallet_bus::storage::collections());+ }+ #[cfg(feature = "tinymemes")]+ if owner == "memes" {+ return module_owned_collections(tinymemes_bus::storage::collections());+ }+ #[cfg(feature = "inbound-queues")]+ if owner == "teq" {+ return module_owned_collections(tinyeventqueues_bus::storage::collection_specs());}- items+ let _ = owner;+ Vec::new()}-/// What one owner declares at module scope.-#[derive(Debug, Default, Clone)]-pub struct ModuleItems {- /// Collections, with their indexes.- pub collections: Vec<tinystoragedrivers::CollectionSpec>,- /// Stream family names.- pub streams: Vec<String>,- /// Blob key prefixes.- pub blobs: Vec<String>,- /// Secret key prefixes.- pub secrets: Vec<String>,+/// A module may receive its own collections, never TSD's host-managed records.+fn module_owned_collections(mut collections: Vec<CollectionSpec>) -> Vec<CollectionSpec> {+ collections.retain(|collection| !collection.name.starts_with("tsd."));+ collections}#[cfg(test)]diff --cc docs/storage-schema.mdindex 06cb4a4f98,b3d8ad3250..f52503e622--- a/docs/storage-schema.md+++ b/docs/storage-schema.md@@@ -106,18 -197,36 +106,24 @@@ Record shapes and migrations stay with## history-| Kind | Name | Version | Scope | Indexed fields |-| --- | --- | --- | --- | --- |-| collection | `history.messages` | 2 | agent | `session_id`, `id` |-| collection | `history.search` | 2 | agent | `session_id` |-| collection | `history.sessions` | 2 | agent | `status`, `started_ms`, `parent_session_id`, `started_ms`, `agent_definition_id`, `thread_id`, `source_channel`, `started_ms` |-| collection | `history.tool_calls` | 2 | agent | `session_id`, `id`, `tool_name`, `created_ms` |--Migration steps:--- `sessions_v2`: `history.sessions` v1 to v2 from `session_history_sessions`-- `messages_v2`: `history.messages` v1 to v2 from `session_history_messages`-- `tool_calls_v2`: `history.tool_calls` v1 to v2 from `session_history_tool_calls`-- `search_v2`: `history.search` v1 to v2 from `session_history_fts`+| Collection | Indexes | Expiry field | Search fields |+| --- | --- | --- | --- |+| `history.messages` | `session_id` (`session_id`, `id`) | | |+| `history.search` | `session` (`session_id`) | | `agent_name`, `content`, `tool_name` |+| `history.sessions` | `agent` (`agent_definition_id`)<br>`channel` (`source_channel`)<br>`parent` (`parent_session_id`, `started_ms`)<br>`started` (`started_ms`)<br>`status_started` (`status`, `started_ms`)<br>`thread` (`thread_id`) | | |+| `history.tool_calls` | `created` (`created_ms`)<br>`session_id` (`session_id`, `id`)<br>`tool` (`tool_name`) | | |+ ## inbound++ | Kind | Name | Version | Scope | Indexed fields |+ | --- | --- | --- | --- | --- |+ | collection | `inbound.results` | 1 | tenant | `status`, `created_ms`, `source`, `created_ms` |+## juice-| Kind | Name | Version | Scope | Indexed fields |-| --- | --- | --- | --- | --- |-| collection | `juice.savings` | 1 | module | |-| blobs | `juice/ccr/` | | module | |--Migration steps:--- `ccr_prefix_v2`: `juice/ccr/` v1 to v2 from `tinyjuice_ccr/`+| Collection | Indexes | Expiry field | Search fields |+| --- | --- | --- | --- |+| `juice.savings` | | | |## ledgerdiff --cc scripts/ci/check-openhuman-rust-layout.mjsindex c654a81f7e,cd605a0a24..577bbcdb13--- a/scripts/ci/check-openhuman-rust-layout.mjs+++ b/scripts/ci/check-openhuman-rust-layout.mjs@@@ -37,9 -37,9 +37,9 @@@ const LEGACY_LIMIT_ENTRIES =// their current sizes while follow-up work separates their test concerns.// `core/` was pruned from the line limit by name until these pins; its// oversized files are pinned at the size they had when enforcement began.- ["crates/openhuman-core/src/core/all.rs", 1114],+ ["crates/openhuman-core/src/core/all.rs", 1113],["crates/openhuman-core/src/core/all_tests.rs", 1465],- ["crates/openhuman-core/src/core/events.rs", 1697],+ ["crates/openhuman-core/src/core/events.rs", 1649],["crates/openhuman-core/src/core/events_tests.rs", 988],["crates/openhuman-core/src/core/observability.rs", 3361],];diff --cc vendor/tinydocsindex 7618cfbfbd,7618cfbfbd..260c6d6efb--- a/vendor/tinydocs+++ b/vendor/tinydocs@@@ -1,1 -1,1 +1,1 @@@--Subproject commit 7618cfbfbdb26772035e16ff40e9c4b149c487af++Subproject commit 260c6d6efbc15deee3c63370eb7081c43e7a3adddiff --cc vendor/tinyeventqueuesindex c3b21fc9f3,2417abf3c0..3d0bf5340b--- a/vendor/tinyeventqueues+++ b/vendor/tinyeventqueues@@@ -1,1 -1,1 +1,1 @@@- Subproject commit c3b21fc9f331ee970b53b3334b57d354ce414015-Subproject commit 2417abf3c0da2aa37f00e675565edb51f8124d48++Subproject commit 3d0bf5340beb88fe7f683b7e8869d8dce305bedbdiff --cc vendor/tinyjuiceindex b9225e8ef7,7c43eedd7d..1ff17f09dd--- a/vendor/tinyjuice+++ b/vendor/tinyjuice@@@ -1,1 -1,1 +1,1 @@@- Subproject commit b9225e8ef7701a68dea0c7289847ba92487fd532-Subproject commit 7c43eedd7d7917fa41ea1bd488649fe233d00531++Subproject commit 1ff17f09dd07e5f1ab885e0859c4e850d3590ecfdiff --cc vendor/tinystoragedriversindex 2856dfa6f5,7b3bfbc0e3..05eaada962--- a/vendor/tinystoragedrivers+++ b/vendor/tinystoragedrivers@@@ -1,1 -1,1 +1,1 @@@- Subproject commit 2856dfa6f5b4de981a4db2801ae6be80c6432b3b-Subproject commit 7b3bfbc0e33b3f8f8fce9b6f521c3ec700f2652b++Subproject commit 05eaada962decbab33bafa4763d2bd1a67f6b456