Skip to content

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

test(core): add schema-controller parity checks across subsystems

Steven Enamakelf8c99346ebbd
diff --git a/crates/openhuman-core/src/core/all.rs b/crates/openhuman-core/src/core/all.rs
index fa6e651d05..37e4b67875 100644
--- a/crates/openhuman-core/src/core/all.rs
+++ b/crates/openhuman-core/src/core/all.rs
@@ -1259,6 +1259,28 @@ pub(crate) fn required_input_contract(
}
}
+#[cfg(test)]
+pub(crate) fn required_fields_contract(
+ schema: &ControllerSchema,
+ required: &[&str],
+) -> Result<(), String> {
+ for name in required {
+ let Some(field) = schema.inputs.iter().find(|field| field.name == *name) else {
+ return Err(format!(
+ "{}.{} is missing required input `{name}`",
+ schema.namespace, schema.function
+ ));
+ };
+ if !field.required {
+ return Err(format!(
+ "{}.{} input `{name}` is not required",
+ schema.namespace, schema.function
+ ));
+ }
+ }
+ Ok(())
+}
+
#[cfg(test)]
pub(crate) fn expect_schema_input_order(schema: &ControllerSchema, inputs: &[&str]) {
let actual: Vec<_> = schema.inputs.iter().map(|field| field.name).collect();
diff --git a/crates/openhuman-core/src/core/all_tests.rs b/crates/openhuman-core/src/core/all_tests.rs
index 06d670e421..c2193b4ea3 100644
--- a/crates/openhuman-core/src/core/all_tests.rs
+++ b/crates/openhuman-core/src/core/all_tests.rs
@@ -122,7 +122,7 @@ fn registered_controller_schemas_are_consistent_and_serializable() {
if method == "openhuman.wallet_setup" {
assert_eq!(
- required_input_contract(schema, &["encryptedMnemonic"]),
+ required_fields_contract(schema, &["encryptedMnemonic"]),
Ok(()),
"wallet.setup required-input contract"
);
diff --git a/crates/openhuman-core/src/core/subsystem/schemas_tests.rs b/crates/openhuman-core/src/core/subsystem/schemas_tests.rs
index 020646ee12..700f189e22 100644
--- a/crates/openhuman-core/src/core/subsystem/schemas_tests.rs
+++ b/crates/openhuman-core/src/core/subsystem/schemas_tests.rs
@@ -1,5 +1,15 @@
use super::*;
use crate::core::runtime::DispatchCtx;
+use crate::core::all::assert_schema_controller_parity;
+
+#[test]
+fn subsystem_catalog_matches_registered_controllers() {
+ assert_schema_controller_parity(
+ &all_controller_schemas(),
+ &all_registered_controllers(),
+ "status",
+ );
+}
#[tokio::test]
async fn handler_returns_a_subsystems_array_containing_the_memory_slot() {
diff --git a/crates/openhuman-core/src/flows/schemas_tests.rs b/crates/openhuman-core/src/flows/schemas_tests.rs
index 1dfc511c46..1e13451646 100644
--- a/crates/openhuman-core/src/flows/schemas_tests.rs
+++ b/crates/openhuman-core/src/flows/schemas_tests.rs
@@ -1,5 +1,5 @@
use super::*;
-use crate::core::all::{expect_schema_fields, expect_schema_input_order, expect_schema_output_names, expect_schema_required_inputs};
+use crate::core::all::{expect_schema_fields, expect_schema_identity, expect_schema_input_order, expect_schema_output_names, expect_schema_required_inputs};
use serde_json::json;
#[test]
@@ -23,7 +23,7 @@ fn flow_schema_wire_contracts_are_preserved() {
];
for (function, required, optional) in contracts {
let schema = schemas(function);
- assert_eq!(schema.namespace, "flows", "{function} namespace");
+ expect_schema_identity(&schema, "flows", function);
expect_schema_required_inputs(&schema, required);
expect_schema_fields(
&schema,
diff --git a/crates/openhuman-core/src/inference/host_runtime/schemas_tests.rs b/crates/openhuman-core/src/inference/host_runtime/schemas_tests.rs
index 12acadf423..43d9d9e3b5 100644
--- a/crates/openhuman-core/src/inference/host_runtime/schemas_tests.rs
+++ b/crates/openhuman-core/src/inference/host_runtime/schemas_tests.rs
@@ -1,4 +1,14 @@
use super::*;
+use crate::core::all::assert_schema_controller_parity;
+
+#[test]
+fn runtime_schema_catalog_matches_registered_controllers() {
+ assert_schema_controller_parity(
+ &all_controller_schemas(),
+ &all_registered_controllers(),
+ "agent_chat",
+ );
+}
#[test]
fn every_registered_key_resolves_to_non_unknown_schema() {
diff --git a/crates/openhuman-core/src/inference/schemas_tests.rs b/crates/openhuman-core/src/inference/schemas_tests.rs
index 1792146a99..98093644a2 100644
--- a/crates/openhuman-core/src/inference/schemas_tests.rs
+++ b/crates/openhuman-core/src/inference/schemas_tests.rs
@@ -1,9 +1,15 @@
use super::*;
+use crate::core::all::assert_schema_controller_parity;
use crate::core::runtime::DispatchCtx;
use crate::core::TypeSchema;
#[test]
fn inference_schema_function_names_are_stable() {
+ assert_schema_controller_parity(
+ &all_controller_schemas(),
+ &all_registered_controllers(),
+ "status",
+ );
let functions: Vec<&str> = all_controller_schemas()
.into_iter()
.map(|schema| schema.function)
diff --git a/crates/openhuman-core/src/mcp/ui/schemas_tests.rs b/crates/openhuman-core/src/mcp/ui/schemas_tests.rs
index 76aee4bc69..f57e335b77 100644
--- a/crates/openhuman-core/src/mcp/ui/schemas_tests.rs
+++ b/crates/openhuman-core/src/mcp/ui/schemas_tests.rs
@@ -1,14 +1,18 @@
use super::*;
-use crate::core::all::{expect_schema_fields, expect_schema_identity};
+use crate::core::all::{
+ assert_schema_controller_parity, expect_schema_identity, expect_schema_required_inputs,
+};
use crate::core::runtime::DispatchCtx;
#[test]
fn mcp_ui_schema_contracts_are_preserved() {
let schema = schemas("tool_call");
expect_schema_identity(&schema, "mcp_ui", "tool_call");
- expect_schema_fields(
- &schema,
- &[("server_id", Some(true)), ("tool_name", Some(true))],
+ expect_schema_required_inputs(&schema, &["server_id", "tool_name"]);
+ assert_schema_controller_parity(
+ &all_controller_schemas(),
+ &all_registered_controllers(),
+ "tool_call",
);
}
diff --git a/crates/openhuman-core/src/voice/schemas_tests.rs b/crates/openhuman-core/src/voice/schemas_tests.rs
index 23d2c272cb..f732d5da77 100644
--- a/crates/openhuman-core/src/voice/schemas_tests.rs
+++ b/crates/openhuman-core/src/voice/schemas_tests.rs
@@ -1,4 +1,5 @@
use super::*;
+use crate::core::all::expect_schema_required_inputs;
use crate::core::runtime::DispatchCtx;
use serde_json::json;
@@ -69,6 +70,8 @@ fn voice_schema_wire_contracts_are_preserved() {
);
}
}
+ expect_schema_required_inputs(&voice_schemas("voice_server_start"), &[]);
+ expect_schema_required_inputs(&voice_schemas("voice_update_provider_settings"), &[]);
let registered: Vec<_> = all_voice_registered_controllers()
.into_iter()
.map(|controller| controller.schema.function)
diff --git a/crates/openhuman-core/src/web3/wallet/schemas_tests.rs b/crates/openhuman-core/src/web3/wallet/schemas_tests.rs
index 3c659f1189..f647e370c4 100644
--- a/crates/openhuman-core/src/web3/wallet/schemas_tests.rs
+++ b/crates/openhuman-core/src/web3/wallet/schemas_tests.rs
@@ -1,13 +1,18 @@
use super::*;
use crate::core::all::{
- expect_schema_fields, expect_schema_identity, expect_schema_input_order,
- expect_schema_required_inputs, required_input_contract,
+ assert_schema_controller_parity, expect_schema_fields, expect_schema_identity, expect_schema_input_order,
+ expect_schema_required_inputs, required_fields_contract,
};
#[test]
fn wallet_schema_wire_contracts_are_preserved() {
assert_eq!(all_wallet_controller_schemas().len(), 16);
assert_eq!(all_wallet_registered_controllers().len(), 16);
+ assert_schema_controller_parity(
+ &all_wallet_controller_schemas(),
+ &all_wallet_registered_controllers(),
+ "setup",
+ );
for (function, inputs) in [
("generate_mnemonic", &["wordCount"][..]),
@@ -61,7 +66,7 @@ fn required_input_contract_rejects_removed_or_optional_encrypted_mnemonic() {
"fixed contract field must exist before mutation"
);
assert_eq!(
- required_input_contract(schema, &["encryptedMnemonic"]),
+ required_fields_contract(schema, &["encryptedMnemonic"]),
Ok(()),
"real registered wallet.setup schema satisfies the independent oracle"
);
@@ -70,9 +75,9 @@ fn required_input_contract_rejects_removed_or_optional_encrypted_mnemonic() {
removed
.inputs
.retain(|input| input.name != "encryptedMnemonic");
- assert!(required_input_contract(&removed, &["encryptedMnemonic"])
+ assert!(required_fields_contract(&removed, &["encryptedMnemonic"])
.unwrap_err()
- .contains("expected [\"encryptedMnemonic\"], got []"));
+ .contains("is missing required input `encryptedMnemonic`"));
let mut optional = schema.clone();
optional
@@ -81,7 +86,7 @@ fn required_input_contract_rejects_removed_or_optional_encrypted_mnemonic() {
.find(|input| input.name == "encryptedMnemonic")
.expect("asserted field exists")
.required = false;
- assert!(required_input_contract(&optional, &["encryptedMnemonic"])
+ assert!(required_fields_contract(&optional, &["encryptedMnemonic"])
.unwrap_err()
- .contains("expected [\"encryptedMnemonic\"], got []"));
+ .contains("input `encryptedMnemonic` is not required"));
}