FA-62651 / Tax bracket computation / Open access
A carryforward expires one year early · case 01
A loss is unusable in its final permitted year.
ROOT CAUSE
The expiry filter uses y - origin < life.
VERIFIED REPAIR
Keep carryforwards while year - origin <= life.
Unsuccessful approach: Expiring carryforwards only in the final report still uses expired losses during the years.
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 // 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 expiry-boundary 1', ([-8000, 0, 5000], 2), [[0, 0, 1000], [[0, 4000]]]),
('regression expiry-boundary 2', ([-50000, 0, -10000, 20000, -10000, 20000], 1), [[0, 0, 0, 10000, 0, 10000], []]),
('partial repair guard 1', ([-10000, 0, 0, 10000], 2), [[0, 0, 0, 10000], []]),
('control: fifo two years', ([-10000, 5000, 20000], 5), [[0, 1000, 14000], []]),
('control: two losses', ([-5000, -3000, 10000], 5), [[0, 0, 2000], []]),
('control: odd cap', ([-50000, 10001], 5), [[0, 2001], [[0, 42000]]]),
('control: losses after income', ([10000, -4000, -6000, 5000, 5000], 3), [[10000, 0, 0, 1000, 1000], [[2, 2000]]])],
[('regression expiry-boundary 1', ([-3000, -10000, -10000, -3000, -3000, 51657, -50000], 5),
[[0, 0, 0, 0, 0, 22657, 0], [[6, 50000]]]),
('regression expiry-boundary 2', ([-50000, 20000, 77236, 20000, 60000, -50000, 20000], 1),
[[0, 4000, 77236, 20000, 60000, 0, 4000], [[5, 34000]]]),
('partial repair guard 2', ([-3000, -5199, -3000, -14464, 20000], 1), [[0, 0, 0, 0, 5536], []]),
('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 expiry-boundary 1', ([-3000, -5199, -3000, -14464, 20000], 1), [[0, 0, 0, 0, 5536], []]),
('regression expiry-boundary 2', ([20000, 28622, -50000, 5000, 5000, 72523, 20000], 3),
[[20000, 28622, 0, 1000, 1000, 30523, 20000], []]),
('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', ([-15586, -10000, 60000, 5000, -50000, 60000, -10000], 1),
[[0, 0, 50000, 5000, 0, 12000, 0], [[6, 10000]]]),
('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 expiry-boundary 1', ([60000, -3000, -3000, 20000, 60000, 0, -10000], 2),
[[60000, 0, 0, 14000, 60000, 0, 0], [[6, 10000]]]),
('regression expiry-boundary 2', ([-3000, 60000, 20966, 29858, 5000, 0, 0], 1),
[[0, 57000, 20966, 29858, 5000, 0, 0], []]),
('partial repair guard 1', ([-50000, 5000, -10000, -50000, -50000, 60000], 1),
[[0, 1000, 0, 0, 0, 12000], [[4, 2000]]]),
('partial repair guard 2', ([19011, 0, -50000, 20000, 20000], 1), [[19011, 0, 0, 4000, 20000], []]),
('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 expiry-boundary 1', ([-15586, -10000, 60000, 5000, -50000, 60000, -10000], 1),
[[0, 0, 50000, 5000, 0, 12000, 0], [[6, 10000]]]),
('regression expiry-boundary 2', ([-50000, 5000, -10000, -50000, -50000, 60000], 1),
[[0, 1000, 0, 0, 0, 12000], [[4, 2000]]]),
('partial repair guard 1', ([-50000, 5000, 5000, -37469, 5000], 2), [[0, 1000, 1000, 0, 1000], [[3, 33469]]]),
('partial repair guard 2', ([-50000, 48915, -3000, 27132, -50000], 2), [[0, 9783, 0, 24132, 0], [[4, 50000]]]),
('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 expiry-boundary 1 | [[0, 0, 5000], []] | [[0, 0, 1000], [[0, 4000]]] | Failed |
| regression expiry-boundary 2 | [[0, 0, 0, 20000, 0, 20000], []] | [[0, 0, 0, 10000, 0, 10000], []] | Failed |
| partial repair guard 1 | [[0, 0, 0, 10000], []] | [[0, 0, 0, 10000], []] | Passed |
| control: fifo two years | [[0, 1000, 14000], []] | [[0, 1000, 14000], []] | Passed |
| control: two losses | [[0, 0, 2000], []] | [[0, 0, 2000], []] | Passed |
| control: odd cap | [[0, 2001], [[0, 42000]]] | [[0, 2001], [[0, 42000]]] | Passed |
| control: losses after income | [[10000, 0, 0, 1000, 1000], [[2, 2000]]] | [[10000, 0, 0, 1000, 1000], [[2, 2000]]] | Passed |
SHA-256 / 248331715b93a49c5915be62e8712e7c7813f8c5dfc7e9cacd772e7444310271
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
pass
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 expiry-boundary 1', ([-8000, 0, 5000], 2), [[0, 0, 1000], [[0, 4000]]]),
('regression expiry-boundary 2', ([-50000, 0, -10000, 20000, -10000, 20000], 1), [[0, 0, 0, 10000, 0, 10000], []]),
('partial repair guard 1', ([-10000, 0, 0, 10000], 2), [[0, 0, 0, 10000], []]),
('control: fifo two years', ([-10000, 5000, 20000], 5), [[0, 1000, 14000], []]),
('control: two losses', ([-5000, -3000, 10000], 5), [[0, 0, 2000], []]),
('control: odd cap', ([-50000, 10001], 5), [[0, 2001], [[0, 42000]]]),
('control: losses after income', ([10000, -4000, -6000, 5000, 5000], 3), [[10000, 0, 0, 1000, 1000], [[2, 2000]]])],
[('regression expiry-boundary 1', ([-3000, -10000, -10000, -3000, -3000, 51657, -50000], 5),
[[0, 0, 0, 0, 0, 22657, 0], [[6, 50000]]]),
('regression expiry-boundary 2', ([-50000, 20000, 77236, 20000, 60000, -50000, 20000], 1),
[[0, 4000, 77236, 20000, 60000, 0, 4000], [[5, 34000]]]),
('partial repair guard 2', ([-3000, -5199, -3000, -14464, 20000], 1), [[0, 0, 0, 0, 5536], []]),
('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 expiry-boundary 1', ([-3000, -5199, -3000, -14464, 20000], 1), [[0, 0, 0, 0, 5536], []]),
('regression expiry-boundary 2', ([20000, 28622, -50000, 5000, 5000, 72523, 20000], 3),
[[20000, 28622, 0, 1000, 1000, 30523, 20000], []]),
('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', ([-15586, -10000, 60000, 5000, -50000, 60000, -10000], 1),
[[0, 0, 50000, 5000, 0, 12000, 0], [[6, 10000]]]),
('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 expiry-boundary 1', ([60000, -3000, -3000, 20000, 60000, 0, -10000], 2),
[[60000, 0, 0, 14000, 60000, 0, 0], [[6, 10000]]]),
('regression expiry-boundary 2', ([-3000, 60000, 20966, 29858, 5000, 0, 0], 1),
[[0, 57000, 20966, 29858, 5000, 0, 0], []]),
('partial repair guard 1', ([-50000, 5000, -10000, -50000, -50000, 60000], 1),
[[0, 1000, 0, 0, 0, 12000], [[4, 2000]]]),
('partial repair guard 2', ([19011, 0, -50000, 20000, 20000], 1), [[19011, 0, 0, 4000, 20000], []]),
('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 expiry-boundary 1', ([-15586, -10000, 60000, 5000, -50000, 60000, -10000], 1),
[[0, 0, 50000, 5000, 0, 12000, 0], [[6, 10000]]]),
('regression expiry-boundary 2', ([-50000, 5000, -10000, -50000, -50000, 60000], 1),
[[0, 1000, 0, 0, 0, 12000], [[4, 2000]]]),
('partial repair guard 1', ([-50000, 5000, 5000, -37469, 5000], 2), [[0, 1000, 1000, 0, 1000], [[3, 33469]]]),
('partial repair guard 2', ([-50000, 48915, -3000, 27132, -50000], 2), [[0, 9783, 0, 24132, 0], [[4, 50000]]]),
('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 expiry-boundary 1 | [[0, 0, 1000], [[0, 4000]]] | [[0, 0, 1000], [[0, 4000]]] | Passed |
| regression expiry-boundary 2 | [[0, 0, 0, 4000, 0, 4000], [[4, 10000]]] | [[0, 0, 0, 10000, 0, 10000], []] | Failed |
| partial repair guard 1 | [[0, 0, 0, 2000], []] | [[0, 0, 0, 10000], []] | Failed |
| control: fifo two years | [[0, 1000, 14000], []] | [[0, 1000, 14000], []] | Passed |
| control: two losses | [[0, 0, 2000], []] | [[0, 0, 2000], []] | Passed |
| control: odd cap | [[0, 2001], [[0, 42000]]] | [[0, 2001], [[0, 42000]]] | Passed |
| control: losses after income | [[10000, 0, 0, 1000, 1000], [[2, 2000]]] | [[10000, 0, 0, 1000, 1000], [[2, 2000]]] | Passed |
SHA-256 / 21c5a3c378955398fa825054744c5283e0ab43bb66a7516294b2eaf0b218fc5d
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 expiry-boundary 1', ([-8000, 0, 5000], 2), [[0, 0, 1000], [[0, 4000]]]),
('regression expiry-boundary 2', ([-50000, 0, -10000, 20000, -10000, 20000], 1), [[0, 0, 0, 10000, 0, 10000], []]),
('partial repair guard 1', ([-10000, 0, 0, 10000], 2), [[0, 0, 0, 10000], []]),
('control: fifo two years', ([-10000, 5000, 20000], 5), [[0, 1000, 14000], []]),
('control: two losses', ([-5000, -3000, 10000], 5), [[0, 0, 2000], []]),
('control: odd cap', ([-50000, 10001], 5), [[0, 2001], [[0, 42000]]]),
('control: losses after income', ([10000, -4000, -6000, 5000, 5000], 3), [[10000, 0, 0, 1000, 1000], [[2, 2000]]])],
[('regression expiry-boundary 1', ([-3000, -10000, -10000, -3000, -3000, 51657, -50000], 5),
[[0, 0, 0, 0, 0, 22657, 0], [[6, 50000]]]),
('regression expiry-boundary 2', ([-50000, 20000, 77236, 20000, 60000, -50000, 20000], 1),
[[0, 4000, 77236, 20000, 60000, 0, 4000], [[5, 34000]]]),
('partial repair guard 2', ([-3000, -5199, -3000, -14464, 20000], 1), [[0, 0, 0, 0, 5536], []]),
('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 expiry-boundary 1', ([-3000, -5199, -3000, -14464, 20000], 1), [[0, 0, 0, 0, 5536], []]),
('regression expiry-boundary 2', ([20000, 28622, -50000, 5000, 5000, 72523, 20000], 3),
[[20000, 28622, 0, 1000, 1000, 30523, 20000], []]),
('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', ([-15586, -10000, 60000, 5000, -50000, 60000, -10000], 1),
[[0, 0, 50000, 5000, 0, 12000, 0], [[6, 10000]]]),
('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 expiry-boundary 1', ([60000, -3000, -3000, 20000, 60000, 0, -10000], 2),
[[60000, 0, 0, 14000, 60000, 0, 0], [[6, 10000]]]),
('regression expiry-boundary 2', ([-3000, 60000, 20966, 29858, 5000, 0, 0], 1),
[[0, 57000, 20966, 29858, 5000, 0, 0], []]),
('partial repair guard 1', ([-50000, 5000, -10000, -50000, -50000, 60000], 1),
[[0, 1000, 0, 0, 0, 12000], [[4, 2000]]]),
('partial repair guard 2', ([19011, 0, -50000, 20000, 20000], 1), [[19011, 0, 0, 4000, 20000], []]),
('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 expiry-boundary 1', ([-15586, -10000, 60000, 5000, -50000, 60000, -10000], 1),
[[0, 0, 50000, 5000, 0, 12000, 0], [[6, 10000]]]),
('regression expiry-boundary 2', ([-50000, 5000, -10000, -50000, -50000, 60000], 1),
[[0, 1000, 0, 0, 0, 12000], [[4, 2000]]]),
('partial repair guard 1', ([-50000, 5000, 5000, -37469, 5000], 2), [[0, 1000, 1000, 0, 1000], [[3, 33469]]]),
('partial repair guard 2', ([-50000, 48915, -3000, 27132, -50000], 2), [[0, 9783, 0, 24132, 0], [[4, 50000]]]),
('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 expiry-boundary 1 | [[0, 0, 1000], [[0, 4000]]] | [[0, 0, 1000], [[0, 4000]]] | Passed |
| regression expiry-boundary 2 | [[0, 0, 0, 10000, 0, 10000], []] | [[0, 0, 0, 10000, 0, 10000], []] | Passed |
| partial repair guard 1 | [[0, 0, 0, 10000], []] | [[0, 0, 0, 10000], []] | Passed |
| control: fifo two years | [[0, 1000, 14000], []] | [[0, 1000, 14000], []] | Passed |
| control: two losses | [[0, 0, 2000], []] | [[0, 0, 2000], []] | Passed |
| control: odd cap | [[0, 2001], [[0, 42000]]] | [[0, 2001], [[0, 42000]]] | Passed |
| control: losses after income | [[10000, 0, 0, 1000, 1000], [[2, 2000]]] | [[10000, 0, 0, 1000, 1000], [[2, 2000]]] | Passed |
SHA-256 / 39fd9153425c26e37d0c712d20c9dbbab881a184d0b8295696563b661cdbca4e
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.659534+00:00.
Case digest / 4ef90e5042d5c42337d8c6767f034fb0d76f6f28ce99ffc887ee43538bc02c36