FAILURE MAP
← Case archive

FA-58871 / Payroll withholding rules / Open access

Additional Medicare withholding threshold: prior excess measurement · case 01

Employees below the threshold get additional Medicare wages larger than the paycheck itself.

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

ROOT CAUSE

The excess before this paycheck is not floored at zero, so a negative prior excess inflates the difference.

VERIFIED REPAIR

Restore the contract rule at the prior excess measurement step: use `over_before = max(0, ytd - 20000000)`.

Unsuccessful approach: The attempt floors the prior excess but subtracts the current paycheck from year-to-date as if it were already included, double-counting the crossing paycheck.

Case contract

Input [ytd_wages, wages] in cents. Regular Medicare is 1.45% of wages rounded half-up. Additional Medicare is 0.9% of the part of this paycheck that pushes year-to-date wages above 200,000.00, rounded half-up separately. Return [medicare, additional_wages, medicare + additional].

Why this case matters

The employer must begin the extra 0.9% exactly with the paycheck that crosses the threshold, and only on the excess portion.

1 / The failure

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

N = 1
observations = []
def solve(x):
    ytd, wages = x
    base_tax = (wages * 145 + 5000) // 10000
    over_before = ytd - 20000000
    over_after = max(0, ytd + wages - 20000000)
    extra_wages = over_after - over_before
    extra = (extra_wages * 9 + 500) // 1000
    return [base_tax, extra_wages, base_tax + extra]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression (boundary)', [19950000, 100000], [1450, 50000, 1900]), ('regression (boundary)', [0, 0], [0, 0, 0]), ('partial-repair probe (boundary)', [25000000, 12345], [179, 12345, 290]), ('partial-repair probe', [20158685, 407195], [5904, 407195, 9569]), ('boundary control', [20000000, 100000], [1450, 100000, 2350]), ('normal control', [20000000, 1829965], [26534, 1829965, 43004]), ('normal control', [20000000, 654261], [9487, 654261, 15375]), ('normal control', [20000000, 1204410], [17464, 1204410, 28304]), ('normal control', [20000000, 35595], [516, 35595, 836])], [('regression (boundary)', [0, 0], [0, 0, 0]), ('regression (boundary)', [19999999, 1], [0, 0, 0]), ('partial-repair probe', [20518887, 2208012], [32016, 2208012, 51888]), ('partial-repair probe', [20723172, 31906], [463, 31906, 750]), ('boundary control', [20000000, 100000], [1450, 100000, 2350]), ('normal control', [20000000, 13601], [197, 13601, 319]), ('normal control', [20000000, 211218], [3063, 211218, 4964]), ('normal control', [20000000, 541335], [7849, 541335, 12721]), ('normal control', [20000000, 14262], [207, 14262, 335])], [('regression (boundary)', [19999999, 1], [0, 0, 0]), ('regression', [7554383, 209883], [3043, 0, 3043]), ('partial-repair probe', [20767841, 19138], [278, 19138, 450]), ('partial-repair probe', [20469014, 260626], [3779, 260626, 6125]), ('boundary control', [20000000, 100000], [1450, 100000, 2350]), ('normal control', [20000000, 15560], [226, 15560, 366]), ('normal control', [20000000, 46156], [669, 46156, 1084]), ('normal control', [20000000, 8435], [122, 8435, 198]), ('normal control', [20000000, 12860], [186, 12860, 302])], [('regression', [7554383, 209883], [3043, 0, 3043]), ('regression', [8001356, 2662166], [38601, 0, 38601]), ('partial-repair probe', [23912137, 659488], [9563, 659488, 15498]), ('partial-repair probe', [21835663, 1842418], [26715, 1842418, 43297]), ('boundary control', [20000000, 100000], [1450, 100000, 2350]), ('normal control', [20000000, 2376741], [34463, 2376741, 55854]), ('normal control', [20000000, 808350], [11721, 808350, 18996]), ('normal control', [20000000, 9624], [140, 9624, 227]), ('normal control', [20000000, 1041041], [15095, 1041041, 24464])], [('regression', [8001356, 2662166], [38601, 0, 38601]), ('regression', [2439490, 49414], [717, 0, 717]), ('partial-repair probe', [20631534, 41656], [604, 41656, 979]), ('partial-repair probe', [20609547, 21397], [310, 21397, 503]), ('boundary control', [20000000, 100000], [1450, 100000, 2350]), ('normal control', [20000000, 325488], [4720, 325488, 7649]), ('normal control', [20000000, 229558], [3329, 229558, 5395]), ('normal control', [20000000, 2962928], [42962, 2962928, 69628]), ('normal control', [20000000, 1917303], [27801, 1917303, 45057])]]
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 (boundary) 0[1450, 100000, 2350][1450, 50000, 1900]Failed
regression (boundary) 1[0, 20000000, 180000][0, 0, 0]Failed
partial-repair probe (boundary) 2[179, 12345, 290][179, 12345, 290]Passed
partial-repair probe 3[5904, 407195, 9569][5904, 407195, 9569]Passed
boundary control 4[1450, 100000, 2350][1450, 100000, 2350]Passed
normal control 5[26534, 1829965, 43004][26534, 1829965, 43004]Passed
normal control 6[9487, 654261, 15375][9487, 654261, 15375]Passed
normal control 7[17464, 1204410, 28304][17464, 1204410, 28304]Passed
normal control 8[516, 35595, 836][516, 35595, 836]Passed

