Skip to content

A Civilization-style strategy game about governing Israel from 15 May 1948. Real ministers, real map, every fact sourced. Unity + deterministic C# sim.

Tests: a v0.3.4 gdd-0.1 save with no operation card still replays identically (#2414)

Eyal Golan13cc71eb5d7a
diff --git a/sim/Statecraft.Sim.Tests/OldSaveCompatibilityTests.cs b/sim/Statecraft.Sim.Tests/OldSaveCompatibilityTests.cs
index 572b3edee..4f725db11 100644
--- a/sim/Statecraft.Sim.Tests/OldSaveCompatibilityTests.cs
+++ b/sim/Statecraft.Sim.Tests/OldSaveCompatibilityTests.cs
@@ -25,6 +25,8 @@ public class OldSaveCompatibilityTests
// operation card replays differently now that the cards' unit orders apply under gdd-0.1, and loads with
// replay_differs. No v0.3.4 save that never touches these cards was produced, so this save checks the accepted
// outcome: it still loads, keeps its open order and warns content_changed plus replay_differs, nothing else.
+ // Then changed (3 Nov 2026, maintainer agent; the lines above are Beri's, unchanged): a v0.3.4 save that never
+ // touches these cards now exists and still replays identically (OldSaveNoOperationCardsTests).
var order = Assert.IsType<UnitOrder>(Assert.Single(loaded.Committed));
Assert.Equal((3, Orders.Fortify), (order.Unit, order.Order));
diff --git a/sim/Statecraft.Sim.Tests/OldSaveNoOperationCardsTests.cs b/sim/Statecraft.Sim.Tests/OldSaveNoOperationCardsTests.cs
new file mode 100644
index 000000000..5dd3647b7
--- /dev/null
+++ b/sim/Statecraft.Sim.Tests/OldSaveNoOperationCardsTests.cs
@@ -0,0 +1,51 @@
+using System.IO;
+using Statecraft.Sim;
+
+/// <summary>
+/// The fixture is a real gdd-0.1 save written by v0.3.4, from a game in which no operation card ever fires, so the
+/// operation cards' unit orders (#2087) cannot change its replay. Replay drift under gdd-0.1 means a v0.3.4 player's save
+/// no longer loads identically; that is a release blocker, not a fixture to regenerate.
+/// </summary>
+public class OldSaveNoOperationCardsTests
+{
+ [Fact]
+ public void V034Gdd01SaveWithNoOperationCardStillLoadsIdentically()
+ {
+ var content = ContentLoader.Load(RealContentTests.ContentRoot());
+ var repo = Directory.GetParent(RealContentTests.ContentRoot())!.FullName;
+ var path = Path.Combine(repo, "sim", "Statecraft.Sim.Tests", "saves", "v0.3.4-gdd01-noops.txt");
+ var text = File.ReadAllText(path);
+
+ var saved = SaveGame.Parse(text);
+ Assert.Equal(SaveGame.GddRuleset, saved.Ruleset);
+
+ // The operation cards: the events whose options give unit orders under gdd-0.1 (#2087). A card given unit
+ // orders later fails here, so this fixture is checked against it.
+ var operationCards = content.Events.Where(e => e.Options.Any(o => o.UnitOrders.Count > 0)).Select(e => e.Id)
+ .OrderBy(id => id, StringComparer.Ordinal).ToArray();
+ Assert.NotEmpty(operationCards);
+ Assert.Equal(
+ new[] { "latrun_proposal", "operation_hiram", "operation_horev", "operation_yoav", "ten_days" }, operationCards);
+
+ var loaded = GameSession.Load(content, text, out var warnings);
+
+ // The game is four turns, 15 May to 15 September 1948: first_truce is refused, so ten_days (which requires
+ // first_truce accept) never fires; second_truce is defied, so latrun_proposal (which requires second_truce comply)
+ // never fires; operation_yoav, operation_hiram and operation_horev open on 15 October, 31 October and 15 December
+ // 1948, after the last turn ends. So no operation card is chosen or delegated. If one fires here, a content change
+ // moved it into this game and the fixture no longer keeps clear of the operation cards' rules.
+ Assert.DoesNotContain(loaded.State.FiredEvents, operationCards.Contains);
+
+ // The replay and the open turn first: with other content, drift only adds replay_differs, so checking the
+ // warnings first would hide which part drifted.
+ // If this fails after a deliberate gdd-0.1 rule or design-value change (a golden re-pin, docs/determinism.md),
+ // v0.3.4 players' saves no longer replay identically: they load with replay_differs (GameSession.Load). That needs an
+ // owner decision, not a fixture update or deleting this test. The operation cards' unit orders (#2087) were such a
+ // decision for saves that reach those cards; this save never does, so it must still replay identically.
+ Assert.Equal(saved.FinalHash, loaded.State.Hash());
+ var order = Assert.IsType<UnitOrder>(Assert.Single(loaded.Committed));
+ Assert.Equal((3, Orders.Fortify), (order.Unit, order.Order));
+
+ Assert.Equal(new[] { GameSession.ContentChanged }, warnings);
+ }
+}
diff --git a/sim/Statecraft.Sim.Tests/saves/v0.3.4-gdd01-noops.txt b/sim/Statecraft.Sim.Tests/saves/v0.3.4-gdd01-noops.txt
new file mode 100644
index 000000000..c5fe0dfbe
--- /dev/null
+++ b/sim/Statecraft.Sim.Tests/saves/v0.3.4-gdd01-noops.txt
@@ -0,0 +1,25 @@
+statecraft-save 3
+content 162a08693f3d6873262f7006afee478d29e837435723d8edb88dde0e24c892b3
+seed 1948
+mode Historical
+ruleset gdd-0.1
+turn
+move 0 9 11
+work tel_aviv job 90
+train tel_aviv halutz 158
+turn
+move 0 8 11
+project housing haifa 6 9
+event first_truce refuse
+turn
+event second_truce defy
+capture nazareth occupy
+order 1 fortify
+turn
+dollars 1
+arms 10
+project industry haifa 7 9
+order 2 hold
+open
+order 3 fortify
+end 5fb5834e51d6fda46f5cc46a46cc0d754036feed9778f4ade558aecbfbbd7f1b