FAILURE MAP
← Case archive

FA-62491 / Tax bracket computation / Open access

Income exactly at a threshold is assigned to the higher bracket · case 01

Someone with taxable income exactly 40000 is told their marginal rate is 22%.

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

ROOT CAUSE

The containing bracket uses taxable < upper.

VERIFIED REPAIR

Use (lower, upper] membership: taxable <= upper.

Unsuccessful approach: Special-casing zero income does not repair membership at other thresholds.

Case contract

solve(gross, deduction, brackets): taxable = max(0, gross - deduction); tax uses the progressive slices. The marginal rate is the rate of the bracket containing taxable income with (lower, upper] semantics (income exactly at a threshold is in the lower bracket), and is '0' when gross < deduction (unused deduction absorbs the next dollar; at gross == deduction the next dollar is taxed at the first rate). The effective rate is tax / gross in basis points rounded half-up (0 when gross <= 0). Return [marginal_rate_string, effective_bps].

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
from fractions import Fraction
N = 1
observations = []
def solve(gross, deduction, brackets):
    def prog(x, br):
        tax, lower = Fraction(0), 0
        for upper, rate in br:
            top = x if upper is None else min(x, upper)
            if top > lower: tax += (top - lower) * Fraction(rate) / 100
            if upper is None or x <= upper: break
            lower = upper
        return tax
    def cents(v):
        v = v * 100
        return int(v + Fraction(1, 2)) if v >= 0 else -int(-v + Fraction(1, 2))
    
    taxable = max(0, gross - deduction)
    tax = prog(taxable, brackets)
    if gross < deduction:
        marginal = '0'
    else:
        marginal = next(rate for upper, rate in brackets if upper is None or taxable < upper)
    eff = cents(tax * 100 / gross) if gross > 0 else 0
    return [marginal, eff]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
cases = [[('regression threshold-membership 1', (54600, 14600, [[10000, '10'], [40000, '12'], [None, '22']]), ['12', 842]),
  ('regression threshold-membership 2', (10000, 0, [[10000, '10'], [40000, '12'], [None, '22']]), ['10', 1000]),
  ('control: top bracket', (50000, 0, [[10000, '10'], [40000, '12'], [None, '22']]), ['22', 1360]),
  ('control: deduction not exhausted', (10000, 14600, [[10000, '10'], [40000, '12'], [None, '22']]), ['0', 0]),
  ('control: deduction exactly used', (14600, 14600, [[10000, '10'], [40000, '12'], [None, '22']]), ['10', 0]),
  ('control: five brackets',
   (123456, 14600, [[11000, '10'], [44725, '12'], [95375, '22'], [182100, '24'], [None, '32.5']]), ['24', 1582])],
 [('regression threshold-membership 1', (13000, 3000, [[10000, '10'], [40000, '12'], [None, '22']]), ['10', 769]),
  ('regression threshold-membership 2', (40000, 0, [[10000, '10'], [40000, '12'], [None, '22']]), ['12', 1150]),
  ('control: deduction not exhausted', (10000, 14600, [[10000, '10'], [40000, '12'], [None, '22']]), ['0', 0]),
  ('control: deduction exactly used', (14600, 14600, [[10000, '10'], [40000, '12'], [None, '22']]), ['10', 0]),
  ('control: five brackets',
   (123456, 14600, [[11000, '10'], [44725, '12'], [95375, '22'], [182100, '24'], [None, '32.5']]), ['24', 1582]),
  ('control: zero gross', (0, 0, [[10000, '10'], [40000, '12'], [None, '22']]), ['10', 0])],
 [('regression threshold-membership 1', (54600, 14600, [[10000, '10'], [40000, '12'], [None, '22']]), ['12', 842]),
  ('regression threshold-membership 2', (10000, 0, [[10000, '10'], [40000, '12'], [None, '22']]), ['10', 1000]),
  ('control: zero gross', (0, 0, [[10000, '10'], [40000, '12'], [None, '22']]), ['10', 0]),
  ('control: one above threshold', (10001, 0, [[10000, '10'], [40000, '12'], [None, '22']]), ['12', 1000]),
  ('control: top bracket', (50000, 0, [[10000, '10'], [40000, '12'], [None, '22']]), ['22', 1360]),
  ('control: deduction not exhausted', (10000, 14600, [[10000, '10'], [40000, '12'], [None, '22']]), ['0', 0])],
 [('regression threshold-membership 1', (13000, 3000, [[10000, '10'], [40000, '12'], [None, '22']]), ['10', 769]),
  ('regression threshold-membership 2', (40000, 0, [[10000, '10'], [40000, '12'], [None, '22']]), ['12', 1150]),
  ('control: top bracket', (50000, 0, [[10000, '10'], [40000, '12'], [None, '22']]), ['22', 1360]),
  ('control: exact first threshold', (10000, 0, [[10000, '10'], [40000, '12'], [None, '22']]), ['10', 1000]),
  ('control: deduction not exhausted', (10000, 14600, [[10000, '10'], [40000, '12'], [None, '22']]), ['0', 0]),
  ('control: deduction exactly used', (14600, 14600, [[10000, '10'], [40000, '12'], [None, '22']]), ['10', 0])],
 [('regression threshold-membership 1', (54600, 14600, [[10000, '10'], [40000, '12'], [None, '22']]), ['12', 842]),
  ('regression threshold-membership 2', (10000, 0, [[10000, '10'], [40000, '12'], [None, '22']]), ['10', 1000]),
  ('control: deduction exactly used', (14600, 14600, [[10000, '10'], [40000, '12'], [None, '22']]), ['10', 0]),
  ('control: five brackets',
   (123456, 14600, [[11000, '10'], [44725, '12'], [95375, '22'], [182100, '24'], [None, '32.5']]), ['24', 1582]),
  ('control: zero gross', (0, 0, [[10000, '10'], [40000, '12'], [None, '22']]), ['10', 0]),
  ('control: one above threshold', (10001, 0, [[10000, '10'], [40000, '12'], [None, '22']]), ['12', 1000])]]
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 threshold-membership 1['22', 842]['12', 842]Failed
regression threshold-membership 2['12', 1000]['10', 1000]Failed
control: top bracket['22', 1360]['22', 1360]Passed
control: deduction not exhausted['0', 0]['0', 0]Passed
control: deduction exactly used['10', 0]['10', 0]Passed
control: five brackets['24', 1582]['24', 1582]Passed

SHA-256 / 7de3e737aea6d7a6c4a03afbd78de910a64fb6214d760a264d11c7c1fbfc5fcc

2 / The unsuccessful fix

Exit 1
"""Failure Map reference implementation. Python standard library only."""
import json
from fractions import Fraction
N = 1
observations = []
def solve(gross, deduction, brackets):
    def prog(x, br):
        tax, lower = Fraction(0), 0
        for upper, rate in br:
            top = x if upper is None else min(x, upper)
            if top > lower: tax += (top - lower) * Fraction(rate) / 100
            if upper is None or x <= upper: break
            lower = upper
        return tax
    def cents(v):
        v = v * 100
        return int(v + Fraction(1, 2)) if v >= 0 else -int(-v + Fraction(1, 2))
    
    taxable = max(0, gross - deduction)
    tax = prog(taxable, brackets)
    if gross < deduction:
        marginal = '0'
    else:
        marginal = next(rate for upper, rate in brackets if upper is None or taxable < upper or taxable == 0)
    eff = cents(tax * 100 / gross) if gross > 0 else 0
    return [marginal, eff]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
cases = [[('regression threshold-membership 1', (54600, 14600, [[10000, '10'], [40000, '12'], [None, '22']]), ['12', 842]),
  ('regression threshold-membership 2', (10000, 0, [[10000, '10'], [40000, '12'], [None, '22']]), ['10', 1000]),
  ('control: top bracket', (50000, 0, [[10000, '10'], [40000, '12'], [None, '22']]), ['22', 1360]),
  ('control: deduction not exhausted', (10000, 14600, [[10000, '10'], [40000, '12'], [None, '22']]), ['0', 0]),
  ('control: deduction exactly used', (14600, 14600, [[10000, '10'], [40000, '12'], [None, '22']]), ['10', 0]),
  ('control: five brackets',
   (123456, 14600, [[11000, '10'], [44725, '12'], [95375, '22'], [182100, '24'], [None, '32.5']]), ['24', 1582])],
 [('regression threshold-membership 1', (13000, 3000, [[10000, '10'], [40000, '12'], [None, '22']]), ['10', 769]),
  ('regression threshold-membership 2', (40000, 0, [[10000, '10'], [40000, '12'], [None, '22']]), ['12', 1150]),
  ('control: deduction not exhausted', (10000, 14600, [[10000, '10'], [40000, '12'], [None, '22']]), ['0', 0]),
  ('control: deduction exactly used', (14600, 14600, [[10000, '10'], [40000, '12'], [None, '22']]), ['10', 0]),
  ('control: five brackets',
   (123456, 14600, [[11000, '10'], [44725, '12'], [95375, '22'], [182100, '24'], [None, '32.5']]), ['24', 1582]),
  ('control: zero gross', (0, 0, [[10000, '10'], [40000, '12'], [None, '22']]), ['10', 0])],
 [('regression threshold-membership 1', (54600, 14600, [[10000, '10'], [40000, '12'], [None, '22']]), ['12', 842]),
  ('regression threshold-membership 2', (10000, 0, [[10000, '10'], [40000, '12'], [None, '22']]), ['10', 1000]),
  ('control: zero gross', (0, 0, [[10000, '10'], [40000, '12'], [None, '22']]), ['10', 0]),
  ('control: one above threshold', (10001, 0, [[10000, '10'], [40000, '12'], [None, '22']]), ['12', 1000]),
  ('control: top bracket', (50000, 0, [[10000, '10'], [40000, '12'], [None, '22']]), ['22', 1360]),
  ('control: deduction not exhausted', (10000, 14600, [[10000, '10'], [40000, '12'], [None, '22']]), ['0', 0])],
 [('regression threshold-membership 1', (13000, 3000, [[10000, '10'], [40000, '12'], [None, '22']]), ['10', 769]),
  ('regression threshold-membership 2', (40000, 0, [[10000, '10'], [40000, '12'], [None, '22']]), ['12', 1150]),
  ('control: top bracket', (50000, 0, [[10000, '10'], [40000, '12'], [None, '22']]), ['22', 1360]),
  ('control: exact first threshold', (10000, 0, [[10000, '10'], [40000, '12'], [None, '22']]), ['10', 1000]),
  ('control: deduction not exhausted', (10000, 14600, [[10000, '10'], [40000, '12'], [None, '22']]), ['0', 0]),
  ('control: deduction exactly used', (14600, 14600, [[10000, '10'], [40000, '12'], [None, '22']]), ['10', 0])],
 [('regression threshold-membership 1', (54600, 14600, [[10000, '10'], [40000, '12'], [None, '22']]), ['12', 842]),
  ('regression threshold-membership 2', (10000, 0, [[10000, '10'], [40000, '12'], [None, '22']]), ['10', 1000]),
  ('control: deduction exactly used', (14600, 14600, [[10000, '10'], [40000, '12'], [None, '22']]), ['10', 0]),
  ('control: five brackets',
   (123456, 14600, [[11000, '10'], [44725, '12'], [95375, '22'], [182100, '24'], [None, '32.5']]), ['24', 1582]),
  ('control: zero gross', (0, 0, [[10000, '10'], [40000, '12'], [None, '22']]), ['10', 0]),
  ('control: one above threshold', (10001, 0, [[10000, '10'], [40000, '12'], [None, '22']]), ['12', 1000])]]
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 threshold-membership 1['22', 842]['12', 842]Failed
regression threshold-membership 2['12', 1000]['10', 1000]Failed
control: top bracket['22', 1360]['22', 1360]Passed
control: deduction not exhausted['0', 0]['0', 0]Passed
control: deduction exactly used['10', 0]['10', 0]Passed
control: five brackets['24', 1582]['24', 1582]Passed

