Solution for long term memory for agent coding CLIs and to facilitate handoff between different agent vendors
Rust
Merge main into release/3.1 after PR #1323
AkitaOnRails1665a97c8d3d
diff --cc CHANGELOG.mdindex eb42c490,652b5e2b..9c37dd71--- a/CHANGELOG.md+++ b/CHANGELOG.md@@@ -11,195 -11,23 +11,211 @@@ version in [`docs/changelog/`](docs/cha## [Unreleased]+### Added+- Added opt-in `[consolidation] verbatim_residue = true`, which recovers a+ bounded set of literal error lines, paths, URLs, status codes and versions+ from observations omitted or truncated by the consolidation projection.+ The residue is marked as untrusted, grouped and indented so captured text+ cannot forge prompt structure, and never changes stored page content except+ through the existing structured LLM response. The default remains off and+ preserves existing prompt bytes. The eval harness can compare both states+ with `ab --residue` and `projection --residue`. (#1215)+- Grouped interactive `status` and `doctor` reports into sections with semantic+ colors, consistent margins and terminal-width wrapping, retaining every+ diagnostic field and remedy. Redirected, `NO_COLOR`,+ `TERM=dumb` and JSON reports kept their existing stdout format. (#1313)+- Added an opt-in server-rendered management console for users, sessions, and+ personal MCP API keys, using existing authentication and SQLite storage.+ Required the `management-ui` build feature and runtime switch. (#1231)+- 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)+- Added an opt-in sweep of old hook event ledgers by age. With `[decay]+ ledger_retention_months = N` (env `AI_MEMORY_DECAY__LEDGER_RETENTION_MONTHS`;+ `0`, the default, disables it; a negative value is rejected at startup), the+ forget sweep deletes a project's `log-YYYY-MM.md` once `N` whole UTC calendar+ months have passed after its month ended. A file qualifies only when its name+ is a rotated ledger **and** its content opens like a ledger, so a page that+ merely shares the name is never deleted; that content gate is repeated after+ the blocking admission round-trip. `log.md`, the current month and the+ previous month are never deleted whatever `N` is. The deletion goes through+ the wiki (`Wiki::delete_event_ledger`, under the mutation guard) and never+ writes the database; a dry run reports `ledgers_prunable` and+ `ledger_bytes_prunable` and deletes nothing, and a real run reports+ `ledgers_pruned`, `ledger_bytes_pruned` and `ledger_page_rows_left` (legacy+ page rows it left alone) in the `forget-sweep` / `memory_forget_sweep`+ report. Each removal consults the blocking admission chain on the new+ `delete_event_ledger` op, the same check a page delete runs: a `reject`-policy+ webhook keeps the file, which the sweep counts in `ledgers_undeleted`, keeps+ going and retries on the next run, and non-blocking observers are told only+ after the unlink. The deletion is permanent on disk; the wiki's git history+ keeps the blobs a checkpoint already captured. (#1322)+++### 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 SessionEnd loading every observation of the session into memory, up to+ three times, on the hook path. One production claude-code session held+ 948,136 observations, so ending it deserialized close to a million rows+ (bodies included) per read. The lifecycle-only decision is now one `EXISTS`+ query, and the summary page and the auto-handoff are rendered from bounded+ reads taken in one read transaction: SQL aggregates for the counts and the+ "last of a kind" markers, the 250 first and 250 last rows the raw list+ prints, and early-exit scans for the first or last prompt that passes the+ usual filters; subagent-preamble prompt bodies are read one at a time and+ only until one names the page. The page, the handoff and the lifecycle-only+ decision are unchanged byte for byte (an equivalence test holds them to the+ original row-list code on sessions of every shape). What still grows with+ the session is what the page itself lists: the title of every user prompt.+ The PreCompact and PostCompaction checkpoint page uses the same bounded+ reads. The writer's lifecycle-only re-check and the reader now build their+ query from one shared predicate. (#1323)+- 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-15diff --cc crates/ai-memory-store/src/lib.rsindex ea644201,27d63198..2a0227d5--- a/crates/ai-memory-store/src/lib.rs+++ b/crates/ai-memory-store/src/lib.rs@@@ -88,15 -88,16 +88,16 @@@ pub use reader::DecayCandidate, DecayTombstone, DerivedIndexStatus, EmbeddingTripleCount, FeedbackFinding,GraphVia, HealthDetail, HealthPage, HybridSearch, InboxCount, InboxEntry, ObservationHit,ObservationOrder, ObservationPage, ObservationPageResult, ObservationRecord, OpenSession,- PAGE_VERSIONS_MAX_LIMIT, PageAuthor, PageHit, PageHitWithMeta, PageLinks, PageLinksPreview,- PageMeta, PageSummary, PageVersion, PageVersionBody, PageVersions,+ PAGE_KINDS, PAGE_VERSIONS_MAX_LIMIT, PageAuthor, PageFilter, PageHit, PageHitWithMeta,+ PageLinks, PageLinksPreview, PageMeta, PageSummary, PageVersion, PageVersionBody, PageVersions,ProjectCoordinateCollisionReason, ProjectCoordinateDiagnostic, ProjectCoordinateStatus,ProjectSummary, RELATED_WALK_MAX_DEPTH, RELATED_WALK_MAX_NODES, ReaderPool,- ReindexTargetStatus, RelatedNode, RelatedPage, RrfContributions, ScopeRow, SearchExplain,- SessionConsolidationQueue, SessionConsolidationSummary, SessionDependentRows,- SessionEndDisposition, SessionSummary, SettledPage, StatusCounts, StorageStatus,- StoredEmbedding, StoredPageBody, StreamTimings, VectorQuery, WorkspaceScopeRow,- WorkspaceSummary, f32_vec_to_bytes,+ ReindexTargetStatus, RelatedNode, RelatedPage, RrfContributions, SESSION_LINE_TITLE_CHARS,+ SUBSTANTIVE_OBSERVATION_KIND_SQL, ScopeRow, SearchExplain, SessionConsolidationQueue,+ SessionConsolidationSummary, SessionDependentRows, SessionEndDisposition, SessionKindSummary,+ SessionLine, SessionObservationSnapshot, SessionSummary, SessionToolTitles, SettledPage,+ StatusCounts, StorageStatus, StoredEmbedding, StoredPageBody, StreamTimings, VectorQuery,+ WorkspaceScopeRow, WorkspaceSummary, f32_vec_to_bytes,};pub use retrieval_tuning::{RetrievalTuning, is_session_recall_query};pub use scope::{diff --cc docs/security-boundaries.mdindex 9ba0d09b,f944d8b1..aeed01bb--- a/docs/security-boundaries.md+++ b/docs/security-boundaries.md@@@ -29,7 -29,8 +29,8 @@@ means the boundary is not built yet| 1e | The shared profile scopes are read-open, write-gated like `_global` | `ai-memory-store/src/project_authz.rs` `is_reserved_global` (a workspace `_profile` joins `default/_global`: on a server that distinguishes operators a write needs root or a `write` grant, creating it grants nothing); `ops.rs` `initial_access_mode` keeps `_profile` open | store `integration::profile` `shared_profiles_are_write_gated_for_database_users` (ungranted user refused for both shares; root and a write grant admitted; reads open); `server.rs` `a_workspace_profile_is_write_gated_and_read_open`; both fail with `_profile` dropped from the gate | STRONG || 1f | Event capture never lands in a profile project, and the sweep keeps them | `ai-memory-hooks/src/router.rs` project resolution refuses `ai_memory_core::profile::is_reserved_scope_project` (`_global`, `_profile`, `_profile.*`) from a directory or a marker override, falling back to the server default; `ops.rs` `sweep_hollow_projects` exempts `_profile` and `_profile.%` | `router.rs` `capture_is_never_attributed_to_a_profile_project` (override and directory spellings refused; ordinary `my_profile` control resolves), fails with the check narrowed to `_global`; store `integration::profile` `the_hollow_project_sweep_keeps_empty_profile_projects` | STRONG || 1g | The profile reaches only the sessions it is meant for: off by default on a multi-user server, suppressed by `[profile] consume = false`, and an opt-out is sticky | `ai_memory_core::profile::ProfileSettings::effective_share` (`enabled = auto` is off once operators are distinguished); `router.rs` `persist_profile_flags` (flags are tri-state: an absent forwarded value keeps the stored one, so a client that sends nothing never undoes an opt-out; every front door sends explicit `0`/`1` once a marker resolved) and `render_requested_profile_digest` (a team profile is headed "team defaults"); `server.rs` `memory_query` drops `profile/` hits for a project whose stored `profile_consume` is off; `admin_profile.rs` `handle_apply` (`ai-memory profile apply`) returns no lines for such a project and sits behind the root-only `/admin/*` gate on a multi-user server | `router.rs` `a_multi_user_server_has_no_profile_digest_by_default`, `profile_digest_honours_consume_once_per_session_and_the_server_switch`, `session_start_records_the_marker_profile_flags` (a session start with no flags after an opt-out keeps the project out of the harvest and the digest; fails when an absent flag defaults to on); `server.rs` `the_single_user_profile_lives_in_global_and_honours_consume` (fails with the consume filter removed); `admin_profile_routes.rs` `apply_lists_the_lines_for_a_project_and_honours_consume`, `apply_is_root_only_on_a_multi_user_server` (database user refused, root control admitted); core `profile::tests::effective_share_matrix` | STRONG |-| 1h | The profile learns only from what it may: the user's own prompts and curated pages, from contributing projects, never another operator's words in a private profile and never a restricted project in a shared one; stored text stays data | `ai-memory-store/src/profile.rs` `profile_prompts_since` (only `user-prompt` observations), `auto_improve_decided_by` (the decider agent a page's `auto_improve_proposal_id` resolves to), `profile_harvest_projects` / `profile_candidates` (`profile_contribute = 0` excluded, including candidates recorded before the opt-out); `ai-memory-store/src/ops.rs` `move_session` (a moved session's `session:<id>` prompt candidates are re-stamped into the target project in the same transaction, so they answer to its contribute flag and access mode, #1265); `ai-memory-consolidate/src/profile.rs` `user_written` (a harness turn or Codex's injected instructions stored as a prompt is skipped whole, and ai-memory's routing and untrusted-history blocks, fenced by markers on their own lines, are cut out before any sentence is read), the auto-approved-proposal skip in `harvest_project` (a page the auto-improve scheduler auto-approved is model output nobody reviewed and never becomes a candidate; a human-approved page, or one whose proposal id has no row, stays curated, #1211), `convergence_targets` (a `user` target keeps only candidates whose `contributor` is that operator, from projects the per-project choke point lets them read; a `global`/`workspace` target on an operator-distinguishing server drops restricted projects), `min_contributors` / `converge` (a team profile admits a statement only on evidence from at least two distinct operators, so one operator cannot plant a default in everyone's session start) (never rewrites a page without its `generated_by` stamp or whose body changed; `profile_entry_ledger` keeps a forgotten entry out), `classify_batch` / `merge_entry` (sanitized, JSON-encoded input; the evidence quote is always the user's sentence) | consolidate `integration::profile_harvest` `tool_output_is_never_a_candidate`, `an_opted_out_project_is_never_harvested`, `a_private_profile_never_harvests_another_operator`, `a_team_profile_never_harvests_a_restricted_project`, `a_team_profile_needs_more_than_one_operator` (one operator in two open projects not admitted; a second operator admits it; fails with the threshold at one), `a_personal_profile_admits_one_operators_habit` (control), `a_hand_edited_entry_is_never_clobbered`, `a_forgotten_entry_is_not_recreated_until_said_again`, `injected_instructions_stay_data`, `injected_instructions_and_ai_memory_blocks_are_never_candidates`, `page_metadata_fields_are_never_candidates`, `auto_approved_auto_improve_pages_are_never_candidates` (an auto-approved page refused; human-approved and hand-written controls admitted; fails with the decider check removed), consolidate `profile::tests::a_stored_page_metadata_field_is_not_a_waiting_habit` (each with a legitimate control; each fails with its guard removed); mcp `integration::admin_profile_routes` `review_and_rebuild_are_root_only_on_a_multi_user_server`; store `integration::session_move` `a_moved_sessions_profile_candidate_follows_the_target_projects_governance` (a session moved into an opted-out project stops counting and one moved into a restricted project is marked restricted; an open-target control still counts, from the target; fails with the `move_session` re-stamp removed) | STRONG |+| 1h | The profile learns only from what it may: the user's own prompts and curated pages, from contributing projects, never another operator's words in a private profile and never a restricted project in a shared one; stored text stays data | `ai-memory-store/src/profile.rs` `profile_prompts_since` (only `user-prompt` observations), `auto_improve_decided_by` (the decider agent a page's `auto_improve_proposal_id` resolves to), `profile_harvest_projects` / `profile_candidates` (`profile_contribute = 0` excluded, including candidates recorded before the opt-out); `ai-memory-store/src/ops.rs` `move_session` (a moved session's `session:<id>` prompt candidates are re-stamped into the target project in the same transaction, so they answer to its contribute flag and access mode, #1265); `ai-memory-consolidate/src/profile.rs` `user_written` (shared with the verbatim-residue caller in row 25: a harness turn or Codex's injected instructions stored as a prompt is skipped whole, and ai-memory's routing and untrusted-history blocks, fenced by markers on their own lines, are cut out before any sentence is read), the auto-approved-proposal skip in `harvest_project` (a page the auto-improve scheduler auto-approved is model output nobody reviewed and never becomes a candidate; a human-approved page, or one whose proposal id has no row, stays curated, #1211), `convergence_targets` (a `user` target keeps only candidates whose `contributor` is that operator, from projects the per-project choke point lets them read; a `global`/`workspace` target on an operator-distinguishing server drops restricted projects), `min_contributors` / `converge` (a team profile admits a statement only on evidence from at least two distinct operators, so one operator cannot plant a default in everyone's session start) (never rewrites a page without its `generated_by` stamp or whose body changed; `profile_entry_ledger` keeps a forgotten entry out), `classify_batch` / `merge_entry` (sanitized, JSON-encoded input; the evidence quote is always the user's sentence) | consolidate `integration::profile_harvest` `tool_output_is_never_a_candidate`, `an_opted_out_project_is_never_harvested`, `a_private_profile_never_harvests_another_operator`, `a_team_profile_never_harvests_a_restricted_project`, `a_team_profile_needs_more_than_one_operator` (one operator in two open projects not admitted; a second operator admits it; fails with the threshold at one), `a_personal_profile_admits_one_operators_habit` (control), `a_hand_edited_entry_is_never_clobbered`, `a_forgotten_entry_is_not_recreated_until_said_again`, `injected_instructions_stay_data`, `injected_instructions_and_ai_memory_blocks_are_never_candidates`, `page_metadata_fields_are_never_candidates`, `auto_approved_auto_improve_pages_are_never_candidates` (an auto-approved page refused; human-approved and hand-written controls admitted; fails with the decider check removed), consolidate `profile::tests::a_stored_page_metadata_field_is_not_a_waiting_habit` (each with a legitimate control; each fails with its guard removed); mcp `integration::admin_profile_routes` `review_and_rebuild_are_root_only_on_a_multi_user_server`; store `integration::session_move` `a_moved_sessions_profile_candidate_follows_the_target_projects_governance` (a session moved into an opted-out project stops counting and one moved into a restricted project is marked restricted; an open-target control still counts, from the target; fails with the `move_session` re-stamp removed); residue control in row 25 | STRONG |+ | 1i | SessionEnd's bounded digest cannot read a foreign session by raw id | `ai-memory-store/src/reader.rs` `session_has_substantive_observation` joins the session row to the caller's `(workspace_id, project_id)`; `read_session_observations` validates that same tuple inside the read transaction before exposing its bounded snapshot, returning the same `SessionCollision` refusal for foreign and missing ids; `ai-memory-hooks/src/router.rs` supplies only the scope pinned by hook admission | `multi_session.rs` `session_end_readers_refuse_foreign_session_ids` (sibling-project and cross-workspace tuples cannot learn the substantive bit or open the snapshot; a missing id gets the same refusal; the owning tuple reads the one-row summary as the legitimate control). Removing either scope predicate fails its corresponding assertion | STRONG || 2 | Workspace isolation | same as #1; same-named project → distinct ids per workspace | `scope.rs` cross-workspace resolution rows; `multi_scope` dedup/validate; `ai-memory-web` `history_replay.rs` (another workspace's page path, version id and session id answer 404, same tests and bites as row 1) | STRONG || 2b | Managed-workstream discovery stays checkout-local, including pagination | `ai-memory-workstream/src/repository.rs` `inspect_repository_fingerprints` shares the launch identity derivation without checkpoint scans; `ai-memory-cli/src/commands/resume.rs` `candidates_for_checkout` queries only the cwd, never registry links; the explicit `--all` walk (`candidates_across_checkouts`) lists each linked checkout through its own fingerprint-scoped request and applies `--workspace` before any request; `ai-memory-hooks/src/workstream.rs` `list_recent_workstreams` resolves an authorized explicit scope on every page; `ai-memory-store/src/workstream.rs` `list_recent` applies workspace/project/repository/worktree predicates before `LIMIT`/`OFFSET` | `resume.rs` `resume_lists_all_current_checkout_rows_not_registered_foreign_checkouts` (same scope/remote foreign checkout refused, 125 local rows visible), `empty_current_checkout_does_not_fall_back_to_the_registry`, `resume_all_walks_every_linked_checkout_and_honours_the_workspace_filter` (a foreign workspace filter sends no request; the default picker still ignores the registry); `workstream.rs` `recent_workstream_pages_reach_older_rows_without_crossing_checkout_or_scope` (foreign repo, worktree, project and workspace excluded on every page; 105 legitimate rows reach the client, huge offsets return nothing); store `recent_workstreams_are_checkout_local_and_include_linked_harnesses` (page two keeps native harness links); `repository.rs` `reports_origin_push_url_and_linked_worktree` verifies lightweight/full fingerprint parity and distinct worktree keys; CLI `resume_yolo_displays_picker_without_scanning_git_status` verifies listing skips status scans | STRONG || 3 | Multi-user auth ladder | `ai-memory-core/src/actor.rs` `AuthLevel::authorize`; `ai-memory-mcp/src/auth.rs` middleware; `admin.rs` `require_root_for_multiuser_admin` / `require_root`; `identity.rs` authorizes `NormalRead` behind the same machine bearer middleware as MCP; `serve.rs` mounts API-only and web+API protected routers behind `require_dual_auth` | `admin.rs` `multiuser_admin_routes_reject_db_user_tier` / `…reject_anonymous` / `create_user_as_user_tier_returns_403`; `auth.rs` unknown-bearer 401; `actor.rs` `skip_admission_chain_rejects_db_users`; `identity.rs` `identity_real_auth_isolates_users_root_and_revoked_keys`, `identity_anonymous_ignores_forged_headers_and_proxy_qualifies_oidc` (distinct users and root, invalid/revoked keys, forged headers, anonymous control); `serve.rs` `api_only_mode_keeps_data_authenticated_and_web_absent` (anonymous API read refused, authenticated control admitted, browser route absent; #986) | STRONG |