From 37f036ee7d598531f22de38ddc1bbeee2c8ab0f1 Mon Sep 17 00:00:00 2001 From: iris Date: Mon, 16 Nov 2026 19:07:08 +0100 Subject: [PATCH] remove the unused reminder rollup request and the stale references to the stats page --- .../agent-state/persistence.md | 3 +- hive-agent-sock/src/lib.rs | 9 --- hive-agent/src/reminders.rs | 61 ++----------------- hive-agent/src/sqlite_writer.rs | 4 +- hive-agent/src/todo_server.rs | 23 +------ hive-agent/src/turn.rs | 2 +- hive-agent/src/turn_stats.rs | 12 ++-- hive-agent/src/vacuum.rs | 3 +- hive-bash-mcp/src/paths.rs | 3 +- hive-bash-mcp/src/runner.rs | 4 +- hive-bash-mcp/src/stats.rs | 4 +- hive-c0re/src/main.rs | 4 +- hive-sh4re/src/inbox.rs | 11 ---- 13 files changed, 26 insertions(+), 117 deletions(-) diff --git a/docs/4-implementation/agent-state/persistence.md b/docs/4-implementation/agent-state/persistence.md index 6460e5180..d31aaf983 100644 --- a/docs/4-implementation/agent-state/persistence.md +++ b/docs/4-implementation/agent-state/persistence.md @@ -227,8 +227,7 @@ Under `/var/lib/hyperhive/agents//`: Retention, by the hourly `hive-agent::vacuum::run` sweep, which runs in-container because hive-c0re can't delete agent-owned files: it reaps delivered (soft-deleted) reminder - rows 14 days after delivery, kept that long only to serve - the trailing-window `ReminderRollup` stats, and reaps acked todo rows + rows 14 days after delivery, and reaps acked todo rows 30 days after acking (long enough that only a genuinely quiet month triggers the "one spurious re-announcement" fallback a reconciled producer like `disk_watch` relies on — see `todos.rs`'s diff --git a/hive-agent-sock/src/lib.rs b/hive-agent-sock/src/lib.rs index 526aae471..0a493df77 100644 --- a/hive-agent-sock/src/lib.rs +++ b/hive-agent-sock/src/lib.rs @@ -117,11 +117,6 @@ pub enum Request { /// This agent's pending-reminder count — used by the pre-`remind` cap /// check and the harness's own turn-stats sink. CountPendingReminders, - /// Scheduled/delivered/pending reminder counts over a trailing - /// `since_secs` window (`0` = all time) — the harness's own `/api/stats` - /// reminder-activity chart data (was `hive-core-agent-sock`'s - /// `ReminderRollup` against the broker; now served from the local store). - ReminderRollup { since_secs: u64 }, /// Agent self-service request to compact the current session, mirroring /// the `compact` MCP tool. Gated server-side: only /// honoured when the last completed turn's context usage is above 40% @@ -158,10 +153,6 @@ pub enum Response { LooseEnds { loose_ends: Vec }, /// `CountPendingReminders` result. PendingRemindersCount { count: u64 }, - /// `ReminderRollup` result. - ReminderRollup { - stats: hive_sh4re::inbox::ReminderStats, - }, /// `Transcribe` result: the text spoken in the audio (empty for silence), /// and whether the service had it already. Transcript { text: String, cached: bool }, diff --git a/hive-agent/src/reminders.rs b/hive-agent/src/reminders.rs index 34207ee5f..da6bbab72 100644 --- a/hive-agent/src/reminders.rs +++ b/hive-agent/src/reminders.rs @@ -7,18 +7,14 @@ //! Unlike todos (discovered passively via `get_loose_ends`), a reminder is //! *active push*: it must fire into the turn loop at `due_at` with its own //! message body (see `reminder_timer.rs`). Delivery is *soft*-deleted -//! (`sent_at` set, not `DELETE`) so the harness's own `/api/stats` reminder -//! rollup can still report scheduled/delivered/pending counts over a -//! trailing window (mirrors the old c0re `ReminderStats` shape exactly). A -//! periodic prune (`vacuum.rs`) reaps old delivered rows so the table -//! doesn't grow unbounded. +//! (`sent_at` set, not `DELETE`); a periodic prune (`vacuum.rs`) reaps old +//! delivered rows so the table doesn't grow unbounded. use std::path::Path; use std::sync::Mutex; use anyhow::{Context, Result}; use chrono::{DateTime, Utc}; -use hive_sh4re::inbox::ReminderStats; use hive_sh4re::wire_time; use rusqlite::{Connection, params}; @@ -211,8 +207,8 @@ impl Reminders { } /// Soft-delete: stamp `sent_at` so the row drops out of - /// `count_pending`/`list_pending`/`due` but survives for the rollup - /// stats until `prune_delivered_older_than` reaps it. + /// `count_pending`/`list_pending`/`due` and is reaped later by + /// `prune_delivered_older_than`. /// /// # Errors /// @@ -232,7 +228,7 @@ impl Reminders { } /// Cancel a still-pending reminder by id (hard delete — it never - /// fired, so there's nothing to keep for the rollup). Returns the + /// fired, so there's nothing to keep). Returns the /// number of rows deleted (0 = unknown id, or already delivered). /// /// # Errors @@ -251,47 +247,6 @@ impl Reminders { Ok(n) } - /// Scheduled/delivered/pending counts within the trailing - /// `since_secs` window (`0` = all time) — the local equivalent of the - /// old c0re `ReminderRollup` query, same `sent_at IS NULL/NOT NULL` - /// shape. - /// - /// # Errors - /// - /// Propagates the sqlite query failure. - /// - /// # Panics - /// - /// Panics if the connection mutex is poisoned. - pub fn rollup(&self, since_secs: i64) -> Result { - let conn = self.conn.lock().unwrap(); - let cutoff = if since_secs > 0 { - Utc::now().timestamp().saturating_sub(since_secs) - } else { - i64::MIN - }; - let scheduled: i64 = conn.query_row( - "SELECT COUNT(*) FROM reminders WHERE created_at >= ?1", - params![cutoff], - |row| row.get(0), - )?; - let delivered: i64 = conn.query_row( - "SELECT COUNT(*) FROM reminders WHERE created_at >= ?1 AND sent_at IS NOT NULL", - params![cutoff], - |row| row.get(0), - )?; - let pending: i64 = conn.query_row( - "SELECT COUNT(*) FROM reminders WHERE created_at >= ?1 AND sent_at IS NULL", - params![cutoff], - |row| row.get(0), - )?; - Ok(ReminderStats { - scheduled: u64::try_from(scheduled).unwrap_or(0), - delivered: u64::try_from(delivered).unwrap_or(0), - pending: u64::try_from(pending).unwrap_or(0), - }) - } - /// Reap delivered rows older than `cutoff` (unix seconds) — called /// from `vacuum.rs`'s periodic sweep so the table doesn't grow /// unbounded. Returns the number of rows deleted. @@ -404,16 +359,12 @@ mod tests { } #[test] - fn mark_delivered_removes_from_pending_but_counts_in_rollup() { + fn mark_delivered_removes_from_pending() { let (_dir, s) = store(); let id = s.store("a", None, 100).unwrap(); s.mark_delivered(id).unwrap(); assert_eq!(s.count_pending().unwrap(), 0); assert!(s.list_pending().unwrap().is_empty()); - let rollup = s.rollup(0).unwrap(); - assert_eq!(rollup.scheduled, 1); - assert_eq!(rollup.delivered, 1); - assert_eq!(rollup.pending, 0); } #[test] diff --git a/hive-agent/src/sqlite_writer.rs b/hive-agent/src/sqlite_writer.rs index a13c1c999..883a23d26 100644 --- a/hive-agent/src/sqlite_writer.rs +++ b/hive-agent/src/sqlite_writer.rs @@ -1,7 +1,7 @@ //! Shared connection setup for the harness's own sqlite writers. //! -//! A write that overlaps another connection's lock (the stats page, the hourly -//! vacuum) fails at once with `SQLITE_BUSY` unless the connection has a busy +//! A write that overlaps another connection's lock (the hourly vacuum, a +//! reader) fails at once with `SQLITE_BUSY` unless the connection has a busy //! timeout, so writers set [`BUSY_TIMEOUT`] to wait instead of dropping the row. use std::time::Duration; diff --git a/hive-agent/src/todo_server.rs b/hive-agent/src/todo_server.rs index e41c41e99..856a73214 100644 --- a/hive-agent/src/todo_server.rs +++ b/hive-agent/src/todo_server.rs @@ -60,8 +60,7 @@ fn socket_path() -> Option { } /// Dial this same in-agent socket from elsewhere IN THIS PROCESS — the -/// harness's own `web_ui` endpoints (`api_todos`, `/api/stats` reminder -/// rollup) and `Surface::post_turn_counts` all need read access to the +/// harness's own `web_ui` endpoints (`api_todos`) and `Surface::post_turn_counts` all need read access to the /// `Todos`/`Reminders` stores this module owns behind an `Arc` on a /// different spawned task, and a loopback dial is simpler than threading /// those `Arc`s through every caller. One-shot, best-effort (no retry, @@ -275,7 +274,6 @@ fn dispatch( Request::ListReminders => list_reminders(reminders), Request::CancelReminder { id } => cancel_reminder(reminders, id), Request::CountPendingReminders => count_pending_reminders(reminders), - Request::ReminderRollup { since_secs } => reminder_rollup(reminders, since_secs), Request::Compact { wake_prompt } => compact(bus, wake_prompt), // Answered by `handle_conn` before this runs: it waits on the queue, // which this store-only function never does. @@ -338,19 +336,6 @@ fn count_pending_reminders(reminders: Option<&Reminders>) -> Response { } } -/// `ReminderRollup` handler: scheduled/delivered/pending counts over a -/// trailing `since_secs` window (`0` = all time). -fn reminder_rollup(reminders: Option<&Reminders>, since_secs: u64) -> Response { - let Some(r) = reminders else { - return no_reminders_store(); - }; - let since_secs = i64::try_from(since_secs).unwrap_or(i64::MAX); - match r.rollup(since_secs) { - Ok(stats) => Response::ReminderRollup { stats }, - Err(e) => err(&e), - } -} - /// `UpsertTodo` handler: writes/refreshes a todo row, logs the outcome, and /// fires `wake` on a new-or-changed upsert so the serve loop runs a turn. fn upsert_todo( @@ -890,7 +875,6 @@ mod tests { Request::ListReminders, Request::CancelReminder { id: 1 }, Request::CountPendingReminders, - Request::ReminderRollup { since_secs: 0 }, ]; for req in reqs { let resp = dispatch(req, &todos, &wake, None, &bus); @@ -924,10 +908,6 @@ mod tests { panic!("one reminder, got {loose_ends:?}"); }; assert_eq!(message, "check the deploy"); - assert!(matches!( - run(Request::ReminderRollup { since_secs: 0 }), - Response::ReminderRollup { .. } - )); assert_eq!(acked(&run(Request::CancelReminder { id: *id })), 1); assert_eq!(acked(&run(Request::CancelReminder { id: *id })), 0); @@ -1150,7 +1130,6 @@ mod tests { Request::ListReminders, Request::CancelReminder { id: 1 }, Request::CountPendingReminders, - Request::ReminderRollup { since_secs: 0 }, ]; for req in requests { let label = format!("{req:?}"); diff --git a/hive-agent/src/turn.rs b/hive-agent/src/turn.rs index 87c85408e..0dfecc598 100644 --- a/hive-agent/src/turn.rs +++ b/hive-agent/src/turn.rs @@ -163,7 +163,7 @@ pub async fn write_system_prompt(socket: &Path, label: &str) -> Result /// the serve loop must act on. The `compacted` bool is `true` when a /// compaction ran this turn (reactively on overflow, or proactively per the /// policy — or a successful agent-requested `/compact` at turn end); it's recorded as -/// `result_kind = "compacted"` in turn stats so the stats page can distinguish +/// `result_kind = "compacted"` in turn stats so a reader can distinguish /// those turns. Both `Ok(true)` and `Ok(false)` are ack'd; the error cases /// each map to a distinct serve-loop action (see [`emit_turn_end`] and the /// `hive-agent` serve loop). diff --git a/hive-agent/src/turn_stats.rs b/hive-agent/src/turn_stats.rs index d49121ac1..adc262863 100644 --- a/hive-agent/src/turn_stats.rs +++ b/hive-agent/src/turn_stats.rs @@ -3,15 +3,15 @@ //! `ended_at`, `duration_ms`), cost (token counts), and behaviour (tool-call //! count + per-tool breakdown). //! -//! **Captured but not yet read** (written every turn, no reader today — -//! kept for a future chart / backfill, not consumed by `stats::snapshot` -//! or the host rollup): `tool_call_count` (the snapshot recomputes tool -//! totals from `tool_call_breakdown_json` instead), `open_threads_count` + +//! **Captured but not yet read** (written every turn, no reader in this +//! repository — kept for a future chart / backfill): `tool_call_count` (a +//! reader recomputes tool totals from `tool_call_breakdown_json` instead), +//! `open_threads_count` + //! `open_reminders_count` (planned: a loose-ends-over-time trend), and //! `note` (failure detail for `result_kind = "failed"`). //! //! Lives in the harness dir (`HYPERHIVE_HARNESS_DIR`) as -//! `hyperhive-turn-stats.sqlite`; the agent's own `/stats` page reads it +//! `hyperhive-turn-stats.sqlite`; the standalone legacy stats viewer reads it //! and no vacuum sweeps it. Schema is //! intentionally append-only — every column has a default so future //! additions don't break old readers; new columns land via @@ -118,7 +118,7 @@ pub struct TurnStatRow { /// when no tools were called (saves a sqlite write of `"{}"`). pub tool_call_breakdown_json: Option, /// Post-turn loose-ends snapshot. Captured, not yet read — planned to - /// feed a loose-ends-over-time trend on the stats page. + /// feed a loose-ends-over-time trend. pub open_threads_count: Option, pub open_reminders_count: Option, /// `"ok" | "failed" | "prompt_too_long"`. diff --git a/hive-agent/src/vacuum.rs b/hive-agent/src/vacuum.rs index b6eb2ad15..7d8b38d34 100644 --- a/hive-agent/src/vacuum.rs +++ b/hive-agent/src/vacuum.rs @@ -23,8 +23,7 @@ const VACUUM_INTERVAL: Duration = Duration::from_hours(1); /// Keep completed bash-task files this long before deleting their trio. const BASH_KEEP_SECS: i64 = 48 * 3600; /// Keep delivered (soft-deleted, `sent_at` set) reminder rows this long -/// before reaping them — same window as `STREAM_KEEP_SECS`, kept around -/// only to serve the trailing-window `ReminderRollup` stats. +/// before reaping them — same window as `STREAM_KEEP_SECS`. const REMINDER_KEEP_SECS: i64 = 14 * 24 * 3600; /// Keep acked (agent-dismissed) todo rows this long before reaping them — /// see `todos.rs`'s module doc for why acking doesn't delete outright. Long diff --git a/hive-bash-mcp/src/paths.rs b/hive-bash-mcp/src/paths.rs index a75725bc0..1750f55a0 100644 --- a/hive-bash-mcp/src/paths.rs +++ b/hive-bash-mcp/src/paths.rs @@ -22,7 +22,8 @@ pub fn tasks_dir() -> PathBuf { /// Per-agent turn-stats sqlite — the harness writes one row per claude /// turn here; the runner appends normalised bash-command heads to its -/// `bash_commands` table for the /stats "favorite tools" view. +/// `bash_commands` table, which the harness reads for its OTEL bash-command +/// counter. #[must_use] pub fn turn_stats_db() -> PathBuf { harness_dir().join("hyperhive-turn-stats.sqlite") diff --git a/hive-bash-mcp/src/runner.rs b/hive-bash-mcp/src/runner.rs index 2e97add93..3797b9c35 100644 --- a/hive-bash-mcp/src/runner.rs +++ b/hive-bash-mcp/src/runner.rs @@ -608,8 +608,8 @@ async fn run_task(mut task: TaskFile, socket: &Path, cgroups: Option<&RunCgroups // full command stays on disk in the task file for `status`/`view` // instead. upsert_bash_todo(socket, &id, format!("bash task `{id}` running")).await; - // Best-effort: tally the normalised command head for the /stats - // "favorite tools" view. Counted once per execution, regardless of + // Best-effort: tally the normalised command head for the OTEL + // bash-command counter. Counted once per execution, regardless of // exit status. Never fails the task. crate::stats::record_command(&task.cmd); diff --git a/hive-bash-mcp/src/stats.rs b/hive-bash-mcp/src/stats.rs index 247958684..e135e6dc6 100644 --- a/hive-bash-mcp/src/stats.rs +++ b/hive-bash-mcp/src/stats.rs @@ -1,6 +1,6 @@ //! Capture of normalised shell-command "heads" per bash task into the -//! per-agent turn-stats sqlite (`bash_commands` table), backing the -//! "favorite tools" doughnut on the /stats page. +//! per-agent turn-stats sqlite (`bash_commands` table), read by the +//! harness for its OTEL bash-command counter. //! //! Best-effort: a missing db, a lock, or a parse miss is logged and //! swallowed — recording a stat never affects task execution. The diff --git a/hive-c0re/src/main.rs b/hive-c0re/src/main.rs index faee9ea59..14b0f1dd1 100644 --- a/hive-c0re/src/main.rs +++ b/hive-c0re/src/main.rs @@ -326,8 +326,8 @@ async fn cmd_serve( // agent-owned, so host-side deletes hit PermissionDenied / readonly-db // under privsep. See issue tracker "perms borked". // (turn-stats.sqlite has no vacuum — it's one tiny row per turn, - // ~hundreds of KB, and the agent's own /stats page reads it - // directly; pruning it would just lose trend history for no gain.) + // ~hundreds of KB, and pruning it would just lose trend + // history for no gain.) // Slow per-container disk sampler: hive-priv measures each agent's state/ // + work/ + writable rootfs every 30 min, cached so a sample only reads // cgroup files. Feeds `disk_bytes` to the OTEL exporter. See diff --git a/hive-sh4re/src/inbox.rs b/hive-sh4re/src/inbox.rs index 24e73dee1..a32da0e99 100644 --- a/hive-sh4re/src/inbox.rs +++ b/hive-sh4re/src/inbox.rs @@ -80,17 +80,6 @@ pub enum ReminderTiming { At { unix_timestamp: i64 }, } -/// Reminder activity statistics for an agent over a time window. -#[derive(Debug, Clone, Serialize, Deserialize)] -pub struct ReminderStats { - /// Total reminders scheduled in the window (`created_at` >= cutoff). - pub scheduled: u64, - /// Reminders that have been delivered in the window (`sent_at` IS NOT NULL). - pub delivered: u64, - /// Reminders still pending in the window (`sent_at` IS NULL). - pub pending: u64, -} - /// One row in the response to `GetLooseEnds`. Tagged enum so new /// thread kinds can land without breaking existing handlers. /// Per-flavour scoping + per-variant fields + clock-anomaly