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(diagnostics): keep a first-audio budget floor for every recording
rubenluetke10-beepd1760be9c03b
diff --git a/jarvis/diagnostics/realtime_forensics.py b/jarvis/diagnostics/realtime_forensics.pyindex 3880325f4a..cedc4d0684 100644--- a/jarvis/diagnostics/realtime_forensics.py+++ b/jarvis/diagnostics/realtime_forensics.py@@ -24,11 +24,14 @@ from typing import Any#:#: The first-audio budget judges ``first_final_to_first_audio_ms`` — the wait#: the USER experiences between finishing an utterance and hearing the answer.-#: It deliberately does NOT judge ``first_audio_ms``: that metric counts from+#: It prefers that metric over ``first_audio_ms``: the latter counts from#: session start and therefore includes the user's own speaking/listening#: time, so a healthy codex call (8 311 ms from start, 923 ms after the-#: final, live 2026-08-08) read as a budget breach. ``first_audio_ms`` stays-#: in the payload and the detail line for continuity with old recordings.+#: final, live 2026-08-08) read as a budget breach. When the newer metric is+#: absent — pre-metric recordings, adapters that never stamp it, calls whose+#: audio never followed a user final — the budget falls back to+#: ``first_audio_ms`` so that no recording class escapes it unjudged. The+#: finding names which of the two was judged.SPAWN_READY_BUDGET_MS = 4_000SPAWN_FIRST_AUDIO_BUDGET_MS = 6_000@@ -245,19 +248,33 @@ def evaluate_postmortem(pm: Mapping[str, Any]) -> list[RealtimeFinding]:first_audio_ms = _count(pm, "first_audio_ms")response_ms = _count(pm, "first_final_to_first_audio_ms")over_ready = ready_ms > SPAWN_READY_BUDGET_MS- # 0 means "never measured" (pre-metric recording, no final, or no audible- # audio after one) — silence there is reported by other counters, and an- # absent metric must not fabricate a budget breach.- over_first = bool(response_ms) and response_ms > SPAWN_FIRST_AUDIO_BUDGET_MS+ # The user-perceived wait is judged whenever the adapter stamped it. Where+ # it is missing (pre-metric recording, no user final, or no audible audio+ # after one) the legacy session-start measurement is judged instead, so a+ # 30 s first audio can never pass unjudged just because the newer metric+ # is absent. 0 in BOTH means "never measured" — that silence is reported+ # by other counters and must not fabricate a budget breach here.+ if response_ms:+ over_first = response_ms > SPAWN_FIRST_AUDIO_BUDGET_MS+ judged = (+ f"first audio {response_ms} ms after the first user final "+ f"(budget {SPAWN_FIRST_AUDIO_BUDGET_MS}; "+ f"{first_audio_ms} ms from session start)"+ )+ else:+ over_first = first_audio_ms > SPAWN_FIRST_AUDIO_BUDGET_MS+ judged = (+ f"first audio {first_audio_ms} ms from session start "+ f"(budget {SPAWN_FIRST_AUDIO_BUDGET_MS}; this recording carries "+ "no wait-after-final measurement)"+ )if over_ready or over_first:add(RealtimeFinding("warn","spawn-over-budget",f"ready {ready_ms} ms (budget {SPAWN_READY_BUDGET_MS}), "- f"first audio {response_ms} ms after the first user final "- f"(budget {SPAWN_FIRST_AUDIO_BUDGET_MS}; "- f"{first_audio_ms} ms from session start)",+ + judged,))diff --git a/tests/unit/diagnostics/test_realtime_forensics_first_final_budget.py b/tests/unit/diagnostics/test_realtime_forensics_first_final_budget.pyindex 4453275fbf..58f3cf2c98 100644--- a/tests/unit/diagnostics/test_realtime_forensics_first_final_budget.py+++ b/tests/unit/diagnostics/test_realtime_forensics_first_final_budget.py@@ -4,10 +4,10 @@user's own speaking/listening time: a live codex call measured 8 311 ms fromstart while the wait after the user's final was 923 ms, and the oldassertion flagged that healthy call as a budget breach. The budget now-judges ``first_final_to_first_audio_ms`` (first user FINAL → first audible-provider frame); ``first_audio_ms`` stays in the payload and the detail-line for continuity with old recordings but is never asserted against the-budget anymore.+prefers ``first_final_to_first_audio_ms`` (first user FINAL → first audible+provider frame) and falls back to ``first_audio_ms`` only where that newer+metric is absent — otherwise pre-metric recordings and adapters that never+stamp it would escape the budget entirely."""from __future__ import annotations@@ -54,15 +54,41 @@ def test_the_codex_8311ms_case_no_longer_reads_as_a_breach() -> None:assert _kinds(healthy_codex) == set()-def test_legacy_first_audio_alone_never_breaches_the_budget() -> None:- # An old recording without the new metric must not fabricate a breach- # from the misleading session-start measurement.- legacy = _healthy() | {"first_audio_ms": SPAWN_FIRST_AUDIO_BUDGET_MS + 1}- assert _kinds(legacy) == set()+def test_a_measured_wait_after_the_final_overrides_a_large_session_age() -> None:+ # The session-start measurement is inflated by design, so once the newer+ # metric is present it alone decides — no double-flagging via the+ # fallback.+ healthy_after_long_listen = _healthy() | {+ "first_audio_ms": 30_000,+ "first_final_to_first_audio_ms": 900,+ }+ assert _kinds(healthy_after_long_listen) == set()+++def test_a_legacy_recording_is_still_judged_against_the_budget() -> None:+ # No ``first_final_to_first_audio_ms`` at all (old capture, or an adapter+ # that never stamps it): the legacy metric is judged so a 30 s first+ # audio cannot pass forensics unjudged.+ legacy_breach = _healthy() | {"first_audio_ms": 30_000}+ findings = evaluate_postmortem(legacy_breach)+ assert [(f.severity, f.kind) for f in findings] == [+ ("warn", "spawn-over-budget")+ ]-def test_zero_means_never_measured_and_stays_quiet() -> None:- assert _kinds(_healthy() | {"first_final_to_first_audio_ms": 0}) == set()+def test_a_legacy_recording_inside_the_budget_stays_clean() -> None:+ legacy_ok = _healthy() | {"first_audio_ms": SPAWN_FIRST_AUDIO_BUDGET_MS}+ assert _kinds(legacy_ok) == set()+++def test_no_measurement_at_all_stays_quiet() -> None:+ # Both metrics zero means nothing was ever measured — the missing audio+ # is reported by other counters, never as a fabricated spawn overrun.+ unmeasured = _healthy() | {+ "first_audio_ms": 0,+ "first_final_to_first_audio_ms": 0,+ }+ assert _kinds(unmeasured) == set()def test_ready_budget_is_untouched() -> None:@@ -78,3 +104,9 @@ def test_detail_line_carries_both_measurements_for_continuity() -> None:(finding,) = evaluate_postmortem(over)assert "after the first user final" in finding.detailassert "8311 ms from session start" in finding.detail+++def test_detail_line_names_the_legacy_metric_when_it_was_judged() -> None:+ (finding,) = evaluate_postmortem(_healthy() | {"first_audio_ms": 30_000})+ assert "30000 ms from session start" in finding.detail+ assert "after the first user final" not in finding.detail