{"abstract":"A short-term loss saves ordinary-rate tax although it should first absorb long-term gain.","category":"Tax bracket computation","checks":7,"contract":"solve(ordinary, stcg, ltcg, status): stipulated two-schedule computation for status 'single' or 'mfj'. Net short- and long-term results against each other first. If the combined capital result is a loss, up to 3000 of it reduces ordinary income (floored at 0) and nothing is preferential. Otherwise positive net short-term gain is ordinary income, and net long-term gain is preferential. Ordinary income uses the status bracket table. Preferential gain is stacked on top of ordinary income: 0% up to T1, 15% up to T2, 20% above (single T1 47025, T2 518900; mfj 94050, 583750). Return total tax in integer cents (half-up).","contract_signature":"ordinary, stcg, ltcg, status","evaluation_group":"w2-tax_bracket_computation-capital-gains-stacking","failed_approach":"Netting only up to 3000 of the short-term loss confuses the ordinary-income loss limit with character netting.","family":"w2-tax_bracket_computation-capital-gains-stacking-cross-netting","id":"FA-62431","implementations":{"attempt":{"sha256":"9cc52710d0cb8c04eec09ab0801cc90c975ed975261b0701896cb011bd38ef9e","source":"\"\"\"Failure Map reference implementation. Python standard library only.\"\"\"\nimport json\nfrom fractions import Fraction\nN = 1\nobservations = []\ndef solve(ordinary, stcg, ltcg, status):\n    def prog(x, br):\n        tax, lower = Fraction(0), 0\n        for upper, rate in br:\n            top = x if upper is None else min(x, upper)\n            if top > lower: tax += (top - lower) * Fraction(rate) / 100\n            if upper is None or x <= upper: break\n            lower = upper\n        return tax\n    def cents(v):\n        v = v * 100\n        return int(v + Fraction(1, 2)) if v >= 0 else -int(-v + Fraction(1, 2))\n    \n    brs = {'single': [[11600, '10'], [47150, '12'], [100525, '22'], [191950, '24'], [243725, '32'], [609350, '35'], [None, '37']], 'mfj': [[23200, '10'], [94300, '12'], [201050, '22'], [383900, '24'], [487450, '32'], [731200, '35'], [None, '37']]}\n    bands = {'single': (47025, 518900), 'mfj': (94050, 583750)}\n    t1, t2 = bands[status]\n    st, lt = stcg, ltcg\n    if st + lt < 0:\n        ord_inc, pref = max(0, ordinary - min(3000, -(st + lt))), 0\n    else:\n        if st < 0: lt, st = lt - min(3000, -st), 0\n        if lt < 0: st, lt = st + lt, 0\n        ord_inc, pref = ordinary + st, lt\n    lo, hi = ord_inc, ord_inc + pref\n    fifteen = max(0, min(hi, t2) - max(lo, t1))\n    twenty = max(0, hi - max(lo, t2))\n    tax = prog(ord_inc, brs[status]) + Fraction(15, 100) * fifteen + Fraction(20, 100) * twenty\n    return cents(tax)\ndef check(label, actual, expected):\n    observations.append({\"check\": label, \"actual\": actual, \"expected\": expected, \"passed\": actual == expected})\ncases = [[('regression cross-netting 1', (100000, -8000, 20000, 'mfj'), 1390600),\n  ('regression cross-netting 2', (60000, -2000, 9000, 'single'), 930300),\n  ('partial repair guard 2', (550000, -8000, 135896, 'single'), 18845395),\n  ('control: stacked partly in zero band', (40000, 0, 20000, 'single'), 651425),\n  ('control: gain only', (0, 0, 50000, 'single'), 44625),\n  ('control: net capital loss', (60000, -5000, 1000, 'single'), 759300),\n  ('control: high mfj', (500000, 0, 100000, 'mfj'), 13156200)],\n [('regression cross-netting 1', (550000, -8000, 135896, 'single'), 18845395),\n  ('regression cross-netting 2', (430707, -1500, 100000, 'mfj'), 10797424),\n  ('partial repair guard 1', (9947, -13667, 100000, 'single'), 838295),\n  ('partial repair guard 2', (173496, -15585, 20000, 'single'), 3534379),\n  ('control: high mfj', (500000, 0, 100000, 'mfj'), 13156200),\n  ('control: short-term gain', (30000, 10000, 5000, 'single'), 456800),\n  ('control: short loss offsets long', (100000, -8000, 20000, 'mfj'), 1390600),\n  ('control: long loss offsets short', (80000, 12000, -4000, 'single'), 1441300)],\n [('regression cross-netting 1', (9947, -13667, 100000, 'single'), 838295),\n  ('regression cross-netting 2', (173496, -15585, 20000, 'single'), 3534379),\n  ('partial repair guard 1', (0, -8000, 100000, 'single'), 674625),\n  ('partial repair guard 2', (40000, -6055, 100000, 'mfj'), 1032025),\n  ('control: long loss offsets short', (80000, 12000, -4000, 'single'), 1441300),\n  ('control: big loss capped', (2000, -9000, -1000, 'mfj'), 0),\n  ('control: stacked partly in zero band', (40000, 0, 20000, 'single'), 651425),\n  ('control: gain only', (0, 0, 50000, 'single'), 44625)],\n [('regression cross-netting 1', (40000, -8000, 20000, 'mfj'), 433600),\n  ('regression cross-netting 2', (0, -8000, 100000, 'single'), 674625),\n  ('partial repair guard 1', (550000, -8000, 100000, 'single'), 18127475),\n  ('partial repair guard 2', (0, -13215, 100000, 'mfj'), 0), ('control: gain only', (0, 0, 50000, 'single'), 44625),\n  ('control: net capital loss', (60000, -5000, 1000, 'single'), 759300),\n  ('control: high mfj', (500000, 0, 100000, 'mfj'), 13156200),\n  ('control: short-term gain', (30000, 10000, 5000, 'single'), 456800)],\n [('regression cross-netting 1', (40000, -6055, 100000, 'mfj'), 1032025),\n  ('regression cross-netting 2', (90000, -1500, 259301, 'single'), 5352315),\n  ('partial repair guard 1', (200000, -8000, 100000, 'single'), 5548650),\n  ('partial repair guard 2', (200000, -18032, 100000, 'mfj'), 4640120),\n  ('control: short-term gain', (30000, 10000, 5000, 'single'), 456800),\n  ('control: short loss offsets long', (100000, -8000, 20000, 'mfj'), 1390600),\n  ('control: long loss offsets short', (80000, 12000, -4000, 'single'), 1441300),\n  ('control: big loss capped', (2000, -9000, -1000, 'mfj'), 0)]]\nfor label, args, expected in cases[N - 1]:\n    check(label, solve(*args), expected)\nprint(json.dumps({\"observations\": observations, \"passed\": all(x[\"passed\"] for x in observations)}, ensure_ascii=False))\nraise SystemExit(0 if all(x[\"passed\"] for x in observations) else 1)\n"},"broken":{"sha256":"6d28efcd6efad4f86c750936b24e2f2f555ab073b2e6f215ef2036dafed416f9","source":"\"\"\"Failure Map reference implementation. Python standard library only.\"\"\"\nimport json\nfrom fractions import Fraction\nN = 1\nobservations = []\ndef solve(ordinary, stcg, ltcg, status):\n    def prog(x, br):\n        tax, lower = Fraction(0), 0\n        for upper, rate in br:\n            top = x if upper is None else min(x, upper)\n            if top > lower: tax += (top - lower) * Fraction(rate) / 100\n            if upper is None or x <= upper: break\n            lower = upper\n        return tax\n    def cents(v):\n        v = v * 100\n        return int(v + Fraction(1, 2)) if v >= 0 else -int(-v + Fraction(1, 2))\n    \n    brs = {'single': [[11600, '10'], [47150, '12'], [100525, '22'], [191950, '24'], [243725, '32'], [609350, '35'], [None, '37']], 'mfj': [[23200, '10'], [94300, '12'], [201050, '22'], [383900, '24'], [487450, '32'], [731200, '35'], [None, '37']]}\n    bands = {'single': (47025, 518900), 'mfj': (94050, 583750)}\n    t1, t2 = bands[status]\n    st, lt = stcg, ltcg\n    if st + lt < 0:\n        ord_inc, pref = max(0, ordinary - min(3000, -(st + lt))), 0\n    else:\n        if st < 0: ordinary, st = ordinary - min(3000, -st), 0\n        if lt < 0: st, lt = st + lt, 0\n        ord_inc, pref = ordinary + st, lt\n    lo, hi = ord_inc, ord_inc + pref\n    fifteen = max(0, min(hi, t2) - max(lo, t1))\n    twenty = max(0, hi - max(lo, t2))\n    tax = prog(ord_inc, brs[status]) + Fraction(15, 100) * fifteen + Fraction(20, 100) * twenty\n    return cents(tax)\ndef check(label, actual, expected):\n    observations.append({\"check\": label, \"actual\": actual, \"expected\": expected, \"passed\": actual == expected})\ncases = [[('regression cross-netting 1', (100000, -8000, 20000, 'mfj'), 1390600),\n  ('regression cross-netting 2', (60000, -2000, 9000, 'single'), 930300),\n  ('partial repair guard 2', (550000, -8000, 135896, 'single'), 18845395),\n  ('control: stacked partly in zero band', (40000, 0, 20000, 'single'), 651425),\n  ('control: gain only', (0, 0, 50000, 'single'), 44625),\n  ('control: net capital loss', (60000, -5000, 1000, 'single'), 759300),\n  ('control: high mfj', (500000, 0, 100000, 'mfj'), 13156200)],\n [('regression cross-netting 1', (550000, -8000, 135896, 'single'), 18845395),\n  ('regression cross-netting 2', (430707, -1500, 100000, 'mfj'), 10797424),\n  ('partial repair guard 1', (9947, -13667, 100000, 'single'), 838295),\n  ('partial repair guard 2', (173496, -15585, 20000, 'single'), 3534379),\n  ('control: high mfj', (500000, 0, 100000, 'mfj'), 13156200),\n  ('control: short-term gain', (30000, 10000, 5000, 'single'), 456800),\n  ('control: short loss offsets long', (100000, -8000, 20000, 'mfj'), 1390600),\n  ('control: long loss offsets short', (80000, 12000, -4000, 'single'), 1441300)],\n [('regression cross-netting 1', (9947, -13667, 100000, 'single'), 838295),\n  ('regression cross-netting 2', (173496, -15585, 20000, 'single'), 3534379),\n  ('partial repair guard 1', (0, -8000, 100000, 'single'), 674625),\n  ('partial repair guard 2', (40000, -6055, 100000, 'mfj'), 1032025),\n  ('control: long loss offsets short', (80000, 12000, -4000, 'single'), 1441300),\n  ('control: big loss capped', (2000, -9000, -1000, 'mfj'), 0),\n  ('control: stacked partly in zero band', (40000, 0, 20000, 'single'), 651425),\n  ('control: gain only', (0, 0, 50000, 'single'), 44625)],\n [('regression cross-netting 1', (40000, -8000, 20000, 'mfj'), 433600),\n  ('regression cross-netting 2', (0, -8000, 100000, 'single'), 674625),\n  ('partial repair guard 1', (550000, -8000, 100000, 'single'), 18127475),\n  ('partial repair guard 2', (0, -13215, 100000, 'mfj'), 0), ('control: gain only', (0, 0, 50000, 'single'), 44625),\n  ('control: net capital loss', (60000, -5000, 1000, 'single'), 759300),\n  ('control: high mfj', (500000, 0, 100000, 'mfj'), 13156200),\n  ('control: short-term gain', (30000, 10000, 5000, 'single'), 456800)],\n [('regression cross-netting 1', (40000, -6055, 100000, 'mfj'), 1032025),\n  ('regression cross-netting 2', (90000, -1500, 259301, 'single'), 5352315),\n  ('partial repair guard 1', (200000, -8000, 100000, 'single'), 5548650),\n  ('partial repair guard 2', (200000, -18032, 100000, 'mfj'), 4640120),\n  ('control: short-term gain', (30000, 10000, 5000, 'single'), 456800),\n  ('control: short loss offsets long', (100000, -8000, 20000, 'mfj'), 1390600),\n  ('control: long loss offsets short', (80000, 12000, -4000, 'single'), 1441300),\n  ('control: big loss capped', (2000, -9000, -1000, 'mfj'), 0)]]\nfor label, args, expected in cases[N - 1]:\n    check(label, solve(*args), expected)\nprint(json.dumps({\"observations\": observations, \"passed\": all(x[\"passed\"] for x in observations)}, ensure_ascii=False))\nraise SystemExit(0 if all(x[\"passed\"] for x in observations) else 1)\n"}},"limitations":"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.","method":"Deterministic executable model with adversarial boundary fixtures.","provenance":{"created_by":"Failure Map","dependencies":"Python standard library","family":"w2-tax_bracket_computation-capital-gains-stacking-cross-netting","generated_at":"2026-09-29T14:47:04.632465+00:00","license":"CC0-1.0","python":"3.12.14","seed":1,"split":"open-access"},"relevance":"Tax computations hinge on which slice, threshold, ordering and rounding rule applies at each step; a misplaced boundary silently misstates liabilities.","root_cause":"Short- and long-term results are not netted against each other before characterizing the gain.","sha256":"0549d46c2602b8d698e67f0e8df2887446db81cfeb7757a76b7ae799d3aa2dfc","title":"A short-term loss reduces ordinary income while long-term gain stays preferential · case 01","variant":1,"variant_policy":"Five numbered records share a model and may reuse boundary fixtures.","verified":true,"visibility":"public","verification":{"attempt":{"elapsed_ms":43.197,"exit_code":1,"observations":[{"actual":1465600,"check":"regression cross-netting 1","expected":1390600,"passed":false},{"actual":930300,"check":"regression cross-netting 2","expected":930300,"passed":true},{"actual":18945395,"check":"partial repair guard 2","expected":18845395,"passed":false},{"actual":651425,"check":"control: stacked partly in zero band","expected":651425,"passed":true},{"actual":44625,"check":"control: gain only","expected":44625,"passed":true},{"actual":759300,"check":"control: net capital loss","expected":759300,"passed":true},{"actual":13156200,"check":"control: high mfj","expected":13156200,"passed":true}],"passed":false,"stderr":"","stdout":"{\"observations\": [{\"check\": \"regression cross-netting 1\", \"actual\": 1465600, \"expected\": 1390600, \"passed\": false}, {\"check\": \"regression cross-netting 2\", \"actual\": 930300, \"expected\": 930300, \"passed\": true}, {\"check\": \"partial repair guard 2\", \"actual\": 18945395, \"expected\": 18845395, \"passed\": false}, {\"check\": \"control: stacked partly in zero band\", \"actual\": 651425, \"expected\": 651425, \"passed\": true}, {\"check\": \"control: gain only\", \"actual\": 44625, \"expected\": 44625, \"passed\": true}, {\"check\": \"control: net capital loss\", \"actual\": 759300, \"expected\": 759300, \"passed\": true}, {\"check\": \"control: high mfj\", \"actual\": 13156200, \"expected\": 13156200, \"passed\": true}], \"passed\": false}\n"},"broken":{"elapsed_ms":39.439,"exit_code":1,"observations":[{"actual":1444600,"check":"regression cross-netting 1","expected":1390600,"passed":false},{"actual":916300,"check":"regression cross-netting 2","expected":930300,"passed":false},{"actual":18900395,"check":"partial repair guard 2","expected":18845395,"passed":false},{"actual":651425,"check":"control: stacked partly in zero band","expected":651425,"passed":true},{"actual":44625,"check":"control: gain only","expected":44625,"passed":true},{"actual":759300,"check":"control: net capital loss","expected":759300,"passed":true},{"actual":13156200,"check":"control: high mfj","expected":13156200,"passed":true}],"passed":false,"stderr":"","stdout":"{\"observations\": [{\"check\": \"regression cross-netting 1\", \"actual\": 1444600, \"expected\": 1390600, \"passed\": false}, {\"check\": \"regression cross-netting 2\", \"actual\": 916300, \"expected\": 930300, \"passed\": false}, {\"check\": \"partial repair guard 2\", \"actual\": 18900395, \"expected\": 18845395, \"passed\": false}, {\"check\": \"control: stacked partly in zero band\", \"actual\": 651425, \"expected\": 651425, \"passed\": true}, {\"check\": \"control: gain only\", \"actual\": 44625, \"expected\": 44625, \"passed\": true}, {\"check\": \"control: net capital loss\", \"actual\": 759300, \"expected\": 759300, \"passed\": true}, {\"check\": \"control: high mfj\", \"actual\": 13156200, \"expected\": 13156200, \"passed\": true}], \"passed\": false}\n"}},"member_only":{"stages":["fixed"],"fields":["implementations.fixed","verification.fixed","harness","repair"],"note":"The verified repair, its recorded checks, the repair description, and the scoring harness are available to members."}}