destroy verb: CLI + admin socket + dashboard button; purges state + approvals

This commit is contained in:
müde 2026-05-15 02:57:22 +02:00
parent c7b50aa5b7
commit b711296460
8 changed files with 92 additions and 4 deletions

View file

@ -132,6 +132,18 @@ impl Approvals {
)?;
Ok(())
}
/// Mark every pending approval for `agent` as failed (returns rows affected).
/// Used by `destroy` to clear the queue of an agent that no longer exists.
pub fn fail_pending_for_agent(&self, agent: &str, note: &str) -> Result<usize> {
let conn = self.conn.lock().unwrap();
let n = conn.execute(
"UPDATE approvals SET status = 'failed', resolved_at = ?1, note = ?2
WHERE agent = ?3 AND status = 'pending'",
params![now_unix(), note, agent],
)?;
Ok(n)
}
}
fn row_to_approval(row: &rusqlite::Row<'_>) -> rusqlite::Result<Approval> {