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
Read the write-audit health from the log the writer writes to\n\nThe MCP write-audit log moved to its own database, `mcp_audit/mcp_audit.db`.\nThe health probe in the tool registry did not move with it: it kept counting\n`mcp_writes` inside the memory engine's chunk database, and nothing has\nwritten that table since the move. No `INSERT INTO mcp_writes` remains\nanywhere in `src/` or the vendored tree.\n\nSo the probe reported zero writes in the last 24 hours on every install,\nindefinitely, while the log underneath it was healthy — and reported it as a\nsuccess, with `last_error: None`. A diagnostic that fails loudly is a bug; one\nthat answers confidently with a number from a table nobody writes is worse,\nbecause nothing downstream can tell it apart from a quiet install.\n\nRead through `mcp::audit` instead, which is where the writer puts rows. No\n`#[cfg]` at the call site: the tool registry is ungated and `list_writes` is\ngated, but the facade's stub mirrors it returning empty, which is what that\nfacade exists for.\n\n`AuditStore` has no count method, so the probe lists and counts, and\n`recent_rows` saturates at the store's list limit rather than reporting a true\ntotal. That is enough for the question this field answers — whether the log is\nreceiving writes at all — and the alternative is a method on a vendored crate,\na release, and a submodule re-pin for a health probe that does not need\nexactness. The cap is named in a constant and documented as a floor.\n\nThe test records a write and requires the probe to see it, rather than\nasserting a count. Asserting a count would not have caught this: the broken\nprobe returned zero, and zero is also what a healthy install with no recent\nwrites returns. Reinstating the old query fails the test.\n\nThis also removes the last reference to the memory engine from outside the\nmemory domain (openhuman#5560) — the remaining direct uses of\n`chunk_store::with_connection` are all inside `memory/tree/`.\n
Shanudac872f355bc
diff --git a/src/openhuman/tools/registry/ops.rs b/src/openhuman/tools/registry/ops.rsindex 0b0c91c7ba..1a839973fd 100644--- a/src/openhuman/tools/registry/ops.rs+++ b/src/openhuman/tools/registry/ops.rs@@ -5,9 +5,9 @@ use serde_json::{json, Map, Value};use crate::core::all;use crate::core::{ControllerSchema, FieldSchema, TypeSchema};use crate::openhuman::config::Config;+use crate::openhuman::mcp::audit::McpWriteListQuery;use crate::openhuman::mcp::server::McpToolSpec;use crate::rpc::RpcOutcome;-use tinymemory_core::store::chunks::store as chunk_store;use super::providers::capability_provider_diagnostics;use super::types::{@@ -150,18 +150,35 @@ fn mcp_allowlists_from_config(config: &Config) -> McpAllowlistDiagnostics {}}+/// How many recent writes the audit log is asked for.+///+/// The store has no count method, so the probe lists and counts. The value is+/// therefore a floor: `recent_rows` saturates here rather than reporting a+/// true total, which is enough for the question this health field answers —+/// is the audit log receiving writes at all.+const RECENT_WRITE_SAMPLE: u64 = tinymcp_bus::MAX_LIST_LIMIT;++/// Whether the write-audit log is recording, and roughly how much.+///+/// Reads through `mcp::audit`, which is where the writer puts rows. It used to+/// query the `mcp_writes` table inside the memory engine's chunk database+/// directly; when the log moved to its own store, that query stayed behind and+/// began counting a table nothing writes any more — so this reported zero+/// writes in the last 24 hours on every install, indefinitely, while the log+/// underneath it was healthy. A diagnostic that cannot fail loudly must at+/// least read the same place the writer wrote.fn mcp_write_audit_health(config: &Config) -> McpWriteAuditHealth {- let result = chunk_store::with_connection(config, |conn| {- let since_ms = chrono::Utc::now()- .timestamp_millis()- .saturating_sub(24 * 60 * 60 * 1000);- let count: i64 = conn.query_row(- "SELECT COUNT(*) FROM mcp_writes WHERE timestamp_ms >= ?1",- rusqlite::params![since_ms],- |row| row.get::<_, i64>(0),- )?;- Ok(u64::try_from(count).unwrap_or(0))- });+ let since_ms = chrono::Utc::now()+ .timestamp_millis()+ .saturating_sub(24 * 60 * 60 * 1000);+ let query = McpWriteListQuery {+ limit: Some(RECENT_WRITE_SAMPLE),+ offset: None,+ since_ms: u64::try_from(since_ms).ok(),+ ..Default::default()+ };+ let result =+ crate::openhuman::mcp::audit::list_writes(config, &query).map(|writes| writes.len() as u64);match result {Ok(count) => McpWriteAuditHealth {diff --git a/src/openhuman/tools/registry/ops_tests.rs b/src/openhuman/tools/registry/ops_tests.rsindex dc54f54cbb..0343bbf0f9 100644--- a/src/openhuman/tools/registry/ops_tests.rs+++ b/src/openhuman/tools/registry/ops_tests.rs@@ -321,6 +321,53 @@ fn capability_provider(}}+/// The health probe must read the store the writer writes to.+///+/// This is the invariant that broke: the audit log moved to its own database+/// and the probe kept querying the old table inside the memory engine's chunk+/// store, which nothing writes any more. Nothing failed — it reported zero+/// writes forever while the log underneath was healthy. Asserting a count+/// alone would not have caught that (zero is what a quiet install reports+/// too), so this writes a row first and requires the probe to see it.+#[cfg(feature = "mcp")]+#[test]+fn the_write_audit_probe_reads_the_store_the_writer_wrote_to() {+ let workspace = tempfile::tempdir().expect("tempdir");+ let config = Config {+ workspace_dir: workspace.path().to_path_buf(),+ ..Config::default()+ };++ let before = diagnostics_for_config(&config)+ .value+ .mcp_write_audit+ .recent_rows;+ assert_eq!(before, Some(0), "a fresh workspace has recorded nothing");++ crate::openhuman::mcp::audit::record_write(+ &config,+ crate::openhuman::mcp::audit::NewMcpWriteRecord {+ timestamp_ms: chrono::Utc::now().timestamp_millis(),+ client_info: "probe-test".to_string(),+ tool_name: "memory_write".to_string(),+ args_summary: serde_json::json!({}),+ resulting_chunk_id: None,+ success: true,+ error_message: None,+ },+ )+ .expect("record a write");++ let after = diagnostics_for_config(&config).value.mcp_write_audit;+ assert_eq!(+ after.recent_rows,+ Some(1),+ "the probe must see a row the writer just recorded; last_error={:?}",+ after.last_error+ );+ assert!(after.enabled, "the log is enabled when it is readable");+}+struct EnvRestore {key: &'static str,previous: Option<std::ffi::OsString>,