FAILURE MAP
← Case archive

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

A rate exactly at the maximum age is declared stale · case 01

A tick exactly max_age old is rejected.

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

ROOT CAUSE

The stale test uses >= max_age instead of > max_age.

VERIFIED REPAIR

Only ages strictly greater than max_age are stale.

Unsuccessful approach: Measuring age from the newest tick in the feed lets a future tick make an old rate look fresh.

Case contract

solve(ticks, trade_ts, max_age): ticks is the published rate feed [[ts, rate], ...] in publication order. Use the tick with the greatest ts <= trade_ts; among ticks with equal ts the later-published one is a correction and wins. No eligible tick returns 'ERR:no-rate'. If max_age is not None and trade_ts - ts > max_age the rate is 'ERR:stale' (max_age 0 accepts only a same-instant tick). Return [ts, rate].

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(ticks, trade_ts, max_age):
    best = None
    for ts, r in ticks:
        if ts <= trade_ts and (best is None or ts >= best[0]):
            best = [ts, r]
    if best is None: return 'ERR:no-rate'
    if max_age is not None and trade_ts - best[0] >= max_age: return 'ERR:stale'
    return best
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
cases = [[('regression staleness-boundary 1', ([[4, '1.11'], [12, '1.50']], 8, 4), [4, '1.11']),
  ('regression staleness-boundary 2', ([[7, '1.40']], 7, 0), [7, '1.40']),
  ('partial repair guard 1', ([[1, '1.10'], [9, '1.30']], 7, 3), 'ERR:stale'),
  ('partial repair guard 2', ([[1, '1.0708'], [20, '1.0061'], [14, '1.0619'], [11, '1.2351']], 18, 2), 'ERR:stale'),
  ('control: correction wins', ([[1, '1.10'], [5, '1.20'], [5, '1.21'], [9, '1.30']], 7, 3), [5, '1.21']),
  ('control: only future', ([[9, '1.30']], 7, None), 'ERR:no-rate'),
  ('control: unlimited age', ([[0, '1.05']], 20, None), [0, '1.05']),
  ('control: empty feed', ([], 3, 5), 'ERR:no-rate')],
 [('regression staleness-boundary 1',
   ([[16, '1.0577'], [3, '1.1605'], [9, '1.0153'], [16, '1.0347'], [5, '1.1882']], 4, 1), [3, '1.1605']),
  ('regression staleness-boundary 2', ([[10, '1.1254'], [1, '1.0516'], [3, '1.1640']], 2, 1), [1, '1.0516']),
  ('partial repair guard 1',
   ([[14, '1.1444'], [0, '1.1478'], [5, '1.1087'], [5, '1.1978'], [11, '1.2115'], [1, '1.2119']], 7, 0), 'ERR:stale'),
  ('partial repair guard 2', ([[1, '1.1610'], [10, '1.2604']], 3, 1), 'ERR:stale'),
  ('control: same instant zero age', ([[7, '1.40']], 7, 0), [7, '1.40']),
  ('control: unlimited age', ([[0, '1.05']], 20, None), [0, '1.05']),
  ('control: age boundary', ([[4, '1.11'], [12, '1.50']], 8, 4), [4, '1.11']),
  ('control: empty feed', ([], 3, 5), 'ERR:no-rate')],
 [('regression staleness-boundary 1', ([[1, '1.2376'], [19, '1.2134'], [14, '1.2465']], 1, 0), [1, '1.2376']),
  ('regression staleness-boundary 2', ([[3, '1.2016'], [20, '1.0619'], [10, '1.1904'], [10, '1.1149']], 6, 3),
   [3, '1.2016']),
  ('partial repair guard 1', ([[17, '1.2848'], [2, '1.1228']], 14, 2), 'ERR:stale'),
  ('partial repair guard 2', ([[10, '1.2328'], [1, '1.0928'], [3, '1.1922'], [19, '1.2521'], [19, '1.2864']], 2, 0),
   'ERR:stale'),
  ('control: empty feed', ([], 3, 5), 'ERR:no-rate'),
  ('control: out of order feed', ([[6, '1.26'], [2, '1.22'], [6, '1.19']], 6, 1), [6, '1.19']),
  ('control: correction wins', ([[1, '1.10'], [5, '1.20'], [5, '1.21'], [9, '1.30']], 7, 3), [5, '1.21']),
  ('control: stale', ([[1, '1.10'], [9, '1.30']], 7, 3), 'ERR:stale')],
 [('regression staleness-boundary 1', ([[4, '1.2845'], [1, '1.0456'], [3, '1.1500'], [14, '1.1676']], 17, 3),
   [14, '1.1676']),
  ('regression staleness-boundary 2', ([[14, '1.2739'], [20, '1.2257'], [0, '1.2886']], 16, 2), [14, '1.2739']),
  ('partial repair guard 1', ([[6, '1.0581'], [9, '1.2011'], [16, '1.2956']], 12, 1), 'ERR:stale'),
  ('partial repair guard 2', ([[17, '1.1794'], [15, '1.0788'], [2, '1.2545']], 12, 0), 'ERR:stale'),
  ('control: stale', ([[1, '1.10'], [9, '1.30']], 7, 3), 'ERR:stale'),
  ('control: only future', ([[9, '1.30']], 7, None), 'ERR:no-rate'),
  ('control: same instant zero age', ([[7, '1.40']], 7, 0), [7, '1.40']),
  ('control: unlimited age', ([[0, '1.05']], 20, None), [0, '1.05'])],
 [('regression staleness-boundary 1',
   ([[5, '1.0271'], [11, '1.2757'], [10, '1.0041'], [14, '1.1151'], [2, '1.2167']], 14, 0), [14, '1.1151']),
  ('regression staleness-boundary 2',
   ([[13, '1.1719'], [0, '1.0347'], [20, '1.2239'], [9, '1.1422'], [3, '1.0957']], 1, 1), [0, '1.0347']),
  ('partial repair guard 1',
   ([[1, '1.0230'], [14, '1.0591'], [3, '1.2010'], [13, '1.0135'], [3, '1.1001'], [13, '1.1421']], 12, 3),
   'ERR:stale'),
  ('partial repair guard 2',
   ([[5, '1.0556'], [2, '1.2743'], [17, '1.2317'], [7, '1.0015'], [4, '1.2457'], [7, '1.1125']], 16, 5), 'ERR:stale'),
  ('control: unlimited age', ([[0, '1.05']], 20, None), [0, '1.05']),
  ('control: age boundary', ([[4, '1.11'], [12, '1.50']], 8, 4), [4, '1.11']),
  ('control: empty feed', ([], 3, 5), 'ERR:no-rate'),
  ('control: out of order feed', ([[6, '1.26'], [2, '1.22'], [6, '1.19']], 6, 1), [6, '1.19'])]]
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 staleness-boundary 1ERR:stale[4, '1.11']Failed
regression staleness-boundary 2ERR:stale[7, '1.40']Failed
partial repair guard 1ERR:staleERR:stalePassed
partial repair guard 2ERR:staleERR:stalePassed
control: correction wins[5, '1.21'][5, '1.21']Passed
control: only futureERR:no-rateERR:no-ratePassed
control: unlimited age[0, '1.05'][0, '1.05']Passed
control: empty feedERR:no-rateERR:no-ratePassed

