FA-62201 / Currency rounding and FX conversion / Open access
The conversion carry is never reset between days · case 01
A fraction left over from Monday pays out on Tuesday.
ROOT CAUSE
The day-change branch only runs for the first item.
VERIFIED REPAIR
Reset the cumulative total and previous floor whenever the day changes.
Unsuccessful approach: Comparing only the year-month prefix of the day still carries remainders across days in the same month.
Case contract
solve(items, rate): items are [day, amount] with integer source minor units (reversals negative) in posting order; rate is target minor units per source minor unit. Within a day, each posting's converted amount is floor(cumulative_exact) - floor(previous cumulative_exact), so daily converted postings sum to floor of the day's exact converted total. The carry (cumulative total and previous floor) resets whenever the day changes. Return the list of integer converted postings.
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(items, rate):
out, cum, prev_floor, day = [], Decimal(0), 0, None
r = Decimal(rate)
for d, a in items:
if day is None:
day, cum, prev_floor = d, Decimal(0), 0
cum += Decimal(a) * r
f = int(cum.to_integral_value(rounding=ROUND_FLOOR))
out.append(f - prev_floor)
prev_floor = f
return out
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
cases = [[('regression daily-reset 1', ([['2026-03-01', 1], ['2026-03-02', 1], ['2026-03-02', 1]], '0.6'), [0, 0, 1]),
('regression daily-reset 2', ([['d1', 1], ['d2', 1], ['d2', 1]], '0.6'), [0, 0, 1]),
('partial repair guard 2',
([['2026-03-01', -18], ['2026-03-01', 240], ['2026-03-02', -19], ['2026-03-02', 81], ['2026-03-02', 129],
['2026-03-02', 231]],
'0.2472'),
[-5, 59, -5, 20, 32, 57]),
('control: three micro postings', ([['d1', 1], ['d1', 1], ['d1', 1]], '0.4'), [0, 0, 1]),
('control: reversal', ([['d1', 5], ['d1', -3]], '0.5'), [2, -1]),
('control: single large', ([['2026-03-01', 12345]], '0.9215'), [11375]),
('control: month change', ([['2026-03-31', 3], ['2026-04-01', 3]], '0.35'), [1, 1])],
[('regression daily-reset 1',
([['2026-03-01', -18], ['2026-03-01', 240], ['2026-03-02', -19], ['2026-03-02', 81], ['2026-03-02', 129],
['2026-03-02', 231]],
'0.2472'),
[-5, 59, -5, 20, 32, 57]),
('regression daily-reset 2',
([['2026-03-02', 92], ['2026-03-03', 36], ['2026-03-03', -15], ['2026-04-01', 46], ['2026-04-01', 50],
['2026-04-01', 95]],
'4.346'),
[399, 156, -65, 199, 218, 413]),
('partial repair guard 2',
([['2026-03-02', 62], ['2026-03-02', 120], ['2026-03-03', 27], ['2026-03-03', 189]], '0.4750'), [29, 57, 12, 90]),
('control: single large', ([['2026-03-01', 12345]], '0.9215'), [11375]),
('control: month change', ([['2026-03-31', 3], ['2026-04-01', 3]], '0.35'), [1, 1]),
('control: empty', ([], '1.5'), []),
('control: negative first', ([['d1', -1], ['d1', -1], ['d1', 2]], '0.3'), [-1, 0, 1])],
[('regression daily-reset 1',
([['2026-03-02', 62], ['2026-03-02', 120], ['2026-03-03', 27], ['2026-03-03', 189]], '0.4750'), [29, 57, 12, 90]),
('regression daily-reset 2',
([['2026-03-01', -26], ['2026-03-01', 4], ['2026-03-01', -3], ['2026-03-02', 57], ['2026-03-02', 131]], '5.53'),
[-144, 22, -17, 315, 724]),
('partial repair guard 2',
([['2026-03-01', 59], ['2026-03-02', 159], ['2026-03-02', 71], ['2026-03-03', 89]], '26.15'),
[1542, 4157, 1857, 2327]),
('control: negative first', ([['d1', -1], ['d1', -1], ['d1', 2]], '0.3'), [-1, 0, 1]),
('control: three micro postings', ([['d1', 1], ['d1', 1], ['d1', 1]], '0.4'), [0, 0, 1]),
('control: day reset', ([['d1', 1], ['d2', 1], ['d2', 1]], '0.6'), [0, 0, 1]),
('control: reversal', ([['d1', 5], ['d1', -3]], '0.5'), [2, -1])],
[('regression daily-reset 1',
([['2026-03-01', 59], ['2026-03-02', 159], ['2026-03-02', 71], ['2026-03-03', 89]], '26.15'),
[1542, 4157, 1857, 2327]),
('regression daily-reset 2', ([['2026-03-01', -26], ['2026-03-02', 215]], '27.52'), [-716, 5916]),
('partial repair guard 2',
([['2026-03-02', 39], ['2026-03-02', 262], ['2026-03-02', -11], ['2026-03-03', 235], ['2026-03-03', -7],
['2026-03-03', 97]],
'4.821'),
[188, 1263, -53, 1132, -33, 467]),
('control: reversal', ([['d1', 5], ['d1', -3]], '0.5'), [2, -1]),
('control: single large', ([['2026-03-01', 12345]], '0.9215'), [11375]),
('control: month change', ([['2026-03-31', 3], ['2026-04-01', 3]], '0.35'), [1, 1]),
('control: empty', ([], '1.5'), [])],
[('regression daily-reset 1',
([['2026-03-02', 39], ['2026-03-02', 262], ['2026-03-02', -11], ['2026-03-03', 235], ['2026-03-03', -7],
['2026-03-03', 97]],
'4.821'),
[188, 1263, -53, 1132, -33, 467]),
('regression daily-reset 2',
([['2026-03-01', 42], ['2026-03-02', 162], ['2026-03-02', 1], ['2026-03-02', 28], ['2026-03-03', 127],
['2026-03-03', -4]],
'0.0325'),
[1, 5, 0, 1, 4, -1]),
('partial repair guard 2', ([['2026-03-01', 296], ['2026-03-02', 52]], '2.581'), [763, 134]),
('control: empty', ([], '1.5'), []),
('control: negative first', ([['d1', -1], ['d1', -1], ['d1', 2]], '0.3'), [-1, 0, 1]),
('control: three micro postings', ([['d1', 1], ['d1', 1], ['d1', 1]], '0.4'), [0, 0, 1]),
('control: day reset', ([['d1', 1], ['d2', 1], ['d2', 1]], '0.6'), [0, 0, 1])]]
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 fixture | Actual | Expected | Outcome |
|---|---|---|---|
| regression daily-reset 1 | [0, 1, 0] | [0, 0, 1] | Failed |
| regression daily-reset 2 | [0, 1, 0] | [0, 0, 1] | Failed |
| partial repair guard 2 | [-5, 59, -4, 20, 32, 57] | [-5, 59, -5, 20, 32, 57] | Failed |
| control: three micro postings | [0, 0, 1] | [0, 0, 1] | Passed |
| control: reversal | [2, -1] | [2, -1] | Passed |
| control: single large | [11375] | [11375] | Passed |
| control: month change | [1, 1] | [1, 1] | Passed |
SHA-256 / c0d33e349d332dc1d3536c3ef2acce2de99665b7a1cb0cfee301e52f6f691dda
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(items, rate):
out, cum, prev_floor, day = [], Decimal(0), 0, None
r = Decimal(rate)
for d, a in items:
if day is None or d[:7] != day[:7]:
day, cum, prev_floor = d, Decimal(0), 0
cum += Decimal(a) * r
f = int(cum.to_integral_value(rounding=ROUND_FLOOR))
out.append(f - prev_floor)
prev_floor = f
return out
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
cases = [[('regression daily-reset 1', ([['2026-03-01', 1], ['2026-03-02', 1], ['2026-03-02', 1]], '0.6'), [0, 0, 1]),
('regression daily-reset 2', ([['d1', 1], ['d2', 1], ['d2', 1]], '0.6'), [0, 0, 1]),
('partial repair guard 2',
([['2026-03-01', -18], ['2026-03-01', 240], ['2026-03-02', -19], ['2026-03-02', 81], ['2026-03-02', 129],
['2026-03-02', 231]],
'0.2472'),
[-5, 59, -5, 20, 32, 57]),
('control: three micro postings', ([['d1', 1], ['d1', 1], ['d1', 1]], '0.4'), [0, 0, 1]),
('control: reversal', ([['d1', 5], ['d1', -3]], '0.5'), [2, -1]),
('control: single large', ([['2026-03-01', 12345]], '0.9215'), [11375]),
('control: month change', ([['2026-03-31', 3], ['2026-04-01', 3]], '0.35'), [1, 1])],
[('regression daily-reset 1',
([['2026-03-01', -18], ['2026-03-01', 240], ['2026-03-02', -19], ['2026-03-02', 81], ['2026-03-02', 129],
['2026-03-02', 231]],
'0.2472'),
[-5, 59, -5, 20, 32, 57]),
('regression daily-reset 2',
([['2026-03-02', 92], ['2026-03-03', 36], ['2026-03-03', -15], ['2026-04-01', 46], ['2026-04-01', 50],
['2026-04-01', 95]],
'4.346'),
[399, 156, -65, 199, 218, 413]),
('partial repair guard 2',
([['2026-03-02', 62], ['2026-03-02', 120], ['2026-03-03', 27], ['2026-03-03', 189]], '0.4750'), [29, 57, 12, 90]),
('control: single large', ([['2026-03-01', 12345]], '0.9215'), [11375]),
('control: month change', ([['2026-03-31', 3], ['2026-04-01', 3]], '0.35'), [1, 1]),
('control: empty', ([], '1.5'), []),
('control: negative first', ([['d1', -1], ['d1', -1], ['d1', 2]], '0.3'), [-1, 0, 1])],
[('regression daily-reset 1',
([['2026-03-02', 62], ['2026-03-02', 120], ['2026-03-03', 27], ['2026-03-03', 189]], '0.4750'), [29, 57, 12, 90]),
('regression daily-reset 2',
([['2026-03-01', -26], ['2026-03-01', 4], ['2026-03-01', -3], ['2026-03-02', 57], ['2026-03-02', 131]], '5.53'),
[-144, 22, -17, 315, 724]),
('partial repair guard 2',
([['2026-03-01', 59], ['2026-03-02', 159], ['2026-03-02', 71], ['2026-03-03', 89]], '26.15'),
[1542, 4157, 1857, 2327]),
('control: negative first', ([['d1', -1], ['d1', -1], ['d1', 2]], '0.3'), [-1, 0, 1]),
('control: three micro postings', ([['d1', 1], ['d1', 1], ['d1', 1]], '0.4'), [0, 0, 1]),
('control: day reset', ([['d1', 1], ['d2', 1], ['d2', 1]], '0.6'), [0, 0, 1]),
('control: reversal', ([['d1', 5], ['d1', -3]], '0.5'), [2, -1])],
[('regression daily-reset 1',
([['2026-03-01', 59], ['2026-03-02', 159], ['2026-03-02', 71], ['2026-03-03', 89]], '26.15'),
[1542, 4157, 1857, 2327]),
('regression daily-reset 2', ([['2026-03-01', -26], ['2026-03-02', 215]], '27.52'), [-716, 5916]),
('partial repair guard 2',
([['2026-03-02', 39], ['2026-03-02', 262], ['2026-03-02', -11], ['2026-03-03', 235], ['2026-03-03', -7],
['2026-03-03', 97]],
'4.821'),
[188, 1263, -53, 1132, -33, 467]),
('control: reversal', ([['d1', 5], ['d1', -3]], '0.5'), [2, -1]),
('control: single large', ([['2026-03-01', 12345]], '0.9215'), [11375]),
('control: month change', ([['2026-03-31', 3], ['2026-04-01', 3]], '0.35'), [1, 1]),
('control: empty', ([], '1.5'), [])],
[('regression daily-reset 1',
([['2026-03-02', 39], ['2026-03-02', 262], ['2026-03-02', -11], ['2026-03-03', 235], ['2026-03-03', -7],
['2026-03-03', 97]],
'4.821'),
[188, 1263, -53, 1132, -33, 467]),
('regression daily-reset 2',
([['2026-03-01', 42], ['2026-03-02', 162], ['2026-03-02', 1], ['2026-03-02', 28], ['2026-03-03', 127],
['2026-03-03', -4]],
'0.0325'),
[1, 5, 0, 1, 4, -1]),
('partial repair guard 2', ([['2026-03-01', 296], ['2026-03-02', 52]], '2.581'), [763, 134]),
('control: empty', ([], '1.5'), []),
('control: negative first', ([['d1', -1], ['d1', -1], ['d1', 2]], '0.3'), [-1, 0, 1]),
('control: three micro postings', ([['d1', 1], ['d1', 1], ['d1', 1]], '0.4'), [0, 0, 1]),
('control: day reset', ([['d1', 1], ['d2', 1], ['d2', 1]], '0.6'), [0, 0, 1])]]
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 fixture | Actual | Expected | Outcome |
|---|---|---|---|
| regression daily-reset 1 | [0, 1, 0] | [0, 0, 1] | Failed |
| regression daily-reset 2 | [0, 0, 1] | [0, 0, 1] | Passed |
| partial repair guard 2 | [-5, 59, -4, 20, 32, 57] | [-5, 59, -5, 20, 32, 57] | Failed |
| control: three micro postings | [0, 0, 1] | [0, 0, 1] | Passed |
| control: reversal | [2, -1] | [2, -1] | Passed |
| control: single large | [11375] | [11375] | Passed |
| control: month change | [1, 1] | [1, 1] | Passed |
SHA-256 / f438cdc7a01f3d750663a455e07ddbe7c3741416309df8d20a7f1513da997a53
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(items, rate):
out, cum, prev_floor, day = [], Decimal(0), 0, None
r = Decimal(rate)
for d, a in items:
if d != day:
day, cum, prev_floor = d, Decimal(0), 0
cum += Decimal(a) * r
f = int(cum.to_integral_value(rounding=ROUND_FLOOR))
out.append(f - prev_floor)
prev_floor = f
return out
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
cases = [[('regression daily-reset 1', ([['2026-03-01', 1], ['2026-03-02', 1], ['2026-03-02', 1]], '0.6'), [0, 0, 1]),
('regression daily-reset 2', ([['d1', 1], ['d2', 1], ['d2', 1]], '0.6'), [0, 0, 1]),
('partial repair guard 2',
([['2026-03-01', -18], ['2026-03-01', 240], ['2026-03-02', -19], ['2026-03-02', 81], ['2026-03-02', 129],
['2026-03-02', 231]],
'0.2472'),
[-5, 59, -5, 20, 32, 57]),
('control: three micro postings', ([['d1', 1], ['d1', 1], ['d1', 1]], '0.4'), [0, 0, 1]),
('control: reversal', ([['d1', 5], ['d1', -3]], '0.5'), [2, -1]),
('control: single large', ([['2026-03-01', 12345]], '0.9215'), [11375]),
('control: month change', ([['2026-03-31', 3], ['2026-04-01', 3]], '0.35'), [1, 1])],
[('regression daily-reset 1',
([['2026-03-01', -18], ['2026-03-01', 240], ['2026-03-02', -19], ['2026-03-02', 81], ['2026-03-02', 129],
['2026-03-02', 231]],
'0.2472'),
[-5, 59, -5, 20, 32, 57]),
('regression daily-reset 2',
([['2026-03-02', 92], ['2026-03-03', 36], ['2026-03-03', -15], ['2026-04-01', 46], ['2026-04-01', 50],
['2026-04-01', 95]],
'4.346'),
[399, 156, -65, 199, 218, 413]),
('partial repair guard 2',
([['2026-03-02', 62], ['2026-03-02', 120], ['2026-03-03', 27], ['2026-03-03', 189]], '0.4750'), [29, 57, 12, 90]),
('control: single large', ([['2026-03-01', 12345]], '0.9215'), [11375]),
('control: month change', ([['2026-03-31', 3], ['2026-04-01', 3]], '0.35'), [1, 1]),
('control: empty', ([], '1.5'), []),
('control: negative first', ([['d1', -1], ['d1', -1], ['d1', 2]], '0.3'), [-1, 0, 1])],
[('regression daily-reset 1',
([['2026-03-02', 62], ['2026-03-02', 120], ['2026-03-03', 27], ['2026-03-03', 189]], '0.4750'), [29, 57, 12, 90]),
('regression daily-reset 2',
([['2026-03-01', -26], ['2026-03-01', 4], ['2026-03-01', -3], ['2026-03-02', 57], ['2026-03-02', 131]], '5.53'),
[-144, 22, -17, 315, 724]),
('partial repair guard 2',
([['2026-03-01', 59], ['2026-03-02', 159], ['2026-03-02', 71], ['2026-03-03', 89]], '26.15'),
[1542, 4157, 1857, 2327]),
('control: negative first', ([['d1', -1], ['d1', -1], ['d1', 2]], '0.3'), [-1, 0, 1]),
('control: three micro postings', ([['d1', 1], ['d1', 1], ['d1', 1]], '0.4'), [0, 0, 1]),
('control: day reset', ([['d1', 1], ['d2', 1], ['d2', 1]], '0.6'), [0, 0, 1]),
('control: reversal', ([['d1', 5], ['d1', -3]], '0.5'), [2, -1])],
[('regression daily-reset 1',
([['2026-03-01', 59], ['2026-03-02', 159], ['2026-03-02', 71], ['2026-03-03', 89]], '26.15'),
[1542, 4157, 1857, 2327]),
('regression daily-reset 2', ([['2026-03-01', -26], ['2026-03-02', 215]], '27.52'), [-716, 5916]),
('partial repair guard 2',
([['2026-03-02', 39], ['2026-03-02', 262], ['2026-03-02', -11], ['2026-03-03', 235], ['2026-03-03', -7],
['2026-03-03', 97]],
'4.821'),
[188, 1263, -53, 1132, -33, 467]),
('control: reversal', ([['d1', 5], ['d1', -3]], '0.5'), [2, -1]),
('control: single large', ([['2026-03-01', 12345]], '0.9215'), [11375]),
('control: month change', ([['2026-03-31', 3], ['2026-04-01', 3]], '0.35'), [1, 1]),
('control: empty', ([], '1.5'), [])],
[('regression daily-reset 1',
([['2026-03-02', 39], ['2026-03-02', 262], ['2026-03-02', -11], ['2026-03-03', 235], ['2026-03-03', -7],
['2026-03-03', 97]],
'4.821'),
[188, 1263, -53, 1132, -33, 467]),
('regression daily-reset 2',
([['2026-03-01', 42], ['2026-03-02', 162], ['2026-03-02', 1], ['2026-03-02', 28], ['2026-03-03', 127],
['2026-03-03', -4]],
'0.0325'),
[1, 5, 0, 1, 4, -1]),
('partial repair guard 2', ([['2026-03-01', 296], ['2026-03-02', 52]], '2.581'), [763, 134]),
('control: empty', ([], '1.5'), []),
('control: negative first', ([['d1', -1], ['d1', -1], ['d1', 2]], '0.3'), [-1, 0, 1]),
('control: three micro postings', ([['d1', 1], ['d1', 1], ['d1', 1]], '0.4'), [0, 0, 1]),
('control: day reset', ([['d1', 1], ['d2', 1], ['d2', 1]], '0.6'), [0, 0, 1])]]
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 fixture | Actual | Expected | Outcome |
|---|---|---|---|
| regression daily-reset 1 | [0, 0, 1] | [0, 0, 1] | Passed |
| regression daily-reset 2 | [0, 0, 1] | [0, 0, 1] | Passed |
| partial repair guard 2 | [-5, 59, -5, 20, 32, 57] | [-5, 59, -5, 20, 32, 57] | Passed |
| control: three micro postings | [0, 0, 1] | [0, 0, 1] | Passed |
| control: reversal | [2, -1] | [2, -1] | Passed |
| control: single large | [11375] | [11375] | Passed |
| control: month change | [1, 1] | [1, 1] | Passed |
SHA-256 / d6d38102d6e8794941e078b00344ae5bb6cac25010ece390502456a54ace80fc
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.389876+00:00.
Case digest / 808fbaf36467e70fc098e79537f41729dfb18708c8e97f83be63b3024f62d014