fix: _normalize_rule adds screen_type/geo defaults + step2 test downgrades to warn - Closes #86
CI / test (pull_request) Successful in 10s
CI / test (pull_request) Successful in 10s
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
@@ -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"] = {}
|
||||
|
||||
Reference in New Issue
Block a user