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
feat(auth): replace backend auth RPCs with local credential handoff
Steven Enamakel3fcdfc3b6b64
diff --git a/app/src/services/__tests__/rpcMethods.test.ts b/app/src/services/__tests__/rpcMethods.test.tsindex 5524ee549d..e4d32c68f5 100644--- a/app/src/services/__tests__/rpcMethods.test.ts+++ b/app/src/services/__tests__/rpcMethods.test.ts@@ -172,6 +172,8 @@ describe('rpcMethods catalog', () => {readWithParts('../../../../crates/openhuman-core/src/tools/registry/schemas.rs'),readWithParts('../../../../crates/openhuman-core/src/platform/health/schemas.rs'),readWithParts('../../../../crates/openhuman-core/src/channels/controllers/schemas.rs'),+ // The credential handoff RPCs (`auth_set_credential` / `auth_clear_credential`).+ readWithParts('../../../../crates/openhuman-core/src/security/credentials/schemas.rs'),// The channels_* namespace/function literals now live in the vendored// tinychannels workspace (`ChannelControllerSchema`), not in the thin// `crates/openhuman-core/src/channels/controllers/schemas.rs` adapter above, which@@ -195,21 +197,23 @@ describe('rpcMethods catalog', () => {// core.* methods (e.g. core.ping) are special dispatch methods, not in the schema catalog.if (!method.startsWith('openhuman.')) continue;const methodRoot = method.slice('openhuman.'.length);- const namespace = methodRoot.startsWith('inference_')- ? 'inference'- : methodRoot.startsWith('embeddings_')- ? 'embeddings'- : methodRoot.startsWith('providers_')- ? 'providers'- : methodRoot.startsWith('mcp_clients_')- ? 'mcp_clients'- : methodRoot.startsWith('health_')- ? 'health'- : methodRoot.startsWith('channels_')- ? 'channels'- : methodRoot.startsWith('tool_registry_')- ? 'tool_registry'- : 'config';+ const namespace = methodRoot.startsWith('auth_')+ ? 'auth'+ : methodRoot.startsWith('inference_')+ ? 'inference'+ : methodRoot.startsWith('embeddings_')+ ? 'embeddings'+ : methodRoot.startsWith('providers_')+ ? 'providers'+ : methodRoot.startsWith('mcp_clients_')+ ? 'mcp_clients'+ : methodRoot.startsWith('health_')+ ? 'health'+ : methodRoot.startsWith('channels_')+ ? 'channels'+ : methodRoot.startsWith('tool_registry_')+ ? 'tool_registry'+ : 'config';const fnName = methodRoot.slice(`${namespace}_`.length);expect(schemaSources).toContain(`namespace: "${namespace}"`);expect(schemaSources).toContain(`function: "${fnName}"`);diff --git a/tests/config_auth_app_state_connectivity_e2e.rs b/tests/config_auth_app_state_connectivity_e2e.rsindex 40f880eef6..62e8945d80 100644--- a/tests/config_auth_app_state_connectivity_e2e.rs+++ b/tests/config_auth_app_state_connectivity_e2e.rs@@ -50,9 +50,6 @@ use openhuman_core::platform::connectivity::{connectivity_controller_schema,};use openhuman_core::security::credentials::bus::SessionExpiredSubscriber;-use openhuman_core::security::credentials::cli::{- cli_auth_list, cli_auth_login, cli_auth_logout, cli_auth_status, parse_field_equals_entries,-};use openhuman_core::security::credentials::profiles::{AuthProfile, AuthProfilesStore, TokenSet};use openhuman_core::security::credentials::session_support::{build_session_state, get_session_token, is_local_session_token, load_app_session_profile,@@ -2677,99 +2674,6 @@ async fn credentials_secret_helpers_round_trip_with_file_keyring_backend() {assert_eq!(decrypted, "worker-a-sensitive-value");}-#[tokio::test]-async fn auth_cli_flows_cover_app_session_and_provider_storage_paths() {- let _lock = env_lock();- let harness = setup().await;-- let fields = parse_field_equals_entries(&[- "scope=repo".to_string(),- "refresh_token=refresh-1".to_string(),- ])- .expect("parse cli fields");- assert_eq!(fields.get("scope").and_then(Value::as_str), Some("repo"));- assert!(parse_field_equals_entries(&["not-key-value".to_string()]).is_err());- assert!(parse_field_equals_entries(&[" =blank".to_string()]).is_err());-- let provider_login = cli_auth_login(- " github ".to_string(),- "provider-token".to_string(),- None,- None,- fields,- Some("work".to_string()),- true,- )- .await- .expect("provider cli login");- assert!(- provider_login.to_string().contains("github"),- "provider login should mention provider: {provider_login}"- );-- let provider_status = cli_auth_status("github".to_string(), None)- .await- .expect("provider status");- assert!(- provider_status.to_string().contains("github"),- "provider status should include github profile: {provider_status}"- );-- let provider_list = cli_auth_list(Some(" github ".to_string()))- .await- .expect("provider list");- assert!(- provider_list.to_string().contains("github"),- "provider list should include github profile: {provider_list}"- );-- let provider_logout = cli_auth_logout("github".to_string(), Some("work".to_string()))- .await- .expect("provider logout");- assert!(- provider_logout.to_string().contains("removed")- || provider_logout.to_string().contains("true"),- "provider logout should report removal: {provider_logout}"- );-- let session_login = cli_auth_login(- APP_SESSION_PROVIDER.to_string(),- "header.payload.local".to_string(),- Some("cli-user".to_string()),- Some(json!({ "id": "cli-user", "name": "CLI User" })),- Value::Object(Default::default()),- None,- true,- )- .await- .expect("app-session cli login");- assert!(- session_login.to_string().contains("app-session")- && session_login.to_string().contains("session stored"),- "session login should store app session profile: {session_login}"- );-- let session_status = cli_auth_status(APP_SESSION_PROVIDER.to_string(), None)- .await- .expect("session status");- assert!(- session_status.to_string().contains("isAuthenticated")- || session_status.to_string().contains("cli-user"),- "session status should expose auth state: {session_status}"- );-- let session_logout = cli_auth_logout(APP_SESSION_PROVIDER.to_string(), None)- .await- .expect("session logout");- assert!(- session_logout.to_string().contains("isAuthenticated")- || session_logout.to_string().contains("false")- || session_logout.to_string().contains("removed"),- "session logout should clear auth state: {session_logout}"- );-- harness.join.abort();-}#[tokio::test]async fn worker_a_controller_schemas_are_fully_exposed() {@@ -3714,27 +3618,29 @@ async fn auth_credentials_controller_paths_round_trip_and_validate_errors() {"session token read should return a token field even when empty: {token}");+ // The core no longer talks to the backend's auth endpoints: a session JWT+ // arrives already obtained, and one that is not tied to a user is refused.assert_error_contains(&rpc(&harness.rpc_base,20_003,- "openhuman.auth_get_me",- json!({}),+ "openhuman.auth_set_credential",+ json!({ "token": "opaque-jwt" }),).await,- "auth_get_me without session",- "session JWT required",+ "auth_set_credential without a user id",+ "userId required",);assert_error_contains(&rpc(&harness.rpc_base,20_004,- "openhuman.auth_consume_login_token",- json!({ "loginToken": "" }),+ "openhuman.auth_set_credential",+ json!({ "token": "sk-1", "kind": "jwt" }),).await,- "auth_consume_login_token empty",- "loginToken is required",+ "auth_set_credential unknown kind",+ "unknown credential kind",);assert_error_contains(&rpc(@@ -3915,9 +3821,9 @@ async fn auth_credentials_controller_paths_round_trip_and_validate_errors() {.await;assert_eq!(payload(&session, "auth_store_session")- .get("provider")+ .get("credential").and_then(Value::as_str),- Some("app-session")+ Some("local"));let authed = rpc(@@ -3973,9 +3879,9 @@ async fn auth_local_session_normalizes_user_and_app_state_snapshot_uses_stored_i.await;assert_eq!(payload(&session, "auth_store_session local")- .get("provider")+ .get("credential").and_then(Value::as_str),- Some("app-session")+ Some("local"));let state = rpc(@@ -4059,681 +3965,13 @@ async fn auth_local_session_normalizes_user_and_app_state_snapshot_uses_stored_iharness.join.abort();}-#[tokio::test]-async fn auth_remote_backend_paths_and_app_state_current_user_cache_round_trip() {- let _lock = env_lock();- let (backend_base, backend_state, backend_join) = serve_mock_backend().await;- let harness = setup().await;- let _backend_guard = EnvVarGuard::set("BACKEND_URL", &backend_base);-- let session = rpc(- &harness.rpc_base,- 22_001,- "openhuman.auth_store_session",- json!({- "token": "remote-jwt",- "user_id": "remote-user-1",- "user": {- "id": "stale-renderer-user",- "name": "Renderer Cache",- "email": "[email protected]"- }- }),- )- .await;- assert_eq!(- payload(&session, "auth_store_session remote")- .get("provider")- .and_then(Value::as_str),- Some("app-session")- );- assert_eq!(- backend_state.auth_me_hits.load(Ordering::SeqCst),- 1,- "store_session should validate the JWT once"- );-- let me = rpc(- &harness.rpc_base,- 22_002,- "openhuman.auth_get_me",- json!({}),- )- .await;- assert_eq!(- payload(&me, "auth_get_me remote")- .get("email")- .and_then(Value::as_str),- Some("[email protected]")- );-- let consumed = rpc(- &harness.rpc_base,- 22_003,- "openhuman.auth_consume_login_token",- json!({ "loginToken": "telegram-login-token" }),- )- .await;- assert_eq!(- payload(&consumed, "auth_consume_login_token remote")- .get("jwtToken")- .and_then(Value::as_str),- Some("jwt-from-telegram-login-token")- );-- let link = rpc(- &harness.rpc_base,- 22_004,- "openhuman.auth_create_channel_link_token",- json!({ "channel": " Telegram " }),- )- .await;- assert_eq!(- payload(&link, "auth_create_channel_link_token remote")- .get("linkToken")- .and_then(Value::as_str),- Some("link-token-123")- );-- let integrations = rpc(- &harness.rpc_base,- 22_005,- "openhuman.auth_oauth_list_integrations",- json!({}),- )- .await;- assert_eq!(- payload(&integrations, "auth_oauth_list_integrations remote")- .pointer("/0/provider")- .and_then(Value::as_str),- Some("github")- );-- let oauth_connect = rpc(- &harness.rpc_base,- 22_011,- "openhuman.auth_oauth_connect",- json!({- "provider": "github",- "skillId": "worker-a-skill",- "responseType": "code",- "encryptionMode": "handoff"- }),- )- .await;- assert_eq!(- payload(&oauth_connect, "auth_oauth_connect remote")- .get("state")- .and_then(Value::as_str),- Some("worker-a-state")- );- assert_eq!(- payload(&oauth_connect, "auth_oauth_connect remote")- .get("oauthUrl")- .and_then(Value::as_str),- Some("https://github.example.test/oauth?state=worker-a-state")- );-- let integration_tokens = rpc(- &harness.rpc_base,- 22_012,- "openhuman.auth_oauth_fetch_integration_tokens",- json!({- "integrationId": "0123456789abcdef01234567",- "key": "0123456789abcdef0123456789abcdef"- }),- )- .await;- assert_eq!(- payload(- &integration_tokens,- "auth_oauth_fetch_integration_tokens remote"- )- .get("accessToken")- .and_then(Value::as_str),- Some("gh-access-token")- );- assert_eq!(- payload(- &integration_tokens,- "auth_oauth_fetch_integration_tokens remote"- )- .get("refreshToken")- .and_then(Value::as_str),- Some("gh-refresh-token")- );-- let client_key = rpc(- &harness.rpc_base,- 22_006,- "openhuman.auth_oauth_fetch_client_key",- json!({ "integrationId": "0123456789abcdef01234567" }),- )- .await;- assert_eq!(- payload(&client_key, "auth_oauth_fetch_client_key remote")- .get("clientKey")- .and_then(Value::as_str),- Some("client-key-share")- );-- let revoked = rpc(- &harness.rpc_base,- 22_007,- "openhuman.auth_oauth_revoke_integration",- json!({ "integrationId": "0123456789abcdef01234567" }),- )- .await;- assert_eq!(- payload(&revoked, "auth_oauth_revoke_integration remote")- .get("revoked")- .and_then(Value::as_bool),- Some(true)- );-- assert_error_contains(- &rpc(- &harness.rpc_base,- 22_008,- "openhuman.auth_oauth_fetch_integration_tokens",- json!({ "integrationId": "short", "key": "secret" }),- )- .await,- "auth_oauth_fetch_integration_tokens invalid id with session",- "integrationId must be a 24-char hex id",- );-- let snapshot = rpc(- &harness.rpc_base,- 22_009,- "openhuman.app_state_snapshot",- json!({}),- )- .await;- assert_eq!(- payload(&snapshot, "app_state_snapshot remote")- .pointer("/currentUser/email")- .and_then(Value::as_str),- Some("[email protected]")- );- let hits_after_first_snapshot = backend_state.auth_me_hits.load(Ordering::SeqCst);- assert!(- hits_after_first_snapshot >= 3,- "store_session, auth_get_me, and snapshot should all touch /auth/me at least once"- );-- let cached_snapshot = rpc(- &harness.rpc_base,- 22_010,- "openhuman.app_state_snapshot",- json!({}),- )- .await;- assert_eq!(- payload(&cached_snapshot, "app_state_snapshot remote cached")- .pointer("/currentUser/name")- .and_then(Value::as_str),- Some("Remote Worker")- );- assert_eq!(- backend_state.auth_me_hits.load(Ordering::SeqCst),- hits_after_first_snapshot,- "the second snapshot should reuse the current-user cache"- );-- let identity = openhuman_core::desktop::app_state::peek_cached_current_user_identity()- .expect("snapshot should seed cached identity");- assert_eq!(identity.id.as_deref(), Some("remote-user-1"));- assert_eq!(identity.name.as_deref(), Some("Remote Worker"));- assert_eq!(- identity.email.as_deref(),- Some("[email protected]")- );-- harness.join.abort();- backend_join.abort();-}--#[tokio::test]-async fn auth_remote_backend_path_prefix_is_preserved_for_app_state_refresh() {- let _lock = env_lock();- let (backend_base, backend_state, backend_join) = serve_mock_backend().await;- let harness = setup().await;- let _backend_guard = EnvVarGuard::set("BACKEND_URL", &format!("{backend_base}/api"));-- let session = rpc(- &harness.rpc_base,- 22_051,- "openhuman.auth_store_session",- json!({- "token": "remote-path-prefix-jwt",- "user_id": "remote-user-1",- "user": {- "id": "stale-path-prefix-user",- "name": "Path Prefix Renderer",- "email": "[email protected]"- }- }),- )- .await;- assert_eq!(- payload(&session, "auth_store_session with backend path prefix")- .get("provider")- .and_then(Value::as_str),- Some("app-session")- );-- let snapshot = rpc(- &harness.rpc_base,- 22_052,- "openhuman.app_state_snapshot",- json!({}),- )- .await;- assert_eq!(- payload(&snapshot, "app_state_snapshot with backend path prefix")- .pointer("/currentUser/email")- .and_then(Value::as_str),- Some("[email protected]"),- "app_state should join auth/me below the configured backend path prefix"- );- assert!(- backend_state.auth_me_hits.load(Ordering::SeqCst) >= 2,- "store_session and app_state snapshot should both hit the prefixed backend"- );-- harness.join.abort();- backend_join.abort();-}--#[tokio::test]-async fn app_state_snapshot_clears_empty_current_user_cache_and_falls_back_to_stored_user() {- let _lock = env_lock();- let (backend_base, backend_state, backend_join) = serve_sequence_auth_backend().await;- let harness = setup().await;- let _backend_guard = EnvVarGuard::set("BACKEND_URL", &backend_base);-- let session = rpc(- &harness.rpc_base,- 22_101,- "openhuman.auth_store_session",- json!({- "token": "sequence-remote-jwt",- "user_id": "stored-sequence-user",- "user": {- "id": "stored-sequence-user",- "name": "Stored Sequence Worker",- "email": "[email protected]"- }- }),- )- .await;- assert_eq!(- payload(&session, "auth_store_session sequence")- .get("provider")- .and_then(Value::as_str),- Some("app-session")- );- assert_eq!(- backend_state.auth_me_hits.load(Ordering::SeqCst),- 1,- "store_session should validate the sequence JWT once"- );-- let empty_user_snapshot = rpc(- &harness.rpc_base,- 22_102,- "openhuman.app_state_snapshot",- json!({}),- )- .await;- assert_eq!(- backend_state.auth_me_hits.load(Ordering::SeqCst),- 2,- "first snapshot should refresh and receive the empty user payload"- );- assert_eq!(- payload(&empty_user_snapshot, "empty current-user snapshot")- .pointer("/currentUser/email")- .and_then(Value::as_str),- Some("[email protected]"),- "empty backend users should clear the cache and fall back to stored identity"- );- assert!(- openhuman_core::desktop::app_state::peek_cached_current_user_identity().is_none(),- "empty backend user should clear the process current-user cache"- );-- let failed_user_snapshot = rpc(- &harness.rpc_base,- 22_103,- "openhuman.app_state_snapshot",- json!({}),- )- .await;- assert_eq!(- backend_state.auth_me_hits.load(Ordering::SeqCst),- 3,- "second snapshot should retry after the empty-user cache clear"- );- assert_eq!(- payload(&failed_user_snapshot, "failed current-user snapshot")- .pointer("/currentUser/name")- .and_then(Value::as_str),- Some("Stored Sequence Worker"),- "failed backend user fetches should preserve stored session identity"- );-- harness.join.abort();- backend_join.abort();-}--#[tokio::test]-async fn app_state_snapshot_falls_back_to_stored_user_when_current_user_refresh_errors() {- let _lock = env_lock();- let (backend_base, backend_state, backend_join) = serve_static_auth_backend(json!({- "id": "refresh-error-user",- "name": "Refresh Error Worker",- "email": "[email protected]"- }))- .await;- let harness = setup().await;- let backend_guard = EnvVarGuard::set("BACKEND_URL", &backend_base);- let session = rpc(- &harness.rpc_base,- 22_121,- "openhuman.auth_store_session",- json!({- "token": "refresh-error-remote-jwt",- "user_id": "stored-refresh-error-user",- "user": {- "id": "stored-refresh-error-user",- "name": "Stored Refresh Error Worker",- "email": "[email protected]"- }- }),- )- .await;- assert_eq!(- payload(&session, "auth_store_session refresh-error")- .get("provider")- .and_then(Value::as_str),- Some("app-session")- );- assert_eq!(- backend_state.auth_me_hits.load(Ordering::SeqCst),- 1,- "store_session should validate the remote JWT once"- );- drop(backend_guard);- let _broken_backend = EnvVarGuard::set("BACKEND_URL", "http://127.0.0.1:1");- let snapshot = rpc(- &harness.rpc_base,- 22_122,- "openhuman.app_state_snapshot",- json!({}),- )- .await;- assert_eq!(- payload(&snapshot, "app_state_snapshot refresh-error")- .pointer("/currentUser/email")- .and_then(Value::as_str),- Some("[email protected]"),- "backend refresh transport failures should preserve stored session identity"- );- assert_eq!(- backend_state.auth_me_hits.load(Ordering::SeqCst),- 1,- "snapshot should use the broken backend URL instead of hitting the original backend"- );- harness.join.abort();- backend_join.abort();-}-#[tokio::test]-async fn app_state_snapshot_clears_null_current_user_cache_and_falls_back_to_stored_user() {- let _lock = env_lock();- let (backend_base, backend_state, backend_join) = serve_null_auth_backend().await;- let harness = setup().await;- let _backend_guard = EnvVarGuard::set("BACKEND_URL", &backend_base);- let session = rpc(- &harness.rpc_base,- 22_151,- "openhuman.auth_store_session",- json!({- "token": "null-sequence-remote-jwt",- "user_id": "stored-null-sequence-user",- "user": {- "id": "stored-null-sequence-user",- "name": "Stored Null Sequence Worker",- "email": "[email protected]"- }- }),- )- .await;- assert_eq!(- payload(&session, "auth_store_session null sequence")- .get("provider")- .and_then(Value::as_str),- Some("app-session")- );- assert_eq!(- backend_state.auth_me_hits.load(Ordering::SeqCst),- 1,- "store_session should validate the null-sequence JWT once"- );-- let snapshot = rpc(- &harness.rpc_base,- 22_152,- "openhuman.app_state_snapshot",- json!({}),- )- .await;- assert_eq!(- backend_state.auth_me_hits.load(Ordering::SeqCst),- 2,- "snapshot should refresh and receive the null user payload"- );- assert_eq!(- payload(&snapshot, "null current-user snapshot")- .pointer("/currentUser/email")- .and_then(Value::as_str),- Some("[email protected]"),- "null backend users should clear the cache and fall back to stored identity"- );- assert!(- openhuman_core::desktop::app_state::peek_cached_current_user_identity().is_none(),- "null backend user should clear the process current-user cache"- );- harness.join.abort();- backend_join.abort();-}-#[tokio::test]-async fn app_state_cached_identity_peek_accepts_legacy_current_user_fields() {- let _lock = env_lock();- let (backend_base, backend_state, backend_join) = serve_static_auth_backend(json!({- "user_id": "legacy-user-id",- "displayName": "Legacy Display",- "email": "[email protected]"- }))- .await;- let harness = setup().await;- let _backend_guard = EnvVarGuard::set("BACKEND_URL", &backend_base);-- let session = rpc(- &harness.rpc_base,- 22_201,- "openhuman.auth_store_session",- json!({- "token": "legacy-field-remote-jwt",- "user_id": "stored-legacy-user",- "user": {- "id": "stored-legacy-user",- "name": "Stored Legacy Worker",- "email": "[email protected]"- }- }),- )- .await;- assert_eq!(- payload(&session, "auth_store_session legacy fields")- .get("provider")- .and_then(Value::as_str),- Some("app-session")- );-- let snapshot = rpc(- &harness.rpc_base,- 22_202,- "openhuman.app_state_snapshot",- json!({}),- )- .await;- assert_eq!(- payload(&snapshot, "legacy-field current-user snapshot")- .pointer("/currentUser/user_id")- .and_then(Value::as_str),- Some("legacy-user-id")- );- assert_eq!(- backend_state.auth_me_hits.load(Ordering::SeqCst),- 2,- "store_session and snapshot should each fetch the static backend once"- );- let identity = openhuman_core::desktop::app_state::peek_cached_current_user_identity()- .expect("legacy current-user keys should produce a prompt identity");- assert_eq!(identity.id.as_deref(), Some("legacy-user-id"));- assert_eq!(identity.name.as_deref(), Some("Legacy Display"));- assert_eq!(- identity.email.as_deref(),- Some("[email protected]")- );-- harness.join.abort();- backend_join.abort();-}--#[tokio::test]-async fn app_state_cached_identity_peek_accepts_camel_case_fallback_fields() {- let _lock = env_lock();- let (backend_base, _backend_state, backend_join) = serve_static_auth_backend(json!({- "userId": "camel-user-id",- "fullName": "Camel Full Name"- }))- .await;- let harness = setup().await;- let _backend_guard = EnvVarGuard::set("BACKEND_URL", &backend_base);-- let session = rpc(- &harness.rpc_base,- 22_301,- "openhuman.auth_store_session",- json!({- "token": "camel-field-remote-jwt",- "user_id": "stored-camel-user",- "user": {- "id": "stored-camel-user",- "name": "Stored Camel Worker",- "email": "[email protected]"- }- }),- )- .await;- assert_eq!(- payload(&session, "auth_store_session camel fields")- .get("provider")- .and_then(Value::as_str),- Some("app-session")- );-- let snapshot = rpc(- &harness.rpc_base,- 22_302,- "openhuman.app_state_snapshot",- json!({}),- )- .await;- assert_eq!(- payload(&snapshot, "camel-field current-user snapshot")- .pointer("/currentUser/userId")- .and_then(Value::as_str),- Some("camel-user-id")- );- let identity = openhuman_core::desktop::app_state::peek_cached_current_user_identity()- .expect("camel-case current-user keys should produce a prompt identity");- assert_eq!(identity.id.as_deref(), Some("camel-user-id"));- assert_eq!(identity.name.as_deref(), Some("Camel Full Name"));- assert_eq!(identity.email, None);-- harness.join.abort();- backend_join.abort();-}--#[tokio::test]-async fn app_state_cached_identity_peek_ignores_current_user_without_identity_fields() {- let _lock = env_lock();- let (backend_base, backend_state, backend_join) = serve_static_auth_backend(json!({- "metadata": "present-but-not-identity"- }))- .await;- let harness = setup().await;- let _backend_guard = EnvVarGuard::set("BACKEND_URL", &backend_base);-- let session = rpc(- &harness.rpc_base,- 22_351,- "openhuman.auth_store_session",- json!({- "token": "identity-empty-remote-jwt",- "user_id": "stored-empty-identity-user",- "user": {- "id": "stored-empty-identity-user",- "name": "Stored Empty Identity Worker",- "email": "[email protected]"- }- }),- )- .await;- assert_eq!(- payload(&session, "auth_store_session identity-empty")- .get("provider")- .and_then(Value::as_str),- Some("app-session")- );-- let snapshot = rpc(- &harness.rpc_base,- 22_352,- "openhuman.app_state_snapshot",- json!({}),- )- .await;- assert_eq!(- payload(&snapshot, "identity-empty current-user snapshot")- .pointer("/currentUser/metadata")- .and_then(Value::as_str),- Some("present-but-not-identity")- );- assert_eq!(- backend_state.auth_me_hits.load(Ordering::SeqCst),- 2,- "store_session and snapshot should each fetch the no-identity backend once"- );- assert!(- openhuman_core::desktop::app_state::peek_cached_current_user_identity().is_none(),- "current-user objects without id/name/email should not produce prompt identity"- );-- harness.join.abort();- backend_join.abort();-}#[tokio::test]async fn app_state_update_persists_and_snapshot_reads_local_state() {