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(realtime): bound the mid-reply scrub-gate hold at 400 ms (BUG-080)
Ruben Lütkeba96859c0085
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 0a40996f61..fb800befb2 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -11,6 +11,14 @@ versioning per [SemVer](https://semver.org/lang/de/).### Fixed+- **Realtime voice no longer freezes mid-word for seconds.** When the live+ provider's output transcription lagged its audio (Gemini Live: routinely+ 3-22 s), the voice-scrub gate held the audio for the whole lag — an+ audible dead stop mid-sentence. The mid-reply hold is now bounded at+ 400 ms once the reply's transcript has been vetted clean once; the strict+ fail-closed turn opening and the hard-leak kill switch are unchanged+ (BUG-080).+- **macOS 15 no longer kills the app when hotkeys arm or Computer-Use types("Personal Jarvis quit unexpectedly", SIGILL).** pynput resolved thekeyboard layout through HIToolbox TSM calls on background threads, whichdiff --git a/docs/BUGS.md b/docs/BUGS.mdindex 15deabf125..82482b666c 100644--- a/docs/BUGS.md+++ b/docs/BUGS.md@@ -5582,3 +5582,44 @@ Python — mirror CPython and touch only LC_CTYPE; every native library thatprints numbers breaks under a comma-decimal LC_NUMERIC. And any JSON builtby native code is untrusted input to the Python side: parse it behind adegrade-to-no-op guard that preserves the raw payload.++---++## BUG-080: Realtime voice freezes mid-word for seconds — unbounded scrub-gate hold while the provider transcription lags its audio (HIGH, FIXED 2026-07-18)++**Symptom.** Mid-sentence, the live realtime voice stops dead for 2-15+ s,+then resumes exactly where it paused (maintainer session 2026-07-17 20:04,+turn 1: "Servus, bei" — 4.9 s hole — "mir passt ois…"). <!-- i18n-allow: quoted runtime voice output under test -->+~25 incidents across 2026-07-16/17, worst observed 17.1 s. Log signature:+`mid-reply audio stalled N ms (scrub-gate hold M ms …) — the transcript+needed to clear this audio arrived late`.++**Root cause.** The BUG-069 coverage budget releases audio only against+vetted transcript chars. Gemini Live does not pace its output transcription+against its audio: transcript deltas routinely fall 3-22 s behind. When the+budget ran dry mid-reply, `ScrubHoldGate` held the audio backlog for the+WHOLE lag — an unbounded hold whose only effect was audible dead air,+because at the turn boundary `finalize()` flushes the very same+never-covered tail anyway (same night: a 9.3 s never-transcribed tail was+released at the boundary). The hold was not buying safety, only silence.++**Fix (2026-07-18).** The mid-reply hold is now time-bounded+(`_LAGGING_TRANSCRIPT_GRACE_MS = 400 ms`, `jarvis/realtime/scrub_gate.py`):+once the turn's aggregate transcript has been vetted clean at least once, a+backlog held past the grace window flows even though its own transcript has+not arrived yet. The fail-open is narrow and deliberate: the turn opening+stays strictly fail-closed (nothing plays before the first clean+transcript; `fail_closed()` and the 15 s `fail_if_pending_exceeds` bound+are untouched), and a hard leak in a later transcript delta still cancels+the remaining output. In the healthy co-timed case (transcript <300 ms+behind its audio) the scrubber still vets text before it becomes audible.+Guards: `tests/unit/realtime/test_scrub_gate.py::+test_lagging_transcript_backlog_flows_after_grace` plus three siblings+(no grace before the first clean transcript, none on residue-only+transcripts, kill switch intact after a grace release).++**Class rule.** A safety gate on a live media stream may buffer, but never+unboundedly: bound every hold by the moment the withheld content would+reach the user anyway (here: the finalize() flush), and let the kill+switch — not the hold — be the actual safety mechanism. An unbounded hold+converts a provider lag into a user-facing outage.diff --git a/jarvis/realtime/scrub_gate.py b/jarvis/realtime/scrub_gate.pyindex 4791a8c0df..59e0118dc3 100644--- a/jarvis/realtime/scrub_gate.py+++ b/jarvis/realtime/scrub_gate.py@@ -21,6 +21,17 @@ deliberately FASTER than any real speaking voice (~18 chars/s vs a realof the vetted text — released audio therefore always stays inside the spanthe scrubber has already cleared. Audio beyond that span still buffers,fail-closed, exactly as before.++The hold is additionally TIME-BOUNDED once a turn's aggregate transcript has+been vetted clean at least once (BUG-080): Gemini Live's output transcription+routinely falls 3-22 s behind its audio, and an unbounded mid-reply hold+turned every such lag into an audible mid-word freeze. After+``_LAGGING_TRANSCRIPT_GRACE_MS`` the backlog flows even though its own+transcript has not arrived yet — a deliberate, narrow fail-open: the same+never-covered audio would have been flushed by ``finalize()`` at the turn+boundary anyway, and a hard leak in a later transcript delta still cancels+the remaining output. Before the first clean transcript the gate stays+strictly fail-closed with no grace."""from __future__ import annotations@@ -69,6 +80,13 @@ _COVERAGE_MS_PER_CHAR = 55.0# A finalize() tail this far beyond the coverage estimate cannot be explained# by the deliberate underestimation alone; log it as a transcription stall._FINALIZE_EXCESS_LOG_MS = 5_000.0+# Longest a mid-reply hold may last once the aggregate transcript has been+# clean at least once (BUG-080). Short enough that a lagging transcription+# never freezes the voice perceptibly (live 2026-07-17 20:04: a 4.9 s+# mid-word hole; observed lags run 3-22 s), long enough that a co-timed+# transcript (typically <300 ms behind its audio) still wins the race — in+# the healthy case the scrubber keeps vetting text BEFORE its audio plays.+_LAGGING_TRANSCRIPT_GRACE_MS = 400.0class ScrubHoldGate:@@ -200,6 +218,12 @@ class ScrubHoldGate:released audio stays inside the estimated spoken duration of allvetted transcript chars. This is what keeps playback continuouswhen a provider sends its transcript up-front en bloc (BUG-069).+ 3. The lagging-transcript grace (BUG-080): once the aggregate+ transcript has been clean at least once, a backlog held longer+ than ``_LAGGING_TRANSCRIPT_GRACE_MS`` flows anyway — the provider+ transcription is lagging its audio, and an unbounded hold freezes+ the voice mid-word for the whole lag. A hard leak in a later+ transcript delta still cancels the remaining output.Anything else buffers, fail-closed."""if self._hard_leak:@@ -228,6 +252,25 @@ class ScrubHoldGate:self._released_ms += total_msself._consume_hold_clock()return out+ if (+ self._pending_since is not None+ and (time.monotonic() - self._pending_since) * 1_000.0+ >= _LAGGING_TRANSCRIPT_GRACE_MS+ ):+ out = self._pending + [chunk]+ self._pending = []+ self._pending_audio_ms = 0.0+ self._released_ms += total_ms+ self._consume_hold_clock()+ log.info(+ "scrub gate released %d ms of audio after a %d ms hold "+ "— the provider output transcription is lagging behind "+ "its audio; a leak in a later transcript delta still "+ "cancels the remaining output",+ int(total_ms),+ int(self.last_hold_ms),+ )+ return outif not self._pending and self._pending_since is None:self._pending_since = time.monotonic()self._pending.append(chunk)diff --git a/tests/unit/realtime/test_scrub_gate.py b/tests/unit/realtime/test_scrub_gate.pyindex 625454517b..3d2baddd31 100644--- a/tests/unit/realtime/test_scrub_gate.py+++ b/tests/unit/realtime/test_scrub_gate.py@@ -436,3 +436,86 @@ async def test_fail_closed_reports_missing_transcript_action():await gate.push_audio(_chunk(4))assert gate.fail_closed() is Trueassert gate.hard_leak_actions() == ("no_transcript",)+++class _FakeClock:+ """Deterministic stand-in for the gate's ``time`` module."""++ def __init__(self) -> None:+ self.now = 1_000.0++ def monotonic(self) -> float:+ return self.now+++def clock(monkeypatch) -> _FakeClock:+ fake = _FakeClock()+ monkeypatch.setattr(scrub_gate_module, "time", fake)+ return fake+++async def test_lagging_transcript_backlog_flows_after_grace(clock):+ """BUG-080: a mid-reply transcription stall must not freeze the voice.++ Gemini Live's output transcription can fall 3-22 s behind its audio+ (live 2026-07-17 20:04: a 4.9 s mid-word hole). Once the aggregate+ transcript has been clean, a backlog held past the grace window flows+ even though its own transcript has not arrived yet.+ """+ gate = ScrubHoldGate(language="en")++ await gate.feed_transcript("Okay.") # clean: activates coverage+ first = _chunk(9_600) # 400 ms at 24 kHz+ assert await gate.push_audio(first) == [first]++ second = _chunk(9_600)+ assert await gate.push_audio(second) == [] # budget spent: buffers++ clock.now += 0.5 # past the 400 ms grace, transcript still absent+ third = _chunk(9_600)+ assert await gate.push_audio(third) == [second, third]+ assert gate.pending_audio_ms == 0.0+ assert gate.hard_leak_pending() is False+++async def test_no_grace_release_before_first_clean_transcript(clock):+ """The turn opening stays strictly fail-closed — grace never applies."""+ gate = ScrubHoldGate(language="en")++ assert await gate.push_audio(_chunk(9_600)) == []+ clock.now += 10.0+ assert await gate.push_audio(_chunk(9_600)) == []+ assert gate.fail_closed() is True+++async def test_residue_only_transcript_gets_no_grace_release(clock):+ """A turn whose aggregate transcript is still residue funds no grace."""+ gate = ScrubHoldGate(language="en")++ await gate.feed_transcript("Great question.") # residue: filler opener+ assert await gate.push_audio(_chunk(9_600)) == []+ clock.now += 10.0+ assert await gate.push_audio(_chunk(9_600)) == []+++async def test_hard_leak_after_grace_release_still_blocks_further_audio(clock):+ """The grace release must not weaken the hard-leak kill switch."""+ gate = ScrubHoldGate(language="en")++ await gate.feed_transcript("Okay.")+ assert await gate.push_audio(_chunk(9_600))+ assert await gate.push_audio(_chunk(9_600)) == []+ clock.now += 0.5+ assert await gate.push_audio(_chunk(9_600)) # grace release happened++ await gate.feed_transcript(+ "Traceback (most recent call last):\n File x\nValueError: y\n\n"+ )+ assert gate.hard_leak_pending() is True+ assert await gate.push_audio(_chunk(9_600)) == []+ assert gate.finalize() == []