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): hard leading-isolation gate - a wake call stands alone
rubenluetke10-beep43077c263f89
diff --git a/jarvis/plugins/wake/vosk_kws_provider.py b/jarvis/plugins/wake/vosk_kws_provider.pyindex afc91b08c5..4756f2a677 100644--- a/jarvis/plugins/wake/vosk_kws_provider.py+++ b/jarvis/plugins/wake/vosk_kws_provider.py@@ -263,6 +263,33 @@ SHAPE_WAKE = "wake" # looks like a call — competition confirms as bSHAPE_UNDECIDED = "undecided" # tokenisation/confidence contradicts — competition decidesSHAPE_SPEECH = "speech" # too much sound, or no name-sized body: never a wake+# --- leading isolation: a wake call STANDS ALONE (live forensic 2026-08-10) --+# Three fires in 94 s while the user dictated German to a coding agent+# (19:57:53 'herr tracks' undecided, 19:58:34 'hey george' SPELLED by the en+# model out of German flow, 19:59:27 'aufbürdet' undecided; i18n-allow:+# recognition content quoted from the live log). Two leaked through+# the acoustic competition — which measurably does not discriminate mid-stream+# audio (the forced grammar happily keeps the phrase at conf 1.0 inside flowing+# speech) — and one through the spelling path itself, so no per-path tightening+# can close the class.+#+# What every genuine call has and every one of these fires lacks is word-+# agnostic and durational (AP-27-safe): a wake call stands alone, with silence+# immediately BEFORE it, while a forced hit on conversation has the previous+# word ending at the phrase's doorstep. Mid-speech no-fire is the ACCEPTED+# product trade-off (the maintainer explicitly chose it over mid-speech+# recall), so lead-in speech is a HARD rejection for BOTH confirm paths.+# Only the LEADING side is gated — trailing speech is the legitimate+# wake+command breath (2026-07-25) and stays untouched.+#+# Bounds: voiced overlap of strictly-preceding free-decode words with the+# ``_ISOLATION_LEAD_S`` window before the span may not exceed+# ``_ISOLATION_MAX_LEAD_VOICED_S`` (a syllable of slack for breath sounds and+# decoder timing jitter). Combined with the span's own 0.3 s guard this asks+# for ~0.65 s of quiet before the phrase — a natural pause, not a staged one.+_ISOLATION_LEAD_S = 0.6+_ISOLATION_MAX_LEAD_VOICED_S = 0.25+# --- acoustic competition for the SHAPE path (live forensic 2026-07-17) -----# The shape gate accepts anything that LOOKS like a wake call — which a call of# a DIFFERENT name also does. Live: "hey nova" confirmed (shape) for the phrase@@ -678,6 +705,7 @@ class VoskKwsProvider:self._stat_early_shown = 0self._stat_early_retracted = 0self._stat_suppressed_shape_competition = 0+ self._stat_suppressed_lead_speech = 0# Rate limiter for the verify-suppression log. Every rejection used to# be DEBUG-only, so a dropped GENUINE wake left no production trace at# all: the log could not tell "never heard" from "heard, verified,@@ -914,6 +942,7 @@ class VoskKwsProvider:"suppressed_shape_competition": (self._stat_suppressed_shape_competition),+ "suppressed_lead_speech": self._stat_suppressed_lead_speech,}# -- early candidate (visual-only) ----------------------------------------@@ -1205,6 +1234,33 @@ class VoskKwsProvider:if w.get("end", 0.0) >= span_a and w.get("start", 0.0) <= span_b]free_local = " ".join(w.get("word", "") for w in local_words)++ # 4) leading isolation — a wake call STANDS ALONE (see the+ # _ISOLATION_* note). Voiced duration of strictly-preceding free+ # words inside the lead window; a HARD rejection for both confirm+ # paths, ahead of spelling and shape alike, because the spelled+ # path leaked too (live 2026-08-10: the en model spelled+ # 'hey george' out of flowing German dictation). Reads only word+ # TIMINGS, never text (AP-27).+ lead_a = span_a - _ISOLATION_LEAD_S+ lead_voiced = 0.0+ for w in fres.get("result", []):+ if float(w.get("end", 0.0)) >= span_a:+ continue # candidate-adjacent or later: not lead-in+ lead_voiced += max(+ 0.0,+ min(float(w.get("end", 0.0)), span_a)+ - max(float(w.get("start", 0.0)), lead_a),+ )+ if lead_voiced > _ISOLATION_MAX_LEAD_VOICED_S:+ self._stat_suppressed_lead_speech += 1+ self._log_suppression(+ "lead-in speech %.2fs in the %.1fs before the span — "+ "a wake call stands alone, this was mid-speech",+ lead_voiced,+ _ISOLATION_LEAD_S,+ )+ return False# OPEN (2026-07-25, measured): a wake spoken in ONE breath with the# command is materially less likely to fire than an isolated call.# A command word starting inside the trailing 0.3 s slack is counteddiff --git a/tests/unit/plugins/wake/test_vosk_wake_word_agnostic.py b/tests/unit/plugins/wake/test_vosk_wake_word_agnostic.pyindex 704116f277..ded303640e 100644--- a/tests/unit/plugins/wake/test_vosk_wake_word_agnostic.py+++ b/tests/unit/plugins/wake/test_vosk_wake_word_agnostic.py@@ -586,6 +586,119 @@ def test_a_contested_shape_that_loses_the_competition_does_not_fire(assert p.stats()["suppressed_shape_competition"] == 1+# --- a wake call STANDS ALONE (live forensic 2026-08-10) ---------------------+#+# Three fires in 94 s while the user dictated German to a coding agent: the+# grammar forced flowing speech onto 'Hey George' and the verify let it+# through — twice via the acoustic competition, with unrelated German words+# ('herr tracks', 'aufbürdet' — i18n-allow: live-log recognition content)+# at the span, both conf 1.0), once via the SPELLING path itself (the en+# model heard a literal 'hey george' inside German flow). What every genuine+# call has and all three fires lack: silence immediately BEFORE the phrase.+# Mid-speech no-fire is the accepted product trade-off, so lead-in speech is+# a hard rejection for BOTH confirm paths — word-agnostic (timings only).+++_GEORGE_LEAD_IN = [+ # Flowing dictation right up to the phrase's doorstep. i18n-allow:+ # recognition content under test.+ _w("und", 0.30, 0.45, conf=1.0),+ _w("dann", 0.45, 0.70, conf=1.0),+ _w("machen", 0.70, 1.05, conf=1.0),+ _w("wir", 1.05, 1.18, conf=1.0),+]+_GEORGE_GRAMMAR = {+ "text": "hey george",+ "result": [+ {"word": "hey", "start": 1.50, "end": 1.72, "conf": 1.0},+ {"word": "george", "start": 1.72, "end": 2.15, "conf": 1.0},+ ],+}+++def test_a_mid_speech_shape_fire_is_rejected_by_lead_in_speech(monkeypatch) -> None:+ """LIVE (2026-08-10 19:59:27): free ear 'aufbürdet' (i18n-allow:+ recognition content quoted from the live log), shape UNDECIDED, the+ competition kept the phrase at conf 1.0 mid-stream — and it fired."""+ p = VoskKwsProvider("Hey George", model_path="fake", keyword="george")+ free = {+ "text": "und dann machen wir aufbürdet", # i18n-allow: recognition content under test+ "result": [*_GEORGE_LEAD_IN, _w("aufbürdet", 1.45, 2.20, conf=1.0)], # i18n-allow+ }++ monkeypatch.setattr(p, "_take_verify_rec", _stub_take(_GEORGE_GRAMMAR, free))+ assert p._verify_window(_loud_window(3.0), fail_open=True) is False+ assert p.stats()["suppressed_lead_speech"] == 1+++def test_a_mid_speech_spelled_phrase_is_rejected_by_lead_in_speech(+ monkeypatch,+) -> None:+ """LIVE (2026-08-10 19:58:34): the en free ear SPELLED 'hey george' out of+ flowing German — the accept-only spelling path cannot be the way around+ the isolation rule, or mentioning the wake word mid-sentence fires."""+ p = VoskKwsProvider("Hey George", model_path="fake", keyword="george")+ free = {+ "text": "und dann machen wir hey george", # i18n-allow: recognition content under test+ "result": [+ *_GEORGE_LEAD_IN,+ _w("hey", 1.50, 1.72, conf=1.0),+ _w("george", 1.72, 2.15, conf=1.0),+ ],+ }++ monkeypatch.setattr(p, "_take_verify_rec", _stub_take(_GEORGE_GRAMMAR, free))+ assert p._verify_window(_loud_window(3.0), fail_open=True) is False+++def test_an_isolated_call_still_fires_with_nothing_before_it(monkeypatch) -> None:+ """The genuine quiet-room call is untouched: no lead-in words at all."""+ p = VoskKwsProvider("Hey George", model_path="fake", keyword="george")+ free = {+ "text": "gorsch",+ "result": [_w("gorsch", 1.50, 2.15, conf=0.6)],+ }++ monkeypatch.setattr(p, "_take_verify_rec", _stub_take(_GEORGE_GRAMMAR, free))+ assert p._verify_window(_loud_window(3.0), fail_open=True) is True+ assert p.stats()["suppressed_lead_speech"] == 0+++def test_a_call_after_a_natural_pause_still_fires(monkeypatch) -> None:+ """~0.75 s of quiet before the phrase is a natural pause, not a staged one+ — earlier speech beyond the lead window must not eat the wake."""+ p = VoskKwsProvider("Hey George", model_path="fake", keyword="george")+ free = {+ "text": "fertig gorsch", # i18n-allow: recognition content under test+ "result": [+ # ends 0.75 s before the phrase — a natural pause+ _w("fertig", 0.30, 0.75, conf=1.0), # i18n-allow+ _w("gorsch", 1.50, 2.15, conf=0.6),+ ],+ }++ monkeypatch.setattr(p, "_take_verify_rec", _stub_take(_GEORGE_GRAMMAR, free))+ assert p._verify_window(_loud_window(3.0), fail_open=True) is True+++def test_trailing_command_speech_is_never_lead_in(monkeypatch) -> None:+ """Only the LEADING side is gated: the wake+command breath (2026-07-25)+ has all its extra words AFTER the phrase and keeps firing."""+ p = VoskKwsProvider("Hey George", model_path="fake", keyword="george")+ free = {+ "text": "gorsch wie ist das wetter", # i18n-allow: recognition content under test+ "result": [+ _w("gorsch", 1.50, 2.15, conf=0.6),+ _w("wie", 2.55, 2.70, conf=1.0),+ _w("ist", 2.70, 2.82, conf=1.0),+ _w("das", 2.82, 2.95, conf=1.0),+ ],+ }++ monkeypatch.setattr(p, "_take_verify_rec", _stub_take(_GEORGE_GRAMMAR, free))+ assert p._verify_window(_loud_window(3.0), fail_open=True) is True++# --- diagnosability: a suppressed wake must leave a trace (2026-07-25) --------