{"abstract":"USD to EUR fails with ERR:no-rate:USD even though USD is the pivot currency.","category":"Currency rounding and FX conversion","checks":7,"contract":"solve(amount, frm, to, rates): rates maps a currency to units of that currency per 1 USD (decimal strings); USD is implicitly 1 when absent. Convert exactly as amount / rate[frm] * rate[to] with no intermediate rounding, then round half-even to the target exponent (USD/EUR/GBP/CHF/SEK/NOK 2, JPY/KRW 0, KWD 3, CLF 4) and return a plain string. A missing rate returns 'ERR:no-rate:<code>', a zero or negative rate 'ERR:bad-rate:<code>' (source checked first).","evaluation_group":"w2-currency_rounding_and_fx_conversion-usd-pivot-cross","failed_approach":"Defaulting USD only when it is the source currency still rejects conversions into USD.","family":"w2-currency_rounding_and_fx_conversion-usd-pivot-cross-implicit-usd","id":"FA-61886","implementations":{"attempt":{"sha256":"e1eb9a38103081a89d9ce155fee9589ee80f4b3574d4fe6496e1ad279e73a541","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(amount, frm, to, rates):\n    exps = {'USD': 2, 'EUR': 2, 'GBP': 2, 'CHF': 2, 'SEK': 2, 'NOK': 2, 'JPY': 0, 'KRW': 0, 'KWD': 3, 'CLF': 4}\n    def rate(c):\n        if c == 'USD' and c == frm and c not in rates: return Decimal(1)\n        if c not in rates: return None\n        return Decimal(rates[c])\n    rf, rt = rate(frm), rate(to)\n    for c, r in ((frm, rf), (to, rt)):\n        if r is None: return 'ERR:no-rate:' + c\n        if r <= 0: return 'ERR:bad-rate:' + c\n    usd = Decimal(amount) / rf\n    out = usd * rt\n    return format(out.quantize(Decimal(1).scaleb(-exps[to]), rounding=ROUND_HALF_EVEN), 'f')\ndef check(label, actual, expected):\n    observations.append({\"check\": label, \"actual\": actual, \"expected\": expected, \"passed\": actual == expected})\ncases = [[('regression implicit-usd 1', ('42.42', 'EUR', 'USD', {'EUR': '0.92'}), '46.11'),\n  ('regression implicit-usd 2', ('10', 'USD', 'EUR', {'EUR': '0.92'}), '9.20'),\n  ('partial repair guard 2',\n   ('5', 'GBP', 'USD',\n    {'EUR': '0.92',\n     'JPY': '151.37',\n     'KRW': '1352.5',\n     'KWD': '0.3071',\n     'GBP': '0.7893',\n     'CLF': '0.02451',\n     'CHF': '0.8801'}),\n   '6.33'),\n  ('control: euro to yen',\n   ('100', 'EUR', 'JPY',\n    {'EUR': '0.92',\n     'JPY': '151.37',\n     'KRW': '1352.5',\n     'KWD': '0.3071',\n     'GBP': '0.7893',\n     'CLF': '0.02451',\n     'CHF': '0.8801'}),\n   '16453'),\n  ('control: usd to dinar',\n   ('100.00', 'USD', 'KWD',\n    {'EUR': '0.92',\n     'JPY': '151.37',\n     'KRW': '1352.5',\n     'KWD': '0.3071',\n     'GBP': '0.7893',\n     'CLF': '0.02451',\n     'CHF': '0.8801'}),\n   '30.710'),\n  ('control: missing target',\n   ('1', 'EUR', 'SEK',\n    {'EUR': '0.92',\n     'JPY': '151.37',\n     'KRW': '1352.5',\n     'KWD': '0.3071',\n     'GBP': '0.7893',\n     'CLF': '0.02451',\n     'CHF': '0.8801'}),\n   'ERR:no-rate:SEK'),\n  ('control: won to franc',\n   ('250000', 'KRW', 'CHF',\n    {'EUR': '0.92',\n     'JPY': '151.37',\n     'KRW': '1352.5',\n     'KWD': '0.3071',\n     'GBP': '0.7893',\n     'CLF': '0.02451',\n     'CHF': '0.8801'}),\n   '162.68')],\n [('regression implicit-usd 1',\n   ('100.00', 'USD', 'KWD',\n    {'EUR': '0.92',\n     'JPY': '151.37',\n     'KRW': '1352.5',\n     'KWD': '0.3071',\n     'GBP': '0.7893',\n     'CLF': '0.02451',\n     'CHF': '0.8801'}),\n   '30.710'),\n  ('regression implicit-usd 2',\n   ('5', 'GBP', 'USD',\n    {'EUR': '0.92',\n     'JPY': '151.37',\n     'KRW': '1352.5',\n     'KWD': '0.3071',\n     'GBP': '0.7893',\n     'CLF': '0.02451',\n     'CHF': '0.8801'}),\n   '6.33'),\n  ('partial repair guard 1',\n   ('63600', 'EUR', 'USD', {'EUR': '0.92', 'JPY': '151.37', 'KRW': '1352.5', 'KWD': '0.3071', 'CLF': '0.02451'}),\n   '69130.43'),\n  ('partial repair guard 2',\n   ('19481.34', 'KWD', 'USD',\n    {'EUR': '0.92',\n     'JPY': '151.37',\n     'KRW': '1352.5',\n     'KWD': '0.3071',\n     'GBP': '0.7893',\n     'CLF': '0.02451',\n     'CHF': '0.8801'}),\n   '63436.47'),\n  ('control: missing target',\n   ('1', 'EUR', 'SEK',\n    {'EUR': '0.92',\n     'JPY': '151.37',\n     'KRW': '1352.5',\n     'KWD': '0.3071',\n     'GBP': '0.7893',\n     'CLF': '0.02451',\n     'CHF': '0.8801'}),\n   'ERR:no-rate:SEK'),\n  ('control: won to franc',\n   ('250000', 'KRW', 'CHF',\n    {'EUR': '0.92',\n     'JPY': '151.37',\n     'KRW': '1352.5',\n     'KWD': '0.3071',\n     'GBP': '0.7893',\n     'CLF': '0.02451',\n     'CHF': '0.8801'}),\n   '162.68'),\n  ('control: yen to unit of account',\n   ('99999', 'JPY', 'CLF',\n    {'EUR': '0.92',\n     'JPY': '151.37',\n     'KRW': '1352.5',\n     'KWD': '0.3071',\n     'GBP': '0.7893',\n     'CLF': '0.02451',\n     'CHF': '0.8801'}),\n   '16.1920'),\n  ('control: zero rate target', ('10', 'EUR', 'CHF', {'EUR': '0.92', 'CHF': '0'}), 'ERR:bad-rate:CHF')],\n [('regression implicit-usd 1',\n   ('63600', 'EUR', 'USD', {'EUR': '0.92', 'JPY': '151.37', 'KRW': '1352.5', 'KWD': '0.3071', 'CLF': '0.02451'}),\n   '69130.43'),\n  ('regression implicit-usd 2',\n   ('19481.34', 'KWD', 'USD',\n    {'EUR': '0.92',\n     'JPY': '151.37',\n     'KRW': '1352.5',\n     'KWD': '0.3071',\n     'GBP': '0.7893',\n     'CLF': '0.02451',\n     'CHF': '0.8801'}),\n   '63436.47'),\n  ('partial repair guard 1',\n   ('31699.892', 'KWD', 'USD',\n    {'EUR': '0.92', 'KRW': '1352.5', 'KWD': '0.3071', 'GBP': '0.7893', 'CLF': '0.02451', 'CHF': '0.8801'}),\n   '103223.35'),\n  ('partial repair guard 2',\n   ('153425', 'GBP', 'USD',\n    {'EUR': '0.92', 'JPY': '151.37', 'KWD': '0.3071', 'GBP': '0.7893', 'CLF': '0.02451', 'CHF': '0.8801'}),\n   '194381.10'),\n  ('control: zero rate target', ('10', 'EUR', 'CHF', {'EUR': '0.92', 'CHF': '0'}), 'ERR:bad-rate:CHF'),\n  ('control: explicit usd rate', ('10', 'USD', 'EUR', {'USD': '1', 'EUR': '0.92'}), '9.20'),\n  ('control: usd absent', ('42.42', 'EUR', 'USD', {'EUR': '0.92'}), '46.11'),\n  ('control: euro to yen',\n   ('100', 'EUR', 'JPY',\n    {'EUR': '0.92',\n     'JPY': '151.37',\n     'KRW': '1352.5',\n     'KWD': '0.3071',\n     'GBP': '0.7893',\n     'CLF': '0.02451',\n     'CHF': '0.8801'}),\n   '16453')],\n [('regression implicit-usd 1',\n   ('31474', 'USD', 'USD',\n    {'EUR': '0.92', 'JPY': '151.37', 'KRW': '1352.5', 'GBP': '0.7893', 'CLF': '0.02451', 'CHF': '0.8801'}),\n   '31474.00'),\n  ('regression implicit-usd 2',\n   ('31699.892', 'KWD', 'USD',\n    {'EUR': '0.92', 'KRW': '1352.5', 'KWD': '0.3071', 'GBP': '0.7893', 'CLF': '0.02451', 'CHF': '0.8801'}),\n   '103223.35'),\n  ('partial repair guard 1',\n   ('121673.94', 'EUR', 'USD', {'EUR': '0.92', 'KRW': '1352.5', 'KWD': '0.3071', 'GBP': '0.7893', 'CLF': '0.02451'}),\n   '132254.28'),\n  ('partial repair guard 2',\n   ('96170', 'JPY', 'USD',\n    {'EUR': '0.92', 'JPY': '151.37', 'KRW': '1352.5', 'KWD': '0.3071', 'GBP': '0.7893', 'CHF': '0.8801'}),\n   '635.33'),\n  ('control: euro to yen',\n   ('100', 'EUR', 'JPY',\n    {'EUR': '0.92',\n     'JPY': '151.37',\n     'KRW': '1352.5',\n     'KWD': '0.3071',\n     'GBP': '0.7893',\n     'CLF': '0.02451',\n     'CHF': '0.8801'}),\n   '16453'),\n  ('control: usd to dinar',\n   ('100.00', 'USD', 'KWD',\n    {'EUR': '0.92',\n     'JPY': '151.37',\n     'KRW': '1352.5',\n     'KWD': '0.3071',\n     'GBP': '0.7893',\n     'CLF': '0.02451',\n     'CHF': '0.8801'}),\n   '30.710'),\n  ('control: pound to usd',\n   ('5', 'GBP', 'USD',\n    {'EUR': '0.92',\n     'JPY': '151.37',\n     'KRW': '1352.5',\n     'KWD': '0.3071',\n     'GBP': '0.7893',\n     'CLF': '0.02451',\n     'CHF': '0.8801'}),\n   '6.33'),\n  ('control: missing target',\n   ('1', 'EUR', 'SEK',\n    {'EUR': '0.92',\n     'JPY': '151.37',\n     'KRW': '1352.5',\n     'KWD': '0.3071',\n     'GBP': '0.7893',\n     'CLF': '0.02451',\n     'CHF': '0.8801'}),\n   'ERR:no-rate:SEK')],\n [('regression implicit-usd 1',\n   ('91201', 'USD', 'USD', {'EUR': '0.92', 'JPY': '151.37', 'KWD': '0.3071', 'GBP': '0.7893', 'CHF': '0.8801'}),\n   '91201.00'),\n  ('regression implicit-usd 2',\n   ('192940.19', 'USD', 'USD', {'EUR': '0.92', 'KWD': '0.3071', 'CLF': '0.02451', 'CHF': '0.8801'}), '192940.19'),\n  ('partial repair guard 1',\n   ('121828.64', 'KRW', 'USD', {'KRW': '1352.5', 'KWD': '0.3071', 'GBP': '0.7893', 'CLF': '0.02451', 'CHF': '0.8801'}),\n   '90.08'),\n  ('partial repair guard 2',\n   ('13490.966', 'KWD', 'USD',\n    {'EUR': '0.92',\n     'JPY': '151.37',\n     'KRW': '1352.5',\n     'KWD': '0.3071',\n     'GBP': '0.7893',\n     'CLF': '0.02451',\n     'CHF': '0.8801'}),\n   '43930.21'),\n  ('control: missing target',\n   ('1', 'EUR', 'SEK',\n    {'EUR': '0.92',\n     'JPY': '151.37',\n     'KRW': '1352.5',\n     'KWD': '0.3071',\n     'GBP': '0.7893',\n     'CLF': '0.02451',\n     'CHF': '0.8801'}),\n   'ERR:no-rate:SEK'),\n  ('control: won to franc',\n   ('250000', 'KRW', 'CHF',\n    {'EUR': '0.92',\n     'JPY': '151.37',\n     'KRW': '1352.5',\n     'KWD': '0.3071',\n     'GBP': '0.7893',\n     'CLF': '0.02451',\n     'CHF': '0.8801'}),\n   '162.68'),\n  ('control: yen to unit of account',\n   ('99999', 'JPY', 'CLF',\n    {'EUR': '0.92',\n     'JPY': '151.37',\n     'KRW': '1352.5',\n     'KWD': '0.3071',\n     'GBP': '0.7893',\n     'CLF': '0.02451',\n     'CHF': '0.8801'}),\n   '16.1920'),\n  ('control: zero rate target', ('10', 'EUR', 'CHF', {'EUR': '0.92', 'CHF': '0'}), 'ERR:bad-rate:CHF')]]\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":"56c9a38099beef6f47812b4d7496af2d54336a8b466eba27351394e7ab640e4b","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(amount, frm, to, rates):\n    exps = {'USD': 2, 'EUR': 2, 'GBP': 2, 'CHF': 2, 'SEK': 2, 'NOK': 2, 'JPY': 0, 'KRW': 0, 'KWD': 3, 'CLF': 4}\n    def rate(c):\n        if c not in rates: return None\n        return Decimal(rates[c])\n    rf, rt = rate(frm), rate(to)\n    for c, r in ((frm, rf), (to, rt)):\n        if r is None: return 'ERR:no-rate:' + c\n        if r <= 0: return 'ERR:bad-rate:' + c\n    usd = Decimal(amount) / rf\n    out = usd * rt\n    return format(out.quantize(Decimal(1).scaleb(-exps[to]), rounding=ROUND_HALF_EVEN), 'f')\ndef check(label, actual, expected):\n    observations.append({\"check\": label, \"actual\": actual, \"expected\": expected, \"passed\": actual == expected})\ncases = [[('regression implicit-usd 1', ('42.42', 'EUR', 'USD', {'EUR': '0.92'}), '46.11'),\n  ('regression implicit-usd 2', ('10', 'USD', 'EUR', {'EUR': '0.92'}), '9.20'),\n  ('partial repair guard 2',\n   ('5', 'GBP', 'USD',\n    {'EUR': '0.92',\n     'JPY': '151.37',\n     'KRW': '1352.5',\n     'KWD': '0.3071',\n     'GBP': '0.7893',\n     'CLF': '0.02451',\n     'CHF': '0.8801'}),\n   '6.33'),\n  ('control: euro to yen',\n   ('100', 'EUR', 'JPY',\n    {'EUR': '0.92',\n     'JPY': '151.37',\n     'KRW': '1352.5',\n     'KWD': '0.3071',\n     'GBP': '0.7893',\n     'CLF': '0.02451',\n     'CHF': '0.8801'}),\n   '16453'),\n  ('control: usd to dinar',\n   ('100.00', 'USD', 'KWD',\n    {'EUR': '0.92',\n     'JPY': '151.37',\n     'KRW': '1352.5',\n     'KWD': '0.3071',\n     'GBP': '0.7893',\n     'CLF': '0.02451',\n     'CHF': '0.8801'}),\n   '30.710'),\n  ('control: missing target',\n   ('1', 'EUR', 'SEK',\n    {'EUR': '0.92',\n     'JPY': '151.37',\n     'KRW': '1352.5',\n     'KWD': '0.3071',\n     'GBP': '0.7893',\n     'CLF': '0.02451',\n     'CHF': '0.8801'}),\n   'ERR:no-rate:SEK'),\n  ('control: won to franc',\n   ('250000', 'KRW', 'CHF',\n    {'EUR': '0.92',\n     'JPY': '151.37',\n     'KRW': '1352.5',\n     'KWD': '0.3071',\n     'GBP': '0.7893',\n     'CLF': '0.02451',\n     'CHF': '0.8801'}),\n   '162.68')],\n [('regression implicit-usd 1',\n   ('100.00', 'USD', 'KWD',\n    {'EUR': '0.92',\n     'JPY': '151.37',\n     'KRW': '1352.5',\n     'KWD': '0.3071',\n     'GBP': '0.7893',\n     'CLF': '0.02451',\n     'CHF': '0.8801'}),\n   '30.710'),\n  ('regression implicit-usd 2',\n   ('5', 'GBP', 'USD',\n    {'EUR': '0.92',\n     'JPY': '151.37',\n     'KRW': '1352.5',\n     'KWD': '0.3071',\n     'GBP': '0.7893',\n     'CLF': '0.02451',\n     'CHF': '0.8801'}),\n   '6.33'),\n  ('partial repair guard 1',\n   ('63600', 'EUR', 'USD', {'EUR': '0.92', 'JPY': '151.37', 'KRW': '1352.5', 'KWD': '0.3071', 'CLF': '0.02451'}),\n   '69130.43'),\n  ('partial repair guard 2',\n   ('19481.34', 'KWD', 'USD',\n    {'EUR': '0.92',\n     'JPY': '151.37',\n     'KRW': '1352.5',\n     'KWD': '0.3071',\n     'GBP': '0.7893',\n     'CLF': '0.02451',\n     'CHF': '0.8801'}),\n   '63436.47'),\n  ('control: missing target',\n   ('1', 'EUR', 'SEK',\n    {'EUR': '0.92',\n     'JPY': '151.37',\n     'KRW': '1352.5',\n     'KWD': '0.3071',\n     'GBP': '0.7893',\n     'CLF': '0.02451',\n     'CHF': '0.8801'}),\n   'ERR:no-rate:SEK'),\n  ('control: won to franc',\n   ('250000', 'KRW', 'CHF',\n    {'EUR': '0.92',\n     'JPY': '151.37',\n     'KRW': '1352.5',\n     'KWD': '0.3071',\n     'GBP': '0.7893',\n     'CLF': '0.02451',\n     'CHF': '0.8801'}),\n   '162.68'),\n  ('control: yen to unit of account',\n   ('99999', 'JPY', 'CLF',\n    {'EUR': '0.92',\n     'JPY': '151.37',\n     'KRW': '1352.5',\n     'KWD': '0.3071',\n     'GBP': '0.7893',\n     'CLF': '0.02451',\n     'CHF': '0.8801'}),\n   '16.1920'),\n  ('control: zero rate target', ('10', 'EUR', 'CHF', {'EUR': '0.92', 'CHF': '0'}), 'ERR:bad-rate:CHF')],\n [('regression implicit-usd 1',\n   ('63600', 'EUR', 'USD', {'EUR': '0.92', 'JPY': '151.37', 'KRW': '1352.5', 'KWD': '0.3071', 'CLF': '0.02451'}),\n   '69130.43'),\n  ('regression implicit-usd 2',\n   ('19481.34', 'KWD', 'USD',\n    {'EUR': '0.92',\n     'JPY': '151.37',\n     'KRW': '1352.5',\n     'KWD': '0.3071',\n     'GBP': '0.7893',\n     'CLF': '0.02451',\n     'CHF': '0.8801'}),\n   '63436.47'),\n  ('partial repair guard 1',\n   ('31699.892', 'KWD', 'USD',\n    {'EUR': '0.92', 'KRW': '1352.5', 'KWD': '0.3071', 'GBP': '0.7893', 'CLF': '0.02451', 'CHF': '0.8801'}),\n   '103223.35'),\n  ('partial repair guard 2',\n   ('153425', 'GBP', 'USD',\n    {'EUR': '0.92', 'JPY': '151.37', 'KWD': '0.3071', 'GBP': '0.7893', 'CLF': '0.02451', 'CHF': '0.8801'}),\n   '194381.10'),\n  ('control: zero rate target', ('10', 'EUR', 'CHF', {'EUR': '0.92', 'CHF': '0'}), 'ERR:bad-rate:CHF'),\n  ('control: explicit usd rate', ('10', 'USD', 'EUR', {'USD': '1', 'EUR': '0.92'}), '9.20'),\n  ('control: usd absent', ('42.42', 'EUR', 'USD', {'EUR': '0.92'}), '46.11'),\n  ('control: euro to yen',\n   ('100', 'EUR', 'JPY',\n    {'EUR': '0.92',\n     'JPY': '151.37',\n     'KRW': '1352.5',\n     'KWD': '0.3071',\n     'GBP': '0.7893',\n     'CLF': '0.02451',\n     'CHF': '0.8801'}),\n   '16453')],\n [('regression implicit-usd 1',\n   ('31474', 'USD', 'USD',\n    {'EUR': '0.92', 'JPY': '151.37', 'KRW': '1352.5', 'GBP': '0.7893', 'CLF': '0.02451', 'CHF': '0.8801'}),\n   '31474.00'),\n  ('regression implicit-usd 2',\n   ('31699.892', 'KWD', 'USD',\n    {'EUR': '0.92', 'KRW': '1352.5', 'KWD': '0.3071', 'GBP': '0.7893', 'CLF': '0.02451', 'CHF': '0.8801'}),\n   '103223.35'),\n  ('partial repair guard 1',\n   ('121673.94', 'EUR', 'USD', {'EUR': '0.92', 'KRW': '1352.5', 'KWD': '0.3071', 'GBP': '0.7893', 'CLF': '0.02451'}),\n   '132254.28'),\n  ('partial repair guard 2',\n   ('96170', 'JPY', 'USD',\n    {'EUR': '0.92', 'JPY': '151.37', 'KRW': '1352.5', 'KWD': '0.3071', 'GBP': '0.7893', 'CHF': '0.8801'}),\n   '635.33'),\n  ('control: euro to yen',\n   ('100', 'EUR', 'JPY',\n    {'EUR': '0.92',\n     'JPY': '151.37',\n     'KRW': '1352.5',\n     'KWD': '0.3071',\n     'GBP': '0.7893',\n     'CLF': '0.02451',\n     'CHF': '0.8801'}),\n   '16453'),\n  ('control: usd to dinar',\n   ('100.00', 'USD', 'KWD',\n    {'EUR': '0.92',\n     'JPY': '151.37',\n     'KRW': '1352.5',\n     'KWD': '0.3071',\n     'GBP': '0.7893',\n     'CLF': '0.02451',\n     'CHF': '0.8801'}),\n   '30.710'),\n  ('control: pound to usd',\n   ('5', 'GBP', 'USD',\n    {'EUR': '0.92',\n     'JPY': '151.37',\n     'KRW': '1352.5',\n     'KWD': '0.3071',\n     'GBP': '0.7893',\n     'CLF': '0.02451',\n     'CHF': '0.8801'}),\n   '6.33'),\n  ('control: missing target',\n   ('1', 'EUR', 'SEK',\n    {'EUR': '0.92',\n     'JPY': '151.37',\n     'KRW': '1352.5',\n     'KWD': '0.3071',\n     'GBP': '0.7893',\n     'CLF': '0.02451',\n     'CHF': '0.8801'}),\n   'ERR:no-rate:SEK')],\n [('regression implicit-usd 1',\n   ('91201', 'USD', 'USD', {'EUR': '0.92', 'JPY': '151.37', 'KWD': '0.3071', 'GBP': '0.7893', 'CHF': '0.8801'}),\n   '91201.00'),\n  ('regression implicit-usd 2',\n   ('192940.19', 'USD', 'USD', {'EUR': '0.92', 'KWD': '0.3071', 'CLF': '0.02451', 'CHF': '0.8801'}), '192940.19'),\n  ('partial repair guard 1',\n   ('121828.64', 'KRW', 'USD', {'KRW': '1352.5', 'KWD': '0.3071', 'GBP': '0.7893', 'CLF': '0.02451', 'CHF': '0.8801'}),\n   '90.08'),\n  ('partial repair guard 2',\n   ('13490.966', 'KWD', 'USD',\n    {'EUR': '0.92',\n     'JPY': '151.37',\n     'KRW': '1352.5',\n     'KWD': '0.3071',\n     'GBP': '0.7893',\n     'CLF': '0.02451',\n     'CHF': '0.8801'}),\n   '43930.21'),\n  ('control: missing target',\n   ('1', 'EUR', 'SEK',\n    {'EUR': '0.92',\n     'JPY': '151.37',\n     'KRW': '1352.5',\n     'KWD': '0.3071',\n     'GBP': '0.7893',\n     'CLF': '0.02451',\n     'CHF': '0.8801'}),\n   'ERR:no-rate:SEK'),\n  ('control: won to franc',\n   ('250000', 'KRW', 'CHF',\n    {'EUR': '0.92',\n     'JPY': '151.37',\n     'KRW': '1352.5',\n     'KWD': '0.3071',\n     'GBP': '0.7893',\n     'CLF': '0.02451',\n     'CHF': '0.8801'}),\n   '162.68'),\n  ('control: yen to unit of account',\n   ('99999', 'JPY', 'CLF',\n    {'EUR': '0.92',\n     'JPY': '151.37',\n     'KRW': '1352.5',\n     'KWD': '0.3071',\n     'GBP': '0.7893',\n     'CLF': '0.02451',\n     'CHF': '0.8801'}),\n   '16.1920'),\n  ('control: zero rate target', ('10', 'EUR', 'CHF', {'EUR': '0.92', 'CHF': '0'}), 'ERR:bad-rate:CHF')]]\nfor label, args, expected in cases[N - 1]:\n    check(label, solve(*args), expected)\nprint(json.dumps({\"observations\": observations, \"passed\": all(x[\"passed\"] for x in observations)}, ensure_ascii=False))\nraise SystemExit(0 if all(x[\"passed\"] for x in observations) else 1)\n"},"fixed":{"sha256":"b973a3c8ce16fb85735c72a21a4b599d6cca86650e8a2678f34392ae7828f811","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(amount, frm, to, rates):\n    exps = {'USD': 2, 'EUR': 2, 'GBP': 2, 'CHF': 2, 'SEK': 2, 'NOK': 2, 'JPY': 0, 'KRW': 0, 'KWD': 3, 'CLF': 4}\n    def rate(c):\n        if c == 'USD' and c not in rates: return Decimal(1)\n        if c not in rates: return None\n        return Decimal(rates[c])\n    rf, rt = rate(frm), rate(to)\n    for c, r in ((frm, rf), (to, rt)):\n        if r is None: return 'ERR:no-rate:' + c\n        if r <= 0: return 'ERR:bad-rate:' + c\n    usd = Decimal(amount) / rf\n    out = usd * rt\n    return format(out.quantize(Decimal(1).scaleb(-exps[to]), rounding=ROUND_HALF_EVEN), 'f')\ndef check(label, actual, expected):\n    observations.append({\"check\": label, \"actual\": actual, \"expected\": expected, \"passed\": actual == expected})\ncases = [[('regression implicit-usd 1', ('42.42', 'EUR', 'USD', {'EUR': '0.92'}), '46.11'),\n  ('regression implicit-usd 2', ('10', 'USD', 'EUR', {'EUR': '0.92'}), '9.20'),\n  ('partial repair guard 2',\n   ('5', 'GBP', 'USD',\n    {'EUR': '0.92',\n     'JPY': '151.37',\n     'KRW': '1352.5',\n     'KWD': '0.3071',\n     'GBP': '0.7893',\n     'CLF': '0.02451',\n     'CHF': '0.8801'}),\n   '6.33'),\n  ('control: euro to yen',\n   ('100', 'EUR', 'JPY',\n    {'EUR': '0.92',\n     'JPY': '151.37',\n     'KRW': '1352.5',\n     'KWD': '0.3071',\n     'GBP': '0.7893',\n     'CLF': '0.02451',\n     'CHF': '0.8801'}),\n   '16453'),\n  ('control: usd to dinar',\n   ('100.00', 'USD', 'KWD',\n    {'EUR': '0.92',\n     'JPY': '151.37',\n     'KRW': '1352.5',\n     'KWD': '0.3071',\n     'GBP': '0.7893',\n     'CLF': '0.02451',\n     'CHF': '0.8801'}),\n   '30.710'),\n  ('control: missing target',\n   ('1', 'EUR', 'SEK',\n    {'EUR': '0.92',\n     'JPY': '151.37',\n     'KRW': '1352.5',\n     'KWD': '0.3071',\n     'GBP': '0.7893',\n     'CLF': '0.02451',\n     'CHF': '0.8801'}),\n   'ERR:no-rate:SEK'),\n  ('control: won to franc',\n   ('250000', 'KRW', 'CHF',\n    {'EUR': '0.92',\n     'JPY': '151.37',\n     'KRW': '1352.5',\n     'KWD': '0.3071',\n     'GBP': '0.7893',\n     'CLF': '0.02451',\n     'CHF': '0.8801'}),\n   '162.68')],\n [('regression implicit-usd 1',\n   ('100.00', 'USD', 'KWD',\n    {'EUR': '0.92',\n     'JPY': '151.37',\n     'KRW': '1352.5',\n     'KWD': '0.3071',\n     'GBP': '0.7893',\n     'CLF': '0.02451',\n     'CHF': '0.8801'}),\n   '30.710'),\n  ('regression implicit-usd 2',\n   ('5', 'GBP', 'USD',\n    {'EUR': '0.92',\n     'JPY': '151.37',\n     'KRW': '1352.5',\n     'KWD': '0.3071',\n     'GBP': '0.7893',\n     'CLF': '0.02451',\n     'CHF': '0.8801'}),\n   '6.33'),\n  ('partial repair guard 1',\n   ('63600', 'EUR', 'USD', {'EUR': '0.92', 'JPY': '151.37', 'KRW': '1352.5', 'KWD': '0.3071', 'CLF': '0.02451'}),\n   '69130.43'),\n  ('partial repair guard 2',\n   ('19481.34', 'KWD', 'USD',\n    {'EUR': '0.92',\n     'JPY': '151.37',\n     'KRW': '1352.5',\n     'KWD': '0.3071',\n     'GBP': '0.7893',\n     'CLF': '0.02451',\n     'CHF': '0.8801'}),\n   '63436.47'),\n  ('control: missing target',\n   ('1', 'EUR', 'SEK',\n    {'EUR': '0.92',\n     'JPY': '151.37',\n     'KRW': '1352.5',\n     'KWD': '0.3071',\n     'GBP': '0.7893',\n     'CLF': '0.02451',\n     'CHF': '0.8801'}),\n   'ERR:no-rate:SEK'),\n  ('control: won to franc',\n   ('250000', 'KRW', 'CHF',\n    {'EUR': '0.92',\n     'JPY': '151.37',\n     'KRW': '1352.5',\n     'KWD': '0.3071',\n     'GBP': '0.7893',\n     'CLF': '0.02451',\n     'CHF': '0.8801'}),\n   '162.68'),\n  ('control: yen to unit of account',\n   ('99999', 'JPY', 'CLF',\n    {'EUR': '0.92',\n     'JPY': '151.37',\n     'KRW': '1352.5',\n     'KWD': '0.3071',\n     'GBP': '0.7893',\n     'CLF': '0.02451',\n     'CHF': '0.8801'}),\n   '16.1920'),\n  ('control: zero rate target', ('10', 'EUR', 'CHF', {'EUR': '0.92', 'CHF': '0'}), 'ERR:bad-rate:CHF')],\n [('regression implicit-usd 1',\n   ('63600', 'EUR', 'USD', {'EUR': '0.92', 'JPY': '151.37', 'KRW': '1352.5', 'KWD': '0.3071', 'CLF': '0.02451'}),\n   '69130.43'),\n  ('regression implicit-usd 2',\n   ('19481.34', 'KWD', 'USD',\n    {'EUR': '0.92',\n     'JPY': '151.37',\n     'KRW': '1352.5',\n     'KWD': '0.3071',\n     'GBP': '0.7893',\n     'CLF': '0.02451',\n     'CHF': '0.8801'}),\n   '63436.47'),\n  ('partial repair guard 1',\n   ('31699.892', 'KWD', 'USD',\n    {'EUR': '0.92', 'KRW': '1352.5', 'KWD': '0.3071', 'GBP': '0.7893', 'CLF': '0.02451', 'CHF': '0.8801'}),\n   '103223.35'),\n  ('partial repair guard 2',\n   ('153425', 'GBP', 'USD',\n    {'EUR': '0.92', 'JPY': '151.37', 'KWD': '0.3071', 'GBP': '0.7893', 'CLF': '0.02451', 'CHF': '0.8801'}),\n   '194381.10'),\n  ('control: zero rate target', ('10', 'EUR', 'CHF', {'EUR': '0.92', 'CHF': '0'}), 'ERR:bad-rate:CHF'),\n  ('control: explicit usd rate', ('10', 'USD', 'EUR', {'USD': '1', 'EUR': '0.92'}), '9.20'),\n  ('control: usd absent', ('42.42', 'EUR', 'USD', {'EUR': '0.92'}), '46.11'),\n  ('control: euro to yen',\n   ('100', 'EUR', 'JPY',\n    {'EUR': '0.92',\n     'JPY': '151.37',\n     'KRW': '1352.5',\n     'KWD': '0.3071',\n     'GBP': '0.7893',\n     'CLF': '0.02451',\n     'CHF': '0.8801'}),\n   '16453')],\n [('regression implicit-usd 1',\n   ('31474', 'USD', 'USD',\n    {'EUR': '0.92', 'JPY': '151.37', 'KRW': '1352.5', 'GBP': '0.7893', 'CLF': '0.02451', 'CHF': '0.8801'}),\n   '31474.00'),\n  ('regression implicit-usd 2',\n   ('31699.892', 'KWD', 'USD',\n    {'EUR': '0.92', 'KRW': '1352.5', 'KWD': '0.3071', 'GBP': '0.7893', 'CLF': '0.02451', 'CHF': '0.8801'}),\n   '103223.35'),\n  ('partial repair guard 1',\n   ('121673.94', 'EUR', 'USD', {'EUR': '0.92', 'KRW': '1352.5', 'KWD': '0.3071', 'GBP': '0.7893', 'CLF': '0.02451'}),\n   '132254.28'),\n  ('partial repair guard 2',\n   ('96170', 'JPY', 'USD',\n    {'EUR': '0.92', 'JPY': '151.37', 'KRW': '1352.5', 'KWD': '0.3071', 'GBP': '0.7893', 'CHF': '0.8801'}),\n   '635.33'),\n  ('control: euro to yen',\n   ('100', 'EUR', 'JPY',\n    {'EUR': '0.92',\n     'JPY': '151.37',\n     'KRW': '1352.5',\n     'KWD': '0.3071',\n     'GBP': '0.7893',\n     'CLF': '0.02451',\n     'CHF': '0.8801'}),\n   '16453'),\n  ('control: usd to dinar',\n   ('100.00', 'USD', 'KWD',\n    {'EUR': '0.92',\n     'JPY': '151.37',\n     'KRW': '1352.5',\n     'KWD': '0.3071',\n     'GBP': '0.7893',\n     'CLF': '0.02451',\n     'CHF': '0.8801'}),\n   '30.710'),\n  ('control: pound to usd',\n   ('5', 'GBP', 'USD',\n    {'EUR': '0.92',\n     'JPY': '151.37',\n     'KRW': '1352.5',\n     'KWD': '0.3071',\n     'GBP': '0.7893',\n     'CLF': '0.02451',\n     'CHF': '0.8801'}),\n   '6.33'),\n  ('control: missing target',\n   ('1', 'EUR', 'SEK',\n    {'EUR': '0.92',\n     'JPY': '151.37',\n     'KRW': '1352.5',\n     'KWD': '0.3071',\n     'GBP': '0.7893',\n     'CLF': '0.02451',\n     'CHF': '0.8801'}),\n   'ERR:no-rate:SEK')],\n [('regression implicit-usd 1',\n   ('91201', 'USD', 'USD', {'EUR': '0.92', 'JPY': '151.37', 'KWD': '0.3071', 'GBP': '0.7893', 'CHF': '0.8801'}),\n   '91201.00'),\n  ('regression implicit-usd 2',\n   ('192940.19', 'USD', 'USD', {'EUR': '0.92', 'KWD': '0.3071', 'CLF': '0.02451', 'CHF': '0.8801'}), '192940.19'),\n  ('partial repair guard 1',\n   ('121828.64', 'KRW', 'USD', {'KRW': '1352.5', 'KWD': '0.3071', 'GBP': '0.7893', 'CLF': '0.02451', 'CHF': '0.8801'}),\n   '90.08'),\n  ('partial repair guard 2',\n   ('13490.966', 'KWD', 'USD',\n    {'EUR': '0.92',\n     'JPY': '151.37',\n     'KRW': '1352.5',\n     'KWD': '0.3071',\n     'GBP': '0.7893',\n     'CLF': '0.02451',\n     'CHF': '0.8801'}),\n   '43930.21'),\n  ('control: missing target',\n   ('1', 'EUR', 'SEK',\n    {'EUR': '0.92',\n     'JPY': '151.37',\n     'KRW': '1352.5',\n     'KWD': '0.3071',\n     'GBP': '0.7893',\n     'CLF': '0.02451',\n     'CHF': '0.8801'}),\n   'ERR:no-rate:SEK'),\n  ('control: won to franc',\n   ('250000', 'KRW', 'CHF',\n    {'EUR': '0.92',\n     'JPY': '151.37',\n     'KRW': '1352.5',\n     'KWD': '0.3071',\n     'GBP': '0.7893',\n     'CLF': '0.02451',\n     'CHF': '0.8801'}),\n   '162.68'),\n  ('control: yen to unit of account',\n   ('99999', 'JPY', 'CLF',\n    {'EUR': '0.92',\n     'JPY': '151.37',\n     'KRW': '1352.5',\n     'KWD': '0.3071',\n     'GBP': '0.7893',\n     'CLF': '0.02451',\n     'CHF': '0.8801'}),\n   '16.1920'),\n  ('control: zero rate target', ('10', 'EUR', 'CHF', {'EUR': '0.92', 'CHF': '0'}), 'ERR:bad-rate:CHF')]]\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-usd-pivot-cross-implicit-usd","generated_at":"2026-09-29T14:46:59.388893+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.","repair":"Treat USD as rate 1 whenever the table has no USD entry.","root_cause":"The implicit USD rate of 1 is not applied when USD is absent from the table.","sha256":"cfef5a18b89a3b5062acfc7da5d3f93acc280b97a7a9a984eee8bedaa616e6ea","title":"Conversions involving USD require an explicit USD table entry · case 01","variant":1,"variant_policy":"Five numbered records share a model and may reuse boundary fixtures.","verification":{"attempt":{"elapsed_ms":43.703,"exit_code":1,"observations":[{"actual":"ERR:no-rate:USD","check":"regression implicit-usd 1","expected":"46.11","passed":false},{"actual":"9.20","check":"regression implicit-usd 2","expected":"9.20","passed":true},{"actual":"ERR:no-rate:USD","check":"partial repair guard 2","expected":"6.33","passed":false},{"actual":"16453","check":"control: euro to yen","expected":"16453","passed":true},{"actual":"30.710","check":"control: usd to dinar","expected":"30.710","passed":true},{"actual":"ERR:no-rate:SEK","check":"control: missing target","expected":"ERR:no-rate:SEK","passed":true},{"actual":"162.68","check":"control: won to franc","expected":"162.68","passed":true}],"passed":false,"stderr":"","stdout":"{\"observations\": [{\"check\": \"regression implicit-usd 1\", \"actual\": \"ERR:no-rate:USD\", \"expected\": \"46.11\", \"passed\": false}, {\"check\": \"regression implicit-usd 2\", \"actual\": \"9.20\", \"expected\": \"9.20\", \"passed\": true}, {\"check\": \"partial repair guard 2\", \"actual\": \"ERR:no-rate:USD\", \"expected\": \"6.33\", \"passed\": false}, {\"check\": \"control: euro to yen\", \"actual\": \"16453\", \"expected\": \"16453\", \"passed\": true}, {\"check\": \"control: usd to dinar\", \"actual\": \"30.710\", \"expected\": \"30.710\", \"passed\": true}, {\"check\": \"control: missing target\", \"actual\": \"ERR:no-rate:SEK\", \"expected\": \"ERR:no-rate:SEK\", \"passed\": true}, {\"check\": \"control: won to franc\", \"actual\": \"162.68\", \"expected\": \"162.68\", \"passed\": true}], \"passed\": false}\n"},"broken":{"elapsed_ms":41.874,"exit_code":1,"observations":[{"actual":"ERR:no-rate:USD","check":"regression implicit-usd 1","expected":"46.11","passed":false},{"actual":"ERR:no-rate:USD","check":"regression implicit-usd 2","expected":"9.20","passed":false},{"actual":"ERR:no-rate:USD","check":"partial repair guard 2","expected":"6.33","passed":false},{"actual":"16453","check":"control: euro to yen","expected":"16453","passed":true},{"actual":"ERR:no-rate:USD","check":"control: usd to dinar","expected":"30.710","passed":false},{"actual":"ERR:no-rate:SEK","check":"control: missing target","expected":"ERR:no-rate:SEK","passed":true},{"actual":"162.68","check":"control: won to franc","expected":"162.68","passed":true}],"passed":false,"stderr":"","stdout":"{\"observations\": [{\"check\": \"regression implicit-usd 1\", \"actual\": \"ERR:no-rate:USD\", \"expected\": \"46.11\", \"passed\": false}, {\"check\": \"regression implicit-usd 2\", \"actual\": \"ERR:no-rate:USD\", \"expected\": \"9.20\", \"passed\": false}, {\"check\": \"partial repair guard 2\", \"actual\": \"ERR:no-rate:USD\", \"expected\": \"6.33\", \"passed\": false}, {\"check\": \"control: euro to yen\", \"actual\": \"16453\", \"expected\": \"16453\", \"passed\": true}, {\"check\": \"control: usd to dinar\", \"actual\": \"ERR:no-rate:USD\", \"expected\": \"30.710\", \"passed\": false}, {\"check\": \"control: missing target\", \"actual\": \"ERR:no-rate:SEK\", \"expected\": \"ERR:no-rate:SEK\", \"passed\": true}, {\"check\": \"control: won to franc\", \"actual\": \"162.68\", \"expected\": \"162.68\", \"passed\": true}], \"passed\": false}\n"},"fixed":{"elapsed_ms":42.208,"exit_code":0,"observations":[{"actual":"46.11","check":"regression implicit-usd 1","expected":"46.11","passed":true},{"actual":"9.20","check":"regression implicit-usd 2","expected":"9.20","passed":true},{"actual":"6.33","check":"partial repair guard 2","expected":"6.33","passed":true},{"actual":"16453","check":"control: euro to yen","expected":"16453","passed":true},{"actual":"30.710","check":"control: usd to dinar","expected":"30.710","passed":true},{"actual":"ERR:no-rate:SEK","check":"control: missing target","expected":"ERR:no-rate:SEK","passed":true},{"actual":"162.68","check":"control: won to franc","expected":"162.68","passed":true}],"passed":true,"stderr":"","stdout":"{\"observations\": [{\"check\": \"regression implicit-usd 1\", \"actual\": \"46.11\", \"expected\": \"46.11\", \"passed\": true}, {\"check\": \"regression implicit-usd 2\", \"actual\": \"9.20\", \"expected\": \"9.20\", \"passed\": true}, {\"check\": \"partial repair guard 2\", \"actual\": \"6.33\", \"expected\": \"6.33\", \"passed\": true}, {\"check\": \"control: euro to yen\", \"actual\": \"16453\", \"expected\": \"16453\", \"passed\": true}, {\"check\": \"control: usd to dinar\", \"actual\": \"30.710\", \"expected\": \"30.710\", \"passed\": true}, {\"check\": \"control: missing target\", \"actual\": \"ERR:no-rate:SEK\", \"expected\": \"ERR:no-rate:SEK\", \"passed\": true}, {\"check\": \"control: won to franc\", \"actual\": \"162.68\", \"expected\": \"162.68\", \"passed\": true}], \"passed\": true}\n"}},"verified":true,"visibility":"public"}