From def7c8e29e24b5e8ba8168b297e7c7f800d794a2 Mon Sep 17 00:00:00 2001 From: Jack Kingsman Date: Mon, 9 Mar 2026 23:16:17 -0700 Subject: [PATCH] route radio sync through radio runtime --- app/AGENTS.md | 2 +- app/radio_sync.py | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/app/AGENTS.md b/app/AGENTS.md index d681ef9..e44d0f5 100644 --- a/app/AGENTS.md +++ b/app/AGENTS.md @@ -77,7 +77,7 @@ app/ - `RadioManager.start_connection_monitor()` checks health every 5s. - `RadioManager.post_connect_setup()` delegates to `services/radio_lifecycle.py`. -- Routers, startup/lifespan code, and fanout helpers should reach radio state through `services/radio_runtime.py`, not by importing `app.radio.radio_manager` directly. +- Routers, startup/lifespan code, fanout helpers, and `radio_sync.py` should reach radio state through `services/radio_runtime.py`, not by importing `app.radio.radio_manager` directly. - Shared reconnect/setup helpers in `services/radio_lifecycle.py` are used by startup, the monitor, and manual reconnect/reboot flows before broadcasting healthy state. - Setup still includes handler registration, key export, time sync, contact/channel sync, polling/advert tasks. diff --git a/app/radio_sync.py b/app/radio_sync.py index b7b4a47..1fb20cc 100644 --- a/app/radio_sync.py +++ b/app/radio_sync.py @@ -18,7 +18,7 @@ from meshcore import EventType, MeshCore from app.event_handlers import cleanup_expired_acks from app.models import Contact -from app.radio import RadioOperationBusyError, radio_manager +from app.radio import RadioOperationBusyError from app.repository import ( AmbiguousPublicKeyPrefixError, AppSettingsRepository, @@ -26,6 +26,7 @@ from app.repository import ( ContactRepository, ) from app.services.contact_reconciliation import reconcile_contact_messages +from app.services.radio_runtime import radio_runtime as radio_manager logger = logging.getLogger(__name__) @@ -744,6 +745,7 @@ async def sync_recent_contacts_to_radio(force: bool = False, mc: MeshCore | None # If caller provided a MeshCore instance, use it directly (caller holds the lock) if mc is not None: _last_contact_sync = now + assert mc is not None return await _sync_contacts_to_radio_inner(mc) if not radio_manager.is_connected or radio_manager.meshcore is None: @@ -756,6 +758,7 @@ async def sync_recent_contacts_to_radio(force: bool = False, mc: MeshCore | None blocking=False, ) as mc: _last_contact_sync = now + assert mc is not None return await _sync_contacts_to_radio_inner(mc) except RadioOperationBusyError: logger.debug("Skipping contact sync to radio: radio busy")