Repository navigation
UK facts for chronicle#357, #356, #339, #326 and #358: stamp taxes, HBAI, Move to UC, OBR geography, UC by payment indicator, NI and LSOA energy, gas years, rural-urban lookups, UV404 by output area, residence type by age - #359
juaristi22 wants to merge 13 commits into
Conversation
- gas_year: DESNZ's sub-national gas year (mid-May to mid-May since 2018), under the publisher's year label (chronicle#356). - xlsx_read_only_used_range: an opt-in parser that streams only the named worksheets in openpyxl's read-only mode. DESNZ's 50-56 MB LSOA workbooks take over an hour each to load whole and seconds this way. It is opt-in because read-only mode reads a few existing workbooks differently. - zip_ods_used_range: ODS members of a ZIP, for HBAI's confidence intervals. - ons_census_observations_json_rows: ONS Census API census-observations responses, one row per published cell (chronicle#358). - defra joins the UK R2 publishers. - CI fetches R2-only source artifacts (storage.local: false) by sha256 from their publisher URL and caches them between runs. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
chronicle#357 (microcosm#1095 ports): - HMRC Annual Stamp Tax Statistics 2024 to 2025, corrected tables: Tables 8a and 8b by price band and buyer type, and Table 6b's higher rates on additional dwellings, 2023-24 and 2024-25. - EFO March 2026 sheet 3.7's SDLT lines by property type and rate. The EFO publishes no split of SDLT by type of buyer. - OBR table 4.9's DWP lines stamped with DWP's geography (Great Britain; England and Wales for the devolved benefits), the two Northern Ireland rows ported. No value changes. - HBAI, FYE 2025 release: medians and relative low income, before and after housing costs, FYE 1995 to FYE 2025, and the FYE 2025 confidence intervals. chronicle#356: - DESNZ Northern Ireland electricity (2009 to 2024) and gas (2015 to 2024). - GB sub-national gas rows on the gas_year period type. - Domestic meters and kWh by LSOA and data zone, 2023 and 2024. The two workbooks are R2-only. - MSOA workbooks and rural-urban lookups registered raw-only. - DfT BUS04ai operating revenue for Scotland, Wales and Great Britain. chronicle#326: UV404 by 2022 output area (all households, private rented). chronicle#358: residence type by single year of age from the ONS Census API and NISRA's builder, and NRS UV101a at Scotland level. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
chronicle#339: re-extract DWP's UC households by Westminster constituency, by local authority and by constituency and number of children, January 2025 to May 2026, with Payment Indicator (Yes, No) as a dimension, so Microcosm can bind paid claims. Yes + No reproduces the all-claims cells of the 7 October extract to within 9 households per area-month (11 per child band), median 2: the random error Stat-Xplore adds to each cube. - The three all-claims packages are retired, as #313 retired the May 2025 snapshots: aliases and bundle sources go, the preserved responses stay under db/data. Their May 2025 legacy selector families leave the feed. - scripts/build_uk_uc_area_payment_indicator_packages.py writes the three packages from the pinned responses (21,488, 11,900 and 150,416 facts). chronicle#357 item 3: dwp-mtuc-households-legacy-benefit-move-status- july-2022-june-2026, 80 facts. Households sent a Move to UC migration notice by combination of legacy benefits and move status, with DWP's totals, Great Britain, cumulative over notices from July 2022 to June 2026 (the table policyengine-uk-data#534 draws its rates from; DWP's 18 August 2026 release reports the same 1.8 million households, 87% claimed). Official statistics in development, stamped on every fact. The two series zero in every cell are not ported. Both extracts were made on 15 October 2026; all four responses are in R2 and verified. Docs, catalogue, checklist, changelog and tests follow. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The bundle test alone took 84 minutes for 1.03M facts on Oct 14's fastest main run. This branch adds about 549,000 facts (+53%), which would put a runner 1.6x slower near the 210-minute limit, and a timed-out run uploads no failure reports. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…s do The merged bundle refused nrs-census2022-uv404-tenure-output-area: it labelled household_tenure 'Household tenure' where the council-area and constituency UV404 packages say 'publisher tenure category', and gave its two tenure values no label. The package now uses the shared dimension label and labels each value with its publisher text. Fact keys and values are unchanged (87,816 facts, identical aggregate and semantic keys). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A local build of the full bundle at year 2023 (75 minutes) gives the counts chronicle#326, #339, #356, #357 and #358 move: 549,059 more facts (1,579,263), 405 packages (28 added, three UC all-claims packages retired), 102,613 geographies (46,363 output areas, 35,673 LSOA-level keys, 26 pre-2015 NI districts, two scopes), 523 periods (gas_year 2015 to 2024, HBAI's FYE 1995 and 1996) and 122 warnings (DESNZ and NRS spell two Scottish data zones differently). Semantic duplicates stay at 2,324. Each source, period, geography and entity change is attributed in the test's comments; every per-source delta equals its packages' fact counts. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Automated review pass (Claude Code, high effort), round 1 at
|
The surface job failed on two existing tests that pinned the pre-PR truth: - test_obr_table_4_1_council_tax_decomposition_rows counts the expenditure package's facts: 150 -> 164 with table 4.9's two Northern Ireland rows for seven years. - test_subnational_packages_keep_units_reference_periods_and_weather_basis pinned GB gas to calendar_year; it is DESNZ's gas year now, labelled by its opening year, with no exact dates. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Vahid's review, items 4 to 7: - The read-only XLSX parse trusted a sheet's <dimension> element unless it was missing, so a writer that understated it truncated the parse with no error. It now always re-measures the used range, as the full parse does; a synthetic test with an understated element and formula cells pins parity, and both LSOA packages regenerate byte-identical. - read_registered_artifact reads a manifest's file the way a package build does (committed, cached, or fetched with LEDGER_SOURCE_ARTIFACT_FETCH=1, sha256-checked); r2_only_package_artifacts lists those stored in R2 only. Downloads retry on transport errors and 5xx answers. - CI runs scripts/fetch_r2_only_source_artifacts.py before any test, so a gov.uk outage or a replaced file fails one step by name, and logs the bundle test's peak memory with GNU time. - Without the workbooks and without fetching, the LSOA tests and the merged bundle test skip with the reason, as chronicle#343's raw-byte tests do. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…acts Vahid's review, items 3, 9, 14 and 15; no value or key changes: - Every Northern Ireland energy measure's evidence notes now say what the methodology booklet (July 2026) does: NI gas classes meters by profile marker, not GB's 73,200 kWh threshold (sections 4.2, 4.3), and NI electricity is not directly comparable with GB (5.3), nor 2015 onwards with earlier years (5.2). The domestic electricity notes add that NI files three domestic_scope rows under one concept where GB files all_domestic. - NI gas periods note that DESNZ's dates overlap or leave gaps between years (from 2018 consecutive years share their 15 May boundary). - HBAI FYE 2021 and FYE 2022 facts (8) carry Note 5's caution on telephone-only interviewing during the pandemic. - The UV404 header records that the file prints 168,890 '-' cells and no literal '0', and that 4,910 output areas carry no private-rented fact. - The energy builder reads the LSOA workbooks through read_registered_artifact, so a clean checkout uses the cache or a fetch. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
As 5360644 did for quarter and week: the emitted schema's period.type description names the ledger.core vocabulary, so it gains gas_year, and the v4 hash is re-pinned (cc9efb90... -> 577bc1c1...). period.type stays a free string. v1 to v3 keep their own descriptions, so the v3/v4 equality test leaves this one description out. Consumers that pin the hash (Microcosm's chronicle_feed.json) update it with their re-pin. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Vahid's review, items 2, 3, 5, 10, 11, 13 and 16: - test_issue_358 checks that each ONS dimension carries its label beside its option code, so writing the code into the label column fails. - The notes now say Microcosm's table 4.9 selectors pin the United Kingdom (they do), that the child-band selectors must add payment_indicator to their dimensions, how CI fetches the LSOA workbooks, and that the streamed parse re-measures sheets. - NI energy: DESNZ's comparability caveats replace "Microcosm can split the UK Energy Trends level". - Move to UC names both denominators: 86.74% over claimed plus did not claim, DWP's 87% over every notice (86.71%). - The base is 1,030,204 facts; the child-band gap's median is stated as the absolute gap (2; 0 in 28% of cells). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
44d4470 inserted the R2-only skip helper between @pytest.mark.usefixtures("prune_suite_intermediates") and the merged bundle test, so the decorator applied to the helper and the test stopped pruning each suite's intermediate files, a disk risk on CI (found by the ledger-contract judge). The helper now sits above the decorator, and --fixtures-per-test lists the fixture on the test again. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The v4 description put gas_year under the opening-year rule, but DESNZ labels its October-to-September gas years to 2015 by their closing year, as chronicle/core.py says. The description now states both, and the v4 digest is re-pinned (d953306d...). The gas_year changelog fragment notes that the digest moved, so consumers pinning it update, and that policyengine_chronicle no longer loads v4 artifacts built under the old digest (ledger-contract judge). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Response to round 1, at
|
Automated review pass (Claude Code, high effort), round 2 at
|
Summary
Draft. Answers five Microcosm requests in one change. Source notes, decisions and parity checks are in
docs/data-sources/uk-feed-326-339-356-357-358.md. The merged bundle is re-pinned from a local full build (see Bundle).#357, facts for the microcosm#1095 ports
hmrc-stamp-tax-statistics-2024-25, 352 facts.hmrc:england_and_northern_ireland, carries a £40,000 transaction-value constraint and names the corrected edition.obr-efo-receipts-march-2026(+35 facts).dwp-mtuc-households-legacy-benefit-move-status-july-2022-june-2026, 80 facts from Stat-Xplore.dwp-hbai-summary-fye2025: median equivalised income in 2024/25 prices and relative low income, before and after housing costs, FYE 1995 to FYE 2025 (124 facts).dwp-hbai-uncertainty-fye2025: the FYE 2025 95% confidence bounds (8 facts), from the release's data-table ZIP.#339: UC households by area with Payment Indicator, January 2025 to May 2026, re-extracted from Stat-Xplore on 15 October 2026.
db/data.#356
gas_yearperiod type. DESNZ publishes no exact GB gas-year dates, only "mid-May to mid-May".calendar_yeartogas_year: their identity changes, their values do not.desnz-lsoa-domestic-{gas,electricity}-consumption-2024, 338,080 facts.dft-bus04i-operating-revenue-2025carries BUS04ai's total operating revenue for Scotland, Wales and GB (6 facts).#326:
nrs-census2022-uv404-tenure-output-area(87,816 facts). It carries all occupied households and "Private rented: Total" for 46,363 output areas, from NRS's public UV404 output-area CSV. The ward tenure-by-bedrooms export remains unavailable.#358: residence type by age, with 90 and over split out.
Closes #326, closes #339, closes #356, closes #357, closes #358.
Bundle
tests/test_chronicle_bundle.pyagainst it.Review notes
gas_yearperiod type rather than undated calendar years.735820c). Re-pinning to this feed needs the changes below; a Microcosm tracking issue is drafted and will be filed separately.dimensions: ["number_of_children"], which must equal a fact's dimension names, so they match no fact and drop out silently.payment_indicatorto those lists and pinYes.uk.local_geography.uc_households.*) leave the feed; Microcosm's selectors on main don't use them.K02000001, set by rule intools/generate_uk_target_references.py, so 12 match no fact until the generator pins their new stamps. The hand-writtenobr.state_pensiondiagnostic pins it too. Values don't change.domestic_scopeand the GB areas:calendar_yearfor gas.consumer_fact_schema_sha256moves tod953306d…: following 5360644, the v4 description now listsgas_year.period.typestays a free string.policyengine_chronicleno longer loads v4 artifacts built under the old digest.period_coverage.-cells emit no fact. No NRS document defines the symbol. The arithmetic and the file (168,890-cells, no literal0) both point to zero, but Chronicle doesn't assert it, so 4,910 output areas (10.6%) carry no private-rented fact.xlsx_read_only_used_rangeis opt-in. Read-only parsing matched the full parse on 31 of 34 sheet-restricted packages and on the LSOA gas workbook (947,540 cells, 22 s against 65 min). It differs on three existing packages, so none of those changes. It re-measures each sheet's used range rather than trust its<dimension>element; a synthetic test pins that.dft-bus05i-revenue-support-2025does: 2025 is the year ending March 2025.domestic_scoperows under the concept GB files once. NI gas notes say that DESNZ's year dates overlap or leave gaps.obr.sdlt(sheet 3.8), which they sum to, as OBR prints them in one UK table. Stamping SDLT England and Northern Ireland would have to moveobr.sdltwith them, a fact Microcosm binds, so that's a separate decision.Chronicle Governance
ledger-source-ingestorfor the packages and the parsers inchronicle/sources/**;ledger-contract-maintainerfor thegas_yearperiod type inchronicle/core.pyand the v4 schema's description.chronicle/source_package.py,chronicle/bundle.pyandchronicle/artifacts.py;db/data/**,scripts/*,docs/*(other than schemas),changelog.d/*andpackages/uk_local_2025_sources.md;tests/test_issue_*.pyfiles andtests/test_policyengine_chronicle_schema.py;.github/workflows/ci.yml(artifact fetch, cache, memory log and the bundle job's timeout) and.gitignore.validate-packageandbuild-suitefor all 31 new and changed packages: valid, with 0 agent-acceptance errors. The only warnings areconcept_alignment_validation_skippedandno_concept_alignments.publish-raw, thenverify-raw: 37 of 37 new R2 objects match their pins.inventory-artifactsoverdb/data: valid, 446 entries, 40 R2-only, no checksum mismatches.4187f66):ledger-source-fidelity: PASS.test_hbai_confidence_intervals_bracket_the_estimateswould catch it.ledger-contract: PASS.gas_yearjoins the vocabulary thatvalidate_factenforces, and the v4 change is description-only, as in b714b3c and 5360644.ledger-boundary: PASS.monthstamp on Move to UC's cumulative count, and the United Kingdom stamp on the sheet 3.7 SDLT lines.Tests
tests/test_issue_{357,356,326,358}_*.py, covering:tests/test_chronicle_uk_local_2025.py:test_build_bundle_writes_merged_consumer_contractpasses against the local bundle, and the file's other 24 tests pass. The full surface suite runs in CI.<dimension>understates it (with formula cells), and ONS labels against option codes.prune_suite_intermediatesfixture (2480f4a).uv run ruff check chronicle policyengine_chronicle db scripts tests: passed.🤖 Generated with Claude Code