Solution for long term memory for agent coding CLIs and to facilitate handoff between different agent vendors
Rust
fix(web): warn about the hook spool only when delivery is stuck
Robert Wagner1d216e006037
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 4a1e94dc..3dbba76f 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -12,6 +12,13 @@ version in [`docs/changelog/`](docs/changelog/):## [Unreleased]### Fixed+- Fixed `/web/health` warning that hook events wait in the local spool during+ every active session. Hooks spool each event first and deliver it at the turn,+ compaction or session boundary, so a few fresh events in the spool are normal,+ and `ai-memory doctor` already reports them as information. The page now warns+ only when an event has failed a delivery attempt, when the oldest event has+ waited 15 minutes or more, or when its age is unknown; a full spool is still+ an error. (#1320)- Fixed a hook claiming a handoff from the wrong project when an event namedno directory. A `SessionStart` (or Kimi Code's `UserPromptSubmit`, or Grok'sfirst `PostToolUse`) whose payload carried no `cwd` sent `GET /handoff` withdiff --git a/crates/ai-memory-web/src/health.rs b/crates/ai-memory-web/src/health.rsindex 03d9be47..897e5818 100644--- a/crates/ai-memory-web/src/health.rs+++ b/crates/ai-memory-web/src/health.rs@@ -138,6 +138,16 @@ pub struct HealthCheck {pub fix: Option<String>,}+const SPOOL_STUCK_AFTER_MS: u64 = 15 * 60 * 1000;++fn spool_is_stuck(spool: &SpoolState) -> bool {+ spool.pending > 0+ && (spool.retries_total > 0+ || spool+ .oldest_age_ms+ .is_none_or(|age| age >= SPOOL_STUCK_AFTER_MS))+}+/// The checks that fail for `s`, most severe first. An empty list is a/// healthy server.#[must_use]@@ -199,7 +209,7 @@ pub fn checks(s: &HealthSnapshot) -> Vec<HealthCheck> {),Some(fix_lines::RECOVER),);- } else if spool.pending > 0 {+ } else if spool_is_stuck(&spool) {push("spool_pending",CheckStatus::Warn,@@ -405,11 +415,40 @@ mod tests {assert_eq!(only(&snapshot).id, "write_queue");}+ #[test]+ fn a_young_spool_awaiting_its_boundary_drain_is_healthy() {+ let mut snapshot = healthy();+ snapshot.process.spool = Some(SpoolState {+ pending: 6,+ oldest_age_ms: Some(SPOOL_STUCK_AFTER_MS - 1),+ retries_total: 0,+ capacity: 500,+ });+ assert!(checks(&snapshot).is_empty());++ snapshot.process.spool = Some(SpoolState {+ pending: 6,+ oldest_age_ms: Some(1_000),+ retries_total: 1,+ capacity: 500,+ });+ assert_eq!(only(&snapshot).id, "spool_pending");++ snapshot.process.spool = Some(SpoolState {+ pending: 6,+ oldest_age_ms: None,+ retries_total: 0,+ capacity: 500,+ });+ assert_eq!(only(&snapshot).id, "spool_pending");+ }+#[test]fn spool_and_journal_point_at_recover() {let mut snapshot = healthy();snapshot.process.spool = Some(SpoolState {pending: 3,+ oldest_age_ms: Some(SPOOL_STUCK_AFTER_MS),capacity: 500,..SpoolState::default()});