Skip to content

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

Rust

fix(ci): address git2 advisory and macOS repo paths

AkitaOnRailsf77b1b733536
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 141aaf37..ca3b2cac 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -30,6 +30,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
cap stdout at 64 KiB, cap eval rejection evidence, and make direct root admin
requests inherit server eval defaults unless the request explicitly overrides
them.
+- Hook project routing now stores git repo paths using the incoming cwd's visible
+ path spelling, so macOS `/var` vs `/private/var` aliases and symlinked cwd
+ aliases still prefix-match later events into the same project.
+- Updated `git2` to the patched 0.21 line to clear new RustSec unsoundness
+ advisories in libgit2 bindings.
## [1.1.3] - 2026-06-20
diff --git a/Cargo.lock b/Cargo.lock
index e887a42b..80b6178c 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -1096,15 +1096,14 @@ dependencies = [
[[package]]
name = "git2"
-version = "0.20.4"
+version = "0.21.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "7b88256088d75a56f8ecfa070513a775dd9107f6530ef14919dac831af9cfe2b"
+checksum = "ddddbf932745a6be37109b6112d3ee09696106f848449069d3a57bba937ab82e"
dependencies = [
"bitflags",
"libc",
"libgit2-sys",
"log",
- "url",
]
[[package]]
diff --git a/Cargo.toml b/Cargo.toml
index 4b80b832..335020ea 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -108,7 +108,7 @@ flate2 = "1"
regex = "1"
# Wiki git versioning.
-git2 = { version = "0.20", default-features = false, features = ["vendored-libgit2"] }
+git2 = { version = "0.21", default-features = false, features = ["vendored-libgit2"] }
# LLM provider HTTP.
reqwest = { version = "0.12", default-features = false, features = ["json", "rustls-tls", "stream"] }
diff --git a/crates/ai-memory-consolidate/src/bootstrap.rs b/crates/ai-memory-consolidate/src/bootstrap.rs
index cf0ac2bc..e3f7a33d 100644
--- a/crates/ai-memory-consolidate/src/bootstrap.rs
+++ b/crates/ai-memory-consolidate/src/bootstrap.rs
@@ -653,8 +653,8 @@ fn collect_git_commits(
{
break; // revwalk is time-sorted; older commits come next
}
- let summary = commit.summary().unwrap_or("(no summary)");
- let body = commit.body().unwrap_or("");
+ let summary = commit.summary().ok().flatten().unwrap_or("(no summary)");
+ let body = commit.body().ok().flatten().unwrap_or("");
let combined_len = summary.len() + body.len();
// Skip trivial commits.
if combined_len < 120 && !is_conventional_substantive(summary) {
diff --git a/crates/ai-memory-hooks/src/router.rs b/crates/ai-memory-hooks/src/router.rs
index 90de3c89..a385c59a 100644
--- a/crates/ai-memory-hooks/src/router.rs
+++ b/crates/ai-memory-hooks/src/router.rs
@@ -497,7 +497,11 @@ async fn resolve_project_ids(
// (issue #103). A subdir cwd therefore stores None.
ai_memory_consolidate::derive_project_name(path, strat).map(|(name, root)| {
let repo_path = root
- .map(|p| p.to_string_lossy().into_owned())
+ .map(|p| {
+ repo_root_in_cwd_namespace(path, &p)
+ .to_string_lossy()
+ .into_owned()
+ })
.or_else(|| repo_path_from_cwd(cwd));
(name, repo_path)
})
@@ -506,7 +510,41 @@ async fn resolve_project_ids(
fn repo_path_from_cwd(cwd: &str) -> Option<String> {
let path = std::path::Path::new(cwd);
let repo_root = ai_memory_consolidate::discover_repo_root(path).ok()?;
- cwd_is_repo_root(path, &repo_root).then(|| repo_root.to_string_lossy().into_owned())
+ cwd_is_repo_root(path, &repo_root).then(|| {
+ repo_root_in_cwd_namespace(path, &repo_root)
+ .to_string_lossy()
+ .into_owned()
+ })
+ }
+
+ fn repo_root_in_cwd_namespace(
+ cwd: &std::path::Path,
+ repo_root: &std::path::Path,
+ ) -> std::path::PathBuf {
+ // On macOS, temp paths often arrive from the host as `/var/...` while
+ // libgit2 reports the same directory as `/private/var/...`. Prefix
+ // matching later compares the stored `repo_path` against the raw hook
+ // cwd, so keep the repo root in the same spelling/namespace as `cwd`
+ // whenever canonical paths prove that `cwd` is inside `repo_root`.
+ if let (Ok(cwd_canon), Ok(root_canon)) =
+ (std::fs::canonicalize(cwd), std::fs::canonicalize(repo_root))
+ && let Ok(rel) = cwd_canon.strip_prefix(&root_canon)
+ {
+ let mut visible_root = cwd.to_path_buf();
+ for component in rel.components() {
+ match component {
+ std::path::Component::Normal(_) => {
+ if !visible_root.pop() {
+ return repo_root.to_path_buf();
+ }
+ }
+ std::path::Component::CurDir => {}
+ _ => return repo_root.to_path_buf(),
+ }
+ }
+ return visible_root;
+ }
+ repo_root.to_path_buf()
}
fn repo_path_from_project_override(
@@ -2649,6 +2687,51 @@ mod tests {
);
}
+ #[cfg(unix)]
+ #[tokio::test]
+ async fn repo_root_override_stores_repo_path_in_cwd_namespace() {
+ let tmp = TempDir::new().unwrap();
+ let state = make_state(&tmp).await;
+
+ let real_root = tmp.path().join("real");
+ let real_repo = real_root.join("repo");
+ init_repo_with_commit(&real_repo);
+ std::fs::create_dir_all(real_repo.join("app")).unwrap();
+ std::fs::create_dir_all(real_repo.join("sibling")).unwrap();
+
+ let alias_root = tmp.path().join("alias");
+ std::os::unix::fs::symlink(&real_root, &alias_root).unwrap();
+ let alias_app = alias_root.join("repo/app");
+ let alias_sibling = alias_root.join("repo/sibling");
+
+ let (_, proj_from_alias_override) = resolve_project_ids(
+ &state,
+ Some(alias_app.to_str().unwrap()),
+ None,
+ Some("repo"),
+ ProjectStrategy::RepoRoot,
+ &ai_memory_core::ActorKey::default(),
+ )
+ .await
+ .unwrap();
+
+ let (_, proj_from_alias_sibling) = resolve_project_ids(
+ &state,
+ Some(alias_sibling.to_str().unwrap()),
+ None,
+ None,
+ ProjectStrategy::Basename,
+ &ai_memory_core::ActorKey::default(),
+ )
+ .await
+ .unwrap();
+
+ assert_eq!(
+ proj_from_alias_sibling, proj_from_alias_override,
+ "stored repo_path must use the incoming cwd spelling so raw prefix matching works across symlink aliases",
+ );
+ }
+
#[tokio::test]
async fn cache_does_not_poison_across_project_strategies() {
let tmp = TempDir::new().unwrap();
diff --git a/crates/ai-memory-wiki/src/git.rs b/crates/ai-memory-wiki/src/git.rs
index f16d319a..8c3a34bb 100644
--- a/crates/ai-memory-wiki/src/git.rs
+++ b/crates/ai-memory-wiki/src/git.rs
@@ -150,7 +150,12 @@ impl GitAdapter {
let commit = repo.find_commit(oid).map_err(map_git_err)?;
out.push(Checkpoint {
oid: oid.to_string(),
- summary: commit.summary().unwrap_or("(no summary)").to_string(),
+ summary: commit
+ .summary()
+ .ok()
+ .flatten()
+ .unwrap_or("(no summary)")
+ .to_string(),
time: commit.time().seconds(),
});
}