FAILURE MAP
← Case archive

FA-62471 / Tax bracket computation / Open access

Nonrefundable credits are allowed to produce a refund · case 01

A nonrefundable credit larger than the tax pays out cash.

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

ROOT CAUSE

The nonrefundable credit is applied in full instead of being limited to the remaining tax.

VERIFIED REPAIR

Limit nonrefundable credits to the tax remaining when they are applied.

Unsuccessful approach: Letting refundable credits raise the nonrefundable limit still converts part of the credit into a refund.

Case contract

solve(tax, credits): tax is integer cents >= 0; credits is a list of [kind, cents] with kind 'nonref' (nonrefundable, unused part lost), 'carry' (nonrefundable, unused part carried forward) or 'ref' (refundable). Unknown kinds return 'ERR:kind'. Apply all nonref credits first (limited to the remaining tax), then carry credits (limited to what remains), then refundable credits in full (a negative result is a refund). Return [final_tax, carryforward].

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(tax, credits):
    tot = {'nonref': 0, 'carry': 0, 'ref': 0}
    for kind, amount in credits:
        if kind not in tot: return 'ERR:kind'
        tot[kind] += amount
    n, c, r = tot['nonref'], tot['carry'], tot['ref']
    t = tax
    use_n = n
    t -= use_n
    use_c = min(c, t)
    t -= use_c
    cf = c - use_c
    t -= r
    return [t, cf]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
cases = [[('regression nonref-limit 1', (300, [['nonref', 500], ['ref', 100]]), [-100, 0]),
  ('regression nonref-limit 2', (300, [['nonref', 500]]), [0, 0]),
  ('partial repair guard 2', (0, [['nonref', 100], ['ref', 0], ['ref', 50], ['carry', 300]]), [-50, 300]),
  ('control: all kinds', (1000, [['nonref', 400], ['carry', 800], ['ref', 300]]), [-300, 200]),
  ('control: refund', (500, [['ref', 700]]), [-200, 0]), ('control: no tax carry', (0, [['carry', 50]]), [0, 50]),
  ('control: unknown kind', (100, [['bonus', 5]]), 'ERR:kind')],
 [('regression nonref-limit 1', (0, [['nonref', 1308]]), [0, 0]),
  ('regression nonref-limit 2', (1467, [['nonref', 0], ['carry', 50], ['nonref', 2387]]), [0, 50]),
  ('partial repair guard 1', (444, [['nonref', 806], ['ref', 2], ['nonref', 464], ['ref', 0]]), [-2, 0]),
  ('partial repair guard 2', (100, [['ref', 50], ['nonref', 2064]]), [-50, 0]),
  ('control: unknown kind', (100, [['bonus', 5]]), 'ERR:kind'),
  ('control: nonref exceeds tax', (300, [['nonref', 500], ['ref', 100]]), [-100, 0]),
  ('control: split carries', (900, [['carry', 400], ['nonref', 600], ['carry', 100]]), [0, 200]),
  ('control: empty', (1234, []), [1234, 0])],
 [('regression nonref-limit 1', (0, [['nonref', 100], ['carry', 0], ['ref', 0], ['nonref', 50]]), [0, 0]),
  ('regression nonref-limit 2', (0, [['nonref', 100], ['ref', 0], ['ref', 50], ['carry', 300]]), [-50, 300]),
  ('partial repair guard 1', (100, [['ref', 50], ['nonref', 300], ['ref', 380]]), [-430, 0]),
  ('partial repair guard 2', (0, [['ref', 100], ['nonref', 50], ['carry', 100], ['ref', 130]]), [-230, 100]),
  ('control: empty', (1234, []), [1234, 0]),
  ('control: all kinds', (1000, [['nonref', 400], ['carry', 800], ['ref', 300]]), [-300, 200]),
  ('control: refund', (500, [['ref', 700]]), [-200, 0]), ('control: no tax carry', (0, [['carry', 50]]), [0, 50])],
 [('regression nonref-limit 1', (444, [['nonref', 806], ['ref', 2], ['nonref', 464], ['ref', 0]]), [-2, 0]),
  ('regression nonref-limit 2', (0, [['nonref', 889]]), [0, 0]),
  ('partial repair guard 1', (0, [['nonref', 100], ['carry', 100], ['ref', 1667]]), [-1667, 100]),
  ('partial repair guard 2', (100, [['nonref', 2372], ['carry', 100], ['carry', 50], ['ref', 300]]), [-300, 150]),
  ('control: no tax carry', (0, [['carry', 50]]), [0, 50]),
  ('control: unknown kind', (100, [['bonus', 5]]), 'ERR:kind'),
  ('control: nonref exceeds tax', (300, [['nonref', 500], ['ref', 100]]), [-100, 0]),
  ('control: split carries', (900, [['carry', 400], ['nonref', 600], ['carry', 100]]), [0, 200])],
 [('regression nonref-limit 1', (100, [['carry', 300], ['nonref', 300], ['carry', 50], ['nonref', 2635]]), [0, 350]),
  ('regression nonref-limit 2', (100, [['ref', 50], ['nonref', 2064]]), [-50, 0]),
  ('partial repair guard 1', (100, [['nonref', 100], ['ref', 50], ['nonref', 300], ['ref', 1614]]), [-1664, 0]),
  ('partial repair guard 2', (100, [['carry', 0], ['nonref', 1027], ['ref', 2757]]), [-2757, 0]),
  ('control: split carries', (900, [['carry', 400], ['nonref', 600], ['carry', 100]]), [0, 200]),
  ('control: empty', (1234, []), [1234, 0]),
  ('control: all kinds', (1000, [['nonref', 400], ['carry', 800], ['ref', 300]]), [-300, 200]),
  ('control: refund', (500, [['ref', 700]]), [-200, 0])]]
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 nonref-limit 1[-100, 200][-100, 0]Failed
regression nonref-limit 2[0, 200][0, 0]Failed
partial repair guard 2[-50, 400][-50, 300]Failed
control: all kinds[-300, 200][-300, 200]Passed
control: refund[-200, 0][-200, 0]Passed
control: no tax carry[0, 50][0, 50]Passed
control: unknown kindERR:kindERR:kindPassed

