Skip to content

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

Rust

feat(admin): fire the admission chain on move-project

Djalma Júnior44758032053e
diff --git a/crates/ai-memory-mcp/src/admin.rs b/crates/ai-memory-mcp/src/admin.rs
index 3cb68034..b6c99bb7 100644
--- a/crates/ai-memory-mcp/src/admin.rs
+++ b/crates/ai-memory-mcp/src/admin.rs
@@ -1881,9 +1881,12 @@ async fn handle_move_project(
// Preserve the stored title verbatim (PageSummary.title is
// the DB-derived title), rather than re-deriving it.
title: Some(s.title.clone()),
+ // None → the write_page admission chain resolves the
+ // workspace/project NAMES from the destination IDs, so the
+ // git-mirror lands the copy under the destination path.
+ admission_ctx: None,
author_id: None,
actor: ai_memory_core::ActorContext::anonymous(),
- admission_ctx: None,
})
.await
{
@@ -1944,15 +1947,30 @@ async fn handle_move_project(
Err(e) => return internal_err(e.to_string()),
};
- // Remove the source's on-disk dir (mirrors handle_purge_project). DB
- // cascade already deleted the rows; dir removal is best-effort.
- let proj_root = state.wiki.project_root(src_ws, src_proj);
- let proj_root_str = proj_root.display().to_string();
+ // Remove the source's on-disk dir through Wiki::purge_project so the
+ // admission chain is notified (op=purge_project) before removal — a
+ // git-mirror drops its copy of the source project. The DB rows were
+ // just deleted above, so name-resolution would find nothing; pass the
+ // workspace/project NAMES explicitly (mirrors handle_purge_project).
+ let purge_ctx = AdmissionContext {
+ workspace: req.from_workspace.clone(),
+ project: req.project.clone(),
+ op: AdmissionOp::PurgeProject,
+ ..Default::default()
+ };
+ let proj_root_str = state
+ .wiki
+ .project_root(src_ws, src_proj)
+ .display()
+ .to_string();
let mut files_deleted: Vec<String> = Vec::new();
let mut files_failed: Vec<String> = Vec::new();
- match std::fs::remove_dir_all(&proj_root) {
+ match state
+ .wiki
+ .purge_project(src_ws, src_proj, Some(purge_ctx))
+ .await
+ {
Ok(()) => files_deleted.push(proj_root_str),
- Err(e) if e.kind() == std::io::ErrorKind::NotFound => {}
Err(e) => {
warn!(path = %proj_root_str, error = %e, "move-project: failed to remove source dir");
files_failed.push(proj_root_str);
diff --git a/crates/ai-memory-mcp/tests/admin_move.rs b/crates/ai-memory-mcp/tests/admin_move.rs
index a98a6088..5630b608 100644
--- a/crates/ai-memory-mcp/tests/admin_move.rs
+++ b/crates/ai-memory-mcp/tests/admin_move.rs
@@ -78,9 +78,9 @@ async fn seed_page(store: &Store, wiki: &Wiki, ws: &str, project: &str, path: &s
tier: Tier::Semantic,
pinned: false,
title: Some(path.into()),
+ admission_ctx: None,
author_id: None,
actor: ai_memory_core::ActorContext::anonymous(),
- admission_ctx: None,
})
.await
.unwrap();