feat: lazy retention sweep on /web/cases

New module retention::sweep_user_retention is invoked at the top of
handle_my_cases, using the current user's retention policy. Per case:
step 1 auto-closes when the newest .m4a mtime is older than
auto_close_days; step 2 auto-purges when closed_at is older than
auto_delete_days. Order matters - a case auto-closed in the same sweep
has closed_at ~= now and naturally survives the purge check,
preserving the full grace period after a vacation.

Race guard: purge re-reads the close marker immediately before
remove_dir_all so a concurrent upload that reopens the case cancels
the purge. Every automatic action emits an info! line with reason and
threshold; failures warn but never abort the sweep.

Seven integration tests cover both threshold paths, the disable-via-0
escape hatch, the newest-recording rule, the vacation scenario, and
the open-case skip. Tests age the comparison objects (mtime via
filetime, closed_at as handwritten RFC3339) instead of faking "now" -
no clock abstraction needed.
This commit is contained in:
2026-04-21 10:51:27 +02:00
parent e5a62d8f10
commit f358da215d
4 changed files with 469 additions and 0 deletions
+1
View File
@@ -8,6 +8,7 @@ pub mod gazetteer;
pub mod magic_link;
pub mod models;
pub mod paths;
pub mod retention;
pub mod routes;
pub mod transcribe;
pub mod web_session;