FAILURE MAP
← Case archive

FA-62216 / Currency rounding and FX conversion / Open access

The rate deviation is measured relative to the new rate · case 01

A drop exactly at the tolerance is rejected while an equal rise is accepted.

Verified by executionVariant 1 · 8 checks per implementationDownload source bundle ↓JSON ↗

ROOT CAUSE

The relative deviation divides by the new rate instead of the reference.

VERIFIED REPAIR

Divide the absolute difference by the reference rate.

Unsuccessful approach: Dividing by the larger of the two rates makes the band asymmetric in the opposite way.

Case contract

solve(new, ref, tol_bps, inverted): accept a newly published rate if |n - ref| / ref * 10000 <= tol_bps using exact decimals, where n = new, or 1/new when the new quote arrives inverted. A non-positive new or ref returns 'ERR:rate'. Return 'accept' or 'reject'.

Why this case matters

Currency amounts must be rounded at the right stage and in the right unit, or ledgers, quotes and settlements drift by minor units.

1 / The failure

Exit 1
"""Failure Map reference implementation. Python standard library only."""
import json
from decimal import Decimal, ROUND_HALF_EVEN, ROUND_HALF_UP, ROUND_FLOOR, ROUND_CEILING, ROUND_DOWN, ROUND_UP, ROUND_HALF_DOWN
N = 1
observations = []
def solve(new, ref, tol_bps, inverted):
    n, r = Decimal(new), Decimal(ref)
    if r <= 0 or n <= 0: return 'ERR:rate'
    if inverted: n = 1 / n
    dev = abs(n - r) / n
    return 'accept' if dev * 10000 <= tol_bps else 'reject'
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
cases = [[('regression deviation-denominator 1', ('0.9', '1.0', 1000, False), 'accept'),
  ('regression deviation-denominator 2', ('1.610829', '1.6271', 100, False), 'accept'),
  ('partial repair guard 1', ('0.61344857', '1.6285', 10, True), 'reject'),
  ('partial repair guard 2', ('1.87484661', '1.8561', 100, False), 'reject'),
  ('control: upper boundary', ('1.1', '1.0', 1000, False), 'accept'),
  ('control: drop too far', ('0.8', '1.0', 1000, False), 'reject'),
  ('control: inverted exact', ('0.5', '2.0', 0, True), 'accept'),
  ('control: bad ref', ('1.2', '0', 5, False), 'ERR:rate')],
 [('regression deviation-denominator 1', ('1.19829675', '1.2013', 25, False), 'accept'),
  ('regression deviation-denominator 2', ('1.20407797', '0.8389', 100, True), 'accept'),
  ('partial repair guard 1', ('0.93539594', '1.0664', 25, True), 'reject'),
  ('partial repair guard 2', ('1.00665155', '0.9924', 10, True), 'reject'),
  ('control: inverted exact', ('0.5', '2.0', 0, True), 'accept'),
  ('control: bad ref', ('1.2', '0', 5, False), 'ERR:rate'),
  ('control: small move', ('1.08351', '1.0835', 1, False), 'accept'),
  ('control: rise too far', ('1.2', '1.0', 1000, False), 'reject')],
 [('regression deviation-denominator 1', ('0.61344857', '1.6285', 10, True), 'reject'),
  ('regression deviation-denominator 2', ('1.8098883', '1.8117', 10, False), 'accept'),
  ('partial repair guard 1', ('1.41341757', '0.7005', 100, True), 'reject'),
  ('partial repair guard 2', ('0.78742098', '1.2687', 10, True), 'reject'),
  ('control: rise too far', ('1.2', '1.0', 1000, False), 'reject'),
  ('control: inverted far', ('0.9', '1.0', 50, True), 'reject'),
  ('control: upper boundary', ('1.1', '1.0', 1000, False), 'accept'),
  ('control: lower boundary', ('0.9', '1.0', 1000, False), 'accept')],
 [('regression deviation-denominator 1', ('1.093455', '1.1045', 100, False), 'accept'),
  ('regression deviation-denominator 2', ('1.87484661', '1.8561', 100, False), 'reject'),
  ('partial repair guard 1', ('0.78810637', '1.2657', 25, True), 'reject'),
  ('partial repair guard 2', ('1.93703825', '1.7525', 1000, False), 'reject'),
  ('control: lower boundary', ('0.9', '1.0', 1000, False), 'accept'),
  ('control: drop too far', ('0.8', '1.0', 1000, False), 'reject'),
  ('control: inverted exact', ('0.5', '2.0', 0, True), 'accept'),
  ('control: bad ref', ('1.2', '0', 5, False), 'ERR:rate')],
 [('regression deviation-denominator 1', ('0.6260540', '0.6292', 50, False), 'accept'),
  ('regression deviation-denominator 2', ('1.32976725', '1.3331', 25, False), 'accept'),
  ('partial repair guard 1', ('1.36829603', '0.7236', 100, True), 'reject'),
  ('partial repair guard 2', ('0.98224108', '1.0080', 100, True), 'reject'),
  ('control: bad ref', ('1.2', '0', 5, False), 'ERR:rate'),
  ('control: small move', ('1.08351', '1.0835', 1, False), 'accept'),
  ('control: rise too far', ('1.2', '1.0', 1000, False), 'reject'),
  ('control: inverted far', ('0.9', '1.0', 50, True), 'reject')]]
