The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
test: update flows resolve their channel locally; desktop checks get real deps
ethernet0533b03268b8
diff --git a/.github/workflows/js-tests.yml b/.github/workflows/js-tests.ymlindex be298107bd4..0b9a7a2c207 100644--- a/.github/workflows/js-tests.yml+++ b/.github/workflows/js-tests.yml@@ -22,8 +22,11 @@ jobs:id: nodeuses: ./.github/actions/setup-pmwith:- # Desktop checks also run Python payload and icon build helpers.+ # Desktop checks also run Python payload and icon build helpers, and+ # the electron contracts drive real hermes_cli/pm code through+ # HERMES_PYTHON, which needs the application dependencies.toolchain: all+ extras: '["dev"]'- name: Install zsh and a virtual display for Electronif: runner.os == 'Linux'diff --git a/apps/desktop/e2e/peer-device-reset.spec.ts b/apps/desktop/e2e/peer-device-reset.spec.tsindex f068eeff95e..ece43409a23 100644--- a/apps/desktop/e2e/peer-device-reset.spec.ts+++ b/apps/desktop/e2e/peer-device-reset.spec.ts@@ -15,9 +15,8 @@ import {createSandbox,launchDesktop,type Sandbox,- writeEnvFile,- writeMockProviderConfig,} from './fixtures'+import { writeEnvFile, writeMockProviderConfig } from '../../../tests-js/scripts/mock-provider-config'import { collectErrorBanners, type ElectronApplication, expect, installErrorBannerGuard, type Page, test } from './test'const REPO_ROOT = path.resolve(import.meta.dirname, '../../..')diff --git a/apps/desktop/electron/backend-probes-runtime.test.ts b/apps/desktop/electron/backend-probes-runtime.test.tsindex 9872d15f95d..a44e8b7272c 100644--- a/apps/desktop/electron/backend-probes-runtime.test.ts+++ b/apps/desktop/electron/backend-probes-runtime.test.ts@@ -17,7 +17,7 @@ interface RuntimeFixture {dependencies: string}-test('the real bootstrap supplies ruamel-only dependencies and rejects foreign-path rescue', (): void => {+test('the real bootstrap supplies ruamel-only dependencies and rejects foreign-path rescue', async (): Promise<void> => {const temp: string = fs.mkdtempSync(path.join(os.tmpdir(), 'hermes-probe-runtime-'))const home: string = path.join(temp, 'home')@@ -65,8 +65,8 @@ print(json.dumps({'python': str(python), 'site': str(site), 'dependencies': str(cwd: temp, env, encoding: 'utf8', timeout: 90_000, windowsHide: true})) as RuntimeFixture- assert.equal(canImportHermesCli(fixture.python, { cwd: REPO, env }), true)- assert.equal(canImportHermesCli(fixture.python, {+ assert.equal(await canImportHermesCli(fixture.python, { cwd: REPO, env }), true)+ assert.equal(await canImportHermesCli(fixture.python, {cwd: REPO,env: { ...env, PYTHONHOME: path.join(temp, 'foreign-home') }}), true, 'Python home overrides must be scrubbed before the interpreter starts')@@ -74,11 +74,11 @@ print(json.dumps({'python': str(python), 'site': str(site), 'dependencies': str(fs.unlinkSync(path.join(fixture.site, 'selected-dependencies.pth'))const foreign: string = path.join(temp, 'foreign-packages')fs.symlinkSync(fixture.dependencies, foreign, process.platform === 'win32' ? 'junction' : 'dir')- assert.equal(canImportHermesCli(fixture.python, {+ assert.equal(await canImportHermesCli(fixture.python, {cwd: REPO,env: { ...env, PYTHONPATH: foreign }}), false, 'foreign dependencies must not conceal an empty selected environment')- assert.equal(canImportHermesCli(fixture.python, {+ assert.equal(await canImportHermesCli(fixture.python, {cwd: REPO,env: { ...env, PYTHONHOME: path.join(temp, 'foreign-home') }}), false)@@ -86,3 +86,4 @@ print(json.dumps({'python': str(python), 'site': str(site), 'dependencies': str(fs.rmSync(temp, { recursive: true, force: true, maxRetries: 3 })}}, 120_000)+diff --git a/apps/desktop/electron/feature-flags.test.ts b/apps/desktop/electron/feature-flags.test.tsindex 8263a7458a7..20f58054b59 100644--- a/apps/desktop/electron/feature-flags.test.ts+++ b/apps/desktop/electron/feature-flags.test.ts@@ -1,27 +1,27 @@// feature-flags.ts is the single resolver for which gated surfaces are on in-// this artifact. These tests pin the flag table: launch argv opts in on any-// channel, canary builds ride along by default, stable builds stay strict.+// this artifact. These tests pin the flag table: local models ship on the+// packaged desktop platforms (Windows, macOS) on every channel; elsewhere the+// launch argv opts in with --local.import assert from 'node:assert/strict'import { test } from 'vitest'import { isCanaryTag, resolveFeatureFlags } from './feature-flags'-test('stable builds need the --local launch flag for local models', () => {- assert.deepEqual(resolveFeatureFlags({ argv: [], canary: false }), { localModels: false })- assert.deepEqual(resolveFeatureFlags({ argv: ['Hermes.exe'], canary: false }), { localModels: false })+const shipsLocalModels: boolean = process.platform === 'win32' || process.platform === 'darwin'++test('without --local, local models follow the platform on every channel', () => {+ for (const canary of [false, true]) {+ assert.deepEqual(resolveFeatureFlags({ argv: [], canary }), { localModels: shipsLocalModels })+ assert.deepEqual(resolveFeatureFlags({ argv: ['Hermes.exe'], canary }), { localModels: shipsLocalModels })+ }})-test('--local in argv opts into local models on any channel', () => {+test('--local in argv opts into local models on any channel and platform', () => {assert.deepEqual(resolveFeatureFlags({ argv: ['Hermes.exe', '--local'], canary: false }), { localModels: true })assert.deepEqual(resolveFeatureFlags({ argv: ['--local'], canary: true }), { localModels: true })})-test('canary builds get local models by default, no flag needed', () => {- assert.deepEqual(resolveFeatureFlags({ argv: [], canary: true }), { localModels: true })- assert.deepEqual(resolveFeatureFlags({ argv: ['Hermes.exe'], canary: true }), { localModels: true })-})-test('isCanaryTag recognizes canary stamps and rejects stable/dev tags', () => {assert.equal(isCanaryTag('v0.28.0-canary.20260818'), true)assert.equal(isCanaryTag('v0.28.0-canary.20260818123456'), true)diff --git a/apps/desktop/electron/fixtures/source-backend.py b/apps/desktop/electron/fixtures/source-backend.pyindex a000bf8dc4b..dec6e16fcf1 100644--- a/apps/desktop/electron/fixtures/source-backend.py+++ b/apps/desktop/electron/fixtures/source-backend.py@@ -60,7 +60,12 @@ def main() -> None:from pm.environments import selected_venvfrom hermes_cli._launchers import ensure_install_launchers+ # PM's worker runs on PM's own staged runtime (truststore, ruamel), never on+ # the application interpreter; only the tool acquisition is substituted.+ from pm.runtime_stage import stage_runtime+worker = root / "pm" / "worker.py"+ worker_python = stage_runtime(Path(uv), Path(sys.executable), temp / "pm-runtime")worker_code = ("import runpy, sys; from pathlib import Path; "f"sys.path.insert(0, {str(root)!r}); import pm._uv; "@@ -68,7 +73,7 @@ def main() -> None:f"runpy.run_path({str(worker)!r}, run_name='__main__')")client = importlib.import_module("pm.client")- setattr(client, "runtime_command", lambda *args, **kwargs: [sys.executable, "-I", "-c", worker_code])+ setattr(client, "runtime_command", lambda *args, **kwargs: [str(worker_python), "-I", "-c", worker_code])pm.sync_venv(explicit=True, project_root=root)selected = selected_venv(root)assert selected and selected.is_relative_to(Path(os.environ["HERMES_HOME"]))diff --git a/apps/desktop/src/app/settings/local-models-settings.test.tsx b/apps/desktop/src/app/settings/local-models-settings.test.tsxindex 87b4a397097..1413679c3c1 100644--- a/apps/desktop/src/app/settings/local-models-settings.test.tsx+++ b/apps/desktop/src/app/settings/local-models-settings.test.tsx@@ -1,7 +1,11 @@vi.mock('@/store/profile', async (): Promise<object> => {const { atom } = await import('nanostores')- return { $activeGatewayProfile: atom<string>('default') }+ return {+ $activeGatewayProfile: atom<string>('default'),+ $profiles: atom<Array<{ name: string; is_default?: boolean }>>([]),+ normalizeProfileKey: (profile: string | null): string => profile || 'default'+ }})vi.mock('@/store/session', async (): Promise<object> => {const { atom } = await import('nanostores')diff --git a/tests/conftest.py b/tests/conftest.pyindex d6bf5750c18..1c177323651 100644--- a/tests/conftest.py+++ b/tests/conftest.py@@ -1397,6 +1397,9 @@ def pytest_configure(config): # noqa: D401 — pytest hookconfig.addinivalue_line("markers", "allow_real_home_io: explicitly bypass the test-only home I/O guard.")+ config.addinivalue_line(+ "markers", "real_release_channels: keep the real R2 channel reader (no local source-branch stub)."+ )config.addinivalue_line("markers",f"{_GATEWAY_LOOKALIKE_MARK}: the test spawns and reaps its own stub "diff --git a/tests/hermes_cli/conftest.py b/tests/hermes_cli/conftest.pyindex 0d11ab58c40..0bc3cfdac93 100644--- a/tests/hermes_cli/conftest.py+++ b/tests/hermes_cli/conftest.py@@ -56,6 +56,28 @@ def _suppress_concurrent_hermes_gate(request, monkeypatch):)[email protected](autouse=True)+def _source_channels_resolve_locally(request, monkeypatch):+ """Every unflagged ``hermes update`` resolves its channel through R2; tests must+ not reach the network for that. Default every channel to a ``source-branch``+ record delivering ``origin/<name>`` through the documented seam. Channel tests+ that model records themselves re-patch ``_resolve_channel`` after this runs;+ the marker opts out entirely for tests of the reader's own network path.+ """+ if request.node.get_closest_marker("real_release_channels"):+ return+ from hermes_cli import source_releases+ from hermes_cli.release_channels import ChannelResolution++ def resolve(name, repository):+ record = {"schema": 1, "name": name, "repository": repository, "policy": "source-branch",+ "state": "active", "identity": None, "nextSequence": 1, "head": None,+ "delivery": {"kind": "source-branch", "branch": name}}+ return ChannelResolution(record, record, None)++ monkeypatch.setattr(source_releases, "_resolve_channel", resolve)++@pytest.fixturedef isolated_source_completion(monkeypatch):"""Unit-test the completion tail in-process; real transport is tested separately."""diff --git a/tests/hermes_cli/test_manual_serve_deferral.py b/tests/hermes_cli/test_manual_serve_deferral.pyindex fdb0a5797ea..218c2e8298a 100644--- a/tests/hermes_cli/test_manual_serve_deferral.py+++ b/tests/hermes_cli/test_manual_serve_deferral.py@@ -37,12 +37,12 @@ def test_manual_deferral_survives_receipt_rotation(monkeypatch, capsys, kind, corestart.incomplete = Trueif condition != "alive":with pytest.raises(SystemExit) as exc:- fleet._verify_fleet_after_update(restart, _pre_update_plan=plan, _windows_gateway_resume=None, node_failures=[], update_complete=True)+ fleet._verify_fleet_after_update(restart, _pre_update_plan=plan, _windows_gateway_resume=None, update_complete=True)assert exc.value.code == 1assert fleet._fleet_restart_pending_marker_path().exists()assert update_receipt.read_latest_receipt()["outcome"] == "partial"return- fleet._verify_fleet_after_update(restart, _pre_update_plan=plan, _windows_gateway_resume=None, node_failures=[], update_complete=True)+ fleet._verify_fleet_after_update(restart, _pre_update_plan=plan, _windows_gateway_resume=None, update_complete=True)receipt = update_receipt.read_latest_receipt()assert receipt["runtime_outcomes"][0]["outcome"] == "deferred"assert not fleet._fleet_restart_pending_marker_path().exists()diff --git a/tests/hermes_cli/test_source_channel_integration.py b/tests/hermes_cli/test_source_channel_integration.pyindex 22e062b367c..071ea9c29de 100644--- a/tests/hermes_cli/test_source_channel_integration.py+++ b/tests/hermes_cli/test_source_channel_integration.py@@ -13,6 +13,9 @@ from hermes_cli.subcommands.update import build_update_parserfrom hermes_cli.update_channel import channel_record, set_install_channelfrom hermes_cli.config import require_readable_config_before_write+# These tests model channel archives and the reader's own transport.+pytestmark = pytest.mark.real_release_channels+def git(root, *args):return subprocess.run(["git", *args], cwd=root, check=True, capture_output=True,diff --git a/tests/hermes_cli/test_update_channel_stable.py b/tests/hermes_cli/test_update_channel_stable.pyindex b042dbfe2cd..cb92917c89e 100644--- a/tests/hermes_cli/test_update_channel_stable.py+++ b/tests/hermes_cli/test_update_channel_stable.py@@ -64,5 +64,5 @@ class TestSourceUpdateChannel:def test_config_failure_never_changes_the_subscription(self, tmp_path, monkeypatch):monkeypatch.setenv("HERMES_HOME", str(tmp_path))(tmp_path / "config.yaml").write_text("update: [broken", encoding="utf-8")- with pytest.raises(RuntimeError, match="not valid YAML"):+ with pytest.raises(RuntimeError, match="formatting error"):_source_update_channel(_Args())diff --git a/tests/hermes_cli/test_update_completion_process.py b/tests/hermes_cli/test_update_completion_process.pyindex d726d7b0484..f02247a908e 100644--- a/tests/hermes_cli/test_update_completion_process.py+++ b/tests/hermes_cli/test_update_completion_process.py@@ -10,6 +10,8 @@ import venvimport pytest+from hermes_cli import update_completion+@pytest.fixturedef transition(tmp_path):@@ -75,6 +77,9 @@ def transition(tmp_path):"from hermes_cli.probe import event\n""def build_update_products(root, *, desktop): event('build', desktop=desktop)\n")+ # The shared completion tail is part of the NEW tree the child runs from.+ shutil.copy2(Path(update_completion.__file__).with_name("source_completion.py"),+ package / "source_completion.py")(package / "main.py").write_text("")(package / "update_cmd_config.py").write_text("_LAST_SIBLING_SNAPSHOTS = {}\n")(package / "update_inventory.py").write_text(diff --git a/tests/hermes_cli/test_update_fleet_snapshot_settle.py b/tests/hermes_cli/test_update_fleet_snapshot_settle.pyindex a64f2a7ff99..62b55d3494d 100644--- a/tests/hermes_cli/test_update_fleet_snapshot_settle.py+++ b/tests/hermes_cli/test_update_fleet_snapshot_settle.py@@ -161,7 +161,6 @@ def test_verifier_clears_marker_after_late_current_gateway_state(monkeypatch) ->restart,_pre_update_plan=None,_windows_gateway_resume=None,- node_failures=[],update_complete=True,)diff --git a/tests/hermes_cli/test_update_multiplex_migration_hook.py b/tests/hermes_cli/test_update_multiplex_migration_hook.pyindex 5e77a6a370a..b2bf5c5ca2a 100644--- a/tests/hermes_cli/test_update_multiplex_migration_hook.py+++ b/tests/hermes_cli/test_update_multiplex_migration_hook.py@@ -16,6 +16,8 @@ from tests.hermes_cli.test_update_fleet_restart_pending import (_make_head_moved_side_effect, _patch_update_deps, _update_args,)+pytestmark = pytest.mark.usefixtures("isolated_source_completion")+@pytest.fixturedef hook_calls(monkeypatch):diff --git a/tests/hermes_cli/test_update_target_identity.py b/tests/hermes_cli/test_update_target_identity.pyindex 5853f07dbc8..3b041b2cc23 100644--- a/tests/hermes_cli/test_update_target_identity.py+++ b/tests/hermes_cli/test_update_target_identity.py@@ -189,20 +189,25 @@ def test_branch_update_uses_real_refs_and_completion_request(update_tree, monkeyassert git(t.clone, 'remote') == 'origin'[email protected]('server', ['sha', 'tag-fallback', 'moved-sha', 'moved-fallback',- 'at-release', 'ahead-release', 'explicit-branch'])[email protected]('server', ['sha', 'fetch-refused', 'at-release', 'ahead-release', 'explicit-branch'])def test_stable_git_uses_remote_identity_without_moving_local_tags(update_tree, monkeypatch, server):+ """A stable update is pinned to the channel's exact commit: no tag lookup on+ origin, the stale local ``v1.1.0`` never moves, and an explicit --branch+ bypasses the channel."""from hermes_cli import source_releases+ from hermes_cli.release_channels import ChannelResolutiont = update_tree- responses = {- '/releases/stable/release-candidates.json': {'tag': 'v1.1.0', 'commit': t.wanted},- '/repos/NousResearch/hermes-agent/releases/tags/v1.1.0': {- 'tag_name': 'v1.1.0', 'draft': False, 'prerelease': False,- },- '/repos/NousResearch/hermes-agent/commits/v1.1.0': {'sha': t.wanted},- }- monkeypatch.setattr(source_releases, '_read', lambda url, **_: json.dumps(responses[urlsplit(url).path]))+ # The stable channel is an R2 record whose published build pins t.wanted+ # (the documented reader seam; see test_source_channel_integration).+ record = {"schema": 1, "name": "stable", "repository": "NousResearch/hermes-agent",+ "policy": "stable-release", "state": "active", "identity": {}, "nextSequence": 2,+ "head": {"buildId": "build-fixture", "sequence": 1}}+ manifest = {"schema": 1, "request": {"buildId": "build-fixture", "channel": "stable", "sequence": 1,+ "repository": "NousResearch/hermes-agent", "commit": t.wanted, "sourceVersion": "1.1.0",+ "version": "0.0.1", "identity": {}, "bundleEnv": {}}, "packages": []}+ monkeypatch.setattr(source_releases, '_resolve_channel',+ lambda name, repository: ChannelResolution(record, record, manifest))expected = t.wantedif server in {'at-release', 'ahead-release'}:git(t.clone, 'fetch', '--no-tags', 'origin', t.wanted)@@ -211,35 +216,26 @@ def test_stable_git_uses_remote_identity_without_moving_local_tags(update_tree,(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 = t.wantedif server == 'explicit-branch':git(t.origin, 'branch', 'retained-branch', t.newer)t.args.branch = 'retained-branch'expected = t.newerrun = subprocess.runcalls = []- resolved = Falsedef guarded_run(command, *args, **kwargs):- nonlocal resolvedcommand = list(map(str, command))assert Path(command[0]).name.lower() in {'git', 'git.exe'}, commandcwd = 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+ assert 'push' not in command and 'pull' not in command and 'ls-remote' not in command, commandcalls.append(command)- if 'fetch' in command and t.wanted in command and server.endswith('fallback'):+ if 'fetch' in command and t.wanted in command and server == 'fetch-refused':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+ return run(command, *args, **kwargs)monkeypatch.setattr(subprocess, 'run', guarded_run)- if server == 'moved-fallback':+ if server == 'fetch-refused':with pytest.raises(SystemExit) as error:cli_main.cmd_update(t.args)assert error.value.code == 1@@ -265,10 +261,8 @@ def test_stable_git_uses_remote_identity_without_moving_local_tags(update_tree,assert (t.clone / 'content.txt').read_text(encoding='utf-8-sig') == contentbranch = 'retained-branch' if server in {'at-release', 'explicit-branch'} else ''assert git(t.clone, 'branch', '--show-current') == branch- assert resolved == (server != 'explicit-branch')assert git(t.clone, 'rev-parse', 'v1.1.0') == t.baseassert 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)@pytest.mark.platforms('windows')@@ -447,3 +441,4 @@ def test_update_syntax_failure_restores_pre_update_head(update_tree, monkeypatchassert local.read_bytes() == unstagedassert git(t.clone, 'show', ':.gitignore') == staged.decode().strip()assert (t.clone / 'notes.txt').read_bytes() == b'untracked local work\n'+diff --git a/tests/hermes_cli/test_update_venv_health.py b/tests/hermes_cli/test_update_venv_health.pyindex 6bc80b19a0b..2e7cdfda357 100644--- a/tests/hermes_cli/test_update_venv_health.py+++ b/tests/hermes_cli/test_update_venv_health.py@@ -96,7 +96,7 @@ def test_detect_venv_python_matches_uv_default_dotvenv(_winp, tmp_path):(tmp_path / ".venv").mkdir()with patch.object(cli_main, "PROJECT_ROOT", tmp_path), patch.dict(sys.modules, {"psutil": fake_psutil}):- matches = cli_main._detect_venv_python_processes()+ matches = update_cmd_windows._detect_venv_python_processes()assert [match[0] for match in matches] == [104]