Files
ruvnet--ruview/docs/adr/ADR-049-cross-platform-wifi-interface-detection.md
wehub-resource-sync 9740bc64c9
Firmware QEMU Tests (ADR-061) / QEMU Test (edge-tier1) (push) Has been skipped
Firmware QEMU Tests (ADR-061) / QEMU Test (full-adr060) (push) Has been skipped
Firmware QEMU Tests (ADR-061) / QEMU Test (tdm-3node) (push) Has been skipped
Firmware QEMU Tests (ADR-061) / Swarm Test (ADR-062) (push) Has been skipped
npm packages / tools/ruview-mcp (node 22) (push) Failing after 1s
nvsim-server → ghcr.io / build-and-publish (push) Failing after 1s
ruview-swarm CI guard / tests (full+train) (push) Failing after 2s
Bench Regression Guard / bench compile-verify (--no-run) (push) Failing after 0s
Bench Regression Guard / bench fast-run (informational, non-gating) (push) Has been skipped
Firmware CI / Verify version.txt matches release tag (push) Has been skipped
Dashboard a11y + cross-browser / a11y (push) Failing after 0s
nvsim Dashboard → GitHub Pages / build-and-deploy (push) Failing after 2s
Firmware CI / Build firmware (esp32s3 / 4mb) (push) Failing after 15s
Firmware QEMU Tests (ADR-061) / Build Espressif QEMU (push) Failing after 1s
Firmware QEMU Tests (ADR-061) / Fuzz Testing (ADR-061 Layer 6) (push) Failing after 1s
Continuous Deployment / Pre-deployment Checks (push) Has been skipped
Firmware CI / Build firmware (esp32c6 / c6-4mb) (push) Failing after 15s
Firmware CI / Build firmware (esp32s3 / 8mb) (push) Failing after 15s
Firmware QEMU Tests (ADR-061) / QEMU Test (boundary-max) (push) Has been skipped
Firmware QEMU Tests (ADR-061) / QEMU Test (boundary-min) (push) Has been skipped
Firmware QEMU Tests (ADR-061) / QEMU Test (default) (push) Has been skipped
Firmware QEMU Tests (ADR-061) / QEMU Test (edge-tier0) (push) Has been skipped
Firmware QEMU Tests (ADR-061) / NVS Matrix Generation (push) Failing after 1s
Security Scanning / Security Policy Compliance (push) Failing after 0s
Security Scanning / Dependency Vulnerability Scan (push) Failing after 0s
Security Scanning / Static Application Security Testing (push) Failing after 1s
Security Scanning / Infrastructure Security Scan (push) Failing after 1s
Security Scanning / Secret Scanning (push) Failing after 1s
npm packages / harness/ruview (node 22) (push) Failing after 17s
Security Scanning / License Compliance Scan (push) Failing after 1s
Security Scanning / Container Security Scan (push) Failing after 4s
three.js demos → GitHub Pages / build-and-deploy (push) Failing after 1s
Verify Pipeline Determinism / Verify Pipeline Determinism (3.11) (push) Failing after 1s
Fix-Marker Regression Guard / Verify fix markers (push) Failing after 1s
ADR-115 MQTT integration tests / mqtt-integration (push) Failing after 1s
npm packages / harness/ruview (node 20) (push) Failing after 1s
npm packages / tools/ruview-mcp (node 20) (push) Failing after 1s
npm packages / tools/ruview-cli (node 20) (push) Failing after 1s
npm packages / tools/ruview-cli (node 22) (push) Failing after 1s
BFLD MQTT Integration / cargo test --features mqtt (live mosquitto) (push) Failing after 29s
ruview-swarm CI guard / build train_marl bin (push) Failing after 2s
ruview-swarm CI guard / clippy (-D warnings, --no-deps) (push) Failing after 3s
ruview-swarm CI guard / tests (ruflo) (push) Failing after 1s
ruview-swarm CI guard / tests (train) (push) Failing after 2s
ruview-swarm CI guard / tests (default) (push) Failing after 2s
Point Cloud Viewer → GitHub Pages / build-and-deploy (push) Failing after 8s
ruview-swarm CI guard / ITAR / publish guard (push) Failing after 0s
wifi-densepose sensing-server → Docker Hub + ghcr.io / build · push · smoke-test (push) Failing after 1s
Continuous Deployment / Deploy to Production (push) Has been cancelled
Continuous Deployment / Rollback Deployment (push) Has been cancelled
Continuous Deployment / Post-deployment Monitoring (push) Has been cancelled
Continuous Deployment / Notify Deployment Status (push) Has been cancelled
Continuous Deployment / Deploy to Staging (push) Has been cancelled
Security Scanning / Security Report (push) Has been cancelled
chore: import upstream snapshot with attribution
2026-07-13 11:59:54 +08:00

5.8 KiB

ADR-049: Cross-Platform WiFi Interface Detection and Graceful Degradation

