The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(desktop): cron ticker follows the multiplexer allowlist and stands down for served satellites
Teknium0e57543908fd
diff --git a/hermes_cli/web_server.py b/hermes_cli/web_server.pyindex 788e531b5da..34724175106 100644--- a/hermes_cli/web_server.py+++ b/hermes_cli/web_server.py@@ -97,19 +97,25 @@ def _start_desktop_cron_ticker(stop_event: "threading.Event", interval: int = 60start_kwargs: dict = {"interval": interval}if isinstance(provider, InProcessCronScheduler):try:- from hermes_cli.profiles import profiles_to_serve-- profile_homes = list(profiles_to_serve(multiplex=True))+ from hermes_cli.profiles import (+ _check_gateway_running, _served_by_running_multiplexer, profiles_to_serve)+ from hermes_cli.web_server_cron import _default_multiplex_profile_allowlist++ # Same served set as the multiplexer (allowlist honoured): a profile the default+ # gateway deliberately does not serve must not be ticked from the Desktop either.+ profile_homes = list(profiles_to_serve(+ multiplex=True, profile_allowlist=_default_multiplex_profile_allowlist()))if profile_homes:# Even one profile needs the per-tick gateway gate; otherwise# Desktop races its dedicated gateway for the same cron store.start_kwargs["profile_homes"] = profile_homes- # Stand down, per tick, for a profile whose OWN gateway runs:- # it ticks with live adapters, and the tick-lock race would- # otherwise deliver through the standalone path (#100489).- from hermes_cli.profiles import _check_gateway_running-- start_kwargs["profile_gate"] = lambda _name, home: not _check_gateway_running(Path(home))+ # Stand down, per tick, for a profile already owned by a gateway — its OWN+ # process, or the live default multiplexer (a served satellite has no gateway.pid+ # of its own). That gateway ticks with live adapters; winning the tick-lock race+ # here would deliver through the standalone path (#100489, #107485).+ start_kwargs["profile_gate"] = lambda name, home: not (+ _check_gateway_running(Path(home))+ or (name != "default" and _served_by_running_multiplexer(name)))from hermes_logging import enable_profile_log_routingenable_profile_log_routing(profile_homes)diff --git a/hermes_cli/web_server_cron.py b/hermes_cli/web_server_cron.pyindex e894a23494a..92bfb5d34b2 100644--- a/hermes_cli/web_server_cron.py+++ b/hermes_cli/web_server_cron.py@@ -79,6 +79,23 @@ def _validate_dashboard_cron_context_from(refs: Optional[List[str]], profile_namdetail=f"context_from job '{ref}' not found in profile '{profile_name}'")+def _default_multiplex_profile_allowlist() -> "list[str] | None":+ """``gateway.multiplex_profile_allowlist`` as the DEFAULT profile's config declares it (the+ multiplexer's served set), so the Desktop ticker mirrors ``gateway/run.py::_multiplex_profile_homes``+ instead of ticking every installed profile. ``None`` = serve all (historical behavior)."""+ from gateway.config import _normalize_multiplex_profile_allowlist+ from hermes_cli.config import read_user_config_raw+ from hermes_constants import get_default_hermes_root++ cfg_path = get_default_hermes_root() / "config.yaml"+ if not cfg_path.exists():+ return None+ cfg = read_user_config_raw(cfg_path) or {}+ raw = cfg.get("multiplex_profile_allowlist") if "multiplex_profile_allowlist" in cfg else (+ cfg.get("gateway") or {}).get("multiplex_profile_allowlist")+ return _normalize_multiplex_profile_allowlist(raw)++def _cron_profile_dicts() -> List[Dict[str, Any]]:"""Minimal profile records (callers only consume ``name``); avoids ``list_profiles()``,whose config parsing, gateway probes and skill counts are GIL pressure on large pools."""diff --git a/tests/cron/test_cron_multiplex_desktop_ticker_scope.py b/tests/cron/test_cron_multiplex_desktop_ticker_scope.pyindex 1fcc20308e5..7305f810eab 100644--- a/tests/cron/test_cron_multiplex_desktop_ticker_scope.py+++ b/tests/cron/test_cron_multiplex_desktop_ticker_scope.py@@ -115,11 +115,12 @@ def test_desktop_ticker_gates_on_profile_gateway_running(tmp_path, monkeypatch,homes = [("default", tmp_path / "default"), ("ops", tmp_path / "ops")][:profile_count]running = {homes[-1][1]}monkeypatch.setattr(- "hermes_cli.profiles.profiles_to_serve", lambda multiplex=False: list(homes)+ "hermes_cli.profiles.profiles_to_serve", lambda multiplex=False, profile_allowlist=None: list(homes))monkeypatch.setattr("hermes_cli.profiles._check_gateway_running", lambda home: home in running)+ monkeypatch.setattr("hermes_cli.profiles._served_by_running_multiplexer", lambda name: False)captured = {}class _Provider:diff --git a/tests/hermes_cli/test_desktop_cron_ticker_profiles.py b/tests/hermes_cli/test_desktop_cron_ticker_profiles.pyindex b88a7d11507..941d6872fc6 100644--- a/tests/hermes_cli/test_desktop_cron_ticker_profiles.py+++ b/tests/hermes_cli/test_desktop_cron_ticker_profiles.py@@ -130,3 +130,30 @@ def test_external_provider_never_gets_profile_homes(monkeypatch, tmp_path):ws._start_desktop_cron_ticker(threading.Event(), interval=13)assert external.start_kwargs == {"interval": 13}+++def test_desktop_ticker_honours_allowlist_and_yields_to_default_multiplexer(monkeypatch, _providers, tmp_path):+ """The Desktop ticker mirrors the multiplexer's served set (allowlist) and stands down for a+ satellite the live default multiplexer already ticks — that profile has no gateway.pid of its+ own, so the per-home liveness check alone lets both tickers race for its fires (#107485)."""+ import hermes_cli.profiles as profiles_mod+ import yaml++ _sp, builtin = _providers+ root = tmp_path / ".hermes"+ for name in ("worker", "guest"):+ (root / "profiles" / name).mkdir(parents=True)+ (root / "config.yaml").write_text(yaml.safe_dump(+ {"gateway": {"multiplex_profiles": True, "multiplex_profile_allowlist": ["worker"]}}))+ monkeypatch.setattr("hermes_constants.get_default_hermes_root", lambda: root)+ monkeypatch.setattr(profiles_mod, "_get_default_hermes_home", lambda: root)+ monkeypatch.setattr(profiles_mod, "_get_profiles_root", lambda: root / "profiles")+ monkeypatch.setattr(profiles_mod, "_check_gateway_running", lambda home: False)+ monkeypatch.setattr(profiles_mod, "_served_by_running_multiplexer", lambda name: name == "worker")++ ws._start_desktop_cron_ticker(threading.Event(), interval=0)++ assert [name for name, _ in builtin.start_kwargs["profile_homes"]] == ["default", "worker"]+ gate = builtin.start_kwargs["profile_gate"]+ assert gate("default", root) is True+ assert gate("worker", root / "profiles" / "worker") is False