FAILURE MAP
← Case archive

FA-62571 / Tax bracket computation / Open access

An investment loss produces a negative surtax · case 01

A net investment loss reduces other tax through a negative surtax.

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

ROOT CAUSE

The base min(nii, excess) is not floored at zero.

VERIFIED REPAIR

Floor the surtax base at zero.

Unsuccessful approach: Clamping only negative NII still lets a MAGI below the threshold give a negative base.

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 = 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 negative-components 1', (-4000, 400000, 'single'), 0),
  ('regression negative-components 2', (10000, 190000, 'single'), 0),
  ('partial repair guard 2', (0, 125001, 'single'), 0), ('control: excess binding', (50000, 230000, 'single'), 114000),
  ('control: nii binding', (20000, 300000, 'mfj'), 76000), ('control: separate filer', (5001, 130000, 'mfs'), 19000),
  ('control: odd dollars', (7, 400000, 'mfj'), 27)],
 [('regression negative-components 1', (0, 125001, 'single'), 0),
  ('regression negative-components 2', (0, 105501, 'mfj'), 0), ('partial repair guard 2', (13, 125001, 'single'), 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 negative-components 1', (13, 125001, 'single'), 0),
  ('regression negative-components 2', (13, 200001, 'mfj'), 0), ('partial repair guard 2', (0, 125001, 'mfj'), 0),
  ('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 negative-components 1', (0, 125001, 'mfj'), 0),
  ('regression negative-components 2', (0, 200001, 'mfj'), 0), ('partial repair guard 2', (0, 123762, 'single'), 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 negative-components 1', (0, 123762, 'single'), 0),
  ('regression negative-components 2', (7, 125001, 'mfj'), 0), ('partial repair guard 2', (31498, 125001, 'single'), 0),
  ('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 negative-components 1-151990Failed
regression negative-components 2-379990Failed
partial repair guard 2-2849950Failed
control: excess binding114000114000Passed
control: nii binding7600076000Passed
control: separate filer1900019000Passed
control: odd dollars2727Passed

SHA-256 / 90c8f6e2e68caf912d91e1ef538f946ee4cab7615f626aed93462be72b4551f9

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 = min(max(0, 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 negative-components 1', (-4000, 400000, 'single'), 0),
  ('regression negative-components 2', (10000, 190000, 'single'), 0),
  ('partial repair guard 2', (0, 125001, 'single'), 0), ('control: excess binding', (50000, 230000, 'single'), 114000),
  ('control: nii binding', (20000, 300000, 'mfj'), 76000), ('control: separate filer', (5001, 130000, 'mfs'), 19000),
  ('control: odd dollars', (7, 400000, 'mfj'), 27)],
 [('regression negative-components 1', (0, 125001, 'single'), 0),
  ('regression negative-components 2', (0, 105501, 'mfj'), 0), ('partial repair guard 2', (13, 125001, 'single'), 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 negative-components 1', (13, 125001, 'single'), 0),
  ('regression negative-components 2', (13, 200001, 'mfj'), 0), ('partial repair guard 2', (0, 125001, 'mfj'), 0),
  ('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 negative-components 1', (0, 125001, 'mfj'), 0),
  ('regression negative-components 2', (0, 200001, 'mfj'), 0), ('partial repair guard 2', (0, 123762, 'single'), 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 negative-components 1', (0, 123762, 'single'), 0),
  ('regression negative-components 2', (7, 125001, 'mfj'), 0), ('partial repair guard 2', (31498, 125001, 'single'), 0),
  ('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 negative-components 100Passed
regression negative-components 2-379990Failed
partial repair guard 2-2849950Failed
control: excess binding114000114000Passed
control: nii binding7600076000Passed
control: separate filer1900019000Passed
control: odd dollars2727Passed

SHA-256 / b5dc4c32b000f8ae58de6e5b6a7eb7738812b792dd6d696f38bfbf7103df860a

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 negative-components 1', (-4000, 400000, 'single'), 0),
  ('regression negative-components 2', (10000, 190000, 'single'), 0),
  ('partial repair guard 2', (0, 125001, 'single'), 0), ('control: excess binding', (50000, 230000, 'single'), 114000),
  ('control: nii binding', (20000, 300000, 'mfj'), 76000), ('control: separate filer', (5001, 130000, 'mfs'), 19000),
  ('control: odd dollars', (7, 400000, 'mfj'), 27)],
 [('regression negative-components 1', (0, 125001, 'single'), 0),
  ('regression negative-components 2', (0, 105501, 'mfj'), 0), ('partial repair guard 2', (13, 125001, 'single'), 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 negative-components 1', (13, 125001, 'single'), 0),
  ('regression negative-components 2', (13, 200001, 'mfj'), 0), ('partial repair guard 2', (0, 125001, 'mfj'), 0),
  ('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 negative-components 1', (0, 125001, 'mfj'), 0),
  ('regression negative-components 2', (0, 200001, 'mfj'), 0), ('partial repair guard 2', (0, 123762, 'single'), 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 negative-components 1', (0, 123762, 'single'), 0),
  ('regression negative-components 2', (7, 125001, 'mfj'), 0), ('partial repair guard 2', (31498, 125001, 'single'), 0),
  ('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 negative-components 100Passed
regression negative-components 200Passed
partial repair guard 200Passed
control: excess binding114000114000Passed
control: nii binding7600076000Passed
control: separate filer1900019000Passed
control: odd dollars2727Passed

SHA-256 / 845292c59c9658a67ec8a88aba0849329a84c0703fbc1de7cec08b7f58bcdc63

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

Case digest / e77d526734004be8ef8d52bf5b87616f61733b1157af639c25bafe1b39ba9f71