FA-62346 / Tax bracket computation / Open access
Each bracket rate is applied to income measured from zero · case 01
Tax in the second bracket also re-taxes the first bracket's income.
ROOT CAUSE
The slice uses top instead of top - lower.
THE FAILURE
The slice uses top instead of top - lower.
Unsuccessful approach: Counting the slice as inclusive of both endpoints (top - lower + 1) overstates each upper bracket by one dollar.
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 * 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 slice-width 1', (50000, [[10000, '10'], [40000, '12'], [None, '22']]), 680000),
('regression slice-width 2', (40001, [[10000, '10'], [40000, '12'], [None, '22']]), 460022),
('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: fractional rate', (12345, [[11000, '10'], [44725, '12'], [95375, '22'], [182100, '24'], [None, '32.5']]),
126140)],
[('regression slice-width 1', (12345, [[11000, '10'], [44725, '12'], [95375, '22'], [182100, '24'], [None, '32.5']]),
126140),
('regression slice-width 2', (250001, [[11000, '10'], [44725, '12'], [95375, '22'], [182100, '24'], [None, '32.5']]),
5917183),
('control: negative', (-5, [[10000, '10'], [40000, '12'], [None, '22']]), 0),
('control: one over threshold', (40001, [[10000, '10'], [40000, '12'], [None, '22']]), 460022),
('control: non increasing', (10000, [[10000, '10'], [5000, '20'], [None, '30']]), 'ERR:brackets'),
('control: closed top', (10, [[10000, '10'], [20000, '20']]), 'ERR:brackets')],
[('regression slice-width 1', (232540, [[34000, '22'], [101000, '15'], [147000, '10'], [184000, '10'], [None, '30']]),
4039200),
('regression slice-width 2', (236107, [[31000, '10'], [159000, '10'], [172000, '24'], [193000, '22'], [None, '45']]),
4303815),
('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 slice-width 1', (221539, [[9000, '24'], [72000, '5'], [91000, '33.3'], [101000, '5'], [None, '37']]),
5673643),
('regression slice-width 2', (64068, [[32000, '22'], [105000, '10'], [170000, '24'], [193000, '10'], [None, '37']]),
1024680),
('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 slice-width 1', (161544, [[108000, '22'], [122000, '12.5'], [192000, '10'], [None, '30']]), 2946440),
('regression slice-width 2', (84182, [[82000, '12.5'], [138000, '22'], [161000, '15'], [None, '37']]), 1073004),
('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 slice-width 1 | 1680000 | 680000 | Failed |
| regression slice-width 2 | 1460022 | 460022 | Failed |
| control: at first threshold | 100000 | 100000 | Passed |
| control: zero | 0 | 0 | Passed |
| control: negative | 0 | 0 | Passed |
| control: fractional rate | 258140 | 126140 | Failed |
SHA-256 / 302e0cf27649205ee6a2ceca8439117c7c197dc0977ca49d1f3f20f070912b64
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 + (1 if lower else 0)) * 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 slice-width 1', (50000, [[10000, '10'], [40000, '12'], [None, '22']]), 680000),
('regression slice-width 2', (40001, [[10000, '10'], [40000, '12'], [None, '22']]), 460022),
('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: fractional rate', (12345, [[11000, '10'], [44725, '12'], [95375, '22'], [182100, '24'], [None, '32.5']]),
126140)],
[('regression slice-width 1', (12345, [[11000, '10'], [44725, '12'], [95375, '22'], [182100, '24'], [None, '32.5']]),
126140),
('regression slice-width 2', (250001, [[11000, '10'], [44725, '12'], [95375, '22'], [182100, '24'], [None, '32.5']]),
5917183),
('control: negative', (-5, [[10000, '10'], [40000, '12'], [None, '22']]), 0),
('control: one over threshold', (40001, [[10000, '10'], [40000, '12'], [None, '22']]), 460022),
('control: non increasing', (10000, [[10000, '10'], [5000, '20'], [None, '30']]), 'ERR:brackets'),
('control: closed top', (10, [[10000, '10'], [20000, '20']]), 'ERR:brackets')],
[('regression slice-width 1', (232540, [[34000, '22'], [101000, '15'], [147000, '10'], [184000, '10'], [None, '30']]),
4039200),
('regression slice-width 2', (236107, [[31000, '10'], [159000, '10'], [172000, '24'], [193000, '22'], [None, '45']]),
4303815),
('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 slice-width 1', (221539, [[9000, '24'], [72000, '5'], [91000, '33.3'], [101000, '5'], [None, '37']]),
5673643),
('regression slice-width 2', (64068, [[32000, '22'], [105000, '10'], [170000, '24'], [193000, '10'], [None, '37']]),
1024680),
('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 slice-width 1', (161544, [[108000, '22'], [122000, '12.5'], [192000, '10'], [None, '30']]), 2946440),
('regression slice-width 2', (84182, [[82000, '12.5'], [138000, '22'], [161000, '15'], [None, '37']]), 1073004),
('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 slice-width 1 | 680034 | 680000 | Failed |
| regression slice-width 2 | 460056 | 460022 | Failed |
| control: at first threshold | 100000 | 100000 | Passed |
| control: zero | 0 | 0 | Passed |
| control: negative | 0 | 0 | Passed |
| control: fractional rate | 126152 | 126140 | Failed |
SHA-256 / 98693f6f29dcf43299511a4502cfd46560baf94b4e496d816d6a2636bb9c1785
HELD IN THE MEMBER ARCHIVE
The verified repair and its recorded checks are member-only.
This mechanism has 6 recorded checks per implementation. The open-access tier publishes the failure and the unsuccessful fix; the repaired source that passes every check, and the observations that prove it, are available to members.
Every case sharing this mechanism uses the same contract and the same repair, so this one record is held back for all of them.
Member access is invitation-based. Sign in with your invited account to inspect the repair.
Sign in to the archive ↗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.810901+00:00.
Case digest / 5f7eccbdfb47546b1d9d0a4f26833a6893aaf37b1f1c075c54228a8c8df4dcbf