Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
The ACS local lane no longer counts a respondent's partnership income twice (microcosm#1387). ACS SEMP already includes income from one's own partnership, and the 2024 ACS form tells respondents to report jointly received income wholly under one person, yet the transfer drew the PUF donor's nonpassive `partnership_income` onto those rows. A new keyword-only `semp_covers_partnership_income` on `transfer_acs_inputs`, `acs_transfer_execution_contract_identity` and `build_optional_acs_multispine` (off by default; only the legacy ACS base builder turns it on) keeps a newly drawn `partnership_income` at zero on rows with a finite nonzero SEMP, on tax-unit heads and spouses whose head or spouse reports one, and on rows with blank SEMP, before the passive partnership/S-corp subset is reconciled to line 32. `s_corp_income` is kept: ACS counts incorporated owners as wage workers. The rule refuses, before any fit, a plan that transfers `partnership_income` without `s_corp_income`, a recipient without `SEMP`, `person_tax_unit_id` or `tax_unit_role_input`, a `SEMP` value that is not a number, a recipient whose persons aged 15 or over all have blank `SEMP` (an extract that lost it), and a tax-unit role outside HEAD/SPOUSE/DEPENDENT, including non-ASCII lookalikes and undecodable bytes. An imputation mask that is not a boolean array on the person rows is refused. The partnership provenance record carries a receipt: per row set, the cells kept at zero, the nonzero draws discarded, and the discarded draws in whole dollars, unweighted and weighted by ACS household design weights; the count of persons aged 15 or over with blank `SEMP` and under 15 with a finite one; and the passive draws left on discarded rows whose S-corp income is nonzero, which the gate cannot see. Off the flag every contract payload and draw is unchanged; the US spec-engine attestation pins move because `acs_transfer.py` is an attested kernel module. The `acs_self_employment_identity` gate now also requires `partnership_income` to be zero on those three row sets, the passive subset to be zero wherever the person's or tax unit's line 32 is zero, finite line-32 values, numeric `SEMP` and well-formed tax-unit roles, and it needs the line-32, tax-unit and role columns. A blank `partnership_income` on those rows fails as an unmodeled cell, apart from the double-count clauses, and the gate records `SEMP` against the income universe's age. The release tool names a rebuild only when a failure is a double count. The gate is not behind the flag, so ACS local staging and calibrated checkpoints built before this fix fail materialize, consumer export and package and must be rebuilt.
16 changes: 8 additions & 8 deletions docs/evidence/spec-engine/us-f0-coverage.json
Original file line number Diff line number Diff line change
Expand Up @@ -1642,13 +1642,13 @@
"compiler_ir.node_slices"
],
"expected": {
"map_sha256": "8d0542f7b83f030772e6e53b5742d0f13bcad82325a4e9b66d5d999a3fbb5276",
"protocol_sha256": "3ab23e82779263dabe8da210de55ce7f12fdc0464e8145ca2c18649426b7f976"
"map_sha256": "f3a295ea68b894d4f4e38d13edb9aeb3313138f394d9ff67e4dfdb22f4b63f71",
"protocol_sha256": "05b0bc3cb82fdfe6919efb09b15e800206425a0d041336f50818b2da277aea78"
},
"failures": [],
"observed": {
"map_sha256": "8d0542f7b83f030772e6e53b5742d0f13bcad82325a4e9b66d5d999a3fbb5276",
"protocol_sha256": "3ab23e82779263dabe8da210de55ce7f12fdc0464e8145ca2c18649426b7f976"
"map_sha256": "f3a295ea68b894d4f4e38d13edb9aeb3313138f394d9ff67e4dfdb22f4b63f71",
"protocol_sha256": "05b0bc3cb82fdfe6919efb09b15e800206425a0d041336f50818b2da277aea78"
},
"status": "covered"
},
Expand All @@ -1663,7 +1663,7 @@
"compiler_ir.seed_stream_map"
],
"expected": {
"implementation_sha256": "3ab23e82779263dabe8da210de55ce7f12fdc0464e8145ca2c18649426b7f976",
"implementation_sha256": "05b0bc3cb82fdfe6919efb09b15e800206425a0d041336f50818b2da277aea78",
"protocol": "legacy-v1",
"streams": [
"build_model",
Expand All @@ -1684,7 +1684,7 @@
},
"failures": [],
"observed": {
"implementation_sha256": "3ab23e82779263dabe8da210de55ce7f12fdc0464e8145ca2c18649426b7f976",
"implementation_sha256": "05b0bc3cb82fdfe6919efb09b15e800206425a0d041336f50818b2da277aea78",
"protocol": "legacy-v1",
"streams": [
"build_model",
Expand Down Expand Up @@ -2585,7 +2585,7 @@
"country": "us",
"schema_id": "country_spec",
"schema_version": 1,
"spec_sha256": "fa75bd68f579fd7fb0dd0eed955c867415c251f11fc34087bbc24ae3a77a2a49"
"spec_sha256": "2171077615ae07dd8d079fbf3a110aa67b561a5d58048defdb09c4051659d6f0"
}
},
"report_schema_version": 3,
Expand All @@ -2595,7 +2595,7 @@
"country": "us",
"schema_id": "country_spec",
"schema_version": 1,
"spec_sha256": "fa75bd68f579fd7fb0dd0eed955c867415c251f11fc34087bbc24ae3a77a2a49"
"spec_sha256": "2171077615ae07dd8d079fbf3a110aa67b561a5d58048defdb09c4051659d6f0"
},
"status": "pass"
}
Original file line number Diff line number Diff line change
Expand Up @@ -392,8 +392,11 @@
# microcosm#1096 moves both again: solve's opt-in softmax mass
# parametrization projects exactly onto the capped simplex; the default
# projection parametrization is unchanged.
"seed_map": "8d0542f7b83f030772e6e53b5742d0f13bcad82325a4e9b66d5d999a3fbb5276",
"seed_protocol": "3ab23e82779263dabe8da210de55ce7f12fdc0464e8145ca2c18649426b7f976",
# microcosm#1387 moves both again: the ACS transfer's opt-in SEMP-covered
# partnership step changes acs_transfer's attested bytes. Off its flag no
# draw, RNG rule or QRF target changes.
"seed_map": "f3a295ea68b894d4f4e38d13edb9aeb3313138f394d9ff67e4dfdb22f4b63f71",
"seed_protocol": "05b0bc3cb82fdfe6919efb09b15e800206425a0d041336f50818b2da277aea78",
"source_manifest": "dc3879886d2a69f20fb982a675d7fb322c0e4017afef6471be54b0ee3cbd2af6",
"take_up": "9522ce40f7dea569312dd7a7beb474e5a5afadd2f1e10cb5876534c3ef623d35",
"tail": "565f0ceeadab69d3e96a886a00dd0305f7425fa3acde24d12ba48db2b37d5fc0",
Expand Down
167 changes: 165 additions & 2 deletions packages/microcosm-build/src/microcosm/build/us_runtime/acs_inputs.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@
)
from microcosm.build.us_runtime.acs_transfer import (
ACS_SELF_EMPLOYMENT_COMPONENT_INPUTS,
ACS_TAX_UNIT_ROLES,
acs_semp_age_counts,
acs_semp_values,
acs_tax_unit_head_or_spouse,
)
from microcosm.build.us_runtime.spm_role_source import (
NATIVE_SPM_ROLE,
Expand Down Expand Up @@ -671,6 +675,16 @@ def without_acs_group_quarters_children(
for column in ACS_SELF_EMPLOYMENT_COMPONENT_INPUTS
if column not in _SEMP_ROUTED_LEAVES
)
#: microcosm#1387: the line-32 leaves and the passive subset the gate grades,
#: and the tax-unit columns its spouse clause reads. ACS SEMP includes
#: own-partnership income but not S-corp profit, so only partnership_income
#: must be zero where SEMP accounts for it.
_PARTNERSHIP = "partnership_income"
_S_CORP = "s_corp_income"
_PASSIVE = "passive_partnership_s_corp_income"
_TAX_UNIT = "person_tax_unit_id"
_TAX_UNIT_ROLE = "tax_unit_role_input"
_LINE_32_GATE_COLUMNS = (_PARTNERSHIP, _S_CORP, _PASSIVE, _TAX_UNIT, _TAX_UNIT_ROLE)


def acs_self_employment_identity_gate(
Expand All @@ -695,6 +709,32 @@ def acs_self_employment_identity_gate(
or infinite leaf or ``ADJINC`` on a row that reports SEMP fails, because
the identity cannot be checked there, and so does an infinite SEMP,
which is not a blank.

The gate also grades the line-32 leaves (microcosm#1387). ACS SEMP
includes own-partnership income, so ``partnership_income`` must be
exactly zero on a row that reports a finite nonzero SEMP, on a tax-unit
HEAD or SPOUSE row when a HEAD or SPOUSE of the same tax unit reports one
(the form puts jointly received income under one person), and on a row
with blank SEMP. ``s_corp_income`` is not constrained: ACS counts
incorporated owners as wage workers. The passive subset must be zero
wherever the person's or the tax unit's line 32 (partnership plus S-corp
income) is zero, and an infinite line-32 or passive value fails. A
tax-unit role outside HEAD/SPOUSE/DEPENDENT, or a missing role on a row
with a tax unit, fails rather than exempting its unit. A blank
``partnership_income`` on one of those rows fails on its own, as an
unmodeled cell rather than a double count. Every column the gate reads
must be present; none is read as zero.

``SEMP`` must be a number or blank: a value that does not parse fails
rather than being read as blank. With an ``age`` column, the gate
records how many persons aged 15 or over have blank SEMP and how many
under 15 have a finite one (real PUMS has neither: SEMP is asked from
age 15), and fails when every person aged 15 or over has blank SEMP,
which means the extract lost it. Tax units are grouped within the
selected rows, so select whole tax units. The gate cannot see passive
income left on a row whose partnership draw the transfer discarded while
its S-corp income is nonzero; the transfer's receipt measures that
(``passive_kept_on_discarded_rows``).
"""

name = "acs_self_employment_identity"
Expand All @@ -703,7 +743,12 @@ def acs_self_employment_identity_gate(
raise ValueError("rows must be a one-dimensional mask aligned to person.")
missing = [
column
for column in ("SEMP", "ADJINC", *_SELF_EMPLOYMENT_LEAVES)
for column in (
"SEMP",
"ADJINC",
*_SELF_EMPLOYMENT_LEAVES,
*_LINE_32_GATE_COLUMNS,
)
if column not in person.columns
]
if missing:
Expand All @@ -724,7 +769,8 @@ def numeric(column: str) -> np.ndarray:
dtype=np.float64, na_value=np.nan
)

semp = numeric("SEMP")
semp, non_numeric_semp = acs_semp_values(subset["SEMP"])
semp_age = acs_semp_age_counts(subset, semp)
adjinc = numeric("ADJINC")
leaves = np.column_stack([numeric(column) for column in _SELF_EMPLOYMENT_LEAVES])
reported = np.isfinite(semp)
Expand All @@ -749,6 +795,49 @@ def numeric(column: str) -> np.ndarray:
[filled[:, position[column]] != 0.0 for column in _SEMP_ROUTED_LEAVES]
).all(axis=1)

# microcosm#1387: partnership income that SEMP already accounts for.
partnership = numeric(_PARTNERSHIP)
s_corp = numeric(_S_CORP)
passive = numeric(_PASSIVE)
# A blank cell is unmodeled and an infinite one is not a dollar amount;
# each fails on its own below, not as a double count.
partnership_blank = np.isnan(partnership)
partnership_nonzero = np.isfinite(partnership) & (partnership != 0.0)
own_semp = np.isfinite(semp) & (semp != 0.0)
units = subset[_TAX_UNIT]
head_or_spouse, malformed_role = acs_tax_unit_head_or_spouse(
subset[_TAX_UNIT_ROLE], units
)
unit_reports = (
pd.Series(own_semp & head_or_spouse, index=subset.index)
.groupby(units, sort=False)
.transform("any")
.astype("boolean")
.fillna(False)
.to_numpy(dtype=bool)
)
covered_spouse = head_or_spouse & unit_reports & ~own_semp & ~blank_semp
partnership_on_semp = own_semp & partnership_nonzero
partnership_on_spouse = covered_spouse & partnership_nonzero
partnership_on_blank = blank_semp & partnership_nonzero
partnership_blank_on_covered = partnership_blank & (
own_semp | covered_spouse | blank_semp
)
line_32_values = np.column_stack([partnership, s_corp, passive])
infinite_line_32 = np.isinf(line_32_values).any(axis=1)
# Infinite inputs fail on their own clause; inf minus inf is NaN here.
with np.errstate(invalid="ignore"):
person_line_32 = pd.Series(
np.where(np.isnan(partnership), 0.0, partnership)
+ np.where(np.isnan(s_corp), 0.0, s_corp),
index=subset.index,
)
unit_line_32 = person_line_32.groupby(units, sort=False).transform("sum")
no_line_32 = (person_line_32 == 0.0).to_numpy() | (unit_line_32 == 0.0).to_numpy(
dtype=bool, na_value=False
)
passive_without_line_32 = no_line_32 & np.isfinite(passive) & (passive != 0.0)

failures: list[str] = []
if not selected.any():
failures.append("No ACS person rows were selected for the check.")
Expand Down Expand Up @@ -777,6 +866,63 @@ def numeric(column: str) -> np.ndarray:
"carry both base and SSTB self-employment; QBI reconciliation "
"routes SEMP wholly to one of them."
)
if partnership_on_semp.any():
failures.append(
f"{int(partnership_on_semp.sum())} ACS person row(s) reporting a "
"nonzero SEMP carry nonzero partnership_income; ACS SEMP already "
"includes own-partnership income."
)
if partnership_on_spouse.any():
failures.append(
f"{int(partnership_on_spouse.sum())} ACS tax-unit head or spouse "
"row(s) carry nonzero partnership_income while their tax unit's "
"head or spouse reports a nonzero SEMP, which may hold the couple's "
"jointly received partnership income."
)
if partnership_on_blank.any():
failures.append(
f"{int(partnership_on_blank.sum())} ACS person row(s) with blank "
"SEMP carry nonzero partnership_income."
)
if partnership_blank_on_covered.any():
failures.append(
f"{int(partnership_blank_on_covered.sum())} ACS person row(s) where "
"SEMP covers partnership income have a blank partnership_income; "
"the cell was never modeled."
)
if non_numeric_semp.any():
failures.append(
f"{int(non_numeric_semp.sum())} ACS person row(s) have a SEMP that "
"is not a number."
)
if (
semp_age is not None
and semp_age["persons_aged_15_plus"] > 0
and semp_age["blank_semp_age_15_plus_rows"] == semp_age["persons_aged_15_plus"]
):
failures.append(
"SEMP is blank on every one of the "
f"{semp_age['persons_aged_15_plus']} ACS person row(s) aged 15 or "
"over; the extract has lost SEMP."
)
if passive_without_line_32.any():
failures.append(
f"{int(passive_without_line_32.sum())} ACS person row(s) carry "
"passive_partnership_s_corp_income where the person's or the tax "
"unit's partnership plus S-corp income is zero."
)
if malformed_role.any():
failures.append(
f"{int(malformed_role.sum())} ACS person row(s) have a "
f"tax_unit_role_input outside {list(ACS_TAX_UNIT_ROLES)}, or none "
"while in a tax unit, so their tax unit's partnership check "
"cannot run."
)
if infinite_line_32.any():
failures.append(
f"{int(infinite_line_32.sum())} ACS person row(s) have an infinite "
"partnership, S-corp or passive partnership/S-corp income."
)
if infinite_semp.any():
failures.append(
f"{int(infinite_semp.sum())} ACS person row(s) have an infinite SEMP."
Expand Down Expand Up @@ -809,6 +955,23 @@ def numeric(column: str) -> np.ndarray:
"infinite_semp_rows": int(infinite_semp.sum()),
"nonfinite_leaf_rows": int(nonfinite_leaf.sum()),
"nonfinite_adjinc_rows": int(nonfinite_adjinc.sum()),
"partnership_on_semp_rows": int(partnership_on_semp.sum()),
"partnership_on_positive_semp_rows": int(
(partnership_on_semp & (semp > 0.0)).sum()
),
"partnership_on_negative_semp_rows": int(
(partnership_on_semp & (semp < 0.0)).sum()
),
"partnership_on_spouse_rows": int(partnership_on_spouse.sum()),
"partnership_on_blank_semp_rows": int(partnership_on_blank.sum()),
"partnership_blank_on_covered_rows": int(
partnership_blank_on_covered.sum()
),
"non_numeric_semp_rows": int(non_numeric_semp.sum()),
"semp_age": semp_age,
"passive_without_line_32_rows": int(passive_without_line_32.sum()),
"infinite_line_32_rows": int(infinite_line_32.sum()),
"malformed_tax_unit_role_rows": int(malformed_role.sum()),
"nonzero_rows_by_leaf": {
column: int((filled[:, index] != 0.0).sum())
for index, column in enumerate(_SELF_EMPLOYMENT_LEAVES)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ def build_optional_acs_multispine(
work_disability_inputs: bool = False,
income_transfer: bool = False,
native_receipt_anchors: bool = False,
semp_covers_partnership_income: bool = False,
donor_spine: str = ASEC_PUF_DONOR_SPINE,
donor_channel: str | None = ACS_DONOR_CHANNEL_AUTO,
seed: int = 0,
Expand Down Expand Up @@ -164,6 +165,13 @@ def build_optional_acs_multispine(
public-assistance counts it records against ``receives_tanf``) is
``provenance["acs_local_receipt_anchors"]``. The source is checked before
any fit.
``semp_covers_partnership_income`` (the ACS local lane, microcosm#1387)
tells the shared transfer that ACS ``SEMP`` already includes
own-partnership income, so a ``partnership_income`` draw is kept at zero
where the row's or its tax unit's SEMP accounts for it (see
:func:`~microcosm.build.us_runtime.acs_transfer.keep_semp_covered_partnership_income`).
Only the shared call receives it; the hours and income passes do not
draw ``partnership_income``.

Large intermediate frames are released as soon as the next stage has
materialized its own frame. This cannot make the final dense pool small,
Expand Down Expand Up @@ -363,6 +371,11 @@ def build_optional_acs_multispine(
seed=seed,
n_estimators=n_estimators,
max_targets_per_fit=max_targets_per_fit,
**(
{"semp_covers_partnership_income": True}
if semp_covers_partnership_income
else {}
),
)
del mapped_frame
adult_care_gate = _require_recipient_adult_care_structure(transferred.frame)
Expand Down
Loading
Loading