From 1c357a575055cd8b5cced2e35b34a8c456658368 Mon Sep 17 00:00:00 2001 From: skl <57862504+sklsp@users.noreply.github.com> Date: Sat, 21 Nov 2026 22:35:25 +0100 Subject: [PATCH 1/2] Q1: decode git, cline and lms output as UTF-8 2443 passed in 117.74s (0:01:57) PowerShell calls checked, none changed: clipboard_read already passes encoding=utf-8 with its _UTF8 prefix; clipboard_write, screenshot and _capture have no _UTF8 prefix; shortcut_main has no _UTF8 prefix. tools.py nvidia-smi output is ASCII, left alone. --- CHANGELOG.md | 1 + PROGRESS-qwen89.md | 3 +++ iris/agents.py | 3 ++- iris/autopilot.py | 2 ++ iris/dashboard/__init__.py | 2 +- tests/test_agents.py | 16 ++++++++++++++++ tests/test_autopilot.py | 18 ++++++++++++++++++ tests/test_dashboard_branches.py | 25 +++++++++++++++++++++++-- 8 files changed, 66 insertions(+), 4 deletions(-) create mode 100644 PROGRESS-qwen89.md diff --git a/CHANGELOG.md b/CHANGELOG.md index 61f670a..27b4fab 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -23,6 +23,7 @@ - ruff now also checks the SIM, PIE, C4, RET and PERF rule sets on iris/ and tests/, and every finding was fixed without changing behaviour. - ruff now also checks the PTH and RUF rule sets on iris/ and tests/, and every finding was fixed without changing behaviour; the protected files keep their per-file ignores for the new rules too. - Tests are type-checked by mypy as well; 14 test modules still sit on the ignore list until they are typed. +- git, Cline CLI and lms output are decoded as UTF-8 with replacement, so the dashboard's agent status and autopilot survive any text on a non-UTF-8 locale code page. ## 1.0.0 (release date): steady, safer and measured diff --git a/PROGRESS-qwen89.md b/PROGRESS-qwen89.md new file mode 100644 index 0000000..fa4bf0d --- /dev/null +++ b/PROGRESS-qwen89.md @@ -0,0 +1,3 @@ +# Progress: nightshift run qwen89 (repo W:/Iris, branch night-qwen-89) + +- [x] Q1. decode git, cline and lms output as UTF-8 (2443 passed in 117.74s (0:01:57)) diff --git a/iris/agents.py b/iris/agents.py index 853629b..23930ff 100644 --- a/iris/agents.py +++ b/iris/agents.py @@ -123,7 +123,8 @@ def discover(cfg: Config | None = None) -> list[tuple[str, Path]]: def _git(repo: Path, *args: str) -> str: """Run a read-only, lock-free git command in `repo`. Raises on failure so the caller can report it.""" cmd = ["git", "--no-optional-locks", "-C", str(repo), *args] # never takes the index lock - proc = subprocess.run(cmd, capture_output=True, text=True, timeout=GIT_TIMEOUT, check=False) + proc = subprocess.run(cmd, capture_output=True, text=True, encoding="utf-8", errors="replace", + timeout=GIT_TIMEOUT, check=False) if proc.returncode != 0: raise RuntimeError((proc.stderr or "git failed").strip().splitlines()[-1]) return proc.stdout diff --git a/iris/autopilot.py b/iris/autopilot.py index e3a5994..1a683c2 100644 --- a/iris/autopilot.py +++ b/iris/autopilot.py @@ -73,6 +73,7 @@ def cline_sessions( capture_output=True, text=True, encoding="utf-8", + errors="replace", timeout=30, stdin=subprocess.DEVNULL, check=False, @@ -131,6 +132,7 @@ def _dispatch(text: str, cwd: str, run: Callable[..., subprocess.CompletedProces capture_output=True, text=True, encoding="utf-8", + errors="replace", timeout=120, stdin=subprocess.DEVNULL, check=False, diff --git a/iris/dashboard/__init__.py b/iris/dashboard/__init__.py index b7c904b..46eba07 100644 --- a/iris/dashboard/__init__.py +++ b/iris/dashboard/__init__.py @@ -246,7 +246,7 @@ def run_lms(args: list[str]) -> tuple[int, str]: exe = _lms_exe() if not exe: raise ModelActionError(503, "no lms executable found: set IRIS_LMS_BIN or put lms on PATH") - proc = subprocess.run([exe, *args], capture_output=True, text=True, + proc = subprocess.run([exe, *args], capture_output=True, text=True, encoding="utf-8", errors="replace", timeout=LMS_TIMEOUT_SECONDS) return proc.returncode, (proc.stderr or proc.stdout or "").strip() diff --git a/tests/test_agents.py b/tests/test_agents.py index b0858c9..6230072 100644 --- a/tests/test_agents.py +++ b/tests/test_agents.py @@ -56,6 +56,22 @@ def test_uncommitted_files_are_counted(tmp_path): assert repo_status(repo).uncommitted == 2 +def test_repo_status_reads_utf8_subjects_and_file_names(tmp_path): + """git output is decoded as UTF-8, so a non-ASCII subject and file name survive the locale code page.""" + repo = tmp_path / "cafe" + repo.mkdir() + git(repo, "init", "-b", "main") + git(repo, "config", "user.email", "iris@test.local") + git(repo, "config", "user.name", "Iris test") + (repo / "a.txt").write_text("hello", encoding="utf-8") + git(repo, "add", "a.txt") + git(repo, "commit", "-m", "fix café ☕") + (repo / "notities-é.txt").write_text("new", encoding="utf-8") + s = repo_status(repo) + assert s.exists and s.last_commit == "fix café ☕" # the subject comes back exactly as committed + assert s.uncommitted == 1 # the accented file name is counted, not garbled + + def test_stuck_needs_both_uncommitted_changes_and_an_old_commit(tmp_path): fresh = make_repo(tmp_path, "fresh", minutes_ago=5) (fresh / "b.txt").write_text("new", encoding="utf-8") diff --git a/tests/test_autopilot.py b/tests/test_autopilot.py index de25137..28e59af 100644 --- a/tests/test_autopilot.py +++ b/tests/test_autopilot.py @@ -13,6 +13,7 @@ from iris.agent import Journal from iris.autopilot import ( _count_started, + _dispatch, _started_at_epoch, cline_cli, cline_command, @@ -319,12 +320,29 @@ def fake_run(argv, **kwargs): "capture_output": True, "text": True, "encoding": "utf-8", + "errors": "replace", "timeout": 30, "stdin": subprocess.DEVNULL, "check": False, } +def test_dispatch_decodes_cli_output_as_utf8(monkeypatch): + """The CLI's output is decoded as UTF-8 with replacement, so any text survives the locale code page.""" + _clear_cli_env(monkeypatch) + calls: list[tuple[list[str], dict[str, object]]] = [] + + def fake_run(argv, **kwargs): + calls.append((argv, kwargs)) + return SimpleNamespace(stderr="") + + out = _dispatch("fix the bug", "W:/Iris", run=fake_run) + assert out == "" # empty stderr means nothing to report + argv, kwargs = calls[0] + assert argv[-1] == "fix the bug" # the prompt stays one argv item + assert kwargs["encoding"] == "utf-8" and kwargs["errors"] == "replace" + + def test_started_at_epoch_of_a_non_string_is_none(): assert _started_at_epoch(None) is None assert _started_at_epoch(1_700_000_000) is None diff --git a/tests/test_dashboard_branches.py b/tests/test_dashboard_branches.py index 13bc186..4ad8b39 100644 --- a/tests/test_dashboard_branches.py +++ b/tests/test_dashboard_branches.py @@ -33,8 +33,8 @@ class Proc: monkeypatch.setattr(d, "_lms_exe", lambda: "/fake/lms") calls = [] - def fake_run(cmd, capture_output=True, text=True, timeout=600): - calls.append((cmd, timeout)) + def fake_run(cmd, **kwargs): + calls.append((cmd, kwargs)) return Proc() monkeypatch.setattr("iris.dashboard.subprocess.run", fake_run) @@ -43,6 +43,27 @@ def fake_run(cmd, capture_output=True, text=True, timeout=600): assert calls[0][0] == ["/fake/lms", "load", "m"] +def test_run_lms_decodes_output_as_utf8(monkeypatch): + """lms output is decoded as UTF-8 with replacement, so any text survives the locale code page.""" + + class Proc: + returncode = 0 + stderr = "" + stdout = "loaded\n" + + calls: list[dict[str, object]] = [] + + def fake_run(cmd, **kwargs): + calls.append(kwargs) + return Proc() + + monkeypatch.setattr(d, "_lms_exe", lambda: "/fake/lms") + monkeypatch.setattr("iris.dashboard.subprocess.run", fake_run) + code, out = d.run_lms(["load", "m"]) + assert (code, out) == (0, "loaded") # empty stderr, so the stripped stdout wins + assert calls[0]["encoding"] == "utf-8" and calls[0]["errors"] == "replace" + + def test_model_action_rejects_a_body_that_is_not_an_object(): with pytest.raises(d.ModelActionError) as exc: d.model_action("load", cast(dict[str, Any], ["not", "a", "dict"])) From ce534b7b34aeab39a5ae5aa1f793d45e139556c3 Mon Sep 17 00:00:00 2001 From: skl <57862504+sklsp@users.noreply.github.com> Date: Sat, 21 Nov 2026 22:38:46 +0100 Subject: [PATCH 2/2] chore: drop the qwen89 progress file --- PROGRESS-qwen89.md | 3 --- 1 file changed, 3 deletions(-) delete mode 100644 PROGRESS-qwen89.md diff --git a/PROGRESS-qwen89.md b/PROGRESS-qwen89.md deleted file mode 100644 index fa4bf0d..0000000 --- a/PROGRESS-qwen89.md +++ /dev/null @@ -1,3 +0,0 @@ -# Progress: nightshift run qwen89 (repo W:/Iris, branch night-qwen-89) - -- [x] Q1. decode git, cline and lms output as UTF-8 (2443 passed in 117.74s (0:01:57))