Harden route-stability: fix is_self detection bug, add coverage, tighten error handling

Fix: self_label was computed via _name(None, resolve) but edges already
resolve None→device_label, so the resolver could never rename the self
node. Use _name(device_label, resolve) instead.

Quality: replace assert on output_dir with graceful skip, validate
--samples requires --target, add _slug fallback for empty input, fix
Callable import (collections.abc).

Tests: 6 → 25 — adds three-way entropy, single-hop topology, median SNR,
link sorting, degree counting, resolver edge cases (returns None, renames
self), empty/mixed traces, multi-target graph, empty-graph render, output
dir creation, filename slug, SNR colour thresholds, Rich panel branches,
and the questionary validator.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Jean-Pierre MartineauandClaude Opus 4.6 committed 2026-06-21 18:11:41 -04:00
1 parent 736fb4e762
commit 8d2320ba03
4 files changed
+232 -9

No files matched your search

+6 -3
View File
@@ -79,7 +79,11 @@ class RouteMapTool(Tool):
samples = int(params.get("samples", 0))
resolve = None
if samples > 0 and target:
if samples > 0:
if not target:
return ToolResult(
message="[err]✗[/err] --samples requires a --target to trace.",
)
device = await ctx.device()
contacts = await device.get_contacts()
resolve = trace_runner.make_node_resolver(contacts)
@@ -110,8 +114,7 @@ class RouteMapTool(Tool):
ctx.console.print(_graph_panel(graph))
artifacts: list[str] = []
if graph.total_routes and params.get("viz", True):
assert ctx.settings.output_dir is not None
if graph.total_routes and params.get("viz", True) and ctx.settings.output_dir:
out = render_route_graph(graph, ctx.settings.output_dir)
artifacts.append(str(out))