Skip to content

Dodaios is an open-source agent OS for your desktop: it runs your coding agents, browser and apps by voice or chat, on your own machine. Formerly Personal Jarvis.

fix(codex): accept stable Windows native binary

Ruben Lütke57ac63b331ea
diff --git a/jarvis/codex_app_server.py b/jarvis/codex_app_server.py
index c23a253dc9..4be46adf25 100644
--- a/jarvis/codex_app_server.py
+++ b/jarvis/codex_app_server.py
@@ -784,7 +784,14 @@ def _sha256_file(path: Path) -> str:
digest.update(chunk)
completed = os.fstat(handle.fileno())
final = path.stat()
- stable_fields = ("st_dev", "st_ino", "st_size", "st_mtime_ns", "st_ctime_ns")
+ stable_fields = ("st_dev", "st_ino", "st_size", "st_mtime_ns")
+ # Python 3.12 on Windows exposes different ctime semantics for fstat() and
+ # path stat(): the former may mirror mtime while the latter reports file
+ # creation time. Comparing them rejects an unchanged executable. Device,
+ # inode/file index, size, mtime, and the approved digest still bind the
+ # opened handle to the final path. POSIX ctime remains a useful extra guard.
+ if sys.platform != "win32":
+ stable_fields += ("st_ctime_ns",)
if any(
getattr(opened, field, None) != getattr(completed, field, None)
or getattr(opened, field, None) != getattr(final, field, None)
@@ -913,7 +920,7 @@ def _read_codex_capability(binary_path: str | None) -> CodexAppServerCapability:
return CodexAppServerCapability(
available=False,
chatgpt_authenticated=False,
- binary_path=None,
+ binary_path=resolved,
version=version,
reason=str(exc),
reason_code="lifecycle_unavailable",
@@ -923,7 +930,7 @@ def _read_codex_capability(binary_path: str | None) -> CodexAppServerCapability:
return CodexAppServerCapability(
available=False,
chatgpt_authenticated=False,
- binary_path=None,
+ binary_path=resolved,
version=version,
reason=str(exc),
reason_code="setup_invalid",
diff --git a/tests/unit/codex_app_server/test_transport.py b/tests/unit/codex_app_server/test_transport.py
index d47a025c0d..5b30967fe0 100644
--- a/tests/unit/codex_app_server/test_transport.py
+++ b/tests/unit/codex_app_server/test_transport.py
@@ -1651,6 +1651,32 @@ def test_native_codex_version_and_hash_are_both_required(
)
+def test_sha256_file_ignores_windows_fstat_ctime_semantics(
+ monkeypatch: pytest.MonkeyPatch,
+ tmp_path: Path,
+) -> None:
+ binary = tmp_path / "codex.exe"
+ binary.write_bytes(b"official-test-binary")
+ original_stat = Path.stat
+
+ def stat_with_creation_time(path: Path, *args: object, **kwargs: object) -> object:
+ result = original_stat(path, *args, **kwargs)
+ return SimpleNamespace(
+ st_dev=result.st_dev,
+ st_ino=result.st_ino,
+ st_size=result.st_size,
+ st_mtime_ns=result.st_mtime_ns,
+ st_ctime_ns=result.st_ctime_ns + 1,
+ )
+
+ monkeypatch.setattr(transport.sys, "platform", "win32")
+ monkeypatch.setattr(Path, "stat", stat_with_creation_time)
+
+ assert transport._sha256_file(binary) == (
+ "fad79da58e11e95a1ca016dff1191db5df37bd2ee8e15e7e66856f7a2c99450f"
+ )
+
+
def test_trusted_binary_discovery_recovers_from_a_windows_store_launcher(
monkeypatch: pytest.MonkeyPatch,
tmp_path: Path,