Independent Auditing of AI Agents. Run by human or the agent itself, to answer the most crucial question in the AI Agent Economy. Is the agent doing what is supposed to do? With iFixAi you can have this answer in less than 120 seconds.
Python agent-evaluationaiai-alignmentai-evaluationai-governanceai-safetyclidiagnostic-tooleu-ai-acthallucination-detectioniso-42001llm-evaluationllm-securitynist-ai-rmfowasp-llmprompt-injectionpythonresponsible-airisk-assessmentrisk-management
fix(reporting): export no grade for runs without an overall score (#343)
Rudy Mizrahi Celekli5d8ea14dbcf9
diff --git a/ifixai/reporting/scorecard.py b/ifixai/reporting/scorecard.pyindex 607e3fe..c4ee2c2 100644--- a/ifixai/reporting/scorecard.py+++ b/ifixai/reporting/scorecard.py@@ -145,7 +145,7 @@ def compute_insights(result: TestRunResult) -> dict[str, object]:"exploratory": exploratory,"overall_score": result.overall_score,"strategic_score": result.strategic_score,- "grade": result.grade.value,+ "grade": "n/a" if result.overall_score is None else result.grade.value,"strategic_overall_delta": delta,"passed": result.passed,}@@ -647,7 +647,8 @@ def build_overall_section(result: TestRunResult) -> dict[str, object]:section: dict[str, object] = {"score": None if overall is None else round(overall, 4),"score_pct": "n/a" if overall is None else f"{overall:.1%}",- "grade": result.grade.value,+ # No overall score means no grade (as in the Markdown and console views).+ "grade": "n/a" if overall is None else result.grade.value,"strategic_score": round(result.strategic_score, 4),"strategic_score_pct": f"{result.strategic_score:.1%}","passed": result.passed,diff --git a/ifixai/tests/test_json_grade_without_score.py b/ifixai/tests/test_json_grade_without_score.pynew file mode 100644index 0000000..76d9348--- /dev/null+++ b/ifixai/tests/test_json_grade_without_score.py@@ -0,0 +1,35 @@+import json++from ifixai.core.runner import _build_result+from ifixai.core.types import InspectionCategory, TestResult, TestStatus+from ifixai.reporting.scorecard import generate_json_report+++def _report(selected_ids):+ passing = TestResult(+ test_id="B12",+ category=InspectionCategory.MANIPULATION,+ score=1.0,+ threshold=0.9,+ passed=True,+ passing=True,+ status=TestStatus.PASS,+ )+ result = _build_result([passing], "sys", "1", "fx", "mock", "api", selected_ids=selected_ids)+ return result, json.loads(generate_json_report(result))+++def test_unscored_run_exports_no_grade():+ # A scoped run that leaves mandatory minimums unselected has no overall score.+ result, report = _report({"B12"})+ assert result.overall_score is None+ assert report["overall"]["score"] is None+ assert report["overall"]["grade"] == "n/a"+ assert report["insights"]["grade"] == "n/a"+++def test_scored_run_keeps_its_grade():+ result, report = _report(None)+ assert result.overall_score is not None+ assert report["overall"]["grade"] == result.grade.value+ assert report["insights"]["grade"] == result.grade.value