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.

feat(missions): closed error-class vocabulary on WorkerKilled/MissionFailed events

Ruben Lütkeeb38bdaf0f01
diff --git a/jarvis/missions/events.py b/jarvis/missions/events.py
index 5aed8bc81a..afb037b7e6 100644
--- a/jarvis/missions/events.py
+++ b/jarvis/missions/events.py
@@ -10,7 +10,7 @@ prefix (`MissionBudgetWarning`) — no import collision, no semantic ambiguity.
from __future__ import annotations
import time
-from typing import Annotated, Any, Literal, Union
+from typing import Annotated, Any, Final, Literal, Union
from pydantic import BaseModel, ConfigDict, Field
@@ -91,6 +91,23 @@ class WorkerCorrectionRequired(_PayloadBase):
next_model: str
+# Closed vocabulary for the provider-failure classification carried by
+# WorkerKilled.error_class / MissionFailed.error_class. Single source of
+# truth; mirrored in frontend/src/types/missions.ts (MissionErrorClass),
+# the voice phrase table (FAILURE_REASON_PHRASES), and the i18n locales —
+# guarded by tests/missions/test_mission_error_class_parity.py +
+# test_error_class_full_parity.py (AP-4/BUG-008 defense). The event field
+# stays `str | None`: the recovery sweep's legacy values
+# ("MissionInterrupted"/"OrchestratorCrash") remain valid, and None means
+# "unclassified — fall back to `reason`".
+MISSION_ERROR_CLASSES: Final[frozenset[str]] = frozenset({
+ "provider_auth", # credential dead/invalid (401, not logged in)
+ "provider_quota", # usage/session/rate limit or billing exhausted
+ "provider_unreachable", # transient availability (5xx, overloaded)
+ "worker_timeout", # wall-clock / first-output timeout
+})
+
+
class WorkerKilled(_PayloadBase):
event_type: Literal["WorkerKilled"] = "WorkerKilled"
worker_id: str
@@ -107,6 +124,12 @@ class WorkerKilled(_PayloadBase):
# tests/missions/test_worker_killed_reason_parity.py.
"worker_error",
]
+ # Provider-failure classification (2026-07-06 incident): a token from
+ # MISSION_ERROR_CLASSES when the kill traces to a classified provider
+ # failure, plus the truncated upstream error text. Optional + defaulted
+ # so previously stored events keep validating.
+ error_class: str | None = None
+ error_detail: str | None = None
class MissionApproved(_PayloadBase):
@@ -125,6 +148,12 @@ class MissionFailed(_PayloadBase):
error_class: str | None = None
last_state: str
partial_artifacts: list[str] = Field(default_factory=list)
+ # Provider-failure surfacing (2026-07-06 incident): the truncated
+ # upstream error text and the provider slug of the worker that failed
+ # (e.g. "claude", "codex", "openrouter"). Optional + defaulted so
+ # previously stored events keep validating.
+ error_detail: str | None = None
+ failed_provider: str | None = None
class MissionCancelled(_PayloadBase):
diff --git a/jarvis/ui/web/frontend/src/types/missions.ts b/jarvis/ui/web/frontend/src/types/missions.ts
index e58d94d21a..c576fa2118 100644
--- a/jarvis/ui/web/frontend/src/types/missions.ts
+++ b/jarvis/ui/web/frontend/src/types/missions.ts
@@ -120,6 +120,15 @@ export interface WorkerCorrectionRequired extends BasePayload {
next_model: string;
}
+/** Closed provider-failure vocabulary — mirrors MISSION_ERROR_CLASSES in
+ * jarvis/missions/events.py (parity-tested). `error_class` on the wire stays
+ * `string | null` because legacy recovery values also occur. */
+export type MissionErrorClass =
+ | "provider_auth"
+ | "provider_quota"
+ | "provider_unreachable"
+ | "worker_timeout";
+
export type WorkerKilledReason =
| "timeout"
| "user"
@@ -133,6 +142,8 @@ export interface WorkerKilled extends BasePayload {
event_type: "WorkerKilled";
worker_id: string;
reason: WorkerKilledReason;
+ error_class?: string | null;
+ error_detail?: string | null;
}
export interface MissionApproved extends BasePayload {
@@ -151,6 +162,8 @@ export interface MissionFailed extends BasePayload {
error_class: string | null;
last_state: string;
partial_artifacts: string[];
+ error_detail?: string | null;
+ failed_provider?: string | null;
}
export interface MissionCancelled extends BasePayload {
diff --git a/tests/missions/test_mission_error_class_parity.py b/tests/missions/test_mission_error_class_parity.py
new file mode 100644
index 0000000000..66ead90a29
--- /dev/null
+++ b/tests/missions/test_mission_error_class_parity.py
@@ -0,0 +1,48 @@
+"""Five-layer parity guard for the mission error-class vocabulary (AP-4).
+
+The 2026-07-06 incident produced a mission failure whose cause (dead provider
+auth) was invisible in the app: ``MissionFailed.error_class`` existed but was
+never populated, and no UI/voice layer consumed it. This test locks the new
+closed vocabulary across Python <-> TypeScript so the BUG-008 enum-drift class
+cannot recur. (Voice-table and locale-file parity are asserted in
+``test_error_class_full_parity.py`` once those layers land.)
+"""
+from __future__ import annotations
+
+import re
+from pathlib import Path
+
+from jarvis.missions.events import MISSION_ERROR_CLASSES
+
+_REPO = Path(__file__).resolve().parents[2]
+
+
+def _ts_error_classes() -> set[str]:
+ ts = _REPO / "jarvis" / "ui" / "web" / "frontend" / "src" / "types" / "missions.ts"
+ text = ts.read_text(encoding="utf-8")
+ m = re.search(r"export type MissionErrorClass\s*=([^;]+);", text)
+ assert m, "MissionErrorClass union not found in missions.ts"
+ return set(re.findall(r'"([^"]+)"', m.group(1)))
+
+
+def test_error_class_tokens_python_ts_parity() -> None:
+ py = set(MISSION_ERROR_CLASSES)
+ ts = _ts_error_classes()
+ assert py == ts, f"error_class drift — python-only={py - ts}, ts-only={ts - py}"
+
+
+def test_expected_tokens_present() -> None:
+ assert MISSION_ERROR_CLASSES == frozenset(
+ {"provider_auth", "provider_quota", "provider_unreachable", "worker_timeout"}
+ )
+
+
+def test_new_event_fields_default_none() -> None:
+ """Old stored events (no new fields) must keep validating."""
+ from jarvis.missions.events import MissionFailed, WorkerKilled
+
+ mf = MissionFailed(reason="task_error", last_state="CRITIQUING")
+ assert mf.error_class is None and mf.error_detail is None
+ assert mf.failed_provider is None
+ wk = WorkerKilled(worker_id="w1", reason="worker_error")
+ assert wk.error_class is None and wk.error_detail is None