{"abstract":"A one-cent credit converted at 0.3 shows as '-0.00' on the invoice.","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":"Taking the absolute value of every line erases the sign of genuine credits.","family":"w2-currency_rounding_and_fx_conversion-invoice-line-conversion-plug-signed-zero-line","id":"FA-61961","implementations":{"attempt":{"sha256":"33ce7943eba02998057a1b73a3004cffcfa6fc66f84bf56b91fa200686a2660e","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), 'f') for c in conv]\ndef check(label, actual, expected):\n    observations.append({\"check\": label, \"actual\": actual, \"expected\": expected, \"passed\": actual == expected})\ncases = [[('regression signed-zero-line 1', (['100.00', '-0.01'], '0.3', 2), ['30.00', '0.00']),\n  ('regression signed-zero-line 2', (['-50.05', '20.03', '-0.004'], '1.0833', 2), ['-54.22', '21.70', '0.00']),\n  ('partial repair guard 2', (['-3.33', '3.33'], '1.5', 2), ['-5.00', '5.00']),\n  ('control: three equal lines', (['10.01', '10.01', '10.01'], '0.5', 2), ['5.02', '5.00', '5.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  ('control: dinar target', (['1.25', '2.50'], '0.3071', 3), ['0.384', '0.768'])],\n [('regression signed-zero-line 1', (['459.88', '678.92', '1035.66', '1782.23', '-0.03'], '8.49695', 0),\n   ['3908', '5769', '8800', '15143', '0']),\n  ('regression signed-zero-line 2', (['100.00', '-0.01'], '0.3', 2), ['30.00', '0.00']),\n  ('partial repair guard 1', (['-50.05', '20.03', '20.03'], '1.0833', 2), ['-54.22', '21.70', '21.70']),\n  ('partial repair guard 2', (['2301.37', '-29.59', '-177.48'], '4.93100', 0), ['11348', '-146', '-875']),\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 signed-zero-line 1', (['-50.05', '20.03', '-0.004'], '1.0833', 2), ['-54.22', '21.70', '0.00']),\n  ('regression signed-zero-line 2', (['459.88', '678.92', '1035.66', '1782.23', '-0.03'], '8.49695', 0),\n   ['3908', '5769', '8800', '15143', '0']),\n  ('partial repair guard 1', (['2091.78', '2339.22', '2608.61', '-64.15', '300.62'], '14.07556', 3),\n   ['29442.975', '32925.831', '36717.647', '-902.947', '4231.395']),\n  ('partial repair guard 2', (['1729.48', '-260.26', '1061.77', '2756.95'], '151.6104', 2),\n   ['262207.15', '-39458.12', '160975.37', '417982.30']),\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 signed-zero-line 1', (['100.00', '-0.01'], '0.3', 2), ['30.00', '0.00']),\n  ('regression signed-zero-line 2', (['-50.05', '20.03', '-0.004'], '1.0833', 2), ['-54.22', '21.70', '0.00']),\n  ('partial repair guard 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  ('partial repair guard 2', (['-280.82', '2067.63', '2910.24', '2108.94'], '21.7286', 2),\n   ['-6101.83', '44926.71', '63235.44', '45824.31']),\n  ('control: credit and debit', (['-3.33', '3.33'], '1.5', 2), ['-5.00', '5.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  ('control: dinar target', (['1.25', '2.50'], '0.3071', 3), ['0.384', '0.768'])],\n [('regression signed-zero-line 1', (['459.88', '678.92', '1035.66', '1782.23', '-0.03'], '8.49695', 0),\n   ['3908', '5769', '8800', '15143', '0']),\n  ('regression signed-zero-line 2', (['100.00', '-0.01'], '0.3', 2), ['30.00', '0.00']),\n  ('partial repair guard 1', (['-292.61', '2818.06', '1578.31', '1901.03', '2697.06'], '55.5721', 2),\n   ['-16260.95', '156605.51', '87710.00', '105644.23', '149881.29']),\n  ('partial repair guard 2', (['1616.46', '-55.89', '2559.69'], '35.6985', 3), ['57705.197', '-1995.189', '91377.094']),\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":"681c6313cd2067a82756a715c3162a2d20e3da6f5e629ddcee67e22184faaffc","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(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 signed-zero-line 1', (['100.00', '-0.01'], '0.3', 2), ['30.00', '0.00']),\n  ('regression signed-zero-line 2', (['-50.05', '20.03', '-0.004'], '1.0833', 2), ['-54.22', '21.70', '0.00']),\n  ('partial repair guard 2', (['-3.33', '3.33'], '1.5', 2), ['-5.00', '5.00']),\n  ('control: three equal lines', (['10.01', '10.01', '10.01'], '0.5', 2), ['5.02', '5.00', '5.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  ('control: dinar target', (['1.25', '2.50'], '0.3071', 3), ['0.384', '0.768'])],\n [('regression signed-zero-line 1', (['459.88', '678.92', '1035.66', '1782.23', '-0.03'], '8.49695', 0),\n   ['3908', '5769', '8800', '15143', '0']),\n  ('regression signed-zero-line 2', (['100.00', '-0.01'], '0.3', 2), ['30.00', '0.00']),\n  ('partial repair guard 1', (['-50.05', '20.03', '20.03'], '1.0833', 2), ['-54.22', '21.70', '21.70']),\n  ('partial repair guard 2', (['2301.37', '-29.59', '-177.48'], '4.93100', 0), ['11348', '-146', '-875']),\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 signed-zero-line 1', (['-50.05', '20.03', '-0.004'], '1.0833', 2), ['-54.22', '21.70', '0.00']),\n  ('regression signed-zero-line 2', (['459.88', '678.92', '1035.66', '1782.23', '-0.03'], '8.49695', 0),\n   ['3908', '5769', '8800', '15143', '0']),\n  ('partial repair guard 1', (['2091.78', '2339.22', '2608.61', '-64.15', '300.62'], '14.07556', 3),\n   ['29442.975', '32925.831', '36717.647', '-902.947', '4231.395']),\n  ('partial repair guard 2', (['1729.48', '-260.26', '1061.77', '2756.95'], '151.6104', 2),\n   ['262207.15', '-39458.12', '160975.37', '417982.30']),\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 signed-zero-line 1', (['100.00', '-0.01'], '0.3', 2), ['30.00', '0.00']),\n  ('regression signed-zero-line 2', (['-50.05', '20.03', '-0.004'], '1.0833', 2), ['-54.22', '21.70', '0.00']),\n  ('partial repair guard 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  ('partial repair guard 2', (['-280.82', '2067.63', '2910.24', '2108.94'], '21.7286', 2),\n   ['-6101.83', '44926.71', '63235.44', '45824.31']),\n  ('control: credit and debit', (['-3.33', '3.33'], '1.5', 2), ['-5.00', '5.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  ('control: dinar target', (['1.25', '2.50'], '0.3071', 3), ['0.384', '0.768'])],\n [('regression signed-zero-line 1', (['459.88', '678.92', '1035.66', '1782.23', '-0.03'], '8.49695', 0),\n   ['3908', '5769', '8800', '15143', '0']),\n  ('regression signed-zero-line 2', (['100.00', '-0.01'], '0.3', 2), ['30.00', '0.00']),\n  ('partial repair guard 1', (['-292.61', '2818.06', '1578.31', '1901.03', '2697.06'], '55.5721', 2),\n   ['-16260.95', '156605.51', '87710.00', '105644.23', '149881.29']),\n  ('partial repair guard 2', (['1616.46', '-55.89', '2559.69'], '35.6985', 3), ['57705.197', '-1995.189', '91377.094']),\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-signed-zero-line","generated_at":"2026-09-29T14:47:00.081480+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":"Rounded Decimal values keep a negative sign when they collapse to zero.","sha256":"7cd4126381963fc6586d98f54c3ae1d1d8d54bb068945514f37089afbb1e6450","title":"A converted credit that rounds to zero is emitted as minus zero · 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":44.437,"exit_code":1,"observations":[{"actual":["30.00","0.00"],"check":"regression signed-zero-line 1","expected":["30.00","0.00"],"passed":true},{"actual":["54.22","21.70","0.00"],"check":"regression signed-zero-line 2","expected":["-54.22","21.70","0.00"],"passed":false},{"actual":["5.00","5.00"],"check":"partial repair guard 2","expected":["-5.00","5.00"],"passed":false},{"actual":["5.02","5.00","5.00"],"check":"control: three equal lines","expected":["5.02","5.00","5.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},{"actual":["0.384","0.768"],"check":"control: dinar target","expected":["0.384","0.768"],"passed":true}],"passed":false,"stderr":"","stdout":"{\"observations\": [{\"check\": \"regression signed-zero-line 1\", \"actual\": [\"30.00\", \"0.00\"], \"expected\": [\"30.00\", \"0.00\"], \"passed\": true}, {\"check\": \"regression signed-zero-line 2\", \"actual\": [\"54.22\", \"21.70\", \"0.00\"], \"expected\": [\"-54.22\", \"21.70\", \"0.00\"], \"passed\": false}, {\"check\": \"partial repair guard 2\", \"actual\": [\"5.00\", \"5.00\"], \"expected\": [\"-5.00\", \"5.00\"], \"passed\": false}, {\"check\": \"control: three equal lines\", \"actual\": [\"5.02\", \"5.00\", \"5.00\"], \"expected\": [\"5.02\", \"5.00\", \"5.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}, {\"check\": \"control: dinar target\", \"actual\": [\"0.384\", \"0.768\"], \"expected\": [\"0.384\", \"0.768\"], \"passed\": true}], \"passed\": false}\n"},"broken":{"elapsed_ms":42.907,"exit_code":1,"observations":[{"actual":["30.00","-0.00"],"check":"regression signed-zero-line 1","expected":["30.00","0.00"],"passed":false},{"actual":["-54.22","21.70","-0.00"],"check":"regression signed-zero-line 2","expected":["-54.22","21.70","0.00"],"passed":false},{"actual":["-5.00","5.00"],"check":"partial repair guard 2","expected":["-5.00","5.00"],"passed":true},{"actual":["5.02","5.00","5.00"],"check":"control: three equal lines","expected":["5.02","5.00","5.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},{"actual":["0.384","0.768"],"check":"control: dinar target","expected":["0.384","0.768"],"passed":true}],"passed":false,"stderr":"","stdout":"{\"observations\": [{\"check\": \"regression signed-zero-line 1\", \"actual\": [\"30.00\", \"-0.00\"], \"expected\": [\"30.00\", \"0.00\"], \"passed\": false}, {\"check\": \"regression signed-zero-line 2\", \"actual\": [\"-54.22\", \"21.70\", \"-0.00\"], \"expected\": [\"-54.22\", \"21.70\", \"0.00\"], \"passed\": false}, {\"check\": \"partial repair guard 2\", \"actual\": [\"-5.00\", \"5.00\"], \"expected\": [\"-5.00\", \"5.00\"], \"passed\": true}, {\"check\": \"control: three equal lines\", \"actual\": [\"5.02\", \"5.00\", \"5.00\"], \"expected\": [\"5.02\", \"5.00\", \"5.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}, {\"check\": \"control: dinar target\", \"actual\": [\"0.384\", \"0.768\"], \"expected\": [\"0.384\", \"0.768\"], \"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."}}