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.

fix(headless): persist writable container state

Ruben Lütkecabe6c130fd0
diff --git a/Dockerfile b/Dockerfile
index 839bc38934..7c97b0c9df 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -10,6 +10,7 @@
#
# docker build -t personal-jarvis .
# docker run --rm -p 127.0.0.1:8000:8000 \
+# -v jarvis-data:/app/data \
# -e JARVIS_CONTROL_API_KEY=jctl_change_me \
# -e ANTHROPIC_API_KEY=sk-ant-... \
# personal-jarvis
@@ -70,8 +71,12 @@ EXPOSE 8000
# JARVIS_BIND_HOST=0.0.0.0 makes the headless listener reachable through the
# published port (the control key is the security boundary — see compose).
# JARVIS_NONINTERACTIVE skips the first-run wizard; keys come from the env.
+# Config and runtime data both live in the sole writable, persisted directory;
+# the application tree remains read-only to the non-root runtime user.
ENV JARVIS_BIND_HOST=0.0.0.0 \
- JARVIS_NONINTERACTIVE=1
+ JARVIS_NONINTERACTIVE=1 \
+ JARVIS_CONFIG=/app/data/jarvis.toml \
+ JARVIS_DATA_DIR=/app/data
# Generous start-period: first boot builds the brain in the background.
HEALTHCHECK --interval=30s --timeout=5s --start-period=60s --retries=6 \
diff --git a/docker-compose.yml b/docker-compose.yml
index 7cde30ca9e..073168c97e 100644
--- a/docker-compose.yml
+++ b/docker-compose.yml
@@ -33,6 +33,7 @@ services:
volumes:
# Persist runtime state (config, dbs, flight recorder) across restarts,
# isolated from the host — never touches the maintainer's data/ folder.
+ # The image points both JARVIS_CONFIG and JARVIS_DATA_DIR at this mount.
- jarvis-data:/app/data
volumes:
diff --git a/jarvis/platform/probes.py b/jarvis/platform/probes.py
index b91cb0a051..6f4662f1f1 100644
--- a/jarvis/platform/probes.py
+++ b/jarvis/platform/probes.py
@@ -54,8 +54,10 @@ def has_pty() -> bool:
"""Is a pseudo-terminal backend importable (Wave 1.1)?"""
if detect_platform() == "win32":
return _has_module("winpty")
- # POSIX: ptyprocess (added by Wave 1.1) or the stdlib pty fallback.
- return _has_module("ptyprocess") or _has_module("pty")
+ # UnixPtyBackend has one implemented POSIX backend: ptyprocess. The stdlib
+ # ``pty`` module alone is not sufficient and must not produce a false
+ # capability claim that later fails at ``UnixPtyBackend.spawn``.
+ return _has_module("ptyprocess")
def ax_permission_granted() -> bool | None:
diff --git a/tests/unit/core/test_container_persistence_contract.py b/tests/unit/core/test_container_persistence_contract.py
new file mode 100644
index 0000000000..92212e456e
--- /dev/null
+++ b/tests/unit/core/test_container_persistence_contract.py
@@ -0,0 +1,26 @@
+"""Static contract for the non-root headless container's writable state."""
+
+from __future__ import annotations
+
+from pathlib import Path, PurePosixPath
+
+_REPO_ROOT = Path(__file__).resolve().parents[3]
+_DATA_DIR = PurePosixPath("/app/data")
+_CONFIG_PATH = _DATA_DIR / "jarvis.toml"
+
+
+def test_non_root_image_keeps_config_inside_the_persisted_writable_volume() -> None:
+ """The runtime user must never need to write into the application tree."""
+ dockerfile = (_REPO_ROOT / "Dockerfile").read_text(encoding="utf-8")
+ compose = (_REPO_ROOT / "docker-compose.yml").read_text(encoding="utf-8")
+
+ assert f"JARVIS_CONFIG={_CONFIG_PATH.as_posix()}" in dockerfile
+ assert f"JARVIS_DATA_DIR={_DATA_DIR.as_posix()}" in dockerfile
+ assert _CONFIG_PATH.parent == _DATA_DIR
+ assert f"jarvis-data:{_DATA_DIR.as_posix()}" in compose
+
+ chown_data = "chown -R jarvis:jarvis /app/data"
+ non_root_user = "USER jarvis"
+ assert chown_data in dockerfile
+ assert non_root_user in dockerfile
+ assert dockerfile.index(chown_data) < dockerfile.index(non_root_user)
diff --git a/tests/unit/platform/test_probes.py b/tests/unit/platform/test_probes.py
index d0480467b8..c773864d9c 100644
--- a/tests/unit/platform/test_probes.py
+++ b/tests/unit/platform/test_probes.py
@@ -185,12 +185,24 @@ def test_has_elevation_linux_needs_pkexec_or_sudo(monkeypatch):
# --- has_pty / has_overlay -------------------------------------------------
-def test_has_pty_posix_accepts_stdlib_pty(monkeypatch):
- _force_platform(monkeypatch, "linux")
- monkeypatch.setattr(probes, "_has_module", lambda n: n == "pty")
[email protected]("platform", ["linux", "darwin"])
+def test_has_pty_posix_requires_implemented_ptyprocess_backend(
+ monkeypatch, platform
+):
+ _force_platform(monkeypatch, platform)
+ monkeypatch.setattr(probes, "_has_module", lambda n: n == "ptyprocess")
assert probes.has_pty() is True
[email protected]("platform", ["linux", "darwin"])
+def test_has_pty_posix_rejects_unimplemented_stdlib_pty_fallback(
+ monkeypatch, platform
+):
+ _force_platform(monkeypatch, platform)
+ monkeypatch.setattr(probes, "_has_module", lambda n: n == "pty")
+ assert probes.has_pty() is False
+
+
def test_has_overlay_requires_display_and_tkinter(monkeypatch):
monkeypatch.setattr(probes, "display_present", lambda: True)
monkeypatch.setattr(probes, "_has_module", lambda n: n == "tkinter")