Repository navigation
fix(coordinator): commit invite redemption and credit atomically - #948
Gajesh2007 wants to merge 2 commits into
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
@codex review |
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
Consolidated into #1056 for review and merge after #1094, #1095 and #1096. #1056 contains this branch's exact head ( |
Invite redemption currently commits the claim and use count before crediting the account. If the separate balance write fails, the consumer gets 500 with no balance, but the code is already consumed and a retry is rejected.
RedeemInviteCodenow commits the claim, use count, non-withdrawable balance and ledger entry together: one memory lock or the existing PostgreSQL transaction. The API no longer performs a second credit. The existing credit-failure 500 response is retained throughErrInviteCredit; eligibility and duplicate failures retain their current responses.flowchart LR subgraph Before A[handleRedeemInviteCode] --> B[RedeemInviteCode commits claim and use count] B --> C[Separate Store.Credit] C -->|Failure| D[500, no credit, code consumed] C -->|Success| E[200 with balance] end subgraph After F[handleRedeemInviteCode] --> G[RedeemInviteCode locks and validates code] G --> H[Claim, count, creditBalance or creditLocked, ledger] H -->|Commit| I[200 with balance] H -->|Credit failure| J[Rollback claim and balance, 500, retry allowed] endValidation:
claimed=true, balance 0 and 500. It passes after the change and confirms there is no standalone credit call, duplicate redemption remains rejected and invite credit is not withdrawable.The transaction prevents new partial redemptions. It does not retroactively repair previously consumed codes whose old credit failed.