{"abstract":"Valid amounts tagged ' usd' are rejected as unknown currencies.","category":"Currency rounding and FX conversion","checks":6,"contract":"solve(amount, ccy): amount is an exact decimal string, ccy an ISO-like code that is trimmed and upper-cased. Minor-unit exponents: USD 2, EUR 2, JPY 0, KRW 0, KWD 3, BHD 3, CLF 4. Round the exact decimal half-even at the currency exponent and return a plain string with exactly that many fraction digits; a zero result is unsigned. Unknown codes return 'ERR:unknown-currency'.","contract_signature":"amount, ccy","evaluation_group":"w2-currency_rounding_and_fx_conversion-minor-unit-quantize","failed_approach":"Upper-casing without trimming still rejects codes that arrive with surrounding spaces.","family":"w2-currency_rounding_and_fx_conversion-minor-unit-quantize-code-normalization","id":"FA-61846","implementations":{"attempt":{"sha256":"fec17b82cc490641e6f51271e5924162c6e8fa8a0918f3711c529d34cce8a596","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, ccy):\n    exps = {'USD': 2, 'EUR': 2, 'JPY': 0, 'KRW': 0, 'KWD': 3, 'BHD': 3, 'CLF': 4}\n    code = ccy.upper()\n    if code not in exps: return 'ERR:unknown-currency'\n    e = exps[code]\n    x = Decimal(amount)\n    q = x.quantize(Decimal(1).scaleb(-e), rounding=ROUND_HALF_EVEN)\n    if q == 0: q = abs(q)\n    return format(q, 'f')\ndef check(label, actual, expected):\n    observations.append({\"check\": label, \"actual\": actual, \"expected\": expected, \"passed\": actual == expected})\ncases = [[('regression code-normalization 1', ('1.005', ' usd'), '1.00'),\n  ('regression code-normalization 2', ('3', 'Jpy '), '3'), ('control: cents tie to even', ('2.665', 'USD'), '2.66'),\n  ('control: yen tie', ('1235.5', 'JPY'), '1236'), ('control: dinar three places', ('10.0005', 'KWD'), '10.000'),\n  ('control: unit of account four places', ('1.23456', 'CLF'), '1.2346')],\n [('regression code-normalization 1', ('12.345', ' eur '), '12.34'),\n  ('regression code-normalization 2', ('-2562.29293', 'usd'), '-2562.29'),\n  ('partial repair guard 2', ('47295.38', ' jpy'), '47295'),\n  ('control: unit of account four places', ('1.23456', 'CLF'), '1.2346'),\n  ('control: negative small', ('-0.004', 'USD'), '0.00'), ('control: integer input', ('7', 'BHD'), '7.000'),\n  ('control: unknown code', ('1.00', 'ABC'), 'ERR:unknown-currency')],\n [('regression code-normalization 1', ('47295.38', ' jpy'), '47295'),\n  ('regression code-normalization 2', ('35094.719', 'usd'), '35094.72'),\n  ('partial repair guard 1', ('10645.65286', 'Kwd '), '10645.653'),\n  ('partial repair guard 2', ('1600.045697', ' jpy'), '1600'), ('control: integer input', ('7', 'BHD'), '7.000'),\n  ('control: unknown code', ('1.00', 'ABC'), 'ERR:unknown-currency'),\n  ('control: large amount', ('123456789.125', 'USD'), '123456789.12'),\n  ('control: negative tie', ('-2.5', 'KRW'), '-2')],\n [('regression code-normalization 1', ('10645.65286', 'Kwd '), '10645.653'),\n  ('regression code-normalization 2', ('1600.045697', ' jpy'), '1600'),\n  ('partial repair guard 1', ('16193.1040', 'Kwd '), '16193.104'),\n  ('partial repair guard 2', ('32233.55636', 'Kwd '), '32233.556'), ('control: negative tie', ('-2.5', 'KRW'), '-2'),\n  ('control: cents tie to even', ('2.665', 'USD'), '2.66'), ('control: yen tie', ('1235.5', 'JPY'), '1236'),\n  ('control: dinar three places', ('10.0005', 'KWD'), '10.000')],\n [('regression code-normalization 1', ('16193.1040', 'Kwd '), '16193.104'),\n  ('regression code-normalization 2', ('32233.55636', 'Kwd '), '32233.556'),\n  ('partial repair guard 1', ('5555.23', ' jpy'), '5555'), ('partial repair guard 2', ('4726.8350', ' jpy'), '4727'),\n  ('control: dinar three places', ('10.0005', 'KWD'), '10.000'),\n  ('control: unit of account four places', ('1.23456', 'CLF'), '1.2346'),\n  ('control: lowercase code', ('12.345', ' eur '), '12.34'), ('control: negative small', ('-0.004', 'USD'), '0.00')]]\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":"294a4940a84f363e4290c9bb85bf9915047fe5e2bfaa4057568803cc4fcde192","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, ccy):\n    exps = {'USD': 2, 'EUR': 2, 'JPY': 0, 'KRW': 0, 'KWD': 3, 'BHD': 3, 'CLF': 4}\n    code = ccy\n    if code not in exps: return 'ERR:unknown-currency'\n    e = exps[code]\n    x = Decimal(amount)\n    q = x.quantize(Decimal(1).scaleb(-e), rounding=ROUND_HALF_EVEN)\n    if q == 0: q = abs(q)\n    return format(q, 'f')\ndef check(label, actual, expected):\n    observations.append({\"check\": label, \"actual\": actual, \"expected\": expected, \"passed\": actual == expected})\ncases = [[('regression code-normalization 1', ('1.005', ' usd'), '1.00'),\n  ('regression code-normalization 2', ('3', 'Jpy '), '3'), ('control: cents tie to even', ('2.665', 'USD'), '2.66'),\n  ('control: yen tie', ('1235.5', 'JPY'), '1236'), ('control: dinar three places', ('10.0005', 'KWD'), '10.000'),\n  ('control: unit of account four places', ('1.23456', 'CLF'), '1.2346')],\n [('regression code-normalization 1', ('12.345', ' eur '), '12.34'),\n  ('regression code-normalization 2', ('-2562.29293', 'usd'), '-2562.29'),\n  ('partial repair guard 2', ('47295.38', ' jpy'), '47295'),\n  ('control: unit of account four places', ('1.23456', 'CLF'), '1.2346'),\n  ('control: negative small', ('-0.004', 'USD'), '0.00'), ('control: integer input', ('7', 'BHD'), '7.000'),\n  ('control: unknown code', ('1.00', 'ABC'), 'ERR:unknown-currency')],\n [('regression code-normalization 1', ('47295.38', ' jpy'), '47295'),\n  ('regression code-normalization 2', ('35094.719', 'usd'), '35094.72'),\n  ('partial repair guard 1', ('10645.65286', 'Kwd '), '10645.653'),\n  ('partial repair guard 2', ('1600.045697', ' jpy'), '1600'), ('control: integer input', ('7', 'BHD'), '7.000'),\n  ('control: unknown code', ('1.00', 'ABC'), 'ERR:unknown-currency'),\n  ('control: large amount', ('123456789.125', 'USD'), '123456789.12'),\n  ('control: negative tie', ('-2.5', 'KRW'), '-2')],\n [('regression code-normalization 1', ('10645.65286', 'Kwd '), '10645.653'),\n  ('regression code-normalization 2', ('1600.045697', ' jpy'), '1600'),\n  ('partial repair guard 1', ('16193.1040', 'Kwd '), '16193.104'),\n  ('partial repair guard 2', ('32233.55636', 'Kwd '), '32233.556'), ('control: negative tie', ('-2.5', 'KRW'), '-2'),\n  ('control: cents tie to even', ('2.665', 'USD'), '2.66'), ('control: yen tie', ('1235.5', 'JPY'), '1236'),\n  ('control: dinar three places', ('10.0005', 'KWD'), '10.000')],\n [('regression code-normalization 1', ('16193.1040', 'Kwd '), '16193.104'),\n  ('regression code-normalization 2', ('32233.55636', 'Kwd '), '32233.556'),\n  ('partial repair guard 1', ('5555.23', ' jpy'), '5555'), ('partial repair guard 2', ('4726.8350', ' jpy'), '4727'),\n  ('control: dinar three places', ('10.0005', 'KWD'), '10.000'),\n  ('control: unit of account four places', ('1.23456', 'CLF'), '1.2346'),\n  ('control: lowercase code', ('12.345', ' eur '), '12.34'), ('control: negative small', ('-0.004', 'USD'), '0.00')]]\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-minor-unit-quantize-code-normalization","generated_at":"2026-09-29T14:46:59.048355+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 currency code is used verbatim instead of being trimmed and upper-cased before lookup.","sha256":"e1c71823090d68ec5e07f86b345f6051aea05ec0a2f02503e777ae6780557aa1","title":"A padded lower-case currency code is treated as unknown · 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":40.297,"exit_code":1,"observations":[{"actual":"ERR:unknown-currency","check":"regression code-normalization 1","expected":"1.00","passed":false},{"actual":"ERR:unknown-currency","check":"regression code-normalization 2","expected":"3","passed":false},{"actual":"2.66","check":"control: cents tie to even","expected":"2.66","passed":true},{"actual":"1236","check":"control: yen tie","expected":"1236","passed":true},{"actual":"10.000","check":"control: dinar three places","expected":"10.000","passed":true},{"actual":"1.2346","check":"control: unit of account four places","expected":"1.2346","passed":true}],"passed":false,"stderr":"","stdout":"{\"observations\": [{\"check\": \"regression code-normalization 1\", \"actual\": \"ERR:unknown-currency\", \"expected\": \"1.00\", \"passed\": false}, {\"check\": \"regression code-normalization 2\", \"actual\": \"ERR:unknown-currency\", \"expected\": \"3\", \"passed\": false}, {\"check\": \"control: cents tie to even\", \"actual\": \"2.66\", \"expected\": \"2.66\", \"passed\": true}, {\"check\": \"control: yen tie\", \"actual\": \"1236\", \"expected\": \"1236\", \"passed\": true}, {\"check\": \"control: dinar three places\", \"actual\": \"10.000\", \"expected\": \"10.000\", \"passed\": true}, {\"check\": \"control: unit of account four places\", \"actual\": \"1.2346\", \"expected\": \"1.2346\", \"passed\": true}], \"passed\": false}\n"},"broken":{"elapsed_ms":41.551,"exit_code":1,"observations":[{"actual":"ERR:unknown-currency","check":"regression code-normalization 1","expected":"1.00","passed":false},{"actual":"ERR:unknown-currency","check":"regression code-normalization 2","expected":"3","passed":false},{"actual":"2.66","check":"control: cents tie to even","expected":"2.66","passed":true},{"actual":"1236","check":"control: yen tie","expected":"1236","passed":true},{"actual":"10.000","check":"control: dinar three places","expected":"10.000","passed":true},{"actual":"1.2346","check":"control: unit of account four places","expected":"1.2346","passed":true}],"passed":false,"stderr":"","stdout":"{\"observations\": [{\"check\": \"regression code-normalization 1\", \"actual\": \"ERR:unknown-currency\", \"expected\": \"1.00\", \"passed\": false}, {\"check\": \"regression code-normalization 2\", \"actual\": \"ERR:unknown-currency\", \"expected\": \"3\", \"passed\": false}, {\"check\": \"control: cents tie to even\", \"actual\": \"2.66\", \"expected\": \"2.66\", \"passed\": true}, {\"check\": \"control: yen tie\", \"actual\": \"1236\", \"expected\": \"1236\", \"passed\": true}, {\"check\": \"control: dinar three places\", \"actual\": \"10.000\", \"expected\": \"10.000\", \"passed\": true}, {\"check\": \"control: unit of account four places\", \"actual\": \"1.2346\", \"expected\": \"1.2346\", \"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."}}