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
chore: files changed crates/openhuman-core/src/core/all.rs,crates/openhuman-core/src/core/all_keyrin
Steven Enamakel7c35d163a70a
diff --git a/crates/openhuman-core/src/core/all.rs b/crates/openhuman-core/src/core/all.rsindex a641aab10b..f81d72ff5e 100644--- a/crates/openhuman-core/src/core/all.rs+++ b/crates/openhuman-core/src/core/all.rs@@ -388,10 +388,10 @@ fn build_registered_controllers() -> Vec<GroupedController> {crate::security::encryption::all_encryption_controller_entries(),);// Keyring consent — user approval before local secret storage fallback- push(+ push_entries(&mut controllers,DomainGroup::Security,- crate::security::keyring_consent::all_keyring_consent_registered_controllers(),+ crate::security::keyring_consent::all_keyring_consent_controller_entries(),);// Security policy metadatapush(diff --git a/crates/openhuman-core/src/core/all_keyring_consent_controller_tests.rs b/crates/openhuman-core/src/core/all_keyring_consent_controller_tests.rsindex 6c5a4da0ff..0ceda2b258 100644--- a/crates/openhuman-core/src/core/all_keyring_consent_controller_tests.rs+++ b/crates/openhuman-core/src/core/all_keyring_consent_controller_tests.rs@@ -1,38 +1,6 @@use super::*;use serde_json::{json, Map};-fn keyring_consent_fixture_contracts() -> Vec<ControllerParamContract> {- vec![- ControllerParamContract {- method: "keyring_consent.status",- required: &[],- optional: &[],- examples: vec![json!({})],- },- ControllerParamContract {- method: "keyring_consent.decide",- required: &["mode"],- optional: &[],- examples: [- "local_encrypted",- "declined",- "",- "unknown",- " local_encrypted ",- ]- .into_iter()- .map(|mode| json!({ "mode": mode }))- .collect(),- },- ControllerParamContract {- method: "keyring_consent.retry_probe",- required: &[],- optional: &[],- examples: vec![json!({})],- },- ]-}-fn keyring_consent_entries() -> Vec<ControllerEntry> {registry().iter()@@ -59,7 +27,7 @@ fn raw_keyring_consent_registry_matches_its_independent_contract() {registry(),internal_registry(),&contract,- &keyring_consent_fixture_contracts(),+ &crate::security::keyring_consent::keyring_consent_parameter_contracts(),).expect("raw Keyring Consent entries retain their ordered wire contracts");}@@ -111,7 +79,7 @@ fn raw_keyring_consent_decoders_pin_their_safe_wire_boundary() {decide.decode_params(Map::new()).unwrap_err(),"missing required param 'mode'");- for value in [json!(null), json!(false), json!(7), json!([]), json!({})] {+ for value in [json!(null), json!(false), json!(0.5), json!([]), json!({})] {assert_eq!(decide.decode_params(Map::from_iter([("mode".into(), value)]))@@ -121,6 +89,32 @@ fn raw_keyring_consent_decoders_pin_their_safe_wire_boundary() {}}+#[test]+fn raw_keyring_consent_decide_rejects_before_persistence() {+ let decide = keyring_consent_entries()+ .into_iter()+ .find(|entry| entry.schema.function == "decide")+ .expect("raw decide entry");+ let missing =+ futures::executor::block_on(decide.invoke(DispatchCtx::unbound(), Map::new())).unwrap_err();+ assert_eq!(missing, "missing required param 'mode'");+ let wrong_type = futures::executor::block_on(decide.invoke(+ DispatchCtx::unbound(),+ Map::from_iter([("mode".into(), json!(false))]),+ ))+ .unwrap_err();+ assert_eq!(wrong_type, "missing required param 'mode'");+ let unknown = futures::executor::block_on(decide.invoke(+ DispatchCtx::unbound(),+ Map::from_iter([("mode".into(), json!("unknown"))]),+ ))+ .unwrap_err();+ assert_eq!(+ unknown,+ "invalid mode 'unknown': expected 'local_encrypted' or 'declined'"+ );+}+#[test]fn raw_keyring_consent_wire_fields_are_exact() {let entries = keyring_consent_entries();diff --git a/crates/openhuman-core/src/security/keyring_consent/mod.rs b/crates/openhuman-core/src/security/keyring_consent/mod.rsindex 70647218c2..e39956cea2 100644--- a/crates/openhuman-core/src/security/keyring_consent/mod.rs+++ b/crates/openhuman-core/src/security/keyring_consent/mod.rs@@ -6,6 +6,9 @@ pub mod policy;mod schemas;pub mod types;+pub(crate) use schemas::all_keyring_consent_controller_entries;+#[cfg(test)]+pub(crate) use schemas::keyring_consent_parameter_contracts;pub use schemas::{all_keyring_consent_controller_schemas, all_keyring_consent_registered_controllers,};diff --git a/crates/openhuman-core/src/security/keyring_consent/schemas.rs b/crates/openhuman-core/src/security/keyring_consent/schemas.rsindex 6121016897..c70893e9be 100644--- a/crates/openhuman-core/src/security/keyring_consent/schemas.rs+++ b/crates/openhuman-core/src/security/keyring_consent/schemas.rs@@ -3,7 +3,9 @@use crate::core::runtime::DispatchCtx;use serde_json::{Map, Value};-use crate::core::all::{ControllerFuture, RegisteredController};+use crate::core::all::{+ BoundRegisteredController, ControllerEntry, ControllerFuture, RegisteredController,+};use crate::core::{ControllerSchema, FieldSchema, TypeSchema};pub fn all_keyring_consent_controller_schemas() -> Vec<ControllerSchema> {@@ -31,6 +33,20 @@ pub fn all_keyring_consent_registered_controllers() -> Vec<RegisteredController>]}+pub(crate) fn all_keyring_consent_controller_entries() -> Vec<ControllerEntry> {+ vec![+ ControllerEntry::bound(status_controller()),+ ControllerEntry::bound(decide_controller()),+ ControllerEntry::bound(retry_probe_controller()),+ ]+}++#[cfg(test)]+pub(crate) fn keyring_consent_parameter_contracts() -> Vec<crate::core::all::ControllerParamContract>+{+ tests::parameter_contracts()+}+fn keyring_consent_schema(function: &str) -> ControllerSchema {match function {"status" => ControllerSchema {@@ -90,6 +106,49 @@ fn keyring_consent_schema(function: &str) -> ControllerSchema {}fn handle_status(_ctx: DispatchCtx, _params: Map<String, Value>) -> ControllerFuture {+ status_controller().invoke(_ctx, _params)+}++fn handle_decide(ctx: DispatchCtx, params: Map<String, Value>) -> ControllerFuture {+ decide_controller().invoke(ctx, params)+}++fn handle_retry_probe(_ctx: DispatchCtx, _params: Map<String, Value>) -> ControllerFuture {+ retry_probe_controller().invoke(_ctx, _params)+}++fn status_controller() -> BoundRegisteredController {+ BoundRegisteredController::typed(keyring_consent_schema("status"), parse_status, run_status)+}++fn decide_controller() -> BoundRegisteredController {+ BoundRegisteredController::typed(keyring_consent_schema("decide"), parse_decide, run_decide)+}++fn retry_probe_controller() -> BoundRegisteredController {+ BoundRegisteredController::typed(+ keyring_consent_schema("retry_probe"),+ parse_retry_probe,+ run_retry_probe,+ )+}++fn parse_status(_params: Map<String, Value>) -> Result<(), String> {+ Ok(())+}++fn parse_decide(params: Map<String, Value>) -> Result<String, String> {+ match params.get("mode") {+ Some(Value::String(mode)) => Ok(mode.clone()),+ _ => Err("missing required param 'mode'".into()),+ }+}++fn parse_retry_probe(_params: Map<String, Value>) -> Result<(), String> {+ Ok(())+}++fn run_status(_ctx: DispatchCtx, (): ()) -> ControllerFuture {Box::pin(async move {super::ops::keyring_status().await?@@ -97,20 +156,15 @@ fn handle_status(_ctx: DispatchCtx, _params: Map<String, Value>) -> ControllerFu})}-fn handle_decide(ctx: DispatchCtx, params: Map<String, Value>) -> ControllerFuture {+fn run_decide(ctx: DispatchCtx, mode: String) -> ControllerFuture {Box::pin(async move {- let mode = params- .get("mode")- .and_then(|v| v.as_str())- .ok_or("missing required param 'mode'")?- .to_string();super::ops::keyring_consent_decide(&ctx, mode).await?.into_cli_compatible_json()})}-fn handle_retry_probe(_ctx: DispatchCtx, _params: Map<String, Value>) -> ControllerFuture {+fn run_retry_probe(_ctx: DispatchCtx, (): ()) -> ControllerFuture {Box::pin(async move {super::ops::keyring_retry_probe().await?diff --git a/crates/openhuman-core/src/security/keyring_consent/schemas_tests.rs b/crates/openhuman-core/src/security/keyring_consent/schemas_tests.rsindex b9795f44dd..a4fc920340 100644--- a/crates/openhuman-core/src/security/keyring_consent/schemas_tests.rs+++ b/crates/openhuman-core/src/security/keyring_consent/schemas_tests.rs@@ -1,4 +1,38 @@use super::*;+use crate::core::all::ControllerParamContract;+use serde_json::{json, Map};++pub(crate) fn parameter_contracts() -> Vec<ControllerParamContract> {+ vec![+ ControllerParamContract {+ method: "keyring_consent.status",+ required: &[],+ optional: &[],+ examples: vec![json!({})],+ },+ ControllerParamContract {+ method: "keyring_consent.decide",+ required: &["mode"],+ optional: &[],+ examples: [+ "local_encrypted",+ "declined",+ "",+ "unknown",+ " local_encrypted ",+ ]+ .into_iter()+ .map(|mode| json!({ "mode": mode }))+ .collect(),+ },+ ControllerParamContract {+ method: "keyring_consent.retry_probe",+ required: &[],+ optional: &[],+ examples: vec![json!({})],+ },+ ]+}#[test]fn schemas_and_controllers_match() {@@ -25,4 +59,50 @@ fn decide_schema_requires_mode() {assert_eq!(s.inputs.len(), 1);assert!(s.inputs[0].required);assert_eq!(s.inputs[0].name, "mode");+ assert_eq!(s.inputs[0].ty, TypeSchema::String);+ assert_eq!(s.outputs.len(), 1);+ assert_eq!(s.outputs[0].name, "result");+ assert_eq!(s.outputs[0].ty, TypeSchema::Json);+ assert!(s.outputs[0].required);+}++#[test]+fn decide_parser_preserves_every_string_byte_for_byte() {+ for mode in [+ "local_encrypted",+ "declined",+ "",+ "unknown",+ " local_encrypted ",+ ] {+ let params = Map::from_iter([+ ("mode".into(), json!(mode)),+ ("ignored".into(), json!({"nested": [1, true]})),+ ]);+ assert_eq!(+ parse_decide(params).expect("all string values pass through unchanged"),+ mode,+ );+ }+}++#[test]+fn decide_parser_uses_exact_missing_error_for_absent_or_nonstring_mode() {+ let expected = "missing required param 'mode'";+ assert_eq!(parse_decide(Map::new()).unwrap_err(), expected);+ for value in [json!(null), json!(false), json!(0.5), json!([]), json!({})] {+ assert_eq!(+ parse_decide(Map::from_iter([("mode".into(), value)]))+ .unwrap_err()+ .as_str(),+ expected,+ );+ }+}++#[test]+fn status_and_retry_probe_parsers_ignore_the_entire_parameter_map() {+ let params = Map::from_iter([("ignored".into(), json!({"anything": [null, 3.5]}))]);+ assert_eq!(parse_status(params.clone()), Ok(()));+ assert_eq!(parse_retry_probe(params), Ok(()));}