""" Writes to the admin audit trail (backend/sql/admin_audit_schema.sql). Never raises — a failed audit write must not break the action it's recording. """ from utils.supabase_client import get_supabase def log_action(actor: str, kind: str, action: str, summary: str, target: str | None = None) -> None: try: get_supabase().table("admin_audit_log").insert({ "actor": actor, "kind": kind, "action": action, "target": target, "summary": summary, }).execute() except Exception as e: print(f"[audit] failed to log {kind}/{action}: {e}")