Files
rag/test_files/rag_output.txt
lacerate551 cb75b9b274 fix(boundary): 修复多库边界问题、版本管理及删除清理
多库检索与存储修复:
- RRF 融合去重改用 (collection, chunk_id) 复合键,修复同名文件结果被吞
- DocStore 存储路径加 collection 前缀,修复跨库同名切片数据覆盖
- search_multiple 去重改用复合键
- chunk_id 解析改用 rsplit 兼容下划线文件名

上传与版本管理修复:
- 同名文件上传改为覆盖模式,自动清理旧切片
- 修复首次上传不创建版本记录
- 修复覆盖上传版本号回退到 v1
- sync ADDED 分支改用动态版本号生成
- _generate_version_id 改为基于全部版本递增
- 废止/恢复操作同步 SQLite 版本记录
- mark_document_as_superseded 改为仅更新 SQLite

删除清理修复:
- 删除文档时同步清理 SQLite 版本记录和变更日志
- 删除向量库时同步清理该库所有版本记录
- cleanup 改为清理 SQLite 记录而非 ChromaDB

测试:
- test_version_management.py: 27 条版本管理单元测试
- test_edge_cases.py: 28 条边界用例测试
- test_upload_dedup.py: 5 条上传去重测试
- e2e_risk_test.py: 27 条端到端风险测试

文档:
- 新增风险边界问题修复注意事项.md(面向后端的对接文档)
- 新增向量库边界风险分析.md
- 更新多篇现有文档
2026-06-04 23:58:44 +08:00

