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
refactor(core): extract extension controller tests into a dedicated module
Steven Enamakel32476787fbdb
diff --git a/crates/openhuman-core/src/agent/learning/stability_detector_helpers.rs b/crates/openhuman-core/src/agent/learning/stability_detector_helpers.rsindex fa8769deb1..78d0b79c2b 100644--- a/crates/openhuman-core/src/agent/learning/stability_detector_helpers.rs+++ b/crates/openhuman-core/src/agent/learning/stability_detector_helpers.rs@@ -11,7 +11,9 @@ use fs2::FileExt;use crate::agent::learning::candidate::{self, CueFamily, FacetClass, LearningCandidate};use tinymemory_api::provider::{FacetState, FacetType, ProfileFacet, UserState};-use super::{class_budget, half_life, stability, RebuildState, TAU_EVICT, TAU_PROMOTE, TAU_PROVISIONAL};+use super::{+ class_budget, half_life, stability, RebuildState, TAU_EVICT, TAU_PROMOTE, TAU_PROVISIONAL,+};// ── The rebuild time ──────────────────────────────────────────────────────────@@ -172,7 +174,10 @@ pub(super) fn aggregate_stability(}/// Determine the dominant cue family (highest weight).-pub(super) fn dominant_cue(cands: &[LearningCandidate], _existing: Option<&ProfileFacet>) -> CueFamily {+pub(super) fn dominant_cue(+ cands: &[LearningCandidate],+ _existing: Option<&ProfileFacet>,+) -> CueFamily {cands.iter().max_by(|a, b| {@@ -200,7 +205,9 @@ pub(super) fn dominant_cue(cands: &[LearningCandidate], _existing: Option<&Profi/// domain knowledge, not engine storage, and belongs host-side with the rest of/// the learning subsystem. Tracked as stage 4 in/// `docs/specs/2026-08-13-memory-module-port.md`.-pub(super) fn evidence_to_contract(refs: &[candidate::EvidenceRef]) -> Vec<tinymemory_api::host::EvidenceRef> {+pub(super) fn evidence_to_contract(+ refs: &[candidate::EvidenceRef],+) -> Vec<tinymemory_api::host::EvidenceRef> {refs.iter().filter_map(|r| {serde_json::to_value(r)@@ -245,7 +252,10 @@ pub(super) fn merge_evidence_refs(}/// Total evidence count from candidates + existing row.-pub(super) fn total_evidence_count(cands: &[LearningCandidate], existing: Option<&ProfileFacet>) -> u32 {+pub(super) fn total_evidence_count(+ cands: &[LearningCandidate],+ existing: Option<&ProfileFacet>,+) -> u32 {let from_existing = existing.map(|f| f.evidence_count as u32).unwrap_or(0);from_existing + cands.len() as u32}@@ -306,4 +316,3 @@ pub(super) fn state_from_stability(score: f64, user_state: UserState) -> FacetStpub(super) fn class_prefix(class: FacetClass) -> &'static str {crate::agent::learning::cache::class_prefix(class)}-diff --git a/crates/openhuman-core/src/core/all.rs b/crates/openhuman-core/src/core/all.rsindex 67f48bfdb6..fd46b19ea2 100644--- a/crates/openhuman-core/src/core/all.rs+++ b/crates/openhuman-core/src/core/all.rs@@ -1838,3 +1838,7 @@ pub(crate) fn assert_schema_controller_parity(#[cfg(test)]#[path = "all_tests.rs"]mod tests;++#[cfg(test)]+#[path = "all_extensions_tests.rs"]+mod extensions_tests;diff --git a/crates/openhuman-core/src/core/all_extensions_tests.rs b/crates/openhuman-core/src/core/all_extensions_tests.rsnew file mode 100644index 0000000000..fe0a2414cc--- /dev/null+++ b/crates/openhuman-core/src/core/all_extensions_tests.rs@@ -0,0 +1,117 @@+use serde_json::Map;++use super::tests::schema;+use super::*;++// ── Controller extensions (crates above the core) ──────────────────────────++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, 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/all_tests.rs b/crates/openhuman-core/src/core/all_tests.rsindex e1d779cad2..8a4c1dc1ab 100644--- a/crates/openhuman-core/src/core/all_tests.rs+++ b/crates/openhuman-core/src/core/all_tests.rs@@ -3,7 +3,7 @@ use serde_json::Map;use super::*;use crate::core::{ControllerSchema, FieldSchema, TypeSchema};-fn schema(+pub(super) fn schema(namespace: &'static str,function: &'static str,inputs: Vec<FieldSchema>,@@ -2598,116 +2598,3 @@ fn session_db_controllers_are_gone_and_run_ledger_survives() {"the `session_db` namespace was removed and must not be registered, got: {namespaces:?}");}--// ── Controller extensions (crates above the core) ──────────────────────────--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, 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/inference/provider/openhuman_backend_model_tests.rs b/crates/openhuman-core/src/inference/provider/openhuman_backend_model_tests.rsindex 589ed167a9..511bc892d4 100644--- a/crates/openhuman-core/src/inference/provider/openhuman_backend_model_tests.rs+++ b/crates/openhuman-core/src/inference/provider/openhuman_backend_model_tests.rs@@ -49,7 +49,6 @@ fn resolve_model_normalizes_blank_and_trims_non_empty_values() {assert_eq!(resolve_model("hint:reasoning"), "hint:reasoning");}-// ── probe_readiness (B45 — flows provider-connectivity author gate) ────#[test]diff --git a/scripts/ci/agent-runtime-boundary-baseline.json b/scripts/ci/agent-runtime-boundary-baseline.jsonindex 605e02613d..a724910a04 100644--- a/scripts/ci/agent-runtime-boundary-baseline.json+++ b/scripts/ci/agent-runtime-boundary-baseline.json@@ -751,21 +751,21 @@{"rule": "openhuman-task-local","path": "crates/openhuman-core/src/inference/provider/openhuman_backend_model.rs",- "line": 536,+ "line": 466,"text": "fn with_thread_id(request: ModelRequest, thread_id: Option<&str>) -> ModelRequest {","occurrence": 1},{"rule": "openhuman-task-local","path": "crates/openhuman-core/src/inference/provider/openhuman_backend_model.rs",- "line": 667,+ "line": 597,"text": "with_thread_id(apply_reasoning_hint(request), self.thread_id.as_deref()),","occurrence": 1},{"rule": "openhuman-task-local","path": "crates/openhuman-core/src/inference/provider/openhuman_backend_model.rs",- "line": 697,+ "line": 627,"text": "with_thread_id(apply_reasoning_hint(request), self.thread_id.as_deref()),","occurrence": 2},@@ -1077,20 +1077,6 @@"text": "pub use tinytools::{ToolContent, ToolResult};","occurrence": 1},- {- "rule": "openhuman-upstream-reexport",- "path": "crates/openhuman-core/src/tools/impl/meta/mod.rs",- "line": 16,- "text": "pub use tinytools::collapse;",- "occurrence": 1- },- {- "rule": "openhuman-upstream-reexport",- "path": "crates/openhuman-core/src/tools/impl/meta/mod.rs",- "line": 17,- "text": "pub use tinytools::collapse::{",- "occurrence": 1- },{"rule": "openhuman-upstream-reexport","path": "crates/openhuman-core/src/tools/mod.rs",