A Civilization-style strategy game about governing Israel from 15 May 1948. Real ministers, real map, every fact sourced. Unity + deterministic C# sim.
GDD 0.3 courses: the MVP centre is a host-city facility (Refs #1697) (#2413)
Eyal Goland81b257b8822
diff --git a/changelog.d/1697-host-city-centre.md b/changelog.d/1697-host-city-centre.mdnew file mode 100644index 000000000..9f6b351ec--- /dev/null+++ b/changelog.d/1697-host-city-centre.md@@ -0,0 +1,7 @@+- GDD 0.3 training centre courses in the sim test fixture (Refs #1697): a centre is now a facility in its host city+ with one veteran teacher and one pupil, both in the centre's region (which stands in for the city), and no+ reception camp, upgrade or reception bed. A novice needs no tools to enrol (tools are post-MVP), a pupil or teacher+ may leave a job to start a course, released in the same step, and a centre's place freed by a cancel or a+ graduation is free at once. A second teacher or pupil at a centre, or a teacher with no pupil, is refused with a+ plain reason instead of "Deferred". Nothing in the game calls this fixture yet, so nothing changes for players and+ saves are unaffected.diff --git a/docs/gdd/training.md b/docs/gdd/training.mdindex 7efe7f5e2..04bb25385 100644--- a/docs/gdd/training.md+++ b/docs/gdd/training.md@@ -74,7 +74,7 @@ Cancelled retained courses award no unfinished qualification. A course whose slo- `sim/Statecraft.Sim.Tests/golden/manifest.txt`: `mvp-slice` moved (retired at the cutover); `scenario-mvp-absorb-first` did not. Phase 4 PR 3 moves `hash1950`, `hash1952` and `mvp-end`: the reference player builds the two camps once the yishuv sites are taken (docs/determinism.md).- Finished recruit cohorts become military units and never fill `City.Recruits` (`R-TRAIN-003`, `R-UNIT-003`); Amir's proposal to replace recruit counts during training is non-operative [S6].- Unit types, scenario inventory, facilities and training commands require coordinated migration.-- **Amir's proposal [S6]:** reception beds, teacher housing and proposed military trainee slots would be distinct capacity fields; the owner's 30 October 2026 conflict review did not rule on this, and main has only inactive `gdd-0.3` fixtures for them (`docs/rules/mvp.md:107`, `R-TRAIN-005`). Reception beds are post-MVP, the teacher lives as an ordinary resident, and every military camp uses `military.camp_capacity` (owner, 1 November 2026, "Keep R-CITY-004 (Recommended)", Q42 and 27M-25) [S11].+- **Amir's proposal [S6]:** reception beds, teacher housing and proposed military trainee slots would be distinct capacity fields; the owner's 30 October 2026 conflict review did not rule on this, and main has only an inactive `gdd-0.3` reception fixture (`docs/rules/mvp.md:107`). Reception beds are post-MVP, the teacher lives as an ordinary resident, and every military camp uses `military.camp_capacity` (owner, 1 November 2026, "Keep R-CITY-004 (Recommended)", Q42 and 27M-25) [S11].- Historical army size comes from the sourced `content/map/units_1948.yaml` seed (`Q-START-1`, decided 15 October 2026); only the non-Historical parameter `A` and real reception-facility availability stay deferred in the GDD (owner, 30 Oct 2026) [S6]; the starting centre and reception host is Kiryat Shmuel, Haifa (owner, 1 November 2026, O8 and 27M-25) [S11].## Done whendiff --git a/docs/rules/mvp.md b/docs/rules/mvp.mdindex 9b9450f27..67f486e4a 100644--- a/docs/rules/mvp.md+++ b/docs/rules/mvp.md@@ -172,13 +172,13 @@ R-TRAIN-003: Each turn, in ascending id, every cohort has one turn less to go. AR-TRAIN-004: `Reinforce(unit, city, n)` (#1510; owner, 23 October 2026: "Replacements cost Arms", https://github.com/eyalgolan/statecraft-israel/issues/1510#issuecomment-6372356139, and "Default (Recommended)") refills a damaged formation of the player's with trained replacements. The unit must be a military unit of the player's side standing on `city`'s settlement hex. Its course is the trained type of the unit's side and class (a type with a `facility`): the recruit's basic training for a recruit or a veteran soldier, the guns' and the armoured cars' own for artillery and armoured cars (R-UNIT-008); a type no course trains (any enemy type) takes none. The cohort then follows R-TRAIN-001: the city's facility, `n` of its civilians without a job, `n * training_cost` with borrowing (R-MONEY-003), and the Arms of R-ARMS-003 for that course; it carries the unit's id, written into the state hash (`|unit=<id>`) only when set. The cap is the strength the unit had before its first loss, `Unit.Full`: combat stores it on a player's unit at its first loss (R-COMBAT-003) and clears it when replacements bring the unit back to it, and it is written into the state hash (`|full=<n>`) only when set, so a unit that has lost nobody, and every enemy unit, hashes as before. The order is refused, the state and Attention unchanged, for an unknown unit ("There is no such unit"), a unit with no side or an enemy unit (R-ORDER-001's wording), an unknown city, a unit off the city's hex ("Unit N is not in <city>"), a type no course trains ("Unit N cannot take replacements"), a unit with nothing to refill ("Unit N has no losses to replace") and `n` past the cap less the unit's strength and the replacements already training for it ("Unit N can take K more groups"), then for R-TRAIN-001's and R-ARMS-003's reasons. A queued `Reinforce` takes its city's civilians as a queued `Train` does (R-CITY-001). In step 4, before a turn is counted, replacements whose unit has left the state (destroyed, captured, sent home) or stands off the city's hex are cancelled as R-TRAIN-002 cancels a cohort: people and Arms back, the Money spent, with a Why line. A cohort that finishes adds its count to the unit's strength and makes no unit and takes no id; the unit keeps its type, service, order and home (a veteran stays a veteran, R-UNIT-004). The people join the unit's home city's housing (R-HOUSE-003). `attention_cost.reinforce` is 1, Train's cost, a design value (owner, 24 October 2026: "1, like Train (Recommended)", https://github.com/eyalgolan/statecraft-israel/issues/1510#issuecomment-6375591436). The save line is `reinforce <unit> <city> <n>` and the scenario form `{ kind: reinforce, unit, city, count }`.-R-TRAIN-005: In gdd-0.3 synthetic fixtures only (#1697; nothing in the game calls it), a farmer or pioneer course starts at a training centre whose parent reception camp operates and whose upgrade is complete. The teacher is a received free civilian, a veteran of the matching profession, with no other assignment; the trainee is a received, unassigned free civilian who is a novice of that profession with tools. The trainee takes one of the parent camp's own reception beds (Agreed `reception.capacity`, refugee or course-trainee beds per camp); another camp's beds or ordinary work places do not stand in, and the teacher's separate housing is not a reception bed. A teacher takes at most Agreed `profession.trainees_per_teacher` pupils (currently 1), so a busy teacher refuses another pupil. No Money is charged: the tools were paid on entry and a matching course does not charge them again. Teacher and trainee then hold exclusive Teaching and Course assignments, so other assignment paths refuse them. Every refusal leaves the state unchanged. Sources at `605277dfa511dc512562ececeb273b8393b21d35`: `docs/gdd/training.md:15`, "A later matching formal course does not charge tools again."; `:31`, "A training-centre upgrade needs an operating reception camp and a matching veteran teacher. It supplies separate teacher housing. The teacher is fully occupied and cannot work, fight, build, travel or teach another pupil simultaneously. The trainee occupies a reception bed."; `:33`, "A free civilian or matching equipped novice may train." Craftsmen, soldiers and refugees before `reception.turns` cannot enrol. Only exact gdd-0.3 states with an initialized population ledger are accepted; legacy and gdd-0.1 are refused unchanged.+R-TRAIN-005: In gdd-0.3 synthetic fixtures only (#1697; nothing in the game calls it), a farmer or pioneer course starts at an operating training centre, a facility in its host city with no reception camp, centre upgrade or reception bed (owner, 1 November 2026, "No reception-bed layer (Recommended)"; `docs/gdd/training.md:38`, "The MVP has no reception-bed layer"). A centre has one veteran teacher and one pupil, the teacher housed in the centre's city (GDD, 1 November 2026 answers, `docs/GDD.md:372`: "One veteran teacher and one pupil per centre, the teacher housed in the centre's city (Q42)."). A population location has a region and an optional hex or facility but no city, so the centre's region stands in for its host city, an approximation until real places are bound (#1691). A teacher outside the centre's region is refused with a plain reason that cites Q42. Q42 rules only on the teacher; that the trainee is in the centre's city too is our reading, pending maintainer confirmation (#1697 body: "the teacher and the trainee are housed there as ordinary residents"; `docs/GDD.md:374`, "Training is ordered in the camp's city, with no travel (27M-7)."), and a trainee outside the region is refused with a plain reason that says so. A centre takes at most one teacher and one pupil, whatever `profession.trainees_per_teacher` says: a second teacher, or a second pupil while one is on a course there, is refused with a plain reason that cites Q42, not as Deferred, and an inventory with either is refused the same way. The teacher is a free civilian, a veteran of the matching profession; the trainee is a free civilian who is a novice of that profession. Either may hold a job, which is released in the same commit that starts the course (a reading of `docs/gdd/cities.md:42`, "Reassignment releases old capacity atomically.", with `docs/GDD.md:372`, Q43(b) and (c), "can be assigned from the next planning, or at once on cancellation", and `docs/gdd/training.md:66`, people "return at once"); a teacher teaching elsewhere, or a pupil on a course, is refused, since only a cancel or a graduation ends those here. No reception progress is read (`docs/GDD.md:374`, "Refugees cannot train until they become civilians"), and refugees in a reception camp take no course place. No tools are needed or charged: tools are post-MVP (#1693, owner answers of 3 November 2026, answer 1: "Tools in the MVP: no."), and the record's tools fields are kept unchanged. A teacher also takes at most Agreed `profession.trainees_per_teacher` pupils (currently 1; the approved Q42 answer names this value as its basis), so a busy teacher refuses another pupil; a synthetic value above 1 admits no second pupil, because the centre's own limit is one. No Money is charged. Teacher and trainee then hold exclusive Teaching and Course assignments, so other assignment paths refuse them (`docs/gdd/training.md:31` at `605277dfa511dc512562ececeb273b8393b21d35`, "The teacher is fully occupied and cannot work, fight, build, travel or teach another pupil simultaneously."). Every refusal leaves the state unchanged. Craftsmen, soldiers and refugees cannot enrol. Only exact gdd-0.3 states with an initialized population ledger are accepted; legacy and gdd-0.1 are refused unchanged.-R-TRAIN-006: In the same fixture, the enrolment month is course turn 1 (#1668 question 43(a); GDD, 1 November 2026 answers: "A course occupies its people from its first turn"), so a course turn is counted in the enrolment month, even with a snapshot taken before the course started, unless the centre was not available at that month's freeze, and in a later month only when its opening snapshot (the #1716 synthetic month context) already holds that course with the same teacher. It is counted at most once per month ordinal: an ordinal before the enrolment month, or not above the last one counted for that pupil, is refused. A counted turn keeps the same population id and every record field (work XP, reception progress, equipment, location, military history); no person is created, and teaching and the course earn no work XP (`docs/gdd/training.md:17` at `605277dfa511dc512562ececeb273b8393b21d35`, "Travel, idle time, teaching and courses do not count."). The turn that brings a course to Agreed `profession.course_turns` counted turns (currently 3) graduates it: the pupil takes the trained tier through R-QUAL-008's transform and keeps the same id, work XP, reception progress, equipment and the tools' payment fact, location and military history; the pupil and the teacher (when that was the teacher's last pupil) are released in that turn, in one change, as civilians without a job. Nothing is charged and no person is created. #1697: "A free civilian or a matching equipped novice may enrol; completion gives the trained tier." Release timing follows R-TRAIN-008. The fixture also refuses a unit already trained, because Amir's proposal made a trained profession permanent (`docs/gdd/training.md:13` at the same commit, "Once trained, a civilian profession cannot be replaced."). That lock is post-MVP: D3 keeps two-way professions (R-QUAL-006), and the GDD's 1 November 2026 answers say "Graduates join their city's civilians and may re-enrol at any time" (27M-5).+R-TRAIN-006: In the same fixture, the enrolment month is course turn 1 (#1668 question 43(a); GDD, 1 November 2026 answers: "A course occupies its people from its first turn"), so a course turn is counted in the enrolment month, even with a snapshot taken before the course started, unless the centre was not available at that month's freeze, and in a later month only when its opening snapshot (the #1716 synthetic month context) already holds that course with the same teacher. It is counted at most once per month ordinal: an ordinal before the enrolment month, or not above the last one counted for that pupil, is refused. A counted turn keeps the same population id and every record field (work XP, reception progress, equipment, location, military history); no person is created, and teaching and the course earn no work XP (`docs/gdd/training.md:17` at `605277dfa511dc512562ececeb273b8393b21d35`, "Travel, idle time, teaching and courses do not count."). The turn that brings a course to Agreed `profession.course_turns` counted turns (currently 3) graduates it: the pupil takes the trained tier through R-QUAL-008's transform and keeps the same id, work XP, reception progress, equipment and the tools' payment fact, location and military history; the pupil and the teacher (a centre has one pupil, R-TRAIN-005) are released in that turn, in one change, as civilians without a job. Nothing is charged and no person is created. #1697: "A free civilian or a matching equipped novice may enrol; completion gives the trained tier." Release timing follows R-TRAIN-008. The fixture also refuses a unit already trained, because Amir's proposal made a trained profession permanent (`docs/gdd/training.md:13` at the same commit, "Once trained, a civilian profession cannot be replaced."). That lock is post-MVP: D3 keeps two-way professions (R-QUAL-006), and the GDD's 1 November 2026 answers say "Graduates join their city's civilians and may re-enrol at any time" (27M-5).-R-TRAIN-007: In the same fixture, cancelling a course at any turn before its graduation keeps the population id, profession, novice tier, tools and their payment fact and reception progress. It grants no unfinished trained tier, clears the course progress and releases the teacher and the bed. Nothing is refunded and no one moves. The released teacher and pupil are civilians without a job at once, in that month's snapshot, and may take a job that month, or start another course that month where its camp had a bed free at the month's opening (#1716; #1668 question 43(b), owner-approved answer of 1 November 2026, [answers](https://github.com/eyalgolan/statecraft-israel/pull/1668#issuecomment-6553884547): "Cancellation: they are released at once, as civilians without a job."). The freed bed is not reused before the next month's opening (R-TRAIN-008). A second cancel, a cancel of a unit not in a course, or a cancel or further course turn for a graduate, is refused unchanged, and a restart is a full new course with no second tools charge (`docs/gdd/training.md:49`, "Cancelled courses retain paid entry costs and earned reception credit but award no unfinished qualification." and "Unfinished course progress clears, and restarting needs a fresh course.").+R-TRAIN-007: In the same fixture, cancelling a course at any turn before its graduation keeps the population id, profession, novice tier, the record's tools fields and reception progress. It grants no unfinished trained tier, clears the course progress and releases the teacher and the centre's place. Nothing is refunded and no one moves. The released teacher and pupil are civilians without a job at once, in that month's snapshot, and may take a job that month, or start another course that month, and the centre can take another teacher and pupil at once (#1716; #1668 question 43(b), owner-approved answer of 1 November 2026, [answers](https://github.com/eyalgolan/statecraft-israel/pull/1668#issuecomment-6553884547): "Cancellation: they are released at once, as civilians without a job."). A second cancel, a cancel of a unit not in a course, or a cancel or further course turn for a graduate, is refused unchanged, and a restart is a full new course with no charge (`docs/gdd/training.md:49`, "Cancelled courses retain paid entry costs and earned reception credit but award no unfinished qualification." and "Unfinished course progress clears, and restarting needs a fresh course.").-R-TRAIN-008: The fixture refuses, with a "Deferred:" reason and the state unchanged, every case this slice has not built, and chooses no default. Questions 42, 43 and 44 and the novice lock-in below are decided (GDD, 1 November 2026 answers, and D3), so those refusals are implementation gaps, not open design answers; Q42's answer is "One veteran teacher and one pupil per centre, the teacher housed in the centre's city". #1668 question 42 (teachers per centre and teacher housing): a second teacher at one centre, or a teaching teacher with no pupil. #1668 question 43, the one case not built here: starting in a month whose opening snapshot shows either participant on another assignment, except a pupil whose opening assignment was work and who was released from it this turn (an immediate job change; the course occupies them from its start turn, Q43(a), #1716; a teacher who worked at the opening and was released this turn stays Deferred), and except a pupil or teacher whose opening course or teaching was cancelled this turn (released at once, Q43(b), #1716; R-TRAIN-007). The ruled question 43 limits are refused unchanged with a plain reason that cites the ruling, not as Deferred: counting a month after the enrolment month whose opening snapshot does not hold the course with the same teacher (43(a)); and starting a course when the parent camp's beds taken at the month's opening plus the courses already started in that camp this month fill its beds, so a bed freed after the opening, by a cancel, a graduation or otherwise, is not reused that month, and a course started and cancelled in the same month still counts against that month's beds (43(b), with #1668 question 41). #1668 question 44 and the GDD's novice lock-in decision: a free civilian without a profession, or a novice of another profession, entering a course. #1668, 27 October list, question 9: a course turn or cancellation after the parent camp or the centre stops operating. Graduation release under question 43(b) and (c) is built and is not Deferred (#1697 body, owner answers of 1 November 2026: "on graduation the people are released in the turn the last course turn counts and can be assigned from the next turn's planning" and "a person whose course ends this turn starts work the next turn"): a graduate and a teacher released by the graduation cannot start a course in the graduation month (refused unchanged with a plain reason, not Deferred) and can from the next month; the bed the graduate held is not reused before the next month's opening, as above; and work eligibility is read from the month's opening snapshot (#1716), where the graduate still holds the course, so a job given after graduation counts from the next month. Real centres, hosts, regions, map bindings, Money and Food settlement, saves and commands remain held with their owners (#1691, #1696, #1700, #1702, #1713, #1716; #1690 closed on 2 November 2026, its post-MVP regional pools moved to #2233).+R-TRAIN-008: The fixture refuses, with a "Deferred:" reason and the state unchanged, every case this slice has not built, and chooses no default. Question 44 and the novice lock-in below are decided (GDD, 1 November 2026 answers, and D3), so those refusals are implementation gaps, not open design answers. Question 42 is built and refuses with a plain reason that cites it, not as Deferred (R-TRAIN-005): a second teacher or a second pupil at one centre, a teacher outside the centre's region (the region standing in for the city), and a teaching teacher with no pupil (an invalid inventory); a pupil outside the region is refused with a plain reason that names our reading, as R-TRAIN-005 says. Question 43 is built in full: what either participant held at the month's opening (a job, or a course or teaching cancelled this turn) is no bar to starting a course that month (a reading of `docs/gdd/cities.md:42`, "Reassignment releases old capacity atomically."; `docs/GDD.md:372`, "they are released in the turn its last course turn counts and can be assigned from the next planning, or at once on cancellation"; `docs/gdd/training.md:66`, people "return at once"), except a graduation, below. The ruled question 43 limits are refused unchanged with a plain reason that cites the ruling, not as Deferred: counting a month after the enrolment month whose opening snapshot does not hold the course with the same teacher (43(a)). There are no reception beds, so a centre's place freed by a cancel or a graduation is free at once, also in the month a course started and was cancelled; #1668 question 41's bed reuse is post-MVP (`docs/GDD.md:377`). #1668 question 44 and the GDD's novice lock-in decision: a free civilian without a profession, or a novice of another profession, entering a course. #1668, 27 October list, question 9: a course turn or cancellation after the centre stops operating. Graduation release under question 43(b) and (c) is built and is not Deferred (#1697 body, owner answers of 1 November 2026: "on graduation the people are released in the turn the last course turn counts and can be assigned from the next turn's planning" and "a person whose course ends this turn starts work the next turn"): a graduate and a teacher released by the graduation cannot start a course in the graduation month, even after taking a job that month (refused unchanged with a plain reason, not Deferred), and can from the next month; and work eligibility is read from the month's opening snapshot (#1716), where the graduate still holds the course, so a job given after graduation counts from the next month. Real centres, hosts, regions, map bindings, Money and Food settlement, saves and commands remain held with their owners (#1691, #1696, #1700, #1702, #1713, #1716; #1690 closed on 2 November 2026, its post-MVP regional pools moved to #2233).## Craftsmendiff --git a/sim/Statecraft.Sim.Tests/Gdd03TrainingCentreFixtureTests.cs b/sim/Statecraft.Sim.Tests/Gdd03TrainingCentreFixtureTests.csindex 4ab651ae9..981462060 100644--- a/sim/Statecraft.Sim.Tests/Gdd03TrainingCentreFixtureTests.cs+++ b/sim/Statecraft.Sim.Tests/Gdd03TrainingCentreFixtureTests.cs@@ -1,6 +1,6 @@using Statecraft.Sim;-// #1697 first slice: synthetic fixtures only. No real centre, camp, region, host or game caller is exercised.+// #1697: synthetic fixtures only. No real centre, camp, region, host or game caller is exercised.public class Gdd03TrainingCentreFixtureTests{static readonly Lazy<Gdd03BalanceCatalogue> Real = new(() => ContentLoader.Load(RealContentTests.ContentRoot()).Gdd03Balance!);@@ -20,17 +20,18 @@ public class Gdd03TrainingCentreFixtureTestsstatic Gdd03DesignValue Agreed(decimal v) => new() { Basis = "Agreed", Values = new() { v }, Note = "synthetic test value" };static Gdd03DesignValue Deferred() => new() { Basis = "Deferred", Expression = "X", Note = "synthetic deferred value" };- static PopulationBindings Bindings() => new(+ // The reception camps are bound only so that refugees can be placed in one; no centre refers to a camp.+ static PopulationBindings Bindings(bool camps = true) => new(new[] { new PopulationLocation("north"), new PopulationLocation("south") },- new[] { new PopulationTarget(CampA, PopulationAssignmentKind.Reception, "north"),+ (camps ? new[] { new PopulationTarget(CampA, PopulationAssignmentKind.Reception, "north"),new PopulationTarget(CampB, PopulationAssignmentKind.Reception, "north"),- new PopulationTarget(CampSouth, PopulationAssignmentKind.Reception, "south"),+ new PopulationTarget(CampSouth, PopulationAssignmentKind.Reception, "south") } : Array.Empty<PopulationTarget>()).Concat(new[] {new PopulationTarget(CentreA, PopulationAssignmentKind.Course, "north", 3),new PopulationTarget(CentreB, PopulationAssignmentKind.Course, "north", 3),new PopulationTarget(CentreSouth, PopulationAssignmentKind.Course, "south", 3),new PopulationTarget(Field, PopulationAssignmentKind.Work, "north"),new PopulationTarget(Workshop, PopulationAssignmentKind.Work, "north"),- new PopulationTarget(Service, PopulationAssignmentKind.ActiveService, "north") },+ new PopulationTarget(Service, PopulationAssignmentKind.ActiveService, "north") }),Array.Empty<string>(), Array.Empty<string>());static PopulationUnit Person(CivilianProfession profession, CivilianTier tier, string? tools,@@ -46,27 +47,32 @@ public class Gdd03TrainingCentreFixtureTests// Ids follow the row order: 0 farmer teacher, 1 farmer novice, 2 pioneer teacher, 3 pioneer novice,// 4 second farmer teacher, 5 second farmer novice, then any extra rows.- static GameState State(Content c, params PopulationUnit[] extra)+ static GameState State(Content c, params PopulationUnit[] extra) => State(c, Bindings(), extra);+ static GameState State(Content c, PopulationBindings bindings, params PopulationUnit[] extra){var people = new List<PopulationUnit> {Teacher(CivilianProfession.Farmer, "tools-0"), Novice(CivilianProfession.Farmer, "tools-1"),Teacher(CivilianProfession.Pioneer, "tools-2"), Novice(CivilianProfession.Pioneer, "tools-3"),Teacher(CivilianProfession.Farmer, "tools-4"), Novice(CivilianProfession.Farmer, "tools-5") };people.AddRange(extra);- return PopulationLedger.CreateFixture(c, Bindings(), people.Select((p, i) => new PopulationInventoryRow("synthetic", i, p)));+ return PopulationLedger.CreateFixture(c, bindings, people.Select((p, i) => new PopulationInventoryRow("synthetic", i, p)));}- static Gdd03FixtureTrainingCentre[] Centres(bool operating = true, bool upgraded = true) => new[] {- new Gdd03FixtureTrainingCentre(CentreA, CampA, operating, upgraded),- new Gdd03FixtureTrainingCentre(CentreB, CampB, true, true),- new Gdd03FixtureTrainingCentre(CentreSouth, CampSouth, true, true) };+ // R-TRAIN-005, Q42: each centre is a facility in its host city's region; two centres share the north.+ static Gdd03FixtureTrainingCentre[] Centres(bool operating = true) => new[] {+ new Gdd03FixtureTrainingCentre(CentreA, "north", operating),+ new Gdd03FixtureTrainingCentre(CentreB, "north", true),+ new Gdd03FixtureTrainingCentre(CentreSouth, "south", true) };static Gdd03SyntheticMonthContext Month(GameState s, int ordinal, bool centresAvailable = true)=> Gdd03SyntheticMonthContext.CreateSynthetic(SaveGame.Gdd03Ruleset, ordinal, s.PopulationLedger.Units,Facilities.Select(f => new Gdd03SyntheticFacilitySnapshot(f, centresAvailable || !f.Contains("centre", StringComparison.Ordinal), 1)),Array.Empty<int>(), Array.Empty<Gdd03SyntheticHousingSnapshot>(), Array.Empty<Gdd03SyntheticPendingEntry>());static (int teacher, int trainee) Pair(CivilianProfession p) => p == CivilianProfession.Farmer ? (0, 1) : (2, 3);- // A ruled #1668 Q43 refusal is a plain ArgumentException with its reason; only unbuilt cases say "Deferred:".- const string BedWaits = Gdd03TrainingCentreFixture.BedWaitsReason;+ // A ruled #1668 Q42 or Q43 refusal is a plain ArgumentException with its reason; only unbuilt cases say "Deferred:".+ const string OneTeacherOnePupil = Gdd03TrainingCentreFixture.OneTeacherOnePupilReason;+ const string TeacherNeedsAPupil = Gdd03TrainingCentreFixture.TeacherNeedsAPupilReason;+ const string TeacherCity = Gdd03TrainingCentreFixture.TeacherCityReason;+ const string PupilCity = Gdd03TrainingCentreFixture.PupilCityReason;const string GraduationMonth = Gdd03TrainingCentreFixture.GraduationMonthReason;const string CourseAtOpening = Gdd03TrainingCentreFixture.CourseAtOpeningReason;@@ -192,58 +198,111 @@ public class Gdd03TrainingCentreFixtureTestsUnchanged(s, () => f.Start(5, 0, CentreB, Month(s, 1)), typeof(ArgumentException));}- // R-TRAIN-005: the pupil limit is the catalogue value; a synthetic 2 admits a second pupil for the same teacher.- // This only proves the value is read from the catalogue: the GDD allows one pupil per teacher (training.md:31 at 605277df).- [Fact] public void PupilLimitComesFromTheCatalogue()+ // R-TRAIN-005, Q42 (docs/GDD.md:372: "One veteran teacher and one pupil per centre"): a centre holds one pupil+ // whatever the catalogue's per-teacher limit says. With a synthetic profession.trainees_per_teacher of 2 (the+ // catalogue's is 1), a second pupil for the same teacher at the same centre is refused with the Q42 reason, in the+ // same month or a later one, the state unchanged; an inventory with two pupils at one centre is refused the same way.+ [Fact] public void ACentreTakesOnePupilWhateverThePerTeacherLimit(){var c = Catalogue("profession.trainees_per_teacher", Agreed(2)); var s = State(c);var f = new Gdd03TrainingCentreFixture(c, s, Centres());f.Start(1, 0, CentreA, Month(s, 0));- f.Start(5, 0, CentreA, Month(s, 0));- Assert.Equal(0, s.PopulationLedger.Get(5).Assignment.TeacherId);- f.Cancel(1);- Assert.Equal(PopulationAssignmentKind.Teaching, s.PopulationLedger.Get(0).Assignment.Kind);- f.Cancel(5);- Assert.Same(PopulationAssignment.Unassigned, s.PopulationLedger.Get(0).Assignment);+ Unchanged(s, () => f.Start(5, 0, CentreA, Month(s, 0)), typeof(ArgumentException), OneTeacherOnePupil);+ Unchanged(s, () => f.Start(5, 0, CentreA, Month(s, 1)), typeof(ArgumentException), OneTeacherOnePupil);+ Assert.Equal(0, s.PopulationLedger.Get(1).Assignment.TeacherId); Assert.Equal(PopulationStatus.FreeCivilian, s.PopulationLedger.Get(5).Status);++ // Id 6 teaches at centre A with two pupils, 7 and 8.+ var two = State(c,+ Person(CivilianProfession.Farmer, CivilianTier.Veteran, "tools-6", assignment: new PopulationAssignment(PopulationAssignmentKind.Teaching, CentreA)),+ Person(CivilianProfession.Farmer, CivilianTier.Novice, "tools-7", PopulationStatus.Trainee,+ assignment: new PopulationAssignment(PopulationAssignmentKind.Course, CentreA, 0, 6)),+ Person(CivilianProfession.Farmer, CivilianTier.Novice, "tools-8", PopulationStatus.Trainee,+ assignment: new PopulationAssignment(PopulationAssignmentKind.Course, CentreA, 0, 6)));+ Unchanged(two, () => new Gdd03TrainingCentreFixture(c, two, Centres()), typeof(ArgumentException), OneTeacherOnePupil);}- // R-TRAIN-005: the trainee needs a free bed of the centre's own reception camp (Agreed reception.capacity = 3);- // another camp's beds or ordinary work places do not stand in, and the teacher's housing is not a reception bed.- [Fact] public void TraineeNeedsTheParentCampsOwnReceptionBed()+ // R-TRAIN-005: the MVP has no reception-bed layer (owner, 1 November 2026, "No reception-bed layer (Recommended)";+ // docs/gdd/training.md:38), so refugees in a camp take no course place. With three refugees in camp A (the old+ // reception.capacity) and one in camp B, both northern centres still start a course.+ [Fact] public void RefugeesInAReceptionCampTakeNoCoursePlace(){var c = Catalogue();- var full = State(c, Refugee(), Refugee(), Refugee());- var f = new Gdd03TrainingCentreFixture(c, full, Centres());- Unchanged(full, () => f.Start(1, 0, CentreA, Month(full, 0)), typeof(ArgumentException));+ var s = State(c, Refugee(), Refugee(), Refugee(), Refugee(CampB));+ var f = new Gdd03TrainingCentreFixture(c, s, Centres());+ f.Start(1, 0, CentreA, Month(s, 0));+ Assert.Equal(PopulationStatus.Trainee, s.PopulationLedger.Get(1).Status);+ f.Start(3, 2, CentreB, Month(s, 0));+ Assert.Equal(PopulationStatus.Trainee, s.PopulationLedger.Get(3).Status);+ s.PopulationLedger.Reconcile();+ }++ // R-TRAIN-005, Q42 (docs/GDD.md:372): a centre is a facility in its host city and needs no reception camp: with no+ // camp bound at all, a matching novice and veteran start, and the course counts.+ [Fact] public void ACentreInItsHostCityNeedsNoReceptionCamp()+ {+ var c = Catalogue(); var s = State(c, Bindings(camps: false)); var f = new Gdd03TrainingCentreFixture(c, s, Centres());+ var m0 = Month(s, 0);+ f.Start(1, 0, CentreA, m0); f.Advance(1, m0);+ Assert.Equal(PopulationStatus.Trainee, s.PopulationLedger.Get(1).Status);+ Assert.Equal(1, s.PopulationLedger.Get(1).Assignment.ProgressTicks);+ }++ // R-TRAIN-005, #1693 owner answers of 3 November 2026, answer 1: "Tools in the MVP: no." A novice with no tools+ // enrols and keeps an empty tools record.+ [Fact] public void ANoviceWithoutToolsEnrols()+ {+ var c = Catalogue(); var s = State(c, Person(CivilianProfession.Farmer, CivilianTier.Novice, null));+ var f = new Gdd03TrainingCentreFixture(c, s, Centres());+ f.Start(6, 0, CentreA, Month(s, 0));+ var p = s.PopulationLedger.Get(6);+ Assert.Equal(PopulationStatus.Trainee, p.Status); Assert.Null(p.Equipment.ToolsId); Assert.False(p.Equipment.ToolsPaid);+ }- var twoTaken = State(c, Refugee(), Refugee(), Refugee(CampB));- var g = new Gdd03TrainingCentreFixture(c, twoTaken, Centres());- g.Start(1, 0, CentreA, Month(twoTaken, 0)); // 2 refugees + 1 trainee; the teacher takes no bed- Assert.Equal(PopulationStatus.Trainee, twoTaken.PopulationLedger.Get(1).Status);- g.Start(3, 2, CentreB, Month(twoTaken, 0)); // camp B still has two free beds- Assert.Equal(PopulationStatus.Trainee, twoTaken.PopulationLedger.Get(3).Status);+ // R-TRAIN-005, docs/GDD.md:374: "Refugees cannot train until they become civilians". A free civilian is one: the+ // course reads no reception progress, so a teacher and a novice with none teach and enrol.+ [Fact] public void AFreeCivilianNeedsNoReceptionProgress()+ {+ var c = Catalogue(); var s = State(c,+ Person(CivilianProfession.Farmer, CivilianTier.Veteran, "tools-6", reception: 0),+ Person(CivilianProfession.Farmer, CivilianTier.Novice, "tools-7", reception: 0));+ var f = new Gdd03TrainingCentreFixture(c, s, Centres());+ f.Start(7, 6, CentreA, Month(s, 0));+ Assert.Equal(PopulationStatus.Trainee, s.PopulationLedger.Get(7).Status);+ Assert.Equal(PopulationAssignmentKind.Teaching, s.PopulationLedger.Get(6).Assignment.Kind);+ }++ // R-TRAIN-005: the centre's limits are read from no reception value. Without reception.capacity, and with a+ // reception.turns that differs from the ledger's, the fixture builds and a course starts.+ [Fact] public void TheCentreReadsNoReceptionValues()+ {+ var s = State(Catalogue());+ var c = Catalogue("reception.capacity"); c.Gdd03Balance!.Values["reception.turns"] = Agreed(s.PopulationLedger.ReceptionLimit + 1);+ var f = new Gdd03TrainingCentreFixture(c, s, Centres());+ f.Start(1, 0, CentreA, Month(s, 0));+ Assert.Equal(PopulationStatus.Trainee, s.PopulationLedger.Get(1).Status);}// R-TRAIN-005: settled refusals leave the state unchanged and are not reported as Deferred.+ // An unequipped novice and a working trainee or teacher may start now (ANoviceWithoutToolsEnrols,+ // PeopleWithAJobStartACourseAndLeaveItInTheSameCommit); the teacher busy elsewhere is now teaching at centre B.public static IEnumerable<object[]> SettledRefusals() => new[] {- new object[] { "trained trainee", 0, 6, CentreA, true, true },- new object[] { "unequipped novice", 0, 7, CentreA, true, true },- new object[] { "refugee before reception ends", 0, 8, CentreA, true, true },- new object[] { "trainee already working", 0, 9, CentreA, true, true },- new object[] { "craftsman", 0, 10, CentreA, true, true },- new object[] { "active soldier", 0, 11, CentreA, true, true },- new object[] { "trained teacher", 12, 1, CentreA, true, true },- new object[] { "teacher busy elsewhere", 13, 1, CentreA, true, true },- new object[] { "same person", 1, 1, CentreA, true, true },- new object[] { "unknown centre", 0, 1, "fixture-unknown", true, true },- new object[] { "parent not operating", 0, 1, CentreA, false, true },- new object[] { "upgrade incomplete", 0, 1, CentreA, true, false },- // The two region rows are refused by the population ledger's own binding checks, not by a #1697 rule.- new object[] { "other region", 0, 1, CentreSouth, true, true },- new object[] { "trainee in another region", 0, 14, CentreA, true, true },+ new object[] { "trained trainee", 0, 6, CentreA, true },+ new object[] { "refugee", 0, 8, CentreA, true },+ new object[] { "craftsman", 0, 10, CentreA, true },+ new object[] { "active soldier", 0, 11, CentreA, true },+ new object[] { "trained teacher", 12, 1, CentreA, true },+ new object[] { "teacher busy elsewhere", 13, 1, CentreA, true },+ new object[] { "same person", 1, 1, CentreA, true },+ new object[] { "unknown centre", 0, 1, "fixture-unknown", true },+ new object[] { "centre not operating", 0, 1, CentreA, false },+ // The teacher is housed in the centre's city (Q42) and, by our reading, the pupil trains there; the region stands+ // in for the city.+ new object[] { "other region", 0, 1, CentreSouth, true },+ new object[] { "trainee in another region", 0, 14, CentreA, true },+ new object[] { "teacher in another region", 16, 1, CentreA, true },};[Theory, MemberData(nameof(SettledRefusals))]- public void IneligibleStartsAreRefusedWithoutMutation(string why, int teacher, int trainee, string centre, bool operating, bool upgraded)+ public void IneligibleStartsAreRefusedWithoutMutation(string why, int teacher, int trainee, string centre, bool operating){Assert.False(string.IsNullOrEmpty(why));var c = Catalogue();@@ -255,14 +314,34 @@ public class Gdd03TrainingCentreFixtureTestsPerson(CivilianProfession.Craftsman, CivilianTier.Apprentice, "tools-10"), // 10Person(CivilianProfession.Farmer, CivilianTier.Novice, "tools-11", PopulationStatus.ActiveSoldier, assignment: new PopulationAssignment(PopulationAssignmentKind.ActiveService, Service)), // 11Person(CivilianProfession.Farmer, CivilianTier.Trained, "tools-12"), // 12- Person(CivilianProfession.Farmer, CivilianTier.Veteran, "tools-13", assignment: new PopulationAssignment(PopulationAssignmentKind.Work, Field)), // 13- Person(CivilianProfession.Farmer, CivilianTier.Novice, "tools-14", region: "south")); // 14- var f = new Gdd03TrainingCentreFixture(c, s, Centres(operating, upgraded));+ Person(CivilianProfession.Farmer, CivilianTier.Veteran, "tools-13", assignment: new PopulationAssignment(PopulationAssignmentKind.Teaching, CentreB)), // 13+ Person(CivilianProfession.Farmer, CivilianTier.Novice, "tools-14", region: "south"), // 14+ Person(CivilianProfession.Farmer, CivilianTier.Novice, "tools-15", PopulationStatus.Trainee,+ assignment: new PopulationAssignment(PopulationAssignmentKind.Course, CentreB, 0, 13)), // 15, pupil of 13+ Person(CivilianProfession.Farmer, CivilianTier.Veteran, "tools-16", region: "south")); // 16+ var f = new Gdd03TrainingCentreFixture(c, s, Centres(operating));Unchanged(s, () => f.Start(trainee, teacher, centre, Month(s, 0)), typeof(ArgumentException));}- // R-TRAIN-007: cancel at every course turn before graduation keeps id, tools, payment fact and reception credit;- // grants nothing unfinished; clears progress; releases the teacher and the bed; moves no one.+ // R-TRAIN-005, Q42 (docs/GDD.md:372: "the teacher housed in the centre's city"): a teacher outside the centre's region+ // is refused with the Q42 reason; a pupil outside it with our reading's reason (Q42 rules only on the teacher). Both+ // are refused before the ledger is asked, the state unchanged. The region stands in for the city.+ [Fact] public void ATeacherOrPupilOutsideTheHostRegionIsRefused()+ {+ var c = Catalogue(); var s = State(c,+ Person(CivilianProfession.Farmer, CivilianTier.Veteran, "tools-6", region: "south"),+ Person(CivilianProfession.Farmer, CivilianTier.Novice, "tools-7", region: "south"));+ var f = new Gdd03TrainingCentreFixture(c, s, Centres());+ Unchanged(s, () => f.Start(1, 6, CentreA, Month(s, 0)), typeof(ArgumentException), TeacherCity);+ Unchanged(s, () => f.Start(7, 0, CentreA, Month(s, 0)), typeof(ArgumentException), PupilCity);+ Unchanged(s, () => f.Start(1, 0, CentreSouth, Month(s, 0)), typeof(ArgumentException), TeacherCity);+ Unchanged(s, () => f.Start(1, 6, CentreSouth, Month(s, 0)), typeof(ArgumentException), PupilCity);+ f.Start(7, 6, CentreSouth, Month(s, 0));+ Assert.Equal(CentreSouth, s.PopulationLedger.Get(7).Assignment.Target);+ }++ // R-TRAIN-007: cancel at every course turn before graduation keeps id, the tools fields and reception progress;+ // grants nothing unfinished; clears progress; releases the teacher and the centre's place; moves no one.[Theory][InlineData(CivilianProfession.Farmer, 0)][InlineData(CivilianProfession.Farmer, 1)]@@ -270,9 +349,9 @@ public class Gdd03TrainingCentreFixtureTests[InlineData(CivilianProfession.Pioneer, 0)][InlineData(CivilianProfession.Pioneer, 1)][InlineData(CivilianProfession.Pioneer, 2)]- public void CancelAtEveryTurnRetainsPaidStateAndReleasesTeacherAndBed(CivilianProfession profession, int counted)+ public void CancelAtEveryTurnRetainsPaidStateAndReleasesTeacherAndCentre(CivilianProfession profession, int counted){- var c = Catalogue(); var s = State(c, Refugee(), Refugee()); var l = s.PopulationLedger;+ var c = Catalogue(); var s = State(c); var l = s.PopulationLedger;var f = new Gdd03TrainingCentreFixture(c, s, Centres());var (teacher, trainee) = Pair(profession); var before = l.Get(trainee); int count = l.Units.Count, next = l.NextPopulationId;f.Start(trainee, teacher, CentreA, Month(s, 0));@@ -287,7 +366,7 @@ public class Gdd03TrainingCentreFixtureTestsAssert.Same(PopulationAssignment.Unassigned, l.Get(teacher).Assignment);Assert.Same(before.Location, after.Location);Assert.Equal(count, l.Units.Count); Assert.Equal(next, l.NextPopulationId);- // Teacher and bed are free again: the camp's last bed takes a new pupil with another teacher.+ // Teacher and centre are free again: centre A's one place takes a new pupil with another teacher.f.Start(5, 4, CentreA, Month(s, 10));Assert.Equal(PopulationStatus.Trainee, l.Get(5).Status);}@@ -323,17 +402,39 @@ public class Gdd03TrainingCentreFixtureTests}}- // R-TRAIN-008: #1668 Q42 stays open: a second teacher at one centre, or an idle teacher kept at a centre, is refused.- [Fact] public void TeachersPerCentreAndIdleTeacherHousingStayDeferred()+ // R-TRAIN-005, R-TRAIN-008, Q42 (docs/GDD.md:372: "One veteran teacher and one pupil per centre"): a second teacher+ // at a centre is refused with the Q42 reason, not Deferred, the state unchanged, whether or not the pupil already+ // works; an inventory with two teachers at one centre is refused the same way.+ [Fact] public void ASecondTeacherAtACentreIsRefused(){- var c = Catalogue(); var s = State(c); var f = new Gdd03TrainingCentreFixture(c, s, Centres());+ var c = Catalogue(); var s = State(c, Person(CivilianProfession.Farmer, CivilianTier.Novice, "tools-6",+ assignment: new PopulationAssignment(PopulationAssignmentKind.Work, Field)));+ var f = new Gdd03TrainingCentreFixture(c, s, Centres());f.Start(1, 0, CentreA, Month(s, 0));- Unchanged(s, () => f.Start(5, 4, CentreA, Month(s, 0)), typeof(NotSupportedException), "Deferred: #1668 Q42");+ Unchanged(s, () => f.Start(5, 4, CentreA, Month(s, 0)), typeof(ArgumentException), OneTeacherOnePupil);+ Unchanged(s, () => f.Start(6, 4, CentreA, Month(s, 0)), typeof(ArgumentException), OneTeacherOnePupil);+ Assert.Equal(Field, s.PopulationLedger.Get(6).Assignment.Target);++ // Ids 6 and 7 teach at centre A, each with a pupil (8 and 9).+ var two = State(c,+ Person(CivilianProfession.Farmer, CivilianTier.Veteran, "tools-6", assignment: new PopulationAssignment(PopulationAssignmentKind.Teaching, CentreA)),+ Person(CivilianProfession.Farmer, CivilianTier.Veteran, "tools-7", assignment: new PopulationAssignment(PopulationAssignmentKind.Teaching, CentreA)),+ Person(CivilianProfession.Farmer, CivilianTier.Novice, "tools-8", PopulationStatus.Trainee,+ assignment: new PopulationAssignment(PopulationAssignmentKind.Course, CentreA, 0, 6)),+ Person(CivilianProfession.Farmer, CivilianTier.Novice, "tools-9", PopulationStatus.Trainee,+ assignment: new PopulationAssignment(PopulationAssignmentKind.Course, CentreA, 0, 7)));+ Unchanged(two, () => new Gdd03TrainingCentreFixture(c, two, Centres()), typeof(ArgumentException), OneTeacherOnePupil);+ }+ // R-TRAIN-005, R-TRAIN-008, Q42: a centre's teacher teaches its one pupil, so a Teaching record with no pupil is an+ // invalid inventory, refused with the Q42 reason, not Deferred.+ [Fact] public void ATeachingRecordWithNoPupilIsInvalid()+ {+ var c = Catalogue();var idle = State(c, new PopulationUnit(0, PopulationStatus.FreeCivilian, 6, new PopulationLocation("north"),new PopulationAssignment(PopulationAssignmentKind.Teaching, CentreB), CivilianProfession.Farmer, CivilianTier.Veteran,4, "", 2, new PopulationEquipment("tools-6", true)));- Unchanged(idle, () => new Gdd03TrainingCentreFixture(c, idle, Centres()), typeof(NotSupportedException), "Deferred: #1668 Q42");+ Unchanged(idle, () => new Gdd03TrainingCentreFixture(c, idle, Centres()), typeof(ArgumentException), TeacherNeedsAPupil);}// R-TRAIN-006, R-TRAIN-008: #1668 Q43(a) (docs/GDD.md:372: "A course occupies its people from its first turn"). The@@ -370,21 +471,21 @@ public class Gdd03TrainingCentreFixtureTestsAssert.Equal(1, s.PopulationLedger.Get(1).Assignment.ProgressTicks);}- // R-TRAIN-006, R-QUAL-008: graduation reuses the trained-tier transform and charges nothing; a teacher who still has- // another pupil keeps teaching. Two pupils per teacher is a synthetic value (the catalogue's is 1).- [Fact] public void AGraduationKeepsATeacherWhoStillHasAPupil()+ // R-TRAIN-006, R-QUAL-008, Q42: graduation reuses the trained-tier transform and charges nothing. A centre has one+ // pupil (Q42), so even with a synthetic two pupils per teacher (the catalogue's is 1) no second pupil joins the+ // teacher's centre, and the graduation releases the teacher with its one pupil.+ [Fact] public void AGraduationReleasesTheCentresOneTeacher(){var c = Catalogue("profession.trainees_per_teacher", Agreed(2)); var s = State(c); var l = s.PopulationLedger;var f = new Gdd03TrainingCentreFixture(c, s, Centres());var m0 = Month(s, 0);f.Start(1, 0, CentreA, m0); f.Advance(1, m0);- f.Start(5, 0, CentreA, Month(s, 1)); f.Advance(1, Month(s, 1));+ Unchanged(s, () => f.Start(5, 0, CentreA, Month(s, 1)), typeof(ArgumentException), OneTeacherOnePupil);+ f.Advance(1, Month(s, 1));f.Advance(1, Month(s, 2));Assert.Equal(CivilianTier.Trained, l.Get(1).Tier); Assert.Same(PopulationAssignment.Unassigned, l.Get(1).Assignment);- Assert.Equal(PopulationAssignmentKind.Teaching, l.Get(0).Assignment.Kind); Assert.Equal(CentreA, l.Get(0).Assignment.Target);- Assert.Equal(PopulationStatus.Trainee, l.Get(5).Status); Assert.Equal(0, l.Get(5).Assignment.TeacherId);- f.Cancel(5);Assert.Same(PopulationAssignment.Unassigned, l.Get(0).Assignment);+ Assert.Equal(PopulationStatus.FreeCivilian, l.Get(5).Status);l.Reconcile();}@@ -429,18 +530,20 @@ public class Gdd03TrainingCentreFixtureTestsAssert.DoesNotContain(1, next.CourseEligibleIds);}- // R-TRAIN-008, #1668 Q43(b) with Q41: a bed freed by a graduation is not reused that month. Camp A is full at the- // graduation month's opening (two refugees and the pupil); the next month a new course takes the bed.- [Fact] public void ABedFreedByGraduationIsNotReusedThatMonth()+ // R-TRAIN-008, #1668 Q43(b), Q42: graduation releases the people, not the centre for a month. With no reception beds+ // (Q41's bed reuse is post-MVP, docs/GDD.md:377), centre A is empty once its pupil graduates, so another teacher and+ // pupil start there in the graduation month; the released teacher still waits for the next month.+ [Fact] public void ACentreEmptiedByAGraduationTakesAnotherTeacherThatMonth(){var c = Catalogue(); var s = State(c, Refugee(), Refugee()); var f = new Gdd03TrainingCentreFixture(c, s, Centres());var m0 = Month(s, 0);f.Start(1, 0, CentreA, m0); f.Advance(1, m0); f.Advance(1, Month(s, 1));var graduation = Month(s, 2);f.Advance(1, graduation);- Unchanged(s, () => f.Start(5, 4, CentreA, graduation), typeof(ArgumentException), BedWaits);- f.Start(5, 4, CentreA, Month(s, 3));+ Unchanged(s, () => f.Start(5, 0, CentreA, graduation), typeof(ArgumentException), GraduationMonth);+ f.Start(5, 4, CentreA, graduation);Assert.Equal(PopulationStatus.Trainee, s.PopulationLedger.Get(5).Status);+ Assert.Equal(4, s.PopulationLedger.Get(5).Assignment.TeacherId);}// R-TRAIN-007: a graduate is no longer a pupil, so a further course turn or a cancel is refused unchanged, and the@@ -548,42 +651,44 @@ public class Gdd03TrainingCentreFixtureTestsUnchanged(s, () => work.Assign(0, Field), typeof(ArgumentException));}- // R-TRAIN-008, #1716 Q43(b): a bed freed after the month's opening, here by a cancel, is not reused that month. The- // month's new courses in a camp fit only in the beds free at its opening. Two pupils per teacher is a synthetic value- // (the catalogue's is 1), so that one centre can take two starts in a month.- [Fact] public void ABedFreedByACancelIsNotReusedThatMonth()+ // R-TRAIN-007, R-TRAIN-008, #1716 Q43(b), Q42: a place freed by a cancel is free at once, and it is the centre's one+ // place. With a synthetic two pupils per teacher (the catalogue's is 1), the same pupil restarts in the month of the+ // cancel, and a second pupil is still refused with the Q42 reason, the state unchanged.+ [Fact] public void APlaceFreedByACancelIsFreeAtOnce(){- var c = Catalogue("profession.trainees_per_teacher", Agreed(2)); var s = State(c, Refugee(CampA));+ var c = Catalogue("profession.trainees_per_teacher", Agreed(2)); var s = State(c, Refugee(CampA),+ Person(CivilianProfession.Farmer, CivilianTier.Novice, "tools-7"));var f = new Gdd03TrainingCentreFixture(c, s, Centres());f.Start(1, 0, CentreA, Month(s, 0));- var opening = Month(s, 1); // camp A: pupil 1 and refugee 6 hold 2 of its 3 beds+ var opening = Month(s, 1);f.Cancel(1);- f.Start(1, 0, CentreA, opening); // the one bed free at the opening- Unchanged(s, () => f.Start(5, 0, CentreA, opening), typeof(ArgumentException), BedWaits);+ f.Start(1, 0, CentreA, opening);+ Assert.Equal(0, s.PopulationLedger.Get(1).Assignment.TeacherId); Assert.Equal(CentreA, s.PopulationLedger.Get(1).Assignment.Target);+ Unchanged(s, () => f.Start(5, 0, CentreA, opening), typeof(ArgumentException), OneTeacherOnePupil);+ Unchanged(s, () => f.Start(7, 0, CentreA, opening), typeof(ArgumentException), OneTeacherOnePupil);}- // R-TRAIN-008, #1716 Q43(b): with the camp full at the month's opening, a cancelled pupil's own bed waits for the- // next month too, so the restart is refused that month and allowed in the next.- [Fact] public void ARestartInACampFullAtTheOpeningWaitsForTheNextMonth()+ // R-TRAIN-007, #1716 Q43(b): refugees in a camp of the centre's region do not hold a cancelled pupil's place, so with+ // two refugees in camp A (the old full camp) the restart is allowed in the month of the cancel.+ [Fact] public void ARestartIsNotHeldBackByRefugeesInTheRegion(){var c = Catalogue(); var s = State(c, Refugee(CampA), Refugee(CampA));var f = new Gdd03TrainingCentreFixture(c, s, Centres());f.Start(1, 0, CentreA, Month(s, 0));- var opening = Month(s, 1); // camp A: pupil 1 and refugees 6 and 7 hold all 3 beds+ var opening = Month(s, 1);f.Cancel(1);- Unchanged(s, () => f.Start(1, 0, CentreA, opening), typeof(ArgumentException), BedWaits);- f.Start(1, 0, CentreA, Month(s, 2));+ f.Start(1, 0, CentreA, opening);Assert.Equal(PopulationStatus.Trainee, s.PopulationLedger.Get(1).Status);+ Assert.Equal(CentreA, s.PopulationLedger.Get(1).Assignment.Target);}- // R-TRAIN-008, #1716 Q43(b) (with #1668 Q41): only the courses already started "in that camp this month" count against- // a camp's beds. A course started this month in camp A takes none of camp B's, so camp B's last bed free at the- // opening still takes a course that month.- [Fact] public void ACourseStartedInAnotherCampThisMonthTakesNoneOfThisCampsBeds()+ // R-TRAIN-005, Q42: each centre has its own one teacher and one pupil, with no regional or camp limit shared between+ // centres. Centres A and B are both in the north; a course started at A this month takes nothing from B.+ [Fact] public void TwoCentresInOneRegionEachTakeTheirOwnPupil(){var c = Catalogue(); var s = State(c, Refugee(CampB), Refugee(CampB));var f = new Gdd03TrainingCentreFixture(c, s, Centres());- var month = Month(s, 0); // camp B: refugees 6 and 7 hold 2 of its 3 beds+ var month = Month(s, 0);f.Start(1, 0, CentreA, month);f.Start(3, 2, CentreB, month);Assert.Equal(PopulationStatus.Trainee, s.PopulationLedger.Get(3).Status);@@ -633,44 +738,96 @@ public class Gdd03TrainingCentreFixtureTestsAssert.Equal(PopulationAssignmentKind.Course, month.OpeningPeople.Single(p => p.Id == 6).Assignment.Kind);}- // R-TRAIN-008: #1668 Q43(b): a teacher who worked at the month's opening and was released afterwards cannot start- // teaching that month.- [Fact] public void TeacherWhoWorkedAtTheOpeningCannotStartThatMonth()+ // R-TRAIN-005, R-TRAIN-008 (a reading of docs/gdd/cities.md:42, atomic reassignment, with docs/GDD.md:372 Q43(b)/(c)+ // and docs/gdd/training.md:66: what a person held at the month's opening is no bar to a course): a teacher who worked at the month's opening and was released afterwards starts+ // teaching that month, and the course counts that month.+ [Fact] public void ATeacherWhoWorkedAtTheOpeningStartsThatMonth(){var c = Catalogue(); var s = State(c, Person(CivilianProfession.Farmer, CivilianTier.Veteran, "tools-6",assignment: new PopulationAssignment(PopulationAssignmentKind.Work, Field)));var f = new Gdd03TrainingCentreFixture(c, s, Centres());var opening = Month(s, 0);s.PopulationLedger.ChangeAssignment(6, PopulationAssignment.Unassigned);- Unchanged(s, () => f.Start(5, 6, CentreB, opening), typeof(NotSupportedException), "Deferred: #1668 Q43");+ f.Start(5, 6, CentreB, opening);+ Assert.Equal(PopulationAssignmentKind.Teaching, s.PopulationLedger.Get(6).Assignment.Kind);+ f.Advance(5, opening);+ Assert.Equal(1, s.PopulationLedger.Get(5).Assignment.ProgressTicks);+ }++ // R-TRAIN-005 (docs/gdd/cities.md:42: "Reassignment releases old capacity atomically.", read with docs/GDD.md:372+ // Q43(b)/(c) and docs/gdd/training.md:66): a pupil and a teacher who both hold a job start a course; the jobs are released in the same commit,+ // so the work slots are free at once and this month's snapshot shows them on the course and off work.+ [Fact] public void PeopleWithAJobStartACourseAndLeaveItInTheSameCommit()+ {+ var c = Catalogue(); var s = State(c,+ Person(CivilianProfession.Farmer, CivilianTier.Novice, "tools-6", assignment: new PopulationAssignment(PopulationAssignmentKind.Work, Field)),+ Person(CivilianProfession.Farmer, CivilianTier.Veteran, "tools-7", assignment: new PopulationAssignment(PopulationAssignmentKind.Work, Workshop)),+ Person(CivilianProfession.None, CivilianTier.None, null));+ var f = new Gdd03TrainingCentreFixture(c, s, Centres());+ var work = new Gdd03AssignmentFixture(c, s, new[] {+ new Gdd03FixtureSlot(Field, Gdd03FixtureWork.Farm, 1, "fixture"), new Gdd03FixtureSlot(Workshop, Gdd03FixtureWork.Workshop, 1, "fixture") });+ var opening = Month(s, 0);+ Assert.Contains(6, opening.WorkEligibleIds); Assert.Contains(7, opening.WorkEligibleIds);+ int count = s.PopulationLedger.Units.Count;++ f.Start(6, 7, CentreA, opening);+ var pupil = s.PopulationLedger.Get(6); var teacher = s.PopulationLedger.Get(7);+ Assert.Equal(PopulationStatus.Trainee, pupil.Status); Assert.Equal(CentreA, pupil.Assignment.Target); Assert.Equal(7, pupil.Assignment.TeacherId);+ Assert.Equal(PopulationAssignmentKind.Teaching, teacher.Assignment.Kind); Assert.Equal(CentreA, teacher.Assignment.Target);+ Assert.Equal(count, s.PopulationLedger.Units.Count);+ var month = Month(s, 0);+ Assert.DoesNotContain(6, month.WorkEligibleIds); Assert.DoesNotContain(7, month.WorkEligibleIds); Assert.Contains(6, month.CourseEligibleIds);+ // The released jobs' places are free at once: each one-place slot takes another worker.+ Assert.Equal(Gdd03FixtureAssignmentResult.Applied, work.Assign(8, Field));+ Assert.Equal(Gdd03FixtureAssignmentResult.Applied, work.Assign(8, Workshop));+ s.PopulationLedger.Reconcile();+ }++ // R-TRAIN-008, #1668 Q43(b): the ruling that lets a job-holder start does not reach people released by a graduation.+ // A graduate's teacher who takes a job in the graduation month still cannot start a course that month, and the+ // refusal leaves the job in place; from the next month the teacher can, leaving the job.+ [Fact] public void AGraduationReleasedTeacherWithAJobStillWaitsForTheNextMonth()+ {+ var c = Catalogue(); var s = State(c); var l = s.PopulationLedger; var f = new Gdd03TrainingCentreFixture(c, s, Centres());+ var work = new Gdd03AssignmentFixture(c, s, new[] { new Gdd03FixtureSlot(Field, Gdd03FixtureWork.Farm, 1, "fixture") });+ var m0 = Month(s, 0);+ f.Start(1, 0, CentreA, m0); f.Advance(1, m0); f.Advance(1, Month(s, 1));+ var graduation = Month(s, 2);+ f.Advance(1, graduation);+ Assert.Equal(Gdd03FixtureAssignmentResult.Applied, work.Assign(0, Field));+ Unchanged(s, () => f.Start(5, 0, CentreB, graduation), typeof(ArgumentException), GraduationMonth);+ Assert.Equal(Field, l.Get(0).Assignment.Target);+ f.Start(5, 0, CentreB, Month(s, 3));+ Assert.Equal(PopulationAssignmentKind.Teaching, l.Get(0).Assignment.Kind);}- // R-TRAIN-008 (with #1668 Q41): a course started and cancelled in the same month still counts against that month's- // beds, so the bed it freed is not reused that month, by another pupil or by the same one; the next month it is.- // Camp A has two refugees, so one of its three beds is free at the month's opening.- [Fact] public void ACourseStartedAndCancelledThisMonthStillHoldsItsBedThatMonth()+ // R-TRAIN-007, R-TRAIN-008, #1716 Q43(b): with no reception beds (Q41's bed reuse is post-MVP, docs/GDD.md:377), a+ // course started and cancelled in the same month leaves nothing held: another teacher and pupil, and then the first+ // pair again, start at the centre that month.+ [Fact] public void ACourseStartedAndCancelledThisMonthHoldsNothing(){var c = Catalogue(); var s = State(c, Refugee(), Refugee()); var f = new Gdd03TrainingCentreFixture(c, s, Centres());var m0 = Month(s, 0);f.Start(1, 0, CentreA, m0);f.Cancel(1);- Unchanged(s, () => f.Start(5, 4, CentreA, m0), typeof(ArgumentException), BedWaits);- Unchanged(s, () => f.Start(1, 0, CentreA, m0), typeof(ArgumentException), BedWaits);- Unchanged(s, () => f.Start(5, 4, CentreA, Month(s, 0)), typeof(ArgumentException), BedWaits);- f.Start(5, 4, CentreA, Month(s, 1));+ f.Start(5, 4, CentreA, m0);Assert.Equal(PopulationStatus.Trainee, s.PopulationLedger.Get(5).Status);+ f.Cancel(5);+ f.Start(1, 0, CentreA, m0);+ Assert.Equal(PopulationStatus.Trainee, s.PopulationLedger.Get(1).Status);}- // R-TRAIN-008: #1668 Q43(b) and Q41: a bed freed after the month's opening (here by a cancel) is not reused that month.- [Fact] public void ABedFreedAfterTheOpeningIsNotReusedThatMonth()+ // R-TRAIN-007, R-TRAIN-008, #1716 Q43(b), Q42: a place freed after the month's opening (here by a cancel) is free at+ // once, so another teacher and pupil take the centre that month.+ [Fact] public void AnotherTeacherTakesTheCentreInTheMonthACancelFreesIt(){var c = Catalogue(); var s = State(c, Refugee(), Refugee()); var f = new Gdd03TrainingCentreFixture(c, s, Centres());f.Start(1, 0, CentreA, Month(s, 0));var m1 = Month(s, 1);f.Cancel(1);- Unchanged(s, () => f.Start(5, 4, CentreA, m1), typeof(ArgumentException), BedWaits);- f.Start(5, 4, CentreA, Month(s, 2));+ f.Start(5, 4, CentreA, m1);Assert.Equal(PopulationStatus.Trainee, s.PopulationLedger.Get(5).Status);+ Assert.Equal(4, s.PopulationLedger.Get(5).Assignment.TeacherId);}// R-TRAIN-008: #1668 Q44 and the GDD's novice lock-in stay open: no free entrant becomes a novice here, and no@@ -685,9 +842,9 @@ public class Gdd03TrainingCentreFixtureTestsUnchanged(s, () => f.Start(1, 2, CentreA, Month(s, 1)), typeof(NotSupportedException), "Deferred: #1668 Q44");}- // R-TRAIN-008: 27 Oct #1668 list question 9 stays open: no course turn or cancellation once the parent camp or- // centre stops operating.- [Fact] public void CampLossStaysDeferred()+ // R-TRAIN-008: 27 Oct #1668 list question 9 stays open: no course turn or cancellation once the centre stops+ // operating.+ [Fact] public void CentreLossStaysDeferred(){var c = Catalogue(); var s = State(c);new Gdd03TrainingCentreFixture(c, s, Centres()).Start(1, 0, CentreA, Month(s, 0));@@ -715,7 +872,6 @@ public class Gdd03TrainingCentreFixtureTests[Theory][InlineData("profession.course_turns")][InlineData("profession.trainees_per_teacher")]- [InlineData("reception.capacity")]public void MissingOrDeferredValuesFailClosed(string key){foreach (var replacement in new[] { null, Deferred() })@@ -725,17 +881,18 @@ public class Gdd03TrainingCentreFixtureTests}}- // R-TRAIN-005: centre inputs need explicit distinct ids; one centre upgrade per parent camp in this fixture.+ // R-TRAIN-005: centre inputs need an explicit id and host region, and ids are distinct. A centre whose stated region+ // is not where its teacher and pupil are bound is refused with the Q42 reason.[Fact] public void CentreInputsAreValidated(){- Assert.Throws<ArgumentException>(() => new Gdd03FixtureTrainingCentre("", CampA, true, true));- Assert.Throws<ArgumentException>(() => new Gdd03FixtureTrainingCentre(CentreA, " ", true, true));- Assert.Throws<ArgumentException>(() => new Gdd03FixtureTrainingCentre(CampA, CampA, true, true));+ Assert.Throws<ArgumentException>(() => new Gdd03FixtureTrainingCentre("", "north", true));+ Assert.Throws<ArgumentException>(() => new Gdd03FixtureTrainingCentre(CentreA, " ", true));var c = Catalogue(); var s = State(c);Assert.Throws<ArgumentException>(() => new Gdd03TrainingCentreFixture(c, s, new[] {- new Gdd03FixtureTrainingCentre(CentreA, CampA, true, true), new Gdd03FixtureTrainingCentre(CentreB, CampA, true, true) }));- Assert.Throws<ArgumentException>(() => new Gdd03TrainingCentreFixture(c, s, new[] {- new Gdd03FixtureTrainingCentre(CentreA, CampA, true, true), new Gdd03FixtureTrainingCentre(CentreA, CampB, true, true) }));+ new Gdd03FixtureTrainingCentre(CentreA, "north", true), new Gdd03FixtureTrainingCentre(CentreA, "south", true) }));+ new Gdd03TrainingCentreFixture(c, s, Centres()).Start(1, 0, CentreA, Month(s, 0));+ Unchanged(s, () => new Gdd03TrainingCentreFixture(c, s, new[] { new Gdd03FixtureTrainingCentre(CentreA, "south", true) }),+ typeof(ArgumentException), TeacherCity);}// R-TRAIN-006: deterministic and isolated: centre input order does not matter and a clone keeps its own course state.@@ -753,17 +910,4 @@ public class Gdd03TrainingCentreFixtureTestsAssert.NotEqual(cloned, a.Describe());}- // R-TRAIN-005: the initialized ledger owns completion; consistent content is required before any course action.- [Theory]- [InlineData(-1)]- [InlineData(1)]- public void ReceptionLimitMustMatchTheInitializedLedger(int delta)- {- var c = Catalogue(); var state = State(c); var before = state.Describe();- c.Gdd03Balance!.Values["reception.turns"] = Agreed(6 + delta);- var error = Assert.Throws<ContentException>(() => new Gdd03TrainingCentreFixture(c, state, Centres()));- Assert.Equal(Gdd03BalanceCatalogue.FileName, error.File);- Assert.Equal("values.reception.turns", error.Field);- Assert.Equal(before, state.Describe());- }}diff --git a/sim/Statecraft.Sim/Gdd03TrainingCentreFixture.cs b/sim/Statecraft.Sim/Gdd03TrainingCentreFixture.csindex e909e9f22..62d2f0f0f 100644--- a/sim/Statecraft.Sim/Gdd03TrainingCentreFixture.cs+++ b/sim/Statecraft.Sim/Gdd03TrainingCentreFixture.cs@@ -4,20 +4,23 @@ using System.Linq;namespace Statecraft.Sim{- /// <summary>Synthetic centre facts supplied by a test. Operating state and upgrade completion are owned by- /// #1696 (reception) and #1700/#1713 (construction); this fixture only reads them. No real camp, host or region.</summary>+ /// <summary>Synthetic centre facts supplied by a test: a facility in its host city, with no reception camp, upgrade or+ /// reception bed (GDD 1 November 2026 answers, docs/GDD.md:372, Q42: "One veteran teacher and one pupil per centre, the+ /// teacher housed in the centre's city"; owner, 1 November 2026, "No reception-bed layer (Recommended)"). A population+ /// location has a region and an optional hex or facility but no city, so the centre's region stands in for its host+ /// city here, an approximation until real places are bound (#1691). Operating state is owned by+ /// #1700/#1713 (construction); this fixture only reads it. No real centre, host or region.</summary>internal sealed class Gdd03FixtureTrainingCentre{internal string Id { get; }- internal string ParentCamp { get; }- internal bool ParentOperating { get; }- internal bool UpgradeComplete { get; }- internal Gdd03FixtureTrainingCentre(string id, string parentCamp, bool parentOperating, bool upgradeComplete)+ internal string Region { get; }+ internal bool Operating { get; }+ internal Gdd03FixtureTrainingCentre(string id, string region, bool operating){- if (string.IsNullOrWhiteSpace(id) || string.IsNullOrWhiteSpace(parentCamp) || string.Equals(id, parentCamp, StringComparison.Ordinal))- throw new ArgumentException("A centre needs its own course target id and a distinct parent reception camp id.");- PopulationText.ValidateText(id); PopulationText.ValidateText(parentCamp);- Id = id; ParentCamp = parentCamp; ParentOperating = parentOperating; UpgradeComplete = upgradeComplete;+ if (string.IsNullOrWhiteSpace(id) || string.IsNullOrWhiteSpace(region))+ throw new ArgumentException("A centre needs its course target id and its host region.");+ PopulationText.ValidateText(id); PopulationText.ValidateText(region);+ Id = id; Region = region; Operating = operating;}}@@ -26,22 +29,18 @@ namespace Statecraft.Sim/// 2026 answers): "A course occupies its people from its first turn (Q43(a)); they are released in the turn its last/// course turn counts and can be assigned from the next planning, or at once on cancellation, and work starts the turn/// after (Q43(b), Q43(c))." So the enrolment month is course turn 1 and the last counted turn graduates. Cases this- /// slice has not built (#1668 Q42, the rest of Q43 and Q44, decided in the GDD's 1 November 2026 answers, so these- /// refusals are implementation gaps, not open design answers; and the 27 Oct list Q9) are refused with a "Deferred:"- /// NotSupportedException.</summary>+ /// slice has not built (Q44, decided in the GDD's 1 November 2026 answers, so the refusal is an implementation gap, not+ /// an open design answer; and the 27 Oct list Q9) are refused with a "Deferred:" NotSupportedException.</summary>internal sealed class Gdd03TrainingCentreFixture{readonly Content content;readonly GameState state;readonly SortedDictionary<string, Gdd03FixtureTrainingCentre> centres;- readonly int courseTurns, pupilsPerTeacher, bedsPerCamp, receptionTurns;+ readonly int courseTurns, pupilsPerTeacher;// Per fixture instance only (not saved): month ordinals of each pupil's enrolment and last counted course turn// (-1 before the first), and of the month in which a graduation released each person.readonly SortedDictionary<int, (int enrolment, int lastCounted)> months = new SortedDictionary<int, (int, int)>();readonly SortedDictionary<int, int> graduated = new SortedDictionary<int, int>();- // Per fixture instance only: the month ordinal and parent camp of every course started, kept after a cancel or a- // graduation, so a bed a course took this month is not reused that month (R-TRAIN-008).- readonly List<(int month, string camp)> starts = new List<(int, string)>();internal Gdd03TrainingCentreFixture(Content content, GameState state, IEnumerable<Gdd03FixtureTrainingCentre> centres){@@ -50,42 +49,39 @@ namespace Statecraft.Simthis.content = content; this.state = state;courseTurns = content.RequirePopulationInteger("profession.course_turns");pupilsPerTeacher = content.RequirePopulationInteger("profession.trainees_per_teacher");- bedsPerCamp = content.RequirePopulationInteger("reception.capacity");- receptionTurns = content.RequirePopulationInteger("reception.turns");- if (receptionTurns != state.PopulationLedger.ReceptionLimit)- throw new ContentException(Gdd03BalanceCatalogue.FileName, "values.reception.turns",- "must match the initialized population ledger");this.centres = new SortedDictionary<string, Gdd03FixtureTrainingCentre>(StringComparer.Ordinal);- var parents = new HashSet<string>(StringComparer.Ordinal);- foreach (var centre in centres)- {- this.centres.Add(centre.Id, centre); // a duplicate id throws ArgumentException- if (!parents.Add(centre.ParentCamp)) throw new ArgumentException("This fixture supports one centre upgrade per parent camp.");- }+ foreach (var centre in centres) this.centres.Add(centre.Id, centre); // a duplicate id throws ArgumentExceptionValidateInventory();}static NotSupportedException Deferred(string question) => new NotSupportedException("Deferred: " + question);- const string Q42 = "#1668 Q42 (teachers per centre and an idle centre's teacher housing).";- // Q43 is decided (GDD, 1 November 2026 answers). The one Q43 case left Deferred is not built here: a person who held- // another assignment at the month's opening (other than a pupil released from work, or a cancelled course or teaching)- // starting a course that month. The ruled Q43 refusals below are plain ArgumentExceptions citing the ruling.- const string Q43 = "#1668 Q43 (decided, not built here: starting a course after holding another assignment at the month's opening).";- internal const string BedWaitsReason = "No reception bed was free at the month's opening: a bed freed this month is reused from the next month (#1668 Q43(b) with Q41, GDD 1 Nov 2026).";+ // Q42 (GDD 1 November 2026 answers, docs/GDD.md:372): "One veteran teacher and one pupil per centre, the teacher+ // housed in the centre's city". Its refusals, like the ruled Q43 ones, are plain ArgumentExceptions citing the ruling.+ // The one-pupil limit is the centre's own, whatever profession.trainees_per_teacher says.+ internal const string OneTeacherOnePupilReason = "A centre has one veteran teacher and one pupil (#1668 Q42, GDD 1 Nov 2026).";+ internal const string TeacherNeedsAPupilReason = "A centre's teacher teaches its pupil: a teaching record with no pupil is invalid (#1668 Q42, GDD 1 Nov 2026).";+ internal const string TeacherCityReason = "The teacher is housed in the centre's city (#1668 Q42, GDD 1 Nov 2026); this fixture checks the centre's region as an approximation of the city.";+ // Q42 rules only on the teacher. That the pupil is in the centre's city too is our reading, pending maintainer+ // confirmation: #1697's body says "the teacher and the trainee are housed there as ordinary residents", and+ // docs/GDD.md:374 says "Training is ordered in the camp's city, with no travel (27M-7)."+ internal const string PupilCityReason = "The pupil trains in the centre's city, with no travel (a reading of #1697 and 27M-7, pending maintainer confirmation); this fixture checks the centre's region as an approximation of the city.";internal const string GraduationMonthReason = "A person released by a graduation can start a course from the next month (#1668 Q43(b), GDD 1 Nov 2026).";internal const string CourseAtOpeningReason = "After the enrolment month, a course turn counts only when the month's opening holds the course with the same teacher (#1668 Q43(a), GDD 1 Nov 2026).";const string Q44 = "#1668 Q44 and the GDD novice lock-in decision (when a free entrant becomes a novice; profession change after a cancelled course).";const string Q9 = "#1668 27 Oct list Q9 (return after cancellation or camp loss).";- bool Received(PopulationUnit p) => p.Status == PopulationStatus.FreeCivilian && p.ReceptionTicks == receptionTurns;+ // GDD 1 November 2026 answers (docs/GDD.md:374): "Refugees cannot train until they become civilians". In the MVP a+ // refugee becomes a civilian on the housing step (R-CITY-004), so no reception progress is read here.+ static bool Civilian(PopulationUnit p) => p.Status == PopulationStatus.FreeCivilian;+ // The old assignment a course may replace: none, or a job, released in the same commit (docs/gdd/cities.md:42:+ // "Reassignment releases old capacity atomically."). Only a cancel or a graduation ends a course or teaching here.+ static bool FreeOrWorking(PopulationUnit p)+ => p.Assignment.Kind == PopulationAssignmentKind.Unassigned || p.Assignment.Kind == PopulationAssignmentKind.Work;static bool FarmerOrPioneer(CivilianProfession p) => p == CivilianProfession.Farmer || p == CivilianProfession.Pioneer;IEnumerable<PopulationUnit> At(PopulationAssignmentKind kind, string target)=> state.PopulationLedger.Units.Where(p => p.Assignment.Kind == kind && string.Equals(p.Assignment.Target, target, StringComparison.Ordinal));int Pupils(int teacher) => state.PopulationLedger.Units.Count(p => p.Assignment.Kind == PopulationAssignmentKind.Course&& p.Assignment.TeacherId == teacher && centres.ContainsKey(p.Assignment.Target!));- // Agreed reception.capacity counts refugee and course-trainee beds per camp; the teacher's housing is separate.- int BedsTaken(Gdd03FixtureTrainingCentre centre)- => At(PopulationAssignmentKind.Reception, centre.ParentCamp).Count() + At(PopulationAssignmentKind.Course, centre.Id).Count();void ValidateInventory(){@@ -93,19 +89,21 @@ namespace Statecraft.Simforeach (var centre in centres.Values){var teachers = At(PopulationAssignmentKind.Teaching, centre.Id).ToArray();- if (teachers.Length > 1) throw Deferred(Q42);+ var pupils = At(PopulationAssignmentKind.Course, centre.Id).ToArray();+ if (teachers.Length > 1 || pupils.Length > 1) throw new ArgumentException(OneTeacherOnePupilReason);foreach (var t in teachers){int n = Pupils(t.Id);- if (n == 0) throw Deferred(Q42);+ if (n == 0) throw new ArgumentException(TeacherNeedsAPupilReason);if (n > pupilsPerTeacher || !FarmerOrPioneer(t.Profession) || t.Tier != CivilianTier.Veteran)throw new ArgumentException("Centre teacher must be a matching veteran within the pupil limit.");}- foreach (var p in At(PopulationAssignmentKind.Course, centre.Id))+ foreach (var p in pupils)if (p.Assignment.TeacherId is not int teacher || state.PopulationLedger.Get(teacher).Profession != p.Profession|| p.Tier != CivilianTier.Novice || p.Assignment.ProgressTicks >= courseTurns)throw new ArgumentException("Centre pupil must be a matching novice with a teacher and an unfinished course.");- if (BedsTaken(centre) > bedsPerCamp) throw new ArgumentException("Parent camp reception beds are over capacity.");+ if (teachers.Any(p => p.Location!.Region != centre.Region)) throw new ArgumentException(TeacherCityReason);+ if (pupils.Any(p => p.Location!.Region != centre.Region)) throw new ArgumentException(PupilCityReason);}}@@ -131,73 +129,59 @@ namespace Statecraft.Simstatic PopulationUnit Released(PopulationUnit p)=> p.WithPlacement(PopulationStatus.FreeCivilian, p.Location, PopulationAssignment.Unassigned, p.Captor, p.Home);- /// <summary>R-TRAIN-005: enrol a matching equipped novice with a free matching veteran teacher at an operating,- /// upgraded centre that has a free bed in its own parent camp. No payment: the tools were paid on entry.</summary>+ /// <summary>R-TRAIN-005: enrol a matching novice with a matching veteran teacher at an operating centre, both in the+ /// centre's region (Q42 for the teacher, our reading for the pupil), and only into an empty+ /// centre: one teacher and one pupil (Q42). Either may leave a job to do so, released in the same commit. No payment, and no tools:+ /// tools are post-MVP (#1693, owner answers of 3 November 2026, answer 1).</summary>internal void Start(int traineeId, int teacherId, string centreId, Gdd03SyntheticMonthContext month){ValidateInventory();if (centreId == null || !centres.TryGetValue(centreId, out var centre)) throw new ArgumentException("Unknown fixture centre.");- if (!centre.ParentOperating || !centre.UpgradeComplete)- throw new ArgumentException("A course needs an operating parent camp and a completed centre upgrade.");+ if (!centre.Operating) throw new ArgumentException("A course needs an operating centre.");if (traineeId == teacherId) throw new ArgumentException("Teacher and trainee must be different population units.");var ledger = state.PopulationLedger; var trainee = ledger.Get(traineeId); var teacher = ledger.Get(teacherId);bool teachingHere = teacher.Assignment.Kind == PopulationAssignmentKind.Teaching&& string.Equals(teacher.Assignment.Target, centre.Id, StringComparison.Ordinal);- if (!Received(teacher) || !FarmerOrPioneer(teacher.Profession) || teacher.Tier != CivilianTier.Veteran)- throw new ArgumentException("The teacher must be a received matching veteran farmer or pioneer.");- if (teachingHere ? Pupils(teacher.Id) >= pupilsPerTeacher : teacher.Assignment.Kind != PopulationAssignmentKind.Unassigned)+ if (!Civilian(teacher) || !FarmerOrPioneer(teacher.Profession) || teacher.Tier != CivilianTier.Veteran)+ throw new ArgumentException("The teacher must be a free civilian, a veteran farmer or pioneer.");+ if (teachingHere ? Pupils(teacher.Id) >= pupilsPerTeacher : !FreeOrWorking(teacher))throw new ArgumentException("The teacher is occupied and refuses another pupil.");- if (!Received(trainee) || trainee.Assignment.Kind != PopulationAssignmentKind.Unassigned)- throw new ArgumentException("The trainee must be a received, unassigned free civilian.");+ if (!Civilian(trainee) || !FreeOrWorking(trainee))+ throw new ArgumentException("The trainee must be a free civilian with no assignment but a job.");if (trainee.Profession == CivilianProfession.Craftsman)throw new ArgumentException("A course cannot replace another civilian profession.");if (trainee.Profession != CivilianProfession.None && trainee.Tier != CivilianTier.Novice)throw new ArgumentException("Only a novice can gain the trained tier from a course.");- if (trainee.Profession != CivilianProfession.None && trainee.Equipment.ToolsId == null)- throw new ArgumentException("A novice needs matching tools to enrol.");if (trainee.Profession != teacher.Profession) throw Deferred(Q44);- if (At(PopulationAssignmentKind.Teaching, centre.Id).Any(t => t.Id != teacher.Id)) throw Deferred(Q42);- if (BedsTaken(centre) >= bedsPerCamp) throw new ArgumentException("No free reception bed in the centre's parent camp.");-- var traineeOpening = Opening(month, trainee.Id); var teacherOpening = Opening(month, teacher.Id);+ if (teacher.Location!.Region != centre.Region) throw new ArgumentException(TeacherCityReason);+ if (trainee.Location!.Region != centre.Region) throw new ArgumentException(PupilCityReason);+ if (At(PopulationAssignmentKind.Teaching, centre.Id).Any(t => t.Id != teacher.Id)+ || At(PopulationAssignmentKind.Course, centre.Id).Any())+ throw new ArgumentException(OneTeacherOnePupilReason);++ // Both must be in the month's snapshot. What either held at its opening does not matter, a reading of+ // docs/gdd/cities.md:42 ("Reassignment releases old capacity atomically.") with docs/GDD.md:372 Q43(b)/(c)+ // ("can be assigned from the next planning, or at once on cancellation") and docs/gdd/training.md:66 ("at+ // once"): a job, or a course or teaching cancelled this turn, is no bar; only a graduation is.+ Opening(month, trainee.Id); Opening(month, teacher.Id);// #1668 Q43(b) (#1697, 1 Nov 2026): "on graduation the people are released in the turn the last course turn// counts and can be assigned from the next turn's planning", so neither starts a course in that month.if (graduated.TryGetValue(trainee.Id, out var g) && month.MonthOrdinal <= g|| graduated.TryGetValue(teacher.Id, out g) && month.MonthOrdinal <= g)throw new ArgumentException(GraduationMonthReason);- // #1716 month snapshot (owner-relayed Q43(a) and Q34, 28 Oct 2026): a course occupies the pupil from the turn it- // starts and a job change is immediate, so a pupil who worked at the opening and was released this turn may start,- // and this month's work/course snapshot shows the course. #1716 Q43(b) release (owner-approved answer, 1 Nov 2026,- // #1668): "Cancellation: they are released at once, as civilians without a job." A pupil who held a course, or a- // teacher who taught, at the opening and is free now was released by a cancel this turn (only Cancel ends those- // exclusive assignments here), so either may start again this month. A teacher who worked at the opening and was- // released this turn is not built here and stays Deferred.- if ((traineeOpening.Assignment.Kind != PopulationAssignmentKind.Unassigned- && traineeOpening.Assignment.Kind != PopulationAssignmentKind.Work- && traineeOpening.Assignment.Kind != PopulationAssignmentKind.Course)- || (teacherOpening.Assignment.Kind != PopulationAssignmentKind.Unassigned- && teacherOpening.Assignment.Kind != PopulationAssignmentKind.Teaching))- throw Deferred(Q43);- // A bed freed after the month's opening (for example by a cancel) is not reused that month: Q43(b), Q41. So this- // month's new courses in the camp fit only in the beds free at its opening.- int openingBeds = month.OpeningPeople.Count(p => (p.Assignment.Kind == PopulationAssignmentKind.Reception- && string.Equals(p.Assignment.Target, centre.ParentCamp, StringComparison.Ordinal))- || (p.Assignment.Kind == PopulationAssignmentKind.Course- && string.Equals(p.Assignment.Target, centre.Id, StringComparison.Ordinal)));- int startedThisMonth = starts.Count(x => x.month == month.MonthOrdinal- && string.Equals(x.camp, centre.ParentCamp, StringComparison.Ordinal));- if (openingBeds + startedThisMonth >= bedsPerCamp) throw new ArgumentException(BedWaitsReason);+ // #1716 month snapshot (owner-relayed Q43(a) and Q34, 28 Oct 2026): a course occupies its people from the turn it+ // starts and a job change is immediate, so this month's work/course snapshot shows the course. A job either held+ // is replaced in this one commit (docs/gdd/cities.md:42: "Reassignment releases old capacity atomically.").var course = new PopulationAssignment(PopulationAssignmentKind.Course, centre.Id, 0, teacher.Id);var pupil = trainee.WithPlacement(PopulationStatus.Trainee, trainee.Location, course, trainee.Captor, trainee.Home);if (teachingHere) Commit(pupil);else Commit(teacher.WithPlacement(teacher.Status, teacher.Location,new PopulationAssignment(PopulationAssignmentKind.Teaching, centre.Id), teacher.Captor, teacher.Home), pupil);months[trainee.Id] = (month.MonthOrdinal, -1);- starts.Add((month.MonthOrdinal, centre.ParentCamp));}/// <summary>R-TRAIN-006: count one completed course turn, once per month ordinal: in the enrolment month (Q43(a), "A@@ -208,7 +192,7 @@ namespace Statecraft.Sim{ValidateInventory();var ledger = state.PopulationLedger; var trainee = ledger.Get(traineeId); var centre = CentreOf(trainee);- if (!centre.ParentOperating || !centre.UpgradeComplete) throw Deferred(Q9);+ if (!centre.Operating) throw Deferred(Q9);var opening = Opening(month, trainee.Id);bool tracked = months.TryGetValue(trainee.Id, out var known);// Q43(a): the enrolment month counts, though its opening snapshot was taken before the course started.@@ -235,27 +219,26 @@ namespace Statecraft.Simreturn;}// Graduation (Q43(b)): the trained tier from the pupil's pre-release course record, then pupil and teacher are- // released in one commit, so no teacher is left teaching with no pupil.+ // released in one commit, so no teacher is left teaching with no pupil. The pupil is the centre's one pupil (Q42).var graduate = Released(CivilianProfessionRules.AfterMatchingCourse(content, state, trainee.Id, trainee.Profession));var teacher = ledger.Get(trainee.Assignment.TeacherId!.Value);- bool teacherReleased = Pupils(teacher.Id) == 1;- if (teacherReleased) Commit(graduate, Released(teacher)); else Commit(graduate);+ Commit(graduate, Released(teacher));months.Remove(trainee.Id);graduated[trainee.Id] = month.MonthOrdinal;- if (teacherReleased) graduated[teacher.Id] = month.MonthOrdinal;+ graduated[teacher.Id] = month.MonthOrdinal;}- /// <summary>R-TRAIN-007: cancel keeps the id, profession, tier, tools and their payment fact and reception credit;- /// it clears the unfinished course and releases the teacher and the bed. Nothing is refunded or granted and no one- /// moves. The released people can take another assignment at once, in this month's snapshot (#1716, #1668 Q43(b),- /// answered 1 Nov 2026); the freed bed still waits for the next month's opening (R-TRAIN-008).</summary>+ /// <summary>R-TRAIN-007: cancel keeps the id, profession, tier, the record's tools fields and its reception progress;+ /// it clears the unfinished course and releases the teacher and the centre's place. Nothing is refunded or granted+ /// and no one moves. The released people, and the centre, can take another assignment at once, in this month's+ /// snapshot (#1716, #1668 Q43(b), answered 1 Nov 2026).</summary>internal void Cancel(int traineeId){ValidateInventory();var ledger = state.PopulationLedger; var trainee = ledger.Get(traineeId); var centre = CentreOf(trainee);- if (!centre.ParentOperating || !centre.UpgradeComplete) throw Deferred(Q9);+ if (!centre.Operating) throw Deferred(Q9);var teacher = ledger.Get(trainee.Assignment.TeacherId!.Value);- if (Pupils(teacher.Id) > 1) Commit(Released(trainee)); else Commit(Released(trainee), Released(teacher));+ Commit(Released(trainee), Released(teacher)); // the centre's one pupil (Q42), so its teacher is released toomonths.Remove(trainee.Id);}}