Skip to content

The agent that grows with you

fix(gateway): resolve the multiplex owner home inside the off-loop secret load

Teknium51dfa39d8c96
diff --git a/gateway/session_ingress.py b/gateway/session_ingress.py
index 97440c7529b..f5486055504 100644
--- a/gateway/session_ingress.py
+++ b/gateway/session_ingress.py
@@ -285,14 +285,21 @@ async def _execution_scope(authority, home):
config, secrets, state.db), never the launch profile's ambient scope; native provenance
(``home``) refines it. A single-profile gateway keeps its ambient scope byte-for-byte.
Secret sources (external CLIs) hydrate off the loop, as main's per-message scope does (#99519)."""
- if home is None and getattr(getattr(authority.runner, 'config', None), 'multiplex_profiles', False):
- from pathlib import Path
- owner = Path(str(authority.profile_id)) # owner_scope's home: symbolic test ids keep ambient
- home = owner if owner.is_absolute() and owner.is_dir() else None
- if home is None:
+ multiplex = getattr(getattr(authority.runner, 'config', None), 'multiplex_profiles', False)
+ if home is None and not multiplex:
return nullcontext()
from gateway.run import _load_profile_secret_scope, _profile_runtime_scope
- return _profile_runtime_scope(home, await asyncio.to_thread(_load_profile_secret_scope, home))
+
+ def load():
+ from pathlib import Path
+ scope_home = home
+ if scope_home is None: # owner_scope's home; symbolic test ids keep the ambient scope
+ owner = Path(str(authority.profile_id))
+ scope_home = owner if owner.is_absolute() and owner.is_dir() else None
+ return scope_home, scope_home and _load_profile_secret_scope(scope_home)
+
+ scope_home, secrets = await asyncio.to_thread(load)
+ return nullcontext() if scope_home is None else _profile_runtime_scope(scope_home, secrets)
async def deliver_settled(authority, admission_id):
diff --git a/tests/gateway/test_native_epoch_timestamp.py b/tests/gateway/test_native_epoch_timestamp.py
index fa9fad18e44..79c27e0e52d 100644
--- a/tests/gateway/test_native_epoch_timestamp.py
+++ b/tests/gateway/test_native_epoch_timestamp.py
@@ -36,7 +36,7 @@ async def test_epoch_zero_producer_timestamp_runs_with_local_time_and_keeps_retr
monkeypatch.setattr(adapter, 'send', send)
monkeypatch.setattr(runner, '_handle_message_with_agent', turn)
source = adapter.build_source(chat_id=CHAT, user_id=CHAT, chat_type='dm')
- pinned = lambda: MessageEvent(text='hi', source=source, message_id='p1', # noqa: E731
+ pinned = lambda: MessageEvent(text='hi', source=source, message_id='p1',
timestamp=datetime.fromtimestamp(0, UTC))
try:
before = datetime.now()
diff --git a/tests/gateway/test_native_execution_secret_scope_off_loop.py b/tests/gateway/test_native_execution_secret_scope_off_loop.py
index 3c3e8516c8a..d836633c904 100644
--- a/tests/gateway/test_native_execution_secret_scope_off_loop.py
+++ b/tests/gateway/test_native_execution_secret_scope_off_loop.py
@@ -15,7 +15,7 @@ CHAT = '[email protected]'
@pytest.mark.asyncio
async def test_native_execution_and_settled_delivery_hydrate_secrets_off_loop(tmp_path, monkeypatch):
- import hermes_cli.env_loader as env_loader
+ from hermes_cli import env_loader
from plugins.platforms.whatsapp.adapter import WhatsAppAdapter
monkeypatch.setenv('WHATSAPP_ALLOWED_USERS', '15551234567')
hydrations = []
diff --git a/tests/gateway/test_native_media_capture_off_loop.py b/tests/gateway/test_native_media_capture_off_loop.py
index baf461c2294..2a782312a2d 100644
--- a/tests/gateway/test_native_media_capture_off_loop.py
+++ b/tests/gateway/test_native_media_capture_off_loop.py
@@ -43,6 +43,7 @@ async def test_native_media_capture_runs_off_loop_and_commits_owned_bytes(tmp_pa
attachment.write_bytes(b'changed')
row = get_session_admission(authority.db, admission_id=receipt.admission_id)
restored = restore_native(row['payload'], runner)
- assert open(restored.media_urls[0], 'rb').read() == b'video-bytes' * 1000
+ from pathlib import Path
+ assert Path(restored.media_urls[0]).read_bytes() == b'video-bytes' * 1000
finally:
authority.db.close()