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
+6 -6
View File
@@ -239,14 +239,14 @@ make clean # Remove build artifacts and .cache/ contents
```bash
reach validate content # Validate content YAML against JSON schemas
make check-fact-ids # Check fact_id references against knowledge catalogs
reach check fact-ids # Check fact_id references against knowledge catalogs
```
### Gauntlet Checklists
```bash
make checklist-validate # Validate checklist YAML against schema (standalone)
make checklist-generate # Validate + print per-room condition summary
reach validate checklist --check # Validate checklist YAML against schema (standalone)
reach validate checklist # Validate + print per-room condition summary
```
Checklists live at `content/gauntlet/rooms/{room_id}/checklist.yaml` (per-room) and `content/gauntlet/cross_room_checks.yaml` (cross-room). Each condition is evaluable from an `ObserverSnapshot`.
@@ -268,7 +268,7 @@ the next regeneration.
### Generator
`import_economics` (`tooling/economy-db/import_economics.py`) is the sole
`import_economics` (`reach ledger import`, `tooling/domains/ledger/`) is the sole
generator. As its first step it runs the Rust `generate_brands` binary
(via `core.process.cargo_binary`) to refresh `generated_brands.toml`, then imports
economics data and the atlas index (names-only city pool; geometry tables stay
@@ -288,7 +288,7 @@ After every successful non-dry-run, the generator writes a row to the `meta` tab
registry is the `GENERATOR_SOURCES` dict in `tooling/generator_sources.py`.
```bash
make check-systems-db # Verify the stamp is fresh (exit 1 = stale)
reach check systems-db-stamp # Verify the stamp is fresh (exit 1 = stale)
```
### Making a DB change
@@ -299,7 +299,7 @@ make check-systems-db # Verify the stamp is fresh (exit 1 = stale)
4. Commit with `chore(db): regen systems.db — <reason>`
For schema changes, also update `server/data/systems-schema.sql` and add migration DDL
to `MIGRATION_SQL` in `import_economics.py`.
to `MIGRATION_SQL` in `tooling/domains/ledger/economy_import/migration.py`.
See `.claude/rules/asset-pipeline.md` for the full rule set.
@@ -183,7 +183,7 @@ Gemma **never** sets a numeric or eligibility field. This is not a scoping
choice made for simplicity — it's forced by the shape of the guardrails: the
catalog-wide CI checks (`V-TT-01`: ≥5 eligible templates per `BulkClass`
post-gate; `V-TT-02`: no template >60% of its eligible pool's weight,
`tooling/economy-db/economy_import/traits.py`) are properties of the **whole
`tooling/domains/ledger/economy_import/traits.py`) are properties of the **whole
catalog**, not of any one template in isolation. A per-template extraction
pass, looking at one system's prose, has no way to know whether adding this
candidate at `base_weight = 9000` would push some `BulkClass`'s weighted pool
@@ -244,7 +244,7 @@ automatically at bake time — see §7).
5. **CI guardrails as a post-authoring gate, not a pass/fail on Gemma's
output.** Once Miri has assigned `base_weight`/`weight_mods`/gates,
`make regen-db` re-runs `populate_trait_templates()`
(`tooling/economy-db/economy_import/traits.py`), which re-validates
(`tooling/domains/ledger/economy_import/traits.py`), which re-validates
`V-TT-01` and `V-TT-02` across the **whole** catalog, not just the new
entry. A proposal can clear 1-4 and still get rebalanced or rejected at
bake time if it happens to push a `BulkClass` pool over the 60% line —
@@ -269,7 +269,7 @@ Nothing is committed to `architecture_trait_catalog.toml` until it clears 1-4
4. Araminta adds the matching `visual_bundle`, including the D-235 fallback
parent for every new specific tag (a new template ships with a working
generic-parent fallback from day one, same as the shipped 28).
5. `make regen-db` bakes the change via `import_economics.py` →
5. `make regen-db` bakes the change via `reach ledger import` →
`traits.py:populate_trait_templates()`; `V-TT-01`/`V-TT-02` re-run
automatically (§6.5). `make check-systems-db` confirms the meta stamp.
6. Commit the TOML change and the regenerated `systems.db` together — the