A Civilization-style strategy game about governing Israel from 15 May 1948. Real ministers, real map, every fact sourced. Unity + deterministic C# sim.
Sim: employed census units hold Industry work at the dark start (Refs #1725, PR 3) (#3119)
Eyal Golan319fad2fcd91
diff --git a/changelog.d/1725-pr3-industry.md b/changelog.d/1725-pr3-industry.mdnew file mode 100644index 000000000..5a6c81dc2--- /dev/null+++ b/changelog.d/1725-pr3-industry.md@@ -0,0 +1,4 @@+- GDD 0.3 starting population (Refs #1725): on the inactive dark start's Historical ledger, each census city's+ employed people now hold Industry work records: one Industry place per city, holding at most the city's job slots,+ filled by its lowest population ids, so the Haifa teacher stays without a job. The ledger refuses a worker from+ another city and one more worker than the slots. No new-game wiring, so there is no change in the game.diff --git a/docs/rules/mvp.md b/docs/rules/mvp.mdindex a15209e6d..0813c5842 100644--- a/docs/rules/mvp.md+++ b/docs/rules/mvp.md@@ -621,7 +621,7 @@ R-POP-002: A ledger record has exactly one typed status and assignment, validateR-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. A location's optional city (a `regions.yaml` member location of its region that is a census city of `cities.yaml` or one of that region's field hosts, where R-POP-004 houses own people: a settlement hosts only F19 and F20, owner, 7 November 2026, #1689: "These two only (Recommended)"; any other, including a locality, a `sites.yaml` id or a map location, is refused when a fixture is created, naming the city and the region, R-POP-002) is written after its other fields as `|city=` with a length-prefixed id, only when set, as R-UNIT-002's `|home=` is, so a location without a city keeps its canonical text and hash. 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. The 20 farmer units are added to the census total (owner, 7 November 2026: "On top, change the rule (Recommended)", which reverses this rule's earlier "no more and no less"), one a field, with source key `field/<label>` (F01 to F20 of `regions.yaml` `field_hexes`) and ordinal 0 (maintainer call, the coordinator, 7 November 2026, so the key stays if a host changes); see the farmers below. 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), as R-UNIT-009 records; its service target and region are bound at the start with no record (coordinator call, 8 November 2026). 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 the public `Simulation.NewGame` (only the internal dark start of R-POP-002 calls it): 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. A fixture builder (`HistoricalPopulation.LedgerFixture`, internal, fixture-only) turns the inventory into an initialized Historical ledger with mode Historical (R-POP-001's 1,000 a record), each record in a region of `content/regions.yaml` (#1691): a census record takes the region whose `member_locations` hold its city (`census/tel_aviv` is `tel_aviv_jaffa`; Jaffa gets no records), and its location names that city, and a formation record takes the region whose member hexes hold the formation's starting anchor hex (owner, 3 November 2026, #1689 open question 1: "Its anchor hex's region (Recommended)"). A source with no region is refused; no region is invented. Census records are free civilians with no assignment and their reception done: they start at `reception.turns`, the "actual reception turns before free-civilian status" (`docs/gdd/balance.md:91`), the ledger's cap (R-POP-002), since R-VET-001 gives work XP only to a received free civilian (an agent reading of `balance.md:91`, not an owner ruling); formation records keep 0, which no ruling sets. Formation records are active soldiers whose service target is their own formation. Each formation record carries one issued military item, id `units_1948/<row id>/<ordinal>`, owned and recorded as paid; census records carry none. One census record is the training centre's veteran pioneer teacher (owner, 7 November 2026, [#1689](https://github.com/eyalgolan/statecraft-israel/issues/1689#issuecomment-6704565066): "Yes to all three (Recommended)", whose third part reads "the training centre's one veteran pioneer teacher is a Haifa census unit"): `content/gdd03-balance.yaml`'s `start.pioneer_teachers` (1, Agreed, "included in population total") gives the count, so no record is added, and the fixture refuses any other value, since no ruling places a second teacher. It is the last `census/haifa` ordinal (maintainer call, the coordinator eyalgolan-30, 7 November 2026), a free civilian pioneer at the veteran tier (R-TRAIN-005: "a veteran of the matching profession"), with work XP 0 (owner, 7 November 2026, relayed by the coordinator: "0 (Recommended)"), and no assignment, since R-TRAIN-008 refuses a teaching teacher with no pupil; otherwise it is like any other census record. It is "Takeable, but last (Recommended)" (owner, 7 November 2026, relayed by the coordinator): there is no guard, and as the highest `census/haifa` id it is the last record that Q10's "N units" commands and #1692's job default reach. No ledger producer runs the job default or a Train order yet. Issued items are apart from the spare Arms: the fixture leaves the Arms stock untouched, and a new game still starts with `arms_start`'s 12 (#1717, 27M-24: "The starting formations are equipped, and the Arms stock starts at 12"). Still not in the inventory or the fixture: the work assignments of the employed share. The opening field farmers are (#1725 PR 4; the owner's 1:2:1 novice/trained/veteran ratio applies per host, which gives 1 / 18 / 1 nationally: owner, 7 November 2026, "Per host, 1/18/1 (Recommended)", [#1689](https://github.com/eyalgolan/statecraft-israel/issues/1689#issuecomment-6704985642)). `HistoricalPopulation.FieldFarmerHosts` (internal) gives each `regions.yaml` `field_hexes` host its fields' farmers, one a field (owner, 3 November 2026, #1694: "One farmer per field (Recommended)"), split 1:2:1 per host by `Gdd03FarmerTierSplit` in field-label order; the 20 match `start.prepared_fields` (Agreed), and any other total, or a field with no host, is refused. Each farmer is a free civilian farmer staffed on its field from turn 1 (owner, 7 November 2026, [#1689](https://github.com/eyalgolan/statecraft-israel/issues/1689#issuecomment-6704565066): "Yes to all three (Recommended)"): its assignment is Work on the field's target (`field/<q>,<r>`, as `Gdd03FieldFixture`), its location the field's region with its host as the city (Nir Am and Nirim for F19 and F20, R-POP-003). Tiberias hosts six fields, F03 novice, F04 to F07 trained and F08 veteran (owner, 7 November 2026, relayed by the coordinator: "F08 veteran, F03 novice (Recommended)"); every other host has one or two, all trained. Work XP is 0 for every tier (owner, relayed by the coordinator: "0 for all (Recommended)"; veterans "0 (Recommended)", [#1689](https://github.com/eyalgolan/statecraft-israel/issues/1689#issuecomment-6710877137)). Reception is done (`reception.turns`), as for the census (maintainer call, the coordinator, 7 November 2026). No tools: post-MVP (#1693, owner, 3 November 2026, answer 1: "Tools in the MVP: no."). `field/` rows, like `census/` and `units_1948/` rows, are refused outside a Historical ledger (R-POP-001). Farmers hold a field, not a job, so they are not among a city's employed (R-CITY-007) or civilians, not in R-OBJ-004's sums, and not among the people without a job a `Train` order takes (R-TRAIN-001): the dark start's aggregate cities keep the census's counts. The dark start adds one housing place per farmer to each census host's housing capacity (same ruling); Nir Am and Nirim have no `cities.yaml` record and get none for now (owner, relayed by the coordinator: "None for those two for now (Recommended)"), so 18 of the 20 places exist until the housing producer (#1725 PR 7). The public `NewGame` is unchanged. The formations' rows 5 to 8 are in the fixture (owner, 7 November 2026, #1689 comment 6704389240: "Veteran for all 8 (Recommended)" and "1 each, Negev 0 (Recommended)", Negev's 0 a labelled stand-in). The veteran level lives on the formation, a `veteran_soldier` (R-UNIT-006) that is each soldier's ActiveService target, so a formation record's military qualification is its type's `unit_types.yaml` class (`infantry`), the source basic-training graduates use, with no new level field (maintainer call, eyalgolan-30's coordinator, 7 November 2026). Its combat XP is `content/gdd03-start.yaml`'s `formation_combat_xp`: 1 for Golani, Carmeli, Alexandroni, Kiryati, Givati, Etzioni and Harel, 0 for Negev. The list also names each own brigade dated after the start (R-UNIT-009): 1 for the 7th Brigade (owner, 8 November 2026: "1, like the others"). The loader requires the list, refuses a row that is not an own opening or dated formation, a duplicate, a missing formation or a value outside 0 to `military.combat_xp_full`, and the fixture refuses without it (no fallback). Only the ledger fixture reads it: the units `NewGame` starts with keep 0 combat XP (same maintainer call); a `veteran_soldier` gains none (R-UNIT-011). The paragraphs below record the owner's decision on each. 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`)").+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. The 20 farmer units are added to the census total (owner, 7 November 2026: "On top, change the rule (Recommended)", which reverses this rule's earlier "no more and no less"), one a field, with source key `field/<label>` (F01 to F20 of `regions.yaml` `field_hexes`) and ordinal 0 (maintainer call, the coordinator, 7 November 2026, so the key stays if a host changes); see the farmers below. 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), as R-UNIT-009 records; its service target and region are bound at the start with no record (coordinator call, 8 November 2026). 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 the public `Simulation.NewGame` (only the internal dark start of R-POP-002 calls it): 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. A fixture builder (`HistoricalPopulation.LedgerFixture`, internal, fixture-only) turns the inventory into an initialized Historical ledger with mode Historical (R-POP-001's 1,000 a record), each record in a region of `content/regions.yaml` (#1691): a census record takes the region whose `member_locations` hold its city (`census/tel_aviv` is `tel_aviv_jaffa`; Jaffa gets no records), and its location names that city, and a formation record takes the region whose member hexes hold the formation's starting anchor hex (owner, 3 November 2026, #1689 open question 1: "Its anchor hex's region (Recommended)"). A source with no region is refused; no region is invented. Census records are free civilians, with no assignment (but for each city's employed, below) and their reception done: they start at `reception.turns`, the "actual reception turns before free-civilian status" (`docs/gdd/balance.md:91`), the ledger's cap (R-POP-002), since R-VET-001 gives work XP only to a received free civilian (an agent reading of `balance.md:91`, not an owner ruling); formation records keep 0, which no ruling sets. Formation records are active soldiers whose service target is their own formation. Each formation record carries one issued military item, id `units_1948/<row id>/<ordinal>`, owned and recorded as paid; census records carry none. One census record is the training centre's veteran pioneer teacher (owner, 7 November 2026, [#1689](https://github.com/eyalgolan/statecraft-israel/issues/1689#issuecomment-6704565066): "Yes to all three (Recommended)", whose third part reads "the training centre's one veteran pioneer teacher is a Haifa census unit"): `content/gdd03-balance.yaml`'s `start.pioneer_teachers` (1, Agreed, "included in population total") gives the count, so no record is added, and the fixture refuses any other value, since no ruling places a second teacher. It is the last `census/haifa` ordinal (maintainer call, the coordinator eyalgolan-30, 7 November 2026), a free civilian pioneer at the veteran tier (R-TRAIN-005: "a veteran of the matching profession"), with work XP 0 (owner, 7 November 2026, relayed by the coordinator: "0 (Recommended)"), and no assignment, since R-TRAIN-008 refuses a teaching teacher with no pupil; otherwise it is like any other census record. It is "Takeable, but last (Recommended)" (owner, 7 November 2026, relayed by the coordinator): there is no guard, and as the highest `census/haifa` id it is the last record that Q10's "N units" commands and #1692's job default reach. No ledger producer runs the job default or a Train order yet. Issued items are apart from the spare Arms: the fixture leaves the Arms stock untouched, and a new game still starts with `arms_start`'s 12 (#1717, 27M-24: "The starting formations are equipped, and the Arms stock starts at 12"). Each city's employed hold Industry work (#1725 PR 3; owner, 7 November 2026, [#1689](https://github.com/eyalgolan/statecraft-israel/issues/1689#issuecomment-6704428057): "Start in Industry (Recommended)", so every employed unit starts in Industry; the count is R-CITY-007's people x share, "Keep people x share (Recommended)"). Each census city has one Industry Work target, `industry/<city id>`, in its region, naming the city, with the city's `job_slots` as its capacity (R-CITY-007); `start.industry_slots` (8) is the 10,000-scale value and is never a city's capacity. The city's first `employed` census ordinals, its ascending population ids, hold Work on it, as #1692's job default gains the Industry assignment (owner, 3 November 2026: "Approve all three (Recommended)"); the rest have no assignment, so the teacher, the last ordinal, is not among them. The ledger refuses a record on an Industry target of another city (Q27: "a worker works in their own city") and more records than the capacity (R-POP-002). The live month snapshot has one entry per Industry target, available with its capacity, as a field's (owner, 11 November 2026, #1725: "A: available now (Recommended)"). The aggregate employed stays as it was and equals the ledger's Industry count at the start; capacity changes after the start (projects, events) and the job default on the ledger come later. The opening field farmers are (#1725 PR 4; the owner's 1:2:1 novice/trained/veteran ratio applies per host, which gives 1 / 18 / 1 nationally: owner, 7 November 2026, "Per host, 1/18/1 (Recommended)", [#1689](https://github.com/eyalgolan/statecraft-israel/issues/1689#issuecomment-6704985642)). `HistoricalPopulation.FieldFarmerHosts` (internal) gives each `regions.yaml` `field_hexes` host its fields' farmers, one a field (owner, 3 November 2026, #1694: "One farmer per field (Recommended)"), split 1:2:1 per host by `Gdd03FarmerTierSplit` in field-label order; the 20 match `start.prepared_fields` (Agreed), and any other total, or a field with no host, is refused. Each farmer is a free civilian farmer staffed on its field from turn 1 (owner, 7 November 2026, [#1689](https://github.com/eyalgolan/statecraft-israel/issues/1689#issuecomment-6704565066): "Yes to all three (Recommended)"): its assignment is Work on the field's target (`field/<q>,<r>`, as `Gdd03FieldFixture`), its location the field's region with its host as the city (Nir Am and Nirim for F19 and F20, R-POP-003). Tiberias hosts six fields, F03 novice, F04 to F07 trained and F08 veteran (owner, 7 November 2026, relayed by the coordinator: "F08 veteran, F03 novice (Recommended)"); every other host has one or two, all trained. Work XP is 0 for every tier (owner, relayed by the coordinator: "0 for all (Recommended)"; veterans "0 (Recommended)", [#1689](https://github.com/eyalgolan/statecraft-israel/issues/1689#issuecomment-6710877137)). Reception is done (`reception.turns`), as for the census (maintainer call, the coordinator, 7 November 2026). No tools: post-MVP (#1693, owner, 3 November 2026, answer 1: "Tools in the MVP: no."). `field/` rows, like `census/` and `units_1948/` rows, are refused outside a Historical ledger (R-POP-001). Farmers hold a field, not a job, so they are not among a city's employed (R-CITY-007) or civilians, not in R-OBJ-004's sums, and not among the people without a job a `Train` order takes (R-TRAIN-001): the dark start's aggregate cities keep the census's counts. The dark start adds one housing place per farmer to each census host's housing capacity (same ruling); Nir Am and Nirim have no `cities.yaml` record and get none for now (owner, relayed by the coordinator: "None for those two for now (Recommended)"), so 18 of the 20 places exist until the housing producer (#1725 PR 7). The public `NewGame` is unchanged. The formations' rows 5 to 8 are in the fixture (owner, 7 November 2026, #1689 comment 6704389240: "Veteran for all 8 (Recommended)" and "1 each, Negev 0 (Recommended)", Negev's 0 a labelled stand-in). The veteran level lives on the formation, a `veteran_soldier` (R-UNIT-006) that is each soldier's ActiveService target, so a formation record's military qualification is its type's `unit_types.yaml` class (`infantry`), the source basic-training graduates use, with no new level field (maintainer call, eyalgolan-30's coordinator, 7 November 2026). Its combat XP is `content/gdd03-start.yaml`'s `formation_combat_xp`: 1 for Golani, Carmeli, Alexandroni, Kiryati, Givati, Etzioni and Harel, 0 for Negev. The list also names each own brigade dated after the start (R-UNIT-009): 1 for the 7th Brigade (owner, 8 November 2026: "1, like the others"). The loader requires the list, refuses a row that is not an own opening or dated formation, a duplicate, a missing formation or a value outside 0 to `military.combat_xp_full`, and the fixture refuses without it (no fallback). Only the ledger fixture reads it: the units `NewGame` starts with keep 0 combat XP (same maintainer call); a `veteran_soldier` gains none (R-UNIT-011). The paragraphs below record the owner's decision on each. 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`)").The four opening-ledger values were Deferred pending a separate sourced draft for owner approval (4 November 2026, Q24; the coordinator asked: "How should the four deferred opening-ledger values be approved before Historical NewGame initializes the ledger?"; the owner answered: "do the recommended for all"; the chosen option read: "Request and approve a separate sourced draft for employed assignments, farmer identities, formation qualifications and combat XP before wiring NewGame"; [recorded on #1689](https://github.com/eyalgolan/statecraft-israel/issues/1689#issuecomment-6623135448)). Farmer home cities needed a source-backed city-by-field proposal for owner approval (4 November 2026, Q26; the coordinator asked: "How should the census-city home of each opening field’s farmer be selected when its region contains several cities?"; the owner answered: "do the recommended for all"; the chosen option read: "Have an agent prepare a source-backed city-by-field proposal for owner approval"; [recorded on #1717](https://github.com/eyalgolan/statecraft-israel/issues/1717#issuecomment-6623136302)).Owner decision on both drafts, 7 November 2026: "all reccomended in "Decisions for the owner: the GDD 0.3 starting population (#1689) and where the field farmers live (#1717)" - approved" ([recorded on #1689](https://github.com/eyalgolan/statecraft-israel/issues/1689#issuecomment-6703676150)). This wires nothing into `Simulation.NewGame`.diff --git a/sim/Statecraft.Sim.Tests/HistoricalIndustryWorkersTests.cs b/sim/Statecraft.Sim.Tests/HistoricalIndustryWorkersTests.csnew file mode 100644index 000000000..a9445584f--- /dev/null+++ b/sim/Statecraft.Sim.Tests/HistoricalIndustryWorkersTests.cs@@ -0,0 +1,196 @@+using Statecraft.Sim;++/// <summary>#1725 PR 3, the employed part (Refs #1689, #1692): the census cities' employed units hold Industry work records+/// on the Historical ledger (R-POP-004). Owner, 7 November 2026 (#1689 comment 6704389240), "Keep people x share+/// (Recommended)": a city's employed is its people times its share (R-CITY-007); (#1689 comment 6704428057) "Start in+/// Industry (Recommended)": every employed unit starts in Industry. The #1725 PR 3 bullet: a work kind and a capacity on+/// <c>PopulationTarget</c>, checked in <c>Validate</c>; the capacity is each city's <c>job_slots</c> (R-CITY-007), and+/// <c>start.industry_slots</c> is the 10,000-scale value, never a city's Industry capacity. #1692 (owner, 3 November 2026,+/// "Approve all three (Recommended)"): records gain the Industry assignment in ascending population id. Q27: "a worker+/// works in their own city". Farmers stay out of employed (#1725 PR 4); the Haifa teacher is taken last (#1689 comment+/// 6710877137, "Takeable, but last (Recommended)").</summary>+public class HistoricalIndustryWorkersTests+{+ static Content Gdd03() => HistoricalPopulationTests.Real(true);++ static GameState Dark(Content c) => Simulation.NewGame(c, 1, Mode.Historical, darkStart: true);++ // A city's census civilians: its free civilians that are not field farmers (a farmer lives in its host, R-POP-004).+ static List<PopulationUnit> Census(GameState s, string city) => s.PopulationLedger.Units+ .Where(u => u.Status == PopulationStatus.FreeCivilian && u.Profession != CivilianProfession.Farmer+ && string.Equals(u.Location?.City, city, StringComparison.Ordinal)).OrderBy(u => u.Id).ToList();++ static bool InIndustry(PopulationUnit u, string city) => u.Assignment.Kind == PopulationAssignmentKind.Work+ && u.Assignment.Target == HistoricalPopulation.IndustryTarget(city);++ // R-POP-004, R-CITY-007: each census city's first `employed` census records, by ascending population id, hold Work on+ // the city's Industry target; the rest have no assignment. So the ledger's Industry count is the aggregate employed.+ [Fact]+ public void DarkStartEmployedHoldIndustryInAscendingId()+ {+ var c = Gdd03();+ var s = Dark(c);+ Assert.NotEmpty(c.Cities);+ foreach (var city in c.Cities)+ {+ var census = Census(s, city.Id);+ Assert.Equal(city.Civilians, census.Count);+ Assert.True(city.Employed < census.Count, city.Id);+ Assert.Equal(census.Take(city.Employed).Select(u => u.Id), census.Where(u => InIndustry(u, city.Id)).Select(u => u.Id));+ Assert.All(census.Skip(city.Employed), u => Assert.Equal(PopulationAssignmentKind.Unassigned, u.Assignment.Kind));+ Assert.Equal(s.Cities[city.Id].Employed, census.Count(u => InIndustry(u, city.Id)));+ }+ }++ // The PR 3 bullet: the capacity is each city's job_slots (R-CITY-007), never start.industry_slots. One Industry target+ // per census city, in the city's region, naming the city; no other Industry target is bound at the start.+ [Fact]+ public void EachCitysIndustryCapacityIsItsJobSlots()+ {+ var c = Gdd03();+ var ledger = Dark(c).PopulationLedger;+ var industry = ledger.Bindings.Targets.Where(t => t.WorkKind == PopulationWorkKind.Industry).ToList();+ Assert.Equal(c.Cities.Select(x => HistoricalPopulation.IndustryTarget(x.Id)).OrderBy(x => x, StringComparer.Ordinal),+ industry.Select(t => t.Id));+ foreach (var city in c.Cities)+ {+ var t = ledger.Target(HistoricalPopulation.IndustryTarget(city.Id))!;+ Assert.Equal(PopulationAssignmentKind.Work, t.Kind);+ Assert.Equal(city.Id, t.City);+ Assert.Equal(c.PlayerRegions.AtLocation(city.Id)!.Id, t.Region);+ Assert.Equal(city.JobSlots, t.Capacity);+ }+ // start.industry_slots (8, Default) is a 10,000-scale value: Jerusalem's 29, Tel Aviv's 106 and Haifa's 42 are not it.+ Assert.Contains(c.Cities, x => x.JobSlots != 8);+ Assert.All(c.Cities, x => Assert.Equal(x.JobSlots, ledger.Target(HistoricalPopulation.IndustryTarget(x.Id))!.Capacity));+ }++ // Farmers stay out of employed (#1725 PR 4): each keeps its field's Work target. The Haifa teacher, the last census/haifa+ // record, is not among Haifa's employed (R-TRAIN-008: it starts unassigned). The ledger's Industry workers are exactly+ // the census cities' employed, in total too.+ [Fact]+ public void FarmersAndTheTeacherStayOutOfIndustry()+ {+ var c = Gdd03();+ var s = Dark(c);+ var units = s.PopulationLedger.Units;+ var farmers = units.Where(u => u.Profession == CivilianProfession.Farmer).ToList();+ Assert.NotEmpty(farmers);+ Assert.All(farmers, f => Assert.StartsWith(HistoricalPopulation.FarmerPrefix, f.Assignment.Target));+ var teacher = units.Single(u => u.Profession == CivilianProfession.Pioneer);+ Assert.Equal(PopulationAssignmentKind.Unassigned, teacher.Assignment.Kind);+ var industry = units.Where(u => u.Assignment.Kind == PopulationAssignmentKind.Work+ && u.Assignment.Target!.StartsWith(HistoricalPopulation.IndustryPrefix, StringComparison.Ordinal)).ToList();+ Assert.Equal(c.Cities.Sum(x => x.Employed), industry.Count);+ Assert.All(industry, u => Assert.Equal(CivilianProfession.None, u.Profession));+ }++ // Validate (R-POP-002): an Industry target holds at most its capacity. Haifa starts full, so one more Haifa worker is+ // refused, with the ledger unchanged; after one worker is released, the same record is accepted.+ [Fact]+ public void AFullCitysIndustryRefusesOneMoreWorker()+ {+ var c = Gdd03();+ var s = Dark(c);+ var ledger = s.PopulationLedger;+ var haifa = Census(s, "haifa");+ var target = new PopulationAssignment(PopulationAssignmentKind.Work, HistoricalPopulation.IndustryTarget("haifa"));+ var jobless = haifa.First(u => u.Assignment.Kind == PopulationAssignmentKind.Unassigned && u.Profession == CivilianProfession.None);+ var before = string.Join("\n", ledger.Canonical());+ Assert.Throws<ArgumentException>(() => ledger.ChangeAssignment(jobless.Id, target));+ Assert.Equal(before, string.Join("\n", ledger.Canonical()));++ ledger.ChangeAssignment(haifa.First(u => InIndustry(u, "haifa")).Id, PopulationAssignment.Unassigned);+ ledger.ChangeAssignment(jobless.Id, target);+ Assert.Equal(c.Cities.Single(x => x.Id == "haifa").JobSlots, Census(s, "haifa").Count(u => InIndustry(u, "haifa")));+ }++ // Q27, "a worker works in their own city": a record of another city in the same region is refused on an Industry+ // target, while the target's own city's record is accepted. Several census cities share a region, so the region check+ // alone would not catch it.+ [Fact]+ public void AnotherCitysRecordIsRefusedOnACitysIndustry()+ {+ var c = Gdd03();+ var s = Dark(c);+ var ledger = s.PopulationLedger;+ var pair = c.Cities.GroupBy(x => c.PlayerRegions.AtLocation(x.Id)!.Id).First(g => g.Count() > 1).Take(2).ToList();+ var region = c.PlayerRegions.AtLocation(pair[0].Id)!.Id;+ ledger.BindTarget(new PopulationTarget("test/industry", PopulationAssignmentKind.Work, region,+ workKind: PopulationWorkKind.Industry, city: pair[0].Id, capacity: 1000));+ var work = new PopulationAssignment(PopulationAssignmentKind.Work, "test/industry");+ var other = Census(s, pair[1].Id).First(u => u.Assignment.Kind == PopulationAssignmentKind.Unassigned);+ var own = Census(s, pair[0].Id).First(u => u.Assignment.Kind == PopulationAssignmentKind.Unassigned);+ Assert.Equal(region, other.Location!.Region);+ Assert.Throws<ArgumentException>(() => ledger.ChangeAssignment(other.Id, work));+ ledger.ChangeAssignment(own.Id, work);+ Assert.Equal(work.Target, ledger.Units.Single(u => u.Id == own.Id).Assignment.Target);+ }++ static GameState Fixture(Content c, string region, string city) => PopulationLedger.CreateFixture(c,+ new PopulationBindings(new[] { new PopulationLocation(region) }, new[] { new PopulationTarget("test/industry",+ PopulationAssignmentKind.Work, region, workKind: PopulationWorkKind.Industry, city: city, capacity: 1) },+ Array.Empty<string>(), Array.Empty<string>()),+ Array.Empty<PopulationInventoryRow>(), mode: Mode.Historical);++ // R-POP-002 (ValidateCities): an Industry target's city is a census city (cities.yaml, R-CITY-006) of its own region in+ // regions.yaml. A census city of another region is refused, and so is a member location of the region that is not a+ // census city; the refusal names the target and the region. The region's own census city is accepted.+ [Fact]+ public void AnIndustryTargetNeedsACensusCityOfItsRegion()+ {+ var c = Gdd03();+ var census = new HashSet<string>(c.Cities.Select(x => x.Id), StringComparer.Ordinal);+ var region = c.PlayerRegions.AtLocation("haifa")!;+ var elsewhere = c.Cities.First(x => c.PlayerRegions.AtLocation(x.Id)!.Id != region.Id).Id;+ var notCensus = region.MemberLocations.First(p => !census.Contains(p));+ foreach (var city in new[] { elsewhere, notCensus })+ {+ var e = Assert.Throws<ArgumentException>(() => Fixture(c, region.Id, city));+ Assert.Equal("Industry target test/industry needs a census city of region " + region.Id + " (R-POP-002).", e.Message);+ }+ Assert.True(Fixture(c, region.Id, "haifa").PopulationLedger.IsInitialized);+ }++ // The work kind: an Industry target is a Work target with its city and a nonnegative capacity; any other target has+ // neither. A target without the work kind keeps its canonical text, so no existing state hash moves.+ [Fact]+ public void AnIndustryTargetNeedsWorkItsCityAndACapacity()+ {+ Assert.Throws<ArgumentException>(() => new PopulationTarget("i", PopulationAssignmentKind.Work, "r", workKind: PopulationWorkKind.Industry, capacity: 1));+ Assert.Throws<ArgumentException>(() => new PopulationTarget("i", PopulationAssignmentKind.Work, "r", workKind: PopulationWorkKind.Industry, city: "x"));+ Assert.Throws<ArgumentException>(() => new PopulationTarget("i", PopulationAssignmentKind.Work, "r", workKind: PopulationWorkKind.Industry, city: "x", capacity: -1));+ Assert.Throws<ArgumentException>(() => new PopulationTarget("i", PopulationAssignmentKind.ActiveService, "r", workKind: PopulationWorkKind.Industry, city: "x", capacity: 1));+ Assert.Throws<ArgumentException>(() => new PopulationTarget("i", PopulationAssignmentKind.Work, "r", city: "x"));+ Assert.Throws<ArgumentException>(() => new PopulationTarget("i", PopulationAssignmentKind.Work, "r", capacity: 1));+ var ok = new PopulationTarget("i", PopulationAssignmentKind.Work, "r", workKind: PopulationWorkKind.Industry, city: "x", capacity: 0);+ Assert.Equal(0, ok.Capacity);++ var plain = new PopulationTarget("field/1,2", PopulationAssignmentKind.Work, "r");+ Assert.Equal(PopulationWorkKind.None, plain.WorkKind);+ Assert.Null(plain.City); Assert.Null(plain.Capacity);+ Assert.Equal(PopulationText.Fields("field/1,2", PopulationText.Assignment(PopulationAssignmentKind.Work), "r", null), plain.Canonical());+ Assert.NotEqual(ok.Canonical(), new PopulationTarget("i", PopulationAssignmentKind.Work, "r", workKind: PopulationWorkKind.Industry, city: "x", capacity: 1).Canonical());+ }++ // #1725 PR 7 (owner, 8 November 2026, "One snapshot per turn (Recommended)": harvest, Industry income and Food all read+ // it): the live month snapshot has one entry per Industry target, available with the target's capacity (an upper+ // bound; "Yes, recheck (Recommended)"), so every Industry worker is work-eligible and the snapshot builds on a dark start.+ [Fact]+ public void TheMonthSnapshotHasAnEntryPerIndustryTarget()+ {+ var c = Gdd03();+ var s = Dark(c);+ var month = Gdd03SyntheticMonthContext.CreateLive(c, s);+ foreach (var city in c.Cities)+ {+ var entry = month.Facilities.Single(f => f.Id == HistoricalPopulation.IndustryTarget(city.Id));+ Assert.True(entry.AvailableAtMonthFreeze);+ Assert.Equal(city.JobSlots, entry.OpeningCapacity);+ }+ var workers = s.PopulationLedger.Units.Where(u => u.Assignment.Kind == PopulationAssignmentKind.Work+ && u.Assignment.Target!.StartsWith(HistoricalPopulation.IndustryPrefix, StringComparison.Ordinal)).Select(u => u.Id).ToList();+ Assert.Equal(c.Cities.Sum(x => x.Employed), workers.Count);+ Assert.Subset(new HashSet<int>(month.WorkEligibleIds), new HashSet<int>(workers));+ }+}diff --git a/sim/Statecraft.Sim.Tests/HistoricalPioneerTeacherTests.cs b/sim/Statecraft.Sim.Tests/HistoricalPioneerTeacherTests.csindex dc7f353ae..7bc41a025 100644--- a/sim/Statecraft.Sim.Tests/HistoricalPioneerTeacherTests.cs+++ b/sim/Statecraft.Sim.Tests/HistoricalPioneerTeacherTests.cs@@ -95,7 +95,8 @@ public class HistoricalPioneerTeacherTests// Industry assignment in ascending population id (#1692, owner answer of 3 November 2026). The teacher has the highest id// of Haifa's census records, so taking Haifa's first k records by ascending id reaches it only when k is all of them.// At the start Haifa's employed are fewer than its records less one, so a default up to its employed never reaches it.- // No ledger producer runs the job default or Train yet (#1725 PR 6 and PR 7); this pins the order they will read.+ // #1725 PR 3 gives the start's employed their Industry records the same way: Haifa's first `employed` records by+ // ascending id hold Industry work, and the teacher is among the jobless after them, again the last.[Fact]public void TheTeacherIsTakenLastByAscendingId(){@@ -103,13 +104,15 @@ public class HistoricalPioneerTeacherTestsvar haifa = Census(s).Where(x => x.Row.Source == Haifa).Select(x => x.Unit).OrderBy(u => u.Id).ToList();var teacher = haifa.Single(u => u.Profession != CivilianProfession.None);Assert.Equal(haifa.Max(u => u.Id), teacher.Id);- var jobless = haifa.Where(u => u.Status == PopulationStatus.FreeCivilian && u.Assignment.Kind == PopulationAssignmentKind.Unassigned).ToList();- Assert.Equal(haifa.Count, jobless.Count);- for (int k = 1; k <= jobless.Count; k++)- Assert.Equal(k == jobless.Count, jobless.Take(k).Any(u => u.Id == teacher.Id));+ for (int k = 1; k <= haifa.Count; k++)+ Assert.Equal(k == haifa.Count, haifa.Take(k).Any(u => u.Id == teacher.Id));var employed = s.C.Cities.Single(city => city.Id == "haifa").Employed;Assert.True(employed < haifa.Count - 1);- Assert.DoesNotContain(jobless.Take(employed), u => u.Id == teacher.Id);+ Assert.DoesNotContain(haifa.Take(employed), u => u.Id == teacher.Id);+ Assert.All(haifa.Take(employed), u => Assert.Equal(HistoricalPopulation.IndustryTarget("haifa"), u.Assignment.Target));+ var jobless = haifa.Where(u => u.Status == PopulationStatus.FreeCivilian && u.Assignment.Kind == PopulationAssignmentKind.Unassigned).ToList();+ Assert.Equal(haifa.Skip(employed).Select(u => u.Id), jobless.Select(u => u.Id));+ Assert.Equal(teacher.Id, jobless.Last().Id);}// The count is content's start.pioneer_teachers (1, Agreed), which the ruling's "one" matches. No ruling places a seconddiff --git a/sim/Statecraft.Sim.Tests/HistoricalPopulationTests.cs b/sim/Statecraft.Sim.Tests/HistoricalPopulationTests.csindex dbcebd4e3..9d1a16550 100644--- a/sim/Statecraft.Sim.Tests/HistoricalPopulationTests.cs+++ b/sim/Statecraft.Sim.Tests/HistoricalPopulationTests.cs@@ -385,7 +385,8 @@ public class HistoricalPopulationTests}// R-POP-004, mvp.md R-CITY-004 fixture paragraph ("the standalone eligibility predicate requires completed reception,- // free-civilian status and no assignment"): every opening census civilian may start a civilian activity at once.+ // free-civilian status and no assignment"): every opening census civilian without a job may start a civilian activity at+ // once. Each city's employed hold Industry work (#1725 PR 3), so the predicate holds for them only once released.[Fact]public void EveryCensusCivilianCanStartCivilianActivity(){@@ -393,8 +394,11 @@ public class HistoricalPopulationTestsvar inventory = HistoricalPopulation.Inventory(c);var ledger = HistoricalPopulation.LedgerFixture(c).PopulationLedger;var census = ledger.Units.Where((u, i) => inventory[i].Source.StartsWith(HistoricalPopulation.CensusPrefix, StringComparison.Ordinal)).ToList();- Assert.NotEmpty(census);- Assert.All(census, u => Assert.True(Gdd03ReceptionFixture.CanStartCivilianActivity(c, ledger, u)));+ var jobless = census.Where(u => u.Assignment.Kind == PopulationAssignmentKind.Unassigned).ToList();+ Assert.NotEmpty(jobless);+ Assert.Equal(census.Count - c.Cities.Sum(x => x.Employed), jobless.Count);+ Assert.All(jobless, u => Assert.True(Gdd03ReceptionFixture.CanStartCivilianActivity(c, ledger, u)));+ Assert.All(census.Except(jobless), u => Assert.False(Gdd03ReceptionFixture.CanStartCivilianActivity(c, ledger, u)));}// R-POP-004: a record whose city or formation has no region in regions.yaml is refused; no region is invented.@@ -472,10 +476,11 @@ public class HistoricalPopulationTests}}- // R-POP-004 (owner, 7 November 2026): row 4 approved no farmer identities, the farmers come on top of the census, and- // row 3's Industry start is not wired in, so a census record stays a plain free civilian: no profession, no tier and no- // Work assignment. The one exception is the training centre's veteran pioneer teacher, the last census/haifa ordinal- // (owner, 7 November 2026, #1689 comment 6704565066; HistoricalPioneerTeacherTests), left out here by its row.+ // R-POP-004 (owner, 7 November 2026): row 4 approved no farmer identities and the farmers come on top of the census, so+ // a census record stays a plain free civilian: no profession and no tier. Row 3's Industry start (#1725 PR 3,+ // HistoricalIndustryWorkersTests) is its only Work: its own city's Industry target. The one exception is the training+ // centre's veteran pioneer teacher, the last census/haifa ordinal (owner, 7 November 2026, #1689 comment 6704565066;+ // HistoricalPioneerTeacherTests), left out here by its row.[Fact]public void CensusRecordsButTheTeacherHaveNoProfessionTierOrWork(){@@ -490,8 +495,11 @@ public class HistoricalPopulationTests{Assert.Equal(CivilianProfession.None, u.Profession);Assert.Equal(CivilianTier.None, u.Tier);- Assert.NotEqual(PopulationAssignmentKind.Work, u.Assignment.Kind);+ if (u.Assignment.Kind == PopulationAssignmentKind.Work)+ Assert.Equal(HistoricalPopulation.IndustryTarget(u.Location!.City!), u.Assignment.Target);+ else Assert.Equal(PopulationAssignmentKind.Unassigned, u.Assignment.Kind);});+ Assert.Equal(c.Cities.Sum(city => city.Employed), census.Count(u => u.Assignment.Kind == PopulationAssignmentKind.Work));}// R-POP-004, #1689 rows 5 to 8. Owner, 7 November 2026 (comment 6704389240): "Veteran for all 8 (Recommended)" anddiff --git a/sim/Statecraft.Sim.Tests/LedgerHalutzLinkTests.cs b/sim/Statecraft.Sim.Tests/LedgerHalutzLinkTests.csindex 8afe6cc49..d10b6cab4 100644--- a/sim/Statecraft.Sim.Tests/LedgerHalutzLinkTests.cs+++ b/sim/Statecraft.Sim.Tests/LedgerHalutzLinkTests.cs@@ -330,7 +330,8 @@ public class LedgerHalutzLinkTestsvar ledger = s.PopulationLedger;var teacher = ledger.Get(Teacher(s));var region = Region(c, TelAviv);- var field = ledger.Units.First(p => p.Assignment.Kind == PopulationAssignmentKind.Work && p.Location?.Region == region);+ var field = ledger.Units.First(p => p.Assignment.Kind == PopulationAssignmentKind.Work && p.Location?.Region == region+ && p.Assignment.Target!.StartsWith(HistoricalPopulation.FarmerPrefix, StringComparison.Ordinal));ledger.Replace(teacher.WithPlacement(teacher.Status, new PopulationLocation(region, city: TelAviv), field.Assignment, teacher.Captor, teacher.Home));var why = new List<Cause>();var returned = ledger.NextPopulationId;diff --git a/sim/Statecraft.Sim.Tests/LedgerMonthSnapshotTests.cs b/sim/Statecraft.Sim.Tests/LedgerMonthSnapshotTests.csindex 9b70a52db..197ebfb0f 100644--- a/sim/Statecraft.Sim.Tests/LedgerMonthSnapshotTests.cs+++ b/sim/Statecraft.Sim.Tests/LedgerMonthSnapshotTests.cs@@ -13,15 +13,18 @@ public class LedgerMonthSnapshotTestsstatic string Ledger(GameState s) => string.Join("\n", s.PopulationLedger.Canonical());- // The synthetic month the field fixtures build for the same people: every authored field available, one slot each.+ // The synthetic month the field fixtures build for the same people: every authored field available, one slot each, and+ // (#1725 PR 3) every census city's Industry available with its job_slots.static Gdd03SyntheticMonthContext Synthetic(Content c, GameState s) => Gdd03SyntheticMonthContext.CreateSynthetic(SaveGame.Gdd03Ruleset, s.Turn, s.PopulationLedger.Units,- Gdd03FieldFixture.Fields(c).Select(f => new Gdd03SyntheticFacilitySnapshot(f.Id, true, 1)),+ Gdd03FieldFixture.Fields(c).Select(f => new Gdd03SyntheticFacilitySnapshot(f.Id, true, 1))+ .Concat(c.Cities.Select(x => new Gdd03SyntheticFacilitySnapshot(HistoricalPopulation.IndustryTarget(x.Id), true, x.JobSlots))),Array.Empty<Gdd03SyntheticHousingSnapshot>(), Array.Empty<Gdd03SyntheticPendingEntry>());// #1716, R-FOOD-002 (#2470): the snapshot holds every living own record of the ledger once, in id order, with its- // opening record; the facility entries are the ledger's bound field Work targets, in ordinal order, so each farmer- // on a field is work-eligible (an upper bound: the consumer rechecks it).+ // opening record; the facility entries are the ledger's bound field Work targets with one slot each, and (#1725 PR 3)+ // its Industry targets with their capacity, in ordinal order, so each farmer on a field and each Industry worker is+ // work-eligible (an upper bound: the consumer rechecks it).[Fact]public void TheSnapshotHoldsEveryLivingOwnRecordOnce(){@@ -34,12 +37,18 @@ public class LedgerMonthSnapshotTestsAssert.Equal(units, month.OpeningPeople);Assert.Equal(units.Count, Pools.Rations(month.OpeningPeople));Assert.Equal(s.Turn, month.MonthOrdinal);- var fields = units.Where(u => u.Assignment.Kind == PopulationAssignmentKind.Work).Select(u => u.Assignment.Target!)- .Distinct(StringComparer.Ordinal).OrderBy(x => x, StringComparer.Ordinal).ToList();+ var targets = units.Where(u => u.Assignment.Kind == PopulationAssignmentKind.Work).Select(u => u.Assignment.Target!)+ .Distinct(StringComparer.Ordinal).ToList();+ var fields = targets.Where(t => t.StartsWith("field/", StringComparison.Ordinal)).ToList();+ // Every census city's Industry target has an entry, a city with no employed too.+ var industry = c.Cities.Select(x => HistoricalPopulation.IndustryTarget(x.Id)).ToList();Assert.NotEmpty(fields);- Assert.All(fields, f => Assert.StartsWith("field/", f));- Assert.Equal(fields, month.Facilities.Select(f => f.Id));- Assert.All(month.Facilities, f => Assert.True(f.AvailableAtMonthFreeze && f.OpeningCapacity == 1));+ Assert.All(targets, t => Assert.True(fields.Contains(t) || industry.Contains(t), t));+ Assert.Equal(fields.Concat(industry).OrderBy(x => x, StringComparer.Ordinal), month.Facilities.Select(f => f.Id));+ Assert.All(month.Facilities, f => Assert.True(f.AvailableAtMonthFreeze));+ Assert.All(month.Facilities.Where(f => fields.Contains(f.Id)), f => Assert.Equal(1, f.OpeningCapacity));+ Assert.All(month.Facilities.Where(f => industry.Contains(f.Id)), f => Assert.Equal(+ c.Cities.Single(x => HistoricalPopulation.IndustryTarget(x.Id) == f.Id).JobSlots, f.OpeningCapacity));Assert.Equal(units.Where(u => u.Assignment.Kind == PopulationAssignmentKind.Work).Select(u => u.Id), month.WorkEligibleIds);Assert.Empty(month.CourseEligibleIds); Assert.Empty(month.ReceptionEligibleIds);Assert.Empty(month.Housing); Assert.Empty(month.PendingEntries);diff --git a/sim/Statecraft.Sim/Gdd03SyntheticMonthContext.cs b/sim/Statecraft.Sim/Gdd03SyntheticMonthContext.csindex 3fae2c01d..c4d25cce2 100644--- a/sim/Statecraft.Sim/Gdd03SyntheticMonthContext.cs+++ b/sim/Statecraft.Sim/Gdd03SyntheticMonthContext.cs@@ -91,13 +91,13 @@ namespace Statecraft.Sim/// turn, after the player's orders, and harvest, Industry income and Food all read it. The opening people are the/// ledger's living own records (<see cref="PopulationLedger.Units"/>), in id order; the facility entries are the/// ledger's bound Work targets that are authored fields (Gdd03FieldFixture ids,- /// field/q,r), in ordinal order, each available at the freeze with `field.slots`- /// capacity. Owner, 8 November 2026, "Yes, recheck (Recommended)": that availability is only an upper bound, and a+ /// field/q,r), each available at the freeze with `field.slots`+ /// capacity, and (#1725 PR 3) its Industry targets, each available with its own capacity, in ordinal order. Owner, 8 November 2026, "Yes, recheck (Recommended)": that availability is only an upper bound, and a/// consumer rechecks an entry (its id and opening record are kept) against the live state before using it. The/// month ordinal is the turn (<see cref="GameState.Turn"/>). Every check comes before anything is built, and it/// writes nothing: the state, its hash and the ledger are unchanged. A synthetic or Open ledger, an aggregate game/// and any other content are refused (R-POP-002); so is a ledger with a Work, Course, Reception or Teaching target- /// that is not a field, whose entry no ruling defines yet (<see cref="CreateSynthetic"/>'s inventory check).</summary>+ /// that is neither a field nor an Industry target, whose entry no ruling defines yet (<see cref="CreateSynthetic"/>'s inventory check).</summary>internal static Gdd03SyntheticMonthContext CreateLive(Content content, GameState state){if (content == null) throw new ArgumentNullException(nameof(content));@@ -109,8 +109,12 @@ namespace Statecraft.Simvar slots = Gdd03FieldRates.FromCatalogue(content.Gdd03Balance?? throw new ContentException(Gdd03BalanceCatalogue.FileName, "values.field.slots", "required under gdd-0.3")).SlotsPerField;var authored = new HashSet<string>(Gdd03FieldFixture.Fields(content).Select(f => f.Id), StringComparer.Ordinal);- var fields = ledger.Bindings.Targets.Where(t => t.Kind == PopulationAssignmentKind.Work && authored.Contains(t.Id))- .Select(t => new Gdd03SyntheticFacilitySnapshot(t.Id, true, slots)).ToArray();+ // #1725 PR 3 (owner, 11 November 2026, #1725: "A: available now (Recommended)"): an Industry target is an entry as+ // a field is, available at the freeze from turn one with its own capacity (the city's job_slots, R-CITY-007), an+ // upper bound that its consumer (#2469's Industry income) rechecks.+ var fields = ledger.Bindings.Targets.Where(t => t.Kind == PopulationAssignmentKind.Work+ && (authored.Contains(t.Id) || t.WorkKind == PopulationWorkKind.Industry))+ .Select(t => new Gdd03SyntheticFacilitySnapshot(t.Id, true, t.Capacity ?? slots)).ToArray();return CreateSynthetic(SaveGame.Gdd03Ruleset, state.Turn, ledger.Units, fields,Array.Empty<Gdd03SyntheticHousingSnapshot>(), Array.Empty<Gdd03SyntheticPendingEntry>());}diff --git a/sim/Statecraft.Sim/HistoricalPopulation.cs b/sim/Statecraft.Sim/HistoricalPopulation.csindex ba41f6ece..8fcdaff2d 100644--- a/sim/Statecraft.Sim/HistoricalPopulation.cs+++ b/sim/Statecraft.Sim/HistoricalPopulation.cs@@ -65,6 +65,10 @@ namespace Statecraft.Sim/// <summary>The census city of the training centre's one veteran pioneer teacher (owner, 7 November 2026, #1689/// comment 6704565066: "the training centre's one veteran pioneer teacher is a Haifa census unit").</summary>internal const string TeacherCity = "haifa";+ /// <summary>#1725 PR 3: a census city's Industry Work target is this prefix plus the city id (as+ /// military_camp/<city>), so a city has exactly one.</summary>+ internal const string IndustryPrefix = "industry/";+ internal static string IndustryTarget(string city) => IndustryPrefix + city;/// <summary>The population id of the training centre's veteran pioneer teacher on a Historical ledger: the last/// census/haifa record, as the start makes it (#1689), or null when the ledger has no census/haifa record. Owner, 7@@ -184,7 +188,7 @@ namespace Statecraft.Sim/// its real region of regions.yaml. A census record takes the region that lists its city (AtLocation), and its location names that city. A formation/// record takes the region of its starting anchor hex (AtHex): the owner's ruling on #1689's open question 1/// (3 November 2026: "Its anchor hex's region (Recommended)"). A source with no region is refused; no region is invented. Records- /// are free civilians with no assignment and their reception done (reception.turns), and soldiers serving in their own+ /// are free civilians with no assignment (but each city's employed, on its Industry target, #1725 PR 3) and their reception done (reception.turns), and soldiers serving in their own/// formation, with no profession, tier or qualification (#1717 and #1692 add those), but for the training centre's veteran pioneer teacher, the last census/haifa record (#1689). Each soldier carries one issued military item, id/// <c>units_1948/<row>/<ordinal></c>, owned and recorded as paid, apart from the spare Arms (#1717, 27M-24)./// mode Historical gives #2299's 1,000-a-record scale (D2). Fixture-only: the public NewGame does not call it (R-POP-002).</summary>@@ -239,7 +243,11 @@ namespace Statecraft.Sim// facilities' Course targets are bound at the start; and "Cohorts stay main (Rec.)": each trainee's Course// target is per facility (military_camp/<city>, hakhshara/<city>), in the city's region (27M-7, no travel)..Concat(c.Cities.Where(x => regions.ContainsKey(CensusPrefix + x.Id))- .SelectMany(x => Training.LedgerFacilities(c, x.Facilities).Select(f => Training.CourseTargetOf(c, f, x.Id, regions[CensusPrefix + x.Id]))));+ .SelectMany(x => Training.LedgerFacilities(c, x.Facilities).Select(f => Training.CourseTargetOf(c, f, x.Id, regions[CensusPrefix + x.Id]))))+ // #1725 PR 3: each census city's Industry is a Work target in the city's region, naming the city, with the+ // city's job_slots as its capacity (R-CITY-007); start.industry_slots is the 10,000-scale value, never it.+ .Concat(c.Cities.Where(x => regions.ContainsKey(CensusPrefix + x.Id)).Select(x => new PopulationTarget(IndustryTarget(x.Id),+ PopulationAssignmentKind.Work, regions[CensusPrefix + x.Id], workKind: PopulationWorkKind.Industry, city: x.Id, capacity: x.JobSlots)));// #1689 rows 5 to 8 and the 7th Brigade's combat XP: see SoldierValues.var soldier = new Dictionary<string, (string Qualification, int CombatXp)>(StringComparer.Ordinal);foreach (var f in c.StartingForces.Where(Bound)) soldier[FormationPrefix + f.Row] = SoldierValues(c, f);@@ -276,9 +284,18 @@ namespace Statecraft.Sim// Work XP 0 (owner, relayed: "0 for all (Recommended)"; veterans "0 (Recommended)", #1689 comment 6710877137).// Reception done (reception.turns), as for the census (maintainer call, the coordinator, 7 November 2026). No// tools: post-MVP (#1693 answer 1, "Tools in the MVP: no.").+ // #1725 PR 3. Owner, 7 November 2026 (#1689 comments 6704389240 and 6704428057): a city's employed is its people+ // times its share (R-CITY-007), and every employed unit starts in Industry. Which records: the city's first+ // `employed` census ordinals, which are its ascending population ids, as #1692's job default gains the Industry+ // assignment (owner, 3 November 2026, "Approve all three (Recommended)"); so the teacher, the last ordinal, is+ // taken last. Farmers are on top of the census and stay out (#1725 PR 4); the start has no craftsmen.+ var employed = c.Cities.ToDictionary(x => CensusPrefix + x.Id, x => x.Employed, StringComparer.Ordinal);PopulationAssignment Assignment(HistoricalPopulationRow r) => r.Status == PopulationStatus.ActiveSoldier? new PopulationAssignment(PopulationAssignmentKind.ActiveService, r.Source)- : farmer.TryGetValue(r.Source, out var f) ? new PopulationAssignment(PopulationAssignmentKind.Work, f.Field) : PopulationAssignment.Unassigned;+ : farmer.TryGetValue(r.Source, out var f) ? new PopulationAssignment(PopulationAssignmentKind.Work, f.Field)+ : employed.TryGetValue(r.Source, out var n) && r.Ordinal < n+ ? new PopulationAssignment(PopulationAssignmentKind.Work, IndustryTarget(r.Source.Substring(CensusPrefix.Length)))+ : PopulationAssignment.Unassigned;CivilianProfession Profession(HistoricalPopulationRow r) => IsTeacher(r) ? CivilianProfession.Pioneer: farmer.ContainsKey(r.Source) ? CivilianProfession.Farmer : CivilianProfession.None;CivilianTier Tier(HistoricalPopulationRow r) => IsTeacher(r) ? CivilianTier.Veterandiff --git a/sim/Statecraft.Sim/PopulationLedger.cs b/sim/Statecraft.Sim/PopulationLedger.csindex bf8d79409..691627732 100644--- a/sim/Statecraft.Sim/PopulationLedger.cs+++ b/sim/Statecraft.Sim/PopulationLedger.cs@@ -6,22 +6,45 @@ using System.Linq;namespace Statecraft.Sim{+ /// <summary>#1725 PR 3: the kind of work a Work target is. Industry is a city's job slots (R-CITY-007); every other+ /// target has none.</summary>+ public enum PopulationWorkKind { None, Industry }+public sealed class PopulationTarget{public string Id { get; }public PopulationAssignmentKind Kind { get; }public string Region { get; }public int? MaxProgressTicks { get; }- public PopulationTarget(string id, PopulationAssignmentKind kind, string region, int? maxProgressTicks = null)+ /// <summary>#1725 PR 3: <see cref="PopulationWorkKind.Industry"/> for a city's Industry, else None.</summary>+ public PopulationWorkKind WorkKind { get; }+ /// <summary>#1725 PR 3: an Industry target's city, a census city of its region (Q27: "a worker works in their+ /// own city"); null for every other target.</summary>+ public string? City { get; }+ /// <summary>#1725 PR 3: the most records an Industry target holds, the city's job_slots (R-CITY-007); null for every+ /// other target.</summary>+ public int? Capacity { get; }+ /// <summary>An Industry target (<paramref name="workKind"/>) is a Work target with its <paramref name="city"/> and a+ /// nonnegative <paramref name="capacity"/>; any other target has neither.</summary>+ public PopulationTarget(string id, PopulationAssignmentKind kind, string region, int? maxProgressTicks = null,+ PopulationWorkKind workKind = PopulationWorkKind.None, string? city = null, int? capacity = null){PopulationText.Assignment(kind);if (string.IsNullOrWhiteSpace(id) || string.IsNullOrWhiteSpace(region) || kind == PopulationAssignmentKind.Unassigned|| maxProgressTicks < 0 || (kind == PopulationAssignmentKind.Course) != maxProgressTicks.HasValue)throw new ArgumentException("Targets need explicit kind/region; courses need an explicit progress limit.");+ if (!Enum.IsDefined(typeof(PopulationWorkKind), workKind) || (workKind == PopulationWorkKind.Industry+ ? kind != PopulationAssignmentKind.Work || string.IsNullOrWhiteSpace(city) || capacity is not int cap || cap < 0+ : city != null || capacity != null))+ throw new ArgumentException("An Industry target is a Work target with a city and a nonnegative capacity; no other target has either.");PopulationText.ValidateText(id); PopulationText.ValidateText(region);+ if (city != null) PopulationText.ValidateText(city);Id = id; Kind = kind; Region = region; MaxProgressTicks = maxProgressTicks;+ WorkKind = workKind; City = city; Capacity = capacity;}- internal string Canonical() => PopulationText.Fields(Id, PopulationText.Assignment(Kind), Region, MaxProgressTicks);+ // The Industry fields are written only when set (as PopulationLocation's |city=), so every other target keeps its text.+ internal string Canonical() => PopulationText.Fields(Id, PopulationText.Assignment(Kind), Region, MaxProgressTicks)+ + (WorkKind == PopulationWorkKind.Industry ? "|industry=" + PopulationText.Fields(City, Capacity) : "");}/// <summary>Frozen explicit reference inventory. No guesses about regional hex ownership, facilities or qualifications.@@ -78,6 +101,10 @@ namespace Statecraft.Sim/// locality, a sites.yaml id or a map location, is refused (review of #2936, S1-1).</summary>internal void ValidateCities(Content c){+ // #1725 PR 3: an Industry target's city is a census city (cities.yaml, R-CITY-006) of its region in regions.yaml.+ foreach (var t in targets.Values.Where(t => t.City != null))+ if (c.PlayerRegions.AtLocation(t.City!)?.Id != t.Region || !c.Cities.Any(x => x.Id == t.City))+ throw new ArgumentException("Industry target " + t.Id + " needs a census city of region " + t.Region + " (R-POP-002).");foreach (var l in locations){if (l.City == null) continue;@@ -366,6 +393,7 @@ namespace Statecraft.Simvoid Validate(SortedDictionary<int, PopulationUnit> candidate, PopulationBindings bindings){var issued = new HashSet<string>(StringComparer.Ordinal);+ var held = new Dictionary<string, int>(StringComparer.Ordinal); // records per capacity target (#1725 PR 3)foreach (var p in candidate.Values){if (p.ReceptionTicks > receptionLimit || !bindings.HasQualification(p.Qualification))@@ -405,6 +433,15 @@ namespace Statecraft.Simvar target = bindings.Target(p.Assignment);if (target.Region != p.Location!.Region || (kind == PopulationAssignmentKind.Course && p.Assignment.ProgressTicks > target.MaxProgressTicks))throw new ArgumentException("Assignment region/progress is inconsistent.");+ // #1725 PR 3, Q27: "a worker works in their own city".+ if (target.City != null && !string.Equals(p.Location!.City, target.City, StringComparison.Ordinal))+ throw new ArgumentException("An Industry worker works in their own city (R-POP-002).");+ if (target.Capacity is int capacity)+ {+ held.TryGetValue(target.Id, out var n);+ held[target.Id] = ++n;+ if (n > capacity) throw new ArgumentException("Industry target " + target.Id + " holds at most " + capacity.ToString(CultureInfo.InvariantCulture) + " records (R-CITY-007).");+ }if (p.Assignment.TeacherId is int teacherId && (teacherId == p.Id || !candidate.TryGetValue(teacherId, out var teacher)|| teacher.Assignment.Kind != PopulationAssignmentKind.Teaching || teacher.Assignment.Target != p.Assignment.Target))throw new ArgumentException("Course teacher reference must resolve to a teacher of the same course.");