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(wake): make a suppressed wake visible and stop the heartbeat crying DEAD

Ruben Lütke4ef25705a4db
diff --git a/jarvis/plugins/wake/vosk_kws_provider.py b/jarvis/plugins/wake/vosk_kws_provider.py
index 339fefbafc..439f2d8357 100644
--- a/jarvis/plugins/wake/vosk_kws_provider.py
+++ b/jarvis/plugins/wake/vosk_kws_provider.py
@@ -613,6 +613,13 @@ class VoskKwsProvider:
self._stat_early_shown = 0
self._stat_early_retracted = 0
self._stat_suppressed_shape_competition = 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,
+ # rejected at conf 0.88". Surfacing the first few and then every Nth
+ # keeps that diagnosable without turning a candidate storm into a log
+ # flood (same shape as the existing backpressure warning).
+ self._suppress_log_count = 0
# -- lifecycle -----------------------------------------------------------
@@ -939,6 +946,22 @@ class VoskKwsProvider:
return (False, 1.0) # partials carry no conf; the confirm decides
return None
+ def _log_suppression(self, reason: str, *args: Any) -> None:
+ """Report a verify rejection at INFO for the first few, then every 20th.
+
+ A suppressed candidate is the ONLY evidence that distinguishes a wake
+ that was never heard from one that was heard and thrown away — the
+ difference a "sometimes it does not react" report turns on. Diagnostics
+ only: never reads back into a decision, and never logs transcript TEXT
+ beyond what the caller already passes.
+ """
+ self._suppress_log_count += 1
+ n = self._suppress_log_count
+ if n <= 5 or n % 20 == 0:
+ log.info("vosk-kws: verify SUPPRESSED (#%d) — " + reason, n, *args)
+ else:
+ log.debug("vosk-kws: verify SUPPRESSED — " + reason, *args)
+
def _grammar_hit_all(
self, recs: dict[str, Any], pcm: bytes
) -> tuple[bool, float, str] | None:
@@ -1079,17 +1102,16 @@ class VoskKwsProvider:
if w.get("word") in self._grammar_words
]
if self._phrase.lower() not in gres.get("text", "") or not gwords:
- log.debug(
- "vosk-kws: verify SUPPRESSED — re-score did not re-hear "
- "%r (heard %r)",
+ self._log_suppression(
+ "re-score did not re-hear %r (heard %r)",
self._phrase, gres.get("text", "")[:60],
)
return False
conf = min(w.get("conf", 0.0) for w in gwords)
if conf < self._min_final_conf:
- log.debug(
- "vosk-kws: verify SUPPRESSED — re-score conf %.2f < %.2f "
- "for %r", conf, self._min_final_conf, self._phrase,
+ self._log_suppression(
+ "re-score conf %.2f < %.2f for %r",
+ conf, self._min_final_conf, self._phrase,
)
return False
start_s = min(w.get("start", 0.0) for w in gwords)
@@ -1104,9 +1126,9 @@ class VoskKwsProvider:
rms = float(np.sqrt(np.mean(segment * segment) + 1e-12)) if len(segment) else 0.0
if rms < self._match_min_rms:
self._stat_gated_rms += 1
- log.debug(
- "vosk-kws: verify SUPPRESSED — span rms %.4f < %.4f "
- "(silence can never fire)", rms, self._match_min_rms,
+ self._log_suppression(
+ "span rms %.4f < %.4f (silence can never fire)",
+ rms, self._match_min_rms,
)
return False
diff --git a/jarvis/speech/pipeline.py b/jarvis/speech/pipeline.py
index c5942b643a..535183948e 100644
--- a/jarvis/speech/pipeline.py
+++ b/jarvis/speech/pipeline.py
@@ -5498,18 +5498,52 @@ class SpeechPipeline:
Missing output while the watchdog is running exposes a silently
failed task, such as a queue deadlock or swallowed exception.
"""
+ def _detector_state(task: asyncio.Task[Any] | None) -> str:
+ """alive / parked / FAILED / off.
+
+ ``DEAD`` used to cover all of "stopped normally",
+ "cancelled" and "raised", so the log screamed DEAD for the
+ ENTIRELY NORMAL case of a detector parked while a voice
+ session owns the microphone — verified against the desktop
+ logs, where every DEAD window coincides with an active
+ session and recovers when it ends. That cost a forensic
+ detour: a healthy state that reads as a crash is worse than
+ no signal at all.
+ """
+ if task is None:
+ return "off"
+ if not task.done():
+ return "alive"
+ if task.cancelled():
+ return "parked"
+ return "FAILED" if task.exception() is not None else "parked"
+
while True:
await asyncio.sleep(10.0)
- oww_alive = oww_task is not None and not oww_task.done()
- whisper_alive = whisper_task is not None and not whisper_task.done()
- fanout_alive = not fanout_task.done()
+ # The detector's OWN counters name exactly the failure modes
+ # a recall complaint has to distinguish (candidates seen,
+ # gated on energy, suppressed by the confirm, suppressed by
+ # cooldown, fired). They were maintained and never read, so
+ # "how many of my wakes were suppressed?" needed a debugger.
+ # Read-only: nothing here may ever feed a decision.
+ try:
+ stats = getattr(self._wake, "stats", None)
+ detector_stats = stats() if callable(stats) else {}
+ except Exception: # noqa: BLE001 — diagnostics never break the loop
+ detector_stats = {}
log.info(
- "wake-detectors-heartbeat: fanout=%s oww=%s whisper=%s oww_q=%d wsp_q=%d",
- "alive" if fanout_alive else "DEAD",
- "alive" if oww_alive else "DEAD" if oww_task else "off",
- "alive" if whisper_alive else "DEAD" if whisper_task else "off",
+ "wake-detectors-heartbeat: fanout=%s oww=%s whisper=%s "
+ "oww_q=%d wsp_q=%d%s",
+ "alive" if not fanout_task.done() else "FAILED",
+ _detector_state(oww_task),
+ _detector_state(whisper_task),
oww_queue.qsize(),
whisper_queue.qsize(),
+ (
+ " " + " ".join(f"{k}={v}" for k, v in detector_stats.items())
+ if detector_stats
+ else ""
+ ),
)
# Surface a detector task that exited with an exception.
for t in (oww_task, whisper_task):
diff --git a/tests/unit/plugins/wake/test_vosk_wake_word_agnostic.py b/tests/unit/plugins/wake/test_vosk_wake_word_agnostic.py
index 1c50086b68..2021cca9a2 100644
--- a/tests/unit/plugins/wake/test_vosk_wake_word_agnostic.py
+++ b/tests/unit/plugins/wake/test_vosk_wake_word_agnostic.py
@@ -472,3 +472,44 @@ def test_a_bare_interjection_plus_a_command_is_still_not_a_wake() -> None:
[_w("hey", 0.40, 0.60, conf=1.0), _w("ho", 0.60, 0.68, conf=0.5)],
"Hey Ruben",
) is False
+
+
+# --- diagnosability: a suppressed wake must leave a trace (2026-07-25) --------
+
+
+def test_a_suppressed_candidate_is_reported_then_rate_limited(monkeypatch) -> None:
+ """A dropped candidate is the ONLY evidence separating "never heard" from
+ "heard and thrown away" — the distinction a "sometimes it does not react"
+ report turns on. Every rejection used to be DEBUG-only, so that evidence
+ did not exist in production.
+
+ Report the first few at INFO and then every 20th: diagnosable without
+ turning a candidate storm into a log flood.
+ """
+ p = VoskKwsProvider("Hey Ruben", model_path="fake", keyword="ruben")
+ seen: list[int] = []
+ monkeypatch.setattr(
+ "jarvis.plugins.wake.vosk_kws_provider.log.info",
+ lambda *a, **k: seen.append(1),
+ )
+ monkeypatch.setattr(
+ "jarvis.plugins.wake.vosk_kws_provider.log.debug", lambda *a, **k: None
+ )
+
+ for _ in range(25):
+ p._log_suppression("test reason %d", 1)
+
+ # 5 early + the 20th = 6 surfaced out of 25.
+ assert len(seen) == 6, f"expected 6 surfaced suppressions, got {len(seen)}"
+
+
+def test_suppression_logging_never_feeds_a_decision() -> None:
+ """The counter is diagnostics. If a threshold ever read it, the log would
+ have become an uncalibrated rejection path — the exact AP-27 shape."""
+ p = VoskKwsProvider("Hey Ruben", model_path="fake", keyword="ruben")
+ p._suppress_log_count = 10_000
+ # A verify decision must be reachable and unaffected by the counter value.
+ assert candidate_shape_ok(
+ [_w("hey", 0.40, 0.62, conf=0.9), _w("erhoben", 0.62, 1.05, conf=0.6)],
+ "Hey Ruben",
+ ) is True