Declare the uk_national target profile over the ported UK facts (#133) - #164
Open
juaristi22 wants to merge 1 commit into
Open
Declare the uk_national target profile over the ported UK facts (#133)#164juaristi22 wants to merge 1 commit into
juaristi22 wants to merge 1 commit into
Conversation
…cyEngine#133) 186 value-free targets across 20 families mirror the 651-row national registry policyengine-uk-data compiles at the pinned migration ref ebf733c (NATIONAL+COUNTRY+REGION): 609 rows map onto profile targets and 42 carry signed exclusions (no ported facts: computed products, lost sources, or wave-3 scope). Selectors reference raw Chronicle facts by source_concept/measure/groupby; measurement carries entity, map_to, filters, and publisher-dimension pins; bindings.policyengine reifies the semantics uk-data keeps in ~35 name-parsing dispatch branches and 31 compute functions. New declarative binding vocabulary (no values, no runtime hooks): input_substitution_counterfactual (salary-sacrifice relief), parameter_gated_threshold (CGT above the live annual exempt amount), and baseline_flag_crosstab (two-child limit), plus reduce/household_conditions for household-indicator counts uk-data overloads onto is_count. OBR EFO lines, SLC borrower forecasts, and the Scottish budget line carry allow_source_projection (PolicyEngine#154); everything else rides observed_only so ported projections (NPP) stay dormant until populace activates them. Tests: structural pins (families, policies, counterfactual vocabulary) and a full-resolution test that builds the 32 selected packages and asserts every target x geography level resolves at least one built fact with zero selector issues - the mechanical form of this issue's "resolves every selector against built facts" acceptance line. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Declares the
uk_nationaltarget profile over the ported UK facts — the last item in #133's scope. Closes #133.186 value-free targets across 20 families mirror the 651-row national registry policyengine-uk-data compiles at the pinned migration ref
ebf733c(NATIONAL + COUNTRY + REGION, the exact setcreate_target_matrixiterates): 609 rows map onto profile targets and 42 carry signed exclusions — every row is accounted for, no silent gaps. The mapping was machine-generated from a dump of uk-data'sget_all_targets()and the generator asserts the accounting closes before emitting the JSON.What each target carries:
chronicle_selectorreferencing raw Chronicle facts bysource_concept/source_measure_id/groupby_dimension(concept-level selectors for OBR/DWP/ONS families whosemeasure_ids are generic and whoserecord_set_ids are period-scoped).measurementwith entity,map_to, model-concept filters, andsource_dimensionspins naming the exact publisher rows (two-child-limit status, UC family types, SLC lines, household types) — dimension values are not selector vocabulary, so the pins live here as declarations for the consumer.bindings.policyenginereifying the semantics uk-data keeps implicit in ~35 name-parsing dispatch branches and 31 compute functions:value_variable/value_expression,from_entity(native entities verified against policyengine-uk),map_to, filters, andhousehold_conditions+reduce: anyfor the household-indicator counts uk-data overloads ontois_count.bindings.axiomstubs (status: pending) following the existing profiles' convention.New declarative counterfactual vocabulary (no values, no runtime hooks — the payload is the spec populace's metric-provider registry implements in populace#622):
input_substitution_counterfactual— salary-sacrifice relief: zeropension_contributions_via_salary_sacrifice, fold intoemployment_income, target the income-tax/NICs delta, IT relief banded on counterfactualadjusted_net_incomeagainst live parameter thresholds.parameter_gated_threshold— CGT: taxpayer/gains totals gated ongov.hmrc.cgt.annual_exempt_amountread from the parameter tree (gating only one of count/amount would target a mean over two different populations).baseline_flag_crosstab— two-child limit: baselineuc_is_child_limit_affectedflag with per-shape crosstab conditions; no second simulation.Assertion axis (#154): the 28 OBR EFO lines, 4 SLC borrower-forecast targets, and the Scottish budget line carry
allow_source_projection; everything else rides theobserved_onlydefault, so ported projections (NPP 2024-based) stay dormant until populace activates them — porting never activates.Row accounting
council_tax_stockdwp_benefit_capdwp_legacy_benefitsdwp_pipdwp_two_child_limitdwp_universal_credithmrc_cgthmrc_salary_sacrificehmrc_spiiscobrons_employmentons_household_compositionons_landons_national_accountsons_populationscotgov_social_securityslc_borrowersslc_repaymentsslc_student_supportPlus 3 profile targets with no registry row: the salary-sacrifice IT-relief bands, restored from uk-data source code — their values never load at
ebf733cbecause the pinned HMRC CSV now 410s, so uk-data silently drops them (link-rot already logged on the checklist).Signed exclusions (42 rows, no ported facts):
nts/households_{no,one,two_plus}_vehicle(3): DfT facts are percent shares; identity-only resolution cannot scale a share into a count. Populace derives the count targets (share × household total), US derived-CHIP precedent.housing/rent_private,housing/rent_social(2): computed rate × count products; the PIPR/EHS base facts are ported (UK wave 2: housing base facts — PIPR bulletin rents and EHS weekly housing costs (#133) #159), the products stay populace-side declarations.housing/total_mortgage(1): no publisher source — the cited ONS rent bulletin carries no mortgage figure (housing/total_mortgage cites the ONS rent bulletin, which carries no mortgage figure policyengine-uk-data#453).ons/tenure_england_*(5): LA-grain workbook uk-data code-sums; ruled non-portable as national facts on UK source packages, wave 2: national fiscal/benefit families + uk_national target profile #133, moved to wave 3 (UK source packages, wave 3: back the uk_local_geography profile (constituency + local authority) #134).hmrc/{capital_gains,cgt_taxpayers}_band_*(18): the size-of-gain distribution CSV was never packaged (no publisher table pinned); candidate follow-up alongside populace#467.dwp/benefit_cap_total_reduction(1): computed annualization of a monthly figure (UK wave 2: national fiscal/benefit source packages (#133) #139).hmrc/salary_sacrifice_contributions(1): SPP Review 2025 base value, source lost with no Wayback snapshot.ons/household_land_value/{REGION}(11): uk-data's computed dwellings × price allocation — no publisher regional land facts exist.Vintage and value-side differences carried populace-side (enumerated per the acceptance rule; the compile-parity gate in populace#622 adjudicates):
notesflagging them for adjudication rather than silently fixed:obr/ni(total-NI line bound toni_employeeonly, alongside separate employee/employer/self-employed lines),obr/pip(EFO line covers DLA+PIP; uk-data bindspiponly),dwp/jsa_claimants(bound to contributory JSA only).compute_uc_jobseekerdispatch branch (no source emits those names) is not ported.docs/pe-uk-source-checklist.md'suk_nationalrow will be pointed at this PR in a follow-up touch —docs/**is outside this lane's allowed paths.Chronicle Governance
ledger-target-profile-authorFORBIDDEN_VALUE_KEYS/FORBIDDEN_RUNTIME_KEYSenforced recursively at load; the profile loads throughtarget_profile_from_mappingin the tests.defaults.operation: "sum", no per-target operation or aggregation keys anywhere.ledger-source-fidelity: n/a (no source packages touched)ledger-target-profile: pending reviewledger-contract: n/a (no contract/schema change)ledger-boundary: pending reviewTests
Three additions to
tests/test_policyengine_chronicle_target_profiles.py(the lane-owned file):allow_source_projection, no target pairs a policy with anassertionselector key, every target carriespolicyengine+axiombindings, and counterfactualkinds come from the declared vocabulary.uk_nationalconsumer artifact, and asserts every target × geography level resolves ≥1 built fact with zero selector issues (signed-exception set present but empty), plus that the borrower-forecast facts really are projections. Runs in ~80s.Full local suite green: 633 passed, 1 skipped. No bundle-expectation re-measure needed — a profile-only change moves no fact counts.
Resolution spot-checks against uk-data's registry values: benefit cap 110,637 (month 2025-11, observation), CGT 378,000 taxpayers / £65.937bn gains (tax year 2023), OBR income tax £305.905bn (FY2024, observation), UK population 69,281,437 (CY2024, MYE).
🤖 Generated with Claude Code