The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix: startup gateway recovery prints to stderr, never the command's stdout
Tekniume7704fb7a428
diff --git a/hermes_cli/update_cmd_windows.py b/hermes_cli/update_cmd_windows.pyindex 5f7388b11a4..3a74f8873a9 100644--- a/hermes_cli/update_cmd_windows.py+++ b/hermes_cli/update_cmd_windows.py@@ -5,7 +5,7 @@ Origin helpers are imported lazily per function (no cycle; test patches on the o"""import logging-from contextlib import contextmanager, suppress+from contextlib import contextmanager, nullcontext, redirect_stdout, suppressimport osimport reimport shlex@@ -1516,6 +1516,14 @@ def _resume_windows_gateways_after_update(token: dict | None) -> None:if not _m()._is_windows():token["resume_needed"] = Falsereturn+ # Startup recovery runs ahead of an unrelated command whose stdout may be parsed (``--json``):+ # its notices go to stderr, as ``recover()``'s own do.+ with redirect_stdout(sys.stderr) if token.get("recovery") else nullcontext():+ _resume_unless_torn(token)+++def _resume_unless_torn(token: dict) -> None:+ """Resume the paused set, or leave it owed when the checkout is not whole."""from hermes_cli import update_pause_record as pause_recordif token.get("pause_id"):whole, why = pause_record.tree_is_whole(token)diff --git a/tests/hermes_cli/test_update_pause_recovery_stdout.py b/tests/hermes_cli/test_update_pause_recovery_stdout.pynew file mode 100644index 00000000000..740792ee182--- /dev/null+++ b/tests/hermes_cli/test_update_pause_recovery_stdout.py@@ -0,0 +1,25 @@+"""Startup recovery never writes to the stdout of the command it runs ahead of.++``update_pause_record.recover()`` resumes gateways an interrupted update paused before ANY ``hermes``+command (``--json`` ones included) and prints its own notices to stderr; the Windows resume path it+calls must do the same. Real resume entry point; seams are the Windows dispatch and the tree gate's+verdict (a torn checkout), so the deferral notice is what gets printed.+"""++from __future__ import annotations++from hermes_cli import update_pause_record as pause_record+from hermes_cli.update_cmd_windows import _resume_windows_gateways_after_update+++def test_a_recovering_resume_prints_its_notices_to_stderr(monkeypatch, capsys):+ from hermes_cli import main+ monkeypatch.setattr(main, "_is_windows", lambda: True)+ monkeypatch.setattr(pause_record, "tree_is_whole", lambda token: (False, "the checkout is mid-pull"))+ token = {"resume_needed": True, "pause_id": "p", "recovery": True, "profiles": {"default": 4242}}++ _resume_windows_gateways_after_update(token)+ out, err = capsys.readouterr()+ assert out == "", "recovery wrote to the unrelated command's stdout"+ assert "left stopped: the checkout is mid-pull" in err+ assert token["resume_deferred"] == "the checkout is mid-pull"