FAILURE MAP
← Case archive

FA-62476 / Tax bracket computation / Open access

The credit carryforward ignores the part that was used · case 01

The full carry credit is carried forward even after it reduced this year's tax.

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

ROOT CAUSE

cf is set to the full carry credit instead of the unused portion.

VERIFIED REPAIR

Carry forward only c - use_c.

Unsuccessful approach: Computing the carryforward from the tax remaining after the credit mixes up credit and tax balances.

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
    t -= r
    return [t, cf]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
cases = [[('regression carryforward-amount 1', (1000, [['nonref', 400], ['carry', 800], ['ref', 300]]), [-300, 200]),
  ('regression carryforward-amount 2', (900, [['carry', 400], ['nonref', 600], ['carry', 100]]), [0, 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'),
  ('control: nonref exceeds tax', (300, [['nonref', 500], ['ref', 100]]), [-100, 0])],
 [('regression carryforward-amount 1', (500, [['carry', 50], ['carry', 1626], ['carry', 2439], ['carry', 2757]]),
   [0, 6372]),
  ('regression carryforward-amount 2', (1000, [['carry', 300], ['nonref', 100], ['nonref', 100], ['nonref', 765]]),
   [0, 265]),
  ('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 carryforward-amount 1', (2284, [['carry', 50], ['ref', 300]]), [1934, 0]),
  ('regression carryforward-amount 2', (1112, [['carry', 300]]), [812, 0]),
  ('partial repair guard 1', (500, [['carry', 300]]), [200, 0]),
  ('partial repair guard 2', (100, [['ref', 931], ['carry', 300], ['ref', 50]]), [-981, 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]), ('control: no tax carry', (0, [['carry', 50]]), [0, 50])],
 [('regression carryforward-amount 1', (500, [['carry', 300]]), [200, 0]),
  ('regression carryforward-amount 2', (100, [['ref', 931], ['carry', 300], ['ref', 50]]), [-981, 200]),
  ('partial repair guard 1', (500, [['carry', 2501], ['carry', 0], ['nonref', 300], ['ref', 0]]), [0, 2301]),
  ('partial repair guard 2', (1000, [['ref', 50], ['carry', 0], ['carry', 483], ['nonref', 50]]), [417, 0]),
  ('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 carryforward-amount 1', (500, [['carry', 100]]), [400, 0]),
  ('regression carryforward-amount 2', (500, [['carry', 2501], ['carry', 0], ['nonref', 300], ['ref', 0]]), [0, 2301]),
  ('partial repair guard 1', (100, [['carry', 100], ['carry', 0]]), [0, 0]),
  ('partial repair guard 2', (500, [['ref', 300], ['carry', 2443]]), [-300, 1943]),
  ('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 carryforward-amount 1[-300, 800][-300, 200]Failed
regression carryforward-amount 2[0, 500][0, 200]Failed
control: refund[-200, 0][-200, 0]Passed
control: no tax carry[0, 50][0, 50]Passed
control: unknown kindERR:kindERR:kindPassed
control: nonref exceeds tax[-100, 0][-100, 0]Passed

SHA-256 / d9a4a22d0c7ba63cebc47cb77835815c72d90bde95153cfceecfbf3062ae7ed9

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 = max(0, c - t)
    t -= r
    return [t, cf]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
cases = [[('regression carryforward-amount 1', (1000, [['nonref', 400], ['carry', 800], ['ref', 300]]), [-300, 200]),
  ('regression carryforward-amount 2', (900, [['carry', 400], ['nonref', 600], ['carry', 100]]), [0, 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'),
  ('control: nonref exceeds tax', (300, [['nonref', 500], ['ref', 100]]), [-100, 0])],
 [('regression carryforward-amount 1', (500, [['carry', 50], ['carry', 1626], ['carry', 2439], ['carry', 2757]]),
   [0, 6372]),
  ('regression carryforward-amount 2', (1000, [['carry', 300], ['nonref', 100], ['nonref', 100], ['nonref', 765]]),
   [0, 265]),
  ('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 carryforward-amount 1', (2284, [['carry', 50], ['ref', 300]]), [1934, 0]),
  ('regression carryforward-amount 2', (1112, [['carry', 300]]), [812, 0]),
  ('partial repair guard 1', (500, [['carry', 300]]), [200, 0]),
  ('partial repair guard 2', (100, [['ref', 931], ['carry', 300], ['ref', 50]]), [-981, 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]), ('control: no tax carry', (0, [['carry', 50]]), [0, 50])],
 [('regression carryforward-amount 1', (500, [['carry', 300]]), [200, 0]),
  ('regression carryforward-amount 2', (100, [['ref', 931], ['carry', 300], ['ref', 50]]), [-981, 200]),
  ('partial repair guard 1', (500, [['carry', 2501], ['carry', 0], ['nonref', 300], ['ref', 0]]), [0, 2301]),
  ('partial repair guard 2', (1000, [['ref', 50], ['carry', 0], ['carry', 483], ['nonref', 50]]), [417, 0]),
  ('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 carryforward-amount 1', (500, [['carry', 100]]), [400, 0]),
  ('regression carryforward-amount 2', (500, [['carry', 2501], ['carry', 0], ['nonref', 300], ['ref', 0]]), [0, 2301]),
  ('partial repair guard 1', (100, [['carry', 100], ['carry', 0]]), [0, 0]),
  ('partial repair guard 2', (500, [['ref', 300], ['carry', 2443]]), [-300, 1943]),
  ('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 carryforward-amount 1[-300, 800][-300, 200]Failed
regression carryforward-amount 2[0, 500][0, 200]Failed
control: refund[-200, 0][-200, 0]Passed
control: no tax carry[0, 50][0, 50]Passed
control: unknown kindERR:kindERR:kindPassed
control: nonref exceeds tax[-100, 0][-100, 0]Passed

SHA-256 / eef937f5d26c8dff0035f711bafe4f0bd8c56c79bcc325ac67d61b5638d5f704

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 carryforward-amount 1', (1000, [['nonref', 400], ['carry', 800], ['ref', 300]]), [-300, 200]),
  ('regression carryforward-amount 2', (900, [['carry', 400], ['nonref', 600], ['carry', 100]]), [0, 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'),
  ('control: nonref exceeds tax', (300, [['nonref', 500], ['ref', 100]]), [-100, 0])],
 [('regression carryforward-amount 1', (500, [['carry', 50], ['carry', 1626], ['carry', 2439], ['carry', 2757]]),
   [0, 6372]),
  ('regression carryforward-amount 2', (1000, [['carry', 300], ['nonref', 100], ['nonref', 100], ['nonref', 765]]),
   [0, 265]),
  ('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 carryforward-amount 1', (2284, [['carry', 50], ['ref', 300]]), [1934, 0]),
  ('regression carryforward-amount 2', (1112, [['carry', 300]]), [812, 0]),
  ('partial repair guard 1', (500, [['carry', 300]]), [200, 0]),
  ('partial repair guard 2', (100, [['ref', 931], ['carry', 300], ['ref', 50]]), [-981, 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]), ('control: no tax carry', (0, [['carry', 50]]), [0, 50])],
 [('regression carryforward-amount 1', (500, [['carry', 300]]), [200, 0]),
  ('regression carryforward-amount 2', (100, [['ref', 931], ['carry', 300], ['ref', 50]]), [-981, 200]),
  ('partial repair guard 1', (500, [['carry', 2501], ['carry', 0], ['nonref', 300], ['ref', 0]]), [0, 2301]),
  ('partial repair guard 2', (1000, [['ref', 50], ['carry', 0], ['carry', 483], ['nonref', 50]]), [417, 0]),
  ('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 carryforward-amount 1', (500, [['carry', 100]]), [400, 0]),
  ('regression carryforward-amount 2', (500, [['carry', 2501], ['carry', 0], ['nonref', 300], ['ref', 0]]), [0, 2301]),
  ('partial repair guard 1', (100, [['carry', 100], ['carry', 0]]), [0, 0]),
  ('partial repair guard 2', (500, [['ref', 300], ['carry', 2443]]), [-300, 1943]),
  ('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 carryforward-amount 1[-300, 200][-300, 200]Passed
regression carryforward-amount 2[0, 200][0, 200]Passed
control: refund[-200, 0][-200, 0]Passed
control: no tax carry[0, 50][0, 50]Passed
control: unknown kindERR:kindERR:kindPassed
control: nonref exceeds tax[-100, 0][-100, 0]Passed

SHA-256 / 7aa74c231481a72cfae80943561bde1d7856bc5f4e691f74f08923ec04557642

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

Case digest / 37aec9e4d92b96e0f8dae594ffffe08d47b771ed0b58e52dae70751b5c99d2b5