Skip to content

Preserve supplied marital units and infer missing explicit couples - #10000

Draft
hua7450 wants to merge 2 commits into
PolicyEngine:mainfrom
hua7450:preserve-marital-unit-inputs
Draft

hua7450 wants to merge 2 commits into
PolicyEngine:mainfrom
hua7450:preserve-marital-unit-inputs

Conversation

@hua7450

@hua7450 hua7450 commented Oct 7, 2026 •

Copy link
Copy Markdown
Collaborator

Behavior

Fixes #9999 and addresses #9868. When a caller supplies separate marital units for a parent and adult child, the child no longer becomes an inferred tax-unit spouse. When a household omits marital units, an explicit head/spouse pair forms one unit and other people get singleton units, so their SSI marital income is not pooled with the couple.

  • Preserve explicit household marital mappings, including empty mappings and singletons, and all dataset membership IDs. Microcosm's marital structure passes through unchanged; no data rebuild or Microcosm code change is included.
  • Infer missing household pairs only from unambiguous explicit is_tax_unit_head / is_tax_unit_spouse inputs within the same tax unit and household. Their true inputs must share a period. Conflicting dependent inputs or changing pair roles require explicit membership; separated pairs are left unpaired. Age and calculated tax roles never construct marriages.
  • Restrict tax-spouse inference to the head's marital unit only when membership was supplied. Core provenance distinguishes supplied groups from generated defaults. Direct role inputs keep their normal precedence; the existing age/dependent/separation fallback remains when marital membership is absent.
  • Share the construction rule between the Python API and YAML runner through the core hook. Supplied couples may span separate tax units without acquiring a tax-unit spouse.

Draft dependencies and scope

Validation

  • 117 tax-unit YAML cases pass (29 files, one bounded batch).
  • SSI YAML suite: 167 cases pass in two sequential batches; the subsequently added multiple-couple case also passes (all seven cases in its variable-named file), for 168 unique SSI cases covered.
  • 16 Python tests pass: the existing tax-role inference invariants plus nine new construction/data-contract cases. These cover caller isolation, axis expansion, clone provenance, explicit versus missing groups, ambiguous/changing role inputs, and a six-person dataset whose zero/nonsequential marital IDs survive loading and year extension.
  • make format and git diff --check pass.

Policy calculations are tested in variable-named YAML files. The new Python module covers construction and dataset contracts unavailable to YAML, and runs in the existing Microsimulation job; no runner or parallel heavy process is added. Local macOS timing including imports, using the existing six dataset-copy tests as a control: 10.81 seconds / 925,057,024 bytes peak RSS before adding the nine new tests, 11.07 seconds / 841,220,096 bytes after. The lower RSS is run-to-run variation, not a claimed memory improvement. Linux CI resource reports were not downloaded; these small-fixture measurements do not certify the full runner's peak.

axiom: n/a: supplied relationship preservation and simulation entity construction, not a change to a legal provision.

This branch has not been deployed

No deployments
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.

Preserve supplied marital units and infer missing units from explicit relationships

1 participant