Skip to content

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

Rust

Merge main into release/3.3 for v3.3.0

AkitaOnRails29b69e742290
diff --cc CHANGELOG.md
index 5b6effaf,1da27882..fed4851f
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@@ -11,417 -11,41 +11,450 @@@ version in [`docs/changelog/`](docs/cha
## [Unreleased]
+### Added
+
+- Added `[ingest] record_tool_names` (`AI_MEMORY_INGEST__RECORD_TOOL_NAMES`),
+ off by default. When it is on, each tool call keeps its own name, so a
+ Claude Code shell call is stored as `tool non-file: Bash` instead of
+ `tool non-file`. A `Skill` call also keeps the skill it ran, and an `Agent`
+ call keeps its subagent type. Session pages count calls by name and
+ handoffs list them by name. Only short identifiers are kept, never a tool's
+ arguments, and a call that a capture policy reduced to metadata stays
+ unnamed (#1851).
+
+- `global_scope_hits` now include their workspace, project, and global scope,
+ and `memory_read_page` accepts `scope: "global"`. Supplemental global search
+ results can therefore be read directly without risking a same-path lookup in
+ the caller's active project (#1802).
+
+- Added `--project-id` to managed launches and checkout-local discovery to
+ recover populated legacy name collisions without moving or merging history.
+ An interactive launch offers authorized project choices and remembers the
+ selection for that server and checkout. Resumes reuse the binding, and
+ ID-selected runs keep startup context and hook capture in the selected scope
+ after checking current access, run ownership and native session identity.
+ Existing name selectors and legacy runs retain their behavior (#1833).
+
+- Added `ai-memory run --no-exit-prompt`, `[run] exit_prompt = false`, and
+ `AI_MEMORY_RUN_EXIT_PROMPT=false` to skip the switch/rerun menu after a
+ successful interactive session. The menu remains enabled by default (#1776).
+
+- `ai-memory merge-project --workspace <w> --from <source> --into <target>`
+ losslessly joins two project identities inside one workspace. Its default is
+ an exact dry run; `--confirm` re-stamps page history, sessions, observations,
+ handoffs, embeddings and managed workstreams in one writer transaction, then
+ removes the source project. Same-path pages get a new target version that
+ appends the source body behind an `ai-memory:merged-from` marker while both
+ prior histories remain restorable. The target frontmatter wins, a one-sided
+ expiry is removed, and the combined page is flagged stale for consolidation.
+ `restore-page --page-id <uuid>` restores either retained history even after
+ the source identity is removed. Open sessions and live managed runs refuse
+ the merge (#1645).
+
+- `audit-contamination` now reports projects in one workspace whose names
+ collide after Unicode compatibility decomposition, case folding, and
+ removal of non-spacing marks. Findings distinguish case from accent
+ differences and include page/session counts plus last activity (#1645).
+
+- Cross-project messages can carry an optional epistemic `nature` (`unknown`,
+ `measured`, `reported`, or `inferred`) and bounded supporting `evidence`.
+ The server refuses a `measured` send without non-empty evidence; existing
+ messages and callers remain `unknown` by default (#1428).
+
+- Added `memory_patch_page` for atomic, heading-anchored edits to an existing
+ Markdown page without re-emitting its body or metadata. It requires the
+ page's current `page_id`; section replacement additionally requires the
+ bounded SHA-256 token returned by `memory_read_page`. Missing, duplicate or
+ fenced-code headings, stale tokens, conflicting edits, failed admission and
+ concurrent writes leave the page unchanged. The typed TypeScript client
+ exposes the same contract as `pages.patch` (#1697).
+
+- Added an offline `ai-memory-eval abstention` benchmark with versioned
+ clean-room answerable, hard-negative, conflicting, partial and
+ missing-channel fixtures; raw lexical/score/density/belief signals;
+ FSR/FAR/coverage threshold sweeps with undefined denominators preserved;
+ optional reuse of pinned LongMemEval `*_abs` cases; and optional structured
+ LLM answerability through the existing QA provider path. Conflicting and
+ partial cases remain separate from binary ground truth, no threshold is
+ presented as calibrated, and production runtime behavior is unchanged.
+ The retrieval evaluator now also parses production's structured
+ `{text,citations}` answer shape instead of a stale string (#1717).
+
+- Added `[briefing] inject_on_subagent_start` to `.ai-memory.toml`. A project
+ that sets it hands each `claude-code` subagent the project brief when the
+ subagent starts: the same pinned, `_rules/` and `_slots/` brief that
+ `inject_on_session_start` adds at session start, kept within `max_chars` and
+ within the 10,000-character limit of that agent's hook context. The hook
+ reads it from a new read-only `GET /brief`, which resolves and authorizes the
+ project as `/handoff` does but never reads or claims a handoff, so a subagent
+ cannot take its parent session's baton. A server without the route answers
+ 404 and the subagent starts as before. The native hook and the
+ `hooks/claude-code` shell and PowerShell scripts deliver it, and every marker
+ parser treats the key as a settings boundary. It is off by default (#1715).
+
+- Added an optional `[query_answer] max_context_tokens` admission budget for
+ answer synthesis. It preserves retrieval hits, reports omitted or clipped
+ evidence, prioritizes known newer corrections, prefers whole snippets and
+ clips only complete trailing sentences or statements into leftover space. It
+ skips the model when no meaningful evidence fits. The default
+ remains disabled (#1684).
+
+- `GET /admin/status` and `ai-memory status --json` now carry a
+ `consolidation` block: the queue counts plus up to 20 `failed_sessions`
+ (`session_id`, `attempts`, `failed_at_us`, scrubbed `last_error`), newest
+ first. A consolidation run that gives up after its retries now has a
+ machine-readable record with the session ids needed to re-run it, instead of
+ only a journal line and the `/health` panel's count — which also resets with
+ the process. The web health panel's own view stays counts-only, and an older
+ server's status shape is unchanged (#1692).
+
+- Added the bundled `coding-v1` retrieval-evaluation corpus for offline checks
+ of decision rationale, resolved-error causes, correction evidence, and late
+ session details. It reuses the existing scorer and A/B reports; it measures
+ evidence retrieval, not semantic answer correctness or handoff behavior (#1686).
+
+- `[auto_improve.eval] builtin = "structure"` runs the eval gate's structural
+ checks in process, so the gate needs no interpreter, no scorer script inside
+ the container and no timeout to hit. It checks an H1, an upper-case
+ `TODO`/`TBD` placeholder (a hard failure), a `##` section and a list of steps
+ for `procedures/`, and text beyond the heading within 2,400 characters for
+ `_rules/` — never a section name or a wording, so the wiki's language does
+ not matter. `eval_results` records `checker_name = "builtin:structure"`.
+ `builtin` and `command` are mutually exclusive; `command` is unchanged for
+ project-specific scorers (#1638).
+
+- `ai-memory llm-test --server` probes the server's own configured provider
+ instead of building one from the caller's environment, through a new
+ root-only `POST /admin/llm-test`. The retry hint that `status` and the health
+ panel print now names it: with the server in a container or on another host
+ its keys exist only there, so the old client-side hint failed with "no API
+ key" or a provider `400` while the server was healthy. The probe runs one
+ fixed short prompt, reports provider, model, latency and the error class, and
+ scrubs the provider's message before printing it (#1639).
+
+- Added `[handoff] deliver_on_session_start = false` to `.ai-memory.toml`. A
+ project that sets it no longer gets its handoff, or the continuity notice, at
+ session start; the handoff is still created when the session ends and stays
+ open for `memory_handoff_accept`. The native hook, the shell and PowerShell
+ scripts and the generated TypeScript integrations send `handoff=0` only when
+ the value is explicitly falsy (#1621).
+
+- Added first-party Qoder CLI/IDE lifecycle and MCP support. Both installers
+ merge into `~/.qoder/settings.json`: `install-mcp --client qoder` writes a
+ sessionless stdio bridge, while `install-hooks --agent qoder` registers the
+ eight documented memory-bearing events as native commands. Session start
+ delivers a pending handoff through `hookSpecificOutput.additionalContext`,
+ prompt/tool capture uses Qoder's Claude-shaped payloads, and a missing hook
+ `cwd` falls back only to `QODER_PROJECT_DIR`. Setup detects `~/.qoder`,
+ uninstall removes both entries, and agent backups include its settings and
+ shared AGENTS-compatible skills/instructions (#1611).
+
+- Profile writes now return `digest_warning` when the selected summary,
+ abstract, or prose statement exceeds the 240-byte session-start digest
+ limit. The write still succeeds, but its author can shorten the summary
+ instead of discovering the truncation only in a later session (#1609).
+
+- Added project routing for the named profiles of a multiplexing Hermes
+ gateway. The gateway exports only the default profile's `terminal.cwd`, so
+ every other profile's events used to fall back to the gateway's own working
+ directory and all its bots landed in one project. A gateway event of a named
+ profile now routes by an `.ai-memory.toml` placed in that profile's Hermes
+ home (`~/.hermes/profiles/<name>`, or under the gateway's `HERMES_HOME`), and
+ that marker's capture exclusions and server profile apply. A profile without
+ such a marker keeps the old behavior. The profile name is checked against
+ Hermes' profile-id pattern before it is used as a path (#1597).
+
+- Added Hermes Agent hook consent to `ai-memory doctor`. Hermes runs a shell
+ hook only when that exact command is approved in the home's
+ `shell-hooks-allowlist.json`, and each profile under
+ `~/.hermes/profiles/<name>` keeps its own allowlist. A profile with the
+ ai-memory hooks in `config.yaml` but no approvals captured nothing, and its
+ gateway only logged `not allowlisted — skipped` for each event. `doctor` now
+ reads the root home and every profile, reports which ai-memory hook events
+ each one wires, and warns about every profile whose events are not
+ allowlisted (unless `hooks_auto_accept` is on), with the `hermes -p <name>
+ --accept-hooks` command that approves them. The JSON output gains a `hermes`
+ array. It never writes either file and never prints the hook commands,
+ which can embed a bearer token (#1598).
+
+- Added `AI_MEMORY_RERANK_TIMEOUT_SECS` (`rerank_timeout_secs` in
+ `config.toml`) to set the `memory_query` reranker budget, which was fixed at
+ 20 seconds. The default stays 20 and zero is rejected at startup. A hosted
+ provider behind an LLM fallback chain can spend the whole fixed budget on one
+ slow 503 before the next candidate answers, and every such query then keeps
+ its pre-rerank order. ([#1614](https://github.com/akitaonrails/ai-memory/issues/1614))
+
+- `ai-memory status` now shows the client's version next to the server's: a
+ `ai-memory X (client)` line under `ai-memory X (server)`, and `version` in
+ the JSON `client` object. In a split install (native client and hooks, the
+ server in a container or on another host) the two drift apart when only one
+ side is upgraded, and nothing showed it. When they differ in major version,
+ the text report adds a warning to upgrade the older side (#1644).
+
+- Added editing for queued messages in the web inbox. Edit takes a message that
+ is still waiting out of the queue, so no agent can collect it, and opens an
+ inline editor. Saving puts the new text back at the message's original place
+ in the queue, after the usual sanitizer, size caps and `message_send`
+ admission. Discarding returns it unchanged. A held message shows as Editing,
+ with a count above the list and a way back into the editor. Editing needs
+ write access to the mailbox project and to the project the message came from,
+ and a message an agent already collected cannot be edited. Held messages use a
+ new `editing` state (migration V95) that no claim path selects (#1832).
+
+- Added server-side response investigation to the project dashboard. Responses
+ can be filtered by UTC period, exact model, harness, session, turn and tool,
+ with complete pagination, filtered token totals and bounded native turn and
+ tool provenance. The context lives in extra `token_calls` columns and a
+ `token_call_tools` table (migration V94). A response from an older hook keeps
+ its provenance unknown instead of guessed. Filters apply after project
+ authorization and the session-owner check and before counting, ranking and
+ pagination (#1830).
+
+- Added version-specific knowledge evidence to the page and project views:
+ readable source links, declared contradictions, expiration context and an
+ on-page recall recomputation that reuses the original search filters (#1830).
+
+- Added caller-aware installation states and next steps to feature guides and
+ the authenticated `/api/v1/docs/features/status` reference. They
+ separate effective settings from client facts the server cannot know, and
+ administrative settings are masked for callers without admin rights (#1830).
+
+- Replaced the static Inbox label with live, access-filtered pending counts and
+ project links throughout the web navigation. Counts are grouped by workspace
+ and project, hide restricted projects, never consume mail, and link to the
+ pending-only mailbox of the project that has mail. Received inboxes open on
+ pending messages, with older queued requests behind collected history, and the
+ composer shows the current project explicitly (#1830).
+
+- Added bundled product documentation to the web UI and the API. The guides and
+ release notes are compiled into the binary and served at `/web/docs`,
+ `/web/docs/changelog` and `/web/docs/{id}` (a `.md` suffix returns the
+ Markdown). They include searchable feature activation guides, per-release
+ changelogs, and authenticated `/api/v1/docs` JSON and Markdown references for
+ agents. No network access or LLM is needed, and the pages describe shipped
+ capabilities without exposing the running server's configuration or
+ credentials. The source-built Docker image now copies `CHANGELOG.md` for this
+ (#1829).
+
+- Organized project pages into accessible tabs showing one section at a time: Overview,
+ Agents, Token usage, Sessions and Knowledge. The selected tab is kept in the
+ URL (`?tab=agents`), which keeps reload, shared links and browser history in
+ sync, and the tabs support Left, Right, Home and End. Existing
+ `#agents`-style section bookmarks still open the matching tab (#1829).
+
+- Updated the browser inbox composer to default To project to the source
+ project and list only harnesses with captured sessions in the destination
+ workspace and project. It resets a stale recipient when a project changes,
+ and it disables sending, with an explanation, for a project that has no
+ registered agent (#1829).
+
+- Redesigned the responsive web dashboard. It has persistent workspace
+ navigation, searchable project cards, per-agent consumption and coverage, and
+ session drilldowns that show the token totals recorded for each agent (#1828).
+
+- Added a browser inbox at `/web/inbox`. It lists received and sent mail
+ without consuming it. A caller with write access to both the source and the
+ destination project can also queue a message for a registered harness of that
+ project. The text goes through the configured sanitizer and admission before
+ the single writer, and the browser never claims mail or starts an agent.
+ Messages can now be addressed to one harness (`to_agent`, migration V93).
+ `memory_message_pop` and `ai-memory message pop` take an optional `agent`,
+ and only that harness can claim the message, even by id. Existing shared mail
+ (`to_agent = NULL`) behaves as before. A claim from a session-aware client
+ whose routing metadata arrives before its session start was persisted is no
+ longer refused. A browser session opened with the legacy read-only login can
+ send with an explicit write token supplied for that one request and cleared
+ right after, with no browser persistence (#1828).
+
+- Added live, deduplicated response token accounting for Claude Code and Codex.
+ Updated native hooks to send measured response usage on `post-tool-use`,
+ `stop`, `pre-compact` and `session-end`, keeping open-session totals current
+ rather than waiting for session end. Each response is stored once by its
+ native identity in a new `token_calls` ledger (V92). A partial or replayed
+ delivery raises the stored counters column by column and never adds the same
+ response twice. Live extraction reads a bounded 4 MiB transcript tail and
+ reports at most 256 responses per event. Fresh input excludes cache reads, so
+ Codex, whose reports included cached input, is normalized once during the
+ upgrade. The project page has a Token usage panel listing the fifty largest
+ captured responses. It flags contexts of at least 100,000 tokens, outputs of
+ at least 20,000 tokens and responses above three times the project average.
+ Only counters, response identities and model names are kept, and project
+ authorization and session-owner filters apply before ranking or aggregation
+ (#1811).
+
+- Added Light, Dark and System theme controls to the web UI. The choice is
+ stored in the browser and System follows the operating system. Tailwind's
+ dark variant now uses the `dark` class instead of the media query, so a
+ manual choice overrides the system setting (#1811).
+
+- Added a memory dashboard to the read-only web home, using sanitized data:
+ projects, sessions, sanitized capture events, compiled pages, open-session
+ continuity signals and last activity. Project cards separate captured work
+ from compiled pages, so an active hook no longer looks empty just because
+ its sessions have not ended (#1803).
+
+- Added dashboard hook-health counters for accepted, policy-dropped,
+ capacity-shed and rate-limited events. They count events since the process
+ started, and prompt, command, path and payload data is neither persisted nor
+ rendered (#1803).
+
+- Added agent CLI attribution to the project overview to show which harnesses
+ produced a project's memory. The stats card has an "Agents" badge row with session counts per
+ harness, and each Recent Activity entry shows the harness whose session last
+ contributed evidence to that page version. Both are best effort: a page or
+ project with no session evidence shows no badge (#1803).
+
+- Added per-session token accounting. At `session-end` the native hook (Claude Code
+ and Codex) reads the harness's own transcript and reports cumulative input,
+ output, cache-write and cache-read totals. It scans Claude Code's JSONL in
+ full and reads only the tail of Codex's rollout file, since both can reach
+ hundreds of MB. The server stores the totals with a `MAX(existing, reported)`
+ upsert, so a replayed or out-of-order delivery never lowers a total. The
+ project overview page shows a "Tokens" total in the stats card and a Sessions
+ table (agent, start, duration, events, tokens) with the 20 most recent
+ sessions. A session whose harness never reported usage, an unsupported
+ harness or an older client shows no number, never a zero (#1803).
+
+- Added recovery of usage and closure for sessions missing a graceful
+ `session-end`, which previously stayed open without tokens. This usually
+ happens when a paid quota runs out mid-task and the operator switches agents. When a new session
+ starts in the same scope and finds one quiet for at least 15 minutes, the
+ client looks for the old session's own transcript (Claude Code and Codex),
+ reports its usage and closes it with a normal synthetic `session-end`. That
+ is safe if the old session turns out to be live, because a later real
+ `session-end` with more work runs the full end path again. A second, more
+ conservative scheduled sweep closes sessions nobody continues anywhere,
+ after 48 hours without activity in any scope, so `open_session_count` stops
+ growing. It attaches no usage and starts no consolidation, because the
+ server cannot read a client's transcript outside a live hook request (#1803).
+
+- Added optional `max_chars` to `memory_read_page` (default 12000,
+ minimum 500, maximum 64000). It caps the returned body with the same visible
+ truncation marker as `memory_read_session_observations`. The response always
+ includes `truncated` and `total_chars`, which report whether the body was cut
+ and its full size (#1827).
+
+### Changed
+
+- `memory_lint` now reports embedding-band pairs as
+ `similarity_candidate` instead of `contradiction`, and no longer infers that
+ a newer page supersedes an older one from timestamps alone. Explicit
+ `contradicts` edges remain `contradiction` findings (#1685).
+
+- `move-project` now refuses the **copy+purge merge** — the path taken when the
+ destination workspace already holds a project of the same name — unless
+ `--allow-lossy-merge` is passed as well as `--confirm`. That path keeps only
+ the source's latest pages and deletes the project with its sessions,
+ observations, handoffs and older page versions, which `--confirm` written for
+ "move this project" did not say; the refusal answers `409` with the counts it
+ would discard. A true-move (fresh destination, everything preserved) is
+ unchanged, and `merge-workspace`, whose command already says merge, keeps
+ working without the extra flag (#1713).
+
+- `memory_install_self_routing(compact: true)` and `ai-memory
+ install-instructions --compact` now return a block that is actually compact:
+ 2.1 KB instead of 5.9 KB, close to the 7.9 KB full block it was supposed to
+ replace. It keeps the rules a session needs without reading anything else
+ (scope selection for session-aware and static clients, managed-run resume,
+ capture, the untrusted-memory trust rule, and where rules belong) and points
+ at the installed `ai-memory-*` Agent Skills for the rest, which it already
+ required to be installed (#1672).
+
+- When the native session linked to a workstream is missing from its store,
+ an interactive `ai-memory run <harness>` now also names the newest session
+ this checkout still holds for that harness and the native selector that
+ resumes it, such as `resume <id>` for Codex. The launch still starts fresh
+ as before; running the same command again with that selector right after
+ the harness name links that session instead (#1654).
+
+- Managed-workstream startup packets now render completed tool calls and
+ results as compact provenance stubs instead of spending the 30,000-character
+ resume budget on raw command output or generated file content. Conversation,
+ checkpoints, compactions, and annotations remain inline; the complete
+ sanitized tool evidence stays searchable in the ledger (#1607).
+
+- The LLM fallback chain now logs its own events. A transient candidate
+ failure logs a warning with that candidate's provider, model, chain
+ position, error class, HTTP status and cooldown, and an info line records
+ each change of the answering candidate. Before, the chain logged nothing,
+ and callers such as the reranker named only the first candidate, so a log
+ could blame the primary for a timeout another candidate caused. Response
+ bodies are never logged (#1628).
+
+- Reduced the default output of `memory_read_session_observations`: `limit`
+ from 50 to 20 and `body_max_chars` from 4000 to 1000. Callers can still raise
+ them to the unchanged ceilings of 200 and 16384. The smaller response reduces
+ token costs for routine "what did this session do" lookups. Updated the
+ retrieval skill with an `order="desc"` recipe using a narrow `kinds` filter
+ and small `limit` and `body_max_chars` values to avoid reading the whole
+ session (#1827).
+
### Fixed
+- Fixed live response capture after transcript gaps. Bounded batches now resume
+ from durable enqueue checkpoints, including across hook processes and
+ transcript read windows (#1830).
+
+- Fixed response search, signal filtering and recent ordering so they query all
+ authorized calls before pagination. Response pages are independent, and
+ session detail pages refresh usage live (#1830).
+
+- Updated scoped session reads to treat substantive work after an old end as a
+ resumed session, matching the activity feed while preserving persisted
+ lifecycle watermarks. Completed-only listings exclude those resumed sessions (#1830).
+
+- Moved token model label sanitization before truncation to prevent the size
+ limit from exposing a prefix of private text (#1830).
+
+- Updated release selection on the changelog page to load notes immediately
+ and keep the URL, outline and Markdown reference in sync. The form still submits
+ without JavaScript (#1830).
+
+- Added a read-only recovery snapshot at agent startup when the previous
+ substantive session in the project ended without a `SessionEnd` (quota
+ exhaustion, a killed process, a machine restart). The snapshot is built on
+ demand from at most 64 sanitized observations and capped at 6,000
+ characters, so no rolling copy of the transcript exists. It is scoped to the
+ project and owner, leaves out the receiving session, keeps the
+ untrusted-memory boundary, and never closes or claims the source, which may
+ be a legitimate parallel agent. It skips work a handoff already covers and
+ never mixes another live session's transcript into a delivered handoff.
+ Normal single-use handoffs and managed workstream packets are unchanged
+ (#1803).
+
+ - Serialized mutating wikisync runs per destination across their full
+ read/plan/write lifecycle, so overlapping exports no longer race on the
+ shared state temporary file or apply plans from the same baseline (#1847).
+
+ - Bounded the wiki append-versus-commit concurrency regression so filesystem
+ scheduling cannot turn its background writers into an unbounded fsync
+ workload on macOS, while every round still contends with a commit (#1850).
+
+ - Fixed false command timeouts in the macOS menu app when CLI output or
+ diagnostics exceeded a pipe buffer (#1845).
+
+ - Fixed the macOS menu app's LaunchAgent installation and restart checks for
+ app and home-directory paths containing XML characters such as `&` (#1844).
+
+ - OpenCode 1.x `task` subagents no longer claim the pending handoff or leave
+ one behind. OpenCode runs each subagent in a child session, which the
+ generated plugin took for a top-level one: the subagent's first model call
+ claimed the newest open handoff in the checkout, and the end the plugin
+ posts for it when OpenCode exits carried no subagent marker, so the user's
+ next session got the subagent's handoff instead of the top-level session's.
+ The plugin now records a child session's parent from OpenCode's session
+ events, skips the claim for it and marks its end on every close path, a
+ subagent the task tool resumes by `task_id` included (#1842).
+
+ - Preserved `title:` and `body:` filters inside parenthesized CJK searches,
+ so grouped queries no longer include matches from other columns (#1846).
+
+ - Made `auth login --timeout-secs` stop device-authorization polling requests
+ and waits at the deadline for OpenAI OAuth, GitHub Copilot and OIDC device
+ login. Late polling results no longer reach credential storage; provider
+ intervals and `slow_down` backoff are preserved. OpenAI's subsequent exchange
+ of an authorized code keeps its own HTTP request timeout (#1848).
+
## [3.2.10] - 2026-10-29
### Changed
diff --cc docs/security-boundaries.md
index 307851f7,2721a9be..ac7f5d8e
--- a/docs/security-boundaries.md
+++ b/docs/security-boundaries.md
@@@ -67,16 -65,15 +67,17 @@@ the legitimate restricted-project contr
| 4j | A hook never claims a handoff for an event that names no project directory | `GET /handoff` claims the newest open handoff in whatever project the server resolves; a request without `cwd` lets the server use its default or the caller's last active project, so the claim could consume another repository's handoff. Every front door gates the claim on a resolved directory and leaves the handoff open for `memory_handoff_accept`: the native hook in `ai-memory-cli/src/commands/hook.rs` `run_with_payload` (`handoff_scoped`, a resolved `policy_cwd`, gates SessionStart, Kimi's UserPromptSubmit and Grok's PostToolUse, with a stderr warning at SessionStart); the shell bundle's `hooks/_lib.sh` `ai_memory_get_handoff` (refuses a URL without the `&cwd=` that `ai_memory_marker_qs` adds for every named directory); the PowerShell `hooks/lib/ai-memory-hook.ps1` `Invoke-AiMemoryHook` (`$FetchHandoff -and $Cwd`); and the generated OpenCode, OpenCode 2, OMP and Pi integrations' `fetchHandoff` (`if (!cwd) return undefined;`). OpenClaw's `fetchHandoff` already required a directory. The only fallbacks are Devin's documented ones (`DEVIN_PROJECT_DIR`, then the hook's own directory), in `resolve_hook_cwd_with`, `ai_memory_resolve_cwd` and `Resolve-AiMemoryCwd`, and CodeBuddy's documented `CODEBUDDY_PROJECT_DIR` in the native hook (never its process cwd) (#1299) | `hook.rs` `a_handoff_is_never_claimed_without_a_project_directory` (CodeBuddy, Claude Code and Codex SessionStart, Kimi UserPromptSubmit and Grok PostToolUse with no `cwd` send no `GET /handoff`; control: the same events with a `cwd` claim once, naming it); `codebuddy_missing_cwd_uses_codebuddy_project_dir_only` and, end to end against a real server, `ai-memory-cli/tests/suite/external_capture.rs` `codebuddy_start_without_a_directory_leaves_the_default_projects_handoff` (a CodeBuddy SessionStart with no `cwd`, run from inside the project, leaves the server-default project's handoff open; controls: the payload's `cwd`, then `CODEBUDDY_PROJECT_DIR`, claim it); `tests/hooks/test_lib.sh` "a handoff is never claimed without a project directory" (every shell script that fetches a handoff, discovered from the bundle and run from an unrelated directory: no payload directory, no claim; control: a directory claims and names it; Devin claims for its own directory; the PowerShell helper runs the same pair where a PowerShell exists, else a static pin); `install_hooks.rs` `generated_integrations_never_fetch_a_handoff_without_a_directory` and, running the generated OMP extension in Node, `slow_generated_handoff_runtime::omp_extension_never_claims_a_handoff_without_a_directory` (an empty `ctx.cwd` sends no claim; control: a directory claims). Each fails with its guard removed | STRONG for the native hook, the shell bundle and the generated integrations; the PowerShell runtime case runs only where a PowerShell is installed |
| 4k | The idle-session auto-end (`[sessions] idle_end_after_hours`) never ends a session it does not own: idle-threshold + active-run exclusion at selection, guarded CAS stamp, conditional page write, owner attribution | `ai-memory-store/src/reader.rs` `idle_open_sessions` — ONE statement: the idle-threshold predicate (`ended_at IS NULL` + `COALESCE(MAX(observations.created_at), started_at) < cutoff`), `ORDER BY last_activity ASC` capped at the batch, and a correlated `pages` subquery bound to the session's own `workspace_id`/`project_id` and to the path rendered in SQL from the id blob (`lower(hex(id))` with 8-4-4-4-12 hyphens — byte-for-byte the Rust `format!("sessions/{session_id}.md")`, proven by the selection test with a page present and absent) capturing the latest `sessions/<id>.md` version as the tick's write precondition — a read path, never a write; `active_managed_run_native_session_ids` (only `state = 'active'` managed runs). `ai-memory-store/src/ops.rs` `idle_end_sessions` — per-candidate `UPDATE sessions … WHERE id AND workspace_id AND project_id AND ended_at IS NULL` that also re-verifies the session's observation count (EVERY row of the session — the digest's population, no per-row scope filter) and the latest page version; `ended_at` = the tick's clock (last activity kept in the audit detail), `ended_observation_count` counted at the stamp, one `idle_session_end` audit row in the same transaction, and the consolidation gate: the job is enqueued INSIDE the stamp's transaction (`session_consolidation::enqueue_in_tx`), so a failed enqueue rolls back the stamp, the audit row and the job, while the page the tick already wrote stays as an ordinary version; a lost stamp skips the enqueue and never aborts the batch. The lifecycle-only gate applies the same scope/open guard before any mutation, re-checks substantiveness atomically, reuses `end_lifecycle_only_session_in_tx` (releasing the accepted handoff), and writes its OWN `idle_session_end` audit row distinct from the `release_lifecycle_only_handoff` row. `ai-memory-hooks/src/idle_end.rs` `run_idle_end_tick` — excludes active-run sessions in Rust via `SessionId::from_native` BEFORE the batch bound (the serve loop over-fetches, so an excluded backlog cannot starve the batch), classifies via `session_has_substantive_observation`, builds the page and its count from one digest snapshot (`SessionDigest::load_with_count` — the count the CAS guard re-verifies), writes the page with `Wiki::write_page_if` under `PagePrecondition::Latest(seen)`/`Absent` (`Mismatch` skips the whole session), keeps an agent-written page (`session_page_written_by_agent`), and attributes via `router.rs` `stored_session_identity` (the hook path's own fail-closed parse). The tick creates no additional handoff: the consolidation gate and the lifecycle-only release gate are its only handoff-affecting effects | `store` `tests/suite/idle_session_end.rs` — guard by guard: `idle_end_loses_to_an_already_ended_session` (the `ended_at IS NULL` predicate; fails with it removed), `idle_end_counts_the_same_observation_population_as_the_digest` (a multi-project session ends with `ended_observation_count` = 2; fails if the CAS count's population diverges from the digest/counter's), `idle_end_cas_rejects_a_stale_observation_count` (the count guard; fails with it removed), `idle_end_cas_rejects_a_moved_latest_page` (the page-version guard; fails with it removed), `idle_end_pre_stamp_non_end_observation_in_window_loses_the_cas` / `idle_end_pre_stamp_checkpoint_page_in_window_loses_the_cas` / `idle_end_pre_stamp_real_session_end_in_window_loses_the_cas` (the test-only seam runs on the writer connection BEFORE the candidate's stamp transaction and injects the SQL effects a concurrent writer would leave in the read-to-stamp window — simulated effects, not a run of the hook's `SessionEnd` handler; a `Lost` with the consolidation gate on creates no job; each fails with its guard removed), `idle_end_candidate_cannot_cross_the_project_boundary` (a foreign-scope candidate is refused; same-scope control ends), `idle_end_lifecycle_only_refuses_a_foreign_scope_candidate` (the lifecycle-only scope/open guard: `Lost`, no audit, the claimed handoff stays `Accepted`; fails with the guard removed), `idle_end_lifecycle_only_refuses_an_already_ended_session_with_control` (dedicated already-ended case: `Lost` with no audit and no handoff release, next to the open control in the same fixture that ends and releases), `idle_end_lifecycle_only_loses_to_a_substantive_race` (the atomic substantiveness re-check), `idle_end_reopens_the_handoff_a_lifecycle_only_session_claimed` (exactly one `idle_session_end` row, distinct from the release row), `idle_end_watermark_converges_a_late_real_session_end` (a late real `SessionEnd` converges through `AlreadyEnded`/`ReEnd`), `idle_end_batch_stamps_every_candidate_in_one_command`, `idle_selection_is_cutoff_scoped_ordered_and_bounded` (threshold, order, bound; `seen_page_id` captured with a page present and `None` without — the `session_page_path` rendering), `idle_end_stamps_watermark_audit_page_and_consolidation`, `idle_end_consolidation_enqueue_shares_the_callers_transaction` + `idle_end_consolidation_enqueue_failure_rolls_back_and_retries` (the in-transaction enqueue; fails out-of-transaction), `session_observation_count_refuses_foreign_and_missing_scopes` (foreign workspace / foreign project / missing id each count 0; the right tuple counts — the raw-id reader's scope join), `enqueue_in_tx_refuses_a_foreign_scope_and_leaves_the_foreign_queue` (a foreign tuple enqueues nothing and the foreign project's queue is unchanged; the right tuple enqueues — the job INSERT's scope binding). `hooks` `tests/suite/idle_end.rs` + `src/synth.rs` `load_with_count_scopes`: `foreign_and_missing_tuples_load_nothing_the_right_tuple_loads` (`SessionDigest::load_with_count` refuses a foreign tuple and a missing id as `SessionCollision`; the right tuple loads and counts — the tuple validation; fails with it removed), `idle_tick_skips_a_session_ended_by_a_real_session_end_between_selection_and_write` (a real `/hook` `SessionEnd` landing between selection and page write leaves the hook's page as the only version and no additional handoff from the tick; fails with the conditional write removed — the CAS itself is proven by the store tests above), `idle_tick_late_real_session_end_with_new_work_reends_with_handoff` (the late real end re-ends with exactly one handoff), `idle_tick_excludes_active_managed_run_sessions` (+control after `cancel_managed_run`), `idle_tick_excluded_backlog_cannot_starve_the_batch` (25 excluded sessions cannot consume the batch), `idle_tick_ends_idle_substantive_session_with_page_job_and_no_handoff` (owner attribution via `last_modified_by.username`; no additional handoff from the tick), `idle_tick_lifecycle_only_ends_without_page_or_job_and_creates_no_handoff`, `idle_tick_skips_active_sessions_and_respects_the_batch`, `idle_tick_keeps_a_session_page_written_by_the_agent`; `cli` `serve.rs` `idle_end_tick_does_not_start_when_disabled_or_maintenance_off` and `idle_end_tick_ends_an_idle_session_on_the_first_pass` (tick-clock `ended_at`, paused `tokio::time`), `config.rs` `sessions_idle_end_defaults_off_loads_from_toml_and_rejects_out_of_range` | STRONG |
| 4l | The cut-off-session pointer (session-start notice, `memory_briefing` `recent_sessions`, `memory_handoff_list` `newer_unended_session`) names only the caller's own or shared sessions, carries no captured text, and claims nothing; `memory_read_session_observations` without a `session_id` defaults through the same owner-filtered, scope-bound ordering | `ai-memory-store/src/reader.rs` `recent_session_activity` applies the same `OwnerFilter` clause on the session row as `sessions_for_scope` (`actor_user IS NULL OR = :actor`, or `IS NULL` for an unattributed caller) inside the resolved, authorized `(workspace, project)`; `ai-memory-hooks/src/router.rs` `render_continuity_notice` renders only the stored agent kind, the session UUID, an age and the scope's server-side names (the `render_handoff_notice`/`render_inbox_notice` bar) and is computed after `authorize_resolved`; the MCP fields reuse the tool's own resolved scope and owner filter | router `session_start_never_names_another_operators_cut_off_session` (adversarial: with registered users, bob's cut-off session is not named to alice; control: bob's next session is pointed at it; fails with the owner clause removed), `session_start_names_a_session_cut_off_without_ending` (the notice carries none of the session's prompt, command or output text); store `session_activity.rs` `the_owner_filter_hides_another_operators_sessions`; MCP `memory_read_session_observations_default_never_crosses_owner_or_project` (adversarial: bob's newer open session in alice's cwd and alice's newer session in another project are never alice's default; control: alice's own older session is, and bob's default is his own; fails with the owner filter set to `Any`); CLI `harness_switch_e2e.rs` (real server and hook binary; no captured text in the notice) | STRONG |
+| 4m | A project's `[handoff] deliver_on_session_start = false` hides and claims only its own session-start baton | `ai-memory-hooks/src/router.rs` `fetch_and_accept_handoff_at` reads `HandoffQuery.handoff` for the one resolved `(workspace, project)`: opted out, it neither reads (`startup_handoff`), claims, announces nor renders the continuity notice; the handoff stays `open`, and the SessionEnd path that creates it is untouched | `router.rs` `handoff_opt_out_leaves_the_baton_open_and_undelivered` (falsy values hide the baton and leave it open; `1` still delivers and claims) and `handoff_opt_out_is_scoped_to_the_requesting_project` (a second project keeps receiving its own baton, never the opted-out one's, and does not consume it) | STRONG |
+| 4n | A subagent's brief reads only its repository's brief and never claims, publishes or records | `ai-memory-hooks/src/router.rs` `handle_brief`/`fetch_brief` — the project comes from `resolve_readable_startup_scope`, the helper `/handoff` also uses (cwd, marker or explicit scope, then `grants::authorize_resolved(.., ProjectAccess::Read)`, whose refusal is a `403` with its reason); only the brief is rendered, with `[slots] per_user` visibility for the requesting identity and stored text inside the untrusted-history fence; no handoff is read or claimed, no active project is published and no `[profile]` flag is written. Clients (`ai-memory hook`, `hooks/claude-code/subagent-start.{sh,ps1}`) fetch it only for the `claude-code` agent's `SubagentStart` and only with the marker's `[briefing] inject_on_subagent_start`, and never fall back to `/handoff` when the route is missing | `router.rs` `brief_endpoint_never_claims_a_pending_handoff` (the baton stays open; control: `/handoff` with the same query delivers it), `brief_endpoint_delivers_nothing_from_a_repository_the_viewer_cannot_read` (no grant: `403` and no page text; control: a Read grant), `per_user_subagent_brief_carries_own_slot_body_and_not_others` (another operator's slot withheld; own slot delivered), `brief_endpoint_is_empty_without_the_opt_in`; `hook.rs` `subagent_start_delivers_the_opted_in_brief` (no `/handoff` request), `subagent_start_with_no_brief_prints_an_empty_reply` (a `404` never falls back to `/handoff`), `subagent_brief_skips_agents_without_subagent_context`; `tests/hooks/test_lib.sh` (the shell bundle never asks `/handoff`) | STRONG |
| 4o | An OMP subagent session never claims a handoff or leaves one behind | `ai-memory-hooks/src/router.rs` SessionEnd `child_session`: an OpenCode or OMP end whose body carries a subagent marker (`payload.rs` `body_is_subagent`) closes and summarizes the session without a baton. The generated OMP extension (`ai-memory-cli/src/commands/install_hooks.rs` `build_omp_extension`) records a subagent session from `ctx.agent.kind` on the session's own `session_start`, `before_agent_start` and `session_shutdown`, never on a tool event (an advisor's tool calls reach the session they advise as `kind: "sub"` under that session's id), skips `fetchHandoff` for it and posts its events with `agent_id`. Pi reports no `ctx.agent`, so every Pi session stays top-level | router `omp_subagent_session_end_closes_and_summarizes_without_baton` (a marked OMP end leaves no baton; control: a top-level OMP session in the same project still leaves one), beside `opencode_child_session_end_closes_and_summarizes_without_baton`, and `drop_subagent_captures_drops_an_omp_subagent_session` (an opted-in project drops the marked session through its end; control: the top-level session is stored); `install_hooks.rs` `omp_extension_marks_subagent_sessions_and_skips_their_handoff` and, running the generated OMP extension in Node, `slow_generated_handoff_runtime::omp_extension_keeps_subagent_sessions_off_the_baton` (a task subagent, a `/tan` clone and a revived subagent never request `/handoff` and carry `agent_id` on every event, their ends included; controls: the top-level session and a session without `ctx.agent` claim, and the advisor's tool calls leave the top-level session unmarked). Each fails with its guard removed | STRONG |
+ | 4p | An OpenCode 1.x subagent session never claims a handoff or leaves one behind | `ai-memory-cli/src/commands/install_hooks.rs` `build_opencode_plugin`: the generated V1 plugin records a child session's parent from its `session.created` and from the `session.updated` OpenCode publishes on every prompt before the model call (a child the task tool resumes by `task_id` in a later process), skips `fetchHandoff` in `experimental.chat.system.transform` for it, and `endSession` posts its end with `agent_id` on every close path, the `dispose` at exit included, so the router's SessionEnd `child_session` gate (row 4o) closes and summarizes it without a baton | `install_hooks.rs` `opencode_plugin_skips_the_handoff_for_a_subagent_session` (the parent comes from both session events, only from a string `parentID`, and the transform returns for a child before `fetchHandoff`) and `opencode_plugin_marks_a_subagent_session_end` (`dispose` ends sessions through `endSession`, which adds `agent_id` for a recorded child); running the generated plugin in Node, `slow_generated_handoff_runtime::opencode_plugin_keeps_task_subagents_off_the_baton` (a `task` subagent and one resumed by `task_id` never request `/handoff`, and their ends from `dispose` carry `agent_id`; controls: a top-level session and one continued from an earlier process claim and stay unmarked). Each fails with its guard removed | STRONG |
| 5a | Pages shared: `author_id` is never a read filter (invariant #16) | `ai-memory-store/src/reader.rs` `search_pages`/`page_body_by_ids` — `author_id` is an attribution JOIN only, never a WHERE term; `observation_stream_votes` lets every session vote whatever its owner (the owner filter only withholds the observation excerpt and ids, never the vote or the page) | `multi_session.rs` — a page with a **non-null** `author_id` (operator A) is readable by operator B in the same project; `multi_session.rs` `another_operators_observations_lift_their_session_page_in_a_shared_project` (operator B's owned session, authored page and observations lift that page for operator A's query); `ai-memory-mcp` `server.rs` `observation_stream_evidence_stays_inside_a_restricted_project` (a second operator with only a read grant gets the session page lifted by the first operator's observation); `multi_session.rs` `observation_excerpts_follow_the_session_owner_while_the_vote_stays_shared` (B still gets A's session page ranked by A's observation, with the page's own snippet) | STRONG |
| 5b | Page supersession (loser stays reachable) | `ai-memory-store/src/ops.rs` `upsert_page_in_tx` — demote `is_latest=0` (never delete) + `supersedes` chain; read side: `reader.rs` `page_versions` lists every row at the path, with no `is_latest` filter, for `/web/w/…/h/*path` and `/api/v1/…/history/*path`. It does apply TTL expiry (`reader.rs` `history_visible`): a version whose own `expires_at` passed is neither listed nor readable by id, a path whose live version expired shows no history at all (the forget sweep hard-deletes every row there), and a `supersedes` link to a hidden version reads as `null`. Expiry is the only thing that hides a superseded version; a concurrent write never does | `multi_session.rs` `concurrent_writes_to_one_path_supersede_rather_than_destroy`; `retrieval_superseded.rs`; `multi_session.rs` `page_history_keeps_the_overwritten_version_and_stays_in_scope`; `ai-memory-web` `history_replay.rs` `history_keeps_both_sides_of_a_concurrent_divergent_write` (two attributed writers on one base: all three versions and both authors listed, one `is_latest`, the two writers' versions diff by id) and `history_lists_k_plus_one_versions_newest_first_and_diffs_the_latest`; bite: an `is_latest = 1` filter in `page_versions` fails both; `history_hides_expired_versions_and_expired_pages` (an expired superseded version and every version of a page whose live version expired answer 404 by path and by id on HTML and JSON, and the live successor's `supersedes` is `null`; control: a TTL in the future is listed and diffable; bites with the per-row predicate removed, with the live-version clause disabled, and with the `supersedes` hiding removed) | STRONG |
-| 5c | Watcher reindex and Wiki writes share per-page serialization (invariant #16) | `ai-memory-wiki/src/wiki.rs` `reindex_page` takes `mutation_lock.read` before `reindex_page_locked` takes `lock_page`, covering disk read through the single-writer upsert; callers already holding the exclusive global guard do not reacquire it. `write_page` and `restore_page_from_checkpoint` use the same page mutex and `apply_batch` retains sorted, deduplicated locks; restore reads current frontmatter under the guard and rolls back its installed file if the store refuses the version; embedding runs after both guards are released | `wiki.rs` `reindex_page_lock_waits_before_reading_and_allows_another_path` (transient snapshot refused while locked, another path progresses, release indexes the committed bytes without rewriting disk), `reindex_page_lock_serializes_write_through_the_upsert` and `reindex_page_lock_and_reversed_duplicate_batches_do_not_deadlock` (real concurrent operations, final disk/SQL winner and supersession ancestry preserved); all three fail with the reindex page guard removed. `restore_page_lock_waits_before_conformance_and_allows_another_path` (a queued writer wins first, its timestamp is preserved, another path progresses; fails without the restore page guard or with conformance before it), `restore_page_collision_keeps_disk_and_store_unchanged` and `restore_page_store_failure_rolls_back_replacement_and_new_file` (rejected historical alias and injected upsert failures preserve disk and SQL, ordinary restore succeeds after removing the fault; fail without restore rollback). `reindex_page_lock_releases_both_guards_before_embedding` checks both body and abstract embedding; `decay_cleanup_reindex_does_not_embed_under_the_exclusive_lock` covers the exclusive caller | STRONG for a shared Wiki handle and its clones. External editors and independently constructed Wiki handles do not participate in these locks |
+| 5c | Watcher reindex and Wiki writes share per-page serialization (invariant #16) | `ai-memory-wiki/src/wiki.rs` `reindex_page` takes `mutation_lock.read` before `reindex_page_locked` takes `lock_page`, covering disk read through the single-writer upsert; callers already holding the exclusive global guard do not reacquire it. `write_page` uses the same page mutex and `apply_batch` retains sorted, deduplicated locks; embedding runs after both guards are released | `wiki.rs` `reindex_page_lock_waits_before_reading_and_allows_another_path` (transient snapshot refused while locked, another path progresses, release indexes the committed bytes without rewriting disk), `reindex_page_lock_serializes_write_through_the_upsert` and `reindex_page_lock_and_reversed_duplicate_batches_do_not_deadlock` (real concurrent operations, final disk/SQL winner and supersession ancestry preserved); all three fail with the reindex page guard removed. `reindex_page_lock_releases_both_guards_before_embedding` checks both body and abstract embedding; `decay_cleanup_reindex_does_not_embed_under_the_exclusive_lock` covers the exclusive caller | STRONG for a shared Wiki handle and its clones. External editors and independently constructed Wiki handles do not participate in these locks |
| 5d | Wiki project-tree filesystem confinement | `ai-memory-wiki/src/confinement.rs` checks the wiki root, workspace/project roots, every existing ancestor, the final component, and the in-root ordinary `.git` directory with link-aware metadata; repository workdir/gitdir/commondir are containment-checked after opening, and write parents are created one component at a time and rechecked. `Wiki` checks before admission and again under mutation/page locks, while `GitAdapter` rechecks immediately before writes, appends, renames, and removals. Direct reindex, checkpoint restore, manifests, auto-improvement artifacts, ledger append, startup repair, purge/session moves, rollback, migrations, and git tree staging use the same boundary. Confinement is a distinct `WikiError` and therefore cannot trigger missing-file DB fallback | `wiki.rs` `page_reads_refuse_leaf_and_ancestor_symlinks_without_fallback_classification`, `ai-memory-mcp` `admin_read_page.rs` `read_page_does_not_db_fallback_through_a_symlink`, `page_mutations_refuse_ancestor_symlink_and_leave_outside_and_store_unchanged`, `confinement_refusal_happens_before_blocking_and_observer_admission`, `restore_and_reindex_refuse_ancestor_symlink_without_touching_canary_or_db`; `git.rs` `git_metadata_link_is_refused_without_touching_external_repository`, `gitfile_redirect_outside_is_refused_without_touching_target`, `git_metadata_redirect_files_are_refused_before_repository_open`, `configured_worktree_outside_the_wiki_root_is_refused`, `linked_git_metadata_never_reaches_commit_fallback`, `gitfile_metadata_never_reaches_commit_fallback`, `out_of_root_worktree_never_reaches_commit_fallback`, `fallback_preflight_refuses_invalid_git_metadata`, `windows_commit_fallback_accepts_established_eligible_errors`, `eligible_windows_open_error_dispatches_the_fallback_after_validation`, `windows_init_error_dispatches_fallback_after_root_preflight`, `invalid_root_never_reaches_init_fallback`, `checkpoint_and_revision_reads_refuse_a_replaced_git_directory`, and ordinary-repository/API controls `init_is_idempotent_and_creates_dotgit`; `linked_wiki_root_is_refused_during_construction`, `linked_or_dangling_scope_roots_are_refused_but_real_roots_work`, existing `decay_cleanup_refuses_to_reindex_a_symlinked_recreation` and `reindex_rejects_symlinked_scope_manifest`; `ai-memory-mcp` `admin_move.rs` `true_move_refuses_an_invalid_destination_namespace_without_db_changes` and `delete_workspace_refuses_invalid_namespace_before_db_or_notification`; `admin_backup.rs` `backup_refuses_redirected_git_metadata_before_returning_an_archive`, `backup_refuses_wiki_leaf_links_before_returning_an_archive`, `backup_refuses_linked_wiki_directories_before_returning_an_archive`, and ordinary archive controls; `watcher.rs` `direct_file_event_skips_symlink`, `walk_markdown_skips_linked_directories_and_their_ledgers`, and `shared_link_like_helper_accepts_regular_files_and_directories` (Windows directory-link coverage exercises reparse metadata when privilege is available); `backup.rs` `a_pre_migration_backup_refuses_a_linked_wiki_tree_without_an_archive`; `confinement.rs` metadata-helper controls run on every platform | STRONG for imported/static links and same-process mutations. Component checks do not claim descriptor-relative protection against a concurrently malicious same-user process; Windows reparse behavior requires the `windows` PR label/full CI |
-| 5e | Conditional page mutation (#986, invariant #16) | `ai-memory-store/src/ops.rs` `upsert_page_if` reads the latest version and writes in one transaction, the authority; `ai-memory-wiki/src/wiki.rs` `write_page_if` pre-checks under the per-page lock before touching disk and restores the file when the store check fails; conditional deletes reuse `delete_page_if_latest` (exclusive mutation lock plus an in-transaction check). `ai-memory-mcp/src/server.rs` checks the precondition only after scope resolution and the write grant, against the resolved scope's own latest row, and returns `precondition_failed` with no write, checkpoint or webhook dispatch. The agentmemory importer (`agentmemory/mod.rs` `apply_page`) resumes from a conflicting destination only when its complete body equals a planned version; a retained attribution key alone cannot supply the next write's expected version. `companions/ai-memory-wikisync/src/bidi.rs` `build_plan` reads the full page for an edited repository file, keeping classification and `expected_page_id` on the same server version; `delete_server_page` rechecks the repository file's absence before sending a conditional server delete | `multi_session.rs` `conditional_writers_on_one_base_exactly_one_wins_and_nothing_is_destroyed` (two writers from one version: one wins, the base stays reachable, no loser row; fails with the store check removed); `server.rs` `conditional_page_writes::*` (stale id, `create_only` on an existing page, a version id from another project, and conditional deletes are refused and change nothing, with and without the wiki pre-check; the store check proven to bite with the reader pre-check off); `a_reader_may_read_everything_and_change_nothing` (a read-only user's conditional write or delete, with the right id or a wrong one, gets the authorization error and no version data; the page is unchanged); importer `resume_refuses_an_edited_body_even_with_the_original_ingest_key` and `e2e_export_import_rebuilds_chains_and_honours_ttl` (an edited destination body keeps its attribution key but cannot be superseded by a resumed import; both fail with marker-only matching); `resume_after_an_injected_failure_writes_no_duplicates` and `a_foreign_page_at_the_destination_is_never_replaced` are the legitimate-resume and foreign-page controls; wikisync `tests/api_server.rs` `sync_does_not_rebase_an_import_onto_a_concurrent_server_edit` (an edit after the read snapshot is refused by the original version precondition, preserving server, repository and baseline; fails without the conditional-read guard), `sync_imports_a_repo_edit_with_its_metadata` and `sync_exports_metadata_and_round_trips_without_writes` (ordinary import and unchanged-file ETag controls); `sync_keeps_a_server_page_when_its_file_reappears_during_planning` (restored file blocks server deletion and keeps the baseline, with and without `--prefer repo`; another absent file is deleted and a later sync imports the restored edit; fails without the local-absence recheck) | STRONG. Importer resumption compares bodies, not frontmatter-only edits; custom server sanitation that changes the planned body fails closed. Wiki-sync rechecks local absence immediately before the request; this is not atomic across the filesystem and server |
+| 5e | Conditional page mutation (#986, invariant #16) | `ai-memory-store/src/ops.rs` `upsert_page_if` reads the latest version and writes in one transaction, the authority; `ai-memory-wiki/src/wiki.rs` `write_page_if` pre-checks under the per-page lock before touching disk and restores the file when the store check fails; conditional deletes reuse `delete_page_if_latest` (exclusive mutation lock plus an in-transaction check). `ai-memory-mcp/src/server.rs` checks the precondition only after scope resolution and the write grant, against the resolved scope's own latest row, and returns `precondition_failed` with no write, checkpoint or webhook dispatch. The agentmemory importer (`agentmemory/mod.rs` `apply_page`) resumes from a conflicting destination only when its complete body equals a planned version; a retained attribution key alone cannot supply the next write's expected version. `companions/ai-memory-wikisync/src/bidi.rs` `build_plan` reads the full page for an edited repository file, keeping classification and `expected_page_id` on the same server version | `multi_session.rs` `conditional_writers_on_one_base_exactly_one_wins_and_nothing_is_destroyed` (two writers from one version: one wins, the base stays reachable, no loser row; fails with the store check removed); `server.rs` `conditional_page_writes::*` (stale id, `create_only` on an existing page, a version id from another project, and conditional deletes are refused and change nothing, with and without the wiki pre-check; the store check proven to bite with the reader pre-check off); `a_reader_may_read_everything_and_change_nothing` (a read-only user's conditional write or delete, with the right id or a wrong one, gets the authorization error and no version data; the page is unchanged); importer `resume_refuses_an_edited_body_even_with_the_original_ingest_key` and `e2e_export_import_rebuilds_chains_and_honours_ttl` (an edited destination body keeps its attribution key but cannot be superseded by a resumed import; both fail with marker-only matching); `resume_after_an_injected_failure_writes_no_duplicates` and `a_foreign_page_at_the_destination_is_never_replaced` are the legitimate-resume and foreign-page controls; wikisync `tests/api_server.rs` `sync_does_not_rebase_an_import_onto_a_concurrent_server_edit` (an edit after the read snapshot is refused by the original version precondition, preserving server, repository and baseline; fails without the conditional-read guard), `sync_imports_a_repo_edit_with_its_metadata` and `sync_exports_metadata_and_round_trips_without_writes` (ordinary import and unchanged-file ETag controls) | STRONG. Importer resumption compares bodies, not frontmatter-only edits; custom server sanitation that changes the planned body fails closed |
| 5f | Wiki-sync companion destination confinement | `companions/ai-memory-wikisync/src/paths.rs` `prepare_dest` compares canonical and lexical destination components without resolving the lexical path; Windows disk and UNC verbatim prefixes compare as equivalent spellings, while changed directory components are refused. `secure_join` keeps validated page paths below that root and refuses existing symlink components | `paths.rs` `prepare_dest_refuses_windows_junctions_without_touching_the_target` refuses a junction and a destination reached through it, leaves an outside canary unchanged, and accepts the real directory; `windows_destination_prefixes_do_not_hide_different_paths` refuses different drives, shares and directory components with ordinary/verbatim controls; `prepare_dest_refuses_symlinks_and_files` and `secure_join_stays_under_root_and_refuses_symlink_components` retain the Unix link controls | Static path checks; no descriptor-relative protection against a concurrently malicious same-user process. The dedicated `windows.yml` wiki sync companion job runs the prefix and junction tests on companion/workflow changes, `windows` or `full-ci` labels, nightly runs and dispatch |
-| 6 | Active-project pointer (PerActor, no clobber) | `ai-memory-core/src/active_project.rs` `set_for`/`lookup_for` (fail-closed on `Mismatch`); `ai-memory-mcp/src/server.rs` `memory_query` applies the pointer's `default_global` only when `global` is absent and no explicit scope or `as_of` is supplied; `ai-memory-cli/src/commands/mcp_bridge.rs` `bridge_session_id`: the session-less bridge (`--no-session-id`, every non-Claude stdio client on a token-file install) never forwards an inherited `CLAUDE_CODE_SESSION_ID`, so a client launched from a Claude Code terminal cannot steer that session's per-session pointer; the session-aware bridge reads only the variable its `--agent` names (`CLAUDE_CODE_SESSION_ID`, or `MUSE_SESSION_ID` for Meta Muse Code), so neither harness's id stands in for the other's | `active_project.rs` `parallel_harnesses_of_one_user_keep_separate_pointers`, `two_operators_never_read_each_others_pointer`, `a_session_mismatch_fails_closed_once_anything_has_been_keyed`; `multi_session.rs` `same_operator_multiple_sessions_isolate_active_project_pointers_and_resolution` (concurrent sessions of one operator under `AccessMode::Restricted` resolve unscoped reads/writes to their own active project without cross-session clobber, while an unbound session of the same operator fails closed on unscoped write with `AmbiguousUnscopedWrite` and falls back to `DefaultAfterMismatch` on read); `mcp_bridge.rs` `only_the_session_aware_mode_forwards_and_requires_a_session_id` (an inherited id is dropped in session-less mode; the session-aware control forwards it and still fails closed without one), `each_harness_forwards_only_its_own_session_id` (a Muse bridge never forwards an inherited Claude id and fails closed without its own, a Claude bridge never forwards an inherited Muse id; controls forward each harness's own id) and `a_session_less_upstream_config_carries_no_session_header`; `auth_default_e2e.rs` `a_session_less_bridge_serves_any_client_without_holding_the_token` (the built `mcp-bridge --agent muse` refuses to start with only `CLAUDE_CODE_SESSION_ID` set); `server.rs` `memory_query_default_global_marker_honours_explicit_arguments` (both marker values with omitted/false/true `global`, named scopes and scope lists: explicit false never adds another project; fails with the opt-out guard removed), `bob_cannot_find_alices_page_by_searching_in_a_restricted_project` (explicit false still refuses an ungranted restricted active project, with granted and unrestricted controls; global searches retain their visibility filter) | STRONG |
+| 6 | Active-project pointer (PerActor, no clobber) | `ai-memory-core/src/active_project.rs` `set_for`/`lookup_for` (fail-closed on `Mismatch`); `ai-memory-cli/src/commands/mcp_bridge.rs` `bridge_session_id`: the session-less bridge (`--no-session-id`, every non-Claude stdio client on a token-file install) never forwards an inherited `CLAUDE_CODE_SESSION_ID`, so a client launched from a Claude Code terminal cannot steer that session's per-session pointer; the session-aware bridge reads only the variable its `--agent` names (`CLAUDE_CODE_SESSION_ID`, or `MUSE_SESSION_ID` for Meta Muse Code), so neither harness's id stands in for the other's | `active_project.rs` `parallel_harnesses_of_one_user_keep_separate_pointers`, `two_operators_never_read_each_others_pointer`, `a_session_mismatch_fails_closed_once_anything_has_been_keyed`; `multi_session.rs` `same_operator_multiple_sessions_isolate_active_project_pointers_and_resolution` (concurrent sessions of one operator under `AccessMode::Restricted` resolve unscoped reads/writes to their own active project without cross-session clobber, while an unbound session of the same operator fails closed on unscoped write with `AmbiguousUnscopedWrite` and falls back to `DefaultAfterMismatch` on read); `mcp_bridge.rs` `only_the_session_aware_mode_forwards_and_requires_a_session_id` (an inherited id is dropped in session-less mode; the session-aware control forwards it and still fails closed without one), `each_harness_forwards_only_its_own_session_id` (a Muse bridge never forwards an inherited Claude id and fails closed without its own, a Claude bridge never forwards an inherited Muse id; controls forward each harness's own id) and `a_session_less_upstream_config_carries_no_session_header`; `auth_default_e2e.rs` `a_session_less_bridge_serves_any_client_without_holding_the_token` (the built `mcp-bridge --agent muse` refuses to start with only `CLAUDE_CODE_SESSION_ID` set) | STRONG |
| 6b | Native `_meta` routing coordinate is routing-only (never grants identity) | `ai-memory-mcp/src/server.rs` `attach_native_session` reads only `_meta["ai.opencode/sessionID"]` into `ActorKey.session_id` (trimmed, non-empty-string-validated); `user` still comes from the authenticated `ActorContext`, so a forged `_meta` cannot cross a user/scope boundary — it only selects a session slot behind the existing `active_project` guard | `server.rs` `native_session_metadata_is_routing_only_and_preserves_precedence`, `native_session_metadata_validates_strings_without_granting_identity`; `autoscope_multiuser.rs` `native_metadata_routes_concurrent_reads_and_writes_to_hook_workspaces` (#864) | STRONG |
| 6c | Per-user slot namespaces stay per operator (`[slots] per_user`) | `ai-memory-mcp/src/server.rs` `place_slot_mutation`, shared by `place_slot_write` (`memory_write_page`) and `place_slot_delete` (`memory_delete_page`): a non-admin's generic `_slots/<name>.md` is redirected to their own `_slots/u-<operator>/` namespace, a path inside another operator's namespace is refused, admins bypass, and nothing changes with the flag off (#1083) | `slot_identity.rs` `oidc_operator_cannot_delete_another_operators_personal_slot`, `oidc_operator_deleting_shared_slot_path_deletes_their_personal_slot` (shared slot survives), legitimate controls `oidc_operator_can_delete_their_own_personal_slot_explicitly`, `admin_can_delete_shared_and_personal_slots` | STRONG |
| 6d | MCP page restore is admin-only and cannot bypass the write boundary | `ai-memory-mcp/src/server.rs` `memory_restore_page`: `require_admin_capability` gates listing and restoring alike (git keeps text a root deleted, purged or let expire), the same rung as `/admin/restore-page`; scope resolves once with the no-create mutation resolver (`effective_ids_for_mutation_args_with_actor`), so a restricted project needs a write grant even past the gate; a restore writes through `write_page_in_scope` (the `memory_write_page` body) into that resolved scope, so the sanitizer, admission chain, slot placement, attribution and supersession apply, and `checkpoint_write_metadata` re-validates the checkpoint's metadata | `tests/suite/restore_page_authz.rs`: `a_db_user_with_a_write_grant_cannot_list_or_restore` (an `aim_` user who can write the project is refused for both; root control restores), `a_foreign_restricted_project_is_refused_without_a_grant` (no grant on a restricted project, plus an unknown bearer, refused without leaking the version; root control), `a_personal_slot_restores_to_its_exact_path_and_only_for_root` (the slot owner is refused; root restores the exact `_slots/u-…` path, never the shared slot); `server.rs` `memory_restore_page_refuses_unknown_explicit_scope_and_bad_rev`, `memory_restore_page_round_trips_frontmatter_metadata`, legitimate control `memory_restore_page_lists_checkpoints_and_brings_back_a_deleted_page` | STRONG. Bite checks: removing the admin gate fails the write-grant and slot tests; removing it and also resolving without the viewer fails the restricted-project test; dropping the checkpoint metadata fails the round-trip test |