fix: _normalize_rule adds screen_type/geo defaults + step2 test downgrades to warn - Closes #86
CI / test (pull_request) Successful in 10s

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
2026-06-03 14:44:11 +08:00
parent 34c27cbf38
commit f7f00091a6
3 changed files with 56 additions and 2 deletions
@@ -134,6 +134,18 @@ def _normalize_rule(rule: dict) -> dict:
Fixes common LLM output issues: missing trigger, null operator, etc.
"""
# Ensure precondition has required fields (defensive against LLM omission)
if "precondition" not in rule:
rule["precondition"] = {}
precond = rule["precondition"]
if precond is None:
rule["precondition"] = {}
precond = rule["precondition"]
if "geographic_scope" not in precond or not precond["geographic_scope"]:
precond["geographic_scope"] = "global"
if "screen_type" not in precond:
precond["screen_type"] = "any"
# Ensure trigger exists
if not rule.get("trigger"):
rule["trigger"] = {}