test(simulation): lock standalone-HQ-as-ordinary-settlement-row invariant (T-1074)

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
2026-07-16 10:29:17 +02:00
co-authored by Claude Fable 5
parent 62bbf57009
commit 314894d080
2 changed files with 114 additions and 0 deletions
+44
View File
@@ -1154,6 +1154,50 @@ mod tests {
);
}
// ─── D-242 corp-HQ settlement model (T-1074/T-1075) ──────────────────────
//
// A Standalone-HQ settlement (economy_import/corporations.py:
// populate_standalone_hq_settlements) is inserted into atlas_city_names as
// an ORDINARY row — same schema, same fields, no corp linkage marker (the
// corp<->settlement relationship lives on corporations.headquarters_body,
// not on atlas_city_names). This module's test fixture schema
// (make_settlements_db, above) never had a corp_id column to begin with —
// this test makes that design invariant explicit: read_body_settlements
// (the D-211 placement pipeline's input) cannot distinguish a
// corp-Standalone-HQ row from a wiki-pooled city, by construction. If a
// future change ever needs to special-case corp-originated settlements,
// it will have to be threaded through explicitly — this test fails the
// moment that stops being true silently.
#[test]
fn read_body_settlements_treats_standalone_hq_row_identically_to_pooled_city() {
// "Gate Corporation" here stands in for a Phase-B-inserted
// Standalone-HQ row (name = corp proper_name, economic_role from
// corp_hq_placement.toml's standalone_economic_role, population from
// the T-1075 Zipf bake, settlement_class from the same bake/override
// path as any other city) — indistinguishable in shape from the
// ordinary pooled cities "Tributarium"/"Ruhr" it sits alongside.
let db = make_settlements_db(&[
("Tributarium", "manufacturing", 2_727_273_224, Some("PopulationBudget")),
("Ruhr", "manufacturing", 1_363_636_611, Some("PopulationBudget")),
("Gate Corporation", "manufacturing", 909_090_165, Some("NameLocked")),
]);
let reader = CityContextReader::open(&db).expect("open");
let cities = reader.read_body_settlements("PlanetX").expect("read");
assert_eq!(cities.len(), 3, "all three rows read back, HQ or not");
let hq = cities
.iter()
.find(|c| c.name == "Gate Corporation")
.expect("Standalone-HQ row must be present");
// Every CityRecord field the D-211 pipeline reads is populated exactly
// like an ordinary city's — nothing marks this row as corp-originated.
assert_eq!(hq.economic_role, "manufacturing");
assert_eq!(hq.population, 909_090_165);
assert_eq!(hq.settlement_class, SettlementClass::NameLocked);
assert!(!hq.is_capital, "Standalone HQ is not a capital by default");
}
// ─── read_body_city_names (T-949) ────────────────────────────────────────
#[test]