Skip to content

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

chore: files changed crates/openhuman-core/src/core/all_bound_controller_tests.rs,crates/openhuman-c

Steven Enamakelf4c2baff3745
diff --git a/crates/openhuman-core/src/core/all_bound_controller_tests.rs b/crates/openhuman-core/src/core/all_bound_controller_tests.rs
index 32cbbd8cbc..40796aa4cf 100644
--- a/crates/openhuman-core/src/core/all_bound_controller_tests.rs
+++ b/crates/openhuman-core/src/core/all_bound_controller_tests.rs
@@ -714,3 +714,6 @@ mod registry_contract_tests;
#[path = "all_keyring_consent_controller_tests.rs"]
mod keyring_consent_controller_tests;
+
+#[path = "all_tool_registry_controller_tests.rs"]
+mod tool_registry_controller_tests;
diff --git a/crates/openhuman-core/src/core/all_tool_registry_controller_tests.rs b/crates/openhuman-core/src/core/all_tool_registry_controller_tests.rs
new file mode 100644
index 0000000000..0a0feab8cb
--- /dev/null
+++ b/crates/openhuman-core/src/core/all_tool_registry_controller_tests.rs
@@ -0,0 +1,122 @@
+use super::*;
+use serde_json::{json, Map};
+
+fn tool_registry_entries() -> Vec<ControllerEntry> {
+ registry()
+ .iter()
+ .filter(|row| row.controller.schema.namespace == "tool_registry")
+ .map(|row| row.controller.clone())
+ .collect()
+}
+
+#[test]
+fn raw_tool_registry_matches_its_independent_contract() {
+ let contract = registry_test_support::BoundFamilyWireContract {
+ namespaces: &["tool_registry"],
+ group: DomainGroup::Platform,
+ methods: &[
+ ("tool_registry.list", "openhuman.tool_registry_list"),
+ ("tool_registry.get", "openhuman.tool_registry_get"),
+ (
+ "tool_registry.diagnostics",
+ "openhuman.tool_registry_diagnostics",
+ ),
+ ],
+ };
+ let fixtures = [
+ ControllerParamContract {
+ method: "tool_registry.list",
+ required: &[],
+ optional: &[],
+ examples: vec![json!({})],
+ },
+ ControllerParamContract {
+ method: "tool_registry.get",
+ required: &["tool_id"],
+ optional: &[],
+ examples: vec![json!({"tool_id":" tools.web_search "})],
+ },
+ ControllerParamContract {
+ method: "tool_registry.diagnostics",
+ required: &[],
+ optional: &[],
+ examples: vec![json!({})],
+ },
+ ];
+ registry_test_support::verify_family_contract(
+ registry(),
+ internal_registry(),
+ &contract,
+ &fixtures,
+ )
+ .expect("raw Tool Registry entries retain ordered bound wire contracts");
+
+ let entries = tool_registry_entries();
+ use TypeSchema::{Array, Json, String};
+ let expected = [
+ (vec![], vec![("tools", Array(Box::new(Json)), true)]),
+ (
+ vec![("tool_id", String, true)],
+ vec![("tool", Json, true)],
+ ),
+ (vec![], vec![("diagnostics", Json, true)]),
+ ];
+ assert_eq!(entries.len(), expected.len());
+ for (entry, (inputs, outputs)) in entries.iter().zip(expected) {
+ assert_eq!(
+ crate::core::all::verify_wire_fields(&entry.schema.inputs, &inputs),
+ Ok(()),
+ "{} inputs",
+ entry.schema.method_name()
+ );
+ assert_eq!(
+ crate::core::all::verify_wire_fields(&entry.schema.outputs, &outputs),
+ Ok(()),
+ "{} outputs",
+ entry.schema.method_name()
+ );
+ }
+}
+
+#[test]
+fn raw_tool_registry_decoders_keep_ignored_maps_and_tool_id_errors() {
+ let entries = tool_registry_entries();
+ let list = entries
+ .iter()
+ .find(|entry| entry.schema.function == "list")
+ .expect("raw list entry");
+ let diagnostics = entries
+ .iter()
+ .find(|entry| entry.schema.function == "diagnostics")
+ .expect("raw diagnostics entry");
+ let ignored = Map::from_iter([("ignored".into(), json!({"nested": true}))]);
+ list.decode_params(ignored.clone())
+ .expect("list ignores its entire parameter map");
+ diagnostics
+ .decode_params(ignored)
+ .expect("diagnostics ignores its entire parameter map");
+
+ let get = entries
+ .iter()
+ .find(|entry| entry.schema.function == "get")
+ .expect("raw get entry");
+ get.decode_params(Map::from_iter([
+ ("tool_id".into(), json!(" tools.web_search ")),
+ ("ignored".into(), json!(true)),
+ ]))
+ .expect("get accepts a padded id and ignores extra fields");
+ for params in [
+ Map::new(),
+ Map::from_iter([("tool_id".into(), json!(null))]),
+ Map::from_iter([("tool_id".into(), json!(false))]),
+ Map::from_iter([("tool_id".into(), json!(10))]),
+ Map::from_iter([("tool_id".into(), json!([]))]),
+ Map::from_iter([("tool_id".into(), json!({}))]),
+ Map::from_iter([("tool_id".into(), json!(" "))]),
+ ] {
+ assert_eq!(
+ get.decode_params(params).unwrap_err(),
+ "tool_id must be a non-empty string"
+ );
+ }
+}
diff --git a/crates/openhuman-core/src/tools/registry/schemas_tests.rs b/crates/openhuman-core/src/tools/registry/schemas_tests.rs
index def6a1b9a6..4f74baf6f4 100644
--- a/crates/openhuman-core/src/tools/registry/schemas_tests.rs
+++ b/crates/openhuman-core/src/tools/registry/schemas_tests.rs
@@ -39,6 +39,14 @@ fn diagnostics_schema_has_no_inputs() {
assert_eq!(schema.outputs[0].name, "diagnostics");
}
+#[test]
+fn required_tool_id_trims_padded_ids_before_lookup() {
+ let mut params = Map::new();
+ params.insert("tool_id".to_string(), json!(" tools.web_search "));
+
+ assert_eq!(required_tool_id(&params).unwrap(), "tools.web_search");
+}
+
#[test]
fn required_tool_id_rejects_wrong_type() {
let mut params = Map::new();