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: make native preview and worktree checks deterministic

rubenluetke10-beep4c766d7852c8
diff --git a/tests/missions/kontrollierer/test_external_write_verification.py b/tests/missions/kontrollierer/test_external_write_verification.py
index 623139e257..c80feaaddc 100644
--- a/tests/missions/kontrollierer/test_external_write_verification.py
+++ b/tests/missions/kontrollierer/test_external_write_verification.py
@@ -2,8 +2,8 @@
Root cause of mission_019e7abd (2026-05-30, live voice failure): the worker
wrote the requested HTML file to an absolute path OUTSIDE its git worktree
-(`C:\\Users\\Administrator\\Desktop\\M\\hello.html`, exactly as the task
-demanded). `_capture_diff` is worktree-scoped, so the captured diff was empty;
+(an explicitly requested external output directory). `_capture_diff` is
+worktree-scoped, so the captured diff was empty;
the Critic's GROUND-TRUTH-RULE then deterministically failed the mission 3×
with `critic_loop_exhausted` even though the file existed and was correct.
@@ -21,7 +21,6 @@ from __future__ import annotations
import json
import subprocess
-import uuid
from pathlib import Path
import pytest
@@ -30,9 +29,7 @@ from jarvis.missions.kontrollierer.orchestrator import (
Kontrollierer,
_real_diff_is_empty,
)
-
-
-PROJECT_ROOT = Path(__file__).resolve().parents[3]
+from jarvis.core.process_utils import NO_WINDOW_CREATIONFLAGS
def _git(*args: str, cwd: Path | None = None) -> subprocess.CompletedProcess[str]:
@@ -42,23 +39,31 @@ def _git(*args: str, cwd: Path | None = None) -> subprocess.CompletedProcess[str
check=False,
capture_output=True,
text=True,
+ encoding="utf-8",
+ creationflags=NO_WINDOW_CREATIONFLAGS,
timeout=15.0,
)
@pytest.fixture
def worktree(tmp_path: Path):
- """A fresh git worktree branched off `main`, cleaned up after the test."""
- branch = f"test/external-write-{uuid.uuid4().hex[:8]}"
+ """A real worktree of a tiny repository owned entirely by this test."""
+ repo = tmp_path / "repo"
+ repo.mkdir()
+ assert _git("init", "-b", "main", cwd=repo).returncode == 0
+ (repo / "seed.txt").write_text("Fixture repository\n", encoding="utf-8")
+ assert _git("add", "seed.txt", cwd=repo).returncode == 0
+ committed = _git(
+ "-c", "user.name=Fixture", "-c", "[email protected]",
+ "commit", "-m", "Create fixture", cwd=repo,
+ )
+ assert committed.returncode == 0, committed.stderr
wt = tmp_path / "wt"
- add = _git("worktree", "add", "-b", branch, str(wt), "main", cwd=PROJECT_ROOT)
- if add.returncode != 0:
- pytest.skip(f"git worktree add failed: {add.stderr.strip()[:200]}")
- try:
- yield wt
- finally:
- _git("worktree", "remove", "--force", str(wt), cwd=PROJECT_ROOT)
- _git("branch", "-D", branch, cwd=PROJECT_ROOT)
+ added = _git("worktree", "add", "--detach", str(wt), "HEAD", cwd=repo)
+ assert added.returncode == 0, added.stderr
+ # pytest owns both directories and their metadata; no shared refs or
+ # repository-sized checkout is needed to prove the containment boundary.
+ yield wt
@pytest.fixture
diff --git a/tests/unit/dictation/test_local_preview.py b/tests/unit/dictation/test_local_preview.py
index 78adfe7277..27ac6465cf 100644
--- a/tests/unit/dictation/test_local_preview.py
+++ b/tests/unit/dictation/test_local_preview.py
@@ -432,7 +432,11 @@ async def test_a_late_but_successful_preview_ends_the_failure_streak():
try:
assert await engine.transcribe(b"\x00" * 32000) is None # times out, worker runs on
assert engine._failures == 1
- await asyncio.sleep(0.15) # the worker finishes late
+ # Observe native completion rather than assuming a hosted runner can
+ # schedule the worker and its callback inside a fixed sleep.
+ async with asyncio.timeout(2):
+ while engine._busy.locked():
+ await asyncio.sleep(0.005)
assert engine._failures == 0
assert engine.ready is True
finally: