HarnessRouter Community Edition: the self-hosted, Apache-2.0 edition of the unified interface for agent harnesses. Run Codex, Claude Code, Hermes, PI, DSH, and more through one API, with sessions, streaming, files, cancellation, and failure handling. Implements the Unified Harness Protocol (UHP), an open standard. Your keys, your infrastructure.
Python agent-apiagent-frameworkagent-harnessai-agentsai-infrastructurecoding-agentconformance-testingdeepseek-harnessharness-engineeringhermesllmopen-protocolopen-sourceopen-standardpi-coding-agentself-hosteduhpunified-apiunified-harness-protocolunified-interface
runner: the checkpoint spool directory is one the runner can write to (#464)
github-actions[bot]fb4dc79e85b4
diff --git a/runner/server.py b/runner/server.pyindex cac7bce5..ce7bd031 100644--- a/runner/server.py+++ b/runner/server.py@@ -664,11 +664,21 @@ async def _internal_callers_only(request: Request, call_next):# re-tarred) AND on a real DISK, not a RAM-backed tmpfs (which would defeat the memory saving).# Default: a dedicated dir on the container's disk-backed rootfs (same overlay as /workspace on# ACA Dynamic Sessions), created at import. Override with HARNESS_SPOOL_DIR if the runtime differs.-SPOOL_DIR = os.environ.get("HARNESS_SPOOL_DIR", "/var/tmp/harness-spool")-try:- os.makedirs(SPOOL_DIR, exist_ok=True)-except OSError:- SPOOL_DIR = None # fall back to the OS tmpdir if that path isn't writable+def _spool_dir(path: str) -> str | None:+ """`path`, created if missing, when this process can create files in it; else None, which+ tempfile reads as the OS tmpdir. An EXISTING directory counts only if it is writable: on the+ hosted service an image build imported this module as root, which left the default path+ root-owned at 755, and the runner, running as another user, then failed every checkpoint and+ every hydrate with EACCES at mkstemp (2026-10-14). This image runs the runner as root and imports+ nothing at build time, but a container started with `--user` meets the same directory."""+ try:+ os.makedirs(path, exist_ok=True)+ except OSError:+ return None+ return path if os.access(path, os.W_OK | os.X_OK) else None+++SPOOL_DIR = _spool_dir(os.environ.get("HARNESS_SPOOL_DIR", "/var/tmp/harness-spool"))_SPOOL_STALE_S = 3600 # a spool file older than this can't belong to a live transferdiff --git a/runner/tests/test_spool_dir.py b/runner/tests/test_spool_dir.pynew file mode 100644index 00000000..673009ec--- /dev/null+++ b/runner/tests/test_spool_dir.py@@ -0,0 +1,33 @@+"""The checkpoint spool directory must be one the runner can write to. On the hosted service an image+build imported server.py as root, which left /var/tmp/harness-spool root-owned at 755; its runner runs+as another user, so every checkpoint and every hydrate failed at mkstemp with EACCES for 18 hours+(2026-10-14). An existing directory it cannot write to now falls back to the OS tmpdir, as a missing+one did."""+import os+import pathlib+import sys+import tempfile++import pytest++sys.path.insert(0, str(pathlib.Path(__file__).resolve().parents[1]))+import server as rn # noqa: E402+++def test_a_writable_directory_is_kept_and_a_missing_one_is_created(tmp_path):+ assert rn._spool_dir(str(tmp_path)) == str(tmp_path)+ fresh = tmp_path / "spool"+ assert rn._spool_dir(str(fresh)) == str(fresh) and fresh.is_dir()++[email protected](os.geteuid() == 0, reason="root writes anywhere, so the case cannot be built")+def test_an_existing_directory_it_cannot_write_to_falls_back_to_the_tmpdir(tmp_path):+ locked = tmp_path / "harness-spool"+ locked.mkdir(mode=0o755)+ locked.chmod(0o555) # what a root-owned 755 directory is to another user+ try:+ assert rn._spool_dir(str(locked)) is None+ fd, p = tempfile.mkstemp(suffix=".tgz", dir=rn._spool_dir(str(locked))) # what hydrate does+ os.close(fd); os.unlink(p)+ finally:+ locked.chmod(0o755)