Skip to content

Add frame_start: the reader for the US starting frame (T1) - #611

Draft
MaxGhenis wants to merge 4 commits into
masterfrom
microcosm-start-t1-frame-reader
Draft

MaxGhenis wants to merge 4 commits into
masterfrom
microcosm-start-t1-frame-reader

Conversation

@MaxGhenis

Copy link
Copy Markdown
Contributor

This pull request adds populace_dynamics.frame_start, which reads the US frame the projections start from: release populace-us-2024-spm-20260915 of policyengine/populace-us.

  • reader.py holds read_frame, which turns the frame's HDF5 file into one row per person and one per household, with a provenance record.
    • It hashes the file first. It refuses the pinned release unless the caller passes the token of a registered entry point, and the registry starts empty.
    • It reads only the fields that columns.py names.
    • It derives age top codes, marital groups, annual hours and person weights. It builds spouse links two ways and counts where they disagree.
  • frame_structure reports the file's tables, row counts and dtypes from metadata alone.
  • invented.py writes invented frames in the same layout, for tests.
  • pin.py holds the release's tag, file size and SHA-256.

An error names the entity and the column, and gives bad values as a count.

The tests use invented frames only, and the unit tier gains 171 of them:

  • test_reader.py (160) has an example test for each error path and each spouse-link count.
  • test_reader_properties.py (11) checks the package's ten invariants with Hypothesis.

tests/frame_start/conftest.py installs an import guard for two modules that no frame-start test may load. It refuses them always when pytest runs only tests/frame_start. In a full run, it refuses them while frame-start code is on the import's stack.

pyproject.toml adds h5py>=3.9 to the dev extra and to a new frame extra. tests/tier_counts.json adds the 171 tests to the unit tier. Other branches of this work change the same line, and we'll reconcile them before merge.

Open

  • The Tests workflow fails one check here, test_reducer_input_identity_matches_reviewed_branch. That check lists every source file added since the birth-evidence review, and the five new files haven't joined its list.
  • The spouse links assume that each household id holds one copy of a CPS household. We haven't checked that on the real file.
  • The count table in tests/README-tiers.md still shows the unit tier before these tests.

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. The job's first attempt ended on a provider timeout, and its second attempt built on the first's uncommitted draft. It reported these departures from the brief, and none reached a file the brief closed:

  • It read the list of closed files through saved copies of two outputs that were too large to print.
  • It copied part of that list into its scratch folder, and deleted the copy unread.
  • It first read parts of the list with long lines cut short, then printed the cut tails.
  • One ruff check named its two folders by a shell pattern.
  • It searched tests/ once for two file names, with the closed files excluded by name, and printed the matching lines of three test modules.
  • It read a few lines of h5py's own source in its environment.
  • It ran its opening count of local git objects while the first attempt's files sat uncommitted in the working tree.
  • One black call failed on a bad path and changed nothing.
  • It ran three mutation checks, and restored each source file from its own commit.

Each test process also starts one subprocess: importing h5py calls Python's platform.processor(), which runs uname -p on macOS.

🤖 Generated with Claude Code

Max Ghenis and others added 4 commits November 25, 2026 19:18
read_frame turns the pinned populace-us release's HDF5 file into the
person and household tables the projections start from. It hashes the
file first and refuses the pinned release unless the caller passes the
token of a registered entry point; the registry starts empty. It reads
only the named fields of section 3.2, through table.fields([...]), and
derives age top codes, marital groups, annual hours, person weights and
the two spouse views, with counts of where they disagree.

frame_structure reports tables, row counts and dtypes from metadata
alone. invented.py writes invented frames in the same layout for tests.
Errors name the entity and column, report bad values as counts, and
never chain a library exception that could carry a cell value.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
test_reader_properties.py checks the package's ten invariants with
Hypothesis: round trip, weights, symmetric spouse links (and a
brute-force oracle for the links and their counts), named fields only,
the refusal of the pinned file, the prior-year wage gate, determinism,
errors without cell values, age codes, and Kish's effective n against
the replicated sample. test_reader.py has an example test for each
error path and each spouse-link count.

conftest.py installs a meta path finder that refuses the two barred
modules: always when pytest runs only tests/frame_start, and otherwise
when frame-start code is on the import's stack, so a full-suite run
leaves other tests' imports alone.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The frame reader opens HDF5 files, so the dev extra that CI installs
now holds h5py, and a new frame extra holds it for users of the reader
alone. The two frame_start test modules collect 170 tests, all in the
unit tier, so the manifest's unit count rises from 26,654 to 26,824.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
A new test recomputes, from pytest's own arguments, whether every path
lies inside tests/frame_start, and asserts the guard's strict flag
matches. It confirms the conftest's pytest_configure hook set it. The
two modules now collect 171 tests, so the unit count is 26,825.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@vercel

vercel Bot commented Nov 29, 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 29, 2026 12:18pm UTC

Request Review

This branch was successfully deployed

1 active deployment
Preview — 53b11150 Deployed Nov 29, 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