Skip to content

Settle and apply the NZ dependent-child benefit-unit rule (G8-u) - #1226

Merged
MaxGhenis merged 7 commits into
mainfrom
nzhub/g8u-unit-rule
Oct 13, 2026
Merged

MaxGhenis merged 7 commits into
mainfrom
nzhub/g8u-unit-rule

Conversation

@MaxGhenis

@MaxGhenis MaxGhenis commented Oct 12, 2026 •

Copy link
Copy Markdown
Contributor

Settles the NZ dependent-child rule for benefit units (method card MC7) and makes unit construction apply it. This is package G8-u of #1183.

build/nz/benefit_unit_rule.json had age_limit_years: null in an "UNVERIFIED proposal", and transport/compose.py refuses a null limit. So no NZ benefit unit could be built on real data.

The rule, from the Social Security Act 2018 Schedule 2 (as at 1 April 2026)

The hub read the statute and settled the open cases; that is item B8 of the G8 method addendum. The spec now declares:

  • "Child": single and under 18 (exclusive age limit 18), except a 16- or 17-year-old who is financially independent.
  • Financially independent by work: a 16- or 17-year-old whose donor record shows at least 30 hours a week ("full employment") forms their own unit. Hours come from the donor's usual weekly hours, carried as the usual_weekly_hours concept (benefit_unit_rule.json:47).
  • Teen parents:
    • A 16- or 17-year-old with a co-resident child of their own forms their own unit with that child.
    • A parent under 16 stays a dependent child in their own parent's unit, and their child joins that same unit.
    • These branches decide the teen parent's own dependency. When the child's two co-resident parents end up in separate units, the child follows the declared parent-1 placement.
  • Two co-resident parents who are not partners: the child joins parent 1's unit (unchanged, :119).
  • A child with no co-resident parent: joins the household reference person's unit. Construction refuses when that person is themselves a dependent child (:64).

Disclosed, not applied (:59, :124):

  • Donor hours in worked weeks only approximate the statutory average; contracts and the averaging period aren't observed.
  • These limbs aren't observable and are not applied: student allowance and analogous schemes, other main-benefit receipt, contractual full-time exceptions, and orphan's or unsupported child's benefit receipt.
  • Single status (Sch 2 DLM6784713/DLM6784537, s 8) is approximated by the co-resident partner pointer. A young person whose spouse or partner lives elsewhere is treated as single and can be a dependent child. Legal marital status isn't recovered by the donor decoder, and MSD's section 8 determinations aren't observable (412d4a7).
  • Teen parenthood is inferred from co-resident child pointers.

Every number lives in the spec. The shared code reads it and stays country-neutral (transport/cli.py:266, column_kernels.py:134, population_kernels.py:225 share one spec parser).

Code

microcosm/frame/unit_construction.py:

  • parses the cited country declarations and keeps serialized-rule compatibility (:380);
  • reads the teen-parent age (:775) and the employment threshold (:785);
  • follows dependent-parent chains and refuses dependent reference caregivers (:820);
  • reports diagnostics (:609): 16–17-year-olds made independent by hours, teen parents in each branch, non-partnered co-parent households, and children placed with the reference person.

The CREATE receipt carries those counts (population_kernels.py:289).

Invariants (tested as Hypothesis properties over random households, test_transport_dependent_children.py:352, :437)

  • Every person is in exactly one unit.
  • Every unit has an adult head.
  • Partners share a unit.
  • Units nest within households.
  • Inherited family weights sum correctly.
  • The result doesn't depend on row order.

Tests

Hub re-run at this head, one file per run:

File Result
test_transport_dependent_children.py (new) 24 passed
test_unit_construction.py 43 passed
test_units.py 26 passed
test_transport_graph.py 15 passed
test_nz_spec_package.py 72 passed
test_country_spec.py 135 passed

The new file has a fixture for each case:

  • a 17-year-old working 35 hours, and one working 20;
  • a 16-year-old parent and a 15-year-old parent, each with a baby;
  • two non-partnered co-resident parents;
  • a child living only with a grandparent;
  • a dependent-child reference person, which is refused.

It also has boundary cases, spec-variation witnesses and round-trips. The lane also ran the CREATE and column integration tests (2 + 2), the concept tests (26 + 26) and the unit-construction compatibility test (24).

Mutants, each failing a named test with a passing control:

  • age limit 19 → test_eighteen_year_old_is_an_adult_even_without_work;
  • hours limb ignored → test_seventeen_year_old_hours_determine_independence[35-hours];
  • teen parents left dependent → test_teen_parent_and_baby_join_the_declared_unit[age16];
  • parentless child left unassigned → test_child_without_parent_joins_grandparent_reference_person;
  • hours threshold hard-coded → test_hours_threshold_is_read_from_spec[threshold10].

