Skip to content

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

chore: add test support module for RPC schemas and tests

Steven Enamakel76e86573efdb
diff --git a/crates/openhuman-core/src/test_support/README.md b/crates/openhuman-core/src/test_support/README.md
index b43dcebbec..429e3e0fe0 100644
--- a/crates/openhuman-core/src/test_support/README.md
+++ b/crates/openhuman-core/src/test_support/README.md
@@ -4,7 +4,7 @@ Test-support domain: wipe-and-reset plus read-only introspection RPCs that let E
## Responsibilities
-- Reset persistent core state in-place to the "fresh install" baseline: no authenticated user (`active_user.toml` removed, `api_key` cleared), onboarding not completed (`onboarding_completed=false`, `chat_onboarding_completed=false`), no cron jobs, and a wiped memory tree (chunks, summaries, content dirs, sync cursors).
+- Reset persistent core state in-place to the "fresh install" baseline: no authenticated user (`active_user.toml` removed, `api_key` cleared), onboarding not completed (`onboarding_completed=false`, `chat_onboarding_completed=false`), no cron jobs. Memory v2 lives in a remote engine and is not wiped.
- Short-circuit and surface errors on any individual wipe step (partial resets are treated as worse than a clear failure).
- Gate `reset` behind `OPENHUMAN_E2E_MODE` (`1`/`true`/`TRUE`/`yes`/`YES`).
- Provide narrow, read-only introspection RPCs: resolve the active workspace root, list workspace files (depth- and count-capped), read a workspace file (lossy UTF-8, 1 MiB cap), snapshot the in-flight chat map, and snapshot the wallet prepared-quote store.
@@ -15,8 +15,8 @@ Test-support domain: wipe-and-reset plus read-only introspection RPCs that let E
| File | Role |
| --- | --- |
| `crates/openhuman-core/src/test_support/mod.rs` | Export-only module: declares `introspect`, `rpc`, `schemas`; re-exports `all_test_support_controller_schemas` / `all_test_support_registered_controllers`. |
-| `crates/openhuman-core/src/test_support/rpc.rs` | `openhuman.test_reset` implementation: `reset()` wipes cron, memory tree, config fields, and active user; returns a `ResetSummary`. Includes the `OPENHUMAN_E2E_MODE` guard. |
-| `crates/openhuman-core/src/test_support/rpc_tests.rs` | Tests for the `OPENHUMAN_E2E_MODE` guard (`reset` rejects when unset; `1`/`true`/`yes` accepted) and for `wipe_memory_tree` removing content dirs. |
+| `crates/openhuman-core/src/test_support/rpc.rs` | `openhuman.test_reset` implementation: `reset()` wipes cron, config fields, and active user; returns a `ResetSummary`. Includes the `OPENHUMAN_E2E_MODE` guard. |
+| `crates/openhuman-core/src/test_support/rpc_tests.rs` | Tests for the `OPENHUMAN_E2E_MODE` guard (`reset` rejects when unset; `1`/`true`/`yes` accepted). |
| `crates/openhuman-core/src/test_support/introspect.rs` | Read-only introspection RPCs: `workspace_root`, `list_workspace_files`, `read_workspace_file`, `in_flight_chats`, `wallet_prepared_quotes`, plus the `resolve_workspace_relative` path guard and the iterative `walk_dir`. |
| `crates/openhuman-core/src/test_support/introspect_tests.rs` | Tests for `resolve_workspace_relative` only: `..` traversal (missing and existing targets), leading `/` and `./` handling, and (unix) a symlink pointing out of the workspace. The RPC functions themselves have no unit tests here; E2E specs exercise them. |
| `crates/openhuman-core/src/test_support/schemas.rs` | `ControllerSchema` definitions, the registered-controller list, and `handle_*` dispatchers that delegate to `rpc`/`introspect` and serialize via `Outcome::into_cli_compatible_json`. |
@@ -38,7 +38,7 @@ Six controllers, registered into the global registry via `crates/openhuman-core/
| Namespace.function | Inputs | Purpose |
| --- | --- | --- |
-| `test.reset` | none | Wipe auth, onboarding, cron, and memory tree to a fresh-install baseline. Requires `OPENHUMAN_E2E_MODE`. |
+| `test.reset` | none | Wipe auth, onboarding, and cron to a fresh-install baseline. Requires `OPENHUMAN_E2E_MODE`. |
| `test_support.workspace_root` | none | Return active `workspace_dir` path + existence. |
| `test_support.list_workspace_files` | `rel_root?`, `max_depth?` | Recursive listing, capped at depth 6 / 2000 entries. |
| `test_support.read_workspace_file` | `rel_path`, `max_bytes?` | Lossy-UTF-8 file read, capped at 1 MiB; rejects `..` escapes. |
@@ -50,14 +50,13 @@ Note the `reset` controller uses namespace `test` (method `openhuman.test_reset`
## Persistence
This module owns no state of its own. It mutates and reads state owned by other domains:
-- Wipes: cron jobs (`cron::clear_all_jobs`), memory tree rows/content dirs/sync state (`memory::read_rpc::wipe_all_rpc`), config fields (`onboarding_completed`, `chat_onboarding_completed`, `api_key`), and `active_user.toml` (`config::clear_active_user` under `default_root_openhuman_dir`).
+- Wipes: cron jobs (`cron::clear_all_jobs`), config fields (`onboarding_completed`, `chat_onboarding_completed`, `api_key`), and `active_user.toml` (`config::clear_active_user` under `default_root_openhuman_dir`).
- Reads: workspace files under `Config::workspace_dir`, the in-process `IN_FLIGHT` chat map, and the in-memory wallet prepared-quote store.
## Dependencies
- `crate::config`: `Config::load_or_init`/`save`, `workspace_dir`, `clear_active_user`, `default_root_openhuman_dir`; config is the source of truth for the workspace root and the fields reset wipes.
- `crate::cron`: `clear_all_jobs` to wipe scheduled jobs during reset.
-- `crate::memory::read_rpc`: `wipe_all_rpc` to clear memory-tree rows, content dirs, and sync state.
- `crate::web_chat`: `in_flight_entries_for_test` to snapshot the live `IN_FLIGHT` chat map.
- `crate::web3::wallet`: `prepared_quotes_for_test` and `PreparedTransaction` to snapshot prepared quotes.
- `crate::core::all`: `ControllerFuture`, `RegisteredController` for handler wiring.
diff --git a/crates/openhuman-core/src/test_support/rpc.rs b/crates/openhuman-core/src/test_support/rpc.rs
index 3879f225c5..9d292ba4a8 100644
--- a/crates/openhuman-core/src/test_support/rpc.rs
+++ b/crates/openhuman-core/src/test_support/rpc.rs
@@ -4,7 +4,6 @@
//! - no authenticated user (active_user.toml removed, api_key cleared)
//! - onboarding not yet completed (onboarding_completed=false, chat_onboarding_completed=false)
//! - no cron jobs (so the post-onboarding seed re-creates `morning_briefing`)
-//! - no memory-tree chunks, summaries, content dirs, or sync cursors
//!
//! It is intentionally in-process: the sidecar keeps running. Specs reload
//! the webview after this call so the renderer also starts from a blank slate.
@@ -16,7 +15,6 @@ use crate::config::Config;
use crate::config::{clear_active_user, default_root_openhuman_dir};
use crate::core::Outcome;
use crate::cron;
-use crate::memory::read_rpc;
const E2E_MODE_ENV_VAR: &str = "OPENHUMAN_E2E_MODE";
@@ -24,21 +22,11 @@ const E2E_MODE_ENV_VAR: &str = "OPENHUMAN_E2E_MODE";
#[derive(Debug, Serialize)]
pub struct ResetSummary {
pub cron_jobs_removed: usize,
- pub memory_tree_rows_deleted: u64,
- pub memory_tree_dirs_removed: Vec<String>,
- pub memory_tree_sync_state_cleared: u64,
pub onboarding_was_completed: bool,
pub api_key_was_set: bool,
pub active_user_cleared: bool,
}
-#[derive(Debug, Serialize)]
-struct MemoryTreeResetSummary {
- rows_deleted: u64,
- dirs_removed: Vec<String>,
- sync_state_cleared: u64,
-}
-
fn ensure_e2e_mode_enabled() -> Result<(), String> {
ensure_e2e_mode_value(std::env::var(E2E_MODE_ENV_VAR).ok().as_deref())
}
@@ -82,15 +70,6 @@ pub async fn reset() -> Result<Outcome<ResetSummary>, String> {
.map_err(|e| format!("test_reset: cron wipe failed: {e:#}"))?;
log::debug!("[test_reset] step=wipe_cron ok removed={cron_jobs_removed}");
- log::debug!("[test_reset] step=wipe_memory_tree start");
- let memory_tree = wipe_memory_tree(&config).await?;
- log::debug!(
- "[test_reset] step=wipe_memory_tree ok rows={} dirs={:?} sync_state={}",
- memory_tree.rows_deleted,
- memory_tree.dirs_removed,
- memory_tree.sync_state_cleared
- );
-
log::debug!("[test_reset] step=clear_config_fields start");
config.onboarding_completed = false;
config.chat_onboarding_completed = false;
@@ -111,16 +90,8 @@ pub async fn reset() -> Result<Outcome<ResetSummary>, String> {
root.display()
);
- let memory_tree_log = format!(
- "memory_tree wiped rows={} dirs={:?} sync_state={}",
- memory_tree.rows_deleted, memory_tree.dirs_removed, memory_tree.sync_state_cleared
- );
-
let summary = ResetSummary {
cron_jobs_removed,
- memory_tree_rows_deleted: memory_tree.rows_deleted,
- memory_tree_dirs_removed: memory_tree.dirs_removed,
- memory_tree_sync_state_cleared: memory_tree.sync_state_cleared,
onboarding_was_completed,
api_key_was_set,
active_user_cleared: true,
@@ -135,7 +106,6 @@ pub async fn reset() -> Result<Outcome<ResetSummary>, String> {
summary,
vec![
format!("removed {cron_jobs_removed} cron jobs"),
- memory_tree_log,
format!("onboarding_completed + chat_onboarding_completed: {onboarding_was_completed} → false"),
format!("api_key cleared (was set: {api_key_was_set})"),
"active_user.toml removed".to_string(),
@@ -143,18 +113,6 @@ pub async fn reset() -> Result<Outcome<ResetSummary>, String> {
))
}
-async fn wipe_memory_tree(config: &Config) -> Result<MemoryTreeResetSummary, String> {
- let outcome = read_rpc::wipe_all_rpc(config)
- .await
- .map_err(|e| format!("test_reset: memory_tree wipe failed: {e}"))?;
- let value = outcome.value;
- Ok(MemoryTreeResetSummary {
- rows_deleted: value.rows_deleted,
- dirs_removed: value.dirs_removed,
- sync_state_cleared: value.sync_state_cleared,
- })
-}
-
#[cfg(test)]
#[path = "rpc_tests.rs"]
mod tests;
diff --git a/crates/openhuman-core/src/test_support/rpc_tests.rs b/crates/openhuman-core/src/test_support/rpc_tests.rs
index 2096f27f18..4bf8b5ae46 100644
--- a/crates/openhuman-core/src/test_support/rpc_tests.rs
+++ b/crates/openhuman-core/src/test_support/rpc_tests.rs
@@ -38,27 +38,3 @@ fn reset_guard_accepts_explicit_e2e_mode() {
ensure_e2e_mode_value(Some("true")).expect("true enables E2E mode");
ensure_e2e_mode_value(Some("yes")).expect("yes enables E2E mode");
}
-
-#[tokio::test]
-async fn wipe_memory_tree_removes_content_dirs_and_reports_summary() {
- let tmp = TempDir::new().unwrap();
- let mut config = Config::default();
- config.workspace_dir = tmp.path().join("workspace");
-
- let content_root = config.memory_tree_content_root();
- let raw_dir = content_root.join("raw");
- let wiki_dir = content_root.join("wiki");
- std::fs::create_dir_all(&raw_dir).unwrap();
- std::fs::create_dir_all(&wiki_dir).unwrap();
- std::fs::write(raw_dir.join("chunk.md"), "test chunk").unwrap();
- std::fs::write(wiki_dir.join("summary.md"), "test summary").unwrap();
-
- let summary = wipe_memory_tree(&config).await.unwrap();
-
- assert_eq!(summary.rows_deleted, 0);
- assert_eq!(summary.sync_state_cleared, 0);
- assert!(summary.dirs_removed.contains(&"raw".to_string()));
- assert!(summary.dirs_removed.contains(&"wiki".to_string()));
- assert!(!raw_dir.exists());
- assert!(!wiki_dir.exists());
-}
diff --git a/crates/openhuman-core/src/test_support/schemas.rs b/crates/openhuman-core/src/test_support/schemas.rs
index 44af17c255..3b498b5b1a 100644
--- a/crates/openhuman-core/src/test_support/schemas.rs
+++ b/crates/openhuman-core/src/test_support/schemas.rs
@@ -51,7 +51,7 @@ pub fn schemas(function: &str) -> ControllerSchema {
namespace: "test",
function: "reset",
description:
- "Wipe persistent sidecar state in-place: clears auth, onboarding, cron jobs, and memory tree. \
+ "Wipe persistent sidecar state in-place: clears auth, onboarding, and cron jobs. \
E2E specs call this between tests so each starts from a fresh-install baseline.",
inputs: vec![],
outputs: vec![FieldSchema {
@@ -64,24 +64,6 @@ pub fn schemas(function: &str) -> ControllerSchema {
comment: "Number of cron jobs deleted from the workspace database.",
required: true,
},
- FieldSchema {
- name: "memory_tree_rows_deleted",
- ty: TypeSchema::U64,
- comment: "Number of memory-tree SQLite rows deleted.",
- required: true,
- },
- FieldSchema {
- name: "memory_tree_dirs_removed",
- ty: TypeSchema::Array(Box::new(TypeSchema::String)),
- comment: "Memory-tree content directories removed.",
- required: true,
- },
- FieldSchema {
- name: "memory_tree_sync_state_cleared",
- ty: TypeSchema::U64,
- comment: "Number of Composio memory-tree sync-state rows deleted.",
- required: true,
- },
FieldSchema {
name: "onboarding_was_completed",
ty: TypeSchema::Bool,