[Ops] Unify bot event delivery with at-least-once semantics and idempotency #81
Loading…
Reference in a new issue
No description provided.
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?
Context
Backend→bot event delivery is split across three mechanisms with different reliability:
session_reminders_sentdedup.session_proposedgoes HTTP-first to the bot's/notifyendpoint (_post_bot_notification,webapp/backend/app/tasks/reminder_tasks.py:55-69) with Redis pub/sub as fallback.session_summarised,session_completed,vote_update,session_summary_approvedare pub/sub-only: published viapublish_bot_event/publish_bot_event_async(webapp/backend/app/services/bot_pubsub.py:29-46), consumed bylisten_for_bot_notifications(bot/questboard_bot/services/redis_bus.py:42-72), dispatched toon_bot_notify(bot/questboard_bot/cogs/notifications.py:155).Current behavior
Two failure modes:
reminder_tasks.py:62-67). If the bot posts the embed but the response is lost/slow, the backend falls back to pub/sub and the bot posts the same embed twice. Theon_bot_notifydispatcher has no idempotency key.Fix / Spec
qb:bot:events) plus a consumer group:XADDs every event; bot consumes viaXREADGROUP, ACKs (XACK) only after the handler completes.MAXLEN ~) so it cannot grow forever.event_idUUID stamped at publish time.event_ids;on_bot_notifyskips any id already present.session_proposed,session_summarised,session_completed,vote_update,session_summary_approved) onto this one mechanism and delete the per-type divergence. The HTTP-first/notifypath may remain as a latency optimization, but it must carry the sameevent_idso the stream copy is deduplicated.recording:{guild_id}, seeredis_bus.py:16-39) as plain pub/sub — ephemeral status is fine to lose.Acceptance criteria
event_idis ignored by the bot (logged at debug, no second Discord post).References
webapp/backend/app/services/bot_pubsub.py:29-46webapp/backend/app/tasks/reminder_tasks.py:55-69bot/questboard_bot/services/redis_bus.py:42-72bot/questboard_bot/cogs/notifications.py:155Filed from the July 2026 full-project review.