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: files changed crates/openhuman-core/src/agent/harness/definition/registry.rs,crates/openhuman
Steven Enamakelfb570df4af43
diff --git a/crates/openhuman-core/src/agent/harness/definition/registry.rs b/crates/openhuman-core/src/agent/harness/definition/registry.rsindex e820f3623c..a86e29e247 100644--- a/crates/openhuman-core/src/agent/harness/definition/registry.rs+++ b/crates/openhuman-core/src/agent/harness/definition/registry.rs@@ -6,6 +6,15 @@ use std::collections::HashMap;use std::path::Path;use std::sync::{Arc, OnceLock};+/// Whether two definitions serialise identically, which covers every+/// authored field (the process-local `source` and `graph` are not serialised).+fn same_definition(a: &AgentDefinition, b: &AgentDefinition) -> bool {+ match (serde_json::to_value(a), serde_json::to_value(b)) {+ (Ok(a), Ok(b)) => a == b,+ _ => false,+ }+}+/// In-memory registry of all known [`AgentDefinition`]s.////// One singleton instance is initialised at startup via@@ -108,14 +117,17 @@ impl AgentDefinitionRegistry {self.by_id.is_empty()}- /// Whether this registry is exactly the built-in set: the same ids as- /// [`Self::builtins_only`] and no definition loaded from a file or- /// synthesized from a user entry. SaaS boot refuses anything else.+ /// Whether this registry is exactly the built-in set: the same ids+ /// and contents as [`Self::builtins_only`], and no definition loaded from+ /// a file or synthesized from a user entry. SaaS boot refuses anything else.pub fn holds_builtins_only(&self) -> bool {let builtins = Self::builtins_only();self.len() == builtins.len()&& self.list().iter().all(|def| {- def.source == super::DefinitionSource::Builtin && builtins.get(&def.id).is_some()+ def.source == super::DefinitionSource::Builtin+ && builtins+ .get(&def.id)+ .is_some_and(|builtin| same_definition(def, builtin))})}diff --git a/crates/openhuman-core/src/agent/harness/definition/registry_tests.rs b/crates/openhuman-core/src/agent/harness/definition/registry_tests.rsindex c2fbf1b6dc..ba1c17cb6e 100644--- a/crates/openhuman-core/src/agent/harness/definition/registry_tests.rs+++ b/crates/openhuman-core/src/agent/harness/definition/registry_tests.rs@@ -74,3 +74,10 @@ fn a_file_sourced_override_is_not_builtins_only() {let registry = AgentDefinitionRegistry::builtins_only().with_definitions([overridden]);assert!(!registry.holds_builtins_only());}++#[test]+fn a_builtin_tagged_override_with_other_contents_is_not_builtins_only() {+ let registry = AgentDefinitionRegistry::builtins_only()+ .with_definitions([named("orchestrator", "replaced but still tagged Builtin")]);+ assert!(!registry.holds_builtins_only());+}diff --git a/crates/openhuman-core/src/security/policy/enforcement_scratch_dir_tests_tests.rs b/crates/openhuman-core/src/security/policy/enforcement_scratch_dir_tests_tests.rsindex 956e2a6bfe..e035b52399 100644--- a/crates/openhuman-core/src/security/policy/enforcement_scratch_dir_tests_tests.rs+++ b/crates/openhuman-core/src/security/policy/enforcement_scratch_dir_tests_tests.rs@@ -36,6 +36,8 @@ fn roots(saas: bool) -> Vec<String> {#[test]fn saas_policy_skips_the_shared_projects_and_scratch_grants() {+ // `OPENHUMAN_PROJECTS_DIR` is replaced by other tests under this lock.+ let _env = crate::config::TEST_ENV_LOCK.blocking_lock();let projects = crate::config::default_projects_dir().to_string_lossy().to_string();@@ -52,5 +54,9 @@ fn saas_policy_skips_the_shared_projects_and_scratch_grants() {let single = roots(false);assert!(single.contains(&projects));- assert!(single.contains(&scratch));+ // The scratch dir is only granted when it can be created safely (not a+ // symlink, hardenable permissions); that is host state, not policy.+ if ensure_openhuman_scratch_dir().is_some() {+ assert!(single.contains(&scratch));+ }}diff --git a/tests/cost_report_e2e.rs b/tests/cost_report_e2e.rsindex b7e5963d91..92422e343b 100644--- a/tests/cost_report_e2e.rs+++ b/tests/cost_report_e2e.rs@@ -59,12 +59,14 @@ async fn cost_reports_group_the_ledger_and_a_refuse_budget_stops_the_call() {let tracker = cost::try_global().expect("this process owns the global tracker");// Seed the ledger, oldest first.- let start = Utc::now() - Duration::seconds(CALLS.len() as i64 + 1);+ // Milliseconds apart, so the ledger stays inside the current budget month+ // even at a month boundary.+ let start = Utc::now() - Duration::milliseconds(CALLS.len() as i64 + 1);for (i, (model, thread, input, cached, cost_usd)) in CALLS.iter().enumerate() {let mut usage = TokenUsage::new(*model, *input, 10, 0.0, 0.0);usage.cached_input_tokens = *cached;usage.cost_usd = *cost_usd;- usage.timestamp = start + Duration::seconds(i as i64);+ usage.timestamp = start + Duration::milliseconds(i as i64);usage.scope.thread_id = Some((*thread).to_string());usage.scope.agent_id = Some("orchestrator".to_string());tracker.record_usage_unconditional(usage).expect("record");diff --git a/tests/saas_mode_e2e.rs b/tests/saas_mode_e2e.rsindex e9022eebec..6271310b50 100644--- a/tests/saas_mode_e2e.rs+++ b/tests/saas_mode_e2e.rs@@ -428,6 +428,24 @@ fn gateway_requests_run_under_the_named_users_agent() {assert_eq!(status, 401, "alice's signature does not cover bob: {body}");let (status, body) = user_rpc(&client, &base, BEARER, "bob", None, "core.ping");assert_eq!(status, 403, "bob is not provisioned: {body}");+ // A repeated signature header is refused, not resolved to the first value.+ {+ use openhuman_core::user_agents::gateway::{sign, USER_HEADER, USER_SIG_HEADER};+ let response = client+ .post(format!("{base}/rpc"))+ .bearer_auth(BEARER)+ .header(USER_HEADER, "alice")+ .header(USER_SIG_HEADER, sign(BEARER, "alice", now()))+ .header(USER_SIG_HEADER, sign(BEARER, "alice", now()))+ .json(&json!({ "jsonrpc": "2.0", "id": 1, "method": "core.ping", "params": {} }))+ .send()+ .expect("POST /rpc");+ assert_eq!(+ response.status().as_u16(),+ 400,+ "a repeated signature header"+ );+ }// Single-user surfaces are closed.for path in ["/events", "/events/domain", "/v1/models", "/dev/connect"] {