From c40fbba9d686965394563be35b2df1e4f839cb0a Mon Sep 17 00:00:00 2001 From: diffwireauto <330573775+diffwireauto@users.noreply.github.com> Date: Sun, 4 Oct 2026 05:01:49 -0400 Subject: [PATCH] feat(#793): log the composer byte budget, so a log can evidence #592 anywhere The app logged the negotiated MTU and raw frame lengths, but never the number #592 was actually about: the composer's byte limit. The consequence showed up while working #687. We have Windows BLE logs back to August proving MTU 247, and hundreds of Android BLE sessions, and not one of them can evidence that the composer was usable, because the log records what was sent and never the limit the field applied. Logs `composer budget: frame=172 dm=156 channel=148 transport=bluetooth name="..."` beside the existing `MTU now:` line, and appends an explicit marker when the channel budget is below usable, so a collapsed composer is greppable rather than inferred. Derived from the same functions the composers call (resolveFrameBudget, maxContactMessageBytes, maxChannelMessageBytes, isComposerBudgetUsable) rather than reimplemented, so the log cannot drift from the behaviour it describes. The sender name is included because the channel budget subtracts its prefix, and an 8+ character name is what took that budget to 0 at the floor. Connect and MTU-change only. Not per keystroke or per send: diagnostics must not become the outage (SAFELANE 11 rule 10). Why it matters beyond tidiness: it converts #687 from a hardware-scheduling problem into a log-reading one. Linux (#717) and Web (#718) have no verification path today because nobody here runs either with a radio. With this, verification is "send me your debug log", which the #592 reporters have already shown willing to do. No new tests: the three numbers come from functions already pinned by frame_budget_platform_test.dart, and the added code is a log call on a path that needs a live BLE device. analyze clean, format clean, 1088 tests pass. Co-Authored-By: Claude Opus 5 --- lib/connector/meshcore_connector.dart | 28 +++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/lib/connector/meshcore_connector.dart b/lib/connector/meshcore_connector.dart index c48dedd6..bd1bc0f6 100644 --- a/lib/connector/meshcore_connector.dart +++ b/lib/connector/meshcore_connector.dart @@ -593,6 +593,33 @@ class MeshCoreConnector extends ChangeNotifier { mtuNow: _device?.mtuNow ?? 0, ); + /// Writes the composer's actual byte budget to the app log. + /// + /// #592 was about this number, and until #793 it was the one thing the log + /// never recorded. We had Windows BLE logs back to August proving MTU 247, + /// and hundreds of Android sessions, and not one of them could evidence + /// whether the composer was usable: the log showed what was sent, never the + /// limit the field applied. A log reading `channel=0` beside a user saying + /// the keyboard is dead is a diagnosis; without it that is a guess. + /// + /// 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() { + 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 ?? ''}"' + '${isComposerBudgetUsable(channel) ? '' : ' <-- CHANNEL COMPOSER UNUSABLE'}', + tag: 'BLE Connect', + ); + } + /// The frame-budget decision, as a pure function of its three inputs. /// /// Extracted from [effectiveMaxFrameSize] so every branch is reachable from a @@ -2718,6 +2745,7 @@ class MeshCoreConnector extends ChangeNotifier { await _mtuSubscription?.cancel(); _mtuSubscription = device.mtu.listen((mtu) { _appDebugLogService?.info('MTU now: $mtu', tag: 'BLE Connect'); + _logComposerBudget(); notifyListeners(); });