The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(cli): say a held channel install is newer than the release and was held
arcabotai0cc3cff7906b
diff --git a/hermes_cli/update_cmd.py b/hermes_cli/update_cmd.pyindex 82252712ff3..1def7127dad 100644--- a/hermes_cli/update_cmd.py+++ b/hermes_cli/update_cmd.py@@ -1261,7 +1261,7 @@ def _switch_branch_at_commit_point(git_cmd, branch, target_ref, *, pre, stash):return result-def _hold_channel_release_behind_runtime(git_cmd, target_ref: str, channel: str, completion_request: dict) -> str | None:+def _hold_channel_release_behind_runtime(git_cmd, target_ref: str, channel: str) -> str | None:"""HEAD's sha when the channel's release predates the gateway runtime these stores use, else None.The channel picked the release, the user did not ask for that commit: moving there is the@@ -1274,11 +1274,11 @@ def _hold_channel_release_behind_runtime(git_cmd, target_ref: str, channel: str,head = _capture_head_sha(git_cmd, _m().PROJECT_ROOT)if not head:return None # HEAD unreadable: the refusal below still stops the move- print(f"→ This install is ahead of the {channel} release {target_ref[:12]}: that release predates the "+ # "newer", not "ahead": the release may sit beside HEAD's line rather than behind it (#140729).+ print(f"→ This build is newer than the {channel} release {target_ref[:12]}: that release predates the ""gateway runtime your sessions use, so there is nothing to update to yet.")print(f" Hermes stays on {head[:12]} until a newer {channel} release ships. ""To follow every commit instead: `hermes update --set-channel main`.")- completion_request["expected_sha"] = headreturn head@@ -1750,8 +1750,9 @@ def _finalize_receipt(status: str, debug_message: str) -> None:def _finish_already_up_to_date(git_cmd, branch: str, current_branch: str, _plan, *, gw_input_fn, completion_request: dict,- _windows_gateway_resume=None) -> None:+ _windows_gateway_resume=None, held_message: str | None = None) -> None:""""Already up to date" path: restore stash, repair the checkout, catch up the fleet.+ ``held_message`` replaces "Already up to date!" when the channel's release was held, not reached.``sys.exit(1)`` when the repair is incomplete (after gateway exit code + partial receipt)."""# A parked branch the update switched off stays on the target: re-parking on the stale branch# recreates the incident. No other checkout left current_branch (in-place and release updates@@ -1773,7 +1774,7 @@ def _finish_already_up_to_date(# Same code, same host obligation: an SHA-less arm would REPLACE the standing record# (and its restarted proof), so a sibling profile's no-op update re-kills the multiplexer.completion_request["expected_sha"] = _capture_head_sha(git_cmd, _m().PROJECT_ROOT) or ""- completion_request["completion_message"] = (+ completion_request["completion_message"] = held_message or ("✓ Already up to date!" if _plan.upstream_checkedelse "✓ Up to date with your fork (official repo not checked).")_complete_source_update(completion_request)@@ -1945,9 +1946,13 @@ def _cmd_update_impl(args, gateway_mode: bool):current_branch = _current_branch_name(git_cmd, check=True)_commit.record_run_start(git_cmd, _m().PROJECT_ROOT)+ held_message = Noneif release_sha and not target_is_head:- target_ref = _hold_channel_release_behind_runtime(- git_cmd, target_ref, _update_run_channel(args), completion_request) or target_ref+ channel = _update_run_channel(args)+ held = _hold_channel_release_behind_runtime(git_cmd, target_ref, channel)+ if held:+ target_ref = held+ held_message = f"✓ Holding at this build until a newer {channel} release ships."_refuse_before_commit_point(git_cmd, target_ref, _windows_gateway_resume)_plan = _prepare_checkout_for_update(git_cmd, branch, current_branch, is_fork=is_fork, assume_yes=assume_yes,@@ -1958,7 +1963,8 @@ def _cmd_update_impl(args, gateway_mode: bool):if commit_count == 0:_finish_already_up_to_date(git_cmd, branch, current_branch, _plan, gw_input_fn=gw_input_fn,- completion_request=completion_request, _windows_gateway_resume=_windows_gateway_resume)+ completion_request=completion_request, _windows_gateway_resume=_windows_gateway_resume,+ held_message=held_message)returnif release_sha:diff --git a/tests/hermes_cli/test_update_channel_release_hold.py b/tests/hermes_cli/test_update_channel_release_hold.pyindex 490e6bf2a78..8d17d080f4a 100644--- a/tests/hermes_cli/test_update_channel_release_hold.py+++ b/tests/hermes_cli/test_update_channel_release_hold.py@@ -1,7 +1,7 @@"""A channel whose release predates the gateway runtime holds the install where it is (#140729).The channel picked that release, the user did not ask to go back: ``hermes update`` reports that-the install is ahead of the release and exits like an up-to-date run, instead of refusing the+the build is newer than the release and holds there, exiting 0, instead of refusing thedowngrade on every attempt. An explicit ``--branch`` to a pre-runtime commit is still refused."""import argparse@@ -110,9 +110,11 @@ def test_a_channel_release_older_than_the_runtime_holds_the_install_and_exits_clout = capsys.readouterr().outassert git(source.root, "rev-parse", "HEAD") == source.installedassert "Refusing" not in out and "Downgrading is unsupported" not in out- assert f"ahead of the {name} release {source.release[:12]}" in out+ assert f"This build is newer than the {name} release {source.release[:12]}" in outassert "hermes update --set-channel main" in outassert len(source.completed) == 1 and source.completed[0]["expected_sha"] == source.installed+ # A held install is not up to date with its channel: the closing line says it was held.+ assert source.completed[0]["completion_message"] == f"✓ Holding at this build until a newer {name} release ships."def test_the_same_release_still_applies_while_no_store_holds_runtime_history(source, monkeypatch, capsys):@@ -123,7 +125,7 @@ def test_the_same_release_still_applies_while_no_store_holds_runtime_history(souupdate_cmd._cmd_update_impl(source.parser.parse_args(["update", "--yes"]), False)assert git(source.root, "rev-parse", "HEAD") == source.release- assert "ahead of the" not in capsys.readouterr().out+ assert "newer than the" not in capsys.readouterr().outassert source.completed[0]["expected_sha"] == source.release@@ -135,7 +137,7 @@ def test_an_explicit_branch_to_a_pre_runtime_commit_is_still_refused(source, monout = capsys.readouterr().outassert stopped.value.code == 1 and git(source.root, "rev-parse", "HEAD") == source.installed- assert "Downgrading is unsupported" in out and "ahead of the" not in out+ assert "Downgrading is unsupported" in out and "newer than the" not in outassert source.completed == []@@ -147,8 +149,9 @@ def _stable_publishes(monkeypatch, commit):def _assert_held_at_head(source, out, channel="stable"):assert git(source.root, "rev-parse", "HEAD") == source.installedassert "Refusing" not in out and "Downgrading is unsupported" not in out- assert f"ahead of the {channel} release" in out+ assert f"This build is newer than the {channel} release" in outassert len(source.completed) == 1 and source.completed[0]["expected_sha"] == source.installed+ assert source.completed[0]["completion_message"] == f"✓ Holding at this build until a newer {channel} release ships."@pytest.mark.parametrize("argv", [