//! Simulation Bridge Node
//!
//! Translates between Redis pub/sub (framework) and Godot RL Agents protocol (simulation).
//!
//! # Architecture
//!
//! The simulation bridge provides two critical data paths:
//!
//! ## Camera Streaming (Dual Path)
//!
//! ```text
//! Godot Camera (port 11009)
//!   ↓ WebSocket (JPEG/RGB frames)
//! simulation-bridge
//!   ├─→ WebRTC Server (port 11010) → Dashboard (low-latency streaming, 30-50ms)
//!   └─→ Redis Publisher → /camera/rgb → AI Nodes (inference, best-effort)
//! ```
//!
//! ## Control Flow
//!
//! ```text
//! Framework Nodes
//!   → Redis (/motor/cmd_vel)
//!   → simulation-bridge
//!   → Godot RL Agents (port 11008)
//!   → Simulation
//! ```
//!
//! # Key Features
//!
//! - **Zero-copy camera frames**: Arc-based sharing between WebRTC and Redis
//! - **Event-driven**: No polling loops, purely async message-driven
//! - **H.264 encoding**: Fast OpenH264 encoder for WebRTC
//! - **Multi-client WebRTC**: Broadcast channel supports multiple dashboards
//! - **Diagnostics**: Integrated metrics for streaming and connection health
//!
//! # Modules
//!
//! - `bridge`: Main node implementation with event loop
//! - `godot_client`: Godot RL Agents protocol client
//! - `config`: Node configuration (camera resolution, FPS, ports)
//! - `topics`: Redis topic definitions and message types
//!
//! # Video Streaming
//!
//! WebRTC server and signaling are now provided by the `mecha10-video` package.

use mecha10_core::prelude::*;

mod bridge;
mod config;
mod godot_client;
mod topics;

pub use bridge::SimulationBridge;
pub use config::SimulationBridgeConfig;

/// Run the simulation bridge node with V2 configuration system
pub async fn run() -> Result<()> {
    // Create context first (needed for config loading)
    let ctx = Context::new("simulation-bridge").await?;

    // Load config using V2 system with environment-aware file-level fallback
    let config: SimulationBridgeConfig = ctx.load_node_config("simulation-bridge").await?;

    // Run the node with Normal priority (simulation data bridge)
    run_node::<SimulationBridge>(config, ctx, HealthReportingConfig::normal()).await
}
