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(setup): don't save a governance path for the mock agent (#335)

Rudy Mizrahi Celeklie8681024cde4
diff --git a/ifixai/cli/setup_cmd.py b/ifixai/cli/setup_cmd.py
index 1e237b0..2dca28d 100644
--- a/ifixai/cli/setup_cmd.py
+++ b/ifixai/cli/setup_cmd.py
@@ -231,9 +231,11 @@ def setup(ctx: click.Context) -> None:
grounding = "sut"
# Governance: prefer a real declared policy over synthesizing one in the fixture.
- # Skip for http (the live agent enforces its own governance at runtime).
+ # Skip for http (the live agent enforces its own governance at runtime) and
+ # for mock, which always loads fixtures/governance/mock.yaml and whose run
+ # rejects --governance.
governance: str | None = None
- if provider != "http":
+ if provider not in ("http", "mock"):
gov_path = ui.text(
"Path to a real governance policy YAML "
"(blank to skip / synthesize in the fixture):",
diff --git a/ifixai/tests/test_setup_mock_governance.py b/ifixai/tests/test_setup_mock_governance.py
new file mode 100644
index 0000000..d962ff4
--- /dev/null
+++ b/ifixai/tests/test_setup_mock_governance.py
@@ -0,0 +1,35 @@
+"""`ifixai run` rejects --governance with --provider mock, so the setup wizard
+must not save a governance path for a mock agent."""
+
+import yaml
+from click.testing import CliRunner
+
+from ifixai.cli import setup_cmd
+from ifixai.cli.main import ifixai_cli
+
+
+def test_mock_setup_does_not_save_governance(tmp_path, monkeypatch):
+ monkeypatch.chdir(tmp_path)
+ monkeypatch.setenv("HOME", str(tmp_path))
+ monkeypatch.setenv("IFIXAI_TELEMETRY", "0")
+ asked = []
+
+ def select(message, choices, default=None, **kwargs):
+ return "mock" if message.startswith("What is the system under test") else default
+
+ def text(message, default=""):
+ asked.append(message)
+ return str(tmp_path / "policy.yaml") if "governance" in message.lower() else default
+
+ confirms = iter([True, False]) # save the config; don't run now
+ monkeypatch.setattr(setup_cmd.ui, "is_interactive", lambda: True)
+ monkeypatch.setattr(setup_cmd.ui, "select", select)
+ monkeypatch.setattr(setup_cmd.ui, "text", text)
+ monkeypatch.setattr(setup_cmd.ui, "confirm", lambda message, default=True: next(confirms))
+
+ result = CliRunner().invoke(ifixai_cli, ["setup"])
+ assert result.exit_code == 0, result.output
+ saved = yaml.safe_load((tmp_path / "ifixai.yaml").read_text(encoding="utf-8"))
+ assert saved["provider"] == "mock"
+ assert "governance" not in saved
+ assert not any("governance" in message.lower() for message in asked)