{"abstract":"A 1% fee on 1001 minor units is 10 instead of 11.","category":"Currency rounding and FX conversion","checks":6,"contract":"solve(amount, rate, src_exp, dst_exp, fee_bps, min_fee): amount and min_fee are source minor units, fee_bps a non-negative integer. fee = max(min_fee, ceil(amount*fee_bps/10000)) in source minor units, deducted before conversion. A fee greater than or equal to the amount returns 'ERR:amount-below-fee'; a non-positive amount or negative bps returns 'ERR:input'. The net amount is converted exactly (net * rate * 10**(dst_exp - src_exp)) and rounded half-even. Return [fee, converted].","contract_signature":"amount, rate, src_exp, dst_exp, fee_bps, min_fee","evaluation_group":"w2-currency_rounding_and_fx_conversion-conversion-fee-bps","failed_approach":"Rounding the fee to nearest with float division still under-charges fractions below one half.","family":"w2-currency_rounding_and_fx_conversion-conversion-fee-bps-fee-ceiling","id":"FA-62066","implementations":{"attempt":{"sha256":"d1adb7c550a70856b47e8f24a1fd018080481eea9cbed10214375553b4acea3b","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, rate, src_exp, dst_exp, fee_bps, min_fee):\n    if fee_bps < 0 or amount <= 0: return 'ERR:input'\n    conv = lambda m: Decimal(m) * Decimal(rate) * Decimal(10) ** (dst_exp - src_exp)\n    rq = lambda d: int(d.quantize(Decimal(1), rounding=ROUND_HALF_EVEN))\n    pct = round(amount * fee_bps / 10000)\n    fee = max(min_fee, pct)\n    if fee >= amount: return 'ERR:amount-below-fee'\n    return [fee, rq(conv(amount - fee))]\ndef check(label, actual, expected):\n    observations.append({\"check\": label, \"actual\": actual, \"expected\": expected, \"passed\": actual == expected})\ncases = [[('regression fee-ceiling 1', (1001, '1', 2, 2, 100, 0), [11, 990]),\n  ('regression fee-ceiling 2', (1003, '1', 2, 2, 100, 0), [11, 992]),\n  ('control: yen payout', (10000, '151.37', 2, 0, 150, 50), [150, 14910]),\n  ('control: fee equals amount', (500, '0.9', 2, 2, 10, 500), 'ERR:amount-below-fee'),\n  ('control: minimum fee applies', (20000, '0.3071', 2, 3, 25, 100), [100, 61113]),\n  ('control: zero bps', (777, '1.0833', 2, 2, 0, 0), [0, 842])],\n [('regression fee-ceiling 1', (123456, '0.92', 2, 2, 250, 199), [3087, 110739]),\n  ('regression fee-ceiling 2', (197637, '16116.34', 0, 2, 333, 100), [6582, 307910733870]),\n  ('control: minimum fee applies', (20000, '0.3071', 2, 3, 25, 100), [100, 61113]),\n  ('control: zero bps', (777, '1.0833', 2, 2, 0, 0), [0, 842]),\n  ('control: invalid amount', (0, '1.1', 2, 2, 10, 0), 'ERR:input'),\n  ('control: minimum exceeds amount', (99, '1.2', 2, 2, 5, 150), 'ERR:amount-below-fee')],\n [('regression fee-ceiling 1', (22226, '179.9447', 0, 2, 150, 100), [334, 393934937]),\n  ('regression fee-ceiling 2', (50411, '12342.04', 3, 3, 333, 1), [1679, 601452293]),\n  ('partial repair guard 2', (268603, '16.66106', 2, 0, 150, 50), [4030, 44081]),\n  ('control: invalid amount', (0, '1.1', 2, 2, 10, 0), 'ERR:input'),\n  ('control: minimum exceeds amount', (99, '1.2', 2, 2, 5, 150), 'ERR:amount-below-fee'),\n  ('control: yen payout', (10000, '151.37', 2, 0, 150, 50), [150, 14910]),\n  ('control: fee rounds up', (1001, '1', 2, 2, 100, 0), [11, 990])],\n [('regression fee-ceiling 1', (268603, '16.66106', 2, 0, 150, 50), [4030, 44081]),\n  ('regression fee-ceiling 2', (269350, '9.84392', 0, 3, 333, 0), [8970, 2563159890]),\n  ('partial repair guard 2', (84375, '129.7381', 0, 0, 99, 250), [836, 10838191]),\n  ('control: fee rounds up', (1001, '1', 2, 2, 100, 0), [11, 990]),\n  ('control: fee equals amount', (500, '0.9', 2, 2, 10, 500), 'ERR:amount-below-fee'),\n  ('control: minimum fee applies', (20000, '0.3071', 2, 3, 25, 100), [100, 61113]),\n  ('control: zero bps', (777, '1.0833', 2, 2, 0, 0), [0, 842])],\n [('regression fee-ceiling 1', (84375, '129.7381', 0, 0, 99, 250), [836, 10838191]),\n  ('regression fee-ceiling 2', (90216, '1.62136', 0, 2, 1000, 250), [9022, 13164470]),\n  ('partial repair guard 1', (234309, '91.3439', 3, 3, 333, 100), [7803, 20689941]),\n  ('partial repair guard 2', (462525, '13331.53', 0, 0, 1000, 50), [46253, 5549542656]),\n  ('control: zero bps', (777, '1.0833', 2, 2, 0, 0), [0, 842]),\n  ('control: large percentage fee', (123456, '0.92', 2, 2, 250, 199), [3087, 110739]),\n  ('control: invalid amount', (0, '1.1', 2, 2, 10, 0), 'ERR:input'),\n  ('control: minimum exceeds amount', (99, '1.2', 2, 2, 5, 150), 'ERR:amount-below-fee')]]\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":"43330627406d1d069de6528f0ac2a219675b89b9f4438101d255df3404ee2804","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, rate, src_exp, dst_exp, fee_bps, min_fee):\n    if fee_bps < 0 or amount <= 0: return 'ERR:input'\n    conv = lambda m: Decimal(m) * Decimal(rate) * Decimal(10) ** (dst_exp - src_exp)\n    rq = lambda d: int(d.quantize(Decimal(1), rounding=ROUND_HALF_EVEN))\n    pct = amount * fee_bps // 10000\n    fee = max(min_fee, pct)\n    if fee >= amount: return 'ERR:amount-below-fee'\n    return [fee, rq(conv(amount - fee))]\ndef check(label, actual, expected):\n    observations.append({\"check\": label, \"actual\": actual, \"expected\": expected, \"passed\": actual == expected})\ncases = [[('regression fee-ceiling 1', (1001, '1', 2, 2, 100, 0), [11, 990]),\n  ('regression fee-ceiling 2', (1003, '1', 2, 2, 100, 0), [11, 992]),\n  ('control: yen payout', (10000, '151.37', 2, 0, 150, 50), [150, 14910]),\n  ('control: fee equals amount', (500, '0.9', 2, 2, 10, 500), 'ERR:amount-below-fee'),\n  ('control: minimum fee applies', (20000, '0.3071', 2, 3, 25, 100), [100, 61113]),\n  ('control: zero bps', (777, '1.0833', 2, 2, 0, 0), [0, 842])],\n [('regression fee-ceiling 1', (123456, '0.92', 2, 2, 250, 199), [3087, 110739]),\n  ('regression fee-ceiling 2', (197637, '16116.34', 0, 2, 333, 100), [6582, 307910733870]),\n  ('control: minimum fee applies', (20000, '0.3071', 2, 3, 25, 100), [100, 61113]),\n  ('control: zero bps', (777, '1.0833', 2, 2, 0, 0), [0, 842]),\n  ('control: invalid amount', (0, '1.1', 2, 2, 10, 0), 'ERR:input'),\n  ('control: minimum exceeds amount', (99, '1.2', 2, 2, 5, 150), 'ERR:amount-below-fee')],\n [('regression fee-ceiling 1', (22226, '179.9447', 0, 2, 150, 100), [334, 393934937]),\n  ('regression fee-ceiling 2', (50411, '12342.04', 3, 3, 333, 1), [1679, 601452293]),\n  ('partial repair guard 2', (268603, '16.66106', 2, 0, 150, 50), [4030, 44081]),\n  ('control: invalid amount', (0, '1.1', 2, 2, 10, 0), 'ERR:input'),\n  ('control: minimum exceeds amount', (99, '1.2', 2, 2, 5, 150), 'ERR:amount-below-fee'),\n  ('control: yen payout', (10000, '151.37', 2, 0, 150, 50), [150, 14910]),\n  ('control: fee rounds up', (1001, '1', 2, 2, 100, 0), [11, 990])],\n [('regression fee-ceiling 1', (268603, '16.66106', 2, 0, 150, 50), [4030, 44081]),\n  ('regression fee-ceiling 2', (269350, '9.84392', 0, 3, 333, 0), [8970, 2563159890]),\n  ('partial repair guard 2', (84375, '129.7381', 0, 0, 99, 250), [836, 10838191]),\n  ('control: fee rounds up', (1001, '1', 2, 2, 100, 0), [11, 990]),\n  ('control: fee equals amount', (500, '0.9', 2, 2, 10, 500), 'ERR:amount-below-fee'),\n  ('control: minimum fee applies', (20000, '0.3071', 2, 3, 25, 100), [100, 61113]),\n  ('control: zero bps', (777, '1.0833', 2, 2, 0, 0), [0, 842])],\n [('regression fee-ceiling 1', (84375, '129.7381', 0, 0, 99, 250), [836, 10838191]),\n  ('regression fee-ceiling 2', (90216, '1.62136', 0, 2, 1000, 250), [9022, 13164470]),\n  ('partial repair guard 1', (234309, '91.3439', 3, 3, 333, 100), [7803, 20689941]),\n  ('partial repair guard 2', (462525, '13331.53', 0, 0, 1000, 50), [46253, 5549542656]),\n  ('control: zero bps', (777, '1.0833', 2, 2, 0, 0), [0, 842]),\n  ('control: large percentage fee', (123456, '0.92', 2, 2, 250, 199), [3087, 110739]),\n  ('control: invalid amount', (0, '1.1', 2, 2, 10, 0), 'ERR:input'),\n  ('control: minimum exceeds amount', (99, '1.2', 2, 2, 5, 150), 'ERR:amount-below-fee')]]\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-conversion-fee-bps-fee-ceiling","generated_at":"2026-09-29T14:47:01.127071+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":"Integer division amount*bps//10000 truncates the fee.","sha256":"3ce81392c642850b9fc5d1bda7a7897a2c7bcf9fe74fc0824d72476d3497ddcb","title":"The percentage fee is floored instead of rounded up · 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":41.739,"exit_code":1,"observations":[{"actual":[10,991],"check":"regression fee-ceiling 1","expected":[11,990],"passed":false},{"actual":[10,993],"check":"regression fee-ceiling 2","expected":[11,992],"passed":false},{"actual":[150,14910],"check":"control: yen payout","expected":[150,14910],"passed":true},{"actual":"ERR:amount-below-fee","check":"control: fee equals amount","expected":"ERR:amount-below-fee","passed":true},{"actual":[100,61113],"check":"control: minimum fee applies","expected":[100,61113],"passed":true},{"actual":[0,842],"check":"control: zero bps","expected":[0,842],"passed":true}],"passed":false,"stderr":"","stdout":"{\"observations\": [{\"check\": \"regression fee-ceiling 1\", \"actual\": [10, 991], \"expected\": [11, 990], \"passed\": false}, {\"check\": \"regression fee-ceiling 2\", \"actual\": [10, 993], \"expected\": [11, 992], \"passed\": false}, {\"check\": \"control: yen payout\", \"actual\": [150, 14910], \"expected\": [150, 14910], \"passed\": true}, {\"check\": \"control: fee equals amount\", \"actual\": \"ERR:amount-below-fee\", \"expected\": \"ERR:amount-below-fee\", \"passed\": true}, {\"check\": \"control: minimum fee applies\", \"actual\": [100, 61113], \"expected\": [100, 61113], \"passed\": true}, {\"check\": \"control: zero bps\", \"actual\": [0, 842], \"expected\": [0, 842], \"passed\": true}], \"passed\": false}\n"},"broken":{"elapsed_ms":41.293,"exit_code":1,"observations":[{"actual":[10,991],"check":"regression fee-ceiling 1","expected":[11,990],"passed":false},{"actual":[10,993],"check":"regression fee-ceiling 2","expected":[11,992],"passed":false},{"actual":[150,14910],"check":"control: yen payout","expected":[150,14910],"passed":true},{"actual":"ERR:amount-below-fee","check":"control: fee equals amount","expected":"ERR:amount-below-fee","passed":true},{"actual":[100,61113],"check":"control: minimum fee applies","expected":[100,61113],"passed":true},{"actual":[0,842],"check":"control: zero bps","expected":[0,842],"passed":true}],"passed":false,"stderr":"","stdout":"{\"observations\": [{\"check\": \"regression fee-ceiling 1\", \"actual\": [10, 991], \"expected\": [11, 990], \"passed\": false}, {\"check\": \"regression fee-ceiling 2\", \"actual\": [10, 993], \"expected\": [11, 992], \"passed\": false}, {\"check\": \"control: yen payout\", \"actual\": [150, 14910], \"expected\": [150, 14910], \"passed\": true}, {\"check\": \"control: fee equals amount\", \"actual\": \"ERR:amount-below-fee\", \"expected\": \"ERR:amount-below-fee\", \"passed\": true}, {\"check\": \"control: minimum fee applies\", \"actual\": [100, 61113], \"expected\": [100, 61113], \"passed\": true}, {\"check\": \"control: zero bps\", \"actual\": [0, 842], \"expected\": [0, 842], \"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."}}