Skip to content

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

Rust

fix(store): try the exact name first and never create a slashed project

AkitaOnRails7c42cf2677ea
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 0e14ae97..478d5b72 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -7,6 +7,14 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [Unreleased]
+### Fixed
+- Fixed a `workspace/project` label passed as the project failing to resolve
+ (for example `workspace: "default", project: "myorg/myproject"`): when no
+ project has that exact name, the label's own workspace and project are used,
+ under the same access checks as passing them separately. A write never
+ creates a project whose name contains `/` any more; it is refused with the
+ hint instead. (#1152, #1154)
+
## [2.6.1] - 2026-10-08
### Fixed
@@ -15,21 +23,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
"myorg/myproject"` with the default workspace): project names never contain
`/`, so the error now names the separate `workspace` and `project` arguments
to pass. (#1152)
-
-- A `workspace/project` label accidentally passed as the `project`
- argument to a scope-resolving tool (with the workspace often the
- literal `"default"` because a client-side fallback built the args
- from a marker) now auto-splits and resolves to the
- `(split_ws, split_proj)` scope. The split is unambiguous because a
- project name never contains `/`; a non-split project name goes
- through the original `ProjectNotFoundInWorkspace` path unchanged.
- The Display hint from 7e1b50f3 is for humans reading the error;
- this auto-split is for the agent that constructed the malformed
- args in the first place and would otherwise retry with the same
- wrong shape, losing the handoff it was trying to write. Both the
- read path (`ScopeResolver::resolve_existing_args_traced`) and the
- write path (`ScopeResolver::resolve_write_args`) get the same
- one-shot retry. (#1152)
- Fixed the cross-project profile rewriting a settled entry whenever new
evidence merely agreed with it: a statement now changes only when the ruling
or its scope does (the LLM merge reports `changed`), so the line every project
diff --git a/crates/ai-memory-store/src/scope.rs b/crates/ai-memory-store/src/scope.rs
index 088d7d76..f4112e13 100644
--- a/crates/ai-memory-store/src/scope.rs
+++ b/crates/ai-memory-store/src/scope.rs
@@ -992,6 +992,22 @@ impl<'a> ScopeResolver<'a> {
Ok(Some(scope))
}
+ /// An existing project named by both its workspace and project names.
+ async fn resolve_explicit_pair(
+ &self,
+ workspace: &str,
+ project: &str,
+ need: ProjectAccess,
+ ) -> Result<ResolvedScope, ScopeResolutionError> {
+ let workspace_id = lookup_existing_workspace(self.reader, workspace).await?;
+ self.resolve_named_in_workspace(workspace_id, workspace, project, need)
+ .await?
+ .ok_or_else(|| ScopeResolutionError::ProjectNotFoundInWorkspace {
+ workspace: workspace.to_owned(),
+ project: project.to_owned(),
+ })
+ }
+
/// Resolve MCP-style read arguments: explicit pair if both names are
/// provided, reject partial pair, otherwise use project-only lookup or the
/// current-project/default fallback chain.
@@ -1060,33 +1076,23 @@ impl<'a> ScopeResolver<'a> {
trimmed_opt(explicit_project),
) {
(Some(workspace), Some(project)) => {
- // #1152: a `workspace/project` label accidentally passed as
- // the project argument (with the workspace often the
- // literal `"default"` because the caller built the args
- // from a marker via a fallback path) must auto-split and
- // resolve to (split_ws, split_proj). A project name never
- // contains `/`, so a single split is unambiguous. The
- // Display impl of `ProjectNotFoundInWorkspace` already
- // documents this hint; the fix is to actually act on it.
- if let Some((ws, proj)) = split_slashed_project(project) {
- let retry = Box::pin(self.resolve_existing_args_traced(
- Some(ws),
- Some(proj),
- actor,
- need,
- ));
- if let Ok((scope, _)) = retry.await {
- return Ok((scope, ScopeSource::Explicit));
- }
- }
- let workspace_id = lookup_existing_workspace(self.reader, workspace).await?;
- let scope = self
- .resolve_named_in_workspace(workspace_id, workspace, project, need)
- .await?
- .ok_or_else(|| ScopeResolutionError::ProjectNotFoundInWorkspace {
- workspace: workspace.to_owned(),
- project: project.to_owned(),
- })?;
+ let exact = self.resolve_explicit_pair(workspace, project, need).await;
+ let scope = match (exact, split_slashed_project(project)) {
+ // #1152: an agent passed a `workspace/project` label as the
+ // project. The exact name still wins, so a project created
+ // with a `/` before renames refused one stays reachable.
+ (
+ Err(
+ error @ (ScopeResolutionError::WorkspaceNotFound { .. }
+ | ScopeResolutionError::ProjectNotFoundInWorkspace { .. }),
+ ),
+ Some((label_workspace, label_project)),
+ ) => self
+ .resolve_explicit_pair(label_workspace, label_project, need)
+ .await
+ .map_err(|_| error)?,
+ (exact, _) => exact?,
+ };
Ok((scope, ScopeSource::Explicit))
}
(Some(_), None) => Err(ScopeResolutionError::WorkspaceProjectPairRequired),
@@ -1209,25 +1215,52 @@ impl<'a> ScopeResolver<'a> {
return Err(ScopeResolutionError::WriterRequired);
};
let active = self.active_project.and_then(|a| a.get_for(actor));
- // #1152: a slashed `project` argument (label jammed into one
- // field) must auto-split and re-resolve before any create-side
- // work. Mirrors the read path above; a project name never
- // contains `/`, so a single split is unambiguous.
- if let Some(project_str) = trimmed_opt(explicit_project)
- && let Some((ws, proj)) = split_slashed_project(project_str)
- {
- let retry = Box::pin(self.resolve_existing_args(
- Some(ws),
- Some(proj),
- actor,
- ProjectAccess::Write,
- ));
- if let Ok(scope) = retry.await {
- return Ok(ResolvedWriteScope {
- scope,
- promoted_from: None,
- });
- }
+ // #1152: a project name never contains `/` (renames refuse one), so a
+ // write naming one is a `workspace/project` label passed as the
+ // project. Resolve an existing project of that exact name, else the
+ // label's own pair, and never create either.
+ if let Some((label_workspace, label_project)) = split_slashed_project(project) {
+ let exact = match trimmed_opt(explicit_workspace) {
+ Some(workspace) => {
+ self.resolve_explicit_pair(workspace, project, ProjectAccess::Write)
+ .await
+ }
+ None => {
+ let workspace_id = active
+ .map(|(workspace_id, _)| workspace_id)
+ .unwrap_or(self.default_workspace_id);
+ self.resolve_named_in_workspace(
+ workspace_id,
+ "the active workspace",
+ project,
+ ProjectAccess::Write,
+ )
+ .await?
+ .ok_or_else(|| {
+ ScopeResolutionError::ProjectNotFoundInWorkspace {
+ workspace: "the active workspace".to_owned(),
+ project: project.to_owned(),
+ }
+ })
+ }
+ };
+ let scope = match exact {
+ Err(
+ error @ (ScopeResolutionError::WorkspaceNotFound { .. }
+ | ScopeResolutionError::ProjectNotFoundInWorkspace { .. }),
+ ) => {
+ let creator = self.authz.as_ref().and_then(|principal| principal.user_id);
+ refuse_foreign_profile_name(Some(label_workspace), label_project, creator)?;
+ self.resolve_explicit_pair(label_workspace, label_project, ProjectAccess::Write)
+ .await
+ .map_err(|_| error)?
+ }
+ exact => exact?,
+ };
+ return Ok(ResolvedWriteScope {
+ scope,
+ promoted_from: None,
+ });
}
let workspace_id = match trimmed_opt(explicit_workspace) {
Some(workspace) => writer.get_or_create_workspace(workspace.to_owned()).await?,
@@ -1290,12 +1323,8 @@ fn trimmed_opt(value: Option<&str>) -> Option<&str> {
value.map(str::trim).filter(|s| !s.is_empty())
}
-/// #1152: split a `workspace/project` label carried as the project
-/// argument. Returns the `(workspace, project)` pair only when the input
-/// has exactly one `/` and both sides are non-empty; a project name
-/// itself never contains `/` (enforced by `PagePath`/`ProjectName`),
-/// so a single split is unambiguous. Anything else returns `None` and
-/// the caller treats the input as a plain project name.
+/// The `(workspace, project)` halves of a `workspace/project` label passed
+/// as a project name (#1152): exactly one `/` with a name on each side.
fn split_slashed_project(value: &str) -> Option<(&str, &str)> {
let (left, right) = value.split_once('/')?;
if left.is_empty() || right.is_empty() || right.contains('/') {
@@ -1405,6 +1434,168 @@ mod tests {
);
}
+ /// #1152: a write never creates a project whose name carries a `/`. The
+ /// label's own pair is written to when it exists, and anything else is
+ /// refused rather than created.
+ #[tokio::test]
+ async fn a_slashed_write_resolves_its_own_pair_and_never_creates() {
+ let tmp = tempfile::TempDir::new().unwrap();
+ let store = Store::open(tmp.path()).unwrap();
+ let default_ws = store
+ .writer
+ .get_or_create_workspace("default")
+ .await
+ .unwrap();
+ let scratch = store
+ .writer
+ .get_or_create_project(default_ws, "scratch", None)
+ .await
+ .unwrap();
+ let myorg_ws = store.writer.get_or_create_workspace("myorg").await.unwrap();
+ let myproject = store
+ .writer
+ .get_or_create_project(myorg_ws, "myproject", None)
+ .await
+ .unwrap();
+ let resolver =
+ ScopeResolver::new(&store.reader, default_ws, scratch).with_writer(&store.writer);
+ let actor = ActorKey::default();
+
+ for workspace in [Some("default"), None] {
+ let written = resolver
+ .resolve_write_args(workspace, Some("myorg/myproject"), &actor)
+ .await
+ .unwrap();
+ assert_eq!(
+ (written.scope.workspace_id, written.scope.project_id),
+ (myorg_ws, myproject),
+ "{workspace:?}"
+ );
+ }
+ let err = resolver
+ .resolve_write_args(Some("default"), Some("myorg/ghost"), &actor)
+ .await
+ .unwrap_err();
+ assert!(
+ matches!(err, ScopeResolutionError::ProjectNotFoundInWorkspace { .. }),
+ "{err}"
+ );
+ for (workspace_id, name) in [
+ (default_ws, "myorg/myproject"),
+ (default_ws, "myorg/ghost"),
+ (myorg_ws, "ghost"),
+ ] {
+ assert_eq!(
+ store
+ .reader
+ .resolve_existing_project_name(workspace_id, name.to_owned())
+ .await
+ .unwrap(),
+ None,
+ "{name} must not have been created"
+ );
+ }
+ }
+
+ /// A project created with a `/` in its name before renames refused one
+ /// is still reached by that exact name, on reads and writes.
+ #[tokio::test]
+ async fn an_existing_slashed_project_wins_over_the_split() {
+ let tmp = tempfile::TempDir::new().unwrap();
+ let store = Store::open(tmp.path()).unwrap();
+ let default_ws = store
+ .writer
+ .get_or_create_workspace("default")
+ .await
+ .unwrap();
+ let legacy = store
+ .writer
+ .get_or_create_project(default_ws, "myorg/myproject", None)
+ .await
+ .unwrap();
+ let myorg_ws = store.writer.get_or_create_workspace("myorg").await.unwrap();
+ store
+ .writer
+ .get_or_create_project(myorg_ws, "myproject", None)
+ .await
+ .unwrap();
+ let resolver =
+ ScopeResolver::new(&store.reader, default_ws, legacy).with_writer(&store.writer);
+ let actor = ActorKey::default();
+
+ let read = resolver
+ .resolve_existing_args(
+ Some("default"),
+ Some("myorg/myproject"),
+ &actor,
+ ProjectAccess::Read,
+ )
+ .await
+ .unwrap();
+ assert_eq!(read.project_id, legacy);
+ let written = resolver
+ .resolve_write_args(Some("default"), Some("myorg/myproject"), &actor)
+ .await
+ .unwrap();
+ assert_eq!(written.scope.project_id, legacy);
+ }
+
+ /// The split names a pair the caller could have passed directly, so it
+ /// is authorized exactly like one: a user without a grant on the
+ /// label's project is refused on reads and writes, and nothing is
+ /// created in its place.
+ #[tokio::test]
+ async fn a_slashed_label_reaches_only_a_project_the_caller_may_use() {
+ let tmp = tempfile::TempDir::new().unwrap();
+ let store = Store::open(tmp.path()).unwrap();
+ let (ws, project, _, bob) = guard_fixture(&store).await;
+ let other_ws = store.writer.get_or_create_workspace("other").await.unwrap();
+ let secret = store
+ .writer
+ .get_or_create_project(other_ws, "secret", None)
+ .await
+ .unwrap();
+ let actor = ActorKey::default();
+ let bob_resolver = as_user(&store, ws, project, bob);
+
+ for need in [ProjectAccess::Read, ProjectAccess::Write] {
+ let refused = bob_resolver
+ .resolve_existing_args(Some("default"), Some("other/secret"), &actor, need)
+ .await;
+ assert!(refused.is_err(), "{need:?}: {refused:?}");
+ }
+ let refused = bob_resolver
+ .resolve_write_args(Some("default"), Some("other/secret"), &actor)
+ .await;
+ assert!(refused.is_err(), "{refused:?}");
+ assert_eq!(
+ store
+ .reader
+ .resolve_existing_project_name(ws, "other/secret".to_owned())
+ .await
+ .unwrap(),
+ None
+ );
+
+ // Control: with a grant, the same label reaches the project.
+ grant(&store, bob, secret, GrantLevel::Write).await;
+ let read = bob_resolver
+ .resolve_existing_args(
+ Some("default"),
+ Some("other/secret"),
+ &actor,
+ ProjectAccess::Write,
+ )
+ .await
+ .unwrap();
+ assert_eq!(read.project_id, secret);
+ let written = bob_resolver
+ .resolve_write_args(Some("default"), Some("other/secret"), &actor)
+ .await
+ .unwrap();
+ assert_eq!(written.scope.project_id, secret);
+ }
+
async fn user_named(store: &Store, username: &str, byte: u8) -> UserId {
store
.writer
diff --git a/docs/security-boundaries.md b/docs/security-boundaries.md
index ab5a6db4..c2e5cfb7 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; 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` `shared_candidate_query_deduplicates_before_bound_and_uses_only_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`, `a_slashed_label_reaches_only_a_project_the_caller_may_use` (a `workspace/project` label passed as the project is authorized as the pair it names and creates nothing when refused; granted control), `a_slashed_write_resolves_its_own_pair_and_never_creates`, `an_existing_slashed_project_wins_over_the_split`, 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` `shared_candidate_query_deduplicates_before_bound_and_uses_only_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 |