fix(auction): harden lifecycle and durable bid storage

Serialize lifecycle changes and make cancellation, deadlines, and match side effects recoverable and idempotent.

Archive accepted bids durably, quarantine invalid payloads, and preserve compatibility with empty round IDs. Synchronize HTTP polling and socket state with scoped resync events.

Add cancellation cleanup index migration and regression coverage. Validated with 744 API tests, 65 Redis integration tests, and 28 Mongo integration tests.
This commit is contained in:
dahyeon committed 2026-11-09 23:24:11 +09:00
1 parent f2eec479d9
commit f649490cd2
55 files changed
+5374 -522

No files matched your search

@@ -9,6 +9,7 @@ import {
Param,
Post,
UseGuards,
Query,
} from '@nestjs/common';
import mongoose from 'mongoose';
import { AllowPublicAccess } from '../auth/allow-public-access.decorator';
@@ -19,6 +20,7 @@ import { ParseObjectIdPipe } from '../common/parse-object-id.pipe';
import type { UserDocument } from '../global/database/schema';
import { AuctionService } from './auction.service';
import { AuctionGateway } from './auction.gateway';
import { AuctionBidArchiveService } from './auction-bid-archive.service';
import {
NextAuctionDto,
OpenBiddingDto,
@@ -35,6 +37,7 @@ export class AuctionController {
constructor(
private readonly auctionService: AuctionService,
private readonly auctionGateway: AuctionGateway,
private readonly auctionBidArchiveService: AuctionBidArchiveService,
) {}
@Post()
@@ -78,6 +81,20 @@ export class AuctionController {
}
// 공개 — 팀장 2명만 쓸 엔드포인트(트러스트 기반, 10명 동시 관전).
@Get('bids/history')
@AllowPublicAccess()
public async getBidHistory(
@Param('matchId', ParseObjectIdPipe) matchId: mongoose.Types.ObjectId,
@Query('afterRevision') afterRevision?: string,
@Query('limit') limit?: string,
) {
return this.auctionBidArchiveService.list(
matchId,
afterRevision === undefined ? -1 : Number(afterRevision),
limit === undefined ? 100 : Number(limit),
);
}
@Post('open-bidding')
@AllowPublicAccess()
@HttpCode(HttpStatus.OK)
@@ -100,6 +117,7 @@ export class AuctionController {
teamIndex: body.bidderTeamIndex,
amount: body.bidPointAmount,
bidRequestId: body.bidRequestId,
clientObservedBidRoundId: body.clientObservedBidRoundId,
clientObservedAuctionLifecycleId: body.clientObservedAuctionLifecycleId,
clientObservedCurrentBidRoundPlayerUserId:
body.clientObservedCurrentBidRoundPlayerUserId,
@@ -213,7 +231,10 @@ export class AuctionController {
clientObservedPhase: body.clientObservedPhase,
clientObservedRevision: body.clientObservedRevision,
});
this.auctionGateway.broadcastReset(matchId.toString());
this.auctionGateway.broadcastReset(
matchId.toString(),
body.clientObservedAuctionLifecycleId,
);
}
private assertSameCommunity(