FAILURE MAP
← Case archive

FA-62686 / Tax bracket computation / Open access

The local surtax is computed on state tax before credits · case 01

Filers with large nonrefundable credits pay local surtax on tax they never owed.

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

ROOT CAUSE

The surtax base is the gross state tax.

VERIFIED REPAIR

Base the surtax on state tax after nonrefundable credits.

Unsuccessful approach: Also deducting refundable credits from the base under-charges the surtax.

Case contract

solve(state, nonref, ref, pct): amounts in integer cents; pct a decimal percentage string. State tax after nonrefundable credits is max(0, state - nonref). The local surtax is pct% of that amount, rounded half-up to cents. Refundable credits then apply to the combined total in full (a negative total is a refund). Return [local, total].

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(state, nonref, ref, pct):
    after = max(0, state - nonref)
    local = int(state * Fraction(pct) / 100 + Fraction(1, 2))
    return [local, after + local - ref]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
cases = [[('regression surtax-base 1', (100000, 20000, 5000, '17.5'), [14000, 89000]),
  ('regression surtax-base 2', (1000, 3000, 500, '20'), [0, -500]),
  ('partial repair guard 2', (5000, 1000, 9000, '12.5'), [500, -4500]),
  ('control: rounding', (333, 0, 0, '1.5'), [5, 338]), ('control: half cent', (1001, 0, 0, '50'), [501, 1502]),
  ('control: no surtax', (4200, 100, 0, '0'), [0, 4100])],
 [('regression surtax-base 1', (5000, 1000, 9000, '12.5'), [500, -4500]),
  ('regression surtax-base 2', (143686, 20000, 9000, '17.5'), [21645, 136331]),
  ('partial repair guard 2', (86323, 79662, 500, '12.5'), [833, 6994]),
  ('control: half cent', (1001, 0, 0, '50'), [501, 1502]), ('control: no surtax', (4200, 100, 0, '0'), [0, 4100]),
  ('control: typical', (100000, 20000, 5000, '17.5'), [14000, 89000]),
  ('control: credits exceed tax', (1000, 3000, 500, '20'), [0, -500])],
 [('regression surtax-base 1', (133783, 45064, 0, '17.5'), [15526, 104245]),
  ('regression surtax-base 2', (27192, 1000, 0, '12.5'), [3274, 29466]),
  ('partial repair guard 1', (44678, 28763, 500, '50'), [7958, 23373]),
  ('partial repair guard 2', (176644, 20000, 500, '8'), [12532, 168676]),
  ('control: typical', (100000, 20000, 5000, '17.5'), [14000, 89000]),
  ('control: credits exceed tax', (1000, 3000, 500, '20'), [0, -500]),
  ('control: rounding', (333, 0, 0, '1.5'), [5, 338]),
  ('control: large refund', (5000, 1000, 9000, '12.5'), [500, -4500])],
 [('regression surtax-base 1', (86323, 79662, 500, '12.5'), [833, 6994]),
  ('regression surtax-base 2', (44678, 28763, 500, '50'), [7958, 23373]),
  ('partial repair guard 1', (107676, 1000, 9000, '8'), [8534, 106210]),
  ('partial repair guard 2', (96269, 20000, 9000, '8'), [6102, 73371]),
  ('control: large refund', (5000, 1000, 9000, '12.5'), [500, -4500]),
  ('control: half cent', (1001, 0, 0, '50'), [501, 1502]), ('control: no surtax', (4200, 100, 0, '0'), [0, 4100]),
  ('control: typical', (100000, 20000, 5000, '17.5'), [14000, 89000])],
 [('regression surtax-base 1', (176644, 20000, 500, '8'), [12532, 168676]),
  ('regression surtax-base 2', (107676, 1000, 9000, '8'), [8534, 106210]),
  ('partial repair guard 1', (171795, 55836, 500, '1.5'), [1739, 117198]),
  ('partial repair guard 2', (195423, 1000, 9000, '17.5'), [34024, 219447]),
  ('control: typical', (100000, 20000, 5000, '17.5'), [14000, 89000]),
  ('control: credits exceed tax', (1000, 3000, 500, '20'), [0, -500]),
  ('control: rounding', (333, 0, 0, '1.5'), [5, 338]),
  ('control: large refund', (5000, 1000, 9000, '12.5'), [500, -4500])]]
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 surtax-base 1[17500, 92500][14000, 89000]Failed
regression surtax-base 2[200, -300][0, -500]Failed
partial repair guard 2[625, -4375][500, -4500]Failed
control: rounding[5, 338][5, 338]Passed
control: half cent[501, 1502][501, 1502]Passed
control: no surtax[0, 4100][0, 4100]Passed

