Skip to content

Add the OP2(a) newborn entry packet - #602

Draft
MaxGhenis wants to merge 9 commits into
masterfrom
openpop-op2a-newborn-20261106
Draft

MaxGhenis wants to merge 9 commits into
masterfrom
openpop-op2a-newborn-20261106

Conversation

@MaxGhenis

@MaxGhenis MaxGhenis commented Nov 6, 2026 •

Copy link
Copy Markdown
Contributor

WIP. OP2(a) of docs/design/open_population.md: the newborn entry packet. It's stacked on #599, whose commits show in this diff until that PR lands. Four files belong to this part: newborn.py, test_newborn.py and one seal-list line in each of two files.

What it adds

open_population/newborn.py fills the fertility slot. For each maternal birth in the year, it appends a person row with:

  • the mother, and either a second-parent link or one reason from a registered list;
  • a sex from a tagged stream at a required SexRatioPin;
  • the mother's household and weights, and the birth order;
  • synthetic_entry and the five out-of-domain markers set, parity 0 for a girl and missing for a boy, and foreign_born false;
  • NEWBORN_G_FIELDS and NEWBORN_G_WORKER_LINKS, which declare the columns an assembly adapter maps into Track B's G.

harness.py already wraps the slot in BirthEntryAdapter, so the packet writes neither entry_kind nor entry_year, and the harness doesn't change. A GPT-6.1 Sol lane wrote the module and its tests on invented data. I then read them against the sealed code, changed the reader to count only the birth year of a dated state, and added tests.

No real value enters. SexRatioPin has no default, and its source carries a ConventionStatus. NewbornPacketStep.require_frozen refuses anything but a frozen source. §5.4 pins the real share from NCHS before any gate, and that step comes later.

Readings to check

  • The sex stream keys on the mother. The design says "a person-keyed stream". A newborn has no ordinal until the year ends (engine/loop.py:358–360), so the stream uses the mother's ordinal. The kernel gives each woman at most one birth a year, so the packet refuses a second birth to one mother in one year.
  • The state's shape. The reader reads marital.sim_years in the shape the sealed live-roster step hands over (cola_track_a/adapters.py:83–123): spouse_person_id and marital_status, one row a person. A state with a year column counts only the mother's roster year, and two rows for her in that year refuse. The M6 kernel's sim_years (engine/marital.py:435) holds marital_state and no spouse link, so a mother in it reads partner_unknown. §2.4 explains why that kernel can't carry entrants.
  • No state row reads partner_unknown, even if the mother's roster row marks a spouse abroad. The marker counts only once she has a row in the authoritative state.
  • A spouse who died this year. Mortality runs before the marital step (engine/loop.py:297–316). The sealed live-roster step then marks the survivor widowed and moves the link to late_spouse_person_id, so the child reads unpartnered_mother. A state that keeps a link to someone off the roster reads partner_outside_roster. The design's list has no closer reason, and G's assembly adapter can read late_spouse_person_id when a surviving child's benefit needs it.

Invariants

Design §7's newborn-packet and determinism rows, each with a property-based test:

  1. Each newborn has exactly one mother, female and on the roster in the birth year; age 0, birth year equal to the year, and the mother's weight, household and start weight.
  2. Each newborn has exactly one of a link and a registered reason. A linked second parent is on the roster, isn't the mother, and is her spouse or partner in that year's authoritative state.
  3. Incumbent rows keep their values. Packet IDs and counts stay nullable integers and never pass through a float.
  4. A year with no births adds no rows, columns or IDs, and touches no stream.
  5. The packet leaves the module generator unconsumed. Sex is strictly below the share under coupled draws, so raising the share can only turn a girl into a boy, and removing another mother's birth leaves a child's sex unchanged.
  6. Repeating a run gives equal rows, and permuting the roster or the births gives the same rows after sorting.

Differentials. The packet matches the sealed materialize_maternal_births (engine/steps.py:451) in every column that fills, except sex. DirectRNGStreams and ProjectionRNGRegistry give identical packets.

Through run_gate. Accounting reconciles every year, the adapter labels each birth, a newborn faces its first mortality draw the next year at age 0, and two runs give equal slices. A separate test runs packet rows through the sealed apply_mortality and advance_age, and another runs the reader on the sealed widowhood_marital_step.

Evidence

On the host at a94838ca, one process:

  • tests/open_population/test_newborn.py and test_conventions.py: 172 passed in 24.84 s, 121 of them in test_newborn.py.
  • tests/estimates/test_birth_evidence_artifact.py: 14 passed.
  • Black (-l 79) and Ruff come back clean.

Mutants, each under a 1.5 GiB cap with Hypothesis's explain phase off, after an unmutated control:

  • The builder's 50 at da7a59aa: 46 fail a test. New tests pin the other four.
  • 45 more of mine at 5e192802: 43 fail a test. New tests pin the other two.
  • The rerun at a94838ca: all of the builder's 50 and those two fail a test. The module hasn't changed since 5e192802, and the tests have only grown, so all 95 stand killed at this head.

