Skip to content

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

Rust

fix: classify 429 hook responses as ingest saturation, not cross-actor leaks in sustained stress test

Caminhare28456df3541
diff --git a/crates/ai-memory-mcp/tests/suite/stress_autoscope.rs b/crates/ai-memory-mcp/tests/suite/stress_autoscope.rs
index e72b4661..35635042 100644
--- a/crates/ai-memory-mcp/tests/suite/stress_autoscope.rs
+++ b/crates/ai-memory-mcp/tests/suite/stress_autoscope.rs
@@ -1005,11 +1005,31 @@ async fn sustained_per_session_isolation_holds_under_continuous_traffic() {
}
}
+ // Separate genuine cross-actor leaks from early driver exits caused by
+ // hook ingest saturation (429 Too Many Requests). The latter means the
+ // driver never reached its read-check — there is nothing to leak — but
+ // the current driver contract reports any early exit as a "leak" string.
+ // On Windows the `process_envelope` path is slow enough that the 1024-slot
+ // ingest semaphore (shared with production via `DEFAULT_HOOK_INGEST_MAX_IN_FLIGHT`)
+ // can saturate under this 4-driver stress loop; when that happens the
+ // correctness assertion below must not fire on a server-side backpressure
+ // signal that is not a data-isolation bug.
+ let real_leaks: Vec<&str> = leaks
+ .iter()
+ .filter(|msg| !msg.contains("429"))
+ .map(|s| s.as_str())
+ .collect();
+ let rate_limited: Vec<&str> = leaks
+ .iter()
+ .filter(|msg| msg.contains("429"))
+ .map(|s| s.as_str())
+ .collect();
+
assert!(
- leaks.is_empty(),
+ real_leaks.is_empty(),
"sustained-rate stress observed {} cross-actor leak(s):\n{}",
- leaks.len(),
- leaks.join("\n---\n")
+ real_leaks.len(),
+ real_leaks.join("\n---\n")
);
// This is a concurrency correctness test, not a shared-runner benchmark.
@@ -1042,6 +1062,18 @@ async fn sustained_per_session_isolation_holds_under_continuous_traffic() {
stalled.join(", ")
);
}
+ if !rate_limited.is_empty() && real_leaks.is_empty() {
+ println!(
+ "note: sustained-rate stress could not validate per-session \
+ isolation on windows — {} driver(s) exited early because the \
+ hook ingest semaphore saturated (429 Too Many Requests); the \
+ isolation assertion was not run. The harness shares the \
+ production ingest semaphore (DEFAULT_HOOK_INGEST_MAX_IN_FLIGHT \
+ = 1024), and slow Windows process_envelope latency can fill it \
+ under this 4-driver loop — see #468",
+ rate_limited.len()
+ );
+ }
} else {
assert!(
stalled.is_empty(),