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(cli): treat backward clock skew as a stale schema cache; drop dead 'chats' reservation
Ruben Lütke4b56687b5303
diff --git a/jarvis/cli_ctl/openapi_cache.py b/jarvis/cli_ctl/openapi_cache.pyindex b4df859207..642f7ab72a 100644--- a/jarvis/cli_ctl/openapi_cache.py+++ b/jarvis/cli_ctl/openapi_cache.py@@ -63,12 +63,11 @@ def load_spec() -> dict[str, Any] | None:spec, meta = _read_cache()# Freshness is TTL-only -- see the module docstring for why there is no- # version/ETag-based revalidation.- fresh = (- spec is not None- and meta- and (time.time() - float(meta.get("fetched_at", 0))) < ttl_seconds- )+ # version/ETag-based revalidation. A negative age means the wall clock+ # moved backwards (VM restore, container clock drift); treat that as+ # stale rather than "fresh forever".+ age = time.time() - float(meta.get("fetched_at", 0)) if meta else None+ fresh = spec is not None and age is not None and 0 <= age < ttl_secondsif fresh:return spec# Stale or missing: try to (re)fetch the full document.diff --git a/jarvis/cli_ctl/reserved.py b/jarvis/cli_ctl/reserved.pyindex fa9e674808..7cdc462695 100644--- a/jarvis/cli_ctl/reserved.py+++ b/jarvis/cli_ctl/reserved.py@@ -30,7 +30,6 @@ RESERVED_CONTROL_NAMES: frozenset[str] = frozenset("config","wiki","sessions",- "chats","skills","outputs","board",diff --git a/tests/unit/cli_ctl/test_openapi_cache.py b/tests/unit/cli_ctl/test_openapi_cache.pyindex f0e9db72e5..0b0b836265 100644--- a/tests/unit/cli_ctl/test_openapi_cache.py+++ b/tests/unit/cli_ctl/test_openapi_cache.py@@ -75,6 +75,29 @@ def test_no_cache_and_unreachable_returns_none(tmp_path, monkeypatch):assert oc.load_spec(_client(handler)) is None+def test_future_fetched_at_is_treated_as_stale(tmp_path, monkeypatch):+ """Backward clock skew (VM restore) must not pin the cache 'fresh' forever."""+ import time++ monkeypatch.setenv("JARVISCTL_CACHE_HOME", str(tmp_path))+ (tmp_path / "openapi.json").write_text(+ json.dumps({"openapi": "3.1.0", "info": {"version": "old"}, "paths": {}}),+ encoding="utf-8",+ )+ (tmp_path / "openapi.meta.json").write_text(+ json.dumps({"fetched_at": time.time() + 10 * 24 * 3600}), encoding="utf-8"+ )+ calls = {"n": 0}++ def handler(req):+ calls["n"] += 1+ return httpx.Response(200, json=SPEC) # info.version == "1"++ spec = oc.load_spec(_client(handler)) # default TTL; age is negative+ assert spec["info"]["version"] == "1"+ assert calls["n"] == 1++def test_refresh_clears_cache(tmp_path, monkeypatch):monkeypatch.setenv("JARVISCTL_CACHE_HOME", str(tmp_path))(tmp_path / "openapi.json").write_text("{}", encoding="utf-8")