The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.
Rust agent-orchestrationai-agentsai-assistantdesktopllmlocal-firstmcppersonal-aiprivacyrustsecond-braintauri
refactor(desktop): add app state controller tests
Steven Enamakel7338744cacb6
diff --git a/crates/openhuman-core/src/core/all_bound_controller_tests.rs b/crates/openhuman-core/src/core/all_bound_controller_tests.rsindex 3fa4ef2231..233371d6e6 100644--- a/crates/openhuman-core/src/core/all_bound_controller_tests.rs+++ b/crates/openhuman-core/src/core/all_bound_controller_tests.rs@@ -10,7 +10,8 @@ static TEST_LOCK: Mutex<()> = Mutex::new(());static EVENTS: Mutex<Vec<&'static str>> = Mutex::new(Vec::new());fn staged_bound_methods() -> Vec<&'static str> {- let mut methods = vec!["composio.execute"];+ let mut methods = vec!["app_state.snapshot", "app_state.update_local_state"];+ methods.push("composio.execute");#[cfg(feature = "mcp")]methods.push("mcp_clients.registry_get");methods.extend(["doctor.report", "doctor.models"]);@@ -682,3 +683,6 @@ mod encryption_controller_tests;#[path = "all_doctor_controller_tests.rs"]mod doctor_controller_tests;++#[path = "all_app_state_controller_tests.rs"]+mod app_state_controller_tests;diff --git a/crates/openhuman-core/src/desktop/app_state/mod.rs b/crates/openhuman-core/src/desktop/app_state/mod.rsindex fbb93a8ebb..9e36fbc287 100644--- a/crates/openhuman-core/src/desktop/app_state/mod.rs+++ b/crates/openhuman-core/src/desktop/app_state/mod.rs@@ -9,3 +9,6 @@ pub use recovery_signal::{config_recovered_this_session, latch_from_config};pub use schemas::{all_app_state_controller_schemas, all_app_state_registered_controllers, app_state_schemas,};++#[cfg(test)]+pub(crate) use schemas::app_state_parameter_contracts;diff --git a/crates/openhuman-core/src/desktop/app_state/schemas.rs b/crates/openhuman-core/src/desktop/app_state/schemas.rsindex 1eaba75a62..9ed485f067 100644--- a/crates/openhuman-core/src/desktop/app_state/schemas.rs+++ b/crates/openhuman-core/src/desktop/app_state/schemas.rs@@ -39,6 +39,11 @@ pub fn all_app_state_registered_controllers() -> Vec<RegisteredController> {]}+#[cfg(test)]+pub(crate) fn app_state_parameter_contracts() -> Vec<crate::core::all::ControllerParamContract> {+ tests::parameter_contracts()+}+pub fn app_state_schemas(function: &str) -> ControllerSchema {match function {"snapshot" => ControllerSchema {diff --git a/crates/openhuman-core/src/desktop/app_state/schemas_tests.rs b/crates/openhuman-core/src/desktop/app_state/schemas_tests.rsindex b1a12bf34d..a1658e2650 100644--- a/crates/openhuman-core/src/desktop/app_state/schemas_tests.rs+++ b/crates/openhuman-core/src/desktop/app_state/schemas_tests.rs@@ -1,5 +1,62 @@use super::*;-use crate::core::all::{assert_schema_controller_parity, expect_schema_identity};+use crate::core::all::{+ assert_schema_controller_parity, expect_schema_identity, ControllerHandler,+ ControllerParamContract,+};++#[test]+fn legacy_handlers_keep_their_identity_and_order() {+ let expected: [(&str, ControllerHandler); 2] = [+ ("snapshot", handle_snapshot),+ ("update_local_state", handle_update_local_state),+ ];+ let controllers = all_app_state_registered_controllers();+ assert_eq!(controllers.len(), expected.len());+ for ((function, handler), controller) in expected.iter().zip(&controllers) {+ assert_eq!(controller.schema.namespace, "app_state");+ assert_eq!(controller.schema.function, *function);+ assert!(std::ptr::fn_addr_eq(controller.handler, *handler));+ }+}++pub(super) fn parameter_contracts() -> Vec<ControllerParamContract> {+ use serde_json::json;++ vec![+ ControllerParamContract {+ method: "app_state.snapshot",+ required: &[],+ optional: &[],+ examples: vec![json!({})],+ },+ ControllerParamContract {+ method: "app_state.update_local_state",+ required: &[],+ optional: &["encryptionKey", "onboardingTasks", "keyringConsent"],+ examples: vec![+ json!({}),+ json!({+ "encryptionKey": null,+ "onboardingTasks": null,+ "keyringConsent": null+ }),+ json!({+ "encryptionKey": " keep whitespace ",+ "onboardingTasks": {+ "accessibilityPermissionGranted": false,+ "enabledTools": [],+ "connectedSources": [],+ "updatedAtMs": null+ },+ "keyringConsent": {+ "storageMode": "",+ "consentedAtMs": null+ }+ }),+ ],+ },+ ]+}#[test]fn app_state_schema_contracts_and_registration_are_preserved() {