Spaces:
Sleeping
Sleeping
Download server/ground_truth.py from brand0nwalls/NetOps: direct link, hf CLI and curl.
- Browser
- Download file 34.6 kB
-
https://huggingface.co/spaces/brand0nwalls/NetOps/resolve/main/server/ground_truth.py
- Command line
-
hf download hf://spaces/brand0nwalls/NetOps/server/ground_truth.py
-
curl -L -o ground_truth.py https://huggingface.co/spaces/brand0nwalls/NetOps/resolve/main/server/ground_truth.py
34.6 kB
| """Ground truth solutions for all 54 fault types. | |
| Each entry is the minimum correct diagnostic trace: investigate → diagnose → remediate → verify. | |
| Template variables ({router}, {interface}, etc.) are resolved at runtime from GroundTruth.details. | |
| For compound faults, the solution references sub-fault solutions by name. | |
| """ | |
| SOLUTIONS = { | |
| # ==================== EASY (6 faults) ==================== | |
| "link_failure": { | |
| "difficulty": "easy", | |
| "steps": [ | |
| {"action": "query_topology", "args": {}}, | |
| {"action": "diagnose", "args": { | |
| "fault_type": "link_failure", | |
| "component": "{router_a}-{router_b}", | |
| "explanation": "Link between {router_a} and {router_b} is down" | |
| }}, | |
| {"action": "restore_link", "args": {"router1": "{router_a}", "router2": "{router_b}"}}, | |
| {"action": "query_topology", "args": {}}, | |
| ], | |
| "min_steps": 4, | |
| "key_signal": "Interface DOWN on {router_a}/{intf_a} or {router_b}/{intf_b}", | |
| }, | |
| "latency_spike": { | |
| "difficulty": "easy", | |
| "steps": [ | |
| {"action": "query_device", "args": {"router": "{router}"}}, | |
| {"action": "diagnose", "args": { | |
| "fault_type": "latency_spike", | |
| "component": "{router}-{peer}", | |
| "explanation": "netem delay on {interface}" | |
| }}, | |
| {"action": "remove_tc", "args": {"router": "{router}", "interface": "{interface}"}}, | |
| {"action": "query_device", "args": {"router": "{router}"}}, | |
| ], | |
| "min_steps": 4, | |
| "key_signal": "Qdisc: netem on {interface}", | |
| }, | |
| "packet_loss": { | |
| "difficulty": "easy", | |
| "steps": [ | |
| {"action": "query_device", "args": {"router": "{router}"}}, | |
| {"action": "diagnose", "args": { | |
| "fault_type": "packet_loss", | |
| "component": "{router}-{peer}", | |
| "explanation": "netem loss on {interface}" | |
| }}, | |
| {"action": "remove_tc", "args": {"router": "{router}", "interface": "{interface}"}}, | |
| {"action": "query_device", "args": {"router": "{router}"}}, | |
| ], | |
| "min_steps": 4, | |
| "key_signal": "Qdisc: netem with TX drops on {interface}", | |
| }, | |
| "packet_corruption": { | |
| "difficulty": "easy", | |
| "steps": [ | |
| {"action": "query_device", "args": {"router": "{router}"}}, | |
| {"action": "diagnose", "args": { | |
| "fault_type": "packet_corruption", | |
| "component": "{router}-{peer}", | |
| "explanation": "netem corruption on {interface}" | |
| }}, | |
| {"action": "remove_tc", "args": {"router": "{router}", "interface": "{interface}"}}, | |
| {"action": "query_device", "args": {"router": "{router}"}}, | |
| ], | |
| "min_steps": 4, | |
| "key_signal": "Qdisc: netem with RX errors on peer", | |
| }, | |
| "packet_duplication": { | |
| "difficulty": "easy", | |
| "steps": [ | |
| {"action": "query_device", "args": {"router": "{router}"}}, | |
| {"action": "diagnose", "args": { | |
| "fault_type": "packet_duplication", | |
| "component": "{router}-{peer}", | |
| "explanation": "netem duplication on {interface}" | |
| }}, | |
| {"action": "remove_tc", "args": {"router": "{router}", "interface": "{interface}"}}, | |
| {"action": "query_device", "args": {"router": "{router}"}}, | |
| ], | |
| "min_steps": 4, | |
| "key_signal": "Qdisc: netem with inflated RX pkts on peer", | |
| }, | |
| "packet_reordering": { | |
| "difficulty": "easy", | |
| "steps": [ | |
| {"action": "query_device", "args": {"router": "{router}"}}, | |
| {"action": "diagnose", "args": { | |
| "fault_type": "packet_reordering", | |
| "component": "{router}-{peer}", | |
| "explanation": "netem reordering on {interface}" | |
| }}, | |
| {"action": "remove_tc", "args": {"router": "{router}", "interface": "{interface}"}}, | |
| {"action": "query_device", "args": {"router": "{router}"}}, | |
| ], | |
| "min_steps": 4, | |
| "key_signal": "Qdisc: netem with TCP SACK reorder events", | |
| }, | |
| # ==================== MEDIUM (12 faults) ==================== | |
| "interface_flapping": { | |
| "difficulty": "medium", | |
| "steps": [ | |
| {"action": "query_events", "args": {}}, | |
| {"action": "query_device", "args": {"router": "{router}"}}, | |
| {"action": "diagnose", "args": { | |
| "fault_type": "interface_flapping", | |
| "component": "{router}-{peer}", | |
| "explanation": "Interface {interface} flapping up/down" | |
| }}, | |
| {"action": "stop_flapping", "args": {"router": "{router}", "interface": "{interface}"}}, | |
| {"action": "query_topology", "args": {}}, | |
| ], | |
| "min_steps": 5, | |
| "key_signal": "UP/DOWN oscillation on {interface}", | |
| }, | |
| "ospf_cost_change": { | |
| "difficulty": "medium", | |
| "steps": [ | |
| {"action": "query_routing", "args": {"router": "{router}"}}, | |
| {"action": "diagnose", "args": { | |
| "fault_type": "ospf_cost_change", | |
| "component": "{router}-{peer}", | |
| "explanation": "OSPF cost on {interface} changed to {cost}" | |
| }}, | |
| {"action": "adjust_cost", "args": {"router": "{router}", "interface": "{interface}", "cost": 10}}, | |
| {"action": "query_routing", "args": {"router": "{router}"}}, | |
| ], | |
| "min_steps": 4, | |
| "key_signal": "OSPF cost {cost} on {interface} (expected ~10)", | |
| }, | |
| "ospf_timer_mismatch": { | |
| "difficulty": "medium", | |
| "steps": [ | |
| {"action": "query_routing", "args": {"router": "{router}"}}, | |
| {"action": "diagnose", "args": { | |
| "fault_type": "ospf_timer_mismatch", | |
| "component": "{router}-{peer}", | |
| "explanation": "OSPF timers mismatched on {interface}" | |
| }}, | |
| {"action": "restore_ospf_timers", "args": {"router": "{router}", "interface": "{interface}"}}, | |
| {"action": "query_routing", "args": {"router": "{router}"}}, | |
| ], | |
| "min_steps": 4, | |
| "key_signal": "OSPF neighbor stuck below Full state", | |
| }, | |
| "ospf_mtu_mismatch": { | |
| "difficulty": "medium", | |
| "steps": [ | |
| {"action": "query_device", "args": {"router": "{router}"}}, | |
| {"action": "query_routing", "args": {"router": "{router}"}}, | |
| {"action": "diagnose", "args": { | |
| "fault_type": "ospf_mtu_mismatch", | |
| "component": "{router}-{peer}", | |
| "explanation": "MTU mismatch on {interface} causing OSPF stuck" | |
| }}, | |
| {"action": "restore_mtu", "args": {"router": "{router}", "interface": "{interface}", "mtu": 1500}}, | |
| {"action": "query_routing", "args": {"router": "{router}"}}, | |
| ], | |
| "min_steps": 5, | |
| "key_signal": "MTU != 1500 on {interface}, OSPF neighbor stuck", | |
| }, | |
| "ospf_area_mismatch": { | |
| "difficulty": "medium", | |
| "steps": [ | |
| {"action": "query_routing", "args": {"router": "{router}"}}, | |
| {"action": "diagnose", "args": { | |
| "fault_type": "ospf_area_mismatch", | |
| "component": "{router}-{peer}", | |
| "explanation": "OSPF area mismatch on {interface}" | |
| }}, | |
| {"action": "restore_ospf_area", "args": {"router": "{router}", "interface": "{interface}"}}, | |
| {"action": "query_routing", "args": {"router": "{router}"}}, | |
| ], | |
| "min_steps": 4, | |
| "key_signal": "OSPF neighbor missing/not forming", | |
| }, | |
| "ospf_daemon_kill": { | |
| "difficulty": "medium", | |
| "steps": [ | |
| {"action": "query_routing", "args": {"router": "{router}"}}, | |
| {"action": "diagnose", "args": { | |
| "fault_type": "ospf_daemon_kill", | |
| "component": "{router}", | |
| "explanation": "ospfd not running on {router}" | |
| }}, | |
| {"action": "restart_daemon", "args": {"router": "{router}", "daemon": "ospfd"}}, | |
| {"action": "query_routing", "args": {"router": "{router}"}}, | |
| ], | |
| "min_steps": 4, | |
| "key_signal": "No OSPF neighbors on {router}", | |
| }, | |
| "bgp_session_kill": { | |
| "difficulty": "medium", | |
| "steps": [ | |
| {"action": "query_routing", "args": {"router": "{router}"}}, | |
| {"action": "diagnose", "args": { | |
| "fault_type": "bgp_session_kill", | |
| "component": "{router}", | |
| "explanation": "bgpd not running on {router}" | |
| }}, | |
| {"action": "restart_daemon", "args": {"router": "{router}", "daemon": "bgpd"}}, | |
| {"action": "query_routing", "args": {"router": "{router}"}}, | |
| ], | |
| "min_steps": 4, | |
| "key_signal": "BGP peers in Idle/Active state on {router}", | |
| }, | |
| "bgp_route_withdrawal": { | |
| "difficulty": "medium", | |
| "steps": [ | |
| {"action": "query_routing", "args": {"router": "{router}"}}, | |
| {"action": "diagnose", "args": { | |
| "fault_type": "bgp_route_withdrawal", | |
| "component": "{router}", | |
| "explanation": "BGP redistribute removed on {router}" | |
| }}, | |
| {"action": "remove_bgp_config", "args": { | |
| "router": "{router}", | |
| "config": "router bgp {asn}\" -c \"address-family ipv4 unicast\" -c \"redistribute connected\" -c \"redistribute ospf" | |
| }}, | |
| {"action": "query_routing", "args": {"router": "{router}"}}, | |
| ], | |
| "min_steps": 4, | |
| "key_signal": "BGP Established but pfxSnt=0", | |
| }, | |
| "selective_drop_bgp": { | |
| "difficulty": "medium", | |
| "steps": [ | |
| {"action": "query_device", "args": {"router": "{router}"}}, | |
| {"action": "diagnose", "args": { | |
| "fault_type": "selective_drop_bgp", | |
| "component": "{router}", | |
| "explanation": "iptables DROP rule on {router} blocking BGP" | |
| }}, | |
| {"action": "remove_iptables", "args": {"router": "{router}"}}, | |
| {"action": "query_device", "args": {"router": "{router}"}}, | |
| ], | |
| "min_steps": 4, | |
| "key_signal": "iptables DROP rule on port 179", | |
| }, | |
| "bandwidth_throttle": { | |
| "difficulty": "medium", | |
| "steps": [ | |
| {"action": "query_device", "args": {"router": "{router}"}}, | |
| {"action": "diagnose", "args": { | |
| "fault_type": "bandwidth_throttle", | |
| "component": "{router}-{peer}", | |
| "explanation": "tbf rate limiting on {interface}" | |
| }}, | |
| {"action": "remove_tc", "args": {"router": "{router}", "interface": "{interface}"}}, | |
| {"action": "query_device", "args": {"router": "{router}"}}, | |
| ], | |
| "min_steps": 4, | |
| "key_signal": "Qdisc: tbf with TX drops on {interface}", | |
| }, | |
| "bandwidth_saturation": { | |
| "difficulty": "medium", | |
| "steps": [ | |
| {"action": "query_device", "args": {"router": "{router}"}}, | |
| {"action": "diagnose", "args": { | |
| "fault_type": "bandwidth_saturation", | |
| "component": "{router}-{peer}", | |
| "explanation": "Background traffic saturating link" | |
| }}, | |
| {"action": "kill_traffic", "args": {"router": "{router}"}}, | |
| {"action": "query_device", "args": {"router": "{router}"}}, | |
| ], | |
| "min_steps": 4, | |
| "key_signal": "High utilization counters on {interface}", | |
| }, | |
| "unidirectional_failure": { | |
| "difficulty": "medium", | |
| "steps": [ | |
| {"action": "ping", "args": {"src": "{router}", "dst": "{peer}"}}, | |
| {"action": "query_device", "args": {"router": "{router}"}}, | |
| {"action": "diagnose", "args": { | |
| "fault_type": "unidirectional_failure", | |
| "component": "{router}-{peer}", | |
| "explanation": "iptables OUTPUT DROP on {interface}" | |
| }}, | |
| {"action": "remove_iptables", "args": {"router": "{router}"}}, | |
| {"action": "ping", "args": {"src": "{router}", "dst": "{peer}"}}, | |
| ], | |
| "min_steps": 5, | |
| "key_signal": "iptables OUTPUT DROP on {router}", | |
| }, | |
| # ==================== HARD — BGP policy (7 faults) ==================== | |
| "bgp_blackhole": { | |
| "difficulty": "hard", | |
| "steps": [ | |
| {"action": "query_routing", "args": {"router": "{router}"}}, | |
| {"action": "diagnose", "args": { | |
| "fault_type": "bgp_blackhole", | |
| "component": "{router}", | |
| "explanation": "Blackhole route for {prefix} on {router}" | |
| }}, | |
| {"action": "remove_route", "args": {"router": "{router}", "prefix": "{prefix}"}}, | |
| {"action": "remove_bgp_config", "args": { | |
| "router": "{router}", | |
| "config": "router bgp {asn}\" -c \"address-family ipv4 unicast\" -c \"no redistribute static" | |
| }}, | |
| {"action": "query_routing", "args": {"router": "{router}"}}, | |
| ], | |
| "min_steps": 5, | |
| "key_signal": "blackhole route for {prefix} in routing table", | |
| }, | |
| "bgp_hijack": { | |
| "difficulty": "hard", | |
| "steps": [ | |
| {"action": "query_routing", "args": {"router": "{router}"}}, | |
| {"action": "diagnose", "args": { | |
| "fault_type": "bgp_hijack", | |
| "component": "{router}", | |
| "explanation": "More-specific prefixes hijacking {victim_prefix}" | |
| }}, | |
| {"action": "remove_route", "args": {"router": "{router}", "prefix": "{specifics_0}"}}, | |
| {"action": "remove_bgp_config", "args": { | |
| "router": "{router}", | |
| "config": "router bgp {asn}\" -c \"address-family ipv4 unicast\" -c \"no network {specifics_0}" | |
| }}, | |
| {"action": "query_routing", "args": {"router": "{router}"}}, | |
| ], | |
| "min_steps": 5, | |
| "key_signal": "More-specific prefix {specifics_0} originated by {router}", | |
| }, | |
| "bgp_local_pref": { | |
| "difficulty": "hard", | |
| "steps": [ | |
| {"action": "query_routing", "args": {"router": "{router}"}}, | |
| {"action": "diagnose", "args": { | |
| "fault_type": "bgp_local_pref", | |
| "component": "{router}-{peer}", | |
| "explanation": "local-pref {local_pref} on peer {peer_ip}" | |
| }}, | |
| {"action": "remove_bgp_config", "args": { | |
| "router": "{router}", | |
| "config": "router bgp {asn}\" -c \"no neighbor {peer_ip} route-map LOCAL_PREF_OVERRIDE in" | |
| }}, | |
| {"action": "query_routing", "args": {"router": "{router}"}}, | |
| ], | |
| "min_steps": 4, | |
| "key_signal": "Non-default local-pref {local_pref} in BGP path details", | |
| }, | |
| "bgp_prepend": { | |
| "difficulty": "hard", | |
| "steps": [ | |
| {"action": "query_routing", "args": {"router": "{router}"}}, | |
| {"action": "diagnose", "args": { | |
| "fault_type": "bgp_prepend", | |
| "component": "{router}-{peer}", | |
| "explanation": "AS-path prepending on peer {peer_ip}" | |
| }}, | |
| {"action": "remove_bgp_config", "args": { | |
| "router": "{router}", | |
| "config": "router bgp {asn}\" -c \"no neighbor {peer_ip} route-map PREPEND_OUT out" | |
| }}, | |
| {"action": "query_routing", "args": {"router": "{router}"}}, | |
| ], | |
| "min_steps": 4, | |
| "key_signal": "Unusually long AS-path in BGP path details", | |
| }, | |
| "bgp_community": { | |
| "difficulty": "hard", | |
| "steps": [ | |
| {"action": "query_routing", "args": {"router": "{router}"}}, | |
| {"action": "diagnose", "args": { | |
| "fault_type": "bgp_community", | |
| "component": "{router}-{peer}", | |
| "explanation": "Community {community} applied on peer {peer_ip}" | |
| }}, | |
| {"action": "remove_bgp_config", "args": { | |
| "router": "{router}", | |
| "config": "router bgp {asn}\" -c \"no neighbor {peer_ip} route-map COMMUNITY_TAG out" | |
| }}, | |
| {"action": "query_routing", "args": {"router": "{router}"}}, | |
| ], | |
| "min_steps": 4, | |
| "key_signal": "Unexpected communities in BGP path details", | |
| }, | |
| "bgp_route_leak": { | |
| "difficulty": "hard", | |
| "steps": [ | |
| {"action": "query_routing", "args": {"router": "{router}"}}, | |
| {"action": "diagnose", "args": { | |
| "fault_type": "bgp_route_leak", | |
| "component": "{router}", | |
| "explanation": "Route leak of {victim_prefix} through {router}" | |
| }}, | |
| {"action": "remove_bgp_config", "args": { | |
| "router": "{router}", | |
| "config": "router bgp {asn}\" -c \"address-family ipv4 unicast\" -c \"no network {victim_prefix}" | |
| }}, | |
| {"action": "remove_route", "args": {"router": "{router}", "prefix": "{victim_prefix}"}}, | |
| {"action": "query_routing", "args": {"router": "{router}"}}, | |
| ], | |
| "min_steps": 5, | |
| "key_signal": "Unexpected prefix {victim_prefix} in {router}'s BGP", | |
| }, | |
| "bgp_prefix_filter": { | |
| "difficulty": "hard", | |
| "steps": [ | |
| {"action": "query_routing", "args": {"router": "{router}"}}, | |
| {"action": "diagnose", "args": { | |
| "fault_type": "bgp_prefix_filter", | |
| "component": "{router}-{peer}", | |
| "explanation": "Prefix filter blocking all routes from {peer_ip}" | |
| }}, | |
| {"action": "remove_bgp_config", "args": { | |
| "router": "{router}", | |
| "config": "router bgp {asn}\" -c \"no neighbor {peer_ip} prefix-list BLOCK_ALL in" | |
| }}, | |
| {"action": "query_routing", "args": {"router": "{router}"}}, | |
| ], | |
| "min_steps": 4, | |
| "key_signal": "BGP Established but pfxRcd=0 from {peer_ip}", | |
| }, | |
| "bgp_session_flood": { | |
| "difficulty": "hard", | |
| "steps": [ | |
| {"action": "query_routing", "args": {"router": "{router}"}}, | |
| {"action": "diagnose", "args": { | |
| "fault_type": "bgp_session_flood", | |
| "component": "{router}", | |
| "explanation": "Excess prefixes advertised from {router}" | |
| }}, | |
| {"action": "remove_bgp_flood", "args": {"router": "{router}", "num_prefixes": "{num_prefixes}"}}, | |
| {"action": "query_routing", "args": {"router": "{router}"}}, | |
| ], | |
| "min_steps": 4, | |
| "key_signal": "Abnormally high pfxSnt count from {router}", | |
| }, | |
| # ==================== HARD — routing logic (4 faults) ==================== | |
| "routing_loop": { | |
| "difficulty": "hard", | |
| "steps": [ | |
| {"action": "traceroute", "args": {"src": "{router_a}", "dst": "h5"}}, | |
| {"action": "query_routing", "args": {"router": "{router_a}"}}, | |
| {"action": "diagnose", "args": { | |
| "fault_type": "routing_loop", | |
| "component": "{router_a}-{router_b}", | |
| "explanation": "Static routes creating loop for {target_prefix}" | |
| }}, | |
| {"action": "remove_route", "args": {"router": "{router_a}", "prefix": "{target_prefix}"}}, | |
| {"action": "remove_route", "args": {"router": "{router_b}", "prefix": "{target_prefix}"}}, | |
| {"action": "traceroute", "args": {"src": "{router_a}", "dst": "h5"}}, | |
| ], | |
| "min_steps": 6, | |
| "key_signal": "TTL exceeded / repeating hops in traceroute", | |
| }, | |
| "redistribution_loop": { | |
| "difficulty": "hard", | |
| "steps": [ | |
| {"action": "query_routing", "args": {"router": "{router}"}}, | |
| {"action": "diagnose", "args": { | |
| "fault_type": "redistribution_loop", | |
| "component": "{router}", | |
| "explanation": "Mutual redistribution causing route feedback" | |
| }}, | |
| {"action": "remove_bgp_config", "args": { | |
| "router": "{router}", | |
| "config": "router bgp {asn}\" -c \"address-family ipv4 unicast\" -c \"no redistribute static" | |
| }}, | |
| {"action": "query_routing", "args": {"router": "{router}"}}, | |
| ], | |
| "min_steps": 4, | |
| "key_signal": "Route count growing, SPF recalculations", | |
| }, | |
| "stale_routes_after_crash": { | |
| "difficulty": "hard", | |
| "steps": [ | |
| {"action": "query_routing", "args": {"router": "{router}"}}, | |
| {"action": "query_device", "args": {"router": "{router}"}}, | |
| {"action": "diagnose", "args": { | |
| "fault_type": "stale_routes_after_crash", | |
| "component": "{router}", | |
| "explanation": "Stale OSPF cost on {interface} after crash" | |
| }}, | |
| {"action": "adjust_cost", "args": {"router": "{router}", "interface": "{interface}", "cost": 10}}, | |
| {"action": "restart_daemon", "args": {"router": "{router}", "daemon": "ospfd"}}, | |
| {"action": "query_routing", "args": {"router": "{router}"}}, | |
| ], | |
| "min_steps": 6, | |
| "key_signal": "OSPF cost anomaly on {interface}", | |
| }, | |
| "silent_blackhole_aggregate": { | |
| "difficulty": "hard", | |
| "steps": [ | |
| {"action": "query_routing", "args": {"router": "{router}"}}, | |
| {"action": "traceroute", "args": {"src": "h1", "dst": "h2"}}, | |
| {"action": "diagnose", "args": { | |
| "fault_type": "silent_blackhole_aggregate", | |
| "component": "{router}", | |
| "explanation": "Summary route {summary_prefix} blackholing traffic" | |
| }}, | |
| {"action": "remove_route", "args": {"router": "{router}", "prefix": "{summary_prefix}"}}, | |
| {"action": "remove_bgp_config", "args": { | |
| "router": "{router}", | |
| "config": "router bgp {asn}\" -c \"address-family ipv4 unicast\" -c \"no aggregate-address {summary_prefix}" | |
| }}, | |
| {"action": "query_routing", "args": {"router": "{router}"}}, | |
| ], | |
| "min_steps": 6, | |
| "key_signal": "Summary route {summary_prefix} with missing more-specific", | |
| }, | |
| # ==================== HARD — system + QoS (3 faults) ==================== | |
| "cpu_exhaustion": { | |
| "difficulty": "hard", | |
| "steps": [ | |
| {"action": "query_device", "args": {"router": "{router}"}}, | |
| {"action": "diagnose", "args": { | |
| "fault_type": "cpu_exhaustion", | |
| "component": "{router}", | |
| "explanation": "CPU exhaustion on {router}" | |
| }}, | |
| {"action": "remove_cpu_hog", "args": {"router": "{router}"}}, | |
| {"action": "query_device", "args": {"router": "{router}"}}, | |
| ], | |
| "min_steps": 4, | |
| "key_signal": "CPU load >95% on {router}", | |
| }, | |
| "control_plane_isolation": { | |
| "difficulty": "hard", | |
| "steps": [ | |
| {"action": "query_routing", "args": {"router": "{router}"}}, | |
| {"action": "query_device", "args": {"router": "{router}"}}, | |
| {"action": "diagnose", "args": { | |
| "fault_type": "control_plane_isolation", | |
| "component": "{router}", | |
| "explanation": "iptables blocking control plane protocols" | |
| }}, | |
| {"action": "remove_iptables", "args": {"router": "{router}"}}, | |
| {"action": "query_routing", "args": {"router": "{router}"}}, | |
| ], | |
| "min_steps": 5, | |
| "key_signal": "All routing sessions down + iptables DROP rules", | |
| }, | |
| "network_partition": { | |
| "difficulty": "hard", | |
| "steps": [ | |
| {"action": "query_device", "args": {"router": "{router_a}"}}, | |
| {"action": "query_device", "args": {"router": "{router_b}"}}, | |
| {"action": "diagnose", "args": { | |
| "fault_type": "network_partition", | |
| "component": "{router_a}-{router_b}", | |
| "explanation": "iptables partition between {router_a} and {router_b}" | |
| }}, | |
| {"action": "remove_iptables", "args": {"router": "{router_a}"}}, | |
| {"action": "remove_iptables", "args": {"router": "{router_b}"}}, | |
| {"action": "ping", "args": {"src": "h1", "dst": "h5"}}, | |
| ], | |
| "min_steps": 6, | |
| "key_signal": "iptables DROP rules on both {router_a} and {router_b}", | |
| }, | |
| "jitter": { | |
| "difficulty": "hard", | |
| "steps": [ | |
| {"action": "query_device", "args": {"router": "{router}"}}, | |
| {"action": "diagnose", "args": { | |
| "fault_type": "jitter", | |
| "component": "{router}-{peer}", | |
| "explanation": "netem jitter on {interface}" | |
| }}, | |
| {"action": "remove_tc", "args": {"router": "{router}", "interface": "{interface}"}}, | |
| {"action": "query_device", "args": {"router": "{router}"}}, | |
| ], | |
| "min_steps": 4, | |
| "key_signal": "Qdisc: netem on {interface}", | |
| }, | |
| # ==================== HARD — compound (5 faults) ==================== | |
| "multi_fault_easy": { | |
| "difficulty": "hard", | |
| "compound": True, | |
| "sub_solutions": ["link_failure", "latency_spike"], | |
| "min_steps": 8, | |
| }, | |
| "multi_fault_hard": { | |
| "difficulty": "hard", | |
| "compound": True, | |
| "sub_solutions": ["bgp_session_kill", "ospf_cost_change"], | |
| "min_steps": 8, | |
| }, | |
| "cascading_failure": { | |
| "difficulty": "hard", | |
| "compound": True, | |
| "sub_solutions": ["link_failure", "control_plane_isolation"], | |
| "min_steps": 8, | |
| }, | |
| # ==================== EXPERT — red herring + multi (5 faults) ==================== | |
| "red_herring_cpu": { | |
| "difficulty": "expert", | |
| "compound": True, | |
| "sub_solutions": ["bgp_route_leak", "cpu_exhaustion"], | |
| "min_steps": 8, | |
| }, | |
| "red_herring_flap": { | |
| "difficulty": "expert", | |
| "compound": True, | |
| "sub_solutions": ["packet_loss", "interface_flapping"], | |
| "min_steps": 8, | |
| }, | |
| "triple_fault": { | |
| "difficulty": "expert", | |
| "compound": True, | |
| "sub_solutions": ["latency_spike", "ospf_timer_mismatch", "bgp_route_withdrawal"], | |
| "min_steps": 12, | |
| }, | |
| "cross_layer_fault": { | |
| "difficulty": "expert", | |
| "compound": True, | |
| "sub_solutions": ["packet_corruption", "bgp_local_pref"], | |
| "min_steps": 8, | |
| }, | |
| "cascading_reveal": { | |
| "difficulty": "expert", | |
| "compound": True, | |
| "sub_solutions": ["link_failure", "bgp_blackhole"], | |
| "min_steps": 8, | |
| }, | |
| # ==================== NOVEL (12 faults) ==================== | |
| "maintenance_drain_failure": { | |
| "difficulty": "expert", | |
| "steps": [ | |
| {"action": "query_routing", "args": {"router": "{router}"}}, | |
| {"action": "diagnose", "args": { | |
| "fault_type": "maintenance_drain_failure", | |
| "component": "{router}", | |
| "explanation": "Incomplete maintenance drain: OSPF costs maxed, ospfd killed" | |
| }}, | |
| {"action": "restart_daemon", "args": {"router": "{router}", "daemon": "ospfd"}}, | |
| {"action": "restore_drain", "args": {"router": "{router}"}}, | |
| {"action": "query_routing", "args": {"router": "{router}"}}, | |
| ], | |
| "min_steps": 5, | |
| "key_signal": "All OSPF costs 65535 + ospfd dead", | |
| }, | |
| "config_typo_redundant": { | |
| "difficulty": "expert", | |
| "compound": True, | |
| "sub_solutions": ["bgp_prefix_filter", "bgp_prefix_filter"], | |
| "min_steps": 8, | |
| }, | |
| "wrong_device": { | |
| "difficulty": "hard", | |
| "compound": True, | |
| "sub_solutions": ["bgp_session_kill"], | |
| "min_steps": 5, | |
| }, | |
| "micro_flapping": { | |
| "difficulty": "hard", | |
| "steps": [ | |
| {"action": "query_device", "args": {"router": "{router}"}}, | |
| {"action": "diagnose", "args": { | |
| "fault_type": "micro_flapping", | |
| "component": "{router}-{peer}", | |
| "explanation": "Sub-second flapping causing loss on {interface}" | |
| }}, | |
| {"action": "remove_tc", "args": {"router": "{router}", "interface": "{interface}"}}, | |
| {"action": "query_device", "args": {"router": "{router}"}}, | |
| ], | |
| "min_steps": 4, | |
| "key_signal": "Elevated errors + loss on {interface}, interface UP", | |
| }, | |
| "transient_loop": { | |
| "difficulty": "expert", | |
| "compound": True, | |
| "sub_solutions": ["ospf_cost_change"], | |
| "min_steps": 5, | |
| }, | |
| "correlated_outage": { | |
| "difficulty": "hard", | |
| "steps": [ | |
| {"action": "query_device", "args": {"router": "{router}"}}, | |
| {"action": "query_routing", "args": {"router": "{router}"}}, | |
| {"action": "diagnose", "args": { | |
| "fault_type": "correlated_outage", | |
| "component": "{router}", | |
| "explanation": "All daemons killed + all interfaces down on {router}" | |
| }}, | |
| {"action": "restore_all_intfs", "args": {"router": "{router}"}}, | |
| {"action": "restart_daemon", "args": {"router": "{router}", "daemon": "ospfd"}}, | |
| {"action": "restart_daemon", "args": {"router": "{router}", "daemon": "bgpd"}}, | |
| {"action": "query_routing", "args": {"router": "{router}"}}, | |
| ], | |
| "min_steps": 7, | |
| "key_signal": "All interfaces DOWN + no routing sessions on {router}", | |
| }, | |
| "dual_link_failure": { | |
| "difficulty": "hard", | |
| "compound": True, | |
| "sub_solutions": ["link_failure", "link_failure"], | |
| "min_steps": 8, | |
| }, | |
| "exact_prefix_hijack": { | |
| "difficulty": "hard", | |
| "steps": [ | |
| {"action": "query_routing", "args": {"router": "{hijacker}"}}, | |
| {"action": "diagnose", "args": { | |
| "fault_type": "exact_prefix_hijack", | |
| "component": "{hijacker}", | |
| "explanation": "Exact-prefix hijack of {victim_prefix} by {hijacker}" | |
| }}, | |
| {"action": "remove_bgp_config", "args": { | |
| "router": "{hijacker}", | |
| "config": "router bgp {hijacker_as}\" -c \"address-family ipv4 unicast\" -c \"no network {victim_prefix}" | |
| }}, | |
| {"action": "remove_route", "args": {"router": "{hijacker}", "prefix": "{victim_prefix}"}}, | |
| {"action": "query_routing", "args": {"router": "{hijacker}"}}, | |
| ], | |
| "min_steps": 5, | |
| "key_signal": "Foreign prefix {victim_prefix} originated by {hijacker}", | |
| }, | |
| "route_leak_business": { | |
| "difficulty": "expert", | |
| "compound": True, | |
| "sub_solutions": ["bgp_route_leak", "bgp_local_pref", "bandwidth_throttle"], | |
| "min_steps": 12, | |
| }, | |
| "silent_interception": { | |
| "difficulty": "expert", | |
| "steps": [ | |
| {"action": "traceroute", "args": {"src": "h1", "dst": "h5"}}, | |
| {"action": "query_routing", "args": {"router": "{interceptor}"}}, | |
| {"action": "diagnose", "args": { | |
| "fault_type": "silent_interception", | |
| "component": "{interceptor}", | |
| "explanation": "Traffic interception: {subprefix} redirected via {interceptor}" | |
| }}, | |
| {"action": "remove_bgp_config", "args": { | |
| "router": "{interceptor}", | |
| "config": "router bgp {interceptor_as}\" -c \"address-family ipv4 unicast\" -c \"no redistribute static" | |
| }}, | |
| {"action": "remove_route", "args": {"router": "{interceptor}", "prefix": "{subprefix}"}}, | |
| {"action": "query_routing", "args": {"router": "{interceptor}"}}, | |
| ], | |
| "min_steps": 6, | |
| "key_signal": "Traceroute detour through {interceptor} + latency", | |
| }, | |
| "ghost_fault": { | |
| "difficulty": "expert", | |
| "steps": [ | |
| {"action": "query_device", "args": {"router": "{router}"}}, | |
| {"action": "query_routing", "args": {"router": "{router}"}}, | |
| {"action": "diagnose", "args": { | |
| "fault_type": "ghost_fault", | |
| "component": "{router}", | |
| "explanation": "Transient CPU spike killed BGP, now cleared" | |
| }}, | |
| {"action": "restart_daemon", "args": {"router": "{router}", "daemon": "bgpd"}}, | |
| {"action": "query_routing", "args": {"router": "{router}"}}, | |
| ], | |
| "min_steps": 5, | |
| "key_signal": "BGP down + recent OOM activity, no active CPU issue", | |
| }, | |
| "red_herring_noisy": { | |
| "difficulty": "expert", | |
| "compound": True, | |
| "sub_solutions": ["packet_corruption", "bgp_prefix_filter"], | |
| "min_steps": 8, | |
| }, | |
| } | |
| def resolve_steps(fault_type: str, details: dict) -> list[dict]: | |
| """Resolve template variables in ground truth steps for a specific fault instance.""" | |
| sol = SOLUTIONS.get(fault_type) | |
| if not sol: | |
| return [] | |
| if sol.get("compound"): | |
| return [] | |
| expanded = dict(details) | |
| if "specifics" in expanded and isinstance(expanded["specifics"], list): | |
| for i, s in enumerate(expanded["specifics"]): | |
| expanded[f"specifics_{i}"] = s | |
| resolved = [] | |
| for step in sol["steps"]: | |
| r_step = {"action": step["action"]} | |
| r_args = {} | |
| for k, v in step["args"].items(): | |
| if isinstance(v, str): | |
| try: | |
| r_args[k] = v.format(**expanded) | |
| except KeyError: | |
| r_args[k] = v | |
| else: | |
| r_args[k] = v | |
| r_step["args"] = r_args | |
| resolved.append(r_step) | |
| return resolved | |
| def resolve_compound_steps(fault_type: str, ground_truths: list) -> list[dict]: | |
| """Resolve steps for compound faults using their sub-fault ground truths.""" | |
| sol = SOLUTIONS.get(fault_type) | |
| if not sol or not sol.get("compound"): | |
| return [] | |
| all_steps = [] | |
| for gt in ground_truths: | |
| sub_steps = resolve_steps(gt.fault_type, gt.details) | |
| if sub_steps: | |
| all_steps.extend(sub_steps) | |
| return all_steps | |