fix(db): PR #177 review round — H1/H2/T1/T2/M1

H1+H2: headquarters_body is reset+derived every run (DB is never source); optional authored frontmatter override, hard-validated; tiebreak now population DESC -> city-bearing body -> type rank -> body_id, preserving belt tenancies and fixing GJ702B to GJ702Bb. T2: NULL-reset pass for corp_specialization/hq_placement before authored re-apply (poison-tested). T1: wiki/corporations/*.md globbed into IMPORT_ECONOMICS_SOURCES. M1: licensed_clinical_services vocabulary value (31st, NonPhysical->CityTenant) + somatic-futures retag. Fixpoint verified stable across 4 consecutive regens (0 diffs); regen systems.db.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
2026-07-16 13:00:03 +02:00
co-authored by Claude Fable 5
parent 0c8a270471
commit e63caeb620
10 changed files with 275 additions and 128 deletions
+33 -1
View File
@@ -79,6 +79,14 @@ SYSTEM_SPECIALIZATION_TOML: Path = (
CORP_HQ_PLACEMENT_TOML: Path = (
REPO_ROOT / "wiki" / "economics" / "corp_hq_placement.toml"
)
# The corp wiki pages themselves (PR #177 review T1): their frontmatter
# (corp_specialization, headquarters, optional headquarters_body) now shapes
# the DB — specialization drives hq_placement, headquarters_body, and the
# Standalone-HQ settlement rows in atlas_city_names — so a page edit without a
# regen must trip the stamp check exactly like a TOML edit does. Defined here
# (not in economy_import/paths.py) per the stamped-paths-live-here convention;
# paths.py re-exports it.
CORPORATIONS_DIR: Path = REPO_ROOT / "wiki" / "corporations"
# D-242 population/settlement_class bake (T-1075): the small authored
# NameLocked hero-city override list.
SETTLEMENT_NAME_LOCKED_TOML: Path = (
@@ -127,14 +135,38 @@ def _economy_import_modules() -> tuple[Path, ...]:
return modules
def _corporation_pages() -> tuple[Path, ...]:
"""All corp wiki pages the importer reads, collected by glob (T1, PR #177).
`load_wiki_corps` (economy_import/corporations.py) reads every
wiki/corporations/*.md EXCEPT index.md — the frontmatter feeds
corp_specialization/hq_placement/headquarters_body and the Standalone-HQ
settlement rows, so the read-set is stamped with the same glob-not-list +
fail-closed discipline as `_economy_import_modules`. index.md is excluded
because the importer skips it by name: stamping it would flag a false
stale on edits that cannot change DB output.
"""
pages = tuple(
sorted(p for p in CORPORATIONS_DIR.glob("*.md") if p.name != "index.md")
)
if not pages:
raise RuntimeError(
f"corporation pages not found at {CORPORATIONS_DIR} — "
"the import_economics stamp source set would be incomplete"
)
return pages
# Canonical source set for import_economics' meta stamp. Covers the Python
# entrypoint and its module package, the Rust binary it invokes (generate_brands
# main.rs + names.rs + surname corpus + wrapper script), the shared schema
# version constant, the authored data TOMLs, and this registry itself.
# version constant, the authored data TOMLs, the corp wiki pages whose
# frontmatter the importer bakes (T1, PR #177), and this registry itself.
IMPORT_ECONOMICS_SOURCES: tuple[Path, ...] = (
Path(__file__).resolve(), # registry changes must stale the stamp
IMPORT_ECONOMICS_ENTRYPOINT,
*_economy_import_modules(),
*_corporation_pages(),
GENERATE_BRANDS_RS,
GENERATE_BRANDS_NAMES_RS,
GENERATE_BRANDS_SURNAMES_RS,