{"abstract":"Converted lines sum to a value two differences away from the control total.","category":"Currency rounding and FX conversion","checks":7,"contract":"solve(lines, rate, exp): lines are source-currency decimal strings (credits negative), rate a decimal string, exp the target exponent. The converted total is round_half_even(sum(lines)*rate) at exp. Each line is converted and rounded half-even individually; the difference between the converted total and the sum of converted lines is posted in full to the line with the largest absolute source amount (earliest on ties). Return the converted lines as plain strings; zero lines are unsigned. An empty invoice returns [].","contract_signature":"lines, rate, exp","evaluation_group":"w2-currency_rounding_and_fx_conversion-invoice-line-conversion-plug","failed_approach":"Adding the absolute difference only works when the rounded lines under-shoot the total.","family":"w2-currency_rounding_and_fx_conversion-invoice-line-conversion-plug-plug-sign","id":"FA-61956","implementations":{"attempt":{"sha256":"565c66a5837c909d4517612e82cea176f00ad7cab020f11560cca4046bcd05be","source":"\"\"\"Failure Map reference implementation. Python standard library only.\"\"\"\nimport json\nfrom decimal import Decimal, ROUND_HALF_EVEN, ROUND_HALF_UP, ROUND_FLOOR, ROUND_CEILING, ROUND_DOWN, ROUND_UP, ROUND_HALF_DOWN\nN = 1\nobservations = []\ndef solve(lines, rate, exp):\n    r = Decimal(rate)\n    qt = Decimal(1).scaleb(-exp)\n    def q(v): return v.quantize(qt, rounding=ROUND_HALF_EVEN)\n    src = [Decimal(l) for l in lines]\n    if not src: return []\n    conv = [q(v * r) for v in src]\n    total = q(sum(src, Decimal(0)) * r)\n    diff = total - sum(conv, Decimal(0))\n    i = max(range(len(conv)), key=lambda k: (abs(src[k]), -k))\n    conv[i] += abs(diff)\n    return [format(abs(c) if c == 0 else c, 'f') for c in conv]\ndef check(label, actual, expected):\n    observations.append({\"check\": label, \"actual\": actual, \"expected\": expected, \"passed\": actual == expected})\ncases = [[('regression plug-sign 1', (['10.01', '10.01', '10.01'], '0.5', 2), ['5.02', '5.00', '5.00']),\n  ('regression plug-sign 2', (['135.46', '1241.19', '543.10'], '121.0106', 2), ['16392.10', '150197.14', '65720.86']),\n  ('partial repair guard 2', (['2340.71', '566.48', '2486.21', '1232.14'], '11.46450', 3),\n   ['26835.070', '6494.410', '28503.154', '14125.869']),\n  ('control: credit and debit', (['-3.33', '3.33'], '1.5', 2), ['-5.00', '5.00']),\n  ('control: tiny credit', (['100.00', '-0.01'], '0.3', 2), ['30.00', '0.00']),\n  ('control: empty invoice', ([], '1.1', 2), []),\n  ('control: yen target', (['19.99', '5.01', '0.99'], '151.37', 0), ['3026', '758', '150'])],\n [('regression plug-sign 1', (['2009.44', '2296.55', '1393.27', '1770.57', '2944.58'], '81.6625', 2),\n   ['164095.89', '187542.01', '113777.91', '144589.17', '240461.78']),\n  ('regression plug-sign 2', (['1729.48', '-260.26', '1061.77', '2756.95'], '151.6104', 2),\n   ['262207.15', '-39458.12', '160975.37', '417982.30']),\n  ('partial repair guard 1', (['474.23', '2013.40'], '2.07137', 2), ['982.31', '4170.49']),\n  ('partial repair guard 2', (['426.74', '2140.94'], '102.7874', 2), ['43863.50', '220061.65']),\n  ('control: empty invoice', ([], '1.1', 2), []),\n  ('control: yen target', (['19.99', '5.01', '0.99'], '151.37', 0), ['3026', '758', '150']),\n  ('control: dinar target', (['1.25', '2.50'], '0.3071', 3), ['0.384', '0.768']),\n  ('control: single line', (['123.45'], '0.9215', 2), ['113.76'])],\n [('regression plug-sign 1', (['607.45', '-205.45', '116.41', '195.72', '309.63'], '1991.467', 2),\n   ['1209716.64', '-409146.90', '231826.67', '389769.92', '616617.93']),\n  ('regression plug-sign 2', (['2340.71', '566.48', '2486.21', '1232.14'], '11.46450', 3),\n   ['26835.070', '6494.410', '28503.154', '14125.869']),\n  ('partial repair guard 1', (['866.33', '-73.41', '796.96', '969.42'], '561.952', 2),\n   ['486835.88', '-41252.90', '447853.27', '544767.50']),\n  ('partial repair guard 2', (['1337.60', '1422.94', '1036.77', '2321.08'], '12.49239', 2),\n   ['16709.82', '17775.92', '12951.74', '28995.83']),\n  ('control: single line', (['123.45'], '0.9215', 2), ['113.76']),\n  ('control: largest is credit', (['-50.05', '20.03', '20.03'], '1.0833', 2), ['-54.22', '21.70', '21.70']),\n  ('control: three equal lines', (['10.01', '10.01', '10.01'], '0.5', 2), ['5.02', '5.00', '5.00']),\n  ('control: credit and debit', (['-3.33', '3.33'], '1.5', 2), ['-5.00', '5.00'])],\n [('regression plug-sign 1', (['2564.41', '147.72', '2843.10'], '11.81884', 3), ['30308.351', '1745.879', '33602.145']),\n  ('regression plug-sign 2', (['2885.93', '241.41'], '10.35728', 0), ['29891', '2500']),\n  ('partial repair guard 1', (['1936.34', '641.20', '-204.60', '2626.29', '2966.22'], '145.7597', 2),\n   ['282240.34', '93461.12', '-29822.43', '382807.24', '432355.33']),\n  ('partial repair guard 2', (['1035.43', '-191.27', '803.79', '-53.39', '961.52'], '25.8497', 3),\n   ['26765.554', '-4944.272', '20777.730', '-1380.115', '24855.004']),\n  ('control: credit and debit', (['-3.33', '3.33'], '1.5', 2), ['-5.00', '5.00']),\n  ('control: tiny credit', (['100.00', '-0.01'], '0.3', 2), ['30.00', '0.00']),\n  ('control: empty invoice', ([], '1.1', 2), []),\n  ('control: yen target', (['19.99', '5.01', '0.99'], '151.37', 0), ['3026', '758', '150'])],\n [('regression plug-sign 1', (['474.23', '2013.40'], '2.07137', 2), ['982.31', '4170.49']),\n  ('regression plug-sign 2', (['1616.46', '-55.89', '2559.69'], '35.6985', 3), ['57705.197', '-1995.189', '91377.094']),\n  ('partial repair guard 1', (['1446.45', '-213.92', '1311.94', '997.39'], '1.64995', 0),\n   ['2386', '-353', '2165', '1646']),\n  ('partial repair guard 2', (['2819.33', '273.60', '2697.59'], '1443.082', 2),\n   ['4068524.37', '394827.24', '3892843.57']),\n  ('control: yen target', (['19.99', '5.01', '0.99'], '151.37', 0), ['3026', '758', '150']),\n  ('control: dinar target', (['1.25', '2.50'], '0.3071', 3), ['0.384', '0.768']),\n  ('control: single line', (['123.45'], '0.9215', 2), ['113.76']),\n  ('control: largest is credit', (['-50.05', '20.03', '20.03'], '1.0833', 2), ['-54.22', '21.70', '21.70'])]]\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":"ea4610fd4cb1fe0bf19e53e91d781481399c172e93443c2ad532f91e38008886","source":"\"\"\"Failure Map reference implementation. Python standard library only.\"\"\"\nimport json\nfrom decimal import Decimal, ROUND_HALF_EVEN, ROUND_HALF_UP, ROUND_FLOOR, ROUND_CEILING, ROUND_DOWN, ROUND_UP, ROUND_HALF_DOWN\nN = 1\nobservations = []\ndef solve(lines, rate, exp):\n    r = Decimal(rate)\n    qt = Decimal(1).scaleb(-exp)\n    def q(v): return v.quantize(qt, rounding=ROUND_HALF_EVEN)\n    src = [Decimal(l) for l in lines]\n    if not src: return []\n    conv = [q(v * r) for v in src]\n    total = q(sum(src, Decimal(0)) * r)\n    diff = total - sum(conv, Decimal(0))\n    i = max(range(len(conv)), key=lambda k: (abs(src[k]), -k))\n    conv[i] -= diff\n    return [format(abs(c) if c == 0 else c, 'f') for c in conv]\ndef check(label, actual, expected):\n    observations.append({\"check\": label, \"actual\": actual, \"expected\": expected, \"passed\": actual == expected})\ncases = [[('regression plug-sign 1', (['10.01', '10.01', '10.01'], '0.5', 2), ['5.02', '5.00', '5.00']),\n  ('regression plug-sign 2', (['135.46', '1241.19', '543.10'], '121.0106', 2), ['16392.10', '150197.14', '65720.86']),\n  ('partial repair guard 2', (['2340.71', '566.48', '2486.21', '1232.14'], '11.46450', 3),\n   ['26835.070', '6494.410', '28503.154', '14125.869']),\n  ('control: credit and debit', (['-3.33', '3.33'], '1.5', 2), ['-5.00', '5.00']),\n  ('control: tiny credit', (['100.00', '-0.01'], '0.3', 2), ['30.00', '0.00']),\n  ('control: empty invoice', ([], '1.1', 2), []),\n  ('control: yen target', (['19.99', '5.01', '0.99'], '151.37', 0), ['3026', '758', '150'])],\n [('regression plug-sign 1', (['2009.44', '2296.55', '1393.27', '1770.57', '2944.58'], '81.6625', 2),\n   ['164095.89', '187542.01', '113777.91', '144589.17', '240461.78']),\n  ('regression plug-sign 2', (['1729.48', '-260.26', '1061.77', '2756.95'], '151.6104', 2),\n   ['262207.15', '-39458.12', '160975.37', '417982.30']),\n  ('partial repair guard 1', (['474.23', '2013.40'], '2.07137', 2), ['982.31', '4170.49']),\n  ('partial repair guard 2', (['426.74', '2140.94'], '102.7874', 2), ['43863.50', '220061.65']),\n  ('control: empty invoice', ([], '1.1', 2), []),\n  ('control: yen target', (['19.99', '5.01', '0.99'], '151.37', 0), ['3026', '758', '150']),\n  ('control: dinar target', (['1.25', '2.50'], '0.3071', 3), ['0.384', '0.768']),\n  ('control: single line', (['123.45'], '0.9215', 2), ['113.76'])],\n [('regression plug-sign 1', (['607.45', '-205.45', '116.41', '195.72', '309.63'], '1991.467', 2),\n   ['1209716.64', '-409146.90', '231826.67', '389769.92', '616617.93']),\n  ('regression plug-sign 2', (['2340.71', '566.48', '2486.21', '1232.14'], '11.46450', 3),\n   ['26835.070', '6494.410', '28503.154', '14125.869']),\n  ('partial repair guard 1', (['866.33', '-73.41', '796.96', '969.42'], '561.952', 2),\n   ['486835.88', '-41252.90', '447853.27', '544767.50']),\n  ('partial repair guard 2', (['1337.60', '1422.94', '1036.77', '2321.08'], '12.49239', 2),\n   ['16709.82', '17775.92', '12951.74', '28995.83']),\n  ('control: single line', (['123.45'], '0.9215', 2), ['113.76']),\n  ('control: largest is credit', (['-50.05', '20.03', '20.03'], '1.0833', 2), ['-54.22', '21.70', '21.70']),\n  ('control: three equal lines', (['10.01', '10.01', '10.01'], '0.5', 2), ['5.02', '5.00', '5.00']),\n  ('control: credit and debit', (['-3.33', '3.33'], '1.5', 2), ['-5.00', '5.00'])],\n [('regression plug-sign 1', (['2564.41', '147.72', '2843.10'], '11.81884', 3), ['30308.351', '1745.879', '33602.145']),\n  ('regression plug-sign 2', (['2885.93', '241.41'], '10.35728', 0), ['29891', '2500']),\n  ('partial repair guard 1', (['1936.34', '641.20', '-204.60', '2626.29', '2966.22'], '145.7597', 2),\n   ['282240.34', '93461.12', '-29822.43', '382807.24', '432355.33']),\n  ('partial repair guard 2', (['1035.43', '-191.27', '803.79', '-53.39', '961.52'], '25.8497', 3),\n   ['26765.554', '-4944.272', '20777.730', '-1380.115', '24855.004']),\n  ('control: credit and debit', (['-3.33', '3.33'], '1.5', 2), ['-5.00', '5.00']),\n  ('control: tiny credit', (['100.00', '-0.01'], '0.3', 2), ['30.00', '0.00']),\n  ('control: empty invoice', ([], '1.1', 2), []),\n  ('control: yen target', (['19.99', '5.01', '0.99'], '151.37', 0), ['3026', '758', '150'])],\n [('regression plug-sign 1', (['474.23', '2013.40'], '2.07137', 2), ['982.31', '4170.49']),\n  ('regression plug-sign 2', (['1616.46', '-55.89', '2559.69'], '35.6985', 3), ['57705.197', '-1995.189', '91377.094']),\n  ('partial repair guard 1', (['1446.45', '-213.92', '1311.94', '997.39'], '1.64995', 0),\n   ['2386', '-353', '2165', '1646']),\n  ('partial repair guard 2', (['2819.33', '273.60', '2697.59'], '1443.082', 2),\n   ['4068524.37', '394827.24', '3892843.57']),\n  ('control: yen target', (['19.99', '5.01', '0.99'], '151.37', 0), ['3026', '758', '150']),\n  ('control: dinar target', (['1.25', '2.50'], '0.3071', 3), ['0.384', '0.768']),\n  ('control: single line', (['123.45'], '0.9215', 2), ['113.76']),\n  ('control: largest is credit', (['-50.05', '20.03', '20.03'], '1.0833', 2), ['-54.22', '21.70', '21.70'])]]\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-currency_rounding_and_fx_conversion-invoice-line-conversion-plug-plug-sign","generated_at":"2026-09-29T14:47:00.042131+00:00","license":"CC0-1.0","python":"3.12.14","seed":1,"split":"open-access"},"relevance":"Currency amounts must be rounded at the right stage and in the right unit, or ledgers, quotes and settlements drift by minor units.","root_cause":"The plug applies conv[i] -= diff instead of adding the signed difference.","sha256":"656656dd628e42f0fc39ca5c0bb8abc82a9813155bfc764c8339dba50ac8f82e","title":"The rounding difference is subtracted from the plug line · 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.987,"exit_code":1,"observations":[{"actual":["5.02","5.00","5.00"],"check":"regression plug-sign 1","expected":["5.02","5.00","5.00"],"passed":true},{"actual":["16392.10","150197.16","65720.86"],"check":"regression plug-sign 2","expected":["16392.10","150197.14","65720.86"],"passed":false},{"actual":["26835.070","6494.410","28503.156","14125.869"],"check":"partial repair guard 2","expected":["26835.070","6494.410","28503.154","14125.869"],"passed":false},{"actual":["-5.00","5.00"],"check":"control: credit and debit","expected":["-5.00","5.00"],"passed":true},{"actual":["30.00","0.00"],"check":"control: tiny credit","expected":["30.00","0.00"],"passed":true},{"actual":[],"check":"control: empty invoice","expected":[],"passed":true},{"actual":["3026","758","150"],"check":"control: yen target","expected":["3026","758","150"],"passed":true}],"passed":false,"stderr":"","stdout":"{\"observations\": [{\"check\": \"regression plug-sign 1\", \"actual\": [\"5.02\", \"5.00\", \"5.00\"], \"expected\": [\"5.02\", \"5.00\", \"5.00\"], \"passed\": true}, {\"check\": \"regression plug-sign 2\", \"actual\": [\"16392.10\", \"150197.16\", \"65720.86\"], \"expected\": [\"16392.10\", \"150197.14\", \"65720.86\"], \"passed\": false}, {\"check\": \"partial repair guard 2\", \"actual\": [\"26835.070\", \"6494.410\", \"28503.156\", \"14125.869\"], \"expected\": [\"26835.070\", \"6494.410\", \"28503.154\", \"14125.869\"], \"passed\": false}, {\"check\": \"control: credit and debit\", \"actual\": [\"-5.00\", \"5.00\"], \"expected\": [\"-5.00\", \"5.00\"], \"passed\": true}, {\"check\": \"control: tiny credit\", \"actual\": [\"30.00\", \"0.00\"], \"expected\": [\"30.00\", \"0.00\"], \"passed\": true}, {\"check\": \"control: empty invoice\", \"actual\": [], \"expected\": [], \"passed\": true}, {\"check\": \"control: yen target\", \"actual\": [\"3026\", \"758\", \"150\"], \"expected\": [\"3026\", \"758\", \"150\"], \"passed\": true}], \"passed\": false}\n"},"broken":{"elapsed_ms":41.094,"exit_code":1,"observations":[{"actual":["4.98","5.00","5.00"],"check":"regression plug-sign 1","expected":["5.02","5.00","5.00"],"passed":false},{"actual":["16392.10","150197.16","65720.86"],"check":"regression plug-sign 2","expected":["16392.10","150197.14","65720.86"],"passed":false},{"actual":["26835.070","6494.410","28503.156","14125.869"],"check":"partial repair guard 2","expected":["26835.070","6494.410","28503.154","14125.869"],"passed":false},{"actual":["-5.00","5.00"],"check":"control: credit and debit","expected":["-5.00","5.00"],"passed":true},{"actual":["30.00","0.00"],"check":"control: tiny credit","expected":["30.00","0.00"],"passed":true},{"actual":[],"check":"control: empty invoice","expected":[],"passed":true},{"actual":["3026","758","150"],"check":"control: yen target","expected":["3026","758","150"],"passed":true}],"passed":false,"stderr":"","stdout":"{\"observations\": [{\"check\": \"regression plug-sign 1\", \"actual\": [\"4.98\", \"5.00\", \"5.00\"], \"expected\": [\"5.02\", \"5.00\", \"5.00\"], \"passed\": false}, {\"check\": \"regression plug-sign 2\", \"actual\": [\"16392.10\", \"150197.16\", \"65720.86\"], \"expected\": [\"16392.10\", \"150197.14\", \"65720.86\"], \"passed\": false}, {\"check\": \"partial repair guard 2\", \"actual\": [\"26835.070\", \"6494.410\", \"28503.156\", \"14125.869\"], \"expected\": [\"26835.070\", \"6494.410\", \"28503.154\", \"14125.869\"], \"passed\": false}, {\"check\": \"control: credit and debit\", \"actual\": [\"-5.00\", \"5.00\"], \"expected\": [\"-5.00\", \"5.00\"], \"passed\": true}, {\"check\": \"control: tiny credit\", \"actual\": [\"30.00\", \"0.00\"], \"expected\": [\"30.00\", \"0.00\"], \"passed\": true}, {\"check\": \"control: empty invoice\", \"actual\": [], \"expected\": [], \"passed\": true}, {\"check\": \"control: yen target\", \"actual\": [\"3026\", \"758\", \"150\"], \"expected\": [\"3026\", \"758\", \"150\"], \"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."}}