The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(update): pin stable Git and ZIP updates to one commit
ethernetefa21c2832b4
diff --git a/hermes_cli/update_cmd.py b/hermes_cli/update_cmd.pyindex a91ed3cfbde..b39173f298a 100644--- a/hermes_cli/update_cmd.py+++ b/hermes_cli/update_cmd.py@@ -683,17 +683,14 @@ def _stable_channel_active(args) -> bool:except Exception as exc:logger.warning("Channel resolution failed; defaulting to main: %s", exc)return False-def _github_latest_release_tag():- """Resolve the newest final-release tag with the GitHub API (no git necessary).-- The ZIP-fallback path uses this function. That path exists because git- file I/O is broken. The function tries /releases/latest first, because that- endpoint obeys the draft and prerelease curation. If that fails, it lists- the tags and selects the maximum final release.- Returns the tag name or None.- """+++def _github_latest_release():+ """Resolve the official release tag and commit without local Git state."""+ import jsonimport urllib.errorimport urllib.request+ from urllib.parse import quotedef _get_json(url):req = urllib.request.Request(@@ -706,9 +703,11 @@ def _github_latest_release_tag():base = "https://api.github.com/repos/NousResearch/hermes-agent"try:data = _get_json(f"{base}/releases/latest")- tag = data.get("tag_name")+ tag = data.get("tag_name") if isinstance(data, dict) else Noneif isinstance(tag, str) and _parse_release_tag(tag) is not None:- return tag+ commit = _get_json(f"{base}/commits/{quote(tag, safe='')}")+ sha = commit.get("sha") if isinstance(commit, dict) else None+ return tag, sha if isinstance(sha, str) and re.fullmatch(r"[0-9a-f]{40}", sha) else Noneexcept (urllib.error.URLError, OSError, ValueError) as exc:logger.debug("GitHub /releases/latest unavailable: %s", exc)try:@@ -718,11 +717,16 @@ def _github_latest_release_tag():name = entry.get("name") if isinstance(entry, dict) else Noneversion = _parse_release_tag(name) if isinstance(name, str) else Noneif version is not None and (best is None or version > best[0]):- best = (version, name)- return best[1] if best else None+ commit = entry.get("commit")+ sha = commit.get("sha") if isinstance(commit, dict) else None+ best = (version, name, sha)+ if best:+ sha = best[2]+ return best[1], sha if isinstance(sha, str) and re.fullmatch(r"[0-9a-f]{40}", sha) else None+ return None, Noneexcept (urllib.error.URLError, OSError, ValueError) as exc:logger.debug("GitHub /tags unavailable: %s", exc)- return None+ return None, Nonedef _cmd_update_check(branch: str = "main", *, branch_explicit: bool = False):@@ -1260,7 +1264,7 @@ def _prepare_checkout_for_update(# Stable channel: the checkout does NOT switch branches — the current branch# pointer fast-forwards (or merges) to the release tag, so the parked-branch# machinery is main-channel only.- parked_branch_switched, in_place_update, switch_block_reason = False, False, None+ parked_branch_switched, in_place_update, switch_block_reason = False, True, Noneelse:parked_branch_switched, in_place_update, switch_block_reason = _apply_parked_branch_guard(git_cmd, branch, current_branch, switch_branch=switch_branch,@@ -1311,7 +1315,7 @@ def _prepare_checkout_for_update(# "Already up to date!" and verified nothing). Non-fork checkouts have no upstream question: origin IS# the official repo, so "Already up to date!" is fully verified there.upstream_checked = True- if commit_count == 0 and is_fork and branch == "main":+ if commit_count == 0 and is_fork and branch == "main" and not stable_tag:pre_sync_sha = _capture_head_sha(git_cmd, _m().PROJECT_ROOT)upstream_checked = _m()._sync_with_upstream_if_needed(git_cmd, _m().PROJECT_ROOT, assume_yes=assume_yes, input_fn=gw_input_fn)@@ -1509,7 +1513,8 @@ def _current_branch_name(git_cmd, *, check: bool = False) -> str:def _handle_update_called_process_error(- e, args, gateway_mode: bool, had_desktop_app_before_update: bool) -> None:+ e, args, gateway_mode: bool, had_desktop_app_before_update: bool,+ *, target_sha: str | None = None) -> None:"""Git/installer failure: ZIP-fallback when safe, else report and ``sys.exit(1)``."""stage = _format_update_failure_stage(e)if _should_zip_fallback_on_update_error(e):@@ -1517,7 +1522,8 @@ def _handle_update_called_process_error(print("→ Falling back to ZIP download...")print()desktop_build_ok = _update_via_zip(- args, had_desktop_app_before_update=had_desktop_app_before_update)+ args, had_desktop_app_before_update=had_desktop_app_before_update,+ target_sha=target_sha)if gateway_mode:_write_gateway_update_exit_code(desktop_build_ok)else:@@ -1681,10 +1687,27 @@ def _cmd_update_impl(args, gateway_mode: bool):use_zip_update, git_cmd, is_fork = _prepare_git_command()+ branch = _m()._resolve_update_branch(args)+ target_ref = f"origin/{branch}"+ stable_tag, stable_sha = None, None+ if _stable_channel_active(args):+ print("→ Update channel: stable (tagged releases)")+ stable_tag, stable_sha = (+ _github_latest_release() if use_zip_update+ else _resolve_latest_release_tag(git_cmd, _m().PROJECT_ROOT))+ if stable_tag is None or not re.fullmatch(r"[0-9a-f]{40}", stable_sha or ""):+ print("✗ Could not resolve the stable release commit. No update was applied.")+ print(" Retry, or switch channels with: hermes update --set-channel main")+ _m()._resume_windows_gateways_after_update(_windows_gateway_resume)+ sys.exit(1)+ print(f"→ Latest release: {stable_tag}")+ target_ref = stable_sha+if use_zip_update:try:desktop_build_ok = _update_via_zip(- args, had_desktop_app_before_update=had_desktop_app_before_update)+ args, had_desktop_app_before_update=had_desktop_app_before_update,+ target_sha=stable_sha)finally:_m()._resume_windows_gateways_after_update(_windows_gateway_resume)if gateway_mode:@@ -1692,9 +1715,6 @@ def _cmd_update_impl(args, gateway_mode: bool):returntry:- # Scoped fetch: a bare `git fetch origin` pulls thousands of branches and can stall.- branch = _m()._resolve_update_branch(args)-# Self-heal abandoned .git/*.lock files (crashed fetch) or the fetch fails "File exists".from hermes_cli.gitlock import clear_stale_git_locks, clear_stale_tmp_packscleared = clear_stale_git_locks(_m().PROJECT_ROOT)@@ -1704,32 +1724,29 @@ def _cmd_update_impl(args, gateway_mode: bool):if swept:print(" (removed %d aborted-fetch pack temp file(s))" % len(swept))- # Stable channel targets the newest release tag instead of origin/<branch>: the- # current branch fast-forwards to the tag's commit, so the checkout keeps its- # branch shape (no detached HEAD) and the next stable update ff-merges to the tag.- target_ref = f"origin/{branch}"- stable_tag = None- if _stable_channel_active(args):- print("→ Update channel: stable (tagged releases)")- stable_tag, _stable_tag_sha = _resolve_latest_release_tag(git_cmd, _m().PROJECT_ROOT)- if stable_tag is None:- print("✗ No release tags found on origin. An update on the stable channel is not possible.")- print(" Switch channels with: hermes update --set-channel main")- _m()._resume_windows_gateways_after_update(_windows_gateway_resume)- sys.exit(1)- print(f"→ Latest release: {stable_tag}")- target_ref = stable_tag-# Surface autostashes left by earlier updates (--keep-stash, failed restores).# Surface autostash entries left behind by earlier updates (#63717 problem 6) — parked --keep-stash# runs and failed restores preserve the stash but nothing ever mentioned it again._m()._warn_orphaned_update_autostashes(git_cmd, _m().PROJECT_ROOT)print("→ Fetching updates...")- fetch_target = ["tag", stable_tag] if stable_tag else [branch]- fetch_result = _git_run(git_cmd, ["fetch", "origin", *fetch_target], network=True)+ if stable_tag:+ fetch_result = _git_run(git_cmd, ["fetch", "--no-tags", "origin", target_ref], network=True)+ if fetch_result.returncode != 0:+ # Older servers require a named ref. Do not change local tags.+ fetch_result = _git_run(+ git_cmd, ["fetch", "--no-tags", "origin", f"refs/tags/{stable_tag}"], network=True)+ if fetch_result.returncode == 0:+ fetched = _git_run(git_cmd, ["rev-parse", "--verify", "FETCH_HEAD^{commit}"])+ if fetched.returncode != 0 or fetched.stdout.strip() != target_ref:+ print("✗ The release tag changed during this update. Retry to select its new commit.")+ _m()._resume_windows_gateways_after_update(_windows_gateway_resume)+ sys.exit(1)+ else:+ fetch_result = _git_run(git_cmd, ["fetch", "origin", branch], network=True)if fetch_result.returncode != 0:_print_fetch_failure(fetch_result.stderr)+ _m()._resume_windows_gateways_after_update(_windows_gateway_resume)sys.exit(1)current_branch = _current_branch_name(git_cmd, check=True)@@ -1763,12 +1780,16 @@ def _cmd_update_impl(args, gateway_mode: bool):keep_stash=opts.keep_stash, target_ref=target_ref)_apply_pulled_update(git_cmd, branch, pre_pull_sha, _plan, opts, gateway_mode=gateway_mode,- is_fork=is_fork, desktop_dir=desktop_dir,+ is_fork=is_fork and not stable_tag, desktop_dir=desktop_dir,had_desktop_app_before_update=had_desktop_app_before_update,pre_update_snapshot_id=pre_update_snapshot_id, _pre_update_plan=_pre_update_plan,_windows_gateway_resume=_windows_gateway_resume)except subprocess.CalledProcessError as e:- _handle_update_called_process_error(e, args, gateway_mode, had_desktop_app_before_update)+ try:+ _handle_update_called_process_error(+ e, args, gateway_mode, had_desktop_app_before_update, target_sha=stable_sha)+ finally:+ _m()._resume_windows_gateways_after_update(_windows_gateway_resume)# ---- BEGIN PLUGIN-COMPAT (revert-scheduled; see COMPAT_MANIFEST.md) ----diff --git a/hermes_cli/update_cmd_zip.py b/hermes_cli/update_cmd_zip.pyindex 8c6e44f78e2..c6b09130a07 100644--- a/hermes_cli/update_cmd_zip.py+++ b/hermes_cli/update_cmd_zip.py@@ -7,6 +7,7 @@ resolving/monkeypatching. Origin helpers are imported lazily per function (no cyimport loggingfrom contextlib import suppressimport os+import reimport shutilimport subprocessimport sys@@ -344,9 +345,13 @@ def _reinstall_python_deps_after_zip(active_tool_dependencies) -> None:_m()._refresh_active_memory_provider_dependencies()-def _update_via_zip(args, *, had_desktop_app_before_update: bool = False) -> bool:+def _update_via_zip(args, *, had_desktop_app_before_update: bool = False,+ target_sha: str | None = None) -> bool:"""Update via ZIP archive; used on Windows when git file I/O is broken (antivirus / NTFS filter- drivers causing 'Invalid argument'). Returns ``False`` when a Desktop rebuild ran and failed."""+ drivers causing 'Invalid argument'). Returns ``False`` when a Desktop rebuild ran and failed.++ A supplied commit keeps the archive on the target selected before Git failed.+ """from hermes_cli.update_cmd import (_finish_dashboard_update_cleanup,_m,@@ -376,7 +381,10 @@ def _update_via_zip(args, *, had_desktop_app_before_update: bool = False) -> boo)_m().sys.exit(1)_abort_zip_update_if_dirty_tree()- _download_and_swap_zip(branch, f"https://github.com/NousResearch/hermes-agent/archive/refs/heads/{branch}.zip")+ if target_sha is not None and not re.fullmatch(r"[0-9a-f]{40}", target_sha):+ raise ValueError("ZIP update requires an exact full commit SHA")+ ref = target_sha if target_sha is not None else f"refs/heads/{branch}"+ _download_and_swap_zip(branch, f"https://github.com/NousResearch/hermes-agent/archive/{ref}.zip")_sweep_bytecode_after_update(branch)print("→ Updating Python dependencies...")_reinstall_python_deps_after_zip(active_tool_dependencies)diff --git a/tests/compat/old_updater_surface.json b/tests/compat/old_updater_surface.jsonindex 370993eacb3..6d784c180cf 100644--- a/tests/compat/old_updater_surface.json+++ b/tests/compat/old_updater_surface.json@@ -210,6 +210,7 @@"pm.ensure::_identity","pm.ensure::_installed_location","pm.ensure::env_for",+ "pm.ensure::installed_package","pm.ensure::lazy_installs_allowed","pm.ensure::sealed","pm.ensure::sync_venv",@@ -219,6 +220,7 @@"pm.lock::Lockfile","pm.network::retry_network","pm.package::InstallError",+ "pm.packages::npm_env","pm.packages::uv_env","pm.paths::lockfile_path","pm.paths::repo_root",diff --git a/tests/hermes_cli/test_update_target_identity.py b/tests/hermes_cli/test_update_target_identity.pynew file mode 100644index 00000000000..c5ad01b0efa--- /dev/null+++ b/tests/hermes_cli/test_update_target_identity.py@@ -0,0 +1,251 @@+"""Stable updates consume one remote commit across Git and archive transports."""+import json+from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer+import os+from pathlib import Path+import subprocess+import threading+from types import SimpleNamespace+from urllib.parse import urlsplit+import urllib.request++import pytest++from hermes_cli import main as cli_main, update_cmd, update_cmd_zip, update_receipt+++class DependencyBoundary(Exception):+ pass+++def git(root, *args):+ return subprocess.run(['git', *args], cwd=root, check=True, capture_output=True,+ text=True, encoding='utf-8').stdout.strip()+++def update_tree(tmp_path, monkeypatch):+ monkeypatch.setenv('GIT_CONFIG_GLOBAL', str(tmp_path / 'git-config'))+ monkeypatch.setenv('GIT_CONFIG_NOSYSTEM', '1')+ monkeypatch.setenv('GIT_ALLOW_PROTOCOL', 'file')+ monkeypatch.delenv('HERMES_UPDATE_HANDOFF_PID', raising=False)+ monkeypatch.delenv('HERMES_UPDATE_REEXEC', raising=False)+ origin = tmp_path / 'origin'+ origin.mkdir()+ git(origin, 'init', '-q', '-b', 'main')+ git(origin, 'config', 'user.name', 'Fixture')+ git(origin, 'config', 'user.email', '[email protected]')+ (origin / 'content.txt').write_text('base\n', encoding='utf-8')+ (origin / '.gitignore').write_text('.bytecode-fingerprint\n', encoding='utf-8')+ git(origin, 'add', 'content.txt', '.gitignore')+ git(origin, '-c', 'commit.gpgsign=false', 'commit', '-qm', 'base')+ git(origin, 'tag', 'v1.0.0')+ base = git(origin, 'rev-parse', 'HEAD')+ clone = tmp_path / 'install'+ git(tmp_path, 'clone', '-q', str(origin), str(clone))+ git(clone, 'config', 'user.name', 'Fixture')+ git(clone, 'config', 'user.email', '[email protected]')+ git(clone, 'checkout', '-qb', 'retained-branch')+ git(clone, 'tag', 'v1.1.0') # A stale local tag must never choose the release.+ (origin / 'content.txt').write_text('release\n', encoding='utf-8')+ git(origin, '-c', 'commit.gpgsign=false', 'commit', '-qam', 'release')+ wanted = git(origin, 'rev-parse', 'HEAD')+ git(origin, '-c', 'tag.gpgSign=false', 'tag', '-a', 'v1.1.0', '-m', 'release')+ (origin / 'content.txt').write_text('unreleased-main\n', encoding='utf-8')+ git(origin, '-c', 'commit.gpgsign=false', 'commit', '-qam', 'unreleased')+ newer = git(origin, 'rev-parse', 'HEAD')++ monkeypatch.setattr(cli_main, 'PROJECT_ROOT', clone)+ monkeypatch.setattr(update_receipt, '_code_identity', lambda **_: {'commit': base})+ monkeypatch.setattr(cli_main, '_capture_active_lazy_features', lambda: [])+ monkeypatch.setattr(cli_main, '_capture_active_tool_dependencies', lambda: [])+ monkeypatch.setattr(cli_main, '_run_pre_update_backup', lambda *_: None)+ monkeypatch.setattr(cli_main, '_pause_windows_gateways_for_update', lambda: None)+ resumed = []+ monkeypatch.setattr(cli_main, '_resume_windows_gateways_after_update', lambda state: resumed.append(state))+ monkeypatch.setattr(cli_main, '_install_hangup_protection', lambda **_: {'installed': False})+ monkeypatch.setattr(cli_main, '_finalize_update_output', lambda *_: None)+ monkeypatch.setattr(update_cmd, '_begin_update_receipt_and_plan', lambda *_: None)+ monkeypatch.setattr(cli_main, '_sync_with_upstream_if_needed',+ lambda *_a, **_k: pytest.fail('stable update reached upstream branch sync'))++ def stop_at_dependencies(*_args, **_kwargs):+ raise DependencyBoundary()++ monkeypatch.setattr(update_cmd, '_sync_python_dependencies_after_pull', stop_at_dependencies)+ monkeypatch.setattr(update_cmd_zip, '_reinstall_python_deps_after_zip', stop_at_dependencies)+ repaired = []+ monkeypatch.setattr(update_cmd, '_repair_current_checkout', lambda **_: repaired.append(True) or True)+ monkeypatch.setattr(update_cmd, '_apply_pending_fleet_restart_catchup', lambda: None)+ args = SimpleNamespace(branch=None, channel='stable', yes=True, force=True, force_venv=True,+ check=False, plan=False, gateway=False, install_id=False, set_channel=None)+ return SimpleNamespace(origin=origin, clone=clone, base=base, wanted=wanted, newer=newer,+ args=args, resumed=resumed, repaired=repaired)++[email protected]('server', ['sha', 'tag-fallback', 'moved-sha', 'moved-fallback',+ 'at-release', 'ahead-release', 'explicit-branch'])+def test_stable_git_uses_remote_identity_without_moving_local_tags(update_tree, monkeypatch, server):+ t = update_tree+ expected = t.wanted+ if server in {'at-release', 'ahead-release'}:+ git(t.clone, 'fetch', '--no-tags', 'origin', t.wanted)+ git(t.clone, 'merge', '--ff-only', t.wanted)+ if server == 'ahead-release':+ (t.clone / 'local.txt').write_text('local commit\n', encoding='utf-8')+ git(t.clone, 'add', 'local.txt')+ git(t.clone, '-c', 'commit.gpgsign=false', 'commit', '-qm', 'local')+ expected = git(t.clone, 'rev-parse', 'HEAD')+ if server == 'explicit-branch':+ git(t.origin, 'branch', 'retained-branch', t.newer)+ t.args.branch = 'retained-branch'+ expected = t.newer+ run = subprocess.run+ calls = []+ resolved = False++ def guarded_run(command, *args, **kwargs):+ nonlocal resolved+ command = list(map(str, command))+ assert Path(command[0]).name.lower() in {'git', 'git.exe'}, command+ cwd = Path(kwargs.get('cwd', os.getcwd())).resolve()+ assert cwd in {t.clone, t.origin}, (command, cwd)+ assert 'push' not in command and 'pull' not in command, command+ calls.append(command)+ if 'fetch' in command and t.wanted in command and server.endswith('fallback'):+ return subprocess.CompletedProcess(command, 128, stdout='', stderr='fixture: raw SHA wants disabled')+ result = run(command, *args, **kwargs)+ if 'ls-remote' in command and not resolved:+ resolved = True+ if server.startswith('moved'):+ run(['git', '-c', 'tag.gpgSign=false', 'tag', '-fa', 'v1.1.0', t.newer, '-m', 'moved'],+ cwd=t.origin, check=True, capture_output=True)+ return result++ monkeypatch.setattr(subprocess, 'run', guarded_run)+ if server == 'moved-fallback':+ with pytest.raises(SystemExit) as error:+ cli_main.cmd_update(t.args)+ assert error.value.code == 1+ assert git(t.clone, 'rev-parse', 'HEAD') == t.base+ assert t.resumed+ elif server in {'at-release', 'ahead-release'}:+ cli_main.cmd_update(t.args)+ assert t.repaired == [True]+ assert git(t.clone, 'rev-parse', 'HEAD') == expected+ else:+ with pytest.raises(DependencyBoundary):+ cli_main.cmd_update(t.args)+ assert git(t.clone, 'rev-parse', 'HEAD') == expected+ content = 'unreleased-main\n' if server == 'explicit-branch' else 'release\n'+ assert (t.clone / 'content.txt').read_text(encoding='utf-8') == content+ assert git(t.clone, 'branch', '--show-current') == 'retained-branch'+ assert resolved == (server != 'explicit-branch')+ assert git(t.clone, 'rev-parse', 'v1.1.0') == t.base+ assert not git(t.clone, 'status', '--porcelain')+ assert len([cmd for cmd in calls if 'ls-remote' in cmd]) == (0 if server == 'explicit-branch' else 1)++[email protected]('windows')[email protected]('transport', ['gitless', 'no-git', 'api-tags', 'missing-sha',+ 'git-error', 'moved-git-error', 'dirty'])+def test_stable_zip_consumes_the_same_commit_through_the_real_swap(update_tree, monkeypatch, tmp_path, transport):+ t = update_tree+ archive = tmp_path / 'source.zip'+ git(t.origin, 'archive', '--format=zip', '--prefix=hermes-agent-source/', f'--output={archive}', t.wanted)+ archive_bytes = archive.read_bytes()+ latest = {'tag_name': 'v1.1.0'}+ routes = {+ '/repos/NousResearch/hermes-agent/releases/latest': latest,+ '/repos/NousResearch/hermes-agent/commits/v1.1.0': {'sha': t.wanted},+ '/repos/NousResearch/hermes-agent/tags?per_page=100': [{'name': 'v1.1.0', 'commit': {'sha': t.wanted}}],+ f'/NousResearch/hermes-agent/archive/{t.wanted}.zip': archive_bytes,+ }+ if transport == 'api-tags':+ routes.pop('/repos/NousResearch/hermes-agent/releases/latest')+ if transport == 'missing-sha':+ routes['/repos/NousResearch/hermes-agent/commits/v1.1.0'] = {'sha': 'not-a-commit'}+ routes.pop('/repos/NousResearch/hermes-agent/tags?per_page=100')++ class Handler(BaseHTTPRequestHandler):+ def do_GET(self):+ value = routes.get(self.path)+ if value is None:+ self.send_error(404)+ return+ body = value if isinstance(value, bytes) else json.dumps(value).encode()+ self.send_response(200)+ self.send_header('Content-Length', str(len(body)))+ self.end_headers()+ self.wfile.write(body)++ def log_message(self, *_args):+ pass++ server = ThreadingHTTPServer(('127.0.0.1', 0), Handler)+ thread = threading.Thread(target=server.serve_forever, daemon=True)+ thread.start()+ urls, git_calls = [], []+ real_open, real_run = urllib.request.urlopen, subprocess.run+ fetched, failed = False, False++ def local_open(request, *args, **kwargs):+ url = request.full_url if isinstance(request, urllib.request.Request) else request+ parsed = urlsplit(url)+ assert parsed.scheme == 'https' and parsed.netloc in {'api.github.com', 'github.com'}, url+ urls.append(url)+ local = f'http://127.0.0.1:{server.server_port}{parsed.path}'+ if parsed.query:+ local += '?' + parsed.query+ return real_open(local, *args, **kwargs)++ def guarded_run(command, *args, **kwargs):+ nonlocal fetched, failed+ command = list(map(str, command))+ assert Path(command[0]).name.lower() in {'git', 'git.exe'}, command+ cwd = Path(kwargs.get('cwd', os.getcwd())).resolve()+ assert cwd in {t.clone, t.origin}, (command, cwd)+ assert 'push' not in command and 'pull' not in command, command+ git_calls.append(command)+ if transport == 'no-git':+ raise FileNotFoundError('fixture: no Git executable')+ if fetched and not failed and '--abbrev-ref' in command and kwargs.get('check'):+ failed = True+ raise subprocess.CalledProcessError(128, command, '', 'fixture: Git file I/O failed')+ result = real_run(command, *args, **kwargs)+ if 'ls-remote' in command and transport == 'moved-git-error':+ real_run(['git', '-c', 'tag.gpgSign=false', 'tag', '-fa', 'v1.1.0', t.newer, '-m', 'moved'],+ cwd=t.origin, check=True, capture_output=True)+ if 'fetch' in command:+ fetched = True+ return result++ if transport in {'gitless', 'no-git', 'api-tags', 'missing-sha'}:+ (t.clone / '.git').rename(tmp_path / 'git-state')+ if transport == 'dirty':+ (t.clone / 'content.txt').write_text('local work\n', encoding='utf-8')+ before = (t.clone / 'content.txt').read_bytes()+ monkeypatch.setattr(urllib.request, 'urlopen', local_open)+ monkeypatch.setattr(subprocess, 'run', guarded_run)+ try:+ if transport in {'missing-sha', 'dirty'}:+ with pytest.raises(SystemExit) as error:+ cli_main.cmd_update(t.args)+ assert error.value.code == 1+ assert (t.clone / 'content.txt').read_bytes() == before+ assert not any('/archive/' in url for url in urls)+ else:+ with pytest.raises(DependencyBoundary):+ cli_main.cmd_update(t.args)+ assert (t.clone / 'content.txt').read_text(encoding='utf-8') == 'release\n'+ assert [url for url in urls if '/archive/' in url] == [+ f'https://github.com/NousResearch/hermes-agent/archive/{t.wanted}.zip']+ assert t.resumed+ if transport in {'git-error', 'moved-git-error', 'dirty'}:+ assert failed and fetched+ assert len([cmd for cmd in git_calls if 'ls-remote' in cmd]) == 1+ assert not any('api.github.com' in url for url in urls)+ finally:+ server.shutdown()+ thread.join(timeout=5)+ server.server_close()