Solution for long term memory for agent coding CLIs and to facilitate handoff between different agent vendors
Rust
fix(wikisync): discover a repository page whose family is a top-level page
Rudy Mizrahi Celekli3476687db0af
diff --git a/companions/ai-memory-wikisync/src/bidi.rs b/companions/ai-memory-wikisync/src/bidi.rsindex 9c5723d4..dec52870 100644--- a/companions/ai-memory-wikisync/src/bidi.rs+++ b/companions/ai-memory-wikisync/src/bidi.rs@@ -662,6 +662,21 @@ fn local_pages(});continue;}+ if meta.is_file() {+ // A bare top-level page is its own family, which the server+ // side already honours through `family_of`; without this the+ // repository side of such a family is always empty.+ if rel.ends_with(".md") {+ match paths::validate_page_path(&rel) {+ Ok(()) => found.push(rel),+ Err(error) => refused.push(Refusal {+ path: rel,+ reason: format!("cannot import: {error:#}"),+ }),+ }+ }+ continue;+ }if !meta.is_dir() {continue;}@@ -1093,6 +1108,47 @@ mod tests {assert_eq!(fs::read(root.join("_rules/b.md")).unwrap(), b"server");}+ #[test]+ fn local_pages_finds_a_top_level_page_family() {+ let tmp = tempfile::tempdir().unwrap();+ let root = tmp.path().canonicalize().unwrap();+ sync::atomic_write(&root, "README.md", b"---\n---\nbody").unwrap();+ sync::atomic_write(&root, "decisions/0001-a.md", b"---\n---\nbody").unwrap();+ fs::write(root.join("notes.txt"), b"not a page").unwrap();++ let mut refused = Vec::new();+ let refusals = |refused: &[Refusal]| {+ refused+ .iter()+ .map(|refusal| refusal.path.clone())+ .collect::<Vec<_>>()+ };+ let found = local_pages(&root, &["README.md".to_string()], &mut refused).unwrap();+ assert_eq!(found, vec!["README.md".to_string()]);+ assert!(refused.is_empty(), "{:?}", refusals(&refused));++ // Controls: a directory family still walks, a non-`.md` top-level+ // file is not a page, and an unnamed family contributes nothing.+ let found = local_pages(&root, &["decisions".to_string()], &mut refused).unwrap();+ assert_eq!(found, vec!["decisions/0001-a.md".to_string()]);+ let found = local_pages(&root, &["notes.txt".to_string()], &mut refused).unwrap();+ assert!(found.is_empty(), "{found:?}");+ let found = local_pages(&root, &["absent.md".to_string()], &mut refused).unwrap();+ assert!(found.is_empty(), "{found:?}");+ assert!(refused.is_empty(), "{:?}", refusals(&refused));++ // Such a page, absent from the server and from state, is an import.+ assert_eq!(+ decide(+ Some(b"---\n---\nbody"),+ None,+ ServerSide::Absent,+ Policy::default()+ ),+ Action::Import { create: true }+ );+ }+#[test]fn decide_three_way_matrix() {let old = b"old".as_slice();