Solution for long term memory for agent coding CLIs and to facilitate handoff between different agent vendors
Rust
Merge remote-tracking branch 'refs/remotes/audit-open/1566'
AkitaOnRails6b0e1b3cade4
diff --cc CHANGELOG.mdindex 4d313bc9,c0092a68..2dd3b321--- a/CHANGELOG.md+++ b/CHANGELOG.md@@@ -11,14 -11,15 +11,21 @@@ version in [`docs/changelog/`](docs/cha## [Unreleased]+## [3.2.1] - 2026-10-22+### Fixed+- The `user grants` and `project grants` tables now measure terminal display+ cells, so accented and double-width CJK workspace, project and user names+ keep the `USERNAME` and `LEVEL` columns aligned.+ ([#1564](https://github.com/akitaonrails/ai-memory/pull/1564))+ - The LLM dream pass no longer writes a cross-scope wikilink that does not+ resolve. Every other consolidation write runs its proposed bodies through the+ cross-scope link guard, but the dream pass never did, so a `[[project:path]]`+ carried in from a cluster member's body — or invented by the model — reached+ the merged survivor and minted a dangling cross-project edge that the lint+ pass reported on every later run and nothing could clear.+ ([#1566](https://github.com/akitaonrails/ai-memory/pull/1566))- Fixed a 3.2.0 regression that serialized local document embedding anddropped the vector stream from queries that raced a document embed: thelocal embedder's capacity was hardcoded to two slots (one document, onediff --cc crates/ai-memory-consolidate/tests/suite/dream_pass.rsindex fd3b6229,3c511af7..fb4324af--- a/crates/ai-memory-consolidate/tests/suite/dream_pass.rs+++ b/crates/ai-memory-consolidate/tests/suite/dream_pass.rs@@@ -654,88 -574,108 +654,194 @@@ async fn cancel_stops_before_next_clust);}+/// The dream pass builds the same merge stub as A3 and had the same defect:+/// the merged-away page's `summary:` rode onto a page whose body is now a+/// two-line merge note. `page_descriptor_expr` prefers that summary over the+/// body on every non-FTS retrieval path, so the stub advertised a fix that had+/// moved to the survivor.+#[tokio::test]+async fn merge_stub_drops_the_loser_summary_and_abstract() {+ let fx = seed_fixture(true).await;+ write_with_summary(+ &fx,+ "sessions/a.md",+ DUP_A,+ "Fixed the flaky sweep test by guarding the upsert in ops.rs.",+ )+ .await;+ write_with_summary(+ &fx,+ "sessions/b.md",+ DUP_B,+ "Fixed the flaky sweep test by guarding the upsert in ops.rs.",+ )+ .await;+ 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);+ }++ let llm = FakeMergeLlm::new();+ 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_merged, 1, "the merge applied: {report:?}");+ let merge = &report.merges[0];+ let loser_path = merge.merged[0].clone();++ let fm = latest_frontmatter(&fx, &loser_path);+ assert!(+ !fm.contains_key("summary"),+ "the stub carries no summary of content that moved: {fm:?}"+ );+ assert!(+ !fm.contains_key("abstract"),+ "and no abstract, so it is not re-embedded into the abstract stream: {fm:?}"+ );+ // Control: the merge markers are still written, so the removal above did+ // not simply discard the stub's whole frontmatter.+ assert_eq!(fm.get("compacted"), Some(&serde_json::Value::Bool(true)));+ assert_eq!(+ fm.get("merged_into").and_then(serde_json::Value::as_str),+ Some(merge.survivor.as_str())+ );++ // Control: the pre-merge summary is still reachable through supersession,+ // so the test cannot pass because the summary was never written at all.+ let history = superseded_frontmatter(&fx, &loser_path);+ assert!(+ history.iter().any(|fm| fm+ .get("summary")+ .and_then(serde_json::Value::as_str)+ .is_some_and(|s| s.contains("guarding the upsert"))),+ "the pre-merge frontmatter stays in the chain: {history:?}"+ );++ // What retrieval now says about the stub: the merge note, not the fix.+ let descriptor = project_descriptor(&fx, &loser_path).await;+ assert!(+ descriptor.contains("merged into"),+ "the stub describes itself as a merge note: {descriptor}"+ );+ assert!(+ !descriptor.contains("guarding the upsert"),+ "and no longer promises the fix that moved to the survivor: {descriptor}"+ );+}+++ /// Fake provider whose merged body carries a cross-scope wikilink into a+ /// project that does not exist. The merge prompt forbids inventing one, but a+ /// prompt is not a guarantee (#1218), and the member bodies are injected+ /// verbatim, so a `[[project:path]]` reaches the survivor either way.+ struct FakeGhostLinkLlm;++ impl LlmProvider for FakeGhostLinkLlm {+ fn name(&self) -> &'static str {+ "fake-ghost"+ }+ fn model(&self) -> &str {+ "dream-merge"+ }+ fn complete<'life0, 'async_trait>(+ &'life0 self,+ _request: ChatRequest,+ ) -> Pin<Box<dyn Future<Output = LlmResult<ChatResponse>> + Send + 'async_trait>>+ where+ 'life0: 'async_trait,+ Self: 'async_trait,+ {+ Box::pin(async move {+ Ok(ChatResponse {+ text: "unused".into(),+ usage: None,+ model: "dream-merge".into(),+ })+ })+ }+ fn complete_structured_raw<'life0, 'async_trait>(+ &'life0 self,+ _request: ChatRequest,+ _schema: serde_json::Value,+ ) -> Pin<Box<dyn Future<Output = LlmResult<serde_json::Value>> + Send + 'async_trait>>+ where+ 'life0: 'async_trait,+ Self: 'async_trait,+ {+ Box::pin(async move {+ Ok(serde_json::json!({+ "title": "Dream Merge",+ "body_markdown": "Dream-merged coherent page covering \+ crates/ai-memory-store/src/ops.rs and \+ crates/ai-memory-store/src/reader.rs. \+ See [[ghost:notes/missing.md]] for the rest.",+ }))+ })+ }+ }++ /// #1218: a cross-scope link in the merged body must be de-linked before the+ /// survivor is written, exactly as the consolidator and bootstrap writes+ /// already do. Otherwise the dream pass mints a dangling cross-project edge+ /// that `dangling_cross_project_links` reports on every later lint run and+ /// nothing in the pipeline can clear.+ #[tokio::test]+ async fn dream_merge_delinks_an_unresolvable_cross_scope_link() {+ 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 report = run_dream_pass(+ &fx.store.reader,+ &fx.wiki,+ Some(&FakeGhostLinkLlm),+ fx.ws,+ fx.proj,+ &DecayParams::default(),+ 0.0,+ &dream_on(),+ &DreamCancel::new(),+ false,+ )+ .await+ .unwrap();++ assert_eq!(report.clusters_merged, 1, "the merge applied: {report:?}");+ assert_eq!(report.skipped, 0, "the guard de-links, it does not skip");++ // The label survives as prose; the brackets — and the edge — do not.+ let survivor_body = latest_body(&fx, &report.merges[0].survivor);+ assert!(+ survivor_body.contains("ghost:notes/missing.md"),+ "the label stays readable: {survivor_body}"+ );+ assert!(+ !survivor_body.contains("[["),+ "the unresolvable link is de-linked: {survivor_body}"+ );++ // And the lint pass has nothing to report.+ let dangling = fx+ .store+ .reader+ .dangling_cross_project_links(fx.ws, fx.proj)+ .await+ .unwrap();+ assert!(+ dangling.is_empty(),+ "no dangling cross-project edge was minted: {dangling:?}"+ );+ }