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
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
Context
Follow-up from #20 (SEC-001 Audit Trail). Phase 4 of
docs/requirements/AUDIT_TRAIL_ARCHITECTURE.mdlisted "retention policy automation" as a checklist item. The append-only contract is already enforced by SQLite triggers (audit_log_no_update,audit_log_no_deleteblocks DELETE within 365 days), but nothing prunes entries past the retention window.Current State
audit_logtable grows unboundedRequested
Daily APScheduler job that DELETEs
audit_logrows older than 365 days. Trigger-aware so it only runs against the safe window.Acceptance Criteria
services/scheduler_service.py(orcleanup_service.py) running once per dayaudit_logrows wheretimestamp < now - 365 daysAUDIT_LOG_RETENTION_DAYS, default 365)Effort
Low — ~1-2 hr. Single service edit + test.
References
docs/requirements/AUDIT_TRAIL_ARCHITECTURE.md§ Implementation Plansrc/backend/db/schema.py:911