Skip to content

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

chore(scope): remove unused test files and dead code

Steven Enamakele2b29c346b89
diff --git a/crates/openhuman-core/src/platform/doctor/core/daemon_env_checks.rs b/crates/openhuman-core/src/platform/doctor/core/daemon_env_checks.rs
new file mode 100644
index 0000000000..51c7e63a39
--- /dev/null
+++ b/crates/openhuman-core/src/platform/doctor/core/daemon_env_checks.rs
@@ -0,0 +1,277 @@
+//! Daemon liveness, environment, and command-availability checks.
+
+use chrono::{DateTime, Utc};
+
+use crate::config::Config;
+
+use super::types::DiagnosticItem;
+
+const DAEMON_STALE_SECONDS: i64 = 30;
+const SCHEDULER_STALE_SECONDS: i64 = 120;
+const CHANNEL_STALE_SECONDS: i64 = 300;
+const COMMAND_VERSION_PREVIEW_CHARS: usize = 60;
+
+pub(super) fn check_daemon_state(config: &Config, items: &mut Vec<DiagnosticItem>) {
+ let cat = "daemon";
+ let state_file = crate::platform::service::daemon::state_file_path(config);
+
+ if !state_file.exists() {
+ items.push(DiagnosticItem::error(
+ cat,
+ format!(
+ "state file not found: {} - is the daemon running?",
+ state_file.display()
+ ),
+ ));
+ return;
+ }
+
+ let raw = match std::fs::read_to_string(&state_file) {
+ Ok(r) => r,
+ Err(e) => {
+ items.push(DiagnosticItem::error(
+ cat,
+ format!("cannot read state file: {e}"),
+ ));
+ return;
+ }
+ };
+
+ let snapshot: serde_json::Value = match serde_json::from_str(&raw) {
+ Ok(v) => v,
+ Err(e) => {
+ items.push(DiagnosticItem::error(
+ cat,
+ format!("invalid state JSON: {e}"),
+ ));
+ return;
+ }
+ };
+
+ // Daemon heartbeat freshness
+ let updated_at = snapshot
+ .get("updated_at")
+ .and_then(serde_json::Value::as_str)
+ .unwrap_or("");
+
+ if let Ok(ts) = DateTime::parse_from_rfc3339(updated_at) {
+ let age = Utc::now()
+ .signed_duration_since(ts.with_timezone(&Utc))
+ .num_seconds();
+ if age <= DAEMON_STALE_SECONDS {
+ items.push(DiagnosticItem::ok(
+ cat,
+ format!("heartbeat fresh ({age}s ago)"),
+ ));
+ } else {
+ items.push(DiagnosticItem::error(
+ cat,
+ format!("heartbeat stale ({age}s ago)"),
+ ));
+ }
+ } else {
+ items.push(DiagnosticItem::error(
+ cat,
+ format!("invalid daemon timestamp: {updated_at}"),
+ ));
+ }
+
+ // Components
+ if let Some(components) = snapshot
+ .get("components")
+ .and_then(serde_json::Value::as_object)
+ {
+ // Scheduler
+ if let Some(scheduler) = components.get("scheduler") {
+ let scheduler_ok = scheduler
+ .get("status")
+ .and_then(serde_json::Value::as_str)
+ .is_some_and(|s| s == "ok");
+ let scheduler_age = scheduler
+ .get("last_ok")
+ .and_then(serde_json::Value::as_str)
+ .and_then(parse_rfc3339)
+ .map_or(i64::MAX, |dt| {
+ Utc::now().signed_duration_since(dt).num_seconds()
+ });
+
+ if scheduler_ok && scheduler_age <= SCHEDULER_STALE_SECONDS {
+ items.push(DiagnosticItem::ok(
+ cat,
+ format!("scheduler healthy (last ok {scheduler_age}s ago)"),
+ ));
+ } else {
+ items.push(DiagnosticItem::error(
+ cat,
+ format!("scheduler unhealthy (ok={scheduler_ok}, age={scheduler_age}s)"),
+ ));
+ }
+ } else {
+ items.push(DiagnosticItem::warn(
+ cat,
+ "scheduler component not tracked yet",
+ ));
+ }
+
+ // Channels
+ let mut channel_count = 0u32;
+ let mut stale = 0u32;
+ for (name, component) in components {
+ if !name.starts_with("channel:") {
+ continue;
+ }
+ channel_count += 1;
+ let status_ok = component
+ .get("status")
+ .and_then(serde_json::Value::as_str)
+ .is_some_and(|s| s == "ok");
+ let age = component
+ .get("last_ok")
+ .and_then(serde_json::Value::as_str)
+ .and_then(parse_rfc3339)
+ .map_or(i64::MAX, |dt| {
+ Utc::now().signed_duration_since(dt).num_seconds()
+ });
+
+ if status_ok && age <= CHANNEL_STALE_SECONDS {
+ items.push(DiagnosticItem::ok(
+ cat,
+ format!("{name} fresh ({age}s ago)"),
+ ));
+ } else {
+ stale += 1;
+ items.push(DiagnosticItem::error(
+ cat,
+ format!("{name} stale (ok={status_ok}, age={age}s)"),
+ ));
+ }
+ }
+
+ if channel_count == 0 {
+ items.push(DiagnosticItem::warn(
+ cat,
+ "no channel components tracked yet",
+ ));
+ } else if stale > 0 {
+ items.push(DiagnosticItem::warn(
+ cat,
+ format!("{channel_count} channels, {stale} stale"),
+ ));
+ }
+ }
+}
+
+// ── Environment checks ───────────────────────────────────────────
+
+pub(super) fn check_environment(items: &mut Vec<DiagnosticItem>) {
+ let cat = "environment";
+
+ // git
+ check_command_available("git", &["--version"], cat, items);
+
+ // Shell
+ let shell = std::env::var("SHELL").unwrap_or_default();
+ if shell.is_empty() {
+ items.push(DiagnosticItem::warn(cat, "$SHELL not set"));
+ } else {
+ items.push(DiagnosticItem::ok(cat, format!("shell: {shell}")));
+ }
+
+ // HOME
+ if std::env::var("HOME").is_ok() || std::env::var("USERPROFILE").is_ok() {
+ items.push(DiagnosticItem::ok(cat, "home directory env set"));
+ } else {
+ items.push(DiagnosticItem::error(
+ cat,
+ "neither $HOME nor $USERPROFILE is set",
+ ));
+ }
+
+ // Optional tools
+ check_command_available("curl", &["--version"], cat, items);
+}
+
+fn check_command_available(
+ cmd: &str,
+ args: &[&str],
+ cat: &'static str,
+ items: &mut Vec<DiagnosticItem>,
+) {
+ let mut child_cmd = std::process::Command::new(cmd);
+ child_cmd
+ .args(args)
+ .stdout(std::process::Stdio::piped())
+ .stderr(std::process::Stdio::piped());
+ #[cfg(windows)]
+ {
+ use std::os::windows::process::CommandExt;
+ child_cmd.creation_flags(0x0800_0000); // CREATE_NO_WINDOW
+ }
+ match child_cmd.output() {
+ Ok(output) if output.status.success() => {
+ let version = String::from_utf8_lossy(&output.stdout)
+ .lines()
+ .next()
+ .unwrap_or("(unknown)")
+ .to_string();
+ items.push(DiagnosticItem::ok(cat, format!("{cmd}: {version}")));
+ }
+ Ok(output) => {
+ let preview = String::from_utf8_lossy(&output.stderr)
+ .lines()
+ .next()
+ .unwrap_or("(failed)")
+ .to_string();
+ items.push(DiagnosticItem::warn(
+ cat,
+ format!("{cmd} not available ({preview})"),
+ ));
+ }
+ Err(err) => {
+ items.push(DiagnosticItem::warn(
+ cat,
+ format!("{cmd} not available ({err})"),
+ ));
+ }
+ }
+}
+
+// ── Memory-tree DB health ────────────────────────────────────────
+
+/// Probe the memory-tree and push [`DiagnosticItem`]s.
+///
+/// - If the legacy SQLite file does not exist: `Warn` (not yet created by the
+/// embedded driver). This is an informational SQLite-artifact check, not a
+/// gate: drivers that store memory elsewhere have no `chunks.db` by design.
+/// - If a stale `.db-shm` file is present alongside the DB: `Warn`.
+/// - If the driver answered with a chunk count: `Ok`.
+/// - If it did not: `Error`.
+///
+/// The file checks are this function's own — they are `std::fs` calls about a
+/// path, and a driver has nothing to say about them. The count is
+/// `memory_chunks`, taken by the async caller: see [`MemoryChunkCount`] for
+/// why it arrives as an argument rather than being read here.
+///
+/// The driver probe always runs regardless of file existence, so a bound driver
+/// that does not use SQLite still surfaces its health here.
+fn truncate_for_display(text: &str, max_len: usize) -> String {
+ if text.chars().count() <= max_len {
+ return text.to_string();
+ }
+
+ let mut out = String::new();
+ for (idx, ch) in text.chars().enumerate() {
+ if idx >= max_len {
+ break;
+ }
+ out.push(ch);
+ }
+ out.push_str("...");
+ out
+}
+
+fn parse_rfc3339(input: &str) -> Option<DateTime<Utc>> {
+ DateTime::parse_from_rfc3339(input)
+ .ok()
+ .map(|dt| dt.with_timezone(&Utc))
+}
diff --git a/crates/openhuman-core/src/security/keyring/encrypted_store_tests_part_01_tests.rs b/crates/openhuman-core/src/security/keyring/encrypted_store_crypto_migration_tests.rs
similarity index 100%
rename from crates/openhuman-core/src/security/keyring/encrypted_store_tests_part_01_tests.rs
rename to crates/openhuman-core/src/security/keyring/encrypted_store_crypto_migration_tests.rs
diff --git a/crates/openhuman-core/src/security/keyring/encrypted_store_tests_part_02_tests.rs b/crates/openhuman-core/src/security/keyring/encrypted_store_key_management_tests.rs
similarity index 100%
rename from crates/openhuman-core/src/security/keyring/encrypted_store_tests_part_02_tests.rs
rename to crates/openhuman-core/src/security/keyring/encrypted_store_key_management_tests.rs
diff --git a/crates/openhuman-core/src/threads/ops_tests.rs b/crates/openhuman-core/src/threads/ops_tests.rs
index b98f8f11ca..759e158fb6 100644
--- a/crates/openhuman-core/src/threads/ops_tests.rs
+++ b/crates/openhuman-core/src/threads/ops_tests.rs
@@ -82,7 +82,7 @@ async fn create_thread_with_title(_workspace: &tempfile::TempDir, thread_id: &st
.expect("ensure thread");
}
-#[path = "ops_tests_part_01_tests.rs"]
-mod part_01_tests;
-#[path = "ops_tests_part_02_tests.rs"]
-mod part_02_tests;
+#[path = "ops_conversion_tests.rs"]
+mod conversion_tests;
+#[path = "ops_title_and_cancellation_tests.rs"]
+mod title_and_cancellation_tests;
diff --git a/crates/openhuman-core/src/tools/impl/browser/browser_backend_resolution.rs b/crates/openhuman-core/src/tools/impl/browser/browser_backend_resolution.rs
index 478bef9802..b48556e890 100644
--- a/crates/openhuman-core/src/tools/impl/browser/browser_backend_resolution.rs
+++ b/crates/openhuman-core/src/tools/impl/browser/browser_backend_resolution.rs
@@ -4,7 +4,7 @@
use super::*;
impl BrowserTool {
- fn computer_use_endpoint_url(&self) -> anyhow::Result<reqwest::Url> {
+ pub(super) fn computer_use_endpoint_url(&self) -> anyhow::Result<reqwest::Url> {
if self.computer_use.timeout_ms == 0 {
anyhow::bail!("browser.computer_use.timeout_ms must be > 0");
}
@@ -136,7 +136,7 @@ impl BrowserTool {
}
/// Validate URL against allowlist
- fn validate_url(&self, url: &str) -> anyhow::Result<()> {
+ pub(super) fn validate_url(&self, url: &str) -> anyhow::Result<()> {
let url = url.trim();
if url.is_empty() {
diff --git a/crates/openhuman-core/src/tools/impl/browser/browser_computer_use.rs b/crates/openhuman-core/src/tools/impl/browser/browser_computer_use.rs
index db162a95ac..222b2487ae 100644
--- a/crates/openhuman-core/src/tools/impl/browser/browser_computer_use.rs
+++ b/crates/openhuman-core/src/tools/impl/browser/browser_computer_use.rs
@@ -4,7 +4,7 @@
use super::*;
impl BrowserTool {
- fn validate_coordinate(&self, key: &str, value: i64, max: Option<i64>) -> anyhow::Result<()> {
+ pub(super) fn validate_coordinate(&self, key: &str, value: i64, max: Option<i64>) -> anyhow::Result<()> {
if value < 0 {
anyhow::bail!("'{key}' must be >= 0")
}
@@ -30,7 +30,7 @@ impl BrowserTool {
.ok_or_else(|| anyhow::anyhow!("Missing or invalid '{key}' parameter"))
}
- fn validate_computer_use_action(
+ pub(super) fn validate_computer_use_action(
&self,
action: &str,
params: &serde_json::Map<String, Value>,
diff --git a/crates/openhuman-core/src/tools/impl/browser/browser_execution.rs b/crates/openhuman-core/src/tools/impl/browser/browser_execution.rs
index 865ccdcdfd..48b21021a7 100644
--- a/crates/openhuman-core/src/tools/impl/browser/browser_execution.rs
+++ b/crates/openhuman-core/src/tools/impl/browser/browser_execution.rs
@@ -235,7 +235,7 @@ impl BrowserTool {
))
}
- async fn execute_action(
+ pub(super) async fn execute_action(
&self,
action: BrowserAction,
backend: ResolvedBackend,