SHA-256 / 4423fc47e87040d0f52ce7fc5e587e7ae87f188e7b3c531e362f8ca63e310305

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(state, nonref, ref, pct):
    after = max(0, state - nonref)
    local = int(max(0, after - ref) * Fraction(pct) / 100 + Fraction(1, 2))
    return [local, after + local - ref]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
cases = [[('regression surtax-base 1', (100000, 20000, 5000, '17.5'), [14000, 89000]),
  ('regression surtax-base 2', (1000, 3000, 500, '20'), [0, -500]),
  ('partial repair guard 2', (5000, 1000, 9000, '12.5'), [500, -4500]),
  ('control: rounding', (333, 0, 0, '1.5'), [5, 338]), ('control: half cent', (1001, 0, 0, '50'), [501, 1502]),
  ('control: no surtax', (4200, 100, 0, '0'), [0, 4100])],
 [('regression surtax-base 1', (5000, 1000, 9000, '12.5'), [500, -4500]),
  ('regression surtax-base 2', (143686, 20000, 9000, '17.5'), [21645, 136331]),
  ('partial repair guard 2', (86323, 79662, 500, '12.5'), [833, 6994]),
  ('control: half cent', (1001, 0, 0, '50'), [501, 1502]), ('control: no surtax', (4200, 100, 0, '0'), [0, 4100]),
  ('control: typical', (100000, 20000, 5000, '17.5'), [14000, 89000]),
  ('control: credits exceed tax', (1000, 3000, 500, '20'), [0, -500])],
 [('regression surtax-base 1', (133783, 45064, 0, '17.5'), [15526, 104245]),
  ('regression surtax-base 2', (27192, 1000, 0, '12.5'), [3274, 29466]),
  ('partial repair guard 1', (44678, 28763, 500, '50'), [7958, 23373]),
  ('partial repair guard 2', (176644, 20000, 500, '8'), [12532, 168676]),
  ('control: typical', (100000, 20000, 5000, '17.5'), [14000, 89000]),
  ('control: credits exceed tax', (1000, 3000, 500, '20'), [0, -500]),
  ('control: rounding', (333, 0, 0, '1.5'), [5, 338]),
  ('control: large refund', (5000, 1000, 9000, '12.5'), [500, -4500])],
 [('regression surtax-base 1', (86323, 79662, 500, '12.5'), [833, 6994]),
  ('regression surtax-base 2', (44678, 28763, 500, '50'), [7958, 23373]),
  ('partial repair guard 1', (107676, 1000, 9000, '8'), [8534, 106210]),
  ('partial repair guard 2', (96269, 20000, 9000, '8'), [6102, 73371]),
  ('control: large refund', (5000, 1000, 9000, '12.5'), [500, -4500]),
  ('control: half cent', (1001, 0, 0, '50'), [501, 1502]), ('control: no surtax', (4200, 100, 0, '0'), [0, 4100]),
  ('control: typical', (100000, 20000, 5000, '17.5'), [14000, 89000])],
 [('regression surtax-base 1', (176644, 20000, 500, '8'), [12532, 168676]),
  ('regression surtax-base 2', (107676, 1000, 9000, '8'), [8534, 106210]),
  ('partial repair guard 1', (171795, 55836, 500, '1.5'), [1739, 117198]),
  ('partial repair guard 2', (195423, 1000, 9000, '17.5'), [34024, 219447]),
  ('control: typical', (100000, 20000, 5000, '17.5'), [14000, 89000]),
  ('control: credits exceed tax', (1000, 3000, 500, '20'), [0, -500]),
  ('control: rounding', (333, 0, 0, '1.5'), [5, 338]),
  ('control: large refund', (5000, 1000, 9000, '12.5'), [500, -4500])]]
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 surtax-base 1[13125, 88125][14000, 89000]Failed
regression surtax-base 2[0, -500][0, -500]Passed
partial repair guard 2[0, -5000][500, -4500]Failed
control: rounding[5, 338][5, 338]Passed
control: half cent[501, 1502][501, 1502]Passed
control: no surtax[0, 4100][0, 4100]Passed

SHA-256 / af70bf138f2dfd057500e04caf3bc0ea3635d4dfe9b75174de30f86476b0e19a

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(state, nonref, ref, pct):
    after = max(0, state - nonref)
    local = int(after * Fraction(pct) / 100 + Fraction(1, 2))
    return [local, after + local - ref]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
cases = [[('regression surtax-base 1', (100000, 20000, 5000, '17.5'), [14000, 89000]),
  ('regression surtax-base 2', (1000, 3000, 500, '20'), [0, -500]),
  ('partial repair guard 2', (5000, 1000, 9000, '12.5'), [500, -4500]),
  ('control: rounding', (333, 0, 0, '1.5'), [5, 338]), ('control: half cent', (1001, 0, 0, '50'), [501, 1502]),
  ('control: no surtax', (4200, 100, 0, '0'), [0, 4100])],
 [('regression surtax-base 1', (5000, 1000, 9000, '12.5'), [500, -4500]),
  ('regression surtax-base 2', (143686, 20000, 9000, '17.5'), [21645, 136331]),
  ('partial repair guard 2', (86323, 79662, 500, '12.5'), [833, 6994]),
  ('control: half cent', (1001, 0, 0, '50'), [501, 1502]), ('control: no surtax', (4200, 100, 0, '0'), [0, 4100]),
  ('control: typical', (100000, 20000, 5000, '17.5'), [14000, 89000]),
  ('control: credits exceed tax', (1000, 3000, 500, '20'), [0, -500])],
 [('regression surtax-base 1', (133783, 45064, 0, '17.5'), [15526, 104245]),
  ('regression surtax-base 2', (27192, 1000, 0, '12.5'), [3274, 29466]),
  ('partial repair guard 1', (44678, 28763, 500, '50'), [7958, 23373]),
  ('partial repair guard 2', (176644, 20000, 500, '8'), [12532, 168676]),
  ('control: typical', (100000, 20000, 5000, '17.5'), [14000, 89000]),
  ('control: credits exceed tax', (1000, 3000, 500, '20'), [0, -500]),
  ('control: rounding', (333, 0, 0, '1.5'), [5, 338]),
  ('control: large refund', (5000, 1000, 9000, '12.5'), [500, -4500])],
 [('regression surtax-base 1', (86323, 79662, 500, '12.5'), [833, 6994]),
  ('regression surtax-base 2', (44678, 28763, 500, '50'), [7958, 23373]),
  ('partial repair guard 1', (107676, 1000, 9000, '8'), [8534, 106210]),
  ('partial repair guard 2', (96269, 20000, 9000, '8'), [6102, 73371]),
  ('control: large refund', (5000, 1000, 9000, '12.5'), [500, -4500]),
  ('control: half cent', (1001, 0, 0, '50'), [501, 1502]), ('control: no surtax', (4200, 100, 0, '0'), [0, 4100]),
  ('control: typical', (100000, 20000, 5000, '17.5'), [14000, 89000])],
 [('regression surtax-base 1', (176644, 20000, 500, '8'), [12532, 168676]),
  ('regression surtax-base 2', (107676, 1000, 9000, '8'), [8534, 106210]),
  ('partial repair guard 1', (171795, 55836, 500, '1.5'), [1739, 117198]),
  ('partial repair guard 2', (195423, 1000, 9000, '17.5'), [34024, 219447]),
  ('control: typical', (100000, 20000, 5000, '17.5'), [14000, 89000]),
  ('control: credits exceed tax', (1000, 3000, 500, '20'), [0, -500]),
  ('control: rounding', (333, 0, 0, '1.5'), [5, 338]),
  ('control: large refund', (5000, 1000, 9000, '12.5'), [500, -4500])]]
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 surtax-base 1[14000, 89000][14000, 89000]Passed
regression surtax-base 2[0, -500][0, -500]Passed
partial repair guard 2[500, -4500][500, -4500]Passed
control: rounding[5, 338][5, 338]Passed
control: half cent[501, 1502][501, 1502]Passed
control: no surtax[0, 4100][0, 4100]Passed

SHA-256 / 396edfdb804134d218ef5ebae16782c84d1355c6a43a26d3c4769357a0b513c6

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

Case digest / e9ea5f6a65f313c779c8c7bcdbbf2edafb665712e64265be9e03eebd424af0c6