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: split large test modules into focused files
Steven Enamakel458af58b17e1
diff --git a/crates/openhuman-core/src/agent/prompts/mod_tests.rs b/crates/openhuman-core/src/agent/prompts/mod_tests.rsindex b30d303618..82e7646166 100644--- a/crates/openhuman-core/src/agent/prompts/mod_tests.rs+++ b/crates/openhuman-core/src/agent/prompts/mod_tests.rs@@ -87,6 +87,8 @@ mod grounding_spec_check_tests;mod subagent_render_tests;#[path = "mod_tests_tools_sections_tests.rs"]mod tools_sections_tests;+#[path = "mod_tests_user_files_reflections_tests.rs"]+mod user_files_reflections_tests;#[test]fn tool_call_format_maps_to_the_dialect_and_harness_vocabulary() {diff --git a/crates/openhuman-core/src/config/schema/agent_memory_window_tests_tests.rs b/crates/openhuman-core/src/config/schema/agent_memory_window_tests_tests.rsdeleted file mode 100644index e77eb9badc..0000000000--- a/crates/openhuman-core/src/config/schema/agent_memory_window_tests_tests.rs+++ /dev/null@@ -1,215 +0,0 @@-use super::*;--#[test]-fn presets_are_strictly_ordered_and_bounded() {- let m = MemoryContextWindow::Minimal.limits();- let b = MemoryContextWindow::Balanced.limits();- let e = MemoryContextWindow::Extended.limits();- let max = MemoryContextWindow::Maximum.limits();-- // Recall cap grows monotonically with preset size.- assert!(m.max_memory_context_chars < b.max_memory_context_chars);- assert!(b.max_memory_context_chars < e.max_memory_context_chars);- assert!(e.max_memory_context_chars < max.max_memory_context_chars);-- // Tree summary caps grow monotonically too.- assert!(m.per_namespace_max_chars < b.per_namespace_max_chars);- assert!(b.per_namespace_max_chars < e.per_namespace_max_chars);- assert!(e.per_namespace_max_chars < max.per_namespace_max_chars);- assert!(m.total_tree_max_chars < max.total_tree_max_chars);-- // Hard ceiling is bounded — Maximum still leaves headroom in a- // typical 200k-token context window.- assert!(max.total_tree_max_chars <= 128_000);-}--#[test]-fn balanced_matches_legacy_defaults() {- // Balanced preset must keep historical behaviour: 2 000 char- // recall budget and 32 000 char total tree-summary cap (used to- // be hard-coded constants in `agent/prompts/types.rs`).- let b = MemoryContextWindow::Balanced.limits();- assert_eq!(b.max_memory_context_chars, 2_000);- assert_eq!(b.per_namespace_max_chars, 8_000);- assert_eq!(b.total_tree_max_chars, 32_000);-}--#[test]-fn default_agent_config_is_unmigrated_and_resolves_to_balanced_caps() {- // Default = `memory_window: None` (unmigrated). The recall cap- // falls back to the legacy `max_memory_context_chars` default- // (2 000), which matches Balanced — so the resolved limits are- // byte-identical to the historical behaviour.- let cfg = AgentConfig::default();- assert_eq!(cfg.memory_window, None);- assert_eq!(- cfg.resolved_memory_limits(),- MemoryContextWindow::Balanced.limits()- );-}--#[test]-fn explicit_preset_is_authoritative_and_ignores_legacy_raw_field() {- // Once Minimal is chosen, the preset's recall cap (800) is what- // the harness sees — even if the legacy raw field still holds a- // wider value from before the user picked a preset. Without- // this, switching to `Minimal` in the UI would silently fail to- // shrink the recall budget.- let cfg = AgentConfig {- memory_window: Some(MemoryContextWindow::Minimal),- max_memory_context_chars: 4_000,- ..AgentConfig::default()- };- assert_eq!(- cfg.resolved_memory_limits(),- MemoryContextWindow::Minimal.limits(),- "explicit preset must override legacy raw field"- );-}--#[test]-fn unmigrated_config_honours_legacy_raw_field_within_safety_ceiling() {- // Unmigrated power-user config with a legacy override of 4 000- // keeps that recall cap on upgrade so behaviour doesn't shrink- // silently. Tree caps come from the Balanced baseline because- // older builds had no per-namespace cap on this code path.- let cfg = AgentConfig {- memory_window: None,- max_memory_context_chars: 4_000,- ..AgentConfig::default()- };- let limits = cfg.resolved_memory_limits();- assert_eq!(limits.max_memory_context_chars, 4_000);- assert_eq!(- limits.per_namespace_max_chars,- MemoryContextWindow::Balanced- .limits()- .per_namespace_max_chars- );-- // An unbounded legacy value is clamped to the Maximum preset's- // recall cap so on-disk overrides can't blow up prompts.- let runaway = AgentConfig {- memory_window: None,- max_memory_context_chars: 1_000_000,- ..AgentConfig::default()- };- assert_eq!(- runaway.resolved_memory_limits().max_memory_context_chars,- MemoryContextWindow::Maximum- .limits()- .max_memory_context_chars- );-}--#[test]-fn switching_preset_can_shrink_recall_below_legacy_value() {- // Regression for the CodeRabbit concern: an unmigrated config- // with a wide legacy override that then explicitly picks- // `Minimal` in the UI must end up with the Minimal recall cap,- // not the legacy value.- let mut cfg = AgentConfig {- memory_window: None,- max_memory_context_chars: 4_000,- ..AgentConfig::default()- };- assert_eq!(cfg.resolved_memory_limits().max_memory_context_chars, 4_000);- cfg.memory_window = Some(MemoryContextWindow::Minimal);- assert_eq!(- cfg.resolved_memory_limits().max_memory_context_chars,- MemoryContextWindow::Minimal- .limits()- .max_memory_context_chars- );-}--#[test]-fn from_str_opt_round_trips() {- for window in [- MemoryContextWindow::Minimal,- MemoryContextWindow::Balanced,- MemoryContextWindow::Extended,- MemoryContextWindow::Maximum,- ] {- assert_eq!(- MemoryContextWindow::from_str_opt(window.as_str()),- Some(window)- );- }- assert_eq!(- MemoryContextWindow::from_str_opt("MAXIMUM"),- Some(MemoryContextWindow::Maximum)- );- assert_eq!(MemoryContextWindow::from_str_opt("nonsense"), None);-}--#[test]-fn enum_serializes_as_lowercase_string() {- let json = serde_json::to_string(&MemoryContextWindow::Extended).unwrap();- assert_eq!(json, "\"extended\"");- let back: MemoryContextWindow = serde_json::from_str("\"minimal\"").unwrap();- assert_eq!(back, MemoryContextWindow::Minimal);-}--#[test]-fn empty_channel_permissions_with_existing_channels_migrates_to_execute() {- // Legacy install: channel_permissions empty but the user has two- // channels configured. The migration seeds web + each existing- // channel = execute so the new fail-closed default doesn't- // regress them.- let mut cfg = AgentConfig::default();- assert!(cfg.channel_permissions.is_empty());-- let known = ["telegram".to_string(), "discord".to_string()];- let migrated = cfg.migrate_channel_permissions_if_legacy(known.iter());-- assert!(migrated, "legacy install must migrate");- assert_eq!(cfg.channel_permissions.len(), 3);- for ch in ["web", "telegram", "discord"] {- assert_eq!(- cfg.channel_permissions.get(ch).map(String::as_str),- Some("execute"),- "expected execute for channel {ch}"- );- }-}--#[test]-fn migrate_channel_permissions_idempotent() {- let mut cfg = AgentConfig::default();- cfg.migrate_channel_permissions_if_legacy(["telegram".to_string()].iter());- let again = cfg.migrate_channel_permissions_if_legacy(["telegram".to_string()].iter());- assert!(!again, "second migration call must be a no-op");-}--#[test]-fn migrate_channel_permissions_with_no_channels_is_noop() {- // Fresh install with no configured channels and an empty map —- // no migration needed (the engine fails closed on lookup).- let mut cfg = AgentConfig::default();- let migrated = cfg.migrate_channel_permissions_if_legacy(Vec::<String>::new());- assert!(!migrated);- assert!(cfg.channel_permissions.is_empty());-}--#[test]-fn agents_md_enabled_defaults_to_true() {- assert!(- AgentConfig::default().agents_md_enabled,- "AGENTS.md loading must be on by default"- );-}--#[test]-fn agents_md_enabled_defaults_true_when_field_omitted() {- // A config that predates the field must deserialize with the feature on- // (matches the `#[serde(default = ...)]` contract).- let cfg: AgentConfig = serde_json::from_str("{}").unwrap();- assert!(cfg.agents_md_enabled);-}--#[test]-fn agents_md_enabled_roundtrips_when_disabled() {- let cfg: AgentConfig = serde_json::from_str(r#"{"agents_md_enabled": false}"#).unwrap();- assert!(!cfg.agents_md_enabled);-}diff --git a/crates/openhuman-core/src/core/all_extension_tests.rs b/crates/openhuman-core/src/core/all_extension_tests.rsdeleted file mode 100644index 4cdf27d727..0000000000--- a/crates/openhuman-core/src/core/all_extension_tests.rs+++ /dev/null@@ -1,112 +0,0 @@-use super::*;--fn ext_controller(namespace: &'static str, function: &'static str) -> RegisteredController {- fn handler(_params: Map<String, serde_json::Value>) -> ControllerFuture {- Box::pin(async { Ok(serde_json::json!({"ext": true})) })- }- RegisteredController {- schema: schema(namespace, function, vec![]),- handler,- }-}--/// An extension's controllers are first-class for every lookup: schema,-/// dispatch, method routing, capability facts and the namespace description.-#[tokio::test]-async fn registry_extension_is_visible_to_every_lookup_and_dispatches() {- register_controller_extension(ControllerExtension {- group: DomainGroup::Hosted,- controllers: vec![ext_controller("ext_probe", "ping")],- namespaces: &[("ext_probe", "Registry extension probe.")],- })- .expect("register extension");-- assert_eq!(- rpc_method_from_parts("ext_probe", "ping").as_deref(),- Some("openhuman.ext_probe_ping")- );- assert_eq!(capability_for_parts("ext_probe", "ping"), Some(None));- assert_eq!(- capability_for_rpc_method("openhuman.ext_probe_ping"),- Some(None)- );- assert!(schema_for_rpc_method("openhuman.ext_probe_ping").is_some());- assert!(all_controller_schemas()- .iter()- .any(|s| s.namespace == "ext_probe" && s.function == "ping"));- assert_eq!(- namespace_description("ext_probe"),- Some("Registry extension probe.")- );-- let result = try_invoke_registered_rpc("openhuman.ext_probe_ping", Map::new())- .await- .expect("extension method is dispatchable")- .expect("handler succeeds");- assert_eq!(result, serde_json::json!({"ext": true}));-}--/// Re-registering the identical set is a no-op; a *colliding* set (a built-in-/// method) is refused by the same drift guard the boot registry passes.-#[test]-fn registry_extension_is_idempotent_and_refuses_collisions() {- let ext = || ControllerExtension {- group: DomainGroup::Hosted,- controllers: vec![ext_controller("ext_idem", "once")],- namespaces: &[("ext_idem", "Idempotency probe.")],- };- register_controller_extension(ext()).expect("first registration");- register_controller_extension(ext()).expect("identical re-registration is a no-op");- let count = {- let view = registry_view();- view.iter()- .filter(|g| g.controller.schema.namespace == "ext_idem")- .count()- };- assert_eq!(count, 1, "no duplicate rows after re-registration");-- // `memory.list_files`-style collision with a built-in: pick any built-in.- let builtin = registry()- .first()- .expect("built-in registry is non-empty")- .controller- .schema- .clone();- let err = register_controller_extension(ControllerExtension {- group: DomainGroup::Hosted,- controllers: vec![ext_controller(builtin.namespace, builtin.function)],- namespaces: &[],- })- .expect_err("shadowing a built-in method must be refused");- assert!(err.contains("duplicate"), "{err}");-}--/// The ambient `DomainSet` gates extension controllers through their group,-/// exactly like built-ins: with `hosted: false` the method is unknown.-#[tokio::test]-async fn registry_extension_is_gated_by_its_domain_group() {- register_controller_extension(ControllerExtension {- group: DomainGroup::Hosted,- controllers: vec![ext_controller("ext_gate", "ping")],- namespaces: &[],- })- .expect("register extension");-- let mut domains = DomainSet::full();- domains.hosted = false;- let ctx = CoreContext::for_test(domains, None);- let hidden = CoreContext::scope(ctx, async {- (- try_invoke_registered_rpc("openhuman.ext_gate_ping", Map::new())- .await- .is_none(),- schema_for_rpc_method("openhuman.ext_gate_ping").is_none(),- )- })- .await;- assert_eq!(- hidden,- (true, true),- "hosted: false must hide the extension"- );-}diff --git a/crates/openhuman-core/src/core/runtime/context_tests.rs b/crates/openhuman-core/src/core/runtime/context_tests.rsindex 4f2ae9df32..dfaef14494 100644--- a/crates/openhuman-core/src/core/runtime/context_tests.rs+++ b/crates/openhuman-core/src/core/runtime/context_tests.rs@@ -381,3 +381,6 @@ fn degraded_context_rejects_workspace_bound_stores() {"unexpected error: {err}");}++#[path = "context_turn_origin_tests.rs"]+mod turn_origin_tests;diff --git a/crates/openhuman-core/src/integrations/composio/ops/pass_budget_tests.rs b/crates/openhuman-core/src/integrations/composio/ops/pass_budget_tests.rsdeleted file mode 100644index e2a8037a44..0000000000--- a/crates/openhuman-core/src/integrations/composio/ops/pass_budget_tests.rs+++ /dev/null@@ -1,286 +0,0 @@-//! The budgeted drain the single-call sync entry points run (openhuman#6025).-//!-//! Scripted passes stand in for the connector: each test says what the-//! module would return per call and asserts which pass budgets were asked for-//! and what the aggregate reports.--use std::cell::RefCell;-use std::collections::VecDeque;--use super::super::providers_ops::{SyncPassOutcome, SYNC_PASS_MAX_ITEMS};-use super::{run_passes_within_budget, DrainFailure, SINGLE_CALL_ITEM_BUDGET};--fn pass(written: u32, more_pending: bool) -> SyncPassOutcome {- SyncPassOutcome {- records_read: written as usize,- written,- already_ingested: false,- more_pending,- message: None,- failure: None,- }-}--/// Drive the loop with a scripted connector; returns the outcome and the-/// per-pass budgets it asked for, in order.-async fn drive(- budget: u32,- script: Vec<Result<SyncPassOutcome, String>>,-) -> (Result<SyncPassOutcome, DrainFailure>, Vec<usize>) {- let script = RefCell::new(VecDeque::from(script));- let asked = RefCell::new(Vec::new());- let out = run_passes_within_budget(budget, |pass_budget| {- asked.borrow_mut().push(pass_budget);- let next = script- .borrow_mut()- .pop_front()- .expect("the loop asked for more passes than the script holds");- async move { next }- })- .await;- (out, asked.into_inner())-}--#[tokio::test]-async fn stops_when_the_connector_reports_the_end() {- // 320 records: one full pass, then a short one that says "done".- let (out, asked) = drive(- SINGLE_CALL_ITEM_BUDGET,- vec![Ok(pass(200, true)), Ok(pass(120, false))],- )- .await;- let out = out.expect("both passes succeed");- assert_eq!(asked, vec![SYNC_PASS_MAX_ITEMS, SYNC_PASS_MAX_ITEMS]);- assert_eq!(out.written, 320);- assert_eq!(out.records_read, 320);- assert!(!out.more_pending, "the last pass's word wins");-}--#[tokio::test]-async fn stops_when_the_budget_is_spent_and_says_more_is_pending() {- // An account bigger than the budget: 200 + 200 + the 100 remainder, then- // stop even though the connector still has more — that is the ceiling the- // single-call entry points always had, now in deadline-sized calls.- let (out, asked) = drive(- SINGLE_CALL_ITEM_BUDGET,- vec![- Ok(pass(200, true)),- Ok(pass(200, true)),- Ok(pass(100, true)),- ],- )- .await;- let out = out.expect("all passes succeed");- assert_eq!(asked, vec![SYNC_PASS_MAX_ITEMS, SYNC_PASS_MAX_ITEMS, 100]);- assert_eq!(out.written, SINGLE_CALL_ITEM_BUDGET);- assert!(- out.more_pending,- "the caller must learn the account is not drained"- );-}--#[tokio::test]-async fn a_small_account_is_still_one_pass() {- let (out, asked) = drive(SINGLE_CALL_ITEM_BUDGET, vec![Ok(pass(37, false))]).await;- let out = out.expect("one pass succeeds");- assert_eq!(asked, vec![SYNC_PASS_MAX_ITEMS]);- assert_eq!(out.written, 37);- assert!(!out.more_pending);-}--#[tokio::test]-async fn a_pass_error_ends_the_run_with_that_error_and_the_earlier_writes() {- let (out, asked) = drive(- SINGLE_CALL_ITEM_BUDGET,- vec![Ok(pass(200, true)), Err("module went away".to_string())],- )- .await;- // The first pass's 200 records are committed whatever the second did, so- // the run's history row reports them (openhuman#6257).- assert_eq!(- out.unwrap_err(),- DrainFailure {- error: "module went away".to_string(),- written: 200,- }- );- assert_eq!(asked.len(), 2, "no pass is attempted after the failure");-}--#[tokio::test]-async fn a_first_pass_error_reports_nothing_written() {- let (out, asked) = drive(- SINGLE_CALL_ITEM_BUDGET,- vec![Err("connector refused the call".to_string())],- )- .await;- assert_eq!(- out.unwrap_err(),- DrainFailure {- error: "connector refused the call".to_string(),- written: 0,- }- );- assert_eq!(asked.len(), 1);-}--#[tokio::test]-async fn already_ingested_holds_only_when_every_pass_was_a_no_op() {- let noop = SyncPassOutcome {- records_read: 200,- written: 0,- already_ingested: true,- more_pending: true,- message: None,- failure: None,- };- let last = SyncPassOutcome {- more_pending: false,- ..noop.clone()- };- let (out, _) = drive(SINGLE_CALL_ITEM_BUDGET, vec![Ok(noop.clone()), Ok(last)]).await;- let out = out.expect("passes succeed");- assert!(out.already_ingested, "two no-op passes are a no-op run");- assert_eq!(out.records_read, 400);- assert_eq!(out.written, 0);-- let (out, _) = drive(SINGLE_CALL_ITEM_BUDGET, vec![Ok(noop), Ok(pass(5, false))]).await;- assert!(- !out.expect("passes succeed").already_ingested,- "one write makes it a run that wrote"- );-}--#[tokio::test]-async fn the_last_pass_note_wins_present_or_absent() {- let noted = SyncPassOutcome {- message: Some(" daily request budget spent ".to_string()),- ..pass(200, true)- };- let noted = SyncPassOutcome {- more_pending: false,- ..noted- };- let (out, _) = drive(- SINGLE_CALL_ITEM_BUDGET,- vec![Ok(pass(200, true)), Ok(noted)],- )- .await;- assert_eq!(- out.expect("passes succeed").message.as_deref(),- Some(" daily request budget spent "),- "the note rides through untouched; the stage detail trims it"- );-- let noted = SyncPassOutcome {- message: Some("stopped short".to_string()),- ..pass(200, true)- };- let (out, _) = drive(- SINGLE_CALL_ITEM_BUDGET,- vec![Ok(noted), Ok(pass(10, false))],- )- .await;- assert_eq!(- out.expect("passes succeed").message,- None,- "a pass that completes cleanly must not inherit an earlier pass's note"- );-}--#[tokio::test]-async fn the_budget_counts_records_read_not_records_written() {- // Everything the module returns is already ingested, and it keeps saying- // more is pending. The old single call fetched 500 and stopped; so does- // this — charging the budget by writes would ask forever.- let noop = SyncPassOutcome {- records_read: 200,- written: 0,- already_ingested: true,- more_pending: true,- message: None,- failure: None,- };- let (out, asked) = drive(- SINGLE_CALL_ITEM_BUDGET,- vec![- Ok(noop.clone()),- Ok(noop.clone()),- Ok(SyncPassOutcome {- records_read: 100,- ..noop- }),- ],- )- .await;- let out = out.expect("passes succeed");- assert_eq!(asked, vec![SYNC_PASS_MAX_ITEMS, SYNC_PASS_MAX_ITEMS, 100]);- assert_eq!(out.records_read, 500);- assert_eq!(out.written, 0);- assert!(out.more_pending);-}--#[tokio::test]-async fn a_pass_that_reads_nothing_ends_the_run() {- // "More pending" with an empty page cannot be acted on: asking again- // would fetch the same nothing. One pass, then stop.- let empty = SyncPassOutcome {- records_read: 0,- written: 0,- already_ingested: false,- more_pending: true,- message: None,- failure: None,- };- let (out, asked) = drive(SINGLE_CALL_ITEM_BUDGET, vec![Ok(empty)]).await;- let out = out.expect("the pass succeeds");- assert_eq!(asked.len(), 1);- assert_eq!(out.records_read, 0);- assert!(out.more_pending, "the module's own word is still reported");-}--#[tokio::test]-async fn a_pass_the_connector_reports_as_failed_ends_the_run_with_its_reason() {- // openhuman#6255: a failed pass is not "more pending". The pages it read- // before its page failed are committed, so they count toward the written- // total, and the drain stops instead of asking the failing connector again.- let failed = SyncPassOutcome {- failure: Some("GITHUB_SEARCH_ISSUES_AND_PULL_REQUESTS failed".to_string()),- ..pass(40, false)- };- let (out, asked) = drive(- SINGLE_CALL_ITEM_BUDGET,- vec![Ok(pass(200, true)), Ok(failed)],- )- .await;- assert_eq!(- out.unwrap_err(),- DrainFailure {- error: "GITHUB_SEARCH_ISSUES_AND_PULL_REQUESTS failed".to_string(),- written: 240,- }- );- assert_eq!(- asked.len(),- 2,- "a failed pass is not retried within the call"- );-}--#[tokio::test]-async fn a_failed_pass_that_read_nothing_is_still_a_failure() {- // The read-nothing stop would otherwise end this drain as a quiet success.- let failed = SyncPassOutcome {- failure: Some("the github connector stopped without saying why".to_string()),- ..SyncPassOutcome::default()- };- let (out, asked) = drive(SINGLE_CALL_ITEM_BUDGET, vec![Ok(failed)]).await;- assert_eq!(- out.unwrap_err(),- DrainFailure {- error: "the github connector stopped without saying why".to_string(),- written: 0,- }- );- assert_eq!(asked.len(), 1);-}diff --git a/crates/openhuman-core/src/mcp/server/tools_tests.rs b/crates/openhuman-core/src/mcp/server/tools_tests.rsindex e562c48404..26a3914f2b 100644--- a/crates/openhuman-core/src/mcp/server/tools_tests.rs+++ b/crates/openhuman-core/src/mcp/server/tools_tests.rs@@ -15,3 +15,5 @@ fn list_tools_result_for_config(config: &crate::config::Config) -> Value {mod dispatch_tests;#[path = "tools_tests_params_and_specs_tests.rs"]mod params_and_specs_tests;+#[path = "tools_tests_tag_and_dispatch_tests.rs"]+mod tag_and_dispatch_tests;