Preserve tournament result jobs through lock contention and transient failures, atomically schedule retries before acknowledgement, and publish initial polls after releasing the preparation lock. Fix Redis connection blocking, durability Hash cleanup, duplicate auction request ordering, and scheduled-job promotion. Use native Redis 8.10 stream, lock, counter, and field-expiring cache operations with invalidation fencing. Repair 90 test type errors and add a repeatable API typecheck command. Validation: 704 API tests, 129 web tests, 31 real Redis integration tests, 3 dependency checks, workspace type checks and builds, and changed-file lint.
124 lines
4.5 KiB
TypeScript
124 lines
4.5 KiB
TypeScript
import {
|
|
AuctionHistoryEntrySchema,
|
|
AuctionSchema,
|
|
AuctionSideEffectApplicationSchema,
|
|
tournamentModelDefinitions,
|
|
} from './schema';
|
|
|
|
function indexWithKeys(
|
|
schemaIndexes: ReturnType<typeof AuctionSchema.indexes>,
|
|
expectedKeys: Record<string, 1 | -1>,
|
|
) {
|
|
return schemaIndexes.find(([keys]) => {
|
|
return JSON.stringify(keys) === JSON.stringify(expectedKeys);
|
|
});
|
|
}
|
|
|
|
describe('auction Redis schema foundation', () => {
|
|
it('defines Redis v1 projection metadata on auction documents', () => {
|
|
expect(AuctionSchema.path('revision')).toBeDefined();
|
|
expect(AuctionSchema.path('auctionEngineVersion')).toBeDefined();
|
|
expect(AuctionSchema.path('auctionLifecycleId')).toBeDefined();
|
|
expect(
|
|
AuctionSchema.path('lastAppliedAuctionStateTransitionId'),
|
|
).toBeDefined();
|
|
expect(AuctionSchema.path('currentAuctionHistorySequence')).toBeDefined();
|
|
expect(AuctionSchema.path('startAuctionRequestId')).toBeDefined();
|
|
expect(AuctionSchema.path('startAuctionStateTransitionId')).toBeDefined();
|
|
expect(AuctionSchema.path('matchSideEffectStatus')).toBeDefined();
|
|
expect(AuctionSchema.path('matchSideEffectRevision')).toBeDefined();
|
|
});
|
|
|
|
it('defines the new auction state field names for migration targets', () => {
|
|
expect(AuctionSchema.path('auctionTeams')).toBeDefined();
|
|
expect(AuctionSchema.path('auctionPlayerOrder')).toBeDefined();
|
|
expect(AuctionSchema.path('passedAuctionPlayerQueue')).toBeDefined();
|
|
expect(AuctionSchema.path('currentAuctionRound')).toBeDefined();
|
|
expect(AuctionSchema.path('currentAuctionPlayerOrderIndex')).toBeDefined();
|
|
expect(AuctionSchema.path('auctionBidHistory')).toBeDefined();
|
|
expect(AuctionSchema.path('currentHighestBidPointAmount')).toBeDefined();
|
|
expect(AuctionSchema.path('currentHighestBidderTeamIndex')).toBeDefined();
|
|
expect(
|
|
AuctionSchema.path('currentBidRoundDeadlineTimestampMS'),
|
|
).toBeDefined();
|
|
expect(AuctionSchema.path('maximumBidRoundDurationSeconds')).toBeDefined();
|
|
expect(AuctionSchema.path('bidRoundExtensionSeconds')).toBeDefined();
|
|
expect(AuctionSchema.path('initialTeamBidPointAmount')).toBeDefined();
|
|
expect(AuctionSchema.path('topTierAuctionPriorityThreshold')).toBeDefined();
|
|
expect(
|
|
AuctionSchema.path('manualTopTierAuctionPriorityUserIds'),
|
|
).toBeDefined();
|
|
expect(AuctionSchema.path('auctionStartedAtTimestampMS')).toBeDefined();
|
|
expect(AuctionSchema.path('auctionCompletedAtTimestampMS')).toBeDefined();
|
|
});
|
|
|
|
it('adds history transition fields and reset/undo action enum values', () => {
|
|
expect(
|
|
AuctionHistoryEntrySchema.path('auctionStateTransitionId'),
|
|
).toBeDefined();
|
|
expect(AuctionHistoryEntrySchema.path('auctionLifecycleId')).toBeDefined();
|
|
expect(AuctionHistoryEntrySchema.path('revision')).toBeDefined();
|
|
expect(AuctionHistoryEntrySchema.path('historyMutation')).toBeDefined();
|
|
expect(
|
|
AuctionHistoryEntrySchema.path('matchSideEffectMutation'),
|
|
).toBeDefined();
|
|
expect(AuctionHistoryEntrySchema.path('action').options.enum).toEqual(
|
|
expect.arrayContaining([
|
|
'start',
|
|
'open-bidding',
|
|
'bid',
|
|
'sold',
|
|
'passed',
|
|
'next',
|
|
'complete',
|
|
'reset',
|
|
'undo',
|
|
]),
|
|
);
|
|
});
|
|
|
|
it('adds unique history indexes for sequence and transition idempotency', () => {
|
|
const indexes = AuctionHistoryEntrySchema.indexes();
|
|
|
|
expect(
|
|
indexWithKeys(indexes, { auctionId: 1, sequence: 1 })?.[1],
|
|
).toMatchObject({
|
|
unique: true,
|
|
});
|
|
expect(
|
|
indexWithKeys(indexes, {
|
|
auctionId: 1,
|
|
auctionStateTransitionId: 1,
|
|
})?.[1],
|
|
).toMatchObject({ unique: true, sparse: true });
|
|
});
|
|
|
|
it('registers auction side effect application model with lease fields and unique idempotency index', () => {
|
|
expect(
|
|
AuctionSideEffectApplicationSchema.path('processingOwnerToken'),
|
|
).toBeDefined();
|
|
expect(
|
|
AuctionSideEffectApplicationSchema.path(
|
|
'processingLeaseExpiresAtTimestampMS',
|
|
),
|
|
).toBeDefined();
|
|
expect(
|
|
AuctionSideEffectApplicationSchema.path('payloadChecksum'),
|
|
).toBeDefined();
|
|
|
|
const indexes = AuctionSideEffectApplicationSchema.indexes();
|
|
expect(
|
|
indexWithKeys(indexes, {
|
|
auctionId: 1,
|
|
auctionStateTransitionId: 1,
|
|
sideEffectType: 1,
|
|
})?.[1],
|
|
).toMatchObject({ unique: true });
|
|
expect(
|
|
tournamentModelDefinitions.some(
|
|
(definition) => definition.name === 'auctionSideEffectApplication',
|
|
),
|
|
).toBe(true);
|
|
});
|
|
});
|