{"abstract":"An invoice exactly 30 days past due is aged into the 31-60 bucket.","category":"Double-entry ledger accounting","checks":7,"contract":"x = {'as_of': day, 'invoices': [[id, due_day, open cents]], 'rates': [[max_days_past_due or None, basis points]] ascending, 'allowance': existing credit balance (negative = debit balance), 'writeoffs': ids}. Written-off invoices leave receivables and reduce the allowance by their amount. Days past due = max(0, as_of - due); an invoice goes in the first bucket whose limit is None or >= days. Required allowance = sum over buckets of bucket total * bp / 10000 rounded half-up per bucket. Return {'buckets', 'required', 'adjustment': required - allowance after write-offs, 'net_ar'}.","contract_signature":"x","evaluation_group":"w2-double-entry-ledger-accounting-aging-allowance","failed_approach":"Special-casing current invoices still pushes 30-, 60- and 90-day invoices into the next bucket.","family":"w2-double-entry-ledger-accounting-aging-allowance-bucket-upper-bound","id":"FA-58116","implementations":{"attempt":{"sha256":"a8a4407cd54ceb8b508d1d4ec3dc70c2ec2ac188bd600722ce00d07d347e94f2","source":"\"\"\"Failure Map reference implementation. Python standard library only.\"\"\"\nimport json\n\nN = 1\nobservations = []\ndef solve(x):\n    wo = set(x['writeoffs'])\n    allowance = x['allowance']\n    buckets = [0] * len(x['rates'])\n    for iid, due, amt in x['invoices']:\n        if iid in wo:\n            allowance -= amt\n            continue\n        past = max(0, x['as_of'] - due)\n        for k, (limit, bp) in enumerate(x['rates']):\n            if limit is None or past < limit or past == 0:\n                buckets[k] += amt\n                break\n    required = 0\n    for total, (limit, bp) in zip(buckets, x['rates']):\n        q, r = divmod(total * bp, 10000)\n        required += q + (1 if 2 * r >= 10000 else 0)\n    ar = sum(buckets)\n    return {'buckets': buckets, 'required': required, 'adjustment': required - allowance, 'net_ar': ar - required}\ndef check(label, actual, expected):\n    observations.append({\"check\": label, \"actual\": actual, \"expected\": expected, \"passed\": actual == expected})\nfixtures = [[['regression: bucket upper bound', {'as_of': 100, 'invoices': [['I0', 99, 4000], ['I1', 55, 150], ['I2', -100, 333], ['I3', 100, 150], ['I4', 100, 5], ['I5', 9, 4000]], 'rates': [[0, 100], [30, 500], [60, 1500], [90, 4000], [None, 7500]], 'allowance': 200, 'writeoffs': ['I5']}, {'buckets': [155, 4000, 150, 0, 333], 'required': 475, 'adjustment': 4275, 'net_ar': 4163}], ['regression: bucket upper bound, partial-repair probe', {'as_of': 100, 'invoices': [['I0', 39, 4000], ['I1', 10, 150], ['I2', 110, 5], ['I3', 40, 5], ['I4', 99, 150], ['I5', 54, 4000], ['I6', 54, 1000]], 'rates': [[0, 100], [30, 500], [60, 1500], [90, 4000], [None, 7500]], 'allowance': 500, 'writeoffs': ['I6']}, {'buckets': [5, 150, 4005, 4150, 0], 'required': 2269, 'adjustment': 2769, 'net_ar': 6041}], ['control 1', {'as_of': 100, 'invoices': [['I0', -100, 5], ['I1', 39, 333], ['I2', 9, 2500], ['I3', -100, 4000], ['I4', 69, 150], ['I5', 70, 2500], ['I6', 55, 4000]], 'rates': [[0, 100], [30, 500], [60, 1500], [90, 4000], [None, 7500]], 'allowance': 0, 'writeoffs': ['I5', 'I6']}, {'buckets': [0, 0, 150, 333, 6505], 'required': 5035, 'adjustment': 11535, 'net_ar': 1953}], ['control 2', {'as_of': 100, 'invoices': [['I0', 55, 2500], ['I1', 99, 4000], ['I2', 99, 150], ['I3', 55, 5]], 'rates': [[0, 100], [30, 500], [60, 1500], [90, 4000], [None, 7500]], 'allowance': 200, 'writeoffs': ['I0']}, {'buckets': [0, 4150, 5, 0, 0], 'required': 209, 'adjustment': 2509, 'net_ar': 3946}], ['control 3', {'as_of': 100, 'invoices': [['I0', 40, 2500], ['I1', 99, 4000], ['I2', 9, 1000]], 'rates': [[0, 200], [45, 1250], [None, 5000]], 'allowance': 0, 'writeoffs': []}, {'buckets': [0, 4000, 3500], 'required': 2250, 'adjustment': 2250, 'net_ar': 5250}], ['control 4', {'as_of': 100, 'invoices': [['I0', 54, 333], ['I1', 9, 4000], ['I2', 54, 2500], ['I3', 55, 1000], ['I4', 10, 1000], ['I5', 71, 1000]], 'rates': [[0, 200], [45, 1250], [None, 5000]], 'allowance': -150, 'writeoffs': ['I0', 'I1', 'I3']}, {'buckets': [0, 1000, 3500], 'required': 1875, 'adjustment': 7358, 'net_ar': 2625}], ['control 5', {'as_of': 100, 'invoices': [['I0', 39, 4000], ['I1', 70, 333], ['I2', 9, 1000]], 'rates': [[0, 200], [45, 1250], [None, 5000]], 'allowance': 500, 'writeoffs': ['I2']}, {'buckets': [0, 333, 4000], 'required': 2042, 'adjustment': 2542, 'net_ar': 2291}]], [['regression: bucket upper bound', {'as_of': 100, 'invoices': [['I0', 99, 5], ['I1', 39, 5], ['I2', 10, 150], ['I3', -100, 333], ['I4', 39, 1000], ['I5', 39, 4000], ['I6', 100, 2500]], 'rates': [[0, 200], [45, 1250], [None, 5000]], 'allowance': -150, 'writeoffs': ['I2', 'I3']}, {'buckets': [2500, 5, 5005], 'required': 2554, 'adjustment': 3187, 'net_ar': 4956}], ['regression: bucket upper bound, partial-repair probe', {'as_of': 100, 'invoices': [['I0', 54, 2500], ['I1', 55, 5], ['I2', 10, 1000], ['I3', 71, 333], ['I4', 71, 1000], ['I5', 100, 5]], 'rates': [[0, 200], [45, 1250], [None, 5000]], 'allowance': -150, 'writeoffs': ['I2', 'I5']}, {'buckets': [0, 1338, 2500], 'required': 1417, 'adjustment': 2572, 'net_ar': 2421}], ['control 1', {'as_of': 100, 'invoices': [['I0', 99, 2500], ['I1', 69, 1000], ['I2', 55, 333], ['I3', 39, 1000], ['I4', 39, 333], ['I5', 40, 4000]], 'rates': [[0, 100], [30, 500], [60, 1500], [90, 4000], [None, 7500]], 'allowance': 200, 'writeoffs': ['I1', 'I4', 'I5']}, {'buckets': [0, 2500, 333, 1000, 0], 'required': 575, 'adjustment': 5708, 'net_ar': 3258}], ['control 2', {'as_of': 100, 'invoices': [['I0', 70, 5], ['I1', 69, 5], ['I2', 71, 333], ['I3', -100, 5], ['I4', 54, 333], ['I5', 100, 150], ['I6', 71, 150]], 'rates': [[0, 100], [30, 500], [60, 1500], [90, 4000], [None, 7500]], 'allowance': 200, 'writeoffs': ['I0', 'I5']}, {'buckets': [0, 483, 338, 0, 5], 'required': 79, 'adjustment': 34, 'net_ar': 747}], ['control 3', {'as_of': 100, 'invoices': [['I0', -100, 150], ['I1', 40, 1000], ['I2', 40, 5], ['I3', 39, 1000], ['I4', 9, 150], ['I5', 10, 1000], ['I6', 10, 150]], 'rates': [[0, 200], [45, 1250], [None, 5000]], 'allowance': 200, 'writeoffs': ['I2', 'I5']}, {'buckets': [0, 0, 2450], 'required': 1225, 'adjustment': 2030, 'net_ar': 1225}], ['control 4', {'as_of': 100, 'invoices': [['I0', 54, 333], ['I1', 40, 2500], ['I2', 9, 150]], 'rates': [[0, 100], [30, 500], [60, 1500], [90, 4000], [None, 7500]], 'allowance': -150, 'writeoffs': ['I1']}, {'buckets': [0, 0, 333, 0, 150], 'required': 163, 'adjustment': 2813, 'net_ar': 320}], ['control 5', {'as_of': 100, 'invoices': [['I0', 69, 2500], ['I1', 9, 5], ['I2', 71, 333]], 'rates': [[0, 100], [30, 500], [60, 1500], [90, 4000], [None, 7500]], 'allowance': 200, 'writeoffs': ['I2']}, {'buckets': [0, 0, 2500, 0, 5], 'required': 379, 'adjustment': 512, 'net_ar': 2126}]], [['regression: bucket upper bound', {'as_of': 100, 'invoices': [['I0', 54, 150], ['I1', 71, 4000], ['I2', 70, 2500], ['I3', 110, 150], ['I4', 99, 5]], 'rates': [[0, 100], [30, 500], [60, 1500], [90, 4000], [None, 7500]], 'allowance': 500, 'writeoffs': ['I3']}, {'buckets': [0, 6505, 150, 0, 0], 'required': 348, 'adjustment': -2, 'net_ar': 6307}], ['control 1', {'as_of': 100, 'invoices': [['I0', 39, 2500], ['I1', 69, 150], ['I2', 55, 333]], 'rates': [[0, 100], [30, 500], [60, 1500], [90, 4000], [None, 7500]], 'allowance': 200, 'writeoffs': ['I1']}, {'buckets': [0, 0, 333, 2500, 0], 'required': 1050, 'adjustment': 1000, 'net_ar': 1783}], ['control 2', {'as_of': 100, 'invoices': [['I0', -100, 333], ['I1', 99, 5], ['I2', 10, 150], ['I3', 9, 2500], ['I4', -100, 2500], ['I5', 55, 333], ['I6', 71, 2500]], 'rates': [[0, 100], [30, 500], [60, 1500], [90, 4000], [None, 7500]], 'allowance': -150, 'writeoffs': ['I2']}, {'buckets': [0, 2505, 333, 0, 5333], 'required': 4175, 'adjustment': 4475, 'net_ar': 3996}], ['control 3', {'as_of': 100, 'invoices': [['I0', 71, 2500], ['I1', 100, 150], ['I2', 9, 5]], 'rates': [[0, 200], [45, 1250], [None, 5000]], 'allowance': 0, 'writeoffs': ['I1']}, {'buckets': [0, 2500, 5], 'required': 316, 'adjustment': 466, 'net_ar': 2189}], ['control 4', {'as_of': 100, 'invoices': [['I0', 71, 4000], ['I1', -100, 4000], ['I2', 39, 5], ['I3', 99, 2500]], 'rates': [[0, 100], [30, 500], [60, 1500], [90, 4000], [None, 7500]], 'allowance': 0, 'writeoffs': ['I0', 'I3']}, {'buckets': [0, 0, 0, 5, 4000], 'required': 3002, 'adjustment': 9502, 'net_ar': 1003}], ['control 5', {'as_of': 100, 'invoices': [['I0', 10, 333], ['I1', -100, 150], ['I2', 99, 1000], ['I3', 71, 2500], ['I4', 39, 2500], ['I5', 54, 333]], 'rates': [[0, 200], [45, 1250], [None, 5000]], 'allowance': 500, 'writeoffs': []}, {'buckets': [0, 3500, 3316], 'required': 2096, 'adjustment': 1596, 'net_ar': 4720}], ['control 6', {'as_of': 100, 'invoices': [['I0', 99, 333], ['I1', 55, 2500], ['I2', 100, 5]], 'rates': [[0, 100], [30, 500], [60, 1500], [90, 4000], [None, 7500]], 'allowance': -150, 'writeoffs': ['I0', 'I2']}, {'buckets': [0, 0, 2500, 0, 0], 'required': 375, 'adjustment': 863, 'net_ar': 2125}]], [['regression: bucket upper bound', {'as_of': 100, 'invoices': [['I0', 110, 150], ['I1', 10, 1000], ['I2', 70, 150], ['I3', 99, 1000], ['I4', 100, 2500], ['I5', 55, 333], ['I6', 54, 150]], 'rates': [[0, 100], [30, 500], [60, 1500], [90, 4000], [None, 7500]], 'allowance': 0, 'writeoffs': ['I5', 'I6']}, {'buckets': [2650, 1150, 0, 1000, 0], 'required': 485, 'adjustment': 968, 'net_ar': 4315}], ['control 1', {'as_of': 100, 'invoices': [['I0', 70, 1000], ['I1', 10, 5], ['I2', 39, 150], ['I3', 54, 5], ['I4', 70, 2500], ['I5', 40, 150], ['I6', 39, 5]], 'rates': [[0, 200], [45, 1250], [None, 5000]], 'allowance': 200, 'writeoffs': ['I2', 'I4']}, {'buckets': [0, 1000, 165], 'required': 208, 'adjustment': 2658, 'net_ar': 957}], ['control 2', {'as_of': 100, 'invoices': [['I0', 69, 150], ['I1', 71, 150], ['I2', 70, 150]], 'rates': [[0, 100], [30, 500], [60, 1500], [90, 4000], [None, 7500]], 'allowance': 500, 'writeoffs': ['I2']}, {'buckets': [0, 150, 150, 0, 0], 'required': 31, 'adjustment': -319, 'net_ar': 269}], ['control 3', {'as_of': 100, 'invoices': [['I0', 71, 333], ['I1', 39, 150], ['I2', 71, 4000]], 'rates': [[0, 100], [30, 500], [60, 1500], [90, 4000], [None, 7500]], 'allowance': 0, 'writeoffs': []}, {'buckets': [0, 4333, 0, 150, 0], 'required': 277, 'adjustment': 277, 'net_ar': 4206}], ['control 4', {'as_of': 100, 'invoices': [['I0', 9, 5], ['I1', 71, 150], ['I2', 70, 1000], ['I3', 54, 1000]], 'rates': [[0, 100], [30, 500], [60, 1500], [90, 4000], [None, 7500]], 'allowance': 0, 'writeoffs': ['I2']}, {'buckets': [0, 150, 1000, 0, 5], 'required': 162, 'adjustment': 1162, 'net_ar': 993}], ['control 5', {'as_of': 100, 'invoices': [['I0', 69, 2500], ['I1', 69, 150], ['I2', 55, 5], ['I3', 71, 1000], ['I4', 55, 4000], ['I5', -100, 2500], ['I6', 69, 4000]], 'rates': [[0, 100], [30, 500], [60, 1500], [90, 4000], [None, 7500]], 'allowance': 500, 'writeoffs': []}, {'buckets': [0, 1000, 10655, 0, 2500], 'required': 3523, 'adjustment': 3023, 'net_ar': 10632}], ['control 6', {'as_of': 100, 'invoices': [['I0', 10, 4000], ['I1', 9, 1000], ['I2', -100, 2500], ['I3', -100, 150], ['I4', 70, 4000]], 'rates': [[0, 200], [45, 1250], [None, 5000]], 'allowance': 0, 'writeoffs': ['I0']}, {'buckets': [0, 4000, 3650], 'required': 2325, 'adjustment': 6325, 'net_ar': 5325}]], [['regression: bucket upper bound', {'as_of': 100, 'invoices': [['I0', 70, 4000], ['I1', 70, 2500], ['I2', 100, 4000], ['I3', 71, 5]], 'rates': [[0, 200], [45, 1250], [None, 5000]], 'allowance': 0, 'writeoffs': ['I1']}, {'buckets': [4000, 4005, 0], 'required': 581, 'adjustment': 3081, 'net_ar': 7424}], ['regression: bucket upper bound, partial-repair probe', {'as_of': 100, 'invoices': [['I0', 40, 4000], ['I1', 39, 1000], ['I2', -100, 5], ['I3', 99, 5], ['I4', -100, 333], ['I5', 10, 4000]], 'rates': [[0, 100], [30, 500], [60, 1500], [90, 4000], [None, 7500]], 'allowance': 500, 'writeoffs': ['I3']}, {'buckets': [0, 0, 4000, 5000, 338], 'required': 2854, 'adjustment': 2359, 'net_ar': 6484}], ['control 1', {'as_of': 100, 'invoices': [['I0', 9, 150], ['I1', 9, 1000], ['I2', 54, 1000], ['I3', 99, 2500], ['I4', 69, 333], ['I5', 71, 5]], 'rates': [[0, 100], [30, 500], [60, 1500], [90, 4000], [None, 7500]], 'allowance': -150, 'writeoffs': []}, {'buckets': [0, 2505, 1333, 0, 1150], 'required': 1188, 'adjustment': 1338, 'net_ar': 3800}], ['control 2', {'as_of': 100, 'invoices': [['I0', 39, 5], ['I1', 99, 4000], ['I2', 55, 4000]], 'rates': [[0, 100], [30, 500], [60, 1500], [90, 4000], [None, 7500]], 'allowance': 0, 'writeoffs': ['I0', 'I1']}, {'buckets': [0, 0, 4000, 0, 0], 'required': 600, 'adjustment': 4605, 'net_ar': 3400}], ['control 3', {'as_of': 100, 'invoices': [['I0', 54, 5], ['I1', 40, 5], ['I2', 99, 333], ['I3', 71, 150], ['I4', 54, 4000]], 'rates': [[0, 200], [45, 1250], [None, 5000]], 'allowance': 0, 'writeoffs': []}, {'buckets': [0, 483, 4010], 'required': 2065, 'adjustment': 2065, 'net_ar': 2428}], ['control 4', {'as_of': 100, 'invoices': [['I0', 55, 5], ['I1', 100, 150], ['I2', 99, 150]], 'rates': [[0, 100], [30, 500], [60, 1500], [90, 4000], [None, 7500]], 'allowance': 0, 'writeoffs': ['I0', 'I1', 'I2']}, {'buckets': [0, 0, 0, 0, 0], 'required': 0, 'adjustment': 305, 'net_ar': 0}], ['control 5', {'as_of': 100, 'invoices': [['I0', 39, 2500], ['I1', 99, 333], ['I2', 69, 333]], 'rates': [[0, 200], [45, 1250], [None, 5000]], 'allowance': 0, 'writeoffs': ['I0']}, {'buckets': [0, 666, 0], 'required': 83, 'adjustment': 2583, 'net_ar': 583}]]]\nfor label, args, expected in fixtures[N-1]:\n    try:\n        actual = solve(args)\n    except Exception as exc:\n        actual = 'raised ' + type(exc).__name__\n    check(label, actual, 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":"a786ba409d04304317c6552f9509a214645e59f52375f80f839bcc79c4dc0436","source":"\"\"\"Failure Map reference implementation. Python standard library only.\"\"\"\nimport json\n\nN = 1\nobservations = []\ndef solve(x):\n    wo = set(x['writeoffs'])\n    allowance = x['allowance']\n    buckets = [0] * len(x['rates'])\n    for iid, due, amt in x['invoices']:\n        if iid in wo:\n            allowance -= amt\n            continue\n        past = max(0, x['as_of'] - due)\n        for k, (limit, bp) in enumerate(x['rates']):\n            if limit is None or past < limit:\n                buckets[k] += amt\n                break\n    required = 0\n    for total, (limit, bp) in zip(buckets, x['rates']):\n        q, r = divmod(total * bp, 10000)\n        required += q + (1 if 2 * r >= 10000 else 0)\n    ar = sum(buckets)\n    return {'buckets': buckets, 'required': required, 'adjustment': required - allowance, 'net_ar': ar - required}\ndef check(label, actual, expected):\n    observations.append({\"check\": label, \"actual\": actual, \"expected\": expected, \"passed\": actual == expected})\nfixtures = [[['regression: bucket upper bound', {'as_of': 100, 'invoices': [['I0', 99, 4000], ['I1', 55, 150], ['I2', -100, 333], ['I3', 100, 150], ['I4', 100, 5], ['I5', 9, 4000]], 'rates': [[0, 100], [30, 500], [60, 1500], [90, 4000], [None, 7500]], 'allowance': 200, 'writeoffs': ['I5']}, {'buckets': [155, 4000, 150, 0, 333], 'required': 475, 'adjustment': 4275, 'net_ar': 4163}], ['regression: bucket upper bound, partial-repair probe', {'as_of': 100, 'invoices': [['I0', 39, 4000], ['I1', 10, 150], ['I2', 110, 5], ['I3', 40, 5], ['I4', 99, 150], ['I5', 54, 4000], ['I6', 54, 1000]], 'rates': [[0, 100], [30, 500], [60, 1500], [90, 4000], [None, 7500]], 'allowance': 500, 'writeoffs': ['I6']}, {'buckets': [5, 150, 4005, 4150, 0], 'required': 2269, 'adjustment': 2769, 'net_ar': 6041}], ['control 1', {'as_of': 100, 'invoices': [['I0', -100, 5], ['I1', 39, 333], ['I2', 9, 2500], ['I3', -100, 4000], ['I4', 69, 150], ['I5', 70, 2500], ['I6', 55, 4000]], 'rates': [[0, 100], [30, 500], [60, 1500], [90, 4000], [None, 7500]], 'allowance': 0, 'writeoffs': ['I5', 'I6']}, {'buckets': [0, 0, 150, 333, 6505], 'required': 5035, 'adjustment': 11535, 'net_ar': 1953}], ['control 2', {'as_of': 100, 'invoices': [['I0', 55, 2500], ['I1', 99, 4000], ['I2', 99, 150], ['I3', 55, 5]], 'rates': [[0, 100], [30, 500], [60, 1500], [90, 4000], [None, 7500]], 'allowance': 200, 'writeoffs': ['I0']}, {'buckets': [0, 4150, 5, 0, 0], 'required': 209, 'adjustment': 2509, 'net_ar': 3946}], ['control 3', {'as_of': 100, 'invoices': [['I0', 40, 2500], ['I1', 99, 4000], ['I2', 9, 1000]], 'rates': [[0, 200], [45, 1250], [None, 5000]], 'allowance': 0, 'writeoffs': []}, {'buckets': [0, 4000, 3500], 'required': 2250, 'adjustment': 2250, 'net_ar': 5250}], ['control 4', {'as_of': 100, 'invoices': [['I0', 54, 333], ['I1', 9, 4000], ['I2', 54, 2500], ['I3', 55, 1000], ['I4', 10, 1000], ['I5', 71, 1000]], 'rates': [[0, 200], [45, 1250], [None, 5000]], 'allowance': -150, 'writeoffs': ['I0', 'I1', 'I3']}, {'buckets': [0, 1000, 3500], 'required': 1875, 'adjustment': 7358, 'net_ar': 2625}], ['control 5', {'as_of': 100, 'invoices': [['I0', 39, 4000], ['I1', 70, 333], ['I2', 9, 1000]], 'rates': [[0, 200], [45, 1250], [None, 5000]], 'allowance': 500, 'writeoffs': ['I2']}, {'buckets': [0, 333, 4000], 'required': 2042, 'adjustment': 2542, 'net_ar': 2291}]], [['regression: bucket upper bound', {'as_of': 100, 'invoices': [['I0', 99, 5], ['I1', 39, 5], ['I2', 10, 150], ['I3', -100, 333], ['I4', 39, 1000], ['I5', 39, 4000], ['I6', 100, 2500]], 'rates': [[0, 200], [45, 1250], [None, 5000]], 'allowance': -150, 'writeoffs': ['I2', 'I3']}, {'buckets': [2500, 5, 5005], 'required': 2554, 'adjustment': 3187, 'net_ar': 4956}], ['regression: bucket upper bound, partial-repair probe', {'as_of': 100, 'invoices': [['I0', 54, 2500], ['I1', 55, 5], ['I2', 10, 1000], ['I3', 71, 333], ['I4', 71, 1000], ['I5', 100, 5]], 'rates': [[0, 200], [45, 1250], [None, 5000]], 'allowance': -150, 'writeoffs': ['I2', 'I5']}, {'buckets': [0, 1338, 2500], 'required': 1417, 'adjustment': 2572, 'net_ar': 2421}], ['control 1', {'as_of': 100, 'invoices': [['I0', 99, 2500], ['I1', 69, 1000], ['I2', 55, 333], ['I3', 39, 1000], ['I4', 39, 333], ['I5', 40, 4000]], 'rates': [[0, 100], [30, 500], [60, 1500], [90, 4000], [None, 7500]], 'allowance': 200, 'writeoffs': ['I1', 'I4', 'I5']}, {'buckets': [0, 2500, 333, 1000, 0], 'required': 575, 'adjustment': 5708, 'net_ar': 3258}], ['control 2', {'as_of': 100, 'invoices': [['I0', 70, 5], ['I1', 69, 5], ['I2', 71, 333], ['I3', -100, 5], ['I4', 54, 333], ['I5', 100, 150], ['I6', 71, 150]], 'rates': [[0, 100], [30, 500], [60, 1500], [90, 4000], [None, 7500]], 'allowance': 200, 'writeoffs': ['I0', 'I5']}, {'buckets': [0, 483, 338, 0, 5], 'required': 79, 'adjustment': 34, 'net_ar': 747}], ['control 3', {'as_of': 100, 'invoices': [['I0', -100, 150], ['I1', 40, 1000], ['I2', 40, 5], ['I3', 39, 1000], ['I4', 9, 150], ['I5', 10, 1000], ['I6', 10, 150]], 'rates': [[0, 200], [45, 1250], [None, 5000]], 'allowance': 200, 'writeoffs': ['I2', 'I5']}, {'buckets': [0, 0, 2450], 'required': 1225, 'adjustment': 2030, 'net_ar': 1225}], ['control 4', {'as_of': 100, 'invoices': [['I0', 54, 333], ['I1', 40, 2500], ['I2', 9, 150]], 'rates': [[0, 100], [30, 500], [60, 1500], [90, 4000], [None, 7500]], 'allowance': -150, 'writeoffs': ['I1']}, {'buckets': [0, 0, 333, 0, 150], 'required': 163, 'adjustment': 2813, 'net_ar': 320}], ['control 5', {'as_of': 100, 'invoices': [['I0', 69, 2500], ['I1', 9, 5], ['I2', 71, 333]], 'rates': [[0, 100], [30, 500], [60, 1500], [90, 4000], [None, 7500]], 'allowance': 200, 'writeoffs': ['I2']}, {'buckets': [0, 0, 2500, 0, 5], 'required': 379, 'adjustment': 512, 'net_ar': 2126}]], [['regression: bucket upper bound', {'as_of': 100, 'invoices': [['I0', 54, 150], ['I1', 71, 4000], ['I2', 70, 2500], ['I3', 110, 150], ['I4', 99, 5]], 'rates': [[0, 100], [30, 500], [60, 1500], [90, 4000], [None, 7500]], 'allowance': 500, 'writeoffs': ['I3']}, {'buckets': [0, 6505, 150, 0, 0], 'required': 348, 'adjustment': -2, 'net_ar': 6307}], ['control 1', {'as_of': 100, 'invoices': [['I0', 39, 2500], ['I1', 69, 150], ['I2', 55, 333]], 'rates': [[0, 100], [30, 500], [60, 1500], [90, 4000], [None, 7500]], 'allowance': 200, 'writeoffs': ['I1']}, {'buckets': [0, 0, 333, 2500, 0], 'required': 1050, 'adjustment': 1000, 'net_ar': 1783}], ['control 2', {'as_of': 100, 'invoices': [['I0', -100, 333], ['I1', 99, 5], ['I2', 10, 150], ['I3', 9, 2500], ['I4', -100, 2500], ['I5', 55, 333], ['I6', 71, 2500]], 'rates': [[0, 100], [30, 500], [60, 1500], [90, 4000], [None, 7500]], 'allowance': -150, 'writeoffs': ['I2']}, {'buckets': [0, 2505, 333, 0, 5333], 'required': 4175, 'adjustment': 4475, 'net_ar': 3996}], ['control 3', {'as_of': 100, 'invoices': [['I0', 71, 2500], ['I1', 100, 150], ['I2', 9, 5]], 'rates': [[0, 200], [45, 1250], [None, 5000]], 'allowance': 0, 'writeoffs': ['I1']}, {'buckets': [0, 2500, 5], 'required': 316, 'adjustment': 466, 'net_ar': 2189}], ['control 4', {'as_of': 100, 'invoices': [['I0', 71, 4000], ['I1', -100, 4000], ['I2', 39, 5], ['I3', 99, 2500]], 'rates': [[0, 100], [30, 500], [60, 1500], [90, 4000], [None, 7500]], 'allowance': 0, 'writeoffs': ['I0', 'I3']}, {'buckets': [0, 0, 0, 5, 4000], 'required': 3002, 'adjustment': 9502, 'net_ar': 1003}], ['control 5', {'as_of': 100, 'invoices': [['I0', 10, 333], ['I1', -100, 150], ['I2', 99, 1000], ['I3', 71, 2500], ['I4', 39, 2500], ['I5', 54, 333]], 'rates': [[0, 200], [45, 1250], [None, 5000]], 'allowance': 500, 'writeoffs': []}, {'buckets': [0, 3500, 3316], 'required': 2096, 'adjustment': 1596, 'net_ar': 4720}], ['control 6', {'as_of': 100, 'invoices': [['I0', 99, 333], ['I1', 55, 2500], ['I2', 100, 5]], 'rates': [[0, 100], [30, 500], [60, 1500], [90, 4000], [None, 7500]], 'allowance': -150, 'writeoffs': ['I0', 'I2']}, {'buckets': [0, 0, 2500, 0, 0], 'required': 375, 'adjustment': 863, 'net_ar': 2125}]], [['regression: bucket upper bound', {'as_of': 100, 'invoices': [['I0', 110, 150], ['I1', 10, 1000], ['I2', 70, 150], ['I3', 99, 1000], ['I4', 100, 2500], ['I5', 55, 333], ['I6', 54, 150]], 'rates': [[0, 100], [30, 500], [60, 1500], [90, 4000], [None, 7500]], 'allowance': 0, 'writeoffs': ['I5', 'I6']}, {'buckets': [2650, 1150, 0, 1000, 0], 'required': 485, 'adjustment': 968, 'net_ar': 4315}], ['control 1', {'as_of': 100, 'invoices': [['I0', 70, 1000], ['I1', 10, 5], ['I2', 39, 150], ['I3', 54, 5], ['I4', 70, 2500], ['I5', 40, 150], ['I6', 39, 5]], 'rates': [[0, 200], [45, 1250], [None, 5000]], 'allowance': 200, 'writeoffs': ['I2', 'I4']}, {'buckets': [0, 1000, 165], 'required': 208, 'adjustment': 2658, 'net_ar': 957}], ['control 2', {'as_of': 100, 'invoices': [['I0', 69, 150], ['I1', 71, 150], ['I2', 70, 150]], 'rates': [[0, 100], [30, 500], [60, 1500], [90, 4000], [None, 7500]], 'allowance': 500, 'writeoffs': ['I2']}, {'buckets': [0, 150, 150, 0, 0], 'required': 31, 'adjustment': -319, 'net_ar': 269}], ['control 3', {'as_of': 100, 'invoices': [['I0', 71, 333], ['I1', 39, 150], ['I2', 71, 4000]], 'rates': [[0, 100], [30, 500], [60, 1500], [90, 4000], [None, 7500]], 'allowance': 0, 'writeoffs': []}, {'buckets': [0, 4333, 0, 150, 0], 'required': 277, 'adjustment': 277, 'net_ar': 4206}], ['control 4', {'as_of': 100, 'invoices': [['I0', 9, 5], ['I1', 71, 150], ['I2', 70, 1000], ['I3', 54, 1000]], 'rates': [[0, 100], [30, 500], [60, 1500], [90, 4000], [None, 7500]], 'allowance': 0, 'writeoffs': ['I2']}, {'buckets': [0, 150, 1000, 0, 5], 'required': 162, 'adjustment': 1162, 'net_ar': 993}], ['control 5', {'as_of': 100, 'invoices': [['I0', 69, 2500], ['I1', 69, 150], ['I2', 55, 5], ['I3', 71, 1000], ['I4', 55, 4000], ['I5', -100, 2500], ['I6', 69, 4000]], 'rates': [[0, 100], [30, 500], [60, 1500], [90, 4000], [None, 7500]], 'allowance': 500, 'writeoffs': []}, {'buckets': [0, 1000, 10655, 0, 2500], 'required': 3523, 'adjustment': 3023, 'net_ar': 10632}], ['control 6', {'as_of': 100, 'invoices': [['I0', 10, 4000], ['I1', 9, 1000], ['I2', -100, 2500], ['I3', -100, 150], ['I4', 70, 4000]], 'rates': [[0, 200], [45, 1250], [None, 5000]], 'allowance': 0, 'writeoffs': ['I0']}, {'buckets': [0, 4000, 3650], 'required': 2325, 'adjustment': 6325, 'net_ar': 5325}]], [['regression: bucket upper bound', {'as_of': 100, 'invoices': [['I0', 70, 4000], ['I1', 70, 2500], ['I2', 100, 4000], ['I3', 71, 5]], 'rates': [[0, 200], [45, 1250], [None, 5000]], 'allowance': 0, 'writeoffs': ['I1']}, {'buckets': [4000, 4005, 0], 'required': 581, 'adjustment': 3081, 'net_ar': 7424}], ['regression: bucket upper bound, partial-repair probe', {'as_of': 100, 'invoices': [['I0', 40, 4000], ['I1', 39, 1000], ['I2', -100, 5], ['I3', 99, 5], ['I4', -100, 333], ['I5', 10, 4000]], 'rates': [[0, 100], [30, 500], [60, 1500], [90, 4000], [None, 7500]], 'allowance': 500, 'writeoffs': ['I3']}, {'buckets': [0, 0, 4000, 5000, 338], 'required': 2854, 'adjustment': 2359, 'net_ar': 6484}], ['control 1', {'as_of': 100, 'invoices': [['I0', 9, 150], ['I1', 9, 1000], ['I2', 54, 1000], ['I3', 99, 2500], ['I4', 69, 333], ['I5', 71, 5]], 'rates': [[0, 100], [30, 500], [60, 1500], [90, 4000], [None, 7500]], 'allowance': -150, 'writeoffs': []}, {'buckets': [0, 2505, 1333, 0, 1150], 'required': 1188, 'adjustment': 1338, 'net_ar': 3800}], ['control 2', {'as_of': 100, 'invoices': [['I0', 39, 5], ['I1', 99, 4000], ['I2', 55, 4000]], 'rates': [[0, 100], [30, 500], [60, 1500], [90, 4000], [None, 7500]], 'allowance': 0, 'writeoffs': ['I0', 'I1']}, {'buckets': [0, 0, 4000, 0, 0], 'required': 600, 'adjustment': 4605, 'net_ar': 3400}], ['control 3', {'as_of': 100, 'invoices': [['I0', 54, 5], ['I1', 40, 5], ['I2', 99, 333], ['I3', 71, 150], ['I4', 54, 4000]], 'rates': [[0, 200], [45, 1250], [None, 5000]], 'allowance': 0, 'writeoffs': []}, {'buckets': [0, 483, 4010], 'required': 2065, 'adjustment': 2065, 'net_ar': 2428}], ['control 4', {'as_of': 100, 'invoices': [['I0', 55, 5], ['I1', 100, 150], ['I2', 99, 150]], 'rates': [[0, 100], [30, 500], [60, 1500], [90, 4000], [None, 7500]], 'allowance': 0, 'writeoffs': ['I0', 'I1', 'I2']}, {'buckets': [0, 0, 0, 0, 0], 'required': 0, 'adjustment': 305, 'net_ar': 0}], ['control 5', {'as_of': 100, 'invoices': [['I0', 39, 2500], ['I1', 99, 333], ['I2', 69, 333]], 'rates': [[0, 200], [45, 1250], [None, 5000]], 'allowance': 0, 'writeoffs': ['I0']}, {'buckets': [0, 666, 0], 'required': 83, 'adjustment': 2583, 'net_ar': 583}]]]\nfor label, args, expected in fixtures[N-1]:\n    try:\n        actual = solve(args)\n    except Exception as exc:\n        actual = 'raised ' + type(exc).__name__\n    check(label, actual, 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 stipulated toy bookkeeping rules stated in the contract; amounts are integer cents; it makes no claim of conformance to any accounting standard or product. 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-double-entry-ledger-accounting-aging-allowance-bucket-upper-bound","generated_at":"2026-09-29T14:46:23.533562+00:00","license":"CC0-1.0","python":"3.12.14","seed":1,"split":"open-access"},"relevance":"Ledger software must keep debits equal to credits and apply normal-balance, period and cutoff rules exactly; small sign or boundary slips silently misstate financial statements.","root_cause":"Bucket limits are treated as exclusive upper bounds.","sha256":"7b1d9c3a9ea7f44930ffa8269a3db39f74f07b541c32ec3a5ccc6068f0b38f3f","title":"Aging-based allowance adjustment: bucket upper bound · 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":42.894,"exit_code":1,"observations":[{"actual":{"adjustment":4275,"buckets":[155,4000,150,0,333],"net_ar":4163,"required":475},"check":"regression: bucket upper bound","expected":{"adjustment":4275,"buckets":[155,4000,150,0,333],"net_ar":4163,"required":475},"passed":true},{"actual":{"adjustment":2823,"buckets":[5,150,4000,4005,150],"net_ar":5987,"required":2323},"check":"regression: bucket upper bound, partial-repair probe","expected":{"adjustment":2769,"buckets":[5,150,4005,4150,0],"net_ar":6041,"required":2269},"passed":false},{"actual":{"adjustment":11535,"buckets":[0,0,150,333,6505],"net_ar":1953,"required":5035},"check":"control 1","expected":{"adjustment":11535,"buckets":[0,0,150,333,6505],"net_ar":1953,"required":5035},"passed":true},{"actual":{"adjustment":2509,"buckets":[0,4150,5,0,0],"net_ar":3946,"required":209},"check":"control 2","expected":{"adjustment":2509,"buckets":[0,4150,5,0,0],"net_ar":3946,"required":209},"passed":true},{"actual":{"adjustment":2250,"buckets":[0,4000,3500],"net_ar":5250,"required":2250},"check":"control 3","expected":{"adjustment":2250,"buckets":[0,4000,3500],"net_ar":5250,"required":2250},"passed":true},{"actual":{"adjustment":7358,"buckets":[0,1000,3500],"net_ar":2625,"required":1875},"check":"control 4","expected":{"adjustment":7358,"buckets":[0,1000,3500],"net_ar":2625,"required":1875},"passed":true},{"actual":{"adjustment":2542,"buckets":[0,333,4000],"net_ar":2291,"required":2042},"check":"control 5","expected":{"adjustment":2542,"buckets":[0,333,4000],"net_ar":2291,"required":2042},"passed":true}],"passed":false,"stderr":"","stdout":"{\"observations\": [{\"check\": \"regression: bucket upper bound\", \"actual\": {\"buckets\": [155, 4000, 150, 0, 333], \"required\": 475, \"adjustment\": 4275, \"net_ar\": 4163}, \"expected\": {\"buckets\": [155, 4000, 150, 0, 333], \"required\": 475, \"adjustment\": 4275, \"net_ar\": 4163}, \"passed\": true}, {\"check\": \"regression: bucket upper bound, partial-repair probe\", \"actual\": {\"buckets\": [5, 150, 4000, 4005, 150], \"required\": 2323, \"adjustment\": 2823, \"net_ar\": 5987}, \"expected\": {\"buckets\": [5, 150, 4005, 4150, 0], \"required\": 2269, \"adjustment\": 2769, \"net_ar\": 6041}, \"passed\": false}, {\"check\": \"control 1\", \"actual\": {\"buckets\": [0, 0, 150, 333, 6505], \"required\": 5035, \"adjustment\": 11535, \"net_ar\": 1953}, \"expected\": {\"buckets\": [0, 0, 150, 333, 6505], \"required\": 5035, \"adjustment\": 11535, \"net_ar\": 1953}, \"passed\": true}, {\"check\": \"control 2\", \"actual\": {\"buckets\": [0, 4150, 5, 0, 0], \"required\": 209, \"adjustment\": 2509, \"net_ar\": 3946}, \"expected\": {\"buckets\": [0, 4150, 5, 0, 0], \"required\": 209, \"adjustment\": 2509, \"net_ar\": 3946}, \"passed\": true}, {\"check\": \"control 3\", \"actual\": {\"buckets\": [0, 4000, 3500], \"required\": 2250, \"adjustment\": 2250, \"net_ar\": 5250}, \"expected\": {\"buckets\": [0, 4000, 3500], \"required\": 2250, \"adjustment\": 2250, \"net_ar\": 5250}, \"passed\": true}, {\"check\": \"control 4\", \"actual\": {\"buckets\": [0, 1000, 3500], \"required\": 1875, \"adjustment\": 7358, \"net_ar\": 2625}, \"expected\": {\"buckets\": [0, 1000, 3500], \"required\": 1875, \"adjustment\": 7358, \"net_ar\": 2625}, \"passed\": true}, {\"check\": \"control 5\", \"actual\": {\"buckets\": [0, 333, 4000], \"required\": 2042, \"adjustment\": 2542, \"net_ar\": 2291}, \"expected\": {\"buckets\": [0, 333, 4000], \"required\": 2042, \"adjustment\": 2542, \"net_ar\": 2291}, \"passed\": true}], \"passed\": false}\n"},"broken":{"elapsed_ms":40.599,"exit_code":1,"observations":[{"actual":{"adjustment":4281,"buckets":[0,4155,150,0,333],"net_ar":4157,"required":481},"check":"regression: bucket upper bound","expected":{"adjustment":4275,"buckets":[155,4000,150,0,333],"net_ar":4163,"required":475},"passed":false},{"actual":{"adjustment":2823,"buckets":[0,155,4000,4005,150],"net_ar":5987,"required":2323},"check":"regression: bucket upper bound, partial-repair probe","expected":{"adjustment":2769,"buckets":[5,150,4005,4150,0],"net_ar":6041,"required":2269},"passed":false},{"actual":{"adjustment":11535,"buckets":[0,0,150,333,6505],"net_ar":1953,"required":5035},"check":"control 1","expected":{"adjustment":11535,"buckets":[0,0,150,333,6505],"net_ar":1953,"required":5035},"passed":true},{"actual":{"adjustment":2509,"buckets":[0,4150,5,0,0],"net_ar":3946,"required":209},"check":"control 2","expected":{"adjustment":2509,"buckets":[0,4150,5,0,0],"net_ar":3946,"required":209},"passed":true},{"actual":{"adjustment":2250,"buckets":[0,4000,3500],"net_ar":5250,"required":2250},"check":"control 3","expected":{"adjustment":2250,"buckets":[0,4000,3500],"net_ar":5250,"required":2250},"passed":true},{"actual":{"adjustment":7358,"buckets":[0,1000,3500],"net_ar":2625,"required":1875},"check":"control 4","expected":{"adjustment":7358,"buckets":[0,1000,3500],"net_ar":2625,"required":1875},"passed":true},{"actual":{"adjustment":2542,"buckets":[0,333,4000],"net_ar":2291,"required":2042},"check":"control 5","expected":{"adjustment":2542,"buckets":[0,333,4000],"net_ar":2291,"required":2042},"passed":true}],"passed":false,"stderr":"","stdout":"{\"observations\": [{\"check\": \"regression: bucket upper bound\", \"actual\": {\"buckets\": [0, 4155, 150, 0, 333], \"required\": 481, \"adjustment\": 4281, \"net_ar\": 4157}, \"expected\": {\"buckets\": [155, 4000, 150, 0, 333], \"required\": 475, \"adjustment\": 4275, \"net_ar\": 4163}, \"passed\": false}, {\"check\": \"regression: bucket upper bound, partial-repair probe\", \"actual\": {\"buckets\": [0, 155, 4000, 4005, 150], \"required\": 2323, \"adjustment\": 2823, \"net_ar\": 5987}, \"expected\": {\"buckets\": [5, 150, 4005, 4150, 0], \"required\": 2269, \"adjustment\": 2769, \"net_ar\": 6041}, \"passed\": false}, {\"check\": \"control 1\", \"actual\": {\"buckets\": [0, 0, 150, 333, 6505], \"required\": 5035, \"adjustment\": 11535, \"net_ar\": 1953}, \"expected\": {\"buckets\": [0, 0, 150, 333, 6505], \"required\": 5035, \"adjustment\": 11535, \"net_ar\": 1953}, \"passed\": true}, {\"check\": \"control 2\", \"actual\": {\"buckets\": [0, 4150, 5, 0, 0], \"required\": 209, \"adjustment\": 2509, \"net_ar\": 3946}, \"expected\": {\"buckets\": [0, 4150, 5, 0, 0], \"required\": 209, \"adjustment\": 2509, \"net_ar\": 3946}, \"passed\": true}, {\"check\": \"control 3\", \"actual\": {\"buckets\": [0, 4000, 3500], \"required\": 2250, \"adjustment\": 2250, \"net_ar\": 5250}, \"expected\": {\"buckets\": [0, 4000, 3500], \"required\": 2250, \"adjustment\": 2250, \"net_ar\": 5250}, \"passed\": true}, {\"check\": \"control 4\", \"actual\": {\"buckets\": [0, 1000, 3500], \"required\": 1875, \"adjustment\": 7358, \"net_ar\": 2625}, \"expected\": {\"buckets\": [0, 1000, 3500], \"required\": 1875, \"adjustment\": 7358, \"net_ar\": 2625}, \"passed\": true}, {\"check\": \"control 5\", \"actual\": {\"buckets\": [0, 333, 4000], \"required\": 2042, \"adjustment\": 2542, \"net_ar\": 2291}, \"expected\": {\"buckets\": [0, 333, 4000], \"required\": 2042, \"adjustment\": 2542, \"net_ar\": 2291}, \"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."}}