refactor(matching): extend PairUpResult with IsAiFallback flag

Pure shape change ahead of Phase 3 AI-fallback wiring — all current
callers pass IsAiFallback: false. TK2 will always emit false (PvpOnly
policy); rank-battle's PvpFirstThenAiFallback branch sets true after
the threshold elapses.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
gamer147
2026-06-02 00:57:25 -04:00
parent d7bb44973a
commit 3866c93065
2 changed files with 9 additions and 3 deletions

View File

@@ -34,5 +34,11 @@ public interface IMatchingPairUpService
/// nothing else in TK2/ranked reads. We send the split anyway for prod fidelity in
/// case a future flow (rematch UI, private rooms grafted on top) starts consuming it.
/// </para>
/// <para>
/// <see cref="IsAiFallback"/> is true when the resolution came from the
/// <c>PvpFirstThenAiFallback</c> policy expiring its threshold — caller is paired
/// with a silent NoOpBotParticipant. Maps to matching_state 3011
/// (AI_BATTLE_MATCHING_SUCCEEDED). Always false for PvpOnly modes (TK2).
/// </para>
/// </summary>
public sealed record PairUpResult(PendingMatch Match, bool IsOwner);
public sealed record PairUpResult(PendingMatch Match, bool IsOwner, bool IsAiFallback);

View File

@@ -28,7 +28,7 @@ public sealed class InProcessPairUp : IMatchingPairUpService
if (slot.Resolved.TryGetValue(player.ViewerId, out var cached))
{
slot.Resolved.Remove(player.ViewerId);
return Task.FromResult<PairUpResult?>(new PairUpResult(cached, IsOwner: true));
return Task.FromResult<PairUpResult?>(new PairUpResult(cached, IsOwner: true, IsAiFallback: false));
}
// 2. Someone already waiting in this slot? Pair with them.
@@ -46,7 +46,7 @@ public sealed class InProcessPairUp : IMatchingPairUpService
var match = _bridge.RegisterBattle(p1, p2, BattleType.Pvp);
// Cache the result for the FIRST arriver's next poll (consume-on-read).
slot.Resolved[p1.ViewerId] = match;
return Task.FromResult<PairUpResult?>(new PairUpResult(match, IsOwner: false));
return Task.FromResult<PairUpResult?>(new PairUpResult(match, IsOwner: false, IsAiFallback: false));
}
// 3. Empty slot — park this caller.