wire reminder ops into the in-agent socket dispatch (#2635 inc 1)

This commit is contained in:
damocles 2026-07-22 21:01:24 +02:00 committed by mara
commit ecd9030305
6 changed files with 178 additions and 45 deletions

View file

@ -28,6 +28,10 @@ const BASH_KEEP_SECS: i64 = 48 * 3600;
/// kinds are never deleted by this sweep — they carry the semantic per-turn
/// history the operator scrolls back through.
const STREAM_KEEP_SECS: i64 = 14 * 24 * 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.
const REMINDER_KEEP_SECS: i64 = 14 * 24 * 3600;
/// Terminal bash-task statuses whose files are eligible for deletion.
const TERMINAL_STATUSES: &[&str] = &["done", "timed_out", "interrupted"];
@ -60,6 +64,24 @@ fn sweep_once() {
Err(e) => tracing::warn!(error = ?e, "events vacuum failed"),
}
}
let reminders_db = crate::paths::reminders_db();
if reminders_db.exists() {
match vacuum_reminders(&reminders_db) {
Ok(0) => {}
Ok(n) => tracing::info!(removed = n, "reminders vacuum"),
Err(e) => tracing::warn!(error = ?e, "reminders vacuum failed"),
}
}
}
/// Reap delivered reminder rows older than [`REMINDER_KEEP_SECS`] via the
/// typed store API (own short-lived connection — mirrors `vacuum_events`'s
/// own connection to `events.sqlite` rather than sharing the harness's live
/// `Reminders` handle).
fn vacuum_reminders(path: &Path) -> anyhow::Result<usize> {
let store = crate::reminders::Reminders::open(path)?;
store.prune_delivered_older_than(now_unix() - REMINDER_KEEP_SECS)
}
/// Delete eligible bash-task trios in `dir`. Returns the count of `.json`