fix(clippy): fix all clippy warnings in hive-ag3nt, hive-forge, hive-matrix-mcp, hive-sh4re

Fixes all clippy -D warnings errors in the crates iris owns:

hive-sh4re:
- doc_lazy_continuation: add blank /// separator in priv_proto.rs
- doc_markdown: backtick PRIVATE_NETWORK=0 / PRIVATE_NETWORK=1

hive-matrix-mcp:
- map_unwrap_or: map().unwrap_or_else() -> map_or_else() in paths.rs
- collapsible_if: if-let chains in wake.rs
- doc_markdown: backtick M_UNKNOWN_TOKEN in main.rs
- cast_possible_truncation: usize/u64 -> u32::try_from in handlers.rs
- map_unwrap_or: map_or_else() in handlers.rs
- manual_let_else: match Ok(r) => r, Err => return -> let Ok in handlers.rs
- unused_async: remove async from list_invites; update socket.rs call site

hive-forge:
- doc_markdown: backtick REQUEST_CHANGES / APPROVED / COMMENT in pr_reviews.rs
- unnecessary_wraps: list_reviews_text returns () not Result<()>
- doc_markdown: backtick start_page / last_page in comments.rs
- cast_possible_truncation: PAGE_SIZE u64 -> usize; remove as usize casts

hive-ag3nt:
- collapsible_if: if-let chains in events.rs and mcp.rs
- single_match_else: match -> if let in events.rs and mcp.rs
- items_after_statements: hoist STATUS_MAX_CHARS const in mcp.rs
- map_unwrap_or: map_or_else() in mcp.rs and mcp_loose_ends.rs
- cast_possible_truncation: usize -> u32::try_from in mcp.rs
- doc_markdown: backtick snake_case in mcp.rs, needs_update/deployed_sha
  in web_ui.rs, HISTORY_CAPACITY in web_ui.rs
- identical_match_arms: combine manage_root_agent | query_agent_state
- redundant_closure: |s| s.to_string() -> ToString::to_string in web_ui.rs
- duration_suboptimal_units: from_secs(3600) -> from_hours(1) in turn.rs

Remaining failures in hive-c0re (39), hive-priv (8), hive-bash-mcp (11)
are owned by damocles.
This commit is contained in:
iris 2026-06-05 14:28:05 +02:00 committed by mara
commit 92b32d06fb
13 changed files with 128 additions and 133 deletions

View file