Plan

Follow-up for the next design commit

The builder found that §6.1's G bullet cites track_b/gross_benefits.py:1079–1095 for Beneficiary. That class now starts at line 2253.

🤖 Generated with Claude Code

MaxGhenis and others added 4 commits November 6, 2026 06:11
OP2, OP3 and OP4 start side by side from this commit. They meet at one
module: required inputs that name their source and status, the annual
controls OP3's reader emits and OP4's law consumes, the exit-timing
convention OP3's bridge and OP4's law share, and the roster columns and
stream tags more than one part writes or reads. It also adds the four
named refusals those parts raise (design §8).

No projection reads this module yet, and it joins the reducer's exclusion
list.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
OP4's exit law reads a row's nativity, and build_entrant_schedule already
writes foreign_born on entrants, so conventions.py names that column.

The reachability test never named open_population, so nothing asserted that
the reducer can't reach the package the exclusion list leaves out of its
identity. The test now builds the module set from the package itself, as it
does for graph, so a part's new module gets the check unasked. A second test
fails by name when a module in the package misses the list. The list keeps
exact files, as tests/track_u2/test_u2_isolation.py requires.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The conventions mutants left three survivors at 68df739, and each named a
property no example reached:
- `math.fsum` against `sum`: 3.14's built-in `sum` compensates, so no random
  table told them apart. Just past a tie the exact sum rounds up where a
  compensated total stops.
- the share's coercion to a plain float.
- the bound at the annual probability, which no search reached on this
  platform's `expm1`. A patched `expm1` that rounds one unit high shows the
  bound holding.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
OP2(a) of docs/design/open_population.md: each maternal birth appends a
newborn with its mother, second-parent link or registered reason, sex from
a tagged stream keyed on the mother, the mother's household and weights,
birth order and out-of-domain markers. A GPT-6.1 Sol lane wrote the module and
its tests on invented data; this commit adds the module to the reducer's
exclusion lists.

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

vercel Bot commented Nov 6, 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 1:27pm UTC

Request Review

The reader now counts only the mother's roster year when the state carries
a year column, and a test runs it on the sealed live-roster marital step.
New tests pin the mutants the builder's sweep left alive, and the input
frames, plain NumPy columns, known integer columns, the injected reader, the
allocator after a refusal and the sealed mortality and aging steps.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The extra mutant sweep left these two alive.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
MaxGhenis and others added 2 commits November 29, 2026 07:33
Review shared-r1 found that no test pinned entry_year_probability near
zero: three mutants (log(1 - p) for log1p(-p), shares below 1e-10 read as
zero, and results zeroed for annual risks below 1e-15) passed all 51 tests.

Three regressions now pin it:

- half of an annual risk of 2**-100 is exactly 2**-101;
- a share of 2**-100 of an annual risk of 0.36 stays within one unit in
  the last place of a 200-digit Decimal oracle;
- a certain exit stays certain at shares of 2**-1074, 2**-100, 0.25 and
  1 - 2**-53.

All 56 conventions tests pass, and each of the three mutants now fails.
The implementation is unchanged.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Brings in fe90361, which adds tests to test_conventions.py only.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Review op2a-r1 returned REVISE at a94838c with three major
findings. A Sol fix build (20261129-074116-op2a-fix-r1) wrote this
commit's two files; the session hashed them before committing.

- Exact IDs. read_second_parents read a state row with iloc, which
  mixed int64 and float columns into one float row, so a spouse ID of
  2**53 + 1 came back as 2**53. Each state field is now read from its
  own column, with regressions at 2**53 and 2**53 + 1 for int64 and
  Int64.
- Validation before conversion. _integers checks each scalar before it
  builds a nullable integer. Booleans and strings are refused
  everywhere. Roster person IDs, birth mother IDs, birth orders and
  allocated IDs need integer types. Other integer fields accept finite
  whole floats below 2**53 in magnitude, which convert exactly, since
  engine/steps.py:485-507 can leave them float. Each refusal test checks
  that the allocator has not moved.
- Canonical parentage. append_newborn_packet always runs the canonical
  read_second_parents. An injected reader's link must equal the
  canonical link, it can't suppress one, and it can't add a link where
  the canonical reader finds none. It may pick another registered
  reason when both are unlinked. A malformed result (not a mapping, not
  a pair, or a nonscalar field) gets the named refusal before
  allocation.
- The four mutant gaps the review named now each have a test.

On the host: tests/open_population/test_newborn.py and
test_conventions.py give 249 passed, and the seal module gives 14
passed. Black and Ruff are clean.

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

This branch was successfully deployed

1 active deployment
Preview — e7b09c3d 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