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(modules): cover component gating and registry mappings
Steven Enamakel5f294e56d0f4
diff --git a/crates/openhuman-core/src/modules/boot_tests.rs b/crates/openhuman-core/src/modules/boot_tests.rsindex 92fe291094..910b6bdc5e 100644--- a/crates/openhuman-core/src/modules/boot_tests.rs+++ b/crates/openhuman-core/src/modules/boot_tests.rs@@ -18,3 +18,23 @@ async fn boot_tolerates_an_empty_search_path() {config.modules.allow_download = false;load_declared_modules(&config).await;}++#[tokio::test]+async fn boot_skips_disabled_components() {+ // A config with every component off must boot without resolving any+ // eager module (no download, no dlopen) and without error.+ let mut config = Config::default();+ config.modules.enabled = true;+ config.modules.allow_download = false;+ for name in crate::core::runtime::COMPONENT_NAMES {+ assert!(config.components.set(name, false));+ }+ load_declared_modules(&config).await;+ for record in crate::modules::registry::ALL {+ assert!(+ crate::modules::ops::disabled_component(&config, record.id).is_some(),+ "{} should be disabled",+ record.id+ );+ }+}diff --git a/crates/openhuman-core/src/modules/ops.rs b/crates/openhuman-core/src/modules/ops.rsindex cfa7efb9cb..4cdafdfdf2 100644--- a/crates/openhuman-core/src/modules/ops.rs+++ b/crates/openhuman-core/src/modules/ops.rs@@ -632,3 +632,7 @@ fn status_of(config: &Config, record: &ModuleRecord) -> ModuleStatus {#[cfg(test)]#[path = "ops_tests.rs"]mod tests;++#[cfg(test)]+#[path = "ops_components_tests.rs"]+mod components_tests;diff --git a/crates/openhuman-core/src/modules/ops_components_tests.rs b/crates/openhuman-core/src/modules/ops_components_tests.rsnew file mode 100644index 0000000000..7a209f53c8--- /dev/null+++ b/crates/openhuman-core/src/modules/ops_components_tests.rs@@ -0,0 +1,46 @@+use super::*;+use crate::modules::types::ModuleState;++fn config_without(component: &str) -> Config {+ let mut config = Config::default();+ config.modules.enabled = true;+ config.modules.allow_download = true;+ assert!(config.components.set(component, false));+ config+}++#[tokio::test]+async fn a_disabled_component_never_reaches_download_or_dlopen() {+ let config = config_without("mcp");+ let err = ensure_loaded_within(&config, "tinymcp", None)+ .await+ .unwrap_err();+ assert_eq!(err, LoadError::Disabled("mcp"));+ assert_eq!(err.into_message(), "COMPONENT_DISABLED:mcp");+ // Nothing was claimed: the resolution table never saw the id.+ assert_eq!(state_of("tinymcp"), ModuleState::Available);+}++#[test]+fn list_reports_disabled_for_a_switched_off_component() {+ let config = config_without("connectors");+ let statuses = list(&config);+ let status = statuses.iter().find(|s| s.id == "tinyconnectors").unwrap();+ assert_eq!(status.state, ModuleState::Disabled);+ assert!(status.source.is_none());+ assert!(status.detail.as_deref().unwrap().contains("[components]"));+ let other = statuses.iter().find(|s| s.id == "tinymcp").unwrap();+ assert_ne!(other.state, ModuleState::Disabled);+}++#[test]+fn disabled_lib_stems_cover_only_disabled_modules() {+ let config = config_without("search");+ let stems = disabled_lib_stems(&config);+ let search = registry::find("tinysearch").unwrap().source.lib_name;+ assert!(stems.contains(&search.to_string()));+ assert!(stems.contains(&format!("lib{search}")));+ let mcp = registry::find("tinymcp").unwrap().source.lib_name;+ assert!(!stems.contains(&mcp.to_string()));+ assert!(disabled_lib_stems(&Config::default()).is_empty());+}diff --git a/crates/openhuman-core/src/modules/registry_contract_tests.rs b/crates/openhuman-core/src/modules/registry_contract_tests.rsindex 0ac0e36809..971dff1f86 100644--- a/crates/openhuman-core/src/modules/registry_contract_tests.rs+++ b/crates/openhuman-core/src/modules/registry_contract_tests.rs@@ -122,3 +122,22 @@ fn a_product_feature_build_carries_all_eleven_records() {assert!(find(id).is_some(), "{id} missing from the registry");}}++#[test]+fn every_record_maps_to_a_real_component() {+ for record in ALL {+ let component = component_for(record.id)+ .unwrap_or_else(|| panic!("module '{}' has no component mapping", record.id));+ assert!(+ crate::core::runtime::COMPONENT_NAMES.contains(&component),+ "'{component}' is not a [components] name"+ );+ }+ for (id, _) in COMPONENT_OF {+ assert!(+ ALL.iter().any(|r| r.id == *id) || !cfg!(feature = "modules")+ || matches!(*id, "tinydocs" | "tinywallet" | "tinyvoice" | "tinyhosts"),+ "mapping for unknown module '{id}'"+ );+ }+}