FAILURE MAP
← Case archive

FA-62561 / Tax bracket computation / Open access

The surtax is levied on the greater of NII and the MAGI excess · case 01

A filer with small investment income pays surtax on their wages above the threshold.

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

ROOT CAUSE

max() is used where the lesser amount is required.

VERIFIED REPAIR

Tax the lesser of NII and MAGI above the threshold.

Unsuccessful approach: Taking the lesser of NII and total MAGI omits the threshold.

Case contract

solve(nii, magi, status): stipulated 3.8% surtax on the lesser of net investment income and MAGI above the status threshold (single 200000, mfj 250000, mfs 125000), where neither amount counts below zero. Amounts are whole dollars; return the surtax in integer cents rounded half-up.

Why this case matters

Tax computations hinge on which slice, threshold, ordering and rounding rule applies at each step; a misplaced boundary silently misstates liabilities.

1 / The failure

Exit 1
"""Failure Map reference implementation. Python standard library only."""
import json
from fractions import Fraction
N = 1
observations = []
def solve(nii, magi, status):
    thr = {'single': 200000, 'mfj': 250000, 'mfs': 125000}[status]
    base = max(0, max(nii, magi - thr))
    return int(base * Fraction(38, 10) + Fraction(1, 2))
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
cases = [[('regression lesser-of 1', (20000, 300000, 'mfj'), 76000),
  ('regression lesser-of 2', (50000, 230000, 'single'), 114000),
  ('partial repair guard 2', (5001, 130000, 'mfs'), 19000), ('control: investment loss', (-4000, 400000, 'single'), 0),
  ('control: below threshold', (10000, 190000, 'single'), 0), ('control: odd dollars', (7, 400000, 'mfj'), 27)],
 [('regression lesser-of 1', (5001, 130000, 'mfs'), 19000), ('regression lesser-of 2', (-4000, 400000, 'single'), 0),
  ('partial repair guard 1', (10000, 190000, 'single'), 0), ('partial repair guard 2', (42884, 250001, 'mfj'), 4),
  ('control: odd dollars', (7, 400000, 'mfj'), 27), ('control: excess binding', (50000, 230000, 'single'), 114000),
  ('control: nii binding', (20000, 300000, 'mfj'), 76000)],
 [('regression lesser-of 1', (10000, 190000, 'single'), 0), ('regression lesser-of 2', (7, 400000, 'mfj'), 27),
  ('partial repair guard 1', (13, 125001, 'single'), 0), ('partial repair guard 2', (7, 200001, 'single'), 4),
  ('control: excess binding', (50000, 230000, 'single'), 114000),
  ('control: nii binding', (20000, 300000, 'mfj'), 76000), ('control: separate filer', (5001, 130000, 'mfs'), 19000),
  ('control: investment loss', (-4000, 400000, 'single'), 0)],
 [('regression lesser-of 1', (13, 250001, 'single'), 49), ('regression lesser-of 2', (42884, 250001, 'mfj'), 4),
  ('partial repair guard 1', (13, 250001, 'mfj'), 4), ('partial repair guard 2', (13, 200001, 'mfj'), 0),
  ('control: investment loss', (-4000, 400000, 'single'), 0),
  ('control: below threshold', (10000, 190000, 'single'), 0), ('control: odd dollars', (7, 400000, 'mfj'), 27),
  ('control: excess binding', (50000, 230000, 'single'), 114000)],
 [('regression lesser-of 1', (0, 200001, 'mfs'), 0), ('regression lesser-of 2', (13, 125001, 'single'), 0),
  ('partial repair guard 1', (13, 125001, 'mfs'), 4), ('partial repair guard 2', (16055, 250001, 'mfj'), 4),
  ('control: excess binding', (50000, 230000, 'single'), 114000),
  ('control: nii binding', (20000, 300000, 'mfj'), 76000), ('control: separate filer', (5001, 130000, 'mfs'), 19000),
  ('control: investment loss', (-4000, 400000, 'single'), 0)]]
