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 <noreply@anthropic.com>
release/1.6.0
diffwireauto 1 month ago committed by Benjamin Wiechel
parent c40fbba9d6
commit c0379c356b

@ -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 `"<name>: "`
/// 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 &&

Loading…
Cancel
Save

Powered by TurnKey Linux.