FA-60971 / Bond day-count conventions / Open access
Backward coupon schedule generation: maturity on day 30 or later counts as month end · case 01
A 30 May maturity rolls to month ends while a 28 February maturity does not.
ROOT CAUSE
Month-end status of maturity is approximated by day >= 30.
VERIFIED REPAIR
Compare the maturity day with the length of its own month.
Unsuccessful approach: Excluding February from the exact test misses February month-end maturities.
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 >= 30
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 month-end maturity detection 1', [[2037, 4, 26], [2039, 1, 30], 6, True], [[2037, 7, 30], [2038, 1, 30], [2038, 7, 30], [2039, 1, 30]]], ['regression month-end maturity detection 2', [[2013, 9, 30], [2016, 3, 30], 6, True], [[2014, 3, 30], [2014, 9, 30], [2015, 3, 30], [2015, 9, 30], [2016, 3, 30]]], ['partial repair probe 1', [[2018, 1, 27], [2021, 2, 28], 6, True], [[2018, 2, 28], [2018, 8, 31], [2019, 2, 28], [2019, 8, 31], [2020, 2, 29], [2020, 8, 31], [2021, 2, 28]]], ['partial repair probe 2', [[2014, 8, 20], [2017, 2, 28], 1, True], [[2014, 9, 30], [2014, 10, 31], [2014, 11, 30], [2014, 12, 31], [2015, 1, 31], [2015, 2, 28], [2015, 3, 31], [2015, 4, 30], [2015, 5, 31], [2015, 6, 30], [2015, 7, 31], [2015, 8, 31], [2015, 9, 30], [2015, 10, 31], [2015, 11, 30], [2015, 12, 31], [2016, 1, 31], [2016, 2, 29], [2016, 3, 31], [2016, 4, 30], [2016, 5, 31], [2016, 6, 30], [2016, 7, 31], [2016, 8, 31], [2016, 9, 30], [2016, 10, 31], [2016, 11, 30], [2016, 12, 31], [2017, 1, 31], [2017, 2, 28]]], ['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, 1], [2025, 3, 15], 6, False], [[2024, 9, 15], [2025, 3, 15]]], ['normal control 1', [[2018, 12, 23], [2021, 6, 28], 6, True], [[2019, 6, 28], [2019, 12, 28], [2020, 6, 28], [2020, 12, 28], [2021, 6, 28]]], ['normal control 2', [[2026, 5, 14], [2026, 5, 31], 1, False], [[2026, 5, 31]]]], [['regression month-end maturity detection 1', [[2002, 12, 31], [2005, 2, 28], 3, True], [[2003, 2, 28], [2003, 5, 31], [2003, 8, 31], [2003, 11, 30], [2004, 2, 29], [2004, 5, 31], [2004, 8, 31], [2004, 11, 30], [2005, 2, 28]]], ['regression month-end maturity detection 2', [[2024, 2, 20], [2025, 2, 28], 6, True], [[2024, 8, 31], [2025, 2, 28]]], ['partial repair probe 1', [[2001, 5, 21], [2004, 2, 29], 6, True], [[2001, 8, 31], [2002, 2, 28], [2002, 8, 31], [2003, 2, 28], [2003, 8, 31], [2004, 2, 29]]], ['partial repair probe 2', [[2017, 3, 6], [2019, 2, 28], 6, True], [[2017, 8, 31], [2018, 2, 28], [2018, 8, 31], [2019, 2, 28]]], ['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, True], [[2024, 2, 29], [2024, 8, 31], [2025, 2, 28], [2025, 8, 31]]], ['normal control 1', [[1999, 10, 23], [2003, 9, 30], 6, False], [[2000, 3, 30], [2000, 9, 30], [2001, 3, 30], [2001, 9, 30], [2002, 3, 30], [2002, 9, 30], [2003, 3, 30], [2003, 9, 30]]], ['normal control 2', [[2022, 2, 22], [2025, 6, 30], 1, True], [[2022, 3, 31], [2022, 4, 30], [2022, 5, 31], [2022, 6, 30], [2022, 7, 31], [2022, 8, 31], [2022, 9, 30], [2022, 10, 31], [2022, 11, 30], [2022, 12, 31], [2023, 1, 31], [2023, 2, 28], [2023, 3, 31], [2023, 4, 30], [2023, 5, 31], [2023, 6, 30], [2023, 7, 31], [2023, 8, 31], [2023, 9, 30], [2023, 10, 31], [2023, 11, 30], [2023, 12, 31], [2024, 1, 31], [2024, 2, 29], [2024, 3, 31], [2024, 4, 30], [2024, 5, 31], [2024, 6, 30], [2024, 7, 31], [2024, 8, 31], [2024, 9, 30], [2024, 10, 31], [2024, 11, 30], [2024, 12, 31], [2025, 1, 31], [2025, 2, 28], [2025, 3, 31], [2025, 4, 30], [2025, 5, 31], [2025, 6, 30]]]], [['regression month-end maturity detection 1', [[2032, 11, 24], [2033, 12, 30], 12, True], [[2032, 12, 30], [2033, 12, 30]]], ['regression month-end maturity detection 2', [[2026, 11, 26], [2028, 2, 29], 6, True], [[2027, 2, 28], [2027, 8, 31], [2028, 2, 29]]], ['partial repair probe 1', [[2000, 9, 13], [2003, 2, 28], 6, True], [[2001, 2, 28], [2001, 8, 31], [2002, 2, 28], [2002, 8, 31], [2003, 2, 28]]], ['partial repair probe 2', [[2011, 2, 28], [2012, 2, 29], 3, True], [[2011, 5, 31], [2011, 8, 31], [2011, 11, 30], [2012, 2, 29]]], ['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, 3, 1], [2025, 3, 15], 6, False], [[2024, 9, 15], [2025, 3, 15]]], ['normal control 1', [[2009, 9, 20], [2009, 9, 30], 6, False], [[2009, 9, 30]]], ['normal control 2', [[2026, 2, 27], [2027, 2, 17], 12, True], [[2027, 2, 17]]]], [['regression month-end maturity detection 1', [[2007, 1, 2], [2010, 1, 30], 6, True], [[2007, 1, 30], [2007, 7, 30], [2008, 1, 30], [2008, 7, 30], [2009, 1, 30], [2009, 7, 30], [2010, 1, 30]]], ['regression month-end maturity detection 2', [[2038, 6, 27], [2038, 7, 30], 3, True], [[2038, 7, 30]]], ['partial repair probe 1', [[2035, 6, 12], [2036, 2, 29], 3, True], [[2035, 8, 31], [2035, 11, 30], [2036, 2, 29]]], ['partial repair probe 2', [[2029, 4, 5], [2031, 2, 28], 6, True], [[2029, 8, 31], [2030, 2, 28], [2030, 8, 31], [2031, 2, 28]]], ['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', [[2022, 9, 24], [2025, 11, 30], 6, True], [[2022, 11, 30], [2023, 5, 31], [2023, 11, 30], [2024, 5, 31], [2024, 11, 30], [2025, 5, 31], [2025, 11, 30]]], ['normal control 2', [[2008, 1, 19], [2008, 1, 31], 12, False], [[2008, 1, 31]]]], [['regression month-end maturity detection 1', [[2004, 8, 23], [2008, 2, 29], 1, True], [[2004, 9, 30], [2004, 10, 31], [2004, 11, 30], [2004, 12, 31], [2005, 1, 31], [2005, 2, 28], [2005, 3, 31], [2005, 4, 30], [2005, 5, 31], [2005, 6, 30], [2005, 7, 31], [2005, 8, 31], [2005, 9, 30], [2005, 10, 31], [2005, 11, 30], [2005, 12, 31], [2006, 1, 31], [2006, 2, 28], [2006, 3, 31], [2006, 4, 30], [2006, 5, 31], [2006, 6, 30], [2006, 7, 31], [2006, 8, 31], [2006, 9, 30], [2006, 10, 31], [2006, 11, 30], [2006, 12, 31], [2007, 1, 31], [2007, 2, 28], [2007, 3, 31], [2007, 4, 30], [2007, 5, 31], [2007, 6, 30], [2007, 7, 31], [2007, 8, 31], [2007, 9, 30], [2007, 10, 31], [2007, 11, 30], [2007, 12, 31], [2008, 1, 31], [2008, 2, 29]]], ['regression month-end maturity detection 2', [[2014, 2, 2], [2017, 1, 30], 12, True], [[2015, 1, 30], [2016, 1, 30], [2017, 1, 30]]], ['partial repair probe 1', [[2023, 2, 20], [2027, 2, 28], 3, True], [[2023, 5, 31], [2023, 8, 31], [2023, 11, 30], [2024, 2, 29], [2024, 5, 31], [2024, 8, 31], [2024, 11, 30], [2025, 2, 28], [2025, 5, 31], [2025, 8, 31], [2025, 11, 30], [2026, 2, 28], [2026, 5, 31], [2026, 8, 31], [2026, 11, 30], [2027, 2, 28]]], ['partial repair probe 2', [[2010, 5, 22], [2014, 2, 28], 6, True], [[2010, 8, 31], [2011, 2, 28], [2011, 8, 31], [2012, 2, 29], [2012, 8, 31], [2013, 2, 28], [2013, 8, 31], [2014, 2, 28]]], ['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', [[2019, 6, 15], [2019, 6, 30], 6, True], [[2019, 6, 30]]], ['normal control 2', [[2005, 5, 5], [2006, 5, 31], 3, False], [[2005, 5, 31], [2005, 8, 31], [2005, 11, 30], [2006, 2, 28], [2006, 5, 31]]]]]
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 month-end maturity detection 1 | [[2037, 7, 31], [2038, 1, 31], [2038, 7, 31], [2039, 1, 31]] | [[2037, 7, 30], [2038, 1, 30], [2038, 7, 30], [2039, 1, 30]] | Failed |
| regression month-end maturity detection 2 | [[2014, 3, 31], [2014, 9, 30], [2015, 3, 31], [2015, 9, 30], [2016, 3, 31]] | [[2014, 3, 30], [2014, 9, 30], [2015, 3, 30], [2015, 9, 30], [2016, 3, 30]] | Failed |
| partial repair probe 1 | [[2018, 2, 28], [2018, 8, 28], [2019, 2, 28], [2019, 8, 28], [2020, 2, 28], [2020, 8, 28], [2021, 2, 28]] | [[2018, 2, 28], [2018, 8, 31], [2019, 2, 28], [2019, 8, 31], [2020, 2, 29], [2020, 8, 31], [2021, 2, 28]] | Failed |
| partial repair probe 2 | [[2014, 9, 28], [2014, 10, 28], [2014, 11, 28], [2014, 12, 28], [2015, 1, 28], [2015, 2, 28], [2015, 3, 28], [2015, 4, 28], [2015, 5, 28], [2015, 6, 28], [2015, 7, 28], [2015, 8, 28], [2015, 9, 28], [2015, 10, 28], [2015, 11, 28], [2015, 12, 28], [2016, 1, 28], [2016, 2, 28], [2016, 3, 28], [2016, 4, 28], [2016, 5, 28], [2016, 6, 28], [2016, 7, 28], [2016, 8, 28], [2016, 9, 28], [2016, 10, 28], [2016, 11, 28], [2016, 12, 28], [2017, 1, 28], [2017, 2, 28]] | [[2014, 9, 30], [2014, 10, 31], [2014, 11, 30], [2014, 12, 31], [2015, 1, 31], [2015, 2, 28], [2015, 3, 31], [2015, 4, 30], [2015, 5, 31], [2015, 6, 30], [2015, 7, 31], [2015, 8, 31], [2015, 9, 30], [2015, 10, 31], [2015, 11, 30], [2015, 12, 31], [2016, 1, 31], [2016, 2, 29], [2016, 3, 31], [2016, 4, 30], [2016, 5, 31], [2016, 6, 30], [2016, 7, 31], [2016, 8, 31], [2016, 9, 30], [2016, 10, 31], [2016, 11, 30], [2016, 12, 31], [2017, 1, 31], [2017, 2, 28]] | Failed |
| boundary control 1 | [[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 |
| boundary control 2 | [[2024, 9, 15], [2025, 3, 15]] | [[2024, 9, 15], [2025, 3, 15]] | Passed |
| normal control 1 | [[2019, 6, 28], [2019, 12, 28], [2020, 6, 28], [2020, 12, 28], [2021, 6, 28]] | [[2019, 6, 28], [2019, 12, 28], [2020, 6, 28], [2020, 12, 28], [2021, 6, 28]] | Passed |
| normal control 2 | [[2026, 5, 31]] | [[2026, 5, 31]] | Passed |
SHA-256 / 11f6ee9cadd803f64d34696284324d314c38eea4aa18718d954b0efe54e35375
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) and mm != 2
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 month-end maturity detection 1', [[2037, 4, 26], [2039, 1, 30], 6, True], [[2037, 7, 30], [2038, 1, 30], [2038, 7, 30], [2039, 1, 30]]], ['regression month-end maturity detection 2', [[2013, 9, 30], [2016, 3, 30], 6, True], [[2014, 3, 30], [2014, 9, 30], [2015, 3, 30], [2015, 9, 30], [2016, 3, 30]]], ['partial repair probe 1', [[2018, 1, 27], [2021, 2, 28], 6, True], [[2018, 2, 28], [2018, 8, 31], [2019, 2, 28], [2019, 8, 31], [2020, 2, 29], [2020, 8, 31], [2021, 2, 28]]], ['partial repair probe 2', [[2014, 8, 20], [2017, 2, 28], 1, True], [[2014, 9, 30], [2014, 10, 31], [2014, 11, 30], [2014, 12, 31], [2015, 1, 31], [2015, 2, 28], [2015, 3, 31], [2015, 4, 30], [2015, 5, 31], [2015, 6, 30], [2015, 7, 31], [2015, 8, 31], [2015, 9, 30], [2015, 10, 31], [2015, 11, 30], [2015, 12, 31], [2016, 1, 31], [2016, 2, 29], [2016, 3, 31], [2016, 4, 30], [2016, 5, 31], [2016, 6, 30], [2016, 7, 31], [2016, 8, 31], [2016, 9, 30], [2016, 10, 31], [2016, 11, 30], [2016, 12, 31], [2017, 1, 31], [2017, 2, 28]]], ['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, 1], [2025, 3, 15], 6, False], [[2024, 9, 15], [2025, 3, 15]]], ['normal control 1', [[2018, 12, 23], [2021, 6, 28], 6, True], [[2019, 6, 28], [2019, 12, 28], [2020, 6, 28], [2020, 12, 28], [2021, 6, 28]]], ['normal control 2', [[2026, 5, 14], [2026, 5, 31], 1, False], [[2026, 5, 31]]]], [['regression month-end maturity detection 1', [[2002, 12, 31], [2005, 2, 28], 3, True], [[2003, 2, 28], [2003, 5, 31], [2003, 8, 31], [2003, 11, 30], [2004, 2, 29], [2004, 5, 31], [2004, 8, 31], [2004, 11, 30], [2005, 2, 28]]], ['regression month-end maturity detection 2', [[2024, 2, 20], [2025, 2, 28], 6, True], [[2024, 8, 31], [2025, 2, 28]]], ['partial repair probe 1', [[2001, 5, 21], [2004, 2, 29], 6, True], [[2001, 8, 31], [2002, 2, 28], [2002, 8, 31], [2003, 2, 28], [2003, 8, 31], [2004, 2, 29]]], ['partial repair probe 2', [[2017, 3, 6], [2019, 2, 28], 6, True], [[2017, 8, 31], [2018, 2, 28], [2018, 8, 31], [2019, 2, 28]]], ['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, True], [[2024, 2, 29], [2024, 8, 31], [2025, 2, 28], [2025, 8, 31]]], ['normal control 1', [[1999, 10, 23], [2003, 9, 30], 6, False], [[2000, 3, 30], [2000, 9, 30], [2001, 3, 30], [2001, 9, 30], [2002, 3, 30], [2002, 9, 30], [2003, 3, 30], [2003, 9, 30]]], ['normal control 2', [[2022, 2, 22], [2025, 6, 30], 1, True], [[2022, 3, 31], [2022, 4, 30], [2022, 5, 31], [2022, 6, 30], [2022, 7, 31], [2022, 8, 31], [2022, 9, 30], [2022, 10, 31], [2022, 11, 30], [2022, 12, 31], [2023, 1, 31], [2023, 2, 28], [2023, 3, 31], [2023, 4, 30], [2023, 5, 31], [2023, 6, 30], [2023, 7, 31], [2023, 8, 31], [2023, 9, 30], [2023, 10, 31], [2023, 11, 30], [2023, 12, 31], [2024, 1, 31], [2024, 2, 29], [2024, 3, 31], [2024, 4, 30], [2024, 5, 31], [2024, 6, 30], [2024, 7, 31], [2024, 8, 31], [2024, 9, 30], [2024, 10, 31], [2024, 11, 30], [2024, 12, 31], [2025, 1, 31], [2025, 2, 28], [2025, 3, 31], [2025, 4, 30], [2025, 5, 31], [2025, 6, 30]]]], [['regression month-end maturity detection 1', [[2032, 11, 24], [2033, 12, 30], 12, True], [[2032, 12, 30], [2033, 12, 30]]], ['regression month-end maturity detection 2', [[2026, 11, 26], [2028, 2, 29], 6, True], [[2027, 2, 28], [2027, 8, 31], [2028, 2, 29]]], ['partial repair probe 1', [[2000, 9, 13], [2003, 2, 28], 6, True], [[2001, 2, 28], [2001, 8, 31], [2002, 2, 28], [2002, 8, 31], [2003, 2, 28]]], ['partial repair probe 2', [[2011, 2, 28], [2012, 2, 29], 3, True], [[2011, 5, 31], [2011, 8, 31], [2011, 11, 30], [2012, 2, 29]]], ['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, 3, 1], [2025, 3, 15], 6, False], [[2024, 9, 15], [2025, 3, 15]]], ['normal control 1', [[2009, 9, 20], [2009, 9, 30], 6, False], [[2009, 9, 30]]], ['normal control 2', [[2026, 2, 27], [2027, 2, 17], 12, True], [[2027, 2, 17]]]], [['regression month-end maturity detection 1', [[2007, 1, 2], [2010, 1, 30], 6, True], [[2007, 1, 30], [2007, 7, 30], [2008, 1, 30], [2008, 7, 30], [2009, 1, 30], [2009, 7, 30], [2010, 1, 30]]], ['regression month-end maturity detection 2', [[2038, 6, 27], [2038, 7, 30], 3, True], [[2038, 7, 30]]], ['partial repair probe 1', [[2035, 6, 12], [2036, 2, 29], 3, True], [[2035, 8, 31], [2035, 11, 30], [2036, 2, 29]]], ['partial repair probe 2', [[2029, 4, 5], [2031, 2, 28], 6, True], [[2029, 8, 31], [2030, 2, 28], [2030, 8, 31], [2031, 2, 28]]], ['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', [[2022, 9, 24], [2025, 11, 30], 6, True], [[2022, 11, 30], [2023, 5, 31], [2023, 11, 30], [2024, 5, 31], [2024, 11, 30], [2025, 5, 31], [2025, 11, 30]]], ['normal control 2', [[2008, 1, 19], [2008, 1, 31], 12, False], [[2008, 1, 31]]]], [['regression month-end maturity detection 1', [[2004, 8, 23], [2008, 2, 29], 1, True], [[2004, 9, 30], [2004, 10, 31], [2004, 11, 30], [2004, 12, 31], [2005, 1, 31], [2005, 2, 28], [2005, 3, 31], [2005, 4, 30], [2005, 5, 31], [2005, 6, 30], [2005, 7, 31], [2005, 8, 31], [2005, 9, 30], [2005, 10, 31], [2005, 11, 30], [2005, 12, 31], [2006, 1, 31], [2006, 2, 28], [2006, 3, 31], [2006, 4, 30], [2006, 5, 31], [2006, 6, 30], [2006, 7, 31], [2006, 8, 31], [2006, 9, 30], [2006, 10, 31], [2006, 11, 30], [2006, 12, 31], [2007, 1, 31], [2007, 2, 28], [2007, 3, 31], [2007, 4, 30], [2007, 5, 31], [2007, 6, 30], [2007, 7, 31], [2007, 8, 31], [2007, 9, 30], [2007, 10, 31], [2007, 11, 30], [2007, 12, 31], [2008, 1, 31], [2008, 2, 29]]], ['regression month-end maturity detection 2', [[2014, 2, 2], [2017, 1, 30], 12, True], [[2015, 1, 30], [2016, 1, 30], [2017, 1, 30]]], ['partial repair probe 1', [[2023, 2, 20], [2027, 2, 28], 3, True], [[2023, 5, 31], [2023, 8, 31], [2023, 11, 30], [2024, 2, 29], [2024, 5, 31], [2024, 8, 31], [2024, 11, 30], [2025, 2, 28], [2025, 5, 31], [2025, 8, 31], [2025, 11, 30], [2026, 2, 28], [2026, 5, 31], [2026, 8, 31], [2026, 11, 30], [2027, 2, 28]]], ['partial repair probe 2', [[2010, 5, 22], [2014, 2, 28], 6, True], [[2010, 8, 31], [2011, 2, 28], [2011, 8, 31], [2012, 2, 29], [2012, 8, 31], [2013, 2, 28], [2013, 8, 31], [2014, 2, 28]]], ['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', [[2019, 6, 15], [2019, 6, 30], 6, True], [[2019, 6, 30]]], ['normal control 2', [[2005, 5, 5], [2006, 5, 31], 3, False], [[2005, 5, 31], [2005, 8, 31], [2005, 11, 30], [2006, 2, 28], [2006, 5, 31]]]]]
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 month-end maturity detection 1 | [[2037, 7, 30], [2038, 1, 30], [2038, 7, 30], [2039, 1, 30]] | [[2037, 7, 30], [2038, 1, 30], [2038, 7, 30], [2039, 1, 30]] | Passed |
| regression month-end maturity detection 2 | [[2014, 3, 30], [2014, 9, 30], [2015, 3, 30], [2015, 9, 30], [2016, 3, 30]] | [[2014, 3, 30], [2014, 9, 30], [2015, 3, 30], [2015, 9, 30], [2016, 3, 30]] | Passed |
| partial repair probe 1 | [[2018, 2, 28], [2018, 8, 28], [2019, 2, 28], [2019, 8, 28], [2020, 2, 28], [2020, 8, 28], [2021, 2, 28]] | [[2018, 2, 28], [2018, 8, 31], [2019, 2, 28], [2019, 8, 31], [2020, 2, 29], [2020, 8, 31], [2021, 2, 28]] | Failed |
| partial repair probe 2 | [[2014, 9, 28], [2014, 10, 28], [2014, 11, 28], [2014, 12, 28], [2015, 1, 28], [2015, 2, 28], [2015, 3, 28], [2015, 4, 28], [2015, 5, 28], [2015, 6, 28], [2015, 7, 28], [2015, 8, 28], [2015, 9, 28], [2015, 10, 28], [2015, 11, 28], [2015, 12, 28], [2016, 1, 28], [2016, 2, 28], [2016, 3, 28], [2016, 4, 28], [2016, 5, 28], [2016, 6, 28], [2016, 7, 28], [2016, 8, 28], [2016, 9, 28], [2016, 10, 28], [2016, 11, 28], [2016, 12, 28], [2017, 1, 28], [2017, 2, 28]] | [[2014, 9, 30], [2014, 10, 31], [2014, 11, 30], [2014, 12, 31], [2015, 1, 31], [2015, 2, 28], [2015, 3, 31], [2015, 4, 30], [2015, 5, 31], [2015, 6, 30], [2015, 7, 31], [2015, 8, 31], [2015, 9, 30], [2015, 10, 31], [2015, 11, 30], [2015, 12, 31], [2016, 1, 31], [2016, 2, 29], [2016, 3, 31], [2016, 4, 30], [2016, 5, 31], [2016, 6, 30], [2016, 7, 31], [2016, 8, 31], [2016, 9, 30], [2016, 10, 31], [2016, 11, 30], [2016, 12, 31], [2017, 1, 31], [2017, 2, 28]] | Failed |
| boundary control 1 | [[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 |
| boundary control 2 | [[2024, 9, 15], [2025, 3, 15]] | [[2024, 9, 15], [2025, 3, 15]] | Passed |
| normal control 1 | [[2019, 6, 28], [2019, 12, 28], [2020, 6, 28], [2020, 12, 28], [2021, 6, 28]] | [[2019, 6, 28], [2019, 12, 28], [2020, 6, 28], [2020, 12, 28], [2021, 6, 28]] | Passed |
| normal control 2 | [[2026, 5, 31]] | [[2026, 5, 31]] | Passed |
SHA-256 / e317c58a6224bcdd282e52a6a5fbce296aa8da381a95940efbaa200da353a4e1
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 month-end maturity detection 1', [[2037, 4, 26], [2039, 1, 30], 6, True], [[2037, 7, 30], [2038, 1, 30], [2038, 7, 30], [2039, 1, 30]]], ['regression month-end maturity detection 2', [[2013, 9, 30], [2016, 3, 30], 6, True], [[2014, 3, 30], [2014, 9, 30], [2015, 3, 30], [2015, 9, 30], [2016, 3, 30]]], ['partial repair probe 1', [[2018, 1, 27], [2021, 2, 28], 6, True], [[2018, 2, 28], [2018, 8, 31], [2019, 2, 28], [2019, 8, 31], [2020, 2, 29], [2020, 8, 31], [2021, 2, 28]]], ['partial repair probe 2', [[2014, 8, 20], [2017, 2, 28], 1, True], [[2014, 9, 30], [2014, 10, 31], [2014, 11, 30], [2014, 12, 31], [2015, 1, 31], [2015, 2, 28], [2015, 3, 31], [2015, 4, 30], [2015, 5, 31], [2015, 6, 30], [2015, 7, 31], [2015, 8, 31], [2015, 9, 30], [2015, 10, 31], [2015, 11, 30], [2015, 12, 31], [2016, 1, 31], [2016, 2, 29], [2016, 3, 31], [2016, 4, 30], [2016, 5, 31], [2016, 6, 30], [2016, 7, 31], [2016, 8, 31], [2016, 9, 30], [2016, 10, 31], [2016, 11, 30], [2016, 12, 31], [2017, 1, 31], [2017, 2, 28]]], ['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, 1], [2025, 3, 15], 6, False], [[2024, 9, 15], [2025, 3, 15]]], ['normal control 1', [[2018, 12, 23], [2021, 6, 28], 6, True], [[2019, 6, 28], [2019, 12, 28], [2020, 6, 28], [2020, 12, 28], [2021, 6, 28]]], ['normal control 2', [[2026, 5, 14], [2026, 5, 31], 1, False], [[2026, 5, 31]]]], [['regression month-end maturity detection 1', [[2002, 12, 31], [2005, 2, 28], 3, True], [[2003, 2, 28], [2003, 5, 31], [2003, 8, 31], [2003, 11, 30], [2004, 2, 29], [2004, 5, 31], [2004, 8, 31], [2004, 11, 30], [2005, 2, 28]]], ['regression month-end maturity detection 2', [[2024, 2, 20], [2025, 2, 28], 6, True], [[2024, 8, 31], [2025, 2, 28]]], ['partial repair probe 1', [[2001, 5, 21], [2004, 2, 29], 6, True], [[2001, 8, 31], [2002, 2, 28], [2002, 8, 31], [2003, 2, 28], [2003, 8, 31], [2004, 2, 29]]], ['partial repair probe 2', [[2017, 3, 6], [2019, 2, 28], 6, True], [[2017, 8, 31], [2018, 2, 28], [2018, 8, 31], [2019, 2, 28]]], ['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, True], [[2024, 2, 29], [2024, 8, 31], [2025, 2, 28], [2025, 8, 31]]], ['normal control 1', [[1999, 10, 23], [2003, 9, 30], 6, False], [[2000, 3, 30], [2000, 9, 30], [2001, 3, 30], [2001, 9, 30], [2002, 3, 30], [2002, 9, 30], [2003, 3, 30], [2003, 9, 30]]], ['normal control 2', [[2022, 2, 22], [2025, 6, 30], 1, True], [[2022, 3, 31], [2022, 4, 30], [2022, 5, 31], [2022, 6, 30], [2022, 7, 31], [2022, 8, 31], [2022, 9, 30], [2022, 10, 31], [2022, 11, 30], [2022, 12, 31], [2023, 1, 31], [2023, 2, 28], [2023, 3, 31], [2023, 4, 30], [2023, 5, 31], [2023, 6, 30], [2023, 7, 31], [2023, 8, 31], [2023, 9, 30], [2023, 10, 31], [2023, 11, 30], [2023, 12, 31], [2024, 1, 31], [2024, 2, 29], [2024, 3, 31], [2024, 4, 30], [2024, 5, 31], [2024, 6, 30], [2024, 7, 31], [2024, 8, 31], [2024, 9, 30], [2024, 10, 31], [2024, 11, 30], [2024, 12, 31], [2025, 1, 31], [2025, 2, 28], [2025, 3, 31], [2025, 4, 30], [2025, 5, 31], [2025, 6, 30]]]], [['regression month-end maturity detection 1', [[2032, 11, 24], [2033, 12, 30], 12, True], [[2032, 12, 30], [2033, 12, 30]]], ['regression month-end maturity detection 2', [[2026, 11, 26], [2028, 2, 29], 6, True], [[2027, 2, 28], [2027, 8, 31], [2028, 2, 29]]], ['partial repair probe 1', [[2000, 9, 13], [2003, 2, 28], 6, True], [[2001, 2, 28], [2001, 8, 31], [2002, 2, 28], [2002, 8, 31], [2003, 2, 28]]], ['partial repair probe 2', [[2011, 2, 28], [2012, 2, 29], 3, True], [[2011, 5, 31], [2011, 8, 31], [2011, 11, 30], [2012, 2, 29]]], ['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, 3, 1], [2025, 3, 15], 6, False], [[2024, 9, 15], [2025, 3, 15]]], ['normal control 1', [[2009, 9, 20], [2009, 9, 30], 6, False], [[2009, 9, 30]]], ['normal control 2', [[2026, 2, 27], [2027, 2, 17], 12, True], [[2027, 2, 17]]]], [['regression month-end maturity detection 1', [[2007, 1, 2], [2010, 1, 30], 6, True], [[2007, 1, 30], [2007, 7, 30], [2008, 1, 30], [2008, 7, 30], [2009, 1, 30], [2009, 7, 30], [2010, 1, 30]]], ['regression month-end maturity detection 2', [[2038, 6, 27], [2038, 7, 30], 3, True], [[2038, 7, 30]]], ['partial repair probe 1', [[2035, 6, 12], [2036, 2, 29], 3, True], [[2035, 8, 31], [2035, 11, 30], [2036, 2, 29]]], ['partial repair probe 2', [[2029, 4, 5], [2031, 2, 28], 6, True], [[2029, 8, 31], [2030, 2, 28], [2030, 8, 31], [2031, 2, 28]]], ['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', [[2022, 9, 24], [2025, 11, 30], 6, True], [[2022, 11, 30], [2023, 5, 31], [2023, 11, 30], [2024, 5, 31], [2024, 11, 30], [2025, 5, 31], [2025, 11, 30]]], ['normal control 2', [[2008, 1, 19], [2008, 1, 31], 12, False], [[2008, 1, 31]]]], [['regression month-end maturity detection 1', [[2004, 8, 23], [2008, 2, 29], 1, True], [[2004, 9, 30], [2004, 10, 31], [2004, 11, 30], [2004, 12, 31], [2005, 1, 31], [2005, 2, 28], [2005, 3, 31], [2005, 4, 30], [2005, 5, 31], [2005, 6, 30], [2005, 7, 31], [2005, 8, 31], [2005, 9, 30], [2005, 10, 31], [2005, 11, 30], [2005, 12, 31], [2006, 1, 31], [2006, 2, 28], [2006, 3, 31], [2006, 4, 30], [2006, 5, 31], [2006, 6, 30], [2006, 7, 31], [2006, 8, 31], [2006, 9, 30], [2006, 10, 31], [2006, 11, 30], [2006, 12, 31], [2007, 1, 31], [2007, 2, 28], [2007, 3, 31], [2007, 4, 30], [2007, 5, 31], [2007, 6, 30], [2007, 7, 31], [2007, 8, 31], [2007, 9, 30], [2007, 10, 31], [2007, 11, 30], [2007, 12, 31], [2008, 1, 31], [2008, 2, 29]]], ['regression month-end maturity detection 2', [[2014, 2, 2], [2017, 1, 30], 12, True], [[2015, 1, 30], [2016, 1, 30], [2017, 1, 30]]], ['partial repair probe 1', [[2023, 2, 20], [2027, 2, 28], 3, True], [[2023, 5, 31], [2023, 8, 31], [2023, 11, 30], [2024, 2, 29], [2024, 5, 31], [2024, 8, 31], [2024, 11, 30], [2025, 2, 28], [2025, 5, 31], [2025, 8, 31], [2025, 11, 30], [2026, 2, 28], [2026, 5, 31], [2026, 8, 31], [2026, 11, 30], [2027, 2, 28]]], ['partial repair probe 2', [[2010, 5, 22], [2014, 2, 28], 6, True], [[2010, 8, 31], [2011, 2, 28], [2011, 8, 31], [2012, 2, 29], [2012, 8, 31], [2013, 2, 28], [2013, 8, 31], [2014, 2, 28]]], ['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', [[2019, 6, 15], [2019, 6, 30], 6, True], [[2019, 6, 30]]], ['normal control 2', [[2005, 5, 5], [2006, 5, 31], 3, False], [[2005, 5, 31], [2005, 8, 31], [2005, 11, 30], [2006, 2, 28], [2006, 5, 31]]]]]
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 month-end maturity detection 1 | [[2037, 7, 30], [2038, 1, 30], [2038, 7, 30], [2039, 1, 30]] | [[2037, 7, 30], [2038, 1, 30], [2038, 7, 30], [2039, 1, 30]] | Passed |
| regression month-end maturity detection 2 | [[2014, 3, 30], [2014, 9, 30], [2015, 3, 30], [2015, 9, 30], [2016, 3, 30]] | [[2014, 3, 30], [2014, 9, 30], [2015, 3, 30], [2015, 9, 30], [2016, 3, 30]] | Passed |
| partial repair probe 1 | [[2018, 2, 28], [2018, 8, 31], [2019, 2, 28], [2019, 8, 31], [2020, 2, 29], [2020, 8, 31], [2021, 2, 28]] | [[2018, 2, 28], [2018, 8, 31], [2019, 2, 28], [2019, 8, 31], [2020, 2, 29], [2020, 8, 31], [2021, 2, 28]] | Passed |
| partial repair probe 2 | [[2014, 9, 30], [2014, 10, 31], [2014, 11, 30], [2014, 12, 31], [2015, 1, 31], [2015, 2, 28], [2015, 3, 31], [2015, 4, 30], [2015, 5, 31], [2015, 6, 30], [2015, 7, 31], [2015, 8, 31], [2015, 9, 30], [2015, 10, 31], [2015, 11, 30], [2015, 12, 31], [2016, 1, 31], [2016, 2, 29], [2016, 3, 31], [2016, 4, 30], [2016, 5, 31], [2016, 6, 30], [2016, 7, 31], [2016, 8, 31], [2016, 9, 30], [2016, 10, 31], [2016, 11, 30], [2016, 12, 31], [2017, 1, 31], [2017, 2, 28]] | [[2014, 9, 30], [2014, 10, 31], [2014, 11, 30], [2014, 12, 31], [2015, 1, 31], [2015, 2, 28], [2015, 3, 31], [2015, 4, 30], [2015, 5, 31], [2015, 6, 30], [2015, 7, 31], [2015, 8, 31], [2015, 9, 30], [2015, 10, 31], [2015, 11, 30], [2015, 12, 31], [2016, 1, 31], [2016, 2, 29], [2016, 3, 31], [2016, 4, 30], [2016, 5, 31], [2016, 6, 30], [2016, 7, 31], [2016, 8, 31], [2016, 9, 30], [2016, 10, 31], [2016, 11, 30], [2016, 12, 31], [2017, 1, 31], [2017, 2, 28]] | Passed |
| boundary control 1 | [[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 |
| boundary control 2 | [[2024, 9, 15], [2025, 3, 15]] | [[2024, 9, 15], [2025, 3, 15]] | Passed |
| normal control 1 | [[2019, 6, 28], [2019, 12, 28], [2020, 6, 28], [2020, 12, 28], [2021, 6, 28]] | [[2019, 6, 28], [2019, 12, 28], [2020, 6, 28], [2020, 12, 28], [2021, 6, 28]] | Passed |
| normal control 2 | [[2026, 5, 31]] | [[2026, 5, 31]] | Passed |
SHA-256 / 89f25ab04af07ea4bad5a6c5d963c2310eea7a0f2e0472362eb14762603eeeb7
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.678180+00:00.
Case digest / ea374475e48d75b89973716068e4c39723dfa6a06cbd5f06a2b486517392bf9e