Skip to content

Add starting_stock: the PIA behind a benefit in payment (T7) - #610

Draft
MaxGhenis wants to merge 3 commits into
masterfrom
microcosm-start-t7-pia-inference
Draft

MaxGhenis wants to merge 3 commits into
masterfrom
microcosm-start-t7-pia-inference

Conversation

@MaxGhenis

@MaxGhenis MaxGhenis commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor

This pull request adds populace_dynamics.starting_stock, pure functions for the Microcosm start's task T7, which infers the PIA behind a Social Security benefit in payment.

  • pia.py carries a PIA at eligibility forward to a monthly benefit. It applies each year's COLA, floors the amount to the dime after each adjustment, applies the claim factor, then floors to the dollar. It also inverts that rule without rounding and bounds the gap that statutory rounding opens between the two.
  • claim_age.py draws a whole claim age from award shares. It also draws a single year of age for an age stored as a top code (80 or 85). Each draw takes a SHA-256 uniform keyed by seed and person id.
  • limits.py names four limits that we report beside each inferred PIA.

The tests use invented numbers only, and the unit tier gains 102 of them:

  • test_pia.py (91) holds worked examples and error paths.
  • test_pia_properties.py (11) runs the package's eight invariants as Hypothesis property tests. It also checks benefit_from_pia against carry_pia_forward in populace_dynamics.bridge.policyengine_us on the domain both functions share.

tests/starting_stock/conftest.py installs an import guard. While starting-stock code is on the stack, it refuses two modules that no starting-stock test may load.

tests/tier_counts.json adds the 102 tests to the unit tier. Another branch of this work changes the same line, and we'll reconcile the two before merge.

Open

single_year_age draws a single year of age for a person whose age the file stores as 80 or 85, from shares the caller passes and with a key of its own. Candidate H-D in the registration draft (#607) also needs a single age for these people. In a later change, we plan one shared draw for both, with one function and one key, so each person gets one age. Once we pin SSA's area population by single age and sex, that table will supply the draw's shares. That change would also settle five points:

  • the draw would compare the table's integer populations exactly, where it now compares floating-point sums;
  • the frame build would fix one seed for the draw and record it;
  • both callers would key the draw on the frame's person_id;
  • one mapping would turn the frame's sex codes into the function's sex argument;
  • H-D's lock would pin the commit of this function that it uses.

How we built this

Claude Opus 5.5 wrote these commits in a separate job, under a brief that names the files it may read and the commands it may run. It reported six departures from that brief, and none reached a file the brief closed:

  • It ran the interpreter's version check directly, outside the audit wrapper.
  • It ran pytest --collect-only -m unit on its two modules, against the brief's rule that test runs name their modules and use no marker.
  • It read the list of closed files from a saved copy after its terminal output overflowed. It read five of the list's twelve addenda through their headings and the copies in the main list, not file by file.
  • It listed the names of files in tests/, the repository root and src/populace_dynamics/ss/, and opened no file it found that way.
  • It printed the [tool.black], [tool.ruff] and [tool.pytest.ini_options] sections of pyproject.toml, which the brief didn't name.
  • The harness loaded the repository's CLAUDE.md into its context.

🤖 Generated with Claude Code

Max Ghenis and others added 3 commits November 25, 2026 18:39
A new package of pure functions for the starting stock. pia.py holds
the forward rule from a PIA at eligibility to a monthly benefit (COLA
factor, dime floor after each adjustment, claim factor, dollar floor),
its unrounded inverse, and the bound on the gap statutory rounding
opens between them. claim_age.py draws a whole claim age from award
shares by a counter-based SHA-256 uniform keyed by seed and person id,
and a single year of age behind a top-coded age. limits.py names four
limits reported beside each inferred PIA.

Tests use invented numbers only: worked examples and error paths in
test_pia.py, the eight package invariants as Hypothesis tests in
test_pia_properties.py, and a differential test against the bridge's
carry_pia_forward. tests/starting_stock/conftest.py installs an import
guard that refuses two modules no starting-stock test may load.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
tests/starting_stock/test_pia.py (91) and test_pia_properties.py (11),
collected by name: 26,654 + 102 = 26,756.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The finder stays in sys.meta_path for the rest of a pytest session, so
in a full-suite run it would refuse the two modules to test modules
collected after tests/starting_stock. It now refuses an import only
while code of populace_dynamics.starting_stock or tests.starting_stock
is on the stack. The guard test skips, with its reason, in a session
where another module loaded one of the two first, since a cached module
bypasses every finder.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@vercel

vercel Bot commented Nov 25, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
social-security-model Ready Ready Preview Nov 25, 2026 5:54pm UTC

Request Review

This branch was successfully deployed

1 active deployment
Preview — 016d8a9d Deployed Nov 25, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant