Skip to content

perf(rag): Verify the fusion-order change on eval and production #6287

Open

Description

@devops-cli-service

Split from #4965.

The change of #4965 deletes the weighted SearchReranker and lets the RRF order of the hybrid step stand. Its quality gain and its latency need a measurement that the pull request of #4965 cannot make. This issue makes that measurement and records the result on #4965.

Proposed design

Problem statement

Measure the quality and the median latency of the fusion-order change of #4965 over the checked-in knowledge-base gold set, and record the result on #4965. The eval arm fits one pull request and waits on #4965. The production arm waits on the deployment of #4965 and is deferred to its own issue.

Acceptance criteria

Requirement: Offline fusion-order harness

The RAG module SHALL hold an offline harness that runs hybrid retrieval over a gold set and a document set and reports the quality and the median latency of the run.

Scenario: One measured revision

  • WHEN A test calls the harness with a temporary gold set, a temporary document set, a fake Qdrant client and a fake embedder.
  • THEN The harness returns one quality value and one median latency value for the run.

Requirement: Quality metric at 5

The harness SHALL compute nDCG at 5 from the ranked result and the qrels that the gold set's expected sources build.

Scenario: Ranked result matches the qrels

  • WHEN A test gives the harness a fixture whose ranked result lists exactly the relevant documents of its qrels.
  • THEN The harness reports nDCG at 5 of 1.0, and it reports a value below 1.0 when the ranked result omits a relevant document.

Requirement: Revision-agnostic retriever call

The harness SHALL build the retriever with no reranker argument and SHALL write the revision under test into its record, so one harness measures the weighted-reranker arm and the RRF arm.

Scenario: Two revisions, two records

  • WHEN A test runs the harness twice with two revision labels and reads the two records.
  • THEN Each record holds its own revision label with its own metric value, and the harness module source holds no SearchReranker name.

Requirement: Machine-readable record

The harness SHALL write each run as a JSON record that holds the revision, the eval set name, the metric name, the metric value and the latency.

Scenario: Record fields

  • WHEN A test runs the harness on the fixture and loads the JSON record that it writes.
  • THEN The record holds the keys revision, eval_set, metric, value and latency_ms.

Requirement: Pending a person after the merge

The item SHALL record the quality and the latency of the eval arm on issue #4965, with the path of the committed record.

Scenario: Result comment on #4965

Existing Tool Considered

No alternatives check has run. The open library pytrec_eval (distribution pytrec-eval-terrier, MIT) covers nDCG at 5. The project already holds retrieval-metrics code that reports NDCG at 5 for its embedding benchmark (src/devops_cli/ai/benchmark/embedding_runner.py), and tests/ai/benchmark/test_retrieval_metrics.py covers it. The change reuses that code and adds no metric dependency. The harness that calls the hybrid retriever, times each query and writes the record is new project code: about 4,000 tokens to build, 1,000 tokens per year to keep and fix, and about 1 hour of elapsed work.