for label, args, expected in cases[N - 1]:
    check(label, solve(*args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)
Boundary fixtureActualExpectedOutcome
regression deviation-denominator 1rejectacceptFailed
regression deviation-denominator 2rejectacceptFailed
partial repair guard 1acceptrejectFailed
partial repair guard 2acceptrejectFailed
control: upper boundaryacceptacceptPassed
control: drop too farrejectrejectPassed
control: inverted exactacceptacceptPassed
control: bad refERR:rateERR:ratePassed

SHA-256 / 9b85c4b9e27ce8061a5f65c8e657a032db9faef7d879e87bcd000317a470130e

2 / The unsuccessful fix

Exit 1
"""Failure Map reference implementation. Python standard library only."""
import json
from decimal import Decimal, ROUND_HALF_EVEN, ROUND_HALF_UP, ROUND_FLOOR, ROUND_CEILING, ROUND_DOWN, ROUND_UP, ROUND_HALF_DOWN
N = 1
observations = []
def solve(new, ref, tol_bps, inverted):
    n, r = Decimal(new), Decimal(ref)
    if r <= 0 or n <= 0: return 'ERR:rate'
    if inverted: n = 1 / n
    dev = abs(n - r) / max(n, r)
    return 'accept' if dev * 10000 <= tol_bps else 'reject'
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
cases = [[('regression deviation-denominator 1', ('0.9', '1.0', 1000, False), 'accept'),
  ('regression deviation-denominator 2', ('1.610829', '1.6271', 100, False), 'accept'),
  ('partial repair guard 1', ('0.61344857', '1.6285', 10, True), 'reject'),
  ('partial repair guard 2', ('1.87484661', '1.8561', 100, False), 'reject'),
  ('control: upper boundary', ('1.1', '1.0', 1000, False), 'accept'),
  ('control: drop too far', ('0.8', '1.0', 1000, False), 'reject'),
  ('control: inverted exact', ('0.5', '2.0', 0, True), 'accept'),
  ('control: bad ref', ('1.2', '0', 5, False), 'ERR:rate')],
 [('regression deviation-denominator 1', ('1.19829675', '1.2013', 25, False), 'accept'),
  ('regression deviation-denominator 2', ('1.20407797', '0.8389', 100, True), 'accept'),
  ('partial repair guard 1', ('0.93539594', '1.0664', 25, True), 'reject'),
  ('partial repair guard 2', ('1.00665155', '0.9924', 10, True), 'reject'),
  ('control: inverted exact', ('0.5', '2.0', 0, True), 'accept'),
  ('control: bad ref', ('1.2', '0', 5, False), 'ERR:rate'),
  ('control: small move', ('1.08351', '1.0835', 1, False), 'accept'),
  ('control: rise too far', ('1.2', '1.0', 1000, False), 'reject')],
 [('regression deviation-denominator 1', ('0.61344857', '1.6285', 10, True), 'reject'),
  ('regression deviation-denominator 2', ('1.8098883', '1.8117', 10, False), 'accept'),
  ('partial repair guard 1', ('1.41341757', '0.7005', 100, True), 'reject'),
  ('partial repair guard 2', ('0.78742098', '1.2687', 10, True), 'reject'),
  ('control: rise too far', ('1.2', '1.0', 1000, False), 'reject'),
  ('control: inverted far', ('0.9', '1.0', 50, True), 'reject'),
  ('control: upper boundary', ('1.1', '1.0', 1000, False), 'accept'),
  ('control: lower boundary', ('0.9', '1.0', 1000, False), 'accept')],
 [('regression deviation-denominator 1', ('1.093455', '1.1045', 100, False), 'accept'),
  ('regression deviation-denominator 2', ('1.87484661', '1.8561', 100, False), 'reject'),
  ('partial repair guard 1', ('0.78810637', '1.2657', 25, True), 'reject'),
  ('partial repair guard 2', ('1.93703825', '1.7525', 1000, False), 'reject'),
  ('control: lower boundary', ('0.9', '1.0', 1000, False), 'accept'),
  ('control: drop too far', ('0.8', '1.0', 1000, False), 'reject'),
  ('control: inverted exact', ('0.5', '2.0', 0, True), 'accept'),
  ('control: bad ref', ('1.2', '0', 5, False), 'ERR:rate')],
 [('regression deviation-denominator 1', ('0.6260540', '0.6292', 50, False), 'accept'),
  ('regression deviation-denominator 2', ('1.32976725', '1.3331', 25, False), 'accept'),
  ('partial repair guard 1', ('1.36829603', '0.7236', 100, True), 'reject'),
  ('partial repair guard 2', ('0.98224108', '1.0080', 100, True), 'reject'),
  ('control: bad ref', ('1.2', '0', 5, False), 'ERR:rate'),
  ('control: small move', ('1.08351', '1.0835', 1, False), 'accept'),
  ('control: rise too far', ('1.2', '1.0', 1000, False), 'reject'),
  ('control: inverted far', ('0.9', '1.0', 50, True), 'reject')]]
for label, args, expected in cases[N - 1]:
    check(label, solve(*args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)
Boundary fixtureActualExpectedOutcome
regression deviation-denominator 1acceptacceptPassed
regression deviation-denominator 2acceptacceptPassed
partial repair guard 1acceptrejectFailed
partial repair guard 2acceptrejectFailed
control: upper boundaryacceptacceptPassed
control: drop too farrejectrejectPassed
control: inverted exactacceptacceptPassed
control: bad refERR:rateERR:ratePassed

SHA-256 / 970f39102f36256ae5e03e50399bcb3c8fb742b75fd8e13462b5997f158cf4e1

3 / The verified repair

Exit 0
"""Failure Map reference implementation. Python standard library only."""
import json
from decimal import Decimal, ROUND_HALF_EVEN, ROUND_HALF_UP, ROUND_FLOOR, ROUND_CEILING, ROUND_DOWN, ROUND_UP, ROUND_HALF_DOWN
N = 1
observations = []
def solve(new, ref, tol_bps, inverted):
    n, r = Decimal(new), Decimal(ref)
    if r <= 0 or n <= 0: return 'ERR:rate'
    if inverted: n = 1 / n
    dev = abs(n - r) / r
    return 'accept' if dev * 10000 <= tol_bps else 'reject'
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
cases = [[('regression deviation-denominator 1', ('0.9', '1.0', 1000, False), 'accept'),
  ('regression deviation-denominator 2', ('1.610829', '1.6271', 100, False), 'accept'),
  ('partial repair guard 1', ('0.61344857', '1.6285', 10, True), 'reject'),
  ('partial repair guard 2', ('1.87484661', '1.8561', 100, False), 'reject'),
  ('control: upper boundary', ('1.1', '1.0', 1000, False), 'accept'),
  ('control: drop too far', ('0.8', '1.0', 1000, False), 'reject'),
  ('control: inverted exact', ('0.5', '2.0', 0, True), 'accept'),
  ('control: bad ref', ('1.2', '0', 5, False), 'ERR:rate')],
 [('regression deviation-denominator 1', ('1.19829675', '1.2013', 25, False), 'accept'),
  ('regression deviation-denominator 2', ('1.20407797', '0.8389', 100, True), 'accept'),
  ('partial repair guard 1', ('0.93539594', '1.0664', 25, True), 'reject'),
  ('partial repair guard 2', ('1.00665155', '0.9924', 10, True), 'reject'),
  ('control: inverted exact', ('0.5', '2.0', 0, True), 'accept'),
  ('control: bad ref', ('1.2', '0', 5, False), 'ERR:rate'),
  ('control: small move', ('1.08351', '1.0835', 1, False), 'accept'),
  ('control: rise too far', ('1.2', '1.0', 1000, False), 'reject')],
 [('regression deviation-denominator 1', ('0.61344857', '1.6285', 10, True), 'reject'),
  ('regression deviation-denominator 2', ('1.8098883', '1.8117', 10, False), 'accept'),
  ('partial repair guard 1', ('1.41341757', '0.7005', 100, True), 'reject'),
  ('partial repair guard 2', ('0.78742098', '1.2687', 10, True), 'reject'),
  ('control: rise too far', ('1.2', '1.0', 1000, False), 'reject'),
  ('control: inverted far', ('0.9', '1.0', 50, True), 'reject'),
  ('control: upper boundary', ('1.1', '1.0', 1000, False), 'accept'),
  ('control: lower boundary', ('0.9', '1.0', 1000, False), 'accept')],
 [('regression deviation-denominator 1', ('1.093455', '1.1045', 100, False), 'accept'),
  ('regression deviation-denominator 2', ('1.87484661', '1.8561', 100, False), 'reject'),
  ('partial repair guard 1', ('0.78810637', '1.2657', 25, True), 'reject'),
  ('partial repair guard 2', ('1.93703825', '1.7525', 1000, False), 'reject'),
  ('control: lower boundary', ('0.9', '1.0', 1000, False), 'accept'),
  ('control: drop too far', ('0.8', '1.0', 1000, False), 'reject'),
  ('control: inverted exact', ('0.5', '2.0', 0, True), 'accept'),
  ('control: bad ref', ('1.2', '0', 5, False), 'ERR:rate')],
 [('regression deviation-denominator 1', ('0.6260540', '0.6292', 50, False), 'accept'),
  ('regression deviation-denominator 2', ('1.32976725', '1.3331', 25, False), 'accept'),
  ('partial repair guard 1', ('1.36829603', '0.7236', 100, True), 'reject'),
  ('partial repair guard 2', ('0.98224108', '1.0080', 100, True), 'reject'),
  ('control: bad ref', ('1.2', '0', 5, False), 'ERR:rate'),
  ('control: small move', ('1.08351', '1.0835', 1, False), 'accept'),
  ('control: rise too far', ('1.2', '1.0', 1000, False), 'reject'),
  ('control: inverted far', ('0.9', '1.0', 50, True), 'reject')]]
for label, args, expected in cases[N - 1]:
    check(label, solve(*args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)
Boundary fixtureActualExpectedOutcome
regression deviation-denominator 1acceptacceptPassed
regression deviation-denominator 2acceptacceptPassed
partial repair guard 1rejectrejectPassed
partial repair guard 2rejectrejectPassed
control: upper boundaryacceptacceptPassed
control: drop too farrejectrejectPassed
control: inverted exactacceptacceptPassed
control: bad refERR:rateERR:ratePassed

SHA-256 / f67bff9244d2636b725c31d6d5b16d6ebbd50aec8ea0b11a63fd2a8939196c52

Verification & scope

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.

Observations recorded using Python 3.12.14 at 2026-09-29T14:47:02.611186+00:00.

Case digest / d49f2fcae23f78b2d51ec119db8c41d3a9e526ac1dc3c965478e3deef0607a53