FAILURE MAP
← Case archive

FA-62356 / Tax bracket computation / Open access

A schedule with non-increasing thresholds is accepted · case 01

A mis-keyed bracket table silently produces a tax figure.

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

ROOT CAUSE

Only the open final bracket is validated; threshold order is not checked.

VERIFIED REPAIR

Reject schedules whose uppers are not strictly increasing and positive.

Unsuccessful approach: Checking only adjacent pairs after the first bracket misses a bad first threshold.

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]]
    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 threshold-validation 1', (10000, [[10000, '10'], [5000, '20'], [None, '30']]), 'ERR:brackets'),
  ('regression threshold-validation 2', (500, [[0, '10'], [None, '30']]), 'ERR:brackets'),
  ('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 threshold-validation 1', (1, [[44000, '15'], [44000, '22'], [None, '40.5']]), 'ERR:brackets'),
  ('regression threshold-validation 2', (10000, [[60000, '22'], [60000, '15'], [188000, '33.3'], [None, '37']]),
   'ERR:brackets'),
  ('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 threshold-validation 1', (999, [[24000, '33.3'], [24000, '22'], [150000, '10'], [None, '37']]),
   'ERR:brackets'),
  ('regression threshold-validation 2',
   (40000, [[83000, '5'], [83000, '10'], [156000, '10'], [192000, '10'], [None, '37']]), 'ERR:brackets'),
  ('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 threshold-validation 1', (10000, [[178000, '24'], [178000, '33.3'], [None, '45']]), 'ERR:brackets'),
  ('regression threshold-validation 2', (10000, [[44000, '5'], [44000, '15'], [None, '37']]), 'ERR:brackets'),
  ('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 threshold-validation 1', (999, [[105000, '15'], [105000, '24'], [None, '30']]), 'ERR:brackets'),
  ('regression threshold-validation 2', (10000, [[138000, '15'], [138000, '33.3'], [None, '45']]), 'ERR:brackets'),
  ('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 threshold-validation 1100000ERR:bracketsFailed
regression threshold-validation 215000ERR:bracketsFailed
control: three brackets680000680000Passed
control: at first threshold100000100000Passed
control: zero00Passed
control: negative00Passed

SHA-256 / a3c0c41470e8e0f982e6da184724f5e528ce6f2b9fb8e69ba7c2fc0c183c32f1

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(uppers[1:], uppers[2:])): 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 threshold-validation 1', (10000, [[10000, '10'], [5000, '20'], [None, '30']]), 'ERR:brackets'),
  ('regression threshold-validation 2', (500, [[0, '10'], [None, '30']]), 'ERR:brackets'),
  ('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 threshold-validation 1', (1, [[44000, '15'], [44000, '22'], [None, '40.5']]), 'ERR:brackets'),
  ('regression threshold-validation 2', (10000, [[60000, '22'], [60000, '15'], [188000, '33.3'], [None, '37']]),
   'ERR:brackets'),
  ('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 threshold-validation 1', (999, [[24000, '33.3'], [24000, '22'], [150000, '10'], [None, '37']]),
   'ERR:brackets'),
  ('regression threshold-validation 2',
   (40000, [[83000, '5'], [83000, '10'], [156000, '10'], [192000, '10'], [None, '37']]), 'ERR:brackets'),
  ('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 threshold-validation 1', (10000, [[178000, '24'], [178000, '33.3'], [None, '45']]), 'ERR:brackets'),
  ('regression threshold-validation 2', (10000, [[44000, '5'], [44000, '15'], [None, '37']]), 'ERR:brackets'),
  ('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 threshold-validation 1', (999, [[105000, '15'], [105000, '24'], [None, '30']]), 'ERR:brackets'),
  ('regression threshold-validation 2', (10000, [[138000, '15'], [138000, '33.3'], [None, '45']]), 'ERR:brackets'),
  ('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 threshold-validation 1100000ERR:bracketsFailed
regression threshold-validation 215000ERR:bracketsFailed
control: three brackets680000680000Passed
control: at first threshold100000100000Passed
control: zero00Passed
control: negative00Passed

SHA-256 / 0429aa19ae80b45b0b0fc87f18ea894f127b535d0e07047826f14ff1804ba856

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 threshold-validation 1', (10000, [[10000, '10'], [5000, '20'], [None, '30']]), 'ERR:brackets'),
  ('regression threshold-validation 2', (500, [[0, '10'], [None, '30']]), 'ERR:brackets'),
  ('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 threshold-validation 1', (1, [[44000, '15'], [44000, '22'], [None, '40.5']]), 'ERR:brackets'),
  ('regression threshold-validation 2', (10000, [[60000, '22'], [60000, '15'], [188000, '33.3'], [None, '37']]),
   'ERR:brackets'),
  ('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 threshold-validation 1', (999, [[24000, '33.3'], [24000, '22'], [150000, '10'], [None, '37']]),
   'ERR:brackets'),
  ('regression threshold-validation 2',
   (40000, [[83000, '5'], [83000, '10'], [156000, '10'], [192000, '10'], [None, '37']]), 'ERR:brackets'),
  ('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 threshold-validation 1', (10000, [[178000, '24'], [178000, '33.3'], [None, '45']]), 'ERR:brackets'),
  ('regression threshold-validation 2', (10000, [[44000, '5'], [44000, '15'], [None, '37']]), 'ERR:brackets'),
  ('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 threshold-validation 1', (999, [[105000, '15'], [105000, '24'], [None, '30']]), 'ERR:brackets'),
  ('regression threshold-validation 2', (10000, [[138000, '15'], [138000, '33.3'], [None, '45']]), 'ERR:brackets'),
  ('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 threshold-validation 1ERR:bracketsERR:bracketsPassed
regression threshold-validation 2ERR:bracketsERR:bracketsPassed
control: three brackets680000680000Passed
control: at first threshold100000100000Passed
control: zero00Passed
control: negative00Passed

SHA-256 / bc4394eb6be7cee552ab42fa5a848dcfd149528b9ee8b9ae496b18d0899782c7

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

Case digest / 2e7b77d349947626df02824b847824f240c406d82ef135137653fb13e346f628