Skip to content

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

Merge upstream/main into epic-8088-final-rollup

Steven Enamakel173b03e91540
diff --cc Cargo.lock
index 53826a5c8b,1fb77a0182..131eb5fef1
--- a/Cargo.lock
+++ b/Cargo.lock
@@@ -10149,7 -10162,7 +10151,7 @@@ dependencies =
[[package]]
name = "tinyjuice-module"
- version = "0.11.2"
-version = "0.11.3"
++version = "0.11.4"
dependencies = [
"log",
"serde_json",
@@@ -10632,7 -10669,7 +10634,7 @@@ dependencies =
[[package]]
name = "tinyvoice-module"
--version = "0.4.0"
++version = "0.4.1"
dependencies = [
"anyhow",
"async-trait",
diff --cc crates/openhuman-app/Cargo.lock
index a4311e799e,7d72dde37d..93afb5c5d3
--- a/crates/openhuman-app/Cargo.lock
+++ b/crates/openhuman-app/Cargo.lock
@@@ -8195,10 -8110,10 +8196,10 @@@ dependencies =
[[package]]
name = "tinymcp-bus"
- version = "0.20.1"
+ version = "0.20.2"
dependencies = [
"base64 0.23.1",
- "schemars 1.2.3",
+ "schemars 1.2.2",
"serde",
"serde_json",
"tinystoragedrivers-types",
@@@ -8283,9 -8198,9 +8284,9 @@@ dependencies =
[[package]]
name = "tinysearch-bus"
- version = "0.5.1"
+ version = "0.5.3"
dependencies = [
- "schemars 1.2.3",
+ "schemars 1.2.2",
"serde",
"serde_json",
]
diff --cc crates/openhuman-cli/Cargo.toml
index 6fcac40854,a33c519feb..c7d84b2e1a
--- a/crates/openhuman-cli/Cargo.toml
+++ b/crates/openhuman-cli/Cargo.toml
@@@ -444,14 -445,15 +444,17 @@@ serde = { version = "1", features = ["d
tempfile = "3"
tinyinference-llm = { path = "../../vendor/tinyagents/vendor/tinyinference/crates/tinyinference-llm" }
# The document-port contract for failure injection in cron storage regressions.
- tinystoragedrivers-api = { git = "https://github.com/tinyhumansai/tinystoragedrivers", rev = "05eaada962decbab33bafa4763d2bd1a67f6b456" }
- tinystoragedrivers = { git = "https://github.com/tinyhumansai/tinystoragedrivers", rev = "05eaada962decbab33bafa4763d2bd1a67f6b456", default-features = false, features = ["sqlite"] }
+ tinystoragedrivers-api = { git = "https://github.com/tinyhumansai/tinystoragedrivers", rev = "f05fbd230c2c403c8dcdef57316fa55265379039" }
+ tinystoragedrivers = { git = "https://github.com/tinyhumansai/tinystoragedrivers", rev = "f05fbd230c2c403c8dcdef57316fa55265379039", default-features = false, features = ["sqlite"] }
+ # The in-memory host storage backend the integration suites install.
-tinystoragedrivers-testkit = { git = "https://github.com/tinyhumansai/tinystoragedrivers", rev = "f05fbd230c2c403c8dcdef57316fa55265379039" }
+tinystoragedrivers-testkit = { path = "../../vendor/tinystoragedrivers/crates/tinystoragedrivers-testkit" }
zeroize = "1"
tinytools = { path = "../../vendor/tinyagents/vendor/tinytools/crates/tinytools" }
-tinytools-std = { path = "../../vendor/tinyagents/vendor/tinytools/crates/tinytools-std" }
# The completion log a detached sub-agent leaves, for the SaaS delivery-recovery e2e.
tinyagents-tasks = { path = "../../vendor/tinyagents/crates/tinyagents-tasks" }
++# The storage-kit backend port the completion-queue fixture adapts the host backend to.
++tinyagents-storage-kit = { path = "../../vendor/tinyagents/crates/tinyagents-storage-kit" }
+tinyagents-harness-tools = { path = "../../vendor/tinyagents/crates/tinyagents-harness-tools", default-features = false, features = ["goals"] }
toml = "1.0"
tracing = "0.1"
# The TinyComputer contract, for the live computer-use e2e (`computer_bali_live_e2e`).
@@@ -466,9 -468,11 +469,9 @@@ hex = "0.4
parking_lot = "0.12"
sha2 = "0.10"
tar = "0.4"
-tinyagents-graph = { path = "../../vendor/tinyagents/crates/tinyagents-graph", features = ["sqlite", "storage-drivers"] }
tinyagents-harness = { path = "../../vendor/tinyagents/crates/tinyagents-harness", features = ["sqlite", "multimodal"] }
-tinyagents-harness-tools = { path = "../../vendor/tinyagents/crates/tinyagents-harness-tools", default-features = false, features = ["goals"] }
tinyagents-definition = { path = "../../vendor/tinyagents/crates/tinyagents-definition" }
- tinyagents-session = { path = "../../vendor/tinyagents/crates/tinyagents-session" }
+ tinyagents-session = { path = "../../vendor/tinyagents/crates/tinyagents-session", features = ["testkit"] }
tinydocs-bus = { path = "../../vendor/tinydocs/crates/tinydocs-bus" }
# `inbound_linked_e2e` names the ingest dispositions from the contract.
tinyeventqueues-bus = { path = "../../vendor/tinyeventqueues/crates/tinyeventqueues-bus" }
diff --cc crates/openhuman-core/src/agent/subagent_host/ops_tests_model_resolution_tests.rs
index 013e275b3f,995e734133..c089115d65
--- a/crates/openhuman-core/src/agent/subagent_host/ops_tests_model_resolution_tests.rs
+++ b/crates/openhuman-core/src/agent/subagent_host/ops_tests_model_resolution_tests.rs
@@@ -76,6 -80,80 +76,80 @@@ async fn runner_rejects_spawn_beyond_ma
}
#[tokio::test]
+ async fn a_team_depth_cap_below_the_product_limit_is_enforced() {
+ // Driven through `run_subagent`, so the runner's own gate must honour the
+ // team's cap (not the budget helper alone): a team capped at one level runs
+ // a child and refuses a grandchild before any provider dispatch, and a cap
+ // above the product limit cannot widen it.
+ use crate::agent::tinyagents::budget::MAX_SPAWN_DEPTH;
+ let def = make_def_named_tools(&[]);
+
+ let provider = ScriptedProvider::new(vec![text_response("ok")]);
+ let mut options = with_parent(
+ make_parent(provider.clone(), vec![]),
+ SubagentRunOptions::default(),
+ );
+ options.run_context.max_spawn_depth = Some(1);
- let child = run_subagent(&def, "x", options).await;
++ let child = run_host_from_test_options(&def, "x", options).await;
+ assert!(
+ !matches!(child, Err(SubagentRunError::SpawnDepthExceeded { .. })),
+ "a one-level team must admit its child: {child:?}"
+ );
+ assert!(
+ !provider.captured.lock().is_empty(),
+ "the admitted child reaches the provider: {child:?}"
+ );
+
+ let provider = ScriptedProvider::new(vec![text_response("should not be called")]);
+ let mut options = with_parent(
+ make_parent(provider.clone(), vec![]),
+ SubagentRunOptions::default(),
+ );
+ options.run_context.max_spawn_depth = Some(1);
+ let grandchild = with_run_depth(
+ RunDepth {
+ depth: 1,
+ max_depth: MAX_SPAWN_DEPTH,
+ },
- async { run_subagent(&def, "x", options).await },
++ async { run_host_from_test_options(&def, "x", options).await },
+ )
+ .await;
+ assert!(
+ matches!(
+ grandchild,
+ Err(SubagentRunError::SpawnDepthExceeded {
+ attempted_depth: 2,
+ max_depth: 1
+ })
+ ),
+ "a grandchild of a one-level team is refused: {grandchild:?}"
+ );
+ assert!(
+ provider.captured.lock().is_empty(),
+ "the refused grandchild never reaches the provider"
+ );
+
+ let provider = ScriptedProvider::new(vec![text_response("should not be called")]);
+ let mut options = with_parent(
+ make_parent(provider.clone(), vec![]),
+ SubagentRunOptions::default(),
+ );
+ options.run_context.max_spawn_depth = Some(MAX_SPAWN_DEPTH + 3);
+ let beyond = with_run_depth(
+ RunDepth {
+ depth: MAX_SPAWN_DEPTH,
+ max_depth: MAX_SPAWN_DEPTH,
+ },
- async { run_subagent(&def, "x", options).await },
++ async { run_host_from_test_options(&def, "x", options).await },
+ )
+ .await;
+ let Err(SubagentRunError::SpawnDepthExceeded { max_depth, .. }) = &beyond else {
+ panic!("a cap above the product limit cannot widen it: {beyond:?}");
+ };
+ assert_eq!(*max_depth, MAX_SPAWN_DEPTH);
+ }
+
+ #[tokio::test]
async fn typed_mode_model_override_pins_exact_model_for_spawn() {
let provider = ScriptedProvider::new(vec![text_response("ok")]);
let parent = make_parent(provider.clone(), vec![]);
diff --cc crates/openhuman-core/src/channels/routes_tests.rs
index c2b6ba3a99,9e06580779..4bfb287ea4
--- a/crates/openhuman-core/src/channels/routes_tests.rs
+++ b/crates/openhuman-core/src/channels/routes_tests.rs
@@@ -452,5 -453,52 +452,8 @@@ async fn handle_runtime_command_unknown
assert_eq!(sent[0].thread_id.as_deref(), Some("thread-1"));
}
-#[tokio::test]
-async fn handle_runtime_command_set_model_clears_sender_history_and_persists_route_override() {
- let ctx = runtime_context(PathBuf::from("/tmp"));
- let key = "telegram_alice_room";
- ctx.conversation_histories
- .lock()
- .unwrap()
- .insert(key.to_string(), vec![ChatMessage::user("old history")]);
- let channel_impl = Arc::new(RecordingChannel::default());
- let channel: Arc<dyn Channel> = channel_impl.clone();
- let msg = inbound(
- "1".into(),
- "alice".into(),
- "room".into(),
- "/model gpt-5-mini".into(),
- "telegram".into(),
- None,
- );
-
- let handled = handle_runtime_command_if_needed(
- &ctx,
- &msg,
- Some(&channel),
- &conversation_history_key(&msg),
- )
- .await;
- assert!(handled);
-
- assert!(ctx
- .conversation_histories
- .lock()
- .unwrap()
- .get(key)
- .is_none());
- assert_eq!(
- get_route_selection(&ctx, key),
- ChannelRouteSelection {
- provider: "openai".into(),
- model: "gpt-5-mini".into()
- }
- );
-
- let sent = channel_impl.sent.lock().unwrap();
- assert_eq!(sent.len(), 1);
- assert!(sent_text(&sent[0]).contains("Model switched to `gpt-5-mini`"));
-}
+#[path = "routes_command_tests.rs"]
+mod command_tests;
+
+ #[path = "routes_telegram_tests.rs"]
+ mod routes_telegram_tests;
diff --cc crates/openhuman-core/src/cron/scheduler/agent_run.rs
index 662ef0877d,83fc36ccdc..8cc2e537a4
--- a/crates/openhuman-core/src/cron/scheduler/agent_run.rs
+++ b/crates/openhuman-core/src/cron/scheduler/agent_run.rs
@@@ -184,35 -175,14 +185,20 @@@ pub(super) async fn run_agent_job_for_r
MORNING_BRIEFING_TASK_RECENCY_SECS,
)));
}
- // Scope the run's origin around the turn. A job with no
- // channel origin runs as `TrustedAutomation { Cron }`: the
- // approval gate treats it as user-authorized automation
- // (the user created the job and authorized its prompt
- // together). A job created from a channel chat runs as
- // that channel's turn instead, so its external-effect
- // tools stay gated like its creator's were.
- let origin = crate::cron::origin::turn_origin_for_job_run(job, run_id);
- let turn = crate::security::turn_origin::with_origin(
- origin,
- agent.run_single(&prefixed_prompt),
- );
- // A host agent's turn runs in its own context, so every
- // ambient read (config, domains, tool groups, session
- // store) sees that agent rather than the process default.
- let turn: std::pin::Pin<
- Box<dyn std::future::Future<Output = anyhow::Result<String>> + Send + '_>,
- > = match context {
- Some(context) => {
- Box::pin(crate::core::runtime::CoreContext::scope(context, turn))
- }
- None => Box::pin(turn),
- };
- match tokio::time::timeout_at(absolute_deadline, turn).await {
- Box::pin(run_with_corrective_turn(
++ // One absolute deadline bounds the turn and any corrective turn.
++ let run = Box::pin(run_with_corrective_turn(
+ &mut agent,
+ context.as_ref(),
+ job,
+ run_id,
+ &prefixed_prompt,
- ))
- .await
++ ));
++ match tokio::time::timeout_at(absolute_deadline, run).await {
+ Ok(result) => result,
+ Err(_) => Err(anyhow::anyhow!(
+ "cron agent turn timed out after {timeout_secs}s"
+ )),
+ }
}
Err(e) => Err(e),
}
diff --cc crates/openhuman-core/src/inference/provider/factory.rs
index 05aae9e577,eaee763ef9..e4076039a4
--- a/crates/openhuman-core/src/inference/provider/factory.rs
+++ b/crates/openhuman-core/src/inference/provider/factory.rs
@@@ -43,10 -43,12 +43,10 @@@ pub use routing::{provider_for_role, ro
pub(crate) use routing::{workload_router, ConfigRouteSource};
// Factory-internal helpers shared across the implementation modules.
- use access_gates::{emit_inference_egress, enforce_local_only_inference};
+ use access_gates::enforce_local_only_inference;
#[cfg(test)]
use cloud_slug::try_create_cloud_slug_chat_model;
-pub(crate) use managed_backend::{
- make_openhuman_backend_model_for_options, make_openhuman_backend_model_for_thread_in,
-};
+pub(crate) use managed_backend::make_openhuman_backend_model_for_thread_in;
use tinyinference_providers::route::split_model_and_temperature;
/// Test-only seam: inject a mock [`ChatModel`] so e2e tests can drive the
diff --cc crates/openhuman-core/src/storage/boot.rs
index 45684265ae,fcb4366f0f..ed0bff7d7e
--- a/crates/openhuman-core/src/storage/boot.rs
+++ b/crates/openhuman-core/src/storage/boot.rs
@@@ -67,6 -87,44 +87,42 @@@ pub async fn prepare_scope(storage: &St
Ok(count)
}
-/// Runs the tinyagents graph and harness owner-local migrations on `scope`:
-/// v1 checkpoints, leases, task cache, run status, journals, blobs and
-/// key-value stores move to their v2 names. Idempotent.
++/// Runs the tinyagents harness owner-local migrations on `scope`: v1 run
++/// status, journals, blobs and key-value stores move to their v2 names.
++/// Idempotent. (The graph owner is gone with `tinyagents-graph`.)
+ async fn migrate_owners(storage: &Storage, scope: &Scope) -> Result<(), StorageError> {
+ let scoped = tinyagents_storage_kit::ScopedStorage::new(storage.clone(), scope.clone());
- // Each owner migrates independently: a graph failure must not hold back
- // the harness records. The first error is returned after both ran.
- let graph = tinyagents_graph::storage::open_storage(scoped.clone()).await;
- let harness = tinyagents_harness::storage::open_storage(scoped).await;
- graph.and(harness).map(|_| ())
++ tinyagents_harness::storage::open_storage(scoped)
++ .await
++ .map(|_| ())
+ }
+
-/// Runs the graph and harness owner migrations on `scope` again after an
++/// Runs the harness owner migrations on `scope` again after an
+ /// importer copied v1 records into it (the scope move). Their steps already
+ /// finished on the then-empty scope when it was prepared, and a finished step
+ /// is skipped, so the two owners' progress records are cleared first. The
+ /// steps write absent-only, so re-running over migrated records changes
+ /// nothing.
+ ///
+ /// # Errors
+ ///
+ /// The first storage error; the cleared steps re-run on the next preparation.
+ pub async fn remigrate_owners(storage: &Storage, scope: &Scope) -> Result<(), StorageError> {
+ use tinyagents_storage_kit::{DocumentStoreExt, MIGRATIONS_COLLECTION};
+ use tinystoragedrivers::{CollectionSpec, Precondition, Query};
+ let docs = storage.documents();
+ docs.ensure_collection(&CollectionSpec::new(MIGRATIONS_COLLECTION))
+ .await?;
+ for progress in docs.query_all(MIGRATIONS_COLLECTION, &Query::all()).await? {
+ let owner = progress.doc.get("owner").and_then(|value| value.as_str());
- if matches!(owner, Some("graph" | "harness")) {
++ if matches!(owner, Some("harness")) {
+ docs.delete(MIGRATIONS_COLLECTION, &progress.id, Precondition::None)
+ .await?;
+ }
+ }
+ migrate_owners(storage, scope).await
+ }
+
#[cfg(test)]
#[path = "boot_tests.rs"]
mod tests;
diff --cc crates/openhuman-core/src/storage/boot_tests.rs
index 89547d028b,f6f6220c36..6579f54878
--- a/crates/openhuman-core/src/storage/boot_tests.rs
+++ b/crates/openhuman-core/src/storage/boot_tests.rs
@@@ -33,3 -33,117 +33,92 @@@ async fn tenant_scopes_use_each_linked_
.sum::<usize>();
assert_eq!(prepared, declared);
}
+
-/// v1 rows an older build left in `storage`: a delegation graph checkpoint
-/// (thread `t`, checkpoint `d1`) and a harness run status (`run.abc`).
++/// A v1 row an older build left in `storage`: a harness run status
++/// (`run.abc`).
+ async fn put_v1_rows(storage: &Storage) {
+ use tinystoragedrivers::Precondition;
- let checkpoint = tinyagents_graph::checkpoint::Checkpoint::new(7_i32, Vec::new())
- .with_thread_id("t".to_string())
- .with_checkpoint_id("d1".to_string());
++ let rows = [(
++ "harness_run_status",
++ "8f3a-hash".to_string(),
++ serde_json::json!({
++ "runId": "run.abc", "rootRunId": "run.abc", "threadId": "t", "active": false,
++ "record": {
++ "run_id": "run.abc", "root_run_id": "run.abc", "thread_id": "t",
++ "component": "model", "status": "completed", "current_phase": "model",
++ "model_calls": 1, "tool_calls": 0, "active_tool_calls": [],
++ "usage": {}, "cost": {},
++ "started_at": 1_700_000_000_u64, "updated_at": 1_700_000_010_u64,
++ "metadata": {}
++ }
++ }),
++ )];
+ let docs = storage.documents();
- let rows = [
- (
- "delegation_graph_checkpoints",
- format!("1:t/20:{:020}", 0),
- serde_json::json!({
- "thread": "t", "namespace": "", "seq": 0, "checkpoint_id": "d1",
- "record": serde_json::to_value(&checkpoint).unwrap(),
- }),
- ),
- (
- "delegation_graph_threads",
- "1:t".to_string(),
- serde_json::json!({"thread": "t", "next": 1}),
- ),
- (
- "harness_run_status",
- "8f3a-hash".to_string(),
- serde_json::json!({
- "runId": "run.abc", "rootRunId": "run.abc", "threadId": "t", "active": false,
- "record": {
- "run_id": "run.abc", "root_run_id": "run.abc", "thread_id": "t",
- "component": "model", "status": "completed", "current_phase": "model",
- "model_calls": 1, "tool_calls": 0, "active_tool_calls": [],
- "usage": {}, "cost": {},
- "started_at": 1_700_000_000_u64, "updated_at": 1_700_000_010_u64,
- "metadata": {}
- }
- }),
- ),
- ];
+ for (collection, id, body) in rows {
+ docs.put(collection, &id, body, Precondition::None)
+ .await
+ .unwrap();
+ }
+ }
+
+ /// The v1 rows are readable through the v2 readers.
+ async fn assert_v1_rows_migrated(storage: &Storage) {
- use tinyagents_graph::checkpoint::{Checkpointer, DriverCheckpointer};
- let checkpointer =
- DriverCheckpointer::<i32>::with_namespace(Arc::clone(storage.documents()), "delegation");
- let found = checkpointer
- .get("t", None)
- .await
- .unwrap()
- .expect("the v1 delegation checkpoint is readable after preparation");
- assert_eq!((found.checkpoint_id.as_str(), found.state), ("d1", 7));
+ let status = storage
+ .documents()
+ .get("harness.run_status", "run.abc")
+ .await
+ .unwrap();
+ assert!(
+ status.is_some(),
+ "the v1 harness run status is readable after preparation"
+ );
+ }
+
+ #[tokio::test]
-async fn boot_migrates_v1_graph_and_harness_rows_in_the_local_scope() {
++async fn boot_migrates_v1_harness_rows_in_the_local_scope() {
+ let backend: Arc<dyn StorageBackend> =
+ Arc::new(tinystoragedrivers_testkit::MemoryBackend::new());
+ let local = backend.for_scope(&Scope::new("local").unwrap()).unwrap();
+ put_v1_rows(&local).await;
+
+ let report = prepare_and_migrate(&backend).await.unwrap();
+
+ assert_eq!(report.failures, 0);
+ assert_v1_rows_migrated(&local).await;
+ }
+
+ #[tokio::test]
-async fn prepare_scope_migrates_v1_graph_and_harness_rows() {
++async fn prepare_scope_migrates_v1_harness_rows() {
+ let backend = tinystoragedrivers_testkit::MemoryBackend::new();
+ let scope = super::super::scope::scope_for_profile("profile-a");
+ let storage = backend.for_scope(&scope).unwrap();
+ put_v1_rows(&storage).await;
+
+ prepare_scope(&storage, &scope).await.unwrap();
+
+ assert_v1_rows_migrated(&storage).await;
+ }
+
+ #[tokio::test]
+ async fn remigrate_owners_carries_v1_rows_copied_after_preparation() {
- use tinyagents_graph::checkpoint::{Checkpointer, DriverCheckpointer};
+ let backend = tinystoragedrivers_testkit::MemoryBackend::new();
+ let scope = super::super::scope::scope_for_profile("profile-b");
+ let storage = backend.for_scope(&scope).unwrap();
+ // The scope move prepares the target (the owner steps finish on an empty
+ // scope) and only then copies the v1 rows in.
+ prepare_scope(&storage, &scope).await.unwrap();
+ put_v1_rows(&storage).await;
+
+ // A finished step is skipped, so preparing again does not carry them.
+ prepare_scope(&storage, &scope).await.unwrap();
- let checkpointer =
- DriverCheckpointer::<i32>::with_namespace(Arc::clone(storage.documents()), "delegation");
- assert!(checkpointer.get("t", None).await.unwrap().is_none());
++ assert!(storage
++ .documents()
++ .get("harness.run_status", "run.abc")
++ .await
++ .unwrap()
++ .is_none());
+
+ remigrate_owners(&storage, &scope).await.unwrap();
+
+ assert_v1_rows_migrated(&storage).await;
+ }
diff --cc crates/openhuman-core/src/tools/impl/system/shell_tests_platform_tests.rs
index 2667860162,c531e2d13d..fbedff1ec2
--- a/crates/openhuman-core/src/tools/impl/system/shell_tests_platform_tests.rs
+++ b/crates/openhuman-core/src/tools/impl/system/shell_tests_platform_tests.rs
@@@ -3,9 -6,9 +3,10 @@@
use super::*;
use crate::modules::tinybox::host_runtime::{host_shell_flavor, ShellFlavor};
+ use crate::tools::system::shell_support::python_env_defaults;
#[cfg(feature = "modules")]
- use crate::tools::system::shell_support::{python_env_defaults, PYTHON_ENV_DEFAULTS};
+ use crate::tools::system::shell_support::PYTHON_ENV_DEFAULTS;
+use crate::tools::ShellTool;
use std::collections::HashMap;
use std::ffi::OsString;
diff --cc crates/openhuman-tinyhumans/Cargo.toml
index 2db7095fcd,f3c356fa8e..0d1f7dc1df
--- a/crates/openhuman-tinyhumans/Cargo.toml
+++ b/crates/openhuman-tinyhumans/Cargo.toml
@@@ -117,8 -117,6 +117,8 @@@ url = "2
reqwest = { version = "0.12", default-features = false, features = ["json", "multipart", "rustls-tls", "native-tls"] }
[dev-dependencies]
+# Library-runtime tests use the embed facade's in-memory session provider.
- openhuman-embed = { path = "../openhuman-embed", features = ["testkit"] }
++openhuman-embed = { path = "../openhuman-embed", features = ["testkit", "storage-sqlite"] }
# The core's own axum feature set: axum's defaults would switch on extra axum,
# tower and tracing features and force a separate core build (see below).
axum = { version = "0.8", default-features = false, features = ["http1", "json", "tokio", "query", "ws", "macros"] }
diff --cc docs/gitbooks/en/developing/architecture/storage.md
index 7d34ab520b,7d34ab520b..4a38ac3da0
--- a/docs/gitbooks/en/developing/architecture/storage.md
+++ b/docs/gitbooks/en/developing/architecture/storage.md
@@@ -159,7 -159,7 +159,7 @@@ The host's storage tests run on SQLite
Whether each driver honours the storage ports is proven upstream, in `tinystoragedrivers`. Its `conformance` module runs the same checks against every driver (nested scope isolation, compare-and-swap and leases across processes via `run_shared` for drivers that claim `Capability::SharedAcrossProcesses`, fencing, document secrets and migrations), and its CI runs them against a MongoDB replica set as well. The host asks a backend for `Capability::SharedAcrossProcesses` rather than hardcoding driver names where it can (`storage::backend_has_cross_process_cas`); the boot guard judges a URL before anything is opened, so it keeps a name check that a test pins to the real drivers.
--The targets are `storage_approvals_e2e`, `storage_domains_e2e`, `storage_flows_e2e`, `storage_secrets_e2e`, `storage_scope_e2e`, `storage_agent_scopes_e2e`, `storage_delegation_e2e`, `storage_desktop_upgrade_e2e` and `cli_storage_url_e2e`. Run one locally:
++The targets are `storage_approvals_e2e`, `storage_domains_e2e`, `storage_flows_e2e`, `storage_secrets_e2e`, `storage_scope_e2e`, `storage_agent_scopes_e2e`, `storage_desktop_upgrade_e2e` and `cli_storage_url_e2e`. Run one locally:
```bash
cargo test -p openhuman-cli --features storage-sqlite --test storage_approvals_e2e
diff --cc tests/saas_mode/delivery_recovery.rs
index b47f566d2b,940581a614..2c79d2dd27
--- a/tests/saas_mode/delivery_recovery.rs
+++ b/tests/saas_mode/delivery_recovery.rs
@@@ -26,6 -26,6 +26,37 @@@ use tinyagents_tasks::
use super::*;
++/// Presents the host's storage backend as the storage-kit backend the
++/// completion store opens, as the core's own adapter does.
++struct KitBackend(Arc<dyn openhuman_core::storage::StorageBackend>);
++
++impl tinyagents_storage_kit::StorageBackend for KitBackend {
++ fn for_scope(
++ &self,
++ scope: &tinyagents_storage_kit::Scope,
++ ) -> tinyagents_storage_kit::error::Result<tinyagents_storage_kit::ScopedStorage> {
++ let host_scope = openhuman_core::storage::Scope::new(scope.as_str())?;
++ let storage = self.0.for_scope(&host_scope)?;
++ Ok(tinyagents_storage_kit::ScopedStorage::new(
++ storage,
++ scope.clone(),
++ ))
++ }
++
++ fn for_scope_conditioned(
++ &self,
++ scope: &tinyagents_storage_kit::Scope,
++ condition: &tinyagents_storage_kit::WriteCondition,
++ ) -> tinyagents_storage_kit::error::Result<tinyagents_storage_kit::ScopedStorage> {
++ let host_scope = openhuman_core::storage::Scope::new(scope.as_str())?;
++ let storage = self.0.for_scope_conditioned(&host_scope, condition)?;
++ Ok(tinyagents_storage_kit::ScopedStorage::new(
++ storage,
++ scope.clone(),
++ ))
++ }
++}
++
const OWNER: &str = "ann";
const OTHER: &str = "bob";
const THREAD: &str = "shared-thread";
@@@ -99,9 -99,13 +130,12 @@@ fn leave_undelivered_result(root: &std:
Ok(openhuman_core::storage::open(&url).await?)
})
.expect("open the profile's database");
- let scoped = backend
- .for_scope(&openhuman_core::storage::scope_for_profile(id.as_str()))
- .expect("the profile's scope");
+ let scope = openhuman_core::storage::scope_for_profile(id.as_str());
- let store: Arc<dyn CompletionStore> =
- Arc::new(DriverCompletionStore::new(backend, scope).expect("open the completion queue"));
++ let scope = tinyagents_storage_kit::Scope::new(scope.as_str()).expect("the profile's scope");
+ let store: Arc<dyn CompletionStore> = Arc::new(
- DriverCompletionStore::new(Arc::clone(scoped.documents()))
++ DriverCompletionStore::new(Arc::new(KitBackend(backend)), scope)
+ .expect("open the completion queue"),
+ );
let record = CompletionRecord::new(
"task-delivery-recovery-1",
THREAD,
diff --cc tests/storage_delegation_e2e.rs
index 1a0065a5fd,1a0065a5fd..0000000000
deleted file mode 100644,100644
--- a/tests/storage_delegation_e2e.rs
+++ /dev/null
@@@ -1,167 -1,167 +1,0 @@@
--//! The delegation graph's durable checkpointer (`DriverCheckpointer` behind
--//! `open_delegation_checkpointer`) on a configured backend: a checkpoint is
--//! written and resumed, resumed again from a reopened backend, and two
--//! agents' scopes keep their checkpoints apart.
--//!
--//! Its own test binary because it installs a backend into the process-wide
--//! storage slot.
--
--use std::sync::Arc;
--
--use openhuman_core::agent::orchestration::open_delegation_checkpointer;
--use openhuman_core::config::Config;
--use openhuman_core::core::runtime::{
-- AgentContextRegistry, ContextOverlay, CoreBuilder, CoreContext, DomainSet, ServiceSet,
--};
--use openhuman_core::HostKind;
--use tinyagents_graph::checkpoint::{Checkpoint, Checkpointer};
--use tinyagents_graph::delegation::DelegationState;
--
--#[path = "support/tinyhumans_boot.rs"]
--mod tinyhumans_boot;
--
--#[path = "support/storage_case.rs"]
--mod storage_case;
--
--use storage_case::Case;
--
--fn state(plan: &str) -> DelegationState {
-- DelegationState {
-- plan: Some(plan.to_string()),
-- ..DelegationState::default()
-- }
--}
--
--fn checkpoint(thread: &str, id: &str, plan: &str) -> Checkpoint<DelegationState> {
-- Checkpoint::new(state(plan), Vec::new())
-- .with_thread_id(thread)
-- .with_checkpoint_id(id)
--}
--
--async fn plan_of(
-- checkpointer: &Arc<dyn Checkpointer<DelegationState>>,
-- thread: &str,
--) -> Option<String> {
-- checkpointer
-- .get(thread, None)
-- .await
-- .unwrap()
-- .and_then(|checkpoint| checkpoint.state.plan)
--}
--
--#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
--async fn the_delegation_checkpointer_resumes_and_keeps_scopes_apart() {
-- let case = Case::open();
-- let workspace = tempfile::tempdir().unwrap();
-- let config = Config {
-- workspace_dir: workspace.path().join("workspace"),
-- config_path: workspace.path().join("config.toml"),
-- ..Config::default()
-- };
-- tinyhumans_boot::boot();
-- let _runtime = CoreBuilder::new(HostKind::Library)
-- .config(config.clone())
-- .services(ServiceSet::none())
-- .domains(DomainSet::none())
-- .build()
-- .await
-- .unwrap();
-- case.install();
--
-- let derive = |agent: &str| {
-- let context = CoreContext::current().unwrap().derive_with(
-- ContextOverlay::new(config.clone(), DomainSet::none(), Default::default())
-- .session_agent(agent),
-- );
-- AgentContextRegistry::register(agent, &context);
-- context
-- };
-- let alpha = derive("agent-alpha");
-- let beta = derive("agent-beta");
--
-- // Checkpoint as A, and as B under the very same thread id.
-- CoreContext::scope(Arc::clone(&alpha), async {
-- let checkpointer = open_delegation_checkpointer(&config).unwrap();
-- checkpointer
-- .put(checkpoint("run-1", "c1", "alpha plan, step 1"))
-- .await
-- .unwrap();
-- checkpointer
-- .put(checkpoint("run-1", "c2", "alpha plan, step 2"))
-- .await
-- .unwrap();
-- })
-- .await;
-- CoreContext::scope(Arc::clone(&beta), async {
-- let checkpointer = open_delegation_checkpointer(&config).unwrap();
-- assert_eq!(
-- plan_of(&checkpointer, "run-1").await,
-- None,
-- "B sees A's checkpoint"
-- );
-- checkpointer
-- .put(checkpoint("run-1", "c1", "beta plan"))
-- .await
-- .unwrap();
-- })
-- .await;
--
-- // Resume: a fresh handle reads the latest checkpoint of the thread, in
-- // its own scope.
-- for (context, expected, latest, named_c1) in [
-- (&alpha, "alpha plan, step 2", "c2", "alpha plan, step 1"),
-- (&beta, "beta plan", "c1", "beta plan"),
-- ] {
-- CoreContext::scope(Arc::clone(context), async {
-- let checkpointer = open_delegation_checkpointer(&config).unwrap();
-- let resumed = checkpointer.get("run-1", None).await.unwrap().unwrap();
-- assert_eq!(resumed.checkpoint_id, latest);
-- assert_eq!(resumed.state.plan.as_deref(), Some(expected));
-- // A named checkpoint resolves in the same scope only.
-- let first = checkpointer.get("run-1", Some("c1")).await.unwrap();
-- assert_eq!(
-- first
-- .and_then(|checkpoint| checkpoint.state.plan)
-- .as_deref(),
-- Some(named_c1),
-- "the named checkpoint is this agent's own"
-- );
-- assert_eq!(
-- checkpointer.list_threads().await.unwrap(),
-- vec!["run-1".to_string()]
-- );
-- })
-- .await;
-- }
--
-- // Local (no acting agent) holds neither.
-- let local = open_delegation_checkpointer(&config).unwrap();
-- assert!(local.list_threads().await.unwrap().is_empty());
-- assert_eq!(plan_of(&local, "run-1").await, None);
--
-- // The checkpoint resumes after a durable backend is reopened, as a
-- // restarted process would. The memory driver is intentionally volatile:
-- // opening it again creates a new, empty backend, so it cannot exercise
-- // restart persistence.
-- if case.url != "memory" {
-- let url = case.url.clone();
-- let reopened =
-- openhuman_core::storage::block_on(
-- async move { openhuman_core::storage::open(&url).await },
-- )
-- .unwrap();
-- openhuman_core::storage::install(reopened);
-- CoreContext::scope(Arc::clone(&alpha), async {
-- let checkpointer = open_delegation_checkpointer(&config).unwrap();
-- assert_eq!(
-- plan_of(&checkpointer, "run-1").await.as_deref(),
-- Some("alpha plan, step 2"),
-- "the checkpoint survived reopening the backend"
-- );
-- })
-- .await;
-- }
--
-- assert!(AgentContextRegistry::deregister("agent-alpha", &alpha));
-- assert!(AgentContextRegistry::deregister("agent-beta", &beta));
--}
diff --cc vendor/tinyagents
index 4dc8e4e7f3,540997da52..7346fabd30
--- a/vendor/tinyagents
+++ b/vendor/tinyagents
@@@ -1,1 -1,1 +1,1 @@@
- Subproject commit 4dc8e4e7f3a25bc89e440e384665e7ef474612ca
-Subproject commit 540997da5274d0f12c38870d4be1af1a20494eab
++Subproject commit 7346fabd30adee9ac51b656e7059dd1a957778b4
diff --cc vendor/tinyjuice
index a65a00dc44,d454ca139e..e2e51f7cf1
--- a/vendor/tinyjuice
+++ b/vendor/tinyjuice
@@@ -1,1 -1,1 +1,1 @@@
- Subproject commit a65a00dc445a06c4e7eb4652e0ae47e67137a46c
-Subproject commit d454ca139ec8c6f771a19cd184058af84841fece
++Subproject commit e2e51f7cf1384f8d4e639b5f2daff64055bcb752
diff --cc vendor/tinyvoice
index fe4768e74d,96eaa4dcb5..e5ed0f9534
--- a/vendor/tinyvoice
+++ b/vendor/tinyvoice
@@@ -1,1 -1,1 +1,1 @@@
- Subproject commit fe4768e74dcfe9ad4bc1590808fb0ae4351847ca
-Subproject commit 96eaa4dcb568539d538e48872f0e14f2d10363a8
++Subproject commit e5ed0f95344dc3e2cff540514a4790b918e1be14