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
chore: clean up formatting and reorganize test modules
Steven Enamakele79e4ab93f70
diff --git a/crates/openhuman-app/src/mcp_commands_tests.rs b/crates/openhuman-app/src/mcp_commands_tests.rsindex d6407a0424..bc6a2de60b 100644--- a/crates/openhuman-app/src/mcp_commands_tests.rs+++ b/crates/openhuman-app/src/mcp_commands_tests.rs@@ -6,8 +6,7 @@ use super::*;#[test]fn config_path_claude_desktop_macos() {- let path =- config_path_for_client("claude-desktop", "macos").expect("should resolve on macos");+ let path = config_path_for_client("claude-desktop", "macos").expect("should resolve on macos");let s = path.display().to_string();assert!(s.contains("Library/Application Support/Claude/claude_desktop_config.json"),@@ -17,8 +16,7 @@ fn config_path_claude_desktop_macos() {#[test]fn config_path_claude_desktop_linux() {- let path =- config_path_for_client("claude-desktop", "linux").expect("should resolve on linux");+ let path = config_path_for_client("claude-desktop", "linux").expect("should resolve on linux");let s = path.display().to_string();assert!(s.contains(".config/Claude/claude_desktop_config.json"),@@ -109,9 +107,7 @@ fn binary_path_result_contains_openhuman_core() {// Acceptable in a clean CI checkout where the binary hasn't// been built yet. The error must be descriptive.assert!(- e.contains("openhuman-core")- || e.contains("current_exe")- || e.contains("target"),+ e.contains("openhuman-core") || e.contains("current_exe") || e.contains("target"),"error message should reference the binary or path: {e}");}diff --git a/crates/openhuman-app/src/process_kill_tests.rs b/crates/openhuman-app/src/process_kill_tests.rsindex 6331562334..ac794a4c5f 100644--- a/crates/openhuman-app/src/process_kill_tests.rs+++ b/crates/openhuman-app/src/process_kill_tests.rs@@ -2,7 +2,6 @@use super::*;-#[test]fn is_protected_windows_pid_matches_kernel_pids() {assert!(is_protected_windows_pid(0));diff --git a/crates/openhuman-app/src/window_state_tests.rs b/crates/openhuman-app/src/window_state_tests.rsindex 554dcb19ee..9bb8911351 100644--- a/crates/openhuman-app/src/window_state_tests.rs+++ b/crates/openhuman-app/src/window_state_tests.rs@@ -424,8 +424,7 @@ fn center_origin_after_min_floor_stays_in_work_area() {centered_x < work_area.x,"precondition: naive center should land off-screen");- let (x, y, w, h) =- clamp_to_work_area(centered_x, centered_y, clamped_w, clamped_h, work_area);+ let (x, y, w, h) = clamp_to_work_area(centered_x, centered_y, clamped_w, clamped_h, work_area);assert_eq!((x, y), (work_area.x, work_area.y));assert_eq!((w, h), (clamped_w, clamped_h));}diff --git a/crates/openhuman-app/src/workspace_paths_tests.rs b/crates/openhuman-app/src/workspace_paths_tests.rsindex e2d47a0858..378172a1ad 100644--- a/crates/openhuman-app/src/workspace_paths_tests.rs+++ b/crates/openhuman-app/src/workspace_paths_tests.rs@@ -73,8 +73,7 @@ fn preview_workspace_text_from_root_reads_utf8_text() {let workspace = tempdir().unwrap();fs::write(workspace.path().join("readme.md"), "# Hello").unwrap();- let preview =- preview_workspace_text_from_root(workspace.path(), "readme.md", 1024).unwrap();+ let preview = preview_workspace_text_from_root(workspace.path(), "readme.md", 1024).unwrap();assert_eq!(preview.path, "readme.md");assert_eq!(preview.contents, "# Hello");diff --git a/crates/openhuman-core/src/api/config_tests.rs b/crates/openhuman-core/src/api/config_tests.rsnew file mode 100644index 0000000000..9196e59777--- /dev/null+++ b/crates/openhuman-core/src/api/config_tests.rs@@ -0,0 +1,643 @@+use std::sync::MutexGuard;++use super::*;++// ── Test infrastructure ───────────────────────────────────────────────────++/// Serialises all env-mutating tests via the crate-wide backend env lock+/// (see [`super::backend_env_test_lock`]) — module-local locks cannot+/// stop other modules' tests from racing on the same process globals.+fn env_lock() -> MutexGuard<'static, ()> {+ super::backend_env_test_lock()+}++/// RAII guard that captures the current values of the four backend env+/// vars, removes them, and restores them on drop — even if the test panics.+struct EnvSnapshot {+ vars: [(&'static str, Option<String>); 4],+}++impl EnvSnapshot {+ fn clear_backend_env() -> Self {+ let keys = [+ "BACKEND_URL",+ "VITE_BACKEND_URL",+ APP_ENV_VAR,+ VITE_APP_ENV_VAR,+ ];+ let vars = keys.map(|k| (k, std::env::var(k).ok()));+ for (k, _) in &vars {+ std::env::remove_var(k);+ }+ Self { vars }+ }+}++impl Drop for EnvSnapshot {+ fn drop(&mut self) {+ for (key, value) in &self.vars {+ match value {+ Some(v) => std::env::set_var(key, v),+ None => std::env::remove_var(key),+ }+ }+ }+}++/// The URL that should be used as the backend base when no config override+/// is present and the runtime env has been cleared for the test.+fn fallback_backend_base_for_current_build() -> String {+ api_base_from_env().unwrap_or_else(|| {+ default_api_base_url_for_env(app_env_from_env().as_deref()).to_string()+ })+}++// ── api_url ───────────────────────────────────────────────────────────────++#[test]+fn api_url_empty_path_returns_normalized_base() {+ assert_eq!(+ api_url("https://api.tinyhumans.ai", ""),+ "https://api.tinyhumans.ai"+ );+ assert_eq!(+ api_url("https://api.tinyhumans.ai/", ""),+ "https://api.tinyhumans.ai"+ );+ assert_eq!(+ api_url(" https://api.tinyhumans.ai/ ", ""),+ "https://api.tinyhumans.ai"+ );+}++#[test]+fn api_url_absolute_path_replaces_base_path() {+ // Regression: a base with an inference path baked in must not corrupt+ // /agent-integrations/* calls.+ assert_eq!(+ api_url(+ "https://api.tinyhumans.ai/openai/v1/chat/completions",+ "/agent-integrations/composio/toolkits",+ ),+ "https://api.tinyhumans.ai/agent-integrations/composio/toolkits"+ );+}++#[test]+fn api_url_clean_base_joins_cleanly() {+ let expected = "https://api.tinyhumans.ai/agent-integrations/composio/toolkits";+ assert_eq!(+ api_url(+ "https://api.tinyhumans.ai",+ "/agent-integrations/composio/toolkits"+ ),+ expected+ );+ assert_eq!(+ api_url(+ "https://api.tinyhumans.ai/",+ "/agent-integrations/composio/toolkits"+ ),+ expected+ );+}++#[test]+fn api_url_preserves_query_string_on_path() {+ assert_eq!(+ api_url(+ "https://api.tinyhumans.ai",+ "/agent-integrations/composio/tools?toolkits=gmail"+ ),+ "https://api.tinyhumans.ai/agent-integrations/composio/tools?toolkits=gmail"+ );+}++#[test]+fn api_url_unparseable_base_falls_back_to_concat() {+ assert_eq!(api_url("not a url", "/x"), "not a url/x");+ assert_eq!(api_url("not a url/", "/x"), "not a url/x");+}++#[test]+fn api_url_with_lm_studio_base_joins_correctly() {+ // LM Studio URL must not reach effective_backend_api_url in practice+ // (it redirects), but api_url itself must not panic and the result+ // must use the correct host root.+ assert_eq!(+ api_url("http://localhost:1234/v1", "/agent-integrations/foo"),+ "http://localhost:1234/agent-integrations/foo"+ );+}++#[test]+fn api_url_multiple_trailing_slashes_on_base_are_stripped() {+ assert_eq!(+ api_url("https://api.tinyhumans.ai///", "/v1/foo"),+ "https://api.tinyhumans.ai/v1/foo"+ );+}++#[test]+fn api_url_relative_path_without_leading_slash_does_not_panic() {+ // Documented edge-case: relative paths are resolved RFC 3986-style+ // (last base segment dropped). The exact result depends on base+ // structure; we just pin the no-panic contract.+ assert!(!api_url("https://api.tinyhumans.ai", "relative").is_empty());+}++// ── normalize_api_base_url ────────────────────────────────────────────────++#[test]+fn normalize_strips_trailing_slashes_and_whitespace() {+ assert_eq!(+ normalize_api_base_url("https://api.tinyhumans.ai/"),+ "https://api.tinyhumans.ai"+ );+ assert_eq!(+ normalize_api_base_url("https://api.tinyhumans.ai///"),+ "https://api.tinyhumans.ai"+ );+ assert_eq!(+ normalize_api_base_url(" https://api.tinyhumans.ai "),+ "https://api.tinyhumans.ai"+ );+ assert_eq!(+ normalize_api_base_url(" https://api.tinyhumans.ai/ "),+ "https://api.tinyhumans.ai"+ );+}++#[test]+fn normalize_preserves_mid_path() {+ assert_eq!(+ normalize_api_base_url("https://api.tinyhumans.ai/v2"),+ "https://api.tinyhumans.ai/v2"+ );+}++#[test]+fn normalize_empty_string_returns_empty() {+ assert_eq!(normalize_api_base_url(""), "");+}++// ── normalize_backend_api_base_url ────────────────────────────────────────++#[test]+fn normalize_backend_strips_inference_path() {+ assert_eq!(+ normalize_backend_api_base_url("https://api.tinyhumans.ai/openai/v1/chat/completions"),+ "https://api.tinyhumans.ai"+ );+}++#[test]+fn normalize_backend_handles_schemeless_input() {+ // Sentry OPENHUMAN-TAURI-H6 / issue #2075.+ assert_eq!(+ normalize_backend_api_base_url("api.tinyhumans.ai/openai/v1/chat/completions"),+ "https://api.tinyhumans.ai"+ );+}++#[test]+fn normalize_backend_passes_through_clean_root() {+ assert_eq!(+ normalize_backend_api_base_url("https://api.tinyhumans.ai/"),+ "https://api.tinyhumans.ai"+ );+}++#[test]+fn normalize_backend_empty_string_is_idempotent() {+ assert_eq!(normalize_backend_api_base_url(""), "");+}++// ── app / api env resolution ──────────────────────────────────────────────++#[test]+fn staging_env_resolves_to_staging_url() {+ assert_eq!(+ default_api_base_url_for_env(Some("staging")),+ DEFAULT_STAGING_API_BASE_URL+ );+ assert!(is_staging_app_env(Some("STAGING")));+}++#[test]+fn non_staging_env_resolves_to_production_url() {+ assert_eq!(+ default_api_base_url_for_env(Some("production")),+ DEFAULT_API_BASE_URL+ );+ assert_eq!(default_api_base_url_for_env(None), DEFAULT_API_BASE_URL);+ assert!(!is_staging_app_env(Some("development")));+}++#[test]+fn app_env_from_env_reads_runtime_var() {+ // Setting APP_ENV to "staging" flips `default_root_dir_name()` to+ // `.openhuman-staging` process-wide, which breaks any concurrent test+ // resolving the root openhuman dir. Hold the crate-wide env lock too,+ // in the established order (TEST_ENV_LOCK before the backend lock).+ let _env_guard = crate::config::TEST_ENV_LOCK+ .lock()+ .unwrap_or_else(|e| e.into_inner());+ let _guard = env_lock();+ let prev = std::env::var(APP_ENV_VAR).ok();+ std::env::set_var(APP_ENV_VAR, "staging");+ let result = app_env_from_env();+ match prev {+ Some(v) => std::env::set_var(APP_ENV_VAR, v),+ None => std::env::remove_var(APP_ENV_VAR),+ }+ assert_eq!(result.as_deref(), Some("staging"));+}++#[test]+fn app_env_empty_primary_falls_through_to_secondary() {+ // Same staging-root hazard as `app_env_from_env_reads_runtime_var`.+ let _env_guard = crate::config::TEST_ENV_LOCK+ .lock()+ .unwrap_or_else(|e| e.into_inner());+ let _guard = env_lock();+ let prev_p = std::env::var(APP_ENV_VAR).ok();+ let prev_s = std::env::var(VITE_APP_ENV_VAR).ok();+ std::env::set_var(APP_ENV_VAR, "");+ std::env::set_var(VITE_APP_ENV_VAR, "staging");+ let result = app_env_from_env();+ match prev_p {+ Some(v) => std::env::set_var(APP_ENV_VAR, v),+ None => std::env::remove_var(APP_ENV_VAR),+ }+ match prev_s {+ Some(v) => std::env::set_var(VITE_APP_ENV_VAR, v),+ None => std::env::remove_var(VITE_APP_ENV_VAR),+ }+ assert_eq!(result.as_deref(), Some("staging"));+}++#[test]+fn api_base_from_env_reads_runtime_var() {+ let _guard = env_lock();+ let prev = std::env::var("BACKEND_URL").ok();+ std::env::set_var("BACKEND_URL", "https://staging-api.tinyhumans.ai/");+ let result = api_base_from_env();+ match prev {+ Some(v) => std::env::set_var("BACKEND_URL", v),+ None => std::env::remove_var("BACKEND_URL"),+ }+ assert_eq!(result.as_deref(), Some("https://staging-api.tinyhumans.ai"));+}++#[test]+fn api_base_empty_primary_falls_through_to_secondary() {+ let _guard = env_lock();+ let prev_p = std::env::var("BACKEND_URL").ok();+ let prev_s = std::env::var("VITE_BACKEND_URL").ok();+ std::env::set_var("BACKEND_URL", "");+ std::env::set_var("VITE_BACKEND_URL", "https://staging-api.tinyhumans.ai/");+ let result = api_base_from_env();+ match prev_p {+ Some(v) => std::env::set_var("BACKEND_URL", v),+ None => std::env::remove_var("BACKEND_URL"),+ }+ match prev_s {+ Some(v) => std::env::set_var("VITE_BACKEND_URL", v),+ None => std::env::remove_var("VITE_BACKEND_URL"),+ }+ assert_eq!(result.as_deref(), Some("https://staging-api.tinyhumans.ai"));+}++// ── looks_like_local_ai_endpoint ─────────────────────────────────────────++#[test]+fn local_ai_matches_loopback_hosts() {+ assert!(looks_like_local_ai_endpoint("http://127.0.0.1:11434/v1"));+ assert!(looks_like_local_ai_endpoint(+ "http://127.0.0.1:8080/v1/chat/completions"+ ));+ assert!(looks_like_local_ai_endpoint("http://localhost:11434/v1"));+ assert!(looks_like_local_ai_endpoint("http://[::1]:11434"));+ assert!(looks_like_local_ai_endpoint("http://0.0.0.0:11434/v1"));+}++#[test]+fn local_ai_matches_chat_completions_path_on_any_host() {+ assert!(looks_like_local_ai_endpoint(+ "http://203.0.113.5:8080/v1/chat/completions"+ ));+ assert!(looks_like_local_ai_endpoint(+ "https://my-ollama.example/v1/completions"+ ));+}++#[test]+fn local_ai_rejects_bare_loopback_with_random_port() {+ assert!(!looks_like_local_ai_endpoint("http://127.0.0.1:54321"));+ assert!(!looks_like_local_ai_endpoint("http://127.0.0.1:42000/"));+ assert!(!looks_like_local_ai_endpoint("http://localhost:33333"));+ assert!(!looks_like_local_ai_endpoint("http://[::1]:51234"));+}++#[test]+fn local_ai_matches_private_lan_hosts() {+ assert!(looks_like_local_ai_endpoint(+ "http://192.168.1.100:11434/v1"+ ));+ assert!(looks_like_local_ai_endpoint("http://10.0.0.5:8080/v1"));+ assert!(looks_like_local_ai_endpoint("http://172.16.0.42:8000"));+}++#[test]+fn local_ai_rejects_real_backends() {+ assert!(!looks_like_local_ai_endpoint("https://api.tinyhumans.ai"));+ assert!(!looks_like_local_ai_endpoint(+ "https://staging-api.tinyhumans.ai"+ ));+ // OpenAI public API exposes /v1 as a version prefix — must NOT match.+ assert!(!looks_like_local_ai_endpoint("https://api.openai.com/v1"));+ assert!(!looks_like_local_ai_endpoint(+ "https://my-backend.example/v1"+ ));+}++#[test]+fn local_ai_rejects_substring_path_false_positives() {+ // Earlier version used `contains` — these are the regressions it caused.+ assert!(!looks_like_local_ai_endpoint(+ "https://real-backend.example/audit/v1/chat/completions-logs"+ ));+ assert!(!looks_like_local_ai_endpoint(+ "https://real-backend.example/v1/chat/completions/history"+ ));+ assert!(!looks_like_local_ai_endpoint(+ "https://real-backend.example/v1/completions-archive"+ ));+}++#[test]+fn local_ai_handles_garbage_input() {+ assert!(!looks_like_local_ai_endpoint(""));+ assert!(!looks_like_local_ai_endpoint(" "));+ assert!(!looks_like_local_ai_endpoint("not a url"));+ assert!(!looks_like_local_ai_endpoint("/v1/chat/completions")); // relative — must not panic+}++#[test]+fn local_ai_matches_lm_studio_default_port() {+ assert!(looks_like_local_ai_endpoint("http://localhost:1234"));+ assert!(looks_like_local_ai_endpoint("http://127.0.0.1:1234"));+ assert!(looks_like_local_ai_endpoint(+ "http://127.0.0.1:1234/v1/chat/completions"+ ));+}++#[test]+fn local_ai_matches_v1_subpath_on_loopback() {+ assert!(looks_like_local_ai_endpoint(+ "http://localhost:11434/v1/models"+ ));+ assert!(looks_like_local_ai_endpoint(+ "http://127.0.0.1:8080/v1/embeddings"+ ));+}++// ── openhuman_backend detection ───────────────────────────────────────────++#[test]+fn openhuman_backend_detection_accepts_hosted_api_paths() {+ assert!(looks_like_openhuman_backend_endpoint(+ "https://api.tinyhumans.ai/openai/v1/chat/completions"+ ));+ assert!(looks_like_openhuman_backend_endpoint(+ "https://staging-api.tinyhumans.ai/openai/v1/chat/completions"+ ));+ assert!(!looks_like_openhuman_backend_endpoint(+ "https://openrouter.ai/api/v1/chat/completions"+ ));+ assert!(!looks_like_openhuman_backend_endpoint(+ "http://localhost:1234/v1/chat/completions"+ ));+}++// ── effective_backend_api_url ─────────────────────────────────────────────++#[test]+fn backend_url_handles_llm_endpoint_overrides() {+ let _guard = env_lock();+ let _env = EnvSnapshot::clear_backend_env();+ let fallback = fallback_backend_base_for_current_build();++ let cases: &[(&str, &str)] = &[+ (+ "https://api.tinyhumans.ai/openai/v1/chat/completions",+ "https://api.tinyhumans.ai",+ ),+ ("http://localhost:11434/v1/chat/completions", &fallback),+ ("https://api.tinyhumans.ai", "https://api.tinyhumans.ai"),+ (+ "https://api.tinyhumans.ai/openai/v1/",+ "https://api.tinyhumans.ai",+ ),+ ("https://openrouter.ai/api/v1/chat/completions", &fallback),+ ];++ for (api_url, expected) in cases {+ assert_eq!(+ effective_backend_api_url(&Some(api_url.to_string())),+ *expected,+ "api_url = {api_url}"+ );+ }+}++#[test]+fn backend_url_falls_back_for_local_ai_override() {+ let _guard = env_lock();+ let _env = EnvSnapshot::clear_backend_env();+ let expected = fallback_backend_base_for_current_build();++ assert_eq!(+ effective_backend_api_url(&Some("http://127.0.0.1:11434/v1".to_string())),+ expected+ );+}++#[test]+fn backend_url_falls_back_for_cloud_inference_base() {+ // Regression: TAURI-RUST-HW1. A BYO user whose `api_url` is a public+ // cloud-inference provider's *canonical base* (no `/chat/completions`+ // path, public host) must NOT have backend domain calls routed there —+ // `GET /teams/me/usage` was 400ing against `openrouter.ai`.+ let _guard = env_lock();+ let _env = EnvSnapshot::clear_backend_env();+ let fallback = fallback_backend_base_for_current_build();++ let falls_back: &[&str] = &[+ "https://openrouter.ai/api/v1",+ "https://api.atlascloud.ai/v1",+ "https://api.openai.com/v1",+ "https://api.groq.com/openai/v1",+ "https://generativelanguage.googleapis.com/v1beta/openai",+ ];+ for api_url in falls_back {+ assert_eq!(+ effective_backend_api_url(&Some(api_url.to_string())),+ fallback,+ "cloud inference base must fall back: {api_url}"+ );+ }++ // Our own hosted backend still passes through (is_openhuman short-circuit),+ // but an UNKNOWN custom backend at a bare `/v1` base is now classified as+ // an OpenAI-compatible inference base (#4153, Signal 2) and falls back so+ // control-plane calls are not misrouted. A self-hosted backend must use a+ // non-`/v1` base (see the `my-openhuman.example.com` case) to keep routing.+ assert_eq!(+ effective_backend_api_url(&Some("https://api.tinyhumans.ai/v1".to_string())),+ "https://api.tinyhumans.ai",+ "openhuman backend host must pass through"+ );+ assert_eq!(+ effective_backend_api_url(&Some("https://my-backend.example/v1".to_string())),+ fallback,+ "unknown bare-/v1 base is an inference base and must fall back"+ );+}++#[test]+fn backend_url_falls_back_to_env_when_override_is_local_ai() {+ let _guard = env_lock();+ let _env = EnvSnapshot::clear_backend_env();+ std::env::set_var("BACKEND_URL", "https://staging-api.tinyhumans.ai/");++ assert_eq!(+ effective_backend_api_url(&Some(+ "http://127.0.0.1:8080/v1/chat/completions".to_string()+ )),+ "https://staging-api.tinyhumans.ai"+ );+}++#[test]+fn backend_url_keeps_real_backend_override() {+ assert_eq!(+ effective_backend_api_url(&Some("https://staging-api.tinyhumans.ai/".to_string())),+ "https://staging-api.tinyhumans.ai"+ );+}++#[test]+fn backend_url_without_override_matches_effective_api_url() {+ let _guard = env_lock();+ let _env = EnvSnapshot::clear_backend_env();+ assert_eq!(effective_backend_api_url(&None), effective_api_url(&None));+}++// ── GH #4153: remote managed inference providers parked in `api_url` ──────++#[test]+fn inference_provider_matches_known_remote_hosts() {+ // The hosts the #4058 `host` tag pinned the `/teams/me/usage` flood to.+ assert!(looks_like_inference_provider_endpoint(+ "https://openrouter.ai/api/v1"+ ));+ assert!(looks_like_inference_provider_endpoint(+ "https://api.openmodel.ai/v1"+ ));+ assert!(looks_like_inference_provider_endpoint(+ "https://api.atlascloud.ai/v1"+ ));+ // Other managed providers, apex and subdomain.+ assert!(looks_like_inference_provider_endpoint(+ "https://api.openai.com/v1"+ ));+ assert!(looks_like_inference_provider_endpoint(+ "https://api.groq.com/openai/v1"+ ));+ assert!(looks_like_inference_provider_endpoint(+ "https://api.mistral.ai"+ ));+}++#[test]+fn inference_provider_matches_bare_v1_base_on_unknown_host() {+ // An unknown OpenAI-compatible provider, recognised by its `/v1` base.+ assert!(looks_like_inference_provider_endpoint(+ "https://llm.unknown-provider.example/v1"+ ));+ assert!(looks_like_inference_provider_endpoint(+ "https://gw.example.test/api/v1/"+ ));+}++#[test]+fn inference_provider_excludes_openhuman_backend_and_plain_hosts() {+ // Our own hosted backend is a backend, even though it serves inference.+ assert!(!looks_like_inference_provider_endpoint(+ "https://api.tinyhumans.ai/openai/v1/chat/completions"+ ));+ assert!(!looks_like_inference_provider_endpoint(+ "https://staging-api.tinyhumans.ai/"+ ));+ // A custom self-hosted OpenHuman backend (no provider host, no `/v1`+ // base) must keep routing control-plane calls to itself.+ assert!(!looks_like_inference_provider_endpoint(+ "https://my-openhuman.example.com/"+ ));+ // Garbage / relative input never panics or matches.+ assert!(!looks_like_inference_provider_endpoint(""));+ assert!(!looks_like_inference_provider_endpoint("not a url"));+}++#[test]+fn backend_url_falls_back_for_remote_inference_provider_override() {+ // The core of #4153: `config.api_url` set to a managed inference+ // provider must NOT be used as the control-plane base; backend calls+ // fall back to the canonical default chain.+ let _guard = env_lock();+ let _env = EnvSnapshot::clear_backend_env();+ let expected = fallback_backend_base_for_current_build();++ assert_eq!(+ effective_backend_api_url(&Some("https://openrouter.ai/api/v1".to_string())),+ expected+ );+ assert_eq!(+ effective_backend_api_url(&Some("https://api.openmodel.ai/v1".to_string())),+ expected+ );+ assert_eq!(+ effective_backend_api_url(&Some("https://api.atlascloud.ai/v1".to_string())),+ expected+ );+}++#[test]+fn backend_url_falls_back_to_env_for_remote_inference_provider() {+ let _guard = env_lock();+ let _env = EnvSnapshot::clear_backend_env();+ std::env::set_var("BACKEND_URL", "https://staging-api.tinyhumans.ai/");++ assert_eq!(+ effective_backend_api_url(&Some("https://openrouter.ai/api/v1".to_string())),+ "https://staging-api.tinyhumans.ai"+ );+}++#[test]+fn backend_url_strips_inference_path_from_env() {+ // Regression: OPENHUMAN-TAURI-H6 / -HN, issue #2075.+ let _guard = env_lock();+ let _env = EnvSnapshot::clear_backend_env();+ std::env::set_var(+ "BACKEND_URL",+ "https://api.tinyhumans.ai/openai/v1/chat/completions",+ );++ assert_eq!(+ effective_backend_api_url(&None),+ "https://api.tinyhumans.ai"+ );+}diff --git a/crates/openhuman-core/src/memory/guard/test_support/provider_and_sync_impls.rs b/crates/openhuman-core/src/memory/guard/test_support/provider_and_sync_impls.rsnew file mode 100644index 0000000000..541cc95b55--- /dev/null+++ b/crates/openhuman-core/src/memory/guard/test_support/provider_and_sync_impls.rs@@ -0,0 +1,262 @@+//! `RecordingProvider`'s `SourceSink`, `Maintenance`, `SourceSync`, and+//! `CodingSessions` family implementations, plus the top-level+//! `MemoryProvider` impl that advertises every family through its `as_*`+//! accessors.+//!+//! Split out of the original `test_support.rs`; see [`super::fixtures`] for+//! `RecordingProvider`'s type and constructors. The read-heavy families+//! (`Retrieval`, `Episodic`, `Profile`, ...) and the typed-ingestion round+//! live in [`super::retrieval_and_ingest_impls`].++use crate::memory::api::capabilities::Capabilities;+use crate::memory::api::error::MemoryError;+use crate::memory::api::health::MemoryHealth;+use crate::memory::api::provider::operations::{+ MemoryAnswer, MemoryConversationIngest, MemoryDocumentIngest, MemoryEventIngest,+ MemoryLearningIngest,+};+use crate::memory::api::provider::sessions::{+ CodingSessionIngestReport, CodingSessionIngestRequest, CodingSessionSource,+};+use crate::memory::api::provider::sync::{+ RawArchiveCoverage, RawRebuildOutcome, SourceSyncState, SourceSyncStatus, SyncAuditEntry,+ SyncRunOutcome,+};+use crate::memory::api::provider::types::{IngestOutcome, MaintenanceReport, SourceItem};+use crate::memory::api::provider::{+ MemoryChunks, MemoryCodingSessions, MemoryDiff, MemoryDocuments, MemoryEntities,+ MemoryEpisodic, MemoryGoals, MemoryGraph, MemoryIngest, MemoryMaintenance, MemoryPeople,+ MemoryProfile, MemoryProvider, MemoryRetrieval, MemoryScoring, MemorySourceSink,+ MemorySourceSync, MemoryToolMemory, MemoryTree,+};+use crate::memory::api::types::MemoryTaint;+use async_trait::async_trait;++use super::fixtures::{Call, RecordingProvider};++#[async_trait]+impl MemorySourceSink for RecordingProvider {+ async fn accept_source_items(+ &self,+ _source_id: &str,+ _source_kind: &str,+ items: Vec<SourceItem>,+ taint: MemoryTaint,+ ) -> Result<IngestOutcome, MemoryError> {+ self.record(Call {+ method: "sources.accept_source_items".into(),+ content: items.first().map(|i| i.content.clone()),+ taint: Some(taint),+ scoped: None,+ });+ Ok(IngestOutcome::default())+ }++ async fn forget_source(&self, _source_id: &str) -> Result<u64, MemoryError> {+ self.record(Call::plain("sources.forget_source"));+ Ok(0)+ }+}++#[async_trait]+impl MemoryMaintenance for RecordingProvider {+ async fn reembed(&self) -> Result<MaintenanceReport, MemoryError> {+ self.record(Call::plain("maintenance.reembed"));+ Ok(MaintenanceReport::default())+ }++ async fn compact(&self) -> Result<MaintenanceReport, MemoryError> {+ self.record(Call::plain("maintenance.compact"));+ Ok(MaintenanceReport::default())+ }++ async fn consolidate(&self) -> Result<MaintenanceReport, MemoryError> {+ self.record(Call::plain("maintenance.consolidate"));+ Ok(MaintenanceReport::default())+ }++ async fn doctor(&self) -> Result<MaintenanceReport, MemoryError> {+ self.record(Call::plain("maintenance.doctor"));+ Ok(MaintenanceReport::default())+ }++ async fn diagnose(+ &self,+ ) -> Result<crate::memory::api::provider::diagnosis::Diagnosis, MemoryError> {+ self.record(Call::plain("maintenance.diagnose"));+ Ok(Default::default())+ }++ async fn degraded_state(+ &self,+ ) -> Result<crate::memory::api::provider::diagnosis::DegradedCapabilities, MemoryError>+ {+ self.record(Call::plain("maintenance.degraded_state"));+ Ok(Default::default())+ }+}++#[async_trait]+impl MemoryProvider for RecordingProvider {+ fn driver_id(&self) -> &str {+ "recording"+ }++ fn capabilities(&self) -> Capabilities {+ Capabilities::all()+ }++ async fn health(&self) -> MemoryHealth {+ MemoryHealth::Ready+ }++ fn as_ingest(&self) -> Option<&dyn MemoryIngest> {+ Some(self)+ }+ fn as_documents(&self) -> Option<&dyn MemoryDocuments> {+ Some(self)+ }+ fn as_tree(&self) -> Option<&dyn MemoryTree> {+ Some(self)+ }+ fn as_entities(&self) -> Option<&dyn MemoryEntities> {+ Some(self)+ }+ fn as_graph(&self) -> Option<&dyn MemoryGraph> {+ Some(self)+ }+ fn as_diff(&self) -> Option<&dyn MemoryDiff> {+ Some(self)+ }+ fn as_goals(&self) -> Option<&dyn MemoryGoals> {+ Some(self)+ }+ fn as_tool_memory(&self) -> Option<&dyn MemoryToolMemory> {+ Some(self)+ }+ fn as_sources(&self) -> Option<&dyn MemorySourceSink> {+ Some(self)+ }+ fn as_maintenance(&self) -> Option<&dyn MemoryMaintenance> {+ Some(self)+ }+ fn as_people(&self) -> Option<&dyn MemoryPeople> {+ Some(self)+ }+ fn as_chunks(&self) -> Option<&dyn MemoryChunks> {+ Some(self)+ }+ fn as_retrieval(&self) -> Option<&dyn MemoryRetrieval> {+ Some(self)+ }+ fn as_profile(&self) -> Option<&dyn MemoryProfile> {+ Some(self)+ }+ fn as_episodic(&self) -> Option<&dyn MemoryEpisodic> {+ Some(self)+ }+ fn as_source_sync(&self) -> Option<&dyn MemorySourceSync> {+ Some(self)+ }+ fn as_coding_sessions(&self) -> Option<&dyn MemoryCodingSessions> {+ Some(self)+ }+ fn as_scoring(&self) -> Option<&dyn MemoryScoring> {+ Some(self)+ }+ fn as_document_ingest(&self) -> Option<&dyn MemoryDocumentIngest> {+ Some(self)+ }+ fn as_conversation_ingest(&self) -> Option<&dyn MemoryConversationIngest> {+ Some(self)+ }+ fn as_learning_ingest(&self) -> Option<&dyn MemoryLearningIngest> {+ Some(self)+ }+ fn as_event_ingest(&self) -> Option<&dyn MemoryEventIngest> {+ Some(self)+ }+ fn as_answer(&self) -> Option<&dyn MemoryAnswer> {+ Some(self)+ }+}++// The two families tinymemory v1.7.0 added. `capabilities()` above answers+// `Capabilities::all()`, so a driver that advertises them and then hands back+// `None` from the accessor is exactly the inconsistency `audit_provider`+// exists to catch — the recorder has to serve them to stay honest.++#[async_trait]+impl MemorySourceSync for RecordingProvider {+ async fn run_connection_sync(+ &self,+ toolkit: &str,+ connection_id: &str,+ ) -> Result<SyncRunOutcome, MemoryError> {+ self.record(Call::plain("source_sync.run_connection_sync"));+ let _ = (toolkit, connection_id);+ Ok(SyncRunOutcome::default())+ }+ async fn source_sync_state(+ &self,+ toolkit: &str,+ connection_id: &str,+ ) -> Result<Option<SourceSyncState>, MemoryError> {+ self.record(Call::plain("source_sync.source_sync_state"));+ let _ = (toolkit, connection_id);+ Ok(None)+ }+ async fn sync_audit_log(+ &self,+ _limit: Option<usize>,+ ) -> Result<Vec<SyncAuditEntry>, MemoryError> {+ self.record(Call::plain("source_sync.sync_audit_log"));+ Ok(Vec::new())+ }+ async fn estimate_sync_cost_usd(+ &self,+ _input_tokens: u64,+ _output_tokens: u64,+ ) -> Result<f64, MemoryError> {+ self.record(Call::plain("source_sync.estimate_sync_cost_usd"));+ Ok(0.0)+ }+ async fn sync_statuses(&self) -> Result<Vec<SourceSyncStatus>, MemoryError> {+ self.record(Call::plain("source_sync.sync_statuses"));+ Ok(Vec::new())+ }+ async fn raw_archive_coverage(+ &self,+ tree_scope: &str,+ archive_source_id: &str,+ ) -> Result<RawArchiveCoverage, MemoryError> {+ self.record(Call::plain("source_sync.raw_archive_coverage"));+ let _ = (tree_scope, archive_source_id);+ Ok(RawArchiveCoverage::default())+ }+ async fn rebuild_from_raw_archive(+ &self,+ tree_scope: &str,+ archive_source_id: &str,+ ) -> Result<RawRebuildOutcome, MemoryError> {+ self.record(Call::plain("source_sync.rebuild_from_raw_archive"));+ let _ = (tree_scope, archive_source_id);+ Ok(RawRebuildOutcome::default())+ }+}++#[async_trait]+impl MemoryCodingSessions for RecordingProvider {+ async fn coding_session_status(&self) -> Result<Vec<CodingSessionSource>, MemoryError> {+ self.record(Call::plain("coding_sessions.coding_session_status"));+ Ok(Vec::new())+ }+ async fn ingest_coding_sessions(+ &self,+ _request: CodingSessionIngestRequest,+ ) -> Result<CodingSessionIngestReport, MemoryError> {+ self.record(Call::plain("coding_sessions.ingest_coding_sessions"));+ Ok(CodingSessionIngestReport::default())+ }+}+diff --git a/crates/openhuman-core/src/tools/impl/system/shell_tests.rs b/crates/openhuman-core/src/tools/impl/system/shell_tests.rsindex 2f45f5a10a..9880b67c83 100644--- a/crates/openhuman-core/src/tools/impl/system/shell_tests.rs+++ b/crates/openhuman-core/src/tools/impl/system/shell_tests.rs@@ -83,7 +83,7 @@ impl Drop for EnvGuard {}}-#[path = "shell_tests_part_01_tests.rs"]-mod part_01_tests;-#[path = "shell_tests_part_02_tests.rs"]-mod part_02_tests;+#[path = "shell_tests_schema_and_env_tests.rs"]+mod schema_and_env_tests;+#[path = "shell_tests_runtime_and_sandbox_tests.rs"]+mod runtime_and_sandbox_tests;diff --git a/crates/openhuman-core/src/voice/realtime_harness.rs b/crates/openhuman-core/src/voice/realtime_harness.rsindex a18e7372f3..f076b30de0 100644--- a/crates/openhuman-core/src/voice/realtime_harness.rs+++ b/crates/openhuman-core/src/voice/realtime_harness.rs@@ -36,7 +36,9 @@ use prompt::{should_arm_speak_back, spoken_delta, VOICE_READBACK_PREFIX,};#[cfg(test)]-use turn_handler::next_handoff_line;+use turn_handler::{next_handoff_line, VOICE_HANDOFF_LINES};+#[cfg(test)]+use crate::agent::progress::AgentProgress;#[cfg(test)]#[path = "realtime_harness_tests.rs"]