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>
48 lines
1.7 KiB
Python
48 lines
1.7 KiB
Python
"""Transport for the `ledger` domain — args in, delegate, format out."""
|
|
|
|
from __future__ import annotations
|
|
|
|
from pathlib import Path
|
|
|
|
import typer
|
|
|
|
from tooling.core import cli
|
|
from tooling.core.command import command
|
|
|
|
app = cli.domain("ledger", "The economics pipeline — the import that builds systems.db.")
|
|
|
|
|
|
@app.callback()
|
|
def _domain() -> None:
|
|
"""Keeps `ledger` a group (Typer collapses a single-command app)."""
|
|
|
|
|
|
@app.command("import")
|
|
@command
|
|
def import_(
|
|
db: Path = typer.Option(None, "--db", help="systems.db to import into (default: server/data/systems.db)."),
|
|
dry_run: bool = typer.Option(False, "--dry-run", help="Validate every step, write nothing."),
|
|
strict_specialization: bool = typer.Option(
|
|
False,
|
|
"--strict-specialization",
|
|
help="Treat the D-237 completeness gates (V-SES-02, V-FAC-01) as hard errors.",
|
|
),
|
|
) -> None:
|
|
"""Rebuild systems.db from the economics sources, and stamp it.
|
|
|
|
The sole generator of server/data/systems.db — `make regen-db` runs this.
|
|
It regenerates generated_brands.toml first (skipped on --dry-run), imports
|
|
in one transaction, and stamps the meta table so the push gate can tell a
|
|
stale snapshot from a fresh one.
|
|
|
|
Exit 2 means imported AND stamped but the D-175 coverage gate is not met:
|
|
a content gap, not a failure, and tolerated by regen-db and the tooling
|
|
gate. Exit 1 means nothing was written.
|
|
"""
|
|
# Imported here, not at module level: the service pulls in the whole
|
|
# importer package and the stamp registry, and `reach ledger --help`
|
|
# should not pay for that (T-1260).
|
|
from tooling.domains.ledger import service
|
|
|
|
service.run(db or service.DB_PATH, dry_run=dry_run, strict_specialization=strict_specialization)
|