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(doctor): restore missing daemon environment and memory agent checks
Steven Enamakel823ad2bcf517
diff --git a/crates/openhuman-core/src/platform/doctor/core.rs b/crates/openhuman-core/src/platform/doctor/core.rsindex 21910ffe6c..fe49541c7f 100644--- a/crates/openhuman-core/src/platform/doctor/core.rs+++ b/crates/openhuman-core/src/platform/doctor/core.rs@@ -15,7 +15,7 @@ mod run;mod types;mod workspace_checks;-pub use run::{run, run_models, MemoryChunkCount};+pub use run::{run, run_models, MemoryEngineCheck};pub use types::{DiagnosticItem, DoctorReport, DoctorSummary, ModelProbeEntry, ModelProbeOutcome,ModelProbeReport, ModelProbeSummary, Severity,@@ -26,4 +26,4 @@ use config_checks::{check_config_semantics, embedding_provider_validation_error}#[cfg(test)]use daemon_env_checks::truncate_for_display;#[cfg(test)]-use memory_agent_checks::{check_memory_tree_db, model_matches};+use memory_agent_checks::model_matches;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.rsindex 01f1ae23e1..af47235e87 100644--- a/crates/openhuman-core/src/platform/doctor/core/daemon_env_checks.rs+++ b/crates/openhuman-core/src/platform/doctor/core/daemon_env_checks.rs@@ -236,24 +236,6 @@ fn check_command_available(}}-// ── 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.pub(super) fn truncate_for_display(text: &str, max_len: usize) -> String {if text.chars().count() <= max_len {return text.to_string();diff --git a/crates/openhuman-core/src/platform/doctor/core/memory_agent_checks.rs b/crates/openhuman-core/src/platform/doctor/core/memory_agent_checks.rsindex 0bdeac1c1f..1a01808c3a 100644--- a/crates/openhuman-core/src/platform/doctor/core/memory_agent_checks.rs+++ b/crates/openhuman-core/src/platform/doctor/core/memory_agent_checks.rs@@ -1,77 +1,31 @@-//! Memory-tree, embedding-model, and Claude Agent SDK checks.+//! Memory-engine, embedding-model, and Claude Agent SDK checks.use crate::config::Config;use super::daemon_env_checks::{truncate_for_display, COMMAND_VERSION_PREVIEW_CHARS};-use super::run::MemoryChunkCount;+use super::run::MemoryEngineCheck;use super::types::DiagnosticItem;-pub(super) fn check_memory_tree_db(- config: &Config,- memory_chunks: &MemoryChunkCount,- items: &mut Vec<DiagnosticItem>,-) {- let cat = "memory_tree_db";- let db_path = config.workspace_dir.join("memory_tree").join("chunks.db");-- // ── Stale side-files (checked even when chunks.db is absent) ────- let base_name = db_path- .file_name()- .unwrap_or_default()- .to_string_lossy()- .into_owned();- let shm = db_path.with_file_name(format!("{base_name}-shm"));- let wal = db_path.with_file_name(format!("{base_name}-wal"));- for sidecar in [&shm, &wal] {- if sidecar.exists() {- items.push(DiagnosticItem::warn(- cat,- format!(- "stale SQLite side-file present (may indicate unclean shutdown): {}",- sidecar.display()- ),- ));- }- }-- // ── SQLite-artifact check (informational only, not a gate) ──────- if !db_path.exists() {- items.push(DiagnosticItem::warn(- cat,- format!("legacy SQLite artifact is absent: {}", db_path.display()),- ));- }-- // ── Driver probe ────────────────────────────────────────────────- // The count used to be a `SELECT COUNT(*) FROM mem_tree_chunks` through- // the engine's own connection helper. It is the bound driver's answer now,- // which is what lets this check mean something on a workspace whose memory- // is not SQLite at all — and what takes the engine crate out of this file.- match memory_chunks {- Ok(count) => {- log::debug!(- "[doctor] check_memory_tree_db: driver reported {count} chunks at {}",- db_path.display()- );- items.push(DiagnosticItem::ok(- cat,- format!(- "memory driver accessible ({count} chunks); SQLite artifact: {}",- db_path.display()- ),- ));- }- Err(err) => {- log::debug!(- "[doctor] check_memory_tree_db: chunk-count probe failed at {}: {err}",- db_path.display()- );- items.push(DiagnosticItem::error(- cat,- format!("DB probe failed at {}: {err}", db_path.display()),- ));+/// Report the memory engine: which one is bound and whether it answers, or+/// why memory is off. Off is a warning, not an error: a signed-out user with+/// no CortexDB key has memory off by design.+pub(super) fn check_memory_engine(memory: &MemoryEngineCheck, items: &mut Vec<DiagnosticItem>) {+ let cat = "memory_engine";+ log::debug!(+ "[doctor] check_memory_engine: engine={:?} status={}",+ memory.engine,+ memory.status+ );+ let engine = memory.engine.as_deref().unwrap_or("none");+ let reason = memory.reason.as_deref().unwrap_or("no reason given");+ items.push(match memory.status.as_str() {+ "ok" => DiagnosticItem::ok(cat, format!("memory engine '{engine}' is serving")),+ "degraded" => {+ DiagnosticItem::warn(cat, format!("memory engine '{engine}' is degraded: {reason}"))}- }+ "off" => DiagnosticItem::warn(cat, format!("memory is off: {reason}")),+ _ => DiagnosticItem::error(cat, format!("memory engine '{engine}' is down: {reason}")),+ });}// ── Embedding model health ───────────────────────────────────────diff --git a/crates/openhuman-core/src/platform/doctor/core/run.rs b/crates/openhuman-core/src/platform/doctor/core/run.rsindex df642800d0..4dc2e8e95b 100644--- a/crates/openhuman-core/src/platform/doctor/core/run.rs+++ b/crates/openhuman-core/src/platform/doctor/core/run.rs@@ -7,7 +7,7 @@ use crate::config::Config;use super::config_checks::check_config_semantics;use super::daemon_env_checks::{check_daemon_state, check_environment};use super::memory_agent_checks::{- check_claude_agent_sdk, check_embedding_model_health, check_memory_tree_db,+ check_claude_agent_sdk, check_embedding_model_health, check_memory_engine,};use super::types::{DiagnosticItem, DoctorReport, DoctorSummary, ModelProbeEntry, ModelProbeOutcome,@@ -15,38 +15,32 @@ use super::types::{};use super::workspace_checks::check_workspace;-/// How many chunks the bound memory driver holds, or why the count could not-/// be taken.-///-/// The one probe [`run`] cannot take for itself. The count comes from-/// `MemoryMaintenance::store_stats` — driver-neutral, and the reason this-/// check no longer opens the store's SQLite file directly (#5560) — and that-/// member is `async`, while [`run`] is blocking by contract. Blocking on it-/// from inside [`run`] is not an option in either direction: a-/// `Handle::block_on` panics on a current-thread runtime and deadlocks the-/// multi-thread one it is already occupying a worker of.-///-/// So the caller awaits it and hands the answer down. `Err` carries the-/// driver's own message and becomes the `Error` item this check has always-/// pushed when the probe failed.-pub type MemoryChunkCount = Result<u64, String>;+/// The memory engine's status, taken by the async caller (engine health is+/// an HTTP call and [`run`] is blocking by contract).+#[derive(Debug, Clone, PartialEq, Eq)]+pub struct MemoryEngineCheck {+ /// The configured engine id.+ pub engine: Option<String>,+ /// `ok` | `degraded` | `down` | `off`.+ pub status: String,+ /// Why the status is not `ok`.+ pub reason: Option<String>,+}/// Build the full doctor report.////// `ops::doctor_report` runs this in `tokio::task::spawn_blocking` because the/// checks are synchronous and may touch the file system, sqlite, or local HTTP/// endpoints. Keep this function blocking-only; add async probes in the caller-/// or behind their own runtime boundary instead of introducing `.await` here —-/// `memory_chunks` is the first probe to take that route, and `ops`'-/// `memory_chunk_count` is the shape to copy for the next one.-pub fn run(config: &Config, memory_chunks: MemoryChunkCount) -> Result<DoctorReport> {+/// (as `memory` is) instead of introducing `.await` here.+pub fn run(config: &Config, memory: MemoryEngineCheck) -> Result<DoctorReport> {let mut items: Vec<DiagnosticItem> = Vec::new();check_config_semantics(config, &mut items);check_workspace(config, &mut items);check_daemon_state(config, &mut items);check_environment(&mut items);- check_memory_tree_db(config, &memory_chunks, &mut items);+ check_memory_engine(&memory, &mut items);check_embedding_model_health(config, &mut items);check_claude_agent_sdk(config, &mut items);diff --git a/crates/openhuman-core/src/platform/doctor/ops.rs b/crates/openhuman-core/src/platform/doctor/ops.rsindex 5c4f2ff2eb..280b83e8c2 100644--- a/crates/openhuman-core/src/platform/doctor/ops.rs+++ b/crates/openhuman-core/src/platform/doctor/ops.rs@@ -6,57 +6,36 @@use crate::config::Config;use crate::core::Outcome;-use crate::platform::doctor::{self, DoctorReport, MemoryChunkCount, ModelProbeReport};+use crate::platform::doctor::{self, DoctorReport, MemoryEngineCheck, ModelProbeReport};pub async fn doctor_report(config: &Config) -> Result<Outcome<DoctorReport>, String> {// Awaited before the blocking hop, not inside it: `doctor::run` may not- // `.await`, and the driver call may not be blocked on from a runtime- // worker. See `MemoryChunkCount`.- let memory_chunks = memory_chunk_count(config).await;+ // `.await`. See `MemoryEngineCheck`.+ let memory = memory_engine_check(config).await;// `doctor::run` calls `check_embedding_model_health` which uses// `reqwest::blocking::Client` — that panics inside a tokio runtime.// Move the entire sync `run()` onto a blocking thread.let config_clone = config.clone();- let report = tokio::task::spawn_blocking(move || doctor::run(&config_clone, memory_chunks))+ let report = tokio::task::spawn_blocking(move || doctor::run(&config_clone, memory)).await.map_err(|e| format!("doctor task join error: {e}"))?.map_err(|e| e.to_string())?;Ok(Outcome::single_log(report, "doctor report generated"))}-/// How many chunks the workspace's bound memory driver holds.-///-/// `MemoryMaintenance::store_stats` is the driver-neutral answer to the-/// question `check_memory_tree_db` used to put to the engine's SQLite-/// connection directly (#5560).-///-/// A driver that does not serve `Maintenance` is reported as a **failed-/// probe**, not as zero — and that is the one judgement call in here. The-/// sibling status surfaces (`memory_tree`'s `store_stats`/`queue_stats`)-/// degrade a missing family to an empty snapshot, because a status panel that-/// errors tells the user less than one showing an empty store. The doctor is-/// the opposite surface: it exists to name what is wrong, and "0 chunks" from-/// a driver that cannot count is indistinguishable from a memory store the-/// user has just watched themselves fill.-async fn memory_chunk_count(config: &Config) -> MemoryChunkCount {- let binding = crate::memory::binding::for_config(config)?;- let Some(maintenance) = binding.provider().as_maintenance() else {- return Err(format!(- "driver '{}' does not serve Maintenance",- binding.driver_id()- ));- };- let stats = maintenance- .store_stats()- .await- .map_err(|e| format!("store_stats: {e}"))?;- log::debug!(- "[doctor] memory_chunk_count: driver='{}' chunks={}",- binding.driver_id(),- stats.chunks- );- Ok(stats.chunks)+/// The memory engine's status for the doctor report.+async fn memory_engine_check(config: &Config) -> MemoryEngineCheck {+ let view = crate::memory::ops::engine_get(config).await;+ let status = serde_json::to_value(view.status)+ .ok()+ .and_then(|value| value.as_str().map(str::to_string))+ .unwrap_or_else(|| "down".to_string());+ MemoryEngineCheck {+ engine: view.engine,+ status,+ reason: view.reason,+ }}pub async fn doctor_models(