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.

chore: auto-save WIP via Claude stop-hook safety net (2026-07-02 09:58)

Ruben Lütke41853818831a
diff --git a/scripts/cu_rig_results_engine_v2.json b/scripts/cu_rig_results_engine_v2.json
new file mode 100644
index 0000000000..868098d004
--- /dev/null
+++ b/scripts/cu_rig_results_engine_v2.json
@@ -0,0 +1,42 @@
+[
+ {
+ "scenario": "engine-click-targets",
+ "intended_clicks": 4,
+ "received_first_hits": 4,
+ "hit_rate": 1.0,
+ "mean_distance_px": 0.0,
+ "max_distance_px": 0.0,
+ "duplicate_clicks": 0,
+ "step_latency_s_p50": 1.57,
+ "step_latency_s_max": 1.57,
+ "provoked_duplicates_executed": 0,
+ "engine": "v2",
+ "mission_wall_s": 6.28,
+ "final_chunk": "[cu] done (verified: all rig targets were activated)\n[cu] mission profile: steps=5 total=6.3s act=1.2s observe=2.6s think=0.0s verify=2.0s"
+ },
+ {
+ "scenario": "engine-type-once",
+ "engine": "v2",
+ "typed_expected": "example.com",
+ "typed_received": "",
+ "typed_exactly_once": false,
+ "mission_wall_s": 3.12
+ },
+ {
+ "scenario": "engine-duplicate-type-provocation",
+ "engine": "v2",
+ "typed_expected": "example.com",
+ "typed_received": "",
+ "duplicates_executed": 0,
+ "typed_exactly_once": false,
+ "mission_wall_s": 4.72
+ },
+ {
+ "scenario": "engine-misaim-provocation",
+ "engine": "v2",
+ "dead_space_clicks_executed": 3,
+ "blind_repeats_after_first": 2,
+ "mission_wall_s": 4.97,
+ "final_chunk": "[cu] done (verified: all rig targets were activated)\n[cu] mission profile: steps=4 total=5.0s act=0.9s observe=2.0s think=0.0s verify=1.6s"
+ }
+]
\ No newline at end of file
diff --git a/scripts/cu_rig_results_raw.json b/scripts/cu_rig_results_raw.json
index 5c48578cb8..ec131a66c5 100644
--- a/scripts/cu_rig_results_raw.json
+++ b/scripts/cu_rig_results_raw.json
@@ -2,19 +2,20 @@
{
"scenario": "raw-pipeline",
"intended_clicks": 4,
- "received_first_hits": 2,
- "hit_rate": 0.5,
+ "received_first_hits": 4,
+ "hit_rate": 1.0,
"mean_distance_px": 0.0,
"max_distance_px": 0.0,
"duplicate_clicks": 0,
- "step_latency_s_p50": 0.039,
- "step_latency_s_max": 0.063,
+ "step_latency_s_p50": 0.024,
+ "step_latency_s_max": 0.031,
"provoked_duplicates_executed": 0,
"typed_expected": "example.com",
- "typed_received": "",
- "typed_exactly_once": false,
+ "typed_received": "example.com",
+ "typed_exactly_once": true,
"typed_duplicated": false,
"actuator": "windows-sendinput",
- "monitor": "3840x2160@0,0"
+ "monitor": "3840x2160@0,0",
+ "interference_retries": 0
}
]
\ No newline at end of file
diff --git a/scripts/cu_test_rig.py b/scripts/cu_test_rig.py
index e72b7b8e22..ba6ec09826 100644
--- a/scripts/cu_test_rig.py
+++ b/scripts/cu_test_rig.py
@@ -158,9 +158,26 @@ class RigWindow:
entry.bind("<FocusIn>", on_entry_focus)
root.attributes("-topmost", True)
root.update()
+ self._tk_id = root.winfo_id()
self.ready.set()
root.mainloop()
+ def is_foreground(self) -> bool:
+ """Is the rig window the FOREGROUND window? (Windows: real check;
+ elsewhere: trust the activation click.) Guards the typing scenarios —
+ the rig must NEVER type into a foreign window."""
+ if sys.platform != "win32":
+ return True
+ try:
+ import ctypes # noqa: PLC0415
+
+ user32 = ctypes.windll.user32
+ GA_ROOT = 2
+ ours = user32.GetAncestor(int(self._tk_id), GA_ROOT)
+ return bool(ours) and user32.GetForegroundWindow() == ours
+ except Exception: # noqa: BLE001
+ return True
+
def _target_at(self, cx: int, cy: int) -> str | None:
for name, (x1, y1, x2, y2) in TARGETS.items():
if x1 <= cx <= x2 and y1 <= cy <= y2:
@@ -308,35 +325,68 @@ def run_raw(rig: RigWindow) -> list[dict[str, Any]]:
)
intended: list[tuple[str, tuple[int, int]]] = []
step_times: list[float] = []
+ interference_retries = 0
for name in TARGETS:
center = rig.target_center_screen(name)
nx, ny = _norm_for(center, monitor)
t0 = time.monotonic()
sx, sy = mapper.normalized_to_screen(nx, ny)
- move = verified_move(actuator, sx, sy)
- if not move.ok:
- print(f" !! landed-verification failed for {name}: {move.detail}")
- actuator.click(sx, sy)
+ for attempt in (1, 2):
+ move = verified_move(actuator, sx, sy)
+ if not move.ok:
+ print(f" !! landed-verification for {name}: {move.detail}")
+ before = len(rig.log.clicks_on(name))
+ actuator.click(sx, sy)
+ deadline = time.monotonic() + 0.8
+ while time.monotonic() < deadline:
+ if len(rig.log.clicks_on(name)) > before:
+ break
+ time.sleep(0.05)
+ if len(rig.log.clicks_on(name)) > before:
+ break
+ # Nothing arrived: external interference (a human hand on the
+ # mouse / a foreign foreground window). Re-activate and retry ONCE.
+ interference_retries += 1
+ print(f" !! no click event arrived for {name} — retrying once")
+ _activate_rig_click_only(rig, actuator)
step_times.append(time.monotonic() - t0)
intended.append((name, center))
- time.sleep(0.25)
+ time.sleep(0.2)
- # Typing: click the entry, type, verify content.
+ # Typing: click the entry, type, verify content. HARD GUARD: never type
+ # while the rig is not the foreground window (keystrokes would land in a
+ # foreign app).
+ typed_expected: str | None = TYPE_TEXT
ex, ey = rig.entry_center_screen()
actuator.click(ex, ey)
time.sleep(0.3)
- actuator.type_text(TYPE_TEXT, delay_s=0.01)
- time.sleep(0.4)
+ if not rig.is_foreground():
+ _activate_rig_click_only(rig, actuator)
+ actuator.click(ex, ey)
+ time.sleep(0.3)
+ if rig.is_foreground():
+ actuator.type_text(TYPE_TEXT, delay_s=0.01)
+ time.sleep(0.4)
+ else:
+ print(" !! rig lost foreground — typing scenario SKIPPED for safety")
+ typed_expected = None
summary = _summarize(
"raw-pipeline", intended, rig,
- step_times=step_times, typed_expected=TYPE_TEXT,
+ step_times=step_times, typed_expected=typed_expected,
)
summary["actuator"] = actuator.name
summary["monitor"] = f"{monitor.width}x{monitor.height}@{monitor.left},{monitor.top}"
+ summary["interference_retries"] = interference_retries
return [summary]
+def _activate_rig_click_only(rig: RigWindow, actuator: Any) -> None:
+ ox, oy = rig.canvas_origin_on_screen()
+ actuator.click(ox + 410, oy + 480)
+ time.sleep(0.3)
+
+
# ---------------------------------------------------------------------------
# Mode: engine (real engine, scripted brain)
# ---------------------------------------------------------------------------