Skip to content

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

Rust
321 KB
Raw Blame

Security & isolation boundaries — inventory and adversarial-test map

ai-memory is single-tenant wiki data with optional multi-user attribution, run by parallel harnesses and shared teams. A handful of guards keep one project, workspace, operator, or untrusted input from crossing into another. Each guard is only as good as a test that actively tries to break it. A happy-path or single-tenant test cannot see an isolation defect, so a regression that removes the guard would pass CI silently.

This file is the source of truth for which boundaries exist, where each is enforced, and the adversarial test that would fail if the guard were removed. Keep it current (see the protocol at the end); the AGENTS.md "security-boundary tests" rule refers to it.

An adversarial test attempts the violation and asserts refusal, and also runs a legitimate control case so a blanket deny is not mistaken for a working guard. Coverage verdicts: STRONG means a test would fail if the guard were deleted; PARTIAL means only some paths of the guard are probed; FUTURE means the boundary is not built yet.

Boundary 14 treats missing/forward-unknown project metadata as a compatibility case, but a SQL/store failure while reading an existing project's access mode or grants propagates and refuses the request. The an_unreadable_restricted_project_fails_instead_of_opening test carries both the legitimate restricted-project control and the failed-query cases.

Boundary map

# Boundary Enforcing code Adversarial test(s) Coverage
0a A generated DSH hook config cannot expose or redirect an embedded server bearer ai-memory-cli/src/commands/install_hooks.rs write_private_dsh_config creates hooks.json owner-only before writing, resets a pre-existing file to 0600, and refuses a final-component symlink install_hooks.rs apply_to_dsh_keeps_an_embedded_bearer_owner_only (a world-readable predecessor becomes private before the new bearer is written; the bearer control is present), apply_to_dsh_refuses_a_symlinked_hook_config (an attempted redirect is refused and its target stays byte-identical) STRONG on Unix; Windows protection remains the data directory ACL
0b Generated Cline CLI hook files cannot overwrite user hooks or redirect an embedded server bearer ai-memory-cli/src/commands/install_hooks.rs apply_to_cline_hooks accepts only an absent or ai-memory-owned event file, refuses a final-component symlink, writes atomically, and sets each generated file to owner-only executable mode install_hooks.rs cline_apply_writes_native_event_hooks_without_overwriting_user_files (all nine generated files are 0700, a bearer is present, and a user-owned control remains byte-identical), cline_apply_refuses_a_symlinked_hook_without_touching_its_target (redirect refused, target byte-identical) STRONG on Unix; Windows protection remains the user profile ACL
1 Per-project isolation (3-tuple) ai-memory-store/src/scope.rs ScopeResolver::resolve_read_args/resolve_write_args, no-create lookup_existing_scope; reader queries filter by (workspace_id, project_id); reader.rs sessions_for_scope_filtered joins only consolidation jobs in the requested workspace and project; reader.rs incremental_pages filters workspace and project before its keyset and limit; reader.rs session_counts_by_agent filters mixed-source observations by the requested workspace and project; reader.rs observation_stream_votes ([retrieval] observation_stream, on by default) filters both the matching observations and the sessions/<id>.md page they vote for to the queried workspace and project, and attaches a vote's observation excerpt and ids only when the caller's session-timeline owner filter admits the session (sessions_hidden_from; HybridSearch::owner, threaded from memory_query, /web/search and /api/v1/search through OwnerFilter::for_actor_context); the raw-observation fallback search_observations_for_project_as drops sessions that filter does not admit; reader.rs page_versions / page_version_body (web page history) read by (workspace_id, project_id, path) and take a caller's version id only inside that triple; ai-memory-web routes/session.rs takes a raw session id only through session_summary_scoped (row or observation in the project, owner filter) and session_observations_scoped store scope.rs read-resolution table tests; tests/suite/multi_session.rs; session_observations.rs consolidation_summary_latest_generation_is_scope_and_owner_bound (a foreign-scope job is absent; the own latest generation and owner controls pass), incremental_pages_equal_timestamps_cutoff_expiry_and_foreign_scope (foreign scope absent with a same-scope control), mixed_capture_count_scopes_observations_and_preserves_owner_and_window (foreign-scope observations cannot turn an own session into a mixed one; same-scope control can); handoff receiver-session scope: see row 4, multi_session.rs handoff_accept_rejects_foreign_or_missing_receiver_session (cross-project and cross-workspace receivers refused); multi_session.rs observation_stream_never_crosses_a_project_or_workspace (a home observation cannot vote for a same-path session page in another project or workspace, and a foreign project's observation cannot lift a home page; control: home's own page receives the vote), fails with either the observation or the page scope filter removed; multi_session.rs observation_excerpts_follow_the_session_owner_while_the_vote_stays_shared (operator B, and an unattributed caller, querying words only A's owned session holds get A's shared session page with its own snippet, no excerpt, no observation ids and no raw hit; controls: A gets the excerpt, ids and raw hit, an unattributed session's excerpt reaches every viewer, and the unfiltered single-user path is unchanged), bite-checked against both the vote guard and the raw-fallback clause; ai-memory-mcp server.rs memory_query_shows_observation_text_only_to_its_sessions_owner and ai-memory-web recall_trace.rs project_search_shows_observation_excerpts_only_to_the_sessions_owner (the same through memory_query, /web/search and /api/v1/search; each fails when its surface passes OwnerFilter::Any); multi_session.rs page_history_keeps_the_overwritten_version_and_stays_in_scope (a sibling project's or another workspace's version id, or a home id under another path, reads as None; control: both home versions); ai-memory-web history_replay.rs history_refuses_foreign_project_workspace_and_version_ids (another project's or workspace's path, and a foreign version id as from or to, answer 404 on /web/w/…/h/*path and /api/v1/…/history/*path without the foreign text; control: the home history lists only home's rows at a path a sibling also uses, and an explicit home pair diffs) and session_timeline_refuses_foreign_session_ids (a sibling project's or another workspace's session id and an unknown id → 404, another operator's owned session → 404; controls: the home session, and the owner reading theirs); bite: dropping the scope filter from page_version_body or the project filter from page_versions, or replacing the session_summary_scoped check or its owner filter, fails them STRONG
1b Reserved _global scope union never leaks a foreign project (#930) ai-memory-mcp/src/server.rs memory_query — the union runs for single-project queries (scopes empty) and searches only lookup_global_scope's reserved (workspace_id, project_id), never an arbitrary project; the double-search guard resolves the queried project (named or active) so it can't be tricked into skipping server.rs global_union_never_leaks_a_foreign_projects_pages (a third real project's page must not surface via the union; reserved page must), single_project_query_unions_global_scope_and_multi_scope_skips_it STRONG
1c Reserved _global scope is read-open, write-gated (GHSA-7qj3-7wqw-m5w6) ai-memory-store/src/project_authz.rs ProjectAuthz::authorize (a write to default/_global needs root or a write grant in either access mode; creator ignored) fed by resolve_project_authz/read_project_row (reserved_global, grant read for the global scope regardless of mode); ai-memory-mcp/src/server.rs memory_write_page resolves scope: "global" through write_target_ids_with_actor like an explicit default/_global project_authz.rs the_global_scope_admits_writes_only_from_root_or_a_write_grant; server.rs a_user_without_a_global_grant_cannot_change_the_global_scope (both spellings and delete refused for an ungranted user and for _global's creator; page survives; reads stay open), a_global_write_grant_admits_writes_and_the_union_stays_readable (legitimate control: write grant admits both spellings, another user's restricted-project query still unions the page); bite-checked with the authz rule removed and with the raw create_global_scope path restored STRONG
1d A private cross-project profile is readable and writable by its operator alone ([profile] share = "user") ai-memory-store/src/ops.rs initial_access_mode (a _profile.<user id> project is always created restricted, creator recorded in the same transaction); ai-memory-store/src/scope.rs lookup_profile_scope / create_profile_scope (the project name derives from the authenticated viewer's id; no database user, no private profile); ai-memory-mcp/src/server.rs profile_target_ids and the memory_query profile union (resolved per viewer through the per-project choke point); scope.rs refuse_foreign_profile_name (called by ScopeResolver explicit writes and create_explicit_scope_guarded: a database user may name only their own default/_profile.<id>, so nobody can create another operator's private profile first and lock its owner out); ops.rs rename_project (no rename onto or away from a profile name); admin.rs handle_project_access (a profile project's mode is fixed) and move_project_core (a private profile cannot leave default) store integration::profile a_private_profile_refuses_every_other_operator (another operator's read and write by name refused; owner control admitted), reserved_profile_projects_get_their_fixed_access_modes; server.rs a_private_profile_is_private_to_its_operator (no union leak; read, write and delete by name refused; owner and own-profile controls); multi_session.rs two_harnesses_of_one_operator_share_one_private_profile; both fail with the restricted-mode guard removed; server.rs a_user_cannot_squat_another_operators_private_profile (another user's explicit write naming the owner's private profile refused and creates nothing; owner's profile and explicit own-name controls; fails with the name guard removed); ops.rs rename_project_refuses_profile_names_both_ways; admin.rs project_access_sets_the_mode_and_refuses_what_it_must; admin_move.rs move_project_refuses_a_private_profile STRONG
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 (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), looks_like_scripted_prompt (scripted one-shot prompts are skipped whole) and forgoes_a_capability (a capability ban needs explicit cross-project scope; an affirmative preference keeps the normal project threshold), 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, scripted_one_shot_prompts_do_not_become_global_defaults, capability_bans_stay_out_while_affirmative_habits_need_two_projects (bans repeated in two projects are refused; an affirmative habit needs two projects and is then admitted; fails with the capability guard removed), 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
1i2 The consolidation session read fails closed on a session with no observations in its target scope, and memory is bounded by the selection, not the session ai-memory-store/src/reader.rs read_session_observations_in_scope opens the bounded session snapshot only when at least one observation of the session exists in the caller's (workspace_id, project_id) (an EXISTS over observations), returning SessionCollision for foreign, purged and missing alike; SessionObservationSnapshot::projection_totals reads COUNT(*) and MIN/MAX(created_at) in one aggregate inside the same read transaction; SessionObservationSnapshot::row_by_rowid re-reads a single row only when both session_id = ?1 and rowid = ?2 match, so a legitimate snapshot cannot fetch another session's body by raw rowid; ai-memory-consolidate/src/projection.rs project_session_observations streams rows one at a time, keeping only the two anchors' rowids and a bounded top-k heap of the best limit - 2 rows (the shared selection_key the in-memory path sorts with), re-reading only the selected rows by rowid; residue candidate lists exist only while the opt-in residue is on; ai-memory-consolidate/src/consolidator.rs consolidate_session / consolidate_session_multi gate on the scope resolve_target already resolves (the observations' majority scope) and map the refusal to EmptySession, exactly as an empty session did before; auto-improve keeps its session_project_ids gate plus the sessions-row-gated read_session_observations (row 1i), and computes preflight, duration, report and prompt from one single snapshot read — a purge committed between the totals aggregate and the preflight decision cannot split the two generations, and a rowless session with the preflight minimums disabled is still reviewed with the empty (none) projection, as the full-load path did tests/suite/bounded_session_load.rs gated_reader_refuses_foreign_scopes (a foreign workspace and a foreign project are refused with SessionCollision; the session's own scope reads the totals as the legitimate control), store tests/suite/multi_session.rs rowid_fetch_refuses_foreign_sessions_with_legitimate_control (a foreign session's rowid is refused through a legitimate snapshot in both directions; the session's own rowid reads as the control; removing only the session predicate from the rowid fetch fails it), purged_session_is_refused_without_an_llm_call (both entry points fail closed with EmptySession and no LLM call once the rows are gone), stale_sessions_row_does_not_divert_the_write (a sessions row frozen on another project does not move the write out of the observations' project), hybrid_two_project_session_prompt_is_unchanged (a two-project session keeps today's exact prompt: every row of the session id is projected, the page lands in the majority project), streaming_projection_matches_the_frozen_base_projection and current_projection_matches_the_frozen_base_projection (the new paths agree field for field with a verbatim frozen copy of the pre-change projection.rs — an independent rule — at the 256/257/300 sample-cap edges and below), large_session_prompts_match_the_old_full_load_path (at 150k, 100k and 5k rows the streaming prompts are byte-identical to the frozen projection and both #[cfg(test)] full-load oracles, with the top-k heap asserted bounded by the selection cap and zero residue tuples while residue is off), auto_improve_review_uses_one_generation_of_the_session (a purge committed inside the review's single snapshot read cannot split the report's count from the prompt's), auto_improve_review_of_a_rowless_session_with_preflight_off (a present rowless session with zero minimums still gets its (none) review), zero_budget_streaming_path_keeps_the_old_no_budget_marker (the zero-budget early return reaches the streaming path byte-identically), and the byte-identical equivalence tests against the full-load oracles (below and above the cap, residue on/off, character-budget pruning, created_at ties, 16-KiB bodies, routing text, auto-improve at/above its 48/72 limits and preflight) STRONG — the LLM input is proven byte-identical to the pre-change full load, including against a frozen verbatim copy of the base projection; dropping the EXISTS predicate fails gated_reader_refuses_foreign_scopes; removing only the session predicate from the rowid fetch fails the store rowid_fetch_refuses_foreign_sessions_with_legitimate_control
1j Synthesized answer citations refer only to unambiguous evidence supplied in that request ai-memory-mcp/src/server.rs build_answer_request records path-to-PageId identity while rendering snippets; validate_answer_citations refuses unknown or ambiguous paths before returning any answer text query_answer.rs answer_rejects_a_citation_not_in_the_request, answer_rejects_a_citation_from_an_unqueried_project, answer_rejects_same_path_citations_across_scopes, answer_global_preferences_accept_unique_paths_and_refuse_collisions; controls: answer_true_with_provider_synthesizes_cited_answer, answer_deduplicates_citations_in_model_order_and_preserves_unicode; server.rs answer_sources_distinguish_repeated_rows_from_ambiguous_paths STRONG for source identity (the four refusal cases fail with the validator guard removed); generated claims and citation-free abstentions are not semantically verified
1k Budgeted answer chronology uses only retrieved IDs and same-scope session timestamps memory_query passes only authorized hit IDs to bounded answer_evidence_metadata; its session join checks workspace and project and never expands links; evidence priority is scoped Store answer_evidence_metadata_returns_only_requested_ids_without_expanding_links, answer_evidence_metadata_uses_session_time_only_in_the_same_scope; MCP answer_budget_uses_store_recency_without_reordering_retrieval_hits; unit answer_budget_unrelated_scopes_titles_and_equal_times_preserve_rank Adversarial requested-only and foreign-session controls; mutation results recorded in the PR
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
2c ID-selected managed scope remains authorized and invocation-bound scope.rs lookup_project_id_guarded checks the existing workspace/project pair, reserved-profile write policy and current access; workstream.rs project_candidates applies the same selector guard; router.rs pinned_managed_hook_scope checks the opt-in run flag, owner, active lease, harness, checkout and native session, then authorizes and atomically links before startup or capture; store link_native_session_in_transaction refuses a native session already captured under a different scope, agent or operator; project_registry.rs keys local bindings by server, scope, canonical checkout and repository/worktree fingerprints auth.rs managed_project_id_http_enforces_workspace_grants_and_candidate_privacy covers anonymous refusal, DB read/write grants, root control, missing/foreign workspace IDs, reserved profiles and hidden candidates; router.rs managed_project_id_pins_startup_and_capture_without_accepting_foreign_hooks covers legitimate startup/capture and wrong owner, cwd, agent, native session, foreign captured session, revoked grant and expired-run refusals; CLI managed_project_id_launch_reuses_binding_honors_override_and_refuses_old_server and registry isolation tests cover cache reuse, explicit override and old-server refusal; migration project_id_pinning_upgrade_preserves_runs_and_failed_prepare_rolls_back preserves legacy routing and rolls back a failed prepare. Removing the project-access, checkout or existing-native-scope guard fails its adversarial test; the reserved-profile test also failed before its guard was applied 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
3b Browser triage of pending writes (#855) ai-memory-web/src/routes/pending.rs require_admin (AuthLevel::authorize(Capability::Admin, distinguishes_operators), trusted-proxy flag from WebMountSpec) gates GET {web_slug}/pending; html_auth.rs AdminRequired keeps a non-root 403 off the change-password redirect; decisions post to the existing /admin/pending-writes/{id}/approve|reject behind require_dual_auth (session + CSRF) and require_root_for_multiuser_admin. ai-memory-web has no write route ai-memory-web tests/suite/pending.rs — anonymous refused (401, login redirect), DB user refused (403, no proposal text, no redirect), trusted-proxy flag reaches the gate, single-operator control admits, POSTs to /pending* refused, project filter keys do not collide on / in names, projects past the 500-row read cap stay counted and reachable; ai-memory-mcp tests/suite/admin_pending_writes_session.rs — anonymous and DB-user sessions refused, root session without a matching CSRF header refused (each leaves the proposal pending and no file), root approval keeps auto_improve_proposal_id/auto_improve_run_id and records the approver, root reject writes no file (each proven to fail with its guard removed); ai-memory-mcp admin.rs pending_write_approve_foreign_scope_returns_404 and pending_write_reject_foreign_scope_returns_404 — an id staged in workspace alpha requested through an existing default scope is 404 (never approved or rejected across the boundary), with the in-scope reject as the legitimate control (each proven to fail with 500 with the pending_detail guard removed, #1205) STRONG
3c Public human-auth routes refuse bodies a foreign page can send without a preflight (login CSRF, password guessing, root recovery) ai-memory-mcp/src/human_auth.rs handle_login / handle_recovery read their bodies by hand (to rate-limit first), so each checks declares_json_body before reading: a Content-Type other than application/json or application/*+json (parameters and case ignored), or none, → 415 before any password or recovery-token check and without charging the per-IP failure budget. text/plain, form-urlencoded and multipart are the only bodies a cross-site page can POST without a preflight, and /auth/* carries no CORS layer. The built-in login page, the docs/frontend-api.md examples and the recovery curl in docs/install.md send application/json human_auth.rs public_auth_routes_refuse_preflight_free_browser_bodies: valid root credentials and a valid recovery token, sent from a foreign origin as text/plain, form-urlencoded, multipart and with no content type, more times than the per-IP failure budget → 415, no session cookie; controls: a same-origin JSON login then succeeds (password unchanged, budget untouched) and a JSON recovery returns 204. json_body_declaration (header table) STRONG. Bite check: with the check removed, the text/plain login returns 200 with the session cookie (the pre-fix behaviour) and the test fails. /auth/password and /auth/logout were already closed: they run behind require_session, whose unsafe methods need the x-csrf-token header (a custom header, so preflighted), and /auth/password also uses axum Json
3d GET /admin/metrics is root-only on a multi-user server and content-free ai-memory-mcp/src/admin.rs mounts /admin/metrics inside the operational router under require_root_for_multiuser_admin (AuthLevel::authorize(Capability::Admin, distinguishes_operators)); ai-memory-mcp/src/metrics.rs render_prometheus writes only counts and durations under compile-time metric names and the closed label set result / outcome / kind / le; McpMetrics::record_tool_call takes only a read/write bit (no client name); ai-memory-core/src/latency.rs LatencyHistogram holds bucket counts and a sum, nothing keyed on a request; scope is never a label mcp integration::admin_metrics metrics_count_queries_and_hooks_without_leaking_any_content (secret-shaped strings planted in a memory_query query, a /hook prompt and the project name never appear in the scrape, nor do the session id, workspace name or root token; every label key is from the closed set; control: the query and hook histograms, the accepted-hook counter and the read tool-call counter move by exactly what was sent), metrics_are_root_only_on_a_multi_user_server (production require_dual_auth with a real DB-user key: anonymous 401, DB user 403, unknown bearer 401, root control 200); admin.rs multiuser_admin_routes_reject_db_user_tier / …reject_anonymous include the route, multiuser_operational_admin_routes_allow_root admits root STRONG. Bite checks: with the route mounted outside the gate the three refusal tests fail; with the query, the project name or the hook body rendered as a label value the leak test fails on each
3e The web health panel is root-only on a multi-user server, read-only and content-free ai-memory-web/src/routes/mod.rs require_admin (AuthLevel::authorize(Capability::Admin, distinguishes_operators), shared with /web/pending; html_auth.rs AdminRequired keeps a non-root 403 off the change-password redirect) gates GET {web_slug}/health, a GET-only route; routes/health.rs renders only counters, timestamps and configured provider/model labels, provider_line leaves out last_error_message (it can quote a response body), and the process side comes through health::HealthProbe as counts (ServeHealthProbe in ai-memory-cli/src/commands/serve.rs drops the journal's error text); the response is Cache-Control: private, no-store ai-memory-web tests/suite/health.rs — health_page_refuses_anonymous_once_operators_are_distinguished (401, login redirect on navigation, no counters or fix lines), health_page_refuses_a_db_user_and_admits_root (403 "Root access required", no redirect, no counters; root control 200), health_page_follows_the_admin_gate_on_a_single_operator_server (control), health_page_carries_no_secret_material (secret-shaped strings planted in a failed LLM call's and a failed embed's provider error body, a page body, a page title and the project name never appear), health_page_has_no_write_route (POST/PUT/DELETE 405), plus a fixture per rendered check (health_page_renders_each_failing_check_with_its_fix_line, health_page_renders_pending_spool_and_journal_checks, health_page_reports_a_healthy_server_as_passing, and src/health.rs unit tests for every check id) STRONG. Bite checks: with the require_admin call removed from the handler, the anonymous and DB-user tests fail; with last_error_message appended to the provider line, the planted-secret test fails
3f The 1.x token-management surface stays removed, and tokens it issued stay ordinary API keys (3.0) ai-memory-mcp/src/admin.rs mounts only GET /admin/users on that path and no /admin/users/{name}/expire, /revive or /rotate-token route; ai-memory-store migration V79__drop_legacy_user_token_columns.sql drops users.token_hash / token_expired_at and the V55 mirror triggers, with a guard that aborts the migration if the users rebuild would lose any resolving reference to a user (credentials, sessions, grants, authors); authentication reads only api_credentials (api_credentials.rs find_active_user_by_token_hash, revoked_at and expires_at honored) admin.rs removed_legacy_token_routes_are_gone_for_every_tier (production require_dual_auth; each removed route as root: 405 on POST /admin/users, 404 on the rest; as a DB user and as a legacy-token holder: 403 on POST /admin/users, 404 on the rest; anonymous 401; afterwards no user was created, no credential revoked, and the legacy token still authenticates), legacy_user_token_is_managed_as_an_api_key (an unprefixed legacy token authenticates as a non-root user, an expired one is 401, api-key list shows it as legacy-user-token, rotate retires the old secret, revoke refuses the new one); ai-memory-store api_credentials.rs v79_upgrade_keeps_legacy_tokens_as_api_keys (a V78 database seeded the 2.x way with active, expired and rotated tokens plus a web session: after V79 the active and rotated tokens authenticate, the expired and superseded ones do not, all three list as legacy-user-token, rotate/revoke work, the session survives, no FK violation) and v79_rolls_back_rather_than_cascade_delete_credentials (run with foreign keys on, V79 aborts and leaves the V78 schema and the token intact); ai-memory-cli removed_user_token_commands_no_longer_parse STRONG. Bite checks: with a stub POST /admin/users/{name}/expire route mounted the route test fails; without V79 the upgrade test and the schema pin fail; without the guard the rollback test fails
3g A Basic browser sign-in on a server without human accounts never persists the root bearer in a cookie ai-memory-mcp/src/human_auth.rs require_dual_auth accepts Basic (or an ai_memory_auth cookie an older build set) for GET only before human auth exists and sets no cookie on success; the browser resends Basic itself; expire_legacy_cookie_mw retires a leftover cookie once human auth is active; a request admitted this way carries ai_memory_core::LegacyBrowserAuth, which /web/pending reads to show CLI commands instead of decision buttons that would post and fail human_auth.rs a_basic_sign_in_mints_no_cookie_holding_the_root_bearer (no Set-Cookie carries the token, no ai_memory_auth is set; control: the Basic GET is served and the bearer still authenticates; bite-checked against the old cookie minting), legacy_browser_credentials_stop_when_human_bootstrap_completes (Basic and a leftover cookie both stop at bootstrap), only_a_legacy_browser_credential_is_marked_read_only (Basic and the leftover cookie are marked, a Basic POST is still 401; control: the root bearer is unmarked and its POST is served; bite-checked by removing the insertion); ai-memory-web pending_page_offers_cli_commands_instead_of_buttons_to_a_basic_browser (bite-checked) STRONG
3h Cross-project GET /admin/search (no workspace/project, the ai-memory search --global path, #1253) is root-only on a multi-user server ai-memory-mcp/src/admin.rs handle_search runs the no-scope branch through ReaderPool::search_pages_with_meta as OPERATOR (every project, each hit tagged with its workspace and project); the route sits in the operational router under require_root_for_multiuser_admin (AuthLevel::authorize(Capability::Admin, distinguishes_operators)), so a DB user or proxy-asserted user never reaches the unfiltered read. A partial scope is still a 400, never a silent global fallback. ai-memory-cli/src/commands/search.rs sends no scope only when --global is passed, and clap rejects --global with --workspace/--project MCP admin_status_search.rs global_search_never_reaches_a_non_root_caller (a restricted project the user holds no grant on, for both a DB-user deployment and a trusted-proxy deployment with no users rows: user 403 and anonymous 401 with neither the sentinel path nor the query term in the body; root control 200 with both projects' hits), global_search_tags_each_hit_with_its_workspace_and_project, search_rejects_partial_scope_instead_of_global_fallback; the shared admin.rs all-admin 403/401 route matrix includes /admin/search; CLI cli.rs search_global_parses_and_conflicts_with_an_explicit_scope STRONG. Bite check: with the gate's operator test forced off (authorize(Capability::Admin, false)) the refusal test fails on the DB-user case (200 instead of 403)
3i Cross-project GET /admin/recent (no workspace/project, the ai-memory recent --global path) is root-only on a multi-user server ai-memory-mcp/src/admin.rs handle_recent runs the no-scope branch through ReaderPool::recent_pages_global as OPERATOR (every project, each hit tagged with its workspace and project); the route sits in the operational router under require_root_for_multiuser_admin (AuthLevel::authorize(Capability::Admin, distinguishes_operators)), so a DB user or proxy-asserted user never reaches the unfiltered read. A partial scope is still a 400, never a silent global fallback; an unknown scoped project is a 404 and does not leak another project's pages. ai-memory-cli/src/commands/recent.rs sends no scope only when --global is passed, and clap rejects --global with --workspace/--project MCP admin_status_search.rs global_recent_never_reaches_a_non_root_caller (a restricted project the user holds no grant on, for both a DB-user deployment and a trusted-proxy deployment with no users rows: user 403 and anonymous 401 with neither the sentinel path nor the restricted snippet in the body; root control 200 with both projects' hits), global_recent_tags_each_hit_with_its_workspace_and_project, recent_rejects_partial_scope_instead_of_global_fallback, recent_unknown_scope_is_404_and_does_not_leak_other_projects; the shared admin.rs all-admin 403/401 route matrix includes /admin/recent; CLI cli.rs recent_global_parses_and_conflicts_with_an_explicit_scope STRONG. Bite check: with the gate's operator test forced off (authorize(Capability::Admin, false)) the refusal test fails on the DB-user case (200 instead of 403)
3j The managed-workstream web overview is root-only, bounded, read-only, and does not weaken checkout-local discovery ai-memory-web/src/routes/workstreams.rs gates the cross-scope aggregate with the shared require_admin capability check and requests at most 101 rows; ai-memory-store/src/workstream.rs list_operational pages workstreams before joining current harness links, derives state only from run state/lease/exit and event count, and returns no cwd, repository/worktree fingerprint, lease owner, native session id, source id, metadata, segment path, or transcript content; the existing fingerprint-scoped list_recent path used by resume is unchanged ai-memory-web tests/suite/workstreams.rs — anonymous and DB users are refused once operators are distinguished, root and single-user controls are admitted, hostile names render escaped, lifecycle state and attention ordering are visible, sensitive host/native/transcript sentinels are absent, and responses are no-store; ai-memory-store operational_status_uses_only_trusted_lifecycle_fields covers active, stale, expired, signal/nonzero exit, successful evidence, and empty rows STRONG
4 Handoff single-claim / no-steal ai-memory-store/src/ops.rs accept_handoff_in_transaction (metadata state='open' guard + atomic CAS; the receiver-session check, which requires the receiving session to exist in the claim's own workspace, project and agent kind and refuses with InvalidState before the handoff row is touched; an ended receiver is final EXCEPT for the agents where AgentKind::reuses_session_id_after_end() holds — Grok and Kimi Code, whose harnesses reuse the native session id across SessionEnd→resume, so accepting reopens ended_at only after the claim-once guard) multi_session.rs a_second_accept_cannot_steal_an_accepted_handoff; handoff_ownership.rs another_operator_cannot_claim_the_handoff; multi_session.rs handoff_accept_rejects_foreign_or_missing_receiver_session (receivers from a sibling project, another workspace, a different agent kind, and a nonexistent session are each refused as InvalidState with the handoff left open and every accepted_* column NULL; the matching receiver claims it; the same receiver retrying and a second matching session get false with the first claim intact; fails with the project_id or agent_kind predicate, or the missing-session refusal, removed. The workspace_id predicate is redundant defence in depth: project ids are globally unique, so the cross-workspace receiver is already caught by project_id); multi_session.rs accept_reopens_an_ended_receiver_session_but_keeps_claim_once (Grok reopen + no-steal) and accept_reopens_an_ended_kimi_receiver_but_keeps_every_guard (Kimi Code resume claims and reopens ended_at; adversarial controls: an ended claude-code receiver stays refused, a kimi-code receiver in another project stays refused, and the already-claimed guard still refuses the resumed kimi session a second baton); router a_resumed_ended_session_still_gets_its_session_start_context (the session-start caller, fetch_and_accept_handoff_at, treats a refused claim as no claim: the ended claude-code receiver still gets the rest of its on-start context, and the baton stays open) STRONG
4b Handoff owner-scoped recovery (any_owner admin gate) ai-memory-mcp/src/server.rs require_admin_capability on memory_handoff_accept/_cancel any_owner handoff_admission.rs — cancel gate + accept gate (adversarial: non-admin any_owner accept refused) STRONG
4c Turn-checkpoint baton is owner+scope-bound ai-memory-store/src/ops.rs checkpoint_session_handoff — reads the session's own (workspace, project, owner_user) from sessions WHERE id=?1 AND ended_at IS NULL, refuses on scope/owner mismatch, refreshes only that session's own state='open' baton (id preserved), returns None when the session already ended ops.rs checkpoint_session_handoff_refreshes_only_the_live_sessions_own_baton (#865); router.rs antigravity_parallel_conversations_keep_owned_batons_claimed_once (Antigravity checkpoints of two operators each stamp their own owner and reach only that operator), antigravity_stop_checkpoint_requires_a_finished_idle_root_unmanaged_stop (a busy, cancelled, failed, reasonless, subagent, managed or non-Antigravity Stop publishes nothing; the finished NO_TOOL_CALL/model_stop controls do) STRONG; router.rs antigravity_lifecycle_only_turn_keeps_conversation_open_and_handoff_claimed (a turn checkpoint never ends a session: one with nothing captured only completes its ingest key, so the handoff it claimed at start is never reopened for a second receiver)
4d Native session rebind / drifted-end is owner+agent+cwd CAS ai-memory-store/src/ops.rs — session.moved rebind gated on agent==OpenCode + ended_at IS NULL + lexical normalize_cwd(stored)==normalize_cwd(from); expire_same_cwd_auto_handoffs AND-gated on owner_user IS ?4 AND id IS NOT ?5 and on the source not being another still-open session (row 4e, #883); drifted SessionEnd ends only same owner+agent+cwd ops.rs native_move_rebinds_live_session_only_from_its_current_cwd, native_move_rejects_foreign_owner_and_ignores_completed_replay, drifted_session_end_ends_only_the_same_actor_agent_and_cwd (#865) STRONG
4e A live session's baton stays its own until the session is quiet ai-memory-store/src/ops.rs - expire_same_cwd_auto_handoffs spares batons of other open sessions; accept_handoff_in_transaction(.., busy_since) re-checks inside the claim that the source is not an open session with observations after the cutoff, and its sweep expire_superseded_auto_handoffs(.., busy_since) spares a busy open session's baton (every open session's when None, the explicit MCP accept); reader.rs startup_handoff selects with the same cutoff; ai-memory-hooks/src/router.rs LIVE_BATON_QUIET_PERIOD multi_session.rs parallel_live_sessions_keep_their_own_checkpoint_batons, startup_claim_rechecks_the_source_and_sweeps_only_quiet_open_batons; router.rs opencode_parallel_live_batons_are_owned_and_wait_for_quiet, antigravity_parallel_conversations_keep_owned_batons_claimed_once (Antigravity conversations never end, so every one holds a live baton: none is handed over while busy, a claim supersedes only the claimer's own older quiet baton, and each is claimed once) - each fails with its guard removed STRONG
4f Finalize-on-exit closes only a session the run provably owns (invariant #16) ai-memory-cli/src/commands/run.rs finalize_hookless_session runs only for harness.lacks_session_end_hook() harnesses (Command Code, Kiro v2/v3, Antigravity); own_native_session returns a session only when it is named, chosen before the spawn, or linked under this run's own id in this checkout — a merely discovered native session (possibly a concurrent launch's) is never finalized run.rs a_session_linked_during_the_run_wins_over_discovery — own_native_session returns None for the unlinked and other-checkout (nested) cases, so a foreign/concurrent session is refused; the named/linked control is finalized (#944) STRONG
4g memory_handoff_accept status never points a caller at another session's baton ai-memory-store/src/reader.rs handoff_claimed_by_live_session — the caller-supplied session id (header or native _meta, routing-only per row 6b) selects which claim to check, but the answer is bounded by the resolved (workspace_id, project_id), the authenticated handoff_owner_sql owner filter, state='accepted', and a still-open receiving session; ai-memory-mcp/src/server.rs unclaimed_handoff reports consumed_by_hook only on that match (and, for a requested handoff_id, only when it is the matched row), none_pending otherwise handoff_ownership.rs a_session_start_claim_is_confirmed_only_to_its_own_live_session (forged session id under another operator, unattributed reader, foreign project, sibling session and ended session all empty; owner and root controls see the claim); ai-memory-mcp tests/suite/handoff_identity.rs consumed_by_hook_is_reported_only_to_the_session_that_claimed_it (over the production transport: a colleague forwarding the session id, the owner from another session, and a request with no session id all get none_pending; the claiming session gets consumed_by_hook) STRONG
4h Offer-mode SessionStart never consumes or injects handoff-controlled text ai-memory-hooks/src/router.rs fetch_and_accept_handoff_at branches on the startup configuration before admission/claim and render_handoff_notice emits only typed metadata (HandoffId, AgentKind, computed age); the normal writer CAS remains the only later claim path router.rs handoff_notice_is_metadata_only_and_never_carries_the_summary plants hostile summary/questions/steps/files; offer_mode_leaves_the_baton_open_and_notice_omits_the_summary exercises the production hook route, asserts the row remains open, then proves the legitimate exact-id writer claim still consumes it (#1030) STRONG
4i The compaction recap reads one session's own captured text and never writes or claims ai-memory-hooks/src/recap.rs handle_recap/build_recap — anchored on the session row (session_project_ids), then grants::authorize_resolved(.., ProjectAccess::Read) on that project, whose refusal answers exactly like an unknown id (200 with the no-session notice: no 403, no project name), and session_summary_scoped with the /handoff owner filter (User(key) or Unattributed), so another operator's session answers like an unknown id; open handoffs are read with list_handoffs under the same owner filter and never claimed; nothing is written (no claim, active-project publish, observation, or page); stored text is rendered inside the untrusted-history fence with its markers escaped (escape_untrusted_history_markers) recap.rs recap_returns_the_window_and_writes_nothing (the handoff stays open and the session's row count is unchanged), another_operator_cannot_read_an_owned_session (owner control: owner_reads_own_session), db_user_without_grant_reads_a_session_as_unknown (no status, project name or prompt text gives the refusal away; control: a read grant restores it); through the production require_bearer with real aim_ tokens, ai-memory-mcp/tests/suite/recap_identity.rs a_db_user_cannot_read_another_users_session_through_the_middleware (owner control), an_unattributed_caller_cannot_read_an_owned_session (control: an unowned session stays readable) and a_db_user_without_a_grant_reads_their_own_restricted_session_as_unknown (control: a read grant), recap_for_unknown_session_is_a_notice, fence_markers_in_stored_text_are_escaped STRONG
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, OMP or Grok (row 4q) 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
4q A Grok subagent session never claims a handoff or leaves one behind ai-memory-cli/src/commands/hook.rs claims Grok's handoff on PostToolUse only for a payload without a subagent marker (subagent_payload), and ai-memory-hooks/src/router.rs SessionEnd child_session closes and summarizes a Grok end whose body carries subagentType (payload.rs body_is_subagent) without a baton. Grok runs a subagent in a session of its own and stamps subagentType on its events, its SessionEnd included (HookPayload::SessionEnd in xai-grok-hooks event.rs); the main session never carries it, and SessionStart does not fire for a subagent hook.rs grok_post_tool_skips_a_subagent_payload (a marked tool result never requests /handoff); router grok_subagent_session_end_closes_and_summarizes_without_baton (a marked Grok end leaves no baton; control: a top-level Grok session in the same project still leaves one). 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 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 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-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
7 Sanitizer trust boundary (invariant #6) ai-memory-core/src/sanitize.rs Sanitized<T> (private field, only sanitize() ctor); Sanitized::new scrubs the title before the 80-char display cap; ai-memory-mcp/src/server.rs sanitize_feedback_reason scrubs the reason before the 500-char cap; ai-memory-hooks/src/router.rs durable_body scrubs the full excerpt before the per-event body caps (payload::durable_body_cap), which no longer run at excerpt extraction; ai-memory-hooks/src/payload.rs cap_object_fields scrubs with the built-in sanitizer before the client spool cap; WriterHandle::insert_observation requires Sanitized; ops crate-private; Sanitizer::scrub matches each pattern through invisible formatting characters (a Shadow copy without Default_Ignorable_Code_Point characters, each match mapped back to its original span) and stores non-matching text byte for byte, strip_control removes stray tag characters (an emoji flag's tag run is kept), a non-leading U+FEFF and U+2061–2064, the private-key rules run first and cover PGP armor and a block with no end line once a key-body line follows the header, the allowlist never exempts private_key and ignores blank entries (ai-memory-cli/src/config.rs drop_blank_sanitize_allowlist_entries drops and warns at load); companions/ai-memory-client/src/scrub.rs sanitize_external_text mirrors the invisible-character, hidden-text and key rules Structural (compile-time) + store/src/lib.rs insert_observation_boundary_scrubs_before_disk + sanitizer scrub unit tests + ai-memory-core::sanitize title_is_scrubbed_before_the_80_char_cap_runs + ai-memory-hooks::router issue_980_user_prompt_title_is_sanitized_before_truncated (a secret straddling the 80-char boundary is redacted, not stored truncated; #980) + ai-memory-mcp::server feedback_reason_is_scrubbed_before_the_500_char_cap (#1109) + ai-memory-hooks::router issue_1114_user_prompt_body_is_sanitized_before_the_16kib_cap, issue_1114_post_compaction_body_is_sanitized_before_the_16kib_cap, issue_1114_tool_body_is_sanitized_before_the_2kb_cap, tool_body_cap_keeps_the_utf8_boundary + ai-memory-hooks::payload client_body_cap_scrubs_before_truncating (each places a secret straddling the cap and asserts a [REDACTED:…] marker survives with no raw fragment; #1114) + ai-memory-core::sanitize shared_sanitizer_vectors_hold (credentials split by each invisible-character family, complete, PGP and end-line-less key blocks, and controls that must stay byte-identical: emoji ZWJ sequences, keycaps, a subdivision flag, Persian ZWNJ, Indic ZWJ, Thai ZWSP, Hebrew RLM, a soft hyphen, prose and code naming a key header; the same tests/fixtures/sanitizer_vectors.json drives ai-memory-client shared_sanitizer_vectors_hold), invisible_character_inside_an_operator_pattern_match_is_redacted, invisible_characters_neither_break_nor_bypass_the_allowlist, characters_that_hide_text_are_stripped, pgp_private_key_block_is_redacted, private_key_block_without_an_end_line_is_redacted, key_rules_run_before_token_rules_can_split_a_key_body, allowlist_never_exempts_a_private_key, blank_allowlist_entries_are_ignored + ai-memory-hooks::router user_prompt_secret_split_by_an_invisible_character_is_redacted + ai-memory-cli::config config_load_drops_blank_sanitize_allowlist_entries + ai-memory-client characters_that_hide_text_or_split_a_credential_are_removed (GHSA-jpcg-w5c5-wcv6) STRONG (structural)
7a Eval observations: server provenance and reason privacy ai-memory-consolidate/src/auto_improve.rs constructs private results from the existing execution, ignores extra model/scorer result fields and all eval results on report deserialization, hashes the evaluated request/bodies, and scrubs reasons before the 2,048-character cap and pending persistence; changed bodies cannot receive the earlier result auto_improve::tests::structured_eval_records_server_observation; tests/suite/eval_results.rs eval_reason_is_sanitized_before_pending_storage_with_legitimate_control attempts forged deserialized reports and IDs/digests and malicious reasons with secrets/control characters, checks report and stored evidence before sidecar rendering, and preserves a legitimate reason and external evidence without independent results; fails with reason scrubbing or the report deserialization guard removed STRONG
7b New public page metadata is bounded and cannot supply scope, author or admission controls; admin kind retains its legacy adapter ai-memory-core/src/page.rs PageWriteMetadata::into_frontmatter; MCP validates all four fields; admin consumes legacy kind explicitly and shares entities/abstract/relations validation before scope creation; both use Wiki::write_page for sanitization/admission/authenticated attribution admin_write_page.rs write_page_metadata_rejects_invalid_payload_before_scope_creation (invalid shapes, unknown relation kinds, raw-input over-limit values, untrimmed relation scopes and escaping paths refused; legitimate control admitted), write_page_metadata_preserves_admin_auth_and_sanitization (anonymous/DB-user refused, root control admitted with scrubbed metadata and authenticated attribution); server.rs memory_write_page_metadata_rejects_invalid_before_scope_creation, memory_write_page_metadata_preserves_scope_author_and_sanitization (foreign user denied; writer control admitted, forged frontmatter/author ignored, secrets scrubbed, invalid rewrite leaves disk and SQL latest unchanged); core page_write_metadata_scope_components_refuse_surrounding_whitespace and page_write_metadata_limits_apply_before_trimming_and_normalization; admin write_page_metadata_admin_legacy_kind_matches_base compares long/control-character kind behavior with the base adapter; entity-bound refusal bite-checked with its validation removed STRONG
7c A compaction checkpoint cannot bypass consolidate admission by deferring its provider rewrite (#1229) ai-memory-hooks/src/router.rs write_checkpoint_page gives the PreCompact / PostCompaction rule-based write the consolidate admission operation whenever a consolidator is configured, and process_authorized queues the durable rewrite only after that write succeeds; the worker's rewrite runs admission again through Consolidator::consolidate_session router.rs checkpoint_admission_refusal_writes_no_page_and_queues_no_rewrite (a policy refusing consolidate leaves no page and no queued job; control: a policy gating only handoff_begin writes the page and queues the job), checkpoint_preserves_the_consolidate_admission_operation (the hook path sends exactly one consolidate admission call and never calls the provider); both bite-checked with the admission context removed STRONG
7d The Cursor Agent CLI child, which reads captured session text, never sees the server's own credentials ai-memory-llm/src/cursor_agent.rs complete_text spawns agent with env_clear() plus CursorAuth::child_env, which CursorAuth::new filters through cursor_child_env (an allowlist of PATH/HOME/user, locale, temp/XDG, session bus, proxy/CA and Windows basics, plus LC_*/CURSOR_*); the environment and the workspace root are captured once by ai-memory-cli/src/config.rs Config::cursor_auth, so the provider reads no environment itself; a relative workspace root is refused cursor_provider.rs the_child_gets_only_the_allowlisted_environment (AI_MEMORY_AUTH_TOKEN and OPENAI_API_KEY canaries and the test process's own CARGO_* variables never reach the child; control: PATH, HOME and CURSOR_API_KEY do, and the workspace sits under the injected root; bite-checked by dropping env_clear()), a_relative_workspace_root_is_refused; config.rs cursor_provider_hands_the_child_only_allowlisted_env STRONG
7e Executable auto-improvement eval policy is server-owned ai-memory-mcp/src/admin.rs retains the legacy request eval key only as a rejected compatibility field and builds AutoImproveReviewConfig.eval exclusively from AdminState; ai-memory-cli/src/commands/auto_improve.rs sends no executable policy over HTTP MCP auto_improve_admin_refuses_request_eval_and_inherits_server_defaults sends a request-controlled program path and receives 422, then omits the field and proves the configured server gate still runs STRONG
7f Remote authentication and provider error bodies cannot inject terminal controls or expose recognizable secrets at the display cap ai-memory-llm/src/response.rs provider_error_body bounds the network read to 1 MiB, applies the built-in sanitizer to the complete bounded body, then caps terminal output to 1 KiB; every LLM provider and every failure branch in ai-memory-cli/src/commands/auth.rs uses that helper response.rs provider_error_body_redacts_a_secret_straddling_the_display_cut, provider_error_body_strips_terminal_control_sequences, and provider_error_body_caps_what_it_reads_and_what_it_shows (legitimate prefix/control preserved while secrets and controls are removed) STRONG
7g A malformed auth.json OAuth entry never echoes a stored value in its parse error ai-memory-llm/src/auth_file.rs load_entry builds the error for a failed entry from a copy whose string values redact_strings has replaced with <redacted>, so serde's quoted offending value is never a stored one; the OpenAI OAuth, OIDC device and Copilot token loaders all read through it auth_file.rs wrong_type_error_does_not_echo_the_stored_value (a token in expires is absent from the message, which still says invalid type: string) with the control missing_field_error_still_names_the_field STRONG
8a Messaging: recipient-only visibility ai-memory-store/src/ops.rs pop target-select + reader.rs list_messages (to_* predicate) agent_messages.rs a_message_is_only_visible_to_its_recipient; agent_messages_tools.rs non-recipient cannot pop STRONG
8b Messaging: cancel-own-only ai-memory-store/src/ops.rs cancel_messages (AND-gated on from_* sender coordinate) agent_messages.rs — whole-outbox and a foreign specific-id cancel refused STRONG
8c Messaging: pop-exactly-once ai-memory-store/src/ops.rs pop_message_in_transaction atomic CAS WHERE state='pending' agent_messages.rs — sequential and tokio::join! concurrent double-pop yields exactly one Some STRONG
8d Messaging: an inferred scope never changes a queue; a read names it (#854) scope.rs ScopeSource::is_inferred; ai-memory-mcp/src/server.rs refuse_inferred_message_scope, called by memory_message_pop and memory_message_cancel (mailbox scope) and memory_message_send (sender scope) before admission or any writer call, so a shared_slot/startup_seed/default/default_after_mismatch scope is refused with nothing claimed, cancelled, or delivered; inferred_scope_hint on every inferred memory_message_list (inbox and outbox, empty or not); the SessionStart notice (ai-memory-hooks/src/router.rs render_inbox_notice) and memory_briefing scope name the inbox from server-side names only agent_messages_scope.rs unscoped_pop_from_the_shared_slot_is_refused_and_claims_nothing, unscoped_cancel_from_the_shared_slot_is_refused_and_the_outbox_survives, unscoped_send_from_the_shared_slot_is_refused_and_explicit_sender_is_stamped (each with the shared slot on another project; session-bound and explicit callers as controls; each fails with the guard removed), unscoped_list_names_the_mailbox_it_read_even_when_not_empty; agent_messages_briefing.rs no_scope_pop_is_refused_and_the_briefing_names_the_inbox_to_pop, no_scope_inbox_list_that_misses_the_mail_names_the_inferred_scope; router session_start_notice_surfaces_pending_mail_without_consuming_it (names the inbox, carries no message text) STRONG
8e Messaging: admission is the same for MCP and admin sends (#756) ai-memory-mcp/src/admin.rs handle_send_message runs Wiki::authorize_operation(.., AdmissionOp::MessageSend, ..) at the recipient scope before insert_message (a refusal is 403 and stores nothing) and calls notify_operation_observers only after a successful commit; skipping webhooks needs Capability::SkipAdmissionChain (skip_webhooks_for_admin_request); the MCP path is server.rs memory_message_send admin.rs admin_message_send_reject_leaves_inbox_empty (a rejecting webhook gets 403 and an empty inbox; fails with the admission call removed), controls admin_message_send_observer_sees_commit_without_blocking_response and admin_message_send_full_inbox_does_not_notify_observer STRONG
8f Messaging: the web mailbox shows a restricted sender's name and a card's count only to a reader of that repository; it never consumes mail ai-memory-store/src/reader.rs list_inbox_with_senders (readable_repository_predicate("sp.id", viewer) on the sender join, so the name is NULL for an unreadable sender) and pending_inbox_counts (readable_repository_predicate("p.id", viewer)); ai-memory-web/src/routes/project.rs mailbox is list-only, no pop/cancel route exists, and mailbox_scope matches the URL's exact project name (as list_pages does), so an alias never shows another project's mail routes.rs web_mailbox_hides_restricted_sender_names_and_cards (a granted reader of the recipient is shown "a project you cannot read", the restricted sender's name and card never reach the grid, alice as the control; fails with either predicate removed), web_mailbox_lists_only_this_projects_inbox_and_never_consumes_it (sender and bystander pages show nothing of the recipient's mail, a POST is 405 and the message is still pending, the body is HTML-escaped), web_mailbox_does_not_follow_a_project_alias (a legacy key that resolves to acme-api shows none of its mail on /w/default/api; acme-api itself is the control) STRONG
8g Messaging: a measured epistemic tag cannot be stored without evidence (#1428) MCP and admin sends scrub and cap evidence, reject blank evidence with evidence_required, and ai-memory-store/src/ops.rs repeats the invariant at the persistence boundary; V90 leaves old rows nullable and readers surface them as unknown agent_messages_tools.rs measured_send_requires_evidence_but_inferred_does_not; store agent_messages.rs measured_messages_require_evidence_at_the_store_boundary and pre_tag_rows_read_as_unknown_without_evidence STRONG
9 Scope resolution fail-closed ai-memory-store/src/scope.rs no-create lookup_existing_*; identity-aware lookup accepts exact/canonical/v2-basename keys only when they deduplicate to one UUID; ops.rs resolve_project_name_for_write performs write authorization, optional name-only promotion, and audit in one writer transaction; create only via create_explicit_scope; ops.rs get_or_create_project_as — the capture and managed-run creator path — consults the same coordinate lookup before inserting, so a name a promoted project still answers to (its legacy_name or canonical_name) reuses that row, an ambiguous name is refused, and no twin is minted under a key the read path already resolves (the lookup is skipped only while the schema predates V76, via project_coordinates::supports_coordinates). The admin destructive project routes (admin.rs resolve_target_for_admin, used by purge-project / rename-project / move-project / merge-project) accept a bare project_id as an alternative to the name: it is parsed to a UUID (400 on a malformed one), looked up within the workspace the request named via ReaderPool::project_name_by_id (404 when it names no row there, so a real id from another workspace is refused rather than resolved), and the two spellings are mutually exclusive (both or neither is a 400). list-projects carries the id in each row, and inherits the same row-level visibility filter as the name, so a restricted project leaks neither. ProjectNameAmbiguous refuses cross-forge/multi-candidate keys before mutation; its message names each holder and the key it matched by, but a restricted holder only as "a restricted project", because the lookup runs before any caller is authorized and the project list hides restricted names from callers without a grant; an audit failure after the name UPDATE rolls the transaction back. V76's derived-key indexes bound hot lookup to exact/canonical/legacy equality probes with at most four rows. Promoting public APIs return ResolvedWriteScope metadata (no untraced promotion API); MCP, admin, and managed-workstream write entry points make Wiki refresh/checkpoint the committed scope manifest after promotion and surface manifest_warning on success or any later operation failure; pure managed-run input validation precedes promotion. A managed run whose project is the name its checkout's git remote derives (PrepareManagedRunRequest.repository_identity, accepted only through accept_wire_identity and only when path_style_name equals the requested name) resolves through resolve_project_by_identity_for_capture — the identity holder, else the cwd-prefix project with $HOME excluded, claimed or renamed only for a writer — and then authorize_scope_for(Write) on the writer connection, so an identity can neither redirect a differently named run nor open, claim, or create a project the caller may not write; Project manifests persist the typed full identity/source and derived keys so clean reindex restores the same UUID and lookup behavior. Also ai-memory-hooks/src/router.rs workspace_override_is_rescope — the hook router's session-sticky gate resolves a marker's workspace override via this same no-create lookup_existing_workspace (never a hand-rolled lookup) and fails closed (treats it as a rescope, disqualifying sticky) on a different or unresolvable workspace; only an override that resolves to the session's OWN workspace is not a rescope (#976) scope.rs read_resolution_table_driven, multi_scope_resolution_deduplicates_and_validates, identity_resolution.rs a_capture_naming_a_promoted_projects_legacy_key_reuses_it (a capture naming the promoted project's legacy key lands in it, creates nothing and leaves the name resolvable), a_capture_of_an_existing_exact_name_still_lands_there, a_capture_of_a_new_name_still_creates_its_project (controls: the fallback runs only after the exact-name miss and still records the creator), hooks two_api_checkouts_with_different_remotes_get_two_projects (an identity-less capture under a key two projects claim refuses and creates nothing; a fresh folder-named capture still creates its project as the control), a_slashed_label_reaches_only_a_project_the_caller_may_use (a workspace/project label passed as the project is authorized as the pair it names and creates nothing when refused; granted control), a_slashed_write_resolves_its_own_pair_and_never_creates, an_existing_slashed_project_wins_over_the_split, no-auto-create + unscoped_write_with_unresolvable_coordinate_errors; dual_key_scope.rs page_write_failure_after_promotion_preserves_manifest_warning, handoff_failure_after_promotion_preserves_manifest_warning; workstream.rs managed_run_rejects_mutually_exclusive_selection_before_promotion, managed_run_downstream_failure_after_promotion_preserves_manifest_warning; identity_resolution.rs canonical_and_legacy_reads_resolve_one_legacy_row_without_renaming, authorized_write_promotes_in_place_and_preserves_dependents_and_legacy_lookup, read_only_user_cannot_promote_a_legacy_name, canonical_target_conflict_rolls_back_the_promotion, audit_failure_rolls_back_promotion_and_keeps_the_writer_alive, exact_name_that_is_another_forges_canonical_key_fails_closed, an_ambiguous_name_names_its_holders_but_not_a_restricted_one (restricted holder unnamed; open holder named as the control), concurrent_legacy_and_canonical_resolve_or_create_converge_on_one_uuid; admin admin_purge.rs purge_project_refuses_a_real_id_from_another_workspace (a row that really exists in another workspace answers 404 from default and is left intact), admin_rename/admin_move rename_project_refuses_a_real_id_from_another_workspace / move_project_refuses_a_real_id_from_another_workspace (the same for rename and move, the foreign project keeps its name and workspace, with the same id accepted from its own workspace as the control), purge_project_still_refuses_an_ambiguous_name_by_default (a name held by two rows -- one via its legacy_name -- stays a 400 and purges nothing), purge_project_by_id_reaches_the_twin_and_leaves_the_name_holder_intact (legitimate control: the id reaches the row the name could not, and the name-holder survives with its name), and store list_projects_with_stats_hides_a_restricted_projects_id_from_an_ungranted_viewer (the id is absent exactly where the name is, for an ungranted viewer, and present for the operator -- bite-checked with the visibility filter removed); project_coordinates.rs shared_candidate_query_deduplicates_before_bound_and_uses_only_indexes; wiki promoted_identity_round_trips_through_manifest_and_clean_reindex, old_project_manifest_without_identity_still_reindexes, reindex_rejects_project_coordinate_fields_that_do_not_match_identity; admin write_page_surfaces_manifest_failure_after_promotion, bootstrap_surfaces_manifest_failure_after_promotion, move_project_merge_surfaces_destination_promotion_manifest_warning, move_session_create_surfaces_destination_promotion_manifest_warning; multi_session.rs two_operators_promote_two_clone_keys_to_one_uuid_without_moving_active_pointers; MCP dual_key_scope.rs; hooks workstream.rs managed_run_by_remote_identity_claims_the_folder_named_project, managed_run_by_remote_identity_routes_past_an_identityless_twin (name-only control is ambiguous), managed_run_identity_never_redirects_another_project_name, managed_run_by_remote_identity_refuses_a_viewer_without_write (outsider refused with no project created; granted member admitted as the control), managed_run_identity_never_claims_a_restricted_legacy_project (an outsider whose cwd sits in a restricted identity-less project is refused, the identity stays unrecorded and no twin appears; fails with either the writer's claim check or the route's write check removed; a granted member claims it as the control), managed_run_identity_routing_stays_inside_the_requested_workspace, concurrent_identity_runs_on_a_legacy_project_converge_on_it (invariant #16), managed_run_promotion_refreshes_the_scope_manifest, managed_run_discloses_manifest_failure_after_committed_promotion static read/write/authz/cross-workspace/cross-forge cases; router.rs workspace_override_is_rescope_only_on_a_genuine_workspace_change (same/different/unresolvable workspace cases), sticky_routing_keeps_the_session_project_across_a_sibling_checkout (regression: same workspace forwarded on every event + project_src=repo-root from a nested checkout stays sticky), sticky_routing_still_rescopes_when_marker_names_a_different_workspace_mid_session (opposite direction: a genuinely different workspace still rescopes even under sticky) STRONG
10 Destructive-op live-process refusal + confirm flags (invariant #9); purge-project's dry_run always wins over confirm so a preview request can never become destructive; an explicitly empty or whitespace-only CLI scope flag cannot silently select the checkout ai-memory-cli/src/commands/process_guard.rs sibling_processes + confirm flags in reset/restore/reindex/uninstall --purge-data/purge_project; admin.rs handle_purge_project checks req.dry_run unconditionally, before req.confirm, mirroring reclaim-ledger-versions; ai-memory-cli/src/commands/mod.rs resolve_scope_noting_marker_project, resolve_scope_with_marker, and resolve_workspace call commands::refuse_empty_explicit at the shared choke point before resolution or HTTP admin_purge.rs confirm→400; removal.rs — injected live-sibling makes each destructive command bail before touching the data dir; uninstall.rs purge_guard_refuses_a_live_sibling_before_stopping_the_service — uninstall --purge-data checks for siblings (the setup service's own pid excepted) before it stops that service, and purge_guard_rechecks_after_stopping_the_service refuses when the stopped service is still alive; admin_purge.rs purge_project_confirm_true_and_dry_run_true_still_only_previews — {"confirm": true, "dry_run": true} deletes nothing (the regression this row now also covers); ops.rs purge_project_dry_run_changes_nothing — every project-scoped row count, the purged_scopes tombstone, and the audit_log row are identical before/after a PurgeMode::Preview run; ops.rs purge_project_counts_collateral_damage_in_another_project and admin_purge.rs purge_project_dry_run_and_confirmed_purge_both_report_collateral_damage_in_another_project — a purge of project P collaterally deletes an observation, and orphans a handoff's session reference, in a different project Q (via sessions cascading out of P), and both the preview and the confirmed report count it; CLI commands::tests::resolve_scope_and_workspace_refuse_empty_and_whitespace_flags and tests/suite/marker_scope.rs restore_page_refuses_empty_scope_flags_without_sending_a_mutation refuse empty and whitespace-only --workspace/--project with no POST; omitted, partially explicit and fully explicit scopes reach only the expected target as controls. Without the guard, the shipped binary sends the restore to the marker scope and the test fails STRONG
10a Same-workspace project merge preserves both identities' data and fails closed on stale or live input ai-memory-store::merge_project validates source and target ids against the named workspace, checks the complete source/target latest-page plan, refuses open sessions and unexpired managed leases, re-stamps/coalesces every project-keyed table in one writer transaction, creates a combined version for each page collision, and deletes the source row last. Page-id keyed embeddings/evidence/access/links follow unchanged. Wiki::merge_project holds the mutation lock, snapshots the target tree, parks the source, installs files before SQL and restores both trees on refusal. /admin/merge-project remains root-only and resolves optional ids inside the named workspace; retained version restore verifies the exact target scope/path before writing store merge_project_preserves_both_page_histories_and_dependent_rows, merge_project_refuses_open_sessions_and_foreign_project_ids, merge_project_preserves_colliding_workstreams; admin merge_project_dry_run_then_preserves_history_and_sessions (also restores the retained source version), merge_project_refuses_open_sessions_and_foreign_ids, concurrent_project_merges_have_one_winner_without_losing_the_page STRONG
10b Session purge is scope+owner-bound (no cross-session/project over-delete); purge-session's dry_run always wins over confirm, same as purge-project ai-memory-store/src/ops.rs purge_session — selection scoped to (workspace_id, project_id) and keyed on this session's own summary_page_id or path='sessions/<sid>.md' + json_extract(frontmatter_json,'$.session_id')=<sid> (frontmatter owner, not the recursive latest-chain); in_scope==0 → NotFound fail-closed; the session's prompt profile_candidates (source_ref = 'session:<sid>', a globally unique id) are deleted in whichever project the harvest filed them, matching the observations cascade they were harvested from; whole op in one transaction, and the tombstone it leaves is checked by begin_session_row and by the new-session arm of admit_hook_session_event; move_project_workspace re-stamps the purged_sessions tombstone with the rest of the project so it still matches after a move; admin.rs handle_purge_session checks req.dry_run unconditionally, before req.confirm ops.rs purge_session_leaves_a_sibling_session_in_the_same_project_intact, …refuses_a_session_from_another_project_and_deletes_nothing, …refuses_a_session_from_another_workspace, …does_not_delete_an_identically_pathed_page_in_another_project, …removes_older_summary_versions_without_deleting_prior_manual_page (#862); admin_purge.rs purge_session_confirm_true_and_dry_run_true_still_only_previews — {"confirm": true, "dry_run": true} deletes nothing; ops.rs purge_session_dry_run_changes_nothing — every table a session purge touches, the purged_sessions tombstone, and the audit_log row are identical before/after a PurgeMode::Preview run; ops.rs purge_session_counts_collateral_damage_in_another_project and admin_purge.rs purge_session_dry_run_and_confirmed_purge_both_report_collateral_damage_in_another_project — purging session S collaterally deletes an observation, and orphans a handoff's session reference, in a different project (via S's own id cascading), and both the preview and the confirmed report count it; admin_purge.rs purge_session_dry_run_refuses_a_session_outside_its_named_scope — the same session previewed under a different real project (same workspace) or a different real workspace whose project shares the name both 404 with no counts in the body, with the session's own scope as the 200 control; the purged_sessions tombstone holds against live hook ingest as well as begin_session: ops.rs a_purged_session_is_not_recreated_by_hook_admission (admit_hook_session_event refuses a purged session and writes nothing, with a sibling session and the same id in another project admitted as controls) and router.rs async_processing_drops_events_of_a_purged_session (the late delivery is a terminal dropped_invalid, not a failure the client retries) and batch_drops_a_purged_session_then_commits_next_item (the batch endpoint acknowledges it as dropped_invalid and commits the next item instead of stopping fail-fast); the user's own sentences the profile harvested from the session's prompts go with it: ops.rs purge_session_deletes_the_profile_candidates_harvested_from_it (including the candidate harvested from a prompt the session recorded in another project, whose observation the purge deletes through the cascade; a sibling session's candidates in both projects and a page candidate survive); ops.rs a_purged_session_stays_purged_after_its_project_moves (after move-project, begin_session for the purged id in the destination is refused with SessionPurged; a fresh session there is admitted as the control) STRONG
10c Ledger reclaim is content-gated, not filename-gated (invariant #16) ai-memory-store/src/ops.rs reclaim_ledger_versions — a candidate row must pass ai_memory_core::log_ledger::body_opens_with_log_ledger on its own body, and only is_latest=0 AND superseded_at IS NULL rows are eligible, so decay-owned rows stay with forget-sweep; confirm gate in admin.rs handle_reclaim_ledger_versions reclaim_ledger_versions.rs a_prose_page_wearing_the_ledger_name_keeps_its_whole_version_chain, an_ordinary_page_chain_in_another_project_is_untouched, a_decay_tombstone_stays_with_the_sweep_that_owns_it; admin_reclaim_ledger_versions.rs deleting_without_confirm_is_refused_and_changes_nothing (with dry-run and confirmed controls) STRONG
10d Workspace delete's own row counts are scope-bound to workspace_id (a workspace's own rows are never over- or under-counted by a sibling workspace's), its cross-workspace observation/handoff cascade is reported by both preview and confirm rather than prevented (same as purge-project one level down), the non-empty guard fails closed without force, and delete-workspace's dry_run always wins ai-memory-store/src/ops.rs delete_workspace — every direct count and the DELETE FROM workspaces itself are scoped by workspace_id = ?1; the two collateral_* counts are scoped by workspace_id != ?1 so a row is counted as one or the other but never both; projects_deleted > 0 && !force → WorkspaceNotEmpty fail-closed, and a missing workspace is NotFound, both checked identically under PurgeMode::Preview and PurgeMode::Commit; whole op in one transaction; admin.rs handle_delete_workspace checks req.dry_run unconditionally, before building the confirmed path, mirroring reclaim-ledger-versions/purge-project; root-only gate is the shared /admin/* multi-user auth ladder, not a separate check admin_move.rs delete_workspace_dry_run_never_counts_a_different_workspaces_rows — previewing workspace A counts only its own project/page/session/observation/handoff rows, not workspace B's (which holds two like-named projects and its own full row set), and a session living in B that stamps an observation directly into A is counted in A's own observations_deleted, never in collateral_observations_deleted (the two counts are mutually exclusive by construction); admin_move.rs delete_workspace_force_true_and_dry_run_true_still_only_previews — {"force": true, "dry_run": true} deletes nothing; ops.rs delete_workspace_dry_run_changes_nothing — every table's row count, including workspaces itself and the purged_scopes tombstone (the two tables a confirmed delete's own transaction writes to), is identical before/after a PurgeMode::Preview run; ops.rs delete_workspace_dry_run_and_confirmed_delete_both_report_collateral_damage_in_another_workspace and admin_move.rs of the same name — deleting workspace W collaterally deletes an observation, and orphans a handoff's session reference, in a different workspace (via sessions cascading out of W), and both the preview and the confirmed response count it identically — the cascade itself is reported, not blocked, by either; admin_move.rs delete_workspace_dry_run_refuses_non_empty_without_force / delete_workspace_dry_run_nonexistent_workspace_returns_404 — same 409/404 a confirmed delete would give; admin.rs multiuser_delete_workspace_dry_run_rejects_db_user_and_anonymous — root reaches the preview handler (404 control), DB user gets 403, anonymous gets 401 STRONG
10e Reconcile-tombstone of a disk-deleted page is opt-in, soft, scope-bound, and false-positive-guarded (invariant #16, #929 delete-half) ai-memory-wiki/src/watcher.rs — off by default ([maintenance] reconcile_tombstones_deleted_pages); a page is tombstoned only after its file is observed missing on two consecutive passes (streak resets if the path's PageId changed), re-verified against the live filesystem immediately before acting, with reserved/indexed-but-unwalked paths (bootstrap.md, _meta.md, _pending/, sessions/*.md) excluded and a circuit breaker that skips a whole scope when > max(3, 50%) of its pages look missing or a non-partial walk finds nothing; ai-memory-store/src/ops.rs soft_delete_for_reconcile_if_latest is a soft tombstone (is_latest=0 + superseded_at, decay's shape) through the single writer actor in one transaction — never a filesystem write — scoped to the page's own (workspace_id, project_id) watcher.rs reconcile_delete_disabled_by_default_never_tombstones_a_missing_page, reconcile_delete_cross_project_isolation (project A's deletion never tombstones project B's same-path page), reconcile_tombstone_refuses_a_stale_latest_id, reconcile_tombstone_refuses_when_the_file_still_exists, reconcile_tombstone_never_touches_the_filesystem; ops.rs reconcile_tombstone_resurrects_instead_of_orphaning_on_recreate STRONG
10f Session-time repair is scope-bound (no cross-project timestamp rewrite) ai-memory-store/src/ops.rs repair_session_times — every candidate is read back and updated with WHERE id=? AND workspace_id=? AND project_id=?; a row outside that 3-tuple is reported NotFound and untouched, same code path as an id that does not exist at all; ai-memory-mcp/src/admin.rs handle_repair_session_times passes the caller's (workspace, project) straight through, never the candidate's own ops.rs repair_session_times_does_not_touch_a_session_of_another_project (control: sibling session in-scope repaired in the same batch); admin_repair_session_times.rs cross_project_session_is_not_found_and_untouched; both bite-checked by dropping the project_id filter STRONG
10g The event-ledger age sweep deletes only closed ledger files of the swept project: opt-in, content-gated, admission-gated, never the writer's months (invariant #16) ai-memory-consolidate/src/sweep.rs sweep_event_ledgers + ledger_is_expired (off at [decay] ledger_retention_months = 0; never the current or previous UTC month, whatever the age; a dry run only lists; a per-file delete failure is counted in ledgers_undeleted, kept and retried — the sweep does not abort, exactly as a refused page delete is kept and retried); ai-memory-wiki/src/wiki.rs list_event_ledgers / delete_event_ledger — rotated log-YYYY-MM.md name AND log_ledger content gate (checked before and after the admission round-trip under the mutation guard), a project-confined path, no symlink, never log.md, no store write; then the same blocking admission check a page delete runs (remove_page_locked): webhooks subscribed to delete_event_ledger are notified BEFORE the unlink, a reject-policy webhook refuses and the file stays, and the non-blocking observers are told only after the removal is durable consolidate tests/suite/ledger_sweep.rs an_ordinary_page_named_like_a_ledger_is_never_deleted (a page, a frontmatter page and log.md are kept; the real ledger is the control), another_projects_ledgers_are_untouched, the_current_and_previous_month_survive_even_a_one_month_retention, the_default_configuration_deletes_no_ledger, a_dry_run_reports_files_and_bytes_and_deletes_nothing, a_rejecting_admission_webhook_keeps_the_ledger_and_the_report_says_so (adversarial: a reject-policy webhook on delete_event_ledger — the file stays intact, the report counts it in ledgers_undeleted, the sweep keeps the rest going), an_accepting_admission_webhook_is_told_after_the_file_is_gone (legitimate control: an accepting gate lets the delete through and the non-blocking observer receives the op only after removal); sweep.rs ledger_guard_protects_the_current_and_previous_month_regardless_of_age; wiki tests/suite/ledger_files.rs an_admission_webhook_cannot_swap_a_ledger_for_an_ordinary_page_before_delete (the webhook overwrites the accepted ledger while deletion awaits its response; the final gate preserves that page, while a no-swap webhook is the legitimate delete control), a_page_wearing_a_ledger_name_is_not_deleted_even_when_asked_by_name, only_a_rotated_ledger_name_is_accepted (traversal and log.md refused), deleting_in_one_project_leaves_the_neighbours_ledger STRONG
10h restore never adopts a backup's code-bearing config.toml over a live one unasked, and never leaves a kept config unable to verify the restored API keys ai-memory-cli/src/commands/restore.rs stage_then_swap picks the archived config's placement (ConfigPlacement): restored in place only with --with-config or when the data dir has none, otherwise saved owner-only as config.toml.from-backup by save_archived_config after the swap; swap_into_place(.., install_config) moves the live config aside only when installing; with the live config kept and API keys in the staged database, the loaded [auth].token_pepper must verify against the staged pepper verifier before anything live changes restore.rs restore_keeps_a_live_config_and_saves_the_archived_one_beside_it (adversarial: an archive whose config enables an eval command leaves the live config byte-identical and the copy 0600), restore_force_with_config_replaces_the_live_data_and_config and restore_into_an_empty_data_dir_needs_no_force (controls: the flag, and a data dir without a config, restore it in place), keeping_the_live_config_requires_its_pepper_to_match_the_restored_keys (a mismatched or missing live pepper is refused naming --with-config with the live data untouched; controls: --with-config, and a matching live pepper) (GHSA-jpcg-w5c5-wcv6) STRONG
10i Restore requires an initialized database snapshot before replacing live data ai-memory-store/src/lib.rs Store::open_snapshot checks the staged file and reads existing applied migration history without CREATE before normal store migration; ai-memory-cli/src/commands/restore.rs stage_then_swap uses this entry point before the live-directory swap restore.rs restore_force_keeps_live_data_when_the_snapshot_is_missing, restore_force_keeps_live_data_when_the_snapshot_is_zero_bytes, and restore_force_keeps_live_data_when_the_snapshot_has_no_schema refuse unusable sources with all live fixture bytes intact; restore_accepts_an_initialized_snapshot_without_pages and store open_snapshot_migrates_a_snapshot_from_the_first_schema are valid empty/legacy controls. Restoring the ordinary Store::open call makes the three refusal tests fail STRONG for snapshot presence and initialization; existing migration checks still apply, not a complete SQLite integrity audit
11a Hook backpressure (202/429) + bounded fan-out (invariant #5) ai-memory-hooks/src/router.rs semaphore→429, 202 immediately, MAX_HOOK_BATCH_ITEMS, bounded LRU limiter; batch acknowledgements retain only processed indices and classify terminal drops without consuming capacity (the [ingest] drop_events whole-kind drop, 11k, is one such terminal drop); the resolver's filesystem probes of a caller-supplied cwd run through CwdProbes (blocking pool, four permits held until the syscall returns, 2-second deadline), so a blocked open() cannot stall the async workers or pin unbounded threads, and a timed-out resolution fails closed without caching router.rs handle_hook_returns_429_when_ingest_saturated, ingest_rate_limiter_is_bounded; router.rs cwd_probes_keep_a_stuck_open_off_the_async_worker (adversarial: a probe that never returns on a current-thread runtime; the timer still fires, the caller times out, a second probe never runs; fails when the probe runs inline) and cwd_resolution_fails_closed_when_its_probe_cannot_run (fails when the resolver probes inline); router.rs handle_hook_batch_skips_rate_limited_first_item_and_accepts_later_source, handle_hook_batch_reports_failed_index_after_rate_limited_skip, handle_hook_batch_drops_subagent_events_before_capacity_check (each asserts result indices and includes an accepted control) and the_ingest_drop_events_drops_before_any_capacity_is_spent (a whole-kind drop answers 202 with the semaphore exhausted; a kept kind gets the 429 control) STRONG
11a1 SQLite read-pool concurrency stays bounded ai-memory-store/src/reader.rs ReaderPool::with_conn acquires one of four owned permits before spawn_blocking and holds it through checkout, the read and checkin, so later calls wait asynchronously instead of opening more blocking threads and read transactions. close refuses later checkouts and wakes permit waiters with ReaderClosed reader_pool_bounds.rs reads_beyond_the_pool_cap_wait_for_a_connection: four held reads occupy the pool, the fifth cannot start until one returns, then all five complete. Fails on the unbounded base STRONG
11b Capture exclusions drop before storage ai-memory-hooks capture_policy.rs extract reads each adapter's own field names — DSH's Claude Code-shaped tool_name/tool_input pair included, so a DSH file, search or shell call classifies instead of staying Unknown — and inspect→Drop (before semaphore/spawn), including shell commands whose arguments name an ignored path (match_command; argv elements matched whole and tokenized, and every word that holds several words, such as a quoted sh -c script or a "$(…)" substitution, re-split to four levels by ShellCommand::split/push_nested_words, a deeper script metadata-only; ANSI-C strings decoded and a backslash before an ordinary letter dropped (shell_words, push_word); backslash-newline continuations joined (shell_words); a parameter default's operand, a value glued to a short flag and a file: URL's path read as candidates (parameter_operands, shell_arguments, file_url_path); PowerShell and cmd escape characters read out under the PowerShell tool or on a Windows host (without_windows_escapes); ~+ resolved to the cwd and a ~-/~N/~name prefix metadata-only (names_unknown_directory); shell and interpreter options that take a value skipped while looking for a -c script or inline code (takes_shell_value, runs_inline_code, which also lists lua/Rscript/osascript -e, and su -c/script -c as script runners); paths compared without regard to case on a macOS host (fold_case, set by resolve; patterns and candidates composed to NFC and lowercased in full by fold_path, TS captureFold; client-only, the server's sentinel re-inspection never depends on it); a file: URL cut at its query or fragment before decoding (file_url_path); a parameter default nested past four levels metadata-only and a default read again after backslash removal (parameter_operands, push_word_reading); a tilde expanded or treated as an unknown directory only when the shell expands it, unquoted and in a script rather than a quoted message or argv element, every tilde under PowerShell (marked_shell_words, literal_tildes, expand_tilde); a file or shell read of a harness's saved tool output, or a glob that could match one, metadata-only under an active policy (output_spool: Claude Code tool-results/ and tasks/*.output, OpenCode tool-output/, Pi pi-bash-*.log; glob segments fit a name they share a match with, globs_intersect, TS captureGlobsIntersect, and one fitting segment must spell three characters in a row of that name's distinctive text literally, spells, TS captureSpells, so *.log is not read as pi-bash-*.log, a trade-off that leaves a glob with no such literal run, /tmp/p?-b*, outside the rule; the TS matcher applies it to read_many_files entries too); every other marker governing a file-tool target (an apply_patch's header paths, read after leading whitespace, patch_paths), a search/list tool's directory, file or path-like glob argument (search_scope, Hermes file_glob included; a grep pattern is not read) or a separator-bearing shell argument also inspects the call, found by the lexical marker walk from each location's nearest existing directory, each directory's answer remembered for every lookup that passes it (marker.rs MarkerMemo, TS captureMemoMarker, seeded with the event's own walk, remember, TS captureMemoRemember), bounded (4,096 locations, 16 markers, and 16,384 probes sharing the glob walk's 50 ms, MAX_LOOKUP_PROBES, TS CAPTURE_MAX_LOOKUP_PROBES; locations outside the own checkout are looked up first, a glob's literal root before the walk below it (whose single listing can spend the time budget on a large directory), and past a bound fail closed as under an invalid policy, while running out inside the own checkout, whose locations are looked up shallowest first, ends the lookup, its own policy governing there) and combined strictest-first (capture_lookup_locations, CaptureDecision::stricter, hook.rs foreign_capture_decision, also applied by transcript_capture.rs decide_call; TS captureForeignConfigs, captureDecide, captureSearchScope, capturePatchPaths); a location with glob syntax is looked up from its literal root and, when that root lies outside the event's .git checkout, every directory the glob could pass through is checked for a marker (glob_walk, hook.rs GlobBudget::markers_below; TS captureGlobWalk, captureMarkersBelow, captureOwnCheckout: a */? segment lists the child directories it matches, a class/brace/group every child, a ** the subtree except the event's checkout's; a glob rooted inside the event's checkout is not walked; a checkout root at or above the home directory, or the filesystem root, is never the own checkout for these rules (own_checkout), so a dotfiles ~/.git does not stop the walk from ~/Projects; symlinks never followed; 256 directories, counted as a ** lists, 32,768 entries and 50 ms, MAX_GLOB_TIME, TS CAPTURE_MAX_GLOB_MS, injectable clock, past which, or for a brace/group spanning a separator, a ../~ alternative or one a bounded brace expansion builds, brace_alternatives, TS captureBraceAlternatives, a directory alternative bash before 5.2 expands to .. (.{*,x}/), or an expansion too large to list whose pieces could build one of these (brace_overflow_could_leave, TS captureBraceOverflowLeaves: integer and letter sequences cannot, so file{1..200}.txt is walked like any glob), the call fails closed); a .. after a ** is read both as the ** matching no directory and as matching some, by the event's own matcher and the lookup (normalize_readings, TS captureReadings, at most 16 readings, past which the call fails closed), and so is a directory segment that bash before 5.2 can expand to .. (could_name_parent, class_glob_matches with POSIX classes such as [[:punct:]] and extglob groups such as @(.), ?(.), *(.), +(.), !(x); TS captureCouldNameParent, captureClassGlob, captureNamedClass), read as .. too; inside double quotes a backslash before $ or a backquote is dropped, so a quoted script (bash -c "…", eval "…") re-split for its words reads an ANSI-C string as the shell it runs does (shell_tokens, TS captureMarkedWords); a zsh glob group kept in its word and ANSI-C numeric escapes decoded are fed to the lookup (shell_tokens with expand, ShellWords::expanded, glob_group, ansi_c_numeric_escape; TS captureMarkedWords(…, true), captureGlobGroup, captureAnsiNumeric); a file tool whose targets cannot be read or resolved, and a search/list argument that is not a string, fail closed; the path of a git REV:path object name tried from the cwd and the marker directory (git_object_path); Antigravity run_command resolved from its Cwd); an invalid marker makes file, search/list and shell calls metadata-only; an active one makes a shell call metadata-only when a word uses unquoted brace expansion, a bracket class (a leading ] included), a zsh glob group or extglob, or a numeric/control ANSI-C escape (has_unevaluated_expansion, also run on scripts given to sh -c, eval or a substitution), or when it runs inline interpreter code (runs_inline_code: python -c, node -e, ruby -e, perl -e, php -r, deno eval), and either makes tools that read back an earlier command's output metadata-only (reads_earlier_output: BashOutput, TaskOutput, write_stdin, process, read_bash/write_bash and PowerShell twins); the server admits a metadata-only shell or unknown-family body only under an active or invalid marker, with no paths and an extracted state (router.rs metadata_protocol_is_legal), and its own re-inspection strips an older client's keep for either; a Gemini read_many_files literal entry is also read as entry/** (glob_matches_below), and Copilot CLI's runtime view/create/str_replace_editor are file tools for that agent only (agent_family); Factory Droid's Claude-shaped payload is read by extract, its Create and ApplyPatch are file tools for that agent only (agent_family), ApplyPatch reads its input envelope like Codex apply_patch, and its LS directory_path, Glob folder/patterns and Grep glob_pattern locate the call for the cross-checkout lookup (search_direct_paths, search_scope) (#1240); Meta Muse Code's Claude-shaped payload is read by extract with its tool_use_id, its read_file/write_file/edit_file path resolves lexically against cwd, its read_memory/add_memory/edit_memory are file tools for that agent only whose project-scope path is placed under .agents/memory/ and whose personal scopes fail closed to metadata-only (muse_memory_paths), monitor is a shell for that agent only, and bash_input is an output reader for that agent only; CodeBuddy Code's payload carries Claude Code's tool names and fields and is read by the same extract arm (#1299); generated OpenCode/OMP/Pi/OpenClaw integrations mirror it in render_shared.rs ts_capture_policy_v1 (captureMatchCommand, captureShellSplit, captureUnevaluatedExpansion, captureInlineCode, captureGitObjectPath, captureGlobBelow, the reader flag). Candidate/argument flavor (Flavor::Posix vs Flavor::Windows, used to pick which ignore_paths patterns even apply) is derived from the host (the cwd), never from the candidate string alone — a POSIX-host candidate spelled with a leading // is collapsed to a single / before flavor detection (normalize_candidate; TS captureNormalize's windowsHost parameter, sourced from captureHostWindows(cwd)), fixing GHSA-vh98 (a //-prefixed candidate used to self-classify as Flavor::Windows regardless of host, matching zero POSIX patterns and being captured instead of dropped); a genuine Windows/UNC host (cwd itself windows-flavored) is unaffected; hook.rs --check-capture preflight uses the same capture policy before any spool or spawn; transcript imports (ai-memory backfill, including the automatic first-boot run, the ai-memory run ledger upload, and ai-memory recover's finish-failed re-import and degraded-run replay in recovery.rs recover_finish_failed/recover_degraded_run, each built for the journaled checkout's cwd) apply the same decision table through commands/transcript_capture.rs: each recorded tool call is rebuilt in its agent's hook shape (capture_policy.rs tool_call_payload) and inspected by the checkout's policy, and by a reroute destination's policy too; a Drop removes the call and its result (paired by native id, else the strictest call of the turn when the result has no id; a result whose id matches no call, or with no call, follows the orphan rule: dropped under a policy, content-free without one; a record the exporter skipped for exceeding the 1 MiB per-record cap leaves a skipped_record annotation that counts as an orphan call of its turn, so an id-less result there fails closed, #1613), metadata-only posts the hook's metadata-only body with its protocol (backfill) or a withheld placeholder keeping only the family and a call id that passes the server's valid_call_id (ledger), and a shell call whose recorded arguments cannot be parsed drops; both imports also apply the hook's repository admission gate (hook.rs checkout_admits_capture: persisted capture mode, marker opt-in, readable routing marker — the same helpers the hook's own gate uses), so under allowlist mode an unmarked checkout imports nothing, prompts included: backfill stops before contacting the server and the run ledger finishes with no events; a tool the transcript names differently from the hook is rebuilt under the hook's name and fields (capture_policy.rs hook_tool_call: Codex exec_command {cmd, workdir} → Bash {command, workdir}); the Claude Code and Codex JSONL adapters label each event with its record's cwd (transcript.rs stamp_record_cwd, RECORD_CWD_KEY), from which the import resolves arguments, policy and reroutes, falling back to the session cwd, and which is removed before a ledger upload; a rerouted call, and an event whose record cwd lies outside the checkout, must pass that directory's admission gate, resolve to the same server-profile route as the checkout and to the same project scope (transcript_capture.rs admits_elsewhere → hook.rs checkout_admits_capture + delivers_to_same_server, which compares two resolve_hook_route results and never matches a refused selection, + routes_to_same_project, which compares the two hook_scope hint sets and, when they leave the project to the server, under repo-root the repository/marker anchor or the directory itself, under the default basename the directory itself or a destination inside the repository whose root is the source), else it drops with its result, since the import files every event under the importing project; compaction, checkpoint and annotation events answer to the same record-cwd checks; Claude Code ! shell-mode output (a user message opening with a <bash-stdout>/<bash-stderr>/<local-command-stdout> block, whatever it holds) is dropped (shell_mode_output); the Claude Code adapter excludes harness-written background-task turns (transcript.rs claude_task_notification: origin.kind task-notification in any case, or a first text block opening with a <task-notification tag in any case, attributes allowed, after a byte-order mark, zero-width characters or whitespace) and records a compaction summary (isCompactSummary true, "true" or 1, truthy) as a compaction event, which backfill does not post; a tool the matcher does not recognize (unknown family: MCP tools, Codex view_image, …) keeps only its family whatever the policy, as the live server stores for it (EventCapture::Unrecognized: backfill posts title tool unknown and body tool_family: unknown, the ledger a withheld placeholder), and so does a result with no call to inherit from ; in a Windows session every candidate, shell argument and workdir is read as the file Windows opens before matching (windows_spelling, windows_segment, command_base; TS captureWindowsSpelling/captureResolve/captureBase): Git Bash/MSYS2/Cygwin /c/… and /cygdrive/c/…, a drive-less rooted path on the cwd's drive, the \\?\/\\.\/\??\ and UNC prefixes, the local administrative share (\\localhost\C$), and per-segment alternate-data-stream suffixes and trailing dots/spaces, any other device path unusable (metadata-only for a file tool); /c/… and /cygdrive/c/… are also read from the root of the cwd's drive, as a native tool reads them, and either reading matching drops (windows_spellings, normalize_candidates, normalize_readings; TS captureWindowsSpellings/captureAllReadings); the cwd, the marker directory, home and an absolute pattern get the same reading so every side shares one spelling (normalize_root, compile; TS captureRoot, the marker directory cut lexically); a Windows session also reads each shell command and argv element with every backslash literal, as PowerShell and cmd do, so a bare or double-quoted \\server\share\… or \\?\C:\… argument keeps its prefix (literal_shell_words, threaded through push_nested_words/push_argv_item; TS captureMarkedWords(…, literal)); the harness-spool check is linear in the path and charged to the match budget, past it fail-closed (output_spool, TS captureOutputSpool); a shell command over MAX_SHELL_COMMAND_CHARS (1 MiB) is metadata-only and its marker lookup unprovable (ShellCommand::oversized, TS captureCommandOversized); Hermes execute_code is metadata-only under an active policy (INLINE_CODE_TOOL_NAMES); the TS file/search/non-file/inline-code/output-reader tool lists and the command limit are generated from the native constants (FILE_TOOL_NAMES and siblings, spliced by ts_capture_policy_v1), and the TS marker reader honours every TOML spelling of the capture table toml_edit does (dotted capture.ignore_paths, quoted or spaced [capture] headers) and fails closed on the shapes it rejects (inline table, [[capture]], [capture.x], a second definition) (captureTomlKey and the captureConfigAt section loop), tracks every multi-line array so a line inside one (["docs"]) is never a header, and fails closed on a line that is neither header nor key/value, a key line swallowed by an open array, text after a continued array closes, or an inline table left open at a line end (captureValueScan); the TS glob walk reads a directory one entry at a time with opendirSync, stopping at the entry bound; in a Windows session a shell argument or workdir that is drive-relative (C:docs\x, a bare C:) or a device path naming no drive or share (\\?\GLOBALROOT\…, \\.\HarddiskVolume3\…) makes the command metadata-only, a POSIX shell's reading of a placeable native path (C:\repo\x read as C:repox) excused and a device reading never (windows_unplaceable, match_command, the workdir check in inspect; TS captureWindowsUnplaceable, captureMatchCommand, captureDecide); a PowerShell FileSystem::/Microsoft.PowerShell.Core\FileSystem:: provider prefix is dropped before a Windows path is read (strip_powershell_provider in candidate_raw/command_base; TS captureStripProvider in captureResolve/captureBase); a POSIX absolute pattern in a Windows marker makes the marker invalid (compile; TS captureConfigAt) (GHSA-gcpc-88hm-3xqr); server re-inspection compiles an Active never-match sentinel in the cwd's path flavor (inspection_sentinel, capture_inspector) (#1250); an unknown-family tool event keeps no arguments or output, and stores its MCP server and tool names only when the whole name passes [A-Za-z0-9_-] within 64 characters, so no path-bearing text can bypass ignore_paths (#1522) capture_policy.rs per-agent …honors_exclusions tests, shell_fixture_vectors (shared capture-policy.json shell drop/keep vectors: tool aliases incl. OpenClaw/Devin exec and PowerShell, workdir, glob directories, Windows paths, and a POSIX-host leading-// command via /{root}/docs/adr/x.md), shell_tool_shapes_of_every_adapter_honor_exclusions, claude_code_powershell_honors_ignored_paths_on_a_windows_host (#1186: Windows-spelled and -Param:value paths drop, public-path and git status controls kept, invalid marker metadata-only), gemini_cli_shell_and_read_many_files_honor_ignored_paths (Gemini run_shell_command incl. dir_path/directory, and read_many_files globs via match_globs: excluded literal, mixed public+excluded, docs/*, recursive ** and case-variant entries drop, an exclude list cannot rescue them, unsupported glob syntax and malformed lists are metadata-only, public entries kept, POSIX and Windows hosts) and globstar_reaches_lets_double_star_span_any_depth, fixture_vectors (incl. TS-adapter bash/exec vectors, and normalization's leading-// POSIX vectors alongside the kept Windows-cwd UNC vectors as the no-regression control); shell_matching_is_off_when_inactive_and_fails_closed_when_invalid_or_over_budget; router.rs capture_protocol_shell_decisions_survive_server_reinspection, capture_protocol_invalid_marker_shell_is_metadata_only (active metadata-only shell admitted for an unevaluated expansion, inactive refused, older client's invalid-marker keep stripped, commandless control kept), capture_protocol_unparseable_marker_strips_shell_events (server fallback for an unparseable marker), capture_protocol_invalid_shell_metadata_claim_must_be_canonical (a stripped shell claim with a path count or non-extracted state is refused), capture_protocol_active_keep_on_a_windows_cwd_keeps_provable_bodies (#1250: a kept Read and Bash on C:\repo and a UNC cwd stay Keep; brace-expansion still metadata-only); capture_policy.rs invalid_marker_strips_shell_calls_with_unparseable_commands, long_bash_lc_script_in_argv_is_not_dropped_by_the_match_budget, a_leading_double_slash_candidate_does_not_escape_posix_ignore_paths_via_flavor_mismatch (GHSA-vh98 adversarial: attempts the //repo/secret/... violation on a POSIX host, proves it now drops, with a plain-single-slash control and a Windows-hosted genuine-UNC control both still correct — fails on the pre-fix code); hook.rs shell_command_reading_an_ignored_path_is_dropped_before_spool, gemini_cli_shell_and_read_many_files_exclusions_drop_before_spool (pre- and post-tool events with an excluded path are never spooled; public controls spool with their family); capture_policy.rs read_many_files_directory_entries_cannot_reach_ignored_paths (shared read_many_files_directories vectors: docs, ., ./, docs/, case and .. variants drop; src, README.md, docs/adrx kept), output_reader_tools_are_metadata_only_only_under_a_policy (active and invalid strip, inactive and an unrelated unknown tool keep), copilot_cli_runtime_file_tools_are_scoped_to_copilot, unevaluated_shell_expansions_respect_quoting (also leading-] classes, zsh groups and extglobs, ANSI-C numeric escapes; subshells, $((…)), <(…), array assignments kept), the shell fixture's brace/class vectors (quoted, escaped, ${…}, {}, [ … ], HEAD@{1} controls kept); quoted_scripts_in_string_commands_are_read_like_command_lines (sh -c, timeout … bash -c, "$(…)", NAME="$(…)", backquotes, two nested shells and an inline-interpreter literal drop; bash -c 'cargo test' and "$(git rev-parse HEAD)" kept; four levels read, a fifth metadata-only), inline_interpreter_code_is_metadata_only_under_an_active_policy (inline code metadata-only, kept with no policy; modules, script files and grep -e unaffected), git_object_names_are_path_candidates (HEAD:, :, :N: and @{n} names drop, also from a subdirectory; drive letters, URLs, NAME=a:b and flags are not object names; a public object name kept), ansi_c_strings_and_escaped_letters_are_read_like_the_shell, antigravity_run_command_resolves_arguments_from_its_cwd (absolute and relative Cwd drop, a public Cwd kept, another agent's Cwd key ignored), windows_escape_characters_are_read_on_a_windows_host (caret and backquote spellings drop on a Windows host, public controls kept, a POSIX host reads both literally), a_case_folding_host_matches_paths_without_regard_to_case (file tool and shell drop with folding, keep without, public control kept; folding injected through resolve_for_host so it runs on every CI OS), the shell fixture's continuation, PowerShell/cmd escape, option-value, runner, interpreter, glued-flag, file: URL, tilde, parameter-default and fold_case vectors with their controls, the near-miss controls added to common_commands_stay_kept_under_an_active_policy (also quoted tildes, a file: URL with a query, a shallow nested default and a scratchpad log), the shell fixture's file: query/fragment, deep-default, escaped-default, quoted/argv/script tilde, PowerShell tilde, harness-output and Unicode fold_case vectors and the decisions harness-output vectors with their controls, reading_a_harness_output_spool_is_metadata_only_under_a_policy (active and invalid strip, inactive keeps, same-named files elsewhere kept, an ignored path still drops), capture_lookup_locations_name_every_path_a_call_spells, the Unicode rows of a_case_folding_host_matches_paths_without_regard_to_case, hook.rs another_checkouts_exclusions_hold_for_a_call_made_elsewhere (relative, absolute, glob and unmarked-Hermes shell calls naming another checkout's excluded file never spool; a broken foreign marker and too many foreign markers spool metadata-only; public, own-file and few-marker controls spool with content), hook.rs globs_searches_and_unreadable_targets_answer_to_another_checkout (sibling and parent-folder *, brace, bracket, ** and separator-spanning-brace shell globs, a Grep path, a Glob pattern, a parent-folder Grep filter, a Gemini search_file_content directory, a Codex apply_patch header and a target-less Read never spool content; public-glob, own-glob, own-**, own-search, own-Glob-**, public-search and own-patch controls spool with content), transcript_capture.rs globs_and_searches_reaching_another_checkout_honor_its_policy, capture_policy.rs glob_walk_follows_every_segment_a_glob_could_pass_through, an_invalid_policy_makes_a_search_metadata_only, a_brace_that_builds_a_parent_step_cannot_be_walked, a_parent_step_after_a_globstar_is_read_both_ways, glob_groups_and_ansi_c_escapes_reach_the_marker_lookup, a_saved_output_glob_needs_its_distinctive_name_in_literal_text, indented_patch_headers_and_hermes_file_globs_reach_the_marker_lookup, a_dot_glob_directory_that_can_match_the_parent_is_read_as_it (POSIX classes and extglob groups included), an_oversized_brace_expansion_is_walked_unless_its_pieces_could_leave (each attack with its control), the shell fixture's double-quoted bash -c/eval ANSI-C vectors and their controls, marker.rs marker_memo_answers_like_find_marker_once_per_directory, hook.rs a_globstar_above_the_checkout_skips_the_own_subtree (regression: ls ../**/README.md from a 300-directory checkout with no policy is not metadata-only; the sibling cat ../**/secrets.env drops), hook.rs marker_lookups_in_a_deep_tree_cost_one_probe_per_directory (regression: 300 paths in a 300-level tree cost fewer than five probes per level; out of budget inside the checkout kept, outside it metadata-only, the sibling checkout's location looked up before a long list inside the checkout, and a shallow nested marker before a deep list), hook.rs a_dotfiles_checkout_at_home_is_not_the_own_checkout (with ~/.git, cat */secrets.env from ~/Projects drops; a harmless glob kept), the shell fixture's dot-glob directory vectors and their controls, the shell fixture's **-then-.. and *.log vectors and the read_many_files_directories **-then-.. vectors, hook.rs constructed_parent_steps_answer_to_another_checkout (a .. after a ** through a shell, a Glob pattern and a Grep filter, four brace expansions that build a parent step, two zsh glob groups, hex and octal ANSI-C escapes, two dot-glob directory segments, a POSIX-class and four extglob dot-glob segments, a brace-built dot-glob, an oversized brace sequence over ., ANSI-C strings in a double-quoted bash -c and eval, an indented apply_patch header next to an unindented one and a Hermes file_glob never spool content; the same shapes inside the checkout spool with it, and so do four brace expansions too large to list that cannot leave it, which v2.6.3 kept), hook.rs a_monorepo_glob_inside_the_own_checkout_is_not_walked (in a 300-package checkout, with and without a policy of its own, packages/* shell globs stay kept and the sibling ../*/secrets.env and ../a/*.env attacks still drop), hook.rs a_glob_walk_outside_the_checkout_stops_at_its_bounds (directory bound counted while a ** lists, time budget through an injected clock, no walk inside the checkout), the Node evidence test's monorepo-*, walk-*, con-*, globstar-*, deep-* and dotfiles-* checks, and the Node evidence test's glob-*, search-*, patch-* and unreadable-target checks with their controls and transcript_capture.rs a_shell_command_naming_another_checkouts_file_honors_its_policy, both failing with the foreign lookup disabled, and the Node evidence test's cross-* and fold-unicode checks, which fail with captureForeignConfigs disabled, and the shell fixture's quoted-script, git-object, ANSI-C, escaped-letter and inline-interpreter vectors with their controls (cargo test, git status/log, pytest, python3 -m pytest, node build.js, npm run test, a quoted commit message with braces); router.rs capture_protocol_active_keep_of_unprovable_output_is_stripped; hook.rs excluded_content_cannot_reach_the_spool_through_unevaluated_tool_shapes (a harness's own background run — Codex's memory-writing agent, recognized by …/.codex/memories or its ## Memory Writing Agent header — is accepted and stored nowhere, with an ordinary Codex prompt as the control; router.rs codex_memory_agent_runs_are_accepted_and_stored_nowhere, transcript_capture.rs an_import_of_codex_memory_agent_runs_captures_nothing, core scaffolding.rs codex_memory_directory_is_recognized_on_every_platform / codex_memory_agent_header_is_recognized; #1674) (directory entries and Copilot view/create never spool, readers and brace shells spool without content, public controls spool with it); capture_policy.rs droid_tool_calls_honor_capture_exclusions (Read/Create/Edit naming an ignored path drop and a control path keeps, ApplyPatch is metadata-only like Codex apply_patch and its headers name the lookup location, LS/Grep/Glob drop and their directory and glob arguments locate the call, Execute naming an ignored path drops; every excluded case keeps under AgentKind::Other, so it fails with the Droid extract arm or the Create/ApplyPatch mapping removed) and the droid decisions fixture vectors (#1240); capture_policy.rs muse_tool_calls_honor_capture_exclusions (read_file/write_file/edit_file naming an ignored path, relative or absolute, and the project-scope memory tools naming an ignored .agents/memory path drop while a control path keeps, personal-scope memory calls are metadata-only, apply_patch is metadata-only like Codex's, search drops, bash/monitor naming an ignored path from their workdir drop, bash_input is metadata-only; each excluded case keeps under AgentKind::Other, so it fails with the Muse extract arm removed), muse_tool_payload_fields_carry_the_call_id and the muse decisions fixture vectors, taken from Muse Code 1.4.7 hook payloads; capture_policy.rs codebuddy_tool_calls_honor_capture_exclusions (Read/Write/Edit/Bash naming an ignored path drop, a control path keeps, and every excluded case keeps under AgentKind::Other, so it fails with the CodeBuddy extract arm removed) and the codebuddy decisions fixture vectors; render_shared.rs generated_capture_policy_v1_node_runtime_evidence (runs the same fixture sections, including the GHSA-vh98 and Gemini read_many_files/run_shell_command vectors, plus unsupported-glob, empty-list and recursive-** checks, against the emitted TypeScript; #[ignore] locally, run with --ignored under Node 24 by the Linux CI test job); hook.rs check_capture_refuses_partial_scope_and_excluded_content (ignored-path and partial-scope violations refused, complete public-path control passes), check_capture_bounds_marker_hints_and_refuses_oversized_scope (513-byte hints refused, 512-byte control passes; native routing preserved); backfill.rs backfill_never_posts_tool_content_the_capture_policy_excludes (planted Claude transcript: the excluded read's call and output never reach /hook/batch, a malformed read posts only the metadata-only body, public read control posted) and run.rs ledger_upload_drops_tool_content_the_capture_policy_excludes (excluded call and output absent from the finish request, public control present, cursor still advances), both failing with the guard removed; recovery.rs finish_failed_recovery_never_posts_content_the_capture_policy_excludes and degraded_run_recovery_never_posts_content_the_capture_policy_excludes (a full recover pass over a journaled Claude transcript with exact digests and cursor, marker ignore_paths = ["secrets/**"]: the excluded read's path and SENTINEL_RECOVERY_MUST_NOT_POST output never reach /workstream/runs/{id}/recover or /hook/batch, the public read's output does; each fails when its own call site's capture is built for / instead of the entry's cwd, on the control since a foreign-scoped capture fails closed, and both fail on the sentinel when for_checkout loses the marker's policy); transcript_capture.rs an_excluded_read_drops_its_call_and_result_by_id, id_less_results_take_the_strictest_call_of_their_turn, a_skipped_record_makes_the_id_less_results_of_its_turn_orphans (an id-less result after a skipped record is dropped under a policy and content-free without one; control: the same turn without the gap keeps it), unrecoverable_arguments_and_orphan_results_fail_closed_under_a_policy, a_call_into_another_checkout_honors_its_policy, ledger_events_are_dropped_or_stripped_before_upload, without_a_policy_every_event_is_kept (control); capture_policy.rs tool_call_payload_reaches_the_live_decision_for_every_supported_agent; backfill.rs allowlist_mode_backfills_nothing_from_an_unmarked_checkout (no request reaches the server; marked-checkout and denylist controls do), run.rs ledger_upload_under_allowlist_mode_carries_nothing_from_an_unmarked_checkout (finish carries no prompt or tool content; marked and denylist controls upload both), transcript_capture.rs allowlist_mode_admits_nothing_from_an_unmarked_checkout, all failing with the admission gate removed; backfill.rs backfill_inspects_codex_exec_command_as_the_hook_shell_call and run.rs ledger_upload_inspects_codex_exec_command_as_the_hook_shell_call (a planted Codex exec_command whose workdir-relative argument names an ignored file never posts its call or output; the same command from a public workdir does), capture_policy.rs codex_transcript_exec_command_is_inspected_as_the_hook_bash_call (absolute, relative and absent workdir and an argv cmd drop, public control kept, the workdir locates the call, another agent's exec_command stays unknown), all failing with hook_tool_call removed; backfill.rs backfill_resolves_each_call_from_its_record_cwd (cat adr/x.md recorded from docs/ never posts; the same command from the root does) and transcript.rs jsonl_events_carry_their_record_cwd (Claude per line, Codex per turn context, a relative cwd ignored), failing with the record cwd ignored or unstamped; backfill.rs backfill_drops_reroutes_the_live_hook_would_not_deliver_here (under allowlist mode, reads rerouted to an unmarked git repository, to a marker selecting an unregistered profile, and to a marker selecting a registered profile while the source uses the install default are never posted; a read in a marked checkout with no server selection is the posted control), failing with either the admission check or the route comparison removed (each refused case checked on its own); transcript_capture.rs a_record_cwd_answers_to_the_hook_admission_gate_there (prompt, call and result recorded in an unmarked repository drop under allowlist; a subdirectory of the opted-in checkout is kept and its record cwd never reaches the ledger) and claude_shell_mode_output_is_not_imported (stdout, stderr, local-command and size-capped blocks drop; <bash-input>, a prompt quoting a tag, and another agent's message kept); backfill.rs backfill_posts_no_content_for_unrecognized_tools (a planted Codex MCP call's arguments and output never post, the call and output post as tool unknown; a recognized shell output is the posted control) and transcript_capture.rs unrecognized_tools_keep_no_content_with_or_without_a_policy (no policy and an active one; ledger content withheld; public read kept; a call-less result content-free), failing with the unknown-family rule removed, the backfill one also with its content-free body removed; backfill.rs backfill_keeps_reroutes_to_the_same_server_profile_only (a reroute into a checkout selecting the source's registered profile and project is posted; one selecting a different registered profile is not, nor one of another project on the same profile, nor a prompt recorded there), failing with the profile comparison forced either way and with the project comparison removed; transcript_capture.rs a_record_cwd_in_another_project_is_dropped and a_reroute_into_another_project_is_dropped (prompt, call and result recorded in, or a read reaching into, a checkout declaring another project drop; one declaring the same project is kept), failing with routes_to_same_project removed; hook.rs subdirectories_of_one_repository_are_one_project_only_under_repo_root (two subdirectories of an unmarked repository, and a subdirectory importing its root, are two projects; the same directory, the root importing a subdirectory and a repo-root marker agree), failing with the basename rule removed; backfill.rs backfill_posts_no_task_notification_or_compact_summary_as_a_prompt and transcript.rs claude_adapter_keeps_task_notifications_and_compact_summaries_out_of_prompts (a monitored command's notification, a background agent's report and an origin-tagged notice are excluded, also behind a byte-order mark and zero-width characters, in another case, with attributes, after a non-text block, or with an origin kind in another case; a compact summary, also flagged "true" or 1, becomes a compaction event; the typed prompt, also one quoting the tag, and a look-alike tag are the controls), failing with either adapter rule removed or with the spelling rules reverted; transcript_capture.rs boundary_events_answer_to_the_record_cwd_admission_gate (compaction and annotation recorded in a refused directory drop; in the checkout kept), a_result_whose_id_matches_no_call_is_an_orphan (an unmatched id cannot borrow a public read's keep; the read's own result kept), claude_shell_mode_output_is_not_imported (a block holding a literal closing tag drops) and unrecognized_tools_keep_no_content_with_or_without_a_policy (ledger keeps no tool name and no invalid call id), each failing with its rule reverted; windows_spelling_fixture_vectors (shared capture-policy.json windows drop vectors for every spelling above, file tool and shell, with other-drive, other-share, longer-name and pipe controls, and windows_posix_controls proving a POSIX session keeps /c/…, trailing-dot and colon names; windows_scopes drop vectors for a \\?\C:\, \\?\UNC\…, \\localhost\C$\… or UNC cwd and marker directory with relative patterns, a \\?\C:\… absolute pattern from C:\repo, bare and double-quoted \\server\share\…/\\?\…/\\.\…/\\localhost\c$\… PowerShell, cmd, run_shell_command and argv commands, and both readings of /a/x from D:\a\…, each with public-path, other-drive and other-share keep controls; the Node runtime evidence runs the same vectors with the marker spelled in the Windows cwd), tool_family_fixture_vectors (shared tool_families, every native name per family), new decisions vectors (execute_code metadata-only, read_file/patch/fs_read operations drop, write_to_file/browser_navigate keep), output_spool_work_is_linear_and_budgeted (a 2,040-wildcard-segment path stays under a linear work bound; 32 such paths fail closed; one long or 32 short paths keep), an_oversized_shell_command_is_unprovable (one character over the limit is metadata-only and unlooked-up, at the limit keeps, argv summed, inactive untouched), inline_code_tools_are_unprovable_under_a_policy, hook_capture::capture_section_spellings_match_toml_semantics (shared marker_spellings, including a nested-array line ["docs"] before a dotted capture.ignore_paths that must still drop, and a key line inside an open array, text after a closed array and a multi-line inline table that must fail closed), and the Node evidence test running all of these vectors against the generated TypeScript plus its entry-bound read count for the directory walk; each fails with its rule reverted (Windows reading off, spool memo dropped or budget failing open, length check off, inline-code rule off, a name dropped from the list, TS dotted key or inline-table rule reverted, TS walk back on readdirSync, Windows reading of the cwd/marker directory or of an absolute pattern off, literal-backslash reading off, the cwd-drive reading of /a/x off, TS array tracking or any captureValueScan refusal off, Rust and TS alike); new windows_scopes vectors (drive-relative, device-namespace and Git Bash doubled-backslash shell words and a C:docs workdir metadata-only, FileSystem:: file paths, shell words and workdir dropping, a POSIX absolute pattern in a Windows marker failing closed, with type README.md, dir /s /q, git status, a URL, type C:\repo\README.md and Get-Content -Path C:\repo\README.md kept) and windows_marker_rejects_posix_absolute_patterns (the same pattern stays active in a POSIX marker) fail natively and in the Node evidence test with the unplaceable check, its device branch, the workdir check, the provider strip or the marker rejection removed; inspection_sentinel_matches_cwd_flavor (#1250: POSIX sentinel Invalid on a Windows cwd, Windows-flavored sentinel Active there and on UNC, POSIX sentinel Active on /repo and Git Bash /c/repo) is native only, since inspection_sentinel is server re-inspection with no TypeScript counterpart, and fails with the cwd-flavored sentinel or the marker rejection removed; removing the POSIX-reading excusal makes type C:\repo\README.md metadata-only, and excusing a device reading keeps the doubled-backslash device path; capture_policy.rs windows_lookup_locations_keep_glob_segments_whole (a Windows session trims trailing dots from plain segments only, so {.,}. still reaches .. and the sibling checkout's marker; bites with the glob-segment exemption removed) names_outside_the_mcp_shape_keep_no_tool_identity (#1522). STRONG with listed residuals. Matching is lexical by design, so these stay open: shell variables ($VAR, FILE=… sh -c 'cat $FILE') and the output of a command substitution, a cd inside the command, a script read from a file or a heredoc fed to an interpreter (read only for the words it spells out), git's repository root approximated by the marker directory, symlinks (paths are never resolved on disk), a recursive search of a parent directory (grep -r x docs, rg x) through a shell, a search tool rooted at a literal directory above another checkout (it is not walked) and a glob whose literal root lies inside the event's own checkout reaching a checkout nested there (it is not walked), a marker nested inside the own checkout below what the lookup budget reaches, a .git the same command creates (touch .git; cat */x: the hook reads the tree after the command ran, so that directory counts as the own checkout; a .git at or above the home directory never does), a parameter expansion next to glob syntax (${X}/*/x, not walked), a glob through a symlinked directory, a tool's own directory option (git -C), script runners and interpreters the matcher does not list (their words are still read, but expansion or inline code in them is not recognized), a value glued after the first letter of a short-flag cluster, non-ASCII percent-escapes in a file: URL, a bare word naming another checkout's directory (only separator-bearing arguments are looked up for another marker), harness output files outside the listed default locations, and tools the matcher does not list, which keep their current unknown-tool behavior. Transcript imports add: assistant prose quoting an excluded file is kept (as live prompt/assistant capture keeps it), harnesses whose hook schema the matcher does not read (Crush, Kimi Code) keep their tool events as live capture would, adapters that record no per-record cwd (Pi, OMP, OpenCode, Crush, Kimi Code, Command Code, Kiro, Grok) judge every event from the session cwd, a Codex ledger upload resumed from a mid-file cursor judges the events before the next turn context from the session cwd, and id-less adapters over-drop a whole turn's results when one call is excluded, and when the routing hints leave the project to the server, events from inside one repository count as the importing project even where the server has a separate project registered for a subdirectory (anywhere under repo-root; under basename only when the import runs from the repository root); a metadata-only import keeps an event_id (ledger) and ingest_key (backfill) derived from a SHA-256 of the original content plus session and record ids, left in place because those ids are the retry-dedupe keys and a content-free id would merge distinct events — it only confirms a guess of low-entropy content. Under allowlist mode a refused checkout's ai-memory run still records repository checkpoint metadata (HEAD, branch, a status hash and changed-path names, never file content), which the run also sends at launch. Re-splitting quoted words over-drops a quoted message naming an ignored path, and inline interpreter code is metadata-only under an active policy. Mitigation: allowlist capture mode (install-hooks --capture-mode allowlist) for sensitive projects. Bite checks: removing the nested re-split, the git object path or its marker-root base, Antigravity's Cwd key, the leading-] rule, either zsh-group rule, ANSI-C decoding or its numeric-escape rule, the \o reading, the inline-code rule, the nesting-depth rule, the nested-script scan, the line-continuation join, the Windows escape reading, the shell-option and interpreter-option value skips, the added runners and interpreters, the glued-flag value, the file: URL path, the ~+ resolution, the unknown-tilde rule, the parameter-default reading or case folding each fails the Rust tests, and each TypeScript counterpart fails the Node evidence test; so does reverting the file: URL cut, the deep-default rule, the escaped-default reading, the quoted-tilde rule, the harness-output rule or Unicode folding (the new fixture vectors fail against the previous matchers in both languages), and disabling the foreign-marker lookup fails the native, import and Node cross-checkout tests; reading every glob location as literal, skipping search/list locations, or skipping a file tool whose targets cannot be read each fails the native, import and Node glob/search/unreadable tests, removing apply_patch header reading fails the own-patch control, and reverting the saved-output glob rule fails the new fixture vectors in both languages; walking globs rooted inside the event's checkout fails the monorepo tests, accepting any literal text for a saved-output glob fails the *.log vectors, removing the time budget or counting a **'s directories only after it lists fails the bounds tests, and removing the **-then-.. readings, the brace-expansion check, the expanded lookup words, the patch-header trim, the file_glob key or the dot-glob parent reading each fails the Rust tests and the Node evidence test; treating every oversized brace expansion as leaving, dropping the brace-built dot-glob check, listing the own checkout's subtree under a **, looking up locations in their given order (outside before inside, then shallowest first), dropping the per-directory memo, counting a checkout at home as the own one, keeping the backslash before $ in double quotes, or dropping the POSIX-class or extglob reading each fails its Rust test and the Node evidence test; in a Windows session a shell workdir spelled /c/x is read only as Git Bash reads it, so arguments resolved from it miss a native tool's D:\c\x reading, the TS marker reader rejects structural errors anywhere in the marker but does not validate other values' TOML (x = nope invalidates the policy only natively), an administrative share reached through a loopback or host alias other than localhost/127.0.0.1 (\\127.0.0.2\c$, \\127.1\c$, \\<hostname>\c$) or a \\wsl$\… path is matched as the UNC path it spells, Windows matching folds ASCII case only, and a drive-relative word counts as placed when a placeable argument's POSIX reading spells it; a **/ matches one or more directories, never zero (documented in marker-file.md)
11c Capture hook ≤200ms budget (invariant #5) hooks/_lib.sh capture path curl --max-time 0.2 (context-fetch 1.0s and background drain 2.0s are separate, larger-budget paths) none (shell-script timeout; hard to unit-test) — watch on any capture-path change WATCH
11d Hook server-profile routing: a marker-selected server gets only its own capture and its own token (#992) ai-memory-cli/src/server_profiles.rs resolve (validated ProfileName, strict servers.toml parse, roots required once two profiles exist, component-wise root match) and marker.rs find_server_selection (inherited down the tree, any value shape counts); commands/hook.rs resolve_hook_route drops a Rejected route before spool, handoff and backfill, and hands the drainer no live token for a profile route; commands/hook_spool.rs static_retry_token (a profile entry retries only with its own stored token), the loopback reroot skip, chunk splitting on profile, and per-pass endpoint backpressure without changing a queued event's route or credential; generated TS captureServerRouted drops a routed repository and gates fetchHandoff; hooks/_lib.sh ai_memory_server_routed (flag refused by ai_memory_post_hook/ai_memory_get_handoff) and hooks/lib/ai-memory-hook.ps1 Test-AiMemoryServerRouted drop it in the script hooks; --check-capture refuses a rejected server-profile selection without printing its token or URL; once [auth].bearer_token_file names auth-tokens/default (this install's root bearer), commands/server.rs refuse_the_root_token_name refuses server add default and server remove default so no profile can be handed, overwrite or delete the root bearer hook.rs each_repository_spools_to_its_own_profile_with_its_own_token, muse_hooks_honour_marker_scope_profiles_exclusions_and_allowlist (the Meta Muse Code settings-hook front door: marker workspace/project, the profile's server and token never the install's, the payload's session id, an ignored relative read_file dropped with a kept control, allowlist silence from an unmarked checkout with a denylist control), a_selection_that_does_not_resolve_emits_nothing (unknown / tokenless / outside roots / roots required / invalid name, plus a resolving control), session_start_handoff_comes_from_the_profile_server_only, a_repository_without_a_server_key_keeps_the_install_default; hook_spool.rs a_saturated_endpoint_does_not_hold_back_another_endpoint (429 leaves its endpoint queued without retry charges, including partial acknowledgements and fallback/token retries, while another endpoint delivers only with its own token), a_saturated_reroot_is_not_retried_or_allowed_to_block_another_endpoint (a configured-address retry pauses the saturated destination too), a_profile_entry_is_never_retried_with_the_install_live_token (server B accepts exactly the install's live token and must still not get it), a_profile_entry_recovers_with_its_own_rotated_token (control), a_profile_entry_on_a_dead_loopback_port_is_not_rerouted_to_the_default, profile_and_default_entries_at_one_address_ride_separate_batches; server_profiles.rs roots/registry/name tests; marker.rs nested_markers_without_server_inherit_the_ancestor_selection; install_hooks.rs generated_integrations_fail_closed_on_a_server_profile_marker, openclaw_plugin.rs openclaw_plugin_fails_closed_on_a_server_profile_marker, and the server-routed-* checks in generated_capture_policy_v1_node_runtime_evidence; hook.rs an_event_without_a_payload_cwd_routes_by_the_process_cwd, a_refused_route_prints_nothing_for_kimi_user_prompts; hook_spool.rs a_profile_entry_is_not_retried_with_a_token_issued_for_a_new_url; server_profiles.rs changing_the_url_without_a_token_discards_the_old_token, omitted_roots_keep_the_registered_ones; marker.rs outside_home_the_walk_reaches_a_marker_above_the_checkout_root, encoding_noise_cannot_hide_a_server_key, an_unreadable_marker_is_a_refused_selection; backfill.rs a_spawned_backfill_authenticates_like_the_hook_that_spawned_it; tests/hooks/test_lib.sh "server profiles (#992)" section; hook.rs a_mixed_spool_drains_each_event_only_to_its_own_server (two token-gated servers, one spool, one drain: each server receives exactly its own event with exactly its own bearer); tests/suite/server_profiles.rs (the built binary: server add → hook spools to the profile with its token, unknown profile spools nothing, uninstall removes the tokens; two_real_servers_each_receive_only_their_own_repository runs two real ai-memory serve children with different root tokens and checks on each server which repository landed there); ai-memory-hooks powershell_server_routed.rs server_routed_guard_mirrors_the_native_walk (runs Test-AiMemoryServerRouted under real PowerShell: inherited, BOM, look-alike keys, the $HOME boundary with its control, past a checkout root outside home, current directory); hook.rs a_selection_that_does_not_resolve_emits_nothing (rejected routes refuse preflight; resolved profile control passes); tests/hooks/test_lib.sh and powershell_home.rs a_trailing_separator_on_home_keeps_the_walk_boundary (a $HOME ending in / or \ keeps both script walks at home: a server marker above it routes nothing, with a root-home control that does); server.rs the_root_bearer_file_name_cannot_be_registered_or_removed (refused at the root bearer path; another name and an install without a root bearer file are the controls); server_profiles.rs a_default_profile_shares_the_root_bearer_only_at_its_path, clear_tokens_keeps_the_root_bearer_and_removes_profile_tokens STRONG for native hooks, generated TS, .sh and .ps1 hooks. Known gap: an older binary draining a shared spool ignores profile
11e Native self-upgrade archive confinement (#1025) ai-memory-cli/src/commands/upgrade.rs normalizes every tar/zip path, rejects links and special entries, extracts only the binary and hooks/, accepts only the exact non-runtime support layout emitted by release.yml, and caps both entry count and declared expanded bytes before writing upgrade.rs release_workflow_support_assets_are_exact_and_ignored (shipped support paths admitted, near-miss docs/packaging/template paths refused), extracts_archive_built_like_release_yml and extracts_zip_happy_path_with_hooks (real workflow-shaped archives succeed but support assets are not written), validate_rejects_path_traversal, zip_extract_rejects_path_traversal, tar_extract_rejects_declared_expansion_past_limit, with binary/hooks extraction as the legitimate control STRONG
11f Native hook executable-path integrity after self-replacement (#1027) ai-memory-cli/src/commands/render_shared.rs hook_embedded_exe_path is the single executable resolver for every persisted native hook form (POSIX/Windows command, Windows exec, Zero, ZCode, OpenCode 2 assistant capture): it prefers an existing literal path, strips Linux's trailing (deleted) procfs marker only when the stripped installed binary exists, and otherwise falls back to the platform command name. A binary running from /nix/store always renders the bare command (#1275): the store path names one package version that garbage collection deletes, while the profile's bin/ on PATH follows upgrades. Upgrade keeps the already-loaded config and refreshes in-process render_shared.rs embedded_exe_strips_the_marker_when_the_stripped_path_exists, embedded_exe_preserves_a_real_file_whose_name_has_the_marker_suffix, embedded_exe_falls_back_when_the_resolved_path_is_missing, hook_embedded_exe_path_names_an_existing_file_without_marker (asserts the bare command only when the test binary itself runs from the Nix store), hook_rendered_from_a_nix_store_exe_names_the_bare_command (the existence probe reports the store binary present, so only the store-path guard yields the bare command in the rendered exec hook) with its control hook_rendered_from_a_normal_exe_keeps_the_absolute_path (/usr/bin, ~/.nix-profile/bin, and a non-root .../nix/store/... keep the absolute path); upgrade_e2e.rs native_upgrade_refreshes_hooks_without_a_deleted_path_or_losing_cli_data_dir reproduces the replacement window through the shipped binary, plants the corrupt suffix, and proves refresh removes it while preserving a CLI-only data dir STRONG on Linux reproduction plus platform-neutral resolver/render coverage; Windows path rendering remains covered by its existing command/exec tests and full Windows CI
11g Cross-project tool attribution cannot bypass source or destination capture, or destination server routing (#932, #1199) ai-memory-hooks/src/capture_policy.rs absolute_tool_location_paths accepts only bounded, recognized, absolute locations: file-tool targets, a search/list tool's explicit path, or a shell command's structured workdir (command text is never parsed for a location); ai-memory-cli/src/commands/hook.rs tool_location_routing_cwd requires every path to prove the same repository/marker boundary, refuses the reroute when the payload cwd's own capture policy would not keep the event (source ignore_paths may name paths outside the source checkout, and a command may name source files while its workdir points elsewhere), and resolves that destination before capture policy, allowlist marker, server profile, scope hints, or spool credentials. Relative, mixed-project, unsupported, and arbitrary non-project paths keep the payload cwd. For Hermes, hook.rs hermes_terminal_cwd replaces the reported process cwd with TERMINAL_CWD (read from the captured RuntimeEnv) only when it names an existing absolute directory and, inside a gateway (_HERMES_GATEWAY=1), only for an event whose profile is default, the profile whose terminal.cwd a multiplexing gateway exports, before the location lookup above, so that checkout's capture policy, allowlist marker and server profile govern the event. A gateway event of another profile instead goes through hermes_profile_marker_cwd, which accepts only a name matching Hermes' profile-id pattern (^[a-z0-9][a-z0-9_-]{0,63}$, so no separator or .. reaches the path), and only when <HERMES_HOME or ~/.hermes>/profiles/<name> holds its own .ai-memory.toml; that marker's policy then governs the event the same way hook.rs absolute_file_target_uses_destination_scope_and_capture_policy (hostile content under the destination exclusion is never spooled; a public control is routed there), absolute_file_target_cannot_escape_a_destination_server_profile (unregistered destination profile drops instead of falling back to source/install default), file_target_routing_refuses_relative_external_and_mixed_project_paths, workdir_reroute_applies_the_destination_capture_policy (a workdir-rerouted command reading a destination-excluded path is dropped, public control kept), a_reroute_cannot_escape_the_source_capture_exclusions (adversarial: a file read under a source pattern that names another project's directory, and a shell command naming an excluded source file with workdir in another project, are both refused; public file and shell controls still reroute; fails with the source-policy check removed), hermes_tool_location_finds_the_marker_the_process_cwd_lacks (Hermes terminal workdir, read_file path and search_files path reach the repository marker under allowlist; no-workdir, relative-workdir and relative-search controls stay with the unmarked process cwd), hermes_terminal_cwd_applies_the_selected_checkout_policy (adversarial: with TERMINAL_CWD selecting a checkout, a relative read of a path it excludes is never spooled and a marker naming an unregistered server profile drops the event; public control kept; fails with the TERMINAL_CWD routing removed), hermes_terminal_cwd_routes_lifecycle_events (allowlist: a prompt is captured only through an existing absolute TERMINAL_CWD; unset, relative and missing values stay with the unmarked process cwd), hermes_gateway_terminal_cwd_routes_only_the_default_profile (a multiplexed gateway's variable does not route another profile's event), hermes_profile_marker_cwd_refuses_a_name_that_is_not_a_profile_id (adversarial: ../escape, sc-seo/.., a/b, uppercase and over-long names never become a path although a marker waits where they lead; a valid id is the control; fails with the id check removed), hermes_gateway_profile_marker_applies_its_capture_policy (adversarial: under a profile marker an excluded relative read is never spooled and an unregistered server profile drops the event; public control kept), hermes_gateway_profile_routes_by_its_own_marker (allowlist: a marked profile is captured into its project, an unmarked one stays with the gateway cwd and is dropped), hermes_profile_marker_cwd_takes_only_a_marked_named_profile_in_a_gateway (default profile, no gateway, unmarked and missing profiles do not route; a standalone gateway's own HERMES_HOME does), hermes_tool_events_prefer_their_locations_then_terminal_cwd; capture_policy.rs absolute_tool_location_paths_cover_search_dirs_and_shell_workdirs (relative workdir, command-text paths, workdir without a command, and Hermes process yield no location) STRONG for native ai-memory hook; generated and compatibility hooks retain cwd-only routing
11h Docker-wrapper capture-policy capability (#1002) bin/ai-memory routes ordinary Linux/macOS install-hooks, upgrade refreshes, and every hook/hook-drain invocation through the stable checksum-verified native host client, so the hook process executes the capture-policy boundary in 11b before spool/network; a hook config that calls the wrapper never runs in the helper container, and an unavailable client drops the event with exit 0 instead of falling back to it. Only an explicit `AI_MEMORY_HOOK_PLATFORM=posix windowsretains the documented script compatibility path and its warning;AI_MEMORY_NATIVE_BINmay not point back to the wrapper. For a server initialized on the named volume,bin/ai-memory refresh_volume_token(run only byinstall-hooks) copies /data/auth-tokens/default(only when/data/config.tomlnames it) to an owner-onlynative-runner/server-tokenthrough the helper's stdout, anduse_volume_tokenpoints the native client at that copy (the managed host commands andmcp-bridgeonly read it and never enter the container engine) withAI_MEMORY_AUTH__BEARER_TOKEN_FILE, so it is a file-sourced token (never rendered into a harness config) and never an argv; a refresh that reads no token from a reachable volume deletes the copy, and a successful full uninstall --applydeletes it after the container returns; a bind-mountedAI_MEMORY_DATA_DIRis read directly and an explicitAI_MEMORY_AUTH_TOKEN` wins scripts/check-native-packaging.sh Checking host-launch wrapper routing: a default allowlist install reaches the fake native client while a Docker executable that always fails proves no container fallback occurred; the explicit posix control reaches fake Docker and adds no native invocation; the self-referential native override is refused. tests/wrapper_upgrade.sh global-option routing matrix: both separated and = forms of --config/--data-dir preserve native argv, stdin and exit status for all host commands, including hooks; a missing prefixed hook client drops the event without container fallback, while search and explicit script-compatibility controls still use the helper (bite: dispatching on $1 fails these checks). tests/wrapper_upgrade.sh lifecycle hook native host routing: hook --event session-start and hook-drain reach the fake native client with the stdin payload while docker/podman stubs on PATH and in AI_MEMORY_DOCKER stay unused, and a non-executable AI_MEMORY_NATIVE_BIN exits 0 without reaching the engine; Checking the wrapper hands host commands the volume's root bearer: for mcp-bridge, install-hooks and run the fake native client receives the token file (mode 600, right content) and the token is absent from its argv; controls: a bind-mounted data dir and an explicit AI_MEMORY_AUTH_TOKEN make no copy and ask no container (bite: dropping the export fails the check); Checking the host token copy goes with the volume's token and with uninstall: a volume answering with no token removes the copy and hands none over, while an unreachable engine keeps it; a dry-run, --only hooks or failing uninstall keeps it and a successful uninstall --apply removes it (bite: without either removal the check fails); auth_default_e2e.rs a_host_client_given_the_token_file_by_env_authenticates (the native side of the handoff, with a no-variable control)
11j Offline recovery journal and transcript replay ai-memory-cli/src/commands/recovery.rs keeps bounded locators, ordered semantic transcript digests, pre-launch cursors and persistent correlated-delivery/loss evidence in an atomic journal, refuses a symlinked data dir and any symlinked component inside it (ancestors above the data dir are trusted, so macOS /var → /private/var works), sanitizes/caps failure reasons, and bounds each replay plus the whole pass; hook_spool coordinates enqueue and quarantine with short filesystem locks, canonically resolves partial scope from the recorded cwd, bounds per-file reads and current global occupancy across the main spool and recovery directories, sweeps completed tombstones, and holds correlated events outside drain until replay succeeds or restores them on failure; degraded resumes use ai-memory-workstream's adapter-validated delta export, whose blocking parse and baseline scans are capped by record, event-count, source-byte and serialized-byte totals (a record over the per-record cap is discarded through its newline in 64 KiB chunks that count toward the source-byte total, and moves the cursor and prefix hash only once complete, identically in both scans, #1613); backfill::import_exact_session chunks by item and byte limits and requires per-item durable acknowledgements; run.rs journals every session launch, including explicit spool-only evidence for unsupported exporters, and journals a resumed export only after capturing its exact pre-launch cursor; workstream.rs /recover/finish retains owner/project authorization, rejects superseded runs, and validates a finished retry by durable transcript/native/cursor/exit identity without regenerating its checkpoint; validated recovery ingest keys bind session, agent, event kind and sanitized event identity until session purge transcript.rs persisted_baseline_exports_only_offline_append_and_rejects_rewrite, parser/baseline cap and ordered-semantic digest tests, an_oversized_record_is_skipped_only_once_it_is_complete, kimi_baseline_and_export_agree_on_the_prefix_across_a_skipped_record, discarding_an_oversized_record_counts_toward_the_source_byte_cap; CLI run_offline.rs real degraded spool-only and overlap/idempotency tests; recovery.rs spool_only_without_correlated_evidence_never_auto_clears, a_dropped_spool_event_stays_lost_on_the_next_empty_pass, loss/time-budget tests, symlinked_journal_and_ancestor_are_refused, a_symlinked_ancestor_of_the_data_dir_is_trusted, a_symlink_inside_a_data_dir_under_a_symlinked_ancestor_is_refused; hook_spool.rs partial-scope late enqueue, completion-race, occupancy churn/active-cap, bounded-read and tombstone-sweep tests, plus interval isolation (completed_tombstone_keeps_a_later_resume_of_the_same_session proves a post-interval resume hook is delivered, completing_one_recovery_interval_leaves_the_other_intervals_entries_intact proves one interval's completion never consumes another's evidence and ambiguous entries fail closed into the main spool); backfill.rs two_sequential_recovery_intervals_on_one_resumed_session_replay_exactly_once proves the second interval's content and session-end are stored with end-of-session effects while reruns stay pure replays; transcript.rs an_oversized_first_record_is_skipped_by_session_listing_caps proves the first-record byte caps bite before allocation; store insert_observation_ingest_dedups_on_key rejects cross-session and changed-event preclaims; hooks expired_run_recovery_is_owner_only_and_refuses_superseded_runs proves changed transcript refusal and changed-checkpoint no-op STRONG on Unix integration coverage; Unix lock opens use no-follow and atomic replacement rechecks the destination. Windows owner-only ACL/reparse and lock semantics require the PR windows lane
11i OpenCode executable probing and generated-config cleanup (#1097) ai-memory-cli/src/config.rs captures the full process environment once in typed RuntimeEnv; run.rs overlays explicit run --env values with platform key semantics and uses that same effective environment for executable resolution, probing, and launch without rereading process environment; opencode_dialect.rs invokes only direct argv --version, caps output and time, and rejects malformed/future majors. Automatic launch skips only OpenCode on probe failure; explicit OpenCode fails. install_hooks.rs quarantines the incompatible sibling before reading its exact ownership markers, restores unowned content with an atomic no-replace link, and never deletes or overwrites a concurrent replacement; install_mcp.rs owns the shared dual-schema endpoint/token inference used by both installers, rejects conflicting generated V1/V2 entries before mutation, and migrates an alternate-major entry only when endpoint, generated shape, and absent-or-Authorization-only headers match, preserving custom headers and ambiguous entries; auto-wire migrates MCP before hooks infer from that exact config path and skips hook mutation when transition preflight fails run.rs automatic_opencode_probe_failure_keeps_another_harness_available, opencode_executable_probe_selects_v2_for_launch_and_autowire, effective-child-environment PATH casing controls, fake V1/V2/env-derived-major/malformed/future/timeout executable tests, setup-agent V1/V2 no-probe integration controls; install_hooks.rs opencode_plugin_cleanup_removes_only_exact_owned_incompatible_sibling, opencode_plugin_cleanup_preserves_a_concurrent_user_replacement, opencode_plugin_restore_moves_quarantine_when_destination_is_free, opencode_plugin_restore_preserves_an_existing_replacement, opencode_plugin_restore_does_not_replace_a_file_created_at_restore_window, opencode_plugin_cleanup_does_not_escape_custom_target_directory; install_mcp.rs opencode_install_reuses_owned_endpoint_and_token_across_major_transitions, opencode_install_refuses_conflicting_owned_transition_entries, opencode_install_does_not_infer_from_a_user_owned_transition_entry, opencode_mcp_migration_moves_only_owned_alternate_shape, opencode_mcp_migration_preserves_ambiguous_user_entry, opencode_mcp_migration_preserves_custom_headers, opencode_mcp_migration_accepts_only_historical_generated_headers STRONG for Unix process probes and platform-neutral ownership gates; exact Windows executable resolution remains covered by run.rs resolver tests and requires the PR windows label
11k Server-side ingest drop list: tool id/name lists (#1241) and whole event kinds ([ingest] drop_events) ai-memory-hooks/src/drop_list.rs IngestDropList: matches for the tool lists (a tool-call id by prefix, a tool name exactly) and matches_event_kind for the whole kinds (every [ingest] drop_events value parsed with the typed HookEvent::parse; session-start/session-end and the other bucket rejected), both validated once in Config::load (tool lists: at most 64 entries of 128 printable characters each). Checked in router.rs admit_hook and the handle_hook_batch loop after the subagent exclusion (should_drop_subagent) and before the rate limiter, ingest semaphore, sanitizer, and storage, so a marked subagent event seeds the tracking set its unmarked tail is dropped against even when its tool id, tool name, or event kind is listed. The tool lists match only tool events and are read through the per-agent mapping capture_policy::tool_payload_fields that tool metadata uses. A drop answers 202 and counts as dropped_by_policy; the matched value is never logged tool lists: router.rs the_ingest_drop_list_drops_before_any_capacity_is_spent, the_ingest_drop_list_applies_to_hook_batches, marked_tool_policy_drops_seed_subagent_tracking_before_single_ingress_matching, and marked_tool_policy_drops_seed_subagent_tracking_before_batch_matching cover capacity, batch acknowledgements, id-prefix and exact-name seeding order, unmarked tails, and stored controls; drop_list.rs unit tests cover bounds, exact matching, and each agent's native fields. Whole kinds: router.rs the_ingest_drop_events_drops_the_named_kind_and_keeps_the_rest, the_ingest_drop_events_drops_before_any_capacity_is_spent, the_ingest_drop_events_consumes_no_rate_budget, the_ingest_drop_events_batch_reports_per_index_outcomes_and_only_stores_the_kept, the_ingest_drop_events_keeps_dropping_the_unmarked_subagent_tail, the_ingest_drop_events_keeps_dropping_the_unmarked_subagent_tail_in_batches, and a_marked_event_of_a_dropped_kind_still_seeds_subagent_tracking; drop_list.rs drop_events_* tests cover typed matching and rejected state/unknown kinds. Moving any matcher before subagent exclusion fails its single/batch tail tests; removing either batch matcher fails its batch contract STRONG. The list applies to every project on the server; it narrows what is stored and never widens access
11l Marketplace plugin front door: a plugin-launched event gets exactly the native hook's capture policy, scope and server routing, is captured once beside settings-file hooks, and sends nothing without the binary (#1166) plugins/*/scripts/ai-memory-hook (rendered from crates/ai-memory-cli/templates/plugin/ai-memory-hook.sh by render_plugins.rs) has no capture logic: it only finds the binary (an ai_memory_bin option is honoured only as an absolute path, so a checkout cannot plant a relative one) and runs ai-memory hook with AI_MEMORY_HOOK_ORIGIN=<agent>-plugin, hook first so the Docker wrapper routes it, omitting --server-url when the option is empty (a pre-3.0 binary's usage error, exit 2 before it reads stdin, is retried once against the default local server with a stderr hint), and without a binary drains stdin, prints {} (guidance on session-start only) and exits 0; hook.rs is_dropped_plugin_copy + plugin_origin.rs drops_plugin_event drop a plugin copy when the user settings.json (honouring CLAUDE_CONFIG_DIR) or the checkout's .claude/settings.local.json carries an ai-memory hook for the same event (install_hooks::hooks_file_delivers_ai_memory_event), the settings event taken from the payload's hook_event_name when two settings events share a wire event (PostToolUse/PostToolUseFailure), so settings wiring only the success event never silence a failure copy; a Droid-launched copy (droid-plugin) is checked against the one file Droid reads hooks from (~/.factory/hooks.json, else the hooks key of ~/.factory/settings.json); a Muse-launched copy (muse-plugin, recognized by MUSE_PLUGIN_ID with MUSE_SESSION_ID) is checked against the hooks key of ${XDG_CONFIG_HOME:-~/.config}/muse/settings.json, and its subagent events are dropped; both drop a folderless session (no cwd, or a Claude desktop scratch-workspaces cwd); Codex plugin events are never de-duplicated (an untrusted settings hook is skipped silently, so dropping could lose the event); the drift test keeps every plugin hook on the native path (no hooks/<agent>/*.sh, no credential in any plugin file) CLI tests/suite/plugins.rs through the committed launcher and the real binary: ignore_paths_hold_through_the_plugin (ignored path never spooled; public-file control kept), allowlist_mode_holds_through_the_plugin (unmarked checkout emits nothing, prompts included; marked control captured), marker_scope_routes_plugin_events, server_profiles_route_plugin_events (profile URL and token, never the plugin's URL), a_settings_hook_for_the_same_event_drops_the_plugin_copy (user and project settings; unwired-event and no-settings controls), a_droid_hook_for_the_same_event_drops_the_droid_plugin_copy (Droid hooks.json; no-Droid-hook, Claude-settings-only, unwired-event and folderless controls), a_muse_hook_for_the_same_event_drops_the_muse_plugin_copy (Muse settings.json; no-Muse-hook, Claude-settings-only and unwired-event controls; subagent and folderless events dropped), plugin_origin.rs muse_plugin_copy_is_dropped_when_muse_settings_hooks_deliver_the_event (a matcher-narrowed hook does not count), a_plugin_failure_copy_is_dropped_only_when_settings_deliver_the_failure_event (settings wiring only PostToolUse keep the plugin's failure copy; controls: the success copy, no hook_event_name, both events wired) and test_plugin_launcher.sh (an inherited MUSE_SESSION_ID without MUSE_PLUGIN_ID stays claude-code), folderless_sessions_are_not_captured_through_the_plugin, without_a_binary_nothing_is_sent_and_the_agent_is_not_blocked, foreign_hosts_are_attributed_or_ignored, committed_plugins_match_the_renderer, plugin_tree_carries_no_credentials; plugin_origin.rs unit tests (codex_plugin_events_are_never_deduplicated_against_settings, droid_settings_hooks_count_only_while_hooks_json_is_absent, only_a_catch_all_matcher_suppresses_the_plugin_copy: a settings hook narrowed by a matcher never drops the plugin copy); hook.rs plugin_copy_is_dropped_only_with_the_plugin_origin; tests/hooks/test_plugin_launcher.sh (a relative ai_memory_bin planted in the checkout is never run; PATH control); tests/e2e/claude_plugin_smoke.py (real claude -p: settings hook plus plugin give one user-prompt) STRONG. Verified 2026-10-13: removing the is_dropped_plugin_copy guard fails the de-duplication and folderless tests (and the smoke reports user-prompt x2); disabling the native Drop disposition or the allowlist gate fails the ignore_paths and allowlist tests through the launcher. Not covered: tool events from a live model turn (no credential in CI), Windows Git Bash, Cowork and the desktop Code tab (see docs/design-marketplace-plugins.md)
11m The server never opens a filesystem path named in a hook payload ai-memory-hooks/src/payload.rs HookEnvelope::from_query_and_body (run by /hook and every /hook/batch item) only reads the posted JSON; Antigravity step-log enrichment (antigravity.rs enrich_antigravity_step_output, which opens <artifactDirectoryPath or transcriptPath dir>/.system_generated/steps/<stepIdx>/output.txt) runs only client-side in ai-memory-cli/src/commands/hook.rs against the client's own home, and the server stores whatever tool_response the client sent router.rs a_hook_payload_cannot_make_the_server_read_its_own_disk (an Antigravity PostToolUse batch naming a server-only directory through artifactDirectoryPath and through transcriptPath; no stored observation or file contains the server-side sentinel); payload.rs envelope_parsing_never_reads_a_payload_named_antigravity_artifact and antigravity_post_tool_use_renders_client_enriched_output (control: client-supplied output still rendered) STRONG. Both adversarial tests fail with the server-side enrichment call reinstated (the sentinel file content is stored and readable through search)
11n Opt-in tool names ([ingest] record_tool_names) name only a kept call and never carry its arguments ai-memory-hooks/src/capture_policy.rs recorded_tool_name keeps the adapter tool name only when it is at most 64 [A-Za-z0-9_-], and Claude Code's skill / subagent_type only when at most 128 [A-Za-z0-9_.:-], refusing free text whole; payload.rs HookEnvelope::record_tool_name renames only a title that is still the bare tool <family> label; router.rs calls it after inspect_capture_envelope, and metadata_envelope / metadata_only_protocol_envelope clear the recorded name, so a call the client stripped, or a shell call the server strips under an invalid marker, stays unnamed router.rs record_tool_names_names_kept_calls_and_never_metadata_only_ones (a kept Bash call is named; a client-stripped file call and a server-stripped invalid-marker shell call whose payload still says Bash are not; no argument text is stored) fails with both the title guard and the two clears removed, with the control tool_calls_stay_unnamed_when_record_tool_names_is_off; payload.rs record_tool_name_refuses_free_text_names_and_descriptors STRONG
12 Network/auth posture, including auth on by default for new installs (an existing install keeps loopback no-auth until ai-memory auth enable) config.rs loopback DEFAULT_BIND; serve.rs validate_http_exposure, require_allowed_host; auth.rs require_bearer; serve.rs mounts /identity inside the host and machine-auth gates even with web disabled; nix/nixos-module.nix treats only literal 127.0.0.1/::1 as loopback, requires exactly one secret environment source for other binds, keeps secret auth and llm_headers values out of the Nix store, and brackets IPv6 in ExecStart; new-install default: commands/init.rs root_bearer_for_new_config mints a root bearer only on a fresh data dir (no config file and no database) and only when no bearer is supplied otherwise, via local_auth.rs provision_root_token (auth-tokens/ 0700, file 0600, atomic, reused when present) and records the relative [auth].bearer_token_file; config.rs apply_bearer_token_file reads it once (AI_MEMORY_AUTH_TOKEN wins, inline + file together refused, a missing or blank file leaves no bearer) and discover_root_token lets a packaged install's client commands use <data_dir>/auth-tokens/default only with no config file at the probed path, a loopback server URL and no registered default profile (http_client.rs is_loopback_url, shared by every caller, decides loopback from the host reqwest parses and refuses any URL carrying user information); serve.rs refuse_a_missing_token_file stops a server whose configured file holds no token; AuthSettings::renderable_bearer_token keeps a file-sourced token out of every renderer: install_mcp.rs route_file_token (Claude Code gets the session-aware ai-memory mcp-bridge entry, Codex and Prime Agent name AI_MEMORY_AUTH_TOKEN, every other client a stdio_bridge_entry that runs mcp-bridge --no-session-id in its documented stdio shape, Pi keeps its extension, ZCode (HTTP-only) is refused) and mcp_bridge.rs, which authenticates with the config-resolved bearer and connects upstream before serving stdio, so a refused token ends it with 401 Unauthorized instead of hanging; mcp_bridge.rs bridge_bearer sends a configured bearer, else the hook key stored in <data_dir>/auth-token, else the discovered loopback root token (AuthSettings::configured_bearer_token leaves discovery out, so a server+client host never sends root over a stored user key), and the fallback is in the bridge only (Config::load never reads that file, so serve neither requires nor accepts it); install_mcp.rs store_bridge_key stores an explicit --auth-token there for the Claude Code and Muse bridge entries on --apply and writes the entry with --data-dir and no key, keeping the key inline when a configured bearer would win, a different key is stored, the hooks use OIDC, the store fails or the Docker helper runs; uninstall.rs keeps the stored key on --only hooks while install_mcp::bridge_entry_remains; uninstall.rs mcp_entry_is_ours / toml_mcp_entry_targets recognise bridge entries by install_mcp::bridge_entry_url; auth_enable.rs rewire_clients re-registers every client whose entry targets this server, install_hooks.rs (persisted to the hook credential files, never inlined, not even on the F5 persist-failure fallback), setup_agent.rs, run_autowire.rs, setup.rs (runs init, adopts the minted token in memory through adopt_token_file, and calls the installers with no explicit token; the rendered user unit carries none; user_service.rs is_rendered_by_setup lets uninstall stop and delete only a unit carrying setup's identity line whose SHA-256 still matches, never a hand-written or edited one); local_auth.rs seed_hook_credential gives hooks the token through auth-token/auth-header and keeps a different stored credential; uninstall.rs keeps the root bearer (server_profiles::clear_tokens keep); commands/auth_enable.rs is the idempotent opt-in serve.rs host-guard (missing→400 / forged→403), non-loopback-requires-token; auth.rs wrong-token 401; serve.rs machine_identity_remains_authenticated_with_web_disabled_and_expired_keys (wrong and expired keys refused, valid machine key accepted, web remains disabled); flake.nix nixos-module-eval refuses localhost and 0.0.0.0 without a secret source, refuses two secret sources, settings.auth secrets, and settings.llm_headers, with literal IPv4/IPv6 loopback and one-source controls; cli/tests/suite/auth_default_e2e.rs against the shipped binary: a_fresh_install_requires_the_token_and_its_own_clients_still_work (after init, unauthenticated /mcp, /hook, /api/v1/projects, /admin/status → 401 and /healthz → 200; the same requests with the token succeed; the native hook delivers with no token in its environment, status authenticates through config, mcp-bridge lists tools; the token is in neither process's /proc/<pid>/cmdline; after install-hooks, install-mcp --apply for every client it writes (21, by default config path under the test home), a refused ZCode install and auth enable twice, a scan of the whole home finds the token nowhere and a scan of the data dir finds it only in the token file and the two hook credential files), an_existing_install_is_unchanged_until_auth_enable (control: a pre-default install serves every route open and status names the fix; auth enable twice is idempotent, rewires Claude Code to the bridge, and after a restart the routes refuse and the hook still delivers), a_packaged_install_with_an_external_config_wires_its_clients, uninstall_keeps_the_root_bearer_and_a_missing_one_stops_the_server, a_host_client_given_the_token_file_by_env_authenticates; init.rs a_fresh_init_mints_a_root_bearer_the_loader_reads, init_on_an_existing_install_does_not_turn_auth_on, init_with_a_supplied_bearer_mints_nothing, re_running_init_keeps_the_same_root_bearer; config.rs a_relative_bearer_token_file_resolves_against_the_data_dir, a_missing_or_blank_bearer_token_file_is_reported_not_guessed, the_env_token_wins_over_the_bearer_token_file, an_inline_bearer_and_a_bearer_token_file_together_are_refused, a_client_without_a_config_file_discovers_the_root_bearer, root_bearer_discovery_is_refused_outside_its_narrow_case (existing config, remote URL, a remote host behind loopback-looking user information, default profile, env token); http_client.rs loopback_url_is_decided_by_the_parsed_host (user-information, fragment and query forms, look-alike domains, localhost., 0.0.0.0 and IPv4-mapped IPv6 refused; 127.0.0.0/8, [::1] and localhost in any case accepted); mcp_bridge.rs discovered_root_never_leaves_loopback_but_the_stored_user_key_follows_the_entry (adversarial: remote and user-information --server-url forms get no root key; control: an unnamed loopback server does); auth_default_e2e.rs a_session_less_bridge_serves_any_client_without_holding_the_token (tools/list and a scoped memory_query through mcp-bridge --no-session-id against a fresh auth-on server, the token in neither the bridge's /proc/<pid>/cmdline nor its /proc/<pid>/environ; control: the session-aware mode still refuses to start without CLAUDE_CODE_SESSION_ID) and a_bridge_without_the_token_is_refused_cleanly_not_hung (exits promptly naming 401 Unauthorized); mcp_bridge.rs only_the_session_aware_mode_forwards_and_requires_a_session_id, a_session_less_upstream_config_carries_no_session_header, stdio_bridge_forwards_tools_and_session_header_in_both_http_modes (control); config.rs config_load_never_adopts_the_stored_hook_key (adversarial: a stored hook key leaves the loaded bearer empty, so serve on that data dir neither requires nor accepts it; control: a bearer_token_file naming the same file is adopted); mcp_bridge.rs bridge_bearer_puts_the_stored_hook_key_below_a_configured_bearer (a configured bearer wins, a blank one does not), a_stored_user_key_outranks_the_discovered_root_token (adversarial: discoverable loopback root plus a stored key sends the stored key; control: discovery alone still sends root); install_mcp.rs an_explicit_key_for_a_bridge_is_stored_instead_of_written_inline (Claude Code and Muse entries carry no key and name the data dir, the stored pair is the hooks' format; controls keeping the key inline and storing nothing: print path, configured bearer, a different stored key, OIDC hooks, Docker helper, HTTP entry); removal.rs an_explicit_bridge_key_is_stored_and_outlives_only_hooks_removal; install_mcp.rs a_file_sourced_token_wires_every_client_without_entering_its_config (every written client: no token, no header, an entry that reaches the server; ZCode refused and unwritten), stdio_bridge_entries_follow_each_clients_documented_shape, inline_and_explicit_tokens_still_embed_as_before (control); uninstall.rs bridge_entries_are_recognised_by_their_upstream_url (JSON, OpenCode array and TOML shapes; a bridge to another server and a foreign command are kept); install_hooks.rs a_file_sourced_token_is_persisted_but_never_embedded; auth_enable.rs enable_twice_is_idempotent_and_leaks_the_token_into_no_harness_config (every client pre-wired over HTTP is re-registered, ZCode reported as manual, the second run byte-identical), enable_leaves_an_entry_for_another_server_alone, enable_refuses_while_a_default_profile_would_share_the_token; local_auth.rs the_root_bearer_is_owner_only, seeding_never_replaces_a_different_hook_credential; setup_e2e.rs setup_installs_wires_is_idempotent_and_uninstall_removes_its_unit (one setup --yes in a fresh temp home: the token is in no file under the home but the token file and the two hook credential files, not in the user unit and not in setup's output; the self-check's memory_status and a hook event authenticate through the file; uninstall then disables and deletes the unit once and a second uninstall calls nothing), uninstall_leaves_a_unit_it_did_not_write (adversarial: the packaged unit copied by hand is kept, no systemctl call); user_service.rs a_foreign_or_edited_unit_is_left_alone, rendered_units_carry_an_identity_that_survives_only_unedited STRONG. Bite checks for the new-install default: with fresh-install minting disabled the fresh e2e routes answer without a token and the init tests fail; with renderable_bearer_token returning the file token, install-mcp, install-hooks, auth enable and the e2e scans find it in harness configs; without the serve refusal a server whose token file was deleted keeps running (the e2e times out on it); without the hook seeding the fresh e2e hook is refused; without clear_tokens keep uninstall deletes the root bearer; with route_file_token no longer choosing the stdio bridge the every-client and auth enable tests fail; with auth enable skipping the re-registration its test fails; with the session-less mode forwarding an inherited id the bridge unit test fails; without the 401 naming the refusal e2e fails; without bridge-entry recognition the uninstall test fails; with Config::load adopting the stored hook key, without the bridge fallback, with discovery counted as a configured bearer, or with install-mcp never storing the key, the matching new test fails; with setup handing the token to install-mcp its scan finds it in .claude.json; with is_rendered_by_setup accepting any unit, the foreign-unit tests fail; with discovery removed the packaged e2e gets 401, and with each discovery guard removed the matching case of root_bearer_discovery_is_refused_outside_its_narrow_case fails. Residual: a hand-edited servers.toml that adds a default profile after the root bearer exists would read the root bearer as that profile's token (server add refuses it, auth enable refuses while it exists); ZCode takes only HTTP entries and is refused, so it needs a manual entry; the stdio entries for Zero, Muse Code and DeepSeek Harness follow their documented or source-level format but were not run against those clients
12b Managed-workstream provenance privacy, stable replay identity and server event namespace ai-memory-core/src/workstream.rs scrub_workstream_provenance; ai-memory-hooks/src/workstream.rs finish_run reserved client-id check and sanitize_events before immutable segments, with sanitize_events and append_boundary_events scrubbing event/checkpoint/losses content before the 64 KiB cap so a cap-straddling secret is never cut into an unmatchable prefix (#1113); ai-memory-store/src/workstream.rs finish_run stable identity check and stored_event, scrubbing content with the explicitly supplied configured sanitizer before its 16 KiB store-boundary bound; no changes to the typed observation boundary store/tests/suite/workstream_provenance.rs workstream_provenance_is_bounded_scrubbed_and_idempotent_before_storage (hostile and oversized source ids, unknown metadata, legitimate correlation, retry and distinct event ids), workstream_provenance_legacy_reads_strip_secrets_and_unknown_metadata (search and tail, malformed/oversized legacy JSON), workstream_provenance_reused_event_id_retains_data_and_refuses_identity_change (first indexed version retained, identity refusal and batch rollback), workstream_provenance_replay_survives_sanitizer_changes (new extra patterns and removal of a built-in-pattern allowlist exemption, with identity-refusal control), workstream_provenance_replay_preserves_legacy_rows_above_bounds, workstream_provenance_finished_run_ignores_late_events, workstream_provenance_retry_with_marker_matching_pattern_is_idempotent, workstream_content_is_scrubbed_before_the_store_cap (a credential straddling the 16 KiB store cap is redacted, not persisted as an unmatchable prefix; benign control verbatim; #1113); hooks workstream_provenance_finish_scrubs_before_raw_segment_and_search (custom sanitizer, immutable segment, SQL recovery and finished-run no-op), workstream_provenance_client_cannot_use_server_event_ids (reserved ids refused before raw writes, normal client event and server-generated checkpoint/loss controls), finish_run_scrubs_event_content_before_the_byte_cap and finish_run_scrubs_boundary_events_before_the_byte_cap (a credential straddling the 64 KiB event cap is redacted in the raw segment and never reaches the index; checkpoint/losses and benign controls; #1113); cli/tests/suite/workstream_provenance.rs (text/JSON and old server DTOs) STRONG: privacy, stable-identity and reserved-namespace regressions fail with their guards bypassed; an isolated allowlist bypass fails on the unknown key, and bypassing the raw-id search authorization returns 200 where its test requires 403. No provenance is emitted in startup packets, and old raw segments are not rewritten
12c Browser cross-origin writes refused on an unauthenticated server (a foreign page in the operator's browser, DNS rebinding, and a LAN host where browsers send no fetch metadata) serve.rs refuse_cross_origin_browser_requests / is_cross_origin_browser_request, layered on the machine (/mcp, /hook*, /handoff, /workstream/*, /identity) and admin (/admin/*) routes when auth is off: Sec-Fetch-Site other than same-origin/none → 403, or, without fetch metadata, an Origin whose authority is not the Host → 403; and is_non_script_browser_request: any Sec-Fetch-Dest other than empty (case-insensitive; non-UTF-8 refused) → 403 whatever Sec-Fetch-Site says, so links, images, navigations, iframes and form posts are refused even as same-origin or none. Browsers send fetch metadata over plain HTTP only to a potentially trustworthy host, so on any other Host (a LAN address or name in the allowlist, 0.0.0.0, host.docker.internal; is_loopback_host admits only localhost, *.localhost, 127.0.0.0/8 and [::1]) handoff_fetch_lacks_client_marker also refuses GET/HEAD /handoff without a non-empty X-AI-Memory-Client header (ai_memory_hooks::CLIENT_MARKER_HEADER) → 403 whose body names both remedies (re-stage hooks, or set a bearer token). A page cannot add that header without a preflight these routes never answer. /handoff is the one state-changing GET on these routes; the other GETs are reads a foreign page cannot see the answer to, and every cross-origin POST carries Origin. Every first-party client sends the marker: the native hook (hook_capture.rs post_hook/post_batch/get_handoff), CLI subcommands (http_client.rs ServerEndpoint::authenticate), every curl in hooks/_lib.sh, both header tables in hooks/lib/ai-memory-hook.ps1, and the generated TypeScript integrations (render_shared.rs ts_auth_headers_fn plus the spool drain). Loopback hosts keep accepting a fetch without it, so hooks staged before the header existed still work on a default install, except that a request carrying any proxy forwarding header (Forwarded, X-Forwarded-For/-Host/-Proto/-Server/-Port, X-Original-Forwarded-For, X-Real-IP, X-Client-IP, CF-Connecting-IP, True-Client-IP, Via; PROXY_HEADERS) counts as non-loopback, since a plain-HTTP proxy can rewrite Host to loopback while the browser behind it sent no fetch metadata. No first-party client sends those headers. Hooks, the CLI and MCP clients send none of these headers; the web UI's same-origin /admin/pending-writes calls are fetch() (Sec-Fetch-Dest: empty) and pass. Behind it, axum Json and rmcp's Content-Type: application/json check refuse the preflight-free content types (text/plain, form-urlencoded, multipart) with 415; require_allowed_host (and rmcp allowed_hosts on /mcp) refuses a rebinding Host; machine/admin routes carry no CORS layer, so a preflight never comes back permissive. A stored wiki page viewed in the built-in web UI could otherwise turn the guard's same-origin allowance into a claim: ai-memory-web/src/markdown.rs safe_image_url / is_safe_image_target render as # any image target that is root-relative, a network path, carries a .. segment (also percent-encoded), or, for a UI mounted at the base-path root, starts with a server route segment Every /web surface (built-in pages including /web/pending, the login page, a custom SPA and /api/v1) answers X-Frame-Options: DENY and Content-Security-Policy: frame-ancestors 'none' (ai-memory-web/src/mount.rs deny_framing), because a framed page's own Approve/Reject fetch() is same-origin and the guard rightly lets it through cli/tests/suite/cross_origin_e2e.rs browser_cross_origin_requests_cannot_write_to_an_unauthenticated_loopback_server, against the shipped serve: every write route (/hook, /hook/batch, MCP memory_write_page/memory_delete_page/memory_message_send/memory_handoff_accept, /admin/write-page/delete-page/purge-project/messages/send, /workstream/runs) × each simple content type × modern, Origin-only and fetch-metadata-only browser shapes → 4xx; body-less GET /handoff (which claims the single-use baton), POST /admin/profile/rebuild and POST /admin/backup → 403; a rebinding Host → 403; preflights answer no Access-Control-Allow-*; GET /handoff as a same-origin document or image and as a Sec-Fetch-Site: none document → 403 with the baton still open. Then a canary scan of the whole data dir, page/project/handoff survival, and legitimate controls (JSON MCP calls, a JSON hook → 202, the web UI's same-origin /admin/pending-writes list and approve reach their handlers, the anonymous active-project pointer is unmoved after the refused /handoff fetches while the closing hook-style fetch claims the baton and moves it). serve.rs cross_origin_browser_request_detection and non_script_browser_request_detection (header tables) and cross_origin_browser_guard_applies_only_without_auth (same-origin image and none document refused, same-origin empty passes, both pass with auth on); ai-memory-web markdown.rs neutralises_images_that_reach_server_routes (/handoff?…, /admin/backup, //host/…, ../ and %2e%2e/ traversal, root-mounted route names refused) with preserves_relative_images as the legitimate control. cross_origin_e2e.rs handoff_fetch_on_a_lan_host_requires_the_client_marker, against a serve that allowlists a LAN name and address: GET and HEAD /handoff through either without the marker, and with an empty one → 403 carrying the remedy text, with the baton still open and the active-project pointer unmoved; controls: a marked fetch through the LAN name claims the baton, and a marker-less fetch through 127.0.0.1 (a hook staged before the marker) claims the next one; then a 127.0.0.1 fetch carrying each proxy forwarding header and no marker → 403 with the baton still open, and the same fetch with the marker claims it. serve.rs loopback_host_detection, handoff_fetch_client_marker_decision (incl. a loopback Host with each proxy header, refused without the marker and admitted with it, and a named row per header so none can drop out of the list) and handoff_client_marker_guard_on_lan_hosts_and_under_a_base_path (also under a --base-path nest; inactive with auth on). Front-door parity: hook_capture.rs every_native_hook_request_carries_the_client_marker (handoff GET, hook POST, batch POST), http_client.rs authenticate_no_token_sets_only_the_client_marker, the client-marker block of tests/hooks/test_lib.sh (every curl branch of the GET, the POST and the drain, plus a static check that every PowerShell header table carries it and every Invoke-WebRequest passes one), render_shared.rs assert_every_ts_request_carries_client_marker run for OpenCode, OpenCode 2, OMP, Pi and OpenClaw, external_capture_ts.rs (the rendered OpenCode plugin under Node sends no unmarked request) and external_capture_powershell.rs every_request_carries_the_client_marker (Windows leg); ai-memory-web/src/mount.rs web_surfaces_refuse_to_be_framed (/web, /web/pending, /web/login, /api/v1/projects all carry both headers; bites with deny_framing neutralized) STRONG with listed residuals. Bite checks: with the marker check disabled, the LAN e2e marker-less GET /handoff returns 200 and the unit layer test fails; with the proxy-header rule disabled, the proxied loopback e2e fetch claims the baton and the unit decision test fails; dropping the marker from the native handoff GET, the shell token-drain curl, a PowerShell header table or the TypeScript spool drain fails the matching front-door test. With the guard removed, the cross-origin GET /handoff returns 200, consumes the baton and moves the active-project pointer (the pre-fix behaviour); with the guard treating same-origin as foreign, the web UI control gets 403; with the Sec-Fetch-Dest check removed, the same-origin document GET /handoff returns 200 and the unit guard test lets a same-origin image through; with the host layer removed, a rebound /hook returns 202; a permissive CorsLayer fails the preflight assertion; reverting is_safe_image_target to the pre-fix rule fails the markdown test on /handoff?…, dropping the percent-decoding fails it on %2e%2e/, and emptying the route list fails it on a root-mounted handoff. To reproduce the bite on the 415 layer, remove the guard and make /hook read a raw body instead of Json: a text/plain hook then returns 202 and the test fails. Residual, closed by setting a bearer token: a browser that sends no fetch metadata even to a loopback host (Safari before 16.4) sends no Sec-Fetch-* header and no Origin on an image GET or a link click, so such a request to a loopback host still reaches /handoff (loopback keeps accepting marker-less legacy hooks) and the other, read-only GET routes. On a non-loopback host the marker requirement closes /handoff for every browser. A plain-HTTP proxy that rewrites Host to its loopback upstream and adds no forwarding header (nginx's default proxy_pass) looks exactly like a local client, so in front of an unauthenticated server it must add X-Forwarded-For or keep proxy_set_header Host $host, or the server must sit behind TLS or use a bearer token (security.md, https-via-proxy.md). Browsers that send fetch metadata no longer have the earlier link residuals: a link opened from another app (Sec-Fetch-Site: none) and a link clicked in a stored page (same-origin navigation) both carry a non-empty destination and are refused. With auth on, the bearer token and the session CSRF token are the gate and this layer is a no-op
12d The web UI and /api/v1 cannot write, and render stored text inert crates/ai-memory-web/clippy.toml disallowed-methods: every Wiki write and destructive method (write_page, write_page_if, apply_batch, the delete/evict/purge/restore/move/reindex/remove-dir helpers, commit_all, approve_auto_improve_proposal) and the writer() / git() accessors are lint errors in the crate, so the Wiki held by WebState stays read-only under cargo clippy -D warnings; only the integration-test module carries the allow, for fixtures. Templates are askama with HTML auto-escaping; the history diff (templates/history.html) and the session timeline (templates/session.html) print page lines, observation titles and bodies escaped, with no ` safe`, and no captured value is interpolated into a script ai-memory-web history_replay.rs session_timeline_renders_captured_markup_inert (a <script> title and body plus "><img onerror> and ' onmouseover=' payloads, checked to survive ingest first, render escaped) and history_diff_renders_page_markup_inert (the same payloads in a page version's diff lines); mount.rs web_surfaces_refuse_to_be_framed covers the history, timeline and history-API routes (200 with both anti-framing headers)
12e OIDC device login and refresh never send credential-bearing requests in clear text off loopback or through redirects ai-memory-llm/src/stored_token.rs CredentialEndpoint / credential_endpoint make TLS-or-loopback validation a typed prerequisite of the shared refresh-grant POST; oidc.rs discover, request_device_code, poll_token_once and refresh_access_token validate again at every request sink so a caller-mutated discovery or persisted endpoint cannot bypass login-time checks; refresh builds a no-redirect client; ai-memory-cli/src/commands/auth.rs builds every authentication-flow client with redirects disabled. https passes, plain http passes only for localhost, 127.0.0.1/127.0.0.0/8 and ::1, anything else is an LlmError::Auth oidc.rs discover_refuses_plain_http_issuer_before_any_request (remote http issuer refused with no request reaching the mock), discover_refuses_plain_http_endpoints_from_the_document (an http token or device endpoint in the document refused), credential_sinks_revalidate_mutated_discovery_endpoints (both device and poll sinks refuse caller-mutated remote HTTP, with loopback controls), refresh_refuses_a_persisted_plain_http_remote_endpoint, refresh_does_not_forward_the_refresh_token_through_redirects, require_tls_accepts_https_and_loopback_http_only (table incl. localhost.example.com); CLI auth_client_never_forwards_credentials_through_redirects; legitimate control discover_accepts_a_loopback_issuer_and_endpoints STRONG
13 Managed-run transcript attribution (concurrent launches in one checkout, invariant #16) ai-memory-store/src/workstream.rs link_native_session stamps native_session_linked_at on its own run only, both finish updates drop the stamp when the session changes, run_status reports it; ai-memory-cli/src/commands/run.rs resolve_native_session_after_run takes a linked session only when ai-memory-workstream native_session_in_checkout holds it for this checkout (OpenCode by recorded directory), never falls back to a link it set aside, and turns an AmbiguousNativeSession into a warning with nothing imported; for Claude it moves the run's own session to a background session only when ai-memory-workstream claude_continued_session finds a sessionKind: "bg" record that names that exact session as its attached client and this checkout as cwd (#1050), and to a /cleared session only when that session's own transcript records the /clear command and names the run's session as its launch session_id from this checkout or below it; ai-memory-workstream/src/transcript.rs discover_crush claims only the one top-level session created (or, with --continue, touched) during the run, and in a data directory outside the project only one that edited a file in it multi_session.rs a_session_linked_by_one_managed_run_is_not_another_runs; run.rs a_session_linked_during_the_run_wins_over_discovery (concurrent newer session, another checkout's link refused, no fallback to it, unlinked control); transcript.rs claude_continued_session_follows_only_this_checkouts_bg_records (a concurrent launch's background session, another checkout's, and a non-background record refused; own attachment control); transcript.rs claude_continued_session_follows_only_this_launchs_clear (an uncleared transcript, a quoted /clear, another checkout's clear, a concurrent launch's clear, a subagent file, and a pre-run clear refused; own clear and the newest of two as controls); run.rs a_claude_run_that_attached_to_a_background_session_follows_it, a_claude_run_that_was_cleared_follows_the_new_session; transcript.rs native_session_in_checkout_checks_the_opencode_directory; store/src/lib.rs managed_run_status_reports_a_link_made_during_the_run; run.rs ambiguous_crush_discovery_keeps_the_run; transcript.rs crush_discovery_claims_only_the_session_the_run_created, crush_discovery_in_a_shared_store_claims_only_an_edit_here PARTIAL: a run whose child links nothing still falls back to discovering the newest session in the checkout; Crush, which has no hooks, relies on that discovery alone and claims nothing when it is ambiguous
13a Managed Codex stale-daemon run recovery (#987; concurrent launches, project/worktree isolation, operator isolation) managed_runs.owner_user (V71) uses the topology-aware IdentityKey owner stamp; router.rs resolves and authorizes the SessionStart repository before handling the untrusted run id; store link_or_adopt_native_session selects and links in one writer transaction and admits only the sole live, undelivered, never-linked Codex run in the exact workspace/project/checkout-cwd/owner bucket. An active supplied id must itself match every boundary; another harness, an ambiguity, or a second native session is refused multi_session.rs stale_codex_run_recovery_cannot_cross_project_owner_or_session_boundaries (foreign owner, foreign checkout, and cross-project candidates refused; project-local controls and racing rebind), stale_codex_run_recovery_fails_closed_on_ambiguity_and_active_mismatch (two candidates and active foreign id refused, exact control); workstream.rs prepare_stamps_the_operator_bucket_used_by_session_start_recovery (HTTP actor stamp with foreign and legitimate controls); router.rs managed_session_start_delivers_ledger_and_pending_handoff supplies a finished stale id and proves the new run is linked and delivered STRONG for SessionStart recovery. No candidate is selected from a run id's stale scope, another checkout, or another operator bucket; ambiguity deliberately falls back to no managed packet
13b Managed-run lease exclusivity and explicit recovery (one active run per workstream, invariant #16) ai-memory-store/src/workstream.rs prepare_run expires lapsed leases and otherwise refuses an active run inside the writer transaction (StoreError::WorkstreamBusy). The explicit force_unlock path may expire and replace that row in the same transaction only when its durable owner_user equals the incoming actor's attribution; different operators remain isolated. heartbeat renews only active rows. ai-memory-cli/src/commands/run.rs normally uses wait_out_held_lease; --force-unlock instead asks once and fails immediately when refused. Neither path treats the informational lease_owner label as authority multi_session.rs force_unlock_replaces_only_the_same_operators_active_run (foreign operator refused with live control, same operator succeeds, old run loses heartbeat, unattributed single-user control); hooks workstream.rs force_unlock_cannot_evict_another_operator exercises the HTTP actor boundary; CLI run.rs force_unlock_asks_once_instead_of_waiting_out_the_lease; existing controls managed_workstream_batches_are_idempotent_and_release_the_lease, a_renewed_lease_is_reported_as_a_live_owner_not_taken_over, interactive_launch_waits_out_a_lapsing_lease_then_proceeds, and ctrl_c_aborts_the_held_lease_wait_immediately STRONG for exclusivity. The lease_owner label (host:pid) is informational only and not unique inside ai-jail (every jailed launcher reports ai-sandbox:<ns-pid>), so it must never become an ownership key. A shared unattributed/root context is intentionally one operator bucket; deployments needing person-level refusal must authenticate DB users
13c A native store shared by every project yields only this checkout's records (Antigravity history.jsonl or its print-mode brain transcript) ai-memory-workstream/src/transcript.rs export_antigravity — the conversation must first pass locate_session_file (UUID file name + .db workspace == cwd); every history.jsonl line must match both that conversationId and, by same_path, this cwd (a conversation resumed in another directory keeps its id but records that directory, so the id alone is not enough); an id-less opening prompt is attributed only when exactly one same-workspace candidate falls within 5 s of the .db creation time and no other conversation of this checkout was created within 5 s of it; slash/shell entries and oversized lines are dropped, and only records naming this conversation are reported as its losses; when history yields no prompt, antigravity_brain_prompt_events opens only a regular transcript canonically contained below this conversation, caps the file at 8 MiB and each line at 1 MiB, and accepts only explicit USER_INPUT steps transcript.rs antigravity_history_exports_only_this_conversations_prompts_in_this_workspace (other conversation in this and another workspace refused; own control passes), antigravity_history_drops_prompts_from_a_resumed_conversation_in_another_workspace (same id, foreign workspace refused), antigravity_export_rejects_a_conversation_from_another_workspace, antigravity_export_rejects_unknown_or_traversal_ids, antigravity_opening_prompt_is_refused_when_another_conversation_started_with_it (an opener another conversation of this checkout could own is refused), antigravity_opening_prompt_covers_a_single_prompt_conversation (control), antigravity_history_reports_no_losses_for_foreign_records, antigravity_print_mode_falls_back_to_explicit_brain_prompts; backfill_e2e.rs backfill_imports_antigravity_prompts_from_history_and_nothing_foreign (foreign prompts absent from wiki and db) STRONG
13d An explicit backfill session ID retains the native adapter's selection boundaries ai-memory-workstream/src/transcript.rs find_native_session validates the native ID, reuses the file adapter's exact lookup and header/cwd match, checks OpenCode v1/v2 directory in the same SQL query as the ID, and excludes Crush sub-agent/title sessions with parent_session_id IS NULL; backfill.rs uses this lookup only for --session, leaving automatic listing caps intact backfill.rs collect_local_sessions_explicit_file_target_bypasses_listing_cap rejects missing/invalid IDs and a matching ID from another cwd while selecting the old local session; collect_local_sessions_explicit_sql_target_bypasses_listing_cap checks both OpenCode versions, preserving each timestamp and refusing another cwd; collect_local_sessions_explicit_crush_target_keeps_subagents_excluded admits the parent but refuses its child and an invalid timestamp STRONG
14 Per-project authorization (#708) ai-memory-store/src/project_authz.rs authorize_project / ProjectAuthz::authorize choke point (V68 project_grants + projects.access_mode, default open; V69 projects.created_by feeds is_creator); scope.rs ScopeResolver::with_project_authz (reader pool for reads, writer actor for writes) and its free forms authorize_scope_for / *_guarded, attached for every DB user by ai-memory-mcp scope_resolver_as, ai-memory-web authorize_read / lookup_project, and ai-memory-hooks (grants.rs authorize_resolved for run/workstream ids, the capture check in router.rs); read-shaped mutations resolve at ProjectAccess::Write (resolve_existing_args(.., need)); unscoped reads filtered before LIMIT by reader.rs readable_repository_sql; WriterHandle::authorize_project as defense in depth. Page ids are otherwise never taken from a caller (only derived from already-authorized hits); the one exception, the web page-history from/to version ids, is looked up only inside the scope routes/mod.rs resolve_read_scope (lookup_existing_scope_guarded, ProjectAccess::Read) has already authorized and the requested path (page_version_body), so a foreign id reads as not found; incremental recent resolves and authorizes the requested project before decoding its scope-bound cursor; batch outcomes do not bypass the capture grant or session owner check tests/suite/project_authz.rs (decision matrix, ship-inert, resolver gate); tests/suite/access_mode.rs every_caller_against_both_modes, a_restricted_project_admits_the_team_and_refuses_the_outsider, new_projects_follow_the_server_default_and_admit_their_creator; scope.rs the_argument_shape_does_not_decide_the_level, a_user_reaches_only_what_they_were_granted, creating_authorizes_against_a_project_that_already_exists, a_refused_scope_fails_the_search_instead_of_shortening_it; grants.rs search_finds_only_what_the_viewer_may_read, the_limit_counts_only_what_the_viewer_may_see, the_workspace_handoff_comes_only_from_readable_repositories; ai-memory-mcp server.rs a_reader_may_read_everything_and_change_nothing, bob_cannot_read_alices_page_in_a_restricted_project, bob_cannot_find_alices_page_by_searching_in_a_restricted_project, observation_stream_evidence_stays_inside_a_restricted_project (with [retrieval] observation_stream on, a non-grantee naming the restricted project, listing it in scopes, or searching their own project never sees the session page or its observation excerpt; the writer and a read-grant holder do; fails with the read check in ProjectAuthz::authorize neutralized), bob_cannot_consolidate_a_session_in_alices_repository, a_restricted_projects_queues_need_write; ai-memory-hooks a_capture_needs_writer_on_the_repository_it_lands_in, session_start_delivers_nothing_from_a_repository_the_viewer_cannot_read, a_reader_cannot_change_a_projects_profile_flags_at_session_start (a Read grant's profile_contribute/profile_consume at session start neither opts the project out nor back in; Write-grant control records both; fails with the Write check forced on), run_and_workstream_ids_only_answer_someone_who_may_reach_the_repository (foreign raw workstream id refuses populated provenance; granted reader receives the source record and tool correlation); ai-memory-web web_reads_honour_grants_in_a_restricted_project (also a paginated namespace URL, /p/secrets/?page=2), metadata_shows_only_what_the_viewer_may_read — each with a granted or open-project control, and proven to fail with the choke point (19 tests) or the SQL filter (9 tests) neutralized; routes.rs api_recent_incremental_rechecks_restricted_scope_on_cursor (a valid cursor cannot bypass a revoked grant; granted control passes), api_recent_incremental_paginates_over_120_pages_and_binds_cursor; mcp_stateless_http.rs generic_machine_client_writes_queries_and_claims_a_handoff (real machine key, foreign scope and partial scope refused); router.rs an_unauthorized_batch_item_is_consumed_rather_than_retried, batch_acknowledges_foreign_collision_then_commits_next_item (refused foreign item followed by a legitimate stored item); ai-memory-web history_replay.rs history_and_timeline_honour_grants_in_a_restricted_project (page history in HTML and JSON and the session timeline: a non-grantee gets 403 without the body, a grantee and root get 200; bite: resolving through the unguarded lookup_existing_scope fails it) STRONG — slice 3 closed both bypass classes (unscoped reads, raw-id entry points) and added the root-only management surface. Out of scope by design: per-project administrators (granting/restricting is root-only), and access modes, creators and grants live only in SQLite, so reindex resets them
14aa Companion capture privacy before persistence and delivery companions/ai-memory-client/src/lib.rs reject_sensitive, sanitize_external_value, check_body; src/scrub.rs sanitize_external_text; relay identity::validate, check_scope, relay::init and flush_locked; importer plan_external_conversation, planned_hook_event, truncate_utf8, ImportClient::post_hook_batch; importer agentmemory routes vault::plan, export::plan, export::replay_session, agentmemory::validate_id SDK secret-position, nested key, numeric metric (11 names plus numeric *_tokens counts; string values still redact), bounded schema and literal-marker tests; relay sensitive_envelope_is_rejected_before_enqueue_with_clean_control, new_native_bodies_are_sanitized_before_hash_enqueue_and_exact_retry, unsafe_legacy_pending_is_dropped_locally_and_never_blocks_its_session, unsafe_legacy_native_identity_is_dropped_and_its_session_continues, legacy_binding_scope_spaces_are_preserved_on_delivery; importer sensitive_native_identity_is_refused_before_manifest_and_http_with_unicode_control, shared_key_sanitation_precedes_plan_manifest_transport_and_exact_retry, preview_and_manifest_use_scrubbed_bodies_and_digest, forged_body_authority_is_refused_before_transport, sanitized_redaction_markers_survive_utf8_byte_caps_in_bodies_and_titles, agentmemory page_bodies_are_redacted_before_planning, text_is_redacted_before_the_plan_exists (page bodies and replayed observations), ids_that_look_like_credentials_or_carry_controls_are_refused. Controls preserve opaque native Unicode IDs, metric representation and untrusted provenance. An unsafe item queued before these checks never reaches the wire (body or request line); it leaves the queue as a local dropped_policy receipt so the rest of its session ships. Guard-removal runtime probes target the final formatted sources and restore identical hashes. Client-side privacy only; server scope, auth, admission and capture-policy guards remain authoritative
14ap Managed-run mutation owner and current project access (finish, cancel, heartbeat, native-session link, context acceptance) hooks/src/workstream.rs authorize_run_owner derives ManagedRunAuthority only from authenticated middleware extensions and checks the real run before any mutation — for finish before status/payload/segment handling; cancel, heartbeat, link and context acceptance go through the same helper, so none is a side door around finish's rule; ReaderPool::authorize_managed_run and store/src/workstream.rs authorize_run_mutation use a read snapshot and the existing writer transaction, respectively. Strict resolution (project_authz.rs resolve_project_authz_strict, the canonical decision with a fail-closed resolution mode, so the reserved global-scope write gate applies here too) requires the actual workspace/project pair, current user existence and current Write decision for DB principals. The private trusted-proxy policy requires authenticated User capability, a canonical identity, no DB principal and server proxy configuration; it retains legacy project admission after strict scope validation, with ownership still enforced. Human-login disable does not revoke API keys. The legacy resolver and auth middleware remain unchanged. Both writer entry paths, including finished retries, require the same authority; no cross-owner bypass MCP auth.rs owner_finish_http_refuses_another_writer_before_payload_or_segment, owner_finish_http_trusted_proxy_preserves_restricted_lifecycle, owner_finish_http_active_api_key_survives_disabled_human_login; store multi_session.rs owner_finish_store_refuses_another_writer_including_finished_retry, owner_finish_store_rechecks_write_after_preflight, owner_finish_store_refuses_a_deleted_user_after_preflight, owner_finish_store_proxy_policy_requires_server_and_authenticated_identity, owner_finish_store_raw_ids_use_the_actual_project_and_workspace, owner_finish_store_topology_reload_and_phase_controls, owner_finish_store_strict_resolution_refuses_pairing_missing_and_sql_failure, owner_finish_store_keeps_qualified_identity_namespaces; hooks workstream.rs owner_finish_revocation_between_preflight_and_both_writer_paths; MCP auth.rs owner_finish_http_real_auth_rungs_shared_and_project_controls, owner_finish_http_preserves_late_active_terminal_and_missing_phases; hooks workstream.rs run_mutation_routes_refuse_another_operator (another operator and root under another identity refused on heartbeat/link/accept/cancel, run left active; owner admitted); store project_authz.rs strict_resolution_shares_the_global_gate_and_fails_closed_on_a_gap. Guard-neutralization recipes and results accompany the local frozen patch SQL refusal is atomic within finish's writer transaction; a revocation after preflight can leave an unindexed raw segment. Cancel, heartbeat, link and acceptance check one read snapshot immediately before a single-row update (a run's owner never changes). A later hook event carrying AI_MEMORY_RUN_ID links its native session only through link_native_session_in_scope, which applies the SessionStart boundary (ManagedRunBoundaryRow::admits: the run's own project and operator) and refuses a foreign run id while the event itself is still captured (router.rs hook_event_links_a_managed_run_only_from_its_operator, hook_event_in_another_project_does_not_link_the_run, control hook_event_links_a_shared_run_on_a_single_operator_server; #1082). Shared NULL ownership, trusted-proxy project admission and late still-active finishes remain intentional
14au Exact native managed identity and privacy (invariant #16) core/src/workstream.rs NativeSessionIdentity validates original bytes and exact scrub equality; workstream/src/harness.rs and transcript.rs retain selector/path restrictions; CLI run.rs validates old-server prepare/status, planned selectors and finish transport; hooks workstream.rs checks payload and selected identity before raw segments, with the existing owner/current Write preflight first; router.rs validates both managed auto-links while preserving legacy shared capture; store workstream.rs carries validated identities into link/finish SQL after finish authority and before mutation. Store, HTTP search and CLI search project invalid historical identity to empty String without rewriting history Core native_identity_original_bytes_limits_privacy_and_collisions; harness native_identity_selector_rejects_original_before_resume_arguments; transcript native_identity_adapter_preserves_exact_and_rejects_privacy_changes, copilot_discovery_requires_uuid_directory_header_and_checkout (another checkout's session, a session.start naming a different session than its directory, and non-UUID or ../ ids refused; exact-checkout control), claude_transcript_is_located_by_the_real_folder_name (a server-linked Claude id probed across project folders still resolves only to a transcript whose own header names this checkout; another checkout's transcript and a subagent sidechain with the same id are refused), codex_compressed_rollout_still_exists_only_for_its_own_checkout (a Codex rollout compressed to .jsonl.zst is located through the same header and checkout match: another checkout's compressed session is refused, and a copy whose header does not decode is skipped; exact-checkout control); store multi-session native_identity_store_link_refuses_original_dirty_bytes, native_identity_store_adoption_refuses_before_link, native_identity_store_finish_refuses_without_sql_or_index_mutation, native_identity_store_history_projects_unknown_without_rewriting; hooks native_identity_http_link_refuses_before_status_or_sql, native_identity_http_finish_refuses_before_segment_or_sql, native_identity_http_event_guard_and_configured_history_projection, native_identity_http_stored_identity_refuses_before_raw_segment, router native_identity_managed_start_refuses_but_keeps_shared_legacy_capture; CLI native_identity_run_preflight_refuses_before_resume_or_private_path, native_identity_run_old_server_refusal_prevents_child_and_transport, native_identity_finish_transport_refuses_before_request_and_preserves_exact_control, native_identity_run_status_and_expected_refuse_before_discovery, native_identity_run_configured_selector_refuses_before_link_or_child, native_identity_run_configured_old_status_refuses_before_native_io_and_finish, native_identity_run_configured_discovery_refuses_before_export, suite native_identity_search_old_server_json_projects_unknown_and_keeps_history Representation/privacy only: no native authenticity, file-existence, run/event correlation or outcome proof. Original legacy rows and shared observation semantics remain intact; parent finish owner/current Write rules remain mandatory
14b Repository identity routing (#708) ai-memory-store/src/ops.rs resolve_project_by_identity — one transaction; an identity already on a project is never overwritten; an unclaimed project is claimed only when the capturing user may write it (the choke point's resolve_project_authz on the same transaction), otherwise it is returned unclaimed; a different identity under the same name splits into a new project with no shared repo_path; when a Phase-5 client explicitly sends IdentityStyle::Path (#1033) a project it creates takes path_style_name only while no different full identity in the workspace claims that canonical key (checked in the same transaction), so the same path on another forge falls back instead of being merged; authorized captures can claim/promote compatible legacy rows in that transaction while preserving UUID, but handoff/static reads never rename; explicit host_path remains the opt-out; ai-memory-hooks/src/router.rs main_checkout_candidate offers a linked worktree's main-checkout project as the claim candidate only when linked_worktree_main_root finds a git worktree add link (never a submodule, a bare repository's worktree or a separate git dir), the main checkout's name is not a reserved scope (_global, _profile, _profile.*), and that project, looked up in the resolved workspace, holds no identity; the transaction above still decides the claim (#1880); ai-memory-hooks/src/workstream.rs resolve_run_scope sends a managed run through the same transaction (identity holder, else the $HOME-guarded cwd-prefix candidate, inside the requested workspace only) only when the wire identity derives the requested name, then authorizes Write (#1182); ai-memory-hooks/src/router.rs cache_key_for keys the path cache by identity and style; ai-memory-core/src/repository_identity.rs strips credentials from remote URLs client-side, and the server accepts only the routing rungs (explicit, git_remote) from the wire tests/suite/identity_resolution.rs an_outsider_cannot_take_an_unclaimed_projects_identity (control: an_existing_project_is_claimed_in_place), two_unrelated_repositories_with_one_folder_name_stay_apart, a_created_or_split_project_admits_its_creator, the_same_path_on_another_forge_falls_back_instead_of_merging, an_unclaimed_project_holding_the_path_name_is_not_taken, old_client_omitted_style_stays_host_path_and_does_not_promote, explicit_path_capture_claims_and_promotes_an_identityless_legacy_name_in_one_transaction, unauthorized_capture_cannot_claim_or_promote_an_identityless_legacy_name, and explicit_path_capture_falls_back_when_another_identity_claims_the_canonical_key (controls: the_path_style_names_a_new_project_from_the_host_less_path, opting_in_leaves_existing_projects_where_they_are), multi_session.rs two_operators_on_two_clones_of_one_repository_share_its_path_named_project; hooks workstream.rs managed_run_by_remote_identity_refuses_a_viewer_without_write, managed_run_identity_never_claims_a_restricted_legacy_project, managed_run_identity_never_redirects_another_project_name; router.rs the_path_style_names_a_new_repository_and_never_merges_another_forge, one_path_with_two_remotes_is_two_projects, two_api_checkouts_with_different_remotes_get_two_projects (a manifest rung on the wire is ignored), a_linked_worktree_never_takes_a_project_holding_another_identity, a_linked_worktree_never_adopts_another_workspaces_project and a_linked_worktree_never_adopts_a_reserved_scope (control: a_linked_worktree_adopts_the_v2_project_its_main_checkout_would); consolidate linked_worktree_main_root_answers_only_for_a_linked_worktree (a main checkout, a submodule, a bare repository's worktree and a plain directory are refused); repository_identity.rs credential and normalisation tables — the claim guard and the cache key each proven to fail their test when removed STRONG — first claimant wins: in a restricted workspace a user who creates a project under a remote identity first holds it until root grants others
14bb Local marker aliases cannot cross repository or workspace boundaries (#1033) ai-memory-core/src/repository_identity.rs owns the bounded MarkerAliases type and exact one-line/root-level portable grammar; native/POSIX/PowerShell/generated TypeScript clients forward one normalized JSON-array query value only with marker provenance and a hostful git-remote identity; ai-memory-store/src/project_coordinates.rs probes exact names only inside the selected workspace, deduplicates by UUID, and requires the selected row's full stored git-remote identity; ops.rs authorizes in the writer transaction and reuses Phase 1 promotion_target, additionally requiring marker project to equal the canonical path-style name derived from that remote; handoff uses the read-only path and capture uses the write-authorized path; router.rs includes aliases, provenance, and read/write mode in its cache key Core/CLI shared marker_aliases fixture parity covers duplicate keys, table placement, multiline arrays, trailing junk/comma, escapes, max length and duplicate-heavy over-count; store marker_aliases_require_same_remote_identity_and_preserve_uuid, marker_aliases_cannot_promote_to_an_arbitrary_marker_project, hostile_ambiguous_and_cross_workspace_marker_aliases_fail_closed; hooks hook_and_handoff_queries_validate_aliases_identically, malformed_aliases_are_rejected_before_subagent_scope_resolution, empty_aliases_preserve_marker_project_precedence, capture_promotes_an_alias_but_handoff_only_reads_it, project_cache_separates_alias_sets; shell marker aliases keep canonical project and forward remote identity; Windows PowerShell parity and capture-only marker transparency run in Windows CI; OpenClaw openclaw_runtime_preserves_marker_and_home_identity_precedence proves no-marker remote routing sends explicit path, ordinary project markers keep name precedence and omit identity, while alias markers and home identity routes forward it STRONG: hostile arbitrary-name, different-identity and ambiguous aliases refuse or resolve without rename with a legitimate canonical same-identity control; another workspace is never searched; no alias table or persistent fallback exists
14bb2 Operator-home route selectors cannot silently cross repository or path boundaries (#1033) ai-memory-cli/src/marker.rs returns a typed invalid result for malformed/oversized maps; command scope resolution propagates it unless both CLI scope fields are explicit, while native hooks drop before spool/network. The native, POSIX, PowerShell, generated TypeScript and OpenClaw parsers enforce the shared 64-route/64-KiB/512-byte grammar, recognize malformed [routes, routes =, routes., and orphan route_* syntax before any no-routes return, preserve legacy parsing for malformed root-only settings without route syntax, apply global duplicate-field/raw-selector/normalized-path checks, require exact hostful identities (including host-edge-dot refusal), match paths component-wise, and enforce a no-escape boundary for ~/ selectors. A route replaces only routing fields; root privacy/behavior flags survive. Bounded native/PowerShell/TypeScript reads reject before full-file allocation where their APIs permit. ai-memory-core/fixtures/home_route_cases.json is executed by native marker.rs, POSIX, PowerShell, generated TypeScript, and OpenClaw runtime parity, including malformed route syntax and root-only malformed legacy behavior; shell test_lib.sh also exercises route selection, sibling refusal, root-setting retention and invalid-map drop; Windows powershell_marker_aliases.rs executes drive and UNC path routing independently of identity; generated TypeScript runtime tests assert marker versus repo-root project_src; CLI tests prove unscoped/partial refusal and complete-explicit bypass. STRONG for native/POSIX/generated TypeScript/OpenClaw on this platform; PowerShell runtime evidence is enforced on Windows CI and skipped where PowerShell is unavailable
14bc Project-coordinate diagnostics are root-only, read-only and credential-safe (#1033) ai-memory-store/src/reader.rs diagnose_project_coordinate and project_coordinates.rs share one bounded indexed matcher and the write path's canonical-only promotion predicate; ai-memory-mcp/src/admin.rs mounts GET /admin/project-coordinate behind the shared Capability::Admin middleware and returns no stored identity value; ai-memory-cli/src/marker.rs and commands/hook_capture.rs provide one strict typed local inspection consumed by doctor, which reports only marker/source classes, identity source/style and derived names. Ambiguous count lookup keeps local rows and marks captured counts unavailable Store identity_resolution.rs coordinate_diagnostic_classifies_exact_canonical_legacy_and_missing_without_mutation, coordinate_diagnostic_reports_cross_forge_and_identityless_collisions; project_coordinates.rs shared_candidate_query_deduplicates_before_bound_and_uses_only_indexes; MCP admin_status_search.rs project_coordinate_reports_all_statuses_and_never_mutates, project_coordinate_is_root_only_after_multiuser_enablement, project_coordinate_single_user_admin_contract_remains_open, plus the shared all-admin 403/401 route matrix; CLI doctor.rs project_coordinate_renders_promotion_and_cross_forge_fallback_concisely, local_coordinate_reports_marker_precedence_invalid_toml_and_no_credentials; marker.rs strict inspection tests; doctor_e2e.rs ambiguous_coordinate_keeps_local_sessions_and_marks_capture_unavailable STRONG: project/audit/user/grant/page counts, names and manifest bytes are snapshotted; DB-user/anonymous refusal has a root control; sentinel repo paths, identities, users, grants, pages, malformed marker text, absolute marker paths and credential-bearing remotes do not appear in output; an ambiguous preferred candidate remains contextual only and is never rename-eligible
14c Client-supplied event time is bounded and self-scoped (#919) ai-memory-hooks/src/payload.rs HookEnvelope::occurred_at_micros — a /hook caller's optional occurred_at must be > 0 and <= now + 5min; it only sets the caller's own admitted session's started_at/ended_at/created_at, never another session/project/user, and the ingest dedup seen_at/TTL stays on now payload.rs occurred_at_micros_rejects_a_far_future_timestamp, …_rejects_non_positive_values, …_rejects_garbage_strings MEDIUM — self-scoped numeric bound; no cross-tenant surface (a client already controls its own content)
14d include_related and the web page's backlinks show and walk only readable projects (#708) ai-memory-store/src/reader.rs related_walk(.., viewer) — both the outgoing and incoming hop queries carry readable_repository_predicate("pg.project_id", viewer), the same far-end filter page_links and page_links_preview apply (the preview's visible totals are counted under it too), so a page in a project the viewer cannot read is neither returned nor expanded; ai-memory-mcp/src/server.rs memory_read_page passes viewer_from_parts, ai-memory-web/src/routes/page.rs passes the request's viewer to page_links_preview, and the access bump only touches the filtered nodes related_walk.rs the_walk_hides_and_does_not_cross_projects_the_viewer_cannot_read (an outgoing and an incoming neighbour in an ungranted restricted project are absent, and so is a granted page reachable only through one; control: a granted restricted project is shown, and no viewer walks the whole graph) — fails with the predicate removed; ai-memory-web tests/suite/routes.rs page_backlink_from_an_unreadable_project_is_hidden (the /web page's "Cited by" omits a page in an ungranted restricted project, with no title, path or project name; controls: a reader of both projects and an unrestricted viewer see it) — fails with the page handler passing no viewer to page_links_preview; related_walk.rs page_links_preview_caps_in_sql_and_counts_only_readable_neighbours (back-links from an ungranted restricted project are neither listed nor counted in the total behind "and N more"; control: no viewer counts them all) — fails with the predicate removed; ai-memory-mcp server.rs bob_does_not_see_restricted_pages_through_the_related_walk (a 600-character UTF-8 body capped by max_chars=500; an ungranted user's memory_read_page{include_related} omits the restricted page; control: no viewer still reaches it) — fails with memory_read_page passing None instead of viewer_from_parts STRONG
14e memory_write_page session evidence cites only a session of the target project (#708) ai-memory-mcp/src/server.rs memory_write_page — a session_id is accepted only when require_session_in_scope resolves the session (where its observations landed, else its session row, as Consolidator::session_target does) to the same (workspace_id, project_id) the write grant was checked against; unknown and foreign ids get one refusal, so the error is no existence oracle; scope: "global" with a session_id is refused; refuse_pinned_page_overwrite keeps a write that cites a session off a pinned page; only a write to sessions/<id>.md reconciles the session's queued SessionEnd job server.rs write_page_refuses_a_session_from_another_project (a foreign and an unknown session refused, no evidence row written, the foreign job still queued; control: the project's own session accepted), session_evidence_write_leaves_a_pinned_page_alone (control: the same write without session_id edits the page), session_evidence_on_another_path_leaves_the_job_queued, write_page_rejects_a_malformed_or_global_session_id — each of the scope check, the pinned check and the session-page-only reconcile proven to fail its test when removed STRONG
14f Consolidation apply path validates generated cross-scope body links and every typed relation against the store (#1218, #1353) ai-memory-consolidate/src/link_guard.rs unresolved_generated_links keeps body and relation refusals separate. Every [[project:path]] / [[workspace/project:path]] / [[_global:path]] target in a proposed body is resolved with the no-create lookup_existing_scope and batch-checked via reader.rs existing_latest_paths; a missing workspace/project, ambiguous project name, missing or TTL-expired target de-links the body link. Every typed relations: target is checked too, including same-project targets; a local target is admitted only when its latest version is unexpired or it is another page in the same atomic batch. prune_relations drops malformed and unresolved entries. Same-project body links stay untouched by design. Wired into consolidation single/batch and bootstrap before writes; restricted cross-project probes reveal no paths consolidator.rs batch_delinks_invented_cross_scope_wikilinks, single_page_delinks_invented_cross_scope_wikilinks, single_page_drops_unresolved_cross_scope_relations; link_guard.rs same_project_relations_require_existing_or_same_batch_targets (missing local relation refused, same-batch relation and dangling local body link controls), malformed and cross-scope prune tests; bootstrap cross-scope test; store multi_session.rs existing_latest_paths_reports_exactly_the_live_paths (expired target refused, live and future-expiry controls admitted), existing_latest_paths_reports_nothing_for_a_restricted_project STRONG
14g Web project search and its recall trace honour memory_query's scope rules (#708) and never describe another project ai-memory-web/src/routes/search.rs resolves workspace+project through resolve_read_scope (lookup_existing_scope_guarded, no-create, ProjectAccess::Read) before any ranking, and refuses partial scope; scoped /api/v1/search keeps lookup_project / resolve_many_existing_scopes_guarded; ai-memory-web/src/recall.rs ranks only the resolved scopes through ReaderPool::hybrid_search_scopes, whose streams and graph expansion are bound to each (workspace_id, project_id); a search with no scope stays search_pages_with_meta(.., viewer) (readable repositories only) ai-memory-web tests/suite/recall_trace.rs — project_search_refuses_a_restricted_project_without_a_grant (bob, with no grant, gets 403 from /web/search with and without explain=1 and from scoped /api/v1/search, with no path, body text or trace in the response, and a scopes POST naming the restricted project next to an open one is refused; alice's grant and an unrestricted viewer are the controls), project_search_fails_closed_on_unknown_and_partial_scope (unknown project or workspace 404 with nothing created, partial scope 400), explain_renders_stream_ranks_rrf_authority_and_timings (a better-matching page in a sibling project never reaches the hits or the trace), search_scope_selector_lists_only_readable_projects (the search page's "Search in" selector lists only projects the viewer may read, and a hand-typed scope= for an ungranted project is a 403 that leaks nothing; controls: the granted reader and an unrestricted viewer; passing no viewer to list_projects_with_stats in the handler fails it), routes.rs search_page_scope_selector_round_trips_and_rejects_malformed_values (a malformed scope is a 400), search_alias_links_require_a_grant_and_refuse_ambiguous_names (canonical and legacy keys, before and after promotion, refuse an ungranted reader without hits or trace, including an empty query; a granted reader and root are controls, and an ambiguous legacy key stays a 400); recall_trace.rs kind_filter_does_not_widen_what_a_viewer_can_read (a kind/tier filter only narrows: bob gets no hits and a 403 on a scoped search; alice and an unrestricted viewer are the controls), search_filters_a_project_by_kind_and_tier_keeping_rank_order (survivors of a filter keep the unfiltered order), reranker_is_shown_only_the_pages_the_filter_keeps (a dropped page never reaches the reranker), kind_and_tier_filters_hold_in_every_stream (FTS, entity, vector, observation and both graph directions each filter in SQL; dropping any one stream's predicate fails it), kind_filter_finds_a_rare_kind_the_unfiltered_page_ranks_out and cross_project_kind_filter_sees_past_the_candidate_window (the filter sees past the candidate window in both modes); ai-memory-mcp tests/suite/web_search_parity.rs (same top-k order as memory_query from /web and /api/v1, with a deterministic embedder and with none, explain on and off, and merged scopes; controls show a web search without the embedder, or the old FTS-only scoped search, would fail it) STRONG. Bite checks: passing no viewer to resolve_read_scope in the search handler, to lookup_project or to resolve_scopes in the API each fails the restricted-project test; dropping the query vector in recall.rs fails the embedder parity tests
14h Wiki link graph pages and JSON show only readable projects (#708) ai-memory-web/src/routes/graph.rs global_handler calls ReaderPool::cross_project_edges(None, viewer) so an edge needs both ends readable; project_handler resolves through resolve_read_scope (lookup_existing_scope_guarded, no-create, ProjectAccess::Read) then project_link_graph, which ranks and caps nodes in SQL before loading them and queries only edges whose endpoints are among those selected pages; api.rs graph_handler accepts workspace+project together (partial scope 400) and passes the same viewer filter, and project_graph_handler uses lookup_project routes.rs metadata_shows_only_what_the_viewer_may_read (HTML /web/graph, /web/w/…/graph, /api/v1/…/graph, and scoped /api/v1/graph?workspace=&project=: bob cannot see alpha or client-work, a 403 on alpha's graph leaks neither title nor path, a scoped graph hides an edge whose far end he cannot read; carol and no-viewer controls keep the edge; partial scope 400); store project_link_graph.rs hides expired pages, omits cross-project and unresolved links, and verifies the 120-node SQL cap preserves high-degree nodes; graph.rs graph_page_renders_hostile_titles_inert STRONG. Bite checks: passing no viewer to cross_project_edges in the HTML global handler, resolving the project graph through unguarded lookup_existing_scope, or removing the SQL limit fails the restricted-project or node-cap assertions
14i Decoded ordinary Markdown destinations stay inside their original project ai-memory-wiki/src/markdown.rs decode_markdown_destination_path decodes URL path bytes once before normalize_link_target applies scheme, separator and project-root traversal checks; wikilinks remain literal. ai-memory-web/src/markdown.rs scope_relative_link checks the decoded path before route encoding; an encoded spelling cannot become a generated cross-scope route. markdown_url_paths_decode_once_before_link_resolution (space, Unicode and literal-percent controls); decoded_markdown_paths_cannot_escape_or_change_scope (encoded root escape, backslash, external scheme, invalid UTF-8 and controls refused; legitimate in-root normalization passes); routes.rs encoded_markdown_links_resolve_and_remain_in_the_source_scope writes colliding targets in sibling projects and workspaces, verifies home resolution and no foreign backlinks, and follows the generated home URL; web decoded_markdown_destinations_cannot_change_the_web_scope (encoded traversal, root route, separator and scheme refused, encoded w/ remains a page inside the current scope); markdown_url_destinations_are_decoded_once_before_route_encoding STRONG for one-decode path handling and project confinement; URL grammar outside local Markdown destinations remains owned by the Markdown parser and existing safe-URL checks
14j Structured MCP query filters only narrow authorized page results ai-memory-mcp/src/server.rs parses bounded kind, tier, literal path_prefix and exact tag values without changing the normal scope-shape or authorization paths, then passes one typed PageFilter through project, multi-scope, cross-project, reserved-global/profile, historical and pinned searches. ai-memory-store/src/reader.rs binds every filter value as a SQL parameter before each stream's candidate cut; path wildcard characters are escaped and an exact binary-prefix check preserves case, while tags match only string members of a JSON array. A filtered miss cannot fall through to raw observations, which carry no page metadata. server.rs memory_query_filters_apply_before_every_result_source combines all filters and covers literal %/_, case-sensitive paths, tag arrays versus scalars, multi-scope and global search, as_of, superseded metadata, pin_first, the reserved-global/profile union, traversal-shaped input, invalid tiers, controls and Unicode length bounds; store structured_filters_hold_in_vector_and_both_graph_directions isolates path filtering in the vector stream and tag filtering in outgoing and incoming graph expansion; page_filtering_precedes_the_observation_candidate_cut puts 80 stronger excluded observations ahead of an eligible tagged session; memory_query_returns_raw_hits_when_pages_miss proves an unfiltered miss retains fallback while a filtered miss omits it; prompts_and_tool_schema_document_query_options pins the public schema. Existing web every-stream and authorization tests in row 14g exercise kind/tier across the same shared SQL. STRONG: filters are candidate predicates, never an alternative scope resolver. Empty filter fields normalize to absent for backward compatibility; observation fallback remains available only to unfiltered queries.
14k Optional document import treats local files as bounded untrusted input companions/ai-memory-importer/src/document.rs accepts one explicit regular file on Unix (and fails closed elsewhere), refuses final symlinks, uses O_NOFOLLOW plus opened-inode verification, caps source/archive/entry/working/stored text/PDF-stream/sheet/actual-cell dimensions, streams XLSX cells without allocating their coordinate rectangle, follows PPTX relationship order, rejects unsupported or malformed formats, sanitizes extracted text before manifest or transport, derives the destination and stable provenance key from the source SHA-256, and writes through MCP create_only with explicit scope. A conflict is accepted as idempotent only when the current page body exactly equals the current sanitized plan; a provenance marker alone is never trusted and another page is never replaced. Shared manifests use randomized private same-directory temporary files, fsync, and atomic replacement. Importer document::tests: generated bounded and over-limit PDF, visible-text DOCX, relationship-ordered PPTX, sparse-coordinate XLSX, text and cue-state VTT/SRT controls; subtitle_cues_are_sanitized_before_the_document_plan keeps ordinary and NOTE-prefixed cues across LF/CRLF/CR, redacts a credential in each, and excludes actual comments; text_plan_is_redacted_bounded_attributed_and_deterministic; unsafe_sources_prefixes_and_malformed_archives_fail_closed; zip_preflight_refuses_excessive_claimed_expansion; apply_is_conditional_idempotent_and_refuses_foreign_pages; shared writer tests cover repeated replacement and a pre-created legacy temp symlink. STRONG for explicit Unix local text extraction and conditional persistence. Operator review with --show-body remains necessary because DOCX formatting-hidden text can be extracted. OCR, images, raw media, watch folders and server-side upload are excluded.
15 Agent-archive restore path confinement, resource bounds, and consistency ai-memory-cli/src/commands/restore_agents.rs stages only bounded regular UTF-8 entries; requires a one-to-one manifest/body/checksum/target mapping; allowlists destinations by scope; rejects symlinked descendants; treats differing portable permissions as an overwrite requiring --apply --force; writes each file atomically and rolls back earlier writes after a later failure. backup_agents.rs skips direct and directory-root source symlinks, bounds individual assets, attributes a shared skill root only once, and atomically replaces a private archive only after gzip completion backup_agents.rs restore_agents_checks_permissions_before_skipping_identical_content (same bytes with changed mode are previewed and refused without --force; forced restore preserves a backup and a second run is a no-op), restore_agents_without_archived_permissions_keeps_identical_file_mode (missing-mode control), restore_agents_rejects_path_traversal, restore_agents_rejects_unauthorized_destination_path, restore_agents_verifies_sha256_integrity, restore_agents_requires_a_complete_one_to_one_manifest, restore_agents_rejects_oversized_entries_from_the_header, restore_agents_rejects_a_symlinked_destination_parent, backup_agents_does_not_follow_config_or_asset_root_symlinks (Claude and Antigravity roots), and failed_backup_leaves_the_previous_archive_intact; backup_and_restore_agents_round_trip and antigravity_backup_round_trips_every_documented_skill_root are the valid-path controls; restore_agents::tests::rollback_removes_new_files_and_restores_overwrites covers recovery STRONG
16 Relay queue identity, migration, and private filesystem state companions/ai-memory-relay/src/queue.rs Queue::open_inner performs read-only identity preflight, rechecks under IMMEDIATE, commits schema and metadata together; configure checks the presence of user objects and rechecks identity/schema_version metadata on the same connection before every bounded BUSY/LOCKED retry; fsguard.rs checks existing paths and creates owner-only files before SQLite opens them tests/relay.rs a_foreign_database_is_refused_byte_for_byte, unknown_schemas_refuse_without_mutation, a_foreign_database_with_a_writer_is_refused_before_write_coordination, a_foreign_identity_after_preflight_is_refused_without_mutation, a_foreign_identity_during_journal_retry_is_refused_without_mutation, journal_retry_refuses_a_changed_version_or_empty_database_without_mutation; controls: journal_transition_retries_sqlite_lock_without_losing_v1_values, fresh_queue_init_and_v1_reopens_work_across_processes; recovery: interrupted_and_failed_migrations_roll_back_and_recover, journal_reclassification_busy_preserves_committed_migration_and_retries_same_queue; diagnostics: classification_read_failures_display_the_sqlite_cause_once_and_preserve_foreign_bytes; Unix privacy: the_queue_database_and_its_sidecars_are_owner_only and the contended migration control Guard-removal proof covers preflight, locked recheck, and journal retry identity/version checks; full table structure is outside this classification. Windows path rejection is preserved; Windows ACL hardening remains operator-owned
17 Markdown code fences keep instruction-shaped text as data ai-memory-consolidate/src/code_fence.rs and ai-memory-wiki/src/markdown.rs accept a fence delimiter only after zero to three leading ASCII spaces, require the closing glyph to match and the run to be at least as long, and preserve the current fence state across four-space, tab or Unicode-whitespace pseudo-delimiters. Profile harvesting, auto-improvement section parsing, link extraction, link rewriting and de-linking all use those scanners code_fence.rs only_zero_to_three_ascii_spaces_may_prefix_a_fence; profile.rs an_indented_pseudo_closer_cannot_expose_a_profile_preference attempts to expose an instruction-shaped run curl sentence and admits a legitimate preference only after the real close; auto_improve.rs heading_parser_ignores_headings_after_an_indented_pseudo_closer; markdown.rs indented_pseudo_closers_do_not_expose_or_rewrite_fenced_links covers four spaces, tab and Unicode whitespace with visible post-close controls STRONG for the shared consolidation and wiki scanners; independent renderers remain responsible for their own CommonMark parsing
18 Read-only pending-write commands cannot execute stored scope names as shell syntax ai-memory-web/src/routes/pending.rs renders separate posix_cli_command and powershell_cli_command forms. POSIX arguments use single quotes with the standard close/escaped-quote/reopen sequence; PowerShell doubles embedded apostrophes. The template labels the shells and claims no cmd.exe support routes/pending.rs cli_commands_quote_hostile_scope_names_for_each_shell covers quotes, semicolons, pipes and ampersands with ordinary-name controls; tests/suite/pending.rs pending_page_offers_cli_commands_instead_of_buttons_to_a_basic_browser stores hostile workspace/project names and checks both escaped forms through the full route STRONG for POSIX shells and PowerShell; cmd.exe is intentionally not offered
19 ai-jail re-exec never promotes a config-file root bearer into harness-readable environment ai-memory-cli/src/commands/run.rs ensure_jail_does_not_export_config_token refuses explicit and offered jail re-exec when auth came from config rather than AI_MEMORY_AUTH_TOKEN; jail_resolved_env forwards only resolved routing (AI_MEMORY_SERVER_URL, AI_MEMORY_BASE_PATH), while jail_forwarded_names forwards an auth variable only when the operator already placed it in the process environment run.rs jail_refuses_a_config_sourced_token_and_forwards_routing attempts the file-token exposure and verifies route-only output; jail_forwarded_names_come_from_the_captured_env_and_resolved_values is the explicit-environment control STRONG for credentials loaded by ai-memory. Residual: a token the operator exports is already inherited by an unjailed managed harness and may itself be privileged; use a least-privilege API token
20 ai-memory setup --web local wizard: only the page this process printed can read the plan or apply a setup ai-memory-cli/src/commands/setup_web.rs guard (binds 127.0.0.1 on an OS-picked port; every request needs a Host of exactly 127.0.0.1:<port> or localhost:<port> and the one-time 256-bit path secret, compared with subtle; a POST also needs this page's Origin and the CSRF token the page reads from its own JSON; no CORS grant; no-store, no-referrer, DENY framing, and a CSP with a per-run nonce and no outside sources on the page) and apply (agent names must be --agent values, de-duplicated, at least one; the child is always ai-memory setup --yes --agent ... with the wizard's own flags, never a caller-chosen argument) setup_web.rs the_page_is_served_only_to_our_host_and_secret (a rebinding Host, a bare 127.0.0.1, another port, a wrong secret and a missing one refused; controls: 127.0.0.1 and localhost with the secret), apply_refuses_cross_site_and_unknown_input_and_starts_nothing (no Origin, a foreign Origin, no CSRF token and a wrong one each refused; --force, a shell-like name and an empty choice refused; no child starts), apply_runs_setup_with_the_picked_agents_and_streams_its_output (legitimate control: exact argument list); tests/suite/setup_e2e.rs setup_web_serves_the_plan_and_applies_the_picked_agent (the same through the binary); bite-checked by removing the Host check, the Origin check, the CSRF check and the agent allowlist one at a time STRONG
21 uninstall removes only a service setup wrote, including the Windows logon entry ai-memory-cli/src/commands/user_service.rs planned_removal / is_rendered_by_setup (a unit file whose identity digest still matches) and planned_removal_for / is_setup_run_entry_for (a REG_SZ HKCU\...\Run\ai-memory value that is a quoted ai-memory.exe ending in service-host, with no & or ` chaining, whose--data-dir, the first argument after the quoted executable and a whole quoted argument ending at its closing quote, is the data dir being uninstalled, both absolute (X:\…, UNC or \?\Volume{GUID}\…; a drive-relative C:matches nothing), compared without the verbatim\?` / \\?\UNC\ prefix, case or trailing separators) before remove stops anything or deletes it user_service.rs uninstall_removes_only_setups_logon_entry (another install's entry, naming a different --data-dir, is left with only the query run; another program's value under the same name is left; absent value is nothing to do; control: this data dir's entry is deleted), only_the_entry_for_this_data_dir_is_ours (a temporary data dir does not claim the operator's entry, #1280), a_volume_guid_data_dir_owns_its_entry (a volume GUID data dir owns its rendered entry and not another volume's; uninstall_removes_only_setups_logon_entry drives both through remove), a_drive_relative_data_dir_is_not_the_drive_root (--data-dir "C:" does not claim C:\'s entry; control: the rendered drive-root entry does; uninstall_removes_only_setups_logon_entry drives it through remove and asserts nothing is stopped or deleted), a_data_dir_that_runs_past_its_quote_is_not_ours ("C:\d"\other and an escaped closing quote, which Windows reads as other directories, do not claim C:\d's entry; control: the rendered entry does; uninstall_removes_only_setups_logon_entry drives the same case through remove), the_data_dir_is_read_after_the_executable and, on Windows, a_rendered_entry_belongs_to_its_own_data_dir (a --data-dir inside the executable's path neither hides nor fakes the option), data_dirs_compare_without_prefix_case_or_trailing_separator (verbatim UNC matches its plain spelling; another share does not), Windows-only only_a_plain_string_value_is_read (a REG_EXPAND_SZ value under the name is not read as setup's; control: the same data as REG_SZ is), only_setups_entry_shape_counts_as_ours (unquoted, other program, serve, &/`
22 Human-session session inspection and owned purging (serve --enable-session-management, #1267) ai-memory-mcp/src/session_management.rs: human session and CSRF, completed password change, guarded no-create scope lookup, and an exact-owner preflight before any admission or checkpoint side effect; ai-memory-store/src/ops.rs purge_session_with_owner: ownership and project write grant rechecked inside the deletion transaction (previews included), cross-project collateral refused unless an Admin purges; Wiki::purge_owned_session: wiki mutation lock, admission, pre/post checkpoints, partial-cleanup reporting and replay tombstones MCP session_management suite: management_refuses_foreign_ids_shared_deletion_and_missing_csrf_with_admin_control (foreign and shared sessions, anonymous, machine bearer, missing CSRF refused; owner and Admin controls), management_raw_session_ids_fail_closed_on_wrong_and_partial_scope, management_purge_admission_rejection_preserves_rows_and_files, management_pagination_reports_its_limit_and_keeps_pages_disjoint; store multi_session::owned_session_purge_refuses_foreign_shared_and_wrong_scope_sessions, owned_session_purge_refuses_cross_project_cascades_with_admin_control; wiki owned_session_purge_authorization_failure_preserves_page_and_index, owned_session_purge_cleanup_failure_is_reported_and_tombstoned. Bite-checked: removing the transaction owner check fails owned_session_purge_refuses_foreign_shared_and_wrong_scope_sessions; removing it together with the handler preflight fails management_refuses_foreign_ids_shared_deletion_and_missing_csrf_with_admin_control (the two are defence in depth) STRONG
23 Human-session self-service native API keys (serve --enable-self-service-keys, #1268) ai-memory-mcp/src/self_service_keys.rs: human session and CSRF (a disabled account's session is refused by load_session), completed password change; creation takes the authenticated UserId, never a supplied username, trims and bounds label (1 to 128 characters) and asks the writer for create_api_credential_within_limit (at most 20 active keys per user, counted on the writer thread); revocation answers 404 unless the credential is the caller's own and still active; the token appears only in the one-time create response; issued keys stay AuthLevel::User self_service_keys_refuse_foreign_ids_csrf_machine_and_pending_password_with_owner_controls (anonymous, machine bearer, missing CSRF, pending password and foreign-id revoke refused; supplied username ignored; User and Root owner controls), self_service_keys_refuse_blank_and_overlong_labels (empty, whitespace, 129 ASCII and 129 multi-byte characters refused with nothing stored; control: 128 characters and a trimmed label accepted), self_service_keys_cap_active_keys_per_user (the 21st key refused with 409; controls: another user unaffected, a revoked key frees a slot), self_service_keys_refuse_a_disabled_user (list, create and revoke refused; key untouched; control: an enabled user), self_service_keys_revoking_an_unknown_or_revoked_id_is_not_found (unknown and already-revoked ids answer 404 without moving the revocation time or touching another user's key). Bite-checked: removing the owner filter fails the foreign-id test; removing the active filter or the key limit fails the revoked-id and cap tests STRONG
24 Server-rendered management forms preserve browser, identity and origin boundaries ai-memory-web/src/management/forms.rs requires matching Origin/Host and permits only Sec-Fetch-Site: same-origin or none when that header is present before translating a form; commands are a fixed enum with typed raw ids and delegate to the existing human-session, CSRF and capability handlers. management/backend.rs forwards only the real transport peer extension; Askama templates autoescape; management/mod.rs responses deny framing, disable caching and hash-authorize the fixed script. Machine bearer authentication is not accepted as a browser identity MCP management_html_plain_forms_preserve_csrf_owner_and_machine_boundaries (foreign owner, forged CSRF and bearer-only console refusal, with owner/Admin controls), management_html_login_rejects_cross_origin_forms_and_preserves_session_cookies (foreign/missing origin and matching-authority same-site/cross-site/invalid fetch-site values refused; missing fetch metadata plus same-origin and none are legitimate controls); web management_assets_work_under_a_prefix_and_deny_framing (explicit assets only, traversal refused, CSP/framing/no-sniff present). Existing session/key API rows above retain wrong/partial scope, admission, ownership and recovery controls STRONG
25 Opt-in consolidation residue cannot turn captured observation text into prompt structure or a direct wiki write (#1215) ai-memory-consolidate/src/projection.rs render_verbatim_residue excludes routing text, passes prompt-shaped observations through profile::user_written, strips tool metadata, mines bounded literal classes, rejects every Unicode/ASCII line end, and renders one indented token per line under an explicit untrusted-data header; total, group, token and observation-pruning caps bound work and disclosure. Consolidator includes the block only when [consolidation] verbatim_residue is true and still accepts only the existing JSON-schema structured response through the normal wiki-write boundary projection residue_keeps_hostile_lines_indented_and_never_forges_observation_headers (instruction-shaped error plus forged header and mixed line endings; legitimate path control), residue_refuses_harness_prompts_but_keeps_the_same_user_written_error (harness block refused, user-written control admitted), residue_stays_inside_projection_and_group_budgets_without_clipping, residue_off_is_byte_identical_and_on_is_inert_without_missing_text; integration verbatim_residue_consolidation::residue_changes_only_the_provider_request_not_the_stored_page captures both requests and proves the fixed structured response produces the same page STRONG for prompt framing and the direct-write boundary; enabling the option deliberately sends a wider bounded subset of already-sanitized capture to the configured provider

| 26 | Cross-harness native-history continuation stays checkout-scoped and client-local | ai-memory-store/src/workstream.rs prepare_run selects the newest current native session only when its harness differs from the destination and pins that typed identity on the run before destination linking can change recency; ai-memory-cli/src/commands/run.rs validates the returned NativeSessionIdentity, resolves only known adapter flavors, requires native_session_in_checkout, exports through the bounded read-only adapter, and writes an untrusted-history dossier to a private temporary directory exposed only to the child as AI_MEMORY_PREVIOUS_SESSION_HISTORY; the server wire type deliberately has no path/content field and same-harness launches select no source; ai-memory-hooks/src/router.rs keeps the server-authored resume directive outside the untrusted-history fence while fencing the transcript evidence itself, and ai-memory-core/src/routing_snippet.rs gives installed project instructions the same wrapper-variable-gated fallback | Core prepare_response_carries_only_previous_native_identity, older_prepare_response_defaults_to_no_adoption, and snippets_route_managed_continue_to_the_previous_native_history; store managed_adoption_stops_after_any_harness_links_the_workstream (switch control, destination-link recency cannot replace the pinned source, same-harness refusal); hooks managed_context_points_at_local_history_on_a_harness_switch (no session id rendered, directive precedes the untrusted fence); CLI previous_session_history_is_private_local_and_checkout_scoped (legitimate control, foreign checkout refused, private local file removed with its owner) | STRONG for checkout isolation, prompt-boundary placement, and server path/content privacy. The dossier is a bounded visible-history projection, not raw hidden reasoning; if the source store is absent, remote, unreadable, or over bounds, the child receives only the portable ledger and handoff | | 27 | Plain-HTTP human authentication stays fail-closed beyond loopback unless the operator supplies the dedicated dangerous override (#1383) | ai-memory-cli/src/cli.rs exposes serve --allow-insecure-human-auth separately from --allow-insecure-no-auth; serve.rs validate_http_exposure accepts it only when authentication and human mode are both active and the listener is non-loopback with a Non-Secure cookie, while the ordinary unauthenticated guard still runs otherwise. HttpExposure::InsecureHumanAuthByOverride gives that path its own unconditional stderr banner and structured warning, naming passwords, API credentials, session cookies, and memory data as plaintext. The default remains refusal, and secure_cookie=true or loopback remains the safe path | serve.rs human_auth_non_loopback_requires_secure_cookie_posture (default refusal, the no-auth override cannot substitute, the dedicated override succeeds, and that override cannot expose a server with no authentication even under inconsistent human-mode input; secure-cookie and loopback controls), every_unsafe_exposure_produces_an_operator_banner (the dedicated banner names the flag and session-cookie risk), and cli.rs serve_parses_insecure_transport_overrides (both dangerous flags remain distinct) | STRONG for the startup boundary. This is an explicit operator acceptance of transport risk, not encryption; authorization, CSRF, rate limits, Host validation, and the unauthenticated exposure refusal are unchanged | | 27a | Provider credentials stay on the configured origin | ai-memory-llm/src/redirect.rs same_origin_redirects, set on every provider and embedder client (anthropic.rs, codex.rs, copilot.rs, embedding.rs, gemini.rs, google.rs, openai.rs, openai_oauth.rs, opencode.rs): a redirect is followed only when scheme, host and port match the previous request, with reqwest's ten-hop limit; any other redirect fails the request. reqwest's own guard strips only Authorization, cookies and the proxy headers, so x-api-key, x-goog-api-key and llm_headers values depend on this one. The local model download (local.rs) carries no credential and keeps the default policy for its CDN redirects; OIDC and CLI login requests refuse every redirect on clients of their own (oidc.rs, auth.rs auth_http_client) | ai-memory-llm tests/suite/redirect_credentials.rs gemini_api_key_does_not_follow_a_cross_origin_redirect, anthropic_api_key_does_not_follow_a_cross_origin_redirect, operator_headers_do_not_follow_a_cross_origin_redirect (with Authorization stripped as the control), google_embedder_key_does_not_follow_a_cross_origin_redirect, a_refused_redirect_says_where_it_pointed; legitimate control a_same_origin_redirect_still_reaches_the_provider (the key follows a path redirect on one origin); each cross-origin test fails with the policy removed | STRONG for the provider and embedder clients in ai-memory-llm | | 27b | LLM workload telemetry cannot turn prompts, outputs, scopes, projects, or caller text into status data or unbounded metric labels | ai-memory-llm/src/types.rs LlmWorkload is a closed enum carried beside, but absent from the display/wire form of, LlmOperationId; health.rs LlmWorkloadHealth uses one fixed array and fixed latency buckets and records only counts/times/coarse estimates/reported usage/redacted error class and status; ProviderHealth::snapshot omits the rows when LLM support is disabled; /admin/status remains behind the common admin gate | ai-memory-llm workload_snapshot_is_bounded_redacted_and_percentiled (private prompt, output and upstream body absent; fixed row count, recovery-preserved last error, and percentile controls), llm_wrapper_forwards_the_callers_operation_id (label recorded while the same UUID-only id reaches the provider), types::tests::workload_labels_are_stable_and_do_not_change_the_wire_operation_id; ai-memory-mcp status_reports_bounded_content_free_llm_workload_telemetry (private prompt absent from serialized status, one fixed row per label), status_reports_provider_health_block (disabled LLM emits no rows) | STRONG for content/cardinality and the existing root-only admin surface | | 27c | A maintenance compaction cannot replace a newer user page or partly apply a stale batch | ai-memory-consolidate/src/sweep.rs carries each selected source PageId into Wiki::apply_batch_if; ai-memory-wiki/src/wiki.rs checks the preconditions after locking every page, installs files with rollback snapshots, and delegates the decisive check to WriterHandle::upsert_pages_batch_if; ai-memory-store/src/ops.rs validates every latest id and writes every replacement in one SQLite transaction, returning a mismatch before any write | store conditional_page_batch_is_all_or_nothing; wiki conditional_batch_rejects_every_page_when_one_version_changed (file and DB controls); consolidate compaction_does_not_supersede_a_concurrent_fresh_write (an admission barrier lands a semantic pinned correction after A2 reads the old body, then proves the correction remains latest and the selected batch stays uncommitted) | STRONG; all-or-nothing intentionally retries unchanged peers with the next sweep instead of weakening invariant #2 into per-page writes | | 27d | The native hook and generated TypeScript clients never follow a redirect with an event, a bearer or a handoff read | ai-memory-cli/src/commands/hook_capture.rs build_client (Policy::none(), #1818) for the native hook's posts, batches and handoff GET; every fetch in the generated TypeScript integrations passes redirect: "error": the shared spool drain (render_shared.rs ts_spool_runtime), the hook POST add_hook_spooling installs (OpenCode, OpenCode 2, OMP, Pi), the OpenCode handoff and recap reads, the OMP/Pi handoff read and the Pi MCP bridge (install_hooks.rs), and the OpenClaw plugin's post and handoff read (openclaw_plugin.rs). A refused redirect takes the unreachable-server path: the event stays spooled and no handoff is injected | hook_capture.rs build_client_refuses_redirects, post_hook_does_not_follow_redirect, post_batch_does_not_follow_redirect, get_handoff_does_not_follow_redirect (the redirect target receives nothing); render_shared.rs assert_every_ts_request_carries_client_marker (every generated fetch carries redirect: "error", run for all five integrations); install_hooks.rs slow_generated_handoff_runtime::omp_extension_refuses_a_gateway_redirect (a Node run behind a 302/307 gateway: its login origin gets no request, no handoff is injected, a spooled event survives the drain and the session's posts are spooled; it fails with the option removed) | STRONG for the native client and the generated TypeScript integrations; the legacy script bundles are not covered (hooks/_lib.sh curl does not follow but prints any handoff response body; hooks/lib/ai-memory-hook.ps1 Invoke-WebRequest follows by default) | | 28 | An Antigravity hook reads, and uploads as prompts, only the named conversation's own transcript, within bounds | ai-memory-hooks/src/antigravity.rs antigravity_transcript_path accepts the payload's transcriptPath only when it is absolute, has no .., names transcript.jsonl or transcript_full.jsonl, and its canonical directory equals canonical(<home>/.gemini/<app>/brain)/<conversationId>/.system_generated/logs for <app> antigravity, antigravity-cli or antigravity-ide, with conversationId a plain id (antigravity_conversation_id); read_transcript_prompts opens only a regular, non-symlink file that is still the same file once open (open_regular_file, opened with O_NOFOLLOW | O_NONBLOCK so a symlink or FIFO swapped in after the check is refused without blocking, and on Linux only when the opened descriptor's /proc/self/fd path is the checked one, so a directory swapped for a symlink after the containment check is refused too), reads at most MAX_TRANSCRIPT_SCAN_BYTES per hook and parses lines up to MAX_TRANSCRIPT_LINE_BYTES, and returns only USER_INPUT steps whose source is absent or USER_EXPLICIT; ai-memory-cli/src/commands/hook.rs antigravity_transcript_prompt_events runs inside the spool block, so after the capture allowlist, routing, server-profile and external-capture gates, with the home run_with_payload resolved once; its path checks, bounded cursor load and transcript read run behind ANTIGRAVITY_TRANSCRIPT_READ_BUDGET, and a timeout advances no cursor so a later hook retries; cursor replacement uses the canonical atomic writer; each prompt is capped and scrubbed client-side, keyed by conversation and step, and sanitized again by the server (row 7) | antigravity.rs transcript_path_refuses_anything_outside_the_conversations_own_logs (another conversation's transcript, the same layout outside the home, another file in the logs directory, an unknown app directory, .., a traversal or empty id, a relative path, a missing or non-string path; the conversation's own transcript is the control), transcript_path_refuses_symlinked_directories_that_leave_the_conversation (a symlinked .system_generated and brain/<id> refused; a symlinked ~/.gemini accepted as the control), transcript_reader_refuses_symlinks_and_special_files (a symlinked transcript and a directory refused; the same bytes as a regular file are read), skips_injected_malformed_empty_and_non_prompt_steps, a_line_longer_than_the_scan_budget_is_skipped_across_reads, one_read_returns_a_bounded_number_of_prompts; hook.rs antigravity_transcript_reads_are_confined_to_the_conversations_own_logs (end to end through the native hook: a forged path outside the home, another conversation's transcript and an arbitrary JSONL file under the home spool no prompt; the conversation's own transcript spools one), antigravity_transcript_prompts_follow_the_capture_allowlist (a repository the allowlist leaves out is not read), antigravity_transcript_read_deadline_does_not_wait_for_blocked_work, and antigravity_transcript_cursor_store_is_atomic_and_bounded (oversized cursor refused) | STRONG on Linux, including the opened descriptor path. Stable symlink escapes and special files are refused on every platform; without Linux /proc/self/fd, a same-user process able to replace an ancestor in the narrow interval between canonicalization and open could redirect the read, which still remains size- and time-bounded. The directory-swap bite test is Linux-only; the other symlink cases are cfg(unix) | | 29 | Interrupted-session recovery stays scope-, owner-, and receiver-bound | ReaderPool::latest_interrupted_session_candidate (latest_interrupted_session_candidate_sql) filters scope, owner and receiver before selection, and judges a session's work, end and handoff coverage only from rows in the same scope; hooks render only the admitted candidate and exclude the receiving session | multi_session.rs interrupted_recovery_refuses_foreign_scope_owner_and_receiver_with_controls, interrupted_recovery_ignores_foreign_scope_work_and_batons_with_controls (foreign work does not reopen an ended session and a foreign baton does not hide unfinished work; home-scope work and batons are the controls); hooks unfinished_session_recovery_is_owner_scoped_and_excludes_receiver | STRONG | | 30 | Per-response usage remains project/session/owner scoped and replay-monotonic | ReaderPool::token_usage_report_page applies scope, owner, search, and signal filters before pagination; ops::upsert_token_calls keys native response ids by session and merges counters with maxima in one writer transaction | live_token_usage.rs scope, owner, pagination, replay, and mutation controls | STRONG | | 30a | Session drilldowns are owner-scoped for a user and complete for root | ai-memory-web/src/routes/api.rs session_owner_filter_for: AuthLevel::Root → OwnerFilter::Any, every other caller → owner_filter_for (own plus shared). Used by routes/agents.rs, routes/project.rs (sessions, agent and token-usage tabs), routes/session.rs, and the /api/v1 sessions_handler and session_observations_handler. Handoff reads keep owner_filter_for and root's explicit all_owners | ai-memory-web operations.rs operations_root_drilldowns_reach_every_users_sessions_and_users_stay_owned: a user's agent page, Sessions tab and session list omit another user's session and its session page and observations answer 404; root's list it and answer 200 (control: the user's own and the shared session stay visible) | STRONG. Bite checks: with root mapped to owner_filter_for, root's agent page misses the other user's session; with every caller mapped to Any, the user's agent page lists it | | 31 | Browser inbox operations hide restricted projects and preserve both-coordinate write authorization | Inbox and notification routes derive choices and counts from viewer-filtered projects; sends and edits require write access to the recipient and sender coordinates, sanitization, admission, CSRF, and fixed capabilities | operations.rs restricted-project, foreign-workspace, authorization, and notification tests; dashboard browser mutation cases | STRONG | | 32 | Directed and held messages cannot be claimed by the wrong harness or while editing | Both message claim guards require state = 'pending' and match to_agent; begin/finish edit are coordinate- and state-guarded single-writer updates | agent_messages.rs addressed claim-once and editing-state tests; web authorization tests; mutation probes for wrong-harness and held-message claims | STRONG |

IBM Bob evidence

IBM Bob extends boundary 4j through hook.rs a_handoff_is_never_claimed_without_a_project_directory: an unscoped Bob SessionStart cannot send GET /handoff, while the same payload with a cwd claims once and names that directory. It extends boundary 11b through capture_policy.rs ibm_bob_tool_calls_honor_capture_exclusions: an ignored Claude-shaped Read path is dropped, a public-path control is kept, and the same body under an unknown agent stays unclassified. Removing Bob from either guard makes the corresponding adversarial test fail. Coverage: STRONG.

Boundary 4k also has a writer-side managed-run race guard. After the reader-side exclusion and immediately before the idle-end batch, ops.rs active_managed_run_sessions derives every active run's native session id in one batch snapshot and refuses a match. Managed-run links and idle stamps share the single writer actor, so no link can interleave after that decisive snapshot. idle_session_end.rs idle_end_writer_recheck_refuses_runs_linked_after_selection links active runs in the pre-stamp seam for both substantive and lifecycle-only candidates; both remain open, with no idle audit or consolidation job, while an unrelated session is not blanket-refused by the existing positive controls. Removing the writer-side recheck ends both sessions. Coverage: STRONG.

DeepSeek Harness (DSH) evidence

DSH extends boundary 11b through capture_policy.rs dsh_tool_calls_honor_capture_exclusions: an ignored Claude-shaped Read path, and a shell command naming an ignored path through either of DSH's shell tools (Windows pwsh, POSIX bash), are dropped; public-path controls are kept; the same body under an unknown agent stays unclassified. DSH's @deepseek-ai/dsh-hooks-claude-code bridge forwards Claude Code's field names, so extract has to list the agent — without it every DSH call inspects as ToolFamily::Unknown and an active ignore_paths keeps it — and pwsh has to be in NON_FILE_TOOL_NAMES for the same reason. Its headless profile mounts Code Mode, so its one-shot runs call the reserved run_code transport with program source that builds paths at run time: run_code is in both NON_FILE_TOOL_NAMES and INLINE_CODE_TOOL_NAMES, and the test asserts the metadata-only fallback. The shell_tool_shapes_of_every_adapter_honor_exclusions table carries both DSH shell names, and the fixture's tool_families list carries pwsh and run_code. Removing the DSH arm, the pwsh name, or the run_code classification fails the test. Coverage: STRONG.

Keeping this current (the standing protocol)

  1. Touch a guard, add/extend its adversarial test. Any change to code in the "Enforcing code" column, or that adds a new read/write/admin/hook entry point past one of these guards, must add or extend an adversarial test that would fail if the guard were removed, and update this file's row.
  2. New boundary → new row + tests before merge. Adding an isolation dimension (a new tenancy axis, a new capability, a new cross-scope surface) means a new row here and its adversarial tests in the same change.
  3. A raw-id or unscoped entry point is guilty until tested. Any handler that takes a bare session_id/run_id/page_id/message id, or fans out across projects (global=true, global recent, search), bypasses scope resolution by construction. It must resolve→authorize (or filter-before-LIMIT) and carry an adversarial test proving a foreign id/scope is refused.
  4. Prove the test bites. An adversarial test that still passes when the guard is deleted is not a guard test. Confirm that it fails without the guard and passes with it.
  5. Unit tests exercise one session/tenant at a time and cannot see these defects, so the guards live at integration level (multi_session.rs, handoff_ownership.rs, agent_messages.rs, active_project pointer tests, the MCP permission suites). Put boundary tests there.

Query-answer input admission (when configured) validates citations only against admitted source identities. server::tests::answer_budget_keeps_ranked_evidence_and_excludes_omitted_citations attempts an omitted-source citation and checks a legitimate admitted citation; query_answer::answer_budget_never_calls_provider_without_evidence_and_keeps_hits checks the no-evidence provider boundary. The configuration does not change retrieval scope or authorize additional data access.

Budgeted-answer recency uses metadata for at most 300 already-authorized hit IDs, without loading bodies or expanding supersession links. The store tests answer_evidence_metadata_returns_only_requested_ids_without_expanding_links and the session chronology test cover requested-only and same-scope joins. answer_budget_uses_store_recency_without_reordering_retrieval_hits verifies the production metadata-to-prompt path. The transitive-lineage and unusable-newer-hit unit tests keep obsolete evidence out when the current evidence cannot be admitted; existing foreign-project citation and shared-path ambiguity tests continue to enforce the authorization boundary.