SHA-256 / d240e780094e98d6d762b5b1e1c3538bbd429f5335ad4c7b22f5b84e8021f42a

2 / The unsuccessful fix

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

N = 1
observations = []
def solve(x):
    ytd, wages = x
    base_tax = (wages * 145 + 5000) // 10000
    over_before = max(0, ytd - wages - 20000000)
    over_after = max(0, ytd + wages - 20000000)
    extra_wages = over_after - over_before
    extra = (extra_wages * 9 + 500) // 1000
    return [base_tax, extra_wages, base_tax + extra]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression (boundary)', [19950000, 100000], [1450, 50000, 1900]), ('regression (boundary)', [0, 0], [0, 0, 0]), ('partial-repair probe (boundary)', [25000000, 12345], [179, 12345, 290]), ('partial-repair probe', [20158685, 407195], [5904, 407195, 9569]), ('boundary control', [20000000, 100000], [1450, 100000, 2350]), ('normal control', [20000000, 1829965], [26534, 1829965, 43004]), ('normal control', [20000000, 654261], [9487, 654261, 15375]), ('normal control', [20000000, 1204410], [17464, 1204410, 28304]), ('normal control', [20000000, 35595], [516, 35595, 836])], [('regression (boundary)', [0, 0], [0, 0, 0]), ('regression (boundary)', [19999999, 1], [0, 0, 0]), ('partial-repair probe', [20518887, 2208012], [32016, 2208012, 51888]), ('partial-repair probe', [20723172, 31906], [463, 31906, 750]), ('boundary control', [20000000, 100000], [1450, 100000, 2350]), ('normal control', [20000000, 13601], [197, 13601, 319]), ('normal control', [20000000, 211218], [3063, 211218, 4964]), ('normal control', [20000000, 541335], [7849, 541335, 12721]), ('normal control', [20000000, 14262], [207, 14262, 335])], [('regression (boundary)', [19999999, 1], [0, 0, 0]), ('regression', [7554383, 209883], [3043, 0, 3043]), ('partial-repair probe', [20767841, 19138], [278, 19138, 450]), ('partial-repair probe', [20469014, 260626], [3779, 260626, 6125]), ('boundary control', [20000000, 100000], [1450, 100000, 2350]), ('normal control', [20000000, 15560], [226, 15560, 366]), ('normal control', [20000000, 46156], [669, 46156, 1084]), ('normal control', [20000000, 8435], [122, 8435, 198]), ('normal control', [20000000, 12860], [186, 12860, 302])], [('regression', [7554383, 209883], [3043, 0, 3043]), ('regression', [8001356, 2662166], [38601, 0, 38601]), ('partial-repair probe', [23912137, 659488], [9563, 659488, 15498]), ('partial-repair probe', [21835663, 1842418], [26715, 1842418, 43297]), ('boundary control', [20000000, 100000], [1450, 100000, 2350]), ('normal control', [20000000, 2376741], [34463, 2376741, 55854]), ('normal control', [20000000, 808350], [11721, 808350, 18996]), ('normal control', [20000000, 9624], [140, 9624, 227]), ('normal control', [20000000, 1041041], [15095, 1041041, 24464])], [('regression', [8001356, 2662166], [38601, 0, 38601]), ('regression', [2439490, 49414], [717, 0, 717]), ('partial-repair probe', [20631534, 41656], [604, 41656, 979]), ('partial-repair probe', [20609547, 21397], [310, 21397, 503]), ('boundary control', [20000000, 100000], [1450, 100000, 2350]), ('normal control', [20000000, 325488], [4720, 325488, 7649]), ('normal control', [20000000, 229558], [3329, 229558, 5395]), ('normal control', [20000000, 2962928], [42962, 2962928, 69628]), ('normal control', [20000000, 1917303], [27801, 1917303, 45057])]]
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 (boundary) 0[1450, 50000, 1900][1450, 50000, 1900]Passed
regression (boundary) 1[0, 0, 0][0, 0, 0]Passed
partial-repair probe (boundary) 2[179, 24690, 401][179, 12345, 290]Failed
partial-repair probe 3[5904, 565880, 10997][5904, 407195, 9569]Failed
boundary control 4[1450, 100000, 2350][1450, 100000, 2350]Passed
normal control 5[26534, 1829965, 43004][26534, 1829965, 43004]Passed
normal control 6[9487, 654261, 15375][9487, 654261, 15375]Passed
normal control 7[17464, 1204410, 28304][17464, 1204410, 28304]Passed
normal control 8[516, 35595, 836][516, 35595, 836]Passed

