refactor(router): centralize bridge fan-out and type drop reasons

Replace the eight hand-rolled companion-bridge delivery loops in the
packet router with a single _fan_out_to_bridges helper that reads
HandlerResult.authenticated directly, so a broken handler contract
surfaces instead of being hidden by getattr hedges.

Introduce a DropReason str-Enum in the engine for the seventeen fixed
drop reasons (with __str__ returning the value, since str() of a
str-Enum changed on Python 3.11+) and derive the router's
expected-drop check from it, retiring the string-prefix tuple.
Detailed variants keep their suffixes embedded in the reason string.

Split the companion-delivery dedupe cache into a pure check and an
explicit mark so PATH and protocol responses record delivery only
after the fan-out runs — a copy where every bridge raised is retried
on the next copy instead of being suppressed for the full TTL.
This commit is contained in:
agessaman
2026-07-16 08:48:34 -07:00
parent a620433312
commit 5a83fce84c
3 changed files with 171 additions and 136 deletions
+3 -1
View File
@@ -15,6 +15,8 @@ from typing import Dict, Optional, Tuple
from openhop_core.node.handlers.advert import AdvertHandler
from repeater.engine import DropReason
logger = logging.getLogger("AdvertHelper")
@@ -551,7 +553,7 @@ class AdvertHelper:
if not advert_data or not advert_data.get("valid"):
logger.warning("Invalid advert packet received, dropping.")
packet.mark_do_not_retransmit()
packet.drop_reason = "Invalid advert packet"
packet.drop_reason = DropReason.INVALID_ADVERT
return
# Extract data from parsed advert