fix: step3 过滤非法 source type + step1 重试质量门控 - Closes #57
CI / test (pull_request) Successful in 11s
CI / test (pull_request) Successful in 11s
- step3 _normalize_rule: 将 function_unit_description 等非法 source type 标准化为 text - step1 覆盖反馈重试: 仅纳入实际提升覆盖率的 retry 结果,避免低质量输出稀释 ensemble - 新增 UT: test_normalize_source_invalid_type Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
@@ -170,8 +170,11 @@ def _normalize_rule(rule: dict) -> dict:
|
||||
}]
|
||||
|
||||
# Ensure table/text sources have a section field (defensive against LLM omission)
|
||||
# Also normalize invalid source types (LLM hallucinations like function_unit_description)
|
||||
sources = rule.get("sources", [])
|
||||
if sources:
|
||||
valid_types = {"table", "text", "logic_tree"}
|
||||
|
||||
# try to infer a default section from sibling sources or the rule path
|
||||
default_section = ""
|
||||
for s in sources:
|
||||
@@ -186,6 +189,10 @@ def _normalize_rule(rule: dict) -> dict:
|
||||
|
||||
for src in sources:
|
||||
stype = src.get("type", "")
|
||||
# Normalize invalid source types to "text"
|
||||
if stype and stype not in valid_types:
|
||||
src["type"] = "text"
|
||||
stype = "text"
|
||||
if stype in ("table", "text"):
|
||||
if not src.get("section"):
|
||||
src["section"] = default_section
|
||||
|
||||
Reference in New Issue
Block a user