A Civilization-style strategy game about governing Israel from 15 May 1948. Real ministers, real map, every fact sourced. Unity + deterministic C# sim.
Sim: align the gdd-0.3 project-build and absorption fixtures with the one-builder and no-waiting-block rulings (Fixes #2514) (#2668)
Beri0ef9a77f9535
diff --git a/changelog.d/2514-gdd03-fixtures.md b/changelog.d/2514-gdd03-fixtures.mdnew file mode 100644index 000000000..6bbd739c4--- /dev/null+++ b/changelog.d/2514-gdd03-fixtures.md@@ -0,0 +1,5 @@+### Changed++- GDD 0.3 test fixtures follow the later rulings (Fixes #2514): the detached project-build fixture now gives a project+ one builder and counts each turn with it as one of the kind's turns, and the detached absorption check no longer+ blocks on refugees waiting for a bed. Nothing in the game calls either one, so play is unchanged.diff --git a/docs/rules/mvp.md b/docs/rules/mvp.mdindex 9f51c9726..9ed7aa23f 100644--- a/docs/rules/mvp.md+++ b/docs/rules/mvp.md@@ -164,9 +164,9 @@ R-PROJ-005: A specialised project is allowed only in a city that has its resourcR-CITY-011: Under gdd-0.3 only (owner, 3 November 2026: "Builders in the MVP (Recommended)", "One builder, today's times (Recommended)", "Yes, if someone is free"; #1700 slice A), a city project being built has at most one builder. A builder is one of the city's civilians and craftsmen who hold no job and are not a staffed arms workshop's worker or another project's builder (a free person). The builder stays one of them, with no job, profession or qualification change, is not employed (R-CITY-001) and earns no job income (R-CITY-002). `Train`, `ReassignPioneers`, a `job` count, the job default (R-CITY-009) and a workshop's worker cannot take a builder. `StartProject` takes the city's free person as the new project's builder when it has one, at the moment the start runs, in queue order: a `Train` or `AssignWorkers` queued before the start has already changed the count, and one queued after it sees the builder as taken. Otherwise the project starts with no builder; it never takes anyone out of a job, the job default's included, and a project that waits does not pick up a person who becomes free later. On the aggregate cities the builder is one unit of the city's count, counted at the ordinary tier (no cost in the MVP). `AssignWorkers(city, "build", n)` sets the number of the city's projects being built that have a builder: a rise puts builders on the projects that have none, in ascending project id; a fall takes them off the projects that have one, in descending project id. It is refused, with the state unchanged, for an unknown city; a negative count; more than the city's projects being built ("Town A has 1 city project being built"); or more new builders than the city's free people ("... civilians and craftsmen without a job"), with R-ARMS-005's job-default rule (while the default is on, an order may take a builder from the default's jobs, and is refused only past the city's civilians and craftsmen less its staffed workshops and builders). Under every other ruleset the role is refused as "There is no such role". A project's builder is freed when it is built or cancelled. A freed builder does not move to another project by itself. The limits a panel reads with this turn's queue (`Training.Available`, `Workshops.Check`, `Cities.MaxWorkers`) also count the builder each queued `StartProject` in the city may take, so a count up to them is accepted whichever order runs first. On step 6 the staffed arms workshops share the city's people without a job with the builders, who took theirs at step 5 (R-ARMS-006). The Why screen says when a builder starts on a project ("Town: a builder started on a housing project") and when one is freed, as the project is built or cancelled or the `build` count falls ("Town: a builder left a housing project and is free again", #1700 slice B).-For R-PROJ-001 and R-PROJ-003, the preceding rules and the IL 0m upkeep of R-MONEY-002 remain unchanged in the game. The inactive gdd-0.3 addition is `Gdd03ProjectBuildFixture`, synthetic builder rules over the #1963 project catalogue (#1700; no command, save, loader, resolver or UI caller). A start pays the kind's full catalogue cost up front; when Money is short the start goes ahead and the shortfall is borrowed as R-MONEY-003 says, Money stopping at 0 and the rest moving to the fixture's debt (owner, 1 November 2026, D1: "Approve all six (Recommended)"). The record holds work done, not turns left. Each turn only assigned builders add work, at the catalogue's ordinary-or-novice, apprentice or expert rate (1, 1.5, 3), at most `builder.slots_per_project` (3) on one project; a project with no builders makes no progress. Money is not an input to progress, so extra Money never changes the completion turn (Amir, 28 October 2026, recorded on #1668: "Extra Money cannot replace work or speed completion. Housing and improvements also require Money for upkeep."). Work past the kind's `work` is discarded and the project completes that turn; builders are then released, and an order to a completed project is refused. From the completion turn on, every turn, a completed project is charged R-MONEY-002's MVP rate, IL 0m, vacant or not, so Money does not change; the catalogue's non-zero `upkeep` is post-MVP and unused (owner's 30 October 2026 "Keep ruling" on UPKEEP, kept on #1700 on 1 November 2026). A city starts at most one project a turn, and two starts are allowed a turn nationally, as R-PROJ-001 under gdd-0.3 (owner, 3 November 2026: "One per city, plus 2 nationally"): a second start in the same city, or a third in the country, is refused before anything is paid, the city's limit first, with Money, debt and every project unchanged, and both counts reset when the turn ends; projects already running keep progressing. The catalogue's `construction.starts_per_turn` (1, "nationwide per turn") is Amir's catalogue reading; the live rule is R-PROJ-001's. The fixture has no pioneer start, so pioneer work (#1713) never uses the allowance. Cancel, housing repair, completion effects and the live integration are other #1700 slices.+For R-PROJ-001 and R-PROJ-003, the preceding rules and the IL 0m upkeep of R-MONEY-002 remain unchanged in the game. The inactive gdd-0.3 addition is `Gdd03ProjectBuildFixture`, synthetic builder rules over the #1963 project catalogue (#1700; no command, save, loader, resolver or UI caller). A start pays the kind's full catalogue cost up front; when Money is short the start goes ahead and the shortfall is borrowed as R-MONEY-003 says, Money stopping at 0 and the rest moving to the fixture's debt (owner, 1 November 2026, D1: "Approve all six (Recommended)"). A project has at most one builder, and each turn with its builder counts as one turn of the kind's `turns` in `content/projects.yaml` (owner, 3 November 2026, [#1700](https://github.com/eyalgolan/statecraft-israel/issues/1700#issuecomment-6597217639): "One builder, today's times (Recommended)"); a project with no builder makes no progress, and an order naming one project twice is refused with nothing changed. The record holds the turns its builder has worked. A catalogue kind with no row of the same id in `content/projects.yaml` (today all but `industry` and `arms_workshop`) has no `turns` to count, so its start is refused before anything is paid (maintainer reading). Money is not an input to progress, so extra Money never changes the completion turn (Amir, 28 October 2026, recorded on #1668: "Extra Money cannot replace work or speed completion. Housing and improvements also require Money for upkeep."). The project completes on the turn its builder works the kind's last turn; the builder is then released, and an order to a completed project is refused. From the completion turn on, every turn, a completed project is charged R-MONEY-002's MVP rate, IL 0m, vacant or not, so Money does not change; the catalogue's non-zero `upkeep` is post-MVP and unused (owner's 30 October 2026 "Keep ruling" on UPKEEP, kept on #1700 on 1 November 2026). A city starts at most one project a turn, and two starts are allowed a turn nationally, as R-PROJ-001 under gdd-0.3 (owner, 3 November 2026: "One per city, plus 2 nationally"): a second start in the same city, or a third in the country, is refused before anything is paid, the city's limit first, with Money, debt and every project unchanged, and both counts reset when the turn ends; projects already running keep progressing. The catalogue's `construction.starts_per_turn` (1, "nationwide per turn") is Amir's catalogue reading; the live rule is R-PROJ-001's. The fixture has no pioneer start, so pioneer work (#1713) never uses the allowance. Cancel, housing repair, completion effects and the live integration are other #1700 slices.-Then changed (3 Nov 2026, [#1700](https://github.com/eyalgolan/statecraft-israel/issues/1700#issuecomment-6597217639)): the owner chose the option labelled "One builder, today's times (Recommended)". A project has at most one builder, and a turn with its builder counts as one turn of the kind's existing `turns`, as R-CITY-011 and the `gdd-0.3` parts of R-PROJ-001 to R-PROJ-003 build it in the game; the builder tiers, their rates (1, 1.5, 3) and `builder.slots_per_project` (3) above are set aside for the MVP. `Gdd03ProjectBuildFixture` still sums the tiered rates until #2514.+Then changed (3 Nov 2026, [#1700](https://github.com/eyalgolan/statecraft-israel/issues/1700#issuecomment-6597217639)): the owner chose the option labelled "One builder, today's times (Recommended)". A project has at most one builder, and a turn with its builder counts as one turn of the kind's existing `turns`, as R-CITY-011 and the `gdd-0.3` parts of R-PROJ-001 to R-PROJ-003 build it in the game; the builder tiers, their rates (1, 1.5, 3) and `builder.slots_per_project` (3) above are set aside for the MVP. `Gdd03ProjectBuildFixture` follows this since #2514.## Training@@ -416,9 +416,9 @@ R-OBJ-004: An objective may instead name `completes_when: { absorbed: { populatiFor R-OBJ-004, the preceding active gdd-0.1 rule remains unchanged. The gdd-0.3 addition is an inactive, synthetic-only boundary: `Gdd03SyntheticAbsorptionBoundary.HoldsForSyntheticSettledFacts` accepts supplied represented own units, a canonical refugee-awaiting-legal-bed flag, ordinary-housing overflow/demand and employed/all-free-civilian counts; it neither produces nor classifies them (`sim/Statecraft.Sim/Gdd03SyntheticAbsorptionBoundary.cs:6-25@1e4b8a248`). Source: `docs/gdd/objective-card.md:19@605277dfa511dc512562ececeb273b8393b21d35`, "Empty denominators mean no overflow/full employment." and "Reference remains 20 December 1949"; `docs/gdd/balance.md:195-196` at that source revision gives the exceeded population target and inclusive percentage limits.-The synthetic boundary reads the supplied catalogue's Agreed population scale, target and percentages. With the current scale and thresholds, 100 units fail and 101 pass; overflow exactly 10% and employment exactly 40% pass. A true waiting flag blocks the result; the tests supply false for a legal reception bed and true for a port queue or refugee evacuation transit, without implementing that classification. Each valid 0/0 pair passes its ratio subcondition, but cannot bypass population or waiting. Exact BigInteger cross-products avoid rounded shares. Null/wrong-identity catalogues, missing, Deferred, non-Agreed or malformed quantities and negative/non-subset counts throw before any failing gate can hide them; the population scale retains the positive Int32 bound, the target must be positive and whole, and percentage limits must be whole numbers in 0..100 (`sim/Statecraft.Sim/Gdd03SyntheticAbsorptionBoundary.cs:27-65@1e4b8a248`; `sim/Statecraft.Sim/Content.cs:1270-1278@1e4b8a248`; boundary tests in `sim/Statecraft.Sim.Tests/Gdd03SyntheticAbsorptionBoundaryTests.cs:12-108@1e4b8a248`, scale/threshold/exact-product fixtures at `:114-190` at the same head).+The synthetic boundary reads the supplied catalogue's Agreed population scale, target and percentages. With the current scale and thresholds, 100 units fail and 101 pass; overflow exactly 10% and employment exactly 40% pass. The waiting flag does not block the result (see the change below); the tests supply false for a legal reception bed and true for a port queue or refugee evacuation transit, and both pass when the other gates pass, without implementing that classification. Each valid 0/0 pair passes its ratio subcondition, but cannot bypass population. Exact BigInteger cross-products avoid rounded shares. Null/wrong-identity catalogues, missing, Deferred, non-Agreed or malformed quantities and negative/non-subset counts throw before any failing gate can hide them; the population scale retains the positive Int32 bound, the target must be positive and whole, and percentage limits must be whole numbers in 0..100 (`sim/Statecraft.Sim/Gdd03SyntheticAbsorptionBoundary.cs:27-65@1e4b8a248`; `sim/Statecraft.Sim/Content.cs:1270-1278@1e4b8a248`; boundary tests in `sim/Statecraft.Sim.Tests/Gdd03SyntheticAbsorptionBoundaryTests.cs:12-108@1e4b8a248`, scale/threshold/exact-product fixtures at `:114-190` at the same head).-Then changed (1 Nov 2026, [#1696](https://github.com/eyalgolan/statecraft-israel/issues/1696#issuecomment-6554002672)): the owner chose the option labelled "No reception-bed layer (Recommended)", so in the MVP a waiting flag does not block the result; option (a) ([#738](https://github.com/eyalgolan/statecraft-israel/issues/738#issuecomment-6249499957)) has no waiting clause, and the live R-OBJ-004 check reads population, overflow and employment only (`docs/gdd/objective-card.md`). `Gdd03SyntheticAbsorptionBoundary` still blocks on the flag until #2514.+Then changed (1 Nov 2026, [#1696](https://github.com/eyalgolan/statecraft-israel/issues/1696#issuecomment-6554002672)): the owner chose the option labelled "No reception-bed layer (Recommended)", so in the MVP a waiting flag does not block the result; option (a) ([#738](https://github.com/eyalgolan/statecraft-israel/issues/738#issuecomment-6249499957)) has no waiting clause, and the live R-OBJ-004 check reads population, overflow and employment only (`docs/gdd/objective-card.md`). Since #2514 `Gdd03SyntheticAbsorptionBoundary` keeps the flag as a parameter and ignores it.No live completion or completion date is recorded. The #1714 status comment of 27 October 2026 says, "It does not yet compute actual regional totals or award the objective." Represented population (#1689), regional aggregation and approved locations (#1691; #1690 closed on 2 November 2026, its post-MVP regional pools moved to #2233), shared employment (#1692/#1702, also to feed #1715), canonical waiting (#1696), housing (#1703), and monthly-versus-end-state sampling (#1716) remain pending integration decisions/evidence, not choices made by this helper (`sim/Statecraft.Sim/Gdd03SyntheticAbsorptionBoundary.cs:6-17@1e4b8a248`; #1714 status comment, "Human check pending: unresolved rules for combining totals and when to count people"). The 20 December 1949 reference is retained; this slice does not select when to award it.diff --git a/sim/Statecraft.Sim.Tests/Gdd03ProjectBuildFixtureTests.cs b/sim/Statecraft.Sim.Tests/Gdd03ProjectBuildFixtureTests.csindex e8a202676..588b2d3ef 100644--- a/sim/Statecraft.Sim.Tests/Gdd03ProjectBuildFixtureTests.cs+++ b/sim/Statecraft.Sim.Tests/Gdd03ProjectBuildFixtureTests.cs@@ -1,9 +1,10 @@-using System.Collections.Generic;using Statecraft.Sim;// R-PROJ-001, R-PROJ-003: #1700 builder rules over the #1963 catalogue, synthetic fixtures only.// Amir, 28 Oct 2026 (#1668): "Extra Money cannot replace work or speed completion. Housing and improvements also// require Money for upkeep."+// Owner, 3 Nov 2026 (#1700): "One builder, today's times (Recommended)": one builder a project, and a turn with its+// builder counts as one turn of the kind's existing `turns` (content/projects.yaml: industry 6).public class Gdd03ProjectBuildFixtureTests{// The national limit comes from the loaded rules (map_actions_per_turn); a test may override it to prove that.@@ -13,23 +14,22 @@ public class Gdd03ProjectBuildFixtureTests// Synthetic identity selection only; no scenario, region or facility binding.content.Eras = new() { new Era { Systems = new EraSystems { Loop = EraSystems.Gdd, Ruleset = SaveGame.Gdd03Ruleset } } };if (mapActionsPerTurn != null) content.Rules.MapActionsPerTurn = mapActionsPerTurn.Value;- return new Gdd03ProjectBuildFixture(Gdd03ProjectCatalogue.Read(content), content.Rules, money);+ return new Gdd03ProjectBuildFixture(Gdd03ProjectCatalogue.Read(content), content.Rules, content.ProjectKinds, money);}- static readonly IReadOnlyDictionary<int, Gdd03BuilderTier[]> Nobody = new Dictionary<int, Gdd03BuilderTier[]>();- static IReadOnlyDictionary<int, Gdd03BuilderTier[]> On(int id, params Gdd03BuilderTier[] tiers)- => new Dictionary<int, Gdd03BuilderTier[]> { [id] = tiers };+ static readonly int[] Nobody = new int[0];+ static int[] On(params int[] ids) => ids;[Fact]- public void AFundedProjectWithNoBuildersMakesNoProgress()+ public void AFundedProjectWithNoBuilderMakesNoProgress(){- var f = New(5m);- var id = f.Start("maabara", "town_a"); // 5 Money, 1 work+ var f = New(10m);+ var id = f.Start("industry", "town_a"); // 10 Money, 6 turnsAssert.Equal(0m, f.Money); // the full cost up front (R-PROJ-001)for (var i = 0; i < 10; i++) f.EndTurn(Nobody);var p = Assert.Single(f.Projects);Assert.Equal(id, p.Id);- Assert.Equal(0m, p.WorkDone);+ Assert.Equal(0, p.TurnsDone);Assert.Null(p.CompletedTurn);Assert.Equal(0m, f.Money); // an unfinished project owes no upkeep}@@ -40,80 +40,88 @@ public class Gdd03ProjectBuildFixtureTestsint? Completion(decimal money){var f = New(money);- var id = f.Start("permanent_housing", "town_a"); // 15 Money, 3 work- // Builders are released on completion, so they work only while the project is open.- for (var i = 0; i < 10 && f.Projects[0].CompletedTurn == null; i++) f.EndTurn(On(id, Gdd03BuilderTier.OrdinaryOrNovice));+ var id = f.Start("industry", "town_a"); // 10 Money, 6 turns+ // The builder is released on completion, so it works only while the project is open.+ for (var i = 0; i < 10 && f.Projects[0].CompletedTurn == null; i++) f.EndTurn(On(id));return f.Projects[0].CompletedTurn;}- Assert.Equal(3, Completion(15m)); // one ordinary builder: 1 work a turn- Assert.Equal(3, Completion(1000m));+ Assert.Equal(6, Completion(10m)); // one builder: one of the kind's 6 turns a turn+ Assert.Equal(6, Completion(1000m));}[Fact]public void ACompletedImprovementChargesItsUpkeepEachTurnEvenVacant(){var f = New(20m);- var id = f.Start("industry", "town_a"); // 10 Money, 3 work; the catalogue's 0.25 upkeep is post-MVP+ var id = f.Start("industry", "town_a"); // 10 Money, 6 turns; the catalogue's 0.25 upkeep is post-MVPAssert.Equal(10m, f.Money);- f.EndTurn(On(id, Gdd03BuilderTier.Expert)); // 3 work: complete on turn 1- Assert.Equal(1, f.Projects[0].CompletedTurn);+ for (var i = 0; i < 6; i++) f.EndTurn(On(id));+ Assert.Equal(6, f.Projects[0].CompletedTurn);Assert.Equal(10m, f.Money); // charged the MVP rate, IL 0m (R-MONEY-002), from the completion turn+ Assert.Throws<System.InvalidOperationException>(() => f.EndTurn(On(id))); // the builder was releasedf.EndTurn(Nobody);f.EndTurn(Nobody);Assert.Equal(10m, f.Money); // and every turn after, with no one working thereAssert.Equal(0m, f.Debt);- Assert.Equal(3m, f.Projects[0].WorkDone);+ Assert.Equal(6, f.Projects[0].TurnsDone);}[Fact]- public void AShortStartBorrowsAndBuildersAreCappedAtTheSlots()+ public void AShortStartBorrowsAndAProjectHasOneBuilder(){- var f = New(14m);- f.Start("permanent_housing", "town_a"); // 15 Money: the 1 short is borrowed (D1, R-MONEY-003)+ var f = New(4m);+ f.Start("industry", "town_a"); // 10 Money: the 6 short is borrowed (D1, R-MONEY-003)Assert.Equal(0m, f.Money);- Assert.Equal(1m, f.Debt);+ Assert.Equal(6m, f.Debt);f.EndTurn(Nobody); // one start a city a turn (R-PROJ-001 under gdd-0.3)var id = f.Start("industry", "town_a"); // 10 Money, all borrowedAssert.Equal(0m, f.Money);- Assert.Equal(11m, f.Debt);+ Assert.Equal(16m, f.Debt);Assert.Equal(2, f.Projects.Count);- var four = On(id, Gdd03BuilderTier.OrdinaryOrNovice, Gdd03BuilderTier.OrdinaryOrNovice,- Gdd03BuilderTier.OrdinaryOrNovice, Gdd03BuilderTier.OrdinaryOrNovice);- Assert.Throws<System.InvalidOperationException>(() => f.EndTurn(four));- Assert.Equal(0m, f.Projects[1].WorkDone);- Assert.Throws<System.InvalidOperationException>(() => f.EndTurn(On(id, (Gdd03BuilderTier)7))); // no such tier- Assert.Equal(0m, f.Projects[1].WorkDone);- Assert.Equal(1, f.Turn);- f.EndTurn(On(id, Gdd03BuilderTier.Apprentice)); // 1.5 of 3- Assert.Equal(1.5m, f.Projects[1].WorkDone);+ Assert.Throws<System.InvalidOperationException>(() => f.EndTurn(On(id, id))); // a second builder on one project+ Assert.Equal(0, f.Projects[1].TurnsDone);+ Assert.Throws<System.InvalidOperationException>(() => f.EndTurn(On(id, 99))); // no such project+ Assert.Equal(0, f.Projects[1].TurnsDone);+ Assert.Equal(1, f.Turn); // a refused turn changes nothing+ f.EndTurn(On(id)); // 1 of 6+ Assert.Equal(1, f.Projects[1].TurnsDone);Assert.Null(f.Projects[1].CompletedTurn);}+ // The catalogue kinds with no row in content/projects.yaml have no `turns` the ruling could count, so the fixture+ // refuses them before anything is paid rather than invent a length.+ [Fact]+ public void AKindWithNoTurnsInProjectsYamlIsRefusedBeforeAnythingIsPaid()+ {+ var f = New(100m);+ var e = Assert.Throws<System.InvalidOperationException>(() => f.Start("maabara", "town_a"));+ Assert.Equal("No turns in projects.yaml for project kind: maabara", e.Message);+ Assert.Equal((100m, 0m, 0), (f.Money, f.Debt, f.Projects.Count));+ f.Start("industry", "town_a"); // the refusal used no start+ Assert.Single(f.Projects);+ }+[Fact]public void OneStartACityATurnAndRunningProjectsCarryOn(){// #1700 slice B (owner, 3 November 2026: "One per city, plus 2 nationally"), the gdd-0.3 note under R-PROJ-001.var f = New(30m);- var housing = f.Start("permanent_housing", "town_a"); // the city's one start this turn- Assert.Equal(15m, f.Money);- Assert.Throws<System.InvalidOperationException>(() => f.Start("maabara", "town_a")); // a second start in the city- Assert.Equal(15m, f.Money); // refused with Money and state unchanged+ var first = f.Start("industry", "town_a"); // the city's one start this turn+ Assert.Equal(20m, f.Money);+ Assert.Throws<System.InvalidOperationException>(() => f.Start("industry", "town_a")); // a second start in the city+ Assert.Equal(20m, f.Money); // refused with Money and state unchangedAssert.Equal(0m, f.Debt);Assert.Single(f.Projects);- f.EndTurn(On(housing, Gdd03BuilderTier.OrdinaryOrNovice));- var industry = f.Start("industry", "town_a"); // a new turn, a new start- Assert.Equal(5m, f.Money);- Assert.Throws<System.InvalidOperationException>(() => f.Start("maabara", "town_a"));- Assert.Equal(5m, f.Money);+ f.EndTurn(On(first));+ var second = f.Start("industry", "town_a"); // a new turn, a new start+ Assert.Equal(10m, f.Money);+ Assert.Throws<System.InvalidOperationException>(() => f.Start("industry", "town_a"));+ Assert.Equal(10m, f.Money);Assert.Equal(2, f.Projects.Count);// The refused start does not stop projects already running.- f.EndTurn(new Dictionary<int, Gdd03BuilderTier[]>- {- [housing] = new[] { Gdd03BuilderTier.OrdinaryOrNovice },- [industry] = new[] { Gdd03BuilderTier.Expert }- });- Assert.Equal(2m, f.Projects[0].WorkDone);- Assert.Equal(2, f.Projects[1].CompletedTurn);+ f.EndTurn(On(first, second));+ Assert.Equal(2, f.Projects[0].TurnsDone);+ Assert.Equal(1, f.Projects[1].TurnsDone);}[Fact]diff --git a/sim/Statecraft.Sim.Tests/Gdd03SyntheticAbsorptionBoundaryTests.cs b/sim/Statecraft.Sim.Tests/Gdd03SyntheticAbsorptionBoundaryTests.csindex 0784e79aa..81af2618a 100644--- a/sim/Statecraft.Sim.Tests/Gdd03SyntheticAbsorptionBoundaryTests.cs+++ b/sim/Statecraft.Sim.Tests/Gdd03SyntheticAbsorptionBoundaryTests.cs@@ -18,14 +18,17 @@ public class Gdd03SyntheticAbsorptionBoundaryTestsCatalogue(), own, false, 0, 0, 0, 0));}- // The caller supplies canonical waiting, not a location/status inferred by this predicate.+ // Refugees waiting never block the result in the MVP (owner, 1 November 2026, #1696: "No reception-bed layer+ // (Recommended)"; option (a) of #738 has no waiting clause), so either flag passes when the other gates pass.[Theory]- [InlineData(false, true)] // synthetic legal reception bed: no waiting- [InlineData(true, false)] // synthetic port queue OR refugee evacuation transit: waiting- public void OnlyTheSuppliedCanonicalWaitingFlagBlocksReception(bool waiting, bool expected)+ [InlineData(false)] // synthetic legal reception bed: no waiting+ [InlineData(true)] // synthetic port queue OR refugee evacuation transit: waiting+ public void TheWaitingFlagDoesNotBlockTheResult(bool waiting){- Assert.Equal(expected, Gdd03SyntheticAbsorptionBoundary.HoldsForSyntheticSettledFacts(+ Assert.True(Gdd03SyntheticAbsorptionBoundary.HoldsForSyntheticSettledFacts(Catalogue(), 101, waiting, 0, 0, 0, 0));+ Assert.False(Gdd03SyntheticAbsorptionBoundary.HoldsForSyntheticSettledFacts(+ Catalogue(), 100, waiting, 0, 0, 0, 0)); // the population gate still decides}// Synthetic demand 100 and free civilians 10; source percentages are 10 and 40.@@ -52,7 +55,7 @@ public class Gdd03SyntheticAbsorptionBoundaryTestsCatalogue(), 0, false, overflow, demand, employed, free));}- // Invalid test-only facts must fail even if the population/waiting gate would already fail.+ // Invalid test-only facts must fail even if the population gate would already fail.[Theory][InlineData(-1, 0, 0, 0, 0)][InlineData(101, -1, 100, 4, 10)]diff --git a/sim/Statecraft.Sim/Gdd03ProjectBuildFixture.cs b/sim/Statecraft.Sim/Gdd03ProjectBuildFixture.csindex 46d5ae44d..1fe7555e9 100644--- a/sim/Statecraft.Sim/Gdd03ProjectBuildFixture.cs+++ b/sim/Statecraft.Sim/Gdd03ProjectBuildFixture.cs@@ -4,16 +4,16 @@ using System.Linq;namespace Statecraft.Sim{- internal enum Gdd03BuilderTier { OrdinaryOrNovice, Apprentice, Expert }-- /// <summary>One synthetic city project record: work done instead of turns left (#1700).</summary>+ /// <summary>One synthetic city project record: the turns its builder has worked, against the kind's turns (#1700).</summary>internal sealed class Gdd03FixtureProject{internal int Id { get; }internal Gdd03ProjectCatalogue.Project Kind { get; }- internal decimal WorkDone { get; set; }+ /// <summary>The kind's `turns` in content/projects.yaml, the live game's length (owner, 3 November 2026, #1700).</summary>+ internal int Turns { get; }+ internal int TurnsDone { get; set; }internal int? CompletedTurn { get; set; }- internal Gdd03FixtureProject(int id, Gdd03ProjectCatalogue.Project kind) { Id = id; Kind = kind; }+ internal Gdd03FixtureProject(int id, Gdd03ProjectCatalogue.Project kind, int turns) { Id = id; Kind = kind; Turns = turns; }}/// <summary>Builder rules over the #1963 catalogue (#1700), synthetic fixtures only: no command, save, loader,@@ -24,6 +24,7 @@ namespace Statecraft.Sim// 1 November). The catalogue's non-zero Upkeep is post-MVP, so it is not read here.const decimal MvpUpkeep = 0m;readonly Gdd03ProjectCatalogue catalogue;+ readonly IReadOnlyList<ProjectKind> kinds;readonly List<Gdd03FixtureProject> projects = new List<Gdd03FixtureProject>();// #1700 slice B (owner, 3 November 2026: "One per city, plus 2 nationally"): each city's starts this turn.readonly Dictionary<string, int> startsThisTurn = new Dictionary<string, int>(StringComparer.Ordinal);@@ -36,9 +37,11 @@ namespace Statecraft.Sim/// from <paramref name="rules"/>, which the owner's 3 November 2026 ruling keeps ("One per city, plus 2 nationally").</summary>internal int NationalStarts { get; }- internal Gdd03ProjectBuildFixture(Gdd03ProjectCatalogue catalogue, Rules rules, decimal money)+ /// <param name="kinds">The live project kinds (content/projects.yaml), read for each kind's `turns` only.</param>+ internal Gdd03ProjectBuildFixture(Gdd03ProjectCatalogue catalogue, Rules rules, IReadOnlyList<ProjectKind> kinds, decimal money){this.catalogue = catalogue ?? throw new ArgumentNullException(nameof(catalogue));+ this.kinds = kinds ?? throw new ArgumentNullException(nameof(kinds));NationalStarts = (rules ?? throw new ArgumentNullException(nameof(rules))).MapActionsPerTurn;Money = money;}@@ -46,47 +49,47 @@ namespace Statecraft.Sim/// <summary>Pays the kind's full cost up front, borrowing any shortfall (D1, R-MONEY-003). A city starts at most/// <see cref="Statecraft.Sim.Projects.Gdd03CityStartsPerTurn"/> (1) project a turn, and <see cref="NationalStarts"/> (map_actions_per_turn) starts a turn/// nationally, as R-PROJ-001 under gdd-0.3; a start past either is refused before anything is paid, the city's- /// limit first. Cancel and housing repair are other #1700 slices.</summary>+ /// limit first. A catalogue kind with no row of the same id in content/projects.yaml has no `turns` to count, so it is+ /// refused before anything is paid (maintainer reading). Cancel and housing repair are other #1700 slices.</summary>internal int Start(string key, string city){var kind = catalogue.Projects.SingleOrDefault(p => p.Key == key)?? throw new InvalidOperationException("Unknown project kind: " + key);+ var turns = kinds.SingleOrDefault(k => k.Id == key)?.Turns+ ?? throw new InvalidOperationException("No turns in projects.yaml for project kind: " + key);var inCity = startsThisTurn.TryGetValue(city, out var n) ? n : 0;if (inCity >= Statecraft.Sim.Projects.Gdd03CityStartsPerTurn)throw new InvalidOperationException(city + " has started a city project this turn");if (startsThisTurn.Values.Sum() >= NationalStarts)throw new InvalidOperationException("No more than " + NationalStarts + " city starts are allowed a turn");Pay(kind.Cost.Amount);- var project = new Gdd03FixtureProject(projects.Count + 1, kind);+ var project = new Gdd03FixtureProject(projects.Count + 1, kind, turns);projects.Add(project);startsThisTurn[city] = inCity + 1;return project.Id;}- /// <summary>Resolves one turn. Only assigned builders add work, at their tier's rate, at most the catalogue's- /// slots per project; Money is not an input, so extra Money cannot speed a project. Excess work is discarded.- /// Then every completed project, the one completed this turn included and vacant or not, is charged the MVP- /// upkeep rate, IL 0m.</summary>- internal void EndTurn(IReadOnlyDictionary<int, Gdd03BuilderTier[]> builders)+ /// <summary>Resolves one turn. <paramref name="built"/> lists the projects that have their one builder this turn+ /// (owner, 3 November 2026, #1700: "One builder, today's times (Recommended)"); each advances one of its kind's+ /// turns, and a project not listed waits. Money is not an input, so extra Money cannot speed a project. Then every+ /// completed project, the one completed this turn included and vacant or not, is charged the MVP upkeep rate, IL 0m.</summary>+ internal void EndTurn(IReadOnlyCollection<int> built){- // Validate everything first so a refused turn changes nothing; key order makes the first error deterministic.- foreach (var entry in builders.OrderBy(e => e.Key))+ // Validate everything first so a refused turn changes nothing; id order makes the first error deterministic.+ foreach (var id in built.OrderBy(i => i)){- var p = projects.SingleOrDefault(x => x.Id == entry.Key)- ?? throw new InvalidOperationException("Unknown project " + entry.Key);- if (p.CompletedTurn != null) throw new InvalidOperationException("Project " + entry.Key + " is complete");- if (entry.Value.Length > catalogue.BuilderSlots.Amount)- throw new InvalidOperationException("Project " + entry.Key + " has " + catalogue.BuilderSlots.Amount + " builder slots");- foreach (var tier in entry.Value)- if (!Enum.IsDefined(typeof(Gdd03BuilderTier), tier)) throw new InvalidOperationException("Unknown builder tier " + (int)tier);+ var p = projects.SingleOrDefault(x => x.Id == id)+ ?? throw new InvalidOperationException("Unknown project " + id);+ if (p.CompletedTurn != null) throw new InvalidOperationException("Project " + id + " is complete");}+ if (built.Distinct().Count() != built.Count) throw new InvalidOperationException("A project has one builder");Turn++;startsThisTurn.Clear();foreach (var p in projects){- if (p.CompletedTurn != null || !builders.TryGetValue(p.Id, out var tiers)) continue;- p.WorkDone = Math.Min(p.Kind.Work.Amount, p.WorkDone + tiers.Sum(Rate));- if (p.WorkDone == p.Kind.Work.Amount) p.CompletedTurn = Turn;+ if (p.CompletedTurn != null || !built.Contains(p.Id)) continue;+ p.TurnsDone++;+ if (p.TurnsDone == p.Turns) p.CompletedTurn = Turn;}foreach (var p in projects)if (p.CompletedTurn != null) Pay(MvpUpkeep);@@ -99,13 +102,5 @@ namespace Statecraft.SimMoney -= paid;Debt += amount - paid;}-- decimal Rate(Gdd03BuilderTier tier) => tier switch- {- Gdd03BuilderTier.Expert => catalogue.ExpertRate.Amount,- Gdd03BuilderTier.Apprentice => catalogue.ApprenticeRate.Amount,- Gdd03BuilderTier.OrdinaryOrNovice => catalogue.OrdinaryOrNoviceRate.Amount,- _ => throw new InvalidOperationException("Unknown builder tier " + (int)tier) // refused in validation first- };}}diff --git a/sim/Statecraft.Sim/Gdd03SyntheticAbsorptionBoundary.cs b/sim/Statecraft.Sim/Gdd03SyntheticAbsorptionBoundary.csindex 61897059f..407f53982 100644--- a/sim/Statecraft.Sim/Gdd03SyntheticAbsorptionBoundary.cs+++ b/sim/Statecraft.Sim/Gdd03SyntheticAbsorptionBoundary.cs@@ -14,7 +14,9 @@ namespace Statecraft.Sim/// Regional aggregation and monthly-versus-end-state sampling are deliberately outside this contract./// Empty valid pairs satisfy their subcondition. Invalid inputs throw rather than defaulting./// Current catalogue quantities must be single Agreed whole numbers; later fractional design values- /// require a reviewed contract extension. Calling this does not record completion or choose its date.</summary>+ /// require a reviewed contract extension. Calling this does not record completion or choose its date.+ /// The waiting flag is kept for callers but never blocks the result: the MVP has no reception-bed layer (owner,+ /// 1 November 2026, #1696: "No reception-bed layer (Recommended)") and option (a) of #738 has no waiting clause.</summary>public static bool HoldsForSyntheticSettledFacts(Gdd03BalanceCatalogue catalogue,long representedOwnUnits,@@ -42,7 +44,6 @@ namespace Statecraft.Sim// Exact unbounded integer products; 100 is the definition of percent, not a balance default.// No rounded shares, binary floating point, text formatting, RNG or state mutation.return new BigInteger(representedOwnUnits) * peoplePerUnit > populationTarget- && !hasRefugeeAwaitingLegalBed&& new BigInteger(ordinaryOverflow) * 100 <= new BigInteger(ordinaryDemand) * maxOverflow&& new BigInteger(employedFreeCivilians) * 100 >= new BigInteger(allFreeCivilians) * minEmployment;}