mirror of
https://github.com/NousResearch/hermes-agent.git
synced 2026-11-16 19:36:54 +00:00
Merge fallout (my resolution errors, all caught by CI): - hermes_cli/backup.py + gateway.py: `theirs` on those hunks re-imported clusters HEAD had already moved to backup_restore.py / kept in the facade. backup.py loses the 349-line duplicate (main's #110179 fix is ported into backup_restore._import_db_member); the systemd service-unit cluster returns to gateway.py (PM's _prepare_service_launcher / _pm_managed_node_dirs / _systemd_command have no home in main's extraction) with main's utf-8-sig read. gateway_service_unit.py is dropped. - gateway/run.py: main's plugin-update chore is not profile-scoped (the housekeeping ordering test pins the scope/drain sequence). - pyproject + 30 test files: `import yaml` -> `import hermes_yaml as yaml` (pm-clean has no pyyaml); gateway/config._bundled_platform_manifest_name reads through hermes_yaml. - tests re-seamed onto pm-clean's shape: residency admission (installed_engine), supervisor child env (binary is a constructor argument), update import guard (update_cmd_deps is gone; our probe already scrubs PYTHONPATH — both #115032 invariants pass), shallow-count git responses (stash path asks `status --porcelain -z`); dropped tests for retired code (_run_node_bootstrap/_ensure_tui_node, Windows resume demotion). - tests/tools/test_local_env_blocklist.py: restore the two helpers the suite-reduction commit dropped and the blocklist import. Real fixes: - pm: classify_uv_failure/ResolutionConflict move beside the uv runner (pm.environment, stdlib-only). pm.workspace imports tomllib at module level and cannot load on the 3.10 bootstrap python that streams uv output in the Docker arm64 image. - tools/browser_tool.warm_agent_browser_npx_cache: back as a permanent definition — it is on the frozen old-updater surface, and the revert-scheduled compat pointer does not count. - hermes_cli/memory_setup: the dashboard's pip row uses pm.environments. running_from_selected_environment for installed vs restart_required. - scripts/windows-build-deps.ps1: export DISTUTILS_USE_SDK/MSSdk so setuptools trusts the primed MSVC environment instead of asking vswhere (`env -i` test runner on win32-arm64 compiling ruamel-yaml-clib); run_tests.sh forwards them. - tests/pm/test_windows_build_deps.py: start the protocol test from a parent env without the toolchain variables the runner job already exports. - tests/conftest.py scrubs HERMES_BUNDLED_PLUGINS (Nix-wrapped hermes on the dev host); tests/home_io_guard.py treats sys.path site-packages under the real home as the interpreter's installation (PM-activated developer shell). - tests-js: four `curly` lint errors from main's new scripts.
57 lines
2.8 KiB
Python
57 lines
2.8 KiB
Python
"""A managed llama-server child never inherits credential-shaped environment variables.
|
|
|
|
Issue #116109: on Windows the bundled libomp.dll crashed with STATUS_HEAP_CORRUPTION during
|
|
initialisation whenever one `*_API_KEY` variable was present in the inherited Desktop environment
|
|
and loaded fine with only that variable removed. Credentials have no business in a native
|
|
inference child regardless of the crash, so the supervisor scrubs them at its spawn. The scrub
|
|
is the supervisor's, not spawn_server's: the same spawner backs bounded_probe_run (git,
|
|
PowerShell, update probes) whose children legitimately need GH_TOKEN / HF_TOKEN.
|
|
"""
|
|
|
|
import os
|
|
import subprocess
|
|
from types import SimpleNamespace
|
|
|
|
from hermes_cli.local_runtime import supervisor
|
|
from hermes_cli.local_runtime.processes import server_child_env, spawn_server
|
|
|
|
|
|
def test_supervisor_spawns_llama_server_without_credentials_but_keeps_runtime_env(tmp_path, monkeypatch):
|
|
monkeypatch.setenv("FIRECRAWL_API_KEY", "fc-secret")
|
|
monkeypatch.setenv("SOME_TOKEN", "t")
|
|
monkeypatch.setenv("DB_PASSWORD", "p")
|
|
monkeypatch.setenv("CUDA_VISIBLE_DEVICES", "0")
|
|
monkeypatch.setenv("OMP_NUM_THREADS", "4")
|
|
monkeypatch.setattr(supervisor, "runtimes_root", lambda: tmp_path / "runtime")
|
|
monkeypatch.setattr(supervisor, "_direct_io_args", lambda exe: [])
|
|
spawns = []
|
|
monkeypatch.setattr(supervisor, "spawn_server", lambda argv, **kwargs: (
|
|
spawns.append(kwargs) or SimpleNamespace(pid=123, poll=lambda: 0), None,
|
|
))
|
|
sup = supervisor.LlamaServerSupervisor(tmp_path / "engine" / "llama-server", tmp_path / "models", port=19002)
|
|
monkeypatch.setattr(sup, "_write_state", lambda: None)
|
|
try:
|
|
sup._spawn()
|
|
finally:
|
|
sup.stop()
|
|
child_env = spawns[0]["env"]
|
|
assert "FIRECRAWL_API_KEY" not in child_env
|
|
assert "SOME_TOKEN" not in child_env
|
|
assert "DB_PASSWORD" not in child_env
|
|
assert child_env["CUDA_VISIBLE_DEVICES"] == "0"
|
|
assert child_env["OMP_NUM_THREADS"] == "4"
|
|
assert child_env["PATH"] == os.environ["PATH"]
|
|
|
|
|
|
def test_spawn_server_keeps_the_callers_environment(monkeypatch):
|
|
"""The generic spawner (bounded_probe_run's git/PowerShell probes) must pass an explicit
|
|
``env=`` through untouched: a gh-backed credential helper needs GITHUB_TOKEN."""
|
|
monkeypatch.setattr(subprocess, "Popen", lambda cmd, **kwargs: SimpleNamespace(kwargs=kwargs))
|
|
proc, _job = spawn_server(["git", "fetch"], env={"GITHUB_TOKEN": "g", "PATH": "/bin"})
|
|
assert proc.kwargs["env"] == {"GITHUB_TOKEN": "g", "PATH": "/bin"}
|
|
|
|
|
|
def test_server_child_env_is_case_insensitive_and_pure():
|
|
base = {"openai_api_key": "k", "Path": "C:\\x", "GITHUB_TOKEN": "g", "HSA_OVERRIDE_GFX_VERSION": "11"}
|
|
assert server_child_env(base) == {"Path": "C:\\x", "HSA_OVERRIDE_GFX_VERSION": "11"}
|
|
assert base["openai_api_key"] == "k" # input untouched
|