Files
group_fqcd_jr/tests/unit/service/test_knowledge_search_collections.py
T
张胜宇 9675df8453 chore(sync): zsy_developcc 全量同步至 qyqy_develop(W26 口径)
- 分支内容对齐 qyqy_develop b6ec3aa,树完全一致(同步后 git diff 为空)
- 覆盖本轮全部交付:客服 Agent 重构(安全路由 / 五出口 / 记忆与画像 / RAG 全链路)
  + 开发文档 62 份编号体系(D1.1 v1.17 索引)
  + 新增 D2.10-客服Agent端到端答辩文档-2026-09-21.html
- 基线:e239eb7(2026-09-17 品牌口径统一快照),本提交为其直接后继
2026-09-21 21:26:30 +08:00

37 lines
1.6 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
"""检索面白名单:第 4 集合(`乙-7`)**建了但不进默认检索面**。
这条断言守的是一个**实测结论**,不是审美偏好。2026-09-19 把 `fin_basic_collection`
加进默认检索面后复跑 46 条金标,`M-1` 出口准确率 100% → 91.3%:
通用常识文本与很多问题都"像",会把**次优分**抬到 0.69–0.79,
而 `MIN_GAP=0.07` 的"top1 领先不足"判据据此把本该直答的题推给证据约束生成。
要启用它,先做跨集合分数归一 / 重排,并复跑 `_eval_harness` 确认 `M-1` 仍是 100%。
"""
from app.core.knowledge_contracts import ALLOWED_COLLECTIONS
from app.service.knowledge_search_service import (
BASIC_COLLECTION,
DEFAULT_COLLECTIONS,
FALLBACK_COLLECTIONS,
PRIMARY_COLLECTIONS,
)
def test_basic_collection_is_allowlisted_and_built() -> None:
# 集合本身是"已建好、已灌库"的:契约放行 + 有补位位次。
assert BASIC_COLLECTION == "fin_basic_collection"
assert BASIC_COLLECTION in ALLOWED_COLLECTIONS
assert FALLBACK_COLLECTIONS == (BASIC_COLLECTION,)
def test_default_retrieval_surface_stays_the_three_primary_collections() -> None:
assert PRIMARY_COLLECTIONS == (
"fin_faq_collection", "fin_product_collection", "fin_policy_collection",
)
assert DEFAULT_COLLECTIONS == PRIMARY_COLLECTIONS
# 回归红线:第 4 集合不得悄悄回到默认检索面。
assert BASIC_COLLECTION not in DEFAULT_COLLECTIONS
def test_every_default_collection_is_allowlisted() -> None:
assert set(DEFAULT_COLLECTIONS) <= set(ALLOWED_COLLECTIONS)