Key questions

  • Which revisions does the measurement compare?: The parent commit of the merge of fix(ai): rank RAG hits by fusion, not by the weighted score #4965 and the head of fix(ai): rank RAG hits by fusion, not by the weighted score #4965. The parent holds the weighted SearchReranker in src/devops_cli/ai/rag/reranker.py, and the retriever builds it in src/devops_cli/ai/rag/retriever.py. The RRF arm exists only after fix(ai): rank RAG hits by fusion, not by the weighted score #4965 lands, so this item depends on fix(ai): rank RAG hits by fusion, not by the weighted score #4965. [sources: src/devops_cli/ai/rag/reranker.py, src/devops_cli/ai/rag/retriever.py]
  • Where do the eval query set and its relevant documents live?: The checked-in gold set at tests/fixtures/kb_gold_set/gold_set.json holds 12 entries. Each entry has a question and the expected_source that is its relevance judgment. load_gold_set in src/devops_cli/ai/benchmark/gold_set.py reads it. score_gold_set in src/devops_cli/ai/benchmark/gold_set_scorer.py calls SemanticRetriever.search with hybrid=False, so it does not exercise the RRF order. The harness calls search with hybrid=True. [sources: tests/fixtures/kb_gold_set/gold_set.json, src/devops_cli/ai/benchmark/gold_set.py, src/devops_cli/ai/benchmark/gold_set_scorer.py, docs/TESTING.md]
  • Which code computes the retrieval quality metric?: The retrieval-metrics code that the project already holds. The embedding benchmark reports NDCG at 5 with a p50 latency in src/devops_cli/ai/benchmark/embedding_runner.py, and tests/ai/benchmark/test_retrieval_metrics.py covers that code. The archived gold-set change rejected ranx and ir_measures because the retriever seam already ranks results. The harness reuses that code and adds no metric dependency. (best practice) [sources: src/devops_cli/ai/benchmark/embedding_runner.py, tests/ai/benchmark/test_retrieval_metrics.py, openspec/changes/archive/2026-11-17-3902-a-gold-set-measures-retrieval-of/design.md]
    • Chosen: Reuse the project's retrieval-metrics code. The embedding benchmark already reports NDCG at 5, and the tests cover the code, so the harness adds no metric code and no dependency.
    • Rejected: Add pytrec_eval (pytrec-eval-terrier). It duplicates the nDCG code that the project already holds and tests.
    • Rejected: Add ir_measures. The archived gold-set change rejected a metric dependency because the retriever seam already ranks results.
    • Rejected: Write an nDCG function in the harness. It duplicates the code that the project already holds and tests.
  • Which cutoff does the quality metric use?: nDCG at 5. The review loop injects the top 5 results, the gold-set scorer reports its hit rate at k=5, and the embedding benchmark reports NDCG at 5 with a p50 latency. The fusion-order measurement uses the same depth and the same latency statistic. (best practice) [sources: src/devops_cli/ai/benchmark/gold_set_scorer.py, src/devops_cli/ai/benchmark/embedding_runner.py]
    • Chosen: nDCG at 5. It matches the depth of results that the review loop injects and the metric that the embedding benchmark reports.
    • Rejected: nDCG at 10. It scores documents past the depth that the loop injects, so it measures a ranking that production never reads.
  • Where does the harness live and how is it invoked?: A module under src/devops_cli/ai/rag/ with a __main__ entry point. The same file runs by path with PYTHONPATH=<worktree>/src for the parent arm. The module sits with the retriever that it measures. A run by path keeps the harness module out of the package that the parent worktree supplies. (best practice) [sources: CONTEXT.md, src/devops_cli/ai/rag/retriever.py]
    • Chosen: A module under src/devops_cli/ai/rag/ with a __main__ entry point. It sits with the retriever that it measures and runs by path on both revisions without a new CLI command.
    • Rejected: A CLI command. The measurement is a one-off verification, and a new CLI command adds a user-facing surface and a generated reference.
    • Rejected: A script under scripts/. The module belongs with the retriever that it measures.
    • Rejected: A test under tests/ai/rag/. The measurement must run outside CI, on two revisions.
  • How does the harness measure the parent revision?: git worktree add of the parent revision, and a run of the harness file by path with PYTHONPATH=<worktree>/src. The parent's devops_cli package loads, and the harness file's module is __main__. The project already makes worktrees with devops repos worktrees add. (best practice) [sources: CONTEXT.md, src/devops_cli/ai/rag/retriever.py]
    • Chosen: Worktree of the parent revision, harness file run by path with PYTHONPATH=<worktree>/src. The parent revision's package loads first, and the harness file stays in one copy.
    • Rejected: Install the parent revision in a second virtual environment. It duplicates the environment and takes minutes for each run.
    • Rejected: Copy the harness file into the worktree. Two copies of the harness can drift.
  • How does one harness measure both arms?: The harness builds the retriever with no reranker argument and calls search with hybrid=True and no rerank argument. The parent then applies its weighted SearchReranker, and the new revision applies the RRF order. One harness file measures both arms, and the record holds the revision label. (best practice) [sources: src/devops_cli/ai/rag/retriever.py, src/devops_cli/ai/rag/reranker.py, src/devops_cli/ai/benchmark/gold_set_scorer.py]
    • Chosen: Leave the rerank setting at the revision's default. The parent applies its weighted reranker and the new revision applies the RRF order, so one harness measures the change.
    • Rejected: Pass rerank=False to search. It skips the weighted reranker in the parent arm and measures no fusion-order change.
    • Rejected: Pass a reranker argument. The new revision holds no SearchReranker, so the call fails on one arm.
  • Where is the measurement recorded?: The harness writes a JSON record. The pull request commits it under docs/. A comment on fix(ai): rank RAG hits by fusion, not by the weighted score #4965 holds the numbers with the record path. The production arm is deferred to its own issue. (best practice) [sources: docs/TESTING.md, CONTEXT.md]

Fit

Fits in one pull request.

Suspected block

None.

Dependencies

#4965

Activity

  1. added
    type/infra
    source/agent
    on Nov 18, 2026
  2. devops-cli-service commented on Nov 18, 2026

    @devops-cli-service
    ContributorAuthor
  3. added
    status/new
    value/medium
    effort/medium
    scope/rag
    priority/p2-medium
    on Nov 18, 2026
  4. changed the title [-]perf(rag): verify the fusion-order change on the eval set and in production[/-] [+]perf(rag): Verify the fusion-order change on eval and production[/+] on Nov 18, 2026
  5. devops-cli-service commented on Nov 18, 2026

    @devops-cli-service
    ContributorAuthor

    The job shortened the title of this item. The summary had 64 characters, and the limit is 60. The type and the scope stay.

    • Before: perf(rag): verify the fusion-order change on the eval set and in production
    • After: perf(rag): Verify the fusion-order change on eval and production
    • Source of the summary: the background model
  6. devops-cli-service commented on Nov 19, 2026

    @devops-cli-service
    ContributorAuthor

    Refine cannot set this item to Ready at 3ecd647 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/reranker.py, src/devops_cli/ai/rag/retriever.py.

  7. devops-cli-service commented on Nov 27, 2026

    @devops-cli-service
    ContributorAuthor

    Next step: the open items close, or a person replies in a comment or edits the body. See Dependencies and Watched files in the section Proposed design of the body.

  8. devops-cli-service commented on Nov 29, 2026

    @devops-cli-service
    ContributorAuthor

    Next step: the alternatives check records a verdict. See the section Proposed design of the body.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    effort/mediumpriority/p2-mediumscope/ragsource/agentstatus/newtype/infravalue/medium

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions