Skip to content

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

Rust

test(consolidate): cover the dream pass pair merge and fold the duplicate guard test

AkitaOnRails30babdcc444d
diff --git a/crates/ai-memory-consolidate/src/cold_cluster.rs b/crates/ai-memory-consolidate/src/cold_cluster.rs
index 602f7b46..bb0de6a7 100644
--- a/crates/ai-memory-consolidate/src/cold_cluster.rs
+++ b/crates/ai-memory-consolidate/src/cold_cluster.rs
@@ -315,12 +315,6 @@ mod tests {
assert!(eps <= 0.05, "ceiling honoured: {eps}");
}
- #[test]
- fn too_few_points_yields_no_eps() {
- assert_eq!(adaptive_eps(&[vec![1.0, 0.0]], 2, 0.5), None);
- assert_eq!(adaptive_eps(&[], 2, 0.5), None);
- }
-
#[test]
fn no_cluster_when_everything_is_far() {
let points = vec![
diff --git a/crates/ai-memory-consolidate/tests/suite/dream_pass.rs b/crates/ai-memory-consolidate/tests/suite/dream_pass.rs
index bbeff2d7..fe4aa6e8 100644
--- a/crates/ai-memory-consolidate/tests/suite/dream_pass.rs
+++ b/crates/ai-memory-consolidate/tests/suite/dream_pass.rs
@@ -285,8 +285,7 @@ async fn flag_on_merges_cluster_via_llm() {
let fx = seed_fixture(true).await;
write(&fx, "sessions/a.md", DUP_A).await;
write(&fx, "sessions/b.md", DUP_B).await;
- // A third, far-away cold page: the adaptive k-distance elbow needs more than
- // `min_pts` points to form (exactly as A3 does). It is noise, not a cluster.
+ // A third, far-away cold page: it is noise, not a cluster.
write(&fx, "sessions/far.md", K8S_A).await;
for p in ["sessions/a.md", "sessions/b.md", "sessions/far.md"] {
backdate_latest(&fx, p, COLD_DAYS);
@@ -360,6 +359,50 @@ async fn flag_on_merges_cluster_via_llm() {
);
}
+/// B2 shares A3's `adaptive_eps`, so it shares the pair fix: a cold set of
+/// exactly two near-duplicates, with no third page to give the k-distance
+/// elbow a neighbour, still forms one cluster and reaches the LLM merge.
+#[tokio::test]
+async fn flag_on_merges_a_pair_with_no_other_cold_page() {
+ let fx = seed_fixture(true).await;
+ write(&fx, "sessions/a.md", DUP_A).await;
+ write(&fx, "sessions/b.md", DUP_B).await;
+ for p in ["sessions/a.md", "sessions/b.md"] {
+ backdate_latest(&fx, p, COLD_DAYS);
+ }
+
+ let llm = FakeMergeLlm::new();
+ let calls = llm.calls.clone();
+ let report = run_dream_pass(
+ &fx.store.reader,
+ &fx.wiki,
+ Some(&llm),
+ fx.ws,
+ fx.proj,
+ &DecayParams::default(),
+ 0.0,
+ &dream_on(),
+ &DreamCancel::new(),
+ false,
+ )
+ .await
+ .unwrap();
+
+ assert_eq!(
+ report.clusters_considered, 1,
+ "the pair is a cluster: {report:?}"
+ );
+ assert_eq!(report.clusters_merged, 1, "the merge applied: {report:?}");
+ assert_eq!(report.pages_superseded, 1);
+ assert_eq!(calls.load(Ordering::SeqCst), 1, "LLM called exactly once");
+ let survivor_body = latest_body(&fx, &report.merges[0].survivor);
+ assert!(
+ survivor_body.contains("crates/ai-memory-store/src/ops.rs")
+ && survivor_body.contains("crates/ai-memory-store/src/reader.rs"),
+ "survivor keeps every source fact: {survivor_body}"
+ );
+}
+
/// B2: a dry run returns the plan, writes nothing, and never calls the LLM.
#[tokio::test]
async fn dry_run_returns_plan_and_writes_nothing() {