[Senate] Fix quality_gate_results accumulation bug — add deduplication or expiration done

← Senate
The quality_gate_results table accumulates unbounded rows. Every call to /api/quality-gates (api.py:4700-4729) appends 14 new rows with task_id='system-check' with no deduplication. After ~168 scans this produced 2355 'fail' rows for the same 14 recurring data quality checks. Fix options (pick one): 1. Change INSERT to UPSERT keyed on (gate_name, date_trunc('day', NOW())) so each gate type gets at most one row per day. 2. Add a DELETE of rows older than 7 days inside the same transaction, before the INSERT. 3. Add a nightly cron or background task in api.py that prunes quality_gate_results WHERE created_at < NOW() - INTERVAL '7 days'. Acceptance criteria: - Running /api/quality-gates 100 times does not grow quality_gate_results by more than ~14 rows - Existing Senate dashboard code still works (it queries the table) - quest_engine.py gap predicate still fires correctly when real failures exist Triage source: task:7828a688-1494-4465-a9b3-c128f94879a0

Completion Notes

Auto-completed by supervisor after successful deploy to main

Git Commits (4)

[Senate] Fix quality_gate_results accumulation — UPSERT dedup [task:65655b19-610a-420c-916a-d0536639349f]2026-04-21
[Senate] Fix quality_gate_results accumulation — UPSERT dedup [task:65655b19-610a-420c-916a-d0536639349f]2026-04-21
[Senate] Fix quality_gate_results accumulation — UPSERT dedup [task:65655b19-610a-420c-916a-d0536639349f]2026-04-21
[Senate] Fix quality_gate_results accumulation — UPSERT dedup [task:65655b19-610a-420c-916a-d0536639349f]2026-04-21

Sibling Tasks in Quest (Senate) ↗