← Back to Pull requests

eval: prepare reproducible 649-query RAG evidence pipeline #19

Closed
unknown closed this pull request without merging on Sep 29, 2026 20:06 UTC
View on GitHub
unknown unknown commented on Sep 29, 2026 19:24 UTC
Author

Why

PR #18 收敛后,当前 649-query RAG benchmark 的 Hit Rate / MRR 等结果仍为
NOT_VERIFIED(历史 30-query 报告已标记为 historical snapshot)。本工作单目标:
建立 代码 → benchmark → 可复现实验 → 结构化 artifact → 指标 → 失败样本 → 文档
的完整可信 evidence chain,而不是产出单个无法验证的百分比。

本 PR 定位:Evaluation Pipeline PR。不宣称任何当前检索指标。

Status: PARTIAL — pipeline complete, formal evaluation blocked by provider authentication

NO CURRENT RETRIEVAL METRICS ARE CLAIMED BY THIS PR.

正式 649 条评测在 preflight gate 被阻塞(未伪造任何指标):

  • embedding provider 认证失败:SiliconFlow embeddings 端点 401,

  • 语料导入(5000 docs 依赖 embedding)与向量通道随之阻塞
  • reranker provider 同样 401:且 ApiReranker 在 API 失败时静默回退原始顺序,

  • harness 探针通过检查 rerank_score 附加识别 silent_fallback,避免假阳性
  • 本地 Qdrant 为空:集合 0 points(导入被 embedding 阻塞,downstream 症状)

  • 阻塞 evidence artifact:

  • artifacts/evaluation/rag-649/preflight-20260929T191128Z/report.json

    凭据恢复后按 make rag-eval-import → make rag-eval-649-preflight →
    make rag-eval-649-smoke → make rag-eval-649 复现正式评测;
    正式评测结果将进入独立的后续 evidence PR,不在本 PR 内混入。

    Blocker semantics(本 PR 收口修正)

    preflight 判定升级为 primary cause != downstream symptom 的结构化语义
    (rag-eval-evidence/v2):

  • status: BLOCKED + primary_blocker(根因)+ blockers[]

  • (code / stage / blocking / blocks_experiments / caused_by / http_status)
  • 索引为空且 embedding 认证失败时,VECTOR_INDEX_EMPTY.caused_by =

  • EMBEDDING_PROVIDER_AUTH
    ——不再让两个互相矛盾的状态字符串并存
  • reranker 失败(401 → RERANKER_PROVIDER_AUTH;其他 →

  • RERANKER_PROVIDER_DEGRADED)只阻塞 hybrid_rerank,不得阻塞
    vector_only / bm25_only / hybrid_no_rerank(回归测试防护)
  • artifact 只记录 provider HTTP 状态码与探针结果,绝不记录凭据材料

  • (key / Authorization / 凭据 hash / 前后缀均不落盘)
  • 历史 v1 artifact(preflight-20260929T191128Z)原样保留不回填,

  • v1/v2 语义映射已在 docs/reference/rag-evaluation.md §3.3.1 说明

    Gold coverage methodology(三套 population 口径,全部动态计算)

    正式 artifact 必须输出 evaluation_populations(§3.3.2),分母运行时推导、
    禁止硬编码:

    | 视图 | 定义 | 用途 |
    |------|------|------|
    | all_queries(View A,主口径) | 全部查询进分母;GOLD_NOT_INDEXED 仍算失败按 0 分计入 | 系统级:coverage + indexing + retrieval |
    | retrieval_eligible(View B) | ≥1 个 gold doc 已进入索引的查询 | 「至少存在可命中文档」下的 retriever 表现 |
    | full_gold_covered(View C) | 全部 gold docs 都在索引中的查询 | Recall@K / NDCG,避免 gold 缺失压低算法指标 |

    主口径固定为 all_queries(端到端);另两视图只并列输出,不得挑选最好看的
    一组单独宣称。引用指标必须注明 population。

    Benchmark environment

  • benchmark: tests/eval/rag_benchmark.json 649 queries(metadata 与 len 一致,sha256 记录于 artifact)

  • corpus: data/knowledge_base/knowledge_base_5000.jsonl(5000 docs,sha256 记录于 import manifest)

  • gold coverage 审计(import manifest,语料文件口径):1250 unique gold doc 中

  • 1220 在语料(97.6%);30 个 scene_0008xx 不在语料,影响 80 条查询
    (40 条全部 gold 缺失)→ 正式评测按 GOLD_NOT_INDEXED 记账,三视图分母由
    harness 运行时对索引 corpus 动态计算,不硬编码上述数字
  • qdrant client 1.19.0 / server 1.12.0(版本差异已记录进 preflight gate)
  • What this PR delivers(harness hardening)

  • scripts/evaluate_rag.py 重写为 CLI-first evidence pipeline:

  • - 4 检索配置 ablation:vector_only / bm25_only / hybrid_no_rerank / hybrid_rerank
    (override 仅作用于评测进程实例/请求级,生产默认配置不变,有测试防护)
    - 多 K 指标:Hit@K / Recall@K / Precision@K / NDCG@K(binary relevance)/ MRR@K
    - 实测 latency:total + 分阶段(来自 retrieval trace,非推算),mean/P50/P90/P95/P99
    - per-experiment warmup(结果弃置)、failure taxonomy(TIMEOUT / PROVIDER_ERROR /
    GOLD_NOT_INDEXED / MISS_ALL / LOW_RANK + VECTOR_MISS / BM25_MISS /
    FUSION_DEGRADED / RERANK_DEGRADED 通道级诊断)、exception 全记录
    - reranker uplift:RERANK_IMPROVED / RERANK_DEGRADED 作为 comparative tags
    (非 error),含 improved/degraded/unchanged 逐 query 计数
    - artifact:report.json + failures.json(提交),raw_results.json(本地,
    sha256 记录于 report);provenance 全自动采集(git SHA / benchmark sha256 /
    runtime config / 模型名 / timestamp),禁止手填
  • scripts/import_eval_corpus.py:幂等语料导入(确定性 point id)+ BM25 rebuild

  • + gold 覆盖率审计 + import manifest
  • make rag-eval-649 / rag-eval-649-preflight / rag-eval-649-smoke / rag-eval-import

  • docs/reference/rag-evaluation.md:执行管线、blocker v2 语义、三视图口径

  • 文档化,当前指标维持 NOT_VERIFIED 并记录阻塞证据

    Metrics

    未产出。 当前 649-query 指标保持 NOT_VERIFIED(见 Status)。
    历史 30-query 快照(2026-06)保持原样。

    Verification

  • python -m compileall scripts rag core ✅

  • doc guards:audit_doc_consistency / project_facts --check / openapi --check 全 OK

  • pytest tests/unit/test_rag_eval_harness.py -q → 30 passed

  • (其中 blocker semantics 7 个 + population 4 个为本收口新增回归测试)
  • pytest tests/unit/test_doc_consistency.py -q → 26 passed

  • ruff check(changed files)clean

  • gold data 未动:git diff origin/main...HEAD -- tests/eval/rag_benchmark.json 为空

  • 凭据泄漏扫描:diff 与 artifacts 无 credential material(仅字段名/安全说明)
  • Known limitations

  • 正式评测未运行(provider 凭据失效),4 实验 ablation 数字缺位

  • gold coverage 97.6%(30 个 gold doc 不在当前语料),正式评测按

  • GOLD_NOT_INDEXED 记账并以三视图并列报告
  • qdrant client/server 小版本差 >1(1.19 vs 1.12),运行有兼容性警告,

  • 已记录进 preflight gate

    Not changed

  • tests/eval/rag_benchmark.json(gold data 未动,diff 为空)

  • 历史报告 / rag-evaluation-report.json 快照 / 历史 v1 preflight artifact

  • 生产默认配置(HYBRID_* 等)

  • README / 简历 / 面试材料(无已验证指标可引用,遵循证据边界原则)
  • Diff: 620 lines (+465 / -155) across 7 files Reviewer: Xander-Xai Review duration: 41m
    All Vouch review confidence checks passed
    Residual risk 0.20 = Change Risk (0.50) × (1 − Review Confidence (0.60)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.50 · 620 lines diff across 7 files
    0.50
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.17 · 1 substantive comment(s)
    0.17
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    60%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Diff Size diff_size
    0.385
    Shallow Review Depth shallow_review_depth
    0.289
    Real PR Conversation Timeline
    1 comments
    "Review active on #19"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 60.5% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 50.3% (MEDIUM) · Higher = larger blast radius
    50.3%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 60.5% · Lower = rushed or shallow review
    60.5%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 19.9% · Safe to merge
    19.9%