SHA-256 / 20542187388bf68e4501330b1dce819991e5f8ebbb2809d682a1f1ac64c91cde

3 / The verified repair

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

N = 1
observations = []
def solve(x):
    ytd, wages = x
    base_tax = (wages * 145 + 5000) // 10000
    over_before = max(0, ytd - 20000000)
    over_after = max(0, ytd + wages - 20000000)
    extra_wages = over_after - over_before
    extra = (extra_wages * 9 + 500) // 1000
    return [base_tax, extra_wages, base_tax + extra]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression (boundary)', [19950000, 100000], [1450, 50000, 1900]), ('regression (boundary)', [0, 0], [0, 0, 0]), ('partial-repair probe (boundary)', [25000000, 12345], [179, 12345, 290]), ('partial-repair probe', [20158685, 407195], [5904, 407195, 9569]), ('boundary control', [20000000, 100000], [1450, 100000, 2350]), ('normal control', [20000000, 1829965], [26534, 1829965, 43004]), ('normal control', [20000000, 654261], [9487, 654261, 15375]), ('normal control', [20000000, 1204410], [17464, 1204410, 28304]), ('normal control', [20000000, 35595], [516, 35595, 836])], [('regression (boundary)', [0, 0], [0, 0, 0]), ('regression (boundary)', [19999999, 1], [0, 0, 0]), ('partial-repair probe', [20518887, 2208012], [32016, 2208012, 51888]), ('partial-repair probe', [20723172, 31906], [463, 31906, 750]), ('boundary control', [20000000, 100000], [1450, 100000, 2350]), ('normal control', [20000000, 13601], [197, 13601, 319]), ('normal control', [20000000, 211218], [3063, 211218, 4964]), ('normal control', [20000000, 541335], [7849, 541335, 12721]), ('normal control', [20000000, 14262], [207, 14262, 335])], [('regression (boundary)', [19999999, 1], [0, 0, 0]), ('regression', [7554383, 209883], [3043, 0, 3043]), ('partial-repair probe', [20767841, 19138], [278, 19138, 450]), ('partial-repair probe', [20469014, 260626], [3779, 260626, 6125]), ('boundary control', [20000000, 100000], [1450, 100000, 2350]), ('normal control', [20000000, 15560], [226, 15560, 366]), ('normal control', [20000000, 46156], [669, 46156, 1084]), ('normal control', [20000000, 8435], [122, 8435, 198]), ('normal control', [20000000, 12860], [186, 12860, 302])], [('regression', [7554383, 209883], [3043, 0, 3043]), ('regression', [8001356, 2662166], [38601, 0, 38601]), ('partial-repair probe', [23912137, 659488], [9563, 659488, 15498]), ('partial-repair probe', [21835663, 1842418], [26715, 1842418, 43297]), ('boundary control', [20000000, 100000], [1450, 100000, 2350]), ('normal control', [20000000, 2376741], [34463, 2376741, 55854]), ('normal control', [20000000, 808350], [11721, 808350, 18996]), ('normal control', [20000000, 9624], [140, 9624, 227]), ('normal control', [20000000, 1041041], [15095, 1041041, 24464])], [('regression', [8001356, 2662166], [38601, 0, 38601]), ('regression', [2439490, 49414], [717, 0, 717]), ('partial-repair probe', [20631534, 41656], [604, 41656, 979]), ('partial-repair probe', [20609547, 21397], [310, 21397, 503]), ('boundary control', [20000000, 100000], [1450, 100000, 2350]), ('normal control', [20000000, 325488], [4720, 325488, 7649]), ('normal control', [20000000, 229558], [3329, 229558, 5395]), ('normal control', [20000000, 2962928], [42962, 2962928, 69628]), ('normal control', [20000000, 1917303], [27801, 1917303, 45057])]]
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 (boundary) 0[1450, 50000, 1900][1450, 50000, 1900]Passed
regression (boundary) 1[0, 0, 0][0, 0, 0]Passed
partial-repair probe (boundary) 2[179, 12345, 290][179, 12345, 290]Passed
partial-repair probe 3[5904, 407195, 9569][5904, 407195, 9569]Passed
boundary control 4[1450, 100000, 2350][1450, 100000, 2350]Passed
normal control 5[26534, 1829965, 43004][26534, 1829965, 43004]Passed
normal control 6[9487, 654261, 15375][9487, 654261, 15375]Passed
normal control 7[17464, 1204410, 28304][17464, 1204410, 28304]Passed
normal control 8[516, 35595, 836][516, 35595, 836]Passed

SHA-256 / 6518578a9f724417a447afd7a663d57fb1c1facfccf024d5b82b94e6478a7d79

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:30.829820+00:00.

Case digest / e449439b2b0b858c310138f60671bf0072708c628fe2be1d83e0beeea6a502ff