rohitg00/ai-engineering-from-scratch · error · ValueError
unknown predicate: {list(node.keys())}
Error message
unknown predicate: {list(node.keys())} What it means
Error "unknown predicate: {list(node.keys())}" thrown in rohitg00/ai-engineering-from-scratch.
Source
Thrown at phases/19-capstone-projects/86-constitutional-rules-engine/code/main.py:122
if "contains_regex" in node:
m = re.search(node["contains_regex"], text, flags=re.IGNORECASE | re.DOTALL)
return (m is not None), (m.group(0) if m else None)
if "not_contains_regex" in node:
m = re.search(node["not_contains_regex"], text, flags=re.IGNORECASE | re.DOTALL)
return (m is None), (m.group(0) if m else None)
if "ends_with_regex" in node:
m = re.search(node["ends_with_regex"] + r"\Z", text, flags=re.IGNORECASE | re.DOTALL)
return (m is not None), (m.group(0) if m else None)
if "starts_with_regex" in node:
m = re.match(node["starts_with_regex"], text, flags=re.IGNORECASE | re.DOTALL)
return (m is not None), (m.group(0) if m else None)
if "max_words" in node:
wc = _word_count(text)
return (wc <= int(node["max_words"])), (f"word count {wc}" if wc > int(node["max_words"]) else None)
if "min_words" in node:
wc = _word_count(text)
return (wc >= int(node["min_words"])), (f"word count {wc}" if wc < int(node["min_words"]) else None)
raise ValueError(f"unknown predicate: {list(node.keys())}")
class Engine:
def __init__(self, rules: list[dict[str, Any]] | None = None, path: Path | None = None) -> None:
if rules is not None:
self._rules = rules
else:
target = path or DEFAULT_RULES_PATH
data = load_yaml(target.read_text())
if not isinstance(data, dict) or "rules" not in data:
raise ValueError("constitution must be a mapping with a 'rules' key")
self._rules = data["rules"]
for r in self._rules:
if r.get("severity") not in SEVERITY_ORDER:
raise ValueError(f"rule {r.get('name')} has bad severity {r.get('severity')}")
if "name" not in r or "explanation" not in r or "must" not in r:
raise ValueError(f"rule {r.get('name')} missing required field")
View on GitHub (pinned to 39ea8a1c6d)
When it happens
Trigger: Thrown at phases/19-capstone-projects/86-constitutional-rules-engine/code/main.py:122 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of rohitg00/ai-engineering-from-scratch@39ea8a1c6d (2026-08-26).
Data as JSON: /api/errors/8c50a51ba0a21181.
Report an issue: GitHub.