feat(schema): trait_templates + atlas_body_trait_bias tables + bake (#993)

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>
This commit is contained in:
2026-06-03 10:47:35 +02:00
co-authored by Claude Opus 4.8
parent 00c8574e11
commit a133b6416e
6 changed files with 351 additions and 0 deletions
+44
View File
@@ -539,6 +539,50 @@ CREATE INDEX IF NOT EXISTS idx_atlas_province_boundaries_body ON atlas_province_
CREATE INDEX IF NOT EXISTS idx_atlas_city_positions_body ON atlas_city_positions(body_id);
-- END ATLAS INDEX (D-191 §8, #832)
-- ── Architecture-flavor trait templates (D-232, #993) ──────────────────────
-- trait_templates: the shared catalog of holistic architecture-flavor template
-- bundles (NOT per-axis traits). Baked from
-- wiki/economics/architecture_trait_catalog.toml. List/map fields are JSON text
-- (the generator parses). All numerics are integer basis-points (D-010).
-- Catalog content is authored in #1005; this table is the mechanism (#993).
CREATE TABLE IF NOT EXISTS trait_templates (
tag TEXT PRIMARY KEY,
label TEXT NOT NULL,
cultural_description TEXT,
corridor_pool TEXT NOT NULL DEFAULT 'baseline', -- baseline | heritage | cross_corridor
geographic_sector TEXT, -- corridor; NULL = shared/cross-corridor
bulk_class_gate TEXT, -- JSON list of eligible BulkClass; NULL/[] = any
production_ubiquity_gate TEXT, -- JSON list; NULL/[] = any
min_prosperity_bps INTEGER NOT NULL DEFAULT 0, -- hard gate (basis points)
base_weight INTEGER NOT NULL DEFAULT 10000, -- basis points
weight_mods TEXT, -- JSON {dimension: {value: multiplier_bps}}
zone_affinity TEXT, -- JSON {DistrictType: weight_bps}
allow_tags TEXT, -- JSON list of ObjectTag
block_tags TEXT, -- JSON list of ObjectTag
era_scope TEXT,
visual_bundle TEXT, -- JSON (D-235 bundle + fallback parents)
updated_at TEXT NOT NULL DEFAULT (datetime('now'))
);
CREATE INDEX IF NOT EXISTS idx_trait_templates_pool ON trait_templates(corridor_pool);
CREATE INDEX IF NOT EXISTS idx_trait_templates_sector ON trait_templates(geographic_sector);
-- atlas_body_trait_bias: sparse per-body bias on the catalog draw (hero bodies
-- only, ~30-40). pin = mandatory (counts toward K); boost = weight up (<=3x);
-- suppress = weight down (>=0.33x, never 0). Hero-pin content authored in #1017.
CREATE TABLE IF NOT EXISTS atlas_body_trait_bias (
id INTEGER PRIMARY KEY AUTOINCREMENT,
body_id TEXT NOT NULL REFERENCES bodies(body_id) ON DELETE CASCADE,
template_tag TEXT NOT NULL REFERENCES trait_templates(tag) ON DELETE CASCADE,
bias_kind TEXT NOT NULL, -- pin | boost | suppress
weight_multiplier_bps INTEGER, -- boost 10001..30000; suppress 3300..9999; pin NULL
note TEXT,
updated_at TEXT NOT NULL DEFAULT (datetime('now')),
UNIQUE (body_id, template_tag)
);
CREATE INDEX IF NOT EXISTS idx_atlas_body_trait_bias_body ON atlas_body_trait_bias(body_id);
CREATE INDEX IF NOT EXISTS idx_atlas_body_trait_bias_tag ON atlas_body_trait_bias(template_tag);
-- END TRAIT TEMPLATES (D-232, #993)
-- Indexes
-- astronomical_id removed: system_id IS the GJ catalog number
CREATE INDEX IF NOT EXISTS idx_star_systems_sector ON star_systems(geographic_sector);