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(dev): make pre-push gates portable on macOS

Ruben Lütke1d2bcbc50c15
diff --git a/.githooks/pre-push b/.githooks/pre-push
index bd0b2257a9..207c6c7340 100755
--- a/.githooks/pre-push
+++ b/.githooks/pre-push
@@ -27,11 +27,14 @@
remote_name="$1"
remote_url="$2"
-# Prefer the known-good interpreter (a bare 'python' may be a deps-less venv on
-# this machine); fall back to python3 (macOS/Linux boxes often ship ONLY
-# python3), then python. The gates are stdlib + git only, so any Python 3.x
-# works. No Python at all -> fail OPEN.
-PY="/c/Program Files/Python311/python.exe"
+# Prefer the repository venv because several gates import the project's dev
+# dependencies. Cover POSIX and Windows layouts, then retain the historical
+# known-good Windows interpreter before falling back to PATH. No Python at all
+# -> fail OPEN.
+PY=".venv/bin/python3"
+[ -x "$PY" ] || PY=".venv/bin/python"
+[ -x "$PY" ] || PY=".venv/Scripts/python.exe"
+[ -x "$PY" ] || PY="/c/Program Files/Python311/python.exe"
[ -x "$PY" ] || PY="$(command -v python3 2>/dev/null || command -v python 2>/dev/null)"
[ -n "$PY" ] || exit 0
diff --git a/.github/workflows/macos-desktop.yml b/.github/workflows/macos-desktop.yml
index bb092e182d..1c975a3f63 100644
--- a/.github/workflows/macos-desktop.yml
+++ b/.github/workflows/macos-desktop.yml
@@ -10,6 +10,7 @@ on:
pull_request:
paths:
- ".github/workflows/macos-desktop.yml"
+ - ".githooks/pre-push"
- "install/**"
- "jarvis/admin/**"
- "jarvis/cu/**"
@@ -19,6 +20,9 @@ on:
- "jarvis/ui/**"
- "jarvis/vision/**"
- "pyproject.toml"
+ - "scripts/ci/check_boot_budget.py"
+ - "scripts/measure_boot.py"
+ - "scripts/measure_desktop_boot.py"
- "tests/**"
- "uv.lock"
workflow_dispatch:
@@ -143,6 +147,7 @@ jobs:
tests/unit/setup/test_desktop_integration.py \
tests/unit/autostart/test_macos.py \
tests/unit/autostart/test_command.py \
+ tests/unit/ci/test_boot_harness_portability.py \
tests/unit/cu/test_geometry.py \
tests/unit/cu/test_actuate.py \
tests/unit/cu/test_capture.py \
diff --git a/scripts/ci/check_boot_budget.py b/scripts/ci/check_boot_budget.py
index dbe67e73f8..b3b2534d7e 100644
--- a/scripts/ci/check_boot_budget.py
+++ b/scripts/ci/check_boot_budget.py
@@ -57,8 +57,26 @@ DEFAULT_VOICE_BUDGET_MS = 20_000.0
DEFAULT_INTERACTIVE_BUDGET_MS = 20_000.0
+def _macos_microphone_granted() -> bool:
+ """Return whether this process may measure voice without a TCC prompt."""
+ if sys.platform != "darwin":
+ return True
+ try:
+ from jarvis.platform.permissions import ( # noqa: PLC0415
+ PermissionId,
+ PermissionState,
+ SystemPermissionPort,
+ )
+
+ return SystemPermissionPort().state(PermissionId.MICROPHONE) is PermissionState.GRANTED
+ except Exception: # noqa: BLE001 — an uncertain TCC state fails closed
+ return False
+
+
def _audio_capable() -> bool:
"""True when the host can plausibly run the voice stack (mic present)."""
+ if not _macos_microphone_granted():
+ return False
try:
import sounddevice # noqa: PLC0415
@@ -149,7 +167,10 @@ def main() -> int:
flush=True,
)
else:
- print("boot-budget: no audio input device — voice anchor skipped (honest)", flush=True)
+ print(
+ "boot-budget: no usable audio input or permission — voice anchor skipped (honest)",
+ flush=True,
+ )
if window_ms is not None and window_ms <= window_budget:
print(
diff --git a/scripts/measure_boot.py b/scripts/measure_boot.py
index d543135814..26e6e3886d 100644
--- a/scripts/measure_boot.py
+++ b/scripts/measure_boot.py
@@ -36,8 +36,8 @@ Isolation contract (NEVER touches the running production instance)
Usage
-----
- "C:\\Program Files\\Python311\\python.exe" scripts/measure_boot.py
- "...python.exe" scripts/measure_boot.py --runs 5 --warmup 1
+ python scripts/measure_boot.py
+ python scripts/measure_boot.py --python /path/to/python --runs 5 --warmup 1
Writes ``boot-latest.json`` every run and freezes ``boot-baseline.json`` on the
first run (so later optimization passes compare against the original baseline).
@@ -65,7 +65,12 @@ ISO_DIR = BENCH_DIR / "sub-agents-outputs"
BASELINE_PATH = REPO_ROOT / "boot-baseline.json"
LATEST_PATH = REPO_ROOT / "boot-latest.json"
-DEFAULT_PYTHON = r"C:\Program Files\Python311\python.exe"
+_WINDOWS_REFERENCE_PYTHON = Path(r"C:\Program Files\Python311\python.exe")
+DEFAULT_PYTHON = (
+ str(_WINDOWS_REFERENCE_PYTHON)
+ if sys.platform == "win32" and _WINDOWS_REFERENCE_PYTHON.exists()
+ else sys.executable
+)
DEFAULT_PAGES = 80
# Canonical no-window flag (AP-1) with a safe fallback if jarvis is not importable
diff --git a/scripts/measure_desktop_boot.py b/scripts/measure_desktop_boot.py
index 80e32e57be..64ccccc8a2 100644
--- a/scripts/measure_desktop_boot.py
+++ b/scripts/measure_desktop_boot.py
@@ -25,8 +25,8 @@ comparable. Writes ``desktop-boot-latest.json`` every run and freezes
Usage
-----
- "C:\\Program Files\\Python311\\python.exe" scripts/measure_desktop_boot.py
- "...python.exe" scripts/measure_desktop_boot.py --runs 5 --warmup 1
+ python scripts/measure_desktop_boot.py
+ python scripts/measure_desktop_boot.py --python /path/to/python --runs 5 --warmup 1
"""
from __future__ import annotations
diff --git a/tests/unit/ci/test_boot_harness_portability.py b/tests/unit/ci/test_boot_harness_portability.py
new file mode 100644
index 0000000000..6c1076a06c
--- /dev/null
+++ b/tests/unit/ci/test_boot_harness_portability.py
@@ -0,0 +1,67 @@
+"""Cross-platform contracts for the local boot-performance gates."""
+
+from __future__ import annotations
+
+import importlib.util
+import sys
+from pathlib import Path
+from types import SimpleNamespace
+
+import pytest
+
+REPO_ROOT = Path(__file__).resolve().parents[3]
+_SPEC = importlib.util.spec_from_file_location(
+ "measure_boot_portability", REPO_ROOT / "scripts" / "measure_boot.py"
+)
+assert _SPEC is not None and _SPEC.loader is not None
+measure_boot = importlib.util.module_from_spec(_SPEC)
+_SPEC.loader.exec_module(measure_boot)
+_GUARD_SPEC = importlib.util.spec_from_file_location(
+ "check_boot_budget_portability",
+ REPO_ROOT / "scripts" / "ci" / "check_boot_budget.py",
+)
+assert _GUARD_SPEC is not None and _GUARD_SPEC.loader is not None
+check_boot_budget = importlib.util.module_from_spec(_GUARD_SPEC)
+_GUARD_SPEC.loader.exec_module(check_boot_budget)
+
+
+def test_default_benchmark_interpreter_exists_on_this_host() -> None:
+ selected = Path(measure_boot.DEFAULT_PYTHON)
+
+ assert selected.is_file()
+ if sys.platform != "win32":
+ assert selected.samefile(sys.executable)
+
+
+def test_pre_push_prefers_the_repository_venv() -> None:
+ hook = (REPO_ROOT / ".githooks" / "pre-push").read_text(encoding="utf-8")
+
+ posix = hook.index('PY=".venv/bin/python3"')
+ windows = hook.index('PY=".venv/Scripts/python.exe"')
+ path_fallback = hook.index("command -v python3")
+ assert posix < path_fallback
+ assert windows < path_fallback
+
+
+ ("granted", "expected"),
+ ((False, False), (True, True)),
+)
+def test_macos_voice_budget_requires_an_existing_microphone_grant(
+ monkeypatch: pytest.MonkeyPatch,
+ granted: bool,
+ expected: bool,
+) -> None:
+ monkeypatch.setattr(check_boot_budget.sys, "platform", "darwin")
+ monkeypatch.setattr(
+ check_boot_budget,
+ "_macos_microphone_granted",
+ lambda: granted,
+ )
+ monkeypatch.setitem(
+ sys.modules,
+ "sounddevice",
+ SimpleNamespace(query_devices=lambda: [{"max_input_channels": 1}]),
+ )
+
+ assert check_boot_budget._audio_capable() is expected