feat(match): atomic exactly-once match-completion transaction

Add complete_match: one BEGIN/COMMIT that validates identity + result,
enforces a durable (profile_id, match_identity) uniqueness guard
(migration 0022 match_completions), persists match history, and grants
coins + XP/level-ups + W/D/L/DNF statistics + objectives + achievements
exactly once. Any failure rolls the whole match back (no compensating
cleanup). Handles sequential/restart/concurrent replay, conflicting
re-report (first result canonical), DNF (loss economics, own stat
bucket) and no-contest (zero economic effect).

Adds tx-scoped variants: statistics::record_match_tx/
record_position_goals_tx, objective::increment_metric_tx,
achievement::check_and_unlock_tx. New MatchResultKind/CompleteMatchRequest/
MatchCompletionResult models + POST /matches/complete route.
This commit is contained in:
funman300
2026-08-20 16:38:16 +00:00
parent a034e74c16
commit b0306a9b1d
9 changed files with 1284 additions and 5 deletions
+2
View File
@@ -7,6 +7,7 @@ pub struct Statistics {
pub matches_won: i64,
pub matches_drawn: i64,
pub matches_lost: i64,
pub matches_dnf: i64,
pub goals_scored: i64,
pub goals_conceded: i64,
pub packs_opened: i64,
@@ -25,6 +26,7 @@ impl Statistics {
matches_won: 0,
matches_drawn: 0,
matches_lost: 0,
matches_dnf: 0,
goals_scored: 0,
goals_conceded: 0,
packs_opened: 0,