SHA-256 / e687daf2bfab8082dce3bede1ebd9fe7e45ac67f42dba03a9ab61c11bb6629c0

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(ticks, trade_ts, max_age):
    best = None
    for ts, r in ticks:
        if ts <= trade_ts and (best is None or ts >= best[0]):
            best = [ts, r]
    if best is None: return 'ERR:no-rate'
    if max_age is not None and trade_ts - max(t for t, _ in ticks) > max_age: return 'ERR:stale'
    return best
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
cases = [[('regression staleness-boundary 1', ([[4, '1.11'], [12, '1.50']], 8, 4), [4, '1.11']),
  ('regression staleness-boundary 2', ([[7, '1.40']], 7, 0), [7, '1.40']),
  ('partial repair guard 1', ([[1, '1.10'], [9, '1.30']], 7, 3), 'ERR:stale'),
  ('partial repair guard 2', ([[1, '1.0708'], [20, '1.0061'], [14, '1.0619'], [11, '1.2351']], 18, 2), 'ERR:stale'),
  ('control: correction wins', ([[1, '1.10'], [5, '1.20'], [5, '1.21'], [9, '1.30']], 7, 3), [5, '1.21']),
  ('control: only future', ([[9, '1.30']], 7, None), 'ERR:no-rate'),
  ('control: unlimited age', ([[0, '1.05']], 20, None), [0, '1.05']),
  ('control: empty feed', ([], 3, 5), 'ERR:no-rate')],
 [('regression staleness-boundary 1',
   ([[16, '1.0577'], [3, '1.1605'], [9, '1.0153'], [16, '1.0347'], [5, '1.1882']], 4, 1), [3, '1.1605']),
  ('regression staleness-boundary 2', ([[10, '1.1254'], [1, '1.0516'], [3, '1.1640']], 2, 1), [1, '1.0516']),
  ('partial repair guard 1',
   ([[14, '1.1444'], [0, '1.1478'], [5, '1.1087'], [5, '1.1978'], [11, '1.2115'], [1, '1.2119']], 7, 0), 'ERR:stale'),
  ('partial repair guard 2', ([[1, '1.1610'], [10, '1.2604']], 3, 1), 'ERR:stale'),
  ('control: same instant zero age', ([[7, '1.40']], 7, 0), [7, '1.40']),
  ('control: unlimited age', ([[0, '1.05']], 20, None), [0, '1.05']),
  ('control: age boundary', ([[4, '1.11'], [12, '1.50']], 8, 4), [4, '1.11']),
  ('control: empty feed', ([], 3, 5), 'ERR:no-rate')],
 [('regression staleness-boundary 1', ([[1, '1.2376'], [19, '1.2134'], [14, '1.2465']], 1, 0), [1, '1.2376']),
  ('regression staleness-boundary 2', ([[3, '1.2016'], [20, '1.0619'], [10, '1.1904'], [10, '1.1149']], 6, 3),
   [3, '1.2016']),
  ('partial repair guard 1', ([[17, '1.2848'], [2, '1.1228']], 14, 2), 'ERR:stale'),
  ('partial repair guard 2', ([[10, '1.2328'], [1, '1.0928'], [3, '1.1922'], [19, '1.2521'], [19, '1.2864']], 2, 0),
   'ERR:stale'),
  ('control: empty feed', ([], 3, 5), 'ERR:no-rate'),
  ('control: out of order feed', ([[6, '1.26'], [2, '1.22'], [6, '1.19']], 6, 1), [6, '1.19']),
  ('control: correction wins', ([[1, '1.10'], [5, '1.20'], [5, '1.21'], [9, '1.30']], 7, 3), [5, '1.21']),
  ('control: stale', ([[1, '1.10'], [9, '1.30']], 7, 3), 'ERR:stale')],
 [('regression staleness-boundary 1', ([[4, '1.2845'], [1, '1.0456'], [3, '1.1500'], [14, '1.1676']], 17, 3),
   [14, '1.1676']),
  ('regression staleness-boundary 2', ([[14, '1.2739'], [20, '1.2257'], [0, '1.2886']], 16, 2), [14, '1.2739']),
  ('partial repair guard 1', ([[6, '1.0581'], [9, '1.2011'], [16, '1.2956']], 12, 1), 'ERR:stale'),
  ('partial repair guard 2', ([[17, '1.1794'], [15, '1.0788'], [2, '1.2545']], 12, 0), 'ERR:stale'),
  ('control: stale', ([[1, '1.10'], [9, '1.30']], 7, 3), 'ERR:stale'),
  ('control: only future', ([[9, '1.30']], 7, None), 'ERR:no-rate'),
  ('control: same instant zero age', ([[7, '1.40']], 7, 0), [7, '1.40']),
  ('control: unlimited age', ([[0, '1.05']], 20, None), [0, '1.05'])],
 [('regression staleness-boundary 1',
   ([[5, '1.0271'], [11, '1.2757'], [10, '1.0041'], [14, '1.1151'], [2, '1.2167']], 14, 0), [14, '1.1151']),
  ('regression staleness-boundary 2',
   ([[13, '1.1719'], [0, '1.0347'], [20, '1.2239'], [9, '1.1422'], [3, '1.0957']], 1, 1), [0, '1.0347']),
  ('partial repair guard 1',
   ([[1, '1.0230'], [14, '1.0591'], [3, '1.2010'], [13, '1.0135'], [3, '1.1001'], [13, '1.1421']], 12, 3),
   'ERR:stale'),
  ('partial repair guard 2',
   ([[5, '1.0556'], [2, '1.2743'], [17, '1.2317'], [7, '1.0015'], [4, '1.2457'], [7, '1.1125']], 16, 5), 'ERR:stale'),
  ('control: unlimited age', ([[0, '1.05']], 20, None), [0, '1.05']),
  ('control: age boundary', ([[4, '1.11'], [12, '1.50']], 8, 4), [4, '1.11']),
  ('control: empty feed', ([], 3, 5), 'ERR:no-rate'),
  ('control: out of order feed', ([[6, '1.26'], [2, '1.22'], [6, '1.19']], 6, 1), [6, '1.19'])]]
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 staleness-boundary 1[4, '1.11'][4, '1.11']Passed
regression staleness-boundary 2[7, '1.40'][7, '1.40']Passed
partial repair guard 1[1, '1.10']ERR:staleFailed
partial repair guard 2[14, '1.0619']ERR:staleFailed
control: correction wins[5, '1.21'][5, '1.21']Passed
control: only futureERR:no-rateERR:no-ratePassed
control: unlimited age[0, '1.05'][0, '1.05']Passed
control: empty feedERR:no-rateERR:no-ratePassed

