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
produced files: a non-ASCII name is listed as the agent wrote it, so the gateway can fetch it (#551)
Rudy Mizrahi Celekli661f232a5e56
diff --git a/runner/server.py b/runner/server.pyindex f58dd456..758a50af 100644--- a/runner/server.py+++ b/runner/server.py@@ -12979,22 +12979,34 @@ def _produced_list(ws: str) -> list[dict]:_collected_init(ws)seen: dict[str, str] = {}if _git(ws, "rev-parse", "-q", "--verify", _COLLECTED_REF).returncode == 0:- d = _git(ws, "diff", "--name-status", _COLLECTED_REF)- for line in (d.stdout or "").splitlines():- parts = line.split("\t")- if len(parts) < 2:- continue- status, path = parts[0], parts[-1].strip().strip('"')- if _produced_keep(status, path):+ # -z: git's NUL-separated output, which is never quoted or escaped. Without it git renders a+ # non-ASCII path as \NNN octal escapes inside double quotes (core.quotepath only stops those),+ # and a path holding a double quote, a backslash, a tab or a newline is quoted and escaped+ # whatever the config: the name handed on was a spelling no file has, so it could not be+ # stat'ed (mtime 0, size 0) and the gateway's GET /file 404'd while the ack advanced the cursor+ # past it. Both readers below read -z so they cannot disagree.+ d = _git(ws, "diff", "--name-status", "-z", _COLLECTED_REF)+ toks = (d.stdout or "").split("\0")+ i = 0+ while i < len(toks) - 1:+ status = toks[i]+ if status[:1] in ("R", "C"): # a rename or copy: the old path, then the new one+ path, i = toks[i + 2] if i + 2 < len(toks) else "", i + 3+ else:+ path, i = toks[i + 1], i + 2+ if path and _produced_keep(status, path):seen[path] = status[:1]- p = _git(ws, "status", "--porcelain", "-uall")- for line in (p.stdout or "").splitlines():- if len(line) < 4:+ p = _git(ws, "status", "--porcelain", "-z", "-uall")+ toks = (p.stdout or "").split("\0")+ i = 0+ while i < len(toks):+ entry = toks[i]+ i += 1+ if len(entry) < 4:continue- status, path = line[:2], line[3:]- if " -> " in path: # rename: take the new path- path = path.split(" -> ", 1)[1]- path = path.strip().strip('"')+ status, path = entry[:2], entry[3:]+ if "R" in status or "C" in status: # -z gives the new path here and the old one next+ i += 1if _produced_keep(status, path):seen.setdefault(path, status.strip() or "?")keep = set(_without_lo_profiles(list(seen)))diff --git a/runner/tests/test_produced_cursor.py b/runner/tests/test_produced_cursor.pyindex 29a09b69..77c8b9ac 100644--- a/runner/tests/test_produced_cursor.py+++ b/runner/tests/test_produced_cursor.py@@ -131,3 +131,51 @@ def test_each_produced_item_says_how_big_it_is():(pathlib.Path(d) / "out" / "a.txt").write_text("abc")by = {f["path"]: f for f in _produced_list(d)}assert by["hero.png"]["size"] == 4096 and by["out/a.txt"]["size"] == 3+++def test_a_non_ascii_name_is_listed_as_the_agent_wrote_it():+ """git renders a non-ASCII path as \\NNN octal escapes in double quotes unless core.quotepath+ is off, and the listing's unquoting does not undo them. An escaped name is a name no file has:+ it cannot be stat'ed (mtime 0, size 0) and the gateway's GET /file 404s on it — whereupon+ _collect_produced `continue`s and acks anyway, stranding the artifact for good. Both readers+ (untracked via status, committed via diff) are checked, since they must never disagree.+ An ASCII name beside it pins that ordinary paths are unchanged."""+ d = _ws()+ accented = "résumé.pptx"+ (pathlib.Path(d) / accented).write_text("x" * 11)+ (pathlib.Path(d) / "plain.txt").write_text("y" * 7)+ # the premise: git really does quote this name under the default config+ raw = _git(d, "status", "--porcelain", "-uall").stdout+ assert '\\303\\251' in raw, f"fixture name is not quoted by this git; the test proves nothing: {raw!r}"++ by = {f["path"]: f for f in _produced_list(d)} # untracked reader (status)+ assert set(by) == {accented, "plain.txt"}+ assert by[accented]["size"] == 11 and by[accented]["mtime"] > 0+ assert by["plain.txt"]["size"] == 7 and by["plain.txt"]["mtime"] > 0++ _git(d, "add", "-A")+ _git(d, "commit", "-q", "-m", "checkpoint")+ by = {f["path"]: f for f in _produced_list(d)} # committed reader (diff vs the cursor)+ assert set(by) == {accented, "plain.txt"}+ assert by[accented]["size"] == 11 and by[accented]["mtime"] > 0+++def test_a_name_git_would_escape_whatever_the_config_is_listed_as_written():+ """core.quotepath stops only the octal escapes of non-ASCII bytes: git still quotes and escapes a+ path holding a double quote, a backslash, a tab or a newline, so such a name was listed in an+ escaped spelling no file has (and stranded as above). The listings read git's NUL-separated+ output (-z), which is never quoted, for untracked and for committed files, renames included."""+ d = _ws()+ names = ['say "hi".txt', 'back\\slash.txt', 'tab\there.txt', 'two\nlines.txt', 'résumé.pptx']+ for i, n in enumerate(names):+ (pathlib.Path(d) / n).write_text("z" * (i + 1))+ by = {f["path"]: f for f in _produced_list(d)} # untracked+ assert set(by) == set(names)+ assert all(by[n]["size"] == i + 1 for i, n in enumerate(names))+ _git(d, "add", "-A")+ _git(d, "commit", "-q", "-m", "agent's own commit")+ _git(d, "mv", 'say "hi".txt', 'said "hi".txt')+ _git(d, "commit", "-q", "-m", "renamed")+ by = {f["path"]: f for f in _produced_list(d)} # committed past the cursor (diff), a rename among them+ assert set(by) == (set(names) - {'say "hi".txt'}) | {'said "hi".txt'}+ assert by['said "hi".txt']["size"] == 1 and by['two\nlines.txt']["mtime"] > 0