fix: break moderation infinite re-review loop by adding 'flagged' status
Some checks failed
CI / Typecheck & Lint (pull_request) Failing after 1s

When AI flags an event, transition status to 'flagged' instead of
leaving it as 'pending'. This prevents processPending() from picking
up the same flagged events every 30-second poll cycle and burning
AI tokens indefinitely.

- Add 'flagged' to QUEUE_STATUSES enum in schema
- Set status='flagged' in autoReview() when AI flags an event
- Include flagged count in admin stats endpoint
- Add index on relay_event_queue.status for efficient queries

Fixes #27

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Alexander Whitestone
2026-03-22 20:42:13 -04:00
parent 42b8826d18
commit ce3d6ffb4d
4 changed files with 14 additions and 4 deletions

View File

@@ -0,0 +1,9 @@
-- Migration: Add 'flagged' status to relay_event_queue
-- Fixes infinite re-review loop (#27): AI-flagged events now transition to
-- status='flagged' instead of staying 'pending', so processPending() skips them.
--
-- The status column is plain TEXT (not a Postgres enum), so no ALTER TYPE is
-- needed. This migration adds an index for admin queries on flagged events.
CREATE INDEX IF NOT EXISTS idx_relay_event_queue_status
ON relay_event_queue(status);