Skip to content

The agent that grows with you

fix(hosted-rooms): scope the budget and member-file reads with the home override only

Teknium92832474ba1b
diff --git a/tui_gateway/hosted_room_server_rpc.py b/tui_gateway/hosted_room_server_rpc.py
index e8896abef12..360e7912c05 100644
--- a/tui_gateway/hosted_room_server_rpc.py
+++ b/tui_gateway/hosted_room_server_rpc.py
@@ -4,7 +4,6 @@ task proof as an in-process-only Python object that JSON clients cannot forge.""
from __future__ import annotations
-import contextlib
import itertools
import threading
from collections.abc import Mapping, Sequence
@@ -81,18 +80,21 @@ class HostedRoomServerRPC:
if not attachments:
return self._submit(profile, session_id, prompt, source, task, execution_generation,
on_terminal, member_id, images=())
- from gateway.run import _profile_runtime_scope
from gateway.session_hosted_attachments import bound_submission_payload
from gateway.session_ingress_media import capture_lease
+ from hermes_constants import reset_hermes_home_override, set_hermes_home_override
home = self.server._profile_home(profile)
# The member's own caches receive its files (the gateway route's owner scope), and the
# capture lease holds them until prompt.submit has persisted the row that names them.
with capture_lease():
- with (_profile_runtime_scope(home, hydrate_secrets=False)
- if home is not None else contextlib.nullcontext()):
+ token = set_hermes_home_override(str(home)) if home is not None else None
+ try:
inputs = bound_submission_payload(
self.db_path, room_id=task.room_id, member_id=member_id, prompt=prompt,
attachments=list(attachments))
+ finally:
+ if token is not None:
+ reset_hermes_home_override(token)
return self._submit(profile, session_id, inputs["text"], source, task, execution_generation,
on_terminal, member_id,
images=[item["path"] for item in inputs.get("attachments", ())])
diff --git a/tui_gateway/hosted_room_service.py b/tui_gateway/hosted_room_service.py
index 55db3673931..34f7e599bdb 100644
--- a/tui_gateway/hosted_room_service.py
+++ b/tui_gateway/hosted_room_service.py
@@ -52,11 +52,14 @@ def attempt_action(kind: str, task: Mapping[str, Any]) -> dict[str, Any]:
def _discussion_limits(root: Path) -> discussion.DiscussionLimits:
"""Read the room owner's config, never the current member's profile scope. A malformed value
keeps today's defaults (logged) rather than taking every room on this store offline."""
- from gateway.run import _profile_runtime_scope
from hermes_cli.config_effective import load_user_config_effective
+ from hermes_constants import reset_hermes_home_override, set_hermes_home_override
- with _profile_runtime_scope(root, hydrate_secrets=False):
- config = load_user_config_effective()
+ token = set_hermes_home_override(str(root))
+ try:
+ config = load_user_config_effective(root / "config.yaml")
+ finally:
+ reset_hermes_home_override(token)
try:
rooms = config.get("hosted_rooms", {})
if not isinstance(rooms, Mapping):