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
fix(ci): port keyring and session-import e2e tests to the storage ports
M3gA-Mindf96fccb7789d
diff --git a/tests/cli_sigpipe.rs b/tests/cli_sigpipe.rsindex 9e3ffc68e3..084bf5d1f0 100644--- a/tests/cli_sigpipe.rs+++ b/tests/cli_sigpipe.rs@@ -109,9 +109,68 @@ fn headless_default_keyring_stores_provider_secrets_encrypted() {String::from_utf8_lossy(&output.stderr));- let encrypted = std::fs::read(workspace_path.join("secrets.enc"))- .expect("default backend should create the encrypted keyring file");- assert!(!encrypted- .windows(secret.len())- .any(|window| window == secret.as_bytes()));+ // Since the storage ports (#7686) a configured backend (the CLI default is+ // `sqlite:<workspace>/storage`) holds user secrets as encrypted `enc2:`+ // documents (`storage/secrets.rs`) instead of `secrets.enc`. Assert the+ // property, not the file name: the plaintext is nowhere under the+ // workspace, and an encrypted record is.+ let files = files_under(&workspace_path);+ let mut saw_encrypted_record = false;+ for path in &files {+ let bytes = std::fs::read(path).expect("read workspace file");+ assert!(+ !bytes+ .windows(secret.len())+ .any(|window| window == secret.as_bytes()),+ "provider secret stored in plaintext at {}",+ path.display()+ );+ saw_encrypted_record |= bytes.windows(5).any(|window| window == b"enc2:");+ }+ assert!(+ saw_encrypted_record,+ "no encrypted secret record under the workspace; files: {files:?}"+ );++ // And the stored credential reads back in a fresh process.+ let listed = Command::new(env!("CARGO_BIN_EXE_openhuman-core"))+ .args([+ "call",+ "--method",+ "openhuman.auth_list_provider_credentials",+ "--params",+ r#"{"provider":"openai"}"#,+ ])+ .current_dir(&workspace_path)+ .env("OPENHUMAN_WORKSPACE", &workspace_path)+ .env("OPENHUMAN_KEYRING_MASTER_KEY", "42".repeat(32))+ .env_remove("OPENHUMAN_KEYRING_MASTER_KEY_FILE")+ .env_remove("OPENHUMAN_APP_ENV")+ .env_remove("OPENHUMAN_KEYRING_BACKEND")+ .env_remove("OPENHUMAN_MODE")+ .output()+ .expect("run provider credential list command");+ let stdout = String::from_utf8_lossy(&listed.stdout);+ assert!(+ listed.status.success() && stdout.contains("openai"),+ "stored credential not listed: stdout={stdout} stderr={}",+ String::from_utf8_lossy(&listed.stderr)+ );+}++/// Every regular file under `root`, recursively.+fn files_under(root: &std::path::Path) -> Vec<std::path::PathBuf> {+ let mut files = Vec::new();+ let mut dirs = vec![root.to_path_buf()];+ while let Some(dir) = dirs.pop() {+ for entry in std::fs::read_dir(&dir).expect("read workspace dir") {+ let path = entry.expect("workspace dir entry").path();+ if path.is_dir() {+ dirs.push(path);+ } else if path.is_file() {+ files.push(path);+ }+ }+ }+ files}diff --git a/tests/raw_coverage/session_store_e2e.rs b/tests/raw_coverage/session_store_e2e.rsindex db830da836..2e5786c8fc 100644--- a/tests/raw_coverage/session_store_e2e.rs+++ b/tests/raw_coverage/session_store_e2e.rs@@ -28,7 +28,7 @@use crate::env_guard::EnvVarGuard;use std::net::SocketAddr;use std::path::{Path, PathBuf};-use std::sync::{OnceLock};+use std::sync::OnceLock;use std::time::Duration;use axum::http::header::AUTHORIZATION;@@ -67,7 +67,8 @@ fn env_lock() -> tokio::sync::MutexGuard<'static, ()> {async fn env_lock_async() -> tokio::sync::MutexGuard<'static, ()> {ENV_LOCK.get_or_init(|| tokio::sync::Mutex::new(()))- .lock().await+ .lock()+ .await}fn ensure_rpc_auth() {@@ -248,7 +249,7 @@ fn error_message(value: &Value, context: &str) -> String {/// `session_import.run` over a seeded legacy `session_raw/` directory:/// dry-run plans without writing, the real run imports, and a second run is-/// idempotent because the item ledger says the work is done.+/// idempotent because the per-workspace marker says the work is done.#[tokio::test]async fn session_import_plans_imports_then_skips_on_rerun() {let _lock = env_lock_async().await;@@ -300,33 +301,29 @@ async fn session_import_plans_imports_then_skips_on_rerun() {).await;let planned = payload(&planned, "session_import_run dry");+ // Since the storage ports (#7686) the run imports into the storage backend+ // through TinyAgents' legacy reader and reports per domain+ // (`agent/session_import/schemas.rs`): a dry run lists the legacy sources+ // it found and imports nothing.assert_eq!(planned.get("dry_run").and_then(Value::as_bool), Some(true));assert_eq!(- planned.get("scanned").and_then(Value::as_u64),- Some(1),- "the seeded transcript must be discovered: {planned}"+ planned+ .pointer("/sources/session_raw")+ .and_then(Value::as_bool),+ Some(true),+ "the seeded transcript directory must be discovered: {planned}");assert_eq!(- planned.get("messages_written").and_then(Value::as_u64),+ planned+ .get("imports")+ .and_then(Value::as_array)+ .map(Vec::len),Some(0),- "a dry run writes no messages: {planned}"- );- let planned_item = planned- .get("items")- .and_then(Value::as_array)- .and_then(|items| items.first())- .unwrap_or_else(|| panic!("dry run must report the item: {planned}"))- .clone();- assert_eq!(- planned_item.get("action").and_then(Value::as_str),- Some("would_import"),- "dry-run action: {planned_item}"+ "a dry run imports nothing: {planned}");- // A dry run must not write the global marker either — proved below by the- // real run still having work to do. Asserting on the store *directory* would- // be wrong: `run_import` opens the stores before it decides to plan only.- // ── real run: writes the messages into the TinyAgents store ──+ // ── real run: writes the transcript into the storage backend ──+ // It still has work to do, which also proves the dry run wrote no marker.let imported = rpc(&harness.rpc_base,31_002,@@ -339,49 +336,18 @@ async fn session_import_plans_imports_then_skips_on_rerun() {imported.get("dry_run").and_then(Value::as_bool),Some(false));- assert_eq!(- imported.get("imported").and_then(Value::as_u64),- Some(1),- "one source imported: {imported}"- );- assert_eq!(- imported.get("failed").and_then(Value::as_u64),- Some(0),- "no failures: {imported}"- );- assert_eq!(- imported.get("messages_written").and_then(Value::as_u64),- Some(4),- "the four message lines are written; the `_meta` header is not a message: {imported}"- );- let item = imported- .get("items")- .and_then(Value::as_array)- .and_then(|items| items.first())- .unwrap_or_else(|| panic!("the real run must report the item: {imported}"))- .clone();- assert_eq!(item.get("action").and_then(Value::as_str), Some("imported"));- assert_eq!(- item.get("messages").and_then(Value::as_u64),- Some(4),- "the per-item count must agree with the run total: {item}"- );- assert_eq!(- item.get("thread_id").and_then(Value::as_str),- Some("e2e-session-import-thread"),- "the thread id must come from the transcript's `_meta`, not be synthesized: {item}"- );- assert_eq!(- item.get("stream").and_then(Value::as_str),- Some("session.20260907_capitals.messages"),- "messages go to a per-session journal stream named from the stem: {item}"- );+ let outcome = sessions_outcome(&imported);+ let written = outcome+ .strip_prefix("Imported {")+ .and_then(|rest| rest.split("written: ").nth(1))+ .and_then(|rest| rest.trim_end_matches([' ', '}']).parse::<u64>().ok())+ .unwrap_or_else(|| panic!("the real run must import: {imported}"));assert!(- harness.workspace.join("tinyagents_store").exists(),- "the real run must create the store"+ written > 0,+ "the transcript's messages must be written: {imported}");- // ── re-run: idempotent ──+ // ── re-run: idempotent, short-circuited by the per-workspace marker ──let again = rpc(&harness.rpc_base,31_003,@@ -391,19 +357,33 @@ async fn session_import_plans_imports_then_skips_on_rerun() {.await;let again = payload(&again, "session_import_run rerun");assert_eq!(- again.get("messages_written").and_then(Value::as_u64),- Some(0),- "a second run must write nothing: {again}"- );- assert!(- again.get("already_done").and_then(Value::as_bool) == Some(true)- || again.get("skipped").and_then(Value::as_u64) == Some(1),- "the re-run must be short-circuited by the marker or the item ledger: {again}"+ sessions_outcome(&again),+ "AlreadyDone",+ "a second run must be short-circuited by the marker: {again}");harness.join.abort();}+/// The `sessions` domain's outcome in a `session_import_run` result, as the+/// handler renders it (`format!("{outcome:?}")`); an import error fails here.+fn sessions_outcome(result: &Value) -> String {+ let entry = result+ .get("imports")+ .and_then(Value::as_array)+ .and_then(|imports| {+ imports+ .iter()+ .find(|i| i.get("domain").and_then(Value::as_str) == Some("sessions"))+ })+ .unwrap_or_else(|| panic!("no sessions import reported: {result}"));+ entry+ .get("outcome")+ .and_then(Value::as_str)+ .unwrap_or_else(|| panic!("the sessions import failed: {entry}"))+ .to_string()+}+/// Failure path: `dry_run` is declared `Option<Bool>` in the schema, so the/// dispatcher's type check refuses a string before `run_import` opens a store or/// scans a directory.