Also run: ruff check ., tools/ci_test_plan.py verify and git diff --check, all passing. At the current head 4cd53ce (main merged, including #1219), the CI plan verifies 682 files.

The NZ golden country spec is regenerated (ef0be9a). Only the benefit_unit_rule.json resource hash and the spec fingerprint change, and the new hash equals the committed file's sha256.

How it was built

  • A GPT-6.1 Sol lane wrote the spec, code and tests (f58fcbd).
  • The hub reports that a machine restart at 11:42Z cut the run and that it resumed from its worktree. No tracked record proves this; the test results above were re-run at this branch by the hub and by the reviewer.
  • The hub re-ran the two suites the restart interrupted and regenerated the golden.
  • 5488d5e dropped the settled age from _GAPS in test_transport_composed_graph.py, which CI had flagged. 951091c and 4cd53ce merged main and regenerated the golden.

Review

  • r1, 20261012-184520 (GPT-6.1 Sol) at 951091c: APPROVE_WITH_NITS.
    • It found no correctness, safety or honesty defect.
    • It confirmed against the PCO XML (2026-04-01): age 18 exclusive, 16/17 financial independence, the 30-hour threshold, and every cited identifier.
    • 898 baseline tests passed. Mutants for all six invariant classes, and all five named mutants, failed as expected. 1,000 old-rule comparisons matched main.
  • Its three P3 nits are applied:
    • the single-status proxy disclosure in the spec;
    • the reference-person docstring;
    • evidence refreshed here (682-file CI plan at this head, attributed history labelled).
  • Its "Needs Max" flag was for publishing a settled statutory method in the public spec. The hub judged no: the NZ package is inactive and publishes no number, the statutory parts are verified, the placements are disclosed modelling conventions, and the spec is reversible data.
  • r2, 20261012-212506 (GPT-6.1 Sol), delta at 4cd53ce: APPROVE_WITH_NITS.
    • 231 tests passed and 6/6 mutation guards failed as expected. The single-status disclosure matches the code.
    • Its two P3 nits are applied in ce7b8fc:
      • the teen-parent wording is qualified with the parent-1 placement;
      • the spec's two local absolute paths are replaced: the Schedule 2 XML is now cited by its pinned axiom-corpus release (nz-rulespec-2026-07-25), path and sha256 (ce02ac72…), and the B8 settlement by the new in-repo docs/nz-benefit-unit-rule.md.
    • The NZ golden is regenerated (benefit_unit_rule hash and fingerprint only). Tests: dependent_children 24, nz_spec 72, country_spec 135; the CI plan verifies.
    • Its Needs Max flag is the same as r1's and is judged no for the same reasons.

🤖 Generated with Claude Code

MaxGhenis and others added 2 commits October 12, 2026 09:52
Declare the cited age, employment and teen-parent rules in the country spec.
Apply them through shared unit construction, resolve dependent-parent chains,
refuse dependent reference caregivers, and report CREATE placement counts.
Add engine-free fixtures, randomized invariants and spec-variation witnesses.

Co-Authored-By: GPT-6.1 Sol <noreply@openai.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Only the benefit_unit_rule.json resource hash and the spec fingerprint
change; the new hash equals sha256 of the committed rule file.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
MaxGhenis and others added 2 commits October 12, 2026 12:09
The packaged NZ spec now declares age_limit_years 18, so activation no
longer names it as a gap; assert that it stays settled.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
# Conflicts:
#	packages/microcosm-build/tests/golden/nz_country_spec.json
MaxGhenis and others added 3 commits October 12, 2026 21:24
The settled NZ unit rule approximates statutory single status (Sch 2
DLM6784713, DLM6784537; s 8) by the co-resident partner pointer, so a
young person whose spouse or partner lives elsewhere is treated as single.
Disclose that, and MSD's unobserved section 8 determinations, beside the
other unapplied limbs. The UnparentedChildPlacement docstring now describes
the strict reference rule. NZ golden regenerated for the resource hash.

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

The spec pointed at local absolute paths for the Schedule 2 XML and the
settlement note. It now cites the pinned axiom-corpus release, file path
and sha256, and a new docs/nz-benefit-unit-rule.md records the B8
settlement. The teen-parent branches now say they decide the teen's own
dependency; a child of parents in separate units follows parent 1.
NZ golden regenerated for the resource hash.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@MaxGhenis
MaxGhenis marked this pull request as ready for review October 13, 2026 03:16
@MaxGhenis
MaxGhenis merged commit 001814f into main Oct 13, 2026
@MaxGhenis

Copy link
Copy Markdown
Contributor Author

Merged by the NZ hub (session local_e407a527) at ce7b8fc with --squash. Gates: gh pr checks exit 0; MERGEABLE; not draft; no CHANGES_REQUESTED review. Reviewed head: ce7b8fc. Reviews (GPT-6.1 Sol): r1 20261012-184520 APPROVE_WITH_NITS at 951091c (statute verified against the 2026-04-01 PCO XML; 898 tests; all mutants); its nits applied in 412d4a7. r2 20261012-212506 APPROVE_WITH_NITS at 4cd53ce (231 tests; 6/6 mutation guards); its two P3 nits applied in ce7b8fc (teen-parent wording; local paths replaced by the pinned corpus release + sha256 and docs/nz-benefit-unit-rule.md; golden regenerated). ce7b8fc changes only spec text, a new doc and the golden hash; hub re-ran dependent_children 24, nz_spec 72, country_spec 135. Both reviews' 'Needs Max' flags (publishing a settled statutory method in the public spec) judged no by the hub: the NZ package is inactive and publishes no number, statute verified, placements disclosed, reversible spec data.

@MaxGhenis

Copy link
Copy Markdown
Contributor Author

Hub note: this merged at ce7b8fc before CI had registered checks for that commit. The hub's land script treated "no checks reported" right after the push as a repo with no CI, which was a script bug and is now fixed. ce7b8fc changed only spec text (citations and teen-parent wording), added docs/nz-benefit-unit-rule.md and regenerated the golden hash. The hub ran dependent_children (24), nz_spec (72) and country_spec (135) locally, and the previous head 4cd53ce was green apart from one pending engine-us job. Main's CI on the merge commit 001814f is being watched; any failure gets an immediate fix-forward PR.

@MaxGhenis

Copy link
Copy Markdown
Contributor Author

Follow-up to the note above: main's CI on the merge commit 001814f is fully green. All 10 checks passed: engine-free, engine-uk and engine-us on 3.13 and 3.14, integration-uk, lint, select-countries and wheels. No fix-forward needed.

@MaxGhenis
MaxGhenis deleted the nzhub/g8u-unit-rule branch October 13, 2026 06:50
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