Repository navigation
Conversation
The release's tail-concentration gate tests the top 100 records' share of a column's weighted absolute mass (fails above 0.75). One record can carry a fifth of a column and pass: in the #1251 rebuild one tax unit of weight 644.7 drew a $218.9M Schedule E line-32 value and carried 21.7% of partnership_income at initial weights, while the column's top-100 share was 0.399. microcosm.build.gates.single_record_concentration measures, for one column, the largest single record's share of weighted absolute mass, that record's weight, the top-k share and the carrier count, on the gate's own population. It returns measurements only: no verdict, no threshold. The US release tool's tail surface now carries it for every numeric QRF output, dense and thin ones included, as surface.single_record_concentration in qrf_tail_concentration.json. The gate's details are unchanged. The dry run's rows carry the share and the weight at base weights, and the post-export probe compares the block with a release that recorded it. Tests, docs and the changelog entry follow on this branch. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… unchanged single_record_concentration gets Hypothesis properties for the share chain (0 < top-1 <= top-k <= 1), the pigeonhole floors, scale-freedom in the weights (exact for powers of two), sign and value-scale invariance, totality on any float64 input (zero or non-finite mass is reported as None, never divided by), order-freedom, monotonicity, and two differentials: against tail_concentration_gate's share and counts, and against exact rational arithmetic. Example tests pin the #1251 line-32 shape, ties, and two float cases: the gate's own top-k sum can pass the total by one rounding step (the measurement caps at 1), and a column with at most top_k carriers reports exactly 1. All ten mutants of the function are killed. The release tool once again resolves weights only where main did for sparse outputs. A dense output whose entity's weights do not resolve is listed under single_record_concentration.unmeasured with the reason, so the reporting-only measurement cannot fail a run the gate would pass. A property checks the gate's verdict, failures and details equal the shared gate on the sparse columns alone for random geometries. The dry run's verdicts, lines and details are unchanged by any values in the block, or by its absence; the probe compares the block with a release that has it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…its weights README and a changelog entry describe surface.single_record_concentration: reported for every numeric QRF output, never graded, no share for a column without mass. The motivating figures are now paired with the weights they were measured at: in the #1251 rebuild the weight-644.7 unit carried 21.7% of line 32's weighted absolute mass at initial weights while the top 100 tax units carried 44.9%; at the certified Route A final weights the two were 4.4% and 39.9%. The first commit's message paired 21.7% with 0.399. The worked example is re-tuned to the initial-weight top-100 share. 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.
Follow-up to #1259 / #1251 / #1239. Reporting only: no threshold, no verdict changes.
The US release's QRF tail gate fails a sparse column whose top 100 records carry more than 75% of its weighted absolute mass. That test cannot see one record carrying a fifth of a column. In the #1251 rebuild, one tax unit of weight 644.7 drew a $218.9M Schedule E line-32 value and carried 21.7% of line 32's weighted absolute mass at initial weights, while the top 100 tax units carried 44.9%. At the certified Route A final weights the two shares were 4.4% and 39.9%. Both pass.
This PR adds the missing number to the release's tail evidence. For each QRF output it reports the largest single record's share of weighted absolute mass (the top-1 share) and that record's weight, beside the top-100 share.
What it adds
microcosm.build.gates.single_record_concentration(values, weights, top_k=100)returnscarriers,top_1_share,top_1_weightandtop_k_sharefor one column.|value| × weight.Nonefor all three measurements. Thecarrierscount is still reported.qrf_tail_concentration.jsongainssurface.single_record_concentration:{top_k, columns: {column: measurements}, unmeasured: {column: reason}}.detailsare unchanged, so the UK and US contract readers see the same keys.--dry-run-gates-report) addstop_1_share_at_base_weightsandtop_1_weight_at_base_weightsto each tail row. No class or verdict reads them.changelog.d/us-qrf-tail-single-record-share.added.mddescribe the block.The gate path is unchanged
_qrf_tail_concentration_gateruns the same statements as on main. It resolves weights only where main did.unmeasuredwith the reason, and nothing raises. On main, the gate never resolved weights for a dense output, so the diagnostic cannot fail a run the gate would pass.Invariants
Each is a Hypothesis property (300 examples for the function, 40 to 60 through the release tool and the dry run), plus example tests.
0 < top_1_share ≤ top_k_share ≤ 1.top_k = 1the two shares are equal.top_kcarriers,top_k_shareis exactly 1.top_1_share ≥ 1/carriersandtop_k_share ≥ min(top_k, carriers)/carriers, to one rounding step.c > 0leaves both shares and the carrier count unchanged and scalestop_1_weightbyc.None. A column with no carriers is alwaysNone.carriersandtop_1_weightunchanged, and the shares unchanged to rounding.top_1_weightis the largest weight.top_1_share. Raisingtop_knever lowerstop_k_share.tail_concentration_gatechecks,top_k_shareequals the gate'stop_sharebit for bit, andcarriersequals its carrier count. On a thin column,carriersequals the gate's thin count.Fractions.Mutation check. I ran ten mutants of the function: tie handling, the ≤ 1 cap, the ≤
top_kshortcut, a tail one record short, the finite-total check, zero-mass carriers, the weight finiteness filter, signed mass, median for max, and dividing by the tail. All ten are killed (out/mutants.log). Two survived the first round:top_sharecan exceed 1 by one rounding step. Masses[2, 3, 2, 1, 1e16, 7, 1e15, 1, 0.5]attop_k = 8give 1.0000000000000002. The measurement caps at 1.≤ top_kshortcut. It returns exactly 1. Summed in partition order,[2, 1e15, 4.5e15, 1e16, 1, 1e15, 4.5e15]gives 0.9999999999999998.Each now has an example test.
Not changed here. The gate itself can report
top_shareabove 1. The UK data contract requirestop_sharein [0, 1]. Reaching it takes a column whose toptop_krecords hold all but a sub-rounding sliver of its mass, so this PR records it in a test rather than changing the gate.Certified Route A release: which columns exceed 5% and 10%
The release is
populace-us-2024-0fb05b6-4b57d15a287c-20260930T150401Z.417d23ae…, as the release manifest certifies) and its calibration sidecar. Both are public in the ungatedpolicyengine/populace-usrepository; no restricted data was read.scripts/route_a_top1.pyin the evidence folder runs this branch's_qrf_tail_concentration_gateon the H5's QRF columns, using the post-export probe's loader. It runs once at the release's calibrated weights, then at the sidecar'sinitial_household_weight.qrf_tail_concentration.json(sha25683119434…) exactly:detailsafter a JSON round trip, including all 33 top-100 shares and carrier counts;compare_qrf_tail;At the release's final weights, 17 of the 68 measured QRF outputs have a top-1 share above 5%, and 7 have one above 10% (the first seven rows below):
long_term_capital_gains_on_collectiblesinvestment_income_elected_form_4952farm_incomecasualty_losssstb_w2_wages_from_qualified_businessinvestment_interest_expensebond_assetsestate_incomew2_wages_from_qualified_businesssstb_self_employment_income_before_lsrunadjusted_basis_qualified_propertyqualified_bdc_incomecharitable_non_cash_donationsunrecaptured_section_1250_gainsstb_unadjusted_basis_qualified_propertytax_exempt_interest_incomefarm_rent_incomeWhat the table shows:
Above 10%. Four of the seven are thin and one is dense, so the tail gate never grades any of these five:
investment_income_elected_form_4952andfarm_income, each above 43%;casualty_loss;sstb_w2_wages_from_qualified_business;investment_interest_expense, at 17.5%.The other two, collectibles gains and
bond_assets, are checked but waived in the run's d490 register.Above 5% and passing the gate. Eight of the 12 checked columns above 5% pass the gate unwaived. Their top-100 shares run from 47% to 75%.
Calibration moves these shares. At the same household total (138.1M), calibration lowers the median household weight from 378 to 118 and raises the 99th percentile from 1,021 to 3,731. The largest per-household final/initial ratio here is 5.0.
bond_assetsfrom 4.4% to 14.9%.estate_incomedropped from 21.6% to 8.5%,unrecaptured_section_1250_gainfrom 16.7% to 6.3%, anddomestic_production_aldfrom 21.2% to 3.4%.At initial weights, 13 columns exceed 5% and 8 exceed 10%. The three above 5% at initial weights only are
domestic_production_ald,stock_assets(5.3%) andpartnership_income(5.3%).Shared largest records. The same person holds the largest record of
w2_wages_from_qualified_businessand ofsstb_w2_wages_from_qualified_business. Another person holds the largest record of both SSTB self-employment and SSTB UBIA. No other column above 5% shares its largest record.Non-amount outputs. Four numeric QRF outputs are codes or rates (
cps_race,detailed_occupation_recode,hourly_wage,first_home_mortgage_origination_year). They are measured like the rest, but their shares carry no dollar meaning; all are below 0.3%.Zero mass. Four outputs have no mass in this release (
s_corp_incomeand the three second-home mortgage columns). They are reported with no share.What this release predates. Route A predates Bound each PUF QRF draw by the population slice its recipient stands for #1259's draw bound and Carry Schedule E line 32 and its passive subset on the US PUF donor #1251's line-32 split. The bound acts on raw draws at initial weights; these shares are measured on the finished release frame.
All 68 rows are in
out/route_a_top1.mdandout/route_a_top1.jsonin the evidence folder.Decision
Whether this becomes a failing gate is a methodology choice, so it is queued for Max as d1511 rather than decided here. The choice covers:
Tests
The new and touched test files pass locally on Python 3.14.7:
test_single_record_concentration.py: 28 passed;test_gates.pywith that file: 216 passed;test_us_release_gate_dry_run.py: 56 passed;test_us_post_export_probe.py: 23 passed.test_us_fiscal_refresh_builder.py,test_us_puf_capital_gains_tail.pyand the data contract'stest_contract.py: 649 passed, 8 skipped.The full suites run in CI.
ruff checkandruff format --checkare clean on every changed file.CI: pending on the head commit (the repository's runners were stalled for hours earlier today).
Review
Independent review (GPT-6.1 Sol,
subfleet run --task review --tier hard) is pending at this head.Evidence (outside the repository):
~/PolicyEngine/_reviews/us-qrf-tail-top1-share/. It holdsscripts/route_a_top1.py,scripts/mutants.py,out/route_a_top1.{md,json}andout/mutants.log.axiom: n/a: release diagnostics; no policy rule changes.
🤖 Generated with Claude Code