@ -275,7 +275,7 @@ pub async fn list_room_members(client: &Client, room_ref: &str) -> DaemonRespons
DaemonResponse::ok(&list)
}
pub async fn list_invites(client: &Client) -> DaemonResponse {
pub fn list_invites(client: &Client) -> DaemonResponse {
let invites: Vec<InviteInfo> = client
.invited_rooms()
.into_iter()
@ -422,11 +422,14 @@ pub async fn read_room(client: &Client, room_ref: &str, limit: Option<usize>) ->
/// [`collect_unread`] issues for count==1 rooms.
#[must_use]
pub fn unread_count(client: &Client) -> DaemonResponse {
let rooms = client
.joined_rooms()
.into_iter()
.filter(|r| r.unread_notification_counts().notification_count > 0)
.count() as u32;
let rooms = u32::try_from(
client
.joined_rooms()
.into_iter()
.filter(|r| r.unread_notification_counts().notification_count > 0)
.count(),
)
.unwrap_or(u32::MAX);
DaemonResponse::ok(&serde_json::json!({ "rooms": rooms }))
}
@ -447,14 +450,14 @@ pub async fn collect_unread(client: &Client) -> Vec<crate::protocol::RoomUnread>
use crate::protocol::RoomUnread;
let mut result = Vec::new();
for room in client.joined_rooms() {
let count = room.unread_notification_counts().notification_count as u32;
let count = u32::try_from(room.unread_notification_counts().notification_count)
.unwrap_or(u32::MAX);
if count == 0 {
continue;
}
let label = room
.canonical_alias()
.map(|a| a.to_string())
.unwrap_or_else(|| room.room_id().to_string());
.map_or_else(|| room.room_id().to_string(), |a| a.to_string());
let (last_body, last_sender) = if count == 1 {
fetch_last_message(client, &room).await
} else {
@ -482,9 +485,8 @@ async fn fetch_last_message(
let mut req =
get_message_events::v3::Request::new(room.room_id().to_owned(), Direction::Backward);
req.limit = matrix_sdk::ruma::UInt::from(1u32);
let resp = match client.send(req).await {
Ok(r) => r,
Err(_) => return (None, None),
let Ok(resp) = client.send(req).await else {
return (None, None);
};
for raw in &resp.chunk {
if let Ok(ev) = raw.deserialize() {

View file

@ -15,7 +15,7 @@
//! synced with hive-c0re's token-provisioning timing.
//!
//! Stale-token recovery: handled in `client::build_and_restore` — see
//! that module for the M_UNKNOWN_TOKEN detection + cleanup flow.
//! that module for the `M_UNKNOWN_TOKEN` detection + cleanup flow.
use anyhow::{Context, Result};
use matrix_sdk::config::SyncSettings;

View file

@ -83,8 +83,7 @@ pub fn mcp_loose_ends_dir() -> PathBuf {
let state_path = PathBuf::from(&state);
state_path
.parent()
.map(|p| p.join("harness"))
.unwrap_or_else(|| PathBuf::from(state))
.map_or_else(|| PathBuf::from(state), |p| p.join("harness"))
};
base.join("mcp-loose-ends")
}

View file

@ -79,7 +79,7 @@ async fn dispatch(req: DaemonRequest, client: &Client) -> DaemonResponse {
handlers::mark_read(client, &room, &event_id).await
}
DaemonRequest::ListRooms => handlers::list_rooms(client).await,
DaemonRequest::ListInvites => handlers::list_invites(client).await,
DaemonRequest::ListInvites => handlers::list_invites(client),
DaemonRequest::JoinRoom { room } => handlers::join_room(client, &room).await,
DaemonRequest::InviteUser { room, user_id } => {
handlers::invite_user(client, &room, &user_id).await

View file

@ -58,8 +58,8 @@ pub async fn send_wake(socket: &Path, body: impl AsRef<str>) -> Result<()> {
// Drain the response line so the server doesn't get ECONNRESET on
// its write-back. We don't act on the response — best-effort wake.
let mut reader = tokio::io::BufReader::new(read);
let mut _resp = String::new();
let _ = reader.read_line(&mut _resp).await;
let mut resp = String::new();
let _ = reader.read_line(&mut resp).await;
Ok(())
}
@ -86,13 +86,13 @@ pub fn format_unread_summary(rooms: &[crate::protocol::RoomUnread]) -> String {
// Terse path: exactly one room, exactly one unread with body.
if rooms.len() == 1 {
let r = &rooms[0];
if r.count == 1 {
if let (Some(body), Some(sender)) = (&r.last_body, &r.last_sender) {
return format!(
"[matrix] {sender} in {label}: {body} — use read_room to view, mark_read to clear",
label = r.label
);
}
if r.count == 1
&& let (Some(body), Some(sender)) = (&r.last_body, &r.last_sender)
{
return format!(
"[matrix] {sender} in {label}: {body} — use read_room to view, mark_read to clear",
label = r.label
);
}
return format!(
"[matrix] {} unread in {} — use read_room to view, mark_read to clear",
@ -102,11 +102,11 @@ pub fn format_unread_summary(rooms: &[crate::protocol::RoomUnread]) -> String {
// Multi-room path.
let mut out = String::from("[matrix] unread messages:");
for r in rooms {
if r.count == 1 {
if let (Some(body), Some(sender)) = (&r.last_body, &r.last_sender) {
let _ = write!(out, "\n- {}: {sender}: {body}", r.label);
continue;
}
if r.count == 1
&& let (Some(body), Some(sender)) = (&r.last_body, &r.last_sender)
{
let _ = write!(out, "\n- {}: {sender}: {body}", r.label);
continue;
}
let _ = write!(out, "\n- {}: {} unread", r.label, r.count);
}