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.

GDD 0.3: the Historical ledger fixture counts at rules.yaml's 1,000 per unit (D2) (Refs #1689) (#2299)

Eyal Golan0124b2264c3e
diff --git a/changelog.d/1689-d2-ledger-scale.md b/changelog.d/1689-d2-ledger-scale.md
new file mode 100644
index 000000000..d6ea59c5f
--- /dev/null
+++ b/changelog.d/1689-d2-ledger-scale.md
@@ -0,0 +1,5 @@
+### Changed
+- Under the gdd-0.3 rules only, the sim's test fixture of the Historical start's population ledger counts each population
+ unit as 1,000 people, the scale its census cities and formations are sized at, not the 10,000 meant for Open mode
+ (Refs #1689, owner decision D2). It refuses a missing or nonpositive scale, and census or formation rows outside the
+ Historical start. The ledger is not yet in the game; the game players play (gdd-0.1) is unchanged.
diff --git a/content/gdd03-balance.yaml b/content/gdd03-balance.yaml
index 0a455577b..86739fa0a 100644
--- a/content/gdd03-balance.yaml
+++ b/content/gdd03-balance.yaml
@@ -45,7 +45,7 @@
"values": [2]
"population.people_per_unit":
"basis": "Agreed"
- "note": "Population and starting state: people nominally represented by a population unit; Agreed. Source: #1668 balance.md at 605277df."
+ "note": "Population and starting state: people nominally represented by a population unit; Agreed for Open mode. Owner, 1 November 2026, D2 (\"Approve all six (Recommended)\"): the Historical MVP keeps main's census cities at 1,000 people a unit, so a Historical ledger fixture counts at rules.yaml's people_per_unit for the start day (R-POP-004); this row's 10,000 is Open mode's, when Open mode exists. Source: #1668 balance.md at 605277df."
"values": [10000]
"start.population":
"basis": "Default"
diff --git a/docs/rules/mvp.md b/docs/rules/mvp.md
index 451af1638..9fe97bfdf 100644
--- a/docs/rules/mvp.md
+++ b/docs/rules/mvp.md
@@ -565,13 +565,13 @@ R-CAMERA-001: Only exact `gdd-0.3` fixes gameplay yaw at zero (north), including
These contracts cover #1689 steps 1–2 and the Historical start inventory (R-POP-004) only. Production era selection, Food consumption and command/save/reload integration remain held; helper coverage does not complete #1689. See [population-ledger.md](../population-ledger.md).
-R-POP-001: Only exact `gdd-0.3` enables the population-ledger capability, independently of the broad GDD loop and Attention (R-LOOP-002/005). An immutable own-population record has a dedicated nonnegative ordinal id. Synthetic fixture inventory is ordered by source key (ordinal string comparison), then within-source ordinal. Registered arrivals allocate monotonically; only explicit combat losses remove living ids. Sources remain registered after loss, and ids are never reused. Reconciliation checks the exact created-minus-lost id set against the living ledger, not just equal totals. Status/region counts include every matching record once. The gdd-0.3 scale reads one positive Agreed integer from `population.people_per_unit` in its catalogue (currently 10,000, Open mode's scale under D2; the Historical start counts at 1,000, R-POP-004); old identities retain the common rules scale. Missing, fractional, nonpositive, overflowing or Deferred values have no fallback.
+R-POP-001: Only exact `gdd-0.3` enables the population-ledger capability, independently of the broad GDD loop and Attention (R-LOOP-002/005). An immutable own-population record has a dedicated nonnegative ordinal id. Synthetic fixture inventory is ordered by source key (ordinal string comparison), then within-source ordinal. Registered arrivals allocate monotonically; only explicit combat losses remove living ids. Sources remain registered after loss, and ids are never reused. Reconciliation checks the exact created-minus-lost id set against the living ledger, not just equal totals. Status/region counts include every matching record once. The gdd-0.3 scale of a synthetic or Open fixture reads one positive Agreed integer from `population.people_per_unit` in its catalogue (currently 10,000, Open mode's scale under D2); a Historical fixture reads `rules.yaml`'s `people_per_unit` for the start day (1,000), as R-UNIT-006 does (owner, 1 November 2026, D2: "Approve all six (Recommended)", "The Historical MVP keeps main's start: census cities at 1,000 people a unit (`R-CITY-007`)"; R-POP-004); rows with a `census/` or `units_1948/` source key are the Historical start's and are refused in any other fixture. Old identities retain the common rules scale. Missing, fractional, nonpositive, overflowing or Deferred values have no fallback, in either source.
R-POP-002: A ledger record has exactly one typed status and assignment, validated location, home and captor references, whole reception-turn ticks capped by the catalogue requirement, civilian profession-specific tier and actual-work XP, separate military qualification/combat XP, and distinct issued civilian/military equipment and paid facts. Unknown references, unresolved teacher ids, incompatible statuses/assignments, inconsistent region/hex/facility bindings, invalid progress/tiers and duplicate issued-item ownership are refused before mutation. Moves and atomic status/location/assignment transitions retain identity/history. Capture retains home context without inventing a prison hex or refunding equipment. Ledger changes never touch resources, causes, RNG or Attention. Initialization is internal and fixture-only; initialized ledger fixtures refuse aggregate Simulation commands and turns. Old identities refuse ledger mutation. Prices, progression awards, return destinations, tool lock-in and captive-equipment outcomes remain with their owning issues.
R-POP-003: Clone copies all ledger containers; immutable records and frozen bindings may be shared. The canonical writer emits a gdd-0.3-only section ordered by numeric population id, with fixed field order, stable machine tokens, invariant integer formatting and length-prefixed reference strings. It covers every record/assignment/equipment/reference field, binding, creation/loss provenance and allocator even after the last combat loss. Legacy/gdd-0.1 emit no ledger section or allocator marker. R-SAVE-001/002 still govern identity mismatch refusal and replay: no ledger snapshot or new command syntax is added in this foundation, and fixture injection is not replay evidence. Existing unpublished schema-4 draft hashes change; no migration promise is made.
-R-POP-004: The Historical start inventory under exact `gdd-0.3` (#1689; owner, 1 November 2026, D2: "Approve all six (Recommended)", and D4). It is read from the same content as the aggregate start: each census city (R-CITY-006) gives its R-CITY-007 start units as free civilians, and each Israeli starting formation of `map/units_1948.yaml` (R-UNIT-006) gives its strength as active soldiers, no more and no less. Enemy formations are not own population, and a dated arrival (R-UNIT-009) is not in the start inventory: it takes new ids when it arrives (Q11). Counts use `rules.yaml`'s `people_per_unit` (1,000, D2), as R-CITY-007 and R-UNIT-006 do; the `gdd-0.3` catalogue's `population.people_per_unit` (10,000) is Open mode's (D2). A city's records have source key `census/<city id>` and a formation's `units_1948/<row id>`, each with within-source ordinals from 0, so R-POP-001's order (source key by ordinal string comparison, then ordinal) gives the ascending population ids that Q10's "N units" commands take. Legacy and `gdd-0.1` content refuse it. It reads no RNG and changes no state. It is not yet wired into `Simulation.NewGame`: an initialized ledger refuses every aggregate system (R-POP-002), so a new `gdd-0.3` game keeps the aggregate start until the producers are integrated. Still Deferred: the region or location binding of each record (#1690, #1689; `content/regions.yaml` has the nine regions of #1691, which no game initializes yet), the work assignments of the employed share, which census units are farmers (fields, #1691/#1717; the owner's 1:2:1 novice/trained/veteran ratio per city then applies), the formations' military qualification, combat experience and issued equipment (#1717), and the ledger scale for this start (R-POP-001 reads the catalogue's 10,000).
+R-POP-004: The Historical start inventory under exact `gdd-0.3` (#1689; owner, 1 November 2026, D2: "Approve all six (Recommended)", and D4). It is read from the same content as the aggregate start: each census city (R-CITY-006) gives its R-CITY-007 start units as free civilians, and each Israeli starting formation of `map/units_1948.yaml` (R-UNIT-006) gives its strength as active soldiers, no more and no less. Enemy formations are not own population, and a dated arrival (R-UNIT-009) is not in the start inventory: it takes new ids when it arrives (Q11). Counts use `rules.yaml`'s `people_per_unit` (1,000, D2), as R-CITY-007 and R-UNIT-006 do; the `gdd-0.3` catalogue's `population.people_per_unit` (10,000) is Open mode's (D2). A city's records have source key `census/<city id>` and a formation's `units_1948/<row id>`, each with within-source ordinals from 0, so R-POP-001's order (source key by ordinal string comparison, then ordinal) gives the ascending population ids that Q10's "N units" commands take. Legacy and `gdd-0.1` content refuse it. It reads no RNG and changes no state. It is not yet wired into `Simulation.NewGame`: an initialized ledger refuses every aggregate system (R-POP-002), so a new `gdd-0.3` game keeps the aggregate start until the producers are integrated. Still Deferred: the region or location binding of each record (#1690, #1689; `content/regions.yaml` has the nine regions of #1691, which no game initializes yet), the work assignments of the employed share, which census units are farmers (fields, #1691/#1717; the owner's 1:2:1 novice/trained/veteran ratio per city then applies), and the formations' military qualification, combat experience and issued equipment (#1717). The ledger scale for this start is no longer Deferred: a Historical ledger fixture counts each record at `rules.yaml`'s `people_per_unit` for the start day, 1,000 people (R-POP-001; D2: "The Historical MVP keeps main's start: census cities at 1,000 people a unit (`R-CITY-007`)").
#1706 slices 0/1 (coordinator decision, 26 Oct 2026, Q5): the synthetic combat catalogue foundation is inactive in the actual game. R-COMBAT-001 through R-COMBAT-008 retain their current runtime meanings. See [the catalogue foundation](../gdd03-catalogue.md#1706-slices-01-inactive-combat-catalogue-foundation) for its data contract and sources.
diff --git a/sim/Statecraft.Sim.Tests/HistoricalPopulationTests.cs b/sim/Statecraft.Sim.Tests/HistoricalPopulationTests.cs
index 659594bc5..53df9773e 100644
--- a/sim/Statecraft.Sim.Tests/HistoricalPopulationTests.cs
+++ b/sim/Statecraft.Sim.Tests/HistoricalPopulationTests.cs
@@ -107,6 +107,99 @@ public class HistoricalPopulationTests
Assert.Equal(3, Count(rows, HistoricalPopulation.FormationPrefix + "kiryati"));
}
+ // R-POP-001, R-POP-004 with D2 (owner, 1 November 2026, "Approve all six (Recommended)"): a ledger fixture of the
+ // Historical start counts its records at rules.yaml's people_per_unit for the start day (1,000), as StartingForces and
+ // Cities do, while the gdd-0.3 catalogue's population.people_per_unit still reads Open mode's 10,000.
+ [Fact]
+ public void HistoricalLedgerFixtureCountsAtTheRulesScale()
+ {
+ var c = Real(true);
+ // Precondition, not the claim: the two scales differ (D2), so the total below tells them apart.
+ Assert.Equal((1000, 10000), (c.RulesAt(c.Rules.Start).Mvp!.PeoplePerUnit, c.PopulationPeoplePerUnit));
+ var inventory = HistoricalPopulation.Inventory(c);
+ Assert.NotEmpty(inventory);
+ var s = PopulationLedger.CreateFixture(c, PopulationLedgerTests.Bindings(), LedgerRows(inventory), mode: Mode.Historical);
+ Assert.Equal(Mode.Historical, s.Mode);
+ Assert.Equal(inventory.Count, s.PopulationLedger.Units.Count);
+ Assert.Equal((double)inventory.Count * 1000, s.PopulationLedger.TotalPeople);
+ // R-POP-003: Clone keeps the fixture's scale rather than re-reading the catalogue.
+ Assert.Equal((double)inventory.Count * 1000, s.Clone().PopulationLedger.TotalPeople);
+ }
+
+ // R-POP-001 with D2: the catalogue's 10,000 is Open mode's, so an Open fixture and a synthetic one (no mode) keep it.
+ [Fact]
+ public void OpenAndSyntheticLedgerFixturesKeepTheCatalogueScale()
+ {
+ var c = Real(true);
+ var row = new PopulationInventoryRow("synthetic", 0, PopulationLedgerTests.Person());
+ var open = PopulationLedger.CreateFixture(c, PopulationLedgerTests.Bindings(), new[] { row }, mode: Mode.Open);
+ Assert.Equal(Mode.Open, open.Mode);
+ Assert.Equal(10000d, open.PopulationLedger.TotalPeople);
+ Assert.Equal(10000d, PopulationLedger.CreateFixture(c, PopulationLedgerTests.Bindings(), new[] { row }).PopulationLedger.TotalPeople);
+ }
+
+ // R-POP-003 with D2: the canonical writer emits the scale. A synthetic fixture's GameState.Mode is the enum default,
+ // Historical, so the same rows with and without mode Historical differ only in their scale, and their hashes differ.
+ [Fact]
+ public void CanonicalStateTellsTheTwoScalesApart()
+ {
+ var c = Real(true);
+ var row = new PopulationInventoryRow("synthetic", 0, PopulationLedgerTests.Person());
+ var historical = PopulationLedger.CreateFixture(c, PopulationLedgerTests.Bindings(), new[] { row }, mode: Mode.Historical);
+ var synthetic = PopulationLedger.CreateFixture(c, PopulationLedgerTests.Bindings(), new[] { row });
+ Assert.Equal((Mode.Historical, Mode.Historical), (historical.Mode, synthetic.Mode));
+ Assert.Equal((1000d, 10000d), (historical.PopulationLedger.TotalPeople, synthetic.PopulationLedger.TotalPeople));
+ Assert.NotEqual(historical.Hash(), synthetic.Hash());
+ Assert.Equal(historical.Hash(), historical.Clone().Hash());
+ }
+
+ // R-POP-004 with D2: census and units_1948 rows are the Historical start's, so a fixture of them needs mode Historical;
+ // without it they would silently count at Open mode's 10,000.
+ [Theory]
+ [InlineData(null)]
+ [InlineData(Mode.Open)]
+ public void HistoricalRowsRefuseAnyOtherScale(Mode? mode)
+ {
+ var c = Real(true);
+ var inventory = HistoricalPopulation.Inventory(c);
+ foreach (var prefix in new[] { HistoricalPopulation.CensusPrefix, HistoricalPopulation.FormationPrefix })
+ {
+ var rows = LedgerRows(inventory.Where(r => r.Source.StartsWith(prefix, StringComparison.Ordinal)).Take(1).ToList());
+ Assert.Single(rows);
+ var e = Assert.Throws<ArgumentException>(() => PopulationLedger.CreateFixture(c, PopulationLedgerTests.Bindings(), rows, mode: mode));
+ Assert.Equal("Census and units_1948 rows are the Historical start's; their fixture needs mode Historical (R-POP-004).", e.Message);
+ }
+ }
+
+ // R-POP-001's no-fallback rule on the Historical scale: a missing, zero or negative rules.yaml people_per_unit for the
+ // start day is refused, never replaced by the catalogue's value.
+ [Theory]
+ [InlineData(null)]
+ [InlineData(0)]
+ [InlineData(-1000)]
+ public void HistoricalScaleHasNoFallback(int? peoplePerUnit)
+ {
+ var c = Real(true);
+ var rules = c.RulesAt(c.Rules.Start);
+ if (peoplePerUnit is int ppu) rules.Mvp!.PeoplePerUnit = ppu; else rules.Mvp = null;
+ var row = new PopulationInventoryRow("synthetic", 0, PopulationLedgerTests.Person());
+ var e = Assert.Throws<InvalidOperationException>(() => PopulationLedger.CreateFixture(c, PopulationLedgerTests.Bindings(), new[] { row }, mode: Mode.Historical));
+ Assert.Equal("The Historical scale needs a positive mvp.people_per_unit in rules.yaml for the start day; no fallback.", e.Message);
+ }
+
+ // The real inventory as ledger rows: a free civilian per census unit and an active soldier per formation unit.
+ static IEnumerable<PopulationInventoryRow> LedgerRows(IEnumerable<HistoricalPopulationRow> inventory)
+ {
+ var civilian = PopulationLedgerTests.Person();
+ var civilianTemplate = new PopulationUnit(0, PopulationStatus.FreeCivilian, 0, civilian.Location, PopulationAssignment.Unassigned,
+ civilian.Profession, civilian.Tier, 0, "basic", 0, PopulationEquipment.None);
+ var soldierTemplate = new PopulationUnit(0, PopulationStatus.ActiveSoldier, 0, civilian.Location,
+ new PopulationAssignment(PopulationAssignmentKind.ActiveService, "service"), civilian.Profession, civilian.Tier, 0, "basic", 0,
+ PopulationEquipment.None);
+ return inventory.Select(r => new PopulationInventoryRow(
+ r.Source, r.Ordinal, r.Status == PopulationStatus.ActiveSoldier ? soldierTemplate : civilianTemplate)).ToList();
+ }
+
// R-POP-001, R-POP-004: inventory order is source key by ordinal string comparison, then a contiguous within-source
// ordinal from 0, so ascending population ids follow it (Q10). Repeated reads are identical (docs/determinism.md).
[Fact]
diff --git a/sim/Statecraft.Sim/PopulationLedger.cs b/sim/Statecraft.Sim/PopulationLedger.cs
index 1b3b32bd0..8294e8951 100644
--- a/sim/Statecraft.Sim/PopulationLedger.cs
+++ b/sim/Statecraft.Sim/PopulationLedger.cs
@@ -249,18 +249,27 @@ namespace Statecraft.Sim
if (item != null && !issued.Add(item)) throw new ArgumentException("Issued equipment cannot have two owners.");
}
}
- /// <summary>No production caller or content file opts into initialization. Does not invoke old population producers.</summary>
- internal static GameState CreateFixture(Content c, PopulationBindings bindings, IEnumerable<PopulationInventoryRow> rows, int nextPopulationId = 0)
+ /// <summary>No production caller or content file opts into initialization. Does not invoke old population producers.
+ /// The scale: a synthetic fixture (no <paramref name="mode"/>) and an Open one read the gdd-0.3 catalogue's
+ /// population.people_per_unit (10,000, Open mode's); a Historical one reads rules.yaml's people_per_unit for the
+ /// start day (1,000), as StartingForces and Cities do (R-POP-004; owner, 1 November 2026, D2). Census and units_1948
+ /// rows are the Historical start's, so they need mode Historical; the scale has no fallback (R-POP-001).</summary>
+ internal static GameState CreateFixture(Content c, PopulationBindings bindings, IEnumerable<PopulationInventoryRow> rows, int nextPopulationId = 0, Mode? mode = null)
{
if (!c.UsesPopulationLedger) throw new InvalidOperationException("Population fixtures require gdd-0.3 identity.");
if (nextPopulationId < 0) throw new ArgumentOutOfRangeException(nameof(nextPopulationId));
var s = new GameState(c); var l = s.PopulationLedger;
+ if (mode is Mode m) s.Mode = m;
l.bindings = bindings ?? throw new ArgumentNullException(nameof(bindings));
- l.peoplePerUnit = c.PopulationPeoplePerUnit;
+ var ordered = rows.OrderBy(x => x.Source, StringComparer.Ordinal).ThenBy(x => x.Ordinal).ToList();
+ if (mode != Mode.Historical && ordered.Any(x => x.Source.StartsWith(HistoricalPopulation.CensusPrefix, StringComparison.Ordinal)
+ || x.Source.StartsWith(HistoricalPopulation.FormationPrefix, StringComparison.Ordinal)))
+ throw new ArgumentException("Census and units_1948 rows are the Historical start's; their fixture needs mode Historical (R-POP-004).");
+ l.peoplePerUnit = mode == Mode.Historical ? HistoricalPeoplePerUnit(c) : c.PopulationPeoplePerUnit;
l.receptionLimit = c.RequirePopulationInteger("reception.turns");
l.NextPopulationId = nextPopulationId;
// Build all records before validating references: teachers may occur after their pupils in authored order.
- foreach (var row in rows.OrderBy(x => x.Source, StringComparer.Ordinal).ThenBy(x => x.Ordinal))
+ foreach (var row in ordered)
{
var next = checked(l.NextPopulationId + 1);
l.sources.Add(PopulationText.Fields(row.Source, row.Ordinal), l.NextPopulationId);
@@ -269,6 +278,9 @@ namespace Statecraft.Sim
l.Validate(l.units); l.IsInitialized = true;
return s;
}
+ // R-POP-001's no-fallback rule, as for the catalogue value: a missing or nonpositive value is refused, never replaced.
+ static int HistoricalPeoplePerUnit(Content c) => c.RulesAt(c.Rules.Start).Mvp?.PeoplePerUnit is int ppu && ppu > 0 ? ppu
+ : throw new InvalidOperationException("The Historical scale needs a positive mvp.people_per_unit in rules.yaml for the start day; no fallback.");
internal IEnumerable<string> Canonical()
{
yield return PopulationText.Fields("initialized", IsInitialized, "next", NextPopulationId,