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(inference): add model gate tests
Steven Enamakel94de7a55e60a
diff --git a/crates/openhuman-core/src/inference/provider/factory_model_gate_tests.rs b/crates/openhuman-core/src/inference/provider/factory_model_gate_tests.rsnew file mode 100644index 0000000000..320ef991fb--- /dev/null+++ b/crates/openhuman-core/src/inference/provider/factory_model_gate_tests.rs@@ -0,0 +1,63 @@+use super::*;++#[tokio::test]+async fn turn_factory_checks_privacy_then_explicit_host_session_before_building_or_egress() {+ let _guard = crate::inference::inference_test_guard_async().await;+ let _env = crate::config::TEST_ENV_LOCK.lock().await;+ let tmp = tempfile::tempdir().expect("isolated workspace");+ let builds = install_test_managed_provider();+ let mut config = Config::default();+ config.workspace_dir = tmp.path().join("workspace");+ config.config_path = tmp.path().join("config.toml");+ let config = config;++ let ambient_library = crate::core::runtime::CoreContext::for_test_with_host_kind(+ crate::core::types::HostKind::Library,+ crate::core::runtime::DomainSet::full(),+ Some(tmp.path().join("library")),+ );+ let explicit_cli = crate::core::runtime::CoreContext::for_test_with_host_kind(+ crate::core::types::HostKind::Cli,+ crate::core::runtime::DomainSet::full(),+ Some(tmp.path().join("cli")),+ );+ let ctx = crate::core::runtime::DispatchCtx::new(explicit_cli);+ let egress = EgressLedger::per_turn();+ let factory = OpenHumanModelFactory {+ ctx: &ctx,+ config: &config,+ primary_provider: Some(PROVIDER_OPENHUMAN),+ egress: &egress,+ thread_id: None,+ };++ crate::core::runtime::CoreContext::scope(ambient_library, async {+ let _privacy = crate::security::live_policy::test_privacy_scope(+ crate::config::PrivacyMode::LocalOnly,+ );+ let privacy_error = tinyagents_harness::host::TurnModelSet::<()>::builder(+ &factory,+ &factory,+ "chat",+ )+ .primary_model_pin("hint:chat")+ .without_workload_tiers()+ .build()+ .expect_err("LocalOnly must reject managed inference before session lookup");+ assert!(privacy_error.to_string().contains("Local-only privacy mode"));+ })+ .await;++ let session_error = tinyagents_harness::host::TurnModelSet::<()>::builder(+ &factory,+ &factory,+ "chat",+ )+ .primary_model_pin("hint:chat")+ .without_workload_tiers()+ .build()+ .expect_err("explicit CLI dispatch must require a session despite ambient Library");+ assert!(session_error.to_string().contains("session"));+ assert!(builds.lock().expect("build counter").is_empty());+ assert!(egress.is_empty());+}diff --git a/crates/openhuman-core/src/inference/provider/factory_tests.rs b/crates/openhuman-core/src/inference/provider/factory_tests.rsindex e03ae768c2..e63c6d424d 100644--- a/crates/openhuman-core/src/inference/provider/factory_tests.rs+++ b/crates/openhuman-core/src/inference/provider/factory_tests.rs@@ -271,3 +271,5 @@ mod explicit_ctx_tests;mod managed_ledger_tests;#[path = "factory_route_resolution_tests.rs"]mod route_resolution_tests;+#[path = "factory_model_gate_tests.rs"]+mod model_gate_tests;