SHA-256 / c47f800597d9e92bf4b6d47cce98f0b7070b34cba4d4fa45e664da53711daceb

3 / The verified repair

Exit 0
"""Failure Map reference implementation. Python standard library only."""
import json
from fractions import Fraction
N = 1
observations = []
def solve(gross, deduction, brackets):
    def prog(x, br):
        tax, lower = Fraction(0), 0
        for upper, rate in br:
            top = x if upper is None else min(x, upper)
            if top > lower: tax += (top - lower) * Fraction(rate) / 100
            if upper is None or x <= upper: break
            lower = upper
        return tax
    def cents(v):
        v = v * 100
        return int(v + Fraction(1, 2)) if v >= 0 else -int(-v + Fraction(1, 2))
    
    taxable = max(0, gross - deduction)
    tax = prog(taxable, brackets)
    if gross < deduction:
        marginal = '0'
    else:
        marginal = next(rate for upper, rate in brackets if upper is None or taxable <= upper)
    eff = cents(tax * 100 / gross) if gross > 0 else 0
    return [marginal, eff]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
cases = [[('regression threshold-membership 1', (54600, 14600, [[10000, '10'], [40000, '12'], [None, '22']]), ['12', 842]),
  ('regression threshold-membership 2', (10000, 0, [[10000, '10'], [40000, '12'], [None, '22']]), ['10', 1000]),
  ('control: top bracket', (50000, 0, [[10000, '10'], [40000, '12'], [None, '22']]), ['22', 1360]),
  ('control: deduction not exhausted', (10000, 14600, [[10000, '10'], [40000, '12'], [None, '22']]), ['0', 0]),
  ('control: deduction exactly used', (14600, 14600, [[10000, '10'], [40000, '12'], [None, '22']]), ['10', 0]),
  ('control: five brackets',
   (123456, 14600, [[11000, '10'], [44725, '12'], [95375, '22'], [182100, '24'], [None, '32.5']]), ['24', 1582])],
 [('regression threshold-membership 1', (13000, 3000, [[10000, '10'], [40000, '12'], [None, '22']]), ['10', 769]),
  ('regression threshold-membership 2', (40000, 0, [[10000, '10'], [40000, '12'], [None, '22']]), ['12', 1150]),
  ('control: deduction not exhausted', (10000, 14600, [[10000, '10'], [40000, '12'], [None, '22']]), ['0', 0]),
  ('control: deduction exactly used', (14600, 14600, [[10000, '10'], [40000, '12'], [None, '22']]), ['10', 0]),
  ('control: five brackets',
   (123456, 14600, [[11000, '10'], [44725, '12'], [95375, '22'], [182100, '24'], [None, '32.5']]), ['24', 1582]),
  ('control: zero gross', (0, 0, [[10000, '10'], [40000, '12'], [None, '22']]), ['10', 0])],
 [('regression threshold-membership 1', (54600, 14600, [[10000, '10'], [40000, '12'], [None, '22']]), ['12', 842]),
  ('regression threshold-membership 2', (10000, 0, [[10000, '10'], [40000, '12'], [None, '22']]), ['10', 1000]),
  ('control: zero gross', (0, 0, [[10000, '10'], [40000, '12'], [None, '22']]), ['10', 0]),
  ('control: one above threshold', (10001, 0, [[10000, '10'], [40000, '12'], [None, '22']]), ['12', 1000]),
  ('control: top bracket', (50000, 0, [[10000, '10'], [40000, '12'], [None, '22']]), ['22', 1360]),
  ('control: deduction not exhausted', (10000, 14600, [[10000, '10'], [40000, '12'], [None, '22']]), ['0', 0])],
 [('regression threshold-membership 1', (13000, 3000, [[10000, '10'], [40000, '12'], [None, '22']]), ['10', 769]),
  ('regression threshold-membership 2', (40000, 0, [[10000, '10'], [40000, '12'], [None, '22']]), ['12', 1150]),
  ('control: top bracket', (50000, 0, [[10000, '10'], [40000, '12'], [None, '22']]), ['22', 1360]),
  ('control: exact first threshold', (10000, 0, [[10000, '10'], [40000, '12'], [None, '22']]), ['10', 1000]),
  ('control: deduction not exhausted', (10000, 14600, [[10000, '10'], [40000, '12'], [None, '22']]), ['0', 0]),
  ('control: deduction exactly used', (14600, 14600, [[10000, '10'], [40000, '12'], [None, '22']]), ['10', 0])],
 [('regression threshold-membership 1', (54600, 14600, [[10000, '10'], [40000, '12'], [None, '22']]), ['12', 842]),
  ('regression threshold-membership 2', (10000, 0, [[10000, '10'], [40000, '12'], [None, '22']]), ['10', 1000]),
  ('control: deduction exactly used', (14600, 14600, [[10000, '10'], [40000, '12'], [None, '22']]), ['10', 0]),
  ('control: five brackets',
   (123456, 14600, [[11000, '10'], [44725, '12'], [95375, '22'], [182100, '24'], [None, '32.5']]), ['24', 1582]),
  ('control: zero gross', (0, 0, [[10000, '10'], [40000, '12'], [None, '22']]), ['10', 0]),
  ('control: one above threshold', (10001, 0, [[10000, '10'], [40000, '12'], [None, '22']]), ['12', 1000])]]
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 threshold-membership 1['12', 842]['12', 842]Passed
regression threshold-membership 2['10', 1000]['10', 1000]Passed
control: top bracket['22', 1360]['22', 1360]Passed
control: deduction not exhausted['0', 0]['0', 0]Passed
control: deduction exactly used['10', 0]['10', 0]Passed
control: five brackets['24', 1582]['24', 1582]Passed

SHA-256 / 93b1ea649d0e34660ee6c441b86252c4efda5cc7d360f506701ad0dd07a3a757

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

Case digest / f9facbacab31cde1718a6f49cb82da1684c0d27c5ebd7e0ffaf7645e1bb0db6d