From da322d79d92e21351abdb00a357ca00923db1da7 Mon Sep 17 00:00:00 2001 From: Strycher Date: Mon, 10 Aug 2026 03:47:41 -0400 Subject: [PATCH] chore(#550): instrument CoreScope path for joint E2E diagnosis Info logs at each step (0xC6 reply match, hash, CoreScope GET url + result, stored count, message-not-found) so the app debug log shows exactly where the badge chain breaks. Part of #524. Agent: QuietSnow (session 31eaba02) --- lib/connector/meshcore_connector.dart | 23 +++++++++++++++++++++-- lib/services/corescope_service.dart | 13 +++++++++++-- 2 files changed, 32 insertions(+), 4 deletions(-) diff --git a/lib/connector/meshcore_connector.dart b/lib/connector/meshcore_connector.dart index eb02c16..2b7bdaf 100644 --- a/lib/connector/meshcore_connector.dart +++ b/lib/connector/meshcore_connector.dart @@ -4742,6 +4742,10 @@ class MeshCoreConnector extends ChangeNotifier { } final key = '${parsed.timestamp}_${parsed.channelIdx}'; final completer = _pendingPktHashCompleters[key]; + appLogger.info( + '0xC6 reply hash=${parsed.hashHex} key=$key matched=${completer != null}', + tag: 'CoreScope', + ); if (completer != null && !completer.isCompleted) { completer.complete(parsed); } @@ -4756,8 +4760,15 @@ class MeshCoreConnector extends ChangeNotifier { String messageId, ) async { try { + appLogger.info( + 'start ts=$ts chan=$channelIndex msg=$messageId', + tag: 'CoreScope', + ); final pkt = await _queryPacketHash(ts, channelIndex); - if (pkt == null) return; + if (pkt == null) { + appLogger.info('no hash (0xC6 null/timeout)', tag: 'CoreScope'); + return; + } _updateChannelMessageById( channelIndex, messageId, @@ -4770,6 +4781,7 @@ class MeshCoreConnector extends ChangeNotifier { messageId, (m) => m.copyWith(coreScopeObserverCount: count), ); + appLogger.info('stored observer count=$count', tag: 'CoreScope'); notifyListeners(); } catch (e) { appLogger.warn( @@ -4787,7 +4799,14 @@ class MeshCoreConnector extends ChangeNotifier { final messages = _channelMessages[channelIndex]; if (messages == null) return; final i = messages.indexWhere((m) => m.messageId == messageId); - if (i >= 0) messages[i] = transform(messages[i]); + if (i >= 0) { + messages[i] = transform(messages[i]); + } else { + appLogger.warn( + 'message $messageId not found on chan $channelIndex; count dropped', + tag: 'CoreScope', + ); + } } /// Called when a BLOCK_LIST dump ends. A truncated dump (early-END) is diff --git a/lib/services/corescope_service.dart b/lib/services/corescope_service.dart index 6ea6966..32e876d 100644 --- a/lib/services/corescope_service.dart +++ b/lib/services/corescope_service.dart @@ -39,6 +39,7 @@ class CoreScopeService { 'limit': '1', }, ); + appLogger.info('GET $uri', tag: 'CoreScope'); try { final resp = await _client.get(uri).timeout(timeout); if (resp.statusCode != 200) { @@ -51,11 +52,19 @@ class CoreScopeService { final body = jsonDecode(resp.body); if (body is! Map) return null; final packets = body['packets']; - if (packets is! List || packets.isEmpty) return null; + if (packets is! List || packets.isEmpty) { + appLogger.info('no record yet for $packetHash', tag: 'CoreScope'); + return null; + } final first = packets.first; if (first is! Map) return null; final count = first['observer_count']; - return count is num ? count.toInt() : null; + final result = count is num ? count.toInt() : null; + appLogger.info( + 'observer_count=$result for $packetHash', + tag: 'CoreScope', + ); + return result; } catch (e) { appLogger.warn('Query failed for $packetHash: $e', tag: 'CoreScope'); return null;