Skip to content

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

chore(tinyhumans): add test modules for headers, enricher, and memory

Steven Enamakel4eff26ef46fc
diff --git a/crates/openhuman-tinyhumans/src/backend/headers_tests.rs b/crates/openhuman-tinyhumans/src/backend/headers_tests.rs
index e9d7139e60..8d8abcbc34 100644
--- a/crates/openhuman-tinyhumans/src/backend/headers_tests.rs
+++ b/crates/openhuman-tinyhumans/src/backend/headers_tests.rs
@@ -69,8 +69,9 @@ async fn the_profile_client_stamps_versions_and_identity_on_raw_requests() {
#[tokio::test]
async fn the_shell_version_rides_along_when_exported() {
- static ENV_LOCK: std::sync::Mutex<()> = std::sync::Mutex::new(());
- let _env = ENV_LOCK.lock().unwrap_or_else(|e| e.into_inner());
+ // The crate-wide env lock, so tests that fingerprint the attribution
+ // headers cannot observe this test's temporary variable.
+ let _env = crate::backend::url::backend_env_test_lock();
std::env::set_var(TAURI_VERSION_ENV_VAR, "9.8.7-shell+test");
let headers = attribution_headers();
std::env::remove_var(TAURI_VERSION_ENV_VAR);
diff --git a/crates/openhuman-tinyhumans/src/client/enricher_tests.rs b/crates/openhuman-tinyhumans/src/client/enricher_tests.rs
index 87522c49e6..bcaa7dac3f 100644
--- a/crates/openhuman-tinyhumans/src/client/enricher_tests.rs
+++ b/crates/openhuman-tinyhumans/src/client/enricher_tests.rs
@@ -22,6 +22,7 @@ fn socket_url_swaps_scheme_and_appends_the_handshake() {
#[test]
fn a_loopback_api_url_override_drives_every_derived_field() {
+ let _identity = crate::backend::product::product_identity_test_lock();
let _env = crate::backend::url::backend_env_test_lock();
let resolved = resolve(&config_with(Some("http://127.0.0.1:18765")));
assert_eq!(
@@ -44,6 +45,7 @@ fn a_loopback_api_url_override_drives_every_derived_field() {
#[test]
fn control_plane_and_inference_follow_the_same_rules_as_the_transport() {
+ let _identity = crate::backend::product::product_identity_test_lock();
let _env = crate::backend::url::backend_env_test_lock();
// Whatever the override, the enricher must agree with what the SDK
// transport answers to the core's `base_url` questions today.
@@ -73,6 +75,7 @@ fn control_plane_and_inference_follow_the_same_rules_as_the_transport() {
#[test]
fn attribution_headers_and_identity_come_from_this_crate() {
+ let _identity = crate::backend::product::product_identity_test_lock();
let _env = crate::backend::url::backend_env_test_lock();
let resolved = resolve(&config_with(None));
let identity = crate::backend::product::product_identity();
@@ -91,6 +94,7 @@ fn attribution_headers_and_identity_come_from_this_crate() {
#[test]
fn enrich_replaces_resolved_endpoints_and_is_visible_to_the_core_loader_hook() {
+ let _identity = crate::backend::product::product_identity_test_lock();
let _env = crate::backend::url::backend_env_test_lock();
let mut config = config_with(Some("http://127.0.0.1:1"));
assert!(config.resolved_endpoints.is_empty());
@@ -154,6 +158,7 @@ fn a_lookalike_staging_host_is_external_not_staging() {
#[test]
fn the_enricher_fills_otlp_environment_and_managed_hosts() {
+ let _identity = crate::backend::product::product_identity_test_lock();
let _env = crate::backend::url::backend_env_test_lock();
let resolved = resolve(&config_with(Some("http://127.0.0.1:18765")));
assert_eq!(
diff --git a/crates/openhuman-tinyhumans/src/memory/mod_tests.rs b/crates/openhuman-tinyhumans/src/memory/mod_tests.rs
index 779c478263..a44f6bf721 100644
--- a/crates/openhuman-tinyhumans/src/memory/mod_tests.rs
+++ b/crates/openhuman-tinyhumans/src/memory/mod_tests.rs
@@ -75,6 +75,12 @@ fn a_local_session_token_is_off() {
#[test]
fn the_host_credential_binds_below_the_endpoint_and_is_cached() {
+ // The engine cache is keyed by a fingerprint that includes the attribution
+ // headers, which derive from the process-global product identity and the
+ // shell-version variable. Hold both locks so neither changes between the
+ // two binds.
+ let _identity = crate::backend::product::product_identity_test_lock();
+ let _env = crate::backend::url::backend_env_test_lock();
let tmp = tempfile::tempdir().unwrap();
let config = config_with_endpoint(&tmp, "https://memory.example.test");
store_key(&config, "jwt.memory.test");