Repository navigation
Draw is_apprentice for employees aged 21 to 24 on the UK spine (#1372) - #1373
Draft
vahid-ahmadi wants to merge 4 commits into
Draft
vahid-ahmadi wants to merge 4 commits into
vahid-ahmadi wants to merge 4 commits into
Conversation
policyengine-uk#2505 zero-rates employer NICs for relevant apprentices under 25 (SSCBA 1992 s.9B) through the is_apprentice input, which no UK dataset supplies: the FRS 2022-23 to 2024-25 adult tables carry no apprenticeship variable. frs_person_draws now draws it for employees aged 21 to 24 at DfE's England apprenticeship participation per head aged 19 to 24 (5,992 per 100,000 in 2024/25), converted to a rate among the eligible employees at the frame's household weights. Younger and older people keep False, so is_in_non_advanced_education, minimum_wage, Care to Learn and the 16 to 19 Bursary Fund do not move for them. The contract gains apprenticeship_participation_19_to_24, the stage spec and graph declare the output and the employment_status read, the export surface allows person.is_apprentice, the identity-stability tool passes the household weights, and the gate-battery and input-coverage pins move. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…tation (#1372) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This branch has not been deployed
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.
Closes #1372
Summary
Adds
is_apprenticeto the UK spine, so the employer NICs zero rate for apprentices under 25 in policyengine-uk#2505 (SSCBA 1992 s.9B) reaches people aged 21 to 24. Today no UK dataset supplies the input, and the FRS has no apprenticeship variable (see #1372).frs_person_drawsdraws the flag for employees aged 21 to 24 only. Employees are people whoseemployment_statusfromfrs_employmentis FT_EMPLOYED or PT_EMPLOYED. Everyone else keeps the engine default, False.apprenticeship_participation_19_to_24holds DfE's England apprenticeship participation per head of population aged 19 to 24 for 2019/20 to 2024/25. The 2024/25 value is 252,960 / 4,221,504 = 5,992 per 100,000. It comes from the national rows of the DfE data set, and the CSV's sha256 is recorded in the entry.p = min(1, r * W(age 21 to 24) / W(eligible)). A person is flagged when eligible and their identity-keyed uniform (seed 0, saltis_apprentice) is belowp. The weighted apprentices therefore equal r times the weighted population aged 21 to 24.is_apprentice:is_in_non_advanced_education(qualifying young person status for child benefit and Universal Credit),minimum_wage(the self-employed Universal Credit minimum income floor), Care to Learn and the 16 to 19 Bursary Fund.employment_status. The stage refuses a frame without it rather than flag non-employees. It also refuses a frame that already storesis_apprentice.Files
uk_runtime/frs_person_draws.py:derive_is_apprentice, plus the output column and the frame's person weights.uk/take_up_contract.json: the DfE rate series, with its source and derivation.uk/spec/sources.yamlanduk/source_stages.json: anassign_binary_from_rateoperation with its eligibility and rate derivation, the new output, and the stage note.uk_runtime/graph.py: the typed cell, andemployment_statusas a stage read.uk/gates.jsonanduk_runtime/terminal_gates.py:person.is_apprenticeadded to the export surface's allowed extra columns. Liketax_free_childcare_spend_routed_share, it is a genuine model input that the incumbent does not carry.tests/engine_free/uk/test_uk_apprentice_draw.pyis new (10 tests). The stage operation list and rate-key order intest_uk_source_stages.pyare updated, and the shared stochastic fixture gainsemployment_statusand the rate.Tests
test_uk_apprentice_draw.pychecks:employment_status, a rate outside [0, 1], a stored flag);Local runs (fresh venvs, Python 3.13):
node(not installed on this machine).tools/run_integration_tests.sh: passes. It runs the real spine command on the synthetic fixture, sofrs_person_drawsreadsemployment_statusfromfrs_employment.ruff check .: clean.tools/ci_test_plan.py verify: ok.Pins that move with the spec, regenerated with their tools:
microcosm-datacontract.pyand the contract tests);release_input_coverage_manifest.json(tools/build_uk_release_input_coverage_manifest.py);tools/graph_uk_spine_fixture.py).Other changes in this PR:
tools/verify_uk_identity_stability.pypasses the household weights, so its re-derivation matches the stage.Caveats (also in #1372)
🤖 Generated with Claude Code