mirror of
https://github.com/NousResearch/hermes-agent.git
synced 2026-05-21 03:39:54 +00:00
2a7308b7c4
* fix(update): detect concurrent hermes.exe on Windows; retry + restart-defer quarantine Closes #26670. When 'hermes update' runs on Windows with another hermes.exe alive (most commonly the Hermes Desktop Electron app's spawned backend) _quarantine_running_hermes_exe() fails to rename the venv shim with [WinError 32]. uv pip install -e . then exits 2, the git-pull fast path is silently abandoned, and the ZIP fallback runs (and fails the same way) before eventually succeeding. This change implements three of the five proposed fixes from the issue: 1. Concurrent-instance detection (preferred fix). _detect_concurrent_hermes_instances() uses psutil to enumerate processes whose .exe is one of our venv shims (hermes.exe / hermes-gateway.exe), excluding the caller's PID. When any match exists, cmd_update prints an actionable message naming the blocking PIDs and exits 2 BEFORE any destructive work. New --force flag bypasses the gate. 2. Retry + restart-deferred fallback. _quarantine_running_hermes_exe() now retries the rename up to 4 times with 100/250/500/1000 ms backoff (covers the transient AV-scanner-handle case). If all retries fail, it schedules the replacement via MoveFileExW with the OS deferred-rename flag so the new shim can land at the original path and the update completes; the old image is fully unloaded after the user's next system restart. 3. Actionable warning text. The old 'Could not quarantine: [WinError 32]' warning is replaced with one that names the likely culprits (Hermes Desktop, REPLs, gateway, AV) and points to the new --force flag. Tests: - 13 new tests in tests/hermes_cli/test_update_concurrent_quarantine.py covering: psutil-based enumeration, self-pid exclusion, case-insensitive matching of .EXE, no-psutil graceful degradation, off-Windows no-op, helpful warning formatting, retry-then-succeed, restart-deferred fallback, cmd_update abort + exit code 2, and --force bypass. - New autouse fixture in tests/hermes_cli/conftest.py defaults _detect_concurrent_hermes_instances to [] so the rest of the suite isn't tripped by the developer's own running hermes.exe. Opt-out marker 'real_concurrent_gate' registered in pyproject.toml. - Updating docs page (website/docs/getting-started/updating.md) gains a short section explaining the new Windows error and remediation. * chore: refresh uv.lock to match pyproject.toml exact pins aiohttp 3.13.4 -> 3.13.3 (matches pyproject pin: aiohttp==3.13.3) anthropic 0.87.0 -> 0.86.0 (matches pyproject pin: anthropic==0.86.0) hermes-agent 0.13.0 -> 0.14.0 (matches pyproject version) CI's uv lock --check was failing on the merged state because main drifted: pyproject.toml uses exact == pins for those two deps and the hermes-agent version was bumped to 0.14.0 but the lockfile still had 0.13.0.
47 lines
1.8 KiB
Python
47 lines
1.8 KiB
Python
"""Fixtures shared across hermes_cli kanban tests."""
|
|
|
|
from __future__ import annotations
|
|
|
|
import pytest
|
|
|
|
|
|
@pytest.fixture
|
|
def all_assignees_spawnable(monkeypatch):
|
|
"""Pretend every assignee maps to a real Hermes profile.
|
|
|
|
Most dispatcher tests use synthetic assignees ("alice", "bob") that
|
|
don't correspond to actual profile directories on disk. Without this
|
|
patch, the dispatcher's profile-exists guard (PR #20105) routes
|
|
those tasks into ``skipped_nonspawnable`` instead of spawning, which
|
|
would break tests that assert spawn behavior.
|
|
"""
|
|
from hermes_cli import profiles
|
|
monkeypatch.setattr(profiles, "profile_exists", lambda name: True)
|
|
|
|
|
|
@pytest.fixture(autouse=True)
|
|
def _suppress_concurrent_hermes_gate(request, monkeypatch):
|
|
"""Default ``_detect_concurrent_hermes_instances`` to ``[]`` for every test.
|
|
|
|
The Windows update path now refuses to proceed when another
|
|
``hermes.exe`` is detected (issue #26670). On a developer's Windows
|
|
machine running the test suite via ``hermes`` itself, this would
|
|
flag the running agent as a concurrent instance and abort every
|
|
``cmd_update`` test. Tests that want to exercise the gate explicitly
|
|
re-patch ``_detect_concurrent_hermes_instances`` with their own
|
|
return value — autouse here gives a clean default without touching
|
|
the rest of the suite.
|
|
|
|
Tests that need to call the REAL function (e.g. unit tests for the
|
|
helper itself) opt out with ``@pytest.mark.real_concurrent_gate``.
|
|
"""
|
|
if request.node.get_closest_marker("real_concurrent_gate"):
|
|
return
|
|
try:
|
|
from hermes_cli import main as _cli_main
|
|
except Exception:
|
|
return
|
|
monkeypatch.setattr(
|
|
_cli_main, "_detect_concurrent_hermes_instances", lambda *_a, **_k: []
|
|
)
|