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.

24.4 KB
Raw Blame
using Statecraft.Sim;
using System.Globalization;
using YamlDotNet.Serialization;

public partial class DesignValuesTests
{
    const string CatalogueFile = "gdd03-balance.yaml";
    // R-LOOP-005: exact key inventory of #1668 balance.md at 605277df, including project and biome rows.
    static readonly string[] Gdd03Keys = {
        "campaign.play_minutes",
        "money.il_millions",
        "indicator.display_max",
        "indicator.storage_max",
        "indicator.low_on",
        "indicator.low_off",
        "start.cohesion",
        "start.support",
        "event.max_gap_peace",
        "event.max_gap_war",
        "population.people_per_unit",
        "start.population",
        "start.money",
        "start.food",
        "start.spare_arms",
        "start.army",
        "start.farmers",
        "start.prepared_fields",
        "start.trained_pioneers",
        "start.apprentices",
        "start.experts",
        "start.pioneer_teachers",
        "start.military_camps",
        "start.reception_camps",
        "start.training_centres",
        "start.free_civilians",
        "start.industry_slots",
        "start.permanent_housing_projects",
        "start.housing_capacity",
        "start.housing_condition",
        "start.food_production",
        "start.food_consumption",
        "population.food_per_turn",
        "industry.income",
        "farmer.output",
        "profession.farmer_tools",
        "profession.pioneer_tools",
        "profession.course_turns",
        "profession.trainees_per_teacher",
        "profession.work_to_veteran",
        "pioneer.work_rate",
        "craft.course_cost",
        "craft.course_turns",
        "craft.course_income",
        "craft.expert_work_turns",
        "builder.slots_per_project",
        "builder.work_rate",
        "construction.starts_per_turn",
        "field.slots",
        "field.cost",
        "field.work",
        "field.nominal_turns",
        "reception.capacity",
        "reception.turns",
        "reception.basic_credit",
        "housing.condition_max",
        "housing.money_threshold",
        "housing.money_slope",
        "housing.cohesion_threshold",
        "housing.max_cohesion_loss",
        "housing.overflow_deterioration",
        "housing.max_deterioration",
        "transit.cost",
        "reception.queue_cohesion_loss",
        "food.shortage_cohesion_max",
        "food.shortage_combat_slope",
        "import.arms_price",
        "import.food_per_money",
        "import.delivery_turns",
        "immigration.ship_interval",
        "immigration.units_per_ship",
        "immigration.mix",
        "workshop.staffed_turns",
        "workshop.cost",
        "military.camp_capacity",
        "military.basic_turns",
        "military.issue_arms",
        "military.draft_money",
        "military.draft_wait",
        "military.demobilise_money",
        "military.demobilise_wait",
        "military.demobilise_return",
        "military.repeat_issue",
        "military.combat_arms",
        "military.training_money",
        "military.active_money",
        "military.strength",
        "military.combat_xp_gain",
        "military.combat_xp_full",
        "military.refugee_multiplier",
        "military.fort_bonus",
        "military.fortify_turns",
        "military.fortify_bonus",
        "military.stack_limit",
        "military.move_infantry",
        "military.move_armoured",
        "military.move_road",
        "military.move_rail",
        "military.armistice_quiet_turns",
        "occupation.garrison",
        "occupation.turns",
        "annex.tax_town",
        "annex.tax_city",
        "puppet.tax_fraction",
        "annex.support_cost",
        "puppet.support_cost",
        "occupation.tax",
        "prisoner.food",
        "prisoner.return_points",
        "combat.draw_count",
        "combat.enemy_attack_ratio",
        "combat.retreat_hexes",
        "combat.armoured_factor",
        "combat.artillery_range",
        "combat.artillery_factor",
        "combat.loss_cohorts",
        "objective.base_points",
        "objective.early_per_month",
        "objective.early_cap",
        "absorption.population_target",
        "absorption.max_overflow",
        "absorption.min_employment",
        "maabara",
        "permanent_housing",
        "industry",
        "reception_camp",
        "training_centre",
        "arms_workshop",
        "military_camp",
        "housing_repair",
        "designated_yishuv",
        "hula_drainage",
        "road_segment",
        "rail_segment",
        "coastal_plain",
        "lowland",
        "valley",
        "hills",
        "mountains",
        "desert",
        "lake",
        "sea"
    };
    static Dictionary<object, object> Catalogue()
    {
        var path = Path.Combine(RealContentTests.ContentRoot(), CatalogueFile);
        Assert.True(File.Exists(path), "gdd-0.3 balance catalogue must be present");
        return new DeserializerBuilder().WithDuplicateKeyChecking().Build().Deserialize<Dictionary<object, object>>(File.ReadAllText(path));
    }
    static Dictionary<object, object> Row(Dictionary<object, object> map, string key) => (Dictionary<object, object>)map[key];

