Solution for long term memory for agent coding CLIs and to facilitate handoff between different agent vendors
Rust
Merge branch 'main' into release/2.6
AkitaOnRailse3cfa5262be8
diff --cc CHANGELOG.mdindex 64873244,20b2a554..05b30ee2--- a/CHANGELOG.md+++ b/CHANGELOG.md@@@ -438,13 -178,36 +438,46 @@@ and this project adheres to [Semantic VDocumented the observed attach-hook behavior, early-exit import boundary andfallback validation limits.(#1052)+- Fixed `resume` and `workstreams` running `git status` on every linked checkout+ before listing anything: listing now reads only the checkout's stable+ fingerprints, so a large working tree or a slow filesystem-monitor hook no+ longer blocks the picker before its first frame. (#1039)+- Fixed a store write sent while the writer was shutting down occasionally+ waiting forever instead of failing with `WriterClosed`: the writer now+ closes its queue and drains in-flight commands before it stops.++- Fixed `memory_handoff_list` MCP tool calls being counted under writes in++ `client_activity`: the read-only inspection tool is now classified as a read++ in `tool_call_is_write`. (#1088)+ - Fixed the provider-health wrapper dropping the caller's operation id: its+ `complete_with_operation_id` and `complete_structured_raw_with_operation_id`+ fell to the trait defaults, so every retry of one logical operation got a+ fresh id and, for OpenCode, a new session header on every call. The wrapper+ now forwards both. (#1085)+ - Fixed `backfill` failing with a non-root key on a multi-user server. Its+ emptiness check used the root-only `/admin/sessions/by-agent` route, so every+ developer's own key got 403; on a 403 it now asks the grant-checked+ `GET /api/v1/workspaces/{ws}/projects/{p}/sessions` instead. (#1086)+ - Fixed the sanitizer missing uppercase `*_KEY_ID`, `*_PASSPHRASE`,+ `*_SIGNING_KEY`, `*_PEPPER` and `*_SALT` assignments (e.g. an S3+ `…_ACCESS_KEY_ID`, an auth token pepper) and dotless base64 JSON tokens such+ as Cloudflare tunnel tokens (`eyJ…`, 40+ characters); lowercase code+ identifiers, SHAs, UUIDs and short `eyJ` fragments are left alone. (#1084)+ - Fixed `memory_delete_page` bypassing per-user slot namespace routing and+ access checks when `[slots] per_user` is active. Non-admin callers deleting a+ generic slot path (`_slots/current-focus.md`) are now redirected to their+ personal slot namespace instead of removing the shared project-wide slot, and+ deleting directly inside another operator's slot namespace is rejected with an+ invalid request error. (#1083)+ - Fixed the web page view showing a `[[wikilink]]` inside a raw HTML block+ (an HTML comment, a `<div>` block) as generated link markup such as+ `[notes/foo](w/default/scratch/p/notes/foo.md)`. HTML blocks render as+ escaped source text, so the wikilink now stays as the page wrote it. (#1087)+ - Fixed wikilinks dropping `#anchor` and `?query` suffixes. `[[page#section]]`+ and `[[page#section|label]]` lost the fragment when rewritten to standard+ Markdown links (for example on OKF export), leaving the link pointed at the+ page root. The rewriters now keep the suffix, percent-encoded where needed so+ a space or parenthesis in it cannot break the link. In `/web` the suffix is+ kept on the href; the page view does not emit heading ids. (#1089)### Security- Fixed GHSA-7qj3-7wqw-m5w6: in multi-user mode a database user without adiff --cc crates/ai-memory-cli/tests/suite/main.rsindex eb97b2d1,7ee7dfd7..5797a898--- a/crates/ai-memory-cli/tests/suite/main.rs+++ b/crates/ai-memory-cli/tests/suite/main.rs@@@ -9,7 -9,7 +9,8 @@@ mod autoscope_envmod backfill_dry_run;mod backfill_e2e;mod backfill_failures;+ mod backfill_member;+mod backup_agents;mod completions;mod doctor_e2e;mod e2e_support;diff --cc crates/ai-memory-mcp/src/server.rsindex 528e6ed3,b0bf0873..2ee1e57d--- a/crates/ai-memory-mcp/src/server.rs+++ b/crates/ai-memory-mcp/src/server.rs@@@ -4846,44 -4388,15 +4883,44 @@@ impl AiMemoryServer};let path = PagePath::new(args.path.clone()).map_err(|e| McpError::internal_error(format!("invalid path: {e}"), None))?;- let path = self.place_slot_delete(path, &parts).await?;- let (ws, proj) = self- .effective_ids_for_mutation_args_with_actor(- args.workspace.as_deref(),- args.project.as_deref(),- &aps_actor,- Self::viewer_from_parts(Some(&parts)),- )- .await?;+ let (path, (ws, proj)) = match args.scope.as_deref().map(str::trim) {+ None | Some("") => (- path,++ self.place_slot_delete(path, &parts).await?,+ self.effective_ids_for_mutation_args_with_actor(+ args.workspace.as_deref(),+ args.project.as_deref(),+ &aps_actor,+ Self::viewer_from_parts(Some(&parts)),+ )+ .await?,+ ),+ Some("profile") => {+ if args+ .workspace+ .as_deref()+ .is_some_and(|s| !s.trim().is_empty())+ || args+ .project+ .as_deref()+ .is_some_and(|s| !s.trim().is_empty())+ {+ return Err(McpError::invalid_params(+ "scope: \"profile\" cannot be combined with workspace/project",+ None,+ ));+ }+ (+ profile_page_path(path)?,+ self.profile_target_ids(&parts, &aps_actor, false).await?,+ )+ }+ Some(other) => {+ return Err(McpError::invalid_params(+ format!("unknown scope '{other}': the only supported value is \"profile\""),+ None,+ ));+ }+ };// Carry actor identity + loop-prevention skip list (same as write_page).// `Wiki::delete_page` stamps `op = Delete` regardless of what we pass.diff --cc docs/security-boundaries.mdindex 3075fad0,2218ad9f..87dc75b0--- a/docs/security-boundaries.md+++ b/docs/security-boundaries.md@@@ -47,9 -40,8 +47,10 @@@ boundary not yet built| 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 || 6 | Active-project pointer (PerActor, no clobber) | `ai-memory-core/src/active_project.rs` `set_for`/`lookup_for` (fail-closed on `Mismatch`) | `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` | 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 || 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; `WriterHandle::insert_observation` requires `Sanitized`; `ops` crate-private | 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) | 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 || 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 |