The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix: a historical takeover reaches its child on a cp1252 Windows pipe
Tekniumb0cead1d48d9
diff --git a/hermes_cli/_old_updater.py b/hermes_cli/_old_updater.pyindex 4ec20966490..69250d60af0 100644--- a/hermes_cli/_old_updater.py+++ b/hermes_cli/_old_updater.py@@ -125,7 +125,10 @@ def _run_child(request: dict) -> tuple[int, dict]:env.setdefault("HERMES_UPDATE_HANDOFF_PID", str(os.getpid()))# Everything the user saw so far came from the OLD updater; say so before the# new one (package manager) takes over, so logs show where the switch happened.- print("→ Handing off to the new updater (package manager) for the rest of this update...", flush=True)+ # ASCII only, like every line printed before the child starts: a Windows pipe encodes this+ # process's stdout in the ANSI code page, and a non-cp1252 character raised here, before the+ # takeover ever ran (review S1).+ print("-> Handing off to the new updater (package manager) for the rest of this update...", flush=True)with tempfile.TemporaryDirectory(prefix="hermes-update-takeover-") as directory:context = Path(directory) / "request.json"result = Path(directory) / "result.json"@@ -158,7 +161,7 @@ def _run_in_custody(argv: list, root: Path, **kwargs) -> int:try:refusal = bind(proc)if refusal is not None:- print(f" ⚠ The update's job would not take the takeover ({refusal}); it runs outside the job, "+ print(f" ! The update's job would not take the takeover ({refusal}); it runs outside the job, ""holding its own checkout lease.", flush=True)resume(proc)# The takeover is the rest of a committed update (sync + build): a bound would abandon itdiff --git a/tests/hermes_cli/test_old_updater_takeover.py b/tests/hermes_cli/test_old_updater_takeover.pyindex 32870b23557..2ecc8de3d9e 100644--- a/tests/hermes_cli/test_old_updater_takeover.py+++ b/tests/hermes_cli/test_old_updater_takeover.py@@ -136,7 +136,10 @@ def test_shipped_post_swap_argv_enters_takeover_before_current_cli(tmp_path):@pytest.mark.parametrize("status", [0, 7])@pytest.mark.parametrize("encoding", ["utf-8", "utf-8-sig"])@pytest.mark.parametrize("desktop", [None, False, True])-def test_takeover_waits_propagates_status_and_never_reenters_old_code(tmp_path, status, encoding, desktop):+# A Windows console/pipe in the ANSI code page: the old updater's stdout encodes strictly in cp1252,+# and its hand-off banner runs before the child starts (review S1).[email protected]("stdio", [None, "cp1252:strict"])+def test_takeover_waits_propagates_status_and_never_reenters_old_code(tmp_path, status, encoding, desktop, stdio):source = Path(__file__).resolve().parents[2]root = tmp_path / "updated checkout"package = root / "hermes_cli"@@ -184,8 +187,10 @@ def test_takeover_waits_propagates_status_and_never_reenters_old_code(tmp_path,env = {key: value for key, value in os.environ.items()if not key.startswith(('HERMES_', 'PYTHON', 'UV_'))}env.update(HOME=str(home), HERMES_HOME=str(home), PYTHONPATH="/not/the/new/source")+ if stdio:+ env["PYTHONIOENCODING"] = stdioresult = subprocess.run([sys.executable, "-B", str(program)], env=env,- capture_output=True, text=True, timeout=30)+ capture_output=True, text=True, encoding="utf-8", errors="replace", timeout=30)assert result.returncode == status, result.stdout + result.stderrassert (home / "runs").read_text() == "child\n"assert (home / "cleanup").read_text() == "ran"