    [Fact] public void Gdd03CatalogueHasEveryPinnedDesignKeyExactlyOnce()
    {
        var c=Catalogue(); Assert.Equal("gdd-0.3", c["ruleset"]);
        Assert.Equal(Gdd03Keys.OrderBy(x=>x,StringComparer.Ordinal), Row(c,"values").Keys.Cast<string>().OrderBy(x=>x,StringComparer.Ordinal));
    }
    // R-LOOP-005 (#2653): the named parts are pinned too, so an invented or dropped part fails until this list changes.
    static readonly Dictionary<string, string[]> Gdd03Parts = new Dictionary<string, string[]>
    {
        ["reception.queue_cohesion_loss"] = new[] { "cadence_turns" },
        ["combat.draw_count"] = new[] { "at_least_2", "below_0_5", "draw_band", "from_0_5_below_1", "from_1_below_2", "ratio_thresholds" },
        ["maabara"] = new[] { "condition_pp", "cost", "housing", "upkeep", "work" },
        ["permanent_housing"] = new[] { "condition_pp", "cost", "housing", "upkeep", "work" },
        ["industry"] = new[] { "cost", "job_slots", "upkeep", "work" },
        ["reception_camp"] = new[] { "cost", "standalone_application", "upkeep", "work" },
        ["training_centre"] = new[] { "cost", "standalone_application", "upkeep", "work" },
        ["arms_workshop"] = new[] { "cost", "upkeep", "work", "worker_slots" },
        ["military_camp"] = new[] { "cost", "upkeep", "work" },
        ["housing_repair"] = new[] { "condition_pp", "cost", "upkeep", "work" },
        ["designated_yishuv"] = new[] { "cost", "upkeep", "work" },
        ["hula_drainage"] = new[] { "cost", "upkeep", "work" },
        ["road_segment"] = new[] { "cost", "upkeep", "work" },
        ["rail_segment"] = new[] { "cost", "upkeep", "work" },
        ["coastal_plain"] = new[] { "defence_percent", "movement" },
        ["lowland"] = new[] { "defence_percent", "movement" },
        ["valley"] = new[] { "defence_percent", "movement" },
        ["hills"] = new[] { "defence_percent", "movement" },
        ["mountains"] = new[] { "defence_percent", "movement" },
        ["desert"] = new[] { "defence_percent", "movement" },
    };
    [Fact] public void Gdd03CatalogueHasEveryPinnedNamedPartExactlyOnce()
    {
        var v=Row(Catalogue(),"values");
        string Line(string key, IEnumerable<string> parts) => key+": "+string.Join(" ", parts.OrderBy(x=>x,StringComparer.Ordinal));
        var actual=v.Where(kv=>((Dictionary<object,object>)kv.Value).ContainsKey("parts"))
            .Select(kv=>Line((string)kv.Key, Row((Dictionary<object,object>)kv.Value,"parts").Keys.Cast<string>()));
        Assert.Equal(Gdd03Parts.Select(kv=>Line(kv.Key,kv.Value)).OrderBy(x=>x,StringComparer.Ordinal), actual.OrderBy(x=>x,StringComparer.Ordinal));
        // A part has no parts of its own today; one that gains them would need pinning here too.
        Assert.All(Gdd03Parts, kv=>Assert.All(kv.Value, p=>Assert.False(Row(Row(Row(v,kv.Key),"parts"),p).ContainsKey("parts"), kv.Key+"."+p)));
    }
    [Fact] public void Gdd03DistinguishesAgreedDefaultsAndDeferredExpressions()
    {
        var v=Row(Catalogue(),"values");
        Assert.Equal("Agreed",Row(v,"population.people_per_unit")["basis"]);
        Assert.Equal("Default",Row(v,"campaign.play_minutes")["basis"]);
        Assert.Equal("Deferred",Row(v,"start.army")["basis"]); Assert.Equal("A",Row(v,"start.army")["expression"]);
        Assert.False(Row(v,"start.army").ContainsKey("values"));
        Assert.Equal("Deferred",Row(v,"start.free_civilians")["basis"]); Assert.Equal("34 - A",Row(v,"start.free_civilians")["expression"]);
        var parts=Row(Row(v,"maabara"),"parts");
        Assert.Equal("Agreed",Row(parts,"cost")["basis"]); Assert.Equal("Default",Row(parts,"upkeep")["basis"]);
        Assert.Equal("Default",Row(v,"start.housing_capacity")["basis"]);
        Assert.Equal("Agreed",Row(v,"military.combat_arms")["basis"]);
        Assert.Contains("owner ruling, 25 Oct 2026, on #1668",(string)Row(v,"military.combat_arms")["note"]);
    }
    // R-LOOP-005, #2115: rows the owner ruled on after the #1668 transcription carry the ruling's value and basis, and
    // their note names the ruling and its date. Open-mode and post-MVP rows are not Agreed: the Historical MVP does not
    // use them (D2, owner, 1 November 2026: "Approve all six (Recommended)"; post-MVP: "Approve all 79 (Recommended)").
    [Theory]
    [InlineData("start.money", "Default", "25", D2, Nov1)]
    [InlineData("start.food", "Default", "10", D2, Nov1)]
    [InlineData("start.farmers", "Default", "5 10 5", D2, Nov1)]
    [InlineData("start.population", "Default", "65", D2, Nov1)]
    [InlineData("start.spare_arms", "Default", "3", D2, Nov1)]
    [InlineData("start.food_production", "Default", "65", D2, Nov1)]
    [InlineData("start.food_consumption", "Default", "65", D2, Nov1)]
    [InlineData("start.housing_condition", "Agreed", "0.35", "\"0.35, your 15 Oct value (Recommended)\"", Nov1)]
    [InlineData("craft.course_cost", "Agreed", "0.5", Keep, Oct30)]
    [InlineData("craft.course_turns", "Agreed", "3", Keep, Oct30)]
    [InlineData("military.training_money", "Agreed", "0.5", Keep, Oct30)]
    [InlineData("military.active_money", "Agreed", "0.05", Keep, Oct30)]
    [InlineData("prisoner.return_points", "Agreed", "10", "\"10 per unit, main (Recommended)\"", Nov1)]
    [InlineData("military.fortify_bonus", "Agreed", "25", "owner-approved answer O1 (1 November 2026, #1668 issuecomment-6553884547): +25%, one turn to set", Nov1)]
    [InlineData("combat.artillery_range", "Agreed", "2", "owner-approved answer O5 (1 November 2026, https://github.com/eyalgolan/statecraft-israel/pull/1668#issuecomment-6553884547): \"2 hexes.\"", Nov1)]
    [InlineData("combat.artillery_factor", "Agreed", "2", "C1 (10 November 2026, https://github.com/eyalgolan/statecraft-israel/issues/2918#issuecomment-6765662598): \"200% wins (Recommended)\"", "10 November 2026")]
    [InlineData("transit.cost", "Default", "0.50", PostMvp, Nov1)]
    [InlineData("reception.queue_cohesion_loss", "Default", "1", PostMvp, Nov1)]
    [InlineData("housing.max_deterioration", "Default", "10", "declined by the owner", Oct30)]
    [InlineData("housing.overflow_deterioration", "Agreed", "5", "\"Yes, 5 pp under GDD 0.3 (Recommended)\"", "2 November 2026")]
    [InlineData("field.slots", "Agreed", "1", "\"One farmer per field (Recommended)\"", "3 November 2026")]
    [InlineData("military.strength", "Default", "1 2 3", S3, Nov10)]
    [InlineData("military.refugee_multiplier", "Default", "0.75", S3All, Nov10)]
    [InlineData("food.shortage_combat_slope", "Default", "1", S3All, Nov10)]
    [InlineData("food.shortage_cohesion_max", "Default", "10", S3All, Nov10)]
    public void Gdd03RowsFollowTheOwnersLaterRulings(string key, string basis, string values, string ruling, string date)
    {
        var row=ContentLoader.Load(RealContentTests.ContentRoot()).Gdd03Balance!.Values[key];
        Assert.Equal(basis,row.Basis);
        Assert.Equal(values.Split(' ').Select(x=>decimal.Parse(x,CultureInfo.InvariantCulture)),row.Values);
        Assert.Contains(ruling,row.Note);
        Assert.Contains(date,row.Note);
        Assert.Contains("Source: #1668 balance.md at 605277df.",row.Note);
        if(basis=="Default") Assert.Contains(key.StartsWith("start.") ? "Open mode" : "not operative in the MVP",row.Note);
        foreach(var part in row.Parts.Values) Assert.DoesNotContain("Agreed",part.Note);
    }
    const string D2="\"Approve all six (Recommended)\"", Keep="\"Keep the set values (Recommended)\"",
        PostMvp="\"Approve all 79 (Recommended)\"", Oct30="30 October 2026", Nov1="1 November 2026",
        S3="\"Default, not operative (Recommended)\"", S3All="\"Same answer for all 4 (Recommended)\"", Nov10="10 November 2026";
    [Theory]
    [InlineData("0")][InlineData("1")][InlineData("34")][InlineData("-1")][InlineData("1.5")]
    public void Gdd03LoaderRefusesEveryNumericArmyGuessWhileDeferred(string number)
    {
        var yaml=$"ruleset: gdd-0.3\nvalues:\n  start.army: {{ basis: Deferred, values: [{number}], note: test }}\n";
        var dir=Fixture.Write(new Dictionary<string,string>{{CatalogueFile,yaml}});
        var ex=Assert.Throws<ContentException>(()=>ContentLoader.Load(dir));
        Assert.Equal(CatalogueFile,ex.File); Assert.Contains("start.army",ex.Message); Assert.Contains("Deferred",ex.Message);
    }
    [Fact] public void Gdd03LoaderRefusesNumericArmyExpressionAndUnapprovedPromotion()
    {
        foreach(var row in new[]{"basis: Deferred, expression: '12'", "basis: Default, values: [12]", "basis: Agreed, values: [12]"})
        {
            var dir=Fixture.Write(new Dictionary<string,string>{{CatalogueFile,$"ruleset: gdd-0.3\nvalues:\n  start.army: {{ {row}, note: test }}\n"}});
            var ex=Assert.Throws<ContentException>(()=>ContentLoader.Load(dir)); Assert.Contains("start.army",ex.Message);
        }
    }
    [Theory][InlineData("Guessed")][InlineData("")]
    public void Gdd03LoaderRefusesUnlabelledValues(string basis)
    {
        var dir=Fixture.Write(new Dictionary<string,string>{{CatalogueFile,$"ruleset: gdd-0.3\nvalues:\n  start.army: {{ basis: '{basis}', expression: A, note: test }}\n"}});
        Assert.Throws<ContentException>(()=>ContentLoader.Load(dir));
    }
    [Fact] public void Gdd03CatalogueOnlyAcceptsExactDecimalNumbersAndLabelledParts()
    {
        void Check(Dictionary<object,object> row)
        {
            Assert.Contains((string)row["basis"],new[]{"Agreed","Default","Deferred"}); Assert.False(string.IsNullOrWhiteSpace((string)row["note"]));
            if(row.TryGetValue("values",out var nums)) foreach(var x in (List<object>)nums)
                Assert.True(decimal.TryParse(x.ToString(),NumberStyles.AllowLeadingSign|NumberStyles.AllowDecimalPoint,CultureInfo.InvariantCulture,out _));
            if(row.TryGetValue("parts",out var parts)) foreach(var x in ((Dictionary<object,object>)parts).Values) Check((Dictionary<object,object>)x);
        }
        foreach(var r in Row(Catalogue(),"values").Values) Check((Dictionary<object,object>)r);
    }
    [Fact] public void Gdd03CatalogueLoadsWithoutChangingTheExistingLoopAndUsesDecimals()
    {
        var c=ContentLoader.Load(RealContentTests.ContentRoot());
        Assert.NotNull(c.Gdd03Balance); Assert.Equal(SaveGame.GddRuleset,c.Ruleset);
        var v=c.Gdd03Balance.Values;
        Assert.Equal(10000m,Assert.Single(v["population.people_per_unit"].Values));
        Assert.Equal(new[]{0.75m,1m,1.5m},v["pioneer.work_rate"].Values);
        Assert.Equal(0.10m,Assert.Single(v["maabara"].Parts["upkeep"].Values));
        Assert.Equal(0.5m,Assert.Single(v["housing_repair"].Parts["cost"].Values));
        Assert.Equal(65m,Assert.Single(v["start.population"].Values));
        Assert.Equal(new[]{5m,10m,5m},v["start.farmers"].Values);
        Assert.Equal(new[]{0.5m,1m,2m},v["combat.draw_count"].Parts["ratio_thresholds"].Values);
        Assert.Null(ContentLoader.Load(Fixture.Write()).Gdd03Balance); // old authored content still loads
    }
    // The owner's #1700 ruling (docs/GDD.md, "Housing repair price"): "Fixed price 0.5 Money + 1 work", +10 pp condition.
    // Catalogue only: no gameplay path reads the repair cost or work yet (Gdd03HousingFormula reads condition_pp only).
    [Fact] public void HousingRepairCatalogueHoldsTheOwnersFixedPrice()
    {
        var repair = ContentLoader.Load(RealContentTests.ContentRoot()).Gdd03Balance!.Values["housing_repair"];
        Assert.Empty(repair.Parts["cost"].Expression);
        Assert.Equal(0.5m, Assert.Single(repair.Parts["cost"].Values));
        Assert.Equal(1m, Assert.Single(repair.Parts["work"].Values));
        Assert.Equal(10m, Assert.Single(repair.Parts["condition_pp"].Values));
    }
    // R-LOOP-005: every numeric gdd-0.3 catalogue row is checked when the authored file loads.
    // Sets one row's values (or one part's), found by its YAML key, whatever its current value or note text says.
    static string WithValues(string yaml, string key, string values, string? part=null)
    {
        var lines=yaml.Split('\n');
        int Single(int from, int to, Func<string,bool> match)
        {
            var hits=Enumerable.Range(from,to-from).Where(i=>match(lines[i].TrimEnd('\r'))).ToList();
            Assert.Single(hits);
            return hits[0];
        }
        int BlockEnd(int start, int indent)
        {
            var i=start+1;
            while (i<lines.Length && (lines[i].Trim().Length==0 || lines[i].Length-lines[i].TrimStart(' ').Length>indent)) i++;
            return i;
        }
        var at=Single(0,lines.Length,l=>l=="  \""+key+"\":");
        int from=at+1, to=BlockEnd(at,2), indent=4;
        if (part!=null)
        {
            at=Single(from,to,l=>l=="      \""+part+"\":");
            (from,to,indent)=(at+1,BlockEnd(at,6),8);
        }
        var prefix=new string(' ',indent)+"\"values\": [";
        var line=Single(from,to,l=>l.StartsWith(prefix,StringComparison.Ordinal) && l.EndsWith("]",StringComparison.Ordinal));
        lines[line]=prefix+values+"]";
        return string.Join("\n",lines);
    }
    static Dictionary<string,string> Gdd03RulesetFiles(string catalogue)
    {
        var files=Fixture.Gdd(new Dictionary<string,string>{{CatalogueFile,catalogue}});
        files["eras.yaml"]=files["eras.yaml"].Replace("loop: gdd", "loop: gdd, ruleset: gdd-0.3");
        return files;
    }
    static ContentException RefusedNumber(string key, string values)
    {
        var yaml=File.ReadAllText(Path.Combine(RealContentTests.ContentRoot(),CatalogueFile));
        var dir=Fixture.Write(Gdd03RulesetFiles(WithValues(yaml,key,values)));
        return Assert.Throws<ContentException>(()=>ContentLoader.Load(dir));
    }
    [Fact] public void Gdd03LoaderRefusesNegativeCountsAtLoad()
    {
        var ex=RefusedNumber("import.delivery_turns","-1");
        Assert.Equal(CatalogueFile,ex.File); Assert.Equal("values.import.delivery_turns",ex.Field);
        Assert.Contains("must be a whole number >= 0",ex.Message);
    }
    [Fact] public void Gdd03LoaderRefusesNegativePricesAtLoad()
    {
        var ex=RefusedNumber("craft.course_cost","-0.5");
        Assert.Equal(CatalogueFile,ex.File); Assert.Equal("values.craft.course_cost",ex.Field);
        Assert.Contains("must be >= 0",ex.Message);
    }
    [Fact] public void Gdd03LoaderRefusesFractionsOutsideZeroToOneAtLoad()
    {
        var ex=RefusedNumber("start.housing_condition","1.01");
        Assert.Equal(CatalogueFile,ex.File); Assert.Equal("values.start.housing_condition",ex.Field);
        Assert.Contains("must be between 0 and 1",ex.Message);
    }
    [Fact] public void Gdd03LoaderRefusesPercentsOutsideZeroToOneHundredAtLoad()
    {
        var ex=RefusedNumber("immigration.mix","101, 10, 10, 5");
        Assert.Equal(CatalogueFile,ex.File); Assert.Equal("values.immigration.mix",ex.Field);
        Assert.Contains("must be between 0 and 100",ex.Message);
    }
    [Fact] public void Gdd03NumericRulesAllowListedNegativeException()
    {
        var yaml=File.ReadAllText(Path.Combine(RealContentTests.ContentRoot(),CatalogueFile));
        var catalogue=ContentLoader.Load(Fixture.Write(Gdd03RulesetFiles(WithValues(yaml,"permanent_housing","-10","condition_pp")))).Gdd03Balance;
        Assert.NotNull(catalogue);
        Assert.Equal(-10m,Assert.Single(catalogue.Values["permanent_housing"].Parts["condition_pp"].Values));
    }
    [Fact] public void Gdd03NumericRulesAcceptTheRealCatalogueAndEveryListedKeyExists()
    {
        var yaml=File.ReadAllText(Path.Combine(RealContentTests.ContentRoot(),CatalogueFile));
        var files=Fixture.Gdd(new Dictionary<string,string>{{CatalogueFile,yaml}});
        files["eras.yaml"]=files["eras.yaml"].Replace("loop: gdd", "loop: gdd, ruleset: gdd-0.3");
        var catalogue=ContentLoader.Load(Fixture.Write(files)).Gdd03Balance;
        Assert.NotNull(catalogue);
        Assert.Equal(-10m,Assert.Single(catalogue.Values["maabara"].Parts["condition_pp"].Values));
        var listed=Gdd03BalanceCatalogue.NegativeExceptions.Keys
            .Concat(Gdd03BalanceCatalogue.WholeNumberKeys)
            .Concat(Gdd03BalanceCatalogue.FractionKeys)
            .Concat(Gdd03BalanceCatalogue.PercentKeys).ToList();
        Assert.Equal(listed.Count,listed.Distinct(StringComparer.Ordinal).Count());
        foreach (var at in listed)   // a misspelt key would silently check nothing
        {
            var path=at.Substring("values.".Length).Split(new[]{".parts."},StringSplitOptions.None);
            var row=catalogue.Values[path[0]];
            if (path.Length==2) row=row.Parts[path[1]];
            Assert.NotEmpty(row.Values);
        }
    }
    [Theory]
    [InlineData("bad: { basis: Unknown, values: [1], note: test }")]
    [InlineData("bad: { basis: Agreed, values: [1] }")]
    [InlineData("bad: { basis: Agreed, values: } ")]
    [InlineData("bad: { basis: Agreed, parts: } ")]
    [InlineData("bad: null")]
    [InlineData("bad: { basis: Agreed, parts: { cost: null }, note: test }")]
    [InlineData("bad: { basis: Deferred, values: [1], note: test }")]
    [InlineData("bad: { basis: Agreed, values: [1], expression: A, note: test }")]
    [InlineData("bad: { basis: Agreed, values: [1], typo: wrong, note: test }")]
    [InlineData("bad: { basis: Agreed, values: [1], note: test }\n  bad: { basis: Default, values: [2], note: test }")]
    public void Gdd03LoaderRejectsMalformedEntriesAndParts(string row)
    {
        var yaml="ruleset: gdd-0.3\nvalues:\n  start.army: { basis: Deferred, expression: A, note: test }\n  "+row+"\n";
        var dir=Fixture.Write(new Dictionary<string,string>{{CatalogueFile,yaml}});
        var ex=Assert.Throws<ContentException>(()=>ContentLoader.Load(dir)); Assert.Equal(CatalogueFile,ex.File);
    }
    // R-LOOP-005, #2112 (owner, 1 November 2026: "Main's base x 0.3's tiers (Recommended)"): at D2's 1,000 people a unit the
    // tier rates are multiples of main's per-unit rate, counts sized in 10,000-people units are x10, and the absorption
    // target is in people.
    [Theory]
    [InlineData("industry.income", "1 2 3", "R-CITY-002")]
    [InlineData("farmer.output", "2 3 5", "field_food_per_turn")]
    [InlineData("military.camp_capacity", "50", "10,000 people a unit")]
    [InlineData("absorption.population_target", "1000000", "people, not population units")]
    public void Gdd03PerUnitRatesFollowMainsBaseTimesTheTiers(string key, string values, string basis)
    {
        var row=ContentLoader.Load(RealContentTests.ContentRoot()).Gdd03Balance!.Values[key];
        Assert.Equal("Agreed",row.Basis);
        Assert.Equal(values.Split(' ').Select(x=>decimal.Parse(x,CultureInfo.InvariantCulture)),row.Values);
        Assert.Contains("\"Main's base x 0.3's tiers (Recommended)\"",row.Note);
        Assert.Contains("1 November 2026",row.Note);
        Assert.Contains("design value",row.Note);
        Assert.Contains(basis,row.Note);
        Assert.Contains("Source: #1668 balance.md at 605277df.",row.Note);
    }
    // R-HOUSE-005, #1703 (owner, 2 November 2026: "Scale it to unit size (Recommended)"; the option read: "0.1 per unit (as
    // #2112 did for Industry), about 7.6 Money a turn at start."): the surcharge's slope is 0.1 Money per housed unit.
    [Fact]
    public void Gdd03HousingSurchargeSlopeIsScaledToUnitSize()
    {
        var row=ContentLoader.Load(RealContentTests.ContentRoot()).Gdd03Balance!.Values["housing.money_slope"];
        Assert.Equal("Agreed",row.Basis);
        Assert.Equal(new[]{0.1m},row.Values);
        Assert.Contains("\"Scale it to unit size (Recommended)\"",row.Note);
        Assert.Contains("2 November 2026",row.Note);
        Assert.Contains("design value",row.Note);
        Assert.Contains("Source: #1668 balance.md at 605277df.",row.Note);
    }

}