Skip to content

feat: Data retention policy with automated purge (UU PDP compliance) #296

Description

@ajianaz

What

Add configurable data retention policy with automated event purging.

Why

BMAD CLO finding: Error events accumulate indefinitely by default. Under UU PDP Article 16, retention must be purpose-limited and time-bound. Self-hosted users also need this to prevent unbounded storage growth.

Changes

  1. Config option: TRAPFALL_RETENTION_DAYS=30 (default: 30 days, 0 = unlimited)
  2. Automated purge task: Background task (tokio interval) that runs daily and deletes events older than retention period
  3. Per-project override: Allow retention_days column in projects table for per-project customization
  4. Purge logging: Log purge counts for observability
  5. Graceful handling: Don't purge events linked to open alert rules (optional, can defer)
  6. Migration: Add retention_days column to projects table (nullable, falls back to global config)

Testing

  • Unit test: events older than retention → purged
  • Unit test: events within retention → preserved
  • Unit test: per-project override takes precedence over global config
  • Integration test: purge task runs without affecting concurrent queries

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions