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.
Python agent-orchestrationai-agentai-coding-assistantclaude-codecoding-agentcomputer-usedesktop-applocal-firstmcppersonal-jarvisvoice-assistantvoice-coding
fix(wiki): steal a dead owner's vault lock immediately on POSIX
Ruben Lütke1e711f2e01c6
diff --git a/docs/os-parity.md b/docs/os-parity.mdindex 641ea95bae..586c48fd5d 100644--- a/docs/os-parity.md+++ b/docs/os-parity.md@@ -58,6 +58,7 @@ experiences today.| P-13 | Info | Wiki | Wiki DB/vault anchor at `repo_root()` — read-only *wheel* installs would fail writes (not OS-specific; `JARVIS_DATA_DIR` override exists) | `jarvis/memory/wiki/db_path.py:9`, `vault_root.py:59` | None on the advertised install paths || P-14 | Info | CU extras | macOS/Linux actuation and UI trees depend on optional extras (pynput, pyobjc, pyatspi); without them everything degrades honestly to screenshot + pixel-click | `jarvis/cu/actuate/posix.py`, `jarvis/vision/tree_factory.py` | By design (§3); bare install keeps the CU loop functional || P-15 | Low | Desktop downloads | Native drag-out has Windows OLE and macOS AppKit sources but no GTK/WebKitGTK source yet | `jarvis/ui/native_drag.py` | Linux desktop: the saved-file toast keeps reliable **Show in folder** and **Open** actions but is not itself a drag handle; headless: the normal browser download path remains available |+| P-16 | Low | Wiki | `VaultLock` dead-owner fast-steal is POSIX-only (`os.kill(pid, 0)` liveness probe; on Windows `os.kill` cannot probe — a non-CTRL signal terminates the target) | `jarvis/memory/wiki/lock.py::_pid_alive` | Windows: a lock left by a crashed/restarted process is stolen only after the `stale_after_seconds` wall-clock window (300 s) — the pre-fix behavior everywhere; a Win32 `OpenProcess` probe could close this |## Maintenancediff --git a/jarvis/memory/wiki/lock.py b/jarvis/memory/wiki/lock.pyindex 12b6ff6a1c..0492e9a804 100644--- a/jarvis/memory/wiki/lock.py+++ b/jarvis/memory/wiki/lock.py@@ -149,10 +149,19 @@ class VaultLock:owner_pid, owner_ts = self._parse_lock_content(content)- if owner_ts is not None:+ if owner_pid is not None and not self._pid_alive(owner_pid):+ # The owner died without releasing (crash, app restart mid-run).+ # Waiting out the timestamp window would stall every curator+ # trigger for stale_after seconds on each restart.+ log.warning(+ "VaultLock: owner pid %d is gone — stealing its lock at %s",+ owner_pid,+ self._path,+ )+ elif owner_ts is not None:age = time.time() - owner_tsif -_FUTURE_TOLERANCE_S <= age <= self._stale_after:- # Lock is fresh — do not steal.+ # Lock is fresh and its owner is alive — do not steal.return Falseif age < 0:# Far-future timestamp: a pre-fix monotonic remnant or a@@ -196,6 +205,30 @@ class VaultLock:# Another process grabbed it between our unlink and create.return False+ @staticmethod+ def _pid_alive(pid: int) -> bool:+ """Return whether the lock owner's PID is a live process.++ POSIX only: ``os.kill(pid, 0)`` probes liveness without delivering+ a signal. On Windows ``os.kill`` cannot probe — any non-CTRL+ "signal" TERMINATES the target — so the probe reports "alive"+ there and the wall-clock staleness window stays the only steal+ path (tracked in docs/os-parity.md).+ """+ if os.name != "posix":+ return True+ if pid <= 0:+ return False+ try:+ os.kill(pid, 0)+ except ProcessLookupError:+ return False+ except OSError:+ # EPERM and friends: the process exists but belongs to another+ # user — alive for our purposes.+ return True+ return True+@staticmethoddef _parse_lock_content(content: str) -> tuple[int | None, float | None]:"""Parse ``"<pid>;<wall_clock_ts>"`` from lock file content.diff --git a/tests/unit/memory/wiki/test_lock.py b/tests/unit/memory/wiki/test_lock.pyindex 3e5ee71fa2..203d0d5140 100644--- a/tests/unit/memory/wiki/test_lock.py+++ b/tests/unit/memory/wiki/test_lock.py@@ -10,9 +10,13 @@ clock); the in-process acquire deadline loop may keep monotonic.from __future__ import annotationsimport os+import subprocess+import sysimport timefrom pathlib import Path+import pytest+from jarvis.memory.wiki.lock import VaultLock@@ -50,6 +54,26 @@ def test_fresh_lock_is_not_stolen(tmp_path: Path) -> None:assert path.exists()+def test_fresh_lock_of_dead_owner_is_stolen_immediately_on_posix(+ tmp_path: Path,+) -> None:+ """An app restart mid-run leaves a fresh-looking lock owned by a dead+ PID; waiting out the staleness window stalled every curator trigger+ for five minutes per restart. POSIX probes liveness and steals at+ once; Windows keeps the wall-clock window (docs/os-parity.md P-16)."""+ if os.name != "posix":+ pytest.skip("dead-owner fast-steal is POSIX-only")+ proc = subprocess.Popen(+ [sys.executable, "-c", "pass"],+ )+ proc.wait()+ path = tmp_path / "curator.lock"+ _write_lock(path, time.time(), pid=proc.pid)+ lock = VaultLock(path, stale_after_seconds=300)+ assert lock.acquire(timeout_s=0.1) is True+ lock.release()++def test_future_timestamp_is_treated_as_corrupt_and_stolen(tmp_path: Path) -> None:"""A far-future timestamp is a pre-fix monotonic remnant — steal it."""path = tmp_path / "curator.lock"