Retention, erasure and audit

What the stores keep, how to delete what you no longer may keep, and what the audit trail records about it.

The in-memory store forgets: terminal tasks expire after task_ttl (one hour by default). The SQL stores keep every task until you say otherwise. Call purge_expired(&RetentionPolicy::new(max_age)) on a concrete store from your own scheduler; it deletes only Completed, Failed, Canceled and Rejected tasks, in batches, and is safe to run from several replicas (Running More Than One Replica).

A task that runs for a long time also grows its event log for as long as it runs: those rows go only when the finished task is purged. With .with_max_events_per_live_task(Some(n)) the same sweep compacts each live task's log to its newest n events, dropping only events the stored task already reflects (ADR 0047). A subscriber that asks to resume from a dropped position receives the task's snapshot instead, as a subscriber that fell behind does, never a replay with a silent gap. The in-memory store bounds its logs itself (TaskStoreConfig::max_events_per_task).

The tenant-aware stores also have erase_caller(identity), which removes a caller's partitions with their tasks, logged events and idempotency keys (the push-config stores, its webhooks); the SQL stores do it in one transaction. migrate_caller_keys(map) (SQLite and PostgreSQL, task and push-config stores) moves partitions stored under the bare caller names earlier releases used to bearer:<label>, api-key:<label> or jwt:<issuer>:<sub>; run it once per store before serving 0.15 (Upgrading).

With audit, a task deleted through the audited task store is recorded in the hash chain. purge_expired and erase_caller are calls you make outside any request, so you report what they returned yourself (Audit Trail). With encryption, store::encrypted::EncryptedTaskStore seals the parts of a task's history, status message and artifacts before they reach the wrapped store.