mirror of
https://github.com/NousResearch/hermes-agent.git
synced 2026-11-17 04:11:35 +00:00
A named profile that authors `gateway.standalone: true` in its own config.yaml runs its own gateway again, the pre-multiplex topology, while the default gateway keeps serving every other profile. Topology becomes something the operator authors per profile instead of something the box infers from boot state, which is what a fleet running per-profile gateways lost when `gateway.multiplex_profiles: false` was retired. Changed - hermes_cli/profiles.py: `profile_is_standalone(home)` reads the profile's own config.yaml (memo by file signature, tolerant of malformed yaml, always False for the default profile with one warning). `profiles_to_serve()` excludes standalone profiles; roster callers that mean "every installed profile" (plugin deps, Windows update, launch policy, dashboard listing and topology) pass `include_standalone=True`. - gateway/host_attach.py: `standalone_attach_decision` starts a standalone profile's gateway beside the host multiplexer once every live gateway confirms it does not serve that profile; refuses with a rescan message while one still does. Used by the initial attach check and the lock-losing race. - hermes_cli/gateway_multiplex_mode.py: a standalone launcher never becomes the host multiplexer (`STANDALONE_PROFILE_REASON`), including callers that supply an explicit GatewayConfig. - hermes_cli/gateway.py, web_server_gateway.py: `hermes -p X gateway install/start/run` proceeds without --force for a standalone profile; the refusal text for other profiles points at the opt-out; status shows "standalone (gateway.standalone: true)" and the default lists skipped profiles. - gateway/run_profile_reconcile.py: the host does not re-adopt a profile whose own gateway is live (removing the key while it runs no longer double-binds). - hermes_cli/gateway_migrate.py: standalone profiles are neither blocker nor fold target; the plan lists them as "standalone by config". - gateway/run.py: one INFO line per standalone profile at host boot. Tests: two-home E2E through real loaders and resolve_multiplex_mode, decide() with fake host records for both arms, lock-losing branch, reconcile guard, migrate plan, refusal predicate both ways, topology, memo and malformed-yaml contracts. All red on base.
35 lines
1.4 KiB
Python
35 lines
1.4 KiB
Python
"""The runner boundary honours a profile opt-out even for explicit --config inputs."""
|
|
|
|
import asyncio
|
|
from pathlib import Path
|
|
|
|
import pytest
|
|
|
|
|
|
@pytest.mark.parametrize("flag", [None, False, True])
|
|
def test_injected_config_cannot_multiplex_a_standalone_home(tmp_path, monkeypatch, flag):
|
|
from agent.secret_scope import is_multiplex_active, set_multiplex_active
|
|
from gateway.config import GatewayConfig
|
|
from gateway.run import GatewayRunner, _profile_runtime_scope
|
|
|
|
monkeypatch.setattr(Path, "home", lambda: tmp_path)
|
|
root = tmp_path / ".hermes"
|
|
solo = root / "profiles" / "solo"
|
|
solo.mkdir(parents=True)
|
|
(root / "config.yaml").write_text("{}\n")
|
|
(solo / "config.yaml").write_text("gateway:\n standalone: true\n")
|
|
monkeypatch.setenv("HERMES_HOME", str(root))
|
|
previous = is_multiplex_active()
|
|
try:
|
|
for home in (solo, root, solo):
|
|
with _profile_runtime_scope(home):
|
|
config = GatewayConfig(multiplex_profiles=flag, sessions_dir=home / "sessions")
|
|
runner = GatewayRunner(config)
|
|
try:
|
|
assert runner.config.multiplex_profiles is (False if home == solo else flag)
|
|
assert is_multiplex_active() is (False if home == solo else bool(flag))
|
|
finally:
|
|
if runner._session_db is not None:
|
|
asyncio.run(runner._session_db.close())
|
|
finally:
|
|
set_multiplex_active(previous)
|