From 267938c4bf9c252c6b298127bc4d1541a56c0a78 Mon Sep 17 00:00:00 2001 From: eowca <4008965+eowca@users.noreply.github.com> Date: Thu, 26 Nov 2026 08:12:59 +0100 Subject: [PATCH] Drop transient Codex launcher paths before running loop-zero Architecture-Review: unchanged; existing account selection and sandbox environment boundaries are preserved. Co-Authored-By: Codex --- scripts/ai-accounts/ai-accounts | 4 ++++ tests/test_ai_accounts.py | 7 +++++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/scripts/ai-accounts/ai-accounts b/scripts/ai-accounts/ai-accounts index b7871bae..75828558 100755 --- a/scripts/ai-accounts/ai-accounts +++ b/scripts/ai-accounts/ai-accounts @@ -1085,6 +1085,10 @@ def cmd_shim(name: str, args: list[str]) -> int: dirs = os.environ.get("PATH", "").split(os.pathsep) shim_dirs = [d for d in dirs if is_shim_dir(d)] rest = [d for d in dirs if d not in shim_dirs] + if name == "loopzero": + # Codex's transient launcher shims are hidden in the check sandbox. + arg0 = Path(os.environ.get("CODEX_HOME") or Path.home() / ".codex") / "tmp/arg0-linux" + rest = [d for d in rest if Path(d).parent != arg0 or not Path(d).name.startswith("codex-arg0")] real = next((str(c) for d in rest if (c := Path(d or ".") / name).is_file() and os.access(c, os.X_OK)), None) if real is None: diff --git a/tests/test_ai_accounts.py b/tests/test_ai_accounts.py index 05b5ef02..9db4ab49 100644 --- a/tests/test_ai_accounts.py +++ b/tests/test_ai_accounts.py @@ -455,7 +455,10 @@ def test_shim_prefers_verified_codex_only_for_loopzero(helper, tmp_path, monkeyp codex = pin / 'codex' codex.write_text('#!/bin/sh\nexit 0\n') codex.chmod(0o755 if pin_state != 'nonexecutable' else 0o644) - monkeypatch.setenv('PATH', f'{shims}:{binaries}') + codex_home = tmp_path / 'codex-home' + arg0 = codex_home / 'tmp/arg0-linux/codex-arg0ABC123' + monkeypatch.setenv('CODEX_HOME', str(codex_home)) + monkeypatch.setenv('PATH', f'{shims}:{arg0}:{binaries}') monkeypatch.setattr(helper.sys, 'argv', [str(shims / name)]) calls = [] monkeypatch.setattr(helper.os, 'execve', lambda *args: calls.append(args)) @@ -471,7 +474,7 @@ def test_shim_prefers_verified_codex_only_for_loopzero(helper, tmp_path, monkeyp expected.insert(0, str(pin)) assert env['PATH'].split(helper.os.pathsep) == expected else: - assert env['PATH'] == f'{shims}:{binaries}' + assert env['PATH'] == f'{shims}:{arg0}:{binaries}' @pytest.mark.parametrize('provider,email,shown', [