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.
Python agent-orchestrationai-agentai-coding-assistantclaude-codecoding-agentcomputer-usedesktop-applocal-firstmcppersonal-jarvisvoice-assistantvoice-coding
feat(wake): retire the jarvis-family special case — one generic matcher path
Ruben Lütke2d3486cea6a8
diff --git a/jarvis/speech/pipeline.py b/jarvis/speech/pipeline.pyindex d413fd5ff3..4ad1b23a05 100644--- a/jarvis/speech/pipeline.py+++ b/jarvis/speech/pipeline.py@@ -1138,27 +1138,28 @@ class SpeechPipeline:self._wake = OpenWakeWordProvider(keywords=wake_keywords, activation_threshold=wake_threshold)- # Stays off whenever there is no local Whisper engine (lightweight- # path), so the heartbeat reports whisper=off instead of a phantom on.- self._whisper_wake_enabled = enable_whisper_wake and self._stt is not None- # Rolling-Window Whisper: transkribiert alle 500ms die letzten 2.5s- # Audio und matched das Wake-Pattern. Kein VAD-Endpoint-Dependency →- # robust auch bei leisem Mic. RollingWhisperWake needs a local Whisper- # engine; in the lightweight path (self._stt is None) it is always off.- # When a wake_plan is set, its matcher drives the phrase match so a- # custom phrase ("Computer") is detected instead of "jarvis".- if enable_whisper_wake and self._stt is not None:- _poll = self._wake_poll_interval()- if self._wake_matcher is not None:- self._whisper_wake = RollingWhisperWake(- self._stt, pattern=self._wake_matcher, poll_interval_s=_poll- )- else:- self._whisper_wake = RollingWhisperWake(- self._stt, poll_interval_s=_poll- )+ # Rolling-window Whisper: transcribes the last ~2 s of audio on a poll+ # cadence and matches the wake phrase. No VAD-endpoint dependency, so+ # it stays robust on a quiet mic. It needs BOTH a local Whisper engine+ # AND a phrase matcher: with no wake plan there is no phrase to listen+ # for (no shipped default pattern — design 2026-07-07), so no rolling+ # detector is armed; a later set_wake_plan() arms one live. The+ # enabled flag stays in lockstep so the heartbeat reports whisper=off+ # instead of a phantom on.+ if (+ enable_whisper_wake+ and self._stt is not None+ and self._wake_matcher is not None+ ):+ self._whisper_wake = RollingWhisperWake(+ self._stt,+ pattern=self._wake_matcher,+ poll_interval_s=self._wake_poll_interval(),+ )+ self._whisper_wake_enabled = Trueelse:self._whisper_wake = None+ self._whisper_wake_enabled = False# require_hey_prefix may arrive either as an explicit kwarg or from# cfg.trigger.require_hey_prefix. The kwarg wins so tests can override.cfg_require = True@@ -4290,8 +4291,8 @@ class SpeechPipeline:async def _verify_oww_hit(self, pcm_snapshot: bytes) -> bool:"""Second-stage gate: ask the utterance STT whether the few seconds- leading up to an OpenWakeWord hit actually contained "hey/hi/hallo +- jarv". Returns True if the strict prefix is in the transcript.+ leading up to an OpenWakeWord hit actually contained the configured+ wake phrase. Returns True if the phrase's matcher confirms it.STT-outage failure modes degrade OPEN (return True with a log line) soa misconfigured STT, a network blip, or a rate-limit cannot brick thediff --git a/jarvis/speech/rolling_whisper_wake.py b/jarvis/speech/rolling_whisper_wake.pyindex 221a06b780..efa375bb7e 100644--- a/jarvis/speech/rolling_whisper_wake.py+++ b/jarvis/speech/rolling_whisper_wake.py@@ -38,13 +38,11 @@ from jarvis.audio.capture import pcm_bytes_to_npfrom jarvis.core.protocols import AudioChunkfrom jarvis.plugins.stt.fwhisper import FasterWhisperProvider, TranscribeBusy-# The strict "hey/hi/hallo + jarv-stem" pattern now lives in wake_constants as-# the single source of truth (the prefix verifier re-exports the same object),-# so the two STT wake paths can never drift apart (BUG-008). Re-exported here-# under the historical ``DEFAULT_PATTERN`` name so existing call sites and tests-# keep working. ``pattern=`` also accepts a ``WakeMatcher`` (duck-types-# ``.search().group(0)``) so a custom wake phrase can drive this backstop.-from jarvis.speech.wake_constants import JARVIS_WAKE_PATTERN as DEFAULT_PATTERN+# ``pattern=`` accepts a compiled regex or a ``WakeMatcher`` (duck-types+# ``.search().group(0)``). There is NO default pattern: the product ships no+# wake word (design 2026-07-07), so every caller passes the configured+# phrase's matcher from the wake plan — the same object the prefix verifier+# uses, so the two STT wake paths can never drift apart (BUG-008).from jarvis.speech.wake_constants import (STT_HALLUCINATION_RE,normalize_phrase_for_match,@@ -181,8 +179,9 @@ class RollingWhisperWake:self,stt: FasterWhisperProvider,# Either a compiled regex or a WakeMatcher — both expose- # ``.search(text)`` returning an object with ``.group(0)``.- pattern: Any = DEFAULT_PATTERN,+ # ``.search(text)`` returning an object with ``.group(0)``. REQUIRED:+ # there is no shipped default wake pattern (design 2026-07-07).+ pattern: Any,window_s: float = 1.8, # shorter = less silence share = higher avg RMS# 2026-06-30 ("~0.5 s delay"): 0.3 -> 0.2 so a spoken custom wake reaches# the bar within one snappier poll. The gates skip silence cheaply, so thediff --git a/jarvis/speech/wake_constants.py b/jarvis/speech/wake_constants.pyindex afd69362ac..e46b351825 100644--- a/jarvis/speech/wake_constants.py+++ b/jarvis/speech/wake_constants.py@@ -9,9 +9,6 @@ Why this module exists:- ``WAKE_ENGINES`` is the SoT for the five-layer enum (Python ↔ TOML ↔ Pydantic↔ TS ↔ UI). The TS mirror (``frontend/src/constants/wakeEngines.ts``) is heldin lockstep by ``tests/unit/speech/test_wake_engine_parity.py``.-- ``JARVIS_WAKE_PATTERN`` is the strict legacy "hey/hi/hallo + jarv" regex,- moved here so ``rolling_whisper_wake.DEFAULT_PATTERN`` and the prefix verifier- re-export ONE definition instead of duplicating the literal (BUG-008 drift).- The product ships NO named wake model and never resolves a phrase against apretrained one (design 2026-07-07): every phrase goes through the genericengine chain in ``wake_phrase.resolve_wake_plan`` (user-trained custom .onnx@@ -40,14 +37,10 @@ WAKE_ENGINES: tuple[str, ...] = (DEFAULT_WAKE_PHRASE = "" # empty = neutral pre-onboarding default; user must opt in-# Strict legacy wake pattern (was rolling_whisper_wake.DEFAULT_PATTERN). Matches-# "hey/hi/hallo" + a jarv-family stem; a bare "Jarvis" or a Whisper-# hallucination must NOT match (BUG-009). This is the single definition; the-# rolling-whisper backstop and the prefix verifier both re-export it.-JARVIS_WAKE_PATTERN = re.compile(- r"\bh(ey|i|allo)\W+(jarv\w{1,5}|charv\w{1,5}|tscharv\w{1,5}|dschärw\w{1,5})\b", # i18n-allow- re.IGNORECASE,-)+# (JARVIS_WAKE_PATTERN — the strict legacy "hey + jarv-stem" regex — was+# removed 2026-07-07 with the last special-cased wake word. Every phrase now+# compiles to the same generic fuzzy matcher; BUG-009's bare-core-word guard+# lives in WakeMatcher.require_known_prefix for prefixed phrases.)# Known Whisper silence/noise hallucination boilerplate (YouTube end cards,# broadcaster subtitle credits, ad outros). Single definition here (leaf@@ -231,7 +224,6 @@ def resolve_vosk_model_path(language: str | None) -> str | None:__all__ = ["WAKE_ENGINES","DEFAULT_WAKE_PHRASE",- "JARVIS_WAKE_PATTERN","WAKE_PREFIXES","INSTANT_WAKE_PHRASES","normalize_phrase",diff --git a/jarvis/speech/wake_phrase.py b/jarvis/speech/wake_phrase.pyindex 6330f900e7..e5cfab8356 100644--- a/jarvis/speech/wake_phrase.py+++ b/jarvis/speech/wake_phrase.py@@ -30,7 +30,6 @@ from typing import Anyfrom jarvis.plugins.wake.openwakeword_provider import PRODUCTION_WAKE_THRESHOLDfrom jarvis.speech.wake_constants import (DEFAULT_WAKE_PHRASE,- JARVIS_WAKE_PATTERN,WAKE_ENGINES,WAKE_PREFIXES,normalize_phrase_for_match,@@ -109,9 +108,9 @@ class _FuzzyMatch:class WakeMatcher:"""Phrase matcher that duck-types ``re.Pattern.search(text)``.- - jarvis-default: wraps the canonical :data:`JARVIS_WAKE_PATTERN`.- - arbitrary phrase: fuzzy token-window match against a normalised- transcript using ``difflib.SequenceMatcher``. When the configured phrase+ Every phrase gets the same treatment (no special-cased word — design+ 2026-07-07): fuzzy token-window match against a normalised+ transcript using ``difflib.SequenceMatcher``. When the configured phrasestarts with a known wake prefix ("Hey Fable"), the matched window must beIMMEDIATELY preceded by a prefix token too (``require_known_prefix``) —the bare core word inside ordinary speech must NOT activate (user mandate@@ -126,7 +125,6 @@ class WakeMatcher:pattern: Any | None = None,core_tokens: list[str] | None = None,fuzzy_ratio: float = 0.8,- is_jarvis_default: bool = False,require_known_prefix: bool = False,) -> None:self._pattern = pattern@@ -134,16 +132,11 @@ class WakeMatcher:# ("Nico" -> "Niko"/"Nicko"/"Nikko") compares equal (see ``sound_fold``).self._core = [sound_fold(c) for c in (core_tokens or [])]self._ratio = fuzzy_ratio- self._is_jarvis = is_jarvis_defaultself._require_prefix = require_known_prefix# Folded prefix family: the window before the core must fuzzy-match ANY# of these when the configured phrase itself carries a prefix.self._folded_prefixes = tuple({sound_fold(p) for p in WAKE_PREFIXES})- @property- def is_jarvis_default(self) -> bool:- return self._is_jarvis-def _effective_ratio(self, core_token: str) -> float:"""The match ratio required for one core token.@@ -218,11 +211,12 @@ class WakeMatcher:def compile_wake_matcher(phrase: str, *, fuzzy_ratio: float = 0.8) -> WakeMatcher:"""Build a :class:`WakeMatcher` for ``phrase``.- The default "Hey Jarvis" (and any jarvis-only phrase) is matched by the- strict legacy pattern. Every other phrase fuzzy-matches on its CORE tokens;- when the configured phrase itself starts with a known wake prefix ("Hey- Fable"), the prefix is REQUIRED immediately before the core (any known- prefix counts — "Hallo Fable" still wakes a "Hey Fable" config).+ Every phrase — including "Hey Jarvis" — fuzzy-matches on its CORE tokens+ (no special-cased word ships; design 2026-07-07). When the configured+ phrase itself starts with a known wake prefix ("Hey Fable"), the prefix is+ REQUIRED immediately before the core (any known prefix counts — "Hallo+ Fable" still wakes a "Hey Fable" config), so the bare core word in+ ordinary speech stays silent (BUG-009 for prefixed phrases).History: 2026-06-29 deliberately made the prefix OPTIONAL ("lieber leichtertriggern als schwer") because the slow poll cadence (~1.7 s vs a 1.8 s@@ -239,8 +233,6 @@ def compile_wake_matcher(phrase: str, *, fuzzy_ratio: float = 0.8) -> WakeMatche"""tokens = normalize_phrase_for_match(phrase)core = phrase_core_for_match(phrase)- if core == ["jarvis"]:- return WakeMatcher(pattern=JARVIS_WAKE_PATTERN, is_jarvis_default=True)# A leading known prefix was stripped from the core -> the user's phrase# carries one -> demand it in the transcript too.has_prefix = len(core) < len(tokens)@@ -485,7 +477,10 @@ def resolve_wake_plan(needs_local_whisper=True,degraded=degraded,message=message,- verify_prefix=matcher.is_jarvis_default,+ # The rolling-whisper path already matches the phrase itself; no+ # second-stage prefix verification (that gate exists for weak+ # custom_onnx models — see WakeWordPlan.verify_prefix).+ verify_prefix=False,)# 5. No local model for the user's OWN word. The product rule (2026-07-04)diff --git a/jarvis/speech/wake_verifier.py b/jarvis/speech/wake_verifier.pyindex 3878dc5652..ac45fcc4b5 100644--- a/jarvis/speech/wake_verifier.py+++ b/jarvis/speech/wake_verifier.py@@ -20,12 +20,8 @@ from typing import Any, Protocolimport numpy as np-from jarvis.speech.rolling_whisper_wake import DEFAULT_PATTERN-log = logging.getLogger("jarvis.wake.verifier")-WAKE_PREFIX_PATTERN = DEFAULT_PATTERN-# Silence gate for user-trained custom_onnx wake hits (live forensic# 2026-07-02): such models fire on breath/near-silence many times a minute,# and each fire used to cost a full STT verify round-trip — the flood drove@@ -95,16 +91,19 @@ def transcript_has_hey_prefix(text: str, matcher: Any | None = None) -> bool:Pure function — no I/O, no STT. The caller transcribes the audio bufferhowever it likes and passes the resulting text in here.- ``matcher`` is an optional :class:`~jarvis.speech.wake_phrase.WakeMatcher`- (or any object exposing ``.search(text)``). When ``None`` the strict legacy- "hey/hi/hallo + jarv" pattern is used so the default "Hey Jarvis" behaviour- is byte-identical. A custom wake phrase passes its own matcher here so the- OpenWakeWord prefix gate confirms the *configured* word, not "jarvis".+ ``matcher`` is a :class:`~jarvis.speech.wake_phrase.WakeMatcher` (or any+ object exposing ``.search(text)``) — the configured phrase's own matcher+ from the wake plan. There is no default pattern (design 2026-07-07): with+ ``None`` this check FAILS OPEN (returns True with a warning) because a+ missing matcher is a wiring gap, not evidence against the wake — an+ over-eager suppression here would silently brick the wake word."""if not text:return False- pattern = matcher if matcher is not None else WAKE_PREFIX_PATTERN- return pattern.search(text) is not None+ if matcher is None:+ log.warning("Wake verify called without a matcher — failing open.")+ return True+ return matcher.search(text) is not Noneasync def verify_wake_with_stt(@@ -114,10 +113,10 @@ async def verify_wake_with_stt(language: str | None = "de",matcher: Any | None = None,) -> tuple[bool, str | None]:- """Transcribe ``pcm_bytes`` and check the strict wake prefix.+ """Transcribe ``pcm_bytes`` and confirm the configured wake phrase.Returns ``(matched, transcript_text)``. ``matched`` is True only when the- transcript contains the full "hey/hi/hallo + jarv" pattern.+ transcript satisfies the phrase's own matcher.The transcript distinguishes two non-matching cases the caller must treatdifferently: ``""`` means the STT WORKED and heard no speech (evidence of adiff --git a/jarvis/speech/whisper_wake.py b/jarvis/speech/whisper_wake.pydeleted file mode 100644index ebcf79d25c..0000000000--- a/jarvis/speech/whisper_wake.py+++ /dev/null@@ -1,75 +0,0 @@-"""Whisper-based wake-word fallback.--Runs in parallel with openWakeWord as a second, more robust detector: takes-audio chunks, endpoints them via Silero VAD, transcribes each detected-utterance briefly through Whisper, and matches the transcript against a-keyword pattern (default: "jarvis" as a standalone word or within "hey jarvis").--Advantage: understands German pronunciation natively (Whisper is trained-multilingually). Disadvantage: ~800-1200 ms latency (VAD endpoint + Whisper).--We use both in parallel — openWakeWord for fast hits (15-30 ms), Whisper wake-as a safety net for all the cases where openWakeWord doesn't catch it (e.g. a-German accent, low mic level).-"""-from __future__ import annotations--import logging-import re-from collections.abc import AsyncIterator--from jarvis.audio.vad import SileroEndpointer-from jarvis.core.protocols import AudioChunk-from jarvis.plugins.stt.fwhisper import FasterWhisperProvider--log = logging.getLogger("jarvis.wake.whisper")---# 2026-05-12: require the full "Hey/Hi/Hallo Jarvis" phrase, not bare-# "Jarvis". The bare-word pattern fired on any utterance containing-# "Jarvis" anywhere — including Whisper hallucinations on short audio-# windows. Kept consistent with rolling_whisper_wake.DEFAULT_PATTERN.-# Matches "hey jarvis", "hi jarvis", "hallo jarvis" (with or without-# comma, any whitespace). Does NOT match a bare "jarvis" without a-# hey/hi/hallo prefix.-DEFAULT_PATTERN = re.compile(- r"\bh(ey|i|allo)\W+jarvis\b",- re.IGNORECASE,-)---class WhisperWakeDetector:- """VAD-endpointed Whisper transcription with keyword matching."""-- def __init__(- self,- stt: FasterWhisperProvider,- vad: SileroEndpointer | None = None,- pattern: re.Pattern[str] = DEFAULT_PATTERN,- vad_silence_ms: int = 500, # shorter than for a regular utterance- min_speech_ms: int = 150, # shorter — "jarvis" alone is enough- ) -> None:- self._stt = stt- self._vad = vad or SileroEndpointer(- silence_ms=vad_silence_ms,- min_speech_ms=min_speech_ms,- )- self._pattern = pattern-- async def detect(- self, chunks: AsyncIterator[AudioChunk]- ) -> AsyncIterator[str]:- """Consumes audio, yields the matched keyword string on a hit."""- async for utterance_pcm in self._vad.utterances(chunks):- try:- transcript = await self._stt.transcribe_pcm(utterance_pcm)- except Exception as exc: # noqa: BLE001- log.warning("Whisper wake transcription error: %s", exc)- continue- text = transcript.text.strip()- if not text:- continue- log.info("whisper-wake heard: '%s'", text)- m = self._pattern.search(text)- if m:- yield m.group(0)diff --git a/tests/unit/speech/test_rolling_whisper_wake_sensitivity.py b/tests/unit/speech/test_rolling_whisper_wake_sensitivity.pyindex 7b055763ad..c8fb3e19fa 100644--- a/tests/unit/speech/test_rolling_whisper_wake_sensitivity.py+++ b/tests/unit/speech/test_rolling_whisper_wake_sensitivity.py@@ -24,6 +24,7 @@ import numpy as npfrom jarvis.core.protocols import AudioChunk, Transcriptfrom jarvis.speech.rolling_whisper_wake import RollingWhisperWake+from jarvis.speech.wake_phrase import compile_wake_matcherdef _const_chunk(value: int, n: int = 1600) -> AudioChunk:@@ -151,7 +152,7 @@ async def test_quiet_genuine_wake_below_legacy_confidence_floor_is_accepted() ->def test_default_gates_let_quiet_speech_through_but_still_guard_silence() -> None:from jarvis.plugins.stt.fwhisper import FasterWhisperProvider- wake = RollingWhisperWake(FasterWhisperProvider())+ wake = RollingWhisperWake(FasterWhisperProvider(), pattern=compile_wake_matcher("Hey Nova"))# Silence guard preserved (pinned independently by the hallucination guard).assert wake._min_rms >= 0.003 # noqa: SLF001# Peak gate lowered below the legacy 0.02 so a quiet mic is not deafened.@@ -168,7 +169,9 @@ def test_default_gates_let_quiet_speech_through_but_still_guard_silence() -> Nondef test_stats_start_at_zero() -> None:from jarvis.plugins.stt.fwhisper import FasterWhisperProvider- s = RollingWhisperWake(FasterWhisperProvider()).stats()+ s = RollingWhisperWake(+ FasterWhisperProvider(), pattern=compile_wake_matcher("Hey Nova")+ ).stats()assert s["windows_polled"] == 0assert s["transcribed"] == 0assert s["matched"] == 0diff --git a/tests/unit/speech/test_wake_hallucination_guard.py b/tests/unit/speech/test_wake_hallucination_guard.pyindex a4ef782eca..a3e629afb2 100644--- a/tests/unit/speech/test_wake_hallucination_guard.py+++ b/tests/unit/speech/test_wake_hallucination_guard.py@@ -2,6 +2,7 @@ from __future__ import annotationsfrom jarvis.plugins.stt.fwhisper import FasterWhisperProviderfrom jarvis.speech.rolling_whisper_wake import RollingWhisperWake+from jarvis.speech.wake_phrase import compile_wake_matcherdef test_final_stt_has_no_example_prompt_that_can_be_hallucinated() -> None:@@ -11,6 +12,8 @@ def test_final_stt_has_no_example_prompt_that_can_be_hallucinated() -> None:def test_rolling_wake_ignores_very_low_rms_hallucination_windows() -> None:- wake = RollingWhisperWake(FasterWhisperProvider())+ wake = RollingWhisperWake(+ FasterWhisperProvider(), pattern=compile_wake_matcher("Hey Nova")+ )assert wake._min_rms >= 0.003 # noqa: SLF001diff --git a/tests/unit/speech/test_wake_latency.py b/tests/unit/speech/test_wake_latency.pyindex bb34fb016a..cf0597a5b3 100644--- a/tests/unit/speech/test_wake_latency.py+++ b/tests/unit/speech/test_wake_latency.py@@ -20,6 +20,7 @@ from types import SimpleNamespacefrom jarvis.core.events import WakeCandidateDetected, WakeWordDetectedfrom jarvis.plugins.stt.fwhisper import FasterWhisperProviderfrom jarvis.speech.rolling_whisper_wake import RollingWhisperWake+from jarvis.speech.wake_phrase import compile_wake_matcherfrom ui.orb.bus_bridge import OrbBusBridge# Instrumented ceiling for the reveal EVENT path (wake detected -> bar shown).@@ -29,7 +30,9 @@ _REVEAL_BUDGET_MS = 100.0def test_rolling_whisper_poll_interval_is_snappy() -> None:- wake = RollingWhisperWake(FasterWhisperProvider())+ wake = RollingWhisperWake(+ FasterWhisperProvider(), pattern=compile_wake_matcher("Hey Nova")+ )assert wake._poll_interval_s <= 0.2, ( # noqa: SLF001"the custom-wake detector must poll at least every 200 ms so a spoken ""wake reaches the bar quickly"diff --git a/tests/unit/speech/test_wake_live_apply.py b/tests/unit/speech/test_wake_live_apply.pyindex bed82894a8..01824f6b90 100644--- a/tests/unit/speech/test_wake_live_apply.py+++ b/tests/unit/speech/test_wake_live_apply.py@@ -124,13 +124,16 @@ async def test_verify_oww_hit_trusts_non_jarvis_model_without_stt() -> None:assert stt.calls == 0 # trusted the specific OWW model, no STT re-verify-async def test_verify_oww_hit_still_verifies_jarvis() -> None:+async def test_verify_oww_hit_still_rejects_bare_core_word() -> None:+ from jarvis.speech.wake_phrase import compile_wake_matcher+pipe = SpeechPipeline.__new__(SpeechPipeline)pipe._require_hey_prefix = True- stt = _FakeSTT("Jarvis") # bare jarvis -> must be rejected+ stt = _FakeSTT("Jarvis") # bare core word -> must be rejectedpipe._utterance_stt = sttpipe._wake_plan = SimpleNamespace(verify_prefix=True)- pipe._wake_matcher = None # None -> default jarvis pattern in verifier+ # The plan's own matcher drives the verify (no default pattern ships).+ pipe._wake_matcher = compile_wake_matcher("Hey Jarvis")assert await pipe._verify_oww_hit(b"\x00\x00" * 100) is Falseassert stt.calls == 1diff --git a/tests/unit/speech/test_wake_matcher_integration.py b/tests/unit/speech/test_wake_matcher_integration.pyindex 3497e86fc2..651a4d68f1 100644--- a/tests/unit/speech/test_wake_matcher_integration.py+++ b/tests/unit/speech/test_wake_matcher_integration.py@@ -1,16 +1,16 @@-"""The prefix verifier and the rolling-whisper backstop accept a custom-:class:`WakeMatcher`, and their jarvis defaults stay byte-identical.+"""The prefix verifier and the rolling-whisper backstop run on the wake+plan's :class:`WakeMatcher` — one matcher object drives both STT wake paths.-Guards the generalisation step of the custom-wake-word feature: making the two-STT-based wake paths phrase-aware without drifting from the canonical pattern-(BUG-008) or weakening the default jarvis behaviour (BUG-009).+Guards the generalisation of the custom-wake-word feature: both paths are+phrase-aware and share ONE matcher (BUG-008 no-drift), a prefixed phrase+still rejects its bare core word (BUG-009), and no default pattern exists —+the product ships no wake word (design 2026-07-07)."""from __future__ import annotationsfrom types import SimpleNamespace-from jarvis.speech import wake_constants-from jarvis.speech.rolling_whisper_wake import DEFAULT_PATTERN, RollingWhisperWake+from jarvis.speech.rolling_whisper_wake import RollingWhisperWakefrom jarvis.speech.wake_phrase import compile_wake_matcherfrom jarvis.speech.wake_verifier import (transcript_has_hey_prefix,@@ -18,13 +18,9 @@ from jarvis.speech.wake_verifier import ()# ---------------------------------------------------------------------------# Single source of truth: rolling-whisper re-exports the canonical pattern.+# One matcher drives both paths; there is no default pattern.# ---------------------------------------------------------------------------def test_rolling_default_pattern_is_the_canonical_pattern() -> None:- assert DEFAULT_PATTERN is wake_constants.JARVIS_WAKE_PATTERN--def test_rolling_whisper_accepts_a_custom_matcher() -> None:matcher = compile_wake_matcher("Computer")rw = RollingWhisperWake(stt=object(), pattern=matcher)@@ -32,12 +28,20 @@ def test_rolling_whisper_accepts_a_custom_matcher() -> None:# ---------------------------------------------------------------------------# Verifier default == jarvis; with a matcher == the custom phrase.+# Verifier: a matcher confirms its own phrase; no matcher fails OPEN.# ---------------------------------------------------------------------------def test_verifier_default_is_jarvis() -> None:- assert transcript_has_hey_prefix("hey jarvis") is True- assert transcript_has_hey_prefix("jarvis") is False+def test_verifier_with_jarvis_matcher_keeps_bug009_guard() -> None:+ matcher = compile_wake_matcher("Hey Jarvis")+ assert transcript_has_hey_prefix("hey jarvis", matcher=matcher) is True+ assert transcript_has_hey_prefix("jarvis", matcher=matcher) is False+++def test_verifier_without_matcher_fails_open() -> None:+ # A missing matcher is a wiring gap, not evidence against the wake:+ # suppressing here would silently brick the wake word.+ assert transcript_has_hey_prefix("anything at all") is True+ assert transcript_has_hey_prefix("") is False # empty transcript still rejectsdef test_verifier_with_custom_matcher_matches_phrase() -> None:@@ -67,8 +71,11 @@ async def test_verify_with_stt_honours_custom_matcher() -> None:assert "computer" in text.lower()-async def test_verify_with_stt_default_matcher_still_jarvis() -> None:- matched, _ = await verify_wake_with_stt(_FakeSTT("Jarvis"), b"\x00\x00" * 100)+async def test_verify_with_stt_jarvis_matcher_rejects_bare_word() -> None:+ matcher = compile_wake_matcher("Hey Jarvis")+ matched, _ = await verify_wake_with_stt(+ _FakeSTT("Jarvis"), b"\x00\x00" * 100, matcher=matcher+ )assert matched is Falsediff --git a/tests/unit/speech/test_wake_phrase.py b/tests/unit/speech/test_wake_phrase.pyindex 69ee9d7830..20855d5b36 100644--- a/tests/unit/speech/test_wake_phrase.py+++ b/tests/unit/speech/test_wake_phrase.py@@ -60,32 +60,33 @@ def test_matcher_has_search_returning_group_like_re_pattern() -> None:# ---------------------------------------------------------------------------# Default "Hey Jarvis" reproduces the strict legacy pattern+# "Hey Jarvis" is an ordinary phrase on the generic matcher (design 2026-07-07)# --------------------------------------------------------------------------@pytest.mark.parametrize("phrase", ["Hey Jarvis", "jarvis", "Jarvis", "hey jarvis"])-def test_jarvis_family_matches_strict_prefix_phrases(phrase: str) -> None:+def test_jarvis_phrase_matches_prefixed_transcripts(phrase: str) -> None:m = compile_wake_matcher(phrase)assert m.search("hey jarvis") is not Noneassert m.search("hi jarvis") is not Noneassert m.search("hallo jarvis") is not None[email protected]("phrase", ["Hey Jarvis", "jarvis"])-def test_jarvis_family_rejects_bare_word_and_hallucinations(phrase: str) -> None:- # BUG-009: bare "jarvis" without a hey/hi/hallo prefix must NOT trigger,- # and common Whisper hallucinations must not match.- m = compile_wake_matcher(phrase)+def test_prefixed_jarvis_phrase_rejects_bare_word_and_hallucinations() -> None:+ # BUG-009 on the GENERIC matcher: a phrase that carries a wake prefix+ # ("Hey Jarvis") must NOT fire on the bare core word in ordinary speech,+ # and common Whisper hallucinations must never match.+ m = compile_wake_matcher("Hey Jarvis")assert m.search("jarvis") is Noneassert m.search("Thank you") is Noneassert m.search("Vielen Dank") is None-def test_jarvis_matcher_is_backed_by_the_canonical_pattern() -> None:- # The jarvis family must delegate to the single-source pattern so it can- # never drift from rolling_whisper_wake.DEFAULT_PATTERN (BUG-008 territory).- m = compile_wake_matcher("Hey Jarvis")- assert m.is_jarvis_default is True+def test_single_word_jarvis_phrase_behaves_like_any_single_word() -> None:+ # A phrase WITHOUT a prefix is a one-word wake: the word itself fires+ # anywhere — identical to "Computer" (no special-cased word ships).+ m = compile_wake_matcher("jarvis")+ assert m.search("jarvis") is not None+ assert m.search("Thank you") is None# --------------------------------------------------------------------------diff --git a/tests/unit/speech/test_wake_phrase_phonetic.py b/tests/unit/speech/test_wake_phrase_phonetic.pyindex 4fc31c25aa..776ffa2916 100644--- a/tests/unit/speech/test_wake_phrase_phonetic.py+++ b/tests/unit/speech/test_wake_phrase_phonetic.py@@ -45,10 +45,10 @@ def test_double_letter_and_ph_folding() -> None:assert compile_wake_matcher("Sophie").search("Sofie") is not None # ph -> f-def test_jarvis_default_is_untouched_by_folding() -> None:- # The default jarvis phrase uses the strict legacy regex, not the fuzzy/folded- # path, so its exact behaviour is preserved.- m = compile_wake_matcher("Jarvis")+def test_prefixed_jarvis_phrase_keeps_bare_word_guard_under_folding() -> None:+ # "Hey Jarvis" runs the same fuzzy/folded path as every phrase (design+ # 2026-07-07). The prefix requirement keeps the bare core word silent.+ m = compile_wake_matcher("Hey Jarvis")assert m.search("hey jarvis") is not Noneassert m.search("jarvis") is None # bare jarvis still rejectedassert m.search("marco") is Nonediff --git a/tests/unit/speech/test_wake_prefix_gating.py b/tests/unit/speech/test_wake_prefix_gating.pyindex e72bf48597..961054ce53 100644--- a/tests/unit/speech/test_wake_prefix_gating.py+++ b/tests/unit/speech/test_wake_prefix_gating.py@@ -73,8 +73,13 @@ def _bare_pipeline(pipe._utterance_stt = utterance_sttif wake_plan is not None:pipe._wake_plan = wake_plan- if wake_matcher is not None:- pipe._wake_matcher = wake_matcher+ # No default pattern ships (design 2026-07-07): the gate always runs on+ # the wake plan's matcher — these tests use the "Hey Jarvis" phrase.+ from jarvis.speech.wake_phrase import compile_wake_matcher++ pipe._wake_matcher = (+ wake_matcher if wake_matcher is not None else compile_wake_matcher("Hey Jarvis")+ )return pipediff --git a/tests/unit/speech/test_wake_verifier.py b/tests/unit/speech/test_wake_verifier.pyindex b15be2f09c..62405fece7 100644--- a/tests/unit/speech/test_wake_verifier.py+++ b/tests/unit/speech/test_wake_verifier.py@@ -1,16 +1,17 @@-"""Wake-prefix verifier — gates OpenWakeWord hits behind a strict "hey + jarv"-transcript check.+"""Wake-phrase verifier — gates OpenWakeWord hits behind a transcript check+against the configured phrase's own matcher.-Background: the openWakeWord ``hey_jarvis_v0.1`` ONNX model fires on bare-"Jarvis" because the neural features overlap with the full "Hey Jarvis" phrase.+Background: a neural wake model fires on near-misses of its phrase+(historically a bare core word fired the full-phrase model — BUG-009).Lowering the threshold pendulums (BUG-009 — five episodes); raising it pastthe genuine-wake band suppresses real wakes. The clean fix is post-detection:when OWW fires, transcribe the last ~2 s of audio with the cloud STT already-configured for utterance turns and require the strict pattern from-``rolling_whisper_wake.DEFAULT_PATTERN``.+configured for utterance turns and require the wake plan's matcher to confirm+it. There is no default pattern (the product ships no wake word, design+2026-07-07); calling without a matcher fails OPEN.-These tests pin the contract for the pure regex helper and the STT-driven-verification path.+These tests pin the contract for the pure helper and the STT-driven+verification path, using the generic matcher for the phrase "Hey Jarvis"."""from __future__ import annotations@@ -20,6 +21,7 @@ from dataclasses import dataclassimport pytest+from jarvis.speech.wake_phrase import compile_wake_matcherfrom jarvis.speech.wake_verifier import (CUSTOM_WAKE_MIN_RMS,pcm_tail_rms,@@ -27,8 +29,11 @@ from jarvis.speech.wake_verifier import (verify_wake_with_stt,)+# The generic matcher for the phrase used throughout this module.+_JARVIS = compile_wake_matcher("Hey Jarvis")+# ----------------------------------------------------------------------------# Pure regex helper+# Pure transcript helper# ---------------------------------------------------------------------------@@ -43,13 +48,13 @@ from jarvis.speech.wake_verifier import ("hey jarvis was machst du","hallo jarvis kannst du","HEY JARVIS",- # The Whisper backstop also accepts the German-mishear variants.- "Hey Charvis",- "Hallo Tscharvis",+ # One character of ASR drift on the core still matches (sound-folded+ # fuzzy core with a length-aware bar).+ "Hey Jarwis",],)def test_transcripts_with_hey_prefix_match(text: str) -> None:- assert transcript_has_hey_prefix(text) is True+ assert transcript_has_hey_prefix(text, matcher=_JARVIS) is True@pytest.mark.parametrize(@@ -71,10 +76,21 @@ def test_transcripts_with_hey_prefix_match(text: str) -> None:# "Hey" alone, no Jarvis stem."Hey du","Hi there",+ # Far German mishears were only covered by the retired jarvis-family+ # regex; the generic fuzzy matcher bounds tolerance to ~one character+ # of drift (design 2026-07-07 — no special-cased word ships).+ "Hey Charvis",+ "Hallo Tscharvis",],)def test_transcripts_without_hey_prefix_do_not_match(text: str) -> None:- assert transcript_has_hey_prefix(text) is False+ assert transcript_has_hey_prefix(text, matcher=_JARVIS) is False+++def test_no_matcher_fails_open_never_bricks_the_wake() -> None:+ # A missing matcher is a wiring gap, not evidence against the wake.+ assert transcript_has_hey_prefix("anything", matcher=None) is True+ assert transcript_has_hey_prefix("", matcher=None) is False# ---------------------------------------------------------------------------@@ -114,7 +130,7 @@ PCM_2S_16K = b"\x00\x00" * 16_000 * 2 # 2 s int16 silenceasync def test_verify_returns_true_when_transcript_has_hey_prefix() -> None:stt = _FakeSTT("Hey Jarvis, was läuft") # i18n-allow- matched, transcript = await verify_wake_with_stt(stt, PCM_2S_16K)+ matched, transcript = await verify_wake_with_stt(stt, PCM_2S_16K, matcher=_JARVIS)assert matched is Trueassert transcript == "Hey Jarvis, was läuft" # i18n-allow@@ -124,7 +140,7 @@ async def test_verify_returns_true_when_transcript_has_hey_prefix() -> None:async def test_verify_returns_false_when_transcript_is_bare_jarvis() -> None:stt = _FakeSTT("Jarvis")- matched, transcript = await verify_wake_with_stt(stt, PCM_2S_16K)+ matched, transcript = await verify_wake_with_stt(stt, PCM_2S_16K, matcher=_JARVIS)assert matched is Falseassert transcript == "Jarvis"@@ -133,7 +149,7 @@ async def test_verify_returns_false_when_transcript_is_bare_jarvis() -> None:async def test_verify_returns_false_when_transcript_is_empty() -> None:stt = _FakeSTT("")- matched, transcript = await verify_wake_with_stt(stt, PCM_2S_16K)+ matched, transcript = await verify_wake_with_stt(stt, PCM_2S_16K, matcher=_JARVIS)assert matched is False# A SUCCESSFUL transcription that heard nothing is "", never None — the@@ -146,7 +162,7 @@ async def test_verify_returns_false_when_pcm_is_empty() -> None:"""No audio captured yet — must not call STT, must not match."""stt = _FakeSTT("Hey Jarvis") # would match if called- matched, _ = await verify_wake_with_stt(stt, b"")+ matched, _ = await verify_wake_with_stt(stt, b"", matcher=_JARVIS)assert matched is Falseassert stt.calls == [], "STT must not be called with empty PCM"@@ -159,7 +175,7 @@ async def test_verify_returns_false_on_persistent_stt_exception() -> None:OWW hit so the loop re-arms."""stt = _FakeSTT("ignored", raises=RuntimeError("groq 503"))- matched, transcript = await verify_wake_with_stt(stt, PCM_2S_16K)+ matched, transcript = await verify_wake_with_stt(stt, PCM_2S_16K, matcher=_JARVIS)assert matched is False# An STT OUTAGE reports transcript=None (not "") so the caller can degrade@@ -196,7 +212,7 @@ async def test_verify_retries_transient_error_then_succeeds(monkeypatch) -> Nonemonkeypatch.setattr(wv, "_WAKE_VERIFY_BACKOFF_S", 0.0, raising=False)stt = _FlakySTT("Hey Jarvis, was läuft", fail_times=1) # i18n-allow- matched, transcript = await verify_wake_with_stt(stt, PCM_2S_16K)+ matched, transcript = await verify_wake_with_stt(stt, PCM_2S_16K, matcher=_JARVIS)assert matched is Trueassert transcript == "Hey Jarvis, was läuft" # i18n-allow@@ -206,7 +222,7 @@ async def test_verify_retries_transient_error_then_succeeds(monkeypatch) -> Noneasync def test_verify_passes_through_language_override() -> None:stt = _FakeSTT("Hey Jarvis")- await verify_wake_with_stt(stt, PCM_2S_16K, language="en")+ await verify_wake_with_stt(stt, PCM_2S_16K, language="en", matcher=_JARVIS)assert stt.calls == [(len(PCM_2S_16K), 16_000, "en")]@@ -283,7 +299,7 @@ async def test_verify_caps_a_hung_stt_call(monkeypatch) -> None:stt = _HangingSTT(hang_s=1.0)t0 = time.monotonic()- matched, _ = await verify_wake_with_stt(stt, PCM_2S_16K)+ matched, _ = await verify_wake_with_stt(stt, PCM_2S_16K, matcher=_JARVIS)elapsed = time.monotonic() - t0assert matched is False, "a capped (hung) verify must fail closed, not match"