Skip to content

Add EmbeddingGemma retrieval support#155

Merged
flupkede merged 7 commits into
developfrom
feature/embeddinggemma-retrieval
Jul 22, 2026
Merged

Add EmbeddingGemma retrieval support#155
flupkede merged 7 commits into
developfrom
feature/embeddinggemma-retrieval

Conversation

@flupkede

Copy link
Copy Markdown
Owner

Add EmbeddingGemma retrieval support

Lands the EmbeddingGemma retrieval work on develop (this repo's integration branch), rebased clean onto current develop. Supersedes #147 — full credit to @markschroedr for the original implementation; this PR only re-targets the base branch (masterdevelop) and incorporates review feedback.

What it does

  • Adds the EmbeddingGemma300MQ4 model variant as a selectable embedding model.
  • Prose/code labelling is Gemma-only. ModelType::content_label(path) emits Text: for Markdown-family files (.md/.markdown/.txt, via Language::from_path) and Code: otherwise — but only for EmbeddingGemma. Every pre-existing model keeps its exact historical input representation (Code:), so existing indexes are byte-for-byte unaffected and need no rebuild.
  • Memory guard: selecting a heavier-than-default model now warns the user (is_heavier_than_default() compares embedding dimensions against the default). Motivated by OOM risk on large corpora / small serve containers.
  • Rejects a --model that mismatches the model an index was built with, pointing at --force (prevents silently mixing embedding spaces).
  • CLI model list is now derived from ModelType::valid_short_names() instead of a hardcoded list; model_override uses short_name().

Review points addressed

  • Label change scoped strictly to Gemma (no blast radius across existing models / no surprise auto-rebuilds).
  • .txt confirmed to map to Language::Markdown, so it is labelled Text: consistently under Gemma.
  • New integration tests in tests/cli_model_errors.rs cover the model-mismatch rejection path.

Validation

cargo fmt --check, cargo clippy -D warnings, and cargo test --lib were clean on the identical source prior to rebase. Final cargo check/build + full QC gate run in CI (local MSVC toolchain unavailable in the authoring environment).

Closes #147.

Scope prose-aware Text labels to EmbeddingGemma Markdown and plain-text chunks. Keep the historical Code label for all existing models so incremental indexing cannot mix document representations. Warn when explicitly selecting models with larger vector dimensions.
test_sanitize_strips_single_char_escape passed a String argument to
sanitize_for_terminal(s: &str), breaking cargo test --lib. Pass &str
literals to match the sibling sanitize tests. (only surfaces under
--lib test compilation, not plain cargo check)

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@flupkede

Copy link
Copy Markdown
Owner Author

CI status note

This PR's own feature code is validated — test-windows, Analyze (rust), and CodeQL all pass. A compile error in a lib test (sanitize_for_terminal was passed a String instead of &str) was fixed in 0bba5a6.

The remaining red (test-linux + csharp-integration-tests) is a pre-existing develop-wide breakage, unrelated to this PR: 5 Windows-absolute-path tests are not #[cfg(windows)]-gated and fail on Linux —

  • mcp::tests::pick_filter_root_uses_routed_alias_root
  • mcp::tests::test_mcp_filter_matches_absolute_path_under_project_root
  • mcp::tests::test_path_prefix_mixed_separators
  • mcp::tests::test_path_prefix_windows_backslashes
  • search::tests::test_path_filter_matches_absolute_windows_path_under_root

Proof it's not from here: git diff origin/develop..HEAD -- src/mcp/mod.rs is empty, and develop's own recent merge CI (#153, #154) is already failing. This should be fixed first on a dedicated fix/ branch → develop (design choice: #[cfg(windows)]-gate the tests, or make path normalization treat \ as a separator cross-platform for federated Windows-peer paths). Once develop is green and this rebases, #155 goes green.

Test User and others added 3 commits July 22, 2026 18:35
Five tests hardcoded Windows absolute paths (C:\..., \?\C:\..., backslash
separators) and asserted separator-rewriting semantics that normalize_path_str
deliberately applies ONLY on Windows (backslash is a legal filename char on
Unix — see file_meta.rs Aikido 30641757 rationale). They therefore failed on
the Linux CI jobs (test-linux, csharp-integration-tests) while passing on
test-windows.

Gate the Windows-specific tests with #[cfg(windows)] and add #[cfg(unix)]
counterparts using native forward-slash paths for the three path-matching
tests, preserving Linux coverage. The two pure separator-handling tests
(backslashes / mixed) are Windows-only concepts; forward-slash behaviour is
already covered by test_path_prefix_no_alias/_empty_alias on all platforms.

Pre-existing develop breakage, unrelated to the EmbeddingGemma feature
(src/mcp/mod.rs is untouched by that work).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
.map(|l| sanitize_for_terminal(l)) -> .map(sanitize_for_terminal).
.lines() yields &str and sanitize_for_terminal takes &str, so the direct
function reference is valid. clippy -D warnings (Linux CI) flagged it.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
missing_db_not_cached_as_conflicted opened SharedStores directly in the
test setup and then let get_or_open_stores open the same LMDB env again —
two opens of one env in a single process, which AGENTS.md's LMDB rule
forbids. On Linux the first env is not always released before the reopen,
so try_open_stores' open failed intermittently -> readonly -> Conflicted
-> Err (flaky). try_open_stores creates the env itself (see
try_open_stores_creates_db_for_brand_new_repo), so the direct pre-open was
redundant. Dropping it leaves a single deterministic open on both
platforms.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants