feat(engine-ambient): delete static fallbacks; add MultiInstanceEngineTests

Step 8 (final) of multi-instancing migration. All per-battle statics now
require a BattleAmbient scope — unwrapped writes throw InvalidOperationException
(fail-fast forcing function). MultiInstanceEngineTests proves correctness:
two parallel battles resolve independently, N=4/8/16 stress matches sequential
baseline, GameMgr.GetIns throws without scope.

Migration complete. EngineSessionGate gone. Suite fully green.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
gamer147
2026-06-07 23:19:37 -04:00
parent 9e93a7b198
commit c789d836f1
15 changed files with 449 additions and 131 deletions

View File

@@ -176,16 +176,16 @@ public static class Data
public static ReplayDetailInfo ReplayBattleInfo { get; set; }
private static BattleRecoveryInfo _battleRecoveryInfoFallback;
public static BattleRecoveryInfo BattleRecoveryInfo
{
get => SVSim.BattleEngine.Ambient.BattleAmbient.Current?.RecoveryInfo ?? _battleRecoveryInfoFallback;
set
{
var c = SVSim.BattleEngine.Ambient.BattleAmbient.Current;
if (c != null) c.RecoveryInfo = value;
else _battleRecoveryInfoFallback = value;
}
// Soft read: returns null when no scope is active. The MulliganMgrBase.StartDeal call site
// reads this with a null-tolerant ??=-style pattern, so a null degrade is the historical
// fallback. Inside a scope, returns the per-session RecoveryInfo (SessionBattleEngine
// pre-seeds an uninitialized BattleRecoveryInfo on its ctx field initializer).
get => SVSim.BattleEngine.Ambient.BattleAmbient.Current?.RecoveryInfo;
// Strict setter: writes must land on the per-session ctx. No historical production caller
// writes this outside a scope; an unwrapped write now fails fast (forcing function).
set => SVSim.BattleEngine.Ambient.BattleAmbient.Require().RecoveryInfo = value;
}
public static VoteData VoteInfo { get; set; }