def _result_from_counts(rule: dict[str, Any], severity: str, failed_count: int, total_count: int, threshold: Any, message: str) -> dict[str, Any]:
status = "failed" if failed_count > 0 else "passed"
return {
"rule_id": rule.get("rule_id", "unknown"),
"rule_type": rule.get("rule_type", "unknown"),
"column_name": rule.get("column"),
"columns": rule.get("columns"),
"severity": severity,
"status": status,
"action": SEVERITY_TO_ACTION[severity] if status == "failed" else "allow",
"failed_count": int(failed_count),
"total_count": int(total_count),
"failed_pct": float((failed_count / total_count) * 100.0) if total_count > 0 else 0.0,
"threshold": _to_jsonable(threshold),
"message": message,
"reason": rule.get("reason"),
}