Spec a Postgres job runner for concurrent workers

Vibe codingHard30 minStripe style

Your task

Your Python app ships as a single deployable with Postgres and nothing else, and adding Redis or a message broker is not allowed. You need background jobs: sending emails, building PDFs and syncing records to a CRM. An agent will build a job runner with retries and several workers running at once.

Write the build spec you would hand the agent: how workers claim jobs, how retries and failures work, and the acceptance checks.

What you know:

  • Python 3.12, psycopg 3 and Postgres 15
  • 4 to 8 worker processes, spread over 2 machines
  • most jobs take under 10 seconds, and PDF jobs take up to 3 minutes
  • workers are killed during every deploy
  • the CRM sync creates records through the CRM's API

Then, in a few sentences: what does "build a job queue on Postgres" get wrong about concurrency?