rouse-context/work
Jason Monk ec389786d9
Fix #414: Await IntegrationProviderRegistry first emission before checking enabledPaths() (#416)
On a cold-start FCM wake, FcmReceiver and TunnelForegroundService both read
ProviderRegistry.enabledPaths() synchronously to decide whether to honor the
wake. The app-side IntegrationProviderRegistry is DataStore-backed: its
_enabledIds StateFlow starts at emptySet() and only populates after the first
async combine() emission lands. In a freshly-spawned process the FCM message
arrives before that emission, the synchronous read returns emptySet(), and the
wake is silently dropped — every subsequent AI-client request EOFs after the
relay's 20s wakeup timeout.

This fix introduces ProviderRegistry.awaitReady()/awaitReadyBlocking() and
routes the three production callers through it before checking enabledPaths():

- FcmReceiver.onMessageReceived blocks the FCM worker thread (NOT main) on a
  CountDownLatch with a 2s timeout, then runs the empty-check and dispatches.
- TunnelForegroundService.onStartCommand defers the empty-check into a
  lifecycleScope coroutine that suspends on awaitReady() first.
- The state-store collector signals readiness on its first emission (which is
  emptySet() if nothing is enabled on disk — still a valid loaded state).

Empty integrations list → registry is trivially ready (no flow to wait on).
On timeout, drop the wake rather than spin up the tunnel against unknown state.

Reproduced via /tmp/probe-fresh and /tmp/probe-warm1: relay sends FCM, device
logs "Ignoring wake: no integrations enabled" and returns, relay's 20s timer
fires, client gets TLS EOF. The new FcmReceiverTest.`wake dispatches to
startService once registry becomes ready with enabled state` regression test
fails on the pre-fix code (verified) and passes here.

Co-authored-by: Claude Opus 4 (1M context) <noreply@anthropic.com>
2026-04-26 11:38:58 -04:00
..
src Fix #414: Await IntegrationProviderRegistry first emission before checking enabledPaths() (#416) 2026-04-26 11:38:58 -04:00
build.gradle.kts Fix #233: Wire up Firebase Crashlytics for release builds (#261) 2026-04-18 21:46:22 -04:00