harness todos: ack reconciled todos instead of deleting them
This commit is contained in:
parent
ef1554a1b2
commit
8a81085770
3 changed files with 233 additions and 27 deletions
|
|
@ -32,6 +32,12 @@ const STREAM_KEEP_SECS: i64 = 14 * 24 * 3600;
|
|||
/// 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;
|
||||
/// 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
|
||||
/// enough that a genuinely quiet month is the only way to trigger the "one
|
||||
/// spurious re-announcement" fallback path, short enough the table doesn't
|
||||
/// grow meaningfully from one-shot todos that will never be upserted again.
|
||||
const TODO_ACKED_KEEP_SECS: i64 = 30 * 24 * 3600;
|
||||
/// Terminal bash-task statuses whose files are eligible for deletion.
|
||||
const TERMINAL_STATUSES: &[&str] = &["done", "timed_out", "interrupted"];
|
||||
|
||||
|
|
@ -72,6 +78,11 @@ fn sweep_once() {
|
|||
Ok(n) => tracing::info!(removed = n, "reminders vacuum"),
|
||||
Err(e) => tracing::warn!(error = ?e, "reminders vacuum failed"),
|
||||
}
|
||||
match vacuum_todos(&state_db) {
|
||||
Ok(0) => {}
|
||||
Ok(n) => tracing::info!(removed = n, "todos vacuum"),
|
||||
Err(e) => tracing::warn!(error = ?e, "todos vacuum failed"),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -84,6 +95,13 @@ fn vacuum_reminders(path: &Path) -> anyhow::Result<usize> {
|
|||
store.prune_delivered_older_than(now_unix() - REMINDER_KEEP_SECS)
|
||||
}
|
||||
|
||||
/// Reap acked todo rows older than [`TODO_ACKED_KEEP_SECS`] via the typed
|
||||
/// store API — same own-short-lived-connection shape as `vacuum_reminders`.
|
||||
fn vacuum_todos(path: &Path) -> anyhow::Result<usize> {
|
||||
let store = crate::todos::Todos::open(path)?;
|
||||
store.reap_acked(now_unix() - TODO_ACKED_KEEP_SECS)
|
||||
}
|
||||
|
||||
/// Delete eligible bash-task trios in `dir`. Returns the count of `.json`
|
||||
/// sentinels removed (each represents one task; `.out`/`.err` deletions are
|
||||
/// not counted separately).
|
||||
|
|
|
|||
Loading…
Reference in a new issue