Skip to content

ctc_limiting_tax_liability depends on calculation order for itemizers (no_salt branch reuses the parent's cached values) #9740

Closed

Description

@DTrim99

Summary

ctc_limiting_tax_liability gives different values for itemizing tax units depending on which variables the simulation computed before it. It reads income_tax_before_credits from a no_salt branch. Simulation.get_branch clones the parent simulation, including values it has already computed, when the branch is first created, and reuses that branch afterwards. Two cases follow:

  • Federal tax already computed in the parent: the branch appears to return the cached with-SALT income_tax_before_credits. Setting salt_deduction to 0 has no effect.
  • CTC-limiting liability requested first: the branch computes a fresh no-SALT liability, which is higher for itemizers.

The nonrefundable/refundable CTC split and income_tax follow whichever value was produced first. A baseline and a reform simulation can then disagree for reasons unrelated to the reform.

Code: ctc_limiting_tax_liability.py L14-L28 (the branch was added for #8059), and policyengine-core Simulation.get_branch, which clones the parent and caches the branch by name.

How it showed up

Run the Pennsylvania 50% CTC match contributed reform (gov.contrib.states.pa.ctc.ctc_match) on the Pennsylvania households of the Populace ACS local-area file (populace-us-2024-buildo-acs-local-767312d60-20260923T074941Z), for 2026, with policyengine-us 2.19.0, in two different calculation orders. The variable pa_ctc_match reads ctc_limiting_tax_liability, refundable_ctc, and non_refundable_ctc directly.

Computed first in each simulation Tax units whose federal income_tax changes Weighted federal change Households losing net income
pa_income_tax, then income_tax, then household_net_income 146 +$2.83M 2,878 (76 records, average −$555)
household_net_income 0 $0 0

In the first order, among the 146 tax units:

  • ctc_limiting_tax_liability rises by $3.96M in total, and $2.83M of refundable CTC becomes nonrefundable.
  • income_tax_before_credits, salt_deduction, and tax_unit_itemizes do not change.
  • Only 76 of the 146 receive a match at all.

Example tax unit: it itemizes and has no child under 6, so its match is $0.

Baseline Reform (first order)
income_tax_before_credits $1,645 $1,645
ctc_limiting_tax_liability $1,645 $2,145
Refundable CTC $4,406 $3,906

Net income falls by $500.

A refundable state credit cannot lower net income, so the losers are an artifact of calculation order. In the reform simulation, pa_income_tax pulls ctc_limiting_tax_liability before the parent has computed federal tax, so the branch takes the fresh no-SALT path. The baseline simulation takes the cached path.

Impact

  • Any formula that reads the federal CTC pieces before income_tax is computed can trigger it. That includes state CTC matches and microsimulation scripts that compute state tax first.
  • We have not seen it in the app, which appears to compute household net income first. A dashboard pipeline hit it.
  • Separate from the order problem, the two paths disagree on the rule. The docstring says SALT is excluded on purpose, as a known simplification to break the cycle. The cached path in practice uses the with-SALT liability, which is the statutory limit.

Suggested fix

  • Make the value independent of calculation order. Either create the no_salt branch without the parent's computed values, or explicitly clear its cached income_tax_before_credits (and dependents) after set_input.
  • Decide which liability is intended. salt_deduction now reads state_withheld_income_tax rather than state liability, so check whether the no-SALT workaround is still needed to break refundable_ctc ↔ income_tax dependency cycle surfaces on itemizing branch #8059's cycle.
  • Add a regression test: an itemizing household with children, calculating ctc_limiting_tax_liability first versus income_tax first, asserting equal results.

Found while building the Pennsylvania child tax credit options dashboard; the dashboard pipeline now computes household net income first as a workaround.

🤖 Generated with Claude Code

Activity

  1. DTrim99 commented on Nov 20, 2026

    @DTrim99
    CollaboratorAuthor

    #9741 fixed this (merged 2026-10-06, first released in 2.29.9). ctc_limiting_tax_liability no longer uses a no_salt branch: it limits the credit by the actual liability, SALT included, and comparison branches now go through get_override_branch.

    Checked on main at 390a43b against 1.715.2. The test covers 99 married itemizers with 2-4 children in MT, CA and NY, with $40,000-$90,000 wages, $30,000 mortgage interest and $9,000 property tax, for 2026. It computes the CTC split in four orders: income_tax, household_net_income, ctc_limiting_tax_liability or non_refundable_ctc first.

    Version Households whose ctc_limiting_tax_liability, non_refundable_ctc, refundable_ctc or income_tax depends on the order
    1.715.2 99 of 99
    main (390a43b) 0 of 99 (93 have a binding CTC limit)
    Script
    """Does the CTC split depend on calculation order on this policyengine-us?"""
    import itertools
    from policyengine_us import Simulation
    
    Y = 2026
    ORDERS = {
        "income_tax first": ["income_tax"],
        "household_net_income first": ["household_net_income"],
        "ctc_limiting_tax_liability first": ["ctc_limiting_tax_liability"],
        "non_refundable_ctc first": ["non_refundable_ctc"],
    }
    OUT = ["ctc_limiting_tax_liability", "non_refundable_ctc", "refundable_ctc", "income_tax"]
    
    
    def sit(state, wages, kids, mortgage, property_tax):
        yr = str(Y)
        people = {"head": {"age": {yr: 40}, "employment_income": {yr: wages},
                           "deductible_mortgage_interest": {yr: mortgage},
                           "real_estate_taxes": {yr: property_tax}},
                  "spouse": {"age": {yr: 40}}}
        for i in range(kids):
            people[f"k{i}"] = {"age": {yr: 5 + i}}
        m = list(people)
        return {"people": people, "families": {"f": {"members": m}},
                "marital_units": {"mu": {"members": ["head", "spouse"]}},
                "tax_units": {"t": {"members": m}}, "spm_units": {"s": {"members": m}},
                "households": {"h": {"members": m, "state_name": {yr: state}}}}
    
    bad = 0
    for state, wages, kids in itertools.product(["MT", "CA", "NY"], range(40_000, 90_001, 5_000), [2, 3, 4]):
        s = sit(state, wages, kids, 30_000, 9_000)
        results = {}
        for name, first in ORDERS.items():
            sim = Simulation(situation=s)
            for v in first:
                sim.calculate(v, Y)
            results[name] = tuple(round(float(sim.calculate(v, Y).sum()), 2) for v in OUT)
        if len(set(results.values())) > 1:
            bad += 1
            print(state, wages, kids, results)
    print("households with order-dependent results:", bad)

    Closing as fixed by #9741.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions