src/services/exportQuota.ts implements its own small AsyncMutex class (lines 35-54) to serialize in-memory quota increments, while src/services/idempotency.ts implements a conceptually similar pendingIdempotencyRequests promise-queue mechanism for coalescing concurrent identical requests — two independent, hand-rolled implementations of "coordinate concurrent async operations in-process" living in different files with no shared utility. Beyond the duplication itself, neither implementation is exercised by a shared, dedicated concurrency-primitive test suite; each is only tested indirectly through its specific caller's tests. Extracting a single, well-tested AsyncMutex/queue utility (e.g. into src/utils/) would reduce duplicated logic and let both consumers benefit from one hardened implementation.
src/services/exportQuota.tsimplements its own smallAsyncMutexclass (lines 35-54) to serialize in-memory quota increments, whilesrc/services/idempotency.tsimplements a conceptually similarpendingIdempotencyRequestspromise-queue mechanism for coalescing concurrent identical requests — two independent, hand-rolled implementations of "coordinate concurrent async operations in-process" living in different files with no shared utility. Beyond the duplication itself, neither implementation is exercised by a shared, dedicated concurrency-primitive test suite; each is only tested indirectly through its specific caller's tests. Extracting a single, well-testedAsyncMutex/queue utility (e.g. intosrc/utils/) would reduce duplicated logic and let both consumers benefit from one hardened implementation.