UK: pool several FRS years in the spine, three for the local build first
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 5/5
- Estimated time
- Over a week
- Newbie friendliness
- 20/100
- Issue type
- Feature
- Clarity
- Clearly specified
- Activity status
- Active
- Tech stack
- python
- Domain
- backend, data-engineering
Research direction
Start with microcosm.build and us_runtime/asec_pool.py to trace the current pooling behavior, then read microcosm.calibrate.static_aging for its projection and series mapping. The issue specifies a multi-commit change spanning FRS pins, spine bindings, both country pools, and local release checks, with eight decisions still open. Done means the US pool remains unchanged after the shared core moves and the pooled UK builds pass the stated identity, payload, and release gates.
Written by the indexing model from the issue text.
Description
Starts after: #931 closes (PR #1538).
Problem
The UK build reads one FRS year, 2024-25 (SN 9563). The local (dense) line reaches its size by cloning each household K = 15 times.
Clones add rows, not information. All clones of a household carry the same survey answers, so more clones do not give an area more distinct households. With three pooled FRS years, the local line has about three times the distinct households. It then needs about K = 5 for today's candidate count, and the selected households can come from up to three times as many survey households.
The national line has the same need for small groups. #1710 lists pooled FRS years, as IFS uses them, as a longer-term fix for its rows. So the national line may move to two or three years soon after.
What the build does today
- K is a build parameter. After #931, one spine builder serves both lines:
spine_build.py --n-clones K, default 1. The national line builds at K = 1. The local release's recipe fixes K = 15 (local_doctrine.UK_LOCAL_CLONE_COUNT), and the local release path reads it in four places: the release-candidate guard inspine_build.py, the dense posture inrowwise_posture.py,tools/preflight_uk_local_release_candidate.pyandtools/run_uk_cut.py. The dense build reads K from the bound spine. - One release object.
uk/frs_release.jsonholds one FRS year: the survey, base and calibration years,time_period, and the UKDS, DOI and zip pins.load_uk_frs_release()andresolve_uk_year_rule()give every stage that one year. 13 modules callresolve_uk_year_rule. - One set of raw files.
uk/source_stages.jsonpins one tab file per FRS table, andcountry_adapter.pyrefuses any other set. Two places read the raw files: the FRS ingest (frs_spine) and the SPI stage (spi_spine, throughfrs_hmrc_source._read_raw_frs_table). - Ids from SERNUM.
frs_spine._normalize_idssetshousehold_idto SERNUM,benunit_idtohousehold_id * 100 + benunitandperson_idtohousehold_id * 1000 + person. SERNUM is unique only within one year's file. - Weights.
household_weightis the year's GROSS4, so each year alone grosses to the whole UK. - Identity keys. After #931, the geography identity key (
geographic_identity.key_uk_households_by_clone_path) reads each household'ssource_year, maps it to an FRS vintage throughfrs_vintages_by_source_year, and adds thesource_household_idand the clone path. The geographic expansion writessource_yearfrom the frame's time period, and the one release maps that year to its one vintage. Growing K never changes an existing household's key. - Disclosure floor.
receipt_counts.distinct_carrierscounts distinctsource_household_idvalues againstUK_DISCLOSURE_FLOOR. - Other years' amounts. The SPI donor (2022-23) is rebased to the build year before it conditions on FRS incomes (
spi_income._spi_income_uprating_factors), with ratios of policyengine-uk parameters and OBR series.
What the US has
The US pools three CPS ASEC years (#1044):
- Pins, one per year.
us_runtime/asec_sources.pyholds each year's file, SHA-256, size and upload revision. It fetches a year only after it verifies the bytes. Adding a year never moves an earlier year's pin. - A default rule.
newest_pinned_income_years(size)gives the newestsizepinned years. The default pool is the newest three, so pinning a new year moves it. Every pinned year stays selectable, and a build can pass its years explicitly. - The pool.
us_runtime/asec_pool.pyrefuses duplicate years and gives each year a share of the anchor year's weighted population (equal unless declared). It scales each year's weights to that share and writes a per-rowsource_year. - Ids. The pool renumbers households across the years, each year after the last, so
household_idis unique.source_household_idstays the year's own H_SEQ. US draw keys and joins pair it withsource_year(for examplecps_source_geography,snap_take_upandesi_premiums). SPM unit ids are made unique onsource_yearand the id (_globalize_source_unit_column).
The ASEC loading, the Census column restore, the relationship recode and the US unit construction are US-only.
Aging. Neither country ages older years' amounts per record yet:
- #944: pooled prior-year ASEC dollars enter the target year unaged. Its question, whether that is intended, has no answer yet.
- #981: donor dollars (SCF, SIPP) enter unaged. It proposes a per-record ager built on the factor half of static aging (PR #957).
microcosm.calibrate.static_agingalready holds series by year (SeriesProjection) and a map from each column to its series, and it computes index ratios. Today it projects one base-year frame forward. It does not age records that come from different years.
Decided
- First step. The national line stays on one year (2024-25, K = 1). The local line pools 2022-23, 2023-24 and 2024-25 and lowers K to keep today's candidate count.
- Years are a build parameter, like K. The spine build takes the FRS years beside
--n-clones, and the default is the newest pinned year. Both lines run the same code. The local release's recipe names its years next to its K, and the checks that read K read the years too. A later move of the national line to two or three years is a parameter change and a new spine. Years and K act the same way: both multiply the candidate rows and split the weight. - Reuse, do not rewrite. The general parts of the US pool move to a shared, country-agnostic module that both countries call. No US code is copied into UK code, and the US pool's output stays unchanged when the code moves.
- Pooled years are aged, in both countries. Older years' money amounts move to the anchor year per record, with one shared ager. The US pool uses it too. This answers #944's question.
Work
One PR with ordered commits:
- Shared pool core, from the US pool. Move the general parts of
asec_pool.py, andasec_sources.newest_pinned_income_years, into a shared module inmicrocosm.build. The general parts are: the unique-year check, the shares, the anchor-year total, the per-year weight scale, the per-rowsource_year, the id step and the newest-N rule.asec_pool.pycalls the shared module, and the US pool tests show that its output is unchanged.- The id step takes a policy: renumber every year (the US today), or keep the anchor year's ids and offset only the other years (the UK, so that a one-year pool keeps today's ids).
- The population measure is an input (the US uses the weighted person population).
- Shared per-record ager. Each money column follows a declared series. Each record's amount moves by the series' ratio between the record's own year and the anchor year: per record, never through weights. The ager reuses
static_aging'sSeriesProjectionand its column-to-series map. Each country declares its series: the UK the policyengine-uk parameters and OBR series that the SPI rebasing uses, and the US the series #981 names (the SOI chain where one exists, otherwise CPI or a wealth index). For a one-year pool, the ager changes nothing. - One pin per FRS year. A registry of FRS releases keyed by year, on the
asec_sources.pymodel. Each entry is today'suk/frs_release.jsonobject with its own tab pins. Pin 2022-23 (SN 9252) and 2023-24 beside 2024-25. - The years on the spine build. A
--frs-yearsargument beside--n-clonestakes one or more pinned years, and its default is the newest pinned year. The spine binding records the years as it records K. The builds that take a bound spine read the years from it. - The FRS pool. Read each year's raw files and call the shared core with the anchor-keeping id policy. Apply each household offset before
benunit_idandperson_idare derived, so that they follow it. Size the offset so that ids stay unique and fit in int64 after the clone multiplier. A one-year pool is the identity: same ids, same weights, same bytes. - Each household's own year. The geographic expansion writes each household's survey year to
source_year, not the frame's time period.frs_vintages_by_source_yearmaps each pooled year to its own release's vintage. The anchor year's keys stay as they are, so adding a year never changes an existing household's key. - Harmonise and age the FRS years. Map each year's columns to the frame schema. Age older years' money amounts with the shared ager, before any stage compares them with another source (the SPI conditioning first). Ages stay as reported, and calibration sets the age mix.
- Year rules.
resolve_uk_year_rule("survey_year")keeps meaning the anchor year. Callers that need a record's own year read the per-row column. Audit the 13 callers. - The local release recipe.
local_doctrine.pynames the local years next to the new K. The release-candidate guard, the dense posture, the local preflight andrun_uk_cut.pyread both, in place of K = 15 alone. - The US pool ages its years.
asec_pool.pyages each prior year's dollar amounts to the target year with the shared ager and the US series. This changes US outputs. It goes in this PR or an immediate follow-up (decision 8). Later, #981 (the SCF and SIPP donors) and #1715 (WAS wealth) can age their donor values with the same ager.
Decisions needed
- Where to pool. (a) Pool the raw files, so that the ingest and the SPI stage each read one pooled file per table, and age the amounts there. (b) Ingest each year, then pool and age the frames, and give the SPI stage the same years. Option (a) leaves both readers as they are but ages raw columns. Option (b) ages typed frame columns but changes both readers.
- Shares. Equal shares (the US default), or shares by each year's sample size?
- Support copies. Do the SPI support copies, CGT clones and high-value support copies draw from the whole pool or from the anchor year only? The whole pool triples their count.
- Older years' reported receipt. Older years have an older benefit mix, for example more tax credits, which closed in April 2025. Do the take-up stages read older years' reported receipt the same way as the anchor year's?
- K for the local line. 5, or the K that keeps the candidate count closest to today's?
- Disclosure counting. Each year's household counts as its own source household for the floor, because each FRS year is a separate sample and the files carry no cross-year id. Confirm.
- Years by count or by name. The US recipe names a count ("the newest three"), so a new pin moves the pool. Should the UK recipes do the same (national one, local three), or name fixed years?
- When the US pool adopts the ager. In this PR, or in an immediate follow-up PR? Commits 1 and 2 change no US output. Item 10 does, so it needs a US build, a US review and a check against the measurements in #944.
Done when
- The US pool's output is unchanged after the shared core moves.
- A one-year pool reproduces today's national spine: the same content identity and stage-evidence digests, and identical H5 payloads (
tools/compare_uk_h5_payload.py). Node keys may move once. - A local spine builds from the three years at the new K and passes its gates. The floor counts distinct source households across the pooled years.
- The national and local lines differ only in their years and K. Synthetic tests cover one, two and three years at more than one K.
- Each pooled year has its own pins: release object, tab files and zip hash.
- In the US pool, each prior-year record's dollar amounts equal its raw values times its series ratio. This is the check that #944 ran on wages. (In this PR or the follow-up.)
Related
#931, PR #1538, #1301, #1710, #1371, #146, #159, #1044, #944, #981, #1715, PR #957, #333, #723.
- Dominant language
- Python
- Stars
- 0
- Forks
- 6
- Avg merge
- 1d 17h
- Merged PRs (30d)
- 190
Getting set up
- No Dockerfile or Docker Compose file
- No pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from PolicyEngine/microcosm
-
Difficulty 2/5 1-3 hours Newbie friendliness 79/100
PolicyEngine/microcosm#1766 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
PolicyEngine/microcosm#1721 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
PolicyEngine/microcosm#1701 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
PolicyEngine/microcosm#1638 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 85/100
PolicyEngine/microcosm#1431 ·
Maintainers usually reply within 1 day
All issues in PolicyEngine/microcosm
Similar issues
-
claude-subscription-directsdk: tool calls with raw control characters in string values are droppedOpen
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
NousResearch/hermes-official-plugins#538 ·
Maintainers usually reply within 3 days
-
bug(qdiffusion): EnergyModel.score_visible_logits computes biased visible/hidden on-ratios when solver returns variable solution counts per candidatePossibly taken @houzhongyu claimed this today. Open
Difficulty 2/5 1-3 hours Newbie friendliness 83/100
qboson/kaiwu-pytorch-plugin#2133 ·
Maintainers usually reply within 2 days
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
Maintainers usually reply within 1 day
-
needs-triage
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
MakazhanAlpamys/Soup#3415 ·
Maintainers usually reply within 1 day
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Maintainers usually reply within 2 days