The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(gateway): stable bot ownership for satellite fallback; relay completions survive a restart
unsupportedpastels18e16bdd7d01
diff --git a/cron/scheduler_preflight.py b/cron/scheduler_preflight.pyindex 11ae730b6b8..17a3cd7ec8d 100644--- a/cron/scheduler_preflight.py+++ b/cron/scheduler_preflight.py@@ -233,13 +233,13 @@ class SharedRouteAdapters:return default-def has_credential_platform(adapters, reconnecting=None) -> bool:+def has_credential_platform(adapters, owned=None) -> bool:"""True when the profile has a bot of its own. Any local session (Desktop chat, CLI run, Kanbanworker) adds a ``LOCAL`` adapter, which holds no platform credential: a profile with only that is- still a credentialless satellite that may ride routed primary adapters. ``reconnecting`` is the- profile's ``_profile_failed_platforms`` entry: a bot that dropped is removed from the map while- it reconnects, and borrowing the primary meanwhile would send through the wrong bot."""- return bool(reconnecting) or any(+ still a credentialless satellite that may ride routed primary adapters. ``owned`` is the+ profile's ``_profile_bot_platforms`` entry: a bot that dropped leaves the live map while it+ disconnects and reconnects, and borrowing the primary meanwhile would send through the wrong bot."""+ return bool(owned) or any(getattr(platform, "value", platform) != "local" for platform in adapters or ())diff --git a/cron/scheduler_provider.py b/cron/scheduler_provider.pyindex 77915155362..e0c08d001d6 100644--- a/cron/scheduler_provider.py+++ b/cron/scheduler_provider.py@@ -438,7 +438,7 @@ class InProcessCronScheduler(CronScheduler):def start(self, stop_event, *, adapters=None, loop=None, interval=60, can_dispatch=None,profile_homes=None, profile_adapters=None, default_profile=None, profile_gate=None,- profile_failed_platforms=None,+ profile_bot_platforms=None,):from cron.scheduler import CronTickYieldedfrom cron.scheduler import tick as cron_tick@@ -459,7 +459,7 @@ class InProcessCronScheduler(CronScheduler):stop_event, profile_homes=profile_homes, adapters=adapters, loop=loop,interval=interval, can_dispatch=can_dispatch, profile_adapters=profile_adapters,default_profile=default_profile, profile_gate=profile_gate,- profile_failed_platforms=profile_failed_platforms,+ profile_bot_platforms=profile_bot_platforms,)return@@ -536,7 +536,7 @@ class InProcessCronScheduler(CronScheduler):def _start_multiplex(self, stop_event, *, profile_homes, adapters=None, loop=None, interval=60,can_dispatch=None, profile_adapters=None, default_profile=None, profile_gate=None,- profile_failed_platforms=None,+ profile_bot_platforms=None,):"""Tick every profile's store, each scoped via ``_profile_cron_scope``. ``profile_gate(name,home)``, when given, is consulted every cycle; a rejected profile is neither ticked nor@@ -565,8 +565,8 @@ class InProcessCronScheduler(CronScheduler):if profile_name is None or profile_name == default_profile:return adapterstick_adapters = (profile_adapters or {}).get(profile_name) or {}- reconnecting = (profile_failed_platforms or {}).get(profile_name)- if not has_credential_platform(tick_adapters, reconnecting) and adapters:+ owned = (profile_bot_platforms or {}).get(profile_name)+ if not has_credential_platform(tick_adapters, owned) and adapters:return SharedRouteAdapters(adapters, _primary_profile_routes_for_current_home())return tick_adaptersdiff --git a/gateway/authz_mixin.py b/gateway/authz_mixin.pyindex b49a29f8d35..d54e5202d88 100644--- a/gateway/authz_mixin.py+++ b/gateway/authz_mixin.py@@ -246,8 +246,8 @@ class GatewayAuthorizationMixin:config = getattr(self, "config", None)if not getattr(config, "multiplex_profiles", False):return False- # A bot that failed to connect is queued for reconnect: that profile owns a credential.- if (getattr(self, "_profile_failed_platforms", None) or {}).get(profile_name):+ # A bot of its own that is down (failed to connect, or dropped) still makes it a credential boundary.+ if (getattr(self, "_profile_bot_platforms", None) or {}).get(profile_name):return Falseroutes = getattr(config, "profile_routes", None) or []if not any(r.enabled and r.profile == profile_name and r.bot_profile is None for r in routes):diff --git a/gateway/run.py b/gateway/run.pyindex 94006f7fae4..5ae6dc85e02 100644--- a/gateway/run.py+++ b/gateway/run.py@@ -4483,9 +4483,9 @@ def _drain_restart_safe_cron_deliveries(adapters, loop, runner=None) -> None:if profile_adapters is None:continuewith _profile_runtime_scope(profile_home or get_hermes_home()):- reconnecting = (getattr(runner, "_profile_failed_platforms", None) or {}).get(profile_name)+ owned = (getattr(runner, "_profile_bot_platforms", None) or {}).get(profile_name)if (profile_name is not None and adapters- and not sched_preflight.has_credential_platform(profile_adapters, reconnecting)):+ and not sched_preflight.has_credential_platform(profile_adapters, owned)):routes = sched_preflight._primary_profile_routes_for_current_home()if routes:profile_adapters = sched_preflight.SharedRouteAdapters(adapters, routes)diff --git a/gateway/run_adapters.py b/gateway/run_adapters.pyindex 012a3aa7bee..80764deda00 100644--- a/gateway/run_adapters.py+++ b/gateway/run_adapters.py@@ -1325,6 +1325,12 @@ class GatewayAdapterLifecycleMixin:owner_origin=owner_origin, incoming_origin=incoming_origin,) or self._refuse_duplicate_claim(listener_claim, claimed, profile_name, platform, "listener"):continue+ # The profile owns this bot from here on, connected or not: cron and the delivery drain read+ # ownership here from another thread, never from the live map a fatal error rewrites.+ bot_platforms = getattr(self, "_profile_bot_platforms", None)+ if bot_platforms is None:+ bot_platforms = self._profile_bot_platforms = {}+ bot_platforms.setdefault(profile_name, set()).add(platform)self._configure_profile_adapter(adapter, profile_name, platform)try:with _profile_runtime_scope(profile_home, hydrate_secrets=False):diff --git a/gateway/run_bootstrap.py b/gateway/run_bootstrap.pyindex 5ae93988f21..dcfc1c81205 100644--- a/gateway/run_bootstrap.py+++ b/gateway/run_bootstrap.py@@ -414,8 +414,8 @@ def _start_gateway_start_cron_and_housekeeping(runner):# default's. Absent (no multiplexed adapters), delivery for a secondary profile falls# back to the primary's routed adapters or fails closed — the job still FIRES.cron_start_kwargs["profile_adapters"] = getattr(runner, "_profile_adapters", None)- # A secondary bot parked for reconnect is still that profile's own: never borrow meanwhile.- cron_start_kwargs["profile_failed_platforms"] = getattr(runner, "_profile_failed_platforms", None)+ # A secondary bot that dropped is still that profile's own: never borrow meanwhile.+ cron_start_kwargs["profile_bot_platforms"] = getattr(runner, "_profile_bot_platforms", None)# runner.adapters belongs to the LAUNCH profile (``default``, or the ``--profile``# name); naming it keeps the ticker from routing a secondary's cron through that bot# and lets a named multiplexer's own jobs reuse its live adapters.diff --git a/gateway/run_notifications.py b/gateway/run_notifications.pyindex 5654cb7835b..5af54565ae1 100644--- a/gateway/run_notifications.py+++ b/gateway/run_notifications.py@@ -872,8 +872,33 @@ class GatewayNotificationsMixin(GatewayUpdateNotificationsMixin, GatewayNotifica_transport = Noneif _transport is not None:return _transport.adapter+ if source is not None and (relay := self._committed_relay_adapter(source)) is not None:+ return relayreturn next((a for p, a in adapters.items() if p.value == platform_name), None)+ def _committed_relay_adapter(self, source):+ """The relay a restored *source* was admitted through, proven by its route's last committed+ admission. Persisted origins omit relay trust, so a connector-stamped profile with no local+ route to borrow the primary relay by otherwise finds no adapter after a restart."""+ from gateway.session_authorities import active_authority+ from gateway.session_automation import committed_route_envelope+ from gateway.session_envelope import restore_native+ from hermes_state_runtime import RuntimeStoreError+ authority = active_authority(self)+ if authority is None:+ return None+ entry = self.session_store.lookup_by_session_key(self.session_store._generate_session_key(source))+ envelope = committed_route_envelope(authority, entry) if entry is not None else None+ if envelope is None or 'relay' not in envelope['provenance']:+ return None+ # The seal is rechecked against the live connector, as ``snapshot_automation`` does.+ try:+ restored = restore_native({'text': '', 'native_text_v1': {+ key: value for key, value in envelope.items() if key != 'media'}}, self)+ except RuntimeStoreError:+ return None+ return self._adapter_for_source(restored.source)+async def _inject_watch_notification(self, synth_text: str, evt: dict, *, raise_not_accepted: bool = False,) -> Optional[bool]:diff --git a/gateway/run_profile_reconcile.py b/gateway/run_profile_reconcile.pyindex 9789bfc0de0..20bbfce5a24 100644--- a/gateway/run_profile_reconcile.py+++ b/gateway/run_profile_reconcile.py@@ -483,7 +483,8 @@ class GatewayProfileReconcileMixin:# Its ``<name>:<platform>`` runtime entries describe a profile that no longer exists._write_runtime_status_quiet(drop_profile_platforms=name)for attr in ("pairing_stores", "_busy_text_modes_by_profile", "_busy_input_modes_by_profile",- "_busy_text_timing_by_profile", "_human_delay_by_profile", "_profile_configs"):+ "_busy_text_timing_by_profile", "_human_delay_by_profile", "_profile_configs",+ "_profile_bot_platforms"):store = getattr(self, attr, None)if isinstance(store, dict):store.pop(name, None)diff --git a/gateway/run_runtime_init.py b/gateway/run_runtime_init.pyindex 3e75e19c4b0..38e3f8351f1 100644--- a/gateway/run_runtime_init.py+++ b/gateway/run_runtime_init.py@@ -55,6 +55,7 @@ class GatewayRuntimeInitMixin:self._exit_reason: Optional[str] = Noneself._exit_code: Optional[int] = Noneself._profile_failed_platforms: Dict[str, Dict[Platform, asyncio.Task]] = {}+ self._profile_bot_platforms: Dict[str, set[Platform]] = {}self._systemd_watchdog = None# External (NAS-driven) drain, distinct from one-way ``_draining``: set while ``.drain_request.json``# exists — NEW turns refused, process stays up, removing the marker reverts to ``running``.diff --git a/gateway/session_automation.py b/gateway/session_automation.pyindex fe6e8df4c6d..f47a6b7b4f1 100644--- a/gateway/session_automation.py+++ b/gateway/session_automation.py@@ -488,7 +488,13 @@ async def admit_automation(authority, adapter, event, identity, replaces=None):from gateway.session_authority import LiveSessionsid = (payload.get('local_automation_v1') or payload['native_text_v1']['automation'])['owner']ref = SessionRef(authority.profile_id, sid)- authority.sessions.setdefault(ref.session_id, LiveSession(event.source, entry.session_key))+ source, envelope = event.source, payload.get('native_text_v1')+ if envelope is not None and 'relay' in envelope['provenance']:+ # A restored origin carries no relay trust: bind the source the snapshot verified, or the+ # drain resolves no adapter for this session after a restart.+ from gateway.session_envelope import restore_native_source+ source = restore_native_source(payload, authority.runner)+ authority.sessions.setdefault(ref.session_id, LiveSession(source, entry.session_key))from functools import partialfrom gateway.session_runtime_workers import tracked_writeadmitted, replaced = partial(authority._admitted, ref, event), []diff --git a/tests/cron/test_cron_multiplex_shared_route_delivery.py b/tests/cron/test_cron_multiplex_shared_route_delivery.pyindex 4300abda66f..a4326c32174 100644--- a/tests/cron/test_cron_multiplex_shared_route_delivery.py+++ b/tests/cron/test_cron_multiplex_shared_route_delivery.py@@ -220,7 +220,7 @@ def test_multiplex_tick_routes_desktop_served_satellite_with_only_local_adapter(def test_multiplex_tick_keeps_reconnecting_satellite_off_the_primary_bot(tmp_path, monkeypatch):- """A satellite whose OWN bot dropped is parked in ``_profile_failed_platforms`` while only its+ """A satellite whose OWN bot dropped stays in ``_profile_bot_platforms`` while only itsDesktop LOCAL adapter remains. Its cron tick must deliver via its own map (and fail until thebot reconnects), never borrow the primary bot."""import threading@@ -254,7 +254,7 @@ def test_multiplex_tick_keeps_reconnecting_satellite_off_the_primary_bot(tmp_pat"profile_homes": [("sat", sat_home)],"adapters": {Platform.DISCORD: _primary_adapter()},"profile_adapters": {"sat": own},- "profile_failed_platforms": {"sat": {Platform.DISCORD: object()}},+ "profile_bot_platforms": {"sat": {Platform.DISCORD}},"default_profile": "default",},daemon=True,diff --git a/tests/gateway/relay/test_relay_connector_profile_admission.py b/tests/gateway/relay/test_relay_connector_profile_admission.pyindex 9a97cb6b6a2..26e60851684 100644--- a/tests/gateway/relay/test_relay_connector_profile_admission.py+++ b/tests/gateway/relay/test_relay_connector_profile_admission.py@@ -10,6 +10,7 @@ import asyncioimport jsonfrom contextlib import asynccontextmanagerfrom pathlib import Path+from urllib.parse import urlsplitimport pytest@@ -24,7 +25,7 @@ SOURCE = {'platform': 'telegram', 'chat_type': 'dm'}@asynccontextmanager-async def _relay(runner, platforms=('telegram',)):+async def _relay(runner, platforms=('telegram',), port=0):"""A real WebSocketRelayTransport + RelayAdapter wired as ``runner``'s primary relay, against afake connector that acks every outbound. Yields ``(send, outgoing, adapter)``."""from gateway.relay.adapter import RelayAdapter@@ -47,7 +48,7 @@ async def _relay(runner, platforms=('telegram',)):elif frame['type'] == 'going_idle':await ws.send(json.dumps({'type': 'going_idle_ack'}) + '\n')- async with websockets.serve(connector, '127.0.0.1', 0) as server:+ async with websockets.serve(connector, '127.0.0.1', port) as server:transport = WebSocketRelayTransport(f'ws://127.0.0.1:{server.sockets[0].getsockname()[1]}/relay', platforms[0], 'fixture-bot',gateway_id='fixture-gateway', upgrade_secret='fixture-secret', reconnect=False)@@ -210,3 +211,53 @@ async def test_multiplexed_gateway_admits_a_connector_stamped_profile_into_its_oauthority.db.close()for _, home in homes:process_ownership.release(home)+++async def test_stamped_profile_completion_finds_its_relay_after_a_restart(tmp_path, monkeypatch):+ """A persisted origin omits relay trust, and a stamped profile with no local route cannot borrow+ the primary relay by route: after a restart its background completion must still reach the relay,+ proven by the route's committed relay admission, instead of being deferred or refused."""+ from gateway.run_runtime import initialize_gateway_runtime+ from gateway.runtime_ownership import process_ownership++ _root, homes = _reserve_homes(tmp_path, monkeypatch, names=('work',))+ process_ownership.reserve([home for _, home in homes])+ config = GatewayConfig(sessions_dir=tmp_path / 'sessions')+ config.multiplex_profiles = True+ config._runtime_profile_homes = tuple(homes)+ key = 'agent:work:telegram:dm:chat-work'+ runners = []+ try:+ first = GatewayRunner(config)+ runners.append(first)+ turns = _stub_turns(first, monkeypatch)+ await initialize_gateway_runtime(first)+ async with _relay(first) as (send, outgoing, adapter):+ # The relay seal binds the connector URL: the restarted gateway dials the same one.+ port = urlsplit(adapter._transport._url).port+ await send('to-work', 'chat-work', profile='work')+ await async_wait_until(lambda: turns and _replies(outgoing, 'chat-work'), timeout=30,+ what='the stamped turn answered')+ parent = first.session_store.lookup_by_session_key(key).session_id+ for authority in list(first.session_authorities):+ authority.db.close()++ second = GatewayRunner(config) # restart: fresh runner, authorities and relay over persisted state+ runners.append(second)+ turns = _stub_turns(second, monkeypatch)+ await initialize_gateway_runtime(second)+ async with _relay(second, port=port) as (_send, outgoing, _adapter):+ evt = {'type': 'completion', 'session_key': key, 'parent_session_id': parent,+ 'session_id': 'proc_restart', 'started_at': 1.0}+ async with second._completion_event_scope(evt):+ assert await second._inject_watch_notification('[process finished]', evt) is True+ await async_wait_until(lambda: turns and _replies(outgoing, 'chat-work'), timeout=30,+ what='the completion answered through the relay')+ assert turns[0][1:] == (homes[1][1].resolve(), key)+ finally:+ for runner in runners:+ for authority in list(getattr(runner, 'session_authorities', None) or []):+ authority.db.close()+ for _, home in homes:+ process_ownership.release(home)diff --git a/tests/gateway/test_cron_delivery_housekeeping.py b/tests/gateway/test_cron_delivery_housekeeping.pyindex f7803882ffc..038477be712 100644--- a/tests/gateway/test_cron_delivery_housekeeping.py+++ b/tests/gateway/test_cron_delivery_housekeeping.py@@ -218,8 +218,8 @@ def test_multiplex_housekeeping_routes_desktop_served_satellite_with_only_local_def test_multiplex_housekeeping_keeps_reconnecting_satellite_off_the_primary_bot(tmp_path, monkeypatch):- """A satellite whose OWN bot dropped has it popped from ``_profile_adapters`` and parked in- ``_profile_failed_platforms`` for reconnect. With only a Desktop LOCAL adapter left, the drain+ """A satellite whose OWN bot dropped has it popped from ``_profile_adapters`` while it+ reconnects; ``_profile_bot_platforms`` still names it. With only a Desktop LOCAL adapter left, the drainmust still treat it as owning its bot, never route its queue through the primary bot."""from gateway.config import Platform@@ -229,7 +229,7 @@ def test_multiplex_housekeeping_keeps_reconnecting_satellite_off_the_primary_botconfig=SimpleNamespace(multiplex_profiles=True),adapters=root_adapters,_profile_adapters={"secondary": own},- _profile_failed_platforms={"secondary": {Platform.DISCORD: object()}},+ _profile_bot_platforms={"secondary": {Platform.DISCORD}},)calls = []diff --git a/tests/gateway/test_multiplex_adapter_registry.py b/tests/gateway/test_multiplex_adapter_registry.pyindex 1ce45d3cec2..b1ac7f989fc 100644--- a/tests/gateway/test_multiplex_adapter_registry.py+++ b/tests/gateway/test_multiplex_adapter_registry.py@@ -261,6 +261,17 @@ def _install_secondary_reconnect_context(monkeypatch.setattr(runner, "_create_adapter", lambda platform, config: adapter)+def _stub_secondary_start(monkeypatch, runner):+ async def connect(adapter, platform):+ return True++ monkeypatch.setattr("hermes_cli.env_loader.hydrate_profile_secret_sources", lambda h: {})+ monkeypatch.setattr(gateway_run, "_load_gateway_config", dict)+ monkeypatch.setattr(runner, "_snapshot_profile_busy_modes", lambda *a, **k: None)+ monkeypatch.setattr("hermes_cli.plugins.discover_plugins", lambda: None)+ monkeypatch.setattr(runner, "_connect_initial_adapter_with_timeout", connect)++class TestSecondaryProfileFatalRecovery:@pytest.mark.asyncio@pytest.mark.parametrize("entry", ["startup", "reconnect"])@@ -398,6 +409,65 @@ class TestSecondaryProfileFatalRecovery:assert all(path != Path("/profiles/reviewer") for path in redelivery_homes)+ @pytest.mark.asyncio+ async def test_dropped_bot_is_never_swapped_for_the_primary(self, monkeypatch):+ """A routed profile whose own bot dropped (disconnect pending, then no reconnect for a dead+ credential) is still that bot's owner: its notices must not resolve the primary bot."""+ from gateway.profile_routing import ProfileRoute+ runner = _secondary_recovery_runner()+ runner._adapter_disconnect_timeout_secs = lambda: 5+ primary = object()+ runner.adapters = {Platform.DISCORD: primary}+ runner.config.profile_routes = [ProfileRoute("r", "discord", "reviewer", chat_id="C1")]+ monkeypatch.setattr(gateway_run, "_multiplex_profile_homes",+ lambda config: [("reviewer", Path("/profiles/reviewer"))])+ stale = _SecondaryRecoveryAdapter(retryable=False)+ _install_secondary_reconnect_context(monkeypatch, runner, stale)+ _stub_secondary_start(monkeypatch, runner)+ assert await runner._start_one_profile_adapters("reviewer", Path("/profiles/reviewer"), {}) == 1+ runner._profile_adapters["reviewer"][Platform.LOCAL] = object()+ disconnecting, release = asyncio.Event(), asyncio.Event()++ async def disconnect():+ disconnecting.set()+ await release.wait()++ stale.disconnect = disconnect+ handler = asyncio.create_task(+ runner._handle_profile_adapter_fatal_error("reviewer", Platform.DISCORD, stale))+ await asyncio.wait_for(disconnecting.wait(), 5)+ assert runner._adapters_for_profile("reviewer").get(Platform.DISCORD) is None+ release.set()+ await handler+ assert not runner._background_tasks+ assert runner._adapters_for_profile("reviewer").get(Platform.DISCORD) is None++ @pytest.mark.asyncio+ async def test_credential_repair_during_a_dead_disconnect_connects(self, monkeypatch):+ """A rescan after a credential repair, landing while a non-retryable bot is still+ disconnecting, builds the repaired bot: nothing else will (the dead one is never retried)."""+ runner = _secondary_recovery_runner()+ runner._adapter_disconnect_timeout_secs = lambda: 5+ stale, repaired = _SecondaryRecoveryAdapter(retryable=False), _SecondaryRecoveryAdapter()+ _install_secondary_reconnect_context(monkeypatch, runner, stale)+ _stub_secondary_start(monkeypatch, runner)+ assert await runner._start_one_profile_adapters("reviewer", Path("/profiles/reviewer"), {}) == 1+ disconnecting, release = asyncio.Event(), asyncio.Event()++ async def disconnect():+ disconnecting.set()+ await release.wait()++ stale.disconnect = disconnect+ handler = asyncio.create_task(+ runner._handle_profile_adapter_fatal_error("reviewer", Platform.DISCORD, stale))+ await asyncio.wait_for(disconnecting.wait(), 5)+ monkeypatch.setattr(runner, "_create_adapter", lambda platform, config: repaired)+ assert await runner._start_one_profile_adapters("reviewer", Path("/profiles/reviewer"), {}) == 1+ release.set()+ await handler+ assert runner._profile_adapters["reviewer"][Platform.DISCORD] is repaired+@pytest.mark.asyncioasync def test_secondary_reconnect_keeps_inbound_dedup(self, monkeypatch):"""A secondary profile's rebuilt adapter still drops an inbound ID the stale one admitted."""diff --git a/tests/gateway/test_multiplex_interactive_auth.py b/tests/gateway/test_multiplex_interactive_auth.pyindex c8e3805a87b..cc0f8f6ea89 100644--- a/tests/gateway/test_multiplex_interactive_auth.py+++ b/tests/gateway/test_multiplex_interactive_auth.py@@ -202,7 +202,7 @@ def test_authorization_adapter_ignores_per_turn_active_profile(mux_home):runner = _runner(mux_home)default_bot = object()runner.adapters = {Platform.TELEGRAM: default_bot}- runner._profile_failed_platforms = {"secondary": {Platform.TELEGRAM: object()}}+ runner._profile_bot_platforms = {"secondary": {Platform.TELEGRAM}}with _profile_runtime_scope(mux_home / "profiles" / "secondary"):assert runner._authorization_adapter(Platform.TELEGRAM, profile="secondary") is Nonediff --git a/tests/gateway/test_multiplex_transport_matrix.py b/tests/gateway/test_multiplex_transport_matrix.pyindex 3c6d836486b..cfad57cd790 100644--- a/tests/gateway/test_multiplex_transport_matrix.py+++ b/tests/gateway/test_multiplex_transport_matrix.py@@ -138,7 +138,7 @@ def test_restored_rows_fail_closed_on_intake_and_deliver_only_via_a_unique_owner# team_b's bot failed to connect and is queued for reconnect: it owns a credential, so the# route that also names it through the shared bot must not turn it into a satellite.r._profile_adapters["team_b"] = {}- r._profile_failed_platforms = {"team_b": {Platform.TELEGRAM: {}}}+ r._profile_bot_platforms = {"team_b": {Platform.TELEGRAM}}assert r._delivery_adapter_for(restored("team_b")) is Noneassert r._authorization_home_for_source(restored("team_b")) is None