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.

fix(diagnostics): teach the probe judge the transport's real timing

rubenluetke10-beep0547afebbce1
diff --git a/jarvis/diagnostics/realtime_probe.py b/jarvis/diagnostics/realtime_probe.py
index 814ffe5a52..f64a9307ee 100644
--- a/jarvis/diagnostics/realtime_probe.py
+++ b/jarvis/diagnostics/realtime_probe.py
@@ -555,12 +555,15 @@ def evaluate_scenario(
ready_rows = [r for r in rows if r["src"] == "probe" and r["kind"] == "ready"]
ready_mono = ready_rows[0]["mono"] if ready_rows else 0.0
- # Reconstruct exchanges: a turn_complete "earns" a turn when a non-empty
- # final user transcript arrived since the previous boundary.
- exchanges = 0
- ungrounded_turns: list[float] = []
- user_final_pending = False
+ # Timeline primitives. Live round 1 (2026-08-06) taught the judge two
+ # realities: user FINALS can trail their own turn's boundary by seconds
+ # (the recognizer round trip), and a greeting's boundary can arrive long
+ # after ready even though its speech STARTED immediately - so exchanges
+ # are counted question->answer, and the greeting allowance anchors on
+ # when the boundary's speech began, not on when it ended.
+ user_finals: list[float] = []
assistant_text_rows: list[tuple[float, str]] = []
+ boundaries: list[float] = []
for row in surface:
data = row["data"]
if row["kind"] != "json":
@@ -568,16 +571,56 @@ def evaluate_scenario(
if data.get("type") == "transcript":
text = str(data.get("text", "")).strip()
if data.get("role") == "user" and data.get("is_final") and text:
- user_final_pending = True
+ user_finals.append(row["mono"])
elif data.get("role") == "assistant" and text:
assistant_text_rows.append((row["mono"], text))
elif data.get("type") == "turn_complete":
- if user_final_pending:
- exchanges += 1
- user_final_pending = False
- else:
- # A boundary with no grounded user final: greeting or self-talk.
- ungrounded_turns.append(row["mono"])
+ boundaries.append(row["mono"])
+
+ # A grounded exchange: a user final that is ANSWERED - assistant output
+ # begins after it and before the next user final.
+ exchanges = 0
+ for index, final_mono in enumerate(user_finals):
+ next_final = (
+ user_finals[index + 1] if index + 1 < len(user_finals) else float("inf")
+ )
+ if any(final_mono < mono < next_final for mono, _ in assistant_text_rows):
+ exchanges += 1
+
+ # Ungrounded boundaries. A user final may TRAIL its own turn's boundary
+ # by the recognizer's round trip, but a bare trailing final could equally
+ # belong to the NEXT turn - so a final only grounds a boundary when
+ # assistant output sits between the final and that boundary(+slack): the
+ # answer is the tie-breaker. Each final grounds at most one boundary.
+ _FINAL_TRAIL_SLACK_S = 2.5
+ ungrounded_turns: list[float] = []
+ ungrounded_speech_start: dict[float, float] = {}
+ unconsumed_finals = list(user_finals)
+ previous_boundary = float("-inf")
+ for boundary in boundaries:
+ horizon = boundary + _FINAL_TRAIL_SLACK_S
+ grounding_final: float | None = None
+ for final in unconsumed_finals:
+ if not (previous_boundary < final <= horizon):
+ continue
+ if any(final < mono <= horizon for mono, _ in assistant_text_rows):
+ grounding_final = final
+ break
+ if grounding_final is not None:
+ unconsumed_finals.remove(grounding_final)
+ else:
+ # When did this boundary's speech begin? (greeting anchor)
+ speech_start = next(
+ (
+ mono
+ for mono, _ in assistant_text_rows
+ if mono > previous_boundary
+ ),
+ boundary,
+ )
+ ungrounded_speech_start[boundary] = speech_start
+ ungrounded_turns.append(boundary)
+ previous_boundary = boundary
def _verdict(name: str, status: str, detail: str) -> None:
verdicts[name] = {"status": status, "detail": detail}
@@ -594,7 +637,9 @@ def evaluate_scenario(
allowed = [
mono
for mono in ungrounded_turns
- if ready_mono and mono - ready_mono <= GREETING_WINDOW_S
+ if ready_mono
+ and ungrounded_speech_start.get(mono, mono) - ready_mono
+ <= GREETING_WINDOW_S
][:1]
extra = [m for m in ungrounded_turns if m not in allowed]
_verdict(
diff --git a/tests/unit/diagnostics/test_realtime_probe_eval.py b/tests/unit/diagnostics/test_realtime_probe_eval.py
index dc79de363b..4d134ba985 100644
--- a/tests/unit/diagnostics/test_realtime_probe_eval.py
+++ b/tests/unit/diagnostics/test_realtime_probe_eval.py
@@ -54,6 +54,21 @@ def _happy_rows() -> list[dict[str, Any]]:
return rows
+def test_a_final_that_trails_its_boundary_still_grounds_it() -> None:
+ """Live round 1: the recognizer's round trip regularly lands the user
+ FINAL seconds after the turn's boundary. Grounding must tolerate the
+ trail, or every healthy call reads as self-talk."""
+ rows = [
+ _row(1.0, "probe", "ready", {"type": "audio_ready"}),
+ _transcript(4.0, "assistant", "It is violet."),
+ _row(5.0, "surface", "json", {"type": "turn_complete"}),
+ _transcript(6.5, "user", "what color is the violet giraffe"),
+ _transcript(7.0, "assistant", "Still violet."),
+ ]
+ verdict = _judge(rows, _pm(), ["no_ungrounded"])["no_ungrounded"]
+ assert verdict["status"] == "pass", verdict
+
+
def _pm(**overrides: Any) -> dict[str, Any]:
base: dict[str, Any] = {
"turns_completed": 1,
@@ -112,13 +127,26 @@ def test_missing_turn_fails_the_count() -> None:
assert verdicts["turns>=2"]["status"] == "fail"
-def test_ungrounded_boundary_is_allowed_once_as_greeting_then_fails() -> None:
- rows = _happy_rows()
- # A greeting boundary 3 s after ready (inside the window) - allowed.
- rows.insert(3, _row(3.0, "surface", "json", {"type": "turn_complete"}))
+def test_ungrounded_greeting_is_allowed_even_when_its_boundary_lands_late() -> None:
+ """Live round 1: the greeting monologue STARTED right at ready but ran
+ 16+ s, so its boundary fell far outside any window anchored on ready.
+ The allowance keys on when the boundary's speech began."""
+ rows = [
+ _row(1.0, "probe", "ready", {"type": "audio_ready"}),
+ _transcript(2.0, "assistant", "Hey there, ready when you are."),
+ # ... it rambles; the boundary only lands 17 s after ready ...
+ _row(18.0, "surface", "json", {"type": "turn_complete"}),
+ _transcript(20.0, "user", "what color is the violet giraffe"),
+ _transcript(21.0, "assistant", "Violet."),
+ _row(22.0, "surface", "json", {"type": "turn_complete"}),
+ ]
assert _judge(rows, _pm(), ["no_ungrounded"])["no_ungrounded"]["status"] == "pass"
- # A second ungrounded boundary long after the window - self-talk.
- rows.append(_row(30.0, "surface", "json", {"type": "turn_complete"}))
+
+ # A SECOND ungrounded turn, speech starting long past the window: fails.
+ rows += [
+ _transcript(29.0, "assistant", "Anyway, as I was saying to myself."),
+ _row(31.0, "surface", "json", {"type": "turn_complete"}),
+ ]
assert _judge(rows, _pm(), ["no_ungrounded"])["no_ungrounded"]["status"] == "fail"