From c0379c356bb49219647b7cee4bcf0f6fbe21cafb Mon Sep 17 00:00:00 2001 From: diffwireauto <330573775+diffwireauto@users.noreply.github.com> Date: Sun, 4 Oct 2026 05:06:30 -0400 Subject: [PATCH] fix(#793): apply pre-PR review, log name length not the name, and re-log on SELF_INFO Gemini gate, three findings, all verified against the source before acting. ACCEPTED: the first log line reported a budget computed from a null name. `_selfName` is only assigned while parsing SELF_INFO (line ~6127), which arrives after CMD_APP_START, long after the MTU listener attaches. Now logged on either input changing, with the reason named: `(mtu)` and `(self-info)`. Worth recording because the review had the direction backwards: it said the early line would overstate the budget. It understates it. `_senderNameBytes(null)` returns the 31-byte maximum, so a null name produces the largest possible prefix and the smallest possible channel budget. The line was pessimistic, not optimistic. Same defect, opposite sign, and a maintainer reading it would have been misled the other way. ACCEPTED: the budget also drifts if the name changes mid-session. The SELF_INFO hook covers the case that matters, since that is where the name arrives or changes. ACCEPTED, and it matters more than the review framed it: the name is no longer logged, only its length. These files get attached to public issues, and a radio name is usually an amateur callsign, which resolves publicly to a real name and address. The length is the entire input to the budget, so nothing diagnostic is lost. Logs `nameLen=N`, or -1 when unknown, which also makes the null-name state visible rather than silently rendering as empty. analyze clean, format clean, 1088 tests pass. Co-Authored-By: Claude Opus 5 --- lib/connector/meshcore_connector.dart | 33 ++++++++++++++++++++++----- 1 file changed, 27 insertions(+), 6 deletions(-) diff --git a/lib/connector/meshcore_connector.dart b/lib/connector/meshcore_connector.dart index bd1bc0f6..3cdfb2c6 100644 --- a/lib/connector/meshcore_connector.dart +++ b/lib/connector/meshcore_connector.dart @@ -605,16 +605,31 @@ class MeshCoreConnector extends ChangeNotifier { /// Derived from the same functions the composers call, never reimplemented, /// so the log cannot drift away from the behaviour it is describing. /// - /// Called on connect and on MTU change only. Not per keystroke or per send: - /// diagnostics must not become the outage (SAFELANE 11 rule 10). - void _logComposerBudget() { + /// Logs the name's LENGTH, never the name. The length is the whole of what + /// the budget depends on (the channel budget subtracts a `": "` + /// prefix), and these logs get attached to public issues. A radio name is + /// usually an amateur callsign, which is publicly resolvable to a real name + /// and address, so it has no business in a file we ask users to upload + /// (CLAUDE-BASE, redaction discipline). + /// + /// Called whenever an INPUT to the budget changes: the MTU, and the self + /// name. Both matter and they arrive at different times, the name only in + /// SELF_INFO well after the first MTU event, so logging on the MTU alone + /// would report a budget computed from a null name. That is not a harmless + /// gap: `_senderNameBytes(null)` returns the 31-byte maximum, so the early + /// line would understate the real channel budget. + /// + /// Not per keystroke or per send: diagnostics must not become the outage + /// (SAFELANE 11 rule 10). + void _logComposerBudget(String reason) { final frame = effectiveMaxFrameSize; final name = selfName; final dm = maxContactMessageBytes(maxFrameBytes: frame); final channel = maxChannelMessageBytes(name, maxFrameBytes: frame); _appDebugLogService?.info( - 'composer budget: frame=$frame dm=$dm channel=$channel ' - 'transport=${_activeTransport.name} name="${name ?? ''}"' + 'composer budget ($reason): frame=$frame dm=$dm channel=$channel ' + 'transport=${_activeTransport.name} ' + 'nameLen=${name?.length ?? -1}' '${isComposerBudgetUsable(channel) ? '' : ' <-- CHANNEL COMPOSER UNUSABLE'}', tag: 'BLE Connect', ); @@ -2745,7 +2760,7 @@ class MeshCoreConnector extends ChangeNotifier { await _mtuSubscription?.cancel(); _mtuSubscription = device.mtu.listen((mtu) { _appDebugLogService?.info('MTU now: $mtu', tag: 'BLE Connect'); - _logComposerBudget(); + _logComposerBudget('mtu'); notifyListeners(); }); @@ -6391,6 +6406,12 @@ class MeshCoreConnector extends ChangeNotifier { tag: 'Connector', ); } + // The name is the other input to the channel composer's byte budget, and + // it only lands here, well after the first MTU event. Re-log so the entry + // reflects the real name length rather than the null-name worst case + // (#793). + _logComposerBudget('self-info'); + final selfName = _selfName?.trim(); if (_activeTransport == MeshCoreTransportType.usb && selfName != null &&