"""Rule confidence lookup table loaded from rule_confidence.json.""" import json from functools import cache from pathlib import Path from typing import Literal ConfidenceLevel = Literal["HIGH", "MEDIUM", "LOW"] CONFIDENCE_WEIGHTS: dict[ConfidenceLevel, int] = { "HIGH": 100, "MEDIUM": 70, "LOW": 40, } _LOOKUP_PATH = Path(__file__).resolve().parent.parent / "rule_confidence.json" @cache def get_lookup() -> dict[str, ConfidenceLevel]: """Return the rule_id → confidence level lookup table.""" with _LOOKUP_PATH.open() as f: return json.load(f) def get_expected_rule_ids() -> set[str]: """Return the full set of rule IDs the LLM is expected to evaluate.""" return set(get_lookup().keys()) def get_confidence(rule_id: str) -> ConfidenceLevel | None: """Return the confidence level for a rule ID, or None if unknown.""" return get_lookup().get(rule_id)