Skip to content

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

Rust

fix(skills): keep Antigravity routing assets consistent

AkitaOnRails2b459e6c51b0
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 7f9bc349..604f3790 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -71,7 +71,9 @@ version in [`docs/changelog/`](docs/changelog/):
`.agents/skills` with `--scope project`. `ai-memory setup` now uses it for
Antigravity, which until now got its skills only in `~/.agents/skills`, a
directory Antigravity does not read globally, and `uninstall --only skills`
- sweeps both roots. (#1357)
+ sweeps both roots. MCP-driven routing refresh and `backup-agents` expose and
+ preserve the same roots, including the shared project `.agents/skills`.
+ (#1357)
## [3.1.0] - 2026-10-16
diff --git a/crates/ai-memory-cli/src/commands/backup_agents.rs b/crates/ai-memory-cli/src/commands/backup_agents.rs
index 72a0c42e..2dda119b 100644
--- a/crates/ai-memory-cli/src/commands/backup_agents.rs
+++ b/crates/ai-memory-cli/src/commands/backup_agents.rs
@@ -360,14 +360,25 @@ pub fn discover_assets(
".gemini/antigravity-cli/mcp_config.json",
"antigravity/antigravity_mcp.json",
);
+ let [app_skills, cli_skills] =
+ super::install_skills::antigravity_global_skill_roots(home);
collect_dir_assets(
&mut assets,
AgentKind::AntigravityCli,
AgentAssetKind::Skill,
AgentAssetScope::Global,
- &gemini_dir.join("antigravity-cli").join("skills"),
+ &app_skills,
+ ".gemini/config/skills",
+ "antigravity/app-ide-skills",
+ )?;
+ collect_dir_assets(
+ &mut assets,
+ AgentKind::AntigravityCli,
+ AgentAssetKind::Skill,
+ AgentAssetScope::Global,
+ &cli_skills,
".gemini/antigravity-cli/skills",
- "antigravity/skills",
+ "antigravity/cli-skills",
)?;
collect_dir_assets(
&mut assets,
@@ -379,15 +390,18 @@ pub fn discover_assets(
"antigravity/plugins",
)?;
}
- if want_project {
+ // `.agents/skills` is shared with Codex. Attribute it to Codex when
+ // both agents are selected so one archive never maps two entries to
+ // the same restore target; an Antigravity-only backup still owns it.
+ if want_project && !filter_agent(AgentKind::Codex) {
collect_dir_assets(
&mut assets,
AgentKind::AntigravityCli,
AgentAssetKind::Skill,
AgentAssetScope::Project,
- &cwd.join(".gemini").join("skills"),
- ".gemini/skills",
- "project/gemini/skills",
+ &cwd.join(".agents").join("skills"),
+ ".agents/skills",
+ "project/antigravity/skills",
)?;
}
}
diff --git a/crates/ai-memory-cli/tests/suite/backup_agents.rs b/crates/ai-memory-cli/tests/suite/backup_agents.rs
index 07374aec..29b6d7fa 100644
--- a/crates/ai-memory-cli/tests/suite/backup_agents.rs
+++ b/crates/ai-memory-cli/tests/suite/backup_agents.rs
@@ -128,6 +128,9 @@ fn backup_and_restore_agents_round_trip() {
let agents_md = project.path().join("AGENTS.md");
fs::write(&agents_md, "# Project Rules\nCodex rules").unwrap();
+ let shared_skill = project.path().join(".agents/skills/shared/SKILL.md");
+ fs::create_dir_all(shared_skill.parent().unwrap()).unwrap();
+ fs::write(&shared_skill, "# Shared skill").unwrap();
let opencode_config = home.path().join(".config/opencode/opencode.json");
fs::create_dir_all(opencode_config.parent().unwrap()).unwrap();
@@ -236,6 +239,15 @@ fn backup_and_restore_agents_round_trip() {
let restored_agents_md = fs::read_to_string(restore_project.path().join("AGENTS.md")).unwrap();
assert_eq!(restored_agents_md, "# Project Rules\nCodex rules");
+ assert_eq!(
+ fs::read_to_string(
+ restore_project
+ .path()
+ .join(".agents/skills/shared/SKILL.md")
+ )
+ .unwrap(),
+ "# Shared skill"
+ );
let restored_agy =
fs::read_to_string(restore_home.path().join(".gemini/config/mcp_config.json")).unwrap();
@@ -258,6 +270,106 @@ fn backup_and_restore_agents_round_trip() {
}
}
+#[test]
+fn antigravity_backup_round_trips_every_documented_skill_root() {
+ let _guard = cli_test_lock();
+ let home = tempfile::tempdir().unwrap();
+ let project = tempfile::tempdir().unwrap();
+ let fixtures = [
+ (
+ home.path().join(".gemini/config/skills/app/SKILL.md"),
+ "# App and IDE skill",
+ ),
+ (
+ home.path()
+ .join(".gemini/antigravity-cli/skills/cli/SKILL.md"),
+ "# CLI skill",
+ ),
+ (
+ project.path().join(".agents/skills/workspace/SKILL.md"),
+ "# Workspace skill",
+ ),
+ ];
+ for (path, body) in &fixtures {
+ fs::create_dir_all(path.parent().unwrap()).unwrap();
+ fs::write(path, body).unwrap();
+ }
+ let obsolete = project.path().join(".gemini/skills/obsolete/SKILL.md");
+ fs::create_dir_all(obsolete.parent().unwrap()).unwrap();
+ fs::write(&obsolete, "# Old undocumented root").unwrap();
+
+ let archive = project.path().join("antigravity.tar.gz");
+ let backup = command_with_env(home.path(), project.path())
+ .args([
+ "backup-agents",
+ "-o",
+ archive.to_str().unwrap(),
+ "--agents",
+ "antigravity",
+ "--include-secrets",
+ ])
+ .output()
+ .unwrap();
+ assert!(
+ backup.status.success(),
+ "backup failed: {}",
+ String::from_utf8_lossy(&backup.stderr)
+ );
+
+ let restored_home = tempfile::tempdir().unwrap();
+ let restored_project = tempfile::tempdir().unwrap();
+ let restore = command_with_env(restored_home.path(), restored_project.path())
+ .args([
+ "restore-agents",
+ "-i",
+ archive.to_str().unwrap(),
+ "--agents",
+ "antigravity",
+ "--apply",
+ ])
+ .output()
+ .unwrap();
+ assert!(
+ restore.status.success(),
+ "restore failed: {}",
+ String::from_utf8_lossy(&restore.stderr)
+ );
+ assert_eq!(
+ fs::read_to_string(
+ restored_home
+ .path()
+ .join(".gemini/config/skills/app/SKILL.md")
+ )
+ .unwrap(),
+ "# App and IDE skill"
+ );
+ assert_eq!(
+ fs::read_to_string(
+ restored_home
+ .path()
+ .join(".gemini/antigravity-cli/skills/cli/SKILL.md")
+ )
+ .unwrap(),
+ "# CLI skill"
+ );
+ assert_eq!(
+ fs::read_to_string(
+ restored_project
+ .path()
+ .join(".agents/skills/workspace/SKILL.md")
+ )
+ .unwrap(),
+ "# Workspace skill"
+ );
+ assert!(
+ !restored_project
+ .path()
+ .join(".gemini/skills/obsolete/SKILL.md")
+ .exists(),
+ "the undocumented legacy project path must not be archived"
+ );
+}
+
#[test]
fn backup_agents_sanitizes_secrets_by_default() {
let _guard = cli_test_lock();
@@ -879,6 +991,15 @@ fn backup_agents_does_not_follow_config_or_asset_root_symlinks() {
fs::create_dir_all(&external_plugins).unwrap();
fs::write(external_plugins.join("payload"), b"outside plugin").unwrap();
symlink(&external_plugins, home.path().join(".claude/plugins")).unwrap();
+ let external_skills = outside.path().join("skills");
+ fs::create_dir_all(&external_skills).unwrap();
+ fs::write(
+ external_skills.join("SKILL.md"),
+ b"outside Antigravity skill",
+ )
+ .unwrap();
+ fs::create_dir_all(home.path().join(".gemini/config")).unwrap();
+ symlink(&external_skills, home.path().join(".gemini/config/skills")).unwrap();
let archive = project.path().join("backup.tar.gz");
let output = command_with_env(home.path(), project.path())
@@ -889,7 +1010,7 @@ fn backup_agents_does_not_follow_config_or_asset_root_symlinks() {
assert!(output.status.success());
assert!(
!archive.exists(),
- "symlink-only assets must not be archived"
+ "symlink-only Claude and Antigravity assets must not be archived"
);
}
diff --git a/crates/ai-memory-core/src/routing_skills/ai-memory-routing-install/SKILL.md b/crates/ai-memory-core/src/routing_skills/ai-memory-routing-install/SKILL.md
index 3403ff9e..fc7d46c4 100644
--- a/crates/ai-memory-core/src/routing_skills/ai-memory-routing-install/SKILL.md
+++ b/crates/ai-memory-core/src/routing_skills/ai-memory-routing-install/SKILL.md
@@ -55,6 +55,6 @@ Use platform-aware path joining. Do not build paths by string concatenation.
## Refresh guidance
-For an agent-side refresh, call the install-routing tool (pass `compact: true` if the target file already uses the compact snippet or if managed Agent Skills handle detailed routing). Its returned `target_hints` are authoritative for skill roots: choose the right instruction filename from `agent_filenames`, write the markered block with the agent's file-edit tool, and write each managed skill file below the selected hint using its `relative_path`. Claude Code normally uses `CLAUDE.md` and `.claude/skills`; Codex, OpenCode, Cursor, Gemini CLI, and AGENTS-aware clients normally use `AGENTS.md` and `.agents/skills`; Grok Build CLI uses `AGENTS.md` and `.grok/skills`; GitHub Copilot CLI uses `AGENTS.md` and `.github/skills` unless the project says otherwise.
+For an agent-side refresh, call the install-routing tool (pass `compact: true` if the target file already uses the compact snippet or if managed Agent Skills handle detailed routing). Its returned `target_hints` are authoritative for skill roots: choose the right instruction filename from `agent_filenames`, write the markered block with the agent's file-edit tool, and write each managed skill file below the selected hint using its `relative_path`. When a hint is an array, install the skill under every listed root. Claude Code normally uses `CLAUDE.md` and `.claude/skills`; Codex, OpenCode, Cursor, Gemini CLI, and AGENTS-aware clients normally use `AGENTS.md` and `.agents/skills`; Antigravity uses `AGENTS.md` and `.agents/skills` in a project, with separate App/IDE and CLI roots globally; Grok Build CLI uses `AGENTS.md` and `.grok/skills`; GitHub Copilot CLI uses `AGENTS.md` and `.github/skills` unless the project says otherwise.
For a CLI refresh, prefer the canonical install command. The snippet and skills must be updated from the same core-owned assets so they do not drift.
diff --git a/crates/ai-memory-mcp/src/server.rs b/crates/ai-memory-mcp/src/server.rs
index 41809494..69ff5df8 100644
--- a/crates/ai-memory-mcp/src/server.rs
+++ b/crates/ai-memory-mcp/src/server.rs
@@ -6418,7 +6418,8 @@ impl AiMemoryServer {
`agent_filenames` for rules-file targets, `managed_skills` for \
Agent Skill files, and `target_hints` for project/global \
`.claude/skills`, `.agents/skills`, `.devin/skills`, `.grok/skills`, \
- `.github/skills`, `.hermes/skills`, `$GROK_HOME/skills` (default `~/.grok/skills`), \
+ `.github/skills`, `.hermes/skills`, Antigravity's `.gemini` skill roots, \
+ `$GROK_HOME/skills` (default `~/.grok/skills`), \
`$COPILOT_HOME/skills` (default `~/.copilot/skills`), and Devin Windows global roots. \
Use when the user asks to install or refresh ai-memory routing in this project. \
Pass `compact: true` to return the compact routing block that delegates \
@@ -6484,7 +6485,8 @@ impl AiMemoryServer {
"devin": ".devin/skills",
"grok": ".grok/skills",
"copilot_cli": ".github/skills",
- "hermes": ".hermes/skills"
+ "hermes": ".hermes/skills",
+ "antigravity_cli": ".agents/skills"
},
"global": {
"claude_code": "~/.claude/skills",
@@ -6495,7 +6497,11 @@ impl AiMemoryServer {
},
"grok": "$GROK_HOME/skills (default: ~/.grok/skills)",
"copilot_cli": "$COPILOT_HOME/skills (default: ~/.copilot/skills)",
- "hermes": "~/.hermes/skills"
+ "hermes": "~/.hermes/skills",
+ "antigravity_cli": [
+ "~/.gemini/config/skills",
+ "~/.gemini/antigravity-cli/skills"
+ ]
}
},
"overwrite_guidance": {
@@ -6509,7 +6515,7 @@ impl AiMemoryServer {
"If the target file already uses the compact routing block (or if managed Agent Skills handle detailed routing), call memory_install_self_routing with compact: true so the compact format is preserved.",
"If the file doesn't exist, create it with just the markered_block (plus a trailing newline).",
"If the file exists but has no ai-memory markers, append the markered_block with one blank line of separation from existing content.",
- "Install each managed_skills item under the selected skill root from target_hints using its relative_path, for example .claude/skills/<relative_path>, .agents/skills/<relative_path>, .devin/skills/<relative_path>, .grok/skills/<relative_path>, $GROK_HOME/skills/<relative_path> (default ~/.grok/skills), .github/skills/<relative_path> or $COPILOT_HOME/skills/<relative_path> (default ~/.copilot/skills) for GitHub Copilot CLI, or %APPDATA%\\devin\\skills\\<relative_path> on Windows global Devin installs.",
+ "Install each managed_skills item under the selected skill root from target_hints using its relative_path. When a hint is an array, install the item under every listed root; Antigravity's global hint intentionally lists its App/IDE and CLI roots. On Windows, Devin's global root is %APPDATA%\\devin\\skills.",
"Existing skill files containing the managed marker <!-- ai-memory-managed: routing-skill --> may be replaced; unmanaged same-name skills must not be overwritten unless the human explicitly forces replacement."
]
});
@@ -9518,6 +9524,24 @@ mod tests {
.unwrap(),
"~/.hermes/skills"
);
+ assert_eq!(
+ response["target_hints"]["project"]["antigravity_cli"]
+ .as_str()
+ .unwrap(),
+ ".agents/skills"
+ );
+ assert_eq!(
+ response["target_hints"]["global"]["antigravity_cli"]
+ .as_array()
+ .unwrap()
+ .iter()
+ .map(|root| root.as_str().unwrap())
+ .collect::<Vec<_>>(),
+ [
+ "~/.gemini/config/skills",
+ "~/.gemini/antigravity-cli/skills"
+ ]
+ );
assert_eq!(
response["target_hints"]["global"]["claude_code"]
.as_str()
@@ -9576,6 +9600,8 @@ mod tests {
.join("\n");
assert!(notes.contains(ai_memory_core::routing_skills::MANAGED_MARKER));
assert!(notes.contains("unmanaged same-name skills"));
+ assert!(notes.contains("When a hint is an array"));
+ assert!(notes.contains("Antigravity"));
assert!(notes.contains("%APPDATA%\\devin\\skills"));
assert!(notes.contains("explicitly forces replacement"));
}
diff --git a/docs/design-backup-agent-assets.md b/docs/design-backup-agent-assets.md
index 8e47dc3b..ccce50f5 100644
--- a/docs/design-backup-agent-assets.md
+++ b/docs/design-backup-agent-assets.md
@@ -19,7 +19,7 @@ Before these commands were added:
| :--- | :--- | :--- | :--- | :--- |
| **Claude Code / Desktop** | `~/.claude.json`<br>`~/.claude/settings.json`<br>`claude_desktop_config.json` | `~/.claude/skills/`<br>`.claude/skills/` | `~/.claude/plugins/`<br>`Claude Extensions/` | `CLAUDE.md` |
| **OpenAI Codex CLI** | `~/.codex/config.toml`<br>`~/.codex/mcp.json` | `~/.agents/skills/`<br>`.agents/skills/`<br>`~/.codex/skills/` | `~/.codex/plugins/` | `AGENTS.md` |
-| **Antigravity CLI (`agy`) / Gemini** | `~/.gemini/settings.json`<br>`~/.gemini/config/mcp_config.json`<br>`antigravity-cli/mcp_config.json` | `~/.gemini/antigravity-cli/skills/`<br>`~/.gemini/skills/`<br>`.gemini/skills/` | `antigravity-cli/plugins/`<br>`~/.gemini/plugins/` | `GEMINI.md`<br>`AGENTS.md`<br>`rules/` |
+| **Antigravity CLI (`agy`) / Gemini** | `~/.gemini/settings.json`<br>`~/.gemini/config/mcp_config.json`<br>`antigravity-cli/mcp_config.json` | Antigravity: `~/.gemini/config/skills/`, `~/.gemini/antigravity-cli/skills/`, `.agents/skills/`<br>Gemini: `~/.gemini/skills/`, `.gemini/skills/` | `antigravity-cli/plugins/`<br>`~/.gemini/plugins/` | `GEMINI.md`<br>`AGENTS.md`<br>`rules/` |
| **Cursor IDE** | `~/.cursor/mcp.json`<br>`.cursor/mcp.json` | — | VS Code / Cursor extensions | `.cursorrules`<br>`.cursor/rules/` |
| **OpenCode (v1 / v2)** | `opencode.json`<br>`opencode.jsonc`<br>`~/.config/opencode/opencode.json` | `~/.config/opencode/skills/` | `~/.config/opencode/plugins/` | `AGENTS.md` |
| **Devin CLI** | `~/.devin/config.json` | `~/.devin/skills/` | — | Devin instructions |
diff --git a/docs/install.md b/docs/install.md
index 28bd67e9..4bc7f50a 100644
--- a/docs/install.md
+++ b/docs/install.md
@@ -3250,7 +3250,7 @@ Linux, and macOS. This does not rewrite line endings in user-authored files.
|---|---|
| `--no-skills` | Refresh only the markered instruction block. |
| `--skills-scope <scope>` | Choose project-local or user-global skill roots. Values: `project`, `global`. Defaults to `project`. |
-| `--skills-agent <agent>` | Choose `.claude/skills`, `.agents/skills`, `.devin/skills`, `.grok/skills`, GitHub Copilot CLI's `.github/skills`, Google Antigravity's roots, or both Claude/Agents roots. Values: `claude-code`, `agents`, `devin`, `grok`, `copilot-cli`, `antigravity`, `both`. By default, `CLAUDE.md` targets imply `claude-code`, `AGENTS.md` targets imply `agents`, and both instruction files imply `both`. |
+| `--skills-agent <agent>` | Choose `.claude/skills`, `.agents/skills`, `.devin/skills`, `.grok/skills`, `.hermes/skills`, GitHub Copilot CLI's `.github/skills`, Google Antigravity's roots, or both Claude/Agents roots. Values: `claude-code`, `agents`, `devin`, `grok`, `copilot-cli`, `hermes`, `antigravity`, `both`. By default, `CLAUDE.md` targets imply `claude-code`, `AGENTS.md` targets imply `agents`, and both instruction files imply `both`. |
| `--skills-target-dir <dir>` | Write managed skill directories below an explicit root instead of inferring from scope and agent. |
| `--skills-force` | Replace unmanaged same-name skills during `install-instructions`; without it, they are left untouched and the command exits with an actionable error. |
@@ -3263,6 +3263,7 @@ ai-memory install-skills --scope global --agent agents
ai-memory install-skills --scope global --agent devin
ai-memory install-skills --scope global --agent grok
ai-memory install-skills --scope global --agent copilot-cli
+ai-memory install-skills --scope global --agent hermes
ai-memory install-skills --scope global --agent antigravity
ai-memory install-skills --agent both --print
ai-memory install-skills --target-dir .custom/skills --force
@@ -3273,17 +3274,17 @@ ai-memory install-skills --target-dir .custom/skills --force
| Flag | Meaning |
|---|---|
| `--scope <scope>` | Install into this project or the current user's global skill roots. Values: `project`, `global`. Defaults to `project`. |
-| `--agent <agent>` | Install into Claude Code's skill root, the cross-agent skill root, Devin's skill root, Grok's skill root, GitHub Copilot CLI's skill root, Google Antigravity's skill roots, or both Claude/Agents roots. Values: `claude-code`, `agents`, `devin`, `grok`, `copilot-cli`, `antigravity` (aliases `antigravity-cli`, `agy`), `both`. Defaults to `claude-code`. |
+| `--agent <agent>` | Install into Claude Code's skill root, the cross-agent skill root, Devin's skill root, Grok's skill root, Hermes Agent's skill root, GitHub Copilot CLI's skill root, Google Antigravity's skill roots, or both Claude/Agents roots. Values: `claude-code`, `agents`, `devin`, `grok`, `copilot-cli`, `hermes`, `antigravity` (aliases `antigravity-cli`, `agy`), `both`. Defaults to `claude-code`. |
| `--target-dir <dir>` | Write managed skill directories below an explicit root; `--scope` and `--agent` are ignored. |
| `--print` | Print target paths and `SKILL.md` contents without writing files. A global Grok plan also prints `$GROK_HOME/rules/ai-memory-handoff.md`. |
| `--force` | Replace unmanaged same-name skills (and, for global Grok, an unmanaged first-turn rule); without it, user-authored same-name files are preserved. |
Default skill target roots:
-| Scope | `--agent claude-code` | `--agent agents` | `--agent devin` | `--agent grok` | `--agent copilot-cli` | `--agent antigravity` |
-|---|---|---|---|---|---|---|
-| `project` | `.claude/skills` | `.agents/skills` | `.devin/skills` | `.grok/skills` | `.github/skills` | `.agents/skills` |
-| `global` | `~/.claude/skills` | `~/.agents/skills` | Windows: `%APPDATA%\devin\skills`; non-Windows: `~/.devin/skills` | `$GROK_HOME/skills` (default `~/.grok/skills`), plus the first-turn rule `$GROK_HOME/rules/ai-memory-handoff.md` | `$COPILOT_HOME/skills` (default `~/.copilot/skills`) | both `~/.gemini/config/skills` (Antigravity App and IDE) and `~/.gemini/antigravity-cli/skills` (Antigravity CLI) |
+| Scope | `--agent claude-code` | `--agent agents` | `--agent devin` | `--agent grok` | `--agent copilot-cli` | `--agent hermes` | `--agent antigravity` |
+|---|---|---|---|---|---|---|---|
+| `project` | `.claude/skills` | `.agents/skills` | `.devin/skills` | `.grok/skills` | `.github/skills` | `.hermes/skills` | `.agents/skills` |
+| `global` | `~/.claude/skills` | `~/.agents/skills` | Windows: `%APPDATA%\devin\skills`; non-Windows: `~/.devin/skills` | `$GROK_HOME/skills` (default `~/.grok/skills`), plus the first-turn rule `$GROK_HOME/rules/ai-memory-handoff.md` | `$COPILOT_HOME/skills` (default `~/.copilot/skills`) | `~/.hermes/skills` | both `~/.gemini/config/skills` (Antigravity App and IDE) and `~/.gemini/antigravity-cli/skills` (Antigravity CLI) |
Each managed skill is written as `<root>/<skill-name>/SKILL.md`.
diff --git a/docs/security-boundaries.md b/docs/security-boundaries.md
index b87f75e1..43070b6e 100644
--- a/docs/security-boundaries.md
+++ b/docs/security-boundaries.md
@@ -115,7 +115,7 @@ means the boundary is not built yet.
| 14e | `memory_write_page` session evidence cites only a session of the target project (#708) | `ai-memory-mcp/src/server.rs` `memory_write_page` — a `session_id` is accepted only when `require_session_in_scope` resolves the session (where its observations landed, else its session row, as `Consolidator::session_target` does) to the same `(workspace_id, project_id)` the write grant was checked against; unknown and foreign ids get one refusal, so the error is no existence oracle; `scope: "global"` with a `session_id` is refused; `refuse_pinned_page_overwrite` keeps a write that cites a session off a pinned page; only a write to `sessions/<id>.md` reconciles the session's queued SessionEnd job | `server.rs` `write_page_refuses_a_session_from_another_project` (a foreign and an unknown session refused, no evidence row written, the foreign job still queued; control: the project's own session accepted), `session_evidence_write_leaves_a_pinned_page_alone` (control: the same write without `session_id` edits the page), `session_evidence_on_another_path_leaves_the_job_queued`, `write_page_rejects_a_malformed_or_global_session_id` — each of the scope check, the pinned check and the session-page-only reconcile proven to fail its test when removed | STRONG |
| 14f | Consolidation apply path validates cross-scope wikilinks against the store (#1218) | `ai-memory-consolidate/src/link_guard.rs` `unresolved_cross_scope_links` — every `[[project:path]]` / `[[workspace/project:path]]` / `[[_global:path]]` target in a proposed body is resolved with the no-create `lookup_existing_scope` (never creates a scope) and batch-checked via `reader.rs` `existing_latest_paths`; a missing workspace/project, an ambiguous project name, or a missing target page de-links the wikilink, while a genuine store failure aborts the consolidation before any write. Typed `relations:` frontmatter targets go through the same check, and `prune_relations` drops an unresolved entry (an emptied relation and an emptied map with it). `delink_body` → `ai-memory-wiki/src/markdown.rs` `delink_wikilinks` drops the brackets and keeps the label, skipping code fences and inline code exactly as `extract_links` does. Wired into all three apply paths (`consolidator.rs` single-page and batch, `bootstrap.rs`) after the pinned/foreign-slot/portable guards and before the atomic `Wiki::apply_batch` / `write_page`, so an invented cross-project dependency can no longer be written and flagged by the lint pass later. Same-project `[[target]]` links stay untouched by design (the target may be written later). The probe runs with no viewer, so it reports nothing for a `restricted` project (the global preferences project excepted): a link into one is always de-linked, and whether a link survived says nothing about which paths exist there | `consolidator.rs` `batch_delinks_invented_cross_scope_wikilinks` (invented `[[_global:nope]]`, `[[otherproj:notes/missing.md]]`, `[[ghostproj:x.md]]` de-linked to plain text; controls: a cross-scope link to an existing page and a same-project pending link survive byte-identical; `dangling_cross_project_links` left empty), `single_page_delinks_invented_cross_scope_wikilinks`, `single_page_drops_unresolved_cross_scope_relations` (unresolved `relations:` entries dropped; controls: a live cross-scope and a same-project target stay), `link_guard.rs` `prune_relations_drops_only_unresolved_cross_scope_entries`, `bootstrap.rs` `bootstrap_delinks_invented_cross_scope_wikilinks` — each proven to fail with the guard neutralized; `markdown.rs` `delink_wikilinks_strips_only_listed_cross_scope_links`, `delink_wikilinks_without_label_keeps_the_target_text`, `delink_wikilinks_skips_code_and_leaves_empty_set_untouched`; store `multi_session.rs` `existing_latest_paths_reports_exactly_the_live_paths` (exact live-path set, superseded path still resolves, foreign scope sees nothing), `existing_latest_paths_reports_nothing_for_a_restricted_project` (real and absent paths answer alike while restricted; control: reopened, the page is seen) | STRONG |
| 14g | Web project search and its recall trace honour `memory_query`'s scope rules (#708) and never describe another project | `ai-memory-web/src/routes/search.rs` resolves `workspace`+`project` through `resolve_read_scope` (`lookup_existing_scope_guarded`, no-create, `ProjectAccess::Read`) before any ranking, and refuses partial scope; scoped `/api/v1/search` keeps `lookup_project` / `resolve_many_existing_scopes_guarded`; `ai-memory-web/src/recall.rs` ranks only the resolved scopes through `ReaderPool::hybrid_search_scopes`, whose streams and graph expansion are bound to each `(workspace_id, project_id)`; a search with no scope stays `search_pages_with_meta(.., viewer)` (readable repositories only) | `ai-memory-web` `tests/suite/recall_trace.rs` — `project_search_refuses_a_restricted_project_without_a_grant` (bob, with no grant, gets 403 from `/web/search` with and without `explain=1` and from scoped `/api/v1/search`, with no path, body text or trace in the response, and a `scopes` POST naming the restricted project next to an open one is refused; alice's grant and an unrestricted viewer are the controls), `project_search_fails_closed_on_unknown_and_partial_scope` (unknown project or workspace 404 with nothing created, partial scope 400), `explain_renders_stream_ranks_rrf_authority_and_timings` (a better-matching page in a sibling project never reaches the hits or the trace), `search_scope_selector_lists_only_readable_projects` (the search page's "Search in" selector lists only projects the viewer may read, and a hand-typed `scope=` for an ungranted project is a 403 that leaks nothing; controls: the granted reader and an unrestricted viewer; passing no viewer to `list_projects_with_stats` in the handler fails it), `routes.rs` `search_page_scope_selector_round_trips_and_rejects_malformed_values` (a malformed `scope` is a 400); `recall_trace.rs` `kind_filter_does_not_widen_what_a_viewer_can_read` (a `kind`/`tier` filter only narrows: bob gets no hits and a 403 on a scoped search; alice and an unrestricted viewer are the controls), `search_filters_a_project_by_kind_and_tier_keeping_rank_order` (survivors of a filter keep the unfiltered order), `reranker_is_shown_only_the_pages_the_filter_keeps` (a dropped page never reaches the reranker), `kind_and_tier_filters_hold_in_every_stream` (FTS, entity, vector, observation and both graph directions each filter in SQL; dropping any one stream's predicate fails it), `kind_filter_finds_a_rare_kind_the_unfiltered_page_ranks_out` and `cross_project_kind_filter_sees_past_the_candidate_window` (the filter sees past the candidate window in both modes); `ai-memory-mcp` `tests/suite/web_search_parity.rs` (same top-k order as `memory_query` from `/web` and `/api/v1`, with a deterministic embedder and with none, explain on and off, and merged `scopes`; controls show a web search without the embedder, or the old FTS-only scoped search, would fail it) | STRONG. Bite checks: passing no viewer to `resolve_read_scope` in the search handler, to `lookup_project` or to `resolve_scopes` in the API each fails the restricted-project test; dropping the query vector in `recall.rs` fails the embedder parity tests |
-| 15 | Agent-archive restore path confinement, resource bounds, and consistency | `ai-memory-cli/src/commands/restore_agents.rs` stages only bounded regular UTF-8 entries; requires a one-to-one manifest/body/checksum/target mapping; allowlists destinations by scope; rejects symlinked descendants; writes each file atomically and rolls back earlier writes after a later failure. `backup_agents.rs` skips direct and directory-root source symlinks, bounds individual assets, and atomically replaces a private archive only after gzip completion | `backup_agents.rs` `restore_agents_rejects_path_traversal`, `restore_agents_rejects_unauthorized_destination_path`, `restore_agents_verifies_sha256_integrity`, `restore_agents_requires_a_complete_one_to_one_manifest`, `restore_agents_rejects_oversized_entries_from_the_header`, `restore_agents_rejects_a_symlinked_destination_parent`, `backup_agents_does_not_follow_config_or_asset_root_symlinks`, and `failed_backup_leaves_the_previous_archive_intact`; `backup_and_restore_agents_round_trip` is the valid-path control; `restore_agents::tests::rollback_removes_new_files_and_restores_overwrites` covers recovery | STRONG |
+| 15 | Agent-archive restore path confinement, resource bounds, and consistency | `ai-memory-cli/src/commands/restore_agents.rs` stages only bounded regular UTF-8 entries; requires a one-to-one manifest/body/checksum/target mapping; allowlists destinations by scope; rejects symlinked descendants; writes each file atomically and rolls back earlier writes after a later failure. `backup_agents.rs` skips direct and directory-root source symlinks, bounds individual assets, attributes a shared skill root only once, and atomically replaces a private archive only after gzip completion | `backup_agents.rs` `restore_agents_rejects_path_traversal`, `restore_agents_rejects_unauthorized_destination_path`, `restore_agents_verifies_sha256_integrity`, `restore_agents_requires_a_complete_one_to_one_manifest`, `restore_agents_rejects_oversized_entries_from_the_header`, `restore_agents_rejects_a_symlinked_destination_parent`, `backup_agents_does_not_follow_config_or_asset_root_symlinks` (Claude and Antigravity roots), and `failed_backup_leaves_the_previous_archive_intact`; `backup_and_restore_agents_round_trip` and `antigravity_backup_round_trips_every_documented_skill_root` are the valid-path controls; `restore_agents::tests::rollback_removes_new_files_and_restores_overwrites` covers recovery | STRONG |
| 16 | Relay queue identity, migration, and private filesystem state | `companions/ai-memory-relay/src/queue.rs` `Queue::open_inner` performs read-only identity preflight, rechecks under `IMMEDIATE`, commits schema and metadata together; `configure` checks the presence of user objects and rechecks `identity`/`schema_version` metadata on the same connection before every bounded BUSY/LOCKED retry; `fsguard.rs` checks existing paths and creates owner-only files before SQLite opens them | `tests/relay.rs` `a_foreign_database_is_refused_byte_for_byte`, `unknown_schemas_refuse_without_mutation`, `a_foreign_database_with_a_writer_is_refused_before_write_coordination`, `a_foreign_identity_after_preflight_is_refused_without_mutation`, `a_foreign_identity_during_journal_retry_is_refused_without_mutation`, `journal_retry_refuses_a_changed_version_or_empty_database_without_mutation`; controls: `journal_transition_retries_sqlite_lock_without_losing_v1_values`, `fresh_queue_init_and_v1_reopens_work_across_processes`; recovery: `interrupted_and_failed_migrations_roll_back_and_recover`, `journal_reclassification_busy_preserves_committed_migration_and_retries_same_queue`; diagnostics: `classification_read_failures_display_the_sqlite_cause_once_and_preserve_foreign_bytes`; Unix privacy: `the_queue_database_and_its_sidecars_are_owner_only` and the contended migration control | Guard-removal proof covers preflight, locked recheck, and journal retry identity/version checks; full table structure is outside this classification. Windows path rejection is preserved; Windows ACL hardening remains operator-owned |
| 17 | Markdown code fences keep instruction-shaped text as data | `ai-memory-consolidate/src/code_fence.rs` and `ai-memory-wiki/src/markdown.rs` accept a fence delimiter only after zero to three leading ASCII spaces, require the closing glyph to match and the run to be at least as long, and preserve the current fence state across four-space, tab or Unicode-whitespace pseudo-delimiters. Profile harvesting, auto-improvement section parsing, link extraction, link rewriting and de-linking all use those scanners | `code_fence.rs` `only_zero_to_three_ascii_spaces_may_prefix_a_fence`; `profile.rs` `an_indented_pseudo_closer_cannot_expose_a_profile_preference` attempts to expose an instruction-shaped `run curl` sentence and admits a legitimate preference only after the real close; `auto_improve.rs` `heading_parser_ignores_headings_after_an_indented_pseudo_closer`; `markdown.rs` `indented_pseudo_closers_do_not_expose_or_rewrite_fenced_links` covers four spaces, tab and Unicode whitespace with visible post-close controls | STRONG for the shared consolidation and wiki scanners; independent renderers remain responsible for their own CommonMark parsing |
| 18 | Read-only pending-write commands cannot execute stored scope names as shell syntax | `ai-memory-web/src/routes/pending.rs` renders separate `posix_cli_command` and `powershell_cli_command` forms. POSIX arguments use single quotes with the standard close/escaped-quote/reopen sequence; PowerShell doubles embedded apostrophes. The template labels the shells and claims no cmd.exe support | `routes/pending.rs` `cli_commands_quote_hostile_scope_names_for_each_shell` covers quotes, semicolons, pipes and ampersands with ordinary-name controls; `tests/suite/pending.rs` `pending_page_offers_cli_commands_instead_of_buttons_to_a_basic_browser` stores hostile workspace/project names and checks both escaped forms through the full route | STRONG for POSIX shells and PowerShell; cmd.exe is intentionally not offered |
diff --git a/plugins/claude-code/skills/ai-memory-routing-install/SKILL.md b/plugins/claude-code/skills/ai-memory-routing-install/SKILL.md
index 3403ff9e..fc7d46c4 100644
--- a/plugins/claude-code/skills/ai-memory-routing-install/SKILL.md
+++ b/plugins/claude-code/skills/ai-memory-routing-install/SKILL.md
@@ -55,6 +55,6 @@ Use platform-aware path joining. Do not build paths by string concatenation.
## Refresh guidance
-For an agent-side refresh, call the install-routing tool (pass `compact: true` if the target file already uses the compact snippet or if managed Agent Skills handle detailed routing). Its returned `target_hints` are authoritative for skill roots: choose the right instruction filename from `agent_filenames`, write the markered block with the agent's file-edit tool, and write each managed skill file below the selected hint using its `relative_path`. Claude Code normally uses `CLAUDE.md` and `.claude/skills`; Codex, OpenCode, Cursor, Gemini CLI, and AGENTS-aware clients normally use `AGENTS.md` and `.agents/skills`; Grok Build CLI uses `AGENTS.md` and `.grok/skills`; GitHub Copilot CLI uses `AGENTS.md` and `.github/skills` unless the project says otherwise.
+For an agent-side refresh, call the install-routing tool (pass `compact: true` if the target file already uses the compact snippet or if managed Agent Skills handle detailed routing). Its returned `target_hints` are authoritative for skill roots: choose the right instruction filename from `agent_filenames`, write the markered block with the agent's file-edit tool, and write each managed skill file below the selected hint using its `relative_path`. When a hint is an array, install the skill under every listed root. Claude Code normally uses `CLAUDE.md` and `.claude/skills`; Codex, OpenCode, Cursor, Gemini CLI, and AGENTS-aware clients normally use `AGENTS.md` and `.agents/skills`; Antigravity uses `AGENTS.md` and `.agents/skills` in a project, with separate App/IDE and CLI roots globally; Grok Build CLI uses `AGENTS.md` and `.grok/skills`; GitHub Copilot CLI uses `AGENTS.md` and `.github/skills` unless the project says otherwise.
For a CLI refresh, prefer the canonical install command. The snippet and skills must be updated from the same core-owned assets so they do not drift.
diff --git a/plugins/codex/skills/ai-memory-routing-install/SKILL.md b/plugins/codex/skills/ai-memory-routing-install/SKILL.md
index 3403ff9e..fc7d46c4 100644
--- a/plugins/codex/skills/ai-memory-routing-install/SKILL.md
+++ b/plugins/codex/skills/ai-memory-routing-install/SKILL.md
@@ -55,6 +55,6 @@ Use platform-aware path joining. Do not build paths by string concatenation.
## Refresh guidance
-For an agent-side refresh, call the install-routing tool (pass `compact: true` if the target file already uses the compact snippet or if managed Agent Skills handle detailed routing). Its returned `target_hints` are authoritative for skill roots: choose the right instruction filename from `agent_filenames`, write the markered block with the agent's file-edit tool, and write each managed skill file below the selected hint using its `relative_path`. Claude Code normally uses `CLAUDE.md` and `.claude/skills`; Codex, OpenCode, Cursor, Gemini CLI, and AGENTS-aware clients normally use `AGENTS.md` and `.agents/skills`; Grok Build CLI uses `AGENTS.md` and `.grok/skills`; GitHub Copilot CLI uses `AGENTS.md` and `.github/skills` unless the project says otherwise.
+For an agent-side refresh, call the install-routing tool (pass `compact: true` if the target file already uses the compact snippet or if managed Agent Skills handle detailed routing). Its returned `target_hints` are authoritative for skill roots: choose the right instruction filename from `agent_filenames`, write the markered block with the agent's file-edit tool, and write each managed skill file below the selected hint using its `relative_path`. When a hint is an array, install the skill under every listed root. Claude Code normally uses `CLAUDE.md` and `.claude/skills`; Codex, OpenCode, Cursor, Gemini CLI, and AGENTS-aware clients normally use `AGENTS.md` and `.agents/skills`; Antigravity uses `AGENTS.md` and `.agents/skills` in a project, with separate App/IDE and CLI roots globally; Grok Build CLI uses `AGENTS.md` and `.grok/skills`; GitHub Copilot CLI uses `AGENTS.md` and `.github/skills` unless the project says otherwise.
For a CLI refresh, prefer the canonical install command. The snippet and skills must be updated from the same core-owned assets so they do not drift.