A Civilization-style strategy game about governing Israel from 15 May 1948. Real ministers, real map, every fact sourced. Unity + deterministic C# sim.
event.schema.json agrees with the loader (Fixes #2658) (#2676)
Eyal Golan737a65ae059e
diff --git a/changelog.d/2658-event-schema.md b/changelog.d/2658-event-schema.mdnew file mode 100644index 000000000..994d6a8f4--- /dev/null+++ b/changelog.d/2658-event-schema.md@@ -0,0 +1,3 @@+### Changed++- Behind the scenes: `content/schema/event.schema.json` now agrees with the loader on requirements, alternatives, `set_rung` and Hebrew fields. No gameplay change; the schema is not part of the content hash.diff --git a/content/schema/event.schema.json b/content/schema/event.schema.jsonindex 07b4e74aa..04614c7da 100644--- a/content/schema/event.schema.json+++ b/content/schema/event.schema.json@@ -29,7 +29,24 @@}}}- }+ },+ "oneOf": [+ {+ "properties": {+ "basis": { "enum": ["proposed", "debated"] },+ "by": { "type": "string", "pattern": "^[^{}]*\\S[^{}]*$" },+ "sources": { "minItems": 1 }+ },+ "required": ["by", "date", "sources"]+ },+ {+ "properties": {+ "basis": { "const": "design" },+ "by": { "const": "" }+ },+ "not": { "required": ["date"] }+ }+ ]},"requirement": {"type": "object",@@ -40,7 +57,18 @@"event": { "$ref": "#/definitions/id" },"option": { "$ref": "#/definitions/id" },"diverged": { "type": "boolean" }- }+ },+ "oneOf": [+ {+ "required": ["option"],+ "properties": { "diverged": { "const": false } }+ },+ {+ "required": ["diverged"],+ "properties": { "diverged": { "const": true } },+ "not": { "required": ["option"] }+ }+ ]},"variant": {"type": "object",@@ -127,7 +155,7 @@}}},- "set_rung": { "type": "integer" },+ "set_rung": { "type": "integer", "minimum": 1, "maximum": 5 },"set_policy": { "type": "object", "additionalProperties": { "type": "number", "minimum": 0, "maximum": 1 }, "description": "Policy id to a level in [0, 1]." },"grant_units": {"type": "array",@@ -200,5 +228,29 @@"status": { "enum": ["draft", "fact-checked", "historian-reviewed", "sensitivity-reviewed"], "description": "The review status. Default draft." },"reviewed_by": { "type": "string", "pattern": "^[A-Za-z0-9](?:[A-Za-z0-9]|-(?=[A-Za-z0-9])){0,38}$", "description": "The GitHub handle of the person who signed this row off (#375): written only by that person, never by an AI agent on its own; an AI-assisted contributor's source check counts when the pull request discloses the AI help and says what was checked; an AI-co-authored commit never removes it (owner, 4 November 2026: \"Yes, it counts\", #2481 comment 6623108295; scripts/oss/reviewed_by_guard.py); never an email. Needs reviewed_on." },"reviewed_on": { "$ref": "#/definitions/date", "description": "The day of that sign-off. Needs reviewed_by." }- }+ },+ "oneOf": [+ {+ "required": ["title_he", "text_he"],+ "properties": {+ "options": {+ "items": { "required": ["text_he"] }+ }+ }+ },+ {+ "allOf": [+ { "not": { "required": ["title_he"] } },+ { "not": { "required": ["text_he"] } },+ { "not": { "required": ["text_he_review"] } },+ {+ "properties": {+ "options": {+ "items": { "not": { "required": ["text_he"] } }+ }+ }+ }+ ]+ }+ ]}diff --git a/sim/Statecraft.Sim.Tests/SchemaTests.cs b/sim/Statecraft.Sim.Tests/SchemaTests.csindex d0cf5f370..a48629a81 100644--- a/sim/Statecraft.Sim.Tests/SchemaTests.cs+++ b/sim/Statecraft.Sim.Tests/SchemaTests.cs@@ -30,6 +30,7 @@ public class SchemaTests{"$schema", "$ref", "title", "description", "definitions", "type", "properties", "additionalProperties", "required","items", "minItems", "minLength", "pattern", "minimum", "exclusiveMinimum", "maximum", "enum",+ "allOf", "oneOf", "not", "const",};static void Check(JsonElement schema, JsonElement root, JsonNode? value, string path, List<string> errors)@@ -37,6 +38,30 @@ public class SchemaTestsforeach (var k in schema.EnumerateObject())if (!Supported.Contains(k.Name)) throw new InvalidOperationException($"schema keyword '{k.Name}' at {path} is not supported by this test's validator");+ if (schema.TryGetProperty("allOf", out var allOf))+ foreach (var branch in allOf.EnumerateArray())+ Check(branch, root, value, path, errors);+ if (schema.TryGetProperty("oneOf", out var oneOf))+ {+ var matches = 0;+ foreach (var branch in oneOf.EnumerateArray())+ {+ var branchErrors = new List<string>();+ Check(branch, root, value, path, branchErrors);+ if (branchErrors.Count == 0) matches++;+ }+ if (matches != 1) errors.Add($"{path}: must match exactly one allowed shape");+ }+ if (schema.TryGetProperty("not", out var not))+ {+ var forbiddenErrors = new List<string>();+ Check(not, root, value, path, forbiddenErrors);+ if (forbiddenErrors.Count == 0) errors.Add($"{path}: matches a forbidden shape");+ }+ if (schema.TryGetProperty("const", out var constant)+ && !JsonNode.DeepEquals(value, JsonNode.Parse(constant.GetRawText())))+ errors.Add($"{path}: must equal {constant.GetRawText()}");+if (schema.TryGetProperty("$ref", out var r)){var target = root;@@ -350,7 +375,71 @@ people:[Fact]public void AnUnsupportedKeywordIsRefusedNotIgnored() =>- Assert.Throws<InvalidOperationException>(() => Check(JsonDocument.Parse("{\"oneOf\": []}").RootElement, default, JsonValue.Create("x"), "$", new List<string>()));+ Assert.Throws<InvalidOperationException>(() => Check(JsonDocument.Parse("{\"dependentRequired\": {}}").RootElement, default, JsonValue.Create("x"), "$", new List<string>()));++ [Fact]+ public void OneOfRequiresExactlyOneMatchingBranch()+ {+ var oneMatch = JsonDocument.Parse("{\"oneOf\": [{\"type\": \"string\"}, {\"type\": \"integer\"}]}").RootElement;+ var twoMatches = JsonDocument.Parse("{\"oneOf\": [{\"type\": \"string\"}, {\"type\": \"string\"}]}").RootElement;+ var errors = new List<string>();+ Check(oneMatch, default, JsonValue.Create("x"), "$", errors);+ Assert.Empty(errors);+ Check(twoMatches, default, JsonValue.Create("x"), "$", errors);+ Assert.NotEmpty(errors);+ }++ [Fact]+ public void ARequirementSelectsAnOptionOrTrueDivergence()+ {+ const string card = "id: e\ntitle: T\ntext: X\nfrom: 1950-01-01\nREQUIRESoptions:\n - { id: a, text: A }\nsources: [{ url: \"https://example.org\", checked: 2026-10-09 }]\n";+ Assert.Empty(Errors("event.schema.json", card.Replace("REQUIRES", "requires: [{ event: parent, option: path }]\n")));+ Assert.Empty(Errors("event.schema.json", card.Replace("REQUIRES", "requires: [{ event: parent, option: path, diverged: false }]\n")));+ Assert.Empty(Errors("event.schema.json", card.Replace("REQUIRES", "requires: [{ event: parent, diverged: true }]\n")));+ Assert.NotEmpty(Errors("event.schema.json", card.Replace("REQUIRES", "requires: [{ event: parent }]\n")));+ Assert.NotEmpty(Errors("event.schema.json", card.Replace("REQUIRES", "requires: [{ event: parent, diverged: false }]\n")));+ Assert.NotEmpty(Errors("event.schema.json", card.Replace("REQUIRES", "requires: [{ event: parent, option: path, diverged: true }]\n")));+ }++ [Fact]+ public void ConsideredAlternativesNeedWhoWhenAndSources()+ {+ const string card = "id: e\ntitle: T\ntext: X\nfrom: 1950-01-01\noptions:\n - { id: a, text: A, alternative: ALTERNATIVE }\nsources: [{ url: \"https://example.org\", checked: 2026-10-09 }]\n";+ const string source = "[{ url: \"https://example.org\", checked: 2026-10-09 }]";+ Assert.Empty(Errors("event.schema.json", card.Replace("ALTERNATIVE", "{ basis: proposed, by: the cabinet, date: 1950-01-01, sources: " + source + " }")));+ Assert.NotEmpty(Errors("event.schema.json", card.Replace("ALTERNATIVE", "{ basis: proposed, date: 1950-01-01, sources: " + source + " }")));+ Assert.NotEmpty(Errors("event.schema.json", card.Replace("ALTERNATIVE", "{ basis: proposed, by: '', date: 1950-01-01, sources: " + source + " }")));+ Assert.NotEmpty(Errors("event.schema.json", card.Replace("ALTERNATIVE", "{ basis: debated, by: ' ', date: 1950-01-01, sources: " + source + " }")));+ Assert.NotEmpty(Errors("event.schema.json", card.Replace("ALTERNATIVE", "{ basis: proposed, by: '{prime_minister}', date: 1950-01-01, sources: " + source + " }")));+ Assert.NotEmpty(Errors("event.schema.json", card.Replace("ALTERNATIVE", "{ basis: debated, by: the cabinet, sources: " + source + " }")));+ Assert.NotEmpty(Errors("event.schema.json", card.Replace("ALTERNATIVE", "{ basis: proposed, by: the cabinet, date: 1950-01-01, sources: [] }")));+ Assert.Empty(Errors("event.schema.json", card.Replace("ALTERNATIVE", "{ basis: design }")));+ Assert.NotEmpty(Errors("event.schema.json", card.Replace("ALTERNATIVE", "{ basis: design, date: 1950-01-01 }")));+ Assert.NotEmpty(Errors("event.schema.json", card.Replace("ALTERNATIVE", "{ basis: design, by: the cabinet }")));+ }++ [Theory]+ [InlineData(1, true)]+ [InlineData(5, true)]+ [InlineData(0, false)]+ [InlineData(6, false)]+ public void SetRungIsOneToFive(int rung, bool valid)+ {+ var card = $"id: e\ntitle: T\ntext: X\nfrom: 1950-01-01\noptions:\n - {{ id: a, text: A, set_rung: {rung} }}\nsources: [{{ url: \"https://example.org\", checked: 2026-10-09 }}]\n";+ Assert.Equal(valid, Errors("event.schema.json", card).Count == 0);+ }++ [Fact]+ public void EventHebrewIsAllOrNone()+ {+ const string plain = "id: e\ntitle: T\ntext: X\nfrom: 1950-01-01\nTOPoptions:\n - { id: a, text: AOPTION }\nsources: [{ url: \"https://example.org\", checked: 2026-10-09 }]\n";+ Assert.Empty(Errors("event.schema.json", plain.Replace("TOP", "").Replace("OPTION", "")));+ Assert.Empty(Errors("event.schema.json", plain.Replace("TOP", "title_he: כותרת\ntext_he: טקסט\n").Replace("OPTION", ", text_he: בחירה")));+ Assert.NotEmpty(Errors("event.schema.json", plain.Replace("TOP", "title_he: כותרת\n").Replace("OPTION", "")));+ Assert.NotEmpty(Errors("event.schema.json", plain.Replace("TOP", "title_he: כותרת\ntext_he: טקסט\n").Replace("OPTION", "")));+ Assert.NotEmpty(Errors("event.schema.json", plain.Replace("TOP", "").Replace("OPTION", ", text_he: בחירה")));+ Assert.NotEmpty(Errors("event.schema.json", plain.Replace("TOP", "text_he_review: agent-checked\n").Replace("OPTION", "")));+ }// R-MEDIT-001/002/003: synthetic authoring shape, never runtime content.static string SyntheticEditorEnvelope()