feat: add reproducible RAG retrieval benchmark #17
<sub><sub>!P1 Badge</sub></sub> Require retrieval depth to cover every reported cutoff
When --top-k is less than 10 (for example, --top-k 5), the runner retrieves only that many items but still labels metrics as Recall@10, MRR@10, and NDCG@10. Relevant results at ranks 6–10 can never be observed, so these values are silently understated. Reject depths below the largest metric cutoff or retrieve at least 10 items independently of the requested output depth.
Useful? React with 👍 / 👎.
<sub><sub>!P2 Badge</sub></sub> Authenticate the Elasticsearch availability probe
In the repository's standard Compose deployment, Elasticsearch has xpack.security.enabled=true and requires the elastic credentials, but this request ignores ELASTICSEARCH_USERNAME and ELASTICSEARCH_PASSWORD. The resulting HTTP 401 is caught as an unavailable service, so a healthy secured Elasticsearch instance is falsely reported as unreachable even though the production BM25Retriever supports basic authentication.
Useful? React with 👍 / 👎.
<sub><sub>!P2 Badge</sub></sub> Compute coverage from the selected query subset
For runs using --limit or --sample-id, rows still contains the entire dataset while the benchmark executes only queries. Thus the artifact can record metadata.sample_count=5 but report dataset coverage for all 301 rows, and field/bucket availability may be attributed to samples that were not benchmarked. Build coverage from the selected queries' raw rows so the report describes the actual run.
Useful? React with 👍 / 👎.
<sub><sub>!P2 Badge</sub></sub> Check stable-ID fields individually
For any custom --dataset containing doc_id, chunk_id, or source_id, this passes the whole tuple to dict.get as one key instead of checking each field. JSON rows therefore always fall through to level2_normalized_exact_text, even though load_queries separately detects and uses the stable ID, causing the artifact to misreport the relevance strategy used by the run.
Useful? React with 👍 / 👎.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: ffca11c4a3
<details> <summary>ℹ️ About Codex in GitHub</summary>
<br/>
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
</details>
@codex review
<sub><sub>!P2 Badge</sub></sub> Read the configured dense collection
When embedding.text.collection is changed from rag_text_768, the production dense search uses that configured value (models/embedding_service.py:206), but this probe still checks the hard-coded default. A healthy configured collection can therefore be reported as unreachable, or a stale default collection can be validated instead of the collection the benchmark would query.
Useful? React with 👍 / 👎.
<sub><sub>!P2 Badge</sub></sub> Derive the Elasticsearch probe port from its URL
When elasticsearch.host embeds a non-default port, such as http://localhost:19200, or uses HTTPS without a separate port setting, this TCP check still connects to the fallback port 9200. It can reject a reachable Elasticsearch endpoint before attempting the correctly formed HTTP request; parse the hostname and port from the configured URL unless an explicit port override is provided.
Useful? React with 👍 / 👎.
<sub><sub>!P2 Badge</sub></sub> Do not label blocked artifacts as benchmark results
For the currently expected case where every requested configuration is BLOCKED, the artifact contains no retrieval-quality result but metadata still sets results_are_benchmark to true. Any artifact consumer relying on this explicit field can consequently publish or ingest a blocked run as benchmark evidence; derive it from whether a configuration actually executed instead.
Useful? React with 👍 / 👎.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: ffca11c4a3
<details> <summary>ℹ️ About Codex in GitHub</summary>
<br/>
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
</details>
Confirmed P1. Root cause: --top-k was passed straight to the retriever, so a depth below 10 truncated the ranking while metrics were still labelled Recall@10 / MRR@10 / NDCG@10. Fix: added MIN_TOP_K = max(RECALL_KS, HIT_KS, MRR_K, NDCG_K) = 10; the CLI rejects a shallower depth with an explanatory error and run_configuration raises ValueError. Regression tests: test_top_k_below_largest_cutoff_is_rejected, test_min_top_k_covers_the_largest_cutoff, test_cli_rejects_shallow_top_k. Commit 219e0c6.
Confirmed. Root cause: the probe used unauthenticated HTTP, so a secured Elasticsearch (Compose sets xpack.security.enabled=true) answers 401 and was reported as service_unreachable. Fix: _http_get now sends basic auth from ELASTICSEARCH_USERNAME/ELASTICSEARCH_PASSWORD, and an HTTP-level error status is treated as reachable (reported as an auth/index problem) rather than unreachable. Regression tests: test_elastic_probe_uses_configured_credentials, test_http_status_is_reachable_not_unreachable. Commit 219e0c6.
Confirmed. Root cause: coverage was computed from the whole dataset file while only the selected queries ran, so a --limit 5 artifact described 301 samples. Fix: coverage is now built from [query.raw for query in queries]. Regression test: test_coverage_reflects_selected_subset, test_coverage_unavailable_buckets_still_reported. Commit 219e0c6.
Confirmed, real bug. Root cause: row.get(_STABLE_ID_KEYS) passed the whole tuple as a single key, so it always returned None and every dataset was reported as level2 even though load_queries used a stable id when present. Fix: each field is checked individually. Regression tests: test_detect_relevance_level_sees_each_stable_id[doc_id|chunk_id|source_id], test_stable_id_dataset_loads_level1_items. Verified these fail against the old code. Commit 219e0c6.
Confirmed. Root cause: _qdrant_settings hard-coded rag_text_768 instead of the configured embedding.text.collection used by the production dense search. Fix: the probe now prefers embedding.text.collection, then the Qdrant collections map, then the default. Regression test: test_qdrant_probe_uses_configured_text_collection. Commit 219e0c6.
Confirmed. Root cause: the TCP pre-check connected to the 9200 fallback even when elasticsearch.host embedded another port. Fix: _elastic_settings parses hostname/port/scheme from the configured URL and only falls back when no port is given; an explicit port setting still wins. Regression test: test_elastic_port_is_parsed_from_url. Commit 219e0c6.
Confirmed. Root cause: results_are_benchmark was hard-coded true, so a fully BLOCKED artifact advertised itself as benchmark evidence. Fix: it is derived from summary["any_results"], so a blocked run records false. Regression test: test_blocked_run_metadata_is_not_a_benchmark (verified failing against the old hard-coded value). Commit 219e0c6.
@codex review
<sub><sub>!P2 Badge</sub></sub> Reject HTTP errors from the Qdrant collection probe
When Qdrant returns 401, 403, or 404 for this collection endpoint, _http_get returns the truthy sentinel "http"; this condition therefore accepts the error and, if the model directory exists, reports the dense backend as available even when the collection is absent or inaccessible. Handle the HTTP-error sentinel explicitly so availability manifests and --list-configs identify the actual blocker.
Useful? React with 👍 / 👎.
<sub><sub>!P2 Badge</sub></sub> Leave unmeasured stage latency unset
For every configuration executed through retriever_factory, this assigns the same end-to-end retrieval duration to each declared stage; a hybrid run consequently reports BM25, dense, RRF, and reranking as all taking the full request time even though none was timed separately. This corrupts the advertised per-stage percentile data, so these fields should remain None unless the executor supplies actual stage timings.
Useful? React with 👍 / 👎.
<sub><sub>!P2 Badge</sub></sub> Prefer environment credentials in the Elasticsearch probe
When config.json contains credentials but a deployment overrides them with ELASTICSEARCH_USERNAME or ELASTICSEARCH_PASSWORD, the probe uses the config values while the production BM25Retriever uses environment values first. The new auth path now reads the environment, but only as a fallback, so credential rotation or deployment overrides can make real retrieval succeed while the benchmark receives a 401 and reports the backend blocked.
Useful? React with 👍 / 👎.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 219e0c6885
<details> <summary>ℹ️ About Codex in GitHub</summary>
<br/>
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
</details>
Confirmed. Root cause: _http_get returns the truthy sentinel "http" on an HTTP-level error, so if not ok was False and a 401/404 for the Qdrant collection fell through to the model check and could report the dense backend as available. Fix: probe_dense handles the sentinel explicitly and reports service_reachable_but_empty with the status code, naming the collection as the blocker. Regression test: test_qdrant_http_error_is_not_treated_as_available (verified failing against the previous code). Commit 8ee0921.
Confirmed; this was a correctness/honesty defect in my own code. Root cause: the runner copied the end-to-end duration into every declared stage, so a hybrid run advertised BM25, dense, RRF and rerank as each taking the full request time although none was timed. Fix: only total_retrieval_ms is measured; every other stage stays None until a real executor supplies a timing. Regression test: test_per_stage_latency_is_not_fabricated asserts all non-total stages stay None and stage_availability reports 0 (verified failing against the previous code). Commit 8ee0921.
Confirmed. Root cause: the probe read config.json first and used the environment only as a fallback, which is the reverse of retrieval/bm25_retriever.py:48-50 where the environment wins. Fix: the probe now mirrors production exactly (ELASTICSEARCH_USERNAME/ELASTICSEARCH_PASSWORD first, config.json as fallback) and requires both parts before authenticating. Regression tests: test_environment_credentials_take_precedence_over_config (verified failing before the fix) and test_config_credentials_used_when_env_absent. Commit 8ee0921.
@codex review
<sub><sub>!P2 Badge</sub></sub> Hash the effective retrieval configuration
config_sha256 only hashes the selected configuration names, top_k, and dataset hash, so runs using different CONFIG_PATH files or Qdrant environment overrides can receive the same configuration hash despite querying different indexes, collections, model revisions, or retrieval settings. This makes the provenance insufficient to reproduce or safely compare results; hash a sanitized snapshot of the effective runtime configuration, including applied environment overrides.
Useful? React with 👍 / 👎.
<sub><sub>!P2 Badge</sub></sub> Preserve run artifacts when a query retrieval fails
When a retriever raises for any individual query—for example, due to a transient backend timeout—the exception escapes this loop and the CLI exits before write_artifacts runs. A single failed sample therefore discards all completed measurements and produces neither failure counts nor a configuration outcome, contrary to the artifact contract; catch per-query retrieval failures and record them, or convert the configuration into an explicit failed/blocked outcome before writing the run.
Useful? React with 👍 / 👎.
<sub><sub>!P2 Badge</sub></sub> Reject empty Qdrant collections
When the Qdrant collection endpoint returns HTTP 200 but reports zero points, this path checks only that model weights exist and marks the dense backend available. As a result, the backend manifest and --list-configs can describe an empty collection as usable and omit the service_reachable_but_empty blocker; inspect the collection response's point count before returning availability.
Useful? React with 👍 / 👎.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 8ee0921dcb
<details> <summary>ℹ️ About Codex in GitHub</summary>
<br/>
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
</details>
Xander-Xai
Why
The repository had implementation evidence and local runtime evidence, but no
reproducible retrieval-quality evidence. Every retrieval-quality number was
either absent or untraceable, which made retrieval claims unfalsifiable.
This PR builds the measurement harness and deliberately ships no benchmark
result: in this environment no retrieval backend and no corpus are available, so
every configuration honestly reports
BLOCKEDwith a reason instead of a number.What
null(never0) for stages that never ranmetadata.json,environment.json,retrieval_metrics.json,latency_metrics.json,per_query_results.jsonl,report.md(+comparison.mdwhen >= 2 configs execute)Metrics
Current breakdown
overallbusiness_typedifficultyNot included:
visual_required: missing for 301/301 samplescomplexity_label: not stored (0/301)Neither label was fabricated. See
docs/benchmark-data-quality.md.Relevance truth
The golden set has no
doc_id/chunk_id/sample_id, so matching islevel2_normalized_exact_text: NFKC + whitespace normalization + trim. Stable-idmatching is implemented and will be preferred automatically if a future dataset
exposes ids. No LLM judge, embedding similarity threshold or fuzzy threshold is
used anywhere in the canonical path.
Current status: framework REPO_VERIFIED, result PENDING
| config | status | reason |
|---|---|---|
|
bm25| BLOCKED | Elasticsearch unreachable; no corpus containing the ground truth ||
dense| BLOCKED | Qdrant unreachable; BGE weights absent; no corpus ||
hybrid_rrf| BLOCKED | both backends + corpus unavailable ||
hybrid_rrf_biencoder| BLOCKED | + BiEncoder weights absent ||
hybrid_rrf_biencoder_crossencoder| BLOCKED | + CrossEncoder weights not wired to a validated path |A real benchmark additionally requires a corpus that contains the golden-set
passages. Indexing the ground truth itself would make every configuration score
recall 1.0 by construction, so that shortcut is deliberately refused and recorded
as
corpus_does_not_contain_ground_truth.Evidence boundary
Repository benchmark results are not historical production metrics. No benchmark
number is published in this PR, and no configuration reports
EXECUTED.Validation
Real results on
ffca11c:Smoke runs (
--limit 5and--limit 20,--allow-dirty) produced a completeartifact set with
executed: noneand the blocking reasons recorded.Not included
No Kubernetes / Kafka / GraphRAG / Agent / MCP / SSO, no microservice rewrite,
no RAGAS evaluator expansion, no 4B/14B serving benchmark, no label fabrication,
no reuse of historical production numbers.