FAILURE MAP
← Case archive

FA-62366 / Tax bracket computation / Open access

The final tax is converted to cents through binary floating point · case 01

A liability of 4.60 is reported as 459 cents.

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

ROOT CAUSE

The exact tax is rounded with float arithmetic, int(round(float(tax), 2) * 100).

VERIFIED REPAIR

Round the exact rational tax half-up to cents.

Unsuccessful approach: Truncating the exact value to cents avoids float error but drops half-cents.

Case contract

solve(income, brackets): brackets is [[upper, rate_percent], ...] with strictly increasing positive uppers and a final open bracket [None, rate]; otherwise return 'ERR:brackets'. Each rate applies only to the slice of income in (previous upper, upper]. Negative income is taxed as zero. The tax is summed exactly and rounded half-up to cents once, returned as 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):
    if not brackets or brackets[-1][0] is not None: return 'ERR:brackets'
    uppers = [u for u, _ in brackets[:-1]]
    if any(b <= a for a, b in zip([0] + uppers, uppers)): return 'ERR:brackets'
    x = max(0, income)
    tax, lower = Fraction(0), 0
    for upper, rate in brackets:
        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 int(round(float(tax), 2) * 100)
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
cases = [[('regression final-cent-rounding 1', (46, [[None, '10']]), 460),
  ('regression final-cent-rounding 2', (41, [[None, '12.5']]), 513),
  ('partial repair guard 2', (250001, [[11000, '10'], [44725, '12'], [95375, '22'], [182100, '24'], [None, '32.5']]),
   5917183),
  ('control: three brackets', (50000, [[10000, '10'], [40000, '12'], [None, '22']]), 680000),
  ('control: at first threshold', (10000, [[10000, '10'], [40000, '12'], [None, '22']]), 100000),
  ('control: zero', (0, [[10000, '10'], [40000, '12'], [None, '22']]), 0),
  ('control: negative', (-5, [[10000, '10'], [40000, '12'], [None, '22']]), 0)],
 [('regression final-cent-rounding 1',
   (250001, [[11000, '10'], [44725, '12'], [95375, '22'], [182100, '24'], [None, '32.5']]), 5917183),
  ('regression final-cent-rounding 2', (777, [[None, '12.5']]), 9713),
  ('partial repair guard 2', (999, [[24000, '33.3'], [134000, '15'], [190000, '15'], [None, '40.5']]), 33267),
  ('control: negative', (-5, [[10000, '10'], [40000, '12'], [None, '22']]), 0),
  ('control: one over threshold', (40001, [[10000, '10'], [40000, '12'], [None, '22']]), 460022),
  ('control: fractional rate', (12345, [[11000, '10'], [44725, '12'], [95375, '22'], [182100, '24'], [None, '32.5']]),
   126140),
  ('control: non increasing', (10000, [[10000, '10'], [5000, '20'], [None, '30']]), 'ERR:brackets')],
 [('regression final-cent-rounding 1', (10001, [[18000, '12.5'], [80000, '22'], [None, '30']]), 125013),
  ('regression final-cent-rounding 2', (10001, [[60000, '12.5'], [92000, '22'], [None, '45']]), 125013),
  ('partial repair guard 2', (999, [[166000, '33.3'], [178000, '10'], [None, '40.5']]), 33267),
  ('control: non increasing', (10000, [[10000, '10'], [5000, '20'], [None, '30']]), 'ERR:brackets'),
  ('control: closed top', (10, [[10000, '10'], [20000, '20']]), 'ERR:brackets'),
  ('control: high earner', (250001, [[11000, '10'], [44725, '12'], [95375, '22'], [182100, '24'], [None, '32.5']]),
   5917183),
  ('control: single bracket', (777, [[None, '12.5']]), 9713)],
 [('regression final-cent-rounding 1', (1, [[68000, '12.5'], [81000, '10'], [167000, '33.3'], [None, '45']]), 13),
  ('regression final-cent-rounding 2',
   (64068, [[32000, '22'], [105000, '10'], [170000, '24'], [193000, '10'], [None, '37']]), 1024680),
  ('partial repair guard 1', (10001, [[60000, '12.5'], [92000, '22'], [None, '45']]), 125013),
  ('partial repair guard 2', (999, [[17000, '33.3'], [None, '40.5']]), 33267),
  ('control: single bracket', (777, [[None, '12.5']]), 9713),
  ('control: three brackets', (50000, [[10000, '10'], [40000, '12'], [None, '22']]), 680000),
  ('control: at first threshold', (10000, [[10000, '10'], [40000, '12'], [None, '22']]), 100000),
  ('control: zero', (0, [[10000, '10'], [40000, '12'], [None, '22']]), 0)],
 [('regression final-cent-rounding 1', (1, [[94000, '12.5'], [191000, '24'], [None, '45']]), 13),
  ('regression final-cent-rounding 2', (1, [[1000, '12.5'], [59000, '24'], [None, '40.5']]), 13),
  ('partial repair guard 1', (1, [[68000, '12.5'], [81000, '10'], [167000, '33.3'], [None, '45']]), 13),
  ('control: zero', (0, [[10000, '10'], [40000, '12'], [None, '22']]), 0),
  ('control: negative', (-5, [[10000, '10'], [40000, '12'], [None, '22']]), 0),
  ('control: one over threshold', (40001, [[10000, '10'], [40000, '12'], [None, '22']]), 460022),
  ('control: fractional rate', (12345, [[11000, '10'], [44725, '12'], [95375, '22'], [182100, '24'], [None, '32.5']]),
   126140)]]
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 final-cent-rounding 1459460Failed
regression final-cent-rounding 2512513Failed
partial repair guard 259171825917183Failed
control: three brackets680000680000Passed
control: at first threshold100000100000Passed
control: zero00Passed
control: negative00Passed

SHA-256 / f399be2c6c6457f1371b7b823cbc0c22cbd86404560337d5ed18429e0c82801c

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):
    if not brackets or brackets[-1][0] is not None: return 'ERR:brackets'
    uppers = [u for u, _ in brackets[:-1]]
    if any(b <= a for a, b in zip([0] + uppers, uppers)): return 'ERR:brackets'
    x = max(0, income)
    tax, lower = Fraction(0), 0
    for upper, rate in brackets:
        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 int(tax * 100)
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
cases = [[('regression final-cent-rounding 1', (46, [[None, '10']]), 460),
  ('regression final-cent-rounding 2', (41, [[None, '12.5']]), 513),
  ('partial repair guard 2', (250001, [[11000, '10'], [44725, '12'], [95375, '22'], [182100, '24'], [None, '32.5']]),
   5917183),
  ('control: three brackets', (50000, [[10000, '10'], [40000, '12'], [None, '22']]), 680000),
  ('control: at first threshold', (10000, [[10000, '10'], [40000, '12'], [None, '22']]), 100000),
  ('control: zero', (0, [[10000, '10'], [40000, '12'], [None, '22']]), 0),
  ('control: negative', (-5, [[10000, '10'], [40000, '12'], [None, '22']]), 0)],
 [('regression final-cent-rounding 1',
   (250001, [[11000, '10'], [44725, '12'], [95375, '22'], [182100, '24'], [None, '32.5']]), 5917183),
  ('regression final-cent-rounding 2', (777, [[None, '12.5']]), 9713),
  ('partial repair guard 2', (999, [[24000, '33.3'], [134000, '15'], [190000, '15'], [None, '40.5']]), 33267),
  ('control: negative', (-5, [[10000, '10'], [40000, '12'], [None, '22']]), 0),
  ('control: one over threshold', (40001, [[10000, '10'], [40000, '12'], [None, '22']]), 460022),
  ('control: fractional rate', (12345, [[11000, '10'], [44725, '12'], [95375, '22'], [182100, '24'], [None, '32.5']]),
   126140),
  ('control: non increasing', (10000, [[10000, '10'], [5000, '20'], [None, '30']]), 'ERR:brackets')],
 [('regression final-cent-rounding 1', (10001, [[18000, '12.5'], [80000, '22'], [None, '30']]), 125013),
  ('regression final-cent-rounding 2', (10001, [[60000, '12.5'], [92000, '22'], [None, '45']]), 125013),
  ('partial repair guard 2', (999, [[166000, '33.3'], [178000, '10'], [None, '40.5']]), 33267),
  ('control: non increasing', (10000, [[10000, '10'], [5000, '20'], [None, '30']]), 'ERR:brackets'),
  ('control: closed top', (10, [[10000, '10'], [20000, '20']]), 'ERR:brackets'),
  ('control: high earner', (250001, [[11000, '10'], [44725, '12'], [95375, '22'], [182100, '24'], [None, '32.5']]),
   5917183),
  ('control: single bracket', (777, [[None, '12.5']]), 9713)],
 [('regression final-cent-rounding 1', (1, [[68000, '12.5'], [81000, '10'], [167000, '33.3'], [None, '45']]), 13),
  ('regression final-cent-rounding 2',
   (64068, [[32000, '22'], [105000, '10'], [170000, '24'], [193000, '10'], [None, '37']]), 1024680),
  ('partial repair guard 1', (10001, [[60000, '12.5'], [92000, '22'], [None, '45']]), 125013),
  ('partial repair guard 2', (999, [[17000, '33.3'], [None, '40.5']]), 33267),
  ('control: single bracket', (777, [[None, '12.5']]), 9713),
  ('control: three brackets', (50000, [[10000, '10'], [40000, '12'], [None, '22']]), 680000),
  ('control: at first threshold', (10000, [[10000, '10'], [40000, '12'], [None, '22']]), 100000),
  ('control: zero', (0, [[10000, '10'], [40000, '12'], [None, '22']]), 0)],
 [('regression final-cent-rounding 1', (1, [[94000, '12.5'], [191000, '24'], [None, '45']]), 13),
  ('regression final-cent-rounding 2', (1, [[1000, '12.5'], [59000, '24'], [None, '40.5']]), 13),
  ('partial repair guard 1', (1, [[68000, '12.5'], [81000, '10'], [167000, '33.3'], [None, '45']]), 13),
  ('control: zero', (0, [[10000, '10'], [40000, '12'], [None, '22']]), 0),
  ('control: negative', (-5, [[10000, '10'], [40000, '12'], [None, '22']]), 0),
  ('control: one over threshold', (40001, [[10000, '10'], [40000, '12'], [None, '22']]), 460022),
  ('control: fractional rate', (12345, [[11000, '10'], [44725, '12'], [95375, '22'], [182100, '24'], [None, '32.5']]),
   126140)]]
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 final-cent-rounding 1460460Passed
regression final-cent-rounding 2512513Failed
partial repair guard 259171825917183Failed
control: three brackets680000680000Passed
control: at first threshold100000100000Passed
control: zero00Passed
control: negative00Passed

