FA-60966 / Bond day-count conventions / Open access
Backward coupon schedule generation: the only remaining coupon can be removed as a stub · case 01
A bond issued less than 15 days before maturity reports an empty coupon schedule.
ROOT CAUSE
The short-stub removal no longer requires another coupon to absorb the stub.
VERIFIED REPAIR
Remove a short first coupon only when at least one later coupon remains.
Unsuccessful approach: Restoring the guard but testing 15 days inclusively removes stubs of exactly 15 days.
Case contract
Inputs issue and maturity [y,m,d], months per period and an end-of-month flag. Unadjusted coupon dates are generated backward from maturity: the k-th date is maturity shifted back k*months calendar months, keeping the maturity day clamped to the month length; if the flag is set and maturity is the last day of its month, every date is the last day of its month. Dates on or before issue are dropped. If more than one date remains and the first is fewer than 15 days after issue, it is removed (long first coupon). Return the dates ascending.
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(issue, maturity, months, eom):
def mlen(y, m):
if m == 2:
return 29 if (y % 4 == 0 and y % 100 != 0) or y % 400 == 0 else 28
return 30 if m in (4, 6, 9, 11) else 31
def shift(y, m, k):
t = y * 12 + (m - 1) - k
return t // 12, t % 12 + 1
I = datetime.date(*issue)
my, mm, md = maturity
end_eom = md == mlen(my, mm)
out = []
k = 0
while True:
y, m = shift(my, mm, k * months)
d = mlen(y, m) if (eom and end_eom) else min(md, mlen(y, m))
if datetime.date(y, m, d) <= I:
break
out.append([y, m, d])
k += 1
out.reverse()
if out and (datetime.date(*out[0]) - I).days < 15:
out.pop(0)
return out
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['regression single coupon stub guard 1', [[2036, 12, 26], [2036, 12, 31], 1, True], [[2036, 12, 31]]], ['regression single coupon stub guard 2', [[2024, 3, 18], [2024, 3, 31], 12, True], [[2024, 3, 31]]], ['partial repair probe 1', [[2009, 12, 15], [2012, 9, 30], 3, False], [[2009, 12, 30], [2010, 3, 30], [2010, 6, 30], [2010, 9, 30], [2010, 12, 30], [2011, 3, 30], [2011, 6, 30], [2011, 9, 30], [2011, 12, 30], [2012, 3, 30], [2012, 6, 30], [2012, 9, 30]]], ['partial repair probe 2', [[2007, 7, 16], [2010, 1, 31], 6, False], [[2007, 7, 31], [2008, 1, 31], [2008, 7, 31], [2009, 1, 31], [2009, 7, 31], [2010, 1, 31]]], ['boundary control 1', [[2024, 3, 15], [2025, 3, 15], 3, False], [[2024, 6, 15], [2024, 9, 15], [2024, 12, 15], [2025, 3, 15]]], ['boundary control 2', [[2024, 1, 10], [2025, 8, 31], 6, False], [[2024, 2, 29], [2024, 8, 31], [2025, 2, 28], [2025, 8, 31]]], ['normal control 1', [[2025, 3, 31], [2028, 12, 31], 6, True], [[2025, 6, 30], [2025, 12, 31], [2026, 6, 30], [2026, 12, 31], [2027, 6, 30], [2027, 12, 31], [2028, 6, 30], [2028, 12, 31]]], ['normal control 2', [[2018, 12, 30], [2020, 6, 30], 3, False], [[2019, 3, 30], [2019, 6, 30], [2019, 9, 30], [2019, 12, 30], [2020, 3, 30], [2020, 6, 30]]]], [['regression single coupon stub guard 1', [[2008, 8, 29], [2008, 8, 31], 6, False], [[2008, 8, 31]]], ['regression single coupon stub guard 2', [[2010, 9, 28], [2010, 9, 30], 6, False], [[2010, 9, 30]]], ['partial repair probe 1', [[2007, 2, 13], [2011, 1, 30], 1, True], [[2007, 2, 28], [2007, 3, 30], [2007, 4, 30], [2007, 5, 30], [2007, 6, 30], [2007, 7, 30], [2007, 8, 30], [2007, 9, 30], [2007, 10, 30], [2007, 11, 30], [2007, 12, 30], [2008, 1, 30], [2008, 2, 29], [2008, 3, 30], [2008, 4, 30], [2008, 5, 30], [2008, 6, 30], [2008, 7, 30], [2008, 8, 30], [2008, 9, 30], [2008, 10, 30], [2008, 11, 30], [2008, 12, 30], [2009, 1, 30], [2009, 2, 28], [2009, 3, 30], [2009, 4, 30], [2009, 5, 30], [2009, 6, 30], [2009, 7, 30], [2009, 8, 30], [2009, 9, 30], [2009, 10, 30], [2009, 11, 30], [2009, 12, 30], [2010, 1, 30], [2010, 2, 28], [2010, 3, 30], [2010, 4, 30], [2010, 5, 30], [2010, 6, 30], [2010, 7, 30], [2010, 8, 30], [2010, 9, 30], [2010, 10, 30], [2010, 11, 30], [2010, 12, 30], [2011, 1, 30]]], ['partial repair probe 2', [[2002, 6, 15], [2003, 6, 30], 12, True], [[2002, 6, 30], [2003, 6, 30]]], ['boundary control 1', [[2024, 2, 20], [2025, 2, 28], 6, True], [[2024, 8, 31], [2025, 2, 28]]], ['boundary control 2', [[2024, 3, 1], [2025, 3, 15], 6, False], [[2024, 9, 15], [2025, 3, 15]]], ['normal control 1', [[2024, 8, 1], [2025, 4, 30], 1, False], [[2024, 8, 30], [2024, 9, 30], [2024, 10, 30], [2024, 11, 30], [2024, 12, 30], [2025, 1, 30], [2025, 2, 28], [2025, 3, 30], [2025, 4, 30]]], ['normal control 2', [[2038, 4, 15], [2038, 4, 30], 3, False], [[2038, 4, 30]]]], [['regression single coupon stub guard 1', [[2005, 4, 2], [2005, 4, 10], 12, True], [[2005, 4, 10]]], ['regression single coupon stub guard 2', [[2027, 8, 22], [2027, 8, 31], 6, False], [[2027, 8, 31]]], ['partial repair probe 1', [[2001, 11, 15], [2003, 10, 31], 1, False], [[2001, 11, 30], [2001, 12, 31], [2002, 1, 31], [2002, 2, 28], [2002, 3, 31], [2002, 4, 30], [2002, 5, 31], [2002, 6, 30], [2002, 7, 31], [2002, 8, 31], [2002, 9, 30], [2002, 10, 31], [2002, 11, 30], [2002, 12, 31], [2003, 1, 31], [2003, 2, 28], [2003, 3, 31], [2003, 4, 30], [2003, 5, 31], [2003, 6, 30], [2003, 7, 31], [2003, 8, 31], [2003, 9, 30], [2003, 10, 31]]], ['partial repair probe 2', [[2019, 6, 11], [2020, 3, 26], 1, True], [[2019, 6, 26], [2019, 7, 26], [2019, 8, 26], [2019, 9, 26], [2019, 10, 26], [2019, 11, 26], [2019, 12, 26], [2020, 1, 26], [2020, 2, 26], [2020, 3, 26]]], ['boundary control 1', [[2024, 1, 10], [2025, 8, 31], 6, False], [[2024, 2, 29], [2024, 8, 31], [2025, 2, 28], [2025, 8, 31]]], ['boundary control 2', [[2024, 1, 10], [2025, 8, 31], 6, True], [[2024, 2, 29], [2024, 8, 31], [2025, 2, 28], [2025, 8, 31]]], ['normal control 1', [[2000, 2, 20], [2003, 5, 30], 6, True], [[2000, 5, 30], [2000, 11, 30], [2001, 5, 30], [2001, 11, 30], [2002, 5, 30], [2002, 11, 30], [2003, 5, 30]]], ['normal control 2', [[2008, 9, 18], [2012, 9, 17], 6, True], [[2009, 3, 17], [2009, 9, 17], [2010, 3, 17], [2010, 9, 17], [2011, 3, 17], [2011, 9, 17], [2012, 3, 17], [2012, 9, 17]]]], [['regression single coupon stub guard 1', [[2025, 5, 29], [2025, 5, 30], 12, True], [[2025, 5, 30]]], ['regression single coupon stub guard 2', [[2037, 9, 17], [2037, 9, 30], 3, True], [[2037, 9, 30]]], ['partial repair probe 1', [[2011, 1, 19], [2014, 5, 3], 3, False], [[2011, 2, 3], [2011, 5, 3], [2011, 8, 3], [2011, 11, 3], [2012, 2, 3], [2012, 5, 3], [2012, 8, 3], [2012, 11, 3], [2013, 2, 3], [2013, 5, 3], [2013, 8, 3], [2013, 11, 3], [2014, 2, 3], [2014, 5, 3]]], ['partial repair probe 2', [[2040, 4, 15], [2040, 9, 30], 1, False], [[2040, 4, 30], [2040, 5, 30], [2040, 6, 30], [2040, 7, 30], [2040, 8, 30], [2040, 9, 30]]], ['boundary control 1', [[2024, 3, 1], [2025, 3, 15], 6, False], [[2024, 9, 15], [2025, 3, 15]]], ['boundary control 2', [[2024, 1, 10], [2025, 8, 31], 6, False], [[2024, 2, 29], [2024, 8, 31], [2025, 2, 28], [2025, 8, 31]]], ['normal control 1', [[2019, 8, 23], [2023, 5, 31], 6, True], [[2019, 11, 30], [2020, 5, 31], [2020, 11, 30], [2021, 5, 31], [2021, 11, 30], [2022, 5, 31], [2022, 11, 30], [2023, 5, 31]]], ['normal control 2', [[2010, 1, 1], [2011, 11, 30], 6, False], [[2010, 5, 30], [2010, 11, 30], [2011, 5, 30], [2011, 11, 30]]]], [['regression single coupon stub guard 1', [[2009, 2, 27], [2009, 2, 28], 1, False], [[2009, 2, 28]]], ['regression single coupon stub guard 2', [[2018, 5, 29], [2018, 5, 31], 1, True], [[2018, 5, 31]]], ['partial repair probe 1', [[2013, 8, 13], [2014, 11, 28], 3, True], [[2013, 8, 28], [2013, 11, 28], [2014, 2, 28], [2014, 5, 28], [2014, 8, 28], [2014, 11, 28]]], ['partial repair probe 2', [[2010, 7, 14], [2010, 10, 29], 1, False], [[2010, 7, 29], [2010, 8, 29], [2010, 9, 29], [2010, 10, 29]]], ['boundary control 1', [[2024, 1, 10], [2025, 8, 31], 6, True], [[2024, 2, 29], [2024, 8, 31], [2025, 2, 28], [2025, 8, 31]]], ['boundary control 2', [[2024, 3, 15], [2025, 3, 15], 3, False], [[2024, 6, 15], [2024, 9, 15], [2024, 12, 15], [2025, 3, 15]]], ['normal control 1', [[2038, 8, 19], [2040, 7, 31], 12, True], [[2039, 7, 31], [2040, 7, 31]]], ['normal control 2', [[2021, 11, 29], [2024, 4, 30], 6, False], [[2022, 4, 30], [2022, 10, 30], [2023, 4, 30], [2023, 10, 30], [2024, 4, 30]]]]]
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 single coupon stub guard 1 | [] | [[2036, 12, 31]] | Failed |
| regression single coupon stub guard 2 | [] | [[2024, 3, 31]] | Failed |
| partial repair probe 1 | [[2009, 12, 30], [2010, 3, 30], [2010, 6, 30], [2010, 9, 30], [2010, 12, 30], [2011, 3, 30], [2011, 6, 30], [2011, 9, 30], [2011, 12, 30], [2012, 3, 30], [2012, 6, 30], [2012, 9, 30]] | [[2009, 12, 30], [2010, 3, 30], [2010, 6, 30], [2010, 9, 30], [2010, 12, 30], [2011, 3, 30], [2011, 6, 30], [2011, 9, 30], [2011, 12, 30], [2012, 3, 30], [2012, 6, 30], [2012, 9, 30]] | Passed |
| partial repair probe 2 | [[2007, 7, 31], [2008, 1, 31], [2008, 7, 31], [2009, 1, 31], [2009, 7, 31], [2010, 1, 31]] | [[2007, 7, 31], [2008, 1, 31], [2008, 7, 31], [2009, 1, 31], [2009, 7, 31], [2010, 1, 31]] | Passed |
| boundary control 1 | [[2024, 6, 15], [2024, 9, 15], [2024, 12, 15], [2025, 3, 15]] | [[2024, 6, 15], [2024, 9, 15], [2024, 12, 15], [2025, 3, 15]] | Passed |
| boundary control 2 | [[2024, 2, 29], [2024, 8, 31], [2025, 2, 28], [2025, 8, 31]] | [[2024, 2, 29], [2024, 8, 31], [2025, 2, 28], [2025, 8, 31]] | Passed |
| normal control 1 | [[2025, 6, 30], [2025, 12, 31], [2026, 6, 30], [2026, 12, 31], [2027, 6, 30], [2027, 12, 31], [2028, 6, 30], [2028, 12, 31]] | [[2025, 6, 30], [2025, 12, 31], [2026, 6, 30], [2026, 12, 31], [2027, 6, 30], [2027, 12, 31], [2028, 6, 30], [2028, 12, 31]] | Passed |
| normal control 2 | [[2019, 3, 30], [2019, 6, 30], [2019, 9, 30], [2019, 12, 30], [2020, 3, 30], [2020, 6, 30]] | [[2019, 3, 30], [2019, 6, 30], [2019, 9, 30], [2019, 12, 30], [2020, 3, 30], [2020, 6, 30]] | Passed |
SHA-256 / 75072488a5cc1a30f7af7972d69e5fe451bd7c011a36e2706219ae3c02059c2f
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(issue, maturity, months, eom):
def mlen(y, m):
if m == 2:
return 29 if (y % 4 == 0 and y % 100 != 0) or y % 400 == 0 else 28
return 30 if m in (4, 6, 9, 11) else 31
def shift(y, m, k):
t = y * 12 + (m - 1) - k
return t // 12, t % 12 + 1
I = datetime.date(*issue)
my, mm, md = maturity
end_eom = md == mlen(my, mm)
out = []
k = 0
while True:
y, m = shift(my, mm, k * months)
d = mlen(y, m) if (eom and end_eom) else min(md, mlen(y, m))
if datetime.date(y, m, d) <= I:
break
out.append([y, m, d])
k += 1
out.reverse()
if len(out) > 1 and (datetime.date(*out[0]) - I).days <= 15:
out.pop(0)
return out
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['regression single coupon stub guard 1', [[2036, 12, 26], [2036, 12, 31], 1, True], [[2036, 12, 31]]], ['regression single coupon stub guard 2', [[2024, 3, 18], [2024, 3, 31], 12, True], [[2024, 3, 31]]], ['partial repair probe 1', [[2009, 12, 15], [2012, 9, 30], 3, False], [[2009, 12, 30], [2010, 3, 30], [2010, 6, 30], [2010, 9, 30], [2010, 12, 30], [2011, 3, 30], [2011, 6, 30], [2011, 9, 30], [2011, 12, 30], [2012, 3, 30], [2012, 6, 30], [2012, 9, 30]]], ['partial repair probe 2', [[2007, 7, 16], [2010, 1, 31], 6, False], [[2007, 7, 31], [2008, 1, 31], [2008, 7, 31], [2009, 1, 31], [2009, 7, 31], [2010, 1, 31]]], ['boundary control 1', [[2024, 3, 15], [2025, 3, 15], 3, False], [[2024, 6, 15], [2024, 9, 15], [2024, 12, 15], [2025, 3, 15]]], ['boundary control 2', [[2024, 1, 10], [2025, 8, 31], 6, False], [[2024, 2, 29], [2024, 8, 31], [2025, 2, 28], [2025, 8, 31]]], ['normal control 1', [[2025, 3, 31], [2028, 12, 31], 6, True], [[2025, 6, 30], [2025, 12, 31], [2026, 6, 30], [2026, 12, 31], [2027, 6, 30], [2027, 12, 31], [2028, 6, 30], [2028, 12, 31]]], ['normal control 2', [[2018, 12, 30], [2020, 6, 30], 3, False], [[2019, 3, 30], [2019, 6, 30], [2019, 9, 30], [2019, 12, 30], [2020, 3, 30], [2020, 6, 30]]]], [['regression single coupon stub guard 1', [[2008, 8, 29], [2008, 8, 31], 6, False], [[2008, 8, 31]]], ['regression single coupon stub guard 2', [[2010, 9, 28], [2010, 9, 30], 6, False], [[2010, 9, 30]]], ['partial repair probe 1', [[2007, 2, 13], [2011, 1, 30], 1, True], [[2007, 2, 28], [2007, 3, 30], [2007, 4, 30], [2007, 5, 30], [2007, 6, 30], [2007, 7, 30], [2007, 8, 30], [2007, 9, 30], [2007, 10, 30], [2007, 11, 30], [2007, 12, 30], [2008, 1, 30], [2008, 2, 29], [2008, 3, 30], [2008, 4, 30], [2008, 5, 30], [2008, 6, 30], [2008, 7, 30], [2008, 8, 30], [2008, 9, 30], [2008, 10, 30], [2008, 11, 30], [2008, 12, 30], [2009, 1, 30], [2009, 2, 28], [2009, 3, 30], [2009, 4, 30], [2009, 5, 30], [2009, 6, 30], [2009, 7, 30], [2009, 8, 30], [2009, 9, 30], [2009, 10, 30], [2009, 11, 30], [2009, 12, 30], [2010, 1, 30], [2010, 2, 28], [2010, 3, 30], [2010, 4, 30], [2010, 5, 30], [2010, 6, 30], [2010, 7, 30], [2010, 8, 30], [2010, 9, 30], [2010, 10, 30], [2010, 11, 30], [2010, 12, 30], [2011, 1, 30]]], ['partial repair probe 2', [[2002, 6, 15], [2003, 6, 30], 12, True], [[2002, 6, 30], [2003, 6, 30]]], ['boundary control 1', [[2024, 2, 20], [2025, 2, 28], 6, True], [[2024, 8, 31], [2025, 2, 28]]], ['boundary control 2', [[2024, 3, 1], [2025, 3, 15], 6, False], [[2024, 9, 15], [2025, 3, 15]]], ['normal control 1', [[2024, 8, 1], [2025, 4, 30], 1, False], [[2024, 8, 30], [2024, 9, 30], [2024, 10, 30], [2024, 11, 30], [2024, 12, 30], [2025, 1, 30], [2025, 2, 28], [2025, 3, 30], [2025, 4, 30]]], ['normal control 2', [[2038, 4, 15], [2038, 4, 30], 3, False], [[2038, 4, 30]]]], [['regression single coupon stub guard 1', [[2005, 4, 2], [2005, 4, 10], 12, True], [[2005, 4, 10]]], ['regression single coupon stub guard 2', [[2027, 8, 22], [2027, 8, 31], 6, False], [[2027, 8, 31]]], ['partial repair probe 1', [[2001, 11, 15], [2003, 10, 31], 1, False], [[2001, 11, 30], [2001, 12, 31], [2002, 1, 31], [2002, 2, 28], [2002, 3, 31], [2002, 4, 30], [2002, 5, 31], [2002, 6, 30], [2002, 7, 31], [2002, 8, 31], [2002, 9, 30], [2002, 10, 31], [2002, 11, 30], [2002, 12, 31], [2003, 1, 31], [2003, 2, 28], [2003, 3, 31], [2003, 4, 30], [2003, 5, 31], [2003, 6, 30], [2003, 7, 31], [2003, 8, 31], [2003, 9, 30], [2003, 10, 31]]], ['partial repair probe 2', [[2019, 6, 11], [2020, 3, 26], 1, True], [[2019, 6, 26], [2019, 7, 26], [2019, 8, 26], [2019, 9, 26], [2019, 10, 26], [2019, 11, 26], [2019, 12, 26], [2020, 1, 26], [2020, 2, 26], [2020, 3, 26]]], ['boundary control 1', [[2024, 1, 10], [2025, 8, 31], 6, False], [[2024, 2, 29], [2024, 8, 31], [2025, 2, 28], [2025, 8, 31]]], ['boundary control 2', [[2024, 1, 10], [2025, 8, 31], 6, True], [[2024, 2, 29], [2024, 8, 31], [2025, 2, 28], [2025, 8, 31]]], ['normal control 1', [[2000, 2, 20], [2003, 5, 30], 6, True], [[2000, 5, 30], [2000, 11, 30], [2001, 5, 30], [2001, 11, 30], [2002, 5, 30], [2002, 11, 30], [2003, 5, 30]]], ['normal control 2', [[2008, 9, 18], [2012, 9, 17], 6, True], [[2009, 3, 17], [2009, 9, 17], [2010, 3, 17], [2010, 9, 17], [2011, 3, 17], [2011, 9, 17], [2012, 3, 17], [2012, 9, 17]]]], [['regression single coupon stub guard 1', [[2025, 5, 29], [2025, 5, 30], 12, True], [[2025, 5, 30]]], ['regression single coupon stub guard 2', [[2037, 9, 17], [2037, 9, 30], 3, True], [[2037, 9, 30]]], ['partial repair probe 1', [[2011, 1, 19], [2014, 5, 3], 3, False], [[2011, 2, 3], [2011, 5, 3], [2011, 8, 3], [2011, 11, 3], [2012, 2, 3], [2012, 5, 3], [2012, 8, 3], [2012, 11, 3], [2013, 2, 3], [2013, 5, 3], [2013, 8, 3], [2013, 11, 3], [2014, 2, 3], [2014, 5, 3]]], ['partial repair probe 2', [[2040, 4, 15], [2040, 9, 30], 1, False], [[2040, 4, 30], [2040, 5, 30], [2040, 6, 30], [2040, 7, 30], [2040, 8, 30], [2040, 9, 30]]], ['boundary control 1', [[2024, 3, 1], [2025, 3, 15], 6, False], [[2024, 9, 15], [2025, 3, 15]]], ['boundary control 2', [[2024, 1, 10], [2025, 8, 31], 6, False], [[2024, 2, 29], [2024, 8, 31], [2025, 2, 28], [2025, 8, 31]]], ['normal control 1', [[2019, 8, 23], [2023, 5, 31], 6, True], [[2019, 11, 30], [2020, 5, 31], [2020, 11, 30], [2021, 5, 31], [2021, 11, 30], [2022, 5, 31], [2022, 11, 30], [2023, 5, 31]]], ['normal control 2', [[2010, 1, 1], [2011, 11, 30], 6, False], [[2010, 5, 30], [2010, 11, 30], [2011, 5, 30], [2011, 11, 30]]]], [['regression single coupon stub guard 1', [[2009, 2, 27], [2009, 2, 28], 1, False], [[2009, 2, 28]]], ['regression single coupon stub guard 2', [[2018, 5, 29], [2018, 5, 31], 1, True], [[2018, 5, 31]]], ['partial repair probe 1', [[2013, 8, 13], [2014, 11, 28], 3, True], [[2013, 8, 28], [2013, 11, 28], [2014, 2, 28], [2014, 5, 28], [2014, 8, 28], [2014, 11, 28]]], ['partial repair probe 2', [[2010, 7, 14], [2010, 10, 29], 1, False], [[2010, 7, 29], [2010, 8, 29], [2010, 9, 29], [2010, 10, 29]]], ['boundary control 1', [[2024, 1, 10], [2025, 8, 31], 6, True], [[2024, 2, 29], [2024, 8, 31], [2025, 2, 28], [2025, 8, 31]]], ['boundary control 2', [[2024, 3, 15], [2025, 3, 15], 3, False], [[2024, 6, 15], [2024, 9, 15], [2024, 12, 15], [2025, 3, 15]]], ['normal control 1', [[2038, 8, 19], [2040, 7, 31], 12, True], [[2039, 7, 31], [2040, 7, 31]]], ['normal control 2', [[2021, 11, 29], [2024, 4, 30], 6, False], [[2022, 4, 30], [2022, 10, 30], [2023, 4, 30], [2023, 10, 30], [2024, 4, 30]]]]]
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 single coupon stub guard 1 | [[2036, 12, 31]] | [[2036, 12, 31]] | Passed |
| regression single coupon stub guard 2 | [[2024, 3, 31]] | [[2024, 3, 31]] | Passed |
| partial repair probe 1 | [[2010, 3, 30], [2010, 6, 30], [2010, 9, 30], [2010, 12, 30], [2011, 3, 30], [2011, 6, 30], [2011, 9, 30], [2011, 12, 30], [2012, 3, 30], [2012, 6, 30], [2012, 9, 30]] | [[2009, 12, 30], [2010, 3, 30], [2010, 6, 30], [2010, 9, 30], [2010, 12, 30], [2011, 3, 30], [2011, 6, 30], [2011, 9, 30], [2011, 12, 30], [2012, 3, 30], [2012, 6, 30], [2012, 9, 30]] | Failed |
| partial repair probe 2 | [[2008, 1, 31], [2008, 7, 31], [2009, 1, 31], [2009, 7, 31], [2010, 1, 31]] | [[2007, 7, 31], [2008, 1, 31], [2008, 7, 31], [2009, 1, 31], [2009, 7, 31], [2010, 1, 31]] | Failed |
| boundary control 1 | [[2024, 6, 15], [2024, 9, 15], [2024, 12, 15], [2025, 3, 15]] | [[2024, 6, 15], [2024, 9, 15], [2024, 12, 15], [2025, 3, 15]] | Passed |
| boundary control 2 | [[2024, 2, 29], [2024, 8, 31], [2025, 2, 28], [2025, 8, 31]] | [[2024, 2, 29], [2024, 8, 31], [2025, 2, 28], [2025, 8, 31]] | Passed |
| normal control 1 | [[2025, 6, 30], [2025, 12, 31], [2026, 6, 30], [2026, 12, 31], [2027, 6, 30], [2027, 12, 31], [2028, 6, 30], [2028, 12, 31]] | [[2025, 6, 30], [2025, 12, 31], [2026, 6, 30], [2026, 12, 31], [2027, 6, 30], [2027, 12, 31], [2028, 6, 30], [2028, 12, 31]] | Passed |
| normal control 2 | [[2019, 3, 30], [2019, 6, 30], [2019, 9, 30], [2019, 12, 30], [2020, 3, 30], [2020, 6, 30]] | [[2019, 3, 30], [2019, 6, 30], [2019, 9, 30], [2019, 12, 30], [2020, 3, 30], [2020, 6, 30]] | Passed |
SHA-256 / 9d719ff2e4afa670bb3dff435560f80021ab3f386c673719246d609be3019dc9
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(issue, maturity, months, eom):
def mlen(y, m):
if m == 2:
return 29 if (y % 4 == 0 and y % 100 != 0) or y % 400 == 0 else 28
return 30 if m in (4, 6, 9, 11) else 31
def shift(y, m, k):
t = y * 12 + (m - 1) - k
return t // 12, t % 12 + 1
I = datetime.date(*issue)
my, mm, md = maturity
end_eom = md == mlen(my, mm)
out = []
k = 0
while True:
y, m = shift(my, mm, k * months)
d = mlen(y, m) if (eom and end_eom) else min(md, mlen(y, m))
if datetime.date(y, m, d) <= I:
break
out.append([y, m, d])
k += 1
out.reverse()
if len(out) > 1 and (datetime.date(*out[0]) - I).days < 15:
out.pop(0)
return out
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['regression single coupon stub guard 1', [[2036, 12, 26], [2036, 12, 31], 1, True], [[2036, 12, 31]]], ['regression single coupon stub guard 2', [[2024, 3, 18], [2024, 3, 31], 12, True], [[2024, 3, 31]]], ['partial repair probe 1', [[2009, 12, 15], [2012, 9, 30], 3, False], [[2009, 12, 30], [2010, 3, 30], [2010, 6, 30], [2010, 9, 30], [2010, 12, 30], [2011, 3, 30], [2011, 6, 30], [2011, 9, 30], [2011, 12, 30], [2012, 3, 30], [2012, 6, 30], [2012, 9, 30]]], ['partial repair probe 2', [[2007, 7, 16], [2010, 1, 31], 6, False], [[2007, 7, 31], [2008, 1, 31], [2008, 7, 31], [2009, 1, 31], [2009, 7, 31], [2010, 1, 31]]], ['boundary control 1', [[2024, 3, 15], [2025, 3, 15], 3, False], [[2024, 6, 15], [2024, 9, 15], [2024, 12, 15], [2025, 3, 15]]], ['boundary control 2', [[2024, 1, 10], [2025, 8, 31], 6, False], [[2024, 2, 29], [2024, 8, 31], [2025, 2, 28], [2025, 8, 31]]], ['normal control 1', [[2025, 3, 31], [2028, 12, 31], 6, True], [[2025, 6, 30], [2025, 12, 31], [2026, 6, 30], [2026, 12, 31], [2027, 6, 30], [2027, 12, 31], [2028, 6, 30], [2028, 12, 31]]], ['normal control 2', [[2018, 12, 30], [2020, 6, 30], 3, False], [[2019, 3, 30], [2019, 6, 30], [2019, 9, 30], [2019, 12, 30], [2020, 3, 30], [2020, 6, 30]]]], [['regression single coupon stub guard 1', [[2008, 8, 29], [2008, 8, 31], 6, False], [[2008, 8, 31]]], ['regression single coupon stub guard 2', [[2010, 9, 28], [2010, 9, 30], 6, False], [[2010, 9, 30]]], ['partial repair probe 1', [[2007, 2, 13], [2011, 1, 30], 1, True], [[2007, 2, 28], [2007, 3, 30], [2007, 4, 30], [2007, 5, 30], [2007, 6, 30], [2007, 7, 30], [2007, 8, 30], [2007, 9, 30], [2007, 10, 30], [2007, 11, 30], [2007, 12, 30], [2008, 1, 30], [2008, 2, 29], [2008, 3, 30], [2008, 4, 30], [2008, 5, 30], [2008, 6, 30], [2008, 7, 30], [2008, 8, 30], [2008, 9, 30], [2008, 10, 30], [2008, 11, 30], [2008, 12, 30], [2009, 1, 30], [2009, 2, 28], [2009, 3, 30], [2009, 4, 30], [2009, 5, 30], [2009, 6, 30], [2009, 7, 30], [2009, 8, 30], [2009, 9, 30], [2009, 10, 30], [2009, 11, 30], [2009, 12, 30], [2010, 1, 30], [2010, 2, 28], [2010, 3, 30], [2010, 4, 30], [2010, 5, 30], [2010, 6, 30], [2010, 7, 30], [2010, 8, 30], [2010, 9, 30], [2010, 10, 30], [2010, 11, 30], [2010, 12, 30], [2011, 1, 30]]], ['partial repair probe 2', [[2002, 6, 15], [2003, 6, 30], 12, True], [[2002, 6, 30], [2003, 6, 30]]], ['boundary control 1', [[2024, 2, 20], [2025, 2, 28], 6, True], [[2024, 8, 31], [2025, 2, 28]]], ['boundary control 2', [[2024, 3, 1], [2025, 3, 15], 6, False], [[2024, 9, 15], [2025, 3, 15]]], ['normal control 1', [[2024, 8, 1], [2025, 4, 30], 1, False], [[2024, 8, 30], [2024, 9, 30], [2024, 10, 30], [2024, 11, 30], [2024, 12, 30], [2025, 1, 30], [2025, 2, 28], [2025, 3, 30], [2025, 4, 30]]], ['normal control 2', [[2038, 4, 15], [2038, 4, 30], 3, False], [[2038, 4, 30]]]], [['regression single coupon stub guard 1', [[2005, 4, 2], [2005, 4, 10], 12, True], [[2005, 4, 10]]], ['regression single coupon stub guard 2', [[2027, 8, 22], [2027, 8, 31], 6, False], [[2027, 8, 31]]], ['partial repair probe 1', [[2001, 11, 15], [2003, 10, 31], 1, False], [[2001, 11, 30], [2001, 12, 31], [2002, 1, 31], [2002, 2, 28], [2002, 3, 31], [2002, 4, 30], [2002, 5, 31], [2002, 6, 30], [2002, 7, 31], [2002, 8, 31], [2002, 9, 30], [2002, 10, 31], [2002, 11, 30], [2002, 12, 31], [2003, 1, 31], [2003, 2, 28], [2003, 3, 31], [2003, 4, 30], [2003, 5, 31], [2003, 6, 30], [2003, 7, 31], [2003, 8, 31], [2003, 9, 30], [2003, 10, 31]]], ['partial repair probe 2', [[2019, 6, 11], [2020, 3, 26], 1, True], [[2019, 6, 26], [2019, 7, 26], [2019, 8, 26], [2019, 9, 26], [2019, 10, 26], [2019, 11, 26], [2019, 12, 26], [2020, 1, 26], [2020, 2, 26], [2020, 3, 26]]], ['boundary control 1', [[2024, 1, 10], [2025, 8, 31], 6, False], [[2024, 2, 29], [2024, 8, 31], [2025, 2, 28], [2025, 8, 31]]], ['boundary control 2', [[2024, 1, 10], [2025, 8, 31], 6, True], [[2024, 2, 29], [2024, 8, 31], [2025, 2, 28], [2025, 8, 31]]], ['normal control 1', [[2000, 2, 20], [2003, 5, 30], 6, True], [[2000, 5, 30], [2000, 11, 30], [2001, 5, 30], [2001, 11, 30], [2002, 5, 30], [2002, 11, 30], [2003, 5, 30]]], ['normal control 2', [[2008, 9, 18], [2012, 9, 17], 6, True], [[2009, 3, 17], [2009, 9, 17], [2010, 3, 17], [2010, 9, 17], [2011, 3, 17], [2011, 9, 17], [2012, 3, 17], [2012, 9, 17]]]], [['regression single coupon stub guard 1', [[2025, 5, 29], [2025, 5, 30], 12, True], [[2025, 5, 30]]], ['regression single coupon stub guard 2', [[2037, 9, 17], [2037, 9, 30], 3, True], [[2037, 9, 30]]], ['partial repair probe 1', [[2011, 1, 19], [2014, 5, 3], 3, False], [[2011, 2, 3], [2011, 5, 3], [2011, 8, 3], [2011, 11, 3], [2012, 2, 3], [2012, 5, 3], [2012, 8, 3], [2012, 11, 3], [2013, 2, 3], [2013, 5, 3], [2013, 8, 3], [2013, 11, 3], [2014, 2, 3], [2014, 5, 3]]], ['partial repair probe 2', [[2040, 4, 15], [2040, 9, 30], 1, False], [[2040, 4, 30], [2040, 5, 30], [2040, 6, 30], [2040, 7, 30], [2040, 8, 30], [2040, 9, 30]]], ['boundary control 1', [[2024, 3, 1], [2025, 3, 15], 6, False], [[2024, 9, 15], [2025, 3, 15]]], ['boundary control 2', [[2024, 1, 10], [2025, 8, 31], 6, False], [[2024, 2, 29], [2024, 8, 31], [2025, 2, 28], [2025, 8, 31]]], ['normal control 1', [[2019, 8, 23], [2023, 5, 31], 6, True], [[2019, 11, 30], [2020, 5, 31], [2020, 11, 30], [2021, 5, 31], [2021, 11, 30], [2022, 5, 31], [2022, 11, 30], [2023, 5, 31]]], ['normal control 2', [[2010, 1, 1], [2011, 11, 30], 6, False], [[2010, 5, 30], [2010, 11, 30], [2011, 5, 30], [2011, 11, 30]]]], [['regression single coupon stub guard 1', [[2009, 2, 27], [2009, 2, 28], 1, False], [[2009, 2, 28]]], ['regression single coupon stub guard 2', [[2018, 5, 29], [2018, 5, 31], 1, True], [[2018, 5, 31]]], ['partial repair probe 1', [[2013, 8, 13], [2014, 11, 28], 3, True], [[2013, 8, 28], [2013, 11, 28], [2014, 2, 28], [2014, 5, 28], [2014, 8, 28], [2014, 11, 28]]], ['partial repair probe 2', [[2010, 7, 14], [2010, 10, 29], 1, False], [[2010, 7, 29], [2010, 8, 29], [2010, 9, 29], [2010, 10, 29]]], ['boundary control 1', [[2024, 1, 10], [2025, 8, 31], 6, True], [[2024, 2, 29], [2024, 8, 31], [2025, 2, 28], [2025, 8, 31]]], ['boundary control 2', [[2024, 3, 15], [2025, 3, 15], 3, False], [[2024, 6, 15], [2024, 9, 15], [2024, 12, 15], [2025, 3, 15]]], ['normal control 1', [[2038, 8, 19], [2040, 7, 31], 12, True], [[2039, 7, 31], [2040, 7, 31]]], ['normal control 2', [[2021, 11, 29], [2024, 4, 30], 6, False], [[2022, 4, 30], [2022, 10, 30], [2023, 4, 30], [2023, 10, 30], [2024, 4, 30]]]]]
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 single coupon stub guard 1 | [[2036, 12, 31]] | [[2036, 12, 31]] | Passed |
| regression single coupon stub guard 2 | [[2024, 3, 31]] | [[2024, 3, 31]] | Passed |
| partial repair probe 1 | [[2009, 12, 30], [2010, 3, 30], [2010, 6, 30], [2010, 9, 30], [2010, 12, 30], [2011, 3, 30], [2011, 6, 30], [2011, 9, 30], [2011, 12, 30], [2012, 3, 30], [2012, 6, 30], [2012, 9, 30]] | [[2009, 12, 30], [2010, 3, 30], [2010, 6, 30], [2010, 9, 30], [2010, 12, 30], [2011, 3, 30], [2011, 6, 30], [2011, 9, 30], [2011, 12, 30], [2012, 3, 30], [2012, 6, 30], [2012, 9, 30]] | Passed |
| partial repair probe 2 | [[2007, 7, 31], [2008, 1, 31], [2008, 7, 31], [2009, 1, 31], [2009, 7, 31], [2010, 1, 31]] | [[2007, 7, 31], [2008, 1, 31], [2008, 7, 31], [2009, 1, 31], [2009, 7, 31], [2010, 1, 31]] | Passed |
| boundary control 1 | [[2024, 6, 15], [2024, 9, 15], [2024, 12, 15], [2025, 3, 15]] | [[2024, 6, 15], [2024, 9, 15], [2024, 12, 15], [2025, 3, 15]] | Passed |
| boundary control 2 | [[2024, 2, 29], [2024, 8, 31], [2025, 2, 28], [2025, 8, 31]] | [[2024, 2, 29], [2024, 8, 31], [2025, 2, 28], [2025, 8, 31]] | Passed |
| normal control 1 | [[2025, 6, 30], [2025, 12, 31], [2026, 6, 30], [2026, 12, 31], [2027, 6, 30], [2027, 12, 31], [2028, 6, 30], [2028, 12, 31]] | [[2025, 6, 30], [2025, 12, 31], [2026, 6, 30], [2026, 12, 31], [2027, 6, 30], [2027, 12, 31], [2028, 6, 30], [2028, 12, 31]] | Passed |
| normal control 2 | [[2019, 3, 30], [2019, 6, 30], [2019, 9, 30], [2019, 12, 30], [2020, 3, 30], [2020, 6, 30]] | [[2019, 3, 30], [2019, 6, 30], [2019, 9, 30], [2019, 12, 30], [2020, 3, 30], [2020, 6, 30]] | Passed |
SHA-256 / 6e7b40eb8c0282ff81d34d002115a7f5346b40d81ac06a71de4cc090a5e4c1d4
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.681082+00:00.
Case digest / 4a911bcfa6d8280ce3dd3b79528337f02631c17e484f354e1ca46162b1a4b152