1212
1313import pytest
1414
15+ from codex_self_evolution .session_reflection import app_server as app_server_module
1516from codex_self_evolution .session_reflection .app_server import (
1617 AppServerError ,
1718 ReflectionAppServerClient ,
@@ -288,6 +289,7 @@ def test_app_server_proxy_status_reports_missing_control_socket(
288289) -> None :
289290 """Proxy status reports why the default app-server control socket is unusable."""
290291 monkeypatch .setenv ("CODEX_HOME" , str (tmp_path / "codex-home" ))
292+ monkeypatch .setattr (app_server_module .shutil , "which" , lambda name : "/usr/bin/codex" if name == "codex" else None )
291293
292294 status = app_server_proxy_status ()
293295
@@ -299,6 +301,24 @@ def test_app_server_proxy_status_reports_missing_control_socket(
299301 }
300302
301303
304+ def test_app_server_proxy_status_reports_missing_codex_binary (
305+ monkeypatch : pytest .MonkeyPatch ,
306+ tmp_path : Path ,
307+ ) -> None :
308+ """Proxy status fails loudly when neither a socket nor Codex binary exists."""
309+ monkeypatch .setenv ("CODEX_HOME" , str (tmp_path / "codex-home" ))
310+ monkeypatch .setattr (app_server_module .shutil , "which" , lambda name : None )
311+
312+ status = app_server_proxy_status ()
313+
314+ assert status == {
315+ "available" : False ,
316+ "mode" : None ,
317+ "reason" : "codex_binary_missing" ,
318+ "socket_path" : str (tmp_path / "codex-home" / "app-server-control" / "app-server-control.sock" ),
319+ }
320+
321+
302322def test_app_server_proxy_status_accepts_existing_control_socket (
303323 monkeypatch : pytest .MonkeyPatch ,
304324) -> None :
0 commit comments