{"record":{"id":"8c50a51ba0a21181","repo":"rohitg00/ai-engineering-from-scratch","slug":"unknown-predicate-list-node-keys","errorCode":null,"errorMessage":"unknown predicate: {list(node.keys())}","messagePattern":"unknown predicate: (.+?)","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"phases/19-capstone-projects/86-constitutional-rules-engine/code/main.py","lineNumber":122,"sourceCode":"    if \"contains_regex\" in node:\n        m = re.search(node[\"contains_regex\"], text, flags=re.IGNORECASE | re.DOTALL)\n        return (m is not None), (m.group(0) if m else None)\n    if \"not_contains_regex\" in node:\n        m = re.search(node[\"not_contains_regex\"], text, flags=re.IGNORECASE | re.DOTALL)\n        return (m is None), (m.group(0) if m else None)\n    if \"ends_with_regex\" in node:\n        m = re.search(node[\"ends_with_regex\"] + r\"\\Z\", text, flags=re.IGNORECASE | re.DOTALL)\n        return (m is not None), (m.group(0) if m else None)\n    if \"starts_with_regex\" in node:\n        m = re.match(node[\"starts_with_regex\"], text, flags=re.IGNORECASE | re.DOTALL)\n        return (m is not None), (m.group(0) if m else None)\n    if \"max_words\" in node:\n        wc = _word_count(text)\n        return (wc <= int(node[\"max_words\"])), (f\"word count {wc}\" if wc > int(node[\"max_words\"]) else None)\n    if \"min_words\" in node:\n        wc = _word_count(text)\n        return (wc >= int(node[\"min_words\"])), (f\"word count {wc}\" if wc < int(node[\"min_words\"]) else None)\n    raise ValueError(f\"unknown predicate: {list(node.keys())}\")\n\n\nclass Engine:\n    def __init__(self, rules: list[dict[str, Any]] | None = None, path: Path | None = None) -> None:\n        if rules is not None:\n            self._rules = rules\n        else:\n            target = path or DEFAULT_RULES_PATH\n            data = load_yaml(target.read_text())\n            if not isinstance(data, dict) or \"rules\" not in data:\n                raise ValueError(\"constitution must be a mapping with a 'rules' key\")\n            self._rules = data[\"rules\"]\n        for r in self._rules:\n            if r.get(\"severity\") not in SEVERITY_ORDER:\n                raise ValueError(f\"rule {r.get('name')} has bad severity {r.get('severity')}\")\n            if \"name\" not in r or \"explanation\" not in r or \"must\" not in r:\n                raise ValueError(f\"rule {r.get('name')} missing required field\")\n","sourceCodeStart":104,"sourceCodeEnd":140,"githubUrl":"https://github.com/rohitg00/ai-engineering-from-scratch/blob/39ea8a1c6d0b61f071226eff7ede4d4105fed820/phases/19-capstone-projects/86-constitutional-rules-engine/code/main.py#L104-L140","documentation":"Error \"unknown predicate: {list(node.keys())}\" thrown in rohitg00/ai-engineering-from-scratch.","triggerScenarios":"Thrown at phases/19-capstone-projects/86-constitutional-rules-engine/code/main.py:122 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"39ea8a1c6d0b61f071226eff7ede4d4105fed820","analyzedAt":"2026-08-26T03:13:46.626Z","schemaVersion":2},"datasetVersion":"2026-08-26T07:17:17.940Z"}