Revert "feat(mazenet): host resolution + cross-host bridge guard"

This reverts commit 448fcd1227.
This commit is contained in:
2026-04-25 03:26:19 -04:00
parent 448fcd1227
commit e169b891d7
4 changed files with 1 additions and 195 deletions

View File

@@ -5,9 +5,7 @@ from decnet.topology.config import TopologyConfig
from decnet.topology.generator import generate
from decnet.topology.persistence import (
hydrate,
partition_lans_by_host,
persist,
resolve_lan_host,
transition_status,
)
from decnet.topology.status import TopologyStatus, TopologyStatusError
@@ -91,53 +89,3 @@ async def test_config_snapshot_preserves_seed(repo):
topo = await repo.get_topology(tid)
assert topo["config_snapshot"]["seed"] == 12345
assert topo["config_snapshot"]["depth"] == 2
# --- per-LAN host resolution ---
def test_resolve_lan_host_prefers_lan_pin():
topology = {"target_host_uuid": "topo-host"}
lan = {"host_uuid": "lan-host"}
assert resolve_lan_host(lan, topology) == "lan-host"
def test_resolve_lan_host_falls_back_to_topology_target():
topology = {"target_host_uuid": "topo-host"}
lan = {"host_uuid": None}
assert resolve_lan_host(lan, topology) == "topo-host"
def test_resolve_lan_host_returns_none_for_master():
assert resolve_lan_host({"host_uuid": None}, {"target_host_uuid": None}) is None
assert resolve_lan_host({}, {}) is None
def test_partition_lans_by_host_groups_correctly():
hydrated = {
"topology": {"target_host_uuid": None},
"lans": [
{"id": "1", "host_uuid": None},
{"id": "2", "host_uuid": "A"},
{"id": "3", "host_uuid": "A"},
{"id": "4", "host_uuid": "B"},
],
}
out = partition_lans_by_host(hydrated)
assert set(out.keys()) == {None, "A", "B"}
assert [lan["id"] for lan in out["A"]] == ["2", "3"]
assert [lan["id"] for lan in out["B"]] == ["4"]
assert [lan["id"] for lan in out[None]] == ["1"]
def test_partition_lans_uses_topology_default_when_lan_unset():
hydrated = {
"topology": {"target_host_uuid": "default-host"},
"lans": [
{"id": "1", "host_uuid": None},
{"id": "2", "host_uuid": "explicit"},
],
}
out = partition_lans_by_host(hydrated)
assert set(out.keys()) == {"default-host", "explicit"}
assert [lan["id"] for lan in out["default-host"]] == ["1"]

View File

@@ -145,55 +145,6 @@ async def test_service_config_undeclared(repo):
assert "SERVICE_CFG_UNDECLARED" in [i.code for i in validate(h)]
# --------------------------------------------------------------------- per-LAN host
@pytest.mark.anyio
async def test_bridge_decky_same_host_passes_when_colocated(repo):
"""A bridge decky whose LANs share a host must not flag."""
plan = generate(
_cfg(
depth=2,
branching_factor=1,
deckies_per_lan_min=1,
deckies_per_lan_max=1,
cross_edge_probability=0.0,
)
)
h, _ = await _hydrate_plan(repo, plan)
for lan in h["lans"]:
lan["host_uuid"] = "host-A"
assert "BRIDGE_HOST_SPLIT" not in [i.code for i in validate(h)]
@pytest.mark.anyio
async def test_bridge_decky_split_across_hosts_fails(repo):
plan = generate(
_cfg(
depth=2,
branching_factor=1,
deckies_per_lan_min=1,
deckies_per_lan_max=1,
cross_edge_probability=0.0,
)
)
h, _ = await _hydrate_plan(repo, plan)
# Find a bridge decky (one connected to ≥2 LANs).
decky_lans: dict[str, list[str]] = {}
for e in h["edges"]:
decky_lans.setdefault(e["decky_uuid"], []).append(e["lan_id"])
bridge_lan_ids = next(
(lids for lids in decky_lans.values() if len(lids) >= 2), None
)
assert bridge_lan_ids, "test setup expected ≥1 bridge decky"
# Pin its two LANs to different hosts.
lans_by_id = {lan["id"]: lan for lan in h["lans"]}
lans_by_id[bridge_lan_ids[0]]["host_uuid"] = "host-A"
lans_by_id[bridge_lan_ids[1]]["host_uuid"] = "host-B"
codes = [i.code for i in validate(h) if i.severity == "error"]
assert "BRIDGE_HOST_SPLIT" in codes
# --------------------------------------------------------------------- deployer hook