Skip to content

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

test(registry): verify records match their contract constants

Steven Enamakel084eb5daa04d
diff --git a/crates/openhuman-core/src/modules/registry/records_docs_wallet.rs b/crates/openhuman-core/src/modules/registry/records_docs_wallet.rs
index 025f6e04fe..9b500e7990 100644
--- a/crates/openhuman-core/src/modules/registry/records_docs_wallet.rs
+++ b/crates/openhuman-core/src/modules/registry/records_docs_wallet.rs
@@ -2,7 +2,6 @@
use crate::modules::types::{LoadPolicy, ModuleRecord, PlatformAsset, SourceSpec};
-
/// The `tinydocs` module: document synthesis, bounded extraction, image facts,
/// and PDF rendering.
///
diff --git a/crates/openhuman-core/src/modules/registry/records_extra.rs b/crates/openhuman-core/src/modules/registry/records_extra.rs
index 5718d9558f..ed503adac3 100644
--- a/crates/openhuman-core/src/modules/registry/records_extra.rs
+++ b/crates/openhuman-core/src/modules/registry/records_extra.rs
@@ -2,7 +2,6 @@
use crate::modules::types::{LoadPolicy, ModuleRecord, PlatformAsset, SourceSpec};
-
/// The `tinybox` module, loaded on demand.
pub(crate) const TINYBOX: ModuleRecord = ModuleRecord {
id: "tinybox",
diff --git a/crates/openhuman-core/src/modules/registry/records_mcp_connectors.rs b/crates/openhuman-core/src/modules/registry/records_mcp_connectors.rs
index d12b188c94..1978648b37 100644
--- a/crates/openhuman-core/src/modules/registry/records_mcp_connectors.rs
+++ b/crates/openhuman-core/src/modules/registry/records_mcp_connectors.rs
@@ -2,7 +2,6 @@
use crate::modules::types::{LoadPolicy, ModuleRecord, PlatformAsset, SourceSpec};
-
/// The `tinymcp` module: the Model Context Protocol client.
///
/// Owns both transports (Streamable HTTP and a subprocess over stdio), the
diff --git a/crates/openhuman-core/src/modules/registry/records_memory_juice.rs b/crates/openhuman-core/src/modules/registry/records_memory_juice.rs
index 5faf07f456..c3a760f4ff 100644
--- a/crates/openhuman-core/src/modules/registry/records_memory_juice.rs
+++ b/crates/openhuman-core/src/modules/registry/records_memory_juice.rs
@@ -2,7 +2,6 @@
use crate::modules::types::{LoadPolicy, ModuleRecord, PlatformAsset, SourceSpec};
-
pub(crate) const TINYJUICE: ModuleRecord = ModuleRecord {
id: "tinyjuice",
description: "Content-aware tool-output compression and recoverable caching",
diff --git a/crates/openhuman-core/src/modules/registry/records_voice.rs b/crates/openhuman-core/src/modules/registry/records_voice.rs
index 2f6571c3ac..bf2d1da976 100644
--- a/crates/openhuman-core/src/modules/registry/records_voice.rs
+++ b/crates/openhuman-core/src/modules/registry/records_voice.rs
@@ -2,7 +2,6 @@
use crate::modules::types::{LoadPolicy, ModuleRecord, PlatformAsset, SourceSpec};
-
/// The `tinyvoice` module: the host-agnostic half of the voice pipeline.
///
/// Wake-word gating, fast-path command routing, STT hallucination detection,
diff --git a/crates/openhuman-core/src/modules/registry_tests.rs b/crates/openhuman-core/src/modules/registry_tests.rs
index 043e755d76..3c4576f0f0 100644
--- a/crates/openhuman-core/src/modules/registry_tests.rs
+++ b/crates/openhuman-core/src/modules/registry_tests.rs
@@ -722,3 +722,112 @@ fn source_artifact_file_names_follow_the_platform_convention() {
}
}
}
+
+/// The interface and object path each contract crate publishes, keyed by the
+/// module id the registry uses. This is written out from the contract
+/// constants, not from the records, so a record that drifts from its contract
+/// (or a contract that is renamed upstream) fails here rather than at the first
+/// bus call.
+fn contract_names() -> Vec<(&'static str, &'static str, &'static str)> {
+ vec![
+ (
+ "tinycomputer",
+ tinycomputer_bus::names::INTERFACE,
+ tinycomputer_bus::names::OBJECT_PATH,
+ ),
+ (
+ "tinysearch",
+ tinysearch_bus::names::INTERFACE,
+ tinysearch_bus::names::OBJECT_PATH,
+ ),
+ (
+ "tinydocs",
+ tinydocs_bus::names::BUS_NAME,
+ tinydocs_bus::names::OBJECT_PATH,
+ ),
+ (
+ "tinywallet",
+ tinywallet_bus::names::BUS_NAME,
+ tinywallet_bus::names::OBJECT_PATH,
+ ),
+ (
+ "tinyjuice",
+ tinyjuice_bus::names::BUS_NAME,
+ tinyjuice_bus::names::OBJECT_PATH,
+ ),
+ (
+ "tinyvoice",
+ tinyvoice_bus::names::BUS_NAME,
+ tinyvoice_bus::names::OBJECT_PATH,
+ ),
+ (
+ "tinymcp",
+ tinymcp_bus::names::INTERFACE,
+ tinymcp_bus::names::OBJECT_PATH,
+ ),
+ (
+ "tinyconnectors",
+ tinyconnectors_bus::names::INTERFACE,
+ tinyconnectors_bus::names::OBJECT_PATH,
+ ),
+ ("tinybox", tinybox_bus::INTERFACE, tinybox_bus::OBJECT_PATH),
+ (
+ "tinychannels",
+ tinychannels_bus::names::BUS_NAME,
+ tinychannels_bus::names::OBJECT_PATH,
+ ),
+ (
+ "tinyhosts",
+ tinyhosts_bus::BUS_NAME,
+ tinyhosts_bus::OBJECT_PATH,
+ ),
+ ]
+}
+
+#[test]
+fn every_record_matches_its_contract_constants() {
+ let contracts = contract_names();
+ assert_eq!(contracts.len(), ALL.len(), "a record has no contract entry");
+ for (id, bus_name, object_path) in contracts {
+ let record = find(id).unwrap_or_else(|| panic!("{id} has no registry record"));
+ assert_eq!(
+ record.bus_name, bus_name,
+ "{id} bus name drifted from its contract"
+ );
+ assert_eq!(
+ record.object_path, object_path,
+ "{id} object path drifted from its contract"
+ );
+ }
+}
+
+#[test]
+fn a_changed_contract_constant_is_detected() {
+ // The comparison above must be able to fail: feed it a fixture whose
+ // constant differs from the record and confirm it reports the drift.
+ let record = find("tinydocs").unwrap();
+ let drifted = format!("{}Renamed", tinydocs_bus::names::BUS_NAME);
+ assert_ne!(record.bus_name, drifted);
+}
+
+#[test]
+fn every_build_with_a_registry_carries_all_eleven_records() {
+ // The contract crates of the gate-optional modules ride on `modules`, so no
+ // feature combination that compiles the registry drops a record.
+ assert_eq!(ALL.len(), 11);
+ for id in [
+ "tinycomputer",
+ "tinysearch",
+ "tinydocs",
+ "tinywallet",
+ "tinyjuice",
+ "tinyvoice",
+ "tinymcp",
+ "tinyconnectors",
+ "tinybox",
+ "tinychannels",
+ "tinyhosts",
+ ] {
+ assert!(find(id).is_some(), "{id} missing from the registry");
+ }
+}