Skip to content

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

Rust

Merge release/2.6 into PR #1039

AkitaOnRailseb87356f8509
diff --cc CHANGELOG.md
index 5fdfb1df,170601a7..30428297
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@@ -120,13 -128,60 +120,77 @@@ and this project adheres to [Semantic V
or distinct extensions, including backfill).
Mixed-source counts preserve scope, session ownership and time-window filters;
older servers leave unsupported fields unknown. (#1016)
++- Added shared capture privacy checks to the relay and the conversation importer,
++ run before an event is hashed, persisted, previewed or delivered: they refuse
++ credential-shaped native identities, scrub nested credentials while keeping
++ numeric token counts, and drop locally a relay item queued before them that
++ fails them, so it no longer holds its session. (#1072)
++- Added `[handoff].create_on_session_end` (default `true` - unchanged
++ behavior). When set to `false`, unmanaged session ends write the session
++ summary page and enqueue consolidation as usual, but skip creating an
++ automatic open handoff for the next session; OpenCode turn checkpoints
++ refresh the page without a baton too. Explicit handoffs created via
++ `memory_handoff_begin` and managed workstream runs remain unaffected.
++ Server-wide: applies to every operator on this server. (#1043)
+ - Added bounded, sanitized native-record and adapter correlation provenance to
+ managed-workstream search/tail results and the CLI's text/JSON output, with
+ compatible optional fields and sanitization of legacy provenance on reads. (#1057)
+ - Added Portuguese history phrases to the existing opt-in session-recall
+ router (`[retrieval] query_intent`), including accented and unaccented spellings of
+ "última sessão", "onde paramos ontem", and "decisão anterior". Word
+ boundaries and explicit history phrases keep technical session queries
+ unchanged; routing remains off by default. (#1056)
+ - Added shared, typed and bounded `entities`, `abstract`, and `relations`
+ metadata to MCP `memory_write_page` and admin `/admin/write-page`, plus bounded
+ MCP `kind` while preserving the admin's legacy `kind` adapter. Kept existing
+ request shapes, entity normalization, authenticated attribution and the wiki
+ write pipeline. Documented whole-page replacement, raw-input metadata bounds
+ and trimmed relation scope components. (#1055)
+ - Added structured results for the existing auto-improvement eval execution in
+ review reports, staged run metadata, and accepted proposal sidecars, with
+ server-generated eval IDs, evaluated request/body digests, checker invocation
+ identity, observed success/rejection/failure/timeout, and sanitized bounded
+ reasons. Report deserialization discarded supplied eval observations. (#1053)
+ - Added `grizzybot` as a recognised agent (wire value `grizzybot`, alias
+ `grizzy-bot`), so GrizzyBot's lifecycle events are attributed to it instead
+ of `other` and its tool calls are captured as closed-schema tool families,
+ like other Claude Code-shaped agents. GrizzyBot posts to `/hook` and
+ `/mcp` itself, so there is nothing to install. Adds migration V72 to extend
+ the `sessions.agent_kind` CHECK constraint. (#1036)
+ - Added GitHub Copilot CLI as a hooked agent: `install-hooks --agent
+ copilot-cli` writes `$COPILOT_HOME/hooks/ai-memory.json` (default
+ `~/.copilot/hooks/ai-memory.json`) with Copilot's flat, matcher-less entries
+ and PascalCase event names, so Copilot sends its VS Code/Claude-compatible
+ payload. Ten events — Claude Code's nine plus `PostToolUseFailure` — with
+ native commands enforcing capture exclusions; tool output is read from
+ `tool_result.text_result_for_llm` and the outcome from
+ `tool_result.result_type`. The `SessionStart` hook delivers the prior
+ session's handoff through Copilot's top-level `additionalContext` (ported
+ from #1069). There is deliberately no `--scope project`. The bare
+ `install-mcp --client copilot` alias keeps meaning VS Code Copilot;
+ `ai-memory run copilot` follows separately. (#1040)
+ - Added `install-mcp --client copilot-cli`, which merges ai-memory's remote
+ entry (`type: "http"`, `url`, bearer `headers`, `tools: ["*"]`) into the root
+ `mcpServers` map of `$COPILOT_HOME/mcp-config.json` (default
+ `~/.copilot/mcp-config.json`), preserving other servers. `install-hooks
+ --agent copilot-cli` without `--server-url` now reads the server URL and
+ bearer back from that entry, and `uninstall` removes it. (#1040)
+ - Added an optional `session_id` to `memory_write_page`, so an agent can
+ write a session's page with its own model and keep it traceable to the
+ session. The session must belong to the project the page is written to, and
+ the page records it as session evidence. A page that cites a session does
+ not overwrite a pinned page. Writing `sessions/<id>.md` also stamps the
+ frontmatter `memory_consolidate` writes there (`session_id`, `agent`,
+ `consolidated`, plus `consolidated_by: agent`), defaults the tier to
+ `episodic`, applies the same duplicate-title suffix, and marks the session's
+ queued SessionEnd consolidation job completed. (#1038)
### Changed
+- Scoped `ai-memory resume` to the current checkout instead of every linked
+ project, removed its default result cutoff with bounded server pagination,
+ and added `--search` plus immediate type-to-filter name search while preserving
+ Left/Right harness selection. Explicit limits now apply after the initial
+ search; `continue` retained its cross-directory behavior. (#1039)
- Documented FutureInfra as an endpoint for the existing `openai-compat`
provider. (#1026)
- `.github/workflows/nix.yml` builds the flake on `x86_64-linux` for path-
@@@ -134,11 -189,21 +198,24 @@@
sandbox-parity). The `aarch64-darwin` package smoke and the privileged
NixOS container smoke run only on schedule, `workflow_dispatch`, or a PR
labelled `nix` / `full-ci`. (#989)
+ - Restricted managed-workstream provenance to scrubbed source labels and an
+ explicit scalar metadata allowlist, with 512-byte string bounds. Client event
+ ids beginning with `managed-run:` are reserved for server checkpoints and
+ extraction-loss annotations. Active-run retries reject changes to an existing
+ event's agent, native session or kind, and retain its first indexed content
+ and provenance across sanitizer changes. (#1057)
+ - The SessionEnd consolidation worker leaves a session page alone when the
+ agent wrote it through `memory_write_page` and no observation arrived after
+ it: the page records the session's observation count as
+ `observation_generation`, and the worker completes a job whose generation
+ that count reaches instead of replacing the page with the server's
+ provider. A page written before the session's last observation is
+ consolidated as before. (#1038)
### Fixed
+- Removed unnecessary working-tree scans from checkout-local workstream listing
+ and the resume picker, including `ai-jail ai-memory resume --yolo`; launching
+ a selected workstream still captured its full checkpoint. (#1039)
- Fixed completed retries and no-op session endings advancing
`last_persisted_ms` without a durable write. Recovery still advances the
timestamp when it commits a new page or terminal effect. (#1015)
diff --cc crates/ai-memory-core/src/workstream.rs
index 259622b3,ac722595..3a2cb4b1
--- a/crates/ai-memory-core/src/workstream.rs
+++ b/crates/ai-memory-core/src/workstream.rs
@@@ -363,19 -420,20 +424,33 @@@ pub struct WorkstreamEvent
mod tests {
use super::*;
+ #[test]
+ fn older_workstream_event_has_no_provenance() {
+ let event: WorkstreamEvent = serde_json::from_value(serde_json::json!({
+ "sequence": 1, "event_id": "event-1", "agent": "codex",
+ "native_session_id": "native-1", "kind": "message", "content": "visible",
+ }))
+ .unwrap();
+ assert!(event.source_record_id.is_none());
+ assert!(event.metadata.is_null());
+ let encoded = serde_json::to_value(event).unwrap();
+ assert!(encoded.get("source_record_id").is_none());
+ assert!(encoded.get("metadata").is_none());
+ }
+
+ #[test]
+ fn workstream_listing_without_offset_defaults_to_the_first_page() {
+ let request: ListManagedWorkstreamsRequest = serde_json::from_value(serde_json::json!({
+ "workspace": "default",
+ "project": "app",
+ "repo_fingerprint": "repo",
+ "worktree_fingerprint": "tree",
+ "limit": 20,
+ }))
+ .unwrap();
+ assert_eq!(request.offset, 0);
+ }
+
#[test]
fn older_run_status_reads_as_nothing_linked() {
let status: ManagedRunStatus = serde_json::from_value(serde_json::json!({
diff --cc crates/ai-memory-workstream/src/lib.rs
index 6841d099,51a14add..bb1c6691
--- a/crates/ai-memory-workstream/src/lib.rs
+++ b/crates/ai-memory-workstream/src/lib.rs
@@@ -20,12 -20,12 +20,14 @@@ pub use jail::
inside_ai_jail_here, jail_checklist, jail_toggle, marked_choices, parse_jail_toggles,
usable_ai_jail, usable_ai_jail_here,
};
-pub use repository::{RepositoryIdentity, inspect_repository};
+pub use repository::{
+ RepositoryFingerprints, RepositoryIdentity, inspect_repository, inspect_repository_fingerprints,
+};
pub use transcript::{
- AmbiguousNativeSession, ExportedTranscript, NativeSessionCandidate, discover_native_session,
- export_transcript, kiro_harness_from_source_cursor, kiro_v3_resume_uses_default_store,
- list_native_sessions, native_memory_dir, native_session_exists, native_session_in_checkout,
+ AmbiguousNativeSession, ExportedTranscript, NativeSessionCandidate,
+ claude_attached_background_session, claude_live_background_attach_id,
+ claude_session_ran_in_background, discover_native_session, export_transcript,
+ kiro_harness_from_source_cursor, kiro_v3_resume_uses_default_store, list_native_sessions,
+ native_memory_dir, native_session_exists, native_session_in_checkout, native_store_root,
wait_for_transcript_flush,
};
diff --cc docs/security-boundaries.md
index bbea961f,c2270b69..a8b30109
--- a/docs/security-boundaries.md
+++ b/docs/security-boundaries.md
@@@ -24,8 -24,8 +24,9 @@@ boundary not yet built
|---|----------|----------------|---------------------|----------|
| 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 | `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) | 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 |
| 2 | Workspace isolation | same as #1; same-named project → distinct ids per workspace | `scope.rs` cross-workspace resolution rows; `multi_scope` dedup/validate | 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; `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`; `workstream.rs` `recent_workstream_pages_reach_older_rows_without_crossing_checkout_or_scope` (foreign repo, worktree, project and workspace excluded on every page; 105 legitimate rows reach the client, huge offsets return nothing); store `recent_workstreams_are_checkout_local_and_include_linked_harnesses` (page two keeps native harness links); `repository.rs` `reports_origin_push_url_and_linked_worktree` verifies lightweight/full fingerprint parity and distinct worktree keys; CLI `resume_yolo_displays_picker_without_scanning_git_status` verifies listing skips status scans | STRONG |
| 3 | Multi-user auth ladder | `ai-memory-core/src/actor.rs` `AuthLevel::authorize`; `ai-memory-mcp/src/auth.rs` middleware; `admin.rs` `require_root_for_multiuser_admin` / `require_root`; `identity.rs` authorizes `NormalRead` behind the same machine bearer middleware as MCP; `serve.rs` mounts API-only and web+API protected routers behind `require_dual_auth` | `admin.rs` `multiuser_admin_routes_reject_db_user_tier` / `…reject_anonymous` / `create_user_as_user_tier_returns_403`; `auth.rs` unknown-bearer 401; `actor.rs` `skip_admission_chain_rejects_db_users`; `identity.rs` `identity_real_auth_isolates_users_root_and_revoked_keys`, `identity_anonymous_ignores_forged_headers_and_proxy_qualifies_oidc` (distinct users and root, invalid/revoked keys, forged headers, anonymous control); `serve.rs` `api_only_mode_keeps_data_authenticated_and_web_absent` (anonymous API read refused, authenticated control admitted, browser route absent; #986) | STRONG |
| 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) | STRONG |
| 4 | Handoff single-claim / no-steal | `ai-memory-store/src/ops.rs` `accept_handoff_in_transaction` (metadata `state='open'` guard + atomic CAS) | `multi_session.rs` `a_second_accept_cannot_steal_an_accepted_handoff`; `handoff_ownership.rs` `another_operator_cannot_claim_the_handoff` | STRONG |