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(inference): update error code helpers to use test guards
Steven Enamakelf0141bdd176b
diff --git a/crates/openhuman-tinyhumans/src/inference/backend_error_code.rs b/crates/openhuman-tinyhumans/src/inference/backend_error_code.rsindex e514bdc9c0..0427fd9075 100644--- a/crates/openhuman-tinyhumans/src/inference/backend_error_code.rs+++ b/crates/openhuman-tinyhumans/src/inference/backend_error_code.rs@@ -128,16 +128,16 @@ pub fn is_managed_backend_envelope(err: &str) -> bool {|| lower.starts_with(&format!("{label} streaming api error"))}-/// Managed-backend Sentry-ownership decision for **string-only** call sites:-/// the error must both be a managed-backend envelope AND carry a backend-/// `errorCode` the backend owns. Wraps [`backend_error_code_skips_sentry`] with-/// the [`is_managed_backend_envelope`] gate so a BYO payload that contains an-/// `errorCode` token can't suppress FE Sentry.+/// Test helper for the historical string-only Sentry ownership predicate.+/// Production consumers use the registered classification's ownership and+/// reportability fields instead.+#[cfg(test)]pub fn managed_error_skips_sentry(err: &str) -> bool {is_managed_backend_envelope(err) && backend_error_code_skips_sentry(err)}/// Parse a recognised [`BackendErrorCode`] out of a flattened error string.+#[cfg(test)]pub fn extract_backend_error_code(err: &str) -> Option<BackendErrorCode> {extract_backend_error_code_token(err).and_then(|t| BackendErrorCode::from_token(&t))}@@ -166,9 +166,8 @@ pub fn body_flags_malformed(err: &str) -> bool {after_colon.starts_with("true")}-/// Whether the error is a backend-flagged malformed `BAD_REQUEST` — the single-/// `errorCode` case the FE *does* page (a client-built payload the backend-/// rejected as unparseable).+/// Test helper for recognizing a backend-flagged malformed `BAD_REQUEST`.+#[cfg(test)]pub fn is_backend_malformed_bad_request(err: &str) -> bool {matches!(extract_backend_error_code(err),@@ -176,9 +175,7 @@ pub fn is_backend_malformed_bad_request(err: &str) -> bool {) && body_flags_malformed(err)}-/// Whether the `errorCode` names a limit the **client enforces before sending**,-/// so a backend rejection means our pre-send guard leaked — a client-side bug-/// worth paging, not expected user-state.+/// Test helper for recognizing a reported client-side guard leak.////// - `PAYLOAD_TOO_LARGE`: the client gates attachment size up front/// (`app/src/lib/attachments.ts` — per-image / per-file byte caps + a@@ -191,6 +188,7 @@ pub fn is_backend_malformed_bad_request(err: &str) -> bool {/// The backend does not ops-alert either (they are 4xx, not 500), so if the FE/// also suppressed them the guard leak would be invisible to everyone. Display/// classification is unchanged — the user still sees the actionable copy.+#[cfg(test)]pub fn is_backend_client_guard_leak(err: &str) -> bool {matches!(extract_backend_error_code(err),@@ -207,9 +205,9 @@ pub fn is_backend_client_guard_leak(err: &str) -> bool {/// the client should have caught before sending — see/// [`is_backend_client_guard_leak`].///-/// Shared by the provider HTTP layer (`api_error`), the higher-layer re-report-/// classifier (`observability::expected_error_kind`), and the Sentry-/// `before_send` defense-in-depth filter so the three layers can't drift.+/// Production consumers use [`BackendErrorClassification`] so ownership is+/// kept separate from its optional canonical token.+#[cfg(test)]pub fn backend_error_code_skips_sentry(err: &str) -> bool {extract_backend_error_code_token(err).is_some()&& !is_backend_malformed_bad_request(err)diff --git a/crates/openhuman-tinyhumans/src/inference/tiers_tests.rs b/crates/openhuman-tinyhumans/src/inference/tiers_tests.rsindex 24a274334e..c3511f0593 100644--- a/crates/openhuman-tinyhumans/src/inference/tiers_tests.rs+++ b/crates/openhuman-tinyhumans/src/inference/tiers_tests.rs@@ -1,5 +1,11 @@use super::*;+fn normalize_with_hosted_registration(config: &mut Config) -> bool {+ let _registry = crate::registry_test_lock();+ crate::register::register_all(&crate::install::InstallOptions::default());+ super::normalize_config(config)+}+#[test]fn hosted_normalizer_rewrites_legacy_tiers_and_preserves_concrete_pins() {let mut config = Config::default();@@ -15,14 +21,14 @@ fn hosted_normalizer_rewrites_legacy_tiers_and_preserves_concrete_pins() {},);- assert!(normalize_config(&mut config));+ assert!(normalize_with_hosted_registration(&mut config));assert_eq!(config.default_model.as_deref(), Some(MODEL_MANAGED_DEFAULT));assert_eq!(config.orchestrator.model.as_deref(),Some("custom/orchestrator-model"));assert_eq!(config.agents["pinned"].model, "vendor/model-id");- assert!(!normalize_config(&mut config));+ assert!(!normalize_with_hosted_registration(&mut config));}#[test]@@ -68,7 +74,7 @@ fn hosted_normalizer_covers_all_legacy_model_fields_and_preserves_non_tiers() {},]);- assert!(normalize_config(&mut config));+ assert!(normalize_with_hosted_registration(&mut config));assert_eq!(config.default_model.as_deref(), Some(MODEL_MANAGED_DEFAULT));assert_eq!(config.orchestrator.model.as_deref(),@@ -87,19 +93,22 @@ fn hosted_normalizer_covers_all_legacy_model_fields_and_preserves_non_tiers() {assert_eq!(config.model_routes[1].model, "vendor/pinned");assert_eq!(config.model_routes[2].model, "hint:unknown");assert_eq!(config.model_routes[3].model, "");- assert!(!normalize_config(&mut config));+ assert!(!normalize_with_hosted_registration(&mut config));let mut absent = Config::default();- assert!(!normalize_config(&mut absent));+ absent.default_model = None;+ assert!(normalize_with_hosted_registration(&mut absent));assert_eq!(absent.default_model, None);+ assert!(!normalize_with_hosted_registration(&mut absent));}#[test]fn hosted_normalizer_seeds_its_preset_using_the_configured_api_url_once() {let mut config = Config::default();+ config.default_model = None;config.api_url = Some("https://custom.example/api".to_string());- assert!(normalize_config(&mut config));+ assert!(normalize_with_hosted_registration(&mut config));assert_eq!(config.default_model, None);assert_eq!(config.cloud_providers.len(), 1);let provider = &config.cloud_providers[0];@@ -107,7 +116,7 @@ fn hosted_normalizer_seeds_its_preset_using_the_configured_api_url_once() {assert_eq!(provider.endpoint, "https://custom.example/api");let id = provider.id.clone();- assert!(!normalize_config(&mut config));+ assert!(!normalize_with_hosted_registration(&mut config));assert_eq!(config.cloud_providers.len(), 1);assert_eq!(config.cloud_providers[0].id, id);}diff --git a/crates/openhuman-tinyhumans/src/register_tests.rs b/crates/openhuman-tinyhumans/src/register_tests.rsindex f9e37beaa0..4a3920d8cc 100644--- a/crates/openhuman-tinyhumans/src/register_tests.rs+++ b/crates/openhuman-tinyhumans/src/register_tests.rs@@ -11,7 +11,7 @@ fn register_all_is_idempotent() {#[tokio::test]async fn boot_registration_supplies_hosted_model_default_and_normalizer_before_context_exists() {- let _registry = crate::registry_test_lock();+ let _registry = crate::registry_test_lock_async().await;register_all(&InstallOptions::default());let config = openhuman_embed::__host::config::Config::default();