for label, args, expected in cases[N - 1]:
    check(label, 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 lesser-of 119000076000Failed
regression lesser-of 2190000114000Failed
partial repair guard 21900419000Failed
control: investment loss7600000Failed
control: below threshold380000Failed
control: odd dollars57000027Failed

SHA-256 / df109fe65ae1bfb035709427e4c3f8f904c9d6f548cd59bdca6a2ef7540598da

2 / The unsuccessful fix

Exit 1
"""Failure Map reference implementation. Python standard library only."""
import json
from fractions import Fraction
N = 1
observations = []
def solve(nii, magi, status):
    thr = {'single': 200000, 'mfj': 250000, 'mfs': 125000}[status]
    base = max(0, min(nii, magi))
    return int(base * Fraction(38, 10) + Fraction(1, 2))
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
cases = [[('regression lesser-of 1', (20000, 300000, 'mfj'), 76000),
  ('regression lesser-of 2', (50000, 230000, 'single'), 114000),
  ('partial repair guard 2', (5001, 130000, 'mfs'), 19000), ('control: investment loss', (-4000, 400000, 'single'), 0),
  ('control: below threshold', (10000, 190000, 'single'), 0), ('control: odd dollars', (7, 400000, 'mfj'), 27)],
 [('regression lesser-of 1', (5001, 130000, 'mfs'), 19000), ('regression lesser-of 2', (-4000, 400000, 'single'), 0),
  ('partial repair guard 1', (10000, 190000, 'single'), 0), ('partial repair guard 2', (42884, 250001, 'mfj'), 4),
  ('control: odd dollars', (7, 400000, 'mfj'), 27), ('control: excess binding', (50000, 230000, 'single'), 114000),
  ('control: nii binding', (20000, 300000, 'mfj'), 76000)],
 [('regression lesser-of 1', (10000, 190000, 'single'), 0), ('regression lesser-of 2', (7, 400000, 'mfj'), 27),
  ('partial repair guard 1', (13, 125001, 'single'), 0), ('partial repair guard 2', (7, 200001, 'single'), 4),
  ('control: excess binding', (50000, 230000, 'single'), 114000),
  ('control: nii binding', (20000, 300000, 'mfj'), 76000), ('control: separate filer', (5001, 130000, 'mfs'), 19000),
  ('control: investment loss', (-4000, 400000, 'single'), 0)],
 [('regression lesser-of 1', (13, 250001, 'single'), 49), ('regression lesser-of 2', (42884, 250001, 'mfj'), 4),
  ('partial repair guard 1', (13, 250001, 'mfj'), 4), ('partial repair guard 2', (13, 200001, 'mfj'), 0),
  ('control: investment loss', (-4000, 400000, 'single'), 0),
  ('control: below threshold', (10000, 190000, 'single'), 0), ('control: odd dollars', (7, 400000, 'mfj'), 27),
  ('control: excess binding', (50000, 230000, 'single'), 114000)],
 [('regression lesser-of 1', (0, 200001, 'mfs'), 0), ('regression lesser-of 2', (13, 125001, 'single'), 0),
  ('partial repair guard 1', (13, 125001, 'mfs'), 4), ('partial repair guard 2', (16055, 250001, 'mfj'), 4),
  ('control: excess binding', (50000, 230000, 'single'), 114000),
  ('control: nii binding', (20000, 300000, 'mfj'), 76000), ('control: separate filer', (5001, 130000, 'mfs'), 19000),
  ('control: investment loss', (-4000, 400000, 'single'), 0)]]
for label, args, expected in cases[N - 1]:
    check(label, 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 lesser-of 17600076000Passed
regression lesser-of 2190000114000Failed
partial repair guard 21900419000Failed
control: investment loss00Passed
control: below threshold380000Failed
control: odd dollars2727Passed

SHA-256 / 31db5623aa3c66d1bd372702ba6c5fdf18ee8652611120cf4a1103536f8c6510

3 / The verified repair

Exit 0
"""Failure Map reference implementation. Python standard library only."""
import json
from fractions import Fraction
N = 1
observations = []
def solve(nii, magi, status):
    thr = {'single': 200000, 'mfj': 250000, 'mfs': 125000}[status]
    base = max(0, min(nii, magi - thr))
    return int(base * Fraction(38, 10) + Fraction(1, 2))
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
cases = [[('regression lesser-of 1', (20000, 300000, 'mfj'), 76000),
  ('regression lesser-of 2', (50000, 230000, 'single'), 114000),
  ('partial repair guard 2', (5001, 130000, 'mfs'), 19000), ('control: investment loss', (-4000, 400000, 'single'), 0),
  ('control: below threshold', (10000, 190000, 'single'), 0), ('control: odd dollars', (7, 400000, 'mfj'), 27)],
 [('regression lesser-of 1', (5001, 130000, 'mfs'), 19000), ('regression lesser-of 2', (-4000, 400000, 'single'), 0),
  ('partial repair guard 1', (10000, 190000, 'single'), 0), ('partial repair guard 2', (42884, 250001, 'mfj'), 4),
  ('control: odd dollars', (7, 400000, 'mfj'), 27), ('control: excess binding', (50000, 230000, 'single'), 114000),
  ('control: nii binding', (20000, 300000, 'mfj'), 76000)],
 [('regression lesser-of 1', (10000, 190000, 'single'), 0), ('regression lesser-of 2', (7, 400000, 'mfj'), 27),
  ('partial repair guard 1', (13, 125001, 'single'), 0), ('partial repair guard 2', (7, 200001, 'single'), 4),
  ('control: excess binding', (50000, 230000, 'single'), 114000),
  ('control: nii binding', (20000, 300000, 'mfj'), 76000), ('control: separate filer', (5001, 130000, 'mfs'), 19000),
  ('control: investment loss', (-4000, 400000, 'single'), 0)],
 [('regression lesser-of 1', (13, 250001, 'single'), 49), ('regression lesser-of 2', (42884, 250001, 'mfj'), 4),
  ('partial repair guard 1', (13, 250001, 'mfj'), 4), ('partial repair guard 2', (13, 200001, 'mfj'), 0),
  ('control: investment loss', (-4000, 400000, 'single'), 0),
  ('control: below threshold', (10000, 190000, 'single'), 0), ('control: odd dollars', (7, 400000, 'mfj'), 27),
  ('control: excess binding', (50000, 230000, 'single'), 114000)],
 [('regression lesser-of 1', (0, 200001, 'mfs'), 0), ('regression lesser-of 2', (13, 125001, 'single'), 0),
  ('partial repair guard 1', (13, 125001, 'mfs'), 4), ('partial repair guard 2', (16055, 250001, 'mfj'), 4),
  ('control: excess binding', (50000, 230000, 'single'), 114000),
  ('control: nii binding', (20000, 300000, 'mfj'), 76000), ('control: separate filer', (5001, 130000, 'mfs'), 19000),
  ('control: investment loss', (-4000, 400000, 'single'), 0)]]
for label, args, expected in cases[N - 1]:
    check(label, 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 lesser-of 17600076000Passed
regression lesser-of 2114000114000Passed
partial repair guard 21900019000Passed
control: investment loss00Passed
control: below threshold00Passed
control: odd dollars2727Passed

SHA-256 / ae83d1bcadde9aad7b185214147d11fa75be3a0076b784dac642798c55048d12

Verification & scope

A deterministic, bounded teaching model with a stipulated toy contract; it makes no claim of conformance to any real regulation, standard, or institution's rules. 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:47:05.817639+00:00.

Case digest / 35a48df1989c1e577e33bfd49eef0f9d237f9870eba255cb8287d938a7812c78