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(fixtures): match canonical inspection IDs for regulatory coverage (#195)
Rudy Mizrahi Celekli0d24f5dcc32d
diff --git a/ifixai/core/types.py b/ifixai/core/types.pyindex 933c779..0577619 100644--- a/ifixai/core/types.py+++ b/ifixai/core/types.py@@ -2391,7 +2391,11 @@ class Fixture(BaseModel):expected_claims: list["ExpectedClaim"] = Field(default_factory=list)def test_cases_for_test(self, test_id: str) -> list[TestCase]:- return [tc for tc in self.test_cases if tc.test == test_id]+ canonical_id = test_id.removeprefix("SSCI-")+ return [+ tc for tc in self.test_cases+ if tc.test.removeprefix("SSCI-") == canonical_id+ ]def has_coverage_for(self, test_id: str) -> bool:- return any(tc.test == test_id for tc in self.test_cases)+ return bool(self.test_cases_for_test(test_id))diff --git a/ifixai/tests/core/test_discovery_case_ids.py b/ifixai/tests/core/test_discovery_case_ids.pyindex 4a296bc..644cf66 100644--- a/ifixai/tests/core/test_discovery_case_ids.py+++ b/ifixai/tests/core/test_discovery_case_ids.py@@ -30,3 +30,34 @@ def test_generated_case_ids_follow_stable_tool_order():("tc-007", "B08", "tool_eta"),("tc-008", "B08", "tool_theta"),]+++def test_schema_fixture_cases_match_regulation_required_test_ids(tmp_path):+ import yaml++ from ifixai.core.fixture_loader import load_fixture, validate_fixture+ from ifixai.core.types import Regulation+ from ifixai.quick_build import (+ QuickBuildContext,+ fixture_to_yaml,+ generate_fixture_from_context,+ )++ fixture = generate_fixture_from_context(QuickBuildContext(+ tool_names=["read_record"], role_names=["reader"],+ ))+ fixture.regulations = [Regulation(name="Local policy", required_tests=["B01", "B08"])]+ path = tmp_path / "coverage.yaml"+ path.write_text(fixture_to_yaml(fixture), encoding="utf-8")+ assert validate_fixture(path) == []+ restored = load_fixture(path)+ assert restored.has_coverage_for("B01")+ assert restored.has_coverage_for("SSCI-B01")+ assert restored.test_cases_for_test("B01") == restored.test_cases+ assert not restored.has_coverage_for("B08")+ assert restored.test_cases_for_test("B08") == []+ # In-memory generated cases use bare IDs; both sides must accept the prefix.+ assert fixture.has_coverage_for("SSCI-B01")+ assert fixture.test_cases_for_test("SSCI-B01") == fixture.test_cases+ data = yaml.safe_load(path.read_text())+ assert data["test_cases"][0]["test"] == "SSCI-B01"