Skip to main content

ralph/queue/prune/
types.rs

1//! Purpose: Shared data types for done-queue pruning operations.
2//!
3//! Responsibilities:
4//! - Define prune input options.
5//! - Define prune result reporting.
6//!
7//! Scope:
8//! - Type definitions only; no queue IO or pruning logic lives here.
9//!
10//! Usage:
11//! - Consumed by prune core logic, queue re-exports, and CLI callers.
12//!
13//! Invariants/Assumptions:
14//! - `PruneOptions` remains the stable input contract for pruning.
15//! - `PruneReport` remains the stable result contract for dry-run and live pruning.
16
17use crate::contracts::TaskStatus;
18use std::collections::HashSet;
19
20/// Result of a prune operation on the done archive.
21#[derive(Debug, Clone, Default)]
22pub struct PruneReport {
23    /// IDs of tasks that were pruned (or would be pruned in dry-run).
24    pub pruned_ids: Vec<String>,
25    /// IDs of tasks that were kept (protected by keep-last or didn't match filters).
26    pub kept_ids: Vec<String>,
27}
28
29/// Options for pruning tasks from the done archive.
30#[derive(Debug, Clone)]
31pub struct PruneOptions {
32    /// Minimum age in days for a task to be pruned (None = no age filter).
33    pub age_days: Option<u32>,
34    /// Statuses to prune (empty = all statuses).
35    pub statuses: HashSet<TaskStatus>,
36    /// Keep the N most recently completed tasks regardless of other filters.
37    pub keep_last: Option<u32>,
38    /// If true, report what would be pruned without writing to disk.
39    pub dry_run: bool,
40}