mirror of
https://github.com/agessaman/meshcore-bot.git
synced 2026-09-04 06:53:47 +00:00
find_recent_rf_data has four strategies, and the fourth returns the most recent packet in the cache when the first three fail to correlate. That fallback exists for SNR/RSSI timing issues, but callers were also taking its route. So when correlation missed, a message was recorded with some other transmission's path and hop count — the reporter's four-hop message stored as a single direct hop via 79, which is the last hop of an unrelated packet. Rare, because it only fires when correlation fails. Results are now tagged with how they were matched (exact, pubkey, partial or fallback) and rf_data_is_correlated() gates the route. The tag rides on a shallow copy so the cache entry is never marked, and it fails closed: an untagged dict is treated as uncorrelated. Guarded in both handlers. The DM path was worse than the channel one — it falls back to find_recent_rf_data() with no correlation key at all, which can only ever return a fallback, and then overwrote message.path and message.routing_info from it. routing_info is what the path command reads, so a wrong route reached the user directly. The route is now left unresolved rather than fabricated, which also stops a bogus edge being written to the mesh graph from path_nodes that belong to a different packet. SNR and RSSI still use the fallback as before; mis-correlated signal figures are approximate rather than structurally wrong, and changing them is a separate call. Existing tests asserted the returned dict was the cache entry itself. Identity was incidental, so they now compare contents and additionally assert the provenance tag.