SHA-256 / a5e64390154a8fdc38e3e36a8ae676affbf9c69c5c6b67e39377ee7d3d51b74d

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(ticks, trade_ts, max_age):
    best = None
    for ts, r in ticks:
        if ts <= trade_ts and (best is None or ts >= best[0]):
            best = [ts, r]
    if best is None: return 'ERR:no-rate'
    if max_age is not None and trade_ts - best[0] > max_age: return 'ERR:stale'
    return best
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
cases = [[('regression staleness-boundary 1', ([[4, '1.11'], [12, '1.50']], 8, 4), [4, '1.11']),
  ('regression staleness-boundary 2', ([[7, '1.40']], 7, 0), [7, '1.40']),
  ('partial repair guard 1', ([[1, '1.10'], [9, '1.30']], 7, 3), 'ERR:stale'),
  ('partial repair guard 2', ([[1, '1.0708'], [20, '1.0061'], [14, '1.0619'], [11, '1.2351']], 18, 2), 'ERR:stale'),
  ('control: correction wins', ([[1, '1.10'], [5, '1.20'], [5, '1.21'], [9, '1.30']], 7, 3), [5, '1.21']),
  ('control: only future', ([[9, '1.30']], 7, None), 'ERR:no-rate'),
  ('control: unlimited age', ([[0, '1.05']], 20, None), [0, '1.05']),
  ('control: empty feed', ([], 3, 5), 'ERR:no-rate')],
 [('regression staleness-boundary 1',
   ([[16, '1.0577'], [3, '1.1605'], [9, '1.0153'], [16, '1.0347'], [5, '1.1882']], 4, 1), [3, '1.1605']),
  ('regression staleness-boundary 2', ([[10, '1.1254'], [1, '1.0516'], [3, '1.1640']], 2, 1), [1, '1.0516']),
  ('partial repair guard 1',
   ([[14, '1.1444'], [0, '1.1478'], [5, '1.1087'], [5, '1.1978'], [11, '1.2115'], [1, '1.2119']], 7, 0), 'ERR:stale'),
  ('partial repair guard 2', ([[1, '1.1610'], [10, '1.2604']], 3, 1), 'ERR:stale'),
  ('control: same instant zero age', ([[7, '1.40']], 7, 0), [7, '1.40']),
  ('control: unlimited age', ([[0, '1.05']], 20, None), [0, '1.05']),
  ('control: age boundary', ([[4, '1.11'], [12, '1.50']], 8, 4), [4, '1.11']),
  ('control: empty feed', ([], 3, 5), 'ERR:no-rate')],
 [('regression staleness-boundary 1', ([[1, '1.2376'], [19, '1.2134'], [14, '1.2465']], 1, 0), [1, '1.2376']),
  ('regression staleness-boundary 2', ([[3, '1.2016'], [20, '1.0619'], [10, '1.1904'], [10, '1.1149']], 6, 3),
   [3, '1.2016']),
  ('partial repair guard 1', ([[17, '1.2848'], [2, '1.1228']], 14, 2), 'ERR:stale'),
  ('partial repair guard 2', ([[10, '1.2328'], [1, '1.0928'], [3, '1.1922'], [19, '1.2521'], [19, '1.2864']], 2, 0),
   'ERR:stale'),
  ('control: empty feed', ([], 3, 5), 'ERR:no-rate'),
  ('control: out of order feed', ([[6, '1.26'], [2, '1.22'], [6, '1.19']], 6, 1), [6, '1.19']),
  ('control: correction wins', ([[1, '1.10'], [5, '1.20'], [5, '1.21'], [9, '1.30']], 7, 3), [5, '1.21']),
  ('control: stale', ([[1, '1.10'], [9, '1.30']], 7, 3), 'ERR:stale')],
 [('regression staleness-boundary 1', ([[4, '1.2845'], [1, '1.0456'], [3, '1.1500'], [14, '1.1676']], 17, 3),
   [14, '1.1676']),
  ('regression staleness-boundary 2', ([[14, '1.2739'], [20, '1.2257'], [0, '1.2886']], 16, 2), [14, '1.2739']),
  ('partial repair guard 1', ([[6, '1.0581'], [9, '1.2011'], [16, '1.2956']], 12, 1), 'ERR:stale'),
  ('partial repair guard 2', ([[17, '1.1794'], [15, '1.0788'], [2, '1.2545']], 12, 0), 'ERR:stale'),
  ('control: stale', ([[1, '1.10'], [9, '1.30']], 7, 3), 'ERR:stale'),
  ('control: only future', ([[9, '1.30']], 7, None), 'ERR:no-rate'),
  ('control: same instant zero age', ([[7, '1.40']], 7, 0), [7, '1.40']),
  ('control: unlimited age', ([[0, '1.05']], 20, None), [0, '1.05'])],
 [('regression staleness-boundary 1',
   ([[5, '1.0271'], [11, '1.2757'], [10, '1.0041'], [14, '1.1151'], [2, '1.2167']], 14, 0), [14, '1.1151']),
  ('regression staleness-boundary 2',
   ([[13, '1.1719'], [0, '1.0347'], [20, '1.2239'], [9, '1.1422'], [3, '1.0957']], 1, 1), [0, '1.0347']),
  ('partial repair guard 1',
   ([[1, '1.0230'], [14, '1.0591'], [3, '1.2010'], [13, '1.0135'], [3, '1.1001'], [13, '1.1421']], 12, 3),
   'ERR:stale'),
  ('partial repair guard 2',
   ([[5, '1.0556'], [2, '1.2743'], [17, '1.2317'], [7, '1.0015'], [4, '1.2457'], [7, '1.1125']], 16, 5), 'ERR:stale'),
  ('control: unlimited age', ([[0, '1.05']], 20, None), [0, '1.05']),
  ('control: age boundary', ([[4, '1.11'], [12, '1.50']], 8, 4), [4, '1.11']),
  ('control: empty feed', ([], 3, 5), 'ERR:no-rate'),
  ('control: out of order feed', ([[6, '1.26'], [2, '1.22'], [6, '1.19']], 6, 1), [6, '1.19'])]]
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 staleness-boundary 1[4, '1.11'][4, '1.11']Passed
regression staleness-boundary 2[7, '1.40'][7, '1.40']Passed
partial repair guard 1ERR:staleERR:stalePassed
partial repair guard 2ERR:staleERR:stalePassed
control: correction wins[5, '1.21'][5, '1.21']Passed
control: only futureERR:no-rateERR:no-ratePassed
control: unlimited age[0, '1.05'][0, '1.05']Passed
control: empty feedERR:no-rateERR:no-ratePassed

SHA-256 / 59e6ffee62f75ee0245772caba46dab91e15d22d06d1f9d27176dbb421a347be

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

Case digest / c3fa51f1d48caccd5071c70da4114c00d282669ff8874ea1a851521a71c5796d