Scope generation idempotency keys per user instead of globally #8

Open
opened 2026-03-10 14:40:54 +03:00 by sirily · 0 comments
Owner

Problem
packages/db/prisma/schema.prisma makes GenerationRequest.idempotencyKey globally unique even though reuse checks in packages/db/src/generation-store.ts are user-scoped.

Why this matters
Two different users can collide on the same idempotency key and trigger a server error or cross-tenant contention on a field that should only be unique within a user scope.

Acceptance criteria

  • Replace the global unique constraint with a per-user uniqueness rule.
  • Keep idempotency lookup and reuse logic aligned with the schema.
  • Add migration coverage for existing nullable rows and regression tests for cross-user collisions.
Problem `packages/db/prisma/schema.prisma` makes `GenerationRequest.idempotencyKey` globally unique even though reuse checks in `packages/db/src/generation-store.ts` are user-scoped. Why this matters Two different users can collide on the same idempotency key and trigger a server error or cross-tenant contention on a field that should only be unique within a user scope. Acceptance criteria - Replace the global unique constraint with a per-user uniqueness rule. - Keep idempotency lookup and reuse logic aligned with the schema. - Add migration coverage for existing nullable rows and regression tests for cross-user collisions.
Sign in to join this conversation.
No Label
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: sirily/nroxy#8