"""Diagnostics must distinguish policy rejection from inspected job properties.""" import json import plistlib from tools.terminal_tool_guards import gateway_lifecycle_block def test_bootstrap_rejection_does_not_invent_keepalive(tmp_path, monkeypatch): from tools import process_registry monkeypatch.setattr(process_registry, "_is_supervised_gateway_process", lambda: True) plist = tmp_path / "com.example.schedule.plist" plist.write_bytes(plistlib.dumps({ "Label": "com.example.schedule", "ProgramArguments": ["/bin/true"], "RunAtLoad": False, "StartCalendarInterval": {"Hour": 9, "Minute": 0}, })) blocked = gateway_lifecycle_block( command=f"launchctl bootstrap gui/501 {plist}", env=None, env_type="local", cwd=str(tmp_path), workdir=None, session_key="diagnostic-test", ) assert blocked is not None result = json.loads(blocked) assert result["exit_code"] == 1 assert "regardless of the job label" in result["error"] assert "does not inspect" in result["error"] assert "KeepAlive settings" in result["error"] assert "separate shell outside the gateway" in result["error"]