Build delayed microsync drain worker

A Sidekiq worker that consumes outbox messages after a deliberate ~1 minute delay, by which point any concurrent racing writes in Rails have settled.

It handles a message based on its event_type:

  • Upsert: read current state from Rails, diff against the upstream store, write the delta. Skip if Rails has no row (a delete event handles removal).
  • Delete: remove the upstream row using the payload's identifying fields. Rails is not read.

A separate worker runs per target store (L0, L2), each tracking reconciliation state independently. Concurrent rows for the same (entity_type, entity_id, event_type) collapse into one execution via Sidekiq deduplication.

Edited by 🤖 GitLab Bot 🤖