fix: close relay loop from prefixed dedup mismatch

The dispatcher deduped on inbound text but relayed a prefixed copy
("[net/sender] text"), so a re-heard relayed message hashed differently
and was re-relayed, stacking another prefix each hop — an unbounded loop,
exactly what the dedup was meant to prevent.

Add MessageBus.mark_seen() and record the on-air relayed string before
sending, so the bridge recognises and drops its own relayed copies.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
Dorian
2026-07-01 15:31:52 +01:00
co-authored by Claude Opus 4.8
parent d04e4c8370
commit dbfdf1c851
2 changed files with 22 additions and 1 deletions
+6 -1
View File
@@ -82,11 +82,16 @@ def main() -> int:
if bus.is_duplicate(message.text):
continue
print(f"[{message.network}] {message.sender}: {message.text}")
relayed = f"[{message.network}/{message.sender}] {message.text}"
# Record the exact on-air string so that if this relayed copy is
# re-heard from another network it's recognised as a duplicate and
# not re-relayed (which would stack another prefix each hop).
bus.mark_seen(relayed)
for network, adapter in adapters.items():
if network == message.network:
continue # don't echo back onto the network it came from
try:
adapter.send(f"[{message.network}/{message.sender}] {message.text}")
adapter.send(relayed)
except Exception as exc: # noqa: BLE001
print(f" ! failed to relay onto {network}: {exc}", file=sys.stderr)
except KeyboardInterrupt: