Skip to content

Retire the legacy target store on the Thesis ledger branch - #352

Draft
MaxGhenis wants to merge 4 commits into
codex/thesis-ledger-factsfrom
retire/thesis-branch-legacy-targets
Draft

MaxGhenis wants to merge 4 commits into
codex/thesis-ledger-factsfrom
retire/thesis-branch-legacy-targets

Conversation

@MaxGhenis

@MaxGhenis MaxGhenis commented Oct 12, 2026 •

Copy link
Copy Markdown
Contributor

Retires the legacy target store on codex/thesis-ledger-facts, and with it the step in the required "Arch checks" job that ran arch load all on every push and every resolver append PR.

Why

The "Build target input database" step ran arch --db /tmp/arch-targets-ci.db init, load all and stats. load all executes every db/etl_*.py loader, including the state SOI loaders. The audit in #348 (docs/us-legacy-etl-cleanup.md on that PR) found those loaders write invented values presented as IRS figures. This branch's db/etl_soi_state.py, db/etl_soi_deductions.py and db/etl_soi_income_sources.py are byte-identical to main's audited copies at a5280e1. Nothing on this branch read the tables those loaders filled, apart from the stack being removed here.

What the append path executes (task 1)

Checked by reading the code, the workflows and the Thesis resolver, not from the audit summary:

  • Append gate / Trusted base append gate (.github/workflows/thesis-facts-append.yml): runs the BASE commit's scripts/check_thesis_facts_append.py (which loads scripts/receipt_pins.py) in the base's uv sync --locked --no-dev environment. The pytest step runs tests/test_policyengine_ledger.py, test_release_chain.py, test_thesis_append_adversarial.py, test_thesis_append_shim_isolation.py, test_receipt_shim_transparency.py and test_production_tsa_pins.py. These import arch.core (stdlib only), receipt and the scripts.
  • Thesis resolver (ThesisInstitute/thesis scripts/resolve_pending.py, _regenerate_series_catalog and CATALOG_REGENERATION_INPUTS): fetches scripts/build_series_catalog.py, check_thesis_facts_append.py and receipt_pins.py plus the ledger/ catalog inputs from the base commit, and runs the generator with Thesis's own interpreter.
  • chronicle.institute (scripts/refresh-data.sh): reads ledger/official_observations.jsonl, ledger/immutable_prefix.json and releases/ from this branch. It builds its bundle from main, not from this branch.
  • The scripts import only the stdlib, receipt and each other. build_series_catalog.py imports check_thesis_facts_append lazily. The new test_append_path_scripts_load_nothing_from_the_repository_packages enforces this: it imports all six append-path scripts in an isolated interpreter and asserts that no arch, db, micro, calibration, packages, sqlmodel, sqlalchemy or supabase module loads.

What changes

Removed, each with its tests:

  • all 19 db/etl_*.py (etl_targets_supabase.py plus 18 others, including UK etl_hmrc, etl_obr and etl_ons) and db/tests/;

  • arch load, arch stats and arch query; the Stratum, StratumConstraint, Target, TargetType and GeographicLevel models; and query_strata, query_targets, insert_targets_batch and TARGETS_SCHEMA from db/supabase_client.py;

  • arch/targets/, arch/normalization/targets.py (TargetBlueprint, as_target, target_kwargs) and scripts/export_to_json.py;

  • calibration/ (it pulled rows from targets.db through get_targets; constraints, entropy and loader existed only to fit weights to those rows), plus the micro/us modules that read those rows or the hosted copy:

    • targets, pipeline, district, calibrate and hierarchy_validation;
    • validation_dashboard, whose only caller was hierarchy_validation;
    • hierarchical_pipeline, which reads hosted microplex.targets and falls back to mock targets.

    Main removed calibration/ and micro/ outright in Add Ledger governance and raw fact boundary checks #68.

  • scripts/cps_to_policyengine.py --calibrate, which called the deleted micro.us.calibrate (and would otherwise have degraded to a printed warning).

Kept and decoupled:

  • arch/jurisdictions/us/soi.py defines AGI_BRACKETS and TABLE_1_1_AGI_LABEL_TO_BRACKET itself. Both are identical in value and order to db/etl_soi.py, checked by AST evaluation of both files. Main's follow-on branch makes the same move.
  • arch/jurisdictions/{us,uk}/__init__.py no longer import every loader. Before, the bundle reached all 17 loaders through arch.suite -> arch.jurisdictions.us.soi -> arch.jurisdictions.us -> arch.targets.loaders.
  • arch/normalization/transforms.py holds scale_value, convert_units, apply_share and format_derivation, verbatim from the deleted module (checked segment by segment).
  • db/cli.py keeps init, load-source-files and source-stats. db/schema.py keeps the source-artifact tables and the Jurisdiction / DataSource enums.

