fix: step3 _normalize_rule 为空 sources 的 rule 添加最小 text source - Closes #64
CI / test (pull_request) Successful in 11s
CI / test (pull_request) Successful in 11s
防御性处理 LLM 输出中 sources 为空数组的情况,避免 Layer A schema 失败。 Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
@@ -526,3 +526,15 @@ class TestNormalizeRule:
|
||||
assert normalized["sources"][0]["type"] == "text"
|
||||
assert normalized["sources"][1]["type"] == "text"
|
||||
assert normalized["sources"][0]["section"] == "3.1 功能"
|
||||
|
||||
def test_normalize_empty_sources(self):
|
||||
"""Rules with empty sources get a minimal text source (defensive)."""
|
||||
rule = {
|
||||
"trigger": {"conditions": [{"signal": "x", "operator": "==", "value": "1"}]},
|
||||
"path": "3.1 策略 > decision_speed",
|
||||
"sources": [],
|
||||
}
|
||||
normalized = _normalize_rule(rule)
|
||||
assert len(normalized["sources"]) == 1
|
||||
assert normalized["sources"][0]["type"] == "text"
|
||||
assert normalized["sources"][0]["section"] == "3.1 策略"
|
||||
|
||||
Reference in New Issue
Block a user