The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(update): hold a refused release on every check surface, cached or not
ethernetb69c75ea08d7
diff --git a/apps/desktop/src/components/update-status.tsx b/apps/desktop/src/components/update-status.tsxindex 385eec7d0a3..51abbdfe3ff 100644--- a/apps/desktop/src/components/update-status.tsx+++ b/apps/desktop/src/components/update-status.tsx@@ -172,14 +172,14 @@ function currentLine(latestRelease?: (version: string) => string,held?: (version: string) => string): string {- if (target === 'backend') {- return u.latestBodyBackend- }-if (held && status.held && status.sourceVersion) {return held(`v${status.sourceVersion}`)}+ if (target === 'backend') {+ return u.latestBodyBackend+ }+// Stable pins to a release; name it. A checkout ahead of it (forward-only) is newer// than the release, so it keeps the generic line instead of claiming to be on it.const pinned =diff --git a/apps/desktop/src/store/updates-backend-check.test.ts b/apps/desktop/src/store/updates-backend-check.test.tsindex a4175c7dd57..1df7510d1dc 100644--- a/apps/desktop/src/store/updates-backend-check.test.ts+++ b/apps/desktop/src/store/updates-backend-check.test.ts@@ -1,5 +1,7 @@import { describe, expect, it } from 'vitest'+import { deriveUpdateStatus } from '@/components/update-status'+import { en } from '@/i18n/en'import type { BackendUpdateCheckResponse } from '@/types/hermes'import { mapBackendCheck } from './updates'@@ -38,6 +40,22 @@ describe('mapBackendCheck', () => {expect(status.updateAvailable).not.toBe(true)})+ it('names a held backend instead of calling it the latest version', () => {+ const status = mapBackendCheck(response({ held: 'downgrade', source_version: '0.22.2' }))++ const view = deriveUpdateStatus({+ apply: { applying: false, stage: 'idle', message: '', percent: null, error: null, command: null, log: [] },+ checking: false,+ held: en.settings.about.channel.heldBody,+ status,+ target: 'backend',+ u: en.updates+ })++ expect(view.updateAvailable).toBe(false)+ expect(view.line).toBe(en.settings.about.channel.heldBody('v0.22.2'))+ })+it('keeps a real gap intact', () => {const status = mapBackendCheck(response({ behind: 3, update_available: true }))diff --git a/apps/desktop/src/store/updates.ts b/apps/desktop/src/store/updates.tsindex 39b02311b7a..4696e9a532b 100644--- a/apps/desktop/src/store/updates.ts+++ b/apps/desktop/src/store/updates.ts@@ -522,7 +522,8 @@ export function mapBackendCheck(res: BackendUpdateCheckResponse): DesktopUpdateSmessage: res.message ?? undefined,updateAvailable: res.update_available,rollback: Boolean(res.rollback_to),- sourceVersion: res.rollback_to ?? undefined,+ held: res.held ?? undefined,+ sourceVersion: res.rollback_to ?? (res.held ? res.source_version : undefined) ?? undefined,behind: behind === null || behind < 0 ? null : behind,currentVersion: res.current_version,channel: res.channel,diff --git a/apps/desktop/src/types/hermes.ts b/apps/desktop/src/types/hermes.tsindex 5c89cca548f..513e0d6e2b2 100644--- a/apps/desktop/src/types/hermes.ts+++ b/apps/desktop/src/types/hermes.ts@@ -1610,6 +1610,8 @@ export interface BackendUpdateCheckResponse {update_available: boolean/** A stable release this build already contains: applying it moves back. */rollback_to?: null | string+ /** A stable release `hermes update` refuses: the backend stays on its build. */+ held?: 'downgrade' | null/** Update-available only; absent on older backends. */channel?: stringbranch?: null | stringdiff --git a/hermes_cli/source_check.py b/hermes_cli/source_check.pyindex e2d992a29a1..34fac01ea60 100644--- a/hermes_cli/source_check.py+++ b/hermes_cli/source_check.py@@ -300,6 +300,16 @@ def _update_refuses(co: _Checkout, target: str, home: Path) -> bool:return would_refuse(co.root, target, home, git=git)+def _hold_refused_release(result: dict, co: _Checkout, home: Path) -> None:+ """Hold an offered release `hermes update` refuses (it predates the gateway runtime these session+ stores use). Covers releases off this checkout's history too, which the ancestry-only rollback+ test cannot see. Runs on cached offers as well: the stores gain runtime history between checks,+ and a release object the checkout has not fetched yet proves nothing until the update fetches it."""+ target = result.get("targetSha")+ if result.get("updateAvailable") and target and _update_refuses(co, target, home):+ result.update(updateAvailable=False, behind=0, held="downgrade")++def _resolve_channel(result: dict, channel: str, co: _Checkout, home: Path, *, forward_only: bool = False):"""Resolve a release channel's target into ``result``; the SourceTarget, or None on error.@@ -325,11 +335,7 @@ def _resolve_channel(result: dict, channel: str, co: _Checkout, home: Path, *, f# not a new update. Local ancestry only; an unknown relation stays an update.result["rollback"] = bool(co.head and co.head != target and not co.embedded and _git_ok(["merge-base", "--is-ancestor", target, co.head], cwd=co.root, git=co.git))- if result["updateAvailable"] and _update_refuses(co, target, home):- # `hermes update` refuses this release (it predates the gateway runtime these session- # stores use), so it is held, not offered. Covers releases off this checkout's history- # too, which the ancestry-only rollback test cannot see.- result.update(updateAvailable=False, behind=0, held="downgrade")+ _hold_refused_release(result, co, home)if source_target.retired:result["retirement"] = {"destination": source_target.channel, "sourceOnly": True}return source_target@@ -460,7 +466,10 @@ def check_for_updates(*, install_root: Path | None = None, home: Path | None = Nnow = time.time()cached = None if force else _cached_status(cache_file, identity, now)if cached is not None:- return {**cached, "dirty": co.dirty, "currentBranch": co.current_branch}+ cached = {**cached, "dirty": co.dirty, "currentBranch": co.current_branch}+ if cached.get("channel"):+ _hold_refused_release(cached, co, home)+ return cachedresult["fetchedAt"] = int(now * 1000)source_target = Noneif not _is_full_sha(co.head):diff --git a/hermes_cli/update_cmd_check.py b/hermes_cli/update_cmd_check.pyindex 6f73bb67908..80dd1b12a85 100644--- a/hermes_cli/update_cmd_check.py+++ b/hermes_cli/update_cmd_check.py@@ -102,14 +102,15 @@ def channel_compare_branch(selected_channel: str, git_cmd: list[str], root: Pathprint(f"✓ No newer release: {target.label}.")elif _uc()._capture_head_sha(git_cmd, root) == target.commit:print(f"✓ Up to date with the latest release ({target.label}).")+ elif _refuses(git_cmd, root, target.commit):+ # Before the rollback branch: a release this checkout contains is held too, not moved back to.+ print(f"→ Holding at this build: {target.label} predates the gateway runtime your sessions use.")+ print(" `hermes update` stays on this build; the next release that includes the runtime"+ " installs normally (`hermes update --set-channel main` follows every commit).")elif _git(git_cmd, root, ["merge-base", "--is-ancestor", target.commit, "HEAD"]).returncode == 0:print(f"→ This checkout is newer than the selected release: {target.label}.")print(" `hermes update` moves it back to that release"" (`hermes update --set-channel main` follows every commit).")- elif _refuses(git_cmd, root, target.commit):- print(f"→ Holding at this build: {target.label} predates the gateway runtime your sessions use.")- print(" `hermes update` will not move back to it; the next stable release that includes the"- " runtime installs normally (`hermes update --set-channel main` follows every commit).")else:print(f"→ Selected release available: {target.label}")print(" Run `hermes update` to install it.")diff --git a/hermes_cli/web_routers/actions.py b/hermes_cli/web_routers/actions.pyindex 8265e90f96e..85c784d6c47 100644--- a/hermes_cli/web_routers/actions.py+++ b/hermes_cli/web_routers/actions.py@@ -337,6 +337,11 @@ async def check_hermes_update(force: bool = False, profile: Optional[str] = Nonepayload["behind"] = behindif behind is None:payload["message"] = "Couldn't reach the update source — try again later."+ elif behind == 0 and status.get("held"):+ version = status.get("sourceVersion")+ payload.update(held=status["held"], source_version=version,+ message=f"This build is newer than stable release v{version}, which predates the gateway "+ "runtime its sessions use. It stays on this build until a newer release ships.")elif behind == 0:payload["message"] = "You're on the latest version."else:diff --git a/tests/hermes_cli/test_source_check.py b/tests/hermes_cli/test_source_check.pyindex aefea2f24dc..eece237a1ce 100644--- a/tests/hermes_cli/test_source_check.py+++ b/tests/hermes_cli/test_source_check.py@@ -625,3 +625,9 @@ def test_stable_release_the_updater_refuses_is_held_not_offered(installation, tmassert status["rollback"] is False # off-history: the ancestry test alone cannot see itassert status["updateAvailable"] is not ledgeredassert status.get("held") == ("downgrade" if ledgered else None)++ if not ledgered:+ # The first runtime turn lands after an offer was cached: the next passive check holds it.+ _ledgered_store(home)+ cached = check_for_updates(install_root=root, home=home, channel="stable")+ assert cached["updateAvailable"] is False and cached.get("held") == "downgrade", cacheddiff --git a/tests/hermes_cli/test_update_downgrade_guard.py b/tests/hermes_cli/test_update_downgrade_guard.pyindex 4177f41d8c6..192b5b2b8d7 100644--- a/tests/hermes_cli/test_update_downgrade_guard.py+++ b/tests/hermes_cli/test_update_downgrade_guard.py@@ -98,9 +98,10 @@ def test_forward_updates_and_stores_without_ledger_rows_are_never_refused(repo,assert guard.downgrade_refusal(["git"], repo, head, home=ledgered) is None-def test_check_holds_a_release_off_this_history_that_update_would_refuse(repo, tmp_path, monkeypatch, capsys):- """`hermes update --check` must not say "Selected release available" for a release the update then- refuses (#139099). A release cut beside this checkout's history is not a rollback by ancestry."""[email protected]("divergent", [True, False], ids=["beside-history", "in-history"])+def test_check_holds_a_release_that_update_would_refuse(repo, tmp_path, monkeypatch, capsys, divergent):+ """`hermes update --check` must neither offer nor promise a move back to a release the update then+ refuses (#139099): one cut beside this checkout's history, or one it already contains."""from types import SimpleNamespacefrom hermes_cli import source_releases, update_cmd_check@@ -108,22 +109,26 @@ def test_check_holds_a_release_off_this_history_that_update_would_refuse(repo, thome = tmp_path / "home"monkeypatch.setenv("HERMES_HOME", str(home))monkeypatch.setattr("hermes_cli.backup._sibling_profile_homes", lambda h: [])- _git(repo, "checkout", "-q", "-b", "release-line", "old-release")- (repo / "notes.txt").write_text("release fix\n")- _git(repo, "add", "notes.txt")- _git(repo, "commit", "-qm", "release from the older line")- release = _git(repo, "rev-parse", "HEAD")- _git(repo, "checkout", "-q", "main")+ release = _git(repo, "rev-parse", "old-release")+ if divergent:+ _git(repo, "checkout", "-q", "-b", "release-line", "old-release")+ (repo / "notes.txt").write_text("release fix\n")+ _git(repo, "add", "notes.txt")+ _git(repo, "commit", "-qm", "release from the older line")+ release = _git(repo, "rev-parse", "HEAD")+ _git(repo, "checkout", "-q", "main")target = SimpleNamespace(commit=release, retired=False, ahead=False, label="v1.2.3", branch=None)monkeypatch.setattr(source_releases, "resolve_source_target", lambda *a, **k: target)update_cmd_check.channel_compare_branch("stable", ["git"], repo)- assert "Selected release available" in capsys.readouterr().out # no runtime history yet: a real update+ # No runtime history yet: a real update, or a real rollback.+ assert ("Selected release available" if divergent else "moves it back") in capsys.readouterr().out_ledgered_store(home)update_cmd_check.channel_compare_branch("stable", ["git"], repo)out = capsys.readouterr().out- assert "Holding at this build" in out and "Selected release available" not in out+ assert "Holding at this build" in out+ assert "Selected release available" not in out and "moves it back" not in outdef test_the_runtime_schema_marker_is_still_in_this_trees_state_schema():