Postgres job queue with dead letters

The idea

Background work is stored as job rows, claimed with leases and heartbeats, and retried with backoff. A job that keeps failing stays as a dead letter for 30 days.

The problem
Work must survive crashes without a separate queue service, and failures must not disappear.
Why it matters
Another process picks up a crashed job, each org gets a fair share, and an admin can replay a dead job.
Where it stands
In production as of

A step-by-step replay of this idea is not published yet. The library adds one when a recorded run shows it.

  • Background leader lock

    Only the process that holds a Postgres advisory lock runs background work. Other processes serve requests as warm standbys.

  • Front-door fast path and lane

    Status questions get answers from runtime state through templates, with no model, and a receipt goes out before any model call. A separate job lane serves what a person waits on, and casual consumer chat starts no work.

Turn the numbers into shipped work.

Crewshal runs these choices for you: a persistent AI worker with memory and rules, on your Claude and Codex subscriptions.