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
test: pin channel, thread, flow, document and Composio trust boundaries
M3gA-Mind5f3444c81d25
diff --git a/crates/openhuman-core/src/channels/runtime/startup/callback.rs b/crates/openhuman-core/src/channels/runtime/startup/callback.rsindex e381fd7805..0485b50787 100644--- a/crates/openhuman-core/src/channels/runtime/startup/callback.rs+++ b/crates/openhuman-core/src/channels/runtime/startup/callback.rs@@ -202,3 +202,7 @@ impl ChannelHostCallbacks {}}}++#[cfg(test)]+#[path = "callback_tests.rs"]+mod tests;diff --git a/crates/openhuman-core/src/channels/runtime/startup/callback_tests.rs b/crates/openhuman-core/src/channels/runtime/startup/callback_tests.rsnew file mode 100644index 0000000000..8eece8ae7a--- /dev/null+++ b/crates/openhuman-core/src/channels/runtime/startup/callback_tests.rs@@ -0,0 +1,93 @@+//! Trust checks on the module-facing inbound callback: a module instance may+//! only deliver for its own channel, and an oversize payload is refused before+//! it reaches dispatch.++use super::ChannelHostCallbacks;+use crate::channels::runtime::dispatch::RuntimeChannelMessage;+use crate::config::Config;+use std::sync::{Arc, OnceLock};+use tokio::sync::mpsc;++fn callbacks() -> (ChannelHostCallbacks, mpsc::Receiver<RuntimeChannelMessage>) {+ let (tx, rx) = mpsc::channel(1);+ let callbacks = ChannelHostCallbacks::new(+ &crate::core::runtime::DispatchCtx::ambient(),+ Arc::new(Config::default()),+ Arc::new(OnceLock::new()),+ tx,+ );+ (callbacks, rx)+}++fn envelope(channel: &str, text: &str) -> tinychannels::ChannelInboundEnvelope {+ tinychannels::ChannelInboundEnvelope {+ channel: tinychannels::channel::ChannelRef {+ id: channel.into(),+ account_id: None,+ },+ message_id: "m-1".into(),+ conversation: tinychannels::channel::ConversationRef {+ id: "chat-1".into(),+ ..Default::default()+ },+ sender: tinychannels::channel::SenderRef {+ id: "alice".into(),+ ..Default::default()+ },+ text: text.into(),+ ..Default::default()+ }+}++#[tokio::test]+async fn a_message_for_the_callback_channel_is_dispatched() {+ let (callbacks, mut rx) = callbacks();+ let message = serde_json::to_value(envelope("telegram", "hi")).unwrap();+ callbacks+ .deliver_inbound("telegram".into(), message)+ .await+ .expect("own channel");+ let forwarded = rx.try_recv().expect("dispatched");+ assert_eq!(forwarded.message.channel.id, "telegram");+ assert!(!forwarded.authenticated_relay);+}++#[tokio::test]+async fn a_message_for_another_channel_is_refused() {+ let (callbacks, mut rx) = callbacks();+ let message = serde_json::to_value(envelope("discord", "hi")).unwrap();+ let error = callbacks+ .deliver_inbound("telegram".into(), message)+ .await+ .expect_err("another channel's message");+ assert!(error.to_string().contains("does not match"), "{error}");+ assert!(rx.try_recv().is_err(), "nothing may reach dispatch");+}++#[tokio::test]+async fn a_relay_envelope_for_another_channel_is_refused() {+ let (callbacks, mut rx) = callbacks();+ let delivery = serde_json::json!({+ "envelope": envelope("discord", "hi"),+ "delivered_via_authenticated_relay": true,+ });+ let error = callbacks+ .deliver_inbound("telegram".into(), delivery)+ .await+ .expect_err("another channel's relay envelope");+ assert!(error.to_string().contains("does not match"), "{error}");+ assert!(rx.try_recv().is_err(), "nothing may reach dispatch");+}++#[tokio::test]+async fn an_oversize_payload_is_refused() {+ let (callbacks, mut rx) = callbacks();+ let big = "x".repeat(super::MAX_CALLBACK_BYTES + 1);+ let message = serde_json::to_value(envelope("telegram", &big)).unwrap();+ let error = callbacks+ .deliver_inbound("telegram".into(), message)+ .await+ .expect_err("oversize payload");+ assert!(error.to_string().contains("exceeds its limit"), "{error}");+ assert!(rx.try_recv().is_err(), "nothing may reach dispatch");+}diff --git a/crates/openhuman-core/src/flows/ops_triggers_and_resume_tests.rs b/crates/openhuman-core/src/flows/ops_triggers_and_resume_tests.rsindex a54d26f41e..4234d39730 100644--- a/crates/openhuman-core/src/flows/ops_triggers_and_resume_tests.rs+++ b/crates/openhuman-core/src/flows/ops_triggers_and_resume_tests.rs@@ -678,3 +678,33 @@ async fn flows_resume_refuses_when_the_graph_changed_after_park() {"a settled/refused run must not be resumable again");}++/// Resume guard: a parked run resumes only under the flow it belongs to.+#[tokio::test]+async fn flows_resume_refuses_a_run_from_another_flow() {+ let tmp = TempDir::new().unwrap();+ let config = test_config(&tmp);+ let ctx = crate::core::runtime::DispatchCtx::ambient();+ let gated = |name: &str| flows_create(&config, name.into(), approval_gated_graph(), false);+ let (a, b) = (+ gated("a").await.unwrap().value.id,+ gated("b").await.unwrap().value.id,+ );+ let run = flows_run(+ &ctx,+ &config,+ &a,+ json!({ "x": 1 }),+ Default::default(),+ FlowRunTrigger::Rpc,+ )+ .await+ .unwrap();+ let thread_id = run.value["thread_id"].as_str().unwrap().to_string();+ let pending = vec!["gate".to_string()];++ let error = flows_resume(&ctx, &config, &b, &thread_id, pending, vec![])+ .await+ .expect_err("run A resumed under flow B");+ assert!(error.contains("does not belong to flow"), "{error}");+}diff --git a/crates/openhuman-core/src/integrations/composio/client/factory_tests.rs b/crates/openhuman-core/src/integrations/composio/client/factory_tests.rsindex 0e01cecd47..fefbcb0913 100644--- a/crates/openhuman-core/src/integrations/composio/client/factory_tests.rs+++ b/crates/openhuman-core/src/integrations/composio/client/factory_tests.rs@@ -52,3 +52,29 @@ fn a_host_pinned_credential_wins_over_a_registered_builder() {unregister_composio_route_builder("backend");assert!(matches!(route, Ok(ComposioRoute::Direct(_))));}++// Plain-http base URLs are allowed only for loopback; userinfo must not smuggle+// a remote host past that check.+#[test]+fn loopback_http_guard_rejects_smuggled_and_remote_hosts() {+ use super::super::credential::{is_loopback_http_url, DirectCredential};+ for url in [+ "http://127.0.0.1:[email protected]/api/v3",+ "http://[email protected]/",+ "http://evil.com/",+ "http://[::2]:9/",+ ] {+ assert!(!is_loopback_http_url(url), "{url}");+ assert!(+ DirectCredential::new_with_base_urls("k", url.into(), url.into()).is_err(),+ "{url}"+ );+ }+ for url in [+ "http://[::1]:9/v3",+ "http://LOCALHOST:9/",+ "http://127.0.0.1:9/",+ ] {+ assert!(is_loopback_http_url(url), "{url}");+ }+}diff --git a/crates/openhuman-core/src/modules/documents_tests.rs b/crates/openhuman-core/src/modules/documents_tests.rsindex b8a7619710..b62d23def5 100644--- a/crates/openhuman-core/src/modules/documents_tests.rs+++ b/crates/openhuman-core/src/modules/documents_tests.rs@@ -230,6 +230,28 @@ async fn held_outputs_are_released_after_success_read_failure_and_cancellation()));assert_output_is_gone(&proxy, &output_id).await;+ // A declared length over the cap is refused before any read.+ let (proxy, mut handle) = held_docx(&config).await;+ handle.total_bytes = MAX_DOCUMENT_BYTES + 1;+ let output_id = handle.output_id.clone();+ let result = collect(&proxy, handle).await;+ assert!(+ matches!(&result, Err(DocumentCallError::Failed(m)) if m.contains("-byte limit")),+ "{result:?}"+ );+ assert_output_is_gone(&proxy, &output_id).await;++ // A declared length past the real end is a failure, not an endless loop.+ let (proxy, mut handle) = held_docx(&config).await;+ handle.total_bytes += 1;+ let output_id = handle.output_id.clone();+ let result = collect(&proxy, handle).await;+ assert!(+ matches!(&result, Err(DocumentCallError::Failed(m)) if m.contains("ended before")),+ "{result:?}"+ );+ assert_output_is_gone(&proxy, &output_id).await;+let (proxy, handle) = held_docx(&config).await;let output_id = handle.output_id;let release = OutputReleaseGuard {diff --git a/crates/openhuman-core/src/threads/ops/crud_message_append_tests.rs b/crates/openhuman-core/src/threads/ops/crud_message_append_tests.rsindex 1eff122c93..1aa0bff783 100644--- a/crates/openhuman-core/src/threads/ops/crud_message_append_tests.rs+++ b/crates/openhuman-core/src/threads/ops/crud_message_append_tests.rs@@ -320,3 +320,67 @@ async fn raw_append_stages_in_the_bound_thread_folder() {assert!(folder.join(&files[0].path).is_file());assert!(!config.action_dir.join("uploads").exists());}++async fn append_one_attachment(+ config: &crate::config::Config,+ path: &str,+ mime: &str,+ bytes: usize,+) -> Result<(), ThreadsError> {+ let file = config.action_dir.join(path);+ std::fs::create_dir_all(file.parent().unwrap()).unwrap();+ std::fs::write(&file, vec![b'x'; bytes]).unwrap();+ let marker = crate::attachments::Attachment {+ path: path.into(),+ name: path.rsplit('/').next().unwrap().into(),+ mime: mime.into(),+ size_bytes: bytes,+ }+ .marker();+ let mut upload = request("limit", &marker, "user");+ upload.message.extra_metadata = json!({});+ append_with_test_config(upload, config, None)+ .await+ .map(|_| ())+}++async fn no_messages(config: &crate::config::Config) -> bool {+ conversations::blocking::get_messages(+ crate::core::runtime::DispatchCtx::ambient(),+ config.workspace_dir.clone(),+ "uploads".into(),+ )+ .await+ .unwrap()+ .is_empty()+}++#[tokio::test]+async fn an_attachment_over_the_file_limit_is_never_appended() {+ let (_temp, mut config) = setup().await;+ config.multimodal_files.max_file_size_mb = 1;+ let error = append_one_attachment(&config, "uploads/big.txt", "text/plain", 1024 * 1024 + 1)+ .await+ .expect_err("over the file limit");+ assert!(+ error.to_string().contains("exceeds configured file limit"),+ "{error}"+ );+ assert!(no_messages(&config).await);++ // At the limit it goes through, so the refusal above is the size cap.+ append_one_attachment(&config, "uploads/ok.txt", "text/plain", 1024 * 1024)+ .await+ .expect("at the file limit");+}++#[tokio::test]+async fn an_image_is_refused_when_images_are_disabled() {+ let (_temp, mut config) = setup().await;+ config.multimodal.max_images = 0;+ let error = append_one_attachment(&config, "uploads/a.png", "image/png", 16)+ .await+ .expect_err("images disabled");+ assert!(error.to_string().contains("count exceeds"), "{error}");+ assert!(no_messages(&config).await);+}diff --git a/crates/openhuman-core/src/threads/ops/working_dir_tests.rs b/crates/openhuman-core/src/threads/ops/working_dir_tests.rsindex 640f38faef..4b6ea694d1 100644--- a/crates/openhuman-core/src/threads/ops/working_dir_tests.rs+++ b/crates/openhuman-core/src/threads/ops/working_dir_tests.rs@@ -33,3 +33,97 @@ fn relative_missing_file_and_forbidden_paths_are_rejected() {std::fs::create_dir(&ssh).unwrap();assert!(validate_working_dir(Some(&ssh.display().to_string())).is_err());}++fn thread(id: &str, working_dir: Option<String>) -> conversations::CreateConversationThread {+ conversations::CreateConversationThread {+ id: id.into(),+ title: id.into(),+ created_at: "2026-10-23T00:00:00Z".into(),+ parent_thread_id: None,+ labels: None,+ personality_id: None,+ working_dir,+ }+}++#[tokio::test]+async fn a_bound_folder_that_disappears_fails_closed() {+ // The thread must not silently fall back to the global folder.+ let temp = tempfile::tempdir().unwrap();+ let workspace = temp.path().join("internal");+ let folder = temp.path().join("project");+ std::fs::create_dir(&folder).unwrap();+ let folder = folder.canonicalize().unwrap();+ let ctx = DispatchCtx::ambient();+ conversations::blocking::ensure_thread(+ ctx.clone(),+ workspace.clone(),+ thread("bound", Some(folder.to_string_lossy().into_owned())),+ )+ .await+ .unwrap();+ assert_eq!(+ thread_working_dir(&ctx, workspace.clone(), "bound")+ .await+ .unwrap(),+ Some(folder.clone())+ );++ std::fs::remove_dir(&folder).unwrap();+ let error = thread_working_dir(&ctx, workspace, "bound")+ .await+ .expect_err("a vanished bound folder");+ assert!(error.contains("unusable"), "{error}");+}++#[tokio::test]+async fn the_working_folder_is_fixed_after_the_first_message() {+ let _lock = crate::config::TEST_ENV_LOCK.lock().await;+ let home = tempfile::tempdir().unwrap();+ unsafe { std::env::set_var("OPENHUMAN_WORKSPACE", home.path()) };+ let result = async {+ let ctx = DispatchCtx::ambient();+ let workspace = workspace_dir().await.unwrap();+ conversations::blocking::ensure_thread(ctx.clone(), workspace.clone(), thread("t", None))+ .await+ .unwrap();+ let folder = home.path().join("project");+ std::fs::create_dir(&folder).unwrap();+ let request = |dir: &Path| UpdateConversationThreadWorkingDirRequest {+ thread_id: "t".into(),+ action_dir: dir.display().to_string(),+ };+ // Before any message the folder can be bound.+ thread_update_working_dir(&ctx, request(&folder))+ .await+ .unwrap();++ conversations::blocking::append_message(+ ctx.clone(),+ workspace,+ "t".into(),+ conversations::ConversationMessage {+ id: "m1".into(),+ content: "hi".into(),+ message_type: "text".into(),+ extra_metadata: serde_json::json!({}),+ sender: "user".into(),+ created_at: "2026-10-23T00:00:01Z".into(),+ },+ )+ .await+ .unwrap();+ thread_update_working_dir(&ctx, request(home.path()))+ .await+ .map(|_| ())+ }+ .await;+ unsafe { std::env::remove_var("OPENHUMAN_WORKSPACE") };+ let error = result.expect_err("rebinding after the first message");+ assert!(+ error+ .to_string()+ .contains("before the conversation's first message"),+ "{error}"+ );+}