The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(dashboard): secondary native tickets expand config with their own profile's secrets
Teknium42ffb53e80fa
diff --git a/hermes_cli/web_server_profiles.py b/hermes_cli/web_server_profiles.pyindex 9ddc6068bf8..12107987e1c 100644--- a/hermes_cli/web_server_profiles.py+++ b/hermes_cli/web_server_profiles.py@@ -290,17 +290,21 @@ def _config_profile_scope(profile: Optional[str]):Explicit names resolving to the process home retain current-profile semantics.Still enter the requested home so a nested scope cannot retain another profile.+ None/""/"current" mean the request's EFFECTIVE home: a task-local override (a secondary+ profile's native ticket, ``native_profile_scope``) is that profile, so it gets that profile's+ secret scope rather than the launch profile's."""from agent.secret_scope import build_profile_secret_scope, reset_secret_scope, set_secret_scopefrom hermes_cli.env_loader import hydrate_profile_secret_sources+ from hermes_constants import get_hermes_home, get_hermes_home_overridefrom tui_gateway.launch_profile_policy import activate_multi_profile_hosting, launch_secret_scopeprocess_home = get_process_hermes_home()if _is_current_profile(profile):- profile_dir, scoped = None, None # the dashboard's own profile: no home override+ profile_dir = get_hermes_home() if get_hermes_home_override() else Noneelse:profile_dir = _resolve_profile_dir(profile.strip())- scoped = None if profile_dir.resolve() == process_home.resolve() else profile_dir+ scoped = None if profile_dir is None or profile_dir.resolve() == process_home.resolve() else profile_dirif scoped is not None:activate_multi_profile_hosting()hydrate_profile_secret_sources(scoped) # first call may block on the source's fetchdiff --git a/tests/hermes_cli/test_web_multi_profile_scope.py b/tests/hermes_cli/test_web_multi_profile_scope.pyindex 67815e061ae..bf7247ec6d9 100644--- a/tests/hermes_cli/test_web_multi_profile_scope.py+++ b/tests/hermes_cli/test_web_multi_profile_scope.py@@ -99,3 +99,49 @@ def test_console_send_for_named_profile_does_not_write_process_env(two_homes, moassert seen["loader_sees"] == "b-telegram-token" # the loader gets B's token through the scopeassert seen["environ_has"] is False # and the dashboard process env never learns itassert "B_ONLY_TOKEN" not in os.environ+++def _native_ticket(home):+ from types import SimpleNamespace+ return SimpleNamespace(state=SimpleNamespace(native_http_principal={"profile_id": str(home.resolve())}))++[email protected]("selector", [None, "", "current"])+def test_secondary_native_ticket_implicit_selector_expands_only_the_ticket_profiles_secrets(two_homes, selector):+ """R16: under a secondary-profile native ticket, a nested ``_config_profile_scope(None/''/current)``+ installed the LAUNCH profile's secret scope, so B's YAML expanded with A's credentials."""+ from hermes_cli.config import load_config+ from hermes_cli.dashboard_auth.native_http import native_profile_scope+ from hermes_cli.web_server_profiles import _config_profile_scope++ _root, b = two_homes+ environ_before = dict(os.environ)+ with native_profile_scope(_native_ticket(b)), _config_profile_scope(selector):+ probe = load_config()["custom_probe"]+ assert probe["b_ref"] == B_VAL # present only in the ticket profile's .env+ assert probe["a_ref"] == "${A_ONLY_TOKEN}" # missing in B: never borrowed from the launch profile+ assert dict(os.environ) == environ_before+++def test_concurrent_launch_and_secondary_native_requests_keep_their_own_secrets(two_homes):+ import threading++ from hermes_cli.config import load_config+ from hermes_cli.dashboard_auth.native_http import native_profile_scope+ from hermes_cli.web_server_profiles import _config_profile_scope++ root, b = two_homes+ barrier, seen = threading.Barrier(2, timeout=10), {}++ def request(name, home):+ with native_profile_scope(_native_ticket(home)), _config_profile_scope(None):+ barrier.wait() # both scopes are live at once+ seen[name] = load_config()["custom_probe"]++ threads = [threading.Thread(target=request, args=args) for args in (("a", root), ("b", b))]+ for t in threads:+ t.start()+ for t in threads:+ t.join(10)+ assert seen["a"] == {"a_ref": A_VAL, "b_ref": "${B_ONLY_TOKEN}"}+ assert seen["b"] == {"a_ref": "${A_ONLY_TOKEN}", "b_ref": B_VAL}