From 58f7293b331fb55f3fd434ad66108a5a3ddeed4a Mon Sep 17 00:00:00 2001 From: agessaman Date: Fri, 11 Sep 2026 13:57:12 -0700 Subject: [PATCH] fix(companion): skip the scope guard when Core predates the feature Follow-up to review. The dependency pin is `openhop_core@dev`, so CI installs a Core without the per-message flood scope override until that change lands there. The guard imported symbols from it directly, which meant the module could not import at all and this branch could not be green on its own before Core merged. The constants are now reached through the module and a `skipif` covers the whole file, so the branch stands alone and the guard resumes the moment Core lands. The skip reason names the cause, so a permanent silent skip would be visible in the report rather than reading as a pass. Also corrects the `_flood_scope_applied` comment. It claimed losing the mark would let the dispatcher re-scope the packet to the repeater's own region. It would not: `scope_packet` has already set TRANSPORT_FLOOD and the dispatcher re-scopes only ROUTE_TYPE_FLOOD. The assertion stays, as the contract Core states, but it is no longer described as load-bearing. Still outstanding, deliberately: this stops at the bridge's injector and does not drive PacketRouter.inject_packet, the engine, and the final dispatcher with a conflicting repeater region configured. That is the test worth adding next if this guard is ever to carry real weight. --- tests/test_companion_scoped_channel_send.py | 42 ++++++++++++--------- 1 file changed, 25 insertions(+), 17 deletions(-) diff --git a/tests/test_companion_scoped_channel_send.py b/tests/test_companion_scoped_channel_send.py index 9041713..3fe3c64 100644 --- a/tests/test_companion_scoped_channel_send.py +++ b/tests/test_companion_scoped_channel_send.py @@ -23,21 +23,23 @@ from unittest.mock import AsyncMock, Mock import pytest from openhop_core import LocalIdentity -from openhop_core.companion.constants import ( - CMD_SEND_CHANNEL_TXT_MSG, - OPENHOP_CHANNEL_SCOPE_PROBE, - OPENHOP_CHANNEL_TXT_SCOPED, - OPENHOP_EXTENSION_MARKER, - OPENHOP_SCOPE_PROBE_RESERVED_LEN, - RESP_CODE_OK, - RESP_CODE_OPENHOP_EXTENSION, -) +from openhop_core.companion import constants as core_constants from openhop_core.companion.models import Channel from openhop_core.protocol.constants import ROUTE_TYPE_TRANSPORT_FLOOD from openhop_core.protocol.transport_keys import calc_transport_code, get_auto_key_for from repeater.companion.bridge import RepeaterCompanionBridge from repeater.companion.frame_server import CompanionFrameServer +# The dependency pin is `openhop_core@dev`, so until the Core change is on that +# branch CI installs a Core without these symbols and this module cannot even +# import. Skip rather than fail: the branch is then independently green, and +# the moment Core lands the guard starts running again. The skip reason names +# the cause so a silent permanent skip is visible in the report. +pytestmark = pytest.mark.skipif( + not hasattr(core_constants, "OPENHOP_CHANNEL_TXT_SCOPED"), + reason="installed openhop_core predates the per-message flood scope override", +) + SCOPE_KEY = get_auto_key_for("#USA") @@ -58,17 +60,21 @@ async def test_frame_server_subclass_inherits_core_extension_handlers(): bridge.send_channel_message = AsyncMock(return_value=True) server, frames = _frame_server(bridge) - probe = bytes([CMD_SEND_CHANNEL_TXT_MSG, OPENHOP_CHANNEL_SCOPE_PROBE]) - probe += bytes(OPENHOP_SCOPE_PROBE_RESERVED_LEN) + probe = bytes( + [core_constants.CMD_SEND_CHANNEL_TXT_MSG, core_constants.OPENHOP_CHANNEL_SCOPE_PROBE] + ) + probe += bytes(core_constants.OPENHOP_SCOPE_PROBE_RESERVED_LEN) await server._handle_cmd(probe) - send = bytes([CMD_SEND_CHANNEL_TXT_MSG, OPENHOP_CHANNEL_TXT_SCOPED, 1]) + send = bytes( + [core_constants.CMD_SEND_CHANNEL_TXT_MSG, core_constants.OPENHOP_CHANNEL_TXT_SCOPED, 1] + ) send += struct.pack("