fix: route the network components so they actually attach

The diagnostic icons answered it. The wrench was present, so AddBase and
the Overrides had applied correctly all along -- but the thermal-missile
and resource icons were both showing, meaning both NetworkValues read
zero. With both signals absent, VentAllowed collapses to true and
AutoPowerToggle degenerates to plain PowerToggle: on means permanently
on, exactly as reported.

A network component is only attached to the network if a route reaches
it. The part's NetworkPort anchors on one component and a NetworkRouter
bridges that anchor to the rest -- which is how vanilla connects the
radiator's own NetworkedThermalDissipationLoadValue, and how the thermal
amplification pump reaches the resonance beam turret.

Add routes from each part's anchor: NetworkedHeatBuffer on the radiator
via its existing Router, and a new NetworkRouter on the thermal battery,
the missile launcher and base_part_overclock, none of which ships one.

Unrouted network components are not an error -- they simply never
connect and read as absent forever, which is why three versions loaded
cleanly and did nothing. The new test fails on any network component the
mod adds that no route names.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011oLWY1G6S8U35bi2FxVWni
This commit is contained in:
2026-08-29 00:11:39 +02:00
co-authored by Claude Opus 5
parent a4f25f1710
commit 014e45aa2b
5 changed files with 178 additions and 1 deletions
+100
View File
@@ -432,6 +432,106 @@ def test_component_fields_exist_in_schema():
)
# ---------------------------------------------------------------------------
# 6c. Every network component the mod adds must be reachable by a route.
#
# A NetworkValue or NetworkValueReceiver is only attached to the network if
# a route leads to it: the part's NetworkPort anchors on one component, and
# a NetworkRouter bridges that anchor to the rest. An unrouted network
# component is not an error -- it simply never connects and always reads as
# absent. That is exactly how v1.1.0 and v1.2.0 failed: they loaded clean,
# the components existed on the parts, and every signal read zero.
# ---------------------------------------------------------------------------
NETWORK_COMPONENT_TYPES = {"NetworkValue", "NetworkValueReceiver"}
def collect_route_names(node, found=None):
"""Every component name appearing in any Routes list under this node."""
if found is None:
found = set()
if node.kind not in ("group", "list"):
return found
for name in node.order:
child = node.children[name]
if name == "Routes" and child.kind == "list":
for key in child.order:
route = child.children[key]
if route.kind == "list":
for slot in route.order:
value = route.children[slot]
if value.kind == "scalar":
found.add(value.value.strip())
collect_route_names(child, found)
return found
def addbase_targets():
"""Yield (mod_file_path, target_part_rules_path) for each AddBase action."""
mod = rules_parser.parse_file(os.path.join(MOD_ROOT, "mod.rules"))
for action in iter_actions(mod):
kind = action.get("Action")
if not kind or kind.value != "AddBase":
continue
target = action.get("AddBaseTo")
base = action.get("BaseToAdd")
if target is None or base is None:
continue
match = re.match(r"^&?<([^>]+)>$", base.value.strip())
if match is None:
continue
part_path, _inner = split_target(target.value)
yield os.path.join(MOD_ROOT, match.group(1)), part_path
def test_network_components_are_routed():
mod = rules_parser.parse_file(os.path.join(MOD_ROOT, "mod.rules"))
# Routes the mod contributes, keyed by the part they land on.
routed = {}
for mod_file, part_path in addbase_targets():
added = rules_parser.parse_file(mod_file)
routed.setdefault(part_path, set()).update(collect_route_names(added))
for action in iter_actions(mod):
kind = action.get("Action")
add_to = action.get("AddTo")
if not kind or kind.value != "AddMany" or add_to is None:
continue
if "Routes" not in add_to.value:
continue
part_path, _inner = split_target(add_to.value)
entries = action.get("ManyToAdd")
if entries is None:
continue
for key in entries.order:
route = entries.children[key]
if route.kind != "list":
continue
for slot in route.order:
value = route.children[slot]
if value.kind == "scalar":
routed.setdefault(part_path, set()).add(value.value.strip())
for mod_file, part_path in addbase_targets():
added = rules_parser.parse_file(mod_file)
name = os.path.basename(mod_file)
reachable = routed.get(part_path, set())
for component_name in added.order:
component = added.children[component_name]
if component.kind != "group":
continue
type_node = component.get("Type")
if type_node is None or type_node.value not in NETWORK_COMPONENT_TYPES:
continue
check(
component_name in reachable,
f"{name}: {component_name} ({type_node.value}) is not named in any route, "
f"so it never attaches to the network and always reads as absent",
)
# ---------------------------------------------------------------------------
# 7. Added indicators must bind to a real toggle and a real atlas sprite.
# ---------------------------------------------------------------------------