Skip to content

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.

fix: preserve authored fixture content in YAML exports (#253)

Rudy Mizrahi Celekli7d4537db2b8e
diff --git a/ifixai/quick_build.py b/ifixai/quick_build.py
index 4abbef5..b4783d8 100644
--- a/ifixai/quick_build.py
+++ b/ifixai/quick_build.py
@@ -174,7 +174,13 @@ def fixture_to_yaml(fixture: Fixture) -> str:
for case in fixture.test_cases
],
}
- return yaml.dump(data, default_flow_style=False, sort_keys=False)
+ authored = fixture.model_dump(mode="json", exclude_none=True, exclude={"governance_source"})
+ # Keep generated users only when the fixture declares none; authored identities
+ # and every diagnostic field must survive a save/load round trip.
+ if not fixture.users:
+ authored["users"] = data["users"]
+ authored["test_cases"] = data["test_cases"]
+ return yaml.dump(authored, default_flow_style=False, sort_keys=False)
def save_fixture(yaml_str: str, path: str = "ssci_fixture.yaml") -> str:
if os.path.exists(path):
diff --git a/ifixai/tests/test_fixture_yaml_authored_content.py b/ifixai/tests/test_fixture_yaml_authored_content.py
new file mode 100644
index 0000000..18cdb55
--- /dev/null
+++ b/ifixai/tests/test_fixture_yaml_authored_content.py
@@ -0,0 +1,34 @@
+from ifixai.core.fixture_loader import load_fixture, validate_fixture
+from ifixai.core.types import ExpectedClaim, User
+from ifixai.quick_build import (
+ QuickBuildContext,
+ fixture_to_yaml,
+ generate_fixture_from_context,
+)
+
+
+def test_fixture_export_preserves_authored_users_and_diagnostic_context(tmp_path):
+ fixture = generate_fixture_from_context(
+ QuickBuildContext(tool_names=["read"], role_names=["analyst"])
+ )
+ fixture.users = [User(user_id="pat", name="Pat", roles=["analyst"])]
+ fixture.roles[0].department = "Research"
+ fixture.system_purpose = "Find research records"
+ fixture.expected_escalation_channels = ["Research lead"]
+ fixture.expected_claims = [
+ ExpectedClaim(
+ claim="The owner is Pat.",
+ supported=True,
+ source_id="knowledge_base",
+ evidence="The owner is Pat.",
+ )
+ ]
+ path = tmp_path / "fixture.yaml"
+ path.write_text(fixture_to_yaml(fixture), encoding="utf-8")
+ assert validate_fixture(path) == []
+ restored = load_fixture(path)
+ assert restored.users == fixture.users
+ assert restored.roles == fixture.roles
+ assert restored.system_purpose == fixture.system_purpose
+ assert restored.expected_escalation_channels == fixture.expected_escalation_channels
+ assert restored.expected_claims == fixture.expected_claims