You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
feat(audit): automated retention prune for audit_log entries >365d #552
Follow-up from #20 (SEC-001 Audit Trail). Phase 4 of docs/requirements/AUDIT_TRAIL_ARCHITECTURE.md listed "retention policy automation" as a checklist item. The append-only contract is already enforced by SQLite triggers (audit_log_no_update, audit_log_no_delete blocks DELETE within 365 days), but nothing prunes entries past the retention window.
Current State
audit_log table grows unbounded
DELETE within 365d → blocked by trigger
DELETE after 365d → allowed but never invoked
Requested
Daily APScheduler job that DELETEs audit_log rows older than 365 days. Trigger-aware so it only runs against the safe window.
Acceptance Criteria
New scheduled job in services/scheduler_service.py (or cleanup_service.py) running once per day
DELETEs audit_log rows where timestamp < now - 365 days
Logs prune count via structured logger
Configurable retention window via env var (AUDIT_LOG_RETENTION_DAYS, default 365)
Unit test: insert old + new rows, run prune, assert only old removed
If hash chain is enabled, prune logic preserves chain integrity (or explicitly documents the gap)
Effort
Low — ~1-2 hr. Single service edit + test.
References
Spec Phase 4: docs/requirements/AUDIT_TRAIL_ARCHITECTURE.md § Implementation Plan
Activity
feat(audit): daily retention prune for audit_log entries past 365d (#552
docs(user-docs): sync to platform state since 2026-04-23
vybe commentedon Jun 1, 2026
Shipped in v0.6.0 (released via #998).