Skip to content

Solution for long term memory for agent coding CLIs and to facilitate handoff between different agent vendors

Rust

fix(status): report allowlist capture mode so zero counters are readable (#479)

Fabio Akita6196976d5d8e
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 4c0f977d..6d03a39e 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -40,6 +40,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
`capture_mode`, `marker_present` and `admits_capture` so an opt-out can be
verified without sending anything. Default behaviour is unchanged, and
`--capture-mode denylist` restores it.
+- `ai-memory status` now reports the capture mode when it is `allowlist`, in
+ both the human and `--json` renderings. Without it the new ingest counters
+ read identically whether hooks are broken or a repository simply never opted
+ in — the exact ambiguity those counters were added to remove (#428, #446).
### Docs
- Documented the order of magnitude reported for lifecycle-hook overhead,
diff --git a/crates/ai-memory-cli/src/commands/status.rs b/crates/ai-memory-cli/src/commands/status.rs
index 7ba9cd2e..60b336b1 100644
--- a/crates/ai-memory-cli/src/commands/status.rs
+++ b/crates/ai-memory-cli/src/commands/status.rs
@@ -122,10 +122,24 @@ fn report_offline_spool(spool: &SpoolHealth, json: bool) {
}
}
+/// Which capture mode the hook would enforce for this install (#446).
+///
+/// Reads the same file the hook reads rather than keeping a second source of
+/// truth that could drift from the one actually gating events. Anything
+/// unreadable or unrecognised reports the historical default, matching the
+/// hook's own fallback.
+fn resolve_capture_mode(data_dir: &std::path::Path) -> &'static str {
+ match std::fs::read_to_string(data_dir.join(crate::commands::hook::CAPTURE_MODE_FILE)) {
+ Ok(text) if text.trim().eq_ignore_ascii_case("allowlist") => "allowlist",
+ _ => "denylist",
+ }
+}
+
/// Returns an error if the server is unreachable, returns non-2xx, or
/// the response can't be parsed.
pub async fn run(config: &Config, args: StatusArgs) -> Result<()> {
let ep = ServerEndpoint::from_config_resolving_auth(config).await;
+ let capture_mode = resolve_capture_mode(&config.data_dir);
// Read the spool BEFORE contacting the server, and surface it even when
// that call fails.
@@ -162,6 +176,7 @@ pub async fn run(config: &Config, args: StatusArgs) -> Result<()> {
"derived": report.derived,
"providers": report.providers,
"spool": spool,
+ "capture_mode": capture_mode,
"ingest": report.ingest,
"client": { "server_url": ep.url, "auth": ep.auth_token.is_some() },
}))?
@@ -215,6 +230,17 @@ pub async fn run(config: &Config, args: StatusArgs) -> Result<()> {
last_write_line(ingest.last_persisted_ms)
);
}
+ // #446 + #428 interact here: under allowlist mode an unmarked
+ // repository never sends, so zero counters read exactly like a broken
+ // install. Deliberately outside the ingest block above: the mode is a
+ // client-side fact, and an older server returns no ingest section at
+ // all — which is precisely a case where the operator needs telling.
+ if capture_mode == "allowlist" {
+ println!(
+ " capture mode: allowlist — repositories without a \
+ .ai-memory.toml marker send nothing"
+ );
+ }
println!(" providers:");
println!(
" llm: {}",
@@ -305,6 +331,34 @@ fn error_detail(role: &ProviderRoleHealthSnapshot) -> String {
#[cfg(test)]
mod tests {
use super::*;
+
+ /// #428's counters and #446's gate compose into a trap: under allowlist
+ /// mode an unmarked repository never sends, so `accepted: 0` with an empty
+ /// spool looks exactly like a broken install. `status` must be able to say
+ /// which of the two it is. Resolved from the same file the hook enforces
+ /// from, so the two cannot drift.
+ #[test]
+ fn capture_mode_defaults_to_denylist_when_unset() {
+ let tmp = tempfile::tempdir().unwrap();
+ assert_eq!(resolve_capture_mode(tmp.path()), "denylist");
+ }
+
+ #[test]
+ fn capture_mode_reports_allowlist_when_the_hook_would_enforce_it() {
+ let tmp = tempfile::tempdir().unwrap();
+ std::fs::write(
+ tmp.path().join(crate::commands::hook::CAPTURE_MODE_FILE),
+ "allowlist\n",
+ )
+ .unwrap();
+ assert_eq!(resolve_capture_mode(tmp.path()), "allowlist");
+ // The status reader and the hook enforcer must agree.
+ assert_eq!(
+ crate::commands::hook::CAPTURE_MODE_FILE,
+ "capture-mode",
+ "status reads the file the hook enforces from"
+ );
+ }
use jiff::Timestamp;
/// The offline path must be readable and, critically, must not write the
diff --git a/logs/ai-memory.log.2026-08-24 b/logs/ai-memory.log.2026-08-24
new file mode 100644
index 00000000..670e7e00
--- /dev/null
+++ b/logs/ai-memory.log.2026-08-24
@@ -0,0 +1 @@
+2026-08-24T17:42:36.023569Z INFO ai_memory: ai-memory starting version="1.31.1" server_url=http://192.168.0.90:49374 data_dir= bind=127.0.0.1:49374