Field Value
Status Proposed
Date 2026-03-06
Deciders ruv
Depends on ADR-013 (Feature-Level Sensing), ADR-025 (macOS CoreWLAN)
Issue #148

Context

Users report RuntimeError: Cannot read /proc/net/wireless when running WiFi DensePose in environments where the Linux wireless proc filesystem is unavailable:

  • Docker containers on macOS/Windows (Linux kernel detected, but no wireless subsystem)
  • WSL2 without USB WiFi passthrough
  • Headless Linux servers without WiFi hardware
  • Embedded Linux boards without wireless-extensions support

The current architecture has two layers of defense:

  1. ws_server.py (line 345-355) checks os.path.exists("/proc/net/wireless") before instantiating LinuxWifiCollector and falls back to SimulatedCollector if missing.
  2. rssi_collector.py LinuxWifiCollector._validate_interface() (line 178-196) raises a hard RuntimeError if /proc/net/wireless is missing or the interface isn't listed.

However, there are gaps:

  • Direct usage: Any code that instantiates LinuxWifiCollector directly (outside ws_server.py) hits the unguarded RuntimeError with no fallback.
  • Error message: The RuntimeError message tells users to "use SimulatedCollector instead" but doesn't explain how.
  • No auto-detection: The collector selection logic is duplicated between ws_server.py and install.sh with no shared platform-detection utility.
  • Partial /proc/net/wireless: The file may exist (e.g., kernel module loaded) but contain no interfaces, producing a confusing "interface not found" error instead of a clean fallback.

Decision

1. Platform-Aware Collector Factory

Introduce a create_collector() factory function in rssi_collector.py that encapsulates the platform detection and fallback chain:

def create_collector(
    preferred: str = "auto",
    interface: str = "wlan0",
    sample_rate_hz: float = 10.0,
) -> BaseCollector:
    """
    Create the best available WiFi collector for the current platform.

    Resolution order (when preferred="auto"):
      1. ESP32 CSI (if UDP port 5005 is receiving frames)
      2. Platform-native WiFi:
         - Linux: LinuxWifiCollector (requires /proc/net/wireless + active interface)
         - Windows: WindowsWifiCollector (netsh wlan)
         - macOS: MacosWifiCollector (CoreWLAN)
      3. SimulatedCollector (always available)

    Raises nothing — always returns a usable collector.
    """

2. Soft Validation in LinuxWifiCollector

Replace the hard RuntimeError in _validate_interface() with a class method that returns availability status without raising:

@classmethod
def is_available(cls, interface: str = "wlan0") -> tuple[bool, str]:
    """Check if Linux WiFi collection is possible. Returns (available, reason)."""
    if not os.path.exists("/proc/net/wireless"):
        return False, "/proc/net/wireless not found (Docker, WSL, or no wireless subsystem)"
    with open("/proc/net/wireless") as f:
        content = f.read()
    if interface not in content:
        names = cls._parse_interface_names(content)
        return False, f"Interface '{interface}' not in /proc/net/wireless. Available: {names}"
    return True, "ok"

The existing _validate_interface() continues to raise RuntimeError for direct callers who need fail-fast behavior, but create_collector() uses is_available() to probe without exceptions.

3. Structured Fallback Logging

When auto-detection skips a collector, log at WARNING level with actionable context:

WiFi collector: LinuxWifiCollector unavailable (/proc/net/wireless not found — likely Docker/WSL).
WiFi collector: Falling back to SimulatedCollector. For real sensing, connect ESP32 nodes via UDP:5005.

4. Consolidate Platform Detection

Remove duplicated platform-detection logic from ws_server.py and install.sh. Both should use create_collector() (Python) or a shared detect_wifi_platform() shell function.

Consequences

Positive

  • Zero-crash startup: create_collector("auto") never raises — Docker, WSL, and headless users get SimulatedCollector automatically with a clear log message.
  • Single detection path: Platform logic lives in one place (rssi_collector.py), reducing drift between ws_server.py, install.sh, and future entry points.
  • Better DX: Error messages explain why a collector is unavailable and what to do (connect ESP32, install WiFi driver, etc.).

Negative

  • SimulatedCollector may mask hardware issues: Users with real WiFi hardware that fails detection might unknowingly run on simulated data. Mitigated by the WARNING-level log.
  • Breaking change for direct LinuxWifiCollector callers: Code that catches RuntimeError from _validate_interface() as a signal needs to migrate to is_available() or create_collector(). This is a minor change — there are no known external consumers.

Neutral

  • _validate_interface() behavior is unchanged for existing direct callers — this is additive.

Implementation Notes

  1. Add create_collector() and BaseCollector.is_available() to archive/v1/src/sensing/rssi_collector.py
  2. Refactor ws_server.py _init_collector() to call create_collector()
  3. Update install.sh detect_wifi_hardware() to use shared detection logic
  4. Add unit tests for each platform path (mock /proc/net/wireless presence/absence)
  5. Comment on issue #148 with the fix

References