FA-62656 / Tax bracket computation / Open access
The 80% limit is rounded to the nearest unit · case 01
In some years one extra unit of carryforward is used.
ROOT CAUSE
The limit is rounded half-up instead of down.
VERIFIED REPAIR
Use floor(80% of income).
Unsuccessful approach: Rounding the limit up uses one extra unit whenever 80% is fractional.
Case contract
solve(years, life): years are pre-deduction incomes by year index (negative = operating loss). A loss year reports taxable 0 and creates a carryforward [origin, amount]. In an income year, carryforwards older than life years (year - origin > life) expire; the rest are applied oldest first, limited in total to floor(80% of that year's income). Return [taxable_by_year, remaining] where remaining lists [origin, amount] with amount > 0 not expired as of the final year.
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
N = 1
observations = []
def solve(years, life):
nols, out = [], []
for y, inc in enumerate(years):
if inc < 0:
out.append(0)
nols.append([y, -inc])
continue
nols = [n for n in nols if y - n[0] <= life]
room = (inc * 80 + 50) // 100
for n in nols:
use = min(n[1], room)
n[1] -= use
room -= use
inc -= use
out.append(inc)
last = len(years) - 1
return [out, [[o, a] for o, a in nols if a > 0 and last - o <= life]]
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
cases = [[('regression limit-rounding 1', ([-50000, 10001], 5), [[0, 2001], [[0, 42000]]]),
('regression limit-rounding 2', ([-3000, -50000, 2641, -3000, -50000], 5),
[[0, 0, 529, 0, 0], [[0, 888], [1, 50000], [3, 3000], [4, 50000]]]),
('partial repair guard 2', ([-50000, 10003], 5), [[0, 2001], [[0, 41998]]]),
('control: fifo two years', ([-10000, 5000, 20000], 5), [[0, 1000, 14000], []]),
('control: two losses', ([-5000, -3000, 10000], 5), [[0, 0, 2000], []]),
('control: expired', ([-10000, 0, 0, 10000], 2), [[0, 0, 0, 10000], []]),
('control: expiry boundary', ([-8000, 0, 5000], 2), [[0, 0, 1000], [[0, 4000]]])],
[('regression limit-rounding 1', ([-3000, 20000, 20000, -50000, -10000, 36637], 2),
[[0, 17000, 20000, 0, 0, 7328], [[3, 20691], [4, 10000]]]),
('regression limit-rounding 2', ([20000, 60000, -10000, -3000, 14361, 20000], 5),
[[20000, 60000, 0, 0, 2873, 18488], []]),
('partial repair guard 1', ([20000, -50000, 22304, 5000, -10000, 60000, -22379], 3),
[[20000, 0, 4461, 1000, 0, 50000, 0], [[6, 22379]]]),
('partial repair guard 2', ([-3000, -50000, 2641, -3000, -50000], 5),
[[0, 0, 529, 0, 0], [[0, 888], [1, 50000], [3, 3000], [4, 50000]]]),
('control: odd cap', ([-50000, 10001], 5), [[0, 2001], [[0, 42000]]]),
('control: expiry boundary', ([-8000, 0, 5000], 2), [[0, 0, 1000], [[0, 4000]]]),
('control: losses after income', ([10000, -4000, -6000, 5000, 5000], 3), [[10000, 0, 0, 1000, 1000], [[2, 2000]]]),
('control: no losses', ([1000, 2000], 1), [[1000, 2000], []])],
[('regression limit-rounding 1', ([-50000, 5000, -3000, 10922], 3), [[0, 1000, 0, 2185], [[0, 37263], [2, 3000]]]),
('regression limit-rounding 2', ([-10000, 5000, 2971], 5), [[0, 1000, 595], [[0, 3624]]]),
('partial repair guard 1', ([-3000, 2749], 2), [[0, 550], [[0, 801]]]),
('partial repair guard 2', ([-15828, -10000, 26139, -50000, -37672], 5),
[[0, 0, 5228, 0, 0], [[1, 4917], [3, 50000], [4, 37672]]]),
('control: no losses', ([1000, 2000], 1), [[1000, 2000], []]),
('control: fifo two years', ([-10000, 5000, 20000], 5), [[0, 1000, 14000], []]),
('control: two losses', ([-5000, -3000, 10000], 5), [[0, 0, 2000], []]),
('control: expired', ([-10000, 0, 0, 10000], 2), [[0, 0, 0, 10000], []])],
[('regression limit-rounding 1', ([-3000, 717], 2), [[0, 144], [[0, 2427]]]),
('regression limit-rounding 2', ([5000, 20000, -50000, -10000, 13360, 31032, 20000], 20),
[[5000, 20000, 0, 0, 2672, 6207, 4000], [[3, 8487]]]),
('partial repair guard 1', ([0, 0, -3000, 3263], 3), [[0, 0, 0, 653], [[2, 390]]]),
('partial repair guard 2', ([-3000, 20000, 20000, -50000, -10000, 36637], 2),
[[0, 17000, 20000, 0, 0, 7328], [[3, 20691], [4, 10000]]]),
('control: expired', ([-10000, 0, 0, 10000], 2), [[0, 0, 0, 10000], []]),
('control: odd cap', ([-50000, 10001], 5), [[0, 2001], [[0, 42000]]]),
('control: expiry boundary', ([-8000, 0, 5000], 2), [[0, 0, 1000], [[0, 4000]]]),
('control: losses after income', ([10000, -4000, -6000, 5000, 5000], 3), [[10000, 0, 0, 1000, 1000], [[2, 2000]]])],
[('regression limit-rounding 1', ([-10000, 50960, 5000, -50000, 20931, 20000, -3000], 2),
[[0, 40960, 5000, 0, 4187, 4000, 0], [[6, 3000]]]),
('regression limit-rounding 2', ([31584, 0, -50000, 50401, 20000, 5000, -10000], 1),
[[31584, 0, 0, 10081, 20000, 5000, 0], [[6, 10000]]]),
('partial repair guard 1', ([20000, 60000, -10000, -3000, 14361, 20000], 5), [[20000, 60000, 0, 0, 2873, 18488], []]),
('partial repair guard 2', ([-3000, 5000, -50000, 13043], 1), [[0, 2000, 0, 2609], [[2, 39566]]]),
('control: losses after income', ([10000, -4000, -6000, 5000, 5000], 3), [[10000, 0, 0, 1000, 1000], [[2, 2000]]]),
('control: no losses', ([1000, 2000], 1), [[1000, 2000], []]),
('control: fifo two years', ([-10000, 5000, 20000], 5), [[0, 1000, 14000], []]),
('control: two losses', ([-5000, -3000, 10000], 5), [[0, 0, 2000], []])]]
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 limit-rounding 1 | [[0, 2000], [[0, 41999]]] | [[0, 2001], [[0, 42000]]] | Failed |
| regression limit-rounding 2 | [[0, 0, 528, 0, 0], [[0, 887], [1, 50000], [3, 3000], [4, 50000]]] | [[0, 0, 529, 0, 0], [[0, 888], [1, 50000], [3, 3000], [4, 50000]]] | Failed |
| partial repair guard 2 | [[0, 2001], [[0, 41998]]] | [[0, 2001], [[0, 41998]]] | Passed |
| control: fifo two years | [[0, 1000, 14000], []] | [[0, 1000, 14000], []] | Passed |
| control: two losses | [[0, 0, 2000], []] | [[0, 0, 2000], []] | Passed |
| control: expired | [[0, 0, 0, 10000], []] | [[0, 0, 0, 10000], []] | Passed |
| control: expiry boundary | [[0, 0, 1000], [[0, 4000]]] | [[0, 0, 1000], [[0, 4000]]] | Passed |
SHA-256 / 087cdd196deef31c27e0861cfeae3f705bc7df42b03e605758fd38de5daa9f67
2 / The unsuccessful fix
Exit 1"""Failure Map reference implementation. Python standard library only."""
import json
N = 1
observations = []
def solve(years, life):
nols, out = [], []
for y, inc in enumerate(years):
if inc < 0:
out.append(0)
nols.append([y, -inc])
continue
nols = [n for n in nols if y - n[0] <= life]
room = -(-inc * 80 // 100)
for n in nols:
use = min(n[1], room)
n[1] -= use
room -= use
inc -= use
out.append(inc)
last = len(years) - 1
return [out, [[o, a] for o, a in nols if a > 0 and last - o <= life]]
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
cases = [[('regression limit-rounding 1', ([-50000, 10001], 5), [[0, 2001], [[0, 42000]]]),
('regression limit-rounding 2', ([-3000, -50000, 2641, -3000, -50000], 5),
[[0, 0, 529, 0, 0], [[0, 888], [1, 50000], [3, 3000], [4, 50000]]]),
('partial repair guard 2', ([-50000, 10003], 5), [[0, 2001], [[0, 41998]]]),
('control: fifo two years', ([-10000, 5000, 20000], 5), [[0, 1000, 14000], []]),
('control: two losses', ([-5000, -3000, 10000], 5), [[0, 0, 2000], []]),
('control: expired', ([-10000, 0, 0, 10000], 2), [[0, 0, 0, 10000], []]),
('control: expiry boundary', ([-8000, 0, 5000], 2), [[0, 0, 1000], [[0, 4000]]])],
[('regression limit-rounding 1', ([-3000, 20000, 20000, -50000, -10000, 36637], 2),
[[0, 17000, 20000, 0, 0, 7328], [[3, 20691], [4, 10000]]]),
('regression limit-rounding 2', ([20000, 60000, -10000, -3000, 14361, 20000], 5),
[[20000, 60000, 0, 0, 2873, 18488], []]),
('partial repair guard 1', ([20000, -50000, 22304, 5000, -10000, 60000, -22379], 3),
[[20000, 0, 4461, 1000, 0, 50000, 0], [[6, 22379]]]),
('partial repair guard 2', ([-3000, -50000, 2641, -3000, -50000], 5),
[[0, 0, 529, 0, 0], [[0, 888], [1, 50000], [3, 3000], [4, 50000]]]),
('control: odd cap', ([-50000, 10001], 5), [[0, 2001], [[0, 42000]]]),
('control: expiry boundary', ([-8000, 0, 5000], 2), [[0, 0, 1000], [[0, 4000]]]),
('control: losses after income', ([10000, -4000, -6000, 5000, 5000], 3), [[10000, 0, 0, 1000, 1000], [[2, 2000]]]),
('control: no losses', ([1000, 2000], 1), [[1000, 2000], []])],
[('regression limit-rounding 1', ([-50000, 5000, -3000, 10922], 3), [[0, 1000, 0, 2185], [[0, 37263], [2, 3000]]]),
('regression limit-rounding 2', ([-10000, 5000, 2971], 5), [[0, 1000, 595], [[0, 3624]]]),
('partial repair guard 1', ([-3000, 2749], 2), [[0, 550], [[0, 801]]]),
('partial repair guard 2', ([-15828, -10000, 26139, -50000, -37672], 5),
[[0, 0, 5228, 0, 0], [[1, 4917], [3, 50000], [4, 37672]]]),
('control: no losses', ([1000, 2000], 1), [[1000, 2000], []]),
('control: fifo two years', ([-10000, 5000, 20000], 5), [[0, 1000, 14000], []]),
('control: two losses', ([-5000, -3000, 10000], 5), [[0, 0, 2000], []]),
('control: expired', ([-10000, 0, 0, 10000], 2), [[0, 0, 0, 10000], []])],
[('regression limit-rounding 1', ([-3000, 717], 2), [[0, 144], [[0, 2427]]]),
('regression limit-rounding 2', ([5000, 20000, -50000, -10000, 13360, 31032, 20000], 20),
[[5000, 20000, 0, 0, 2672, 6207, 4000], [[3, 8487]]]),
('partial repair guard 1', ([0, 0, -3000, 3263], 3), [[0, 0, 0, 653], [[2, 390]]]),
('partial repair guard 2', ([-3000, 20000, 20000, -50000, -10000, 36637], 2),
[[0, 17000, 20000, 0, 0, 7328], [[3, 20691], [4, 10000]]]),
('control: expired', ([-10000, 0, 0, 10000], 2), [[0, 0, 0, 10000], []]),
('control: odd cap', ([-50000, 10001], 5), [[0, 2001], [[0, 42000]]]),
('control: expiry boundary', ([-8000, 0, 5000], 2), [[0, 0, 1000], [[0, 4000]]]),
('control: losses after income', ([10000, -4000, -6000, 5000, 5000], 3), [[10000, 0, 0, 1000, 1000], [[2, 2000]]])],
[('regression limit-rounding 1', ([-10000, 50960, 5000, -50000, 20931, 20000, -3000], 2),
[[0, 40960, 5000, 0, 4187, 4000, 0], [[6, 3000]]]),
('regression limit-rounding 2', ([31584, 0, -50000, 50401, 20000, 5000, -10000], 1),
[[31584, 0, 0, 10081, 20000, 5000, 0], [[6, 10000]]]),
('partial repair guard 1', ([20000, 60000, -10000, -3000, 14361, 20000], 5), [[20000, 60000, 0, 0, 2873, 18488], []]),
('partial repair guard 2', ([-3000, 5000, -50000, 13043], 1), [[0, 2000, 0, 2609], [[2, 39566]]]),
('control: losses after income', ([10000, -4000, -6000, 5000, 5000], 3), [[10000, 0, 0, 1000, 1000], [[2, 2000]]]),
('control: no losses', ([1000, 2000], 1), [[1000, 2000], []]),
('control: fifo two years', ([-10000, 5000, 20000], 5), [[0, 1000, 14000], []]),
('control: two losses', ([-5000, -3000, 10000], 5), [[0, 0, 2000], []])]]
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 limit-rounding 1 | [[0, 2000], [[0, 41999]]] | [[0, 2001], [[0, 42000]]] | Failed |
| regression limit-rounding 2 | [[0, 0, 528, 0, 0], [[0, 887], [1, 50000], [3, 3000], [4, 50000]]] | [[0, 0, 529, 0, 0], [[0, 888], [1, 50000], [3, 3000], [4, 50000]]] | Failed |
| partial repair guard 2 | [[0, 2000], [[0, 41997]]] | [[0, 2001], [[0, 41998]]] | Failed |
| control: fifo two years | [[0, 1000, 14000], []] | [[0, 1000, 14000], []] | Passed |
| control: two losses | [[0, 0, 2000], []] | [[0, 0, 2000], []] | Passed |
| control: expired | [[0, 0, 0, 10000], []] | [[0, 0, 0, 10000], []] | Passed |
| control: expiry boundary | [[0, 0, 1000], [[0, 4000]]] | [[0, 0, 1000], [[0, 4000]]] | Passed |
SHA-256 / 9bbb24643166e6396e1049bc0a1d7dc9caeb2149a32b06fa4876b33cf058cf7e
3 / The verified repair
Exit 0"""Failure Map reference implementation. Python standard library only."""
import json
N = 1
observations = []
def solve(years, life):
nols, out = [], []
for y, inc in enumerate(years):
if inc < 0:
out.append(0)
nols.append([y, -inc])
continue
nols = [n for n in nols if y - n[0] <= life]
room = inc * 80 // 100
for n in nols:
use = min(n[1], room)
n[1] -= use
room -= use
inc -= use
out.append(inc)
last = len(years) - 1
return [out, [[o, a] for o, a in nols if a > 0 and last - o <= life]]
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
cases = [[('regression limit-rounding 1', ([-50000, 10001], 5), [[0, 2001], [[0, 42000]]]),
('regression limit-rounding 2', ([-3000, -50000, 2641, -3000, -50000], 5),
[[0, 0, 529, 0, 0], [[0, 888], [1, 50000], [3, 3000], [4, 50000]]]),
('partial repair guard 2', ([-50000, 10003], 5), [[0, 2001], [[0, 41998]]]),
('control: fifo two years', ([-10000, 5000, 20000], 5), [[0, 1000, 14000], []]),
('control: two losses', ([-5000, -3000, 10000], 5), [[0, 0, 2000], []]),
('control: expired', ([-10000, 0, 0, 10000], 2), [[0, 0, 0, 10000], []]),
('control: expiry boundary', ([-8000, 0, 5000], 2), [[0, 0, 1000], [[0, 4000]]])],
[('regression limit-rounding 1', ([-3000, 20000, 20000, -50000, -10000, 36637], 2),
[[0, 17000, 20000, 0, 0, 7328], [[3, 20691], [4, 10000]]]),
('regression limit-rounding 2', ([20000, 60000, -10000, -3000, 14361, 20000], 5),
[[20000, 60000, 0, 0, 2873, 18488], []]),
('partial repair guard 1', ([20000, -50000, 22304, 5000, -10000, 60000, -22379], 3),
[[20000, 0, 4461, 1000, 0, 50000, 0], [[6, 22379]]]),
('partial repair guard 2', ([-3000, -50000, 2641, -3000, -50000], 5),
[[0, 0, 529, 0, 0], [[0, 888], [1, 50000], [3, 3000], [4, 50000]]]),
('control: odd cap', ([-50000, 10001], 5), [[0, 2001], [[0, 42000]]]),
('control: expiry boundary', ([-8000, 0, 5000], 2), [[0, 0, 1000], [[0, 4000]]]),
('control: losses after income', ([10000, -4000, -6000, 5000, 5000], 3), [[10000, 0, 0, 1000, 1000], [[2, 2000]]]),
('control: no losses', ([1000, 2000], 1), [[1000, 2000], []])],
[('regression limit-rounding 1', ([-50000, 5000, -3000, 10922], 3), [[0, 1000, 0, 2185], [[0, 37263], [2, 3000]]]),
('regression limit-rounding 2', ([-10000, 5000, 2971], 5), [[0, 1000, 595], [[0, 3624]]]),
('partial repair guard 1', ([-3000, 2749], 2), [[0, 550], [[0, 801]]]),
('partial repair guard 2', ([-15828, -10000, 26139, -50000, -37672], 5),
[[0, 0, 5228, 0, 0], [[1, 4917], [3, 50000], [4, 37672]]]),
('control: no losses', ([1000, 2000], 1), [[1000, 2000], []]),
('control: fifo two years', ([-10000, 5000, 20000], 5), [[0, 1000, 14000], []]),
('control: two losses', ([-5000, -3000, 10000], 5), [[0, 0, 2000], []]),
('control: expired', ([-10000, 0, 0, 10000], 2), [[0, 0, 0, 10000], []])],
[('regression limit-rounding 1', ([-3000, 717], 2), [[0, 144], [[0, 2427]]]),
('regression limit-rounding 2', ([5000, 20000, -50000, -10000, 13360, 31032, 20000], 20),
[[5000, 20000, 0, 0, 2672, 6207, 4000], [[3, 8487]]]),
('partial repair guard 1', ([0, 0, -3000, 3263], 3), [[0, 0, 0, 653], [[2, 390]]]),
('partial repair guard 2', ([-3000, 20000, 20000, -50000, -10000, 36637], 2),
[[0, 17000, 20000, 0, 0, 7328], [[3, 20691], [4, 10000]]]),
('control: expired', ([-10000, 0, 0, 10000], 2), [[0, 0, 0, 10000], []]),
('control: odd cap', ([-50000, 10001], 5), [[0, 2001], [[0, 42000]]]),
('control: expiry boundary', ([-8000, 0, 5000], 2), [[0, 0, 1000], [[0, 4000]]]),
('control: losses after income', ([10000, -4000, -6000, 5000, 5000], 3), [[10000, 0, 0, 1000, 1000], [[2, 2000]]])],
[('regression limit-rounding 1', ([-10000, 50960, 5000, -50000, 20931, 20000, -3000], 2),
[[0, 40960, 5000, 0, 4187, 4000, 0], [[6, 3000]]]),
('regression limit-rounding 2', ([31584, 0, -50000, 50401, 20000, 5000, -10000], 1),
[[31584, 0, 0, 10081, 20000, 5000, 0], [[6, 10000]]]),
('partial repair guard 1', ([20000, 60000, -10000, -3000, 14361, 20000], 5), [[20000, 60000, 0, 0, 2873, 18488], []]),
('partial repair guard 2', ([-3000, 5000, -50000, 13043], 1), [[0, 2000, 0, 2609], [[2, 39566]]]),
('control: losses after income', ([10000, -4000, -6000, 5000, 5000], 3), [[10000, 0, 0, 1000, 1000], [[2, 2000]]]),
('control: no losses', ([1000, 2000], 1), [[1000, 2000], []]),
('control: fifo two years', ([-10000, 5000, 20000], 5), [[0, 1000, 14000], []]),
('control: two losses', ([-5000, -3000, 10000], 5), [[0, 0, 2000], []])]]
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 limit-rounding 1 | [[0, 2001], [[0, 42000]]] | [[0, 2001], [[0, 42000]]] | Passed |
| regression limit-rounding 2 | [[0, 0, 529, 0, 0], [[0, 888], [1, 50000], [3, 3000], [4, 50000]]] | [[0, 0, 529, 0, 0], [[0, 888], [1, 50000], [3, 3000], [4, 50000]]] | Passed |
| partial repair guard 2 | [[0, 2001], [[0, 41998]]] | [[0, 2001], [[0, 41998]]] | Passed |
| control: fifo two years | [[0, 1000, 14000], []] | [[0, 1000, 14000], []] | Passed |
| control: two losses | [[0, 0, 2000], []] | [[0, 0, 2000], []] | Passed |
| control: expired | [[0, 0, 0, 10000], []] | [[0, 0, 0, 10000], []] | Passed |
| control: expiry boundary | [[0, 0, 1000], [[0, 4000]]] | [[0, 0, 1000], [[0, 4000]]] | Passed |
SHA-256 / 8771fdb83895a2c694789a2e1dbe75e2a44226a9df838f33f703b4205fcc6b1c
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:06.668542+00:00.
Case digest / e4849e3e9d6f1ccaae0930afdf52d3b9c0c8c4227d598afeac43c453b44d9fe7