Skip to content

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

Rust

Merge branch 'main' into release/3.1

AkitaOnRails7aa568235cc8
diff --cc CHANGELOG.md
index 4a936f50,1a9a3964..1ab28d20
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@@ -11,152 -11,23 +11,178 @@@ version in [`docs/changelog/`](docs/cha
## [Unreleased]
+### Added
+- Added opt-in session inspection and owned-session purging for signed-in
+ browser users, enabled at runtime with `serve --enable-session-management`
+ (`AI_MEMORY_ENABLE_SESSION_MANAGEMENT`). A user can purge only a session they
+ own in a project they may write; an Admin can purge any. Requested in #1231.
+ (#1267)
+- Added opt-in self-service `aim_` API keys for signed-in browser users,
+ enabled at runtime with `serve --enable-self-service-keys`
+ (`AI_MEMORY_ENABLE_SELF_SERVICE_KEYS`). Labels must be 1 to 128 characters
+ and a user may hold at most 20 active keys. A self-issued key survives a
+ password reset or account disable and must be revoked separately. Requested
+ in #1231. (#1268)
+- Added `ai-memory search --global`, which searches the wiki pages of every
+ project from the terminal instead of only the current one. Each hit shows
+ its `workspace/project` in the text output and carries `workspace` and
+ `project` fields in `--json`. The flag cannot be combined with
+ `--workspace` or `--project`, and a search without it still resolves its
+ scope from the current directory. The server side is `GET /admin/search`
+ with no `workspace`/`project`: its hits now include `workspace` and
+ `project` next to the fields they already had, and the route stays
+ root-only on a multi-user server. Global search covers wiki pages only;
+ raw observations and a search limited to one workspace are not part of
+ this change. (#1253)
+- Added kind and tier filters to the web search. The search page in `/web`
+ has "Kind" and "Tier" selects, and `/web/search` accepts `kind` and `tier`
+ for both a project search and a cross-project one. Every retrieval stream
+ applies the filter in its own query, so other kinds cannot crowd out a rare
+ one, a filtered search asks the streams for no more candidates than an
+ unfiltered one, and the reranker scores only pages the filter keeps. Kind
+ and tier both ignore case, a nonstandard kind is flagged on an empty
+ result, and "Search all projects" keeps the filters. An unknown `tier` is
+ a 400. (#1248)
+- Added `ai-memory setup --plan`, which prints the plan and changes nothing,
+ and `--plan --json`, which prints it as a JSON document with a `format`
+ version for a script or front end to render. The plan now says what each
+ detected agent was found by (its session store, its MCP config, or Muse's
+ directory), numbers the agents, and lists the other agents `--agent`
+ accepts. At the prompt you can type the numbers of the agents to wire
+ instead of `y`; a number outside the plan changes nothing. (#1270)
+- Added a native Windows path to the two-command install. `install.ps1`,
+ published with each release next to its own `.sha256`, checks the release
+ zip against that checksum, refuses archive entries that are absolute or
+ hold `..`, unpacks it under `%LOCALAPPDATA%\Programs\ai-memory` and adds
+ that directory to the user `PATH` (`AI_MEMORY_NO_MODIFY_PATH=1` skips it),
+ with no administrator rights. `ai-memory setup` now has a service step on
+ Windows: it writes an `ai-memory` value under the per-user `Run` key that
+ starts a hidden `ai-memory service-host` at logon, and starts it right away.
+ The value is written and read through the registry API, not by running
+ `reg.exe`: an unsigned binary running `reg.exe add` on the `Run` key is a
+ common persistence signal, and Bitdefender's behavioral engine quarantined
+ `ai-memory.exe` for it (#1280). Its paths are written plainly, without the
+ `\\?\` prefix a canonical path carries. Stopping the host does not run
+ `taskkill` either: `setup` and `uninstall` leave a stop request in the data
+ dir, and the host kills the server it started and exits. `taskkill` is
+ only the fallback for a host that does not answer within ten seconds (one
+ started by an older binary, or a hung one) or a server whose host already
+ died.
+ The host runs the server with no console window and restarts it after a
+ failure, giving up after five failures within ten seconds of starting.
+ `ai-memory uninstall --apply` stops the host and removes the value when it
+ still has the shape `setup` writes and names this install's data dir, so an
+ uninstall against another data dir (a second install, a test's temporary
+ one) leaves the entry alone. `ai-memory doctor` and `ai-memory status`
+ warn (`logon_binary_missing`, also in their `--json` output and when
+ `status` cannot reach the server) when that entry names an
+ `ai-memory.exe` that no longer exists, which is what an antivirus
+ quarantine leaves behind, and say how to restore the binary or remove the
+ entry. (#1271, #1280, #1300, #1311)
+- Added `ai-memory setup --web`, which shows the setup plan as a page in
+ your browser and applies the agents you tick there by running `ai-memory
+ setup --yes --agent ...` and streaming its output to the page. The page is
+ served on `127.0.0.1` behind a one-time address printed in the terminal
+ (opened in the browser unless `--no-open` or there is no desktop), refuses
+ requests with another `Host`, without the address's secret, or, for a
+ change, without the page's own `Origin` and CSRF token, and holds no token.
+ It stops on Finish, after 15 minutes without a request, or on Ctrl-C. (#1272)
+- Added a desktop installer preview, `companions/ai-memory-desktop`: a Tauri
+ app that uses an existing `ai-memory` install or copies its bundled one into
+ the same per-user location as `install.sh` and `install.ps1`, then shows the
+ `ai-memory setup --web` page in its own window. CI builds unsigned Linux,
+ macOS and Windows installers on manual dispatch; they are not attached to
+ releases until the project signs them. `setup --web` gained a hidden
+ `--stop-on-stdin-eof` flag so the page stops when the app does. (#1273)
+- A prompt that starts with `reload context` (for example `reload context
+ after last compaction, then …`) now puts the stretch of the session that
+ its last compaction dropped back in front of the agent: the prompts typed
+ between the latest two compactions, verbatim; the last captured reply (with
+ the assistant-capture opt-in); and the project's open handoffs, listed
+ without claiming them. The new read-only `GET /recap` route builds it from
+ captured observations. Claude Code and Codex receive it with that prompt
+ through `UserPromptSubmit` `additionalContext`, OpenCode V1/V2 through the
+ plugin's system/context hook, and Grok Build on the next `PostToolUse`.
+ Serving the recap writes nothing, so a reload never consumes a baton (#1230).
+- Added first-party CodeBuddy Code (Tencent) support. `codebuddy` is an
+ `AgentKind` (migration V81), so hook events are attributed to it and a
+ Claude Code-shaped tool payload (`tool_name`, `tool_input`, `tool_response`)
+ is stored as a closed tool observation instead of an empty `other` capture.
+ `install-hooks --agent codebuddy` (alias `code-buddy`) merges native
+ `ai-memory hook --event … --agent codebuddy` commands for seven events
+ (`SessionStart`, `UserPromptSubmit`, `PreToolUse`, `PostToolUse`,
+ `PreCompact`, `Stop`, `SessionEnd`) into the `hooks` key of
+ `~/.codebuddy/settings.json`, keeps sibling settings and your own hooks,
+ and changes nothing on a re-run. There is no script bundle. The
+ `SessionStart` hook delivers the pending handoff through
+ `hookSpecificOutput.additionalContext`, and a capture-only `SessionStart` or
+ `UserPromptSubmit` prints nothing, since CodeBuddy appends that output to
+ the session. A `SessionStart` without `cwd` falls back to
+ `CODEBUDDY_PROJECT_DIR`. `setup` wires CodeBuddy when
+ `~/.codebuddy` exists, `setup-agent --agent codebuddy` prints the hook
+ block, and `uninstall` removes the entries. Transcript backfill and
+ headless `codebuddy -p` session close are not part of this change.
+ Requested in #1299. (#1312)
+- Added the `memory_restore_page` MCP tool: without `rev` it lists the git
+ checkpoints that changed a page, and with `rev` it writes that version back
+ through the wiki write path (sanitizer, admission, slots and supersession
+ apply), keeping the checkpoint's frontmatter. Restoring can bring back text
+ a root deleted or purged, so both listing and restoring need the same admin
+ authority as `/admin/restore-page`. The MCP surface is now 24 tools. (#1307)
+
++
+### Changed
+- `ai-memory setup` now ends by naming the agents to restart and the question
+ to ask one of them, "What do you remember about this project?", instead of
+ a generic restart line. `install.sh` names the link's full path in its
+ `next:` line when `~/.local/bin` is not on `PATH`, so the suggested command
+ no longer fails with "command not found". The AUR install and upgrade
+ messages, and the README Fedora, Arch and macOS app steps, point to
+ `ai-memory setup` instead of the manual `init`, `systemctl` and
+ `install-*` commands. (#1270)
+- Changed how the opt-in session-start brief (`[briefing]
+ inject_on_session_start`) spends `max_chars`. Every pinned, `_rules/` and
+ `_slots/` page now gets a short excerpt first, taken from its frontmatter
+ `abstract:` or `summary:`, or else from the prose it opens with (read on
+ into its first list items). The budget left deepens pages to a longer
+ excerpt and then the whole body: pinned and `_slots/` pages first, then
+ pages a few bytes short of whole, then the cheapest bodies. Before, the
+ brief printed whole bodies in order, so one long `_rules/` page was cut with
+ a `[truncated by ...]` note and every page after it became an "omitted"
+ path. Bodies are no longer cut: a body that does not fit whole shows its
+ excerpt. Four or more unpinned excerpts from one folder share a heading,
+ and the omitted list and the closing note point at `memory_read_page`.
+ Small wikis whose pages fit still get every body whole. A project with many
+ standing pages now sees all of them, fewer in full: pin a page, or give it
+ an `abstract:`, to control what it shows. The change adds no marker key
+ and no migration. (#1264)
+
++
+### Fixed
++- Fixed `ai-memory run --yolo` failing with `401 Unauthorized` after it
++ re-ran itself under ai-jail on an install whose bearer token lives in
++ `[auth].bearer_token_file`. ai-jail's private home hides the data dir, so
++ the jailed run had no token. The outer run now passes the token it resolved,
++ and a `server_url` set in `config.toml` or derived from `bind`, into the
++ jail through the environment, never the command line. (#1284)
++
+ ## [3.0.1] - 2026-10-15
+
+ ### Fixed
+ - Fixed the WinSW v2.12.0 service-account example using the v3
+ `<username>` element. WinSW v2.12.0 expects separate `<domain>` and `<user>`
+ elements; it ignored `<username>` and installed the service as
+ `LocalSystem`, which cannot safely own a wiki under another user's profile.
+ The Windows guide now uses the version-correct XML, grants service logon,
+ explains reinstalling an existing service, and verifies its recorded
+ `StartName`. (#1321)
+ - Fixed `/web/health` warning that hook events wait in the local spool during
+ every active session. Hooks spool each event first and deliver it at the turn,
+ compaction or session boundary, so a few fresh events in the spool are normal,
+ and `ai-memory doctor` already reports them as information. The page now warns
+ only when an event has failed a delivery attempt, when the oldest event has
+ waited 15 minutes or more, or when its age is unknown; a full spool is still
+ an error. (#1320)
- Fixed a hook claiming a handoff from the wrong project when an event named
no directory. A `SessionStart` (or Kimi Code's `UserPromptSubmit`, or Grok's
first `PostToolUse`) whose payload carried no `cwd` sent `GET /handoff` with
diff --cc docs/security-boundaries.md
index 44e418d6,d5fad577..b234a565
--- a/docs/security-boundaries.md
+++ b/docs/security-boundaries.md
@@@ -109,13 -106,14 +109,16 @@@ means the boundary is not built yet
| 14d | `include_related` and the web page's backlinks show and walk only readable projects (#708) | `ai-memory-store/src/reader.rs` `related_walk(.., viewer)` — both the outgoing and incoming hop queries carry `readable_repository_predicate("pg.project_id", viewer)`, the same far-end filter `page_links` and `page_links_preview` apply (the preview's visible totals are counted under it too), so a page in a project the viewer cannot read is neither returned nor expanded; `ai-memory-mcp/src/server.rs` `memory_read_page` passes `viewer_from_parts`, `ai-memory-web/src/routes/page.rs` passes the request's viewer to `page_links_preview`, and the access bump only touches the filtered nodes | `related_walk.rs` `the_walk_hides_and_does_not_cross_projects_the_viewer_cannot_read` (an outgoing and an incoming neighbour in an ungranted restricted project are absent, and so is a granted page reachable only through one; control: a granted restricted project is shown, and no viewer walks the whole graph) — fails with the predicate removed; `ai-memory-web` `tests/suite/routes.rs` `page_backlink_from_an_unreadable_project_is_hidden` (the `/web` page's "Cited by" omits a page in an ungranted restricted project, with no title, path or project name; controls: a reader of both projects and an unrestricted viewer see it) — fails with the page handler passing no viewer to `page_links_preview`; `related_walk.rs` `page_links_preview_caps_in_sql_and_counts_only_readable_neighbours` (back-links from an ungranted restricted project are neither listed nor counted in the total behind "and N more"; control: no viewer counts them all) — fails with the predicate removed; `ai-memory-mcp` `server.rs` `bob_does_not_see_restricted_pages_through_the_related_walk` (an ungranted user's `memory_read_page{include_related}` omits the restricted page; control: no viewer still reaches it) — fails with `memory_read_page` passing `None` instead of `viewer_from_parts` | STRONG |
| 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); `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 |
+| 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 |
| 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 | `ai-memory setup --web` local wizard: only the page this process printed can read the plan or apply a setup | `ai-memory-cli/src/commands/setup_web.rs` `guard` (binds `127.0.0.1` on an OS-picked port; every request needs a `Host` of exactly `127.0.0.1:<port>` or `localhost:<port>` and the one-time 256-bit path secret, compared with `subtle`; a POST also needs this page's `Origin` and the CSRF token the page reads from its own JSON; no CORS grant; `no-store`, `no-referrer`, `DENY` framing, and a CSP with a per-run nonce and no outside sources on the page) and `apply` (agent names must be `--agent` values, de-duplicated, at least one; the child is always `ai-memory setup --yes --agent ...` with the wizard's own flags, never a caller-chosen argument) | `setup_web.rs` `the_page_is_served_only_to_our_host_and_secret` (a rebinding `Host`, a bare `127.0.0.1`, another port, a wrong secret and a missing one refused; controls: `127.0.0.1` and `localhost` with the secret), `apply_refuses_cross_site_and_unknown_input_and_starts_nothing` (no `Origin`, a foreign `Origin`, no CSRF token and a wrong one each refused; `--force`, a shell-like name and an empty choice refused; no child starts), `apply_runs_setup_with_the_picked_agents_and_streams_its_output` (legitimate control: exact argument list); `tests/suite/setup_e2e.rs` `setup_web_serves_the_plan_and_applies_the_picked_agent` (the same through the binary); bite-checked by removing the `Host` check, the `Origin` check, the CSRF check and the agent allowlist one at a time | STRONG |
- | 18 | `uninstall` removes only a service `setup` wrote, including the Windows logon entry | `ai-memory-cli/src/commands/user_service.rs` `planned_removal` / `is_rendered_by_setup` (a unit file whose identity digest still matches) and `planned_removal_for` / `is_setup_run_entry_for` (a `REG_SZ` `HKCU\...\Run\ai-memory` value that is a quoted `ai-memory.exe` ending in `service-host`, with no `&` or `|` chaining, whose `--data-dir`, the first argument after the quoted executable and a whole quoted argument ending at its closing quote, is the data dir being uninstalled, both absolute (`X:\…`, UNC or `\\?\Volume{GUID}\…`; a drive-relative `C:` matches nothing), compared without the verbatim `\\?\` / `\\?\UNC\` prefix, case or trailing separators) before `remove` stops anything or deletes it | `user_service.rs` `uninstall_removes_only_setups_logon_entry` (another install's entry, naming a different `--data-dir`, is left with only the query run; another program's value under the same name is left; absent value is nothing to do; control: this data dir's entry is deleted), `only_the_entry_for_this_data_dir_is_ours` (a temporary data dir does not claim the operator's entry, #1280), `a_volume_guid_data_dir_owns_its_entry` (a volume GUID data dir owns its rendered entry and not another volume's; `uninstall_removes_only_setups_logon_entry` drives both through `remove`), `a_drive_relative_data_dir_is_not_the_drive_root` (`--data-dir "C:"` does not claim `C:\`'s entry; control: the rendered drive-root entry does; `uninstall_removes_only_setups_logon_entry` drives it through `remove` and asserts nothing is stopped or deleted), `a_data_dir_that_runs_past_its_quote_is_not_ours` (`"C:\d"\other` and an escaped closing quote, which Windows reads as other directories, do not claim `C:\d`'s entry; control: the rendered entry does; `uninstall_removes_only_setups_logon_entry` drives the same case through `remove`), `the_data_dir_is_read_after_the_executable` and, on Windows, `a_rendered_entry_belongs_to_its_own_data_dir` (a ` --data-dir ` inside the executable's path neither hides nor fakes the option), `data_dirs_compare_without_prefix_case_or_trailing_separator` (verbatim UNC matches its plain spelling; another share does not), Windows-only `only_a_plain_string_value_is_read` (a `REG_EXPAND_SZ` value under the name is not read as setup's; control: the same data as `REG_SZ` is), `only_setups_entry_shape_counts_as_ours` (unquoted, other program, `serve`, `&`/`|` chaining all refused), and the unit-file identity tests in the same module | STRONG |
- | 19 | Human-session session inspection and owned purging (`serve --enable-session-management`, #1267) | `ai-memory-mcp/src/session_management.rs`: human session and CSRF, completed password change, guarded no-create scope lookup, and an exact-owner preflight before any admission or checkpoint side effect; `ai-memory-store/src/ops.rs` `purge_session_with_owner`: ownership and project write grant rechecked inside the deletion transaction (previews included), cross-project collateral refused unless an Admin purges; `Wiki::purge_owned_session`: wiki mutation lock, admission, pre/post checkpoints, partial-cleanup reporting and replay tombstones | MCP `session_management` suite: `management_refuses_foreign_ids_shared_deletion_and_missing_csrf_with_admin_control` (foreign and shared sessions, anonymous, machine bearer, missing CSRF refused; owner and Admin controls), `management_raw_session_ids_fail_closed_on_wrong_and_partial_scope`, `management_purge_admission_rejection_preserves_rows_and_files`, `management_pagination_reports_its_limit_and_keeps_pages_disjoint`; store `multi_session::owned_session_purge_refuses_foreign_shared_and_wrong_scope_sessions`, `owned_session_purge_refuses_cross_project_cascades_with_admin_control`; wiki `owned_session_purge_authorization_failure_preserves_page_and_index`, `owned_session_purge_cleanup_failure_is_reported_and_tombstoned`. Bite-checked: removing the transaction owner check fails `owned_session_purge_refuses_foreign_shared_and_wrong_scope_sessions`; removing it together with the handler preflight fails `management_refuses_foreign_ids_shared_deletion_and_missing_csrf_with_admin_control` (the two are defence in depth) | STRONG |
- | 20 | Human-session self-service native API keys (`serve --enable-self-service-keys`, #1268) | `ai-memory-mcp/src/self_service_keys.rs`: human session and CSRF (a disabled account's session is refused by `load_session`), completed password change; creation takes the authenticated `UserId`, never a supplied username, trims and bounds `label` (1 to 128 characters) and asks the writer for `create_api_credential_within_limit` (at most 20 active keys per user, counted on the writer thread); revocation answers 404 unless the credential is the caller's own and still active; the token appears only in the one-time create response; issued keys stay `AuthLevel::User` | `self_service_keys_refuse_foreign_ids_csrf_machine_and_pending_password_with_owner_controls` (anonymous, machine bearer, missing CSRF, pending password and foreign-id revoke refused; supplied username ignored; User and Root owner controls), `self_service_keys_refuse_blank_and_overlong_labels` (empty, whitespace, 129 ASCII and 129 multi-byte characters refused with nothing stored; control: 128 characters and a trimmed label accepted), `self_service_keys_cap_active_keys_per_user` (the 21st key refused with 409; controls: another user unaffected, a revoked key frees a slot), `self_service_keys_refuse_a_disabled_user` (list, create and revoke refused; key untouched; control: an enabled user), `self_service_keys_revoking_an_unknown_or_revoked_id_is_not_found` (unknown and already-revoked ids answer 404 without moving the revocation time or touching another user's key). Bite-checked: removing the owner filter fails the foreign-id test; removing the active filter or the key limit fails the revoked-id and cap tests | STRONG |
+ | 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 |
+ | 19 | ai-jail re-exec never promotes a config-file root bearer into harness-readable environment | `ai-memory-cli/src/commands/run.rs` `ensure_jail_does_not_export_config_token` refuses explicit and offered jail re-exec when auth came from config rather than `AI_MEMORY_AUTH_TOKEN`; `jail_resolved_env` forwards only resolved routing (`AI_MEMORY_SERVER_URL`, `AI_MEMORY_BASE_PATH`), while `jail_forwarded_names` forwards an auth variable only when the operator already placed it in the process environment | `run.rs` `jail_refuses_a_config_sourced_token_and_forwards_routing` attempts the file-token exposure and verifies route-only output; `jail_forwarded_names_come_from_the_captured_env_and_resolved_values` is the explicit-environment control | STRONG for credentials loaded by ai-memory. Residual: a token the operator exports is already inherited by an unjailed managed harness and may itself be privileged; use a least-privilege API token |
-| 20 | Claude instruction-import discovery has bounded local-file reads | `ai-memory-cli/src/commands/install_instructions.rs` `imports_within` stops at four hops, deduplicates visited paths, reads at most 256 KiB from one file and 1 MiB across one graph, and skips oversized or non-UTF-8 files. It only decides whether to print a setup note; it never executes imported text | `claude_import_detection_refuses_oversized_and_non_utf8_files` attempts both per-file violations; `claude_import_detection_bounds_the_whole_import_graph` exhausts the graph budget before an indirect target; `agents_md_reached_through_nested_imports_counts_up_to_four_hops` supplies the legitimate nested-import control and cycle termination | STRONG |
-| 21 | Automatic-backfill stale takeover has exact marker ownership | `ai-memory-cli/src/commands/backfill.rs` gives each claim a CSPRNG UUID nonce, serializes claim/refresh/release with a persistent per-checkout advisory-lock inode, passes the nonce to the detached worker through a hidden CLI argument, and compares it before refreshing or deleting the marker. A delayed old worker cannot adopt or remove a replacement owner's marker | `backfill.rs` `stale_takeover_refuses_the_previous_owners_refresh_and_release` attempts both stale-owner mutations, then proves the replacement can refresh and release; burst, stale-age, cleanup and detached-argument tests are the controls | STRONG for same-checkout process races on supported local filesystems; the hook's lock attempt is non-blocking to preserve its latency bound |
++| 20 | `ai-memory setup --web` local wizard: only the page this process printed can read the plan or apply a setup | `ai-memory-cli/src/commands/setup_web.rs` `guard` (binds `127.0.0.1` on an OS-picked port; every request needs a `Host` of exactly `127.0.0.1:<port>` or `localhost:<port>` and the one-time 256-bit path secret, compared with `subtle`; a POST also needs this page's `Origin` and the CSRF token the page reads from its own JSON; no CORS grant; `no-store`, `no-referrer`, `DENY` framing, and a CSP with a per-run nonce and no outside sources on the page) and `apply` (agent names must be `--agent` values, de-duplicated, at least one; the child is always `ai-memory setup --yes --agent ...` with the wizard's own flags, never a caller-chosen argument) | `setup_web.rs` `the_page_is_served_only_to_our_host_and_secret` (a rebinding `Host`, a bare `127.0.0.1`, another port, a wrong secret and a missing one refused; controls: `127.0.0.1` and `localhost` with the secret), `apply_refuses_cross_site_and_unknown_input_and_starts_nothing` (no `Origin`, a foreign `Origin`, no CSRF token and a wrong one each refused; `--force`, a shell-like name and an empty choice refused; no child starts), `apply_runs_setup_with_the_picked_agents_and_streams_its_output` (legitimate control: exact argument list); `tests/suite/setup_e2e.rs` `setup_web_serves_the_plan_and_applies_the_picked_agent` (the same through the binary); bite-checked by removing the `Host` check, the `Origin` check, the CSRF check and the agent allowlist one at a time | STRONG |
++| 21 | `uninstall` removes only a service `setup` wrote, including the Windows logon entry | `ai-memory-cli/src/commands/user_service.rs` `planned_removal` / `is_rendered_by_setup` (a unit file whose identity digest still matches) and `planned_removal_for` / `is_setup_run_entry_for` (a `REG_SZ` `HKCU\...\Run\ai-memory` value that is a quoted `ai-memory.exe` ending in `service-host`, with no `&` or `|` chaining, whose `--data-dir`, the first argument after the quoted executable and a whole quoted argument ending at its closing quote, is the data dir being uninstalled, both absolute (`X:\…`, UNC or `\\?\Volume{GUID}\…`; a drive-relative `C:` matches nothing), compared without the verbatim `\\?\` / `\\?\UNC\` prefix, case or trailing separators) before `remove` stops anything or deletes it | `user_service.rs` `uninstall_removes_only_setups_logon_entry` (another install's entry, naming a different `--data-dir`, is left with only the query run; another program's value under the same name is left; absent value is nothing to do; control: this data dir's entry is deleted), `only_the_entry_for_this_data_dir_is_ours` (a temporary data dir does not claim the operator's entry, #1280), `a_volume_guid_data_dir_owns_its_entry` (a volume GUID data dir owns its rendered entry and not another volume's; `uninstall_removes_only_setups_logon_entry` drives both through `remove`), `a_drive_relative_data_dir_is_not_the_drive_root` (`--data-dir "C:"` does not claim `C:\`'s entry; control: the rendered drive-root entry does; `uninstall_removes_only_setups_logon_entry` drives it through `remove` and asserts nothing is stopped or deleted), `a_data_dir_that_runs_past_its_quote_is_not_ours` (`"C:\d"\other` and an escaped closing quote, which Windows reads as other directories, do not claim `C:\d`'s entry; control: the rendered entry does; `uninstall_removes_only_setups_logon_entry` drives the same case through `remove`), `the_data_dir_is_read_after_the_executable` and, on Windows, `a_rendered_entry_belongs_to_its_own_data_dir` (a ` --data-dir ` inside the executable's path neither hides nor fakes the option), `data_dirs_compare_without_prefix_case_or_trailing_separator` (verbatim UNC matches its plain spelling; another share does not), Windows-only `only_a_plain_string_value_is_read` (a `REG_EXPAND_SZ` value under the name is not read as setup's; control: the same data as `REG_SZ` is), `only_setups_entry_shape_counts_as_ours` (unquoted, other program, `serve`, `&`/`|` chaining all refused), and the unit-file identity tests in the same module | STRONG |
++| 22 | Human-session session inspection and owned purging (`serve --enable-session-management`, #1267) | `ai-memory-mcp/src/session_management.rs`: human session and CSRF, completed password change, guarded no-create scope lookup, and an exact-owner preflight before any admission or checkpoint side effect; `ai-memory-store/src/ops.rs` `purge_session_with_owner`: ownership and project write grant rechecked inside the deletion transaction (previews included), cross-project collateral refused unless an Admin purges; `Wiki::purge_owned_session`: wiki mutation lock, admission, pre/post checkpoints, partial-cleanup reporting and replay tombstones | MCP `session_management` suite: `management_refuses_foreign_ids_shared_deletion_and_missing_csrf_with_admin_control` (foreign and shared sessions, anonymous, machine bearer, missing CSRF refused; owner and Admin controls), `management_raw_session_ids_fail_closed_on_wrong_and_partial_scope`, `management_purge_admission_rejection_preserves_rows_and_files`, `management_pagination_reports_its_limit_and_keeps_pages_disjoint`; store `multi_session::owned_session_purge_refuses_foreign_shared_and_wrong_scope_sessions`, `owned_session_purge_refuses_cross_project_cascades_with_admin_control`; wiki `owned_session_purge_authorization_failure_preserves_page_and_index`, `owned_session_purge_cleanup_failure_is_reported_and_tombstoned`. Bite-checked: removing the transaction owner check fails `owned_session_purge_refuses_foreign_shared_and_wrong_scope_sessions`; removing it together with the handler preflight fails `management_refuses_foreign_ids_shared_deletion_and_missing_csrf_with_admin_control` (the two are defence in depth) | STRONG |
++| 23 | Human-session self-service native API keys (`serve --enable-self-service-keys`, #1268) | `ai-memory-mcp/src/self_service_keys.rs`: human session and CSRF (a disabled account's session is refused by `load_session`), completed password change; creation takes the authenticated `UserId`, never a supplied username, trims and bounds `label` (1 to 128 characters) and asks the writer for `create_api_credential_within_limit` (at most 20 active keys per user, counted on the writer thread); revocation answers 404 unless the credential is the caller's own and still active; the token appears only in the one-time create response; issued keys stay `AuthLevel::User` | `self_service_keys_refuse_foreign_ids_csrf_machine_and_pending_password_with_owner_controls` (anonymous, machine bearer, missing CSRF, pending password and foreign-id revoke refused; supplied username ignored; User and Root owner controls), `self_service_keys_refuse_blank_and_overlong_labels` (empty, whitespace, 129 ASCII and 129 multi-byte characters refused with nothing stored; control: 128 characters and a trimmed label accepted), `self_service_keys_cap_active_keys_per_user` (the 21st key refused with 409; controls: another user unaffected, a revoked key frees a slot), `self_service_keys_refuse_a_disabled_user` (list, create and revoke refused; key untouched; control: an enabled user), `self_service_keys_revoking_an_unknown_or_revoked_id_is_not_found` (unknown and already-revoked ids answer 404 without moving the revocation time or touching another user's key). Bite-checked: removing the owner filter fails the foreign-id test; removing the active filter or the key limit fails the revoked-id and cap tests | STRONG |
## Keeping this current (the standing protocol)