Repository navigation
fix(xccode): hybrid keeps lexical-only indices in the BM25 leg (#1146) - #1177
Merged
Merged
Conversation
…org#1146) Motivation. On a corpus where only some indices map `body` as semantic_text, `xerj code --mode hybrid` returned 1 hit where `--mode bm25` returned 20, while its note claimed "BM25 over 2 index(es)". Every lexical-only index was dropped from BOTH legs. Not a synthetic case: a `corpus index` of psf/requests yields one such index. Root cause. `run_code_query` sends the fused native `hybrid` request to the comma-joined capable set when capable < total (xccode/mod.rs, the `target` choice), because a `semantic` leg on a plain-text field is a deliberate 400 (xerj-org#530, engine index.rs `run_semantic`) that fails the whole wildcard request. Nothing sent the BM25 leg to the remaining indices. Fix. The lexical-only indices get the same native `hybrid` with its BM25 leg alone (`hybrid_bm25_leg_body`). The engine fuses per index (`fuse_rrf`, 1/(k+rank)) and merges a multi-index search by `_score` (es_compat.rs cross-index re-sort), so both responses carry RRF scores on one scale; `merge_by_score` repeats that cross-index step client-side (score desc, stable, `_index` on ties, `hits.total` summed). No new fusion arithmetic lives in the client. The note now names the indices: "lexical-only (BM25 leg only, merged by score): <indices>". The body builders share `bm25_leg` / `with_lang` / `hybrid_request`, so `--lang` still rides in `filter` on every leg (xerj-org#1148). Evidence (verified): - New test `hybrid_keeps_lexical_only_indices_in_the_bm25_leg` failed before the fix (2 requests, expected 3) and passes after; `cargo test -p xerj-common`: 189 + 3 passed, 0 failed. - Issue repro on a clean --data-dir, rc.83 release build of this branch (30 short .py files -> `-src-docs` body=text, corpus.json -> `-docs` body=semantic_text): before (the old request, replayed with curl): 1 hit bm25 -k 20: 20 hits hybrid -k 20: 20 hits (19 src-docs + 1 docs), total 31 Single-leg hybrid on the lexical index scores 0.01639, 0.01613, 0.01587 = 1/61, 1/62, 1/63 — the same scale as the fused request. `--lang python` on the hybrid path still answers. Not verified / out of scope: ES-YAML gate not run (no engine code changed — xerj-common client path only). `cargo test -p xerj-mcp` has one failure, `loopback_url_with_no_auth_picks_up_the_local_admin_key`, a macOS /var vs /private/var path comparison unrelated to xccode. Written by an AI agent (Claude Code) for the account that opens the PR.
Ravandevil25
pushed a commit
to Ravandevil25/xerj
that referenced
this pull request
Oct 6, 2026
…— it merged after the rc.85 tag
Merged
neoneye
pushed a commit
to agent-memory-atlas-archive/xerj-org--xerj
that referenced
this pull request
Oct 10, 2026
Fifth daily release cut. The window was dominated by the xerj-org#1109 security audit fixes and the config/telemetry honesty items, plus the first code contribution from a third external contributor. Window (v1.0.0-rc.85..main, PRs all cited in the CHANGELOG): - Security: xerj-org#1109 closed by PR xerj-org#1194 (audit remediation, Security section added to the notes) - Fixed: xerj-org#1158 (build-time half, PR xerj-org#1185, stays open on the issue), xerj-org#1189 + xerj-org#1190 (PR xerj-org#1193), xerj-org#1186 (PR xerj-org#1188), xerj-org#1146 (PR xerj-org#1177) and xerj-org#1092 (PR xerj-org#1184) - both Vincenzo Lombardo, xerj-org#1146 his first merged fix; _doc arrival order (xerj-org#1127, Saurav Kumar, his first code contribution) - Field reports: xerj-org#1178 (Vinz2168), xerj-org#1187 (thomas-villani) - Metrics chore 15b62f5 cited as a Community line (direct commit, [skip ci], rc.85 precedent) Roll mechanics: - engine/Cargo.toml workspace version 1.0.0-rc.86; Cargo.lock regenerated (version-only diff verified: 0 non-version lines) - CHANGELOG: fresh [Unreleased], rc.86 section, new Community section - ROADMAP: Last-reviewed pass for the cut (docs_capability_lists gate requires it), rc.86 paragraph in Next release, Open defects shortlist rolled to the eleven live trackers - landing footers: V1.0.0-RC.85 -> V1.0.0-RC.86 (91), lowercase variant (1); zero rc.85 patterns remain - release-notes-gate.sh run locally before this commit: PASS on freshness, issue-state (11 open-defect checks, 6 Fixed checks incl. the xerj-org#1158 stays-open marker) and coverage (9 window PRs) In flight past the cut: phase-B bulk coalescing for xerj-org#1147 (PR xerj-org#1195, sticky-failure fix + 8-in-flight wire concurrency, rustsec 10.1s->9.7s / pysec 17.4s->16.9s vs rc.85 on the loopback A/B), merges into the rc.87 window.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #1146.
What this changes, and why
On a corpus where only some indices map
bodyassemantic_text,xerj code --mode hybridsent the single fusedhybridrequest only to the capable set. It has to, because asemanticleg on a plain-text field is a deliberate 400 (#530) that fails the whole wildcard. Nothing sent the BM25 leg to the other indices, so every lexical-only index dropped out of both legs, while the note still said "BM25 over N index(es)". Result: 1 hit under hybrid where--mode bm25returned 20.The lexical-only indices now get the same native
hybridwith only its BM25 leg (hybrid_bm25_leg_body). The engine fuses per index (fuse_rrf,1/(k+rank)) and merges a multi-index search by_score(cross-index re-sort ines_compat.rs). That means both responses carry RRF scores on the same scale, andmerge_by_scorejust repeats that cross-index step on the client: score descending, stable,_indexon ties,hits.totalsummed. The client does no fusion arithmetic of its own, which keeps the module's "no client-side fusion" contract. The note now names the indices:lexical-only (BM25 leg only, merged by score): <indices>.The body builders now share
bm25_leg/with_lang/hybrid_request, so--langstill rides infilteron every leg (#1148). When every index is capable, or none is, nothing changes.Evidence
The new test
hybrid_keeps_lexical_only_indices_in_the_bm25_legfailed before the fix and passes after:Live, with the issue's repro on a clean
--data-dir, using the rc.83 release build of this branch:Checks
cargo fmt --all(--checkclean);cargo clippy -p xerj-common --lib --tests -- -D warningscleancargo build --release -j 32 -p xerj-ser 8000 vercargo test -p xerj-commonpassesxerj codeclient path inxerj-commononly.[Unreleased]entry. No other doc quotes the old note.search failed, the same as every other BM25 transport failure in this function.Not run: the ES-YAML gate (see above).
cargo test -p xerj-mcphas one pre-existing failure on macOS,loopback_url_with_no_auth_picks_up_the_local_admin_key, a/varvs/private/varpath comparison that does not touchxccode.Provenance
_indexascending, the same as the engine's own cross-index order. The engine's sort is stable over its index-resolution order, which I did not trace. A same-request comparison where both orders differ would falsify this. It only affects tie order, never which hits make the page. Also not measured: any latency cost of the second request on large corpora.🤖 Generated with Claude Code