FA-62361 / Tax bracket computation / Open access
Income above the last threshold escapes tax · case 01
High earners pay the same tax as someone exactly at the final threshold.
ROOT CAUSE
The loop skips the open-ended final bracket.
VERIFIED REPAIR
Apply the final rate to all income above the last threshold.
Unsuccessful approach: Taxing the excess at the second-to-last rate still ignores the top rate.
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[:-1]:
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 open-top-bracket 1',
(250001, [[11000, '10'], [44725, '12'], [95375, '22'], [182100, '24'], [None, '32.5']]), 5917183),
('regression open-top-bracket 2', (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),
('control: one over threshold', (40001, [[10000, '10'], [40000, '12'], [None, '22']]), 460022)],
[('regression open-top-bracket 1', (40001, [[10000, '10'], [40000, '12'], [None, '22']]), 460022),
('regression open-top-bracket 2', (777, [[None, '12.5']]), 9713),
('control: negative', (-5, [[10000, '10'], [40000, '12'], [None, '22']]), 0),
('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'),
('control: closed top', (10, [[10000, '10'], [20000, '20']]), 'ERR:brackets')],
[('regression open-top-bracket 1',
(232540, [[34000, '22'], [101000, '15'], [147000, '10'], [184000, '10'], [None, '30']]), 4039200),
('regression open-top-bracket 2', (40000, [[None, '45']]), 1800000),
('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 open-top-bracket 1', (139460, [[None, '40.5']]), 5648130),
('regression open-top-bracket 2',
(236107, [[31000, '10'], [159000, '10'], [172000, '24'], [193000, '22'], [None, '45']]), 4303815),
('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 open-top-bracket 1',
(221539, [[9000, '24'], [72000, '5'], [91000, '33.3'], [101000, '5'], [None, '37']]), 5673643),
('regression open-top-bracket 2', (172773, [[None, '30']]), 5183190),
('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 fixture | Actual | Expected | Outcome |
|---|---|---|---|
| regression open-top-bracket 1 | 3710400 | 5917183 | Failed |
| regression open-top-bracket 2 | 460000 | 680000 | Failed |
| control: at first threshold | 100000 | 100000 | Passed |
| control: zero | 0 | 0 | Passed |
| control: negative | 0 | 0 | Passed |
| control: one over threshold | 460000 | 460022 | Failed |
SHA-256 / 3390111d10f109f93b7318c6bb0cc0952fee7a433bfc340984b3c322b7a5f781
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[:-1]:
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
if len(brackets) > 1 and x > brackets[-2][0]: tax += (x - brackets[-2][0]) * Fraction(brackets[-2][1]) / 100
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 open-top-bracket 1',
(250001, [[11000, '10'], [44725, '12'], [95375, '22'], [182100, '24'], [None, '32.5']]), 5917183),
('regression open-top-bracket 2', (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),
('control: one over threshold', (40001, [[10000, '10'], [40000, '12'], [None, '22']]), 460022)],
[('regression open-top-bracket 1', (40001, [[10000, '10'], [40000, '12'], [None, '22']]), 460022),
('regression open-top-bracket 2', (777, [[None, '12.5']]), 9713),
('control: negative', (-5, [[10000, '10'], [40000, '12'], [None, '22']]), 0),
('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'),
('control: closed top', (10, [[10000, '10'], [20000, '20']]), 'ERR:brackets')],
[('regression open-top-bracket 1',
(232540, [[34000, '22'], [101000, '15'], [147000, '10'], [184000, '10'], [None, '30']]), 4039200),
('regression open-top-bracket 2', (40000, [[None, '45']]), 1800000),
('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 open-top-bracket 1', (139460, [[None, '40.5']]), 5648130),
('regression open-top-bracket 2',
(236107, [[31000, '10'], [159000, '10'], [172000, '24'], [193000, '22'], [None, '45']]), 4303815),
('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 open-top-bracket 1',
(221539, [[9000, '24'], [72000, '5'], [91000, '33.3'], [101000, '5'], [None, '37']]), 5673643),
('regression open-top-bracket 2', (172773, [[None, '30']]), 5183190),
('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 fixture | Actual | Expected | Outcome |
|---|---|---|---|
| regression open-top-bracket 1 | 5340024 | 5917183 | Failed |
| regression open-top-bracket 2 | 580000 | 680000 | Failed |
| control: at first threshold | 100000 | 100000 | Passed |
| control: zero | 0 | 0 | Passed |
| control: negative | 0 | 0 | Passed |
| control: one over threshold | 460012 | 460022 | Failed |
SHA-256 / 91d9dbd0e2dd7f117786bb9633fd492330acbff23d3a729aa7ab46580fc7d948
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 open-top-bracket 1',
(250001, [[11000, '10'], [44725, '12'], [95375, '22'], [182100, '24'], [None, '32.5']]), 5917183),
('regression open-top-bracket 2', (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),
('control: one over threshold', (40001, [[10000, '10'], [40000, '12'], [None, '22']]), 460022)],
[('regression open-top-bracket 1', (40001, [[10000, '10'], [40000, '12'], [None, '22']]), 460022),
('regression open-top-bracket 2', (777, [[None, '12.5']]), 9713),
('control: negative', (-5, [[10000, '10'], [40000, '12'], [None, '22']]), 0),
('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'),
('control: closed top', (10, [[10000, '10'], [20000, '20']]), 'ERR:brackets')],
[('regression open-top-bracket 1',
(232540, [[34000, '22'], [101000, '15'], [147000, '10'], [184000, '10'], [None, '30']]), 4039200),
('regression open-top-bracket 2', (40000, [[None, '45']]), 1800000),
('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 open-top-bracket 1', (139460, [[None, '40.5']]), 5648130),
('regression open-top-bracket 2',
(236107, [[31000, '10'], [159000, '10'], [172000, '24'], [193000, '22'], [None, '45']]), 4303815),
('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 open-top-bracket 1',
(221539, [[9000, '24'], [72000, '5'], [91000, '33.3'], [101000, '5'], [None, '37']]), 5673643),
('regression open-top-bracket 2', (172773, [[None, '30']]), 5183190),
('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 fixture | Actual | Expected | Outcome |
|---|---|---|---|
| regression open-top-bracket 1 | 5917183 | 5917183 | Passed |
| regression open-top-bracket 2 | 680000 | 680000 | Passed |
| control: at first threshold | 100000 | 100000 | Passed |
| control: zero | 0 | 0 | Passed |
| control: negative | 0 | 0 | Passed |
| control: one over threshold | 460022 | 460022 | Passed |
SHA-256 / 61d141b524b830050dba721acfd893b7dc0147e15090a93ee5aec81242983f79
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.985243+00:00.
Case digest / c47028d45dd4e648f7208b4e4e856c5d4bd9e3f9ce8edadb092c2af463f1c4eb