FAILURE MAP
← Case archive

FA-62481 / Tax bracket computation / Open access

Refundable credits are capped at the remaining tax · case 01

Refundable credits never produce a refund.

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

ROOT CAUSE

The final result is floored at zero after refundable credits.

VERIFIED REPAIR

Apply refundable credits in full; a negative result is a refund.

Unsuccessful approach: Limiting refundable credits to the original tax still withholds refunds.

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 = min(n, t)
    t -= use_n
    use_c = min(c, t)
    t -= use_c
    cf = c - use_c
    t = max(0, t - r)
    return [t, cf]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
cases = [[('regression refundable-limit 1', (500, [['ref', 700]]), [-200, 0]),
  ('regression refundable-limit 2', (1000, [['nonref', 400], ['carry', 800], ['ref', 300]]), [-300, 200]),
  ('partial repair guard 2', (0, [['carry', 300], ['ref', 50]]), [-50, 300]),
  ('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 refundable-limit 1', (300, [['nonref', 500], ['ref', 100]]), [-100, 0]),
  ('regression refundable-limit 2', (0, [['carry', 300], ['ref', 50]]), [-50, 300]),
  ('partial repair guard 1', (0, [['ref', 2834], ['carry', 0]]), [-2834, 0]),
  ('partial repair guard 2', (0, [['nonref', 100], ['ref', 0], ['ref', 50], ['carry', 300]]), [-50, 300]),
  ('control: unknown kind', (100, [['bonus', 5]]), 'ERR:kind'),
  ('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])],
 [('regression refundable-limit 1', (0, [['ref', 2834], ['carry', 0]]), [-2834, 0]),
  ('regression refundable-limit 2', (0, [['nonref', 100], ['ref', 0], ['ref', 50], ['carry', 300]]), [-50, 300]),
  ('partial repair guard 1', (100, [['ref', 931], ['carry', 300], ['ref', 50]]), [-981, 200]),
  ('partial repair guard 2', (100, [['ref', 300]]), [-200, 0]), ('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 refundable-limit 1', (444, [['nonref', 806], ['ref', 2], ['nonref', 464], ['ref', 0]]), [-2, 0]),
  ('regression refundable-limit 2', (100, [['ref', 931], ['carry', 300], ['ref', 50]]), [-981, 200]),
  ('partial repair guard 1', (100, [['ref', 50], ['ref', 300], ['ref', 300], ['ref', 100]]), [-650, 0]),
  ('partial repair guard 2', (0, [['ref', 100], ['carry', 100]]), [-100, 100]),
  ('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 refundable-limit 1', (100, [['ref', 300]]), [-200, 0]),
  ('regression refundable-limit 2', (100, [['ref', 50], ['ref', 300], ['ref', 300], ['ref', 100]]), [-650, 0]),
  ('partial repair guard 1', (500, [['carry', 100], ['nonref', 100], ['ref', 634], ['nonref', 100]]), [-434, 0]),
  ('partial repair guard 2', (500, [['ref', 50], ['ref', 50], ['nonref', 0], ['ref', 2444]]), [-2044, 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 refundable-limit 1[0, 0][-200, 0]Failed
regression refundable-limit 2[0, 200][-300, 200]Failed
partial repair guard 2[0, 300][-50, 300]Failed
control: no tax carry[0, 50][0, 50]Passed
control: unknown kindERR:kindERR:kindPassed
control: nonref exceeds tax[0, 0][-100, 0]Failed
control: split carries[0, 200][0, 200]Passed

SHA-256 / 67ca01684902a0099313aceb3e258f2600821592d51e7aace77ea54dfaabf41f

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)
    t -= use_n
    use_c = min(c, t)
    t -= use_c
    cf = c - use_c
    t -= min(r, tax)
    return [t, cf]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
cases = [[('regression refundable-limit 1', (500, [['ref', 700]]), [-200, 0]),
  ('regression refundable-limit 2', (1000, [['nonref', 400], ['carry', 800], ['ref', 300]]), [-300, 200]),
  ('partial repair guard 2', (0, [['carry', 300], ['ref', 50]]), [-50, 300]),
  ('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 refundable-limit 1', (300, [['nonref', 500], ['ref', 100]]), [-100, 0]),
  ('regression refundable-limit 2', (0, [['carry', 300], ['ref', 50]]), [-50, 300]),
  ('partial repair guard 1', (0, [['ref', 2834], ['carry', 0]]), [-2834, 0]),
  ('partial repair guard 2', (0, [['nonref', 100], ['ref', 0], ['ref', 50], ['carry', 300]]), [-50, 300]),
  ('control: unknown kind', (100, [['bonus', 5]]), 'ERR:kind'),
  ('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])],
 [('regression refundable-limit 1', (0, [['ref', 2834], ['carry', 0]]), [-2834, 0]),
  ('regression refundable-limit 2', (0, [['nonref', 100], ['ref', 0], ['ref', 50], ['carry', 300]]), [-50, 300]),
  ('partial repair guard 1', (100, [['ref', 931], ['carry', 300], ['ref', 50]]), [-981, 200]),
  ('partial repair guard 2', (100, [['ref', 300]]), [-200, 0]), ('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 refundable-limit 1', (444, [['nonref', 806], ['ref', 2], ['nonref', 464], ['ref', 0]]), [-2, 0]),
  ('regression refundable-limit 2', (100, [['ref', 931], ['carry', 300], ['ref', 50]]), [-981, 200]),
  ('partial repair guard 1', (100, [['ref', 50], ['ref', 300], ['ref', 300], ['ref', 100]]), [-650, 0]),
  ('partial repair guard 2', (0, [['ref', 100], ['carry', 100]]), [-100, 100]),
  ('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 refundable-limit 1', (100, [['ref', 300]]), [-200, 0]),
  ('regression refundable-limit 2', (100, [['ref', 50], ['ref', 300], ['ref', 300], ['ref', 100]]), [-650, 0]),
  ('partial repair guard 1', (500, [['carry', 100], ['nonref', 100], ['ref', 634], ['nonref', 100]]), [-434, 0]),
  ('partial repair guard 2', (500, [['ref', 50], ['ref', 50], ['nonref', 0], ['ref', 2444]]), [-2044, 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 refundable-limit 1[0, 0][-200, 0]Failed
regression refundable-limit 2[-300, 200][-300, 200]Passed
partial repair guard 2[0, 300][-50, 300]Failed
control: no tax carry[0, 50][0, 50]Passed
control: unknown kindERR:kindERR:kindPassed
control: nonref exceeds tax[-100, 0][-100, 0]Passed
control: split carries[0, 200][0, 200]Passed

SHA-256 / 15a7aa826ceec3f8c36cc2a94c8fee8c8378de3bff296a1f7b1bdb65211b7a94

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 refundable-limit 1', (500, [['ref', 700]]), [-200, 0]),
  ('regression refundable-limit 2', (1000, [['nonref', 400], ['carry', 800], ['ref', 300]]), [-300, 200]),
  ('partial repair guard 2', (0, [['carry', 300], ['ref', 50]]), [-50, 300]),
  ('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 refundable-limit 1', (300, [['nonref', 500], ['ref', 100]]), [-100, 0]),
  ('regression refundable-limit 2', (0, [['carry', 300], ['ref', 50]]), [-50, 300]),
  ('partial repair guard 1', (0, [['ref', 2834], ['carry', 0]]), [-2834, 0]),
  ('partial repair guard 2', (0, [['nonref', 100], ['ref', 0], ['ref', 50], ['carry', 300]]), [-50, 300]),
  ('control: unknown kind', (100, [['bonus', 5]]), 'ERR:kind'),
  ('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])],
 [('regression refundable-limit 1', (0, [['ref', 2834], ['carry', 0]]), [-2834, 0]),
  ('regression refundable-limit 2', (0, [['nonref', 100], ['ref', 0], ['ref', 50], ['carry', 300]]), [-50, 300]),
  ('partial repair guard 1', (100, [['ref', 931], ['carry', 300], ['ref', 50]]), [-981, 200]),
  ('partial repair guard 2', (100, [['ref', 300]]), [-200, 0]), ('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 refundable-limit 1', (444, [['nonref', 806], ['ref', 2], ['nonref', 464], ['ref', 0]]), [-2, 0]),
  ('regression refundable-limit 2', (100, [['ref', 931], ['carry', 300], ['ref', 50]]), [-981, 200]),
  ('partial repair guard 1', (100, [['ref', 50], ['ref', 300], ['ref', 300], ['ref', 100]]), [-650, 0]),
  ('partial repair guard 2', (0, [['ref', 100], ['carry', 100]]), [-100, 100]),
  ('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 refundable-limit 1', (100, [['ref', 300]]), [-200, 0]),
  ('regression refundable-limit 2', (100, [['ref', 50], ['ref', 300], ['ref', 300], ['ref', 100]]), [-650, 0]),
  ('partial repair guard 1', (500, [['carry', 100], ['nonref', 100], ['ref', 634], ['nonref', 100]]), [-434, 0]),
  ('partial repair guard 2', (500, [['ref', 50], ['ref', 50], ['nonref', 0], ['ref', 2444]]), [-2044, 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 refundable-limit 1[-200, 0][-200, 0]Passed
regression refundable-limit 2[-300, 200][-300, 200]Passed
partial repair guard 2[-50, 300][-50, 300]Passed
control: no tax carry[0, 50][0, 50]Passed
control: unknown kindERR:kindERR:kindPassed
control: nonref exceeds tax[-100, 0][-100, 0]Passed
control: split carries[0, 200][0, 200]Passed

SHA-256 / 49598d0814ca8dbab98bc022c19a6afcbca021600fbb0f2dff79b795d3c84b2b

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

Case digest / a842cd20bee1c504eba2abfd62e218a8dc285b46ca851623e1736c2d0052609d