SHA-256 / ff6c9b28e74ab6b91fc4ddfadfc8c62404ecbb5ed6825d56b3989d8948a7d3ce

2 / The unsuccessful fix

Exit 1
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(tax, credits):
    tot = {'nonref': 0, 'carry': 0, 'ref': 0}
    for kind, amount in credits:
        if kind not in tot: return 'ERR:kind'
        tot[kind] += amount
    n, c, r = tot['nonref'], tot['carry'], tot['ref']
    t = tax
    use_n = min(n, t + r)
    t -= use_n
    use_c = min(c, t)
    t -= use_c
    cf = c - use_c
    t -= r
    return [t, cf]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
cases = [[('regression nonref-limit 1', (300, [['nonref', 500], ['ref', 100]]), [-100, 0]),
  ('regression nonref-limit 2', (300, [['nonref', 500]]), [0, 0]),
  ('partial repair guard 2', (0, [['nonref', 100], ['ref', 0], ['ref', 50], ['carry', 300]]), [-50, 300]),
  ('control: all kinds', (1000, [['nonref', 400], ['carry', 800], ['ref', 300]]), [-300, 200]),
  ('control: refund', (500, [['ref', 700]]), [-200, 0]), ('control: no tax carry', (0, [['carry', 50]]), [0, 50]),
  ('control: unknown kind', (100, [['bonus', 5]]), 'ERR:kind')],
 [('regression nonref-limit 1', (0, [['nonref', 1308]]), [0, 0]),
  ('regression nonref-limit 2', (1467, [['nonref', 0], ['carry', 50], ['nonref', 2387]]), [0, 50]),
  ('partial repair guard 1', (444, [['nonref', 806], ['ref', 2], ['nonref', 464], ['ref', 0]]), [-2, 0]),
  ('partial repair guard 2', (100, [['ref', 50], ['nonref', 2064]]), [-50, 0]),
  ('control: unknown kind', (100, [['bonus', 5]]), 'ERR:kind'),
  ('control: nonref exceeds tax', (300, [['nonref', 500], ['ref', 100]]), [-100, 0]),
  ('control: split carries', (900, [['carry', 400], ['nonref', 600], ['carry', 100]]), [0, 200]),
  ('control: empty', (1234, []), [1234, 0])],
 [('regression nonref-limit 1', (0, [['nonref', 100], ['carry', 0], ['ref', 0], ['nonref', 50]]), [0, 0]),
  ('regression nonref-limit 2', (0, [['nonref', 100], ['ref', 0], ['ref', 50], ['carry', 300]]), [-50, 300]),
  ('partial repair guard 1', (100, [['ref', 50], ['nonref', 300], ['ref', 380]]), [-430, 0]),
  ('partial repair guard 2', (0, [['ref', 100], ['nonref', 50], ['carry', 100], ['ref', 130]]), [-230, 100]),
  ('control: empty', (1234, []), [1234, 0]),
  ('control: all kinds', (1000, [['nonref', 400], ['carry', 800], ['ref', 300]]), [-300, 200]),
  ('control: refund', (500, [['ref', 700]]), [-200, 0]), ('control: no tax carry', (0, [['carry', 50]]), [0, 50])],
 [('regression nonref-limit 1', (444, [['nonref', 806], ['ref', 2], ['nonref', 464], ['ref', 0]]), [-2, 0]),
  ('regression nonref-limit 2', (0, [['nonref', 889]]), [0, 0]),
  ('partial repair guard 1', (0, [['nonref', 100], ['carry', 100], ['ref', 1667]]), [-1667, 100]),
  ('partial repair guard 2', (100, [['nonref', 2372], ['carry', 100], ['carry', 50], ['ref', 300]]), [-300, 150]),
  ('control: no tax carry', (0, [['carry', 50]]), [0, 50]),
  ('control: unknown kind', (100, [['bonus', 5]]), 'ERR:kind'),
  ('control: nonref exceeds tax', (300, [['nonref', 500], ['ref', 100]]), [-100, 0]),
  ('control: split carries', (900, [['carry', 400], ['nonref', 600], ['carry', 100]]), [0, 200])],
 [('regression nonref-limit 1', (100, [['carry', 300], ['nonref', 300], ['carry', 50], ['nonref', 2635]]), [0, 350]),
  ('regression nonref-limit 2', (100, [['ref', 50], ['nonref', 2064]]), [-50, 0]),
  ('partial repair guard 1', (100, [['nonref', 100], ['ref', 50], ['nonref', 300], ['ref', 1614]]), [-1664, 0]),
  ('partial repair guard 2', (100, [['carry', 0], ['nonref', 1027], ['ref', 2757]]), [-2757, 0]),
  ('control: split carries', (900, [['carry', 400], ['nonref', 600], ['carry', 100]]), [0, 200]),
  ('control: empty', (1234, []), [1234, 0]),
  ('control: all kinds', (1000, [['nonref', 400], ['carry', 800], ['ref', 300]]), [-300, 200]),
  ('control: refund', (500, [['ref', 700]]), [-200, 0])]]
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 nonref-limit 1[-100, 100][-100, 0]Failed
regression nonref-limit 2[0, 0][0, 0]Passed
partial repair guard 2[-50, 350][-50, 300]Failed
control: all kinds[-300, 200][-300, 200]Passed
control: refund[-200, 0][-200, 0]Passed
control: no tax carry[0, 50][0, 50]Passed
control: unknown kindERR:kindERR:kindPassed

