refactor(engine-ambient): wrap residual UnitTests + delete EngineSessionGate

Step 7 of multi-instancing migration. Residual SVSim.UnitTests that touch
engine code directly are wrapped in TestBattleScope. EngineSessionGate is
deleted along with the _engineOwned bookkeeping in BattleSession; engine
setup is unconditional now that per-battle state is isolated on the ambient.
Gate-specific fallback branches in BattleSession.ShadowIngest are simplified.

Suite fully green (SVSim.UnitTests, SVSim.BattleEngine.Tests).

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
gamer147
2026-06-07 22:43:18 -04:00
parent 8af1be6555
commit 9e93a7b198
6 changed files with 57 additions and 80 deletions

View File

@@ -26,9 +26,9 @@ namespace SVSim.UnitTests.BattleNode.Integration;
/// <para>Engine globals (<c>CardMaster</c>, <c>GameMgr</c>, <c>Wizard.Data</c>) are primed by
/// <c>SessionBattleEngine.Setup</c> itself (it calls <c>EngineGlobalInit.EnsureInitialized()</c>, which
/// loads the full cards.json from <c>AppContext.BaseDirectory/Data/cards.json</c>). The harness adds no
/// global init of its own. NOTE: unlike the live session, the harness does NOT acquire
/// <c>EngineSessionGate</c> — driving the engine directly bypasses it. One engine-backed battle at a
/// time is assumed within a test (the engine's process-global statics can't back two concurrently).</para>
/// global init of its own. Per-battle state is isolated via the engine's per-session
/// <c>BattleAmbientContext</c> (Task 7 of multi-instancing migration), so the historical
/// single-active-engine gate is gone — concurrent harnesses + sessions are now safe.</para>
/// </summary>
internal sealed class NodeNativeBattleHarness : IDisposable
{

View File

@@ -139,9 +139,9 @@ public class KnownListBuilderTests
[Test]
public void BuildPlayedCard_defaults_clan_to_zero_and_tribe_to_string_zero_when_caller_passes_none()
{
// A play whose engine read degraded (single-active-engine gate: _mgr null → the accessor fallback)
// emits clan 0 (ClanType.ALL ordinal) and tribe "0" (the prod no-tribe form, NEVER empty —
// empty is wire-illegal). The param defaults match the accessor fallbacks.
// A play whose engine read degraded (Setup failed and the ComputeFrames try/catch swallowed it →
// _mgr null → the accessor fallback) emits clan 0 (ClanType.ALL ordinal) and tribe "0" (the prod
// no-tribe form, NEVER empty — empty is wire-illegal). The param defaults match the accessor fallbacks.
var entry = KnownListBuilder.BuildPlayedCard(playIdx: 3, cardId: 101311010L, orderList: OrderListMove(3, 10, 20));
Assert.That(entry, Is.Not.Null);
Assert.That(entry!.Clan, Is.EqualTo(0));