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.

chore: auto-save WIP via Claude stop-hook safety net (2026-07-07 15:18)

Ruben Lütke840a6cbb28aa
diff --git a/jarvis/overlay/triggers.py b/jarvis/overlay/triggers.py
index 95b47912d9..1c6e8f8bbc 100644
--- a/jarvis/overlay/triggers.py
+++ b/jarvis/overlay/triggers.py
@@ -58,6 +58,12 @@ class ActionKind(str, Enum):
BROWSER = "navigate" # backward-compat alias for Phase-9.1 code
+# AP-23 W2-C: names of optional overlay dependencies we've already warned
+# about in this process, so a hot loop of keyboard/mouse calls on a host
+# missing the dependency logs once, not on every call.
+_missing_overlay_dep_logged: set[str] = set()
+
+
def _get_bridge() -> Any:
"""Lazy lookup of the singleton to avoid circular imports.
@@ -67,8 +73,32 @@ def _get_bridge() -> Any:
When None: the decorator falls back to a very lightweight no-op stub
that simply runs the function.
+
+ Honest degrade (AP-23): resolving ``get_overlay`` pulls in the whole
+ overlay bridge chain (``.integration`` -> ``.bridge`` -> ``.schema`` ->
+ the OS-Level overlay package -> ``ulid``). On a host missing an optional
+ overlay dependency (e.g. a fresh clone without ``python-ulid``, or
+ without the OS-Level package at all), that import raises
+ ``ModuleNotFoundError``. Without this guard it escaped straight out of
+ the decorator into the caller's keyboard/mouse tool action — crashing a
+ real user action over a purely cosmetic overlay dependency. Degrade to
+ ``None`` instead: the decorator already treats ``bridge is None`` as
+ "run the function, skip the overlay visuals" (see
+ ``test_sync_decorator_no_bridge_is_no_op``).
"""
- from jarvis.overlay import get_overlay # spaet importieren
+ try:
+ from jarvis.overlay import get_overlay # spaet importieren
+ except ModuleNotFoundError as exc:
+ missing = exc.name or "unknown"
+ if missing not in _missing_overlay_dep_logged:
+ _missing_overlay_dep_logged.add(missing)
+ logger.warning(
+ "Desktop overlay unavailable: dependency %r missing — "
+ "overlay/mascot visuals stay off, but the underlying "
+ "keyboard/mouse action still runs.",
+ missing,
+ )
+ return None
return get_overlay()
diff --git a/jarvis/ui/desktop_app.py b/jarvis/ui/desktop_app.py
index 98294eb958..02c4647503 100644
--- a/jarvis/ui/desktop_app.py
+++ b/jarvis/ui/desktop_app.py
@@ -1537,12 +1537,20 @@ class DesktopApp:
except ModuleNotFoundError as exc:
from loguru import logger as _overlay_logger
if exc.name == "overlay":
+ # Genuinely headless: the optional overlay package
+ # itself isn't installed (cloud/VPS base install).
_overlay_logger.debug(
"Overlay bootstrap skipped: optional overlay package not installed."
)
else:
+ # AP-23 W2-C: some OTHER dependency in the overlay
+ # import chain is missing (e.g. `python-ulid`) — a
+ # real, fixable gap, not "no overlay package". Name
+ # it explicitly instead of collapsing into the same
+ # silent "headless" bucket.
_overlay_logger.opt(exception=exc).warning(
- "Overlay bootstrap failed."
+ "Overlay bootstrap skipped: overlay dependency {!r} missing.",
+ exc.name,
)
except Exception as exc: # noqa: BLE001
from loguru import logger as _overlay_logger
diff --git a/jarvis/ui/web/launcher.py b/jarvis/ui/web/launcher.py
index 14da19052c..d23809f728 100644
--- a/jarvis/ui/web/launcher.py
+++ b/jarvis/ui/web/launcher.py
@@ -632,7 +632,25 @@ async def _run_headless(args) -> int:
# (stop_overlay, below) valid. start_overlay itself no-ops when disabled.
try:
from jarvis.overlay.integration import start_overlay, stop_overlay
- except ModuleNotFoundError:
+ except ModuleNotFoundError as exc:
+ import logging as _overlay_logging
+
+ _overlay_log = _overlay_logging.getLogger(__name__)
+ if exc.name == "overlay":
+ # Genuinely headless: the optional overlay package itself isn't
+ # installed (cloud/VPS base install). Quiet — expected.
+ _overlay_log.debug(
+ "Overlay bootstrap skipped: optional overlay package not installed."
+ )
+ else:
+ # AP-23 W2-C: some OTHER import in the overlay chain is missing
+ # (e.g. `python-ulid`) — this is a real, fixable dependency gap,
+ # not "no overlay package". Log it honestly instead of silently
+ # collapsing into the same "headless" bucket.
+ _overlay_log.warning(
+ "Overlay bootstrap skipped: overlay dependency %r missing.",
+ exc.name,
+ )
async def start_overlay(*_a: object, **_k: object) -> None: # type: ignore[misc]
return None
diff --git a/pyproject.toml b/pyproject.toml
index 4387ee15d0..b333d9e060 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -18,6 +18,13 @@ dependencies = [
"pydantic>=2.9,<3.0",
"pydantic-settings>=2.6",
"pyyaml>=6.0",
+ # Desktop overlay/mascot IPC wire IDs (jarvis/overlay + OS-Level/src/overlay
+ # schema.py `from ulid import ULID`). Small pure-Python, platform-universal
+ # package — was previously declared ONLY in OS-Level's own egg-info, so a
+ # fresh clone without the maintainer's manual `pip install -e OS-Level`
+ # raised `ModuleNotFoundError: ulid` the first time any keyboard/mouse tool
+ # action ran (AP-23).
+ "python-ulid>=2.2",
"structlog>=24.4",
"loguru>=0.7",
"keyring>=25.5",
diff --git a/requirements.in b/requirements.in
index d1dd89191d..541da21815 100644
--- a/requirements.in
+++ b/requirements.in
@@ -28,6 +28,11 @@ pydantic>=2.9,<3.0
pydantic-settings>=2.6
pyyaml>=6.0
+# Desktop overlay/mascot IPC wire IDs (jarvis/overlay + OS-Level/src/overlay
+# schema.py `from ulid import ULID`). Small pure-Python, platform-universal
+# package. See pyproject.toml note.
+python-ulid>=2.2
+
# Logging
structlog>=24.4
loguru>=0.7
diff --git a/requirements.txt b/requirements.txt
index 7e508e4037..d5dd58f0b0 100644
--- a/requirements.txt
+++ b/requirements.txt
@@ -1585,6 +1585,10 @@ python-telegram-bot==22.8 \
--hash=sha256:42373918097f1b837cc4e717d588c19ea79651497ec712bb5b0c76e5e63c50e1 \
--hash=sha256:f9d3847fcb23ee603477e442800b33bb4adf851a73e0619d2050be879decf1ef
# via -r requirements.in
+python-ulid==3.1.0 \
+ --hash=sha256:e2cdc979c8c877029b4b7a38a6fba3bc4578e4f109a308419ff4d3ccf0a46619 \
+ --hash=sha256:ff0410a598bc5f6b01b602851a3296ede6f91389f913a5d5f8c496003836f636
+ # via -r requirements.in
pywin32==312 ; sys_platform == 'win32' \
--hash=sha256:02ebca0f0242b75292e218065004310d6a477407c09fa449bfe4f6022bc0c0fc \
--hash=sha256:17948aeadbdb091f0ced6ef0841620794e68327b94ee415571c1203594b7215c \
diff --git a/tests/missions/kontrollierer/test_loop.py b/tests/missions/kontrollierer/test_loop.py
index 1867b18a67..8f9f3d0bfe 100644
--- a/tests/missions/kontrollierer/test_loop.py
+++ b/tests/missions/kontrollierer/test_loop.py
@@ -1091,6 +1091,38 @@ async def test_worker_auth_error_every_iteration_fails_honestly(
assert killed[-1].reason == "worker_error" # type: ignore[attr-defined]
+async def test_mission_failed_carries_error_classification(
+ manager: MissionManager, tmp_path: Path
+) -> None:
+ """The 2026-07-06 gap: MissionFailed.error_class was always None, so the
+ UI/voice could not name the cause. An all-401 mission must now carry
+ error_class="provider_auth", the truncated upstream text, and the
+ provider slug of the worker that failed."""
+ worker = _AuthErrorWorker()
+ critic = FakeCriticRunner(_make_approve_verdict())
+ k = _make_kontrollierer(
+ manager=manager, tmp_path=tmp_path, critic=critic,
+ worker_factory_fn=lambda step: worker,
+ )
+ mid = await manager.dispatch(prompt="task on a dead credential")
+
+ end = await k.run_mission(mid)
+ assert end == MissionState.FAILED
+
+ events = await manager.store.events_for_mission(mid)
+ failed = [e.payload for e in events if e.payload.event_type == "MissionFailed"]
+ assert len(failed) == 1
+ assert failed[0].error_class == "provider_auth"
+ assert "401" in (failed[0].error_detail or "")
+ assert failed[0].failed_provider == "claude"
+
+ killed = [e.payload for e in events if e.payload.event_type == "WorkerKilled"]
+ assert killed
+ assert killed[-1].error_class == "provider_auth"
+ assert "401" in (killed[-1].error_detail or "")
+
+
@pytest.mark.asyncio
async def test_critic_timeout_retries_then_approves(
manager: MissionManager, tmp_path: Path
diff --git a/tests/overlay/test_triggers.py b/tests/overlay/test_triggers.py
index 60f6e660de..10aeeecc0c 100644
--- a/tests/overlay/test_triggers.py
+++ b/tests/overlay/test_triggers.py
@@ -99,6 +99,62 @@ def test_sync_decorator_no_bridge_is_no_op() -> None:
assert called == ["fn"]
+def test_get_bridge_degrades_to_none_when_optional_dep_missing(
+ monkeypatch: pytest.MonkeyPatch,
+) -> None:
+ """AP-23 W2-C: on a fresh clone without ``python-ulid`` installed, the
+ overlay import chain (``jarvis.overlay`` -> ``.integration`` ->
+ ``.bridge`` -> ``.schema`` -> ``ulid``) raises ``ModuleNotFoundError``.
+ ``_get_bridge`` must degrade honestly to ``None`` (the same no-op path
+ already exercised by ``test_sync_decorator_no_bridge_is_no_op``) instead
+ of letting the import error escape into a keyboard/mouse tool action.
+ """
+ import jarvis.overlay as overlay_pkg
+ from jarvis.overlay import triggers
+
+ # Force re-resolution through the PEP-562 lazy __getattr__ (a prior test
+ # in this session may already have cached the real ``get_overlay`` on
+ # the package's __dict__).
+ monkeypatch.delattr(overlay_pkg, "get_overlay", raising=False)
+
+ def _boom(name: str) -> Any:
+ if name == "get_overlay":
+ raise ModuleNotFoundError("No module named 'ulid'", name="ulid")
+ raise AttributeError(name)
+
+ monkeypatch.setattr(overlay_pkg, "__getattr__", _boom)
+
+ assert triggers._get_bridge() is None
+
+
+def test_sync_decorator_runs_fn_when_overlay_dep_missing(
+ monkeypatch: pytest.MonkeyPatch,
+) -> None:
+ """Same missing-dependency scenario, exercised through the decorated
+ keyboard/mouse call path: the actual action must still run (matching
+ the AP-23 fix intent — the decorated tool action degrades to a clean
+ no-op for the overlay VISUAL, never a crash for the real action)."""
+ import jarvis.overlay as overlay_pkg
+
+ monkeypatch.delattr(overlay_pkg, "get_overlay", raising=False)
+
+ def _boom(name: str) -> Any:
+ if name == "get_overlay":
+ raise ModuleNotFoundError("No module named 'ulid'", name="ulid")
+ raise AttributeError(name)
+
+ monkeypatch.setattr(overlay_pkg, "__getattr__", _boom)
+
+ called = []
+
+ @overlay_action_sync(ActionKind.CLICK)
+ def doit() -> None:
+ called.append("fn")
+
+ doit()
+ assert called == ["fn"]
+
+
# -------------------------------------------------------------------------
# Async-Decorator
# -------------------------------------------------------------------------