FAILURE MAP
← Case archive

FA-58921 / Payroll withholding rules / Open access

W-4 step adjustment withholding: step 2 bracket scaling · case 01

Married and head-of-household employees who check step 2 are under-withheld.

Verified by executionVariant 1 · 9 checks per implementationDownload source bundle ↓JSON ↗

ROOT CAUSE

The halved bracket thresholds for step 2 are applied only to single filers.

VERIFIED REPAIR

Restore the contract rule at the step 2 bracket scaling step: use `div = 4 if x['step2'] else 2`.

Unsuccessful approach: The attempt extends the halving to head of household but still exempts married filers.

Case contract

Input {wage, periods, status single|mfj|hoh, step2, credits, other_income, deductions, extra}; annual amounts in cents except wage and extra (per period). Annual = wage*periods + other_income. Deduction = base standard (single 8,600, mfj 12,900, hoh 8,600 dollars; halved when step2) + itemized deductions (never halved). Thresholds 7,000/30,000/90,000 dollars at 10/12/22% scaled by status unit (single 2, mfj 4, hoh 3)/2, or /4 when step2. Tentative per-period = annual tax/periods half-up; credits/periods half-up is subtracted, floored at 0, then extra is added.

Why this case matters

Modern W-4 withholding combines annual adjustments with per-period ones, and the order of flooring and adding extra withholding matters.

1 / The failure