CI (.github/workflows/ci.yml, job arch, display name Arch checks, unchanged, so branch protection needs no edit):

  • lint and pytest lists drop the deleted files and add tests/test_legacy_targets_retired.py;
  • "Build target input database" becomes "Smoke-test the source-artifact database CLI" (init + source-stats), as main's follow-on does;
  • the wheel smoke test imports soi, normalization and micro.us.entities, and asserts the retired modules are not in the wheel.

pyproject.toml changes only the hatch packages list (drops calibration). uv.lock is unchanged (uv lock --check passes). Nothing under ledger/ or releases/ and no gate-surface file changes.

Invariants

  • Ledger, release and gate surfaces are untouched: git diff d7e45bc5...HEAD -- ledger releases scripts/check_thesis_facts_append.py scripts/verify_release_chain.py scripts/canonical_json.py scripts/cut_release_manifest.py scripts/receipt_pins.py scripts/build_series_catalog.py .github/workflows/thesis-facts-append.yml uv.lock is empty.
  • Append-path import closure contains no repository package and no legacy-stack dependency (tested).
  • No remaining file imports a retired module or name. The test walks the AST of every Python file under arch/, db/, micro/, packages/, scripts/, tests/ and data/.
  • arch init creates exactly the four source-artifact tables, and load, stats and query exit 2 with "invalid choice" (tested).
  • The consumer bundle is unchanged. arch build-bundle --year 2023 was built at d7e45bc and at da5a7eb, and all 745 files match: 548 byte for byte, including consumer_facts.jsonl (10,268 rows, sha256 78ca9a51…) and coverage.json. The rest are equal apart from the run's absolute paths, the arch_builds.created_at build timestamp, and the checksum and size fields in datapackage.json / ro-crate-metadata.json for files already proven equal. A comparison script holds those rules and keeps a per-file sha256 manifest (local evidence folder; the raw bundles were deleted for disk space).

These are exhaustive checks over finite sets (every module, every file, every bundle byte). The branch's dependencies don't include Hypothesis, and there is no input domain to sample.

Verification

  • GitHub CI, required "Arch checks": green (run 38324513379) on a probe branch whose tree is identical to this PR's head 29c7ccd (tree 04746dca). The run covers lint, the pytest list, the source-artifact CLI smoke test, the wheel build and the wheel smoke test. The probe was needed because the base was red until Fold seven entity-drift lineages into their economy/aggregate siblings #344 merged.
  • Locally, at da5a7eb + 08418cf:
    • the "Arch checks" pytest list plus all six append-gate test files: 283 passed, 1 skipped, 5 xfailed;
    • the whole surviving suite minus the slow bundle tests: 691 passed, 15 skipped, 5 xfailed. The one failure was the stale catalog pin (test_committed_catalog_is_current_and_valid), which Fold seven entity-drift lineages into their economy/aggregate siblings #344 fixed and which this branch now includes;
    • ruff passed on the CI lint list, uv lock --check passed, and the wheel builds with none of the retired files in it.
  • Mutation check: adding import db.schema to scripts/canonical_json.py, and a lazy from db.etl_soi import AGI_BRACKETS to arch/core.py, makes the closure test and the import-walk test fail. Both mutations were reverted.
  • Independent review (GPT-6.1 Sol): round 1 at da5a7eb requested changes on "targets" left in arch.__all__ (P2) and two docs that still described the deleted loaders as current (P3). Both are fixed in 08418cf, which also replaces a README coverage table that listed BLS and UK sources only those loaders supplied. Round 2 covers the delta.

Merge order and coordination

axiom: n/a: infra and dead-code removal on the Thesis ledger branch; no policy logic changes.

🤖 Generated with Claude Code

MaxGhenis and others added 4 commits October 12, 2026 19:31
Remove the SQLite strata/stratum_constraints/targets store and everything
that only existed to fill or read it: the 19 db/etl_*.py loaders, the
arch load/stats/query commands, the Supabase target helpers, arch.targets,
scripts/export_to_json.py, the calibration/ package and the Microplex
calibration modules in micro/us/ that consumed those rows. Live modules keep
working: soi.py carries its AGI bracket constants, normalization keeps its
lineage transforms, and db.cli keeps the source-artifact commands.

The required "Arch checks" job no longer runs `arch load all`; it smoke-tests
the source-artifact CLI instead. tests/test_legacy_targets_retired.py pins the
removal and checks that the append-path scripts import nothing from this
repository's packages.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
`from arch import *` raised once arch/targets/ was gone; a test now checks
every advertised arch export resolves. docs/pe-calibration-targets.md and
docs/data-sources/irs-soi-state.md described the removed loaders as current,
and the README coverage table listed BLS and UK sources only those loaders
supplied; it now shows the per-source fact counts that tests/test_arch_bundle.py
pins for the default 2023 bundle.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant