Skip to content

The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.

refactor(modules): tidy search path helpers and cover artifact naming

Steven Enamakel9e02a1277add
diff --git a/crates/openhuman-core/src/modules/boot.rs b/crates/openhuman-core/src/modules/boot.rs
index 45b8ee7238..bad167fa47 100644
--- a/crates/openhuman-core/src/modules/boot.rs
+++ b/crates/openhuman-core/src/modules/boot.rs
@@ -40,11 +40,11 @@ pub async fn load_declared_modules(config: &Config) {
// Search paths first: an artifact an operator has placed deliberately should
// win over a download, and `ensure_loaded` below then finds it already
// serving rather than fetching a second copy.
- for outcome in super::search_path::load_enabled(
- runtime.host(),
- &ops::disabled_lib_stems(config),
- |id| ops::module_config(config, id),
- ) {
+ for outcome in
+ super::search_path::load_enabled(runtime.host(), &ops::disabled_lib_stems(config), |id| {
+ ops::module_config(config, id)
+ })
+ {
match outcome {
Ok(info) => log::info!(
"[modules] loaded '{}' {} from the module search path",
diff --git a/crates/openhuman-core/src/modules/search_path.rs b/crates/openhuman-core/src/modules/search_path.rs
index 5f5b8677b6..91a751561a 100644
--- a/crates/openhuman-core/src/modules/search_path.rs
+++ b/crates/openhuman-core/src/modules/search_path.rs
@@ -24,6 +24,7 @@ pub fn configured_module_lib_stems() -> Vec<String> {
format!("{stem}_module"),
format!("lib{stem}_module"),
]
+ .to_vec()
}
fn module_id_for_artifact(path: &Path) -> Option<&'static str> {
@@ -31,7 +32,7 @@ fn module_id_for_artifact(path: &Path) -> Option<&'static str> {
let stem = stem.strip_prefix("lib").unwrap_or(stem);
let stem = stem.strip_suffix("_module").unwrap_or(stem);
super::registry::ALL.iter().find_map(|record| {
- (record.id == stem || record.source.lib_name.as_str() == stem).then_some(record.id)
+ (record.id == stem || record.source.lib_name == stem).then_some(record.id)
})
}
diff --git a/crates/openhuman-core/src/modules/search_path_tests.rs b/crates/openhuman-core/src/modules/search_path_tests.rs
index e1f98f95bb..7b347b0f11 100644
--- a/crates/openhuman-core/src/modules/search_path_tests.rs
+++ b/crates/openhuman-core/src/modules/search_path_tests.rs
@@ -8,3 +8,17 @@ fn skips_only_files_named_after_a_disabled_library() {
assert!(is_skipped(&PathBuf::from("/x/tinysearch.dll"), &skip));
assert!(!is_skipped(&PathBuf::from("/x/libtinydocs.so"), &skip));
}
+
+#[test]
+fn recognizes_source_and_release_artifacts_for_configured_modules() {
+ let stems = configured_module_lib_stems();
+ for artifact in [
+ "/modules/libtinymcp.so",
+ "/modules/libtinymcp_module.so",
+ "/modules/tinymcp_module.dll",
+ ] {
+ let path = PathBuf::from(artifact);
+ assert!(is_skipped(&path, &stems));
+ assert_eq!(module_id_for_artifact(&path), Some("tinymcp"));
+ }
+}