Solution for long term memory for agent coding CLIs and to facilitate handoff between different agent vendors
Rust
fix(logging): do not raise rmcp above a quieter log_level
João Carlos Magalhães06c2354cbbd2
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 4bfd236d..34f309e4 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -38,6 +38,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0feedback-loop guard stays non-overridable. (#894)### Fixed+- The default log filter's `rmcp=warn` cap (#894) no longer raises rmcp+ above a quieter `log_level`. A target directive beats the global level+ either way, so with `log_level = "error"` or `"off"` the cap re-enabled the+ SDK's warnings the operator had silenced; it now only applies when+ `log_level` is louder than `warn`. (#896)- A manual `memory_consolidate` now reconciles the session's durableconsolidation job row. The MCP handler wrote the page directly through theconsolidator without touching `session_consolidation_jobs`, so a sessiondiff --git a/crates/ai-memory-cli/src/logging.rs b/crates/ai-memory-cli/src/logging.rsindex 655a4cc5..5449dd41 100644--- a/crates/ai-memory-cli/src/logging.rs+++ b/crates/ai-memory-cli/src/logging.rs@@ -21,6 +21,7 @@ use anyhow::Result;use tracing_appender::non_blocking::WorkerGuard;use tracing_appender::rolling::{RollingFileAppender, Rotation};use tracing_subscriber::EnvFilter;+use tracing_subscriber::filter::LevelFilter;use tracing_subscriber::layer::SubscriberExt;use tracing_subscriber::util::SubscriberInitExt;@@ -96,6 +97,9 @@ fn resolve_file_appender(/// operator can restore the external MCP SDK's per-request info logs/// through `log_level` (e.g. `info,rmcp=info`) without setting `RUST_LOG`./// Left at info, `rmcp` alone is ~half the default server log (#894).+/// A target directive also beats a *quieter* global level, so the cap is+/// left out when `log_level` is already `warn` or quieter: it may only+/// lower rmcp, never re-enable warnings an `error`/`off` level silenced./// - `tracing_appender=warn` stays **appended**, so it is the strongest and/// cannot be lowered through `log_level`. That guard is invariant #15: the/// appender must never log at its own level or it feeds itself (the loop@@ -103,7 +107,16 @@ fn resolve_file_appender(////// `RUST_LOG` (`EnvFilter::try_from_default_env`) still overrides all of this.fn default_filter(log_level: &str) -> String {- format!("rmcp=warn,{log_level},tracing_appender=warn")+ // The last bare level in the list is the global one EnvFilter applies.+ let global = log_level+ .split(',')+ .filter_map(|directive| directive.trim().parse::<LevelFilter>().ok())+ .next_back();+ if global.is_some_and(|level| level <= LevelFilter::WARN) {+ format!("{log_level},tracing_appender=warn")+ } else {+ format!("rmcp=warn,{log_level},tracing_appender=warn")+ }}/// Initialise the global tracing subscriber.@@ -196,6 +209,26 @@ mod tests {);}+ #[test]+ fn a_quieter_log_level_is_not_overridden_for_rmcp() {+ // (d) A target directive beats the global level whichever is louder,+ // so a prepended `rmcp=warn` under `log_level = "error"` or `"off"`+ // would re-enable the SDK's warnings the operator had silenced. The+ // cap may only lower rmcp: here it must carry no directive at all.+ for quieter in ["warn", "error", "off", "debug,error"] {+ assert_eq!(+ effective_level(quieter, "rmcp"),+ None,+ "log_level {quieter:?} must govern rmcp itself"+ );+ }+ assert_eq!(+ effective_level("off,rmcp=info", "rmcp").as_deref(),+ Some("info"),+ "an explicit rmcp directive still wins"+ );+ }+#[test]fn log_level_cannot_lower_the_appender_below_warn() {// (c) `tracing_appender=warn` is appended (strongest), so no log_level