69 lines
9.0 KiB
Plaintext
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.
data: {"type": "intent_result", "data": {"intent": "factual", "confidence": 0.9, "rewritten_query": "迟到处罚有什么规定", "sub_queries": ["迟到处罚有什么规定"], "need_retrieval": true, "reason": "问题询问迟到处罚的具体规定,属于事实查询,需要从知识库检索相关信息。"}}
data: {"type": "start", "message": "正在检索知识库..."}
data: {"type": "retrieval_debug", "data": {"steps": [{"name": "multi_kb_search", "collections": ["dept_a_kb", "dept_b_kb"]}, {"name": "rrf_fusion", "count": 2, "inputs": 2}, {"name": "mmr_dedup", "before": 2, "after": 2}, {"name": "rerank", "count": 2}, {"name": "context_expansion", "before": 2, "after": 2}], "collections_searched": ["dept_a_kb", "dept_b_kb"], "total_candidates": 2}}
data: {"type": "chunks_retrieved", "data": {"count": 2, "chunks": [{"rank": 1, "source": "rule_a.txt", "page": 1, "chunk_type": "text", "section": "", "score": 0.6388, "content": "部门B考勤管理制度\n\n第一条 工作时间\n部门B实行弹性工时制核心工作时间为10:00-16:00其余时间自由安排。\n\n第二条 迟到处罚\n部门B不设迟到处罚但月度累计迟到超过5次需提交书面说明。\n\n第三条 加班规定\n部门B鼓励高效工作不提倡加班如需加班可调休补偿。\n\n第四条 请假流程\n部门B员工请假通过钉钉申请5天以内直属主管审批即可。\n\n第五条 特殊条款\n部门B因研发性质每周五下午为技术分享日不计入考勤。"}, {"rank": 2, "source": "rule_a.txt", "page": 1, "chunk_type": "text", "section": "", "score": 0.6258, "content": "部门A考勤管理制度2026年修订版\n\n第一条 工作时间(已更新)\n部门A自2026年起实行混合办公制每周一三五到岗周二四可远程办公。\n核心工作时间10:00-16:00必须在岗或在线。\n\n第二条 迟到处罚(已更新)\n部门A员工迟到超过10分钟第一次口头警告第二次扣除当日午餐补贴。\n月度累计迟到3次以上需参加时间管理培训。\n\n第三条 加班规定(已更新)\n部门A加班实行积分制每小时积1分满10分可兑换1天调休。\n季度积分不清零年度清零。\n\n第四条 年假制度(新增条款)\n部门A员工入职满1年享5天年假满3年享10天年假满5年享15天年假。\n年假需提前一周申请不可跨年累积。\n\n"}]}}
data: {"type": "sources", "sources": [{"source": "rule_a.txt", "page": null, "page_end": null, "page_range": "", "section": "", "chunk_type": "text", "doc_type": "other", "section_chunk_id": null, "score": 0.639}]}
data: {"type": "images_selected", "data": {"total_scored": 0, "selected_count": 0, "images": []}}
data: {"type": "context_built", "data": {"chunk_count": 2, "context_length": 578, "budget_max_chars": 8000, "min_score_filter": 0.05, "confidence_top3": 0.6323, "score_stats": {"max": 0.6388, "min": 0.6258, "avg": 0.6323}, "context_preview": "部门B考勤管理制度\n\n第一条 工作时间\n部门B实行弹性工时制核心工作时间为10:00-16:00其余时间自由安排。\n\n第二条 迟到处罚\n部门B不设迟到处罚但月度累计迟到超过5次需提交书面说明。\n\n第三条 加班规定\n部门B鼓励高效工作不提倡加班如需加班可调休补偿。\n\n第四条 请假流程\n部门B员工请假通过钉钉申请5天以内直属主管审批即可。\n\n第五条 特殊条款\n部门B因研发性质每周五下午为技术分享日不计入考勤。\n\n部门A考勤管理制度2026年修订版\n\n第一条 工作时间(已更新)\n部门A自2026年起实行混合办公制每周一三五到岗周二四可远程办公。\n核心工作时间10:00-16:00必须在岗或在线。\n\n第二条 迟到处罚(已更新)\n部门A员工迟到超过10分钟第一次口头警告第二次扣除当日午餐补贴。\n月度累计迟到3次以上需参加时间管理培训。\n\n第三条 加班规定(已更新)\n部门A加班实行积分制每小时积1分满10分可兑换1天调休。\n季度积分不清零年度清零。\n\n第四条 年假制度(新增条款)\n部门A员工入职满1年享5天年假满3年享10天年假满5年享15天年假。\n年假需提前一", "chunks_used": [{"source": "rule_a.txt", "page": 1, "score": 0.6387675809081186, "preview": "部门B考勤管理制度\n\n第一条 工作时间\n部门B实行弹性工时制核心工作时间为10:00-16:00其余时间自由安排。\n\n第二条 迟到处罚\n部门B不设迟到处罚但月度累计迟到超过5次需提交书面说明。\n"}, {"source": "rule_a.txt", "page": 1, "score": 0.6258080932992242, "preview": "部门A考勤管理制度2026年修订版\n\n第一条 工作时间(已更新)\n部门A自2026年起实行混合办公制每周一三五到岗周二四可远程办公。\n核心工作时间10:00-16:00必须在岗或在线。\n\n第二"}]}}
data: {"type": "chunk", "content": "根据提供的"}
data: {"type": "chunk", "content": "参考资料,部门"}
data: {"type": "chunk", "content": "A和部门"}
data: {"type": "chunk", "content": "B的"}
data: {"type": "chunk", "content": "迟到处罚规定如下"}
data: {"type": "chunk", "content": "\n\n**"}
data: {"type": "chunk", "content": "部门B的"}
data: {"type": "chunk", "content": "迟到处罚规定**"}
data: {"type": "chunk", "content": "\n"}
data: {"type": "chunk", "content": "部门B不设"}
data: {"type": "chunk", "content": "迟到处罚,但"}
data: {"type": "chunk", "content": "月度累计迟到"}
data: {"type": "chunk", "content": "超过5次需"}
data: {"type": "chunk", "content": "提交书面说明。"}
data: {"type": "chunk", "content": "[1]\n\n**"}
data: {"type": "chunk", "content": "部门A的迟到"}
data: {"type": "chunk", "content": "处罚规定**\n"}
data: {"type": "chunk", "content": "部门A员工迟到"}
data: {"type": "chunk", "content": "超过10分钟"}
data: {"type": "chunk", "content": ",第一次口头警告"}
data: {"type": "chunk", "content": ",第二次扣除当日"}
data: {"type": "chunk", "content": "午餐补贴。月"}
data: {"type": "chunk", "content": "度累计迟到3"}
data: {"type": "chunk", "content": "次以上需参加"}
data: {"type": "chunk", "content": "时间管理培训。"}
data: {"type": "chunk", "content": "[2]"}
data: {"type": "finish", "answer": "根据提供的参考资料部门A和部门B的迟到处罚规定如下\n\n**部门B的迟到处罚规定**\n部门B不设迟到处罚但月度累计迟到超过5次需提交书面说明。[ref:rule_a.txt_0]\n\n**部门A的迟到处罚规定**\n部门A员工迟到超过10分钟第一次口头警告第二次扣除当日午餐补贴。月度累计迟到3次以上需参加时间管理培训。[ref:rule_a.txt_0]", "mode": "rag", "session_id": "e3e3bcf5-b350-4c62-bfbe-396066641e27", "sources": [{"source": "rule_a.txt", "page": null, "page_end": null, "page_range": "", "section": "", "chunk_type": "text", "doc_type": "other", "section_chunk_id": null, "score": 0.639}], "citations": [{"chunk_id": "rule_a.txt_0", "chunk_index": 0, "source": "rule_a.txt", "collection": "dept_b_kb", "doc_type": "other", "section": "", "preview": "", "content": "部门B考勤管理制度\n\n第一条 工作时间\n部门B实行弹性工时制核心工作时间为10:00-16:00其余时间自由安排。\n\n第二条 迟到处罚\n部门B不设迟到处罚但月度累计迟到超过5次需提交书面说明。\n\n第三条 加班规定\n部门B鼓励高效工作不提倡加班如需加班可调休补偿。\n\n第四条 请假流程\n部门B员工请假通过钉钉申请5天以内直属主管审批即可。\n\n第五条 特殊条款\n部门B因研发性质每周五下午为技术分享日不计入考勤。", "chunk_type": "text", "page": 1, "page_end": 1, "bbox": null, "bbox_mode": null}, {"chunk_id": "rule_a.txt_0", "chunk_index": 0, "source": "rule_a.txt", "collection": "dept_a_kb", "doc_type": "other", "section": "", "preview": "", "content": "部门A考勤管理制度2026年修订版\n\n第一条 工作时间(已更新)\n部门A自2026年起实行混合办公制每周一三五到岗周二四可远程办公。\n核心工作时间10:00-16:00必须在岗或在线。\n\n第二条 迟到处罚(已更新)\n部门A员工迟到超过10分钟第一次口头警告第二次扣除当日午餐补贴。\n月度累计迟到3次以上需参加时间管理培训。\n\n第三条 加班规定(已更新)\n部门A加班实行积分制每小时积1分满10分可兑换1天调休。\n季度积分不清零年度清零。\n\n第四条 年假制度(新增条款)\n部门A员工入职满1年享5天年假满3年享10天年假满5年享15天年假。\n年假需提前一周申请不可跨年累积。\n\n", "chunk_type": "text", "page": 1, "page_end": 1, "bbox": null, "bbox_mode": null}], "images": [], "tables": [], "sections": [], "duration_ms": 6048, "confidence_score": 0.6323, "timing": {"total_search_ms": 88, "rerank_ms": 0, "rerank_cached": false, "total_ms": 6048}}