Solution for long term memory for agent coding CLIs and to facilitate handoff between different agent vendors
Rust
fix(store): name the projects behind an ambiguous project name (#1144)
Felipe Neves Ricardo0ecd666d1d33
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 1b9fcf5a..a99c50b4 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -156,6 +156,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0multi-page layout (session, concept, decision, gotcha and rule pages, atmost five). `memory_consolidate` stays for other sessions and headlessruns. (#1140)+- Fixed the "project 'X' is ambiguous" refusal giving no clue which projects+ collided. It now names each project that answers to the name and the key it+ answers by (its name, its canonical key, or its legacy key), so an operator+ whose undeclared clone created `acme-widget` with `widget` as its legacy key+ can see which project to purge or rename. A restricted project is reported+ as "a restricted project", never by name, matching the project list. (#1144)## [2.6.0] - 2026-10-07diff --git a/crates/ai-memory-store/src/error.rs b/crates/ai-memory-store/src/error.rsindex 764ff640..c8586610 100644--- a/crates/ai-memory-store/src/error.rs+++ b/crates/ai-memory-store/src/error.rs@@ -4,6 +4,57 @@ use thiserror::Error;use ai_memory_core::MemoryError;+/// Which of its keys makes a project answer to an ambiguous name.+#[derive(Debug, Clone, Copy, PartialEq, Eq)]+pub enum AmbiguousMatch {+ /// The project's current name.+ Name,+ /// The canonical path-style key derived from its repository identity.+ CanonicalKey,+ /// The v2 basename key derived from its repository identity.+ LegacyKey,+}++/// One project that answers to an ambiguous name.+#[derive(Debug, Clone, PartialEq, Eq)]+pub struct AmbiguousProjectHolder {+ /// The project's current name, or `None` for a restricted project: the+ /// project list hides those names from callers without a grant, and the+ /// lookup that fails here runs before any caller is authorized.+ pub name: Option<String>,+ /// The key that matched.+ pub matched_by: AmbiguousMatch,+}++/// The projects behind a [`StoreError::ProjectNameAmbiguous`], rendered as+/// the tail of its message so the operator can see which project to rename,+/// purge or pin with a marker. Empty when the lookup did not collect them.+#[derive(Debug, Clone, Default, PartialEq, Eq)]+pub struct AmbiguousProjectHolders(pub Vec<AmbiguousProjectHolder>);++impl std::fmt::Display for AmbiguousProjectHolders {+ fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {+ let last = self.0.len().saturating_sub(1);+ for (index, holder) in self.0.iter().enumerate() {+ f.write_str(match index {+ 0 => ": it is ",+ _ if index == last => " and ",+ _ => ", ",+ })?;+ f.write_str(match holder.matched_by {+ AmbiguousMatch::Name => "the name of ",+ AmbiguousMatch::CanonicalKey => "the canonical key of ",+ AmbiguousMatch::LegacyKey => "the legacy key of ",+ })?;+ match &holder.name {+ Some(name) => write!(f, "project '{name}'")?,+ None => f.write_str("a restricted project")?,+ }+ }+ Ok(())+ }+}+/// Result alias used throughout the store crate.pub type StoreResult<T> = Result<T, StoreError>;@@ -72,8 +123,13 @@ pub enum StoreError {ProjectNameTaken(String),/// More than one project in a workspace matched a compatibility name.- #[error("project name '{0}' is ambiguous in this workspace")]- ProjectNameAmbiguous(String),+ #[error("project name '{name}' is ambiguous in this workspace{holders}")]+ ProjectNameAmbiguous {+ /// The name the caller asked for.+ name: String,+ /// The projects that answer to it, when the lookup knows them.+ holders: AmbiguousProjectHolders,+ },/// The supplied project name failed validation (empty, slash, etc.).#[error("invalid project name: {0}")]diff --git a/crates/ai-memory-store/src/lib.rs b/crates/ai-memory-store/src/lib.rsindex f4e0429a..0468fc38 100644--- a/crates/ai-memory-store/src/lib.rs+++ b/crates/ai-memory-store/src/lib.rs@@ -55,7 +55,9 @@ pub use decay::{lambda_from_half_life_days, retention_score, retention_score_with_breadth,salience_after_feedback,};-pub use error::{StoreError, StoreResult};+pub use error::{+ AmbiguousMatch, AmbiguousProjectHolder, AmbiguousProjectHolders, StoreError, StoreResult,+};pub use grants::{GrantFilter, GrantListing, GrantOutcome, ProjectGrant};pub use maintenance::MaintenanceJob;pub use ops::{diff --git a/crates/ai-memory-store/src/project_coordinates.rs b/crates/ai-memory-store/src/project_coordinates.rsindex 3e4bd1f8..9da2a7b4 100644--- a/crates/ai-memory-store/src/project_coordinates.rs+++ b/crates/ai-memory-store/src/project_coordinates.rs@@ -6,7 +6,9 @@ use ai_memory_core::repository_identity::{use ai_memory_core::{ProjectId, WorkspaceId};use rusqlite::{Connection, OptionalExtension, params};-use crate::{StoreError, StoreResult};+use crate::{+ AmbiguousMatch, AmbiguousProjectHolder, AmbiguousProjectHolders, StoreError, StoreResult,+};pub(crate) const MAX_COORDINATE_ROWS: usize = 4;@@ -43,7 +45,8 @@ const MATCH_SQL: &str = "WITH \(exact_match OR canonical_match OR legacy_match) DESC, id LIMIT ?5) \SELECT p.id, p.name, NULLIF(p.identity, ''), NULLIF(p.identity_source, ''), \NULLIF(p.canonical_name, ''), NULLIF(p.legacy_name, ''), \- m.exact_match, m.canonical_match, m.legacy_match, m.identity_match, m.canonical_target \+ m.exact_match, m.canonical_match, m.legacy_match, m.identity_match, m.canonical_target, \+ p.access_mode = 'restricted' \FROM unique_matches m JOIN projects p ON p.id = m.id AND p.workspace_id = ?1 \ORDER BY m.identity_match DESC, m.exact_match DESC, \(m.exact_match OR m.canonical_match OR m.legacy_match) DESC, m.id";@@ -71,9 +74,32 @@ pub(crate) struct ProjectCoordinateMatch {pub(crate) identity_source: Option<String>,pub(crate) canonical_name: Option<String>,pub(crate) legacy_name: Option<String>,+ pub(crate) restricted: bool,pub(crate) provenance: MatchProvenance,}+impl ProjectCoordinateMatch {+ fn ambiguous_holder(&self) -> AmbiguousProjectHolder {+ AmbiguousProjectHolder {+ name: (!self.restricted).then(|| self.current_name.clone()),+ matched_by: if self.provenance.exact {+ AmbiguousMatch::Name+ } else if self.provenance.canonical_compat {+ AmbiguousMatch::CanonicalKey+ } else {+ AmbiguousMatch::LegacyKey+ },+ }+ }+}++fn ambiguous(name: &str, holders: AmbiguousProjectHolders) -> StoreError {+ StoreError::ProjectNameAmbiguous {+ name: name.to_owned(),+ holders,+ }+}+pub(crate) fn matches(conn: &Connection,workspace_id: WorkspaceId,@@ -106,6 +132,7 @@ pub(crate) fn matches(row.get::<_, i64>(8)?,row.get::<_, i64>(9)?,row.get::<_, i64>(10)?,+ row.get::<_, bool>(11)?,))},)?@@ -124,6 +151,7 @@ pub(crate) fn matches(legacy_compat,identity_match,canonical_target,+ restricted,)| {Ok(ProjectCoordinateMatch {id: ProjectId::from_slice(&raw_id)?,@@ -132,6 +160,7 @@ pub(crate) fn matches(identity_source,canonical_name,legacy_name,+ restricted,provenance: MatchProvenance {exact: exact != 0,canonical_compat: canonical_compat != 0,@@ -157,7 +186,15 @@ pub(crate) fn resolve(match matches.len() {0 => Ok(None),1 => Ok(matches.pop()),- _ => Err(StoreError::ProjectNameAmbiguous(requested.to_owned())),+ _ => Err(ambiguous(+ requested,+ AmbiguousProjectHolders(+ matches+ .iter()+ .map(ProjectCoordinateMatch::ambiguous_holder)+ .collect(),+ ),+ )),}}@@ -175,6 +212,7 @@ fn row_to_match(row: &rusqlite::Row<'_>) -> rusqlite::Result<ProjectCoordinateMaidentity_source: row.get(3)?,canonical_name: row.get(4)?,legacy_name: row.get(5)?,+ restricted: row.get(6)?,provenance: MatchProvenance {exact: true,..MatchProvenance::default()@@ -190,12 +228,13 @@ pub(crate) fn resolve_aliases(repository: &RepositoryIdentity,) -> StoreResult<Option<ProjectCoordinateMatch>> {if repository.source != IdentitySource::GitRemote || aliases.is_empty() {- return Err(StoreError::ProjectNameAmbiguous(canonical.to_owned()));+ return Err(ambiguous(canonical, AmbiguousProjectHolders::default()));}let canonical_match = conn.query_row("SELECT id, name, NULLIF(identity, ''), NULLIF(identity_source, ''), \- NULLIF(canonical_name, ''), NULLIF(legacy_name, '') FROM projects \+ NULLIF(canonical_name, ''), NULLIF(legacy_name, ''), \+ access_mode = 'restricted' FROM projects \INDEXED BY sqlite_autoindex_projects_2 WHERE workspace_id = ?1 AND name = ?2",params![workspace_id.as_bytes(), canonical],row_to_match,@@ -208,14 +247,15 @@ pub(crate) fn resolve_aliases({return Ok(Some(canonical_match));}- return Err(StoreError::ProjectNameAmbiguous(canonical.to_owned()));+ return Err(ambiguous(canonical, AmbiguousProjectHolders::default()));}let mut candidates = Vec::new();for alias in aliases.as_slice() {let local = conn.query_row("SELECT id, name, NULLIF(identity, ''), NULLIF(identity_source, ''), \- NULLIF(canonical_name, ''), NULLIF(legacy_name, '') FROM projects \+ NULLIF(canonical_name, ''), NULLIF(legacy_name, ''), \+ access_mode = 'restricted' FROM projects \INDEXED BY sqlite_autoindex_projects_2 WHERE workspace_id = ?1 AND name = ?2",params![workspace_id.as_bytes(), alias],row_to_match,@@ -228,7 +268,7 @@ pub(crate) fn resolve_aliases(candidates.sort_by_key(|candidate| candidate.id.to_string());candidates.dedup_by_key(|candidate| candidate.id);if candidates.len() > 1 {- return Err(StoreError::ProjectNameAmbiguous(canonical.to_owned()));+ return Err(ambiguous(canonical, AmbiguousProjectHolders::default()));}let Some(candidate) = candidates.pop() else {return Ok(None);@@ -236,7 +276,7 @@ pub(crate) fn resolve_aliases(if candidate.identity.as_deref() != Some(repository.identity.as_str())|| candidate.identity_source.as_deref() != Some(IdentitySource::GitRemote.as_str()){- return Err(StoreError::ProjectNameAmbiguous(canonical.to_owned()));+ return Err(ambiguous(canonical, AmbiguousProjectHolders::default()));}Ok(Some(candidate))}@@ -360,7 +400,7 @@ mod tests {);assert!(matches!(resolve(&conn, workspace, "collision"),- Err(StoreError::ProjectNameAmbiguous(_))+ Err(StoreError::ProjectNameAmbiguous { .. })));for index in ["sqlite_autoindex_projects_2",diff --git a/crates/ai-memory-store/src/scope.rs b/crates/ai-memory-store/src/scope.rsindex 2214e610..09d598b3 100644--- a/crates/ai-memory-store/src/scope.rs+++ b/crates/ai-memory-store/src/scope.rs@@ -13,7 +13,7 @@ use ai_memory_core::{ActiveProject, ActiveProjectLookup, ActorKey, ProjectId, ReadPointer, UserId, WorkspaceId,};-use crate::error::StoreError;+use crate::error::{AmbiguousProjectHolders, StoreError};use crate::project_authz::{GrantLevel, ProjectAccess, ProjectPrincipal};use crate::{ReaderPool, WriterHandle};@@ -182,6 +182,8 @@ pub enum ScopeResolutionError {workspace: String,/// Project name supplied by the caller.project: String,+ /// The projects that answer to the name, when the lookup knows them.+ holders: AmbiguousProjectHolders,},/// A project-only read did not resolve in either the actor's active/// workspace or the server's default workspace.@@ -259,10 +261,14 @@ impl fmt::Display for ScopeResolutionError {"project '{project}' not found in workspace '{workspace}'")}- ScopeResolutionError::ProjectNameAmbiguous { workspace, project } => {+ ScopeResolutionError::ProjectNameAmbiguous {+ workspace,+ project,+ holders,+ } => {write!(f,- "project '{project}' is ambiguous in workspace '{workspace}'"+ "project '{project}' is ambiguous in workspace '{workspace}'{holders}")}ScopeResolutionError::ProjectNotFoundInActiveOrDefault { project } => {@@ -290,10 +296,13 @@ impl From<StoreError> for ScopeResolutionError {fn project_lookup_error(error: StoreError, workspace: &str, project: &str) -> ScopeResolutionError {match error {- StoreError::ProjectNameAmbiguous(_) => ScopeResolutionError::ProjectNameAmbiguous {- workspace: workspace.to_owned(),- project: project.to_owned(),- },+ StoreError::ProjectNameAmbiguous { holders, .. } => {+ ScopeResolutionError::ProjectNameAmbiguous {+ workspace: workspace.to_owned(),+ project: project.to_owned(),+ holders,+ }+ }StoreError::Forbidden(message) => ScopeResolutionError::Forbidden(format!("not authorized for {project}: this needs write access. {message}")),diff --git a/crates/ai-memory-store/tests/suite/identity_resolution.rs b/crates/ai-memory-store/tests/suite/identity_resolution.rsindex 320c43b3..289ebc05 100644--- a/crates/ai-memory-store/tests/suite/identity_resolution.rs+++ b/crates/ai-memory-store/tests/suite/identity_resolution.rs@@ -1589,6 +1589,61 @@ async fn exact_name_that_is_another_forges_canonical_key_fails_closed() {));}+/// A clone without the marker that declares `widget` creates `acme-widget`+/// with `widget` as its legacy key (#1144). The refusal names both projects+/// and the key each answers by, so the operator can tell which one to purge+/// or rename, but never names a restricted project: the project list hides+/// those names from callers without a grant, and this lookup runs before any+/// caller is authorized.+#[tokio::test]+async fn an_ambiguous_name_names_its_holders_but_not_a_restricted_one() {+ let tmp = tempfile::TempDir::new().unwrap();+ let store = Store::open(tmp.path()).unwrap();+ let ws = workspace(&store).await;+ let declared = store+ .writer+ .get_or_create_project(ws, "widget", None)+ .await+ .unwrap();+ let clone = resolve_capture(+ &store,+ ws,+ &remote("github.com/acme/widget"),+ IdentityStyle::Path,+ "acme-widget",+ None,+ )+ .await+ .0;+ assert_ne!(declared, clone);+ assert_eq!(row(&store, clone).0, "acme-widget");++ let error = lookup_existing_scope(&store.reader, "default", "widget")+ .await+ .unwrap_err();+ assert!(error.is_bad_request());+ assert_eq!(+ error.to_string(),+ "project 'widget' is ambiguous in workspace 'default': it is the name of \+ project 'widget' and the legacy key of project 'acme-widget'"+ );++ store+ .writer+ .set_access_mode(clone, AccessMode::Restricted)+ .await+ .unwrap();+ let error = lookup_existing_scope(&store.reader, "default", "widget")+ .await+ .unwrap_err();+ assert_eq!(+ error.to_string(),+ "project 'widget' is ambiguous in workspace 'default': it is the name of \+ project 'widget' and the legacy key of a restricted project"+ );+ assert!(!error.to_string().contains("acme-widget"));+}+#[tokio::test(flavor = "multi_thread", worker_threads = 2)]async fn concurrent_legacy_and_canonical_resolve_or_create_converge_on_one_uuid() {let tmp = tempfile::TempDir::new().unwrap();diff --git a/docs/security-boundaries.md b/docs/security-boundaries.mdindex 44fe8127..8b669733 100644--- a/docs/security-boundaries.md+++ b/docs/security-boundaries.md@@ -57,7 +57,7 @@ boundary not yet built.| 8c | Messaging: pop-exactly-once | `ai-memory-store/src/ops.rs` `pop_message_in_transaction` atomic CAS `WHERE state='pending'` | `agent_messages.rs` — sequential **and** `tokio::join!` concurrent double-pop yields exactly one `Some` | STRONG || 8d | Messaging: inferred-scope read is diagnosed (#854) | `scope.rs` `is_inferred`; `server.rs` `inferred_scope_hint` on empty pop/list | `agent_messages_briefing.rs` `no_scope_pop_that_misses_the_mail_is_diagnosed_not_a_silent_null` | STRONG || 8e | Messaging: admission is the same for MCP and admin sends (#756) | `ai-memory-mcp/src/admin.rs` `handle_send_message` runs `Wiki::authorize_operation(.., AdmissionOp::MessageSend, ..)` at the recipient scope before `insert_message` (a refusal is 403 and stores nothing) and calls `notify_operation_observers` only after a successful commit; skipping webhooks needs `Capability::SkipAdmissionChain` (`skip_webhooks_for_admin_request`); the MCP path is `server.rs` `memory_message_send` | `admin.rs` `admin_message_send_reject_leaves_inbox_empty` (a rejecting webhook gets 403 and an empty inbox; fails with the admission call removed), controls `admin_message_send_observer_sees_commit_without_blocking_response` and `admin_message_send_full_inbox_does_not_notify_observer` | STRONG |-| 9 | Scope resolution fail-closed | `ai-memory-store/src/scope.rs` no-create `lookup_existing_*`; identity-aware lookup accepts exact/canonical/v2-basename keys only when they deduplicate to one UUID; `ops.rs` `resolve_project_name_for_write` performs write authorization, optional name-only promotion, and audit in one writer transaction; create only via `create_explicit_scope`. `ProjectNameAmbiguous` refuses cross-forge/multi-candidate keys before mutation; an audit failure after the name UPDATE rolls the transaction back. V76's derived-key indexes bound hot lookup to exact/canonical/legacy equality probes with at most four rows. Promoting public APIs return `ResolvedWriteScope` metadata (no untraced promotion API); MCP, admin, and managed-workstream write entry points make Wiki refresh/checkpoint the committed scope manifest after promotion and surface `manifest_warning` on success or any later operation failure; pure managed-run input validation precedes promotion. Project manifests persist the typed full identity/source and derived keys so clean reindex restores the same UUID and lookup behavior. Also `ai-memory-hooks/src/router.rs` `workspace_override_is_rescope` — the hook router's session-sticky gate resolves a marker's `workspace` override via this same no-create `lookup_existing_workspace` (never a hand-rolled lookup) and fails closed (treats it as a rescope, disqualifying sticky) on a different or unresolvable workspace; only an override that resolves to the session's OWN workspace is not a rescope (#976) | `scope.rs` `read_resolution_table_driven`, `multi_scope_resolution_deduplicates_and_validates`, no-auto-create + `unscoped_write_with_unresolvable_coordinate_errors`; `dual_key_scope.rs` `page_write_failure_after_promotion_preserves_manifest_warning`, `handoff_failure_after_promotion_preserves_manifest_warning`; `workstream.rs` `managed_run_rejects_mutually_exclusive_selection_before_promotion`, `managed_run_downstream_failure_after_promotion_preserves_manifest_warning`; `identity_resolution.rs` `canonical_and_legacy_reads_resolve_one_legacy_row_without_renaming`, `authorized_write_promotes_in_place_and_preserves_dependents_and_legacy_lookup`, `read_only_user_cannot_promote_a_legacy_name`, `canonical_target_conflict_rolls_back_the_promotion`, `audit_failure_rolls_back_promotion_and_keeps_the_writer_alive`, `exact_name_that_is_another_forges_canonical_key_fails_closed`, `concurrent_legacy_and_canonical_resolve_or_create_converge_on_one_uuid`; `project_coordinates.rs` `candidate_query_is_bounded_and_uses_only_coordinate_indexes`; wiki `promoted_identity_round_trips_through_manifest_and_clean_reindex`, `old_project_manifest_without_identity_still_reindexes`, `reindex_rejects_project_coordinate_fields_that_do_not_match_identity`; admin `write_page_surfaces_manifest_failure_after_promotion`, `bootstrap_surfaces_manifest_failure_after_promotion`, `move_project_merge_surfaces_destination_promotion_manifest_warning`, `move_session_create_surfaces_destination_promotion_manifest_warning`; `multi_session.rs` `two_operators_promote_two_clone_keys_to_one_uuid_without_moving_active_pointers`; MCP `dual_key_scope.rs`; hooks `workstream.rs` `managed_run_promotion_refreshes_the_scope_manifest`, `managed_run_discloses_manifest_failure_after_committed_promotion` static read/write/authz/cross-workspace/cross-forge cases; `router.rs` `workspace_override_is_rescope_only_on_a_genuine_workspace_change` (same/different/unresolvable workspace cases), `sticky_routing_keeps_the_session_project_across_a_sibling_checkout` (regression: same workspace forwarded on every event + `project_src=repo-root` from a nested checkout stays sticky), `sticky_routing_still_rescopes_when_marker_names_a_different_workspace_mid_session` (opposite direction: a genuinely different workspace still rescopes even under `sticky`) | STRONG |+| 9 | Scope resolution fail-closed | `ai-memory-store/src/scope.rs` no-create `lookup_existing_*`; identity-aware lookup accepts exact/canonical/v2-basename keys only when they deduplicate to one UUID; `ops.rs` `resolve_project_name_for_write` performs write authorization, optional name-only promotion, and audit in one writer transaction; create only via `create_explicit_scope`. `ProjectNameAmbiguous` refuses cross-forge/multi-candidate keys before mutation; its message names each holder and the key it matched by, but a restricted holder only as "a restricted project", because the lookup runs before any caller is authorized and the project list hides restricted names from callers without a grant; an audit failure after the name UPDATE rolls the transaction back. V76's derived-key indexes bound hot lookup to exact/canonical/legacy equality probes with at most four rows. Promoting public APIs return `ResolvedWriteScope` metadata (no untraced promotion API); MCP, admin, and managed-workstream write entry points make Wiki refresh/checkpoint the committed scope manifest after promotion and surface `manifest_warning` on success or any later operation failure; pure managed-run input validation precedes promotion. Project manifests persist the typed full identity/source and derived keys so clean reindex restores the same UUID and lookup behavior. Also `ai-memory-hooks/src/router.rs` `workspace_override_is_rescope` — the hook router's session-sticky gate resolves a marker's `workspace` override via this same no-create `lookup_existing_workspace` (never a hand-rolled lookup) and fails closed (treats it as a rescope, disqualifying sticky) on a different or unresolvable workspace; only an override that resolves to the session's OWN workspace is not a rescope (#976) | `scope.rs` `read_resolution_table_driven`, `multi_scope_resolution_deduplicates_and_validates`, no-auto-create + `unscoped_write_with_unresolvable_coordinate_errors`; `dual_key_scope.rs` `page_write_failure_after_promotion_preserves_manifest_warning`, `handoff_failure_after_promotion_preserves_manifest_warning`; `workstream.rs` `managed_run_rejects_mutually_exclusive_selection_before_promotion`, `managed_run_downstream_failure_after_promotion_preserves_manifest_warning`; `identity_resolution.rs` `canonical_and_legacy_reads_resolve_one_legacy_row_without_renaming`, `authorized_write_promotes_in_place_and_preserves_dependents_and_legacy_lookup`, `read_only_user_cannot_promote_a_legacy_name`, `canonical_target_conflict_rolls_back_the_promotion`, `audit_failure_rolls_back_promotion_and_keeps_the_writer_alive`, `exact_name_that_is_another_forges_canonical_key_fails_closed`, `an_ambiguous_name_names_its_holders_but_not_a_restricted_one` (restricted holder unnamed; open holder named as the control), `concurrent_legacy_and_canonical_resolve_or_create_converge_on_one_uuid`; `project_coordinates.rs` `candidate_query_is_bounded_and_uses_only_coordinate_indexes`; wiki `promoted_identity_round_trips_through_manifest_and_clean_reindex`, `old_project_manifest_without_identity_still_reindexes`, `reindex_rejects_project_coordinate_fields_that_do_not_match_identity`; admin `write_page_surfaces_manifest_failure_after_promotion`, `bootstrap_surfaces_manifest_failure_after_promotion`, `move_project_merge_surfaces_destination_promotion_manifest_warning`, `move_session_create_surfaces_destination_promotion_manifest_warning`; `multi_session.rs` `two_operators_promote_two_clone_keys_to_one_uuid_without_moving_active_pointers`; MCP `dual_key_scope.rs`; hooks `workstream.rs` `managed_run_promotion_refreshes_the_scope_manifest`, `managed_run_discloses_manifest_failure_after_committed_promotion` static read/write/authz/cross-workspace/cross-forge cases; `router.rs` `workspace_override_is_rescope_only_on_a_genuine_workspace_change` (same/different/unresolvable workspace cases), `sticky_routing_keeps_the_session_project_across_a_sibling_checkout` (regression: same workspace forwarded on every event + `project_src=repo-root` from a nested checkout stays sticky), `sticky_routing_still_rescopes_when_marker_names_a_different_workspace_mid_session` (opposite direction: a genuinely different workspace still rescopes even under `sticky`) | STRONG || 10 | Destructive-op live-process refusal + confirm flags (invariant #9); `purge-project`'s `dry_run` always wins over `confirm` so a preview request can never become destructive | `ai-memory-cli/src/commands/process_guard.rs` `sibling_processes` + confirm flags in `reset`/`restore`/`reindex`/`uninstall --purge-data`/`purge_project`; `admin.rs` `handle_purge_project` checks `req.dry_run` unconditionally, before `req.confirm`, mirroring `reclaim-ledger-versions` | `admin_purge.rs` confirm→400; `removal.rs` — injected live-sibling makes each destructive command bail before touching the data dir; `admin_purge.rs` `purge_project_confirm_true_and_dry_run_true_still_only_previews` — `{"confirm": true, "dry_run": true}` deletes nothing (the regression this row now also covers); `ops.rs` `purge_project_dry_run_changes_nothing` — every project-scoped row count, the `purged_scopes` tombstone, and the `audit_log` row are identical before/after a `PurgeMode::Preview` run; `ops.rs` `purge_project_counts_collateral_damage_in_another_project` and `admin_purge.rs` `purge_project_dry_run_and_confirmed_purge_both_report_collateral_damage_in_another_project` — a purge of project P collaterally deletes an observation, and orphans a handoff's session reference, in a *different* project Q (via `sessions` cascading out of P), and both the preview and the confirmed report count it | STRONG || 10b | Session purge is scope+owner-bound (no cross-session/project over-delete); `purge-session`'s `dry_run` always wins over `confirm`, same as `purge-project` | `ai-memory-store/src/ops.rs` `purge_session` — selection scoped to `(workspace_id, project_id)` and keyed on this session's own `summary_page_id` **or** `path='sessions/<sid>.md'` + `json_extract(frontmatter_json,'$.session_id')=<sid>` (frontmatter owner, not the recursive latest-chain); `in_scope==0 → NotFound` fail-closed; whole op in one transaction; `admin.rs` `handle_purge_session` checks `req.dry_run` unconditionally, before `req.confirm` | `ops.rs` `purge_session_leaves_a_sibling_session_in_the_same_project_intact`, `…refuses_a_session_from_another_project_and_deletes_nothing`, `…refuses_a_session_from_another_workspace`, `…does_not_delete_an_identically_pathed_page_in_another_project`, `…removes_older_summary_versions_without_deleting_prior_manual_page` (#862); `admin_purge.rs` `purge_session_confirm_true_and_dry_run_true_still_only_previews` — `{"confirm": true, "dry_run": true}` deletes nothing; `ops.rs` `purge_session_dry_run_changes_nothing` — every table a session purge touches, the `purged_sessions` tombstone, and the `audit_log` row are identical before/after a `PurgeMode::Preview` run; `ops.rs` `purge_session_counts_collateral_damage_in_another_project` and `admin_purge.rs` `purge_session_dry_run_and_confirmed_purge_both_report_collateral_damage_in_another_project` — purging session S collaterally deletes an observation, and orphans a handoff's session reference, in a *different* project (via `S`'s own id cascading), and both the preview and the confirmed report count it; `admin_purge.rs` `purge_session_dry_run_refuses_a_session_outside_its_named_scope` — the same session previewed under a different real project (same workspace) or a different real workspace whose project shares the name both 404 with no counts in the body, with the session's own scope as the 200 control | STRONG || 10c | Ledger reclaim is content-gated, not filename-gated (invariant #16) | `ai-memory-store/src/ops.rs` `reclaim_ledger_versions` — a candidate row must pass `ai_memory_core::log_ledger::body_opens_with_log_ledger` on its own `body`, and only `is_latest=0 AND superseded_at IS NULL` rows are eligible, so decay-owned rows stay with `forget-sweep`; confirm gate in `admin.rs` `handle_reclaim_ledger_versions` | `reclaim_ledger_versions.rs` `a_prose_page_wearing_the_ledger_name_keeps_its_whole_version_chain`, `an_ordinary_page_chain_in_another_project_is_untouched`, `a_decay_tombstone_stays_with_the_sweep_that_owns_it`; `admin_reclaim_ledger_versions.rs` `deleting_without_confirm_is_refused_and_changes_nothing` (with dry-run and confirmed controls) | STRONG |