{"abstract":"Expiring nonrefundable credits are wasted while carryable credits are used up.","category":"Tax bracket computation","checks":7,"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].","evaluation_group":"w2-tax_bracket_computation-credit-ordering","failed_approach":"Applying refundable credits first leaves no tax for the nonrefundable credits to reduce.","family":"w2-tax_bracket_computation-credit-ordering-nonref-before-carry","id":"FA-62466","implementations":{"attempt":{"sha256":"64d6ee47d54c212ec8e0d1384921c739f7e3817de89cb51b76b4d5a3b67dc169","source":"\"\"\"Failure Map reference implementation. Python standard library only.\"\"\"\nimport json\n\nN = 1\nobservations = []\ndef solve(tax, credits):\n    tot = {'nonref': 0, 'carry': 0, 'ref': 0}\n    for kind, amount in credits:\n        if kind not in tot: return 'ERR:kind'\n        tot[kind] += amount\n    n, c, r = tot['nonref'], tot['carry'], tot['ref']\n    t = tax\n    t -= r\n    use_n = min(n, max(0, t))\n    t -= use_n\n    use_c = min(c, max(0, t))\n    t -= use_c\n    cf = c - use_c\n    return [t, cf]\ndef check(label, actual, expected):\n    observations.append({\"check\": label, \"actual\": actual, \"expected\": expected, \"passed\": actual == expected})\ncases = [[('regression nonref-before-carry 1', (1000, [['nonref', 400], ['carry', 800], ['ref', 300]]), [-300, 200]),\n  ('regression nonref-before-carry 2', (900, [['carry', 400], ['nonref', 600], ['carry', 100]]), [0, 200]),\n  ('partial repair guard 2', (300, [['nonref', 500], ['ref', 100]]), [-100, 0]),\n  ('control: refund', (500, [['ref', 700]]), [-200, 0]), ('control: no tax carry', (0, [['carry', 50]]), [0, 50]),\n  ('control: unknown kind', (100, [['bonus', 5]]), 'ERR:kind'), ('control: empty', (1234, []), [1234, 0])],\n [('regression nonref-before-carry 1', (1467, [['nonref', 0], ['carry', 50], ['nonref', 2387]]), [0, 50]),\n  ('regression nonref-before-carry 2', (1000, [['carry', 300], ['nonref', 100], ['nonref', 100], ['nonref', 765]]),\n   [0, 265]),\n  ('partial repair guard 1', (444, [['nonref', 806], ['ref', 2], ['nonref', 464], ['ref', 0]]), [-2, 0]),\n  ('partial repair guard 2', (100, [['ref', 931], ['carry', 300], ['ref', 50]]), [-981, 200]),\n  ('control: unknown kind', (100, [['bonus', 5]]), 'ERR:kind'),\n  ('control: nonref exceeds tax', (300, [['nonref', 500], ['ref', 100]]), [-100, 0]),\n  ('control: split carries', (900, [['carry', 400], ['nonref', 600], ['carry', 100]]), [0, 200]),\n  ('control: empty', (1234, []), [1234, 0])],\n [('regression nonref-before-carry 1', (100, [['carry', 300], ['nonref', 300], ['carry', 50], ['nonref', 2635]]),\n   [0, 350]),\n  ('regression nonref-before-carry 2', (500, [['carry', 2501], ['carry', 0], ['nonref', 300], ['ref', 0]]), [0, 2301]),\n  ('partial repair guard 1', (500, [['ref', 300], ['carry', 2443]]), [-300, 1943]),\n  ('partial repair guard 2', (500, [['carry', 100], ['nonref', 100], ['ref', 634], ['nonref', 100]]), [-434, 0]),\n  ('control: empty', (1234, []), [1234, 0]),\n  ('control: all kinds', (1000, [['nonref', 400], ['carry', 800], ['ref', 300]]), [-300, 200]),\n  ('control: refund', (500, [['ref', 700]]), [-200, 0]), ('control: no tax carry', (0, [['carry', 50]]), [0, 50])],\n [('regression nonref-before-carry 1', (1000, [['carry', 0], ['nonref', 1810], ['carry', 123]]), [0, 123]),\n  ('regression nonref-before-carry 2', (100, [['nonref', 300], ['carry', 853], ['carry', 0]]), [0, 853]),\n  ('partial repair guard 1', (500, [['ref', 1249], ['ref', 300], ['carry', 300], ['carry', 1980]]), [-1549, 1780]),\n  ('partial repair guard 2', (100, [['ref', 50], ['nonref', 2064]]), [-50, 0]),\n  ('control: no tax carry', (0, [['carry', 50]]), [0, 50]),\n  ('control: unknown kind', (100, [['bonus', 5]]), 'ERR:kind'),\n  ('control: nonref exceeds tax', (300, [['nonref', 500], ['ref', 100]]), [-100, 0]),\n  ('control: split carries', (900, [['carry', 400], ['nonref', 600], ['carry', 100]]), [0, 200])],\n [('regression nonref-before-carry 1', (100, [['nonref', 50], ['carry', 100], ['ref', 0]]), [0, 50]),\n  ('regression nonref-before-carry 2', (500, [['nonref', 100], ['carry', 300], ['carry', 300]]), [0, 200]),\n  ('partial repair guard 1', (100, [['ref', 50], ['nonref', 300], ['ref', 380]]), [-430, 0]),\n  ('partial repair guard 2', (1000, [['ref', 2008], ['ref', 50], ['nonref', 100]]), [-1158, 0]),\n  ('control: split carries', (900, [['carry', 400], ['nonref', 600], ['carry', 100]]), [0, 200]),\n  ('control: empty', (1234, []), [1234, 0]),\n  ('control: all kinds', (1000, [['nonref', 400], ['carry', 800], ['ref', 300]]), [-300, 200]),\n  ('control: refund', (500, [['ref', 700]]), [-200, 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":"a05e01592d3c6cc78f953ba7f0bbf119a5298ad41b2bbbd4ccd8178cc8d8fb15","source":"\"\"\"Failure Map reference implementation. Python standard library only.\"\"\"\nimport json\n\nN = 1\nobservations = []\ndef solve(tax, credits):\n    tot = {'nonref': 0, 'carry': 0, 'ref': 0}\n    for kind, amount in credits:\n        if kind not in tot: return 'ERR:kind'\n        tot[kind] += amount\n    n, c, r = tot['nonref'], tot['carry'], tot['ref']\n    t = tax\n    use_c = min(c, t)\n    t -= use_c\n    cf = c - use_c\n    use_n = min(n, t)\n    t -= use_n\n    t -= r\n    return [t, cf]\ndef check(label, actual, expected):\n    observations.append({\"check\": label, \"actual\": actual, \"expected\": expected, \"passed\": actual == expected})\ncases = [[('regression nonref-before-carry 1', (1000, [['nonref', 400], ['carry', 800], ['ref', 300]]), [-300, 200]),\n  ('regression nonref-before-carry 2', (900, [['carry', 400], ['nonref', 600], ['carry', 100]]), [0, 200]),\n  ('partial repair guard 2', (300, [['nonref', 500], ['ref', 100]]), [-100, 0]),\n  ('control: refund', (500, [['ref', 700]]), [-200, 0]), ('control: no tax carry', (0, [['carry', 50]]), [0, 50]),\n  ('control: unknown kind', (100, [['bonus', 5]]), 'ERR:kind'), ('control: empty', (1234, []), [1234, 0])],\n [('regression nonref-before-carry 1', (1467, [['nonref', 0], ['carry', 50], ['nonref', 2387]]), [0, 50]),\n  ('regression nonref-before-carry 2', (1000, [['carry', 300], ['nonref', 100], ['nonref', 100], ['nonref', 765]]),\n   [0, 265]),\n  ('partial repair guard 1', (444, [['nonref', 806], ['ref', 2], ['nonref', 464], ['ref', 0]]), [-2, 0]),\n  ('partial repair guard 2', (100, [['ref', 931], ['carry', 300], ['ref', 50]]), [-981, 200]),\n  ('control: unknown kind', (100, [['bonus', 5]]), 'ERR:kind'),\n  ('control: nonref exceeds tax', (300, [['nonref', 500], ['ref', 100]]), [-100, 0]),\n  ('control: split carries', (900, [['carry', 400], ['nonref', 600], ['carry', 100]]), [0, 200]),\n  ('control: empty', (1234, []), [1234, 0])],\n [('regression nonref-before-carry 1', (100, [['carry', 300], ['nonref', 300], ['carry', 50], ['nonref', 2635]]),\n   [0, 350]),\n  ('regression nonref-before-carry 2', (500, [['carry', 2501], ['carry', 0], ['nonref', 300], ['ref', 0]]), [0, 2301]),\n  ('partial repair guard 1', (500, [['ref', 300], ['carry', 2443]]), [-300, 1943]),\n  ('partial repair guard 2', (500, [['carry', 100], ['nonref', 100], ['ref', 634], ['nonref', 100]]), [-434, 0]),\n  ('control: empty', (1234, []), [1234, 0]),\n  ('control: all kinds', (1000, [['nonref', 400], ['carry', 800], ['ref', 300]]), [-300, 200]),\n  ('control: refund', (500, [['ref', 700]]), [-200, 0]), ('control: no tax carry', (0, [['carry', 50]]), [0, 50])],\n [('regression nonref-before-carry 1', (1000, [['carry', 0], ['nonref', 1810], ['carry', 123]]), [0, 123]),\n  ('regression nonref-before-carry 2', (100, [['nonref', 300], ['carry', 853], ['carry', 0]]), [0, 853]),\n  ('partial repair guard 1', (500, [['ref', 1249], ['ref', 300], ['carry', 300], ['carry', 1980]]), [-1549, 1780]),\n  ('partial repair guard 2', (100, [['ref', 50], ['nonref', 2064]]), [-50, 0]),\n  ('control: no tax carry', (0, [['carry', 50]]), [0, 50]),\n  ('control: unknown kind', (100, [['bonus', 5]]), 'ERR:kind'),\n  ('control: nonref exceeds tax', (300, [['nonref', 500], ['ref', 100]]), [-100, 0]),\n  ('control: split carries', (900, [['carry', 400], ['nonref', 600], ['carry', 100]]), [0, 200])],\n [('regression nonref-before-carry 1', (100, [['nonref', 50], ['carry', 100], ['ref', 0]]), [0, 50]),\n  ('regression nonref-before-carry 2', (500, [['nonref', 100], ['carry', 300], ['carry', 300]]), [0, 200]),\n  ('partial repair guard 1', (100, [['ref', 50], ['nonref', 300], ['ref', 380]]), [-430, 0]),\n  ('partial repair guard 2', (1000, [['ref', 2008], ['ref', 50], ['nonref', 100]]), [-1158, 0]),\n  ('control: split carries', (900, [['carry', 400], ['nonref', 600], ['carry', 100]]), [0, 200]),\n  ('control: empty', (1234, []), [1234, 0]),\n  ('control: all kinds', (1000, [['nonref', 400], ['carry', 800], ['ref', 300]]), [-300, 200]),\n  ('control: refund', (500, [['ref', 700]]), [-200, 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"},"fixed":{"sha256":"c8bd0344c2ac9f90cecc833ad13fab8c8c198e0bef52ba730ea7b20470694e0d","source":"\"\"\"Failure Map reference implementation. Python standard library only.\"\"\"\nimport json\n\nN = 1\nobservations = []\ndef solve(tax, credits):\n    tot = {'nonref': 0, 'carry': 0, 'ref': 0}\n    for kind, amount in credits:\n        if kind not in tot: return 'ERR:kind'\n        tot[kind] += amount\n    n, c, r = tot['nonref'], tot['carry'], tot['ref']\n    t = tax\n    use_n = min(n, t)\n    t -= use_n\n    use_c = min(c, t)\n    t -= use_c\n    cf = c - use_c\n    t -= r\n    return [t, cf]\ndef check(label, actual, expected):\n    observations.append({\"check\": label, \"actual\": actual, \"expected\": expected, \"passed\": actual == expected})\ncases = [[('regression nonref-before-carry 1', (1000, [['nonref', 400], ['carry', 800], ['ref', 300]]), [-300, 200]),\n  ('regression nonref-before-carry 2', (900, [['carry', 400], ['nonref', 600], ['carry', 100]]), [0, 200]),\n  ('partial repair guard 2', (300, [['nonref', 500], ['ref', 100]]), [-100, 0]),\n  ('control: refund', (500, [['ref', 700]]), [-200, 0]), ('control: no tax carry', (0, [['carry', 50]]), [0, 50]),\n  ('control: unknown kind', (100, [['bonus', 5]]), 'ERR:kind'), ('control: empty', (1234, []), [1234, 0])],\n [('regression nonref-before-carry 1', (1467, [['nonref', 0], ['carry', 50], ['nonref', 2387]]), [0, 50]),\n  ('regression nonref-before-carry 2', (1000, [['carry', 300], ['nonref', 100], ['nonref', 100], ['nonref', 765]]),\n   [0, 265]),\n  ('partial repair guard 1', (444, [['nonref', 806], ['ref', 2], ['nonref', 464], ['ref', 0]]), [-2, 0]),\n  ('partial repair guard 2', (100, [['ref', 931], ['carry', 300], ['ref', 50]]), [-981, 200]),\n  ('control: unknown kind', (100, [['bonus', 5]]), 'ERR:kind'),\n  ('control: nonref exceeds tax', (300, [['nonref', 500], ['ref', 100]]), [-100, 0]),\n  ('control: split carries', (900, [['carry', 400], ['nonref', 600], ['carry', 100]]), [0, 200]),\n  ('control: empty', (1234, []), [1234, 0])],\n [('regression nonref-before-carry 1', (100, [['carry', 300], ['nonref', 300], ['carry', 50], ['nonref', 2635]]),\n   [0, 350]),\n  ('regression nonref-before-carry 2', (500, [['carry', 2501], ['carry', 0], ['nonref', 300], ['ref', 0]]), [0, 2301]),\n  ('partial repair guard 1', (500, [['ref', 300], ['carry', 2443]]), [-300, 1943]),\n  ('partial repair guard 2', (500, [['carry', 100], ['nonref', 100], ['ref', 634], ['nonref', 100]]), [-434, 0]),\n  ('control: empty', (1234, []), [1234, 0]),\n  ('control: all kinds', (1000, [['nonref', 400], ['carry', 800], ['ref', 300]]), [-300, 200]),\n  ('control: refund', (500, [['ref', 700]]), [-200, 0]), ('control: no tax carry', (0, [['carry', 50]]), [0, 50])],\n [('regression nonref-before-carry 1', (1000, [['carry', 0], ['nonref', 1810], ['carry', 123]]), [0, 123]),\n  ('regression nonref-before-carry 2', (100, [['nonref', 300], ['carry', 853], ['carry', 0]]), [0, 853]),\n  ('partial repair guard 1', (500, [['ref', 1249], ['ref', 300], ['carry', 300], ['carry', 1980]]), [-1549, 1780]),\n  ('partial repair guard 2', (100, [['ref', 50], ['nonref', 2064]]), [-50, 0]),\n  ('control: no tax carry', (0, [['carry', 50]]), [0, 50]),\n  ('control: unknown kind', (100, [['bonus', 5]]), 'ERR:kind'),\n  ('control: nonref exceeds tax', (300, [['nonref', 500], ['ref', 100]]), [-100, 0]),\n  ('control: split carries', (900, [['carry', 400], ['nonref', 600], ['carry', 100]]), [0, 200])],\n [('regression nonref-before-carry 1', (100, [['nonref', 50], ['carry', 100], ['ref', 0]]), [0, 50]),\n  ('regression nonref-before-carry 2', (500, [['nonref', 100], ['carry', 300], ['carry', 300]]), [0, 200]),\n  ('partial repair guard 1', (100, [['ref', 50], ['nonref', 300], ['ref', 380]]), [-430, 0]),\n  ('partial repair guard 2', (1000, [['ref', 2008], ['ref', 50], ['nonref', 100]]), [-1158, 0]),\n  ('control: split carries', (900, [['carry', 400], ['nonref', 600], ['carry', 100]]), [0, 200]),\n  ('control: empty', (1234, []), [1234, 0]),\n  ('control: all kinds', (1000, [['nonref', 400], ['carry', 800], ['ref', 300]]), [-300, 200]),\n  ('control: refund', (500, [['ref', 700]]), [-200, 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-credit-ordering-nonref-before-carry","generated_at":"2026-09-29T14:47:04.947475+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.","repair":"Apply nonref credits first, then carry credits.","root_cause":"The carry credits are applied first, leaving less tax for credits that cannot be carried.","sha256":"fd0c3d2bf29a235533a1f299063de2759f2520c1b9883095df48d7f91860659c","title":"Carryforward credits are consumed before ordinary nonrefundable credits · case 01","variant":1,"variant_policy":"Five numbered records share a model and may reuse boundary fixtures.","verification":{"attempt":{"elapsed_ms":39.878,"exit_code":1,"observations":[{"actual":[0,500],"check":"regression nonref-before-carry 1","expected":[-300,200],"passed":false},{"actual":[0,200],"check":"regression nonref-before-carry 2","expected":[0,200],"passed":true},{"actual":[0,0],"check":"partial repair guard 2","expected":[-100,0],"passed":false},{"actual":[-200,0],"check":"control: refund","expected":[-200,0],"passed":true},{"actual":[0,50],"check":"control: no tax carry","expected":[0,50],"passed":true},{"actual":"ERR:kind","check":"control: unknown kind","expected":"ERR:kind","passed":true},{"actual":[1234,0],"check":"control: empty","expected":[1234,0],"passed":true}],"passed":false,"stderr":"","stdout":"{\"observations\": [{\"check\": \"regression nonref-before-carry 1\", \"actual\": [0, 500], \"expected\": [-300, 200], \"passed\": false}, {\"check\": \"regression nonref-before-carry 2\", \"actual\": [0, 200], \"expected\": [0, 200], \"passed\": true}, {\"check\": \"partial repair guard 2\", \"actual\": [0, 0], \"expected\": [-100, 0], \"passed\": false}, {\"check\": \"control: refund\", \"actual\": [-200, 0], \"expected\": [-200, 0], \"passed\": true}, {\"check\": \"control: no tax carry\", \"actual\": [0, 50], \"expected\": [0, 50], \"passed\": true}, {\"check\": \"control: unknown kind\", \"actual\": \"ERR:kind\", \"expected\": \"ERR:kind\", \"passed\": true}, {\"check\": \"control: empty\", \"actual\": [1234, 0], \"expected\": [1234, 0], \"passed\": true}], \"passed\": false}\n"},"broken":{"elapsed_ms":38.428,"exit_code":1,"observations":[{"actual":[-300,0],"check":"regression nonref-before-carry 1","expected":[-300,200],"passed":false},{"actual":[0,0],"check":"regression nonref-before-carry 2","expected":[0,200],"passed":false},{"actual":[-100,0],"check":"partial repair guard 2","expected":[-100,0],"passed":true},{"actual":[-200,0],"check":"control: refund","expected":[-200,0],"passed":true},{"actual":[0,50],"check":"control: no tax carry","expected":[0,50],"passed":true},{"actual":"ERR:kind","check":"control: unknown kind","expected":"ERR:kind","passed":true},{"actual":[1234,0],"check":"control: empty","expected":[1234,0],"passed":true}],"passed":false,"stderr":"","stdout":"{\"observations\": [{\"check\": \"regression nonref-before-carry 1\", \"actual\": [-300, 0], \"expected\": [-300, 200], \"passed\": false}, {\"check\": \"regression nonref-before-carry 2\", \"actual\": [0, 0], \"expected\": [0, 200], \"passed\": false}, {\"check\": \"partial repair guard 2\", \"actual\": [-100, 0], \"expected\": [-100, 0], \"passed\": true}, {\"check\": \"control: refund\", \"actual\": [-200, 0], \"expected\": [-200, 0], \"passed\": true}, {\"check\": \"control: no tax carry\", \"actual\": [0, 50], \"expected\": [0, 50], \"passed\": true}, {\"check\": \"control: unknown kind\", \"actual\": \"ERR:kind\", \"expected\": \"ERR:kind\", \"passed\": true}, {\"check\": \"control: empty\", \"actual\": [1234, 0], \"expected\": [1234, 0], \"passed\": true}], \"passed\": false}\n"},"fixed":{"elapsed_ms":39.549,"exit_code":0,"observations":[{"actual":[-300,200],"check":"regression nonref-before-carry 1","expected":[-300,200],"passed":true},{"actual":[0,200],"check":"regression nonref-before-carry 2","expected":[0,200],"passed":true},{"actual":[-100,0],"check":"partial repair guard 2","expected":[-100,0],"passed":true},{"actual":[-200,0],"check":"control: refund","expected":[-200,0],"passed":true},{"actual":[0,50],"check":"control: no tax carry","expected":[0,50],"passed":true},{"actual":"ERR:kind","check":"control: unknown kind","expected":"ERR:kind","passed":true},{"actual":[1234,0],"check":"control: empty","expected":[1234,0],"passed":true}],"passed":true,"stderr":"","stdout":"{\"observations\": [{\"check\": \"regression nonref-before-carry 1\", \"actual\": [-300, 200], \"expected\": [-300, 200], \"passed\": true}, {\"check\": \"regression nonref-before-carry 2\", \"actual\": [0, 200], \"expected\": [0, 200], \"passed\": true}, {\"check\": \"partial repair guard 2\", \"actual\": [-100, 0], \"expected\": [-100, 0], \"passed\": true}, {\"check\": \"control: refund\", \"actual\": [-200, 0], \"expected\": [-200, 0], \"passed\": true}, {\"check\": \"control: no tax carry\", \"actual\": [0, 50], \"expected\": [0, 50], \"passed\": true}, {\"check\": \"control: unknown kind\", \"actual\": \"ERR:kind\", \"expected\": \"ERR:kind\", \"passed\": true}, {\"check\": \"control: empty\", \"actual\": [1234, 0], \"expected\": [1234, 0], \"passed\": true}], \"passed\": true}\n"}},"verified":true,"visibility":"public"}