The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(auth): isolate dashboard provider registration by launch home
fangliquanflqd93f74b7589d
diff --git a/hermes_cli/plugins.py b/hermes_cli/plugins.pyindex a979c394918..be0d1c3a28b 100644--- a/hermes_cli/plugins.py+++ b/hermes_cli/plugins.py@@ -28,7 +28,7 @@ from functools import cached_propertyfrom pathlib import Pathfrom typing import Any, Callable, Dict, List, Mapping, Optional, Set, Tuple, Union-from hermes_constants import get_hermes_home, hermes_home_key+from hermes_constants import get_hermes_home, get_process_hermes_home, hermes_home_keyfrom registration_lifecycle import replacement_coordinatorfrom utils import env_var_enabledfrom hermes_cli.config import load_config_readonly@@ -756,6 +756,18 @@ class PluginContext:from hermes_cli.dashboard_auth.registry import register_global_provider, unregister_global_providerif self._wrong_type(provider, DashboardAuthProvider, "dashboard-auth provider"):return+ launch_scope = hermes_home_key(get_process_hermes_home())+ if self._manager.scope_key != launch_scope:+ logger.warning(+ "Plugin '%s' tried to register dashboard-auth provider %r "+ "from profile scope %s; ignoring it because dashboard auth "+ "is owned by launch scope %s.",+ self.manifest.name,+ provider.name,+ self._manager.scope_key,+ launch_scope,+ )+ returnregistry_name = provider.name# The auth registry is process-global (lifetime = web server). Disposing it on a routine# per-home manager teardown emptied it for the WHOLE process and disabled sign-in untildiff --git a/tests/hermes_cli/test_dashboard_auth_plugin_hook.py b/tests/hermes_cli/test_dashboard_auth_plugin_hook.pyindex 96834b45e96..987eff59ba5 100644--- a/tests/hermes_cli/test_dashboard_auth_plugin_hook.py+++ b/tests/hermes_cli/test_dashboard_auth_plugin_hook.py@@ -5,6 +5,8 @@ art)."""from __future__ import annotations+from pathlib import Path+import pytestfrom hermes_cli.dashboard_auth import clear_providers, get_provider@@ -171,6 +173,26 @@ def test_auth_provider_re_register_rotates_in_place():assert get_provider("basic") is new+def test_profile_manager_cannot_replace_launch_home_auth_provider():+ """Profile plugin discovery must not rotate the dashboard's auth gate."""+ manager, ctx = _real_ctx()+ launch_provider = _Basic("launch-home")+ ctx.register_dashboard_auth_provider(launch_provider)++ profile_scope = hermes_home_key(Path(manager.scope_key) / "profiles" / "bot")+ profile_manager = PluginManager(scope_key=profile_scope)+ profile_ctx = PluginContext(+ PluginManifest(name="basic", version="0.0.1", kind="backend"),+ manager=profile_manager,+ )++ registration = profile_ctx.register_dashboard_auth_provider(_Basic("profile"))++ assert registration is None+ assert get_provider("basic") is launch_provider+ assert "basic" not in profile_manager._ownership_ledger++# ---------------------------------------------------------------------------# #91701 follow-up: persistence must not outlive the plugin. A targeted# unload (plugin disable/uninstall) and a re-discovery that drops the plugin