{"abstract":"Prepaid toll account auto-replenishment returns a wrong result when the negative index is overwritten by later charges.","category":"Toll and parking fee computation","checks":8,"contract":"Input {balance, charges, threshold, min_replenish, usage_30d, card_ok}. The replenish amount is max(min_replenish, ceil(usage_30d/4) rounded up to a multiple of 500). After each charge, if the balance is strictly below threshold and the card works, one replenishment is added. first_negative is the index of the first charge after which the balance is negative (or null). Return {balance, replenished, first_negative}.","evaluation_group":"w2-toll_and_parking_fee_computation-auto-replenish","failed_approach":"Counting a zero balance as negative flags accounts that are exactly empty.","family":"w2-toll_and_parking_fee_computation-auto-replenish-first-negative","id":"FA-68631","implementations":{"attempt":{"sha256":"fd6731dd6321e7b1314eea9f2cce750a91b185a8f3f59fbbccb1d74bbc22f055","source":"\"\"\"Failure Map reference implementation. Python standard library only.\"\"\"\nimport json\n\nN = 1\nobservations = []\ndef solve(x):\n    bal = x['balance']\n    n = 0\n    first = None\n    amt = max(x['min_replenish'], -(-x['usage_30d'] // 2000) * 500)\n    for i, c in enumerate(x['charges']):\n        bal -= c\n        if bal < x['threshold'] and x['card_ok']:\n            bal += amt\n            n += 1\n        if bal <= 0 and first is None:\n            first = i\n    return {'balance': bal, 'replenished': n, 'first_negative': first}\ndef check(label, actual, expected):\n    observations.append({\"check\": label, \"actual\": actual, \"expected\": expected, \"passed\": actual == expected})\nfixtures = [[({'balance': 1322, 'charges': [650], 'threshold': 1000, 'min_replenish': 2000, 'usage_30d': 18596, 'card_ok': True}, {'balance': 5672, 'replenished': 1, 'first_negative': None}), ({'balance': 994, 'charges': [3000, 400, 3000, 650, 3000, 3000, 275], 'threshold': 1000, 'min_replenish': 1000, 'usage_30d': 16149, 'card_ok': True}, {'balance': 1169, 'replenished': 3, 'first_negative': None}), ({'balance': 921, 'charges': [1200, 650, 650, 150, 1200, 400, 1200, 150], 'threshold': 500, 'min_replenish': 1000, 'usage_30d': 11909, 'card_ok': False}, {'balance': -4679, 'replenished': 0, 'first_negative': 0}), ({'balance': 400, 'charges': [400], 'threshold': 500, 'min_replenish': 1000, 'usage_30d': 0, 'card_ok': False}, {'balance': 0, 'replenished': 0, 'first_negative': None}), ({'balance': 3320, 'charges': [3000, 3000, 3000, 400, 3000], 'threshold': 500, 'min_replenish': 2500, 'usage_30d': 7303, 'card_ok': False}, {'balance': -9080, 'replenished': 0, 'first_negative': 1}), ({'balance': 1400, 'charges': [400], 'threshold': 1000, 'min_replenish': 1000, 'usage_30d': 9000, 'card_ok': True}, {'balance': 1000, 'replenished': 0, 'first_negative': None}), ({'balance': 300, 'charges': [400, 150, 275], 'threshold': 500, 'min_replenish': 1000, 'usage_30d': 0, 'card_ok': False}, {'balance': -525, 'replenished': 0, 'first_negative': 0}), ({'balance': 2429, 'charges': [275, 150, 275, 150, 150, 400, 1200], 'threshold': 1000, 'min_replenish': 2500, 'usage_30d': 6810, 'card_ok': True}, {'balance': 2329, 'replenished': 1, 'first_negative': None})], [({'balance': 400, 'charges': [400], 'threshold': 500, 'min_replenish': 1000, 'usage_30d': 0, 'card_ok': False}, {'balance': 0, 'replenished': 0, 'first_negative': None}), ({'balance': 753, 'charges': [650, 3000], 'threshold': 1500, 'min_replenish': 2000, 'usage_30d': 2408, 'card_ok': False}, {'balance': -2897, 'replenished': 0, 'first_negative': 1}), ({'balance': 300, 'charges': [400, 150, 275], 'threshold': 500, 'min_replenish': 1000, 'usage_30d': 0, 'card_ok': False}, {'balance': -525, 'replenished': 0, 'first_negative': 0}), ({'balance': 1400, 'charges': [400], 'threshold': 1000, 'min_replenish': 1000, 'usage_30d': 9000, 'card_ok': True}, {'balance': 1000, 'replenished': 0, 'first_negative': None}), ({'balance': 1987, 'charges': [275, 1200, 150, 400], 'threshold': 1000, 'min_replenish': 2000, 'usage_30d': 17952, 'card_ok': True}, {'balance': 4462, 'replenished': 1, 'first_negative': None}), ({'balance': 3568, 'charges': [150, 1200, 150, 3000, 275, 650], 'threshold': 1500, 'min_replenish': 2500, 'usage_30d': 16196, 'card_ok': False}, {'balance': -1857, 'replenished': 0, 'first_negative': 3}), ({'balance': 616, 'charges': [1200, 275, 275, 650, 275], 'threshold': 1000, 'min_replenish': 1000, 'usage_30d': 5115, 'card_ok': False}, {'balance': -2059, 'replenished': 0, 'first_negative': 0}), ({'balance': 1428, 'charges': [275, 3000, 1200, 650, 3000, 3000, 1200], 'threshold': 500, 'min_replenish': 2000, 'usage_30d': 12671, 'card_ok': True}, {'balance': 3103, 'replenished': 4, 'first_negative': None})], [({'balance': 390, 'charges': [400, 1200], 'threshold': 1500, 'min_replenish': 2000, 'usage_30d': 1137, 'card_ok': False}, {'balance': -1210, 'replenished': 0, 'first_negative': 0}), ({'balance': 1400, 'charges': [400], 'threshold': 1000, 'min_replenish': 1000, 'usage_30d': 9000, 'card_ok': True}, {'balance': 1000, 'replenished': 0, 'first_negative': None}), ({'balance': 1694, 'charges': [275, 1200, 275, 275, 650], 'threshold': 1500, 'min_replenish': 1000, 'usage_30d': 904, 'card_ok': False}, {'balance': -981, 'replenished': 0, 'first_negative': 2}), ({'balance': 400, 'charges': [400], 'threshold': 500, 'min_replenish': 1000, 'usage_30d': 0, 'card_ok': False}, {'balance': 0, 'replenished': 0, 'first_negative': None}), ({'balance': 2427, 'charges': [400, 400, 400, 3000, 650], 'threshold': 500, 'min_replenish': 1000, 'usage_30d': 2179, 'card_ok': True}, {'balance': -423, 'replenished': 2, 'first_negative': 3}), ({'balance': 1802, 'charges': [650], 'threshold': 500, 'min_replenish': 2000, 'usage_30d': 19640, 'card_ok': True}, {'balance': 1152, 'replenished': 0, 'first_negative': None}), ({'balance': 1400, 'charges': [400, 150], 'threshold': 1000, 'min_replenish': 1000, 'usage_30d': 9000, 'card_ok': True}, {'balance': 3350, 'replenished': 1, 'first_negative': None}), ({'balance': 155, 'charges': [400, 650, 275, 650], 'threshold': 1000, 'min_replenish': 2500, 'usage_30d': 2650, 'card_ok': True}, {'balance': 3180, 'replenished': 2, 'first_negative': None})], [({'balance': 400, 'charges': [400], 'threshold': 500, 'min_replenish': 1000, 'usage_30d': 0, 'card_ok': False}, {'balance': 0, 'replenished': 0, 'first_negative': None}), ({'balance': 1910, 'charges': [275, 400, 3000, 1200, 400], 'threshold': 500, 'min_replenish': 2000, 'usage_30d': 12496, 'card_ok': True}, {'balance': 3635, 'replenished': 2, 'first_negative': None}), ({'balance': 1400, 'charges': [400, 150], 'threshold': 1000, 'min_replenish': 1000, 'usage_30d': 9000, 'card_ok': True}, {'balance': 3350, 'replenished': 1, 'first_negative': None}), ({'balance': 2190, 'charges': [275], 'threshold': 1000, 'min_replenish': 1000, 'usage_30d': 15361, 'card_ok': True}, {'balance': 1915, 'replenished': 0, 'first_negative': None}), ({'balance': 300, 'charges': [400, 150, 275], 'threshold': 500, 'min_replenish': 1000, 'usage_30d': 0, 'card_ok': False}, {'balance': -525, 'replenished': 0, 'first_negative': 0}), ({'balance': 3344, 'charges': [650, 3000, 1200, 1200, 3000], 'threshold': 1500, 'min_replenish': 1000, 'usage_30d': 104, 'card_ok': True}, {'balance': -1706, 'replenished': 4, 'first_negative': 4}), ({'balance': -397, 'charges': [1200, 1200, 400, 1200, 1200, 275, 150], 'threshold': 1500, 'min_replenish': 1000, 'usage_30d': 452, 'card_ok': False}, {'balance': -6022, 'replenished': 0, 'first_negative': 0}), ({'balance': 2655, 'charges': [650, 3000, 275], 'threshold': 1500, 'min_replenish': 2500, 'usage_30d': 9407, 'card_ok': False}, {'balance': -1270, 'replenished': 0, 'first_negative': 1})], [({'balance': 2215, 'charges': [3000, 150, 275], 'threshold': 1500, 'min_replenish': 2000, 'usage_30d': 16466, 'card_ok': False}, {'balance': -1210, 'replenished': 0, 'first_negative': 0}), ({'balance': 261, 'charges': [3000, 1200, 1200], 'threshold': 500, 'min_replenish': 2000, 'usage_30d': 11452, 'card_ok': True}, {'balance': 861, 'replenished': 2, 'first_negative': None}), ({'balance': -14, 'charges': [1200, 275, 400, 650, 650, 650], 'threshold': 500, 'min_replenish': 2000, 'usage_30d': 6151, 'card_ok': True}, {'balance': 2161, 'replenished': 3, 'first_negative': None}), ({'balance': 400, 'charges': [400], 'threshold': 500, 'min_replenish': 1000, 'usage_30d': 0, 'card_ok': False}, {'balance': 0, 'replenished': 0, 'first_negative': None}), ({'balance': 3175, 'charges': [1200, 650, 400, 650, 275, 400, 3000], 'threshold': 1500, 'min_replenish': 1000, 'usage_30d': 15568, 'card_ok': False}, {'balance': -3400, 'replenished': 0, 'first_negative': 5}), ({'balance': -156, 'charges': [275, 1200], 'threshold': 1000, 'min_replenish': 2000, 'usage_30d': 11597, 'card_ok': False}, {'balance': -1631, 'replenished': 0, 'first_negative': 0}), ({'balance': 1400, 'charges': [400], 'threshold': 1000, 'min_replenish': 1000, 'usage_30d': 9000, 'card_ok': True}, {'balance': 1000, 'replenished': 0, 'first_negative': None}), ({'balance': 300, 'charges': [400, 150, 275], 'threshold': 500, 'min_replenish': 1000, 'usage_30d': 0, 'card_ok': False}, {'balance': -525, 'replenished': 0, 'first_negative': 0})]]\nfor i, (args, expected) in enumerate(fixtures[N-1]):\n    check('fee oracle' + ' %d' % i, 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":"335e96c0e32f05a7524d6d254f13511f19348f694c91f0f84f34dae89c303a6d","source":"\"\"\"Failure Map reference implementation. Python standard library only.\"\"\"\nimport json\n\nN = 1\nobservations = []\ndef solve(x):\n    bal = x['balance']\n    n = 0\n    first = None\n    amt = max(x['min_replenish'], -(-x['usage_30d'] // 2000) * 500)\n    for i, c in enumerate(x['charges']):\n        bal -= c\n        if bal < x['threshold'] and x['card_ok']:\n            bal += amt\n            n += 1\n        if bal < 0:\n            first = i\n    return {'balance': bal, 'replenished': n, 'first_negative': first}\ndef check(label, actual, expected):\n    observations.append({\"check\": label, \"actual\": actual, \"expected\": expected, \"passed\": actual == expected})\nfixtures = [[({'balance': 1322, 'charges': [650], 'threshold': 1000, 'min_replenish': 2000, 'usage_30d': 18596, 'card_ok': True}, {'balance': 5672, 'replenished': 1, 'first_negative': None}), ({'balance': 994, 'charges': [3000, 400, 3000, 650, 3000, 3000, 275], 'threshold': 1000, 'min_replenish': 1000, 'usage_30d': 16149, 'card_ok': True}, {'balance': 1169, 'replenished': 3, 'first_negative': None}), ({'balance': 921, 'charges': [1200, 650, 650, 150, 1200, 400, 1200, 150], 'threshold': 500, 'min_replenish': 1000, 'usage_30d': 11909, 'card_ok': False}, {'balance': -4679, 'replenished': 0, 'first_negative': 0}), ({'balance': 400, 'charges': [400], 'threshold': 500, 'min_replenish': 1000, 'usage_30d': 0, 'card_ok': False}, {'balance': 0, 'replenished': 0, 'first_negative': None}), ({'balance': 3320, 'charges': [3000, 3000, 3000, 400, 3000], 'threshold': 500, 'min_replenish': 2500, 'usage_30d': 7303, 'card_ok': False}, {'balance': -9080, 'replenished': 0, 'first_negative': 1}), ({'balance': 1400, 'charges': [400], 'threshold': 1000, 'min_replenish': 1000, 'usage_30d': 9000, 'card_ok': True}, {'balance': 1000, 'replenished': 0, 'first_negative': None}), ({'balance': 300, 'charges': [400, 150, 275], 'threshold': 500, 'min_replenish': 1000, 'usage_30d': 0, 'card_ok': False}, {'balance': -525, 'replenished': 0, 'first_negative': 0}), ({'balance': 2429, 'charges': [275, 150, 275, 150, 150, 400, 1200], 'threshold': 1000, 'min_replenish': 2500, 'usage_30d': 6810, 'card_ok': True}, {'balance': 2329, 'replenished': 1, 'first_negative': None})], [({'balance': 400, 'charges': [400], 'threshold': 500, 'min_replenish': 1000, 'usage_30d': 0, 'card_ok': False}, {'balance': 0, 'replenished': 0, 'first_negative': None}), ({'balance': 753, 'charges': [650, 3000], 'threshold': 1500, 'min_replenish': 2000, 'usage_30d': 2408, 'card_ok': False}, {'balance': -2897, 'replenished': 0, 'first_negative': 1}), ({'balance': 300, 'charges': [400, 150, 275], 'threshold': 500, 'min_replenish': 1000, 'usage_30d': 0, 'card_ok': False}, {'balance': -525, 'replenished': 0, 'first_negative': 0}), ({'balance': 1400, 'charges': [400], 'threshold': 1000, 'min_replenish': 1000, 'usage_30d': 9000, 'card_ok': True}, {'balance': 1000, 'replenished': 0, 'first_negative': None}), ({'balance': 1987, 'charges': [275, 1200, 150, 400], 'threshold': 1000, 'min_replenish': 2000, 'usage_30d': 17952, 'card_ok': True}, {'balance': 4462, 'replenished': 1, 'first_negative': None}), ({'balance': 3568, 'charges': [150, 1200, 150, 3000, 275, 650], 'threshold': 1500, 'min_replenish': 2500, 'usage_30d': 16196, 'card_ok': False}, {'balance': -1857, 'replenished': 0, 'first_negative': 3}), ({'balance': 616, 'charges': [1200, 275, 275, 650, 275], 'threshold': 1000, 'min_replenish': 1000, 'usage_30d': 5115, 'card_ok': False}, {'balance': -2059, 'replenished': 0, 'first_negative': 0}), ({'balance': 1428, 'charges': [275, 3000, 1200, 650, 3000, 3000, 1200], 'threshold': 500, 'min_replenish': 2000, 'usage_30d': 12671, 'card_ok': True}, {'balance': 3103, 'replenished': 4, 'first_negative': None})], [({'balance': 390, 'charges': [400, 1200], 'threshold': 1500, 'min_replenish': 2000, 'usage_30d': 1137, 'card_ok': False}, {'balance': -1210, 'replenished': 0, 'first_negative': 0}), ({'balance': 1400, 'charges': [400], 'threshold': 1000, 'min_replenish': 1000, 'usage_30d': 9000, 'card_ok': True}, {'balance': 1000, 'replenished': 0, 'first_negative': None}), ({'balance': 1694, 'charges': [275, 1200, 275, 275, 650], 'threshold': 1500, 'min_replenish': 1000, 'usage_30d': 904, 'card_ok': False}, {'balance': -981, 'replenished': 0, 'first_negative': 2}), ({'balance': 400, 'charges': [400], 'threshold': 500, 'min_replenish': 1000, 'usage_30d': 0, 'card_ok': False}, {'balance': 0, 'replenished': 0, 'first_negative': None}), ({'balance': 2427, 'charges': [400, 400, 400, 3000, 650], 'threshold': 500, 'min_replenish': 1000, 'usage_30d': 2179, 'card_ok': True}, {'balance': -423, 'replenished': 2, 'first_negative': 3}), ({'balance': 1802, 'charges': [650], 'threshold': 500, 'min_replenish': 2000, 'usage_30d': 19640, 'card_ok': True}, {'balance': 1152, 'replenished': 0, 'first_negative': None}), ({'balance': 1400, 'charges': [400, 150], 'threshold': 1000, 'min_replenish': 1000, 'usage_30d': 9000, 'card_ok': True}, {'balance': 3350, 'replenished': 1, 'first_negative': None}), ({'balance': 155, 'charges': [400, 650, 275, 650], 'threshold': 1000, 'min_replenish': 2500, 'usage_30d': 2650, 'card_ok': True}, {'balance': 3180, 'replenished': 2, 'first_negative': None})], [({'balance': 400, 'charges': [400], 'threshold': 500, 'min_replenish': 1000, 'usage_30d': 0, 'card_ok': False}, {'balance': 0, 'replenished': 0, 'first_negative': None}), ({'balance': 1910, 'charges': [275, 400, 3000, 1200, 400], 'threshold': 500, 'min_replenish': 2000, 'usage_30d': 12496, 'card_ok': True}, {'balance': 3635, 'replenished': 2, 'first_negative': None}), ({'balance': 1400, 'charges': [400, 150], 'threshold': 1000, 'min_replenish': 1000, 'usage_30d': 9000, 'card_ok': True}, {'balance': 3350, 'replenished': 1, 'first_negative': None}), ({'balance': 2190, 'charges': [275], 'threshold': 1000, 'min_replenish': 1000, 'usage_30d': 15361, 'card_ok': True}, {'balance': 1915, 'replenished': 0, 'first_negative': None}), ({'balance': 300, 'charges': [400, 150, 275], 'threshold': 500, 'min_replenish': 1000, 'usage_30d': 0, 'card_ok': False}, {'balance': -525, 'replenished': 0, 'first_negative': 0}), ({'balance': 3344, 'charges': [650, 3000, 1200, 1200, 3000], 'threshold': 1500, 'min_replenish': 1000, 'usage_30d': 104, 'card_ok': True}, {'balance': -1706, 'replenished': 4, 'first_negative': 4}), ({'balance': -397, 'charges': [1200, 1200, 400, 1200, 1200, 275, 150], 'threshold': 1500, 'min_replenish': 1000, 'usage_30d': 452, 'card_ok': False}, {'balance': -6022, 'replenished': 0, 'first_negative': 0}), ({'balance': 2655, 'charges': [650, 3000, 275], 'threshold': 1500, 'min_replenish': 2500, 'usage_30d': 9407, 'card_ok': False}, {'balance': -1270, 'replenished': 0, 'first_negative': 1})], [({'balance': 2215, 'charges': [3000, 150, 275], 'threshold': 1500, 'min_replenish': 2000, 'usage_30d': 16466, 'card_ok': False}, {'balance': -1210, 'replenished': 0, 'first_negative': 0}), ({'balance': 261, 'charges': [3000, 1200, 1200], 'threshold': 500, 'min_replenish': 2000, 'usage_30d': 11452, 'card_ok': True}, {'balance': 861, 'replenished': 2, 'first_negative': None}), ({'balance': -14, 'charges': [1200, 275, 400, 650, 650, 650], 'threshold': 500, 'min_replenish': 2000, 'usage_30d': 6151, 'card_ok': True}, {'balance': 2161, 'replenished': 3, 'first_negative': None}), ({'balance': 400, 'charges': [400], 'threshold': 500, 'min_replenish': 1000, 'usage_30d': 0, 'card_ok': False}, {'balance': 0, 'replenished': 0, 'first_negative': None}), ({'balance': 3175, 'charges': [1200, 650, 400, 650, 275, 400, 3000], 'threshold': 1500, 'min_replenish': 1000, 'usage_30d': 15568, 'card_ok': False}, {'balance': -3400, 'replenished': 0, 'first_negative': 5}), ({'balance': -156, 'charges': [275, 1200], 'threshold': 1000, 'min_replenish': 2000, 'usage_30d': 11597, 'card_ok': False}, {'balance': -1631, 'replenished': 0, 'first_negative': 0}), ({'balance': 1400, 'charges': [400], 'threshold': 1000, 'min_replenish': 1000, 'usage_30d': 9000, 'card_ok': True}, {'balance': 1000, 'replenished': 0, 'first_negative': None}), ({'balance': 300, 'charges': [400, 150, 275], 'threshold': 500, 'min_replenish': 1000, 'usage_30d': 0, 'card_ok': False}, {'balance': -525, 'replenished': 0, 'first_negative': 0})]]\nfor i, (args, expected) in enumerate(fixtures[N-1]):\n    check('fee oracle' + ' %d' % i, 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":"f11ee9f73687c09e795204895896075c3d3c3000ac54cbac71c62004d4738fed","source":"\"\"\"Failure Map reference implementation. Python standard library only.\"\"\"\nimport json\n\nN = 1\nobservations = []\ndef solve(x):\n    bal = x['balance']\n    n = 0\n    first = None\n    amt = max(x['min_replenish'], -(-x['usage_30d'] // 2000) * 500)\n    for i, c in enumerate(x['charges']):\n        bal -= c\n        if bal < x['threshold'] and x['card_ok']:\n            bal += amt\n            n += 1\n        if bal < 0 and first is None:\n            first = i\n    return {'balance': bal, 'replenished': n, 'first_negative': first}\ndef check(label, actual, expected):\n    observations.append({\"check\": label, \"actual\": actual, \"expected\": expected, \"passed\": actual == expected})\nfixtures = [[({'balance': 1322, 'charges': [650], 'threshold': 1000, 'min_replenish': 2000, 'usage_30d': 18596, 'card_ok': True}, {'balance': 5672, 'replenished': 1, 'first_negative': None}), ({'balance': 994, 'charges': [3000, 400, 3000, 650, 3000, 3000, 275], 'threshold': 1000, 'min_replenish': 1000, 'usage_30d': 16149, 'card_ok': True}, {'balance': 1169, 'replenished': 3, 'first_negative': None}), ({'balance': 921, 'charges': [1200, 650, 650, 150, 1200, 400, 1200, 150], 'threshold': 500, 'min_replenish': 1000, 'usage_30d': 11909, 'card_ok': False}, {'balance': -4679, 'replenished': 0, 'first_negative': 0}), ({'balance': 400, 'charges': [400], 'threshold': 500, 'min_replenish': 1000, 'usage_30d': 0, 'card_ok': False}, {'balance': 0, 'replenished': 0, 'first_negative': None}), ({'balance': 3320, 'charges': [3000, 3000, 3000, 400, 3000], 'threshold': 500, 'min_replenish': 2500, 'usage_30d': 7303, 'card_ok': False}, {'balance': -9080, 'replenished': 0, 'first_negative': 1}), ({'balance': 1400, 'charges': [400], 'threshold': 1000, 'min_replenish': 1000, 'usage_30d': 9000, 'card_ok': True}, {'balance': 1000, 'replenished': 0, 'first_negative': None}), ({'balance': 300, 'charges': [400, 150, 275], 'threshold': 500, 'min_replenish': 1000, 'usage_30d': 0, 'card_ok': False}, {'balance': -525, 'replenished': 0, 'first_negative': 0}), ({'balance': 2429, 'charges': [275, 150, 275, 150, 150, 400, 1200], 'threshold': 1000, 'min_replenish': 2500, 'usage_30d': 6810, 'card_ok': True}, {'balance': 2329, 'replenished': 1, 'first_negative': None})], [({'balance': 400, 'charges': [400], 'threshold': 500, 'min_replenish': 1000, 'usage_30d': 0, 'card_ok': False}, {'balance': 0, 'replenished': 0, 'first_negative': None}), ({'balance': 753, 'charges': [650, 3000], 'threshold': 1500, 'min_replenish': 2000, 'usage_30d': 2408, 'card_ok': False}, {'balance': -2897, 'replenished': 0, 'first_negative': 1}), ({'balance': 300, 'charges': [400, 150, 275], 'threshold': 500, 'min_replenish': 1000, 'usage_30d': 0, 'card_ok': False}, {'balance': -525, 'replenished': 0, 'first_negative': 0}), ({'balance': 1400, 'charges': [400], 'threshold': 1000, 'min_replenish': 1000, 'usage_30d': 9000, 'card_ok': True}, {'balance': 1000, 'replenished': 0, 'first_negative': None}), ({'balance': 1987, 'charges': [275, 1200, 150, 400], 'threshold': 1000, 'min_replenish': 2000, 'usage_30d': 17952, 'card_ok': True}, {'balance': 4462, 'replenished': 1, 'first_negative': None}), ({'balance': 3568, 'charges': [150, 1200, 150, 3000, 275, 650], 'threshold': 1500, 'min_replenish': 2500, 'usage_30d': 16196, 'card_ok': False}, {'balance': -1857, 'replenished': 0, 'first_negative': 3}), ({'balance': 616, 'charges': [1200, 275, 275, 650, 275], 'threshold': 1000, 'min_replenish': 1000, 'usage_30d': 5115, 'card_ok': False}, {'balance': -2059, 'replenished': 0, 'first_negative': 0}), ({'balance': 1428, 'charges': [275, 3000, 1200, 650, 3000, 3000, 1200], 'threshold': 500, 'min_replenish': 2000, 'usage_30d': 12671, 'card_ok': True}, {'balance': 3103, 'replenished': 4, 'first_negative': None})], [({'balance': 390, 'charges': [400, 1200], 'threshold': 1500, 'min_replenish': 2000, 'usage_30d': 1137, 'card_ok': False}, {'balance': -1210, 'replenished': 0, 'first_negative': 0}), ({'balance': 1400, 'charges': [400], 'threshold': 1000, 'min_replenish': 1000, 'usage_30d': 9000, 'card_ok': True}, {'balance': 1000, 'replenished': 0, 'first_negative': None}), ({'balance': 1694, 'charges': [275, 1200, 275, 275, 650], 'threshold': 1500, 'min_replenish': 1000, 'usage_30d': 904, 'card_ok': False}, {'balance': -981, 'replenished': 0, 'first_negative': 2}), ({'balance': 400, 'charges': [400], 'threshold': 500, 'min_replenish': 1000, 'usage_30d': 0, 'card_ok': False}, {'balance': 0, 'replenished': 0, 'first_negative': None}), ({'balance': 2427, 'charges': [400, 400, 400, 3000, 650], 'threshold': 500, 'min_replenish': 1000, 'usage_30d': 2179, 'card_ok': True}, {'balance': -423, 'replenished': 2, 'first_negative': 3}), ({'balance': 1802, 'charges': [650], 'threshold': 500, 'min_replenish': 2000, 'usage_30d': 19640, 'card_ok': True}, {'balance': 1152, 'replenished': 0, 'first_negative': None}), ({'balance': 1400, 'charges': [400, 150], 'threshold': 1000, 'min_replenish': 1000, 'usage_30d': 9000, 'card_ok': True}, {'balance': 3350, 'replenished': 1, 'first_negative': None}), ({'balance': 155, 'charges': [400, 650, 275, 650], 'threshold': 1000, 'min_replenish': 2500, 'usage_30d': 2650, 'card_ok': True}, {'balance': 3180, 'replenished': 2, 'first_negative': None})], [({'balance': 400, 'charges': [400], 'threshold': 500, 'min_replenish': 1000, 'usage_30d': 0, 'card_ok': False}, {'balance': 0, 'replenished': 0, 'first_negative': None}), ({'balance': 1910, 'charges': [275, 400, 3000, 1200, 400], 'threshold': 500, 'min_replenish': 2000, 'usage_30d': 12496, 'card_ok': True}, {'balance': 3635, 'replenished': 2, 'first_negative': None}), ({'balance': 1400, 'charges': [400, 150], 'threshold': 1000, 'min_replenish': 1000, 'usage_30d': 9000, 'card_ok': True}, {'balance': 3350, 'replenished': 1, 'first_negative': None}), ({'balance': 2190, 'charges': [275], 'threshold': 1000, 'min_replenish': 1000, 'usage_30d': 15361, 'card_ok': True}, {'balance': 1915, 'replenished': 0, 'first_negative': None}), ({'balance': 300, 'charges': [400, 150, 275], 'threshold': 500, 'min_replenish': 1000, 'usage_30d': 0, 'card_ok': False}, {'balance': -525, 'replenished': 0, 'first_negative': 0}), ({'balance': 3344, 'charges': [650, 3000, 1200, 1200, 3000], 'threshold': 1500, 'min_replenish': 1000, 'usage_30d': 104, 'card_ok': True}, {'balance': -1706, 'replenished': 4, 'first_negative': 4}), ({'balance': -397, 'charges': [1200, 1200, 400, 1200, 1200, 275, 150], 'threshold': 1500, 'min_replenish': 1000, 'usage_30d': 452, 'card_ok': False}, {'balance': -6022, 'replenished': 0, 'first_negative': 0}), ({'balance': 2655, 'charges': [650, 3000, 275], 'threshold': 1500, 'min_replenish': 2500, 'usage_30d': 9407, 'card_ok': False}, {'balance': -1270, 'replenished': 0, 'first_negative': 1})], [({'balance': 2215, 'charges': [3000, 150, 275], 'threshold': 1500, 'min_replenish': 2000, 'usage_30d': 16466, 'card_ok': False}, {'balance': -1210, 'replenished': 0, 'first_negative': 0}), ({'balance': 261, 'charges': [3000, 1200, 1200], 'threshold': 500, 'min_replenish': 2000, 'usage_30d': 11452, 'card_ok': True}, {'balance': 861, 'replenished': 2, 'first_negative': None}), ({'balance': -14, 'charges': [1200, 275, 400, 650, 650, 650], 'threshold': 500, 'min_replenish': 2000, 'usage_30d': 6151, 'card_ok': True}, {'balance': 2161, 'replenished': 3, 'first_negative': None}), ({'balance': 400, 'charges': [400], 'threshold': 500, 'min_replenish': 1000, 'usage_30d': 0, 'card_ok': False}, {'balance': 0, 'replenished': 0, 'first_negative': None}), ({'balance': 3175, 'charges': [1200, 650, 400, 650, 275, 400, 3000], 'threshold': 1500, 'min_replenish': 1000, 'usage_30d': 15568, 'card_ok': False}, {'balance': -3400, 'replenished': 0, 'first_negative': 5}), ({'balance': -156, 'charges': [275, 1200], 'threshold': 1000, 'min_replenish': 2000, 'usage_30d': 11597, 'card_ok': False}, {'balance': -1631, 'replenished': 0, 'first_negative': 0}), ({'balance': 1400, 'charges': [400], 'threshold': 1000, 'min_replenish': 1000, 'usage_30d': 9000, 'card_ok': True}, {'balance': 1000, 'replenished': 0, 'first_negative': None}), ({'balance': 300, 'charges': [400, 150, 275], 'threshold': 500, 'min_replenish': 1000, 'usage_30d': 0, 'card_ok': False}, {'balance': -525, 'replenished': 0, 'first_negative': 0})]]\nfor i, (args, expected) in enumerate(fixtures[N-1]):\n    check('fee oracle' + ' %d' % i, 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 toy model with a stipulated contract; it makes no claim of conformance to any agency manual or standard. 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-toll_and_parking_fee_computation-auto-replenish-first-negative","generated_at":"2026-09-29T14:48:04.096372+00:00","license":"CC0-1.0","python":"3.12.14","seed":1,"split":"open-access"},"relevance":"Fee engines bill customers in integer cents; a wrong boundary, rounding stage or cap scope silently over- or under-charges.","repair":"Restore the first negative latch rule so that the step reads `if bal < 0 and first is None:`.","root_cause":"Without the latch the last negative charge is reported instead of the first.","sha256":"5233e222df5c3d388619ca293d76c5af42e6c47ccff8cc331574c6006bcd4e5f","title":"Prepaid toll account auto-replenishment: the negative index is overwritten by later charges · case 01","variant":1,"variant_policy":"Five numbered records share a model and may reuse boundary fixtures.","verification":{"attempt":{"elapsed_ms":42.555,"exit_code":1,"observations":[{"actual":{"balance":5672,"first_negative":null,"replenished":1},"check":"fee oracle 0","expected":{"balance":5672,"first_negative":null,"replenished":1},"passed":true},{"actual":{"balance":1169,"first_negative":null,"replenished":3},"check":"fee oracle 1","expected":{"balance":1169,"first_negative":null,"replenished":3},"passed":true},{"actual":{"balance":-4679,"first_negative":0,"replenished":0},"check":"fee oracle 2","expected":{"balance":-4679,"first_negative":0,"replenished":0},"passed":true},{"actual":{"balance":0,"first_negative":0,"replenished":0},"check":"fee oracle 3","expected":{"balance":0,"first_negative":null,"replenished":0},"passed":false},{"actual":{"balance":-9080,"first_negative":1,"replenished":0},"check":"fee oracle 4","expected":{"balance":-9080,"first_negative":1,"replenished":0},"passed":true},{"actual":{"balance":1000,"first_negative":null,"replenished":0},"check":"fee oracle 5","expected":{"balance":1000,"first_negative":null,"replenished":0},"passed":true},{"actual":{"balance":-525,"first_negative":0,"replenished":0},"check":"fee oracle 6","expected":{"balance":-525,"first_negative":0,"replenished":0},"passed":true},{"actual":{"balance":2329,"first_negative":null,"replenished":1},"check":"fee oracle 7","expected":{"balance":2329,"first_negative":null,"replenished":1},"passed":true}],"passed":false,"stderr":"","stdout":"{\"observations\": [{\"check\": \"fee oracle 0\", \"actual\": {\"balance\": 5672, \"replenished\": 1, \"first_negative\": null}, \"expected\": {\"balance\": 5672, \"replenished\": 1, \"first_negative\": null}, \"passed\": true}, {\"check\": \"fee oracle 1\", \"actual\": {\"balance\": 1169, \"replenished\": 3, \"first_negative\": null}, \"expected\": {\"balance\": 1169, \"replenished\": 3, \"first_negative\": null}, \"passed\": true}, {\"check\": \"fee oracle 2\", \"actual\": {\"balance\": -4679, \"replenished\": 0, \"first_negative\": 0}, \"expected\": {\"balance\": -4679, \"replenished\": 0, \"first_negative\": 0}, \"passed\": true}, {\"check\": \"fee oracle 3\", \"actual\": {\"balance\": 0, \"replenished\": 0, \"first_negative\": 0}, \"expected\": {\"balance\": 0, \"replenished\": 0, \"first_negative\": null}, \"passed\": false}, {\"check\": \"fee oracle 4\", \"actual\": {\"balance\": -9080, \"replenished\": 0, \"first_negative\": 1}, \"expected\": {\"balance\": -9080, \"replenished\": 0, \"first_negative\": 1}, \"passed\": true}, {\"check\": \"fee oracle 5\", \"actual\": {\"balance\": 1000, \"replenished\": 0, \"first_negative\": null}, \"expected\": {\"balance\": 1000, \"replenished\": 0, \"first_negative\": null}, \"passed\": true}, {\"check\": \"fee oracle 6\", \"actual\": {\"balance\": -525, \"replenished\": 0, \"first_negative\": 0}, \"expected\": {\"balance\": -525, \"replenished\": 0, \"first_negative\": 0}, \"passed\": true}, {\"check\": \"fee oracle 7\", \"actual\": {\"balance\": 2329, \"replenished\": 1, \"first_negative\": null}, \"expected\": {\"balance\": 2329, \"replenished\": 1, \"first_negative\": null}, \"passed\": true}], \"passed\": false}\n"},"broken":{"elapsed_ms":41.7,"exit_code":1,"observations":[{"actual":{"balance":5672,"first_negative":null,"replenished":1},"check":"fee oracle 0","expected":{"balance":5672,"first_negative":null,"replenished":1},"passed":true},{"actual":{"balance":1169,"first_negative":null,"replenished":3},"check":"fee oracle 1","expected":{"balance":1169,"first_negative":null,"replenished":3},"passed":true},{"actual":{"balance":-4679,"first_negative":7,"replenished":0},"check":"fee oracle 2","expected":{"balance":-4679,"first_negative":0,"replenished":0},"passed":false},{"actual":{"balance":0,"first_negative":null,"replenished":0},"check":"fee oracle 3","expected":{"balance":0,"first_negative":null,"replenished":0},"passed":true},{"actual":{"balance":-9080,"first_negative":4,"replenished":0},"check":"fee oracle 4","expected":{"balance":-9080,"first_negative":1,"replenished":0},"passed":false},{"actual":{"balance":1000,"first_negative":null,"replenished":0},"check":"fee oracle 5","expected":{"balance":1000,"first_negative":null,"replenished":0},"passed":true},{"actual":{"balance":-525,"first_negative":2,"replenished":0},"check":"fee oracle 6","expected":{"balance":-525,"first_negative":0,"replenished":0},"passed":false},{"actual":{"balance":2329,"first_negative":null,"replenished":1},"check":"fee oracle 7","expected":{"balance":2329,"first_negative":null,"replenished":1},"passed":true}],"passed":false,"stderr":"","stdout":"{\"observations\": [{\"check\": \"fee oracle 0\", \"actual\": {\"balance\": 5672, \"replenished\": 1, \"first_negative\": null}, \"expected\": {\"balance\": 5672, \"replenished\": 1, \"first_negative\": null}, \"passed\": true}, {\"check\": \"fee oracle 1\", \"actual\": {\"balance\": 1169, \"replenished\": 3, \"first_negative\": null}, \"expected\": {\"balance\": 1169, \"replenished\": 3, \"first_negative\": null}, \"passed\": true}, {\"check\": \"fee oracle 2\", \"actual\": {\"balance\": -4679, \"replenished\": 0, \"first_negative\": 7}, \"expected\": {\"balance\": -4679, \"replenished\": 0, \"first_negative\": 0}, \"passed\": false}, {\"check\": \"fee oracle 3\", \"actual\": {\"balance\": 0, \"replenished\": 0, \"first_negative\": null}, \"expected\": {\"balance\": 0, \"replenished\": 0, \"first_negative\": null}, \"passed\": true}, {\"check\": \"fee oracle 4\", \"actual\": {\"balance\": -9080, \"replenished\": 0, \"first_negative\": 4}, \"expected\": {\"balance\": -9080, \"replenished\": 0, \"first_negative\": 1}, \"passed\": false}, {\"check\": \"fee oracle 5\", \"actual\": {\"balance\": 1000, \"replenished\": 0, \"first_negative\": null}, \"expected\": {\"balance\": 1000, \"replenished\": 0, \"first_negative\": null}, \"passed\": true}, {\"check\": \"fee oracle 6\", \"actual\": {\"balance\": -525, \"replenished\": 0, \"first_negative\": 2}, \"expected\": {\"balance\": -525, \"replenished\": 0, \"first_negative\": 0}, \"passed\": false}, {\"check\": \"fee oracle 7\", \"actual\": {\"balance\": 2329, \"replenished\": 1, \"first_negative\": null}, \"expected\": {\"balance\": 2329, \"replenished\": 1, \"first_negative\": null}, \"passed\": true}], \"passed\": false}\n"},"fixed":{"elapsed_ms":43.724,"exit_code":0,"observations":[{"actual":{"balance":5672,"first_negative":null,"replenished":1},"check":"fee oracle 0","expected":{"balance":5672,"first_negative":null,"replenished":1},"passed":true},{"actual":{"balance":1169,"first_negative":null,"replenished":3},"check":"fee oracle 1","expected":{"balance":1169,"first_negative":null,"replenished":3},"passed":true},{"actual":{"balance":-4679,"first_negative":0,"replenished":0},"check":"fee oracle 2","expected":{"balance":-4679,"first_negative":0,"replenished":0},"passed":true},{"actual":{"balance":0,"first_negative":null,"replenished":0},"check":"fee oracle 3","expected":{"balance":0,"first_negative":null,"replenished":0},"passed":true},{"actual":{"balance":-9080,"first_negative":1,"replenished":0},"check":"fee oracle 4","expected":{"balance":-9080,"first_negative":1,"replenished":0},"passed":true},{"actual":{"balance":1000,"first_negative":null,"replenished":0},"check":"fee oracle 5","expected":{"balance":1000,"first_negative":null,"replenished":0},"passed":true},{"actual":{"balance":-525,"first_negative":0,"replenished":0},"check":"fee oracle 6","expected":{"balance":-525,"first_negative":0,"replenished":0},"passed":true},{"actual":{"balance":2329,"first_negative":null,"replenished":1},"check":"fee oracle 7","expected":{"balance":2329,"first_negative":null,"replenished":1},"passed":true}],"passed":true,"stderr":"","stdout":"{\"observations\": [{\"check\": \"fee oracle 0\", \"actual\": {\"balance\": 5672, \"replenished\": 1, \"first_negative\": null}, \"expected\": {\"balance\": 5672, \"replenished\": 1, \"first_negative\": null}, \"passed\": true}, {\"check\": \"fee oracle 1\", \"actual\": {\"balance\": 1169, \"replenished\": 3, \"first_negative\": null}, \"expected\": {\"balance\": 1169, \"replenished\": 3, \"first_negative\": null}, \"passed\": true}, {\"check\": \"fee oracle 2\", \"actual\": {\"balance\": -4679, \"replenished\": 0, \"first_negative\": 0}, \"expected\": {\"balance\": -4679, \"replenished\": 0, \"first_negative\": 0}, \"passed\": true}, {\"check\": \"fee oracle 3\", \"actual\": {\"balance\": 0, \"replenished\": 0, \"first_negative\": null}, \"expected\": {\"balance\": 0, \"replenished\": 0, \"first_negative\": null}, \"passed\": true}, {\"check\": \"fee oracle 4\", \"actual\": {\"balance\": -9080, \"replenished\": 0, \"first_negative\": 1}, \"expected\": {\"balance\": -9080, \"replenished\": 0, \"first_negative\": 1}, \"passed\": true}, {\"check\": \"fee oracle 5\", \"actual\": {\"balance\": 1000, \"replenished\": 0, \"first_negative\": null}, \"expected\": {\"balance\": 1000, \"replenished\": 0, \"first_negative\": null}, \"passed\": true}, {\"check\": \"fee oracle 6\", \"actual\": {\"balance\": -525, \"replenished\": 0, \"first_negative\": 0}, \"expected\": {\"balance\": -525, \"replenished\": 0, \"first_negative\": 0}, \"passed\": true}, {\"check\": \"fee oracle 7\", \"actual\": {\"balance\": 2329, \"replenished\": 1, \"first_negative\": null}, \"expected\": {\"balance\": 2329, \"replenished\": 1, \"first_negative\": null}, \"passed\": true}], \"passed\": true}\n"}},"verified":true,"visibility":"public"}