From 0e552497b255ca62c09660abce99fa072cd47e60 Mon Sep 17 00:00:00 2001 From: HumbleTurtle Date: Sat, 1 Aug 2026 04:03:01 -0300 Subject: [PATCH] Use one relay listener lane by default --- resources/scripts/napseer_mcp_server.py | 9 ++++++-- tests/test_gateway_listener_lanes.py | 30 +++++++++++++++++++++++++ 2 files changed, 37 insertions(+), 2 deletions(-) create mode 100644 tests/test_gateway_listener_lanes.py diff --git a/resources/scripts/napseer_mcp_server.py b/resources/scripts/napseer_mcp_server.py index 65716ea..9f50212 100755 --- a/resources/scripts/napseer_mcp_server.py +++ b/resources/scripts/napseer_mcp_server.py @@ -2839,9 +2839,9 @@ def gateway_listener_min_lanes(): def gateway_listener_max_lanes(): try: - configured = int(os.environ.get("NAPSEER_GATEWAY_RELAY_LISTENER_MAX_LANES", "3")) + configured = int(os.environ.get("NAPSEER_GATEWAY_RELAY_LISTENER_MAX_LANES", "1")) except ValueError: - configured = 3 + configured = 1 return max(gateway_listener_min_lanes(), min(5, configured)) @@ -4567,6 +4567,11 @@ def handle_gateway_relay_session(connect_request, listener_sock=None): "snapshot_truncated": len(snapshot_data) >= max_snapshot_bytes, "sent_at": iso_now(), }) + elif gateway_remote_should_run(): + # An explicitly configured spare lane stays silent while it is + # outside the current target. It is not a readiness failure. + closed_by_relay_streak = 0 + failure_streak = 0 else: for chunk in attach.chunks: send_gateway_payload({ diff --git a/tests/test_gateway_listener_lanes.py b/tests/test_gateway_listener_lanes.py new file mode 100644 index 0000000..86d0ece --- /dev/null +++ b/tests/test_gateway_listener_lanes.py @@ -0,0 +1,30 @@ +import importlib.util +import pathlib + + +def load_module(): + script_path = pathlib.Path(__file__).resolve().parents[1] / "resources" / "scripts" / "napseer_mcp_server.py" + spec = importlib.util.spec_from_file_location("napseer_gateway_listener_lanes_test", script_path) + module = importlib.util.module_from_spec(spec) + assert spec and spec.loader + spec.loader.exec_module(module) + return module + + +def test_gateway_relay_uses_one_listener_lane_by_default(monkeypatch): + mod = load_module() + monkeypatch.delenv("NAPSEER_GATEWAY_RELAY_LISTENER_MIN_LANES", raising=False) + monkeypatch.delenv("NAPSEER_GATEWAY_RELAY_LISTENER_MAX_LANES", raising=False) + + assert mod.gateway_listener_min_lanes() == 1 + assert mod.gateway_listener_max_lanes() == 1 + assert mod.gateway_listener_target_lanes() == 1 + assert mod.gateway_listener_lane_ids() == ["lane-1"] + + +def test_gateway_relay_extra_lanes_require_explicit_configuration(monkeypatch): + mod = load_module() + monkeypatch.setenv("NAPSEER_GATEWAY_RELAY_LISTENER_MIN_LANES", "1") + monkeypatch.setenv("NAPSEER_GATEWAY_RELAY_LISTENER_MAX_LANES", "3") + + assert mod.gateway_listener_lane_ids() == ["lane-1", "lane-2", "lane-3"]