Solution for long term memory for agent coding CLIs and to facilitate handoff between different agent vendors
Rust
Merge PR #823 into release/2.5
AkitaOnRails9b7ed8e8b6c1
diff --cc .github/workflows/ci.ymlindex 7723a980,16197305..2f7709e6--- a/.github/workflows/ci.yml+++ b/.github/workflows/ci.yml@@@ -71,10 -71,18 +71,22 @@@ jobsif: matrix.os == 'ubuntu-latest'run: echo "TAILWIND_BUILD=1" >> "$GITHUB_ENV"- run: cargo test --workspace --all-targets+ # `--all-targets` deliberately excludes doctests, so a doc-comment code+ # block that fails to compile (e.g. an indented shell example rustdoc+ # reads as Rust) shipped unnoticed. Run them explicitly.+ - run: cargo test --workspace --doc+ - uses: astral-sh/setup-uv@bec219d24cd3e171d82865faccec33120bb574f4 # v10.1.0+ with:+ enable-cache: false+ - name: Build the external lifecycle relay+ env:+ CARGO_TARGET_DIR: ${{ github.workspace }}/target+ run: cargo build --locked --manifest-path companions/ai-memory-relay/Cargo.toml+ - name: External lifecycle delivery against the real server+ run: >+ uv run --no-project python tests/e2e/external_relay_smoke.py+ --ai-memory-bin "${{ github.workspace }}/target/debug/ai-memory"+ --relay-bin "${{ github.workspace }}/target/debug/ai-memory-relay"- name: Vendored tailwind.css is currentif: matrix.os == 'ubuntu-latest'run: git diff --exit-code -- crates/ai-memory-web/static/tailwind.cssdiff --cc CHANGELOG.mdindex 7638e1df,01dd65a4..3a7a5193--- a/CHANGELOG.md+++ b/CHANGELOG.md@@@ -8,62 -8,10 +8,66 @@@ and this project adheres to [Semantic V## [Unreleased]### Added+- Native `ai-memory upgrade` for GitHub-release installs (Linux/macOS+ tarballs and Windows x86_64 zip): downloads the matching release archive,+ verifies the `.sha256` sidecar, replaces the on-disk binary (and a sibling+ `hooks/` tree when present), then re-runs `install-hooks --apply` for staged+ agents. Windows uses rename-aside self-replace (running `.exe` → `.old`,+ promote `.new`) because the mapped image cannot be overwritten in place.+ Refuses package-managed paths (Homebrew/AUR/`/usr`), containers, and+ unwritable prefixes; the Docker wrapper's `upgrade` path is unchanged. Pin+ with `--version` / force a re-download with `--force`. Optional+ `AI_MEMORY_RELEASE_BASE_URL` / `release_base_url` overrides the Releases+ base for mirrors and hermetic tests (loaded via `Config`, not ad-hoc env).+ Downloads refuse bodies over 128 MiB (Content-Length and streamed cap).+ (#801, #802)+- `ai-memory run` accepts a repeatable `--env KEY=VALUE` and an `--env-file+ <path>` (blank lines and `#` comments skipped) to pass extra environment+ into the spawned harness — e.g. a per-account `CLAUDE_CONFIG_DIR` for+ callers who previously had to wrap the launch in `env KEY=VAL harness`.+ Both flags are wrapper-owned like `--yolo`/`--executable` and must precede+ the harness name; a `--env` entry overrides a same-key `--env-file` line.+ The resolved environment reaches both the spawned process and ai-memory's+ own native-session resolution, so the two agree on where a+ `CLAUDE_CONFIG_DIR`-style override points the session store. See+ `docs/managed-workstreams.md`. (#820)+- `contradiction_band_min` / `contradiction_band_max` config keys (env:+ `AI_MEMORY_CONTRADICTION_BAND_MIN` / `AI_MEMORY_CONTRADICTION_BAND_MAX`)+ make `memory_lint`'s A5 zero-LLM contradiction-detection cosine-similarity+ band configurable, defaulting to the historical fixed `0.4`–`0.75`. The+ band is a fixed absolute cosine value, but background similarity is+ corpus-dependent: on a single-language or single-domain store, unrelated+ pages already sit above the general-purpose floor, so the default band+ measures domain proximity more than conflict and produces noisy findings.+ Raising `contradiction_band_min` trims that noise. Rejected at config load+ unless `0.0 <= contradiction_band_min < contradiction_band_max <= 1.0` and+ both are finite. (#853)+- Fedora users can install prebuilt x86_64 and aarch64 RPMs from GitHub+ Releases, with the existing native systemd service assets. (#858)+- `embedding_query_prefix` / `embedding_document_prefix` config keys (env:+ `AI_MEMORY_EMBEDDING_QUERY_PREFIX` / `AI_MEMORY_EMBEDDING_DOCUMENT_PREFIX`)+ for the `openai` and `openai-compat` embedders: an optional string+ prepended to query / document text before the existing truncation, so+ truncation still bounds the whole input. Asymmetric embedding models need+ a query-side instruction their publisher specifies; the OpenAI-compatible+ `/v1/embeddings` wire format has no field for it.+ `nvidia/Nemotron-3-Embed-1B-BF16` and base E5 models use a simple+ `"query: "` / `"passage: "` pair; instruction-tuned E5 variants and+ Qwen3-Embedding instead need a task-instruction string on the query side+ only (documents stay plain). Empty by default — no behaviour change when+ unset, and not trimmed (nor is a present-but-empty env-var override, which+ now clears a `config.toml` value), so a publisher's trailing space is+ preserved. A non-empty `embedding_document_prefix` is folded into the+ stored embedding identity (`Embedder::model_identity`), so a document+ prefix change makes retrieval, backfill, and cleanup treat existing pages+ as stale and re-embed them automatically — an empty prefix keeps the+ pre-existing identity, so upgrading installs need no migration, and a+ query-only prefix change never needs a rebuild. See+ `docs/llm-providers.md`. (#859)+ - Added the optional `ai-memory-relay` companion for external lifecycle events.+ It queues events locally and sends ordered batches through the public hook API,+ using stable event identities for retries. The package has its own workspace+ and does not change the server's capture or storage defaults. (#823)- `auto_improve.patchable_page_prefixes` makes the folders whose page bodies thereviewer reads configurable, defaulting to the historical `_rules/` and`procedures/`. Only those two folders' contents were ever sent; every otherdiff --cc CONTRIBUTING.mdindex dbbfd124,02f2abb8..01b277fa--- a/CONTRIBUTING.md+++ b/CONTRIBUTING.md@@@ -77,22 -77,21 +77,33 @@@ Skipped tests still count as "skipped"independent things run them anyway: the pre-push hook and CI.Install the hook once per clone with `scripts/install-git-hooks.sh` (from Git-Bash on Windows). It appends or updates only ai-memory's managed block in-`.git/hooks/pre-push`, preserving any existing hook body. Bypass it on a-work-in-progress branch with `git push --no-verify`.+Bash on Windows). It can run from the main checkout or a linked worktree;+both use the shared repository hook directory. Reinstallation replaces+ai-memory's managed block in place, preserving surrounding user commands and+their order. If `core.hooksPath` is set, the installer stops before writing;+integrate the block through your existing hook manager instead. Incomplete or+duplicate managed markers also stop installation and leave the hook unchanged.+Bypass it on a work-in-progress branch with `git push --no-verify`.++The managed test block clears Git's repository environment and disables global+and system Git configuration for Cargo and its children. Fixture commands can+then use their own repositories without inheriting the checkout being pushed.+The publishing Git process and other hook code retain their configuration, and+the block's shell options stay inside it; a failing test run still fails the+hook even when your own commands follow the block without `set -e`.+Run the installer again to update an existing installation.+ The managed test block clears Git's repository environment and disables global+ and system Git configuration for Cargo and its children. Fixture commands can+ then use their own repositories without inheriting the checkout being pushed.+ The publishing Git process and other hook code retain their configuration.+ Run the installer again to update an existing installation.++ Companions have separate Cargo workspaces. Check each changed companion with+ `cargo fmt`, `cargo clippy --all-targets -- -D warnings`, and `cargo test`, passing+ its `--manifest-path`. Changes to the lifecycle relay also need the real-server+ test documented in [its README](companions/ai-memory-relay/README.md#validation).+Integration tests live in `tests/suite/` per crate and compile into thecrate's own test harness (declare a new file with `mod name;` in`tests/suite/mod.rs`); only the CLI keeps a separate test binary, because its