SHA-256 / 704b82fde7e315a6d05db6d75243e4898a57d9a3abb4f53f80b54c9b734aa4c3

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):
    if not brackets or brackets[-1][0] is not None: return 'ERR:brackets'
    uppers = [u for u, _ in brackets[:-1]]
    if any(b <= a for a, b in zip([0] + uppers, uppers)): return 'ERR:brackets'
    x = max(0, income)
    tax, lower = Fraction(0), 0
    for upper, rate in brackets:
        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 int(tax * 100 + Fraction(1, 2))
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
cases = [[('regression final-cent-rounding 1', (46, [[None, '10']]), 460),
  ('regression final-cent-rounding 2', (41, [[None, '12.5']]), 513),
  ('partial repair guard 2', (250001, [[11000, '10'], [44725, '12'], [95375, '22'], [182100, '24'], [None, '32.5']]),
   5917183),
  ('control: three brackets', (50000, [[10000, '10'], [40000, '12'], [None, '22']]), 680000),
  ('control: at first threshold', (10000, [[10000, '10'], [40000, '12'], [None, '22']]), 100000),
  ('control: zero', (0, [[10000, '10'], [40000, '12'], [None, '22']]), 0),
  ('control: negative', (-5, [[10000, '10'], [40000, '12'], [None, '22']]), 0)],
 [('regression final-cent-rounding 1',
   (250001, [[11000, '10'], [44725, '12'], [95375, '22'], [182100, '24'], [None, '32.5']]), 5917183),
  ('regression final-cent-rounding 2', (777, [[None, '12.5']]), 9713),
  ('partial repair guard 2', (999, [[24000, '33.3'], [134000, '15'], [190000, '15'], [None, '40.5']]), 33267),
  ('control: negative', (-5, [[10000, '10'], [40000, '12'], [None, '22']]), 0),
  ('control: one over threshold', (40001, [[10000, '10'], [40000, '12'], [None, '22']]), 460022),
  ('control: fractional rate', (12345, [[11000, '10'], [44725, '12'], [95375, '22'], [182100, '24'], [None, '32.5']]),
   126140),
  ('control: non increasing', (10000, [[10000, '10'], [5000, '20'], [None, '30']]), 'ERR:brackets')],
 [('regression final-cent-rounding 1', (10001, [[18000, '12.5'], [80000, '22'], [None, '30']]), 125013),
  ('regression final-cent-rounding 2', (10001, [[60000, '12.5'], [92000, '22'], [None, '45']]), 125013),
  ('partial repair guard 2', (999, [[166000, '33.3'], [178000, '10'], [None, '40.5']]), 33267),
  ('control: non increasing', (10000, [[10000, '10'], [5000, '20'], [None, '30']]), 'ERR:brackets'),
  ('control: closed top', (10, [[10000, '10'], [20000, '20']]), 'ERR:brackets'),
  ('control: high earner', (250001, [[11000, '10'], [44725, '12'], [95375, '22'], [182100, '24'], [None, '32.5']]),
   5917183),
  ('control: single bracket', (777, [[None, '12.5']]), 9713)],
 [('regression final-cent-rounding 1', (1, [[68000, '12.5'], [81000, '10'], [167000, '33.3'], [None, '45']]), 13),
  ('regression final-cent-rounding 2',
   (64068, [[32000, '22'], [105000, '10'], [170000, '24'], [193000, '10'], [None, '37']]), 1024680),
  ('partial repair guard 1', (10001, [[60000, '12.5'], [92000, '22'], [None, '45']]), 125013),
  ('partial repair guard 2', (999, [[17000, '33.3'], [None, '40.5']]), 33267),
  ('control: single bracket', (777, [[None, '12.5']]), 9713),
  ('control: three brackets', (50000, [[10000, '10'], [40000, '12'], [None, '22']]), 680000),
  ('control: at first threshold', (10000, [[10000, '10'], [40000, '12'], [None, '22']]), 100000),
  ('control: zero', (0, [[10000, '10'], [40000, '12'], [None, '22']]), 0)],
 [('regression final-cent-rounding 1', (1, [[94000, '12.5'], [191000, '24'], [None, '45']]), 13),
  ('regression final-cent-rounding 2', (1, [[1000, '12.5'], [59000, '24'], [None, '40.5']]), 13),
  ('partial repair guard 1', (1, [[68000, '12.5'], [81000, '10'], [167000, '33.3'], [None, '45']]), 13),
  ('control: zero', (0, [[10000, '10'], [40000, '12'], [None, '22']]), 0),
  ('control: negative', (-5, [[10000, '10'], [40000, '12'], [None, '22']]), 0),
  ('control: one over threshold', (40001, [[10000, '10'], [40000, '12'], [None, '22']]), 460022),
  ('control: fractional rate', (12345, [[11000, '10'], [44725, '12'], [95375, '22'], [182100, '24'], [None, '32.5']]),
   126140)]]
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 final-cent-rounding 1460460Passed
regression final-cent-rounding 2513513Passed
partial repair guard 259171835917183Passed
control: three brackets680000680000Passed
control: at first threshold100000100000Passed
control: zero00Passed
control: negative00Passed

SHA-256 / e7e127e689de1814f9112a9bc29763b2ce5764e90cc39b870e0cf93694cda7fd

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

Case digest / dee970e9fdb0dd53762f810d2cefa00365496e44e91fe52e0b771caa2e2deec7