FA-60931 / Bond day-count conventions / Open access
Act/Act ISDA year fraction: a reversed interval is silently swapped · case 01
Callers passing dates in the wrong order get a positive fraction instead of an error value.
ROOT CAUSE
The guard swaps the dates instead of reporting the reversed input.
VERIFIED REPAIR
Return "end before start" when the end precedes the start.
Unsuccessful approach: Returning 0.0 hides the reversed input as an empty accrual.
Case contract
Inputs start and end [y,m,d]. If end < start return "end before start". Split the interval at each 1 January; each piece contributes its actual days divided by 366 if the piece lies in a Gregorian leap year, else 365. Sum exactly and return the float rounded to 9 decimals.
Why this case matters
Bond accrual and pricing systems depend on exact day-count arithmetic; a single-day error changes settlement cash.
1 / The failure
Exit 1"""Failure Map reference implementation. Python standard library only."""
import json
import datetime
from fractions import Fraction
N = 1
observations = []
def solve(a, b):
A = datetime.date(*a)
B = datetime.date(*b)
if B < A:
A, B = B, A
def leap(y):
return (y % 4 == 0 and y % 100 != 0) or y % 400 == 0
total = Fraction(0)
cur = A
while cur < B:
nxt = min(B, datetime.date(cur.year + 1, 1, 1))
total += Fraction((nxt - cur).days, 366 if leap(cur.year) else 365)
cur = nxt
return round(float(total), 9)
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['regression reversed interval handling 1', [[2045, 10, 29], [2045, 10, 26]], 'end before start'], ['regression reversed interval handling 2', [[2093, 7, 30], [2093, 6, 25]], 'end before start'], ['partial repair probe 1', [[1925, 1, 13], [1924, 12, 14]], 'end before start'], ['partial repair probe 2', [[1922, 10, 16], [1922, 10, 9]], 'end before start'], ['boundary control 1', [[2024, 3, 1], [2024, 3, 1]], 0.0], ['boundary control 2', [[2024, 1, 1], [2025, 1, 1]], 1.0], ['normal control 1', [[1926, 2, 28], [1927, 1, 25]], 0.906849315], ['normal control 2', [[1960, 4, 12], [1961, 5, 15]], 1.088434763]], [['regression reversed interval handling 1', [[1916, 6, 29], [1916, 6, 19]], 'end before start'], ['regression reversed interval handling 2', [[2060, 7, 28], [2060, 6, 19]], 'end before start'], ['partial repair probe 1', [[2056, 2, 28], [2056, 1, 30]], 'end before start'], ['partial repair probe 2', [[1920, 8, 13], [1920, 7, 14]], 'end before start'], ['boundary control 1', [[2099, 12, 1], [2100, 3, 1]], 0.246575342], ['boundary control 2', [[2023, 12, 31], [2024, 1, 1]], 0.002739726], ['normal control 1', [[2061, 10, 31], [2062, 1, 9]], 0.191780822], ['normal control 2', [[2091, 5, 1], [2094, 3, 23]], 2.893150685]], [['regression reversed interval handling 1', [[2006, 3, 31], [2006, 2, 22]], 'end before start'], ['regression reversed interval handling 2', [[2045, 8, 19], [2045, 7, 31]], 'end before start'], ['partial repair probe 1', [[2006, 12, 29], [2006, 11, 27]], 'end before start'], ['partial repair probe 2', [[1950, 4, 8], [1950, 3, 6]], 'end before start'], ['boundary control 1', [[2024, 3, 1], [2024, 3, 1]], 0.0], ['boundary control 2', [[2023, 12, 31], [2024, 1, 1]], 0.002739726], ['normal control 1', [[2094, 3, 31], [2096, 2, 10]], 1.865454001], ['normal control 2', [[2061, 8, 20], [2067, 4, 16]], 5.654794521]], [['regression reversed interval handling 1', [[2094, 7, 1], [2094, 6, 30]], 'end before start'], ['regression reversed interval handling 2', [[2051, 10, 26], [2051, 9, 25]], 'end before start'], ['partial repair probe 1', [[2036, 10, 28], [2036, 9, 26]], 'end before start'], ['partial repair probe 2', [[1935, 6, 19], [1935, 6, 17]], 'end before start'], ['boundary control 1', [[2023, 12, 31], [2024, 1, 1]], 0.002739726], ['boundary control 2', [[2024, 1, 1], [2025, 1, 1]], 1.0], ['normal control 1', [[1910, 1, 6], [1914, 6, 27]], 4.471232877], ['normal control 2', [[2074, 6, 24], [2074, 7, 3]], 0.024657534]], [['regression reversed interval handling 1', [[2053, 9, 30], [2053, 9, 9]], 'end before start'], ['regression reversed interval handling 2', [[1939, 3, 31], [1939, 3, 29]], 'end before start'], ['partial repair probe 1', [[1939, 10, 1], [1939, 9, 3]], 'end before start'], ['partial repair probe 2', [[2067, 10, 31], [2067, 9, 22]], 'end before start'], ['boundary control 1', [[2024, 3, 1], [2024, 3, 1]], 0.0], ['boundary control 2', [[2023, 7, 1], [2024, 7, 1]], 1.001377349], ['normal control 1', [[1911, 4, 24], [1914, 11, 14]], 3.55890411], ['normal control 2', [[1976, 4, 7], [1977, 1, 18]], 0.78154802]]]
for label, args, expected in fixtures[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 reversed interval handling 1 | 0.008219178 | end before start | Failed |
| regression reversed interval handling 2 | 0.095890411 | end before start | Failed |
| partial repair probe 1 | 0.08205704 | end before start | Failed |
| partial repair probe 2 | 0.019178082 | end before start | Failed |
| boundary control 1 | 0.0 | 0.0 | Passed |
| boundary control 2 | 1.0 | 1.0 | Passed |
| normal control 1 | 0.906849315 | 0.906849315 | Passed |
| normal control 2 | 1.088434763 | 1.088434763 | Passed |
SHA-256 / e1e1126c1c6fa88d0db3e56fcec7a932602ddec661c77d492cbfbabc4d0a678d
2 / The unsuccessful fix
Exit 1"""Failure Map reference implementation. Python standard library only."""
import json
import datetime
from fractions import Fraction
N = 1
observations = []
def solve(a, b):
A = datetime.date(*a)
B = datetime.date(*b)
if B < A:
return 0.0
def leap(y):
return (y % 4 == 0 and y % 100 != 0) or y % 400 == 0
total = Fraction(0)
cur = A
while cur < B:
nxt = min(B, datetime.date(cur.year + 1, 1, 1))
total += Fraction((nxt - cur).days, 366 if leap(cur.year) else 365)
cur = nxt
return round(float(total), 9)
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['regression reversed interval handling 1', [[2045, 10, 29], [2045, 10, 26]], 'end before start'], ['regression reversed interval handling 2', [[2093, 7, 30], [2093, 6, 25]], 'end before start'], ['partial repair probe 1', [[1925, 1, 13], [1924, 12, 14]], 'end before start'], ['partial repair probe 2', [[1922, 10, 16], [1922, 10, 9]], 'end before start'], ['boundary control 1', [[2024, 3, 1], [2024, 3, 1]], 0.0], ['boundary control 2', [[2024, 1, 1], [2025, 1, 1]], 1.0], ['normal control 1', [[1926, 2, 28], [1927, 1, 25]], 0.906849315], ['normal control 2', [[1960, 4, 12], [1961, 5, 15]], 1.088434763]], [['regression reversed interval handling 1', [[1916, 6, 29], [1916, 6, 19]], 'end before start'], ['regression reversed interval handling 2', [[2060, 7, 28], [2060, 6, 19]], 'end before start'], ['partial repair probe 1', [[2056, 2, 28], [2056, 1, 30]], 'end before start'], ['partial repair probe 2', [[1920, 8, 13], [1920, 7, 14]], 'end before start'], ['boundary control 1', [[2099, 12, 1], [2100, 3, 1]], 0.246575342], ['boundary control 2', [[2023, 12, 31], [2024, 1, 1]], 0.002739726], ['normal control 1', [[2061, 10, 31], [2062, 1, 9]], 0.191780822], ['normal control 2', [[2091, 5, 1], [2094, 3, 23]], 2.893150685]], [['regression reversed interval handling 1', [[2006, 3, 31], [2006, 2, 22]], 'end before start'], ['regression reversed interval handling 2', [[2045, 8, 19], [2045, 7, 31]], 'end before start'], ['partial repair probe 1', [[2006, 12, 29], [2006, 11, 27]], 'end before start'], ['partial repair probe 2', [[1950, 4, 8], [1950, 3, 6]], 'end before start'], ['boundary control 1', [[2024, 3, 1], [2024, 3, 1]], 0.0], ['boundary control 2', [[2023, 12, 31], [2024, 1, 1]], 0.002739726], ['normal control 1', [[2094, 3, 31], [2096, 2, 10]], 1.865454001], ['normal control 2', [[2061, 8, 20], [2067, 4, 16]], 5.654794521]], [['regression reversed interval handling 1', [[2094, 7, 1], [2094, 6, 30]], 'end before start'], ['regression reversed interval handling 2', [[2051, 10, 26], [2051, 9, 25]], 'end before start'], ['partial repair probe 1', [[2036, 10, 28], [2036, 9, 26]], 'end before start'], ['partial repair probe 2', [[1935, 6, 19], [1935, 6, 17]], 'end before start'], ['boundary control 1', [[2023, 12, 31], [2024, 1, 1]], 0.002739726], ['boundary control 2', [[2024, 1, 1], [2025, 1, 1]], 1.0], ['normal control 1', [[1910, 1, 6], [1914, 6, 27]], 4.471232877], ['normal control 2', [[2074, 6, 24], [2074, 7, 3]], 0.024657534]], [['regression reversed interval handling 1', [[2053, 9, 30], [2053, 9, 9]], 'end before start'], ['regression reversed interval handling 2', [[1939, 3, 31], [1939, 3, 29]], 'end before start'], ['partial repair probe 1', [[1939, 10, 1], [1939, 9, 3]], 'end before start'], ['partial repair probe 2', [[2067, 10, 31], [2067, 9, 22]], 'end before start'], ['boundary control 1', [[2024, 3, 1], [2024, 3, 1]], 0.0], ['boundary control 2', [[2023, 7, 1], [2024, 7, 1]], 1.001377349], ['normal control 1', [[1911, 4, 24], [1914, 11, 14]], 3.55890411], ['normal control 2', [[1976, 4, 7], [1977, 1, 18]], 0.78154802]]]
for label, args, expected in fixtures[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 reversed interval handling 1 | 0.0 | end before start | Failed |
| regression reversed interval handling 2 | 0.0 | end before start | Failed |
| partial repair probe 1 | 0.0 | end before start | Failed |
| partial repair probe 2 | 0.0 | end before start | Failed |
| boundary control 1 | 0.0 | 0.0 | Passed |
| boundary control 2 | 1.0 | 1.0 | Passed |
| normal control 1 | 0.906849315 | 0.906849315 | Passed |
| normal control 2 | 1.088434763 | 1.088434763 | Passed |
SHA-256 / cad8fc0fef77633805d2c4f0b7c60de28c8cfdb105d82b0fa2e4622ab5c522d0
3 / The verified repair
Exit 0"""Failure Map reference implementation. Python standard library only."""
import json
import datetime
from fractions import Fraction
N = 1
observations = []
def solve(a, b):
A = datetime.date(*a)
B = datetime.date(*b)
if B < A:
return 'end before start'
def leap(y):
return (y % 4 == 0 and y % 100 != 0) or y % 400 == 0
total = Fraction(0)
cur = A
while cur < B:
nxt = min(B, datetime.date(cur.year + 1, 1, 1))
total += Fraction((nxt - cur).days, 366 if leap(cur.year) else 365)
cur = nxt
return round(float(total), 9)
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['regression reversed interval handling 1', [[2045, 10, 29], [2045, 10, 26]], 'end before start'], ['regression reversed interval handling 2', [[2093, 7, 30], [2093, 6, 25]], 'end before start'], ['partial repair probe 1', [[1925, 1, 13], [1924, 12, 14]], 'end before start'], ['partial repair probe 2', [[1922, 10, 16], [1922, 10, 9]], 'end before start'], ['boundary control 1', [[2024, 3, 1], [2024, 3, 1]], 0.0], ['boundary control 2', [[2024, 1, 1], [2025, 1, 1]], 1.0], ['normal control 1', [[1926, 2, 28], [1927, 1, 25]], 0.906849315], ['normal control 2', [[1960, 4, 12], [1961, 5, 15]], 1.088434763]], [['regression reversed interval handling 1', [[1916, 6, 29], [1916, 6, 19]], 'end before start'], ['regression reversed interval handling 2', [[2060, 7, 28], [2060, 6, 19]], 'end before start'], ['partial repair probe 1', [[2056, 2, 28], [2056, 1, 30]], 'end before start'], ['partial repair probe 2', [[1920, 8, 13], [1920, 7, 14]], 'end before start'], ['boundary control 1', [[2099, 12, 1], [2100, 3, 1]], 0.246575342], ['boundary control 2', [[2023, 12, 31], [2024, 1, 1]], 0.002739726], ['normal control 1', [[2061, 10, 31], [2062, 1, 9]], 0.191780822], ['normal control 2', [[2091, 5, 1], [2094, 3, 23]], 2.893150685]], [['regression reversed interval handling 1', [[2006, 3, 31], [2006, 2, 22]], 'end before start'], ['regression reversed interval handling 2', [[2045, 8, 19], [2045, 7, 31]], 'end before start'], ['partial repair probe 1', [[2006, 12, 29], [2006, 11, 27]], 'end before start'], ['partial repair probe 2', [[1950, 4, 8], [1950, 3, 6]], 'end before start'], ['boundary control 1', [[2024, 3, 1], [2024, 3, 1]], 0.0], ['boundary control 2', [[2023, 12, 31], [2024, 1, 1]], 0.002739726], ['normal control 1', [[2094, 3, 31], [2096, 2, 10]], 1.865454001], ['normal control 2', [[2061, 8, 20], [2067, 4, 16]], 5.654794521]], [['regression reversed interval handling 1', [[2094, 7, 1], [2094, 6, 30]], 'end before start'], ['regression reversed interval handling 2', [[2051, 10, 26], [2051, 9, 25]], 'end before start'], ['partial repair probe 1', [[2036, 10, 28], [2036, 9, 26]], 'end before start'], ['partial repair probe 2', [[1935, 6, 19], [1935, 6, 17]], 'end before start'], ['boundary control 1', [[2023, 12, 31], [2024, 1, 1]], 0.002739726], ['boundary control 2', [[2024, 1, 1], [2025, 1, 1]], 1.0], ['normal control 1', [[1910, 1, 6], [1914, 6, 27]], 4.471232877], ['normal control 2', [[2074, 6, 24], [2074, 7, 3]], 0.024657534]], [['regression reversed interval handling 1', [[2053, 9, 30], [2053, 9, 9]], 'end before start'], ['regression reversed interval handling 2', [[1939, 3, 31], [1939, 3, 29]], 'end before start'], ['partial repair probe 1', [[1939, 10, 1], [1939, 9, 3]], 'end before start'], ['partial repair probe 2', [[2067, 10, 31], [2067, 9, 22]], 'end before start'], ['boundary control 1', [[2024, 3, 1], [2024, 3, 1]], 0.0], ['boundary control 2', [[2023, 7, 1], [2024, 7, 1]], 1.001377349], ['normal control 1', [[1911, 4, 24], [1914, 11, 14]], 3.55890411], ['normal control 2', [[1976, 4, 7], [1977, 1, 18]], 0.78154802]]]
for label, args, expected in fixtures[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 reversed interval handling 1 | end before start | end before start | Passed |
| regression reversed interval handling 2 | end before start | end before start | Passed |
| partial repair probe 1 | end before start | end before start | Passed |
| partial repair probe 2 | end before start | end before start | Passed |
| boundary control 1 | 0.0 | 0.0 | Passed |
| boundary control 2 | 1.0 | 1.0 | Passed |
| normal control 1 | 0.906849315 | 0.906849315 | Passed |
| normal control 2 | 1.088434763 | 1.088434763 | Passed |
SHA-256 / 2bc05af00fd505a4459ad9492a1b1189ea401e012cc442e144bb38722b2b527e
Verification & scope
A deterministic toy contract stated explicitly in the contract field; no claim of conformance to any published convention text. 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:46:50.254900+00:00.
Case digest / a72c61bbd2f529a6199f4660f03b316cc359792050d12ef6060aa865aef74526