Repository navigation
Description
Problem or Motivation
BM25 runs in Python only over the dense pool (hybrid_search_results, src/devops_cli/ai/rag/retriever.py:206-212), so it cannot find a chunk that dense search missed. Each query merges two collections, devops_code and devops_docs, in the client. Each point holds one unnamed dense vector, and no point carries visibility.
On the 62-query project eval set of #4961, BM25 over all chunks fused with dense search by RRF (B2f) gives:
- nDCG@10 0.514 against 0.468 for dense only (B2f - D0 +0.046 [+0.004, +0.088], p 0.040);
- on exact identifiers, 0.673 against 0.507 (+0.166, p 0.001);
- on the 42 natural-language queries, no gain: -0.012 [-0.051, +0.026], p 0.57.
Thus the only measured gain of the hybrid step is on exact-identifier lookup. The relevance of an identifier query is an exact string match, so this gain is lexical by construction, and git grep also serves it. The hybrid pool also feeds the cross-encoder of child 7. B2 (hybrid pool, reranked) against B1d (dense pool, reranked) is +0.042 overall (p 0.10), +0.073 on identifiers (p 0.017), and -0.050 on issue_fix (p 0.004).
Qdrant 1.19.1 is live. It supports named sparse vectors with the IDF modifier, BM25 on the server (in core for self-hosted servers since 1.15.3), and prefetch with RRF and a set k (since 1.16).
Proposed Solution & Architectural Design
- Make one collection behind the alias
devops_rag(a dated collection name under it). It replacesdevops_codeanddevops_docs. - Vectors:
dense(1024, Cosine, int8 scalar quantization quantile 0.99 in RAM, HNSW m 16, ef_construct 100, as today) and the sparse vectorbm25with modifieridf. Qdrant fillsbm25on the server from the chunk text (Documentwith modelqdrant/bm25). Check that qdrant-client sends the text to the server and does not load fastembed in the client process. - Payload: as today, plus
commitanddoc_classfrom feat(ai): RAG points carry the commit and the document class #4921 if it is merged. Keyword indexes forcategory,languageandsymbol_names. Writevisibilityon every point. - Query: one Query API call with two prefetches (dense top 100 and bm25 top 100, same filter) and RRF, limit 50, no cosine threshold. Set the RRF k explicitly: the study used 1/(60 + rank) with rank from 1, Qdrant counts positions from 0 and its default k is 2, so k 61 gives the study's fusion. Check the formula in the Qdrant source of the live version.
- Delete the BM25 of
src/devops_cli/ai/lexical.pyfrom the retriever path, and the client RRF and merge. - Re-index once: ingest into the new collection. The model does not change, so cached dense vectors are reused. At the measured 45 texts/s with all cache misses, about 70,800 chunks after fix(ai): RAG chunks cover module code and use a token size #4967 take about 26 minutes. Check the point count and
visibility, run the eval, then switch the alias. Keep the old collections for 7 days, then delete them. Open WebUI keeps the same embedding route. - If Qdrant 1.20 is live, also measure BM25 on a full-text index with the code tokenizer, and keep the better arm.
- Do not claim a gain for natural-language queries until the code-behaviour queries of test(ai): a gold set measures retrieval of knowledge base facts #3902 measure it.
Target Subsystem
src/devops_cli/ai/rag/ (retriever, Qdrant store, indexer), src/devops_cli/ai/lexical.py, the Qdrant collection and alias, the RAG ingest.
Existing Tool Considered
Qdrant 1.19.1: named sparse vectors, server-side BM25 (qdrant/bm25, statistical, no model weights), the Query API with prefetch and RRF, and collection aliases. qdrant-client. No model server and no GPU. Rejected: a learned sparse model (the bge-m3 sparse output has no server among the candidates, and the SPLADE models are CC-BY-NC-SA-4.0). Estimated cost: about 0.40M tokens and 6 hours, plus the re-index.
Acceptance criteria
- The collection has the named dense vector and the sparse vector
bm25with modifieridf. The point count equals the chunk count of the ingest. Every point has avisibilityvalue. - The query sets the RRF k explicitly.
git grepfinds no client BM25 or RRF code in the retriever path.- On the eval set of test(ai): a gold set measures retrieval of knowledge base facts #3902: nDCG@10 >= 0.50 and exact_identifier nDCG@10 >= 0.65 (measured B2f 0.514 and 0.673), above B0prod with p < 0.05, and natural-language nDCG@10 not lower than dense only by more than its bootstrap interval.
- The full re-index takes less than 1 hour. The alias switches only after the eval passes.
- RAG query p95 without rerank stays at or below 737 ms over 7 days.
Dependencies
#3902 (the eval set and the scorer), #4965 (the weighted reranker is gone) and #4967 (the chunker fix goes into the same re-index). Related: #4566 (the cluster ingest has never run; the re-index needs a working ingest path, in the cluster or from a workstation).
Source: #4961
Alternatives check of 2026-11-21: in-use.
The repository already uses this tool.
Tool: qdrant/qdrant (https://github.com/qdrant/qdrant), Apache-2.0, last activity 2026-11-20, maintained.
Reason: Searches returned no usable page, but the repository facts confirm Qdrant, which the issue already names as in use, and it supplies server-side BM25 sparse vectors, prefetch RRF fusion and aliases that the whole need rests on.
Covers:
- Named sparse vector with IDF modifier
- Server-side BM25 computed from chunk text
- Query API prefetch with explicit RRF k
- Aliases for one-step collection switch
Lacks:
- No eval set or scorer of test(ai): a gold set measures retrieval of knowledge base facts #3902
- No chunker fix of fix(ai): RAG chunks cover module code and use a token size #4967 or proven ingest path
- No visibility payload field or keyword indexes
- Client Document upload unconfirmed on installed version
Proposed design
Problem statement
The RAG hybrid step scores BM25 in Python over the dense candidate pool. It cannot find a chunk that dense search missed. Each query merges the devops_code and devops_docs collections in the client, and no point carries visibility. The change moves the lexical arm into Qdrant: one collection behind the devops_rag alias, the named dense vector dense, the sparse vector bm25 with the idf modifier, server-side BM25 from the chunk text, and one Query API call with two prefetches and RRF at k 61. The measured gain is on exact-identifier queries only.
Acceptance criteria
Requirement: One collection behind the devops_rag alias
The RAG store SHALL read and write one collection through the devops_rag alias and SHALL not merge devops_code and devops_docs.
Scenario: Collection resolution
- WHEN The retriever resolves the collection name
- THEN It returns
devops_ragand the store sends no request todevops_codeordevops_docs.
Requirement: Collection schema with dense and sparse vectors
The Qdrant store SHALL create the collection with the named dense vector dense (size 1024, Cosine, int8 scalar quantization in RAM) and the named sparse vector bm25 with the idf modifier.
Scenario: Create-collection request
- WHEN The store builds the create-collection request for a collection that does not exist
- THEN The request defines
densewith size 1024 and distance Cosine under int8 scalar quantization, and definesbm25as a sparse vector with modifieridf.
Requirement: Keyword payload indexes
The collection setup SHALL create keyword payload indexes for category, language and symbol_names.
Scenario: Payload index requests
- WHEN The store creates the collection schema
- THEN It sends keyword index requests for
category,languageandsymbol_names.
Requirement: Server-side BM25 from the chunk text
The indexer MUST send each chunk text as a Document with model qdrant/bm25 under the bm25 vector name and MUST NOT compute BM25 in the client process.
Scenario: Point for one chunk
- WHEN The indexer builds the point for one chunk
- THEN The point holds the chunk text as a
Documentwith modelqdrant/bm25underbm25, and the indexer module imports neither a BM25 scorer norfastembed.
Requirement: Visibility on every point
The ingest SHALL write a non-empty visibility value on every point and SHALL fail when a chunk has no visibility value.
Scenario: Chunk with no visibility
- WHEN The indexer builds a point for a chunk whose
visibilityis empty - THEN The indexer raises an error and writes no point.
Requirement: One point for each chunk
The ingest SHALL write exactly one point for each chunk.
Scenario: Fixture ingest
- WHEN The ingest completes over a fixture of N chunks
- THEN The collection holds N points and each point has a non-empty
visibilityvalue.
Requirement: One fused query with an explicit RRF k
The retriever MUST send one Query API call with a dense prefetch of 100 and a bm25 prefetch of 100 under the same filter, fuse them with RRF at the explicit k 61, and set limit 50 with no score threshold.
Scenario: Query request for one search
- WHEN The retriever runs one search
- THEN The store sends one query call with two prefetches under the same filter,
rrffusion with k 61, limit 50 and no score threshold.
Requirement: No client BM25, RRF or merge in the retriever path
The RAG retriever path SHALL contain no client BM25 ranking, no client RRF and no client merge of two collections.
Scenario: Retriever module import and search
- WHEN The RAG retriever module is imported and one search runs
- THEN It imports no BM25 or RRF function from
devops_cli.ai.lexical, runs one store call and reads one collection name.
Requirement: Alias switch waits for the eval
The alias switch MUST refuse to point the devops_rag alias at the new collection when the eval result is below nDCG@10 0.50 or exact-identifier nDCG@10 0.65.
Scenario: Eval below the threshold
- WHEN The switch reads an eval result that records nDCG
@100.49 - THEN The switch returns an error, the alias keeps its target and the new collection stays.
Requirement: Pending a person after the merge
The migration MUST complete the re-index in less than 1 hour, MUST switch the alias only after the eval of #3902 passes, and MUST keep RAG query p95 without rerank at or below 737 ms for 7 days after the switch.
Scenario: Live re-index, eval and latency window
- WHEN A person runs the re-index into the dated collection, runs the eval of test(ai): a gold set measures retrieval of knowledge base facts #3902 against it, and reads the RAG query p95 over the next 7 days
- THEN The re-index takes less than 1 hour, the point count equals the chunk count, the eval reports nDCG
@10at or above 0.50 and exact-identifier nDCG@10at or above 0.65, both above B0prod with p < 0.05, natural-language is not lower than dense only by more than its bootstrap interval, and the 7-day p95 is at or below 737 ms.
Existing Tool Considered
Qdrant (qdrant/qdrant, Apache-2.0, maintained) is the tool. The alternatives check of 2026-11-21 in the issue body gives the verdict in-use: the repository already uses Qdrant. The block lists what Qdrant covers and lacks. This change adds the project-side parts that the block lists as lacking: the visibility payload field and keyword indexes, the Document upload with qdrant/bm25, and the eval-gated alias switch. The first task confirms the client Document upload on the installed qdrant-client. The change builds no replacement for a Qdrant feature. The issue estimates the change at about 0.40M tokens and 6 hours plus the re-index.
Key questions
- How does the indexer get server-side BM25 from the chunk text?: Send
models.Document(text=chunk.content, model='qdrant/bm25')under thebm25vector name. Add a test that the indexer builds this object and imports nofastembed. The first task confirms the installed client. (best practice) [sources: src/devops_cli/ai/rag/indexer.py]- Chosen: Client Document with qdrant/bm25. Qdrant computes the sparse vector on the server and needs no model weights.
- Rejected: Client BM25 scorer. It cannot score chunks outside the dense pool, which is the problem.
- Rejected: fastembed in the client. It loads a model in the ingest process and adds a dependency.
- Which RRF k does the query set?: Set the explicit k 61. Qdrant scores RRF as 1/(k + rank). The study fused at 1/(60 + rank) with a rank from 1, and Qdrant counts positions from 0. The first task checks the rank base in the live Qdrant source. (best practice) [sources: src/devops_cli/ai/rag/retriever.py]
- Chosen: k 61. It matches 1/(60 + rank) when Qdrant ranks from 0.
- Rejected: k 60. It is off by one when Qdrant ranks from 0.
- Rejected: the default k 2. It overweights the top ranks and is not the study fusion.
- Does the change delete
src/devops_cli/ai/lexical.py?: No. Keep the module and remove its use from the RAG retriever path only. Conversation search still calls the scorer. (best practice) [sources: src/devops_cli/ai/lexical.py, src/devops_cli/ai/rag/retriever.py]- Chosen: Keep the module and remove it from the RAG path. Conversation search shares the scorer, so a deletion breaks it.
- Rejected: Delete the module. It breaks conversation search.
- Rejected: Copy the scorer into the retriever. Two copies drift apart.
- How does the migration replace the
devops_codeanddevops_docscollections?: Ingest into a dated collection and point thedevops_ragalias at it. The old collections stay read-only for 7 days and give a rollback. The switch is one alias update. (best practice) [sources: src/devops_cli/ai/rag/qdrant.py, src/devops_cli/ai/rag/retriever.py]- Chosen: A dated collection behind an alias. The switch is one step and the old collections give a rollback.
- Rejected: Recreate one collection in place. There is no rollback, and the query fails during the re-index.
- Rejected: Write both schemas. Two write paths must stay in step.
- How is the eval gate enforced on the alias switch?: Add a guard in the switch code. It reads the eval result and refuses to move the alias when nDCG
@10is below 0.50 or exact-identifier nDCG@10is below 0.65. A test checks the refusal offline. (best practice) [sources: src/devops_cli/ai/rag/qdrant.py]- Chosen: A guard in the switch code. The safe order is the only order and a test checks it offline.
- Rejected: A runbook step. A person can skip it under time pressure.
- Rejected: A CI check. CI holds no live collection and no eval result.
- Which payload fields does the new collection hold?: Write today's fields plus
visibilityand the keyword indexes forcategory,languageandsymbol_names. Thecommitanddoc_classfields arrive with feat(ai): RAG points carry the commit and the document class #4921, not this change. (best practice) [sources: src/devops_cli/ai/rag/indexer.py, src/devops_cli/ai/rag/models.py]- Chosen: Today's fields plus visibility. The change needs visibility and the indexes, and it does not wait on feat(ai): RAG points carry the commit and the document class #4921.
- Rejected: Require feat(ai): RAG points carry the commit and the document class #4921 first. It blocks the re-index on another item.
- Rejected: Omit visibility. The issue needs visibility on every point.
- Does the re-index depend on feat(k8s): let Argo Workflows run roadmap pods in devops #4566?: No hard dependency. The code change can use the workstation ingest path, and the live re-index is a post-merge person step. feat(k8s): let Argo Workflows run roadmap pods in devops #4566 stays related. If neither the cluster nor the workstation path works, that step blocks. (best practice) [sources: src/devops_cli/ai/rag/indexer.py, tests/commands/test_ai_rag_commands.py]
- Chosen: Keep feat(k8s): let Argo Workflows run roadmap pods in devops #4566 related. A working workstation path can run the re-index, so the code change does not wait.
- Rejected: Record feat(k8s): let Argo Workflows run roadmap pods in devops #4566 as a dependency. It blocks the change on the cluster path alone.
- Rejected: Drop the re-index. The alias switch needs the new collection.
- What does the ingest do when a chunk has no
visibilityvalue?: Refuse the point and raise an error. The issue needs a non-emptyvisibilityon every point, and a default would hide missing data. (best practice) [sources: src/devops_cli/ai/rag/indexer.py]- Chosen: Refuse the point. The issue needs a non-empty value on every point.
- Rejected: Default to private. It hides missing data and changes the filter result.
- Rejected: Write no field. It breaks the visibility requirement.
Fit
Fits in one pull request.
Suspected block
None.
Activity
dan-petty commentedon Nov 12, 2026
Both work on RAG point payloads in the same subsystem; #4921 adds commit and doc_class fields, while the candidate restructures the entire search pipeline to Qdrant server-side BM25 and RRF fusion.devops-cli-service commentedon Nov 15, 2026
Alternatives check: in-use
Reason: Searches and the Qdrant docs show that Qdrant already ships everything the issue asks to adopt: named dense and sparse vectors, a sparse vector with the IDF modifier filled server-side from the chunk text by the
qdrant/bm25model, the Query API with prefetch plus RRF fusion and an explicitk, and collection aliases. The issue itself states Qdrant 1.19.1 is live in the project, so the change is a configuration and migration of the existing store, not new code.The repository already uses this tool.
Tool: qdrant/qdrant (https://github.com/qdrant/qdrant)
Covers:
idfmodifier, IDF kept at the collection levelqdrant/bm25model (a Document is sent on upsert and on query, so no model weights or GPU are needed)rrffusion, withkset explicitlyLacks:
visibilitypayload field, payload indexes and the point-count check are schema and ingest work on our side, not a tool featureTools considered:
Searches run:
Sources:
Checked on 2026-11-15. A person decides what this means for the item. The check changes no label and closes no issue.
devops-cli-service commentedon Nov 16, 2026
Refine cannot set this item to Ready at 181f85e while the items below stay open. The next refine round looks at the item again when they close, or when a person replies in a comment or edits the body.
The next refine round also looks at the item again when a commit on the default branch changes one of these files:
src/devops_cli/ai/rag/chunker.py,src/devops_cli/ai/rag/ingest.py,src/devops_cli/ai/rag/reranker.py.devops-cli-service commentedon Nov 18, 2026
Refine cannot set this item to Ready at 86358b6 while the items below stay open. The next refine round looks at the item again when they close, or when a person replies in a comment or edits the body.
devops-cli-service commentedon Nov 26, 2026
Next step: the open items close, or a person replies in a comment or edits the body. See Dependencies in the section Proposed design of the body.