The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
test(http): pin launch-home ticket against a foreign ambient home override
Teknium81cc569494a7
diff --git a/hermes_cli/dashboard_auth/native_http.py b/hermes_cli/dashboard_auth/native_http.pyindex 2bba4b1cf39..da6c7eab909 100644--- a/hermes_cli/dashboard_auth/native_http.py+++ b/hermes_cli/dashboard_auth/native_http.py@@ -23,7 +23,8 @@ def native_profile_scope(request):``get_hermes_home()`` / ``_default_db_path()``, which is the launch home unless thetask-local override says otherwise. A secondary-profile ticket must read and write itsown profile, never the launch profile's dashboard state. The launch profile's own ticket- already resolves there, so it keeps the ambient (single-profile) behaviour byte-for-byte.+ binds its home override too, so it never inherits a foreign override that happens to be+ ambient in the request context."""grant = getattr(request.state, 'native_http_principal', None)if grant is None:diff --git a/tests/gateway/test_native_config_owner_scope.py b/tests/gateway/test_native_config_owner_scope.pyindex 0dde3ff34c0..4a11ff84416 100644--- a/tests/gateway/test_native_config_owner_scope.py+++ b/tests/gateway/test_native_config_owner_scope.py@@ -1,32 +1,26 @@-"""A native ticket's implicit selectors retain its secrets through nested config scopes."""-import asyncio+"""A native ticket binds its own home even when a foreign home override is ambient."""from pathlib import Pathfrom types import SimpleNamespace-import pytest--async def test_concurrent_ticket_profiles_bind_nested_config_secrets(tmp_path, monkeypatch):+def test_launch_ticket_overrides_foreign_ambient_scope(tmp_path, monkeypatch):from agent.secret_scope import get_secretfrom hermes_cli.dashboard_auth.native_http import native_profile_scopefrom hermes_cli.web_server_profiles import _config_profile_scope- from hermes_constants import get_hermes_home+ from hermes_constants import get_hermes_home, reset_hermes_home_override, set_hermes_home_overridehome = tmp_path / '.hermes'home.mkdir()monkeypatch.setenv('HERMES_HOME', str(home))monkeypatch.setattr(Path, 'home', lambda: tmp_path)monkeypatch.setenv('SCOPE_SENTINEL', 'launch')- monkeypatch.setenv('SCOPE_MISSING', 'launch-only')- beta, gamma = home / 'profiles' / 'beta', home / 'profiles' / 'gamma'- for profile in (beta, gamma):- profile.mkdir(parents=True)- (profile / '.env').write_text('SCOPE_SENTINEL=' + profile.name + '\n', encoding='utf-8')- async def read(profile, selector):- request = SimpleNamespace(state=SimpleNamespace(native_http_principal={'profile_id': str(profile)}))- with native_profile_scope(request), _config_profile_scope(selector):- await asyncio.sleep(0)- assert get_hermes_home() == profile- assert get_secret('SCOPE_SENTINEL') == profile.name- assert get_secret('SCOPE_MISSING') is None- await asyncio.gather(*(read(profile, selector) for profile in (beta, gamma) for selector in (None, '', 'current')))+ beta = home / 'profiles' / 'beta'+ beta.mkdir(parents=True)+ (beta / '.env').write_text('SCOPE_SENTINEL=beta\n', encoding='utf-8')+ ambient = set_hermes_home_override(str(beta))+ try:+ request = SimpleNamespace(state=SimpleNamespace(native_http_principal={'profile_id': str(home)}))+ with native_profile_scope(request), _config_profile_scope(None):+ seen = (get_hermes_home(), get_secret('SCOPE_SENTINEL'))+ finally:+ reset_hermes_home_override(ambient)+ assert seen == (home, 'launch')