caelum0x f3917aad16 fix(game-economy): an abandoned cosmetic/pass reservation no longer blocks the player forever
A single-owner reservation outlived its purchase when the purchase failed and
the release did not land (a storage error) or the process died: nothing ever
expired it, so the player could never buy that cosmetic or pass again.

A reservation held longer than the TTL (GAME_RESERVATION_TTL_SECS, default 15
minutes) by a purchase that never completed is now taken over by a new
purchase, but only after Mint proves the old purchase can never charge: its
hold is opened (if it never was) and released under the old purchase's own
keys. If that hold was already captured, the old purchase paid and stays
reserved for its same-key retry. Takeover is a compare-and-swap on the holder
(Postgres UPDATE ... WHERE idem_key = old).

Tests: core abandoned_reservation (takeover charges once and the old key can
no longer capture; a recent reservation still blocks and touches nothing; a
paid old purchase keeps it and completes on retry), and the first live
Postgres tests of the adapter (exclusive reservations, holder-only moves,
8 concurrent takeovers -> one winner). 104 passed.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-06 15:44:41 +03:00
..