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: warm the import cycle for the harness, self-mod, and skills suites

Ruben Lütke2f8fe77ed5b8
diff --git a/tests/unit/harness/conftest.py b/tests/unit/harness/conftest.py
new file mode 100644
index 0000000000..9356ad12e2
--- /dev/null
+++ b/tests/unit/harness/conftest.py
@@ -0,0 +1,24 @@
+"""Shared isolation for Computer-Use loop tests.
+
+The mission-start hooks ``_ensure_target_on_primary`` (move the foreground window
+to primary) and ``_focus_task_target_window`` (raise the goal's named app from
+another monitor) query + MOVE/RAISE the real desktop's windows. Any test that
+drives the loop (``_run_screenshot_loop`` / ``run_cu_loop``) would otherwise fire
+them against the host — a real, host-dependent side effect. Stub both to no-ops
+for every harness test; their own behavior is unit-tested directly in
+``test_cu_ensure_on_primary.py`` / ``test_cu_focus_task_target.py`` (which capture
+the real functions at import time to bypass this stub).
+"""
+from __future__ import annotations
+
+import pytest
+
+from jarvis.harness import screenshot_only_loop as _loop
+
+
[email protected](autouse=True)
+def _no_real_window_move(monkeypatch: pytest.MonkeyPatch) -> None:
+ monkeypatch.setattr(_loop, "_ensure_target_on_primary", lambda _ctx: None)
+ monkeypatch.setattr(
+ _loop, "_focus_task_target_window", lambda _ctx, _task: None,
+ )
diff --git a/tests/unit/self_mod/conftest.py b/tests/unit/self_mod/conftest.py
new file mode 100644
index 0000000000..a95dab7b6b
--- /dev/null
+++ b/tests/unit/self_mod/conftest.py
@@ -0,0 +1,15 @@
+"""Preload jarvis.core.config before any self_mod test module imports.
+
+There is a pre-existing import cycle: importing ``jarvis.core.self_mod`` first
+pulls ``pending → writer → jarvis.core.config``, and config (via its section
+models AckBrainConfig etc.) pulls ``brain → voice → echo_confirmation`` which
+imports back from ``jarvis.core.self_mod`` while it is still initializing. In a
+full test run config happens to load early; an isolated ``pytest
+tests/unit/self_mod/`` run collects test_audit.py first and trips the cycle.
+
+pytest imports this conftest before collecting the sibling test modules, so a
+single import here loads config fully and breaks the cycle for the whole folder.
+"""
+from __future__ import annotations
+
+import jarvis.core.config # noqa: F401 (preload to satisfy the import order)
diff --git a/tests/unit/skills/conftest.py b/tests/unit/skills/conftest.py
new file mode 100644
index 0000000000..ea88d841c0
--- /dev/null
+++ b/tests/unit/skills/conftest.py
@@ -0,0 +1,19 @@
+"""Skills-suite import ordering guard.
+
+Several modules under ``jarvis.skills.authoring`` / ``jarvis.core.self_mod``
+participate in a latent import cycle
+(``self_mod`` -> ``config`` -> ``brain`` -> ``voice.echo_confirmation`` ->
+``self_mod``). The cycle is harmless once ``jarvis.core.config`` has finished
+loading first, which is what happens implicitly when the full suite runs. But a
+test module that imports ``jarvis.skills.authoring`` in isolation triggers the
+cycle before ``config`` is warm and fails collection with a confusing
+``cannot import name 'PendingMutation'`` error.
+
+Importing ``jarvis.core.config`` here — at skills-suite collection time, before
+any test module is imported — resolves the cycle deterministically for every
+skills test, isolated or not. Importing config has no side effects (it only
+defines classes/functions).
+"""
+from __future__ import annotations
+
+import jarvis.core.config # noqa: F401 (import-for-side-effect: warm the cycle)