fix(takserver): drop CoT the mesh delivers more than once#5667
Merged
Conversation
jamesarich
approved these changes
May 30, 2026
The mesh can hand the bridge the same logical CoT event multiple times (a packet relayed over several LoRa paths, or a sender that retransmits), which made ATAK surface doubled chat / TAK-Talk messages. Add a small TTL cache (CotDeliveryDedup) keyed by the exact, already-normalized CoT XML and gate handleV2Packet on it: an identical event within the window is dropped, while genuine updates (new PLI position, moved marker, …) differ in content and pass through. Confined to the single meshPacketFlow collector coroutine, so no locking. Complements the *:-1:stcp endpoint fix (#5661) — that lets the TAK client dedupe cross-transport copies by uid; this stops the bridge from emitting its own duplicates. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
- spotlessApply reformats KDoc line wrapping in CotDeliveryDedup.kt - Rename test to remove comma character (illegal on Kotlin/Native targets) Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…tive identifiers)
Backtick-quoted function names may contain a comma on JVM but not on Kotlin/Native, so :core:takserver:compileTestKotlinIosSimulatorArm64 failed ("Name contains illegal characters: ','") while jvmTest passed. Rename the one offending test.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
b4ba9dc to
92af91a
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
When the same two nodes are reachable by more than one path (e.g. both on Wi-Fi and the mesh, or a LoRa message relayed over several hops), ATAK surfaces duplicate chat / TAK-Talk messages. CoT's identity model is dedup-by-`uid`, but two copies only collapse at the client if they match.
This PR addresses the duplicates the bridge itself can emit: the mesh can hand `handleV2Packet` the same logical CoT event more than once (multi-path relay, or a sender retransmit).
Fix
Scope (what this does not do)
It dedupes only what the bridge injects — it can't see copies the TAK client receives over another transport (e.g. Wi-Fi network SA). For those, the client dedupes by `uid`, which is why #5661 hands ATAK the `*:-1:stcp` contact and the SDK preserves the uid/timestamps across the round-trip so the copies collapse client-side. (`ensureMinimumStaleForMesh` already excludes ephemeral `m-t-t`/`b-t-f` via `STATIC_COT_PREFIXES`, so chat/TAK-Talk timestamps are preserved — no change needed there.)
Tests
5 unit tests (`CotDeliveryDedupTest`) with an injected clock: exact-repeat drop, distinct events pass, same-uid-changed-content passes, re-admit after the TTL elapses, and `maxEntries` eviction.
🤖 Generated with Claude Code