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(install): verify voice models on disk, report per-model truth

Ruben Lütkef24f197fd59a
diff --git a/install/installer.py b/install/installer.py
index 8c18eeb7fc..333cd9d307 100644
--- a/install/installer.py
+++ b/install/installer.py
@@ -265,12 +265,58 @@ def step_models(*, dry_run: bool) -> None:
if dry_run:
console.print(f"[muted] (dry-run) {' '.join(cmd)}[/]")
return
- rc = run(cmd, cwd=repo_root(), check=False)
- if rc == 0:
- ok("all voice models are on disk")
+ # The download step's exit code alone is not proof: a skipped or cache-served
+ # model can still leave "done" looking complete. So don't stop at rc — VERIFY
+ # what actually landed on disk and print a per-model truth. Read-only +
+ # best-effort: this never bricks the install (CLAUDE.md section 3).
+ run(cmd, cwd=repo_root(), check=False)
+ verify_models()
+
+
+def verify_models() -> None:
+ """Print a per-model truth: what is on disk, what is pending, what is missing.
+
+ Runs the read-only report inside the venv's Python — the interpreter that
+ will actually run Jarvis — so it sees the real installed packages and model
+ caches. Exit 0 = every REQUIRED model present; non-zero = a required model is
+ missing. A probe failure degrades to an honest note, never a failed install.
+ """
+ probe = (
+ "from jarvis.setup.model_report import "
+ "voice_model_report, report_complete, format_report\n"
+ "items = voice_model_report()\n"
+ "print('\\n'.join(format_report(items)))\n"
+ "import sys; sys.exit(0 if report_complete(items) else 3)\n"
+ )
+ try:
+ result = subprocess.run(
+ [str(venv_python()), "-c", probe], cwd=repo_root(),
+ capture_output=True, text=True, encoding="utf-8", errors="replace",
+ timeout=180,
+ )
+ except (OSError, subprocess.TimeoutExpired):
+ note("could not verify the voice models - they will be checked on first launch")
+ return
+ produced = False
+ for raw in (result.stdout or "").splitlines():
+ line = raw.rstrip()
+ if not line:
+ continue
+ produced = True
+ # markup=False: the report text contains literal '[full]' / quotes that
+ # must NOT be parsed as rich markup.
+ style = "ok" if line.startswith("✓") else ("bad" if line.startswith("✗") else "muted")
+ console.print(f" {line}", style=style, markup=False)
+ if not produced:
+ note("could not verify the voice models - they will be checked on first launch")
+ for tail in (result.stderr or "").strip().splitlines()[-5:]:
+ console.print(f"[muted] {tail}[/]")
+ return
+ if result.returncode == 0:
+ ok("everything the default voice path needs is present")
else:
- console.print("[bad] Some models could not be downloaded - the app "
- "will fetch them on first launch instead.[/]")
+ console.print("[bad] Some required voice models are missing - re-run "
+ "the installer or check your connection.[/]")
def step_worker_cli(*, dry_run: bool) -> None:
diff --git a/jarvis/__main__.py b/jarvis/__main__.py
index a83fb53c94..3de1b0414c 100644
--- a/jarvis/__main__.py
+++ b/jarvis/__main__.py
@@ -73,6 +73,14 @@ def _build_parser() -> argparse.ArgumentParser:
help="Download all voice models the current config needs, then exit. "
"Used by the installer so the first launch has nothing left to fetch.",
)
+ parser.add_argument(
+ "--verify-models",
+ action="store_true",
+ dest="verify_models",
+ help="Check which voice models are actually on disk and print a per-model "
+ "report (wake word, end-of-speech, custom-wake, local speech), then "
+ "exit. Read-only; exits non-zero when a required model is missing.",
+ )
parser.add_argument(
"--uninstall",
action="store_true",
@@ -491,6 +499,17 @@ def main(argv: list[str] | None = None) -> int:
from jarvis.setup.prefetch import prefetch_all
return prefetch_all()
+ if args.verify_models:
+ from jarvis.setup.model_report import (
+ format_report,
+ report_complete,
+ voice_model_report,
+ )
+
+ items = voice_model_report()
+ for line in format_report(items):
+ print(line)
+ return 0 if report_complete(items) else 3
if args.command == "serve":
# Headless web UI — the cloud-first path (no desktop/tray). Delegates to
# the web launcher so `jarvis serve` == `python -m jarvis.ui.web.launcher --headless`.
diff --git a/jarvis/setup/model_report.py b/jarvis/setup/model_report.py
new file mode 100644
index 0000000000..e9844da75f
--- /dev/null
+++ b/jarvis/setup/model_report.py
@@ -0,0 +1,220 @@
+"""Honest on-disk verification of the voice models — the truth behind "done".
+
+``prefetch.py`` DOWNLOADS the models the voice path needs; this module VERIFIES
+what actually landed on disk afterwards, so the installer (and a standalone
+check) can print a per-model truth instead of a flat "all models are on disk".
+It answers the only question that matters to a fresh downloader: *is the thing
+really here, and if not, why?*
+
+Design contract (CLAUDE.md section 3 — a flaky probe must never brick an
+install):
+
+- **Read-only + best-effort.** Every probe is wrapped so a failure reads as
+ "absent", never as a raised exception. The report can always be produced.
+- **No network.** The faster-whisper cache probe uses ``local_files_only`` so it
+ never triggers a download while merely *checking*.
+- **Honest optionality.** ``required`` separates the models the DEFAULT voice
+ path needs (bundled neural wake backbone + Silero VAD — both ship in-repo)
+ from the optional ones (the per-language Vosk custom-wake model and the local
+ Whisper models, which are downloaded / behind the ``[full]`` profile). A
+ missing optional model is a pending download, not a failure — so
+ ``report_complete`` gates only on the required set and never sabotages an
+ install that legitimately runs cloud speech.
+
+Seams (module-level functions) keep the heavy imports lazy and let tests inject
+fakes without a real config, network, or model cache — same style as
+``prefetch.py``.
+"""
+
+from __future__ import annotations
+
+import importlib.util
+from collections.abc import Callable, Sequence
+from dataclasses import dataclass
+from typing import Any
+
+
+@dataclass(frozen=True)
+class ModelStatus:
+ """One line of the report: a model, whether it is usable, and why."""
+
+ label: str # human-readable name shown to the user
+ present: bool # usable on disk right now
+ detail: str # honest one-line explanation (why present / why not)
+ required: bool # True: the default voice path needs it; False: optional/by-design
+
+
+# --------------------------------------------------------------------------
+# Seams — patched in tests; keep the heavy imports lazy for a light module load.
+# --------------------------------------------------------------------------
+def _wake_backbone_present() -> bool:
+ """The always-on neural wake backbones ship in-repo (jarvis/assets/wakeword)."""
+ import jarvis.assets
+
+ return jarvis.assets.bundled_wakeword_models() is not None
+
+
+def _vad_present() -> bool:
+ """The Silero end-of-speech model ships in-repo (jarvis/assets/vad)."""
+ import jarvis.assets
+
+ return jarvis.assets.bundled_silero_vad_model() is not None
+
+
+def _load_config() -> Any:
+ from jarvis.core.config import load_config
+
+ return load_config()
+
+
+def _wake_language(cfg: Any) -> str | None:
+ from jarvis.speech.wake_model_fetch import resolve_wake_language
+
+ return resolve_wake_language(cfg)
+
+
+def _vosk_present(language: str | None, data_dir: str | None) -> bool:
+ from jarvis.speech.wake_model_fetch import vosk_model_present
+
+ return vosk_model_present(language, data_dir=data_dir)
+
+
+def _faster_whisper_available() -> bool:
+ return importlib.util.find_spec("faster_whisper") is not None
+
+
+def _whisper_cached(name: str) -> bool:
+ """True when faster-whisper model ``name`` is already in the local HF cache.
+
+ ``local_files_only`` keeps this a pure cache lookup — it never reaches the
+ network. Any failure (not cached, lib missing, odd cache layout) reads as
+ "not present".
+ """
+ from faster_whisper.utils import download_model # type: ignore[import-not-found]
+
+ download_model(name, local_files_only=True)
+ return True
+
+
+def _whisper_models_needed(cfg: Any) -> list[str]:
+ """The faster-whisper model names the CURRENT config would load at runtime.
+
+ Mirrors ``prefetch._whisper_models_needed``: the wake-match model always,
+ plus the utterance model only when the local provider is selected.
+ """
+ models = [cfg.stt.wake_model]
+ if cfg.stt.provider == "faster-whisper" and cfg.stt.model not in models:
+ models.append(cfg.stt.model)
+ return models
+
+
+# --------------------------------------------------------------------------
+# Report
+# --------------------------------------------------------------------------
+def _safe(fn: Callable[[], Any], default: Any) -> Any:
+ """Run a probe; any failure degrades to ``default`` — the report never raises."""
+ try:
+ return fn()
+ except Exception: # noqa: BLE001 - a probe that cannot answer means "absent"
+ return default
+
+
+def voice_model_report(cfg: Any | None = None, *, data_dir: str | None = None) -> list[ModelStatus]:
+ """Verify, read-only, which voice models are actually ready on disk.
+
+ ``cfg`` defaults to the live config (loaded via the same path the runtime
+ uses); pass one explicitly to keep a caller/test hermetic.
+ """
+ if cfg is None:
+ cfg = _safe(_load_config, None)
+
+ items: list[ModelStatus] = []
+
+ # 1. Neural wake-word backbone — bundled in-repo, core path.
+ wake_ok = bool(_safe(_wake_backbone_present, False))
+ items.append(
+ ModelStatus(
+ "wake word (neural)",
+ wake_ok,
+ "bundled with the app"
+ if wake_ok
+ else "MISSING from the package - partial download? re-run the installer",
+ required=True,
+ )
+ )
+
+ # 2. End-of-speech detection (Silero VAD) — bundled in-repo, core path.
+ vad_ok = bool(_safe(_vad_present, False))
+ items.append(
+ ModelStatus(
+ "end-of-speech detection",
+ vad_ok,
+ "bundled with the app"
+ if vad_ok
+ else "MISSING from the package - partial download? re-run the installer",
+ required=True,
+ )
+ )
+
+ # 3. Custom-wake model (Vosk, per language) — downloaded once, optional.
+ lang = _safe(lambda: _wake_language(cfg), None) if cfg is not None else None
+ vosk_ok = bool(_safe(lambda: _vosk_present(lang, data_dir), False))
+ items.append(
+ ModelStatus(
+ f"custom-wake model '{lang or 'default'}'",
+ vosk_ok,
+ "ready" if vosk_ok else "not downloaded yet - the app fetches it on first use",
+ required=False,
+ )
+ )
+
+ # 4. Local speech recognition (faster-whisper) — optional; cloud is default.
+ if not bool(_safe(_faster_whisper_available, False)):
+ items.append(
+ ModelStatus(
+ "local speech model",
+ False,
+ "not installed - cloud speech is the default "
+ "(install the [full] profile for offline speech)",
+ required=False,
+ )
+ )
+ else:
+ needed = _safe(lambda: _whisper_models_needed(cfg), []) if cfg is not None else []
+ for name in needed:
+ cached = bool(_safe(lambda n=name: _whisper_cached(n), False))
+ items.append(
+ ModelStatus(
+ f"local speech model '{name}'",
+ cached,
+ "ready" if cached else "not downloaded yet - the app fetches it on first use",
+ required=False,
+ )
+ )
+
+ return items
+
+
+def report_complete(items: Sequence[ModelStatus]) -> bool:
+ """True when every REQUIRED model is present (optional ones may be pending)."""
+ return all(it.present for it in items if it.required)
+
+
+def format_report(items: Sequence[ModelStatus]) -> list[str]:
+ """Render the report as aligned human lines with ✓ / ✗ / — markers.
+
+ ✓ present · ✗ required-but-missing (a real problem) · — optional-and-pending.
+ """
+ lines: list[str] = []
+ for it in items:
+ mark = "✓" if it.present else ("✗" if it.required else "—")
+ lines.append(f"{mark} {it.label:<26} {it.detail}")
+ return lines
+
+
+__all__ = [
+ "ModelStatus",
+ "voice_model_report",
+ "report_complete",
+ "format_report",
+]
diff --git a/tests/unit/setup/test_model_report.py b/tests/unit/setup/test_model_report.py
new file mode 100644
index 0000000000..3a73fd7817
--- /dev/null
+++ b/tests/unit/setup/test_model_report.py
@@ -0,0 +1,119 @@
+"""voice_model_report: honest on-disk verification of what the voice path needs.
+
+Every probe is a module-level seam so these tests inject fakes without touching
+a real config, the network, or the model cache. Mirrors the hermetic style of
+test_prefetch.py.
+"""
+
+from jarvis.setup import model_report as mr
+
+
+class _Stt:
+ wake_model = "base"
+ provider = "groq-api" # cloud provider -> only the wake model is "needed"
+ model = "large-v3-turbo"
+
+
+class _Cfg:
+ stt = _Stt()
+
+
+def _patch_bundled(monkeypatch, *, wake: bool = True, vad: bool = True) -> None:
+ monkeypatch.setattr(mr, "_wake_backbone_present", lambda: wake)
+ monkeypatch.setattr(mr, "_vad_present", lambda: vad)
+ monkeypatch.setattr(mr, "_wake_language", lambda _cfg: "de")
+
+
+def test_all_required_present_is_complete(monkeypatch) -> None:
+ _patch_bundled(monkeypatch)
+ monkeypatch.setattr(mr, "_vosk_present", lambda *_a, **_kw: True)
+ monkeypatch.setattr(mr, "_faster_whisper_available", lambda: False)
+
+ items = mr.voice_model_report(_Cfg())
+
+ assert mr.report_complete(items) is True
+ wake = next(i for i in items if "wake word" in i.label)
+ assert wake.present is True and wake.required is True
+
+
+def test_missing_bundled_backbone_marks_incomplete(monkeypatch) -> None:
+ # A partial download that dropped the neural backbone must NOT read complete.
+ _patch_bundled(monkeypatch, wake=False)
+ monkeypatch.setattr(mr, "_vosk_present", lambda *_a, **_kw: True)
+ monkeypatch.setattr(mr, "_faster_whisper_available", lambda: False)
+
+ items = mr.voice_model_report(_Cfg())
+
+ assert mr.report_complete(items) is False
+ wake = next(i for i in items if "wake word" in i.label)
+ assert wake.present is False and wake.required is True
+
+
+def test_absent_local_whisper_is_optional_not_a_failure(monkeypatch) -> None:
+ # Cloud speech is the default: no local Whisper is by-design, not incomplete.
+ _patch_bundled(monkeypatch)
+ monkeypatch.setattr(mr, "_vosk_present", lambda *_a, **_kw: True)
+ monkeypatch.setattr(mr, "_faster_whisper_available", lambda: False)
+
+ items = mr.voice_model_report(_Cfg())
+
+ local = next(i for i in items if "local speech" in i.label)
+ assert local.required is False
+ assert local.present is False
+ assert "cloud speech is the default" in local.detail
+ assert mr.report_complete(items) is True
+
+
+def test_pending_vosk_download_is_optional_not_a_failure(monkeypatch) -> None:
+ _patch_bundled(monkeypatch)
+ monkeypatch.setattr(mr, "_vosk_present", lambda *_a, **_kw: False)
+ monkeypatch.setattr(mr, "_faster_whisper_available", lambda: False)
+
+ items = mr.voice_model_report(_Cfg())
+
+ vosk = next(i for i in items if "custom-wake" in i.label)
+ assert vosk.required is False and vosk.present is False
+ assert mr.report_complete(items) is True # required set is still satisfied
+
+
+def test_installed_whisper_reports_cache_hit_per_model(monkeypatch) -> None:
+ _patch_bundled(monkeypatch)
+ monkeypatch.setattr(mr, "_vosk_present", lambda *_a, **_kw: True)
+ monkeypatch.setattr(mr, "_faster_whisper_available", lambda: True)
+ monkeypatch.setattr(mr, "_whisper_models_needed", lambda _cfg: ["base"])
+ monkeypatch.setattr(mr, "_whisper_cached", lambda name: name == "base")
+
+ items = mr.voice_model_report(_Cfg())
+
+ whisper = next(i for i in items if "local speech model 'base'" in i.label)
+ assert whisper.present is True
+
+
+def test_format_report_marks_present_missing_and_optional(monkeypatch) -> None:
+ _patch_bundled(monkeypatch, wake=False) # required + absent -> hard cross
+ monkeypatch.setattr(mr, "_vosk_present", lambda *_a, **_kw: False) # optional + absent -> dash
+ monkeypatch.setattr(mr, "_faster_whisper_available", lambda: False)
+
+ items = mr.voice_model_report(_Cfg())
+ text = "\n".join(mr.format_report(items))
+
+ assert "✓" in text # a present item (VAD) renders a check
+ assert "✗" in text # the missing required backbone renders a cross
+ assert "—" in text # the pending optional item renders a dash
+
+
+def test_probe_failure_reads_as_absent_never_raises(monkeypatch) -> None:
+ # A probe that blows up must degrade to "absent", never crash the report.
+ def _boom() -> bool:
+ raise RuntimeError("probe exploded")
+
+ monkeypatch.setattr(mr, "_wake_backbone_present", _boom)
+ monkeypatch.setattr(mr, "_vad_present", lambda: True)
+ monkeypatch.setattr(mr, "_wake_language", lambda _cfg: "de")
+ monkeypatch.setattr(mr, "_vosk_present", lambda *_a, **_kw: True)
+ monkeypatch.setattr(mr, "_faster_whisper_available", lambda: False)
+
+ items = mr.voice_model_report(_Cfg()) # must not raise
+
+ wake = next(i for i in items if "wake word" in i.label)
+ assert wake.present is False