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-06 20:51)

Ruben Lütkecb8c6352f80c
diff --git a/CLAUDE.md b/CLAUDE.md
index d356f8a752..b196d241bf 100644
--- a/CLAUDE.md
+++ b/CLAUDE.md
@@ -317,14 +317,13 @@ auto-activated (AP-15).
| AP-22 | Configure a tier (router/ack/STT/TTS/worker/critic/fallback) whose primary AND fallback resolve to the SAME provider family, or build a fallback chain from hardcoded provider NAMES | Single-provider brick: one missing key / 429 / 402 / outage kills the whole tier even with a healthy DIFFERENT provider present. Resolve every tier through one key-aware chain that skips dead/keyless providers, crosses families, and degrades honestly only when NO family is reachable — recoverable in-app |
| AP-23 | Build or TEST a feature only against the maintainer's config / keys / provider / OS and claim it done | The whole API-keys surface silently bricked for every other downloader + on a headless VPS (credentials couldn't be SAVED, ENV keys read as "not configured", channels/plugins/OAuth 500'd). Verify the three non-maintainer paths in §3 |
-The remaining anti-patterns need more context than a table cell allows:
+AP-24 to AP-29 need more room than a table cell:
### AP-24 — Never share a native inference engine between concurrent callers
-Never call a shared native inference engine (ctranslate2/faster-whisper, an
-ONNX/torch session) concurrently from two callers, and never "recover" a hung
-inference with only a timeout that re-polls the SAME wedged engine.
-`WhisperModel.transcribe` is NOT thread-safe: the wake poll loop + VAD probe
+This covers ctranslate2/faster-whisper and ONNX/torch sessions. Equally
+banned: "recovering" a hung inference with only a timeout that re-polls the
+SAME wedged engine. `WhisperModel.transcribe` is NOT thread-safe: the wake poll loop + VAD probe
sharing one provider hung it forever, and a hung `to_thread` can't be
cancelled — a timeout only BOUNDS, never RECOVERS. Fix: a non-blocking
per-instance inference lock (second call → skip) + a `recover()` that rebuilds
diff --git a/tests/missions/test_worker_cross_family_fallback.py b/tests/missions/test_worker_cross_family_fallback.py
index 8684e78c1e..d930506979 100644
--- a/tests/missions/test_worker_cross_family_fallback.py
+++ b/tests/missions/test_worker_cross_family_fallback.py
@@ -105,6 +105,56 @@ def test_codex_needing_reauth_is_skipped(monkeypatch: pytest.MonkeyPatch) -> Non
assert worker.provider == "gemini"
+# --- 2026-07-06: a PRESENT `claude` binary with DEAD auth must not dead-end ---
+
+
+def test_claude_binary_with_dead_auth_routes_to_codex(
+ monkeypatch: pytest.MonkeyPatch,
+) -> None:
+ """The 2026-07-06 incident shape: the `claude` binary exists, but its OAuth
+ token is expired/dead (auth non-viable). The old binary-presence-only check
+ picked ClaudeDirectWorker anyway and every mission died 401. Claude must be
+ SKIPPED so the healthy codex subscription runs."""
+ _patch_env(
+ monkeypatch,
+ claude_binary="/usr/bin/claude",
+ claude_auth_viable=False,
+ codex_oauth=True,
+ )
+ worker = mi._cross_family_last_resort_worker("t")
+ assert isinstance(worker, CodexDirectWorker)
+
+
+def test_claude_binary_with_dead_auth_crosses_to_api_key(
+ monkeypatch: pytest.MonkeyPatch,
+) -> None:
+ """Dead claude auth + no codex → the configured API-key family runs."""
+ _patch_env(
+ monkeypatch,
+ claude_binary="/usr/bin/claude",
+ claude_auth_viable=False,
+ keys=("openrouter",),
+ )
+ worker = mi._cross_family_last_resort_worker("t")
+ assert isinstance(worker, ApiAgentWorker)
+ assert worker.provider == "openrouter"
+
+
+def test_claude_binary_with_live_auth_stays_preferred(
+ monkeypatch: pytest.MonkeyPatch,
+) -> None:
+ """Sanity: a claude binary WITH viable auth keeps the subscription floor."""
+ _patch_env(
+ monkeypatch,
+ claude_binary="/usr/bin/claude",
+ claude_auth_viable=True,
+ codex_oauth=True,
+ keys=("openrouter",),
+ )
+ worker = mi._cross_family_last_resort_worker("t")
+ assert isinstance(worker, ClaudeDirectWorker)
+
+
# --- The genuine no-credential case still degrades honestly -------------------
@@ -113,3 +163,14 @@ def test_nothing_reachable_returns_none(monkeypatch: pytest.MonkeyPatch) -> None
last resort (which fails legibly rather than silently)."""
_patch_env(monkeypatch)
assert mi._cross_family_last_resort_worker("t") is None
+
+
+def test_claude_binary_dead_auth_nothing_else_returns_none(
+ monkeypatch: pytest.MonkeyPatch,
+) -> None:
+ """Dead claude auth and no other family → None; the caller's honest Claude
+ last resort then fails legibly (and its 401 re-arms the dead flag)."""
+ _patch_env(
+ monkeypatch, claude_binary="/usr/bin/claude", claude_auth_viable=False
+ )
+ assert mi._cross_family_last_resort_worker("t") is None