GPT-5 finding
Seed script ‘idempotent’ claim is undermined by TOCTOU race; unique violation not handled
- apps/web/scripts/seed-outgoing-pr.ts:1-17
- apps/web/scripts/seed-outgoing-pr.ts:54-94
The script performs a separate existence check before insert. Two concurrent invocations with identical args can both pass the check and then collide on the unique constraint, causing one to crash. This violates the practical idempotency guarantee under concurrency.
Recommendation
Make the insert atomic with ON CONFLICT DO NOTHING/DO UPDATE (or catch unique-violation errors and treat as a no-op). For example, use drizzle’s onConflictDoNothing().returning() and handle the empty return as ‘already exists’.