# src/explainability.py # ----------------------------------------------------------------------------- # Minimal helpers kept for guideline rerun logic (hash-based staleness). # ----------------------------------------------------------------------------- from __future__ import annotations import hashlib import re def normalize_text(s: str) -> str: return re.sub(r"\s+", " ", (s or "").strip()) def text_hash(s: str) -> str: s_norm = normalize_text(s) return hashlib.sha256(s_norm.encode("utf-8")).hexdigest()[:16] def is_stale(current_text: str, baseline_hash: str | None) -> bool: if not baseline_hash: return False return text_hash(current_text) != baseline_hash