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.
52 lines
1.9 KiB
Rust
52 lines
1.9 KiB
Rust
//! Generic scanner for MCP loose-end summary files.
|
|
//!
|
|
//! External MCP daemons (hive-bash-mcp, hive-matrix-mcp, etc.) write
|
|
//! JSON files to `$HYPERHIVE_HARNESS_DIR/mcp-loose-ends/<name>.json`.
|
|
//! Each file contains a JSON array of plain-text summary strings.
|
|
//!
|
|
//! The harness reads all files in this directory in `get_loose_ends` to
|
|
//! surface active background work from any MCP without hardcoding
|
|
//! per-MCP knowledge here.
|
|
|
|
use std::path::PathBuf;
|
|
|
|
/// NOTE: the base-dir resolution logic here is intentionally mirrored in
|
|
/// `hive-bash-mcp/src/paths.rs::mcp_loose_ends_dir()`. They can't share
|
|
/// code across crates — keep them in sync if the fallback logic changes.
|
|
fn loose_ends_dir() -> PathBuf {
|
|
let base = if let Some(p) = std::env::var_os("HYPERHIVE_HARNESS_DIR") {
|
|
PathBuf::from(p)
|
|
} else {
|
|
let state = std::env::var("HYPERHIVE_STATE_DIR").unwrap_or_default();
|
|
let state_path = PathBuf::from(&state);
|
|
state_path
|
|
.parent()
|
|
.map_or_else(|| PathBuf::from(state), |p| p.join("harness"))
|
|
};
|
|
base.join("mcp-loose-ends")
|
|
}
|
|
|
|
/// Collect all loose-end summary strings published by external MCP daemons.
|
|
/// Each string is a single line suitable for inclusion in `get_loose_ends`
|
|
/// output. Returns an empty vec if the directory doesn't exist or is empty.
|
|
#[must_use]
|
|
pub fn collect() -> Vec<String> {
|
|
let Ok(rd) = std::fs::read_dir(loose_ends_dir()) else {
|
|
return Vec::new();
|
|
};
|
|
let mut out = Vec::new();
|
|
for entry in rd.flatten() {
|
|
let path = entry.path();
|
|
if path.extension().and_then(|e| e.to_str()) != Some("json") {
|
|
continue;
|
|
}
|
|
let Ok(content) = std::fs::read_to_string(&path) else {
|
|
continue;
|
|
};
|
|
let Ok(items) = serde_json::from_str::<Vec<String>>(&content) else {
|
|
continue;
|
|
};
|
|
out.extend(items);
|
|
}
|
|
out
|
|
}
|