[Relay] Event Moderation Queue + Timmy AI Review #48
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
What & Why
Every post arriving at the relay goes through a moderation queue before publishing. Timmy reviews them: he auto-approves clearly benign content and flags anything ambiguous for the relay admin. Elite accounts bypass the queue entirely.
Done looks like
relay_event_queueDB table:event_id,pubkey,kind,raw_event(JSON),status(pending/approved/rejected/auto_approved),reviewed_by(timmy_ai/admin/null),review_reason,created_at,decided_atPOST /api/relay/policyupdated: whitelisted account → insert event into queue withpendingstatus → returnshadowRejectto strfry (held pending approval); approved events injected via strfry HTTP import APIModerationService:enqueue(event),autoReview(eventId)(Claude Haiku — returnsapproveorflag),decide(eventId, decision, reason)GET /api/admin/relay/queue?status=pending,POST .../approve,POST .../rejectautoReviewNote: This is the root cause of the P0 infinite re-review bug (#27) where
processPending()never transitions events out ofpending. The fix is adding a"flagged"status transition after AI flags an event.Out of scope
Tasks
relay_event_queuetable. Rundb:push.writeaccess (non-elite): insert event → returnshadowReject. Forelite: inject event → returnaccept.injectEvent(rawEvent)calling strfryPOST /importendpoint.enqueue,autoReview(Haiku call; on flag → set status toflaggednotpendingto prevent re-review loop),decide(updates DB + callsinjectEventon approval).setIntervalon startup; process up to 10pendingevents every 30 s./api/admin/relay/queue. Admin auth middleware.Relevant files
lib/db/src/schema/index.tsartifacts/api-server/src/lib/agent.tsartifacts/api-server/src/routes/index.ts