fix #265: resolve all remaining clippy warnings (cast, too_many_lines, doc nits)
This commit is contained in:
parent
30d82148e0
commit
484cea62c7
12 changed files with 95 additions and 86 deletions
|
|
@ -149,7 +149,7 @@ async fn main() -> Result<()> {
|
|||
}
|
||||
}
|
||||
|
||||
#[allow(clippy::too_many_arguments, clippy::similar_names)]
|
||||
#[allow(clippy::too_many_arguments, clippy::similar_names, clippy::too_many_lines)]
|
||||
async fn serve(
|
||||
socket: &Path,
|
||||
interval: Duration,
|
||||
|
|
@ -307,14 +307,14 @@ async fn serve(
|
|||
}
|
||||
}
|
||||
|
||||
/// Per-turn user prompt. The role/tools/etc. is in the system prompt
|
||||
/// (`prompts/agent.md` → `claude --system-prompt-file`); this is just the
|
||||
/// wake signal claude reacts to. `unread` is the count of *other*
|
||||
/// messages in the inbox right after this one was popped.
|
||||
/// `redelivered` flags messages that were popped in a prior harness
|
||||
/// session, never acked, and resurfaced after a restart — a banner
|
||||
/// at the top of the wake prompt warns that any side-effects of
|
||||
/// previous handling may already have happened.
|
||||
// Per-turn user prompt: the role/tools/etc. is in the system prompt
|
||||
// (`prompts/agent.md` → `claude --system-prompt-file`); this is just the
|
||||
// wake signal claude reacts to. `unread` is the count of *other*
|
||||
// messages in the inbox right after this one was popped.
|
||||
// `redelivered` flags messages that were popped in a prior harness
|
||||
// session, never acked, and resurfaced after a restart — a banner
|
||||
// at the top of the wake prompt warns that any side-effects of
|
||||
// previous handling may already have happened.
|
||||
|
||||
/// Best-effort: tell the broker every message we popped during the
|
||||
/// turn is now fully handled (turn-end-OK). Swallows transport
|
||||
|
|
|
|||
|
|
@ -113,6 +113,7 @@ async fn main() -> Result<()> {
|
|||
}
|
||||
}
|
||||
|
||||
#[allow(clippy::too_many_lines)] // linear startup sequence; splitting adds indirection without clarity
|
||||
async fn serve(
|
||||
socket: &Path,
|
||||
interval: Duration,
|
||||
|
|
|
|||
|
|
@ -22,6 +22,7 @@
|
|||
//! are silently marked read — the agent already knows it opened them.
|
||||
//! - Comment notifications where the comment author matches this agent's own
|
||||
//! forge login are silently marked read.
|
||||
//!
|
||||
//! Own login is fetched once at startup via `GET /user` and cached for the
|
||||
//! lifetime of the polling loop.
|
||||
//!
|
||||
|
|
@ -32,6 +33,7 @@
|
|||
//! generic `[comment on PR #N repo]` so agents can action it immediately.
|
||||
|
||||
use std::collections::HashSet;
|
||||
use std::fmt::Write as _;
|
||||
use std::path::{Path, PathBuf};
|
||||
use std::time::Duration;
|
||||
|
||||
|
|
@ -209,6 +211,7 @@ fn review_state_label(state: &str) -> Option<&str> {
|
|||
///
|
||||
/// Number is extracted from `html_url` last path segment before any `#`.
|
||||
/// Repo slug (`owner/name`) is always included — agents may watch multiple repos.
|
||||
#[allow(clippy::too_many_lines)] // multiple notification types handled in one place by design
|
||||
async fn format_notification(
|
||||
client: &reqwest::Client,
|
||||
token: &str,
|
||||
|
|
@ -329,9 +332,9 @@ async fn format_notification(
|
|||
let kind = format!("PR {review_label}{num}{repo}");
|
||||
let mut out = format!("[{kind}] {title}\nurl: {url}");
|
||||
if body_text.is_empty() {
|
||||
out.push_str(&format!("\n\nreviewer: {author}"));
|
||||
write!(out, "\n\nreviewer: {author}").ok();
|
||||
} else {
|
||||
out.push_str(&format!("\n\n{author}: {}", truncate(body_text, BODY_TRUNCATE)));
|
||||
write!(out, "\n\n{author}: {}", truncate(body_text, BODY_TRUNCATE)).ok();
|
||||
}
|
||||
out.push_str(&meta_suffix);
|
||||
Some(out)
|
||||
|
|
@ -449,15 +452,12 @@ async fn poll_once(
|
|||
debug!(count = notifications.len(), "forge_notify: delivering notifications");
|
||||
|
||||
for notif in ¬ifications {
|
||||
let id = match notif["id"].as_u64() {
|
||||
Some(n) => n,
|
||||
None => continue,
|
||||
};
|
||||
let Some(id) = notif["id"].as_u64() else { continue };
|
||||
|
||||
let body_opt = format_notification(client, token, notif, own_login).await;
|
||||
|
||||
// None means self-echo — mark read silently, no delivery.
|
||||
let body = if let Some(b) = body_opt { b } else {
|
||||
let Some(body) = body_opt else {
|
||||
mark_read(client, forge_url, token, id).await;
|
||||
continue;
|
||||
};
|
||||
|
|
|
|||
|
|
@ -198,6 +198,7 @@ pub fn rate_limit_sleep_secs() -> u64 {
|
|||
/// 1. `HIVE_AUTO_RESET_WATERMARK_TOKENS` env var (explicit override).
|
||||
/// 2. 50% of the model's context window (derived from `bus.model()` +
|
||||
/// `events::context_window_tokens`).
|
||||
///
|
||||
/// `0` disables auto-reset entirely.
|
||||
fn auto_reset_watermark_tokens(bus: &Bus) -> u64 {
|
||||
if let Some(v) = std::env::var("HIVE_AUTO_RESET_WATERMARK_TOKENS")
|
||||
|
|
@ -223,6 +224,7 @@ fn cache_ttl_secs() -> u64 {
|
|||
/// 1. `HIVE_COMPACT_WATERMARK_TOKENS` env var (explicit override).
|
||||
/// 2. 75% of the model's context window (derived from `bus.model()` +
|
||||
/// `events::context_window_tokens`).
|
||||
///
|
||||
/// `0` disables proactive compaction (reactive path still applies).
|
||||
fn compact_watermark_tokens(bus: &Bus) -> u64 {
|
||||
if let Some(v) = std::env::var("HIVE_COMPACT_WATERMARK_TOKENS")
|
||||
|
|
|
|||
|
|
@ -335,7 +335,9 @@ async fn api_stats(
|
|||
// Pass the window span to the reminder-stats RPC so the broker
|
||||
// filters its counts to the same time range as the chart data.
|
||||
let window_secs = window.span_secs();
|
||||
snapshot.reminder_stats = fetch_reminder_stats(&state.socket, state.flavor(), window_secs as u64).await;
|
||||
#[allow(clippy::cast_sign_loss)] // window span is always a positive duration
|
||||
let window_secs_u = window_secs.max(0) as u64;
|
||||
snapshot.reminder_stats = fetch_reminder_stats(&state.socket, state.flavor(), window_secs_u).await;
|
||||
axum::Json(snapshot)
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue