FAILURE MAP
← Case archive

FA-62511 / Tax bracket computation / Open access

The tax table uses the bottom of each band instead of its midpoint · case 01

Tax-table amounts are systematically a few dollars low.

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

ROOT CAUSE

The band's lower edge is taxed instead of its midpoint.

VERIFIED REPAIR

Tax the band midpoint lo + width/2.

Unsuccessful approach: Hard-coding the 25-dollar half-width of the wide bands puts narrow-band midpoints at their upper edge.

Case contract

solve(income, brackets): stipulated tax-table lookup. income < 0 returns 0 and incomes below 5 have zero tax. For income < 100000 the tax is the progressive tax on the midpoint of the income's band, rounded half-up to whole dollars: bands are 25 wide below 3000 ([0,25), [25,50), ...) and 50 wide from 3000 ([3000,3050), ...). Incomes of 100000 or more use the exact progressive tax rounded half-up to cents. Return integer cents.

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(income, brackets):
    def prog(x, br):
        tax, lower = Fraction(0), 0
        for upper, rate in br:
            top = x if upper is None else min(x, upper)
            if top > lower: tax += (top - lower) * Fraction(rate) / 100
            if upper is None or x <= upper: break
            lower = upper
        return tax
    def cents(v):
        v = v * 100
        return int(v + Fraction(1, 2)) if v >= 0 else -int(-v + Fraction(1, 2))
    
    if income < 5: return 0
    if income >= 100000: return cents(prog(income, brackets))
    w = 25 if income < 3000 else 50
    lo = income // w * w
    mid = lo
    return int(prog(mid, brackets) + Fraction(1, 2)) * 100
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
cases = [[('regression band-midpoint 1', (12345, [[10000, '10'], [40000, '12'], [None, '22']]), 127900),
  ('regression band-midpoint 2', (2999, [[10000, '10'], [40000, '12'], [None, '22']]), 29900),
  ('partial repair guard 2', (24, [[None, '10']]), 100),
  ('control: first wide band', (3000, [[10000, '10'], [40000, '12'], [None, '22']]), 30300),
  ('control: table cutoff', (100000, [[10000, '10'], [40000, '12'], [None, '22']]), 1780000),
  ('control: tiny', (4, [[10000, '10'], [40000, '12'], [None, '22']]), 0),
  ('control: small', (24, [[10000, '10'], [40000, '12'], [None, '22']]), 100)],
 [('regression band-midpoint 1', (24, [[None, '10']]), 100),
  ('regression band-midpoint 2', (3000, [[10000, '10'], [40000, '12'], [None, '22']]), 30300),
  ('partial repair guard 1', (24, [[10000, '10'], [40000, '12'], [None, '22']]), 100),
  ('partial repair guard 2', (576, [[10000, '10'], [40000, '12'], [None, '22']]), 5900),
  ('control: table cutoff', (100000, [[10000, '10'], [40000, '12'], [None, '22']]), 1780000),
  ('control: tiny', (4, [[10000, '10'], [40000, '12'], [None, '22']]), 0),
  ('control: just under cutoff', (99999, [[11000, '10'], [44725, '12'], [95375, '22'], [182100, '24'], [None, '32.5']]),
   1739400),
  ('control: above cutoff', (100001, [[11000, '10'], [44725, '12'], [95375, '22'], [182100, '24'], [None, '32.5']]),
   1740024)],
 [('regression band-midpoint 1', (24, [[10000, '10'], [40000, '12'], [None, '22']]), 100),
  ('regression band-midpoint 2', (99999, [[11000, '10'], [44725, '12'], [95375, '22'], [182100, '24'], [None, '32.5']]),
   1739400),
  ('partial repair guard 1', (603, [[10000, '10'], [40000, '12'], [None, '22']]), 6100),
  ('partial repair guard 2', (5, [[11000, '10'], [44725, '12'], [95375, '22'], [182100, '24'], [None, '32.5']]), 100),
  ('control: above cutoff', (100001, [[11000, '10'], [44725, '12'], [95375, '22'], [182100, '24'], [None, '32.5']]),
   1740024),
  ('control: band edge', (40050, [[10000, '10'], [40000, '12'], [None, '22']]), 461700),
  ('control: last narrow band', (2999, [[10000, '10'], [40000, '12'], [None, '22']]), 29900),
  ('control: first wide band', (3000, [[10000, '10'], [40000, '12'], [None, '22']]), 30300)],
 [('regression band-midpoint 1', (40050, [[10000, '10'], [40000, '12'], [None, '22']]), 461700),
  ('regression band-midpoint 2', (61548, [[11000, '10'], [44725, '12'], [95375, '22'], [182100, '24'], [None, '32.5']]),
   884300),
  ('partial repair guard 1', (2999, [[11000, '10'], [44725, '12'], [95375, '22'], [182100, '24'], [None, '32.5']]),
   29900),
  ('partial repair guard 2', (1821, [[10000, '10'], [40000, '12'], [None, '22']]), 18100),
  ('control: last narrow band', (2999, [[10000, '10'], [40000, '12'], [None, '22']]), 29900),
  ('control: first wide band', (3000, [[10000, '10'], [40000, '12'], [None, '22']]), 30300),
  ('control: ordinary', (12345, [[10000, '10'], [40000, '12'], [None, '22']]), 127900),
  ('control: table cutoff', (100000, [[10000, '10'], [40000, '12'], [None, '22']]), 1780000)],
 [('regression band-midpoint 1', (576, [[10000, '10'], [40000, '12'], [None, '22']]), 5900),
  ('regression band-midpoint 2', (603, [[10000, '10'], [40000, '12'], [None, '22']]), 6100),
  ('partial repair guard 1', (1428, [[10000, '10'], [40000, '12'], [None, '22']]), 14400),
  ('partial repair guard 2', (12, [[10000, '10'], [40000, '12'], [None, '22']]), 100),
  ('control: table cutoff', (100000, [[10000, '10'], [40000, '12'], [None, '22']]), 1780000),
  ('control: tiny', (4, [[10000, '10'], [40000, '12'], [None, '22']]), 0),
  ('control: small', (24, [[10000, '10'], [40000, '12'], [None, '22']]), 100),
  ('control: just under cutoff', (99999, [[11000, '10'], [44725, '12'], [95375, '22'], [182100, '24'], [None, '32.5']]),
   1739400)]]
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 band-midpoint 1127600127900Failed
regression band-midpoint 22980029900Failed
partial repair guard 20100Failed
control: first wide band3000030300Failed
control: table cutoff17800001780000Passed
control: tiny00Passed
control: small0100Failed

SHA-256 / 8a61c33e5ac81e52165cbb01bc8b0e8eaa41b560425fca7a187583a07f2ab85e

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(income, brackets):
    def prog(x, br):
        tax, lower = Fraction(0), 0
        for upper, rate in br:
            top = x if upper is None else min(x, upper)
            if top > lower: tax += (top - lower) * Fraction(rate) / 100
            if upper is None or x <= upper: break
            lower = upper
        return tax
    def cents(v):
        v = v * 100
        return int(v + Fraction(1, 2)) if v >= 0 else -int(-v + Fraction(1, 2))
    
    if income < 5: return 0
    if income >= 100000: return cents(prog(income, brackets))
    w = 25 if income < 3000 else 50
    lo = income // w * w
    mid = lo + 25
    return int(prog(mid, brackets) + Fraction(1, 2)) * 100
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
cases = [[('regression band-midpoint 1', (12345, [[10000, '10'], [40000, '12'], [None, '22']]), 127900),
  ('regression band-midpoint 2', (2999, [[10000, '10'], [40000, '12'], [None, '22']]), 29900),
  ('partial repair guard 2', (24, [[None, '10']]), 100),
  ('control: first wide band', (3000, [[10000, '10'], [40000, '12'], [None, '22']]), 30300),
  ('control: table cutoff', (100000, [[10000, '10'], [40000, '12'], [None, '22']]), 1780000),
  ('control: tiny', (4, [[10000, '10'], [40000, '12'], [None, '22']]), 0),
  ('control: small', (24, [[10000, '10'], [40000, '12'], [None, '22']]), 100)],
 [('regression band-midpoint 1', (24, [[None, '10']]), 100),
  ('regression band-midpoint 2', (3000, [[10000, '10'], [40000, '12'], [None, '22']]), 30300),
  ('partial repair guard 1', (24, [[10000, '10'], [40000, '12'], [None, '22']]), 100),
  ('partial repair guard 2', (576, [[10000, '10'], [40000, '12'], [None, '22']]), 5900),
  ('control: table cutoff', (100000, [[10000, '10'], [40000, '12'], [None, '22']]), 1780000),
  ('control: tiny', (4, [[10000, '10'], [40000, '12'], [None, '22']]), 0),
  ('control: just under cutoff', (99999, [[11000, '10'], [44725, '12'], [95375, '22'], [182100, '24'], [None, '32.5']]),
   1739400),
  ('control: above cutoff', (100001, [[11000, '10'], [44725, '12'], [95375, '22'], [182100, '24'], [None, '32.5']]),
   1740024)],
 [('regression band-midpoint 1', (24, [[10000, '10'], [40000, '12'], [None, '22']]), 100),
  ('regression band-midpoint 2', (99999, [[11000, '10'], [44725, '12'], [95375, '22'], [182100, '24'], [None, '32.5']]),
   1739400),
  ('partial repair guard 1', (603, [[10000, '10'], [40000, '12'], [None, '22']]), 6100),
  ('partial repair guard 2', (5, [[11000, '10'], [44725, '12'], [95375, '22'], [182100, '24'], [None, '32.5']]), 100),
  ('control: above cutoff', (100001, [[11000, '10'], [44725, '12'], [95375, '22'], [182100, '24'], [None, '32.5']]),
   1740024),
  ('control: band edge', (40050, [[10000, '10'], [40000, '12'], [None, '22']]), 461700),
  ('control: last narrow band', (2999, [[10000, '10'], [40000, '12'], [None, '22']]), 29900),
  ('control: first wide band', (3000, [[10000, '10'], [40000, '12'], [None, '22']]), 30300)],
 [('regression band-midpoint 1', (40050, [[10000, '10'], [40000, '12'], [None, '22']]), 461700),
  ('regression band-midpoint 2', (61548, [[11000, '10'], [44725, '12'], [95375, '22'], [182100, '24'], [None, '32.5']]),
   884300),
  ('partial repair guard 1', (2999, [[11000, '10'], [44725, '12'], [95375, '22'], [182100, '24'], [None, '32.5']]),
   29900),
  ('partial repair guard 2', (1821, [[10000, '10'], [40000, '12'], [None, '22']]), 18100),
  ('control: last narrow band', (2999, [[10000, '10'], [40000, '12'], [None, '22']]), 29900),
  ('control: first wide band', (3000, [[10000, '10'], [40000, '12'], [None, '22']]), 30300),
  ('control: ordinary', (12345, [[10000, '10'], [40000, '12'], [None, '22']]), 127900),
  ('control: table cutoff', (100000, [[10000, '10'], [40000, '12'], [None, '22']]), 1780000)],
 [('regression band-midpoint 1', (576, [[10000, '10'], [40000, '12'], [None, '22']]), 5900),
  ('regression band-midpoint 2', (603, [[10000, '10'], [40000, '12'], [None, '22']]), 6100),
  ('partial repair guard 1', (1428, [[10000, '10'], [40000, '12'], [None, '22']]), 14400),
  ('partial repair guard 2', (12, [[10000, '10'], [40000, '12'], [None, '22']]), 100),
  ('control: table cutoff', (100000, [[10000, '10'], [40000, '12'], [None, '22']]), 1780000),
  ('control: tiny', (4, [[10000, '10'], [40000, '12'], [None, '22']]), 0),
  ('control: small', (24, [[10000, '10'], [40000, '12'], [None, '22']]), 100),
  ('control: just under cutoff', (99999, [[11000, '10'], [44725, '12'], [95375, '22'], [182100, '24'], [None, '32.5']]),
   1739400)]]
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 band-midpoint 1127900127900Passed
regression band-midpoint 23000029900Failed
partial repair guard 2300100Failed
control: first wide band3030030300Passed
control: table cutoff17800001780000Passed
control: tiny00Passed
control: small300100Failed

SHA-256 / b6fac88566c7c0039def5510e0ac3ed3dad46673f4f5762dc9c8a5aa2f7ba799

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(income, brackets):
    def prog(x, br):
        tax, lower = Fraction(0), 0
        for upper, rate in br:
            top = x if upper is None else min(x, upper)
            if top > lower: tax += (top - lower) * Fraction(rate) / 100
            if upper is None or x <= upper: break
            lower = upper
        return tax
    def cents(v):
        v = v * 100
        return int(v + Fraction(1, 2)) if v >= 0 else -int(-v + Fraction(1, 2))
    
    if income < 5: return 0
    if income >= 100000: return cents(prog(income, brackets))
    w = 25 if income < 3000 else 50
    lo = income // w * w
    mid = lo + Fraction(w, 2)
    return int(prog(mid, brackets) + Fraction(1, 2)) * 100
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
cases = [[('regression band-midpoint 1', (12345, [[10000, '10'], [40000, '12'], [None, '22']]), 127900),
  ('regression band-midpoint 2', (2999, [[10000, '10'], [40000, '12'], [None, '22']]), 29900),
  ('partial repair guard 2', (24, [[None, '10']]), 100),
  ('control: first wide band', (3000, [[10000, '10'], [40000, '12'], [None, '22']]), 30300),
  ('control: table cutoff', (100000, [[10000, '10'], [40000, '12'], [None, '22']]), 1780000),
  ('control: tiny', (4, [[10000, '10'], [40000, '12'], [None, '22']]), 0),
  ('control: small', (24, [[10000, '10'], [40000, '12'], [None, '22']]), 100)],
 [('regression band-midpoint 1', (24, [[None, '10']]), 100),
  ('regression band-midpoint 2', (3000, [[10000, '10'], [40000, '12'], [None, '22']]), 30300),
  ('partial repair guard 1', (24, [[10000, '10'], [40000, '12'], [None, '22']]), 100),
  ('partial repair guard 2', (576, [[10000, '10'], [40000, '12'], [None, '22']]), 5900),
  ('control: table cutoff', (100000, [[10000, '10'], [40000, '12'], [None, '22']]), 1780000),
  ('control: tiny', (4, [[10000, '10'], [40000, '12'], [None, '22']]), 0),
  ('control: just under cutoff', (99999, [[11000, '10'], [44725, '12'], [95375, '22'], [182100, '24'], [None, '32.5']]),
   1739400),
  ('control: above cutoff', (100001, [[11000, '10'], [44725, '12'], [95375, '22'], [182100, '24'], [None, '32.5']]),
   1740024)],
 [('regression band-midpoint 1', (24, [[10000, '10'], [40000, '12'], [None, '22']]), 100),
  ('regression band-midpoint 2', (99999, [[11000, '10'], [44725, '12'], [95375, '22'], [182100, '24'], [None, '32.5']]),
   1739400),
  ('partial repair guard 1', (603, [[10000, '10'], [40000, '12'], [None, '22']]), 6100),
  ('partial repair guard 2', (5, [[11000, '10'], [44725, '12'], [95375, '22'], [182100, '24'], [None, '32.5']]), 100),
  ('control: above cutoff', (100001, [[11000, '10'], [44725, '12'], [95375, '22'], [182100, '24'], [None, '32.5']]),
   1740024),
  ('control: band edge', (40050, [[10000, '10'], [40000, '12'], [None, '22']]), 461700),
  ('control: last narrow band', (2999, [[10000, '10'], [40000, '12'], [None, '22']]), 29900),
  ('control: first wide band', (3000, [[10000, '10'], [40000, '12'], [None, '22']]), 30300)],
 [('regression band-midpoint 1', (40050, [[10000, '10'], [40000, '12'], [None, '22']]), 461700),
  ('regression band-midpoint 2', (61548, [[11000, '10'], [44725, '12'], [95375, '22'], [182100, '24'], [None, '32.5']]),
   884300),
  ('partial repair guard 1', (2999, [[11000, '10'], [44725, '12'], [95375, '22'], [182100, '24'], [None, '32.5']]),
   29900),
  ('partial repair guard 2', (1821, [[10000, '10'], [40000, '12'], [None, '22']]), 18100),
  ('control: last narrow band', (2999, [[10000, '10'], [40000, '12'], [None, '22']]), 29900),
  ('control: first wide band', (3000, [[10000, '10'], [40000, '12'], [None, '22']]), 30300),
  ('control: ordinary', (12345, [[10000, '10'], [40000, '12'], [None, '22']]), 127900),
  ('control: table cutoff', (100000, [[10000, '10'], [40000, '12'], [None, '22']]), 1780000)],
 [('regression band-midpoint 1', (576, [[10000, '10'], [40000, '12'], [None, '22']]), 5900),
  ('regression band-midpoint 2', (603, [[10000, '10'], [40000, '12'], [None, '22']]), 6100),
  ('partial repair guard 1', (1428, [[10000, '10'], [40000, '12'], [None, '22']]), 14400),
  ('partial repair guard 2', (12, [[10000, '10'], [40000, '12'], [None, '22']]), 100),
  ('control: table cutoff', (100000, [[10000, '10'], [40000, '12'], [None, '22']]), 1780000),
  ('control: tiny', (4, [[10000, '10'], [40000, '12'], [None, '22']]), 0),
  ('control: small', (24, [[10000, '10'], [40000, '12'], [None, '22']]), 100),
  ('control: just under cutoff', (99999, [[11000, '10'], [44725, '12'], [95375, '22'], [182100, '24'], [None, '32.5']]),
   1739400)]]
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 band-midpoint 1127900127900Passed
regression band-midpoint 22990029900Passed
partial repair guard 2100100Passed
control: first wide band3030030300Passed
control: table cutoff17800001780000Passed
control: tiny00Passed
control: small100100Passed

SHA-256 / 8d0169ed1045b6fc67fb727890a10d7b7c0d364dd027891646ce182516c34929

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

Case digest / 9efc4aa2212d4078032e68f54e9aa3d71cd1bd88dd48f889389ea3ab8851cbb2