SHA-256 / 2ba35fa3c97c3bc565852c7f8c52b6d5f331b7362737183d465557c1cc856d76

3 / The verified repair

Exit 0
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(tax, credits):
    tot = {'nonref': 0, 'carry': 0, 'ref': 0}
    for kind, amount in credits:
        if kind not in tot: return 'ERR:kind'
        tot[kind] += amount
    n, c, r = tot['nonref'], tot['carry'], tot['ref']
    t = tax
    use_n = min(n, t)
    t -= use_n
    use_c = min(c, t)
    t -= use_c
    cf = c - use_c
    t -= r
    return [t, cf]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
cases = [[('regression nonref-limit 1', (300, [['nonref', 500], ['ref', 100]]), [-100, 0]),
  ('regression nonref-limit 2', (300, [['nonref', 500]]), [0, 0]),
  ('partial repair guard 2', (0, [['nonref', 100], ['ref', 0], ['ref', 50], ['carry', 300]]), [-50, 300]),
  ('control: all kinds', (1000, [['nonref', 400], ['carry', 800], ['ref', 300]]), [-300, 200]),
  ('control: refund', (500, [['ref', 700]]), [-200, 0]), ('control: no tax carry', (0, [['carry', 50]]), [0, 50]),
  ('control: unknown kind', (100, [['bonus', 5]]), 'ERR:kind')],
 [('regression nonref-limit 1', (0, [['nonref', 1308]]), [0, 0]),
  ('regression nonref-limit 2', (1467, [['nonref', 0], ['carry', 50], ['nonref', 2387]]), [0, 50]),
  ('partial repair guard 1', (444, [['nonref', 806], ['ref', 2], ['nonref', 464], ['ref', 0]]), [-2, 0]),
  ('partial repair guard 2', (100, [['ref', 50], ['nonref', 2064]]), [-50, 0]),
  ('control: unknown kind', (100, [['bonus', 5]]), 'ERR:kind'),
  ('control: nonref exceeds tax', (300, [['nonref', 500], ['ref', 100]]), [-100, 0]),
  ('control: split carries', (900, [['carry', 400], ['nonref', 600], ['carry', 100]]), [0, 200]),
  ('control: empty', (1234, []), [1234, 0])],
 [('regression nonref-limit 1', (0, [['nonref', 100], ['carry', 0], ['ref', 0], ['nonref', 50]]), [0, 0]),
  ('regression nonref-limit 2', (0, [['nonref', 100], ['ref', 0], ['ref', 50], ['carry', 300]]), [-50, 300]),
  ('partial repair guard 1', (100, [['ref', 50], ['nonref', 300], ['ref', 380]]), [-430, 0]),
  ('partial repair guard 2', (0, [['ref', 100], ['nonref', 50], ['carry', 100], ['ref', 130]]), [-230, 100]),
  ('control: empty', (1234, []), [1234, 0]),
  ('control: all kinds', (1000, [['nonref', 400], ['carry', 800], ['ref', 300]]), [-300, 200]),
  ('control: refund', (500, [['ref', 700]]), [-200, 0]), ('control: no tax carry', (0, [['carry', 50]]), [0, 50])],
 [('regression nonref-limit 1', (444, [['nonref', 806], ['ref', 2], ['nonref', 464], ['ref', 0]]), [-2, 0]),
  ('regression nonref-limit 2', (0, [['nonref', 889]]), [0, 0]),
  ('partial repair guard 1', (0, [['nonref', 100], ['carry', 100], ['ref', 1667]]), [-1667, 100]),
  ('partial repair guard 2', (100, [['nonref', 2372], ['carry', 100], ['carry', 50], ['ref', 300]]), [-300, 150]),
  ('control: no tax carry', (0, [['carry', 50]]), [0, 50]),
  ('control: unknown kind', (100, [['bonus', 5]]), 'ERR:kind'),
  ('control: nonref exceeds tax', (300, [['nonref', 500], ['ref', 100]]), [-100, 0]),
  ('control: split carries', (900, [['carry', 400], ['nonref', 600], ['carry', 100]]), [0, 200])],
 [('regression nonref-limit 1', (100, [['carry', 300], ['nonref', 300], ['carry', 50], ['nonref', 2635]]), [0, 350]),
  ('regression nonref-limit 2', (100, [['ref', 50], ['nonref', 2064]]), [-50, 0]),
  ('partial repair guard 1', (100, [['nonref', 100], ['ref', 50], ['nonref', 300], ['ref', 1614]]), [-1664, 0]),
  ('partial repair guard 2', (100, [['carry', 0], ['nonref', 1027], ['ref', 2757]]), [-2757, 0]),
  ('control: split carries', (900, [['carry', 400], ['nonref', 600], ['carry', 100]]), [0, 200]),
  ('control: empty', (1234, []), [1234, 0]),
  ('control: all kinds', (1000, [['nonref', 400], ['carry', 800], ['ref', 300]]), [-300, 200]),
  ('control: refund', (500, [['ref', 700]]), [-200, 0])]]
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 nonref-limit 1[-100, 0][-100, 0]Passed
regression nonref-limit 2[0, 0][0, 0]Passed
partial repair guard 2[-50, 300][-50, 300]Passed
control: all kinds[-300, 200][-300, 200]Passed
control: refund[-200, 0][-200, 0]Passed
control: no tax carry[0, 50][0, 50]Passed
control: unknown kindERR:kindERR:kindPassed

SHA-256 / 2bd56924cb65ad6b5c0623bfe321c54441920ed8e06229c9da4aa3c4645a559c

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

Case digest / 76ec34bcb2ea8f9d31d5ef438bf8e749004a1efc9fa0074a56d059794a7aafc9