refactor(tooling): T-1289 — economy-db becomes reach ledger

The sole generator of systems.db moves to tooling/domains/ledger/ and is
now `reach ledger import`. economy_import/ keeps its name (Rust comments in
server/src cite it); the entrypoint becomes service.py; schema_version.py
moves with the importer, which is where the version is defined.

The stamp survived the move, which is the thing that had to hold:

- generated_brands.toml is byte-identical (sha256 e748531…) before and after
- `reach check systems-db-stamp` reported STALE after the move (the registry
  saw it) and OK after the regen
- the dry-run carries every count and warning of the baseline transcript,
  and exit 2 — imported and stamped, coverage gate unmet — still reaches the
  caller through @command

`make regen-db` survives as a one-line delegate, per D-263's muscle-memory
clause: about fifty files name it, including the headers of generated wiki
TOMLs and the remedies the push gate prints. `make economy-db` is retired;
it ran `reach generate brands` before the import, which the import already
does as its first step.

economy_import.errors is reconciled as DOMAINS.md asked. ImportAborted stays
as internal rollback control flow and never reaches a caller; the service
converts it to a ReachError carrying the remedy.

regenerate_brands caught cargo_binary's ReachError, printed it and raised
ImportAborted, dropping the remedy. It runs before the import transaction
opens, so there is nothing to roll back — it now propagates.

Both sys.path bootstraps are gone; they existed only because the directory
was hyphenated. The step labels ran [1/10]…[10/13]…[17/19]; one 24-step
counter now drives the event phase and progress.

Stale pointers fixed on the way: MIGRATION_SQL has lived in
economy_import/migration.py since T-1067, but the asset-pipeline rule,
DEVOPS and the schema comments still sent readers to import_economics.py;
the rule and DEVOPS also still named the check scripts T-1281 retired.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-09-23 16:18:59 +02:00
co-authored by Claude Opus 5.5
parent 668772075c
commit 23538d640f
35 changed files with 720 additions and 572 deletions
+4 -4
View File
@@ -298,7 +298,7 @@ CREATE TABLE IF NOT EXISTS commodities (
-- D-237 authored specialization layer: economic-specialization vocabulary.
-- Each value maps to a commodity + projected (BulkClass, ProductionUbiquity) for D-233.
-- Scale is encoded in the value (breadbasket vs estate_farming); no separate scale column.
-- Compiled from wiki/economics/specialization_vocabulary.toml by import_economics.py.
-- Compiled from wiki/economics/specialization_vocabulary.toml by `reach ledger import`.
CREATE TABLE IF NOT EXISTS specialization_vocabulary (
specialization_id TEXT PRIMARY KEY,
commodity_id TEXT NOT NULL REFERENCES commodities(commodity_id),
@@ -400,7 +400,7 @@ CREATE TABLE IF NOT EXISTS corp_lifecycle_events (
-- have to scan hundreds of JSON files. Polyline geometry stays in the files —
-- the DB only stores scalar/filterable fields + `point_count` as a rough length
-- proxy. The geometry tables are populated by the server-side generation
-- cascade (Phase 4, D-223) and start empty; tooling/economy-db/import_economics.py
-- cascade (Phase 4, D-223) and start empty; tooling/domains/ledger/ (reach ledger import)
-- extracts this entire block (between BEGIN/END ATLAS INDEX markers) from this
-- file at runtime and empties the geometry tables on regen, so the DDL lives in
-- exactly one place.
@@ -505,7 +505,7 @@ CREATE INDEX IF NOT EXISTS idx_atlas_mountain_ranges_body ON atlas_mountain_rang
-- Heightmap BLOB storage REMOVED (D-202 amended, #963): canonical elevation is
-- now a per-body 16-bit grayscale heightmap.png file (sea_level in a tEXt
-- chunk), not a systems.db BLOB. The atlas_body_heightmaps table is dropped via
-- MIGRATION_SQL in import_economics.py.
-- MIGRATION_SQL in tooling/domains/ledger/economy_import/migration.py.
-- City name reservations — replaces authored city positions in markers.json (D-207, #902)
-- Position is generated by the city placement algorithm; name is authored or LLM-generated.
@@ -675,7 +675,7 @@ CREATE INDEX IF NOT EXISTS idx_gate_links_to ON gate_links(to_system_id);
-- One row per generator, updated on each successful non-dry-run.
-- schema_version: monotonic semver string (e.g. "1.0.0") — bump on backwards-incompatible changes.
-- Orderable, enabling savegame migration lineage (Phase 5+).
-- Defined as SCHEMA_VERSION constant in tooling/schema_version.py.
-- Defined as SCHEMA_VERSION constant in tooling/domains/ledger/schema_version.py.
-- schema_sha: SHA-1 hex of systems-schema.sql content at generation time (tamper detection).
-- generator_sha: SHA-1 hex of the generator source file(s) content
-- generated_at: ISO-8601 UTC timestamp of the run
Binary file not shown.