FAILURE MAP
← Case archive

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

An inverted incoming quote is compared without inversion · case 01

A USD/EUR print is compared directly with the EUR/USD reference and rejected.

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

ROOT CAUSE

The inverted flag is ignored.

VERIFIED REPAIR

Invert the new rate before comparing when it arrives in the opposite orientation.

Unsuccessful approach: Inverting the reference instead of the new rate changes the denominator of the deviation.

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'
    pass
    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 inverted-quote 1', ('0.5', '2.0', 0, True), 'accept'),
  ('regression inverted-quote 2', ('0.52599504', '1.9023', 10, True), 'accept'),
  ('partial repair guard 1', ('1.20407797', '0.8389', 100, True), 'accept'),
  ('partial repair guard 2', ('0.61344857', '1.6285', 10, True), 'reject'),
  ('control: upper boundary', ('1.1', '1.0', 1000, False), 'accept'),
  ('control: lower boundary', ('0.9', '1.0', 1000, False), 'accept'),
  ('control: drop too far', ('0.8', '1.0', 1000, False), 'reject'),
  ('control: bad ref', ('1.2', '0', 5, False), 'ERR:rate')],
 [('regression inverted-quote 1', ('0.58349261', '1.7075', 50, True), 'accept'),
  ('regression inverted-quote 2', ('1.20407797', '0.8389', 100, True), 'accept'),
  ('partial repair guard 1', ('0.66867939', '1.5030', 50, True), 'accept'),
  ('partial repair guard 2', ('0.93539594', '1.0664', 25, 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 inverted-quote 1', ('0.91004974', '0.9784', 1000, True), 'reject'),
  ('regression inverted-quote 2', ('0.66896926', '1.4874', 50, True), 'accept'),
  ('partial repair guard 1', ('1.00665155', '0.9924', 10, True), 'reject'),
  ('partial repair guard 2', ('0.51145669', '1.9601', 25, True), 'accept'),
  ('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 inverted-quote 1', ('0.79028053', '1.2655', 10, True), 'accept'),
  ('regression inverted-quote 2', ('0.53202622', '1.8710', 100, True), 'accept'),
  ('partial repair guard 1', ('1.41341757', '0.7005', 100, True), 'reject'),
  ('partial repair guard 2', ('0.78742098', '1.2687', 10, True), '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 inverted-quote 1', ('0.66867939', '1.5030', 50, True), 'accept'),
  ('regression inverted-quote 2', ('1.96761890', '0.5057', 50, True), 'accept'),
  ('partial repair guard 1', ('0.78810637', '1.2657', 25, True), 'reject'),
  ('partial repair guard 2', ('0.87256913', '1.1518', 50, 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'),
  ('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 inverted-quote 1rejectacceptFailed
regression inverted-quote 2rejectacceptFailed
partial repair guard 1rejectacceptFailed
partial repair guard 2rejectrejectPassed
control: upper boundaryacceptacceptPassed
control: lower boundaryacceptacceptPassed
control: drop too farrejectrejectPassed
control: bad refERR:rateERR:ratePassed

SHA-256 / 16201b274bc3c8c0458bbec4bb2c71cebd495d55e071403385067786b22ab2cb

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: r = 1 / r
    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 inverted-quote 1', ('0.5', '2.0', 0, True), 'accept'),
  ('regression inverted-quote 2', ('0.52599504', '1.9023', 10, True), 'accept'),
  ('partial repair guard 1', ('1.20407797', '0.8389', 100, True), 'accept'),
  ('partial repair guard 2', ('0.61344857', '1.6285', 10, True), 'reject'),
  ('control: upper boundary', ('1.1', '1.0', 1000, False), 'accept'),
  ('control: lower boundary', ('0.9', '1.0', 1000, False), 'accept'),
  ('control: drop too far', ('0.8', '1.0', 1000, False), 'reject'),
  ('control: bad ref', ('1.2', '0', 5, False), 'ERR:rate')],
 [('regression inverted-quote 1', ('0.58349261', '1.7075', 50, True), 'accept'),
  ('regression inverted-quote 2', ('1.20407797', '0.8389', 100, True), 'accept'),
  ('partial repair guard 1', ('0.66867939', '1.5030', 50, True), 'accept'),
  ('partial repair guard 2', ('0.93539594', '1.0664', 25, 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 inverted-quote 1', ('0.91004974', '0.9784', 1000, True), 'reject'),
  ('regression inverted-quote 2', ('0.66896926', '1.4874', 50, True), 'accept'),
  ('partial repair guard 1', ('1.00665155', '0.9924', 10, True), 'reject'),
  ('partial repair guard 2', ('0.51145669', '1.9601', 25, True), 'accept'),
  ('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 inverted-quote 1', ('0.79028053', '1.2655', 10, True), 'accept'),
  ('regression inverted-quote 2', ('0.53202622', '1.8710', 100, True), 'accept'),
  ('partial repair guard 1', ('1.41341757', '0.7005', 100, True), 'reject'),
  ('partial repair guard 2', ('0.78742098', '1.2687', 10, True), '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 inverted-quote 1', ('0.66867939', '1.5030', 50, True), 'accept'),
  ('regression inverted-quote 2', ('1.96761890', '0.5057', 50, True), 'accept'),
  ('partial repair guard 1', ('0.78810637', '1.2657', 25, True), 'reject'),
  ('partial repair guard 2', ('0.87256913', '1.1518', 50, 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'),
  ('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 inverted-quote 1acceptacceptPassed
regression inverted-quote 2acceptacceptPassed
partial repair guard 1rejectacceptFailed
partial repair guard 2acceptrejectFailed
control: upper boundaryacceptacceptPassed
control: lower boundaryacceptacceptPassed
control: drop too farrejectrejectPassed
control: bad refERR:rateERR:ratePassed

SHA-256 / 1b9187c3546dec83c08be60edeb58a683b712b10a853a0d5d1ba3a1c8346ed48

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 inverted-quote 1', ('0.5', '2.0', 0, True), 'accept'),
  ('regression inverted-quote 2', ('0.52599504', '1.9023', 10, True), 'accept'),
  ('partial repair guard 1', ('1.20407797', '0.8389', 100, True), 'accept'),
  ('partial repair guard 2', ('0.61344857', '1.6285', 10, True), 'reject'),
  ('control: upper boundary', ('1.1', '1.0', 1000, False), 'accept'),
  ('control: lower boundary', ('0.9', '1.0', 1000, False), 'accept'),
  ('control: drop too far', ('0.8', '1.0', 1000, False), 'reject'),
  ('control: bad ref', ('1.2', '0', 5, False), 'ERR:rate')],
 [('regression inverted-quote 1', ('0.58349261', '1.7075', 50, True), 'accept'),
  ('regression inverted-quote 2', ('1.20407797', '0.8389', 100, True), 'accept'),
  ('partial repair guard 1', ('0.66867939', '1.5030', 50, True), 'accept'),
  ('partial repair guard 2', ('0.93539594', '1.0664', 25, 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 inverted-quote 1', ('0.91004974', '0.9784', 1000, True), 'reject'),
  ('regression inverted-quote 2', ('0.66896926', '1.4874', 50, True), 'accept'),
  ('partial repair guard 1', ('1.00665155', '0.9924', 10, True), 'reject'),
  ('partial repair guard 2', ('0.51145669', '1.9601', 25, True), 'accept'),
  ('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 inverted-quote 1', ('0.79028053', '1.2655', 10, True), 'accept'),
  ('regression inverted-quote 2', ('0.53202622', '1.8710', 100, True), 'accept'),
  ('partial repair guard 1', ('1.41341757', '0.7005', 100, True), 'reject'),
  ('partial repair guard 2', ('0.78742098', '1.2687', 10, True), '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 inverted-quote 1', ('0.66867939', '1.5030', 50, True), 'accept'),
  ('regression inverted-quote 2', ('1.96761890', '0.5057', 50, True), 'accept'),
  ('partial repair guard 1', ('0.78810637', '1.2657', 25, True), 'reject'),
  ('partial repair guard 2', ('0.87256913', '1.1518', 50, 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'),
  ('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 inverted-quote 1acceptacceptPassed
regression inverted-quote 2acceptacceptPassed
partial repair guard 1acceptacceptPassed
partial repair guard 2rejectrejectPassed
control: upper boundaryacceptacceptPassed
control: lower boundaryacceptacceptPassed
control: drop too farrejectrejectPassed
control: bad refERR:rateERR:ratePassed

SHA-256 / f0e96484988378b4b54d0d432967f7053d1a10599a8fc0924682fbd9bf88524e

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.655444+00:00.

Case digest / 00fbe61041eca932e312e554f4b82b1a713dc7779c249d0def6159ca94da38ed