Fix timeout observations, drop the last-rx feature and evict weak paths

- Record delivery observations with the path of the attempt the ACK
  belongs to, and skip ambiguous ACKs, so a late direct ACK is not
  learned as a flood delivery.
- Remove secondsSinceLastRx from the timeout model: it measured time
  since any companion frame, which was near zero at train and predict.
- When a contact's path history is full, evict the lowest-scoring path
  instead of silently dropping new discoveries.
This commit is contained in:
zjs81 committed 2026-10-25 11:36:13 -07:00
1 parent 6bc6143c4e
commit 82dcab1d92
8 files changed
+70 -31

No files matched your search

-14
View File
@@ -334,12 +334,6 @@ class MeshCoreConnector extends ChangeNotifier {
ReceivedImageStore? _receivedImageStore;
void Function(ImageChunkOutcome outcome)? _onImageChunk;
void Function(int senderPrefix)? _onImageSenderPrefix;
// Intentionally global (not per-contact): tracks overall network activity.
// Frequent RX from any source indicates a busy network with more collisions.
DateTime _lastRxTime = DateTime.now();
// Snapshot of _lastRxTime taken before the ACK frame updates it, so that
// onDeliveryObserved records the pre-ACK elapsed time (matching prediction).
DateTime _lastRxBeforeFrame = DateTime.fromMillisecondsSinceEpoch(0);
DateTime _lastRadioRxTime = DateTime.fromMillisecondsSinceEpoch(0);
DateTime _lastContactMsgRxTime = DateTime.fromMillisecondsSinceEpoch(0);
DateTime _lastChannelMsgRxTime = DateTime.fromMillisecondsSinceEpoch(0);
@@ -1810,15 +1804,11 @@ class MeshCoreConnector extends ChangeNotifier {
recentSelections: recentSelections,
),
onDeliveryObserved: (contactKey, pathLength, messageBytes, tripTimeMs) {
final secSinceRx = DateTime.now()
.difference(_lastRxBeforeFrame)
.inSeconds;
_timeoutPredictionService?.recordObservation(
contactKey: contactKey,
pathLength: pathLength,
messageBytes: messageBytes,
tripTimeMs: tripTimeMs,
secondsSinceLastRx: secSinceRx,
);
},
),
@@ -6073,8 +6063,6 @@ class MeshCoreConnector extends ChangeNotifier {
void _handleFrame(List<int> data) {
if (data.isEmpty) return;
_lastRxBeforeFrame = _lastRxTime;
_lastRxTime = DateTime.now();
final frame = Uint8List.fromList(data);
_receivedFramesController.add(frame);
@@ -6834,12 +6822,10 @@ class MeshCoreConnector extends ChangeNotifier {
final physicsMax = _physicsMaxTimeout(pathLength, airtime);
// Try ML-based prediction
final secSinceRx = DateTime.now().difference(_lastRxTime).inSeconds;
final mlTimeout = _timeoutPredictionService?.predictTimeout(
contactKey: contactKey,
pathLength: pathLength,
messageBytes: messageBytes,
secondsSinceLastRx: secSinceRx,
);
if (mlTimeout != null) {
// Use device est_timeout as a baseline floor when available —