A Civilization-style strategy game about governing Israel from 15 May 1948. Real ministers, real map, every fact sourced. Unity + deterministic C# sim.
Unity shareable gate: refuse unsigned alternate cards and omitted review keys (#2610) (#2637)
Eyal Golanbc1c7d060bc9
diff --git a/changelog.d/2610.md b/changelog.d/2610.mdnew file mode 100644index 000000000..e21c1ca23--- /dev/null+++ b/changelog.d/2610.md@@ -0,0 +1,3 @@+### Fixed++- Refused Unity shareable builds when alternate cards lack a person's sign-off or settlement-control review keys are omitted.diff --git a/docs/m3-release.md b/docs/m3-release.mdindex b16f14d77..2de9510a0 100644--- a/docs/m3-release.md+++ b/docs/m3-release.md@@ -285,11 +285,12 @@ war-casualties). The owner's sign-off for all seven events below is recorded insensitive event photograph (`docs/event-images.md`). Use `-shareable` and the script for every buildthat leaves this machine, including the M4 private Draft once it is shared with anyone. Local dev builds (no flag)are not gated, because web_check and the golden checks need them.-- **Alternate-timeline content (R-ALT-011, Q-ALT-9):** `Statecraft.Cli --release-gate`, and so- `tools/package_release.py` and `scripts/oss/release_gate.sh`, also refuse while any consequence card (`kind:- consequence`) or any event with `variants` has no `reviewed_by`, naming them on a `RELEASE GATE REFUSED` line- (`Statecraft.Sim.ReleaseGate.AlternateUnsigned`; the CLI also prints each as `unsigned alternate card: <id>`). The- sign-off is a person's `reviewed_by`, written only by that person. The Unity `-shareable` build flag checks the sensitive events only.+- **Alternate-timeline content (R-ALT-011, Q-ALT-9):** Unity player builds made with `-shareable` and+ `Statecraft.Cli --release-gate`, and therefore `tools/package_release.py` and `scripts/oss/release_gate.sh`, refuse+ while any consequence card (`kind: consequence`) or any event with `variants` has no `reviewed_by`, naming them+ (`Statecraft.Sim.ReleaseGate.AlternateUnsigned`): Unity on its `BUILD REFUSED` line, the CLI on a `RELEASE GATE REFUSED`+ line, and the CLI also prints each as `unsigned alternate card: <id>`. The+ sign-off is a person's `reviewed_by`, written only by that person.- **Pinned set:** `FinalWaveTests.TheSensitiveEventsArePinned` lists the twelve ids, and`TheOwnerTableListsEverySensitiveEvent` fails if a sensitive event is missing from this table, so a new one cannotskip the review.diff --git a/unity/Assets/Editor/Build.cs b/unity/Assets/Editor/Build.csindex b42d1c35c..efcd23c9d 100644--- a/unity/Assets/Editor/Build.cs+++ b/unity/Assets/Editor/Build.cs@@ -55,7 +55,8 @@ namespace Statecraft.Game.EditorTools};/// <summary>Why a shareable build may not be made, or null: every event with a sensitive tag needs the owner's- /// sensitivity review first (status sensitivity-reviewed; docs/m3-release.md, M3 final review I4), every row the+ /// sensitivity review first (status sensitivity-reviewed; docs/m3-release.md, M3 final review I4), every consequence+ /// card and event with variants needs a person's reviewed_by (ReleaseGate.AlternateUnsigned; R-ALT-011), every row the/// starting forces come from must be fact-checked (ReleaseGate.StartingForcesUnchecked; R-UNIT-006), every settlement/// target row sensitivity-reviewed (ReleaseGate.SettlementTargetsUnchecked; Q-TGT-3 (b)), and so does every/// sensitive event photograph the build would carry (EventImageCatalog; docs/event-images.md), and every sensitive@@ -70,6 +71,10 @@ namespace Statecraft.Game.EditorToolsvar reasons = new List<string>();if (open.Count > 0)reasons.Add("a shareable build needs the owner's sensitivity review of: " + string.Join(", ", open) + " (set status: sensitivity-reviewed; see docs/m3-release.md)");+ // R-ALT-011, Q-ALT-9: every alternate card needs a person's sign-off before it may be shared.+ if (Statecraft.Sim.ReleaseGate.AlternateUnsigned(c) is { Count: > 0 } unsigned)+ reasons.Add("a shareable build needs a person's reviewed_by for these alternate cards: "+ + string.Join(", ", unsigned) + " (see docs/m3-release.md)");// R-UNIT-006, Q-START-3 (#743): the rows a new game starts a unit from are game state, so a person checks them first.if (Statecraft.Sim.ReleaseGate.StartingForcesUnchecked(c) is { Count: > 0 } forces)reasons.Add("a shareable build needs these starting forces' rows fact-checked: " + string.Join(", ", forces)diff --git a/unity/Assets/Editor/SettlementControlStringReview.cs b/unity/Assets/Editor/SettlementControlStringReview.csindex 69a13e730..13e2eb98c 100644--- a/unity/Assets/Editor/SettlementControlStringReview.cs+++ b/unity/Assets/Editor/SettlementControlStringReview.cs@@ -23,6 +23,13 @@ namespace Statecraft.Game.EditorToolspublic string Status { get; set; } = "";public List<Row> Strings { get; set; } = new List<Row>();+ /// <summary>Whether a UI key is part of R-GATE-002's settlement-control review surface.</summary>+ public static bool IsSettlementControlKey(string key) =>+ key.StartsWith("capture.", StringComparison.Ordinal)+ || key.StartsWith("map.control.", StringComparison.Ordinal)+ || key.StartsWith("info.control.", StringComparison.Ordinal)+ || key == "hud.standing_displaced_places";+/// <summary>Parses a review manifest, rejecting malformed YAML and unknown fields with the file name.</summary>public static SettlementControlStringReview Parse(string yaml, string file){@@ -52,6 +59,15 @@ namespace Statecraft.Game.EditorToolsvar repeated = review.Strings.GroupBy(x => x.Key, StringComparer.Ordinal).FirstOrDefault(x => x.Count() > 1);if (repeated != null)return "the settlement-control strings review has repeated key '" + repeated.Key + "'";+ var reviewed = new HashSet<string>(review.Strings.Select(x => x.Key), StringComparer.Ordinal);+ var omitted = en.Keys.Concat(he.Keys)+ .Where(IsSettlementControlKey)+ .Distinct(StringComparer.Ordinal)+ .Where(x => !reviewed.Contains(x))+ .OrderBy(x => x, StringComparer.Ordinal)+ .FirstOrDefault();+ if (omitted != null)+ return "the settlement-control strings review is missing settlement-control key '" + omitted + "'";foreach (var row in review.Strings){if (!en.Has(row.Key)) return "strings.en.yaml is missing settlement-control key '" + row.Key + "'";diff --git a/unity/Assets/Scripts/UI/UiText.cs b/unity/Assets/Scripts/UI/UiText.csindex d58312536..157bf1d5a 100644--- a/unity/Assets/Scripts/UI/UiText.cs+++ b/unity/Assets/Scripts/UI/UiText.cs@@ -45,6 +45,9 @@ namespace Statecraft.Game.UI/// <summary>True when the strings have <paramref name="key"/> (a lookup that must not throw, as GameStart's fallback).</summary>public bool Has(string key) => map.ContainsKey(key);+ /// <summary>The keys in this strings file. The collection is read-only to callers.</summary>+ public IEnumerable<string> Keys => map.Keys;+public string this[string key] =>map.TryGetValue(key, out var v) ? v : throw new KeyNotFoundException($"{file} has no key '{key}'");diff --git a/unity/Assets/Tests/EditMode/BuildGateTests.cs b/unity/Assets/Tests/EditMode/BuildGateTests.csindex b297c2d77..e3a08e06c 100644--- a/unity/Assets/Tests/EditMode/BuildGateTests.cs+++ b/unity/Assets/Tests/EditMode/BuildGateTests.cs@@ -8,8 +8,7 @@ using Statecraft.Game;using Statecraft.Game.UI;using Statecraft.Sim;-/// <summary>Final review I4: a shareable build (Build.Web -shareable) is refused while any sensitive event lacks the owner's-/// sensitivity review, and the refusal names each one.</summary>+/// <summary>The content and review gates applied by every Unity player build made with -shareable.</summary>public class BuildGateTests{static Type SettlementReview => Type.GetType("Statecraft.Game.EditorTools.SettlementControlStringReview, Assembly-CSharp-Editor")!;@@ -17,6 +16,9 @@ public class BuildGateTestsSettlementReview.GetMethod("Parse", BindingFlags.Public | BindingFlags.Static)!.Invoke(null, new object[] { yaml, file })!;static string? SettlementReviewRefusal(object? review, UiText en, UiText he) =>(string?)SettlementReview.GetMethod("Refusal", BindingFlags.Public | BindingFlags.Static)!.Invoke(null, new[] { review, en, he });+ static bool IsSettlementControlKey(string key) =>+ (bool)SettlementReview.GetMethod("IsSettlementControlKey", BindingFlags.Public | BindingFlags.Static)!+ .Invoke(null, new object[] { key })!;internal static string? ReviewedSettlementControlStrings(){@@ -77,6 +79,19 @@ public class BuildGateTestsAssert.IsInstanceOf<InvalidOperationException>(unreadable!.InnerException);}+ [TestCase("capture.fixture")]+ [TestCase("map.control.fixture")]+ [TestCase("info.control.fixture")]+ [TestCase("hud.standing_displaced_places")]+ public void SettlementControlStringsReviewRefusesAnOmittedEligibleKey(string omitted) // R-GATE-002+ {+ var en = UiText.Parse("a: English\n" + omitted + ": Fixture\n", "strings.en.yaml");+ var he = UiText.Parse("a: עברית\n" + omitted + ": בדיקה\n", "strings.he.yaml");+ var review = ParseSettlementReview(+ "status: sensitivity-reviewed\nstrings:\n - { key: a, en: English, he: עברית }\n", "fixture");+ StringAssert.Contains(omitted, SettlementReviewRefusal(review, en, he));+ }+[Test]public void TheSettlementControlStringsRefusalJoinsTheShareableGateOnly() // R-GATE-002{@@ -115,8 +130,7 @@ public class BuildGateTests// A settlement-control key added to either strings file later (U6's dialog, #799's annex words) must join the manifest.foreach (var file in new[] { UiPaths.Strings, UiPaths.StringsHebrew })foreach (var key in new YamlDotNet.Serialization.Deserializer().Deserialize<System.Collections.Generic.Dictionary<string, string>>(File.ReadAllText(file)).Keys)- if (key.StartsWith("capture.", StringComparison.Ordinal) || key.StartsWith("map.control.", StringComparison.Ordinal)- || key.StartsWith("info.control.", StringComparison.Ordinal) || key == "hud.standing_displaced_places")+ if (IsSettlementControlKey(key))CollectionAssert.Contains(keys, key, file + ": " + key + " is a settlement-control string, so R-GATE-002's manifest lists it");}@@ -157,6 +171,19 @@ public class BuildGateTestsAssert.IsNull(Refusal(c));}+ /// <summary>R-ALT-011: an unsigned consequence card blocks Unity's shareable-build gate and is named.</summary>+ [Test]+ public void AShareableBuildWaitsForAnUnsignedConsequenceCard()+ {+ var c = ReviewedContent();+ var card = c.Events.Single(e => e.Id == "jerusalem_demilitarisation_guard");+ var signer = card.ReviewedBy;+ card.ReviewedBy = "";+ StringAssert.Contains(card.Id, Refusal(c));+ card.ReviewedBy = signer;+ Assert.IsNull(Refusal(c));+ }+[Test]public void AShareableBuildWaitsForTheSensitivityReview(){