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.

test(ci): make watchdog recovery independent of runner timing

rubenluetke10-beep6009eeddadc4
diff --git a/jarvis/skills/builtin/cli-gcloud/SKILL.md b/jarvis/skills/builtin/cli-gcloud/SKILL.md
index 064704e3a9..73ece20220 100644
--- a/jarvis/skills/builtin/cli-gcloud/SKILL.md
+++ b/jarvis/skills/builtin/cli-gcloud/SKILL.md
@@ -12,9 +12,7 @@ when_to_use: >-
VMs, buckets, IAM roles — and gcloud is connected. Reach for the cli_gcloud
tool, never the browser console.
category: meta
-tags: [gcloud, google-cloud, cli, billing]
-intent_objects: [gcloud, google cloud, google-cloud]
-intent_verbs: [inspect, list, show, check, cost, costs, kostet, kosten, cuesta, coste, costos] # i18n-allow: billing questions
+tags: [gcloud, google-cloud, cli, billing, google cloud, cloud costs, cloud billing, kostet, kosten, cuesta, coste, costos] # i18n-allow: billing search vocabulary
author: builtin
license: Apache-2.0
requires_tools: [cli_gcloud]
diff --git a/tests/fakes/fake_watchdog_clock.py b/tests/fakes/fake_watchdog_clock.py
new file mode 100644
index 0000000000..e47b945c98
--- /dev/null
+++ b/tests/fakes/fake_watchdog_clock.py
@@ -0,0 +1,32 @@
+"""Controlled heartbeat delivery for watchdog state-machine tests."""
+
+from collections.abc import Callable, Iterable
+
+
+class ScriptedWatchdogClock:
+ """Advance one interval per wait, delivering queued beats on healthy ticks."""
+
+ def __init__(self, healthy_ticks: Iterable[bool]) -> None:
+ self._ticks = list(healthy_ticks)
+ self._index = 0
+ self._now = 0.0
+ self._pending: list[Callable[[], None]] = []
+
+ def monotonic(self) -> float:
+ return self._now
+
+ def call_soon_threadsafe(self, callback: Callable[[], None]) -> None:
+ self._pending.append(callback)
+
+ def is_set(self) -> bool:
+ return self._index == len(self._ticks)
+
+ def wait(self, interval: float) -> bool:
+ self._now += interval
+ healthy = self._ticks[self._index]
+ self._index += 1
+ if healthy:
+ pending, self._pending = self._pending, []
+ for callback in pending:
+ callback()
+ return False
diff --git a/tests/unit/core/test_loop_watchdog.py b/tests/unit/core/test_loop_watchdog.py
index 072f383f91..02dee0373e 100644
--- a/tests/unit/core/test_loop_watchdog.py
+++ b/tests/unit/core/test_loop_watchdog.py
@@ -11,10 +11,12 @@ from __future__ import annotations
import asyncio
import threading
import time
+from types import SimpleNamespace
import pytest
from jarvis.core.loop_watchdog import EventLoopWatchdog
+from tests.fakes.fake_watchdog_clock import ScriptedWatchdogClock
class _Recorder:
@@ -121,31 +123,21 @@ def test_an_ongoing_stall_is_not_repeated_every_check(live_loop):
)
-def test_recovery_re_arms_the_report(live_loop):
+def test_recovery_re_arms_the_report(monkeypatch):
"""After the loop frees itself, a LATER stall is reported again."""
+ from jarvis.core import loop_watchdog
+
+ clock = ScriptedWatchdogClock([True, False, False, False, True, False, False, False])
+ monkeypatch.setattr(loop_watchdog, "time", SimpleNamespace(monotonic=clock.monotonic))
recorder = _Recorder()
watchdog = EventLoopWatchdog(
- live_loop, interval_s=0.05, stall_s=0.2, repeat_s=30.0, on_stall=recorder
+ clock, interval_s=0.25, stall_s=0.5, repeat_s=30.0, on_stall=recorder
)
- watchdog.start()
-
- try:
- first = threading.Event()
- live_loop.call_soon_threadsafe(lambda: first.wait(1.0))
- assert recorder.seen.wait(3.0)
- first.set()
-
- time.sleep(0.3) # let the loop beat again — this clears the report
- recorder.seen.clear()
-
- second = threading.Event()
- live_loop.call_soon_threadsafe(lambda: second.wait(1.0))
- assert recorder.seen.wait(3.0), "a fresh stall after recovery went unreported"
- second.set()
- finally:
- watchdog.stop()
-
- assert len(recorder.calls) == 2
+ # Real-loop tests above cover thread scheduling. This case controls the
+ # recovery boundary so CI load cannot introduce an unrelated third stall.
+ watchdog._stop = clock
+ watchdog._run()
+ assert [duration for duration, _stack in recorder.calls] == [0.5, 0.5]
def test_stop_is_idempotent_and_start_does_not_double_up(live_loop):