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
fix(wake): the lock proxy hid SetGrammar, so the acoustic competition confirmed stray words (BUG-163)
rubenluetke10-beep0b3ec4d6cf78
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex d1ac765595..4aacc936fc 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -17,6 +17,11 @@ versioning per [SemVer](https://semver.org/).dictation waited several seconds for its text. Windows are now read whileyou are still speaking, and whatever is left at release is read side by sideon providers that allow it; a local engine still takes one call at a time.+- **The wake word no longer fires on a stray single word.** Since the 20 Aug+ crash fix, the check that decides between "Hey George" and whatever was+ actually said had quietly lost its strongest comparison, so a lone word like+ "power" or "Pedro" could open a voice session by itself. The comparison is+ back, and the app now says so in the log if it ever has to run without it.## [1.5.3] — 2026-08-22diff --git a/docs/BUGS.md b/docs/BUGS.mdindex abec2d7f58..0d51dc72be 100644--- a/docs/BUGS.md+++ b/docs/BUGS.md@@ -11454,3 +11454,64 @@ is currently invisible; the dictation lane runs a local preview decode everyalso remains a density heuristic: it cannot catch a truncation that drops onlya short final clause, because no token count distinguishes that from ordinaryspeech. A recognizer offering word timestamps would settle it directly.++## BUG-163: the wake word fires on a single unrelated word ('power', 'pedro', 'hey nova') — the BUG-151 lock proxy hid `SetGrammar`, so the acoustic competition silently ran on its static grammar (HIGH, FIXED 2026-08-22)++**Symptom.** Live 2026-08-22 17:10:52 (`data/jarvis_desktop.log`): with no+key pressed and no dictation running, the Jarvis Bar opened a Gemini Live+voice session on its own; the user hung it up ten seconds later with zero+turns and reported "it kept running after I let go of my key". The log line+behind it: `vosk-kws: verify OK (wake) — free ear heard 'power' at the+candidate span (conf=1.00) vs phrase 'Hey George'` — a ONE-word utterance+confirmed as a two-word wake phrase, fired from the early (partial)+candidate check on the `de` model. `scripts/vosk_wake_bench.py --phrase+"Hey George"` at HEAD reproduced it wholesale: 16/16 positives fired, but+13 of 40 negatives fired too — `neg_random` 4/12 ('pedro', 'peter',+'petra'), `neg_other_name` 6/12 ('hey nova', 'hallo florian'), `neg_flow`+3/8 — every one via the `de` model, every one "verify OK (wake|undecided)",+i.e. accepted by the acoustic competition. The 2026-08-12 calibration of+exactly that competition had measured these classes at 0.++**Cause.** The competition (`_shape_competition_ok`) installs its+per-candidate alternatives — the phrase, `"<prefix> [unk]"`, the free+ear's OWN hypothesis for the span, `"[unk]"` — with `SetGrammar`, which it+PROBES (`getattr(rec, "SetGrammar", None)`) because vosk builds before+0.3.32 lack it; without it the prewarmed recognizer keeps its static+grammar (phrase vs `"<prefix> [unk]"` vs `"[unk]"`), "a weaker but valid+competition". BUG-151 (2026-08-20) wrapped every native recognizer in+`vosk_native.LockedRecognizer`, a proxy that listed only the methods the+provider calls unconditionally — `AcceptWaveform`, `PartialResult`,+`Result`, `FinalResult`, `Reset`, `SetWords`. `SetGrammar` was not on the+list, so the probe answered "absent" on EVERY build and the competition+degraded to the static grammar everywhere, with no log line to tell the+two apart. Against phrase-vs-`[unk]` alone, a short isolated word that the+forced grammar had already stretched onto the phrase wins the phrase back+at conf ≥ 0.9; with the free hypothesis ('power', 'pedro') in the grammar+the decoder keeps the hypothesis and the candidate is rejected. The unit+test that pins the alternatives+(`test_the_competition_judges_span_trimmed_audio_with_the_hypothesis`)+passed throughout because it hands the provider a bare stub that is never+wrapped — the live path goes through the proxy.++**Fix (2026-08-22).** `LockedRecognizer` exposes `SetGrammar` explicitly+and proxies every OTHER native method through a `__getattr__` backstop+(locked, and answering a `getattr(..., None)` probe exactly like the+wrapped recognizer would), so no optional method can fall off the proxy+again. `_shape_competition_ok` logs ONE WARNING per provider when a+recognizer really has no `SetGrammar` — the static-grammar degrade is a+measurably weaker judge and must never be silent again. Tests:+`test_locked_recognizer_proxies_set_grammar_under_the_lock`,+`test_locked_recognizer_reaches_every_native_method_locked`,+`test_locked_recognizer_reports_a_missing_optional_method_honestly`+(`tests/unit/plugins/wake/test_vosk_native.py`);+`test_the_competition_installs_its_alternatives_through_the_native_lock`+(the live path: a vosk-named recognizer THROUGH `wrap_recognizer`) and+`test_a_competition_without_set_grammar_says_so_once`+(`test_vosk_wake_word_agnostic.py`). Bench after the fix, same corpus:+16/16 positives, 0/40 negatives.++**Lesson (AP-24/BUG-151 family).** A proxy around a native engine must be+TRANSPARENT — expose the wrapped object's whole surface, not the subset one+call site uses today — and any "optional capability" probe in the code+base (`getattr(x, "Method", None)`) is a place where a wrapper can lie+silently. When such a probe selects a weaker path, that path logs.diff --git a/jarvis/plugins/wake/vosk_kws_provider.py b/jarvis/plugins/wake/vosk_kws_provider.pyindex 361709dbf9..8220af39f3 100644--- a/jarvis/plugins/wake/vosk_kws_provider.py+++ b/jarvis/plugins/wake/vosk_kws_provider.py@@ -816,6 +816,9 @@ class VoskKwsProvider:self._competition_grammar = json.dumps([self._phrase.lower(), f"{raw_tokens[0]} [unk]", "[unk]"])+ # One-shot flag for the "competition degraded to its static grammar"+ # warning in ``_shape_competition_ok`` (BUG-163).+ self._warned_static_competition = Falseself._match_min_rms = float(match_min_rms)self._cooldown_s = float(cooldown_s)self._rejected_candidate_backoff_s = max(@@ -1813,6 +1816,19 @@ class VoskKwsProvider:set_grammar = getattr(rec, "SetGrammar", None)if callable(set_grammar):set_grammar(json.dumps(alternatives))+ elif not getattr(self, "_warned_static_competition", False):+ # Say so ONCE, at WARNING. The static grammar is a measurably+ # weaker judge (bench 2026-08-22: 13 false fires on 40+ # negatives vs 0 with the per-candidate alternatives), and+ # the degrade used to be invisible — BUG-163 ran for two days+ # behind a proxy that hid ``SetGrammar`` without a single+ # log line telling it apart from the real competition.+ self._warned_static_competition = True+ log.warning(+ "vosk-kws: this recognizer offers no SetGrammar — the "+ "acoustic competition runs on its static grammar only "+ "(weaker precision; vosk >= 0.3.32 restores it)."+ )rec.AcceptWaveform(pcm)res = json.loads(rec.FinalResult())if self._phrase.lower() not in res.get("text", ""):diff --git a/jarvis/plugins/wake/vosk_native.py b/jarvis/plugins/wake/vosk_native.pyindex 78fc43f4f2..b012f565e7 100644--- a/jarvis/plugins/wake/vosk_native.py+++ b/jarvis/plugins/wake/vosk_native.py@@ -64,6 +64,43 @@ class LockedRecognizer:with _LOCK:return self._rec.SetWords(flag)+ def SetGrammar(self, grammar: Any) -> Any: # noqa: N802 — vosk API+ # BUG-163: the first version of this proxy listed only the methods the+ # provider calls UNCONDITIONALLY. ``SetGrammar`` is probed with+ # ``getattr(rec, "SetGrammar", None)`` (older vosk builds lack it), so+ # leaving it off this class silently downgraded the acoustic+ # competition to its static grammar on every build — the free ear's+ # own hypothesis never joined the alternatives again, and bare words+ # ('power', 'pedro', 'hey nova') won the wake. The proxy must expose+ # every method the wrapped recognizer has, hence ``__getattr__`` below+ # as the backstop; this explicit method exists so the one the+ # precision rests on can never fall through to it by accident.+ with _LOCK:+ return self._rec.SetGrammar(grammar)++ def __getattr__(self, name: str) -> Any:+ """Every OTHER native method stays reachable — and locked.++ ``getattr(rec, "SomeMethod", None)`` on the proxy must answer exactly+ as it would on the wrapped recognizer: present on builds that have it,+ absent otherwise. A callable is returned behind the same process-wide+ lock every listed method holds; a plain attribute passes through.+ (``__getattr__`` only runs for names this class does not define, so+ the explicit methods above are unaffected and ``_rec`` itself never+ recurses.)+ """+ if name == "_rec": # guard against half-initialised proxies+ raise AttributeError(name)+ target = getattr(self._rec, name)+ if not callable(target):+ return target++ def _locked(*args: Any, **kwargs: Any) -> Any:+ with _LOCK:+ return target(*args, **kwargs)++ return _locked+def wrap_recognizer(rec: Any) -> Any:"""Lock a native recognizer; leave test doubles untouched."""diff --git a/tests/unit/plugins/wake/test_vosk_native.py b/tests/unit/plugins/wake/test_vosk_native.pyindex aad7604d38..3c86875f84 100644--- a/tests/unit/plugins/wake/test_vosk_native.py+++ b/tests/unit/plugins/wake/test_vosk_native.py@@ -105,3 +105,59 @@ def test_build_recognizer_uses_the_patched_vosk_factory(monkeypatch) -> None:assert rec is built[0]assert rec.words is Trueassert rec.grammar == '["hey nova","[unk]"]'+++class _GrammarRec(_Contended):+ """A recognizer that also carries the optional ``SetGrammar``."""++ def __init__(self) -> None:+ super().__init__()+ self.grammars: list[str] = []++ def SetGrammar(self, grammar: str) -> None: # noqa: N802+ self._enter()+ self.grammars.append(grammar)+++def test_locked_recognizer_proxies_set_grammar_under_the_lock() -> None:+ """BUG-163: the proxy hid ``SetGrammar`` and the competition never saw+ the free ear's hypothesis again — 'power' won the wake for 'Hey George'.+ The provider PROBES the method (``getattr(rec, "SetGrammar", None)``), so+ the proxy must answer that probe exactly like the wrapped recognizer."""+ inner = _GrammarRec()+ rec = LockedRecognizer(inner)+ set_grammar = getattr(rec, "SetGrammar", None)+ assert callable(set_grammar)+ set_grammar('["hey george", "power", "[unk]"]')+ assert inner.grammars == ['["hey george", "power", "[unk]"]']+++def test_locked_recognizer_reaches_every_native_method_locked() -> None:+ """Any method the proxy does not list explicitly is still reachable, and+ still serialised — a future optional method cannot fall off the proxy."""+ inner = _GrammarRec()+ rec = LockedRecognizer(inner)+ errors: list[BaseException] = []++ def _feed() -> None:+ try:+ rec.SetGrammar("[]")+ rec.AcceptWaveform(b"\x00\x00")+ except BaseException as exc: # noqa: BLE001 — collect for the assertion+ errors.append(exc)++ threads = [threading.Thread(target=_feed) for _ in range(4)]+ for thread in threads:+ thread.start()+ for thread in threads:+ thread.join(timeout=2.0)+ assert not thread.is_alive()+ assert errors == []+ assert inner.overlaps == 0+++def test_locked_recognizer_reports_a_missing_optional_method_honestly() -> None:+ """An older vosk build without ``SetGrammar`` must still read as absent+ through the proxy — the provider's static-grammar degrade depends on it."""+ rec = LockedRecognizer(_Contended())+ assert getattr(rec, "SetMaxAlternatives", None) is Nonediff --git a/tests/unit/plugins/wake/test_vosk_wake_word_agnostic.py b/tests/unit/plugins/wake/test_vosk_wake_word_agnostic.pyindex f42856c525..1f8523f0b5 100644--- a/tests/unit/plugins/wake/test_vosk_wake_word_agnostic.py+++ b/tests/unit/plugins/wake/test_vosk_wake_word_agnostic.py@@ -970,3 +970,66 @@ def test_suppression_logging_never_feeds_a_decision() -> None:[_w("hey", 0.40, 0.62, conf=0.9), _w("erhoben", 0.62, 1.05, conf=0.6)],"Hey Ruben",) is True+++def test_the_competition_installs_its_alternatives_through_the_native_lock(+ monkeypatch,+) -> None:+ """BUG-163 (live 2026-08-22 17:10): the wake fired on the single word+ 'power'. Since BUG-151 every native recognizer is wrapped in+ ``LockedRecognizer``; that proxy did not expose ``SetGrammar``, so the+ competition's per-candidate alternatives (phrase, "<prefix> [unk]", the+ free ear's OWN hypothesis, "[unk]") were never installed and the static+ grammar — phrase against "[unk]" only — confirmed bare words. Bench+ 2026-08-22: 13 false fires on 40 negatives before, 0 after. This pins+ the path the live engine takes: through the wrapper, not a bare stub.+ """+ from jarvis.plugins.wake.vosk_native import wrap_recognizer++ p = VoskKwsProvider("Hey George", model_path="fake", keyword="george")+ free = {"text": "power", "result": [_w("power", 1.60, 2.10, conf=0.9)]}+ seen: dict = {}++ class KaldiRecognizer(_StubRec): # the wrapper keys on this name/module+ def SetGrammar(self, grammar: str) -> None: # noqa: N802 - vosk API+ seen["alternatives"] = json.loads(grammar)++ def FinalResult(self) -> str: # noqa: N802 - vosk API+ # Once the alternatives are installed the decoder keeps the+ # free hypothesis for 'power' audio; without them it would have+ # been forced to pick the phrase.+ if "alternatives" in seen:+ return json.dumps({"text": "power", "result": []})+ return json.dumps(_GEORGE_GRAMMAR)++ KaldiRecognizer.__module__ = "vosk"++ def _take(model_path, kind): # noqa: ANN001+ if kind == "competition":+ return wrap_recognizer(KaldiRecognizer({}))+ return _StubRec(_GEORGE_GRAMMAR if kind == "grammar" else free)++ monkeypatch.setattr(p, "_take_verify_rec", _take)+ assert p._verify_window(_loud_window(3.0), fail_open=True) is False+ assert seen["alternatives"] == ["hey george", "hey [unk]", "power", "[unk]"]+++def test_a_competition_without_set_grammar_says_so_once(monkeypatch, caplog) -> None:+ """The static-grammar degrade is a measurably weaker judge; it must be+ visible in the log exactly once per provider, never silent (BUG-163)."""+ import logging++ p = VoskKwsProvider("Hey George", model_path="fake", keyword="george")+ free = {"text": "pedro", "result": [_w("pedro", 1.60, 2.10, conf=0.9)]}+ monkeypatch.setattr(+ p,+ "_take_verify_rec",+ _stub_take(+ _GEORGE_GRAMMAR, free, competition={"text": "pedro", "result": []}+ ),+ )+ with caplog.at_level(logging.WARNING, logger="jarvis.wake.vosk"):+ p._verify_window(_loud_window(3.0), fail_open=True)+ p._verify_window(_loud_window(3.0), fail_open=True)+ hits = [r for r in caplog.records if "no SetGrammar" in r.getMessage()]+ assert len(hits) == 1