Data-retention purge: deletes TERMINAL runs (success/failed/tripwire/
canceled/bailed/skipped) whose updatedAt is older than the TTL from
mastra_workflow_snapshot — and, when artifactStore is wired, each purged
run's R2 artifacts with its row. Live runs (running/suspended/waiting/
pending/paused) are never touched — expiring a suspended run would kill a
pending approval. A missing snapshot table reads as zero purgeable runs
(Mastra creates it lazily with the first persisted run). TTL enforcement
is a storage-layer property, so it lives here; scheduling (Worker cron /
DO alarm) stays with the caller. Returns the number of deleted rows.
Data-retention purge: deletes TERMINAL runs (success/failed/tripwire/ canceled/bailed/skipped) whose updatedAt is older than the TTL from mastra_workflow_snapshot — and, when
artifactStoreis wired, each purged run's R2 artifacts with its row. Live runs (running/suspended/waiting/ pending/paused) are never touched — expiring a suspended run would kill a pending approval. A missing snapshot table reads as zero purgeable runs (Mastra creates it lazily with the first persisted run). TTL enforcement is a storage-layer property, so it lives here; scheduling (Worker cron / DO alarm) stays with the caller. Returns the number of deleted rows.