Exit 1
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(x):
    p = x['periods']
    annual = x['wage'] * p + x['other_income']
    base_std = {'single': 860000, 'mfj': 1290000, 'hoh': 860000}[x['status']]
    ded = (base_std // 2 if x['step2'] else base_std) + x['deductions']
    taxable = max(0, annual - ded)
    unit = {'single': 2, 'mfj': 4, 'hoh': 3}[x['status']]
    div = 4 if x['step2'] and x['status'] == 'single' else 2
    bounds = [700000 * unit // div, 3000000 * unit // div, 9000000 * unit // div]
    rates = [10, 12, 22]
    tax = 0
    for i, lo in enumerate(bounds):
        hi = bounds[i + 1] if i + 1 < len(bounds) else taxable
        if taxable > lo:
            tax += (min(taxable, hi) - lo) * rates[i]
    tentative = (tax * 2 + 100 * p) // (200 * p)
    credit_pp = (x['credits'] * 2 + p) // (2 * p)
    wh = max(0, tentative - credit_pp) + x['extra']
    return [tentative, wh]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression', {'wage': 124748, 'periods': 26, 'status': 'mfj', 'step2': True, 'credits': 0, 'other_income': 0, 'deductions': 0, 'extra': 0}, [7302, 7302]), ('regression', {'wage': 69636, 'periods': 24, 'status': 'hoh', 'step2': True, 'credits': 877725, 'other_income': 1721162, 'deductions': 1014955, 'extra': 0}, [5927, 0]), ('partial-repair probe', {'wage': 176, 'periods': 12, 'status': 'mfj', 'step2': True, 'credits': 0, 'other_income': 1390591, 'deductions': 0, 'extra': 0}, [398, 398]), ('partial-repair probe', {'wage': 178354, 'periods': 26, 'status': 'mfj', 'step2': True, 'credits': 0, 'other_income': 0, 'deductions': 112718, 'extra': 0}, [12905, 12905]), ('boundary control', {'wage': 0, 'periods': 26, 'status': 'single', 'step2': False, 'credits': 400000, 'other_income': 0, 'deductions': 0, 'extra': 5000}, [0, 5000]), ('normal control', {'wage': 4942, 'periods': 12, 'status': 'single', 'step2': False, 'credits': 400000, 'other_income': 1831505, 'deductions': 0, 'extra': 8860}, [2757, 8860]), ('normal control', {'wage': 111690, 'periods': 26, 'status': 'mfj', 'step2': False, 'credits': 0, 'other_income': 0, 'deductions': 0, 'extra': 0}, [823, 823]), ('normal control', {'wage': 67447, 'periods': 24, 'status': 'mfj', 'step2': False, 'credits': 400000, 'other_income': 0, 'deductions': 0, 'extra': 2500}, [0, 2500]), ('normal control', {'wage': 1041418, 'periods': 24, 'status': 'hoh', 'step2': False, 'credits': 0, 'other_income': 0, 'deductions': 0, 'extra': 2500}, [156854, 159354])], [('regression', {'wage': 176, 'periods': 12, 'status': 'mfj', 'step2': True, 'credits': 0, 'other_income': 1390591, 'deductions': 0, 'extra': 0}, [398, 398]), ('regression', {'wage': 285367, 'periods': 52, 'status': 'hoh', 'step2': True, 'credits': 0, 'other_income': 0, 'deductions': 1182238, 'extra': 2500}, [41104, 43604]), ('partial-repair probe', {'wage': 178354, 'periods': 26, 'status': 'mfj', 'step2': True, 'credits': 0, 'other_income': 0, 'deductions': 112718, 'extra': 0}, [12905, 12905]), ('partial-repair probe', {'wage': 190399, 'periods': 24, 'status': 'mfj', 'step2': True, 'credits': 200000, 'other_income': 1327070, 'deductions': 0, 'extra': 0}, [20842, 12509]), ('boundary control', {'wage': 0, 'periods': 26, 'status': 'single', 'step2': False, 'credits': 400000, 'other_income': 0, 'deductions': 0, 'extra': 5000}, [0, 5000]), ('normal control', {'wage': 245742, 'periods': 24, 'status': 'single', 'step2': False, 'credits': 0, 'other_income': 0, 'deductions': 0, 'extra': 2500}, [19772, 22272]), ('normal control', {'wage': 196398, 'periods': 12, 'status': 'single', 'step2': False, 'credits': 0, 'other_income': 0, 'deductions': 0, 'extra': 0}, [6640, 6640]), ('normal control', {'wage': 64669, 'periods': 24, 'status': 'single', 'step2': False, 'credits': 0, 'other_income': 0, 'deductions': 0, 'extra': 2500}, [0, 2500]), ('normal control', {'wage': 492438, 'periods': 12, 'status': 'single', 'step2': True, 'credits': 400000, 'other_income': 131536, 'deductions': 0, 'extra': 0}, [59948, 26615])], [('regression', {'wage': 178354, 'periods': 26, 'status': 'mfj', 'step2': True, 'credits': 0, 'other_income': 0, 'deductions': 112718, 'extra': 0}, [12905, 12905]), ('regression', {'wage': 124748, 'periods': 26, 'status': 'mfj', 'step2': True, 'credits': 0, 'other_income': 0, 'deductions': 0, 'extra': 0}, [7302, 7302]), ('partial-repair probe', {'wage': 224276, 'periods': 26, 'status': 'mfj', 'step2': True, 'credits': 400000, 'other_income': 1419837, 'deductions': 0, 'extra': 0}, [25489, 10104]), ('partial-repair probe', {'wage': 876215, 'periods': 26, 'status': 'mfj', 'step2': True, 'credits': 458880, 'other_income': 257651, 'deductions': 0, 'extra': 2500}, [149874, 134725]), ('boundary control', {'wage': 0, 'periods': 26, 'status': 'single', 'step2': False, 'credits': 400000, 'other_income': 0, 'deductions': 0, 'extra': 5000}, [0, 5000]), ('normal control', {'wage': 232685, 'periods': 52, 'status': 'mfj', 'step2': False, 'credits': 200000, 'other_income': 0, 'deductions': 479252, 'extra': 0}, [18839, 14993]), ('normal control', {'wage': 79014, 'periods': 24, 'status': 'mfj', 'step2': False, 'credits': 400000, 'other_income': 1864011, 'deductions': 0, 'extra': 0}, [4460, 0]), ('normal control', {'wage': 322003, 'periods': 12, 'status': 'single', 'step2': False, 'credits': 0, 'other_income': 0, 'deductions': 0, 'extra': 2500}, [19207, 21707]), ('normal control', {'wage': 93316, 'periods': 12, 'status': 'mfj', 'step2': False, 'credits': 200000, 'other_income': 1111591, 'deductions': 0, 'extra': 1563}, [0, 1563])], [('regression', {'wage': 190399, 'periods': 24, 'status': 'mfj', 'step2': True, 'credits': 200000, 'other_income': 1327070, 'deductions': 0, 'extra': 0}, [20842, 12509]), ('regression', {'wage': 90292, 'periods': 52, 'status': 'hoh', 'step2': True, 'credits': 0, 'other_income': 0, 'deductions': 0, 'extra': 2500}, [7968, 10468]), ('partial-repair probe', {'wage': 72508, 'periods': 12, 'status': 'mfj', 'step2': True, 'credits': 0, 'other_income': 629389, 'deductions': 0, 'extra': 3100}, [1287, 4387]), ('partial-repair probe', {'wage': 1074758, 'periods': 52, 'status': 'mfj', 'step2': True, 'credits': 104962, 'other_income': 0, 'deductions': 0, 'extra': 2500}, [213910, 214391]), ('boundary control', {'wage': 0, 'periods': 26, 'status': 'single', 'step2': False, 'credits': 400000, 'other_income': 0, 'deductions': 0, 'extra': 5000}, [0, 5000]), ('normal control', {'wage': 37313, 'periods': 52, 'status': 'mfj', 'step2': False, 'credits': 117737, 'other_income': 1320234, 'deductions': 0, 'extra': 5664}, [1097, 5664]), ('normal control', {'wage': 179669, 'periods': 52, 'status': 'single', 'step2': False, 'credits': 0, 'other_income': 0, 'deductions': 0, 'extra': 0}, [17076, 17076]), ('normal control', {'wage': 170108, 'periods': 12, 'status': 'single', 'step2': True, 'credits': 200000, 'other_income': 167672, 'deductions': 0, 'extra': 0}, [12373, 0]), ('normal control', {'wage': 244499, 'periods': 26, 'status': 'hoh', 'step2': False, 'credits': 305778, 'other_income': 170107, 'deductions': 0, 'extra': 0}, [18656, 6895])], [('regression', {'wage': 224276, 'periods': 26, 'status': 'mfj', 'step2': True, 'credits': 400000, 'other_income': 1419837, 'deductions': 0, 'extra': 0}, [25489, 10104]), ('regression', {'wage': 142479, 'periods': 52, 'status': 'hoh', 'step2': True, 'credits': 551126, 'other_income': 0, 'deductions': 0, 'extra': 3806}, [14670, 7877]), ('partial-repair probe', {'wage': 93176, 'periods': 52, 'status': 'mfj', 'step2': True, 'credits': 200000, 'other_income': 0, 'deductions': 310339, 'extra': 0}, [6476, 2630]), ('partial-repair probe', {'wage': 737849, 'periods': 24, 'status': 'mfj', 'step2': True, 'credits': 400000, 'other_income': 0, 'deductions': 0, 'extra': 3155}, [113498, 99986]), ('boundary control', {'wage': 0, 'periods': 26, 'status': 'single', 'step2': False, 'credits': 400000, 'other_income': 0, 'deductions': 0, 'extra': 5000}, [0, 5000]), ('normal control', {'wage': 250357, 'periods': 52, 'status': 'single', 'step2': False, 'credits': 0, 'other_income': 0, 'deductions': 0, 'extra': 2500}, [31632, 34132]), ('normal control', {'wage': 251742, 'periods': 52, 'status': 'hoh', 'step2': False, 'credits': 0, 'other_income': 0, 'deductions': 392790, 'extra': 0}, [23568, 23568]), ('normal control', {'wage': 290758, 'periods': 26, 'status': 'single', 'step2': False, 'credits': 0, 'other_income': 1100573, 'deductions': 944056, 'extra': 0}, [26644, 26644]), ('normal control', {'wage': 76761, 'periods': 52, 'status': 'hoh', 'step2': False, 'credits': 400000, 'other_income': 0, 'deductions': 0, 'extra': 2500}, [4003, 2500])]]
for i, (label, args, expected) in enumerate(fixtures[N-1]):
    check("%s %d" % (label, i), solve(args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)
Boundary fixtureActualExpectedOutcome
regression 0[4609, 4609][7302, 7302]Failed
regression 1[3739, 0][5927, 0]Failed
partial-repair probe 2[0, 0][398, 398]Failed
partial-repair probe 3[9536, 9536][12905, 12905]Failed
boundary control 4[0, 5000][0, 5000]Passed
normal control 5[2757, 8860][2757, 8860]Passed
normal control 6[823, 823][823, 823]Passed
normal control 7[0, 2500][0, 2500]Passed
normal control 8[156854, 159354][156854, 159354]Passed

SHA-256 / 485162085f3db428c0c06f9185d5e03176c9532cd441b09bf8f3fe32a4fd5320

2 / The unsuccessful fix

Exit 1
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(x):
    p = x['periods']
    annual = x['wage'] * p + x['other_income']
    base_std = {'single': 860000, 'mfj': 1290000, 'hoh': 860000}[x['status']]
    ded = (base_std // 2 if x['step2'] else base_std) + x['deductions']
    taxable = max(0, annual - ded)
    unit = {'single': 2, 'mfj': 4, 'hoh': 3}[x['status']]
    div = 4 if x['step2'] and x['status'] != 'mfj' else 2
    bounds = [700000 * unit // div, 3000000 * unit // div, 9000000 * unit // div]
    rates = [10, 12, 22]
    tax = 0
    for i, lo in enumerate(bounds):
        hi = bounds[i + 1] if i + 1 < len(bounds) else taxable
        if taxable > lo:
            tax += (min(taxable, hi) - lo) * rates[i]
    tentative = (tax * 2 + 100 * p) // (200 * p)
    credit_pp = (x['credits'] * 2 + p) // (2 * p)
    wh = max(0, tentative - credit_pp) + x['extra']
    return [tentative, wh]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression', {'wage': 124748, 'periods': 26, 'status': 'mfj', 'step2': True, 'credits': 0, 'other_income': 0, 'deductions': 0, 'extra': 0}, [7302, 7302]), ('regression', {'wage': 69636, 'periods': 24, 'status': 'hoh', 'step2': True, 'credits': 877725, 'other_income': 1721162, 'deductions': 1014955, 'extra': 0}, [5927, 0]), ('partial-repair probe', {'wage': 176, 'periods': 12, 'status': 'mfj', 'step2': True, 'credits': 0, 'other_income': 1390591, 'deductions': 0, 'extra': 0}, [398, 398]), ('partial-repair probe', {'wage': 178354, 'periods': 26, 'status': 'mfj', 'step2': True, 'credits': 0, 'other_income': 0, 'deductions': 112718, 'extra': 0}, [12905, 12905]), ('boundary control', {'wage': 0, 'periods': 26, 'status': 'single', 'step2': False, 'credits': 400000, 'other_income': 0, 'deductions': 0, 'extra': 5000}, [0, 5000]), ('normal control', {'wage': 4942, 'periods': 12, 'status': 'single', 'step2': False, 'credits': 400000, 'other_income': 1831505, 'deductions': 0, 'extra': 8860}, [2757, 8860]), ('normal control', {'wage': 111690, 'periods': 26, 'status': 'mfj', 'step2': False, 'credits': 0, 'other_income': 0, 'deductions': 0, 'extra': 0}, [823, 823]), ('normal control', {'wage': 67447, 'periods': 24, 'status': 'mfj', 'step2': False, 'credits': 400000, 'other_income': 0, 'deductions': 0, 'extra': 2500}, [0, 2500]), ('normal control', {'wage': 1041418, 'periods': 24, 'status': 'hoh', 'step2': False, 'credits': 0, 'other_income': 0, 'deductions': 0, 'extra': 2500}, [156854, 159354])], [('regression', {'wage': 176, 'periods': 12, 'status': 'mfj', 'step2': True, 'credits': 0, 'other_income': 1390591, 'deductions': 0, 'extra': 0}, [398, 398]), ('regression', {'wage': 285367, 'periods': 52, 'status': 'hoh', 'step2': True, 'credits': 0, 'other_income': 0, 'deductions': 1182238, 'extra': 2500}, [41104, 43604]), ('partial-repair probe', {'wage': 178354, 'periods': 26, 'status': 'mfj', 'step2': True, 'credits': 0, 'other_income': 0, 'deductions': 112718, 'extra': 0}, [12905, 12905]), ('partial-repair probe', {'wage': 190399, 'periods': 24, 'status': 'mfj', 'step2': True, 'credits': 200000, 'other_income': 1327070, 'deductions': 0, 'extra': 0}, [20842, 12509]), ('boundary control', {'wage': 0, 'periods': 26, 'status': 'single', 'step2': False, 'credits': 400000, 'other_income': 0, 'deductions': 0, 'extra': 5000}, [0, 5000]), ('normal control', {'wage': 245742, 'periods': 24, 'status': 'single', 'step2': False, 'credits': 0, 'other_income': 0, 'deductions': 0, 'extra': 2500}, [19772, 22272]), ('normal control', {'wage': 196398, 'periods': 12, 'status': 'single', 'step2': False, 'credits': 0, 'other_income': 0, 'deductions': 0, 'extra': 0}, [6640, 6640]), ('normal control', {'wage': 64669, 'periods': 24, 'status': 'single', 'step2': False, 'credits': 0, 'other_income': 0, 'deductions': 0, 'extra': 2500}, [0, 2500]), ('normal control', {'wage': 492438, 'periods': 12, 'status': 'single', 'step2': True, 'credits': 400000, 'other_income': 131536, 'deductions': 0, 'extra': 0}, [59948, 26615])], [('regression', {'wage': 178354, 'periods': 26, 'status': 'mfj', 'step2': True, 'credits': 0, 'other_income': 0, 'deductions': 112718, 'extra': 0}, [12905, 12905]), ('regression', {'wage': 124748, 'periods': 26, 'status': 'mfj', 'step2': True, 'credits': 0, 'other_income': 0, 'deductions': 0, 'extra': 0}, [7302, 7302]), ('partial-repair probe', {'wage': 224276, 'periods': 26, 'status': 'mfj', 'step2': True, 'credits': 400000, 'other_income': 1419837, 'deductions': 0, 'extra': 0}, [25489, 10104]), ('partial-repair probe', {'wage': 876215, 'periods': 26, 'status': 'mfj', 'step2': True, 'credits': 458880, 'other_income': 257651, 'deductions': 0, 'extra': 2500}, [149874, 134725]), ('boundary control', {'wage': 0, 'periods': 26, 'status': 'single', 'step2': False, 'credits': 400000, 'other_income': 0, 'deductions': 0, 'extra': 5000}, [0, 5000]), ('normal control', {'wage': 232685, 'periods': 52, 'status': 'mfj', 'step2': False, 'credits': 200000, 'other_income': 0, 'deductions': 479252, 'extra': 0}, [18839, 14993]), ('normal control', {'wage': 79014, 'periods': 24, 'status': 'mfj', 'step2': False, 'credits': 400000, 'other_income': 1864011, 'deductions': 0, 'extra': 0}, [4460, 0]), ('normal control', {'wage': 322003, 'periods': 12, 'status': 'single', 'step2': False, 'credits': 0, 'other_income': 0, 'deductions': 0, 'extra': 2500}, [19207, 21707]), ('normal control', {'wage': 93316, 'periods': 12, 'status': 'mfj', 'step2': False, 'credits': 200000, 'other_income': 1111591, 'deductions': 0, 'extra': 1563}, [0, 1563])], [('regression', {'wage': 190399, 'periods': 24, 'status': 'mfj', 'step2': True, 'credits': 200000, 'other_income': 1327070, 'deductions': 0, 'extra': 0}, [20842, 12509]), ('regression', {'wage': 90292, 'periods': 52, 'status': 'hoh', 'step2': True, 'credits': 0, 'other_income': 0, 'deductions': 0, 'extra': 2500}, [7968, 10468]), ('partial-repair probe', {'wage': 72508, 'periods': 12, 'status': 'mfj', 'step2': True, 'credits': 0, 'other_income': 629389, 'deductions': 0, 'extra': 3100}, [1287, 4387]), ('partial-repair probe', {'wage': 1074758, 'periods': 52, 'status': 'mfj', 'step2': True, 'credits': 104962, 'other_income': 0, 'deductions': 0, 'extra': 2500}, [213910, 214391]), ('boundary control', {'wage': 0, 'periods': 26, 'status': 'single', 'step2': False, 'credits': 400000, 'other_income': 0, 'deductions': 0, 'extra': 5000}, [0, 5000]), ('normal control', {'wage': 37313, 'periods': 52, 'status': 'mfj', 'step2': False, 'credits': 117737, 'other_income': 1320234, 'deductions': 0, 'extra': 5664}, [1097, 5664]), ('normal control', {'wage': 179669, 'periods': 52, 'status': 'single', 'step2': False, 'credits': 0, 'other_income': 0, 'deductions': 0, 'extra': 0}, [17076, 17076]), ('normal control', {'wage': 170108, 'periods': 12, 'status': 'single', 'step2': True, 'credits': 200000, 'other_income': 167672, 'deductions': 0, 'extra': 0}, [12373, 0]), ('normal control', {'wage': 244499, 'periods': 26, 'status': 'hoh', 'step2': False, 'credits': 305778, 'other_income': 170107, 'deductions': 0, 'extra': 0}, [18656, 6895])], [('regression', {'wage': 224276, 'periods': 26, 'status': 'mfj', 'step2': True, 'credits': 400000, 'other_income': 1419837, 'deductions': 0, 'extra': 0}, [25489, 10104]), ('regression', {'wage': 142479, 'periods': 52, 'status': 'hoh', 'step2': True, 'credits': 551126, 'other_income': 0, 'deductions': 0, 'extra': 3806}, [14670, 7877]), ('partial-repair probe', {'wage': 93176, 'periods': 52, 'status': 'mfj', 'step2': True, 'credits': 200000, 'other_income': 0, 'deductions': 310339, 'extra': 0}, [6476, 2630]), ('partial-repair probe', {'wage': 737849, 'periods': 24, 'status': 'mfj', 'step2': True, 'credits': 400000, 'other_income': 0, 'deductions': 0, 'extra': 3155}, [113498, 99986]), ('boundary control', {'wage': 0, 'periods': 26, 'status': 'single', 'step2': False, 'credits': 400000, 'other_income': 0, 'deductions': 0, 'extra': 5000}, [0, 5000]), ('normal control', {'wage': 250357, 'periods': 52, 'status': 'single', 'step2': False, 'credits': 0, 'other_income': 0, 'deductions': 0, 'extra': 2500}, [31632, 34132]), ('normal control', {'wage': 251742, 'periods': 52, 'status': 'hoh', 'step2': False, 'credits': 0, 'other_income': 0, 'deductions': 392790, 'extra': 0}, [23568, 23568]), ('normal control', {'wage': 290758, 'periods': 26, 'status': 'single', 'step2': False, 'credits': 0, 'other_income': 1100573, 'deductions': 944056, 'extra': 0}, [26644, 26644]), ('normal control', {'wage': 76761, 'periods': 52, 'status': 'hoh', 'step2': False, 'credits': 400000, 'other_income': 0, 'deductions': 0, 'extra': 2500}, [4003, 2500])]]
for i, (label, args, expected) in enumerate(fixtures[N-1]):
    check("%s %d" % (label, i), solve(args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)
Boundary fixtureActualExpectedOutcome
regression 0[4609, 4609][7302, 7302]Failed
regression 1[5927, 0][5927, 0]Passed
partial-repair probe 2[0, 0][398, 398]Failed
partial-repair probe 3[9536, 9536][12905, 12905]Failed
boundary control 4[0, 5000][0, 5000]Passed
normal control 5[2757, 8860][2757, 8860]Passed
normal control 6[823, 823][823, 823]Passed
normal control 7[0, 2500][0, 2500]Passed
normal control 8[156854, 159354][156854, 159354]Passed

SHA-256 / fe962947f1c148cda9685c27996b3eab0ded0c9d66f5c66a51427d03b22a26de

3 / The verified repair

Exit 0
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(x):
    p = x['periods']
    annual = x['wage'] * p + x['other_income']
    base_std = {'single': 860000, 'mfj': 1290000, 'hoh': 860000}[x['status']]
    ded = (base_std // 2 if x['step2'] else base_std) + x['deductions']
    taxable = max(0, annual - ded)
    unit = {'single': 2, 'mfj': 4, 'hoh': 3}[x['status']]
    div = 4 if x['step2'] else 2
    bounds = [700000 * unit // div, 3000000 * unit // div, 9000000 * unit // div]
    rates = [10, 12, 22]
    tax = 0
    for i, lo in enumerate(bounds):
        hi = bounds[i + 1] if i + 1 < len(bounds) else taxable
        if taxable > lo:
            tax += (min(taxable, hi) - lo) * rates[i]
    tentative = (tax * 2 + 100 * p) // (200 * p)
    credit_pp = (x['credits'] * 2 + p) // (2 * p)
    wh = max(0, tentative - credit_pp) + x['extra']
    return [tentative, wh]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression', {'wage': 124748, 'periods': 26, 'status': 'mfj', 'step2': True, 'credits': 0, 'other_income': 0, 'deductions': 0, 'extra': 0}, [7302, 7302]), ('regression', {'wage': 69636, 'periods': 24, 'status': 'hoh', 'step2': True, 'credits': 877725, 'other_income': 1721162, 'deductions': 1014955, 'extra': 0}, [5927, 0]), ('partial-repair probe', {'wage': 176, 'periods': 12, 'status': 'mfj', 'step2': True, 'credits': 0, 'other_income': 1390591, 'deductions': 0, 'extra': 0}, [398, 398]), ('partial-repair probe', {'wage': 178354, 'periods': 26, 'status': 'mfj', 'step2': True, 'credits': 0, 'other_income': 0, 'deductions': 112718, 'extra': 0}, [12905, 12905]), ('boundary control', {'wage': 0, 'periods': 26, 'status': 'single', 'step2': False, 'credits': 400000, 'other_income': 0, 'deductions': 0, 'extra': 5000}, [0, 5000]), ('normal control', {'wage': 4942, 'periods': 12, 'status': 'single', 'step2': False, 'credits': 400000, 'other_income': 1831505, 'deductions': 0, 'extra': 8860}, [2757, 8860]), ('normal control', {'wage': 111690, 'periods': 26, 'status': 'mfj', 'step2': False, 'credits': 0, 'other_income': 0, 'deductions': 0, 'extra': 0}, [823, 823]), ('normal control', {'wage': 67447, 'periods': 24, 'status': 'mfj', 'step2': False, 'credits': 400000, 'other_income': 0, 'deductions': 0, 'extra': 2500}, [0, 2500]), ('normal control', {'wage': 1041418, 'periods': 24, 'status': 'hoh', 'step2': False, 'credits': 0, 'other_income': 0, 'deductions': 0, 'extra': 2500}, [156854, 159354])], [('regression', {'wage': 176, 'periods': 12, 'status': 'mfj', 'step2': True, 'credits': 0, 'other_income': 1390591, 'deductions': 0, 'extra': 0}, [398, 398]), ('regression', {'wage': 285367, 'periods': 52, 'status': 'hoh', 'step2': True, 'credits': 0, 'other_income': 0, 'deductions': 1182238, 'extra': 2500}, [41104, 43604]), ('partial-repair probe', {'wage': 178354, 'periods': 26, 'status': 'mfj', 'step2': True, 'credits': 0, 'other_income': 0, 'deductions': 112718, 'extra': 0}, [12905, 12905]), ('partial-repair probe', {'wage': 190399, 'periods': 24, 'status': 'mfj', 'step2': True, 'credits': 200000, 'other_income': 1327070, 'deductions': 0, 'extra': 0}, [20842, 12509]), ('boundary control', {'wage': 0, 'periods': 26, 'status': 'single', 'step2': False, 'credits': 400000, 'other_income': 0, 'deductions': 0, 'extra': 5000}, [0, 5000]), ('normal control', {'wage': 245742, 'periods': 24, 'status': 'single', 'step2': False, 'credits': 0, 'other_income': 0, 'deductions': 0, 'extra': 2500}, [19772, 22272]), ('normal control', {'wage': 196398, 'periods': 12, 'status': 'single', 'step2': False, 'credits': 0, 'other_income': 0, 'deductions': 0, 'extra': 0}, [6640, 6640]), ('normal control', {'wage': 64669, 'periods': 24, 'status': 'single', 'step2': False, 'credits': 0, 'other_income': 0, 'deductions': 0, 'extra': 2500}, [0, 2500]), ('normal control', {'wage': 492438, 'periods': 12, 'status': 'single', 'step2': True, 'credits': 400000, 'other_income': 131536, 'deductions': 0, 'extra': 0}, [59948, 26615])], [('regression', {'wage': 178354, 'periods': 26, 'status': 'mfj', 'step2': True, 'credits': 0, 'other_income': 0, 'deductions': 112718, 'extra': 0}, [12905, 12905]), ('regression', {'wage': 124748, 'periods': 26, 'status': 'mfj', 'step2': True, 'credits': 0, 'other_income': 0, 'deductions': 0, 'extra': 0}, [7302, 7302]), ('partial-repair probe', {'wage': 224276, 'periods': 26, 'status': 'mfj', 'step2': True, 'credits': 400000, 'other_income': 1419837, 'deductions': 0, 'extra': 0}, [25489, 10104]), ('partial-repair probe', {'wage': 876215, 'periods': 26, 'status': 'mfj', 'step2': True, 'credits': 458880, 'other_income': 257651, 'deductions': 0, 'extra': 2500}, [149874, 134725]), ('boundary control', {'wage': 0, 'periods': 26, 'status': 'single', 'step2': False, 'credits': 400000, 'other_income': 0, 'deductions': 0, 'extra': 5000}, [0, 5000]), ('normal control', {'wage': 232685, 'periods': 52, 'status': 'mfj', 'step2': False, 'credits': 200000, 'other_income': 0, 'deductions': 479252, 'extra': 0}, [18839, 14993]), ('normal control', {'wage': 79014, 'periods': 24, 'status': 'mfj', 'step2': False, 'credits': 400000, 'other_income': 1864011, 'deductions': 0, 'extra': 0}, [4460, 0]), ('normal control', {'wage': 322003, 'periods': 12, 'status': 'single', 'step2': False, 'credits': 0, 'other_income': 0, 'deductions': 0, 'extra': 2500}, [19207, 21707]), ('normal control', {'wage': 93316, 'periods': 12, 'status': 'mfj', 'step2': False, 'credits': 200000, 'other_income': 1111591, 'deductions': 0, 'extra': 1563}, [0, 1563])], [('regression', {'wage': 190399, 'periods': 24, 'status': 'mfj', 'step2': True, 'credits': 200000, 'other_income': 1327070, 'deductions': 0, 'extra': 0}, [20842, 12509]), ('regression', {'wage': 90292, 'periods': 52, 'status': 'hoh', 'step2': True, 'credits': 0, 'other_income': 0, 'deductions': 0, 'extra': 2500}, [7968, 10468]), ('partial-repair probe', {'wage': 72508, 'periods': 12, 'status': 'mfj', 'step2': True, 'credits': 0, 'other_income': 629389, 'deductions': 0, 'extra': 3100}, [1287, 4387]), ('partial-repair probe', {'wage': 1074758, 'periods': 52, 'status': 'mfj', 'step2': True, 'credits': 104962, 'other_income': 0, 'deductions': 0, 'extra': 2500}, [213910, 214391]), ('boundary control', {'wage': 0, 'periods': 26, 'status': 'single', 'step2': False, 'credits': 400000, 'other_income': 0, 'deductions': 0, 'extra': 5000}, [0, 5000]), ('normal control', {'wage': 37313, 'periods': 52, 'status': 'mfj', 'step2': False, 'credits': 117737, 'other_income': 1320234, 'deductions': 0, 'extra': 5664}, [1097, 5664]), ('normal control', {'wage': 179669, 'periods': 52, 'status': 'single', 'step2': False, 'credits': 0, 'other_income': 0, 'deductions': 0, 'extra': 0}, [17076, 17076]), ('normal control', {'wage': 170108, 'periods': 12, 'status': 'single', 'step2': True, 'credits': 200000, 'other_income': 167672, 'deductions': 0, 'extra': 0}, [12373, 0]), ('normal control', {'wage': 244499, 'periods': 26, 'status': 'hoh', 'step2': False, 'credits': 305778, 'other_income': 170107, 'deductions': 0, 'extra': 0}, [18656, 6895])], [('regression', {'wage': 224276, 'periods': 26, 'status': 'mfj', 'step2': True, 'credits': 400000, 'other_income': 1419837, 'deductions': 0, 'extra': 0}, [25489, 10104]), ('regression', {'wage': 142479, 'periods': 52, 'status': 'hoh', 'step2': True, 'credits': 551126, 'other_income': 0, 'deductions': 0, 'extra': 3806}, [14670, 7877]), ('partial-repair probe', {'wage': 93176, 'periods': 52, 'status': 'mfj', 'step2': True, 'credits': 200000, 'other_income': 0, 'deductions': 310339, 'extra': 0}, [6476, 2630]), ('partial-repair probe', {'wage': 737849, 'periods': 24, 'status': 'mfj', 'step2': True, 'credits': 400000, 'other_income': 0, 'deductions': 0, 'extra': 3155}, [113498, 99986]), ('boundary control', {'wage': 0, 'periods': 26, 'status': 'single', 'step2': False, 'credits': 400000, 'other_income': 0, 'deductions': 0, 'extra': 5000}, [0, 5000]), ('normal control', {'wage': 250357, 'periods': 52, 'status': 'single', 'step2': False, 'credits': 0, 'other_income': 0, 'deductions': 0, 'extra': 2500}, [31632, 34132]), ('normal control', {'wage': 251742, 'periods': 52, 'status': 'hoh', 'step2': False, 'credits': 0, 'other_income': 0, 'deductions': 392790, 'extra': 0}, [23568, 23568]), ('normal control', {'wage': 290758, 'periods': 26, 'status': 'single', 'step2': False, 'credits': 0, 'other_income': 1100573, 'deductions': 944056, 'extra': 0}, [26644, 26644]), ('normal control', {'wage': 76761, 'periods': 52, 'status': 'hoh', 'step2': False, 'credits': 400000, 'other_income': 0, 'deductions': 0, 'extra': 2500}, [4003, 2500])]]
for i, (label, args, expected) in enumerate(fixtures[N-1]):
    check("%s %d" % (label, i), solve(args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)
Boundary fixtureActualExpectedOutcome
regression 0[7302, 7302][7302, 7302]Passed
regression 1[5927, 0][5927, 0]Passed
partial-repair probe 2[398, 398][398, 398]Passed
partial-repair probe 3[12905, 12905][12905, 12905]Passed
boundary control 4[0, 5000][0, 5000]Passed
normal control 5[2757, 8860][2757, 8860]Passed
normal control 6[823, 823][823, 823]Passed
normal control 7[0, 2500][0, 2500]Passed
normal control 8[156854, 159354][156854, 159354]Passed

SHA-256 / 0e68c92262ecf924b8e8c137515d0ef23d49474c3ea19c7bc7a6e1c3040e1ace

Verification & scope

A deterministic teaching model of a stipulated payroll rule with toy thresholds and rates. It makes no claim of conformance to any tax authority, statute or jurisdiction and is not payroll software. This reproducer isolates one failure mechanism. Results cover the supplied fixtures. Variants within a family share a test contract and should remain grouped when constructing evaluation splits. Related mechanisms with a shared evaluation_group must also remain together; these controlled models are not independent production incidents.

Observations recorded using Python 3.12.14 at 2026-09-29T14:46:31.406941+00:00.

Case digest / f33be4bd8b761d5b47dffc3e78510722719323c1b27516df1cb8189ed38e295b