From daf7bcd9ba4bc550865fe5da7275f851932e0847 Mon Sep 17 00:00:00 2001 From: Siavash Sameni Date: Sat, 11 Apr 2026 08:28:26 +0400 Subject: [PATCH] =?UTF-8?q?chore(warnings):=20sweep=20the=20workspace=20?= =?UTF-8?q?=E2=80=94=20zero=20warnings=20on=20lib=20+=20bin=20targets?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Addressed every rustc warning surfaced by \`cargo check --workspace --release --lib --bins\` on opus-DRED-v2. Split across three categories: ## Real bugs surfaced by the audit (fix, don't silence) - **crates/wzp-relay/src/federation.rs** — the per-peer RTT monitor task computed \`rtt_ms\` every 5 s and threw it on the floor. The \`wzp_federation_peer_rtt_ms\` gauge has been registered in metrics.rs the whole time but was never receiving samples, leaving the Grafana panel blank. Wired it up: the task now calls \`fm_rtt.metrics.federation_peer_rtt_ms.with_label_values(&[&label_rtt]).set(rtt_ms)\` on every sample. Fixes three warnings (\`rtt_ms\`, \`fm_rtt\`, \`label_rtt\` were all captured for this task and all dead). ## Dead code removal - **crates/wzp-relay/src/federation.rs** — removed \`local_delivery_seq: AtomicU16\` field and its initializer. It was described in comments as "per-room seq counter for federation media delivered to local clients" but was declared, initialized to 0, and never read or written anywhere else. Genuine half-wired feature; deletable with zero behavior change. - **crates/wzp-relay/src/room.rs** — removed \`let recv_start = Instant::now()\` at the top of a recv loop that was never read. Separate variable \`last_recv_instant\` already measures the actual gap that's used for the \`max_recv_gap_ms\` stat. - **crates/wzp-client/src/cli.rs** — removed \`let my_fp = fp.clone()\` from the signal loop setup. Cloned but never used in any match arm. ## Stub-intent warnings (underscore + explanatory comment) - **crates/wzp-relay/src/handshake.rs** — \`choose_profile\` hardcodes \`QualityProfile::GOOD\` and ignores its \`supported\` parameter. Comment already documented "Cap at GOOD (24k) for now — studio tiers not yet tested for federation reliability". Renamed to \`_supported\`, expanded the comment to explicitly note the future plan (pick highest supported ≤ relay ceiling). - **crates/wzp-relay/src/federation.rs** — \`forward_to_peers\` takes \`room_name: &str\` but only uses \`room_hash\`. The caller (handle_datagram) passes the name for caller-site symmetry with other helpers; kept the param shape and underscored the binding with a comment noting it's reserved for future per-name logging. ## Cosmetic fixes - **crates/wzp-relay/src/event_log.rs** — dropped \`use std::sync::Arc\` (unused). - **crates/wzp-relay/src/signal_hub.rs** — trimmed \`use tracing::{info, warn}\` to \`use tracing::info\`. Also removed unnecessary \`mut\` on \`hub\` binding in the \`register_unregister\` test. - **crates/wzp-relay/src/room.rs** — trimmed \`use tracing::{debug, error, info, trace, warn}\` to \`{error, info, warn}\`. Also removed unnecessary \`mut\` on \`mgr\` binding in the \`room_join_leave\` test. - **crates/wzp-relay/src/main.rs** — removed unnecessary \`mut\` on the \`config\` destructured binding from \`parse_args()\`; and dropped \`ref caller_alias\` from the \`DirectCallOffer\` match pattern since the relay just forwards the full \`msg\` (caller_alias is preserved end-to-end, we don't need to read it on the relay). - **crates/wzp-crypto/tests/featherchat_compat.rs** — dropped \`CallSignalType\` from a \`use wzp_client::featherchat::{...}\` (unused in the test body). Note: this test file has pre-existing compile errors from SignalMessage schema drift unrelated to this sweep; that's tracked separately. ## Crate-level annotation - **crates/wzp-android/src/lib.rs** — added \`#![allow(dead_code, unused_imports, unused_variables, unused_mut)]\` with a doc block explaining the crate is dead code since the Tauri mobile rewrite. The legacy Kotlin+JNI Android app that consumed this crate was replaced by desktop/src-tauri (live Android recv path) + crates/wzp-native (Oboe bridge). Rather than piecemeal cleanup of a crate that shouldn't be maintained, the whole-crate allow keeps CI clean until someone removes the crate entirely. Kills all 6 wzp-android warnings (4 unused imports/vars, 1 unused \`mut\` on a JNI env param, 1 dead \`command_rx\` field) in one line. ## Not touched - **deps/featherchat/warzone/crates/warzone-protocol/src/x3dh.rs** — 3 unused-variable warnings in \`alice_spk_secret\`, \`alice_bundle\`, \`bob_bundle_bytes\`. This is a vendored third-party submodule; upstream's problem, not ours. Would need to be reported to featherchat upstream if we care. ## Verification - \`cargo check --workspace --release --lib --bins\` → 0 warnings, 0 errors - \`cargo check --workspace --release --all-targets\` → only the 3 featherchat submodule warnings remain, plus the pre-existing 3 broken integration tests (SignalMessage schema drift from Phase 2, tracked separately and explicitly out of scope). Co-Authored-By: Claude Opus 4.6 (1M context) --- crates/wzp-android/src/lib.rs | 13 +++++++++++ crates/wzp-client/src/cli.rs | 1 - crates/wzp-crypto/tests/featherchat_compat.rs | 2 +- crates/wzp-relay/src/event_log.rs | 1 - crates/wzp-relay/src/federation.rs | 22 ++++++++++++++----- crates/wzp-relay/src/handshake.rs | 10 ++++++--- crates/wzp-relay/src/main.rs | 4 ++-- crates/wzp-relay/src/room.rs | 5 ++--- crates/wzp-relay/src/signal_hub.rs | 4 ++-- 9 files changed, 43 insertions(+), 19 deletions(-) diff --git a/crates/wzp-android/src/lib.rs b/crates/wzp-android/src/lib.rs index 8c0d5df..dfaa737 100644 --- a/crates/wzp-android/src/lib.rs +++ b/crates/wzp-android/src/lib.rs @@ -8,6 +8,19 @@ //! //! On non-Android targets, the Oboe C++ layer compiles as a stub, //! allowing `cargo check` and unit tests on the host. +//! +//! ## Status +//! +//! **Dead code as of the Tauri mobile rewrite.** The legacy Kotlin+JNI +//! Android app that consumed this crate was replaced by a Tauri 2.x +//! Mobile app (see `desktop/src-tauri/src/engine.rs` for the live +//! Android audio recv path and `crates/wzp-native/` for the Oboe +//! bridge). We keep this crate in the workspace for reference and to +//! preserve the commit history, but it is not built by any shipping +//! target. Allow the accumulated leftover warnings so CI/workspace +//! checks stay clean — any real cleanup should happen as part of +//! removing the crate entirely, not piecemeal. +#![allow(dead_code, unused_imports, unused_variables, unused_mut)] pub mod audio_android; pub mod audio_ring; diff --git a/crates/wzp-client/src/cli.rs b/crates/wzp-client/src/cli.rs index fbb6f7b..4169487 100644 --- a/crates/wzp-client/src/cli.rs +++ b/crates/wzp-client/src/cli.rs @@ -776,7 +776,6 @@ async fn run_signal_mode( // Signal recv loop — handle incoming signals let signal_transport = transport.clone(); let relay = relay_addr; - let my_fp = fp.clone(); let my_seed = seed.0; loop { diff --git a/crates/wzp-crypto/tests/featherchat_compat.rs b/crates/wzp-crypto/tests/featherchat_compat.rs index 06062e8..574b541 100644 --- a/crates/wzp-crypto/tests/featherchat_compat.rs +++ b/crates/wzp-crypto/tests/featherchat_compat.rs @@ -273,7 +273,7 @@ fn auth_invalid_response_matches() { #[test] fn all_signal_types_map_correctly() { - use wzp_client::featherchat::{signal_to_call_type, CallSignalType}; + use wzp_client::featherchat::signal_to_call_type; let cases: Vec<(wzp_proto::SignalMessage, &str)> = vec![ ( diff --git a/crates/wzp-relay/src/event_log.rs b/crates/wzp-relay/src/event_log.rs index fb4fcb8..d0805fc 100644 --- a/crates/wzp-relay/src/event_log.rs +++ b/crates/wzp-relay/src/event_log.rs @@ -5,7 +5,6 @@ //! Use `wzp-analyzer` to correlate events across multiple relays. use std::path::PathBuf; -use std::sync::Arc; use serde::Serialize; use tokio::sync::mpsc; diff --git a/crates/wzp-relay/src/federation.rs b/crates/wzp-relay/src/federation.rs index 07c1733..48c3cfa 100644 --- a/crates/wzp-relay/src/federation.rs +++ b/crates/wzp-relay/src/federation.rs @@ -142,9 +142,6 @@ pub struct FederationManager { peer_links: Arc>>, /// Dedup filter for incoming federation datagrams. dedup: Mutex, - /// Per-room seq counter for federation media delivered to local clients. - /// Ensures clients see monotonically increasing seq regardless of federation sender. - local_delivery_seq: std::sync::atomic::AtomicU16, /// JSONL event log for protocol analysis. event_log: EventLogger, /// Per-room rate limiters for inbound federation media. @@ -172,7 +169,6 @@ impl FederationManager { metrics, peer_links: Arc::new(Mutex::new(HashMap::new())), dedup: Mutex::new(Deduplicator::new(DEDUP_WINDOW_SIZE)), - local_delivery_seq: std::sync::atomic::AtomicU16::new(0), event_log, rate_limiters: Mutex::new(HashMap::new()), } @@ -296,7 +292,12 @@ impl FederationManager { /// Forward locally-generated media to all connected peers. /// For locally-originated media, we send to ALL peers (they decide whether to deliver). /// For forwarded media (multi-hop), handle_datagram filters by active_rooms. - pub async fn forward_to_peers(&self, room_name: &str, room_hash: &[u8; 8], media_data: &Bytes) { + /// + /// `_room_name` is kept in the signature for caller-site symmetry with + /// the other room-tagged helpers and for future per-room-name logging + /// or rate limiting; the body currently forwards on `room_hash` alone + /// because that's what the wire format carries. + pub async fn forward_to_peers(&self, _room_name: &str, room_hash: &[u8; 8], media_data: &Bytes) { let links = self.peer_links.lock().await; if links.is_empty() { return; @@ -623,11 +624,20 @@ async fn run_federation_link( } }; - // RTT monitor: periodically sample QUIC RTT for this peer + // RTT monitor: periodically sample QUIC RTT for this peer and push it + // into the `wzp_federation_peer_rtt_ms` gauge. The gauge is registered + // in metrics.rs but previously never received any samples — the task + // computed rtt_ms and dropped it on the floor, leaving the Grafana + // panel blank. Fixed as part of the workspace warning sweep. let rtt_task = async move { loop { tokio::time::sleep(Duration::from_secs(5)).await; let rtt_ms = rtt_transport.connection().stats().path.rtt.as_millis() as f64; + fm_rtt + .metrics + .federation_peer_rtt_ms + .with_label_values(&[&label_rtt]) + .set(rtt_ms); } }; diff --git a/crates/wzp-relay/src/handshake.rs b/crates/wzp-relay/src/handshake.rs index d31e3e9..2099b6b 100644 --- a/crates/wzp-relay/src/handshake.rs +++ b/crates/wzp-relay/src/handshake.rs @@ -94,9 +94,13 @@ pub async fn accept_handshake( } /// Select the best quality profile from those the caller supports. -fn choose_profile(supported: &[QualityProfile]) -> QualityProfile { - // Cap at GOOD (24k) for now — studio tiers (32k/48k/64k) not yet tested - // for federation reliability (large packets may exceed path MTU). +/// +/// The `_supported` list is currently ignored — we hardcode GOOD (24k) until +/// studio tiers (32k/48k/64k) have been validated across federation (large +/// packets may exceed path MTU and fragment in unpleasant ways). Once that's +/// tested, the body should pick the highest supported profile ≤ the relay's +/// configured ceiling. +fn choose_profile(_supported: &[QualityProfile]) -> QualityProfile { QualityProfile::GOOD } diff --git a/crates/wzp-relay/src/main.rs b/crates/wzp-relay/src/main.rs index 3528c74..2b7f5f1 100644 --- a/crates/wzp-relay/src/main.rs +++ b/crates/wzp-relay/src/main.rs @@ -272,7 +272,7 @@ const BUILD_GIT_HASH: &str = env!("WZP_BUILD_HASH"); #[tokio::main] async fn main() -> anyhow::Result<()> { - let CliResult { mut config, identity_path, config_file, config_needs_create } = parse_args(); + let CliResult { config, identity_path, config_file, config_needs_create } = parse_args(); tracing_subscriber::fmt().init(); info!(version = BUILD_GIT_HASH, "wzp-relay build"); rustls::crypto::ring::default_provider() @@ -766,7 +766,7 @@ async fn main() -> anyhow::Result<()> { match transport.recv_signal().await { Ok(Some(msg)) => { match msg { - SignalMessage::DirectCallOffer { ref target_fingerprint, ref call_id, ref caller_alias, .. } => { + SignalMessage::DirectCallOffer { ref target_fingerprint, ref call_id, .. } => { let target_fp = target_fingerprint.clone(); let call_id = call_id.clone(); diff --git a/crates/wzp-relay/src/room.rs b/crates/wzp-relay/src/room.rs index b1c5b86..6104e62 100644 --- a/crates/wzp-relay/src/room.rs +++ b/crates/wzp-relay/src/room.rs @@ -10,7 +10,7 @@ use std::time::Duration; use bytes::Bytes; use tokio::sync::Mutex; -use tracing::{debug, error, info, trace, warn}; +use tracing::{error, info, warn}; use wzp_proto::packet::TrunkFrame; use wzp_proto::MediaTransport; @@ -483,7 +483,6 @@ async fn run_participant_plain( ); loop { - let recv_start = std::time::Instant::now(); let pkt = match transport.recv_media().await { Ok(Some(pkt)) => pkt, Ok(None) => { @@ -838,7 +837,7 @@ mod tests { #[test] fn room_join_leave() { - let mut mgr = RoomManager::new(); + let mgr = RoomManager::new(); assert_eq!(mgr.room_size("test"), 0); assert!(mgr.list().is_empty()); } diff --git a/crates/wzp-relay/src/signal_hub.rs b/crates/wzp-relay/src/signal_hub.rs index d4254f9..2d497a6 100644 --- a/crates/wzp-relay/src/signal_hub.rs +++ b/crates/wzp-relay/src/signal_hub.rs @@ -7,7 +7,7 @@ use std::collections::HashMap; use std::sync::Arc; use std::time::Instant; -use tracing::{info, warn}; +use tracing::info; use wzp_proto::{MediaTransport, SignalMessage}; use wzp_transport::QuinnTransport; @@ -94,7 +94,7 @@ mod tests { #[test] fn register_unregister() { - let mut hub = SignalHub::new(); + let hub = SignalHub::new(); assert_eq!(hub.online_count(), 0); assert!(!hub.is_online("alice"));