Solution for long term memory for agent coding CLIs and to facilitate handoff between different agent vendors
Rust
Merge branch 'main' into fix/issue-103-cwd-resolver-catchall
Thiago Silvaf4f2e8e0a68e
diff --cc CHANGELOG.mdindex 713aab2e,1392699d..deba33f5--- a/CHANGELOG.md+++ b/CHANGELOG.md@@@ -7,24 -7,28 +7,46 @@@ and this project adheres to [Semantic V## [Unreleased]+### Fixed+- Unscoped MCP queries could resolve to the wrong project on a shared+ install. The cwd-to-project resolver recorded the bare working directory+ as a project's `repo_path` whenever the cwd was not inside a git repo+ (which, under the default basename strategy, was always), so opening a+ session in a broad ancestor such as `$HOME` created a row that+ prefix-matched every project nested beneath it and captured their unscoped+ lookups. A project's `repo_path` is now the git working-tree root, or unset+ when the cwd is not inside a git repo, never the bare cwd; under the+ default basename strategy it is recorded only when the cwd is the+ repository root, never a subdirectory. A read-time guard additionally+ refuses to prefix-match a stored `repo_path` equal to the operator's+ `$HOME`, and `ai-memory serve` heals existing installs on startup by+ clearing any `repo_path` that is not a real git working-tree root (such as+ a legacy `~/projects` or `/work` catch-all), not only `$HOME` and the+ filesystem root, while leaving paths it cannot see locally (a remote or+ multi-user client path, or an unmounted drive) untouched. (issue #103)++ ### Added+ - `GET /admin/audit-contamination` (and `ai-memory audit-contamination`) — a+ read-only, SQL-only structural cross-project contamination audit. Flags+ sessions whose `cwd` longest-prefix-resolves to a different project than the+ one they landed in (the auto-scope-bleed signature, resolved with the same+ prefix logic the runtime uses) and observations whose project disagrees with+ their owning session (a regression tripwire that should stay empty on a+ healthy DB). Optional `?workspace=&project=` scope; reports only, never+ mutates, so it is safe to run on any cadence. Purely semantic mislandings+ (no cwd/session anomaly) are out of scope by design.+ - Mid-session hook-spool drain: on `post-tool-use`, once the local spool backlog+ crosses a threshold, the hook runs a tightly time-boxed (~250 ms) catch-up+ drain so a heavy session keeps the backlog flat instead of waiting for the next+ session boundary. Tunable via `AI_MEMORY_HOOK_INCREMENTAL_THRESHOLD`+ (default 32 events).++ ### Fixed+ - Hook spool no longer counts a server `429` (saturation / `hook queue full`)+ against a spooled event's `MAX_ATTEMPTS` retry budget: transient backpressure+ keeps the event queued without burning an attempt (`MAX_AGE_MS` still bounds+ it), so a saturation burst no longer silently discards real observations.+## [1.1.0] - 2026-06-16### Fixed