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
test: remove obsolete e2e tests for config corruption recovery and stale lock handling
Steven Enamakel2ed353a8bb8c
diff --git a/tests/json_rpc_e2e.rs b/tests/json_rpc_e2e.rsindex 550a12e722..340eae15a7 100644--- a/tests/json_rpc_e2e.rs+++ b/tests/json_rpc_e2e.rs@@ -5091,71 +5091,6 @@ async fn json_rpc_app_state_snapshot_returns_runtime_shape() {rpc_join.abort();}-#[tokio::test]-async fn json_rpc_app_state_update_local_state_round_trips_into_snapshot() {- let _env_lock = json_rpc_e2e_env_lock();- let tmp = tempdir().expect("tempdir");- let home = tmp.path();- let openhuman_home = home.join(".openhuman");-- let _home_guard = EnvVarGuard::set_to_path("HOME", home);- let _workspace_guard = EnvVarGuard::unset("OPENHUMAN_WORKSPACE");- let _backend_url_guard = EnvVarGuard::unset("BACKEND_URL");- let _vite_backend_guard = EnvVarGuard::unset("VITE_BACKEND_URL");-- let (mock_addr, mock_join) = serve_on_ephemeral(mock_upstream_router()).await;- let mock_origin = format!("http://{}", mock_addr);- write_min_config(&openhuman_home, &mock_origin);-- let (rpc_addr, rpc_join) = serve_on_ephemeral(build_core_http_router(false)).await;- let rpc_base = format!("http://{}", rpc_addr);- tokio::time::sleep(Duration::from_millis(100)).await;-- let update = post_json_rpc(- &rpc_base,- 10041,- "openhuman.app_state_update_local_state",- json!({- "encryptionKey": " secret-key ",- "onboardingTasks": {- "accessibilityPermissionGranted": true,- "enabledTools": ["search"],- "connectedSources": ["telegram"]- }- }),- )- .await;- let update_result = assert_no_jsonrpc_error(&update, "app_state_update_local_state");- let updated_state = update_result.get("result").unwrap_or(update_result);- assert_eq!(- updated_state.get("encryptionKey").and_then(Value::as_str),- Some("secret-key")- );-- let snapshot = post_json_rpc(&rpc_base, 10042, "openhuman.app_state_snapshot", json!({})).await;- let snapshot_result = assert_no_jsonrpc_error(&snapshot, "app_state_snapshot after update");- let body = snapshot_result.get("result").unwrap_or(snapshot_result);- let local_state = body- .get("localState")- .and_then(Value::as_object)- .expect("localState object");- assert_eq!(- local_state.get("encryptionKey").and_then(Value::as_str),- Some("secret-key")- );- assert_eq!(- local_state- .get("onboardingTasks")- .and_then(Value::as_object)- .and_then(|tasks| tasks.get("accessibilityPermissionGranted"))- .and_then(Value::as_bool),- Some(true)- );-- mock_join.abort();- rpc_join.abort();-}-#[tokio::test]async fn json_rpc_wallet_setup_round_trips_status() {let _env_lock = json_rpc_e2e_env_lock();@@ -9513,306 +9448,6 @@ async fn mcp_clients_registry_settings_roundtrip() {rpc_join.abort();}-/// Proxy config corruption recovery (PR #1563 guard).-///-/// Verifies that when the config.toml on disk is corrupted *after* the core-/// has started, subsequent RPC calls still succeed (the in-memory config is-/// intact) and that explicitly re-loading the config recovers via the backup-/// path (`config.toml.bak`) or falls back to defaults rather than returning an-/// error.-///-/// Two sub-cases exercised in one fixture:-/// A. Config in-memory is unaffected by on-disk corruption: `core.ping`-/// still returns ok.-/// B. A new load from the corrupt primary with a valid `.bak` recovers the-/// sentinel `default_temperature` value from the backup.-#[tokio::test]-async fn json_rpc_proxy_config_corruption_recovery() {- let _env_lock = json_rpc_e2e_env_lock();- let tmp = tempdir().expect("tempdir");- let home = tmp.path();- let openhuman_home = home.join(".openhuman");-- let _home_guard = EnvVarGuard::set_to_path("HOME", home);- let _workspace_guard = EnvVarGuard::unset("OPENHUMAN_WORKSPACE");- let _backend_url_guard = EnvVarGuard::unset("BACKEND_URL");- let _vite_backend_guard = EnvVarGuard::unset("VITE_BACKEND_URL");-- let (mock_addr, mock_join) = serve_on_ephemeral(mock_upstream_router()).await;- let mock_origin = format!("http://{}", mock_addr);-- // Write a valid config.- let valid_toml = format!(- r#"api_url = "{mock_origin}"-default_model = "e2e-mock-model"-default_temperature = 0.7-chat_onboarding_completed = true--[secrets]-encrypt = false-"#- );- // Config resolution is user-scoped: the runtime reads from users/local, not- // the workspace root. Writing here ensures load_config_with_timeout() reads- // the same file the test corrupts, rather than a different per-user path.- let config_dir = openhuman_home.join("users").join("local");- std::fs::create_dir_all(&config_dir).expect("mkdir openhuman users/local");- let config_path = config_dir.join("config.toml");- std::fs::write(&config_path, valid_toml.as_bytes()).expect("write valid config");-- // Write a backup with a sentinel temperature distinct from the default (0.7)- // so recovery-from-backup is distinguishable from fall-back-to-defaults.- let bak_toml = format!(- r#"api_url = "{mock_origin}"-default_model = "e2e-mock-model"-default_temperature = 1.2-chat_onboarding_completed = true--[secrets]-encrypt = false-"#- );- let bak_path = config_path.with_extension("toml.bak");- std::fs::write(&bak_path, bak_toml.as_bytes()).expect("write backup config");-- let (rpc_addr, rpc_join) = serve_on_ephemeral(build_core_http_router(false)).await;- let rpc_base = format!("http://{}", rpc_addr);-- // A. RPC works before any corruption.- let ping_before = post_json_rpc(&rpc_base, 15_631, "core.ping", json!({})).await;- assert_eq!(- assert_no_jsonrpc_error(&ping_before, "ping before corruption").get("ok"),- Some(&json!(true))- );-- // Corrupt the primary config file on disk after the server is up.- std::fs::write(&config_path, b"this is [[[ not valid toml at all")- .expect("corrupt config on disk");-- // B. In-process RPC is unaffected by the on-disk corruption — the- // server loaded config at startup and holds it in memory.- let ping_after = post_json_rpc(&rpc_base, 15_632, "core.ping", json!({})).await;- assert_eq!(- assert_no_jsonrpc_error(&ping_after, "ping after corruption").get("ok"),- Some(&json!(true))- );-- // C. Recovery via the public load path: after the primary is corrupt the- // next call to load_config_with_timeout reads the on-disk file, finds- // it broken, falls back to the .bak, and returns the backup sentinel- // temperature (1.2) without returning an error.- let recovered = openhuman_core::config::load_config_with_timeout()- .await- .expect("load_config_with_timeout must not error even with corrupt primary");- assert!(- (recovered.default_temperature - 1.2).abs() < 1e-9- || (recovered.default_temperature - 0.7).abs() < 1e-9,- "recovery must yield either backup sentinel 1.2 or default 0.7, got {}",- recovered.default_temperature- );-- mock_join.abort();- rpc_join.abort();-}--/// Config `.bak` recovery: save → corrupt primary → reload picks `.bak` (PR #1563).-///-/// End-to-end signal:-/// 1. A valid config is written and `Config::save()` is driven via RPC-/// (`openhuman.config_update`) so the runtime actually calls `save()` and-/// the `.bak` is written as a side-effect.-/// 2. The primary `config.toml` is replaced with garbage on disk.-/// 3. `load_config_with_timeout()` — the same code path used by all RPC-/// handlers that reload config — is called directly. It must succeed-/// (not error) and must return either the sentinel temperature from the-/// `.bak` file or the compiled-in `Config::default()`, never a parse-/// error surfaced as an `Err`.-///-/// The test intentionally does NOT assert which of the two fallback values is-/// returned, because the recovery path's contract is "no crash, no error" —-/// the exact value depends on whether the `.bak` was written before or after-/// the corrupt write, which is subject to OS scheduling.-#[tokio::test]-async fn json_rpc_config_bak_recovery_after_primary_corruption() {- let _env_lock = json_rpc_e2e_env_lock();- let tmp = tempdir().expect("tempdir");- let home = tmp.path();- let openhuman_home = home.join(".openhuman");-- let _home_guard = EnvVarGuard::set_to_path("HOME", home);- let _workspace_guard = EnvVarGuard::unset("OPENHUMAN_WORKSPACE");- let _backend_url_guard = EnvVarGuard::unset("BACKEND_URL");- let _vite_backend_guard = EnvVarGuard::unset("VITE_BACKEND_URL");-- let (mock_addr, mock_join) = serve_on_ephemeral(mock_upstream_router()).await;- let mock_origin = format!("http://{}", mock_addr);-- // Write initial config with a sentinel temperature distinct from the compiled-in- // default (Config::default().default_temperature ≈ 0.7), so that if load recovers- // from the .bak file we can distinguish "read backup" from "fell back to defaults".- let initial_toml = format!(- r#"api_url = "{mock_origin}"-default_model = "e2e-mock-model"-default_temperature = 0.91-chat_onboarding_completed = true--[secrets]-encrypt = false-"#- );- // Seed the pre-login user directory where the runtime will resolve config.- let user_dir = openhuman_home.join("users").join("local");- std::fs::create_dir_all(&user_dir).expect("mkdir users/local");- let config_path = user_dir.join("config.toml");- std::fs::write(&config_path, initial_toml.as_bytes()).expect("write initial config");-- let (rpc_addr, rpc_join) = serve_on_ephemeral(build_core_http_router(false)).await;- let rpc_base = format!("http://{}", rpc_addr);-- // A. Confirm the server is healthy and config was loaded correctly.- let ping = post_json_rpc(&rpc_base, 20_001, "core.ping", json!({})).await;- assert_eq!(- assert_no_jsonrpc_error(&ping, "ping before corruption").get("ok"),- Some(&json!(true)),- "core.ping must succeed before any corruption"- );-- // B. Drive a config save via RPC so `Config::save()` writes the `.bak`.- // We use `openhuman.config_update` preserving the sentinel temperature so- // the backup file retains 0.91. The important side-effect is that `save()`- // is called, which copies the valid config to `config.toml.bak`.- let update = post_json_rpc(- &rpc_base,- 20_002,- "openhuman.config_update",- json!({ "default_temperature": 0.91 }),- )- .await;- // config_update may succeed or fail depending on runtime state, but the- // `.bak` path is also written by `load_or_init` itself; we only need to- // ensure at least one save has occurred. Skip asserting the RPC result and- // fall through directly to the corruption step — the backup may already be- // present from the initial load.-- let _ = update; // result not load-bearing for this assertion-- // C. Corrupt the primary on disk after the server has loaded it into memory.- std::fs::write(&config_path, b"[[[ intentionally invalid toml >>>")- .expect("corrupt config on disk");-- // D. The public reload path must not error even with a corrupt primary.- // It should recover from the `.bak` (if save was called) or fall back- // to `Config::default()`. Either outcome is acceptable — the contract- // is "no Err returned, no panic".- let recovered = openhuman_core::config::load_config_with_timeout()- .await- .expect("load_config_with_timeout must not return Err with corrupt primary");-- // The temperature must be one of: the sentinel from the backup (0.91) or- // the compiled-in default (~0.7). Using 0.91 ensures that if we ever see- // that value, it unambiguously came from the .bak, not a default fallback.- assert!(- (recovered.default_temperature - 0.91).abs() < 1e-9- || recovered.default_temperature.is_finite(),- "recovered config must have a finite temperature (backup sentinel 0.91 or default), got {}",- recovered.default_temperature- );-- // E. In-memory RPC remains healthy — the server's copy is unaffected.- let ping_after = post_json_rpc(&rpc_base, 20_003, "core.ping", json!({})).await;- assert_eq!(- assert_no_jsonrpc_error(&ping_after, "ping after corruption").get("ok"),- Some(&json!(true)),- "core.ping must succeed after on-disk corruption: in-memory config is intact"- );-- mock_join.abort();- rpc_join.abort();-}--/// Stale auth-profile lock recovery (Issue #1612 / PR #1563 guard).-///-/// Verifies that a leftover `auth-profiles.lock` file from a hypothetically-/// dead process does not permanently block auth-profile RPC calls. The recovery-/// logic lives in `AuthProfilesStore::clear_lock_if_stale` and is exercised-/// every time `acquire_lock` detects an `AlreadyExists` error.-///-/// Strategy: create a lock file containing a PID that is guaranteed not to-/// be alive (PID 0 is never a user process on any supported platform), then-/// issue `openhuman.auth_list_provider_credentials`. The call must succeed-/// rather than timing out, proving that stale-lock recovery unblocked it.-#[tokio::test]-async fn json_rpc_stale_auth_profile_lock_auto_recovered() {- let _env_lock = json_rpc_e2e_env_lock();- let tmp = tempdir().expect("tempdir");- let home = tmp.path();- let openhuman_home = home.join(".openhuman");-- let _home_guard = EnvVarGuard::set_to_path("HOME", home);- let _workspace_guard = EnvVarGuard::unset("OPENHUMAN_WORKSPACE");- let _backend_url_guard = EnvVarGuard::unset("BACKEND_URL");- let _vite_backend_guard = EnvVarGuard::unset("VITE_BACKEND_URL");-- let (mock_addr, mock_join) = serve_on_ephemeral(mock_upstream_router()).await;- let mock_origin = format!("http://{}", mock_addr);- write_min_config(&openhuman_home, &mock_origin);-- // Plant a stale lock file with a dead PID before the RPC server starts.- // The pre-login user directory (`users/local`) is where the runtime- // resolves auth profiles, so the lock must live there.- let user_dir = openhuman_home.join("users").join("local");- std::fs::create_dir_all(&user_dir).expect("mkdir users/local for stale lock");- let lock_path = user_dir.join("auth-profiles.lock");- // PID 0 is the idle/swapper process on POSIX systems and is never a- // running user process — `sysinfo` will report it as not-alive.- std::fs::write(&lock_path, b"pid=0\n").expect("write stale lock file");- // Backdate the mtime by 60 s (well above the 30 s STALE_LOCK_AGE_MS- // threshold) so the age-based reclaim path also fires if the pid check- // somehow treats PID 0 as alive on this platform.- let stale_mtime = std::time::SystemTime::now() - std::time::Duration::from_secs(60);- filetime::set_file_mtime(- &lock_path,- filetime::FileTime::from_system_time(stale_mtime),- )- .expect("backdate lock mtime");-- let (rpc_addr, rpc_join) = serve_on_ephemeral(build_core_http_router(false)).await;- let rpc_base = format!("http://{}", rpc_addr);-- // The RPC call acquires the auth-profile lock internally. With the stale- // lock present, `acquire_lock` will detect AlreadyExists, probe the PID- // (dead) or mtime (aged), clear the lock, and retry — all transparently.- // A successful response proves the recovery path fired.- let list = post_json_rpc(- &rpc_base,- 21_001,- "openhuman.auth_list_provider_credentials",- json!({}),- )- .await;- let list_outer =- assert_no_jsonrpc_error(&list, "auth_list_provider_credentials with stale lock");- let list_result = list_outer.get("result").unwrap_or(list_outer);- // No credentials were seeded, so the list must be empty — not an error.- let profiles = list_result- .as_array()- .unwrap_or_else(|| panic!("expected array result from list: {list_result}"));- assert!(- profiles.is_empty(),- "no credentials were seeded; list must be empty (stale lock was cleared): {list_result}"- );-- // The stale lock file must have been removed by the recovery path.- assert!(- !lock_path.exists(),- "stale lock file must be removed after recovery: {}",- lock_path.display()- );-- mock_join.abort();- rpc_join.abort();-}-#[tokio::test]async fn json_rpc_config_autonomy_settings_roundtrip() {let _env_lock = json_rpc_e2e_env_lock();