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: distinguish inspected coverage from observed pass rate (#288)
Rudy Mizrahi Celekli74d4c7389b30
diff --git a/docs/scoring.md b/docs/scoring.mdindex 3bc028b..7083b47 100644--- a/docs/scoring.md+++ b/docs/scoring.md@@ -84,3 +84,13 @@ The scorecard emits a Wilson 95% CI per inspection; compare runs by CI overlap,## HistoryScoring has changed across harness versions; for the comparability log, see this file's git history and re-run old targets rather than comparing old headlines.++Regulatory summaries distinguish inspection coverage from the observed pass rate.+`Inspected / mapped` counts the framework's mapped inspections that this run+executed against all inspections in its mapping. `Inspection coverage` is that+fraction; `Observed pass rate` is the fraction of executed mapped inspections+that passed. A selected run can pass every inspection it ran while covering only+a small part of a framework. Neither percentage certifies regulatory compliance.+JSON retains `tests_mapped` (executed count), `coverage` and `coverage_pct`+(observed pass rate) for compatibility, and adds `tests_mapped_total`,+`tests_not_run`, `inspection_coverage` and `inspection_coverage_pct`.diff --git a/ifixai/reporting/artifact.py b/ifixai/reporting/artifact.pyindex 728ff2e..fe9a014 100644--- a/ifixai/reporting/artifact.py+++ b/ifixai/reporting/artifact.py@@ -386,8 +386,8 @@ function categories(){function compliance(){if(!D.compliance.length) return '';- const rows = D.compliance.map(c=>`<tr><td>${esc(c.name)}</td><td>${esc(c.version)}</td><td>${c.tests_passing}/${c.tests_mapped}</td><td>${esc(c.coverage_pct)}</td></tr>`).join('');- return `<h2>Compliance-framework coverage</h2><table><thead><tr><th>Framework</th><th>Version</th><th>Passing / mapped</th><th>Coverage</th></tr></thead><tbody>${rows}</tbody></table>`;+ const rows = D.compliance.map(c=>`<tr><td>${esc(c.name)}</td><td>${esc(c.version)}</td><td>${c.tests_mapped}/${c.tests_mapped_total}</td><td>${c.tests_passing}</td><td>${esc(c.coverage_pct)}</td><td>${esc(c.inspection_coverage_pct)}</td></tr>`).join('');+ return `<h2>Compliance-framework coverage</h2><table><thead><tr><th>Framework</th><th>Version</th><th>Inspected / mapped</th><th>Passing</th><th>Observed pass rate</th><th>Inspection coverage</th></tr></thead><tbody>${rows}</tbody></table>`;}function diffSection(){diff --git a/ifixai/reporting/regulatory.py b/ifixai/reporting/regulatory.pyindex bb76969..0e6399c 100644--- a/ifixai/reporting/regulatory.py+++ b/ifixai/reporting/regulatory.py@@ -26,6 +26,10 @@ def build_regulatory_summary(if br.passing:passing_count += 1+ # Keep the legacy observed pass-rate fields for existing JSON consumers.+ # Coverage of the framework is separate: omitted inspections were not run.+ total_mapped = len(fw.mappings)+ inspection_coverage = mapped_count / total_mapped if total_mapped else 0.0coverage = passing_count / mapped_count if mapped_count > 0 else 0.0summary.append({@@ -33,6 +37,10 @@ def build_regulatory_summary("version": fw.version,"tests_mapped": mapped_count,"tests_passing": passing_count,+ "tests_mapped_total": total_mapped,+ "tests_not_run": total_mapped - mapped_count,+ "inspection_coverage": round(inspection_coverage, 4),+ "inspection_coverage_pct": f"{inspection_coverage:.0%}","coverage": round(coverage, 4),"coverage_pct": f"{coverage:.0%}",})diff --git a/ifixai/reporting/scorecard.py b/ifixai/reporting/scorecard.pyindex d2e68e7..f645b48 100644--- a/ifixai/reporting/scorecard.py+++ b/ifixai/reporting/scorecard.py@@ -1068,15 +1068,15 @@ def render_regulatory_compliance(lines = ["## Regulatory Compliance Summary\n",- "| Framework | Version | Tests Mapped | Passing | Coverage |",- "|---|---|---|---|---|",+ "| Framework | Version | Inspected / mapped | Passing | Observed pass rate | Inspection coverage |",+ "|---|---|---|---|---|---|",]for item in summary:lines.append(f"| {item['name']} | {item['version']} "- f"| {item['tests_mapped']} | {item['tests_passing']} "- f"| {item['coverage_pct']} |"+ f"| {item['tests_mapped']}/{item['tests_mapped_total']} | {item['tests_passing']} "+ f"| {item['coverage_pct']} | {item['inspection_coverage_pct']} |")return "\n".join(lines)diff --git a/ifixai/tests/test_regulatory_inspection_coverage.py b/ifixai/tests/test_regulatory_inspection_coverage.pynew file mode 100644index 0000000..276d5b7--- /dev/null+++ b/ifixai/tests/test_regulatory_inspection_coverage.py@@ -0,0 +1,51 @@+import json++from ifixai.core.types import TestResult, TestRunResult, TestStatus+from ifixai.mappings.loader import load_all_mappings+from ifixai.reporting.regulatory import build_regulatory_summary+from ifixai.reporting.scorecard import (+ generate_json_report,+ render_regulatory_compliance,+)+++def test_partial_scorecard_separates_observed_pass_rate_from_inspection_coverage():+ result = TestRunResult(test_results=[TestResult(test_id='B01', passing=True, status=TestStatus.PASS, score=1.0)])+ frameworks = load_all_mappings()+ rows = build_regulatory_summary(result, frameworks)+ export = json.loads(generate_json_report(result))['regulatory']['compliance_summary']+ for row, exported in zip(rows, export, strict=True):+ total = len(frameworks[row['name']].mappings)+ assert total > 1+ assert row['tests_mapped'] == 1+ assert row['coverage'] == 1.0 # legacy observed pass-rate field retained+ assert row['tests_mapped_total'] == total+ assert row['tests_not_run'] == total - 1+ assert row['inspection_coverage'] == round(1 / total, 4)+ assert exported['tests_mapped_total'] == total+ markdown = render_regulatory_compliance(result, frameworks)+ assert 'Inspected / mapped' in markdown+ assert 'Observed pass rate' in markdown+ assert 'Inspection coverage' in markdown+++def test_full_and_empty_runs_keep_mapping_denominator():+ frameworks = load_all_mappings()+ ids = sorted({test_id for fw in frameworks.values() for test_id in fw.mappings})+ full = TestRunResult(test_results=[TestResult(test_id=test_id, passing=True, status=TestStatus.PASS, score=1.0) for test_id in ids])+ for row in build_regulatory_summary(full, frameworks):+ assert row['tests_mapped'] == row['tests_mapped_total']+ assert row['tests_not_run'] == 0+ assert row['coverage'] == row['inspection_coverage'] == 1.0+ for row in build_regulatory_summary(TestRunResult(), frameworks):+ assert row['tests_mapped'] == 0+ assert row['tests_not_run'] == row['tests_mapped_total']+ assert row['coverage'] == row['inspection_coverage'] == 0.0+++def test_artifact_labels_observed_pass_rate_and_inspection_coverage():+ from ifixai.reporting.artifact import render_artifact+ html = render_artifact(TestRunResult(test_results=[TestResult(test_id='B01', passing=True, status=TestStatus.PASS, score=1.0)]), live=False, transport='owned fixture', sut_model=None, judge_model=None, honesty_note='Offline rendering control')+ assert '<th>Inspected / mapped</th>' in html+ assert '<th>Observed pass rate</th>' in html+ assert '<th>Inspection coverage</th>' in html