Spec queue workers that credit each sale once

Vibe codingHard25 minStripe style

Your task

Your marketplace credits a seller's balance for each completed sale. Sale events land on an Amazon SQS standard queue, and 12 Python workers read from it. Finance found 3 sellers credited twice last month, and nobody can reproduce it. A coding agent will rewrite the worker.

Write the spec you would hand the agent.

What you know:

  • each message holds sale_id, seller_id and amount_cents
  • balances live in sellers.balance_cents in Postgres, and the database stalls for up to a minute at peak
  • the queue's visibility timeout is 30 seconds
  • today's worker reads the balance, adds the amount in Python, writes it back, then deletes the message

Then, in a few sentences: what does "make each message process exactly once" miss?