Skip to content

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

test(core): verify bound controllers against independent contracts

Steven Enamakelbdf54bf85344
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 e85402adca..614cb9b178 100644
--- a/crates/openhuman-core/src/core/all_bound_controller_tests.rs
+++ b/crates/openhuman-core/src/core/all_bound_controller_tests.rs
@@ -324,34 +324,27 @@ fn production_registry_binds_mcp_registry_get_to_its_declared_parser() {
entry.rpc_method_name(),
"openhuman.mcp_clients_registry_get"
);
- required_input_contract(&entry.schema, &["qualified_name"])
- .expect("qualified_name is an independently required input");
+ let contract = crate::mcp::registry::schemas::registry_get_parameter_contract();
+ crate::core::all::verify_parameter_contracts(std::slice::from_ref(entry),
+ std::slice::from_ref(&contract))
+ .expect("raw MCP entry matches its independent contract and bound decoder");
assert!(entry.schema.inputs.iter().all(|field| field.required));
- for example in [
- json!({"qualified_name":"example/server"}),
- json!({"qualified_name":" example/server "}),
- ] {
- let params = example.as_object().expect("example object").clone();
- validate_params(&entry.schema, &params).expect("schema accepts independent example");
- entry
- .decode_params(params)
- .expect("bound decoder accepts independent example");
- }
-
for remove in [true, false] {
let mut broken = entry.schema.clone();
if remove {
- broken.inputs.retain(|field| field.name != "qualified_name");
+ broken
+ .inputs
+ .retain(|field| field.name != contract.required[0]);
} else {
broken
.inputs
.iter_mut()
- .find(|field| field.name == "qualified_name")
- .expect("positive contract includes qualified_name")
+ .find(|field| field.name == contract.required[0])
+ .expect("positive contract includes its required input")
.required = false;
}
- assert!(required_input_contract(&broken, &["qualified_name"])
+ assert!(required_input_contract(&broken, contract.required)
.unwrap_err()
.contains("required inputs mismatch"));
}
@@ -387,13 +380,10 @@ fn production_registry_binds_computer_status_to_its_declared_parser() {
assert_eq!(entry.schema.inputs[0].name, "load");
assert!(!entry.schema.inputs[0].required);
- for example in [json!({}), json!({"load":true}), json!({"load":false})] {
- let params = example.as_object().expect("example object").clone();
- validate_params(&entry.schema, &params).expect("schema accepts independent example");
- entry
- .decode_params(params)
- .expect("bound decoder accepts independent example");
- }
+ let contract = crate::modules::schemas::computer_status_parameter_contract();
+ crate::core::all::verify_parameter_contracts(std::slice::from_ref(entry),
+ std::slice::from_ref(&contract))
+ .expect("raw Modules entry matches its independent contract and bound decoder");
// Runtime parsing intentionally keeps its permissive false default for
// non-boolean inputs; these maps are parser cases, not schema examples.
diff --git a/crates/openhuman-core/src/mcp/registry/schemas/mod.rs b/crates/openhuman-core/src/mcp/registry/schemas/mod.rs
index 6c895eb6c0..afd3cf2ce5 100644
--- a/crates/openhuman-core/src/mcp/registry/schemas/mod.rs
+++ b/crates/openhuman-core/src/mcp/registry/schemas/mod.rs
@@ -46,9 +46,19 @@ pub(crate) fn registry_get_controller_entry() -> ControllerEntry {
))
}
-// Test-only bridges: `schemas_tests.rs` (kept as-is; not part of the unsplit
-// batch) reaches these through `use super::*`, mirroring the flat scope it
-// had when `include!` spliced everything into one file.
+// Test-only re-exports used by the companion schema tests.
#[cfg(test)]
use params::{read_optional_u32, read_required};
+#[cfg(test)]
+pub(crate) fn registry_get_parameter_contract() -> crate::core::all::ControllerParamContract {
+ crate::core::all::ControllerParamContract {
+ method: "mcp_clients.registry_get",
+ required: &["qualified_name"],
+ optional: &[],
+ examples: vec![
+ serde_json::json!({"qualified_name":"example/server"}),
+ serde_json::json!({"qualified_name":" example/server "}),
+ ],
+ }
+}
diff --git a/crates/openhuman-core/src/modules/schemas.rs b/crates/openhuman-core/src/modules/schemas.rs
index 60a60df0aa..846f41fd09 100644
--- a/crates/openhuman-core/src/modules/schemas.rs
+++ b/crates/openhuman-core/src/modules/schemas.rs
@@ -363,3 +363,17 @@ fn computer_status_controller_entry() -> ControllerEntry {
))
}
+#[cfg(test)]
+pub(crate) fn computer_status_parameter_contract() -> crate::core::all::ControllerParamContract {
+ crate::core::all::ControllerParamContract {
+ method: "modules.computer_status",
+ required: &[],
+ optional: &["load"],
+ examples: vec![
+ serde_json::json!({}),
+ serde_json::json!({"load":false}),
+ serde_json::json!({"load":true}),
+ ],
+ }
+}
+