FA-61316 / Bond day-count conventions / Open access
Coupon period lookup for a settlement date: a settlement on a coupon date is assigned to the ending period · case 01
Settling on a coupon date charges a full period of accrued interest.
ROOT CAUSE
The search uses bisect_left, which places an exact coupon date in the preceding period.
VERIFIED REPAIR
Use bisect_right so a coupon date starts the next period.
Unsuccessful approach: Special-casing only the first coupon date leaves later coupon dates misassigned.
Case contract
Inputs issue date, ascending coupon schedule (last = maturity) and settlement. Settlement before issue returns "not issued"; on or after maturity returns "matured". Otherwise return [period start, next coupon] where a settlement on a coupon date belongs to the following period and the first period starts at issue.
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
import bisect
N = 1
observations = []
def solve(issue, schedule, settle):
I = datetime.date(*issue)
dates = [datetime.date(*d) for d in schedule]
S = datetime.date(*settle)
if S < I:
return 'not issued'
if S >= dates[-1]:
return 'matured'
i = bisect.bisect_left(dates, S)
prev = dates[i - 1] if i > 0 else I
nxt = dates[i]
return [[prev.year, prev.month, prev.day], [nxt.year, nxt.month, nxt.day]]
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['regression coupon date ownership 1', [[2036, 10, 5], [[2037, 2, 28], [2038, 2, 28], [2039, 2, 28], [2040, 2, 28], [2041, 2, 28], [2042, 2, 28]], [2037, 2, 28]], [[2037, 2, 28], [2038, 2, 28]]], ['regression coupon date ownership 2', [[2005, 3, 14], [[2006, 1, 30], [2006, 7, 30], [2007, 1, 30], [2007, 7, 30]], [2007, 1, 30]], [[2007, 1, 30], [2007, 7, 30]]], ['partial repair probe 1', [[2020, 11, 21], [[2021, 1, 31], [2021, 4, 30], [2021, 7, 31], [2021, 10, 31], [2022, 1, 31]], [2021, 7, 31]], [[2021, 7, 31], [2021, 10, 31]]], ['partial repair probe 2', [[2027, 7, 19], [[2028, 3, 31], [2028, 9, 30], [2029, 3, 31], [2029, 9, 30], [2030, 3, 31], [2030, 9, 30]], [2029, 3, 31]], [[2029, 3, 31], [2029, 9, 30]]], ['normal control 1', [[2035, 7, 30], [[2036, 7, 4], [2036, 10, 4]], [2036, 7, 22]], [[2036, 7, 4], [2036, 10, 4]]], ['normal control 2', [[2017, 9, 22], [[2018, 5, 31], [2018, 8, 31], [2018, 11, 30], [2019, 2, 28], [2019, 5, 31], [2019, 8, 31]], [2018, 4, 14]], [[2017, 9, 22], [2018, 5, 31]]], ['normal control 3', [[2007, 11, 1], [[2008, 4, 20], [2009, 4, 20], [2010, 4, 20], [2011, 4, 20], [2012, 4, 20], [2013, 4, 20]], [2012, 8, 17]], [[2012, 4, 20], [2013, 4, 20]]], ['normal control 4', [[2035, 7, 7], [[2035, 12, 1], [2036, 12, 1], [2037, 12, 1], [2038, 12, 1], [2039, 12, 1]], [2035, 9, 22]], [[2035, 7, 7], [2035, 12, 1]]]], [['regression coupon date ownership 1', [[2004, 9, 18], [[2005, 5, 31], [2006, 5, 31], [2007, 5, 31], [2008, 5, 31]], [2007, 5, 31]], [[2007, 5, 31], [2008, 5, 31]]], ['regression coupon date ownership 2', [[2037, 4, 15], [[2038, 5, 9], [2038, 11, 9], [2039, 5, 9], [2039, 11, 9], [2040, 5, 9], [2040, 11, 9]], [2038, 11, 9]], [[2038, 11, 9], [2039, 5, 9]]], ['partial repair probe 1', [[2037, 2, 10], [[2038, 1, 19], [2038, 7, 19], [2039, 1, 19], [2039, 7, 19]], [2038, 7, 19]], [[2038, 7, 19], [2039, 1, 19]]], ['partial repair probe 2', [[2029, 12, 28], [[2030, 8, 25], [2030, 11, 25], [2031, 2, 25], [2031, 5, 25], [2031, 8, 25], [2031, 11, 25]], [2031, 8, 25]], [[2031, 8, 25], [2031, 11, 25]]], ['normal control 1', [[2011, 8, 10], [[2012, 8, 20], [2013, 8, 20], [2014, 8, 20], [2015, 8, 20], [2016, 8, 20]], [2014, 4, 14]], [[2013, 8, 20], [2014, 8, 20]]], ['normal control 2', [[2006, 1, 31], [[2006, 4, 22], [2006, 10, 22], [2007, 4, 22]], [2006, 2, 9]], [[2006, 1, 31], [2006, 4, 22]]], ['normal control 3', [[2017, 7, 2], [[2018, 7, 29], [2019, 7, 29], [2020, 7, 29], [2021, 7, 29], [2022, 7, 29], [2023, 7, 29]], [2017, 12, 19]], [[2017, 7, 2], [2018, 7, 29]]], ['normal control 4', [[2009, 4, 28], [[2009, 8, 28], [2009, 11, 28], [2010, 2, 28], [2010, 5, 28], [2010, 8, 28]], [2009, 4, 26]], 'not issued']], [['regression coupon date ownership 1', [[2026, 6, 8], [[2027, 1, 31], [2027, 7, 31], [2028, 1, 31], [2028, 7, 31], [2029, 1, 31]], [2027, 1, 31]], [[2027, 1, 31], [2027, 7, 31]]], ['regression coupon date ownership 2', [[2021, 7, 26], [[2022, 4, 30], [2022, 7, 30], [2022, 10, 30]], [2022, 7, 30]], [[2022, 7, 30], [2022, 10, 30]]], ['partial repair probe 1', [[2006, 6, 11], [[2007, 6, 8], [2007, 9, 8], [2007, 12, 8], [2008, 3, 8], [2008, 6, 8], [2008, 9, 8]], [2008, 6, 8]], [[2008, 6, 8], [2008, 9, 8]]], ['partial repair probe 2', [[2024, 8, 18], [[2025, 6, 18], [2025, 9, 18], [2025, 12, 18], [2026, 3, 18]], [2025, 9, 18]], [[2025, 9, 18], [2025, 12, 18]]], ['normal control 1', [[2038, 8, 29], [[2038, 12, 21], [2039, 3, 21], [2039, 6, 21], [2039, 9, 21], [2039, 12, 21]], [2039, 5, 16]], [[2039, 3, 21], [2039, 6, 21]]], ['normal control 2', [[2008, 1, 6], [[2008, 4, 30], [2008, 7, 30]], [2008, 4, 11]], [[2008, 1, 6], [2008, 4, 30]]], ['normal control 3', [[2013, 8, 10], [[2014, 1, 30], [2015, 1, 30], [2016, 1, 30], [2017, 1, 30], [2018, 1, 30], [2019, 1, 30]], [2019, 1, 30]], 'matured'], ['normal control 4', [[2007, 8, 10], [[2008, 2, 27], [2008, 5, 27]], [2007, 12, 1]], [[2007, 8, 10], [2008, 2, 27]]]], [['regression coupon date ownership 1', [[2037, 7, 21], [[2038, 2, 27], [2038, 5, 27], [2038, 8, 27]], [2038, 2, 27]], [[2038, 2, 27], [2038, 5, 27]]], ['regression coupon date ownership 2', [[2018, 2, 25], [[2019, 3, 10], [2019, 9, 10], [2020, 3, 10], [2020, 9, 10]], [2019, 3, 10]], [[2019, 3, 10], [2019, 9, 10]]], ['partial repair probe 1', [[2032, 3, 12], [[2032, 12, 14], [2033, 6, 14], [2033, 12, 14], [2034, 6, 14], [2034, 12, 14]], [2034, 6, 14]], [[2034, 6, 14], [2034, 12, 14]]], ['partial repair probe 2', [[2016, 5, 5], [[2016, 10, 31], [2017, 1, 31], [2017, 4, 30], [2017, 7, 31], [2017, 10, 31]], [2017, 4, 30]], [[2017, 4, 30], [2017, 7, 31]]], ['normal control 1', [[2040, 3, 17], [[2040, 12, 17], [2041, 6, 17]], [2040, 6, 8]], [[2040, 3, 17], [2040, 12, 17]]], ['normal control 2', [[2006, 2, 27], [[2006, 11, 2], [2007, 5, 2]], [2006, 4, 2]], [[2006, 2, 27], [2006, 11, 2]]], ['normal control 3', [[2023, 4, 11], [[2024, 4, 20], [2025, 4, 20], [2026, 4, 20], [2027, 4, 20], [2028, 4, 20]], [2024, 4, 4]], [[2023, 4, 11], [2024, 4, 20]]], ['normal control 4', [[2040, 10, 29], [[2040, 11, 13], [2041, 2, 13], [2041, 5, 13], [2041, 8, 13], [2041, 11, 13], [2042, 2, 13]], [2040, 11, 7]], [[2040, 10, 29], [2040, 11, 13]]]], [['regression coupon date ownership 1', [[2037, 11, 10], [[2038, 3, 31], [2038, 6, 30], [2038, 9, 30], [2038, 12, 31]], [2038, 3, 31]], [[2038, 3, 31], [2038, 6, 30]]], ['regression coupon date ownership 2', [[2019, 2, 10], [[2019, 11, 28], [2020, 5, 28], [2020, 11, 28], [2021, 5, 28]], [2020, 5, 28]], [[2020, 5, 28], [2020, 11, 28]]], ['partial repair probe 1', [[2010, 6, 29], [[2011, 5, 31], [2012, 5, 31], [2013, 5, 31], [2014, 5, 31], [2015, 5, 31]], [2012, 5, 31]], [[2012, 5, 31], [2013, 5, 31]]], ['partial repair probe 2', [[2004, 11, 28], [[2005, 8, 24], [2006, 8, 24], [2007, 8, 24], [2008, 8, 24], [2009, 8, 24]], [2008, 8, 24]], [[2008, 8, 24], [2009, 8, 24]]], ['normal control 1', [[2023, 2, 24], [[2023, 6, 18], [2023, 12, 18], [2024, 6, 18], [2024, 12, 18], [2025, 6, 18], [2025, 12, 18]], [2023, 9, 4]], [[2023, 6, 18], [2023, 12, 18]]], ['normal control 2', [[2032, 10, 14], [[2033, 5, 30], [2034, 5, 30], [2035, 5, 30], [2036, 5, 30], [2037, 5, 30], [2038, 5, 30]], [2034, 2, 28]], [[2033, 5, 30], [2034, 5, 30]]], ['normal control 3', [[2021, 9, 10], [[2022, 4, 21], [2023, 4, 21]], [2023, 4, 21]], 'matured'], ['normal control 4', [[2010, 11, 2], [[2011, 3, 17], [2011, 9, 17], [2012, 3, 17]], [2011, 12, 2]], [[2011, 9, 17], [2012, 3, 17]]]]]
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 coupon date ownership 1 | [[2036, 10, 5], [2037, 2, 28]] | [[2037, 2, 28], [2038, 2, 28]] | Failed |
| regression coupon date ownership 2 | [[2006, 7, 30], [2007, 1, 30]] | [[2007, 1, 30], [2007, 7, 30]] | Failed |
| partial repair probe 1 | [[2021, 4, 30], [2021, 7, 31]] | [[2021, 7, 31], [2021, 10, 31]] | Failed |
| partial repair probe 2 | [[2028, 9, 30], [2029, 3, 31]] | [[2029, 3, 31], [2029, 9, 30]] | Failed |
| normal control 1 | [[2036, 7, 4], [2036, 10, 4]] | [[2036, 7, 4], [2036, 10, 4]] | Passed |
| normal control 2 | [[2017, 9, 22], [2018, 5, 31]] | [[2017, 9, 22], [2018, 5, 31]] | Passed |
| normal control 3 | [[2012, 4, 20], [2013, 4, 20]] | [[2012, 4, 20], [2013, 4, 20]] | Passed |
| normal control 4 | [[2035, 7, 7], [2035, 12, 1]] | [[2035, 7, 7], [2035, 12, 1]] | Passed |
SHA-256 / 2a3f7b4c941ead41d3e71d5e3c8b06086335ed81ee6a00424ebfe988a287e6bb
2 / The unsuccessful fix
Exit 1"""Failure Map reference implementation. Python standard library only."""
import json
import datetime
import bisect
N = 1
observations = []
def solve(issue, schedule, settle):
I = datetime.date(*issue)
dates = [datetime.date(*d) for d in schedule]
S = datetime.date(*settle)
if S < I:
return 'not issued'
if S >= dates[-1]:
return 'matured'
i = bisect.bisect_left(dates, S) + (1 if S == dates[0] else 0)
prev = dates[i - 1] if i > 0 else I
nxt = dates[i]
return [[prev.year, prev.month, prev.day], [nxt.year, nxt.month, nxt.day]]
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['regression coupon date ownership 1', [[2036, 10, 5], [[2037, 2, 28], [2038, 2, 28], [2039, 2, 28], [2040, 2, 28], [2041, 2, 28], [2042, 2, 28]], [2037, 2, 28]], [[2037, 2, 28], [2038, 2, 28]]], ['regression coupon date ownership 2', [[2005, 3, 14], [[2006, 1, 30], [2006, 7, 30], [2007, 1, 30], [2007, 7, 30]], [2007, 1, 30]], [[2007, 1, 30], [2007, 7, 30]]], ['partial repair probe 1', [[2020, 11, 21], [[2021, 1, 31], [2021, 4, 30], [2021, 7, 31], [2021, 10, 31], [2022, 1, 31]], [2021, 7, 31]], [[2021, 7, 31], [2021, 10, 31]]], ['partial repair probe 2', [[2027, 7, 19], [[2028, 3, 31], [2028, 9, 30], [2029, 3, 31], [2029, 9, 30], [2030, 3, 31], [2030, 9, 30]], [2029, 3, 31]], [[2029, 3, 31], [2029, 9, 30]]], ['normal control 1', [[2035, 7, 30], [[2036, 7, 4], [2036, 10, 4]], [2036, 7, 22]], [[2036, 7, 4], [2036, 10, 4]]], ['normal control 2', [[2017, 9, 22], [[2018, 5, 31], [2018, 8, 31], [2018, 11, 30], [2019, 2, 28], [2019, 5, 31], [2019, 8, 31]], [2018, 4, 14]], [[2017, 9, 22], [2018, 5, 31]]], ['normal control 3', [[2007, 11, 1], [[2008, 4, 20], [2009, 4, 20], [2010, 4, 20], [2011, 4, 20], [2012, 4, 20], [2013, 4, 20]], [2012, 8, 17]], [[2012, 4, 20], [2013, 4, 20]]], ['normal control 4', [[2035, 7, 7], [[2035, 12, 1], [2036, 12, 1], [2037, 12, 1], [2038, 12, 1], [2039, 12, 1]], [2035, 9, 22]], [[2035, 7, 7], [2035, 12, 1]]]], [['regression coupon date ownership 1', [[2004, 9, 18], [[2005, 5, 31], [2006, 5, 31], [2007, 5, 31], [2008, 5, 31]], [2007, 5, 31]], [[2007, 5, 31], [2008, 5, 31]]], ['regression coupon date ownership 2', [[2037, 4, 15], [[2038, 5, 9], [2038, 11, 9], [2039, 5, 9], [2039, 11, 9], [2040, 5, 9], [2040, 11, 9]], [2038, 11, 9]], [[2038, 11, 9], [2039, 5, 9]]], ['partial repair probe 1', [[2037, 2, 10], [[2038, 1, 19], [2038, 7, 19], [2039, 1, 19], [2039, 7, 19]], [2038, 7, 19]], [[2038, 7, 19], [2039, 1, 19]]], ['partial repair probe 2', [[2029, 12, 28], [[2030, 8, 25], [2030, 11, 25], [2031, 2, 25], [2031, 5, 25], [2031, 8, 25], [2031, 11, 25]], [2031, 8, 25]], [[2031, 8, 25], [2031, 11, 25]]], ['normal control 1', [[2011, 8, 10], [[2012, 8, 20], [2013, 8, 20], [2014, 8, 20], [2015, 8, 20], [2016, 8, 20]], [2014, 4, 14]], [[2013, 8, 20], [2014, 8, 20]]], ['normal control 2', [[2006, 1, 31], [[2006, 4, 22], [2006, 10, 22], [2007, 4, 22]], [2006, 2, 9]], [[2006, 1, 31], [2006, 4, 22]]], ['normal control 3', [[2017, 7, 2], [[2018, 7, 29], [2019, 7, 29], [2020, 7, 29], [2021, 7, 29], [2022, 7, 29], [2023, 7, 29]], [2017, 12, 19]], [[2017, 7, 2], [2018, 7, 29]]], ['normal control 4', [[2009, 4, 28], [[2009, 8, 28], [2009, 11, 28], [2010, 2, 28], [2010, 5, 28], [2010, 8, 28]], [2009, 4, 26]], 'not issued']], [['regression coupon date ownership 1', [[2026, 6, 8], [[2027, 1, 31], [2027, 7, 31], [2028, 1, 31], [2028, 7, 31], [2029, 1, 31]], [2027, 1, 31]], [[2027, 1, 31], [2027, 7, 31]]], ['regression coupon date ownership 2', [[2021, 7, 26], [[2022, 4, 30], [2022, 7, 30], [2022, 10, 30]], [2022, 7, 30]], [[2022, 7, 30], [2022, 10, 30]]], ['partial repair probe 1', [[2006, 6, 11], [[2007, 6, 8], [2007, 9, 8], [2007, 12, 8], [2008, 3, 8], [2008, 6, 8], [2008, 9, 8]], [2008, 6, 8]], [[2008, 6, 8], [2008, 9, 8]]], ['partial repair probe 2', [[2024, 8, 18], [[2025, 6, 18], [2025, 9, 18], [2025, 12, 18], [2026, 3, 18]], [2025, 9, 18]], [[2025, 9, 18], [2025, 12, 18]]], ['normal control 1', [[2038, 8, 29], [[2038, 12, 21], [2039, 3, 21], [2039, 6, 21], [2039, 9, 21], [2039, 12, 21]], [2039, 5, 16]], [[2039, 3, 21], [2039, 6, 21]]], ['normal control 2', [[2008, 1, 6], [[2008, 4, 30], [2008, 7, 30]], [2008, 4, 11]], [[2008, 1, 6], [2008, 4, 30]]], ['normal control 3', [[2013, 8, 10], [[2014, 1, 30], [2015, 1, 30], [2016, 1, 30], [2017, 1, 30], [2018, 1, 30], [2019, 1, 30]], [2019, 1, 30]], 'matured'], ['normal control 4', [[2007, 8, 10], [[2008, 2, 27], [2008, 5, 27]], [2007, 12, 1]], [[2007, 8, 10], [2008, 2, 27]]]], [['regression coupon date ownership 1', [[2037, 7, 21], [[2038, 2, 27], [2038, 5, 27], [2038, 8, 27]], [2038, 2, 27]], [[2038, 2, 27], [2038, 5, 27]]], ['regression coupon date ownership 2', [[2018, 2, 25], [[2019, 3, 10], [2019, 9, 10], [2020, 3, 10], [2020, 9, 10]], [2019, 3, 10]], [[2019, 3, 10], [2019, 9, 10]]], ['partial repair probe 1', [[2032, 3, 12], [[2032, 12, 14], [2033, 6, 14], [2033, 12, 14], [2034, 6, 14], [2034, 12, 14]], [2034, 6, 14]], [[2034, 6, 14], [2034, 12, 14]]], ['partial repair probe 2', [[2016, 5, 5], [[2016, 10, 31], [2017, 1, 31], [2017, 4, 30], [2017, 7, 31], [2017, 10, 31]], [2017, 4, 30]], [[2017, 4, 30], [2017, 7, 31]]], ['normal control 1', [[2040, 3, 17], [[2040, 12, 17], [2041, 6, 17]], [2040, 6, 8]], [[2040, 3, 17], [2040, 12, 17]]], ['normal control 2', [[2006, 2, 27], [[2006, 11, 2], [2007, 5, 2]], [2006, 4, 2]], [[2006, 2, 27], [2006, 11, 2]]], ['normal control 3', [[2023, 4, 11], [[2024, 4, 20], [2025, 4, 20], [2026, 4, 20], [2027, 4, 20], [2028, 4, 20]], [2024, 4, 4]], [[2023, 4, 11], [2024, 4, 20]]], ['normal control 4', [[2040, 10, 29], [[2040, 11, 13], [2041, 2, 13], [2041, 5, 13], [2041, 8, 13], [2041, 11, 13], [2042, 2, 13]], [2040, 11, 7]], [[2040, 10, 29], [2040, 11, 13]]]], [['regression coupon date ownership 1', [[2037, 11, 10], [[2038, 3, 31], [2038, 6, 30], [2038, 9, 30], [2038, 12, 31]], [2038, 3, 31]], [[2038, 3, 31], [2038, 6, 30]]], ['regression coupon date ownership 2', [[2019, 2, 10], [[2019, 11, 28], [2020, 5, 28], [2020, 11, 28], [2021, 5, 28]], [2020, 5, 28]], [[2020, 5, 28], [2020, 11, 28]]], ['partial repair probe 1', [[2010, 6, 29], [[2011, 5, 31], [2012, 5, 31], [2013, 5, 31], [2014, 5, 31], [2015, 5, 31]], [2012, 5, 31]], [[2012, 5, 31], [2013, 5, 31]]], ['partial repair probe 2', [[2004, 11, 28], [[2005, 8, 24], [2006, 8, 24], [2007, 8, 24], [2008, 8, 24], [2009, 8, 24]], [2008, 8, 24]], [[2008, 8, 24], [2009, 8, 24]]], ['normal control 1', [[2023, 2, 24], [[2023, 6, 18], [2023, 12, 18], [2024, 6, 18], [2024, 12, 18], [2025, 6, 18], [2025, 12, 18]], [2023, 9, 4]], [[2023, 6, 18], [2023, 12, 18]]], ['normal control 2', [[2032, 10, 14], [[2033, 5, 30], [2034, 5, 30], [2035, 5, 30], [2036, 5, 30], [2037, 5, 30], [2038, 5, 30]], [2034, 2, 28]], [[2033, 5, 30], [2034, 5, 30]]], ['normal control 3', [[2021, 9, 10], [[2022, 4, 21], [2023, 4, 21]], [2023, 4, 21]], 'matured'], ['normal control 4', [[2010, 11, 2], [[2011, 3, 17], [2011, 9, 17], [2012, 3, 17]], [2011, 12, 2]], [[2011, 9, 17], [2012, 3, 17]]]]]
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 coupon date ownership 1 | [[2037, 2, 28], [2038, 2, 28]] | [[2037, 2, 28], [2038, 2, 28]] | Passed |
| regression coupon date ownership 2 | [[2006, 7, 30], [2007, 1, 30]] | [[2007, 1, 30], [2007, 7, 30]] | Failed |
| partial repair probe 1 | [[2021, 4, 30], [2021, 7, 31]] | [[2021, 7, 31], [2021, 10, 31]] | Failed |
| partial repair probe 2 | [[2028, 9, 30], [2029, 3, 31]] | [[2029, 3, 31], [2029, 9, 30]] | Failed |
| normal control 1 | [[2036, 7, 4], [2036, 10, 4]] | [[2036, 7, 4], [2036, 10, 4]] | Passed |
| normal control 2 | [[2017, 9, 22], [2018, 5, 31]] | [[2017, 9, 22], [2018, 5, 31]] | Passed |
| normal control 3 | [[2012, 4, 20], [2013, 4, 20]] | [[2012, 4, 20], [2013, 4, 20]] | Passed |
| normal control 4 | [[2035, 7, 7], [2035, 12, 1]] | [[2035, 7, 7], [2035, 12, 1]] | Passed |
SHA-256 / 668b2d0a6e151a5be094ae511c5c94584d83dd5353c7ed5e5a3373a4abded5b7
3 / The verified repair
Exit 0"""Failure Map reference implementation. Python standard library only."""
import json
import datetime
import bisect
N = 1
observations = []
def solve(issue, schedule, settle):
I = datetime.date(*issue)
dates = [datetime.date(*d) for d in schedule]
S = datetime.date(*settle)
if S < I:
return 'not issued'
if S >= dates[-1]:
return 'matured'
i = bisect.bisect_right(dates, S)
prev = dates[i - 1] if i > 0 else I
nxt = dates[i]
return [[prev.year, prev.month, prev.day], [nxt.year, nxt.month, nxt.day]]
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['regression coupon date ownership 1', [[2036, 10, 5], [[2037, 2, 28], [2038, 2, 28], [2039, 2, 28], [2040, 2, 28], [2041, 2, 28], [2042, 2, 28]], [2037, 2, 28]], [[2037, 2, 28], [2038, 2, 28]]], ['regression coupon date ownership 2', [[2005, 3, 14], [[2006, 1, 30], [2006, 7, 30], [2007, 1, 30], [2007, 7, 30]], [2007, 1, 30]], [[2007, 1, 30], [2007, 7, 30]]], ['partial repair probe 1', [[2020, 11, 21], [[2021, 1, 31], [2021, 4, 30], [2021, 7, 31], [2021, 10, 31], [2022, 1, 31]], [2021, 7, 31]], [[2021, 7, 31], [2021, 10, 31]]], ['partial repair probe 2', [[2027, 7, 19], [[2028, 3, 31], [2028, 9, 30], [2029, 3, 31], [2029, 9, 30], [2030, 3, 31], [2030, 9, 30]], [2029, 3, 31]], [[2029, 3, 31], [2029, 9, 30]]], ['normal control 1', [[2035, 7, 30], [[2036, 7, 4], [2036, 10, 4]], [2036, 7, 22]], [[2036, 7, 4], [2036, 10, 4]]], ['normal control 2', [[2017, 9, 22], [[2018, 5, 31], [2018, 8, 31], [2018, 11, 30], [2019, 2, 28], [2019, 5, 31], [2019, 8, 31]], [2018, 4, 14]], [[2017, 9, 22], [2018, 5, 31]]], ['normal control 3', [[2007, 11, 1], [[2008, 4, 20], [2009, 4, 20], [2010, 4, 20], [2011, 4, 20], [2012, 4, 20], [2013, 4, 20]], [2012, 8, 17]], [[2012, 4, 20], [2013, 4, 20]]], ['normal control 4', [[2035, 7, 7], [[2035, 12, 1], [2036, 12, 1], [2037, 12, 1], [2038, 12, 1], [2039, 12, 1]], [2035, 9, 22]], [[2035, 7, 7], [2035, 12, 1]]]], [['regression coupon date ownership 1', [[2004, 9, 18], [[2005, 5, 31], [2006, 5, 31], [2007, 5, 31], [2008, 5, 31]], [2007, 5, 31]], [[2007, 5, 31], [2008, 5, 31]]], ['regression coupon date ownership 2', [[2037, 4, 15], [[2038, 5, 9], [2038, 11, 9], [2039, 5, 9], [2039, 11, 9], [2040, 5, 9], [2040, 11, 9]], [2038, 11, 9]], [[2038, 11, 9], [2039, 5, 9]]], ['partial repair probe 1', [[2037, 2, 10], [[2038, 1, 19], [2038, 7, 19], [2039, 1, 19], [2039, 7, 19]], [2038, 7, 19]], [[2038, 7, 19], [2039, 1, 19]]], ['partial repair probe 2', [[2029, 12, 28], [[2030, 8, 25], [2030, 11, 25], [2031, 2, 25], [2031, 5, 25], [2031, 8, 25], [2031, 11, 25]], [2031, 8, 25]], [[2031, 8, 25], [2031, 11, 25]]], ['normal control 1', [[2011, 8, 10], [[2012, 8, 20], [2013, 8, 20], [2014, 8, 20], [2015, 8, 20], [2016, 8, 20]], [2014, 4, 14]], [[2013, 8, 20], [2014, 8, 20]]], ['normal control 2', [[2006, 1, 31], [[2006, 4, 22], [2006, 10, 22], [2007, 4, 22]], [2006, 2, 9]], [[2006, 1, 31], [2006, 4, 22]]], ['normal control 3', [[2017, 7, 2], [[2018, 7, 29], [2019, 7, 29], [2020, 7, 29], [2021, 7, 29], [2022, 7, 29], [2023, 7, 29]], [2017, 12, 19]], [[2017, 7, 2], [2018, 7, 29]]], ['normal control 4', [[2009, 4, 28], [[2009, 8, 28], [2009, 11, 28], [2010, 2, 28], [2010, 5, 28], [2010, 8, 28]], [2009, 4, 26]], 'not issued']], [['regression coupon date ownership 1', [[2026, 6, 8], [[2027, 1, 31], [2027, 7, 31], [2028, 1, 31], [2028, 7, 31], [2029, 1, 31]], [2027, 1, 31]], [[2027, 1, 31], [2027, 7, 31]]], ['regression coupon date ownership 2', [[2021, 7, 26], [[2022, 4, 30], [2022, 7, 30], [2022, 10, 30]], [2022, 7, 30]], [[2022, 7, 30], [2022, 10, 30]]], ['partial repair probe 1', [[2006, 6, 11], [[2007, 6, 8], [2007, 9, 8], [2007, 12, 8], [2008, 3, 8], [2008, 6, 8], [2008, 9, 8]], [2008, 6, 8]], [[2008, 6, 8], [2008, 9, 8]]], ['partial repair probe 2', [[2024, 8, 18], [[2025, 6, 18], [2025, 9, 18], [2025, 12, 18], [2026, 3, 18]], [2025, 9, 18]], [[2025, 9, 18], [2025, 12, 18]]], ['normal control 1', [[2038, 8, 29], [[2038, 12, 21], [2039, 3, 21], [2039, 6, 21], [2039, 9, 21], [2039, 12, 21]], [2039, 5, 16]], [[2039, 3, 21], [2039, 6, 21]]], ['normal control 2', [[2008, 1, 6], [[2008, 4, 30], [2008, 7, 30]], [2008, 4, 11]], [[2008, 1, 6], [2008, 4, 30]]], ['normal control 3', [[2013, 8, 10], [[2014, 1, 30], [2015, 1, 30], [2016, 1, 30], [2017, 1, 30], [2018, 1, 30], [2019, 1, 30]], [2019, 1, 30]], 'matured'], ['normal control 4', [[2007, 8, 10], [[2008, 2, 27], [2008, 5, 27]], [2007, 12, 1]], [[2007, 8, 10], [2008, 2, 27]]]], [['regression coupon date ownership 1', [[2037, 7, 21], [[2038, 2, 27], [2038, 5, 27], [2038, 8, 27]], [2038, 2, 27]], [[2038, 2, 27], [2038, 5, 27]]], ['regression coupon date ownership 2', [[2018, 2, 25], [[2019, 3, 10], [2019, 9, 10], [2020, 3, 10], [2020, 9, 10]], [2019, 3, 10]], [[2019, 3, 10], [2019, 9, 10]]], ['partial repair probe 1', [[2032, 3, 12], [[2032, 12, 14], [2033, 6, 14], [2033, 12, 14], [2034, 6, 14], [2034, 12, 14]], [2034, 6, 14]], [[2034, 6, 14], [2034, 12, 14]]], ['partial repair probe 2', [[2016, 5, 5], [[2016, 10, 31], [2017, 1, 31], [2017, 4, 30], [2017, 7, 31], [2017, 10, 31]], [2017, 4, 30]], [[2017, 4, 30], [2017, 7, 31]]], ['normal control 1', [[2040, 3, 17], [[2040, 12, 17], [2041, 6, 17]], [2040, 6, 8]], [[2040, 3, 17], [2040, 12, 17]]], ['normal control 2', [[2006, 2, 27], [[2006, 11, 2], [2007, 5, 2]], [2006, 4, 2]], [[2006, 2, 27], [2006, 11, 2]]], ['normal control 3', [[2023, 4, 11], [[2024, 4, 20], [2025, 4, 20], [2026, 4, 20], [2027, 4, 20], [2028, 4, 20]], [2024, 4, 4]], [[2023, 4, 11], [2024, 4, 20]]], ['normal control 4', [[2040, 10, 29], [[2040, 11, 13], [2041, 2, 13], [2041, 5, 13], [2041, 8, 13], [2041, 11, 13], [2042, 2, 13]], [2040, 11, 7]], [[2040, 10, 29], [2040, 11, 13]]]], [['regression coupon date ownership 1', [[2037, 11, 10], [[2038, 3, 31], [2038, 6, 30], [2038, 9, 30], [2038, 12, 31]], [2038, 3, 31]], [[2038, 3, 31], [2038, 6, 30]]], ['regression coupon date ownership 2', [[2019, 2, 10], [[2019, 11, 28], [2020, 5, 28], [2020, 11, 28], [2021, 5, 28]], [2020, 5, 28]], [[2020, 5, 28], [2020, 11, 28]]], ['partial repair probe 1', [[2010, 6, 29], [[2011, 5, 31], [2012, 5, 31], [2013, 5, 31], [2014, 5, 31], [2015, 5, 31]], [2012, 5, 31]], [[2012, 5, 31], [2013, 5, 31]]], ['partial repair probe 2', [[2004, 11, 28], [[2005, 8, 24], [2006, 8, 24], [2007, 8, 24], [2008, 8, 24], [2009, 8, 24]], [2008, 8, 24]], [[2008, 8, 24], [2009, 8, 24]]], ['normal control 1', [[2023, 2, 24], [[2023, 6, 18], [2023, 12, 18], [2024, 6, 18], [2024, 12, 18], [2025, 6, 18], [2025, 12, 18]], [2023, 9, 4]], [[2023, 6, 18], [2023, 12, 18]]], ['normal control 2', [[2032, 10, 14], [[2033, 5, 30], [2034, 5, 30], [2035, 5, 30], [2036, 5, 30], [2037, 5, 30], [2038, 5, 30]], [2034, 2, 28]], [[2033, 5, 30], [2034, 5, 30]]], ['normal control 3', [[2021, 9, 10], [[2022, 4, 21], [2023, 4, 21]], [2023, 4, 21]], 'matured'], ['normal control 4', [[2010, 11, 2], [[2011, 3, 17], [2011, 9, 17], [2012, 3, 17]], [2011, 12, 2]], [[2011, 9, 17], [2012, 3, 17]]]]]
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 coupon date ownership 1 | [[2037, 2, 28], [2038, 2, 28]] | [[2037, 2, 28], [2038, 2, 28]] | Passed |
| regression coupon date ownership 2 | [[2007, 1, 30], [2007, 7, 30]] | [[2007, 1, 30], [2007, 7, 30]] | Passed |
| partial repair probe 1 | [[2021, 7, 31], [2021, 10, 31]] | [[2021, 7, 31], [2021, 10, 31]] | Passed |
| partial repair probe 2 | [[2029, 3, 31], [2029, 9, 30]] | [[2029, 3, 31], [2029, 9, 30]] | Passed |
| normal control 1 | [[2036, 7, 4], [2036, 10, 4]] | [[2036, 7, 4], [2036, 10, 4]] | Passed |
| normal control 2 | [[2017, 9, 22], [2018, 5, 31]] | [[2017, 9, 22], [2018, 5, 31]] | Passed |
| normal control 3 | [[2012, 4, 20], [2013, 4, 20]] | [[2012, 4, 20], [2013, 4, 20]] | Passed |
| normal control 4 | [[2035, 7, 7], [2035, 12, 1]] | [[2035, 7, 7], [2035, 12, 1]] | Passed |
SHA-256 / c8e1da18f4d87042880b49831e59b69dfc04a4183bf0b0c5b1d568af215fb86c
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:54.210959+00:00.
Case digest / c28fca7bc84bd094f4139462aabb866ecbfc383a4944ba1535d4e08c0f344b04