feat(schema): trait-template tables + bake + core catalog (#993, #1005) #148

Closed
jpmschweitzer wants to merge 0 commits from trait-template-tables into main
Owner

Summary

Builds the D-232 architecture-flavor storage + content foundation — the data
the Phase-4 generator will read to decide how settlements look. Two tickets,
one branch:

  • #993 — the tables + import-bake mechanism
  • #1005 — the core hand-curated trait-template catalog (28 templates)

The generator consumer (#977) and per-body hero pins (#1017) are downstream; this
PR is storage + content only.

#993 — tables + bake mechanism

  • trait_templates — shared catalog of holistic template bundles (two-tier
    eligibility: hard gates bulk_class/prosperity_bps/ubiquity + soft weight
    mods; zone_affinity, allow/block tags, visual_bundle). List/map fields
    are JSON; all numerics integer basis-points (D-010).
  • atlas_body_trait_bias — sparse per-body hero bias (pin/boost/suppress
    with basis-point multiplier ranges; boost ≤3×, suppress ≥0.33× never 0).
  • Baked at import (steps 14/15) from wiki/economics/architecture_trait_catalog.toml
    • architecture_trait_bias.toml. FK-validated (body_id → bodies, template_tag
      → trait_templates), enum + multiplier-range checks, graceful on absent source.
  • Retires the round-2 atlas_body_culture tables. Source location provisional
    pending Q-107; the baked tables are invariant per D-232. Schema in both the
    canonical systems-schema.sql and MIGRATION_SQL; stamp sources updated.

#1005 — core catalog (28 templates)

  • Cross-corridor pool (10): economic-function templates gated by BulkClass
    (extraction / industrial / cold-chain / precision / information / civic) +
    universal baselines + the foreign-import swerve. Guarantees the CI floor.
  • Per-corridor baseline (8): core cosmopolitan, north anglo-frontier, south
    lusophone, west germanic + compact-cooperative, east dense-utilitarian,
    deep-frontier surname + hardscrabble.
  • Heritage sub-pools (10): scottish highland, west-african compound, iberian
    hacienda, atlantic creole, nordic timber, central-european blok, east-asian
    temple, vietnamese water village, afrikaans kraal, arab oasis — tied to the
    D-237 heritage taxonomy.
  • Shared ObjectTag material palette (walls/roofs/facades/streets) with generic
    fallback parents (D-235); zone_affinity keys use the real DistrictType enum.
  • CI guardrails added to the baker (V-TT-01: ≥5 templates eligible per
    BulkClass; V-TT-02: no template >60% of pool weight). Both pass with margin:
    23–24 eligible/class, 5% max share.

Verification

make regen-db clean · 28 templates baked, JSON fields parse, guardrails pass ·
bias FK-validation proven (valid row inserts; bad multiplier aborts) ·
empty-bias-source graceful · ruff clean · meta stamp fresh · pre-push gates green.

Unblocks

#1005 (done here) → #959/#988/#994/#1003; and one of the four prerequisites of
#1017. The draw consumer is #977.

🤖 Generated with Claude Code

## Summary Builds the **D-232 architecture-flavor storage + content foundation** — the data the Phase-4 generator will read to decide how settlements *look*. Two tickets, one branch: - **#993** — the tables + import-bake mechanism - **#1005** — the core hand-curated trait-template catalog (28 templates) The generator consumer (#977) and per-body hero pins (#1017) are downstream; this PR is storage + content only. ## #993 — tables + bake mechanism - `trait_templates` — shared catalog of holistic template bundles (two-tier eligibility: hard gates `bulk_class`/`prosperity_bps`/`ubiquity` + soft weight mods; `zone_affinity`, `allow`/`block` tags, `visual_bundle`). List/map fields are JSON; all numerics integer basis-points (D-010). - `atlas_body_trait_bias` — sparse per-body hero bias (`pin`/`boost`/`suppress` with basis-point multiplier ranges; boost ≤3×, suppress ≥0.33× never 0). - Baked at import (steps 14/15) from `wiki/economics/architecture_trait_catalog.toml` + `architecture_trait_bias.toml`. FK-validated (body_id → bodies, template_tag → trait_templates), enum + multiplier-range checks, graceful on absent source. - Retires the round-2 `atlas_body_culture` tables. Source location provisional pending Q-107; the baked tables are invariant per D-232. Schema in both the canonical `systems-schema.sql` and `MIGRATION_SQL`; stamp sources updated. ## #1005 — core catalog (28 templates) - **Cross-corridor pool (10):** economic-function templates gated by BulkClass (extraction / industrial / cold-chain / precision / information / civic) + universal baselines + the foreign-import swerve. Guarantees the CI floor. - **Per-corridor baseline (8):** core cosmopolitan, north anglo-frontier, south lusophone, west germanic + compact-cooperative, east dense-utilitarian, deep-frontier surname + hardscrabble. - **Heritage sub-pools (10):** scottish highland, west-african compound, iberian hacienda, atlantic creole, nordic timber, central-european blok, east-asian temple, vietnamese water village, afrikaans kraal, arab oasis — tied to the D-237 heritage taxonomy. - Shared ObjectTag material palette (walls/roofs/facades/streets) with generic fallback parents (D-235); `zone_affinity` keys use the real DistrictType enum. - **CI guardrails added to the baker** (V-TT-01: ≥5 templates eligible per BulkClass; V-TT-02: no template >60% of pool weight). Both pass with margin: 23–24 eligible/class, 5% max share. ## Verification `make regen-db` clean · 28 templates baked, JSON fields parse, guardrails pass · bias FK-validation proven (valid row inserts; bad multiplier aborts) · empty-bias-source graceful · ruff clean · meta stamp fresh · pre-push gates green. ## Unblocks #1005 (done here) → #959/#988/#994/#1003; and one of the four prerequisites of #1017. The draw consumer is #977. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
jpmschweitzer added 3 commits 2026-06-03 11:10:31 +02:00
D-232 architecture-flavor storage mechanism (content is #1005/#1017):

- trait_templates: shared catalog of holistic template bundles — two-tier
  eligibility (hard gates bulk_class/prosperity_bps/ubiquity + soft weight
  mods), zone_affinity, allow/block tags, visual_bundle. List/map fields
  are JSON; all numerics integer basis-points (D-010).
- atlas_body_trait_bias: sparse per-body hero pins — pin/boost/suppress
  with basis-point multiplier ranges (boost ≤3×, suppress ≥0.33× never 0).
- Baked at import (steps 14/15) from wiki/economics/architecture_trait_
  catalog.toml + architecture_trait_bias.toml. FK-validated (body_id →
  bodies, template_tag → trait_templates), enum + multiplier-range checks,
  graceful on absent source. Source location provisional pending Q-107;
  the baked tables are invariant per D-232. Retires the round-2
  atlas_body_culture tables.
- Catalog ships a 3-template bootstrap seed to prove the bake end-to-end;
  the full ~35-template catalog is #1005, hero pins #1017.
- Stamp sources updated (IMPORT_ECONOMICS_SOURCES + GENERATOR_SOURCES).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
The D-232 core hand-curated catalog (28 templates) the architecture-flavor
draw reads from, baked into trait_templates (#993):

- Cross-corridor pool (10): economic-function templates gated by BulkClass
  (extraction/industrial/cold-chain/precision/information/civic) + universal
  baselines + the foreign-import swerve. Guarantees the CI floor.
- Per-corridor baseline (8): each corridor's default cohesive look — core
  cosmopolitan, north anglo-frontier, south lusophone, west germanic +
  compact-cooperative, east dense-utilitarian, deep-frontier surname +
  hardscrabble.
- Heritage sub-pools (10): deep-history callbacks tied to the D-237 heritage
  taxonomy (scottish highland, west-african compound, iberian hacienda,
  atlantic creole, nordic timber, central-european blok, east-asian temple,
  vietnamese water village, afrikaans kraal, arab oasis).

Each template = holistic bundle: two-tier eligibility (hard gates
bulk_class/ubiquity/prosperity_bps + soft weight mods), zone_affinity over
the real DistrictType enum, allow/block tags from a shared ObjectTag
palette, and a D-235 visual_bundle with generic fallback parents. All
numerics integer basis-points (D-010).

Adds the D-232 CI guardrails to the baker (V-TT-01: >=5 templates eligible
per BulkClass; V-TT-02: no template >60% of pool weight) — both pass with
margin (23-24 eligible/class, 5% max share). Catalog can grow via the
bounded Gemma pass (#992); hero pins are #1017.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
jpmschweitzer added 1 commit 2026-06-03 11:36:47 +02:00
Review fixes (Hoshe/Tyre, both APPROVE):

- populate_trait_templates / populate_atlas_body_trait_bias: the table
  DELETEs ran unconditionally (safe only via transaction rollback on
  dry-run, and divergent from every other populate_* function). Restructured
  so validation + guardrails always run (dry-run now actually surfaces the
  would-bake counts and catches errors) but mutations happen only under
  `if not dry_run:`. Verified: --dry-run reports 28 templates, writes nothing.
- atlas_body_trait_bias: reject `pin` entries that carry a
  weight_multiplier_bps (pin is mandatory, no multiplier) — closes a silent-
  accept gap before #1017 authors ~30-40 real pins.

Deferred (noted on tickets): visual_bundle fallback-map completeness
(Phase-5/Araminta), pin-count-vs-K bake check (#1017 acceptance),
geographic_sector pool-narrowing semantics (#977).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Author
Owner

Review — PR #148 (code: trait-template tables + bake + core catalog, #993/#1005)

Multi-agent code review (Hoshe / Tyre).

Reviewer Focus Verdict
Hoshe QA / correctness APPROVE
Tyre Architecture APPROVE

Verdict: APPROVED. Both actionable comments fixed in a4727bf73.

Clean on review

Schema ↔ migration parity exact; FK-safe clear+rebuild; all catalog bulk_class_gate / production_ubiquity_gate / zone_affinity values match the Rust enums; guardrails correct (V-TT-01 ≥5/class, V-TT-02 integer >60% math — both pass with margin, 23–24 eligible/class, ~5% max share); both TOMLs registered in IMPORT_ECONOMICS_SOURCES + GENERATOR_SOURCES; JSON columns are the right call for a read-once baked artifact; integer basis-points throughout (D-010); atlas_body_culture DROP correctly placed. Schema is a faithful realization of the D-232 storage spec and forward-fits #977/#1017 without changes.

Fixed

# Reviewer Finding Fix
1 Hoshe + Tyre populate_trait_templates/_trait_bias ran table DELETEs unconditionally (safe only via dry-run rollback; divergent from every other populate_*) Fixed — validation + guardrails now run always (dry-run surfaces would-bake counts + catches errors); mutations gated by if not dry_run:. Verified --dry-run reports 28 templates, writes nothing
2 Hoshe pin bias entries with a stray weight_multiplier_bps were silently accepted Fixed — now rejected (pin is mandatory, no multiplier); closes the gap before #1017's ~30–40 pins

Deferred (tracked, not blocking)

  • visual_bundle fallback-map completeness (Hoshe) — 14 templates have axis tokens without a fallback entry. D-235 asset-resolution concern (Phase 5); the baker doesn't enforce it. Follow-up for Araminta's visual pass.
  • pin-count vs K budget (Tyre) — bake can't see complexity_tier; noted on #1017 acceptance (enforce in #977 draw or generator validation).
  • geographic_sector pool-narrowing semantics (Tyre) — column is a soft pool hint, never a gate; composes with weight_mods. Noted on #977.

Re-verified after fixes

regen clean · 28 templates · guardrails pass · dry-run non-mutating · ruff clean · stamp fresh · pre-push gates green.

🤖 Generated with Claude Code

## Review — PR #148 (code: trait-template tables + bake + core catalog, #993/#1005) Multi-agent code review (Hoshe / Tyre). | Reviewer | Focus | Verdict | |---|---|---| | Hoshe | QA / correctness | APPROVE | | Tyre | Architecture | APPROVE | **Verdict: APPROVED.** Both actionable comments fixed in `a4727bf73`. ### Clean on review Schema ↔ migration parity exact; FK-safe clear+rebuild; all catalog `bulk_class_gate` / `production_ubiquity_gate` / `zone_affinity` values match the Rust enums; guardrails correct (V-TT-01 ≥5/class, V-TT-02 integer >60% math — both pass with margin, 23–24 eligible/class, ~5% max share); both TOMLs registered in `IMPORT_ECONOMICS_SOURCES` + `GENERATOR_SOURCES`; JSON columns are the right call for a read-once baked artifact; integer basis-points throughout (D-010); `atlas_body_culture` DROP correctly placed. Schema is a faithful realization of the D-232 storage spec and forward-fits #977/#1017 without changes. ### Fixed | # | Reviewer | Finding | Fix | |---|----------|---------|-----| | 1 | Hoshe + Tyre | `populate_trait_templates`/`_trait_bias` ran table DELETEs unconditionally (safe only via dry-run rollback; divergent from every other `populate_*`) | **Fixed** — validation + guardrails now run always (dry-run surfaces would-bake counts + catches errors); mutations gated by `if not dry_run:`. Verified `--dry-run` reports 28 templates, writes nothing | | 2 | Hoshe | `pin` bias entries with a stray `weight_multiplier_bps` were silently accepted | **Fixed** — now rejected (pin is mandatory, no multiplier); closes the gap before #1017's ~30–40 pins | ### Deferred (tracked, not blocking) - **visual_bundle fallback-map completeness** (Hoshe) — 14 templates have axis tokens without a `fallback` entry. D-235 asset-resolution concern (Phase 5); the baker doesn't enforce it. Follow-up for Araminta's visual pass. - **pin-count vs K budget** (Tyre) — bake can't see `complexity_tier`; noted on **#1017** acceptance (enforce in #977 draw or generator validation). - **geographic_sector pool-narrowing semantics** (Tyre) — column is a soft pool hint, never a gate; composes with `weight_mods`. Noted on **#977**. ### Re-verified after fixes regen clean · 28 templates · guardrails pass · dry-run non-mutating · ruff clean · stamp fresh · pre-push gates green. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
jpmschweitzer closed this pull request 2026-06-03 11:51:29 +02:00

Pull request closed

This pull request cannot be reopened because the branch was deleted.
Sign in to join this conversation.
No Reviewers
No labels
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: jpmschweitzer/settled-reach#148