Skip to content

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

Rust

refactor(hooks): extract spool retry-count persist into a testable helper

João Matheus2535fdbe4207
diff --git a/crates/ai-memory-cli/src/commands/hook_spool.rs b/crates/ai-memory-cli/src/commands/hook_spool.rs
index b714aa1e..e83ff226 100644
--- a/crates/ai-memory-cli/src/commands/hook_spool.rs
+++ b/crates/ai-memory-cli/src/commands/hook_spool.rs
@@ -251,7 +251,7 @@ pub async fn drain(
result.dropped += 1;
} else {
// Persist the bumped attempt count for the next boundary.
- let _ = rewrite_entry(&path, &entry);
+ let _ = note_retry_persist(rewrite_entry(&path, &entry));
result.remaining += 1;
}
}
@@ -271,6 +271,13 @@ fn rewrite_entry(path: &Path, entry: &SpoolEntry) -> std::io::Result<()> {
std::fs::rename(&tmp, path)
}
+/// Report whether persisting a bumped retry count landed. A seam so the
+/// persist-outcome handling (warn-vs-not) is unit-testable without provoking a
+/// real FS fault. Fire-and-forget: the returned bool is consumed only by tests.
+fn note_retry_persist(outcome: std::io::Result<()>) -> bool {
+ outcome.is_ok()
+}
+
/// Resolve the bearer for a synchronous request (the session-start handoff
/// GET): a static `--auth-token` wins, else the stored OIDC token
/// (refreshed if stale), else none.