Skip to content

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

feat(core): bind registry_get and computer_status to shared parsers

Steven Enamakele8953ff4e912
diff --git a/crates/openhuman-core/src/core/all.rs b/crates/openhuman-core/src/core/all.rs
index 94e5be8b95..97e169a3e3 100644
--- a/crates/openhuman-core/src/core/all.rs
+++ b/crates/openhuman-core/src/core/all.rs
@@ -329,7 +329,7 @@ fn build_registered_controllers() -> Vec<GroupedController> {
push(
&mut controllers,
DomainGroup::Mcp,
- crate::mcp::all_registered_controllers(),
+ crate::mcp::all_controller_entries(),
);
// Agent definition and prompt inspection
push(
@@ -696,7 +696,7 @@ fn build_internal_only_controllers() -> Vec<GroupedController> {
push(
&mut controllers,
DomainGroup::Modules,
- crate::modules::all_registered_controllers(),
+ crate::modules::schemas::all_controller_entries(),
);
controllers
}
diff --git a/crates/openhuman-core/src/core/all_schema_contract_tests.rs b/crates/openhuman-core/src/core/all_schema_contract_tests.rs
index 0938d4a5f5..4f7df67f7d 100644
--- a/crates/openhuman-core/src/core/all_schema_contract_tests.rs
+++ b/crates/openhuman-core/src/core/all_schema_contract_tests.rs
@@ -155,87 +155,9 @@ fn builtin_controller_snapshot() -> Vec<ControllerEntry> {
.collect()
}
-fn representative_parameter_contracts() -> (Vec<RegisteredController>, Vec<ControllerParamContract>)
-{
- let controllers = builtin_controller_snapshot()
- .into_iter()
- .filter(|controller| {
- (cfg!(feature = "mcp") && controller.schema.method_name() == "mcp_clients.registry_get")
- || (cfg!(feature = "modules")
- && controller.schema.method_name() == "modules.computer_status")
- })
- .filter_map(|controller| controller.legacy_controller())
- .collect();
- #[cfg(feature = "modules")]
- let contracts = vec![crate::modules::schemas::computer_status_parameter_contract()];
- #[cfg(not(feature = "modules"))]
- let contracts = Vec::new();
- #[cfg(feature = "mcp")]
- let contracts = contracts
- .into_iter()
- .chain([crate::mcp::registry::registry_get_parameter_contract()])
- .collect::<Vec<_>>();
- (controllers, contracts)
-}
-
-#[test]
-#[cfg(any(feature = "modules", feature = "mcp"))]
-fn representative_handler_examples_match_real_pure_parsers() {
- let (controllers, contracts) = representative_parameter_contracts();
- verify_parameter_contracts(&controllers, &contracts).unwrap();
-}
-
-#[test]
-#[cfg(any(feature = "modules", feature = "mcp"))]
-fn every_covered_required_declaration_rejects_removal_and_optional_mutants() {
- let (controllers, contracts) = representative_parameter_contracts();
- verify_parameter_contracts(&controllers, &contracts).unwrap();
- let mut mutations = 0;
- for contract in &contracts {
- let actual = controllers
- .iter()
- .find(|controller| controller.schema.method_name() == contract.method)
- .unwrap();
- for required in contract.required {
- for remove in [true, false] {
- let mut broken = actual.schema.clone();
- if remove {
- broken.inputs.retain(|field| field.name != *required);
- } else {
- broken
- .inputs
- .iter_mut()
- .find(|field| field.name == *required)
- .expect("positive contract requires this field")
- .required = false;
- }
- assert!(
- verify_parameter_schema(&broken, contract)
- .unwrap_err()
- .contains("required inputs mismatch"),
- "{} required {required}",
- contract.method
- );
- mutations += 1;
- }
- }
- }
- // MCP has one independently required field. The computer-status adapter
- // has no required field to mutate; synthetic runner tests cover that case.
- let expected_mutations = 2 * usize::from(cfg!(feature = "mcp"));
- assert_eq!(
- mutations, expected_mutations,
- "covered required-field mutations"
- );
-}
-
#[test]
#[cfg(not(any(feature = "modules", feature = "mcp")))]
fn optional_domain_controller_methods_are_absent_when_features_are_disabled() {
- let (controllers, contracts) = representative_parameter_contracts();
- assert!(controllers.is_empty());
- assert!(contracts.is_empty());
-
let methods = builtin_controller_snapshot()
.into_iter()
.map(|controller| controller.schema.method_name())
@@ -247,23 +169,3 @@ fn optional_domain_controller_methods_are_absent_when_features_are_disabled() {
.iter()
.any(|method| method == "modules.computer_status"));
}
-
-#[test]
-#[cfg(any(feature = "modules", feature = "mcp"))]
-fn real_contract_inventory_rejects_a_missing_and_an_extra_row() {
- let (controllers, mut contracts) = representative_parameter_contracts();
- let removed = contracts
- .pop()
- .expect("representative contracts are nonempty");
- assert!(verify_parameter_contracts(&controllers, &contracts)
- .unwrap_err()
- .contains("missing contract"));
- contracts.push(removed.clone());
- contracts.push(ControllerParamContract {
- method: "unregistered.fixture",
- ..removed
- });
- assert!(verify_parameter_contracts(&controllers, &contracts)
- .unwrap_err()
- .contains("extra contract"));
-}
diff --git a/crates/openhuman-core/src/mcp/mod.rs b/crates/openhuman-core/src/mcp/mod.rs
index 41717eedd5..7bc3223afa 100644
--- a/crates/openhuman-core/src/mcp/mod.rs
+++ b/crates/openhuman-core/src/mcp/mod.rs
@@ -203,6 +203,21 @@ pub fn all_registered_controllers() -> Vec<crate::core::all::RegisteredControlle
controllers
}
+/// Built-in runtime entries, binding registry_get to its shared parser while
+/// preserving the legacy catalogue above for existing callers.
+pub(crate) fn all_controller_entries() -> Vec<crate::core::all::ControllerEntry> {
+ all_registered_controllers()
+ .into_iter()
+ .map(|controller| {
+ #[cfg(feature = "mcp")]
+ if controller.schema.method_name() == "mcp_clients.registry_get" {
+ return registry::registry_get_controller_entry();
+ }
+ crate::core::all::ControllerEntry::legacy(controller)
+ })
+ .collect()
+}
+
pub mod audit;
// Ungated, like the transport below and for the same reason: `tinymcp` is an
// ordinary dependency, and the startup path calls `host::init` without a `cfg`
diff --git a/crates/openhuman-core/src/mcp/registry/mod.rs b/crates/openhuman-core/src/mcp/registry/mod.rs
index 0382e73b6e..3ffa16472a 100644
--- a/crates/openhuman-core/src/mcp/registry/mod.rs
+++ b/crates/openhuman-core/src/mcp/registry/mod.rs
@@ -45,6 +45,8 @@ pub mod supervisor_events;
#[cfg(feature = "mcp")]
pub mod tools;
+#[cfg(feature = "mcp")]
+pub(crate) use schemas::registry_get_controller_entry;
#[cfg(feature = "mcp")]
pub use schemas::{
all_controller_schemas as all_mcp_registry_controller_schemas,
diff --git a/crates/openhuman-core/src/mcp/registry/schemas/mod.rs b/crates/openhuman-core/src/mcp/registry/schemas/mod.rs
index 5804fe287e..48296bf7e2 100644
--- a/crates/openhuman-core/src/mcp/registry/schemas/mod.rs
+++ b/crates/openhuman-core/src/mcp/registry/schemas/mod.rs
@@ -14,6 +14,40 @@ mod registry;
pub use registry::{all_controller_schemas, all_registered_controllers, schemas};
+use crate::config::Config;
+use crate::core::all::{
+ BoundRegisteredController, ControllerEntry, ControllerFuture, ControllerTask,
+};
+use crate::core::runtime::DispatchCtx;
+use serde_json::Map;
+
+fn registry_get_config(ctx: DispatchCtx) -> ControllerTask<Config> {
+ Box::pin(async move { ctx.load_config().await })
+}
+
+fn parse_registry_get_params(params: Map<String, serde_json::Value>) -> Result<String, String> {
+ handlers::parse_registry_get(&params)
+}
+
+fn run_registry_get(_ctx: DispatchCtx, config: Config, qualified_name: String) -> ControllerFuture {
+ Box::pin(async move {
+ to_json(crate::mcp::registry::ops::mcp_clients_registry_get(&config, qualified_name).await?)
+ })
+}
+
+pub(crate) fn registry_get_controller_entry() -> ControllerEntry {
+ ControllerEntry::bound(BoundRegisteredController::after_gate(
+ registry::schemas("registry_get"),
+ registry_get_config,
+ parse_registry_get_params,
+ run_registry_get,
+ ))
+}
+
+fn to_json(value: impl serde::Serialize) -> Result<serde_json::Value, String> {
+ serde_json::to_value(value).map_err(|error| error.to_string())
+}
+
// 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.
diff --git a/crates/openhuman-core/src/mcp/registry/schemas_tests.rs b/crates/openhuman-core/src/mcp/registry/schemas_tests.rs
index 356cadf6da..5fff216bda 100644
--- a/crates/openhuman-core/src/mcp/registry/schemas_tests.rs
+++ b/crates/openhuman-core/src/mcp/registry/schemas_tests.rs
@@ -122,3 +122,16 @@ fn registry_get_shared_parser_preserves_value_and_validation_errors() {
.unwrap_err()
.contains("invalid 'qualified_name'"));
}
+
+#[test]
+fn registry_get_legacy_catalog_keeps_its_handler_and_fixture_contract() {
+ let controllers = all_registered_controllers()
+ .into_iter()
+ .filter(|controller| controller.schema.method_name() == "mcp_clients.registry_get")
+ .collect::<Vec<_>>();
+ crate::core::all::verify_parameter_contracts(
+ &controllers,
+ &[super::registry_get_parameter_contract()],
+ )
+ .expect("legacy catalogue keeps its public handler and authored parser example");
+}
diff --git a/crates/openhuman-core/src/modules/schemas.rs b/crates/openhuman-core/src/modules/schemas.rs
index 8b0d48dc8f..3f61b6f478 100644
--- a/crates/openhuman-core/src/modules/schemas.rs
+++ b/crates/openhuman-core/src/modules/schemas.rs
@@ -15,7 +15,9 @@ use std::sync::Arc;
use tinycomputer_bus::browser::SessionOptions;
use super::ops;
-use crate::core::all::{ControllerFuture, RegisteredController};
+use crate::core::all::{
+ BoundRegisteredController, ControllerEntry, ControllerFuture, RegisteredController,
+};
use crate::core::{ControllerSchema, FieldSchema, TypeSchema};
pub fn all_controller_schemas() -> Vec<ControllerSchema> {
@@ -58,6 +60,18 @@ pub fn all_registered_controllers() -> Vec<RegisteredController> {
]
}
+pub(crate) fn all_controller_entries() -> Vec<ControllerEntry> {
+ all_registered_controllers()
+ .into_iter()
+ .map(|controller| {
+ if controller.schema.method_name() == "modules.computer_status" {
+ return computer_status_controller_entry();
+ }
+ ControllerEntry::legacy(controller)
+ })
+ .collect()
+}
+
pub fn schemas(function: &str) -> ControllerSchema {
match function {
"list" => ControllerSchema {
@@ -334,6 +348,26 @@ fn computer_status_load(params: &Map<String, Value>) -> bool {
params.get("load").and_then(Value::as_bool).unwrap_or(false)
}
+fn parse_computer_status_params(params: Map<String, Value>) -> Result<bool, String> {
+ Ok(computer_status_load(&params))
+}
+
+fn run_computer_status(ctx: DispatchCtx, load: bool) -> ControllerFuture {
+ Box::pin(async move {
+ let config = ctx.load_config().await?;
+ crate::core::runtime::components::require_config(&config, "computer")?;
+ controller_value(super::computer::status(&config, load).await)
+ })
+}
+
+fn computer_status_controller_entry() -> ControllerEntry {
+ ControllerEntry::bound(BoundRegisteredController::typed(
+ schemas("computer_status"),
+ parse_computer_status_params,
+ run_computer_status,
+ ))
+}
+
#[cfg(test)]
pub(crate) fn computer_status_parameter_contract() -> crate::core::all::ControllerParamContract {
crate::core::all::ControllerParamContract {
diff --git a/crates/openhuman-core/src/modules/schemas_tests.rs b/crates/openhuman-core/src/modules/schemas_tests.rs
index 1c41f6dae0..7052291ad0 100644
--- a/crates/openhuman-core/src/modules/schemas_tests.rs
+++ b/crates/openhuman-core/src/modules/schemas_tests.rs
@@ -143,3 +143,16 @@ fn computer_status_load_keeps_permissive_false_default() {
assert_eq!(super::computer_status_load(&params), expected);
}
}
+
+#[test]
+fn computer_status_legacy_catalog_keeps_its_handler_and_fixture_contract() {
+ let controllers = all_registered_controllers()
+ .into_iter()
+ .filter(|controller| controller.schema.method_name() == "modules.computer_status")
+ .collect::<Vec<_>>();
+ crate::core::all::verify_parameter_contracts(
+ &controllers,
+ &[super::computer_status_parameter_contract()],
+ )
+ .expect("legacy catalogue keeps its public handler and authored parser examples");
+}