FAILURE MAP
← Case archive

FA-61131 / Bond day-count conventions / Open access

Inflation-linked reference index interpolation: the interpolation uses two- and one-month lags · case 01

The reference index is one month too recent.

Verified by executionVariant 1 · 8 checks per implementationDownload source bundle ↓JSON ↗

ROOT CAUSE

The lagged index keys are m-2 and m-1 instead of m-3 and m-2.

VERIFIED REPAIR

Interpolate between the third and second preceding months.

Unsuccessful approach: Fixing only the lower lag interpolates across a two-month gap.

Case contract

Inputs a date [y,m,d], a map "YYYY-MM" to CPI level and a base index. RefCPI = CPI(m-3) + (d-1)/days_in_month(m) * (CPI(m-2) - CPI(m-3)), computed in Decimal and rounded half-up to 5 decimals; the index ratio is RefCPI/base rounded half-up to 5 decimals. Return both as strings.

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
from decimal import Decimal, ROUND_HALF_UP, ROUND_DOWN
N = 1
observations = []
def solve(date, cpi, base):
    y, m, d = date
    def key(k):
        t = y * 12 + (m - 1) - k
        return '%04d-%02d' % (t // 12, t % 12 + 1)
    def mlen(yy, mm):
        if mm == 2:
            return 29 if (yy % 4 == 0 and yy % 100 != 0) or yy % 400 == 0 else 28
        return 30 if mm in (4, 6, 9, 11) else 31
    c3 = Decimal(str(cpi[key(2)]))
    c2 = Decimal(str(cpi[key(1)]))
    ref = c3 + Decimal(d - 1) / Decimal(mlen(y, m)) * (c2 - c3)
    q = Decimal('0.00001')
    ref = ref.quantize(q, rounding=ROUND_HALF_UP)
    ratio = (ref / Decimal(str(base))).quantize(q, rounding=ROUND_HALF_UP)
    return [str(ref), str(ratio)]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['regression reference month lags 1', [[2014, 3, 12], {'2013-10': 285.004, '2013-11': 284.763, '2013-12': 285.943, '2014-01': 286.085, '2014-02': 286.493}, 252.22559], ['285.99339', '1.13388']], ['regression reference month lags 2', [[2030, 4, 8], {'2029-11': 320.66, '2029-12': 321.26, '2030-01': 322.249, '2030-02': 323.636, '2030-03': 323.815}, 269.90041], ['322.57263', '1.19515']], ['partial repair probe 1', [[2015, 7, 7], {'2015-02': 264.924, '2015-03': 265.93, '2015-04': 265.338, '2015-05': 264.603, '2015-06': 265.431}, 181.72035], ['265.19574', '1.45936']], ['partial repair probe 2', [[2027, 6, 15], {'2027-01': 231.116, '2027-02': 231.355, '2027-03': 231.897, '2027-04': 233.364, '2027-05': 232.897}, 199.93903], ['232.58160', '1.16326']], ['normal control 1', [[2024, 3, 1], {'2023-10': 260.395, '2023-11': 260.124, '2023-12': 259.903, '2024-01': 261.332, '2024-02': 261.114}, 191.32116], ['259.90300', '1.35846']], ['normal control 2', [[2020, 12, 15], {'2020-07': 230.527, '2020-08': 229.871, '2020-09': 229.539, '2020-10': 229.33, '2020-11': 229.649}, 237.40667], ['229.44461', '0.96646']], ['normal control 3', [[2015, 8, 31], {'2015-03': 281.76, '2015-04': 283.056, '2015-05': 282.318, '2015-06': 282.694, '2015-07': 283.913}, 233.30576], ['282.68187', '1.21164']], ['normal control 4', [[2012, 10, 1], {'2012-05': 231.342, '2012-06': 231.179, '2012-07': 232.299, '2012-08': 233.028, '2012-09': 233.246}, 270.97933], ['232.29900', '0.85726']]], [['regression reference month lags 1', [[2023, 1, 1], {'2022-08': 266.711, '2022-09': 267.206, '2022-10': 266.956, '2022-11': 268.536, '2022-12': 267.908}, 197.53338], ['266.95600', '1.35145']], ['regression reference month lags 2', [[2031, 1, 1], {'2030-08': 253.541, '2030-09': 253.435, '2030-10': 254.441, '2030-11': 254.579, '2030-12': 254.877}, 270.24681], ['254.44100', '0.94151']], ['partial repair probe 1', [[2017, 7, 21], {'2017-02': 224.025, '2017-03': 225.528, '2017-04': 225.83, '2017-05': 225.106, '2017-06': 224.778}, 229.55085], ['225.36290', '0.98176']], ['partial repair probe 2', [[2030, 6, 26], {'2030-01': 225.478, '2030-02': 226.266, '2030-03': 227.364, '2030-04': 226.998, '2030-05': 227.552}, 276.92924], ['227.05900', '0.81992']], ['normal control 1', [[2023, 6, 30], {'2023-01': 312.952, '2023-02': 313.427, '2023-03': 314.771, '2023-04': 315.869, '2023-05': 316.72}, 241.8232], ['315.83240', '1.30605']], ['normal control 2', [[2021, 9, 15], {'2021-04': 245.557, '2021-05': 245.498, '2021-06': 247.019, '2021-07': 246.276, '2021-08': 246.4}, 262.61553], ['246.67227', '0.93929']], ['normal control 3', [[2026, 10, 15], {'2026-05': 276.443, '2026-06': 277.626, '2026-07': 278.463, '2026-08': 277.845, '2026-09': 278.06}, 240.91398], ['278.18390', '1.15470']], ['normal control 4', [[2019, 6, 15], {'2019-01': 236.666, '2019-02': 235.995, '2019-03': 237.532, '2019-04': 238.097, '2019-05': 239.059}, 281.04403], ['237.79567', '0.84612']]], [['regression reference month lags 1', [[2028, 5, 15], {'2027-12': 304.238, '2028-01': 303.687, '2028-02': 302.908, '2028-03': 302.755, '2028-04': 302.122}, 299.2292], ['302.83890', '1.01206']], ['regression reference month lags 2', [[2030, 3, 6], {'2029-10': 295.309, '2029-11': 296.907, '2029-12': 296.367, '2030-01': 296.489, '2030-02': 296.839}, 299.08836], ['296.38668', '0.99097']], ['partial repair probe 1', [[2013, 2, 15], {'2012-09': 253.875, '2012-10': 254.039, '2012-11': 254.645, '2012-12': 254.658, '2013-01': 255.573}, 287.96727], ['254.65150', '0.88431']], ['partial repair probe 2', [[2021, 6, 29], {'2021-01': 279.907, '2021-02': 281.5, '2021-03': 281.113, '2021-04': 282.438, '2021-05': 282.5}, 192.97556], ['282.34967', '1.46314']], ['normal control 1', [[2030, 12, 28], {'2030-07': 306.559, '2030-08': 307.218, '2030-09': 306.68, '2030-10': 306.55, '2030-11': 306.188}, 195.67727], ['306.56677', '1.56670']], ['normal control 2', [[2017, 1, 1], {'2016-08': 253.152, '2016-09': 252.764, '2016-10': 252.052, '2016-11': 252.954, '2016-12': 253.05}, 198.61459], ['252.05200', '1.26905']], ['normal control 3', [[2013, 10, 1], {'2013-05': 255.612, '2013-06': 255.479, '2013-07': 256.153, '2013-08': 256.766, '2013-09': 257.865}, 181.76172], ['256.15300', '1.40928']], ['normal control 4', [[2021, 12, 1], {'2021-07': 234.843, '2021-08': 234.85, '2021-09': 234.44, '2021-10': 233.772, '2021-11': 234.991}, 266.07765], ['234.44000', '0.88110']]], [['regression reference month lags 1', [[2015, 2, 1], {'2014-09': 319.269, '2014-10': 319.577, '2014-11': 320.339, '2014-12': 320.392, '2015-01': 321.197}, 282.48459], ['320.33900', '1.13401']], ['regression reference month lags 2', [[2024, 1, 15], {'2023-08': 233.441, '2023-09': 234.867, '2023-10': 235.312, '2023-11': 235.728, '2023-12': 236.834}, 192.24828], ['235.49987', '1.22498']], ['partial repair probe 1', [[2023, 5, 15], {'2022-12': 296.712, '2023-01': 296.358, '2023-02': 295.92, '2023-03': 296.339, '2023-04': 296.201}, 262.58209], ['296.10923', '1.12768']], ['partial repair probe 2', [[2031, 4, 15], {'2030-11': 276.002, '2030-12': 276.34, '2031-01': 277.14, '2031-02': 278.213, '2031-03': 278.53}, 212.74273], ['277.64073', '1.30505']], ['normal control 1', [[2027, 6, 15], {'2027-01': 297.464, '2027-02': 298.353, '2027-03': 297.828, '2027-04': 298.397, '2027-05': 299.751}, 288.66356], ['298.09353', '1.03267']], ['normal control 2', [[2031, 8, 1], {'2031-03': 240.007, '2031-04': 240.309, '2031-05': 241.463, '2031-06': 242.242, '2031-07': 242.084}, 271.3525], ['241.46300', '0.88985']], ['normal control 3', [[2019, 5, 15], {'2018-12': 306.522, '2019-01': 307.912, '2019-02': 307.791, '2019-03': 309.196, '2019-04': 308.809}, 296.31991], ['308.42552', '1.04085']], ['normal control 4', [[2021, 8, 1], {'2021-03': 252.51, '2021-04': 252.577, '2021-05': 253.222, '2021-06': 252.785, '2021-07': 252.64}, 203.10318], ['253.22200', '1.24677']]], [['regression reference month lags 1', [[2017, 2, 6], {'2016-09': 292.897, '2016-10': 293.829, '2016-11': 293.12, '2016-12': 292.997, '2017-01': 293.992}, 240.77423], ['293.09804', '1.21731']], ['regression reference month lags 2', [[2030, 5, 1], {'2029-12': 247.076, '2030-01': 246.589, '2030-02': 245.812, '2030-03': 245.36, '2030-04': 244.958}, 248.74245], ['245.81200', '0.98822']], ['partial repair probe 1', [[2024, 1, 31], {'2023-08': 251.784, '2023-09': 251.694, '2023-10': 251.322, '2023-11': 252.369, '2023-12': 253.452}, 192.55523], ['252.33523', '1.31046']], ['partial repair probe 2', [[2026, 2, 28], {'2025-09': 310.186, '2025-10': 309.524, '2025-11': 309.905, '2025-12': 309.978, '2026-01': 310.025}, 237.45041], ['309.97539', '1.30543']], ['normal control 1', [[2027, 6, 1], {'2027-01': 250.231, '2027-02': 251.067, '2027-03': 251.03, '2027-04': 251.016, '2027-05': 252.533}, 245.70877], ['251.03000', '1.02166']], ['normal control 2', [[2014, 9, 15], {'2014-04': 289.144, '2014-05': 289.179, '2014-06': 289.08, '2014-07': 288.397, '2014-08': 289.09}, 250.20323], ['288.76127', '1.15411']], ['normal control 3', [[2015, 8, 31], {'2015-03': 288.062, '2015-04': 289.587, '2015-05': 290.23, '2015-06': 290.688, '2015-07': 289.9}, 298.45378], ['290.67323', '0.97393']], ['normal control 4', [[2014, 10, 15], {'2014-05': 244.772, '2014-06': 245.336, '2014-07': 245.724, '2014-08': 246.702, '2014-09': 247.079}, 280.45376], ['246.16568', '0.87774']]]]
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 fixtureActualExpectedOutcome
regression reference month lags 1['286.22977', '1.13482']['285.99339', '1.13388']Failed
regression reference month lags 2['323.67777', '1.19925']['322.57263', '1.19515']Failed
partial repair probe 1['264.76326', '1.45698']['265.19574', '1.45936']Failed
partial repair probe 2['233.14607', '1.16609']['232.58160', '1.16326']Failed
normal control 1['261.33200', '1.36593']['259.90300', '1.35846']Failed
normal control 2['229.47406', '0.96659']['229.44461', '0.96646']Failed
normal control 3['283.87368', '1.21675']['282.68187', '1.21164']Failed
normal control 4['233.02800', '0.85995']['232.29900', '0.85726']Failed

SHA-256 / c4e05b6ef79e4d234a937152f2c9f8559774b49355480c0564482d47a6fbc0cd

2 / The unsuccessful fix

Exit 1
"""Failure Map reference implementation. Python standard library only."""
import json
from decimal import Decimal, ROUND_HALF_UP, ROUND_DOWN
N = 1
observations = []
def solve(date, cpi, base):
    y, m, d = date
    def key(k):
        t = y * 12 + (m - 1) - k
        return '%04d-%02d' % (t // 12, t % 12 + 1)
    def mlen(yy, mm):
        if mm == 2:
            return 29 if (yy % 4 == 0 and yy % 100 != 0) or yy % 400 == 0 else 28
        return 30 if mm in (4, 6, 9, 11) else 31
    c3 = Decimal(str(cpi[key(3)]))
    c2 = Decimal(str(cpi[key(1)]))
    ref = c3 + Decimal(d - 1) / Decimal(mlen(y, m)) * (c2 - c3)
    q = Decimal('0.00001')
    ref = ref.quantize(q, rounding=ROUND_HALF_UP)
    ratio = (ref / Decimal(str(base))).quantize(q, rounding=ROUND_HALF_UP)
    return [str(ref), str(ratio)]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['regression reference month lags 1', [[2014, 3, 12], {'2013-10': 285.004, '2013-11': 284.763, '2013-12': 285.943, '2014-01': 286.085, '2014-02': 286.493}, 252.22559], ['285.99339', '1.13388']], ['regression reference month lags 2', [[2030, 4, 8], {'2029-11': 320.66, '2029-12': 321.26, '2030-01': 322.249, '2030-02': 323.636, '2030-03': 323.815}, 269.90041], ['322.57263', '1.19515']], ['partial repair probe 1', [[2015, 7, 7], {'2015-02': 264.924, '2015-03': 265.93, '2015-04': 265.338, '2015-05': 264.603, '2015-06': 265.431}, 181.72035], ['265.19574', '1.45936']], ['partial repair probe 2', [[2027, 6, 15], {'2027-01': 231.116, '2027-02': 231.355, '2027-03': 231.897, '2027-04': 233.364, '2027-05': 232.897}, 199.93903], ['232.58160', '1.16326']], ['normal control 1', [[2024, 3, 1], {'2023-10': 260.395, '2023-11': 260.124, '2023-12': 259.903, '2024-01': 261.332, '2024-02': 261.114}, 191.32116], ['259.90300', '1.35846']], ['normal control 2', [[2020, 12, 15], {'2020-07': 230.527, '2020-08': 229.871, '2020-09': 229.539, '2020-10': 229.33, '2020-11': 229.649}, 237.40667], ['229.44461', '0.96646']], ['normal control 3', [[2015, 8, 31], {'2015-03': 281.76, '2015-04': 283.056, '2015-05': 282.318, '2015-06': 282.694, '2015-07': 283.913}, 233.30576], ['282.68187', '1.21164']], ['normal control 4', [[2012, 10, 1], {'2012-05': 231.342, '2012-06': 231.179, '2012-07': 232.299, '2012-08': 233.028, '2012-09': 233.246}, 270.97933], ['232.29900', '0.85726']]], [['regression reference month lags 1', [[2023, 1, 1], {'2022-08': 266.711, '2022-09': 267.206, '2022-10': 266.956, '2022-11': 268.536, '2022-12': 267.908}, 197.53338], ['266.95600', '1.35145']], ['regression reference month lags 2', [[2031, 1, 1], {'2030-08': 253.541, '2030-09': 253.435, '2030-10': 254.441, '2030-11': 254.579, '2030-12': 254.877}, 270.24681], ['254.44100', '0.94151']], ['partial repair probe 1', [[2017, 7, 21], {'2017-02': 224.025, '2017-03': 225.528, '2017-04': 225.83, '2017-05': 225.106, '2017-06': 224.778}, 229.55085], ['225.36290', '0.98176']], ['partial repair probe 2', [[2030, 6, 26], {'2030-01': 225.478, '2030-02': 226.266, '2030-03': 227.364, '2030-04': 226.998, '2030-05': 227.552}, 276.92924], ['227.05900', '0.81992']], ['normal control 1', [[2023, 6, 30], {'2023-01': 312.952, '2023-02': 313.427, '2023-03': 314.771, '2023-04': 315.869, '2023-05': 316.72}, 241.8232], ['315.83240', '1.30605']], ['normal control 2', [[2021, 9, 15], {'2021-04': 245.557, '2021-05': 245.498, '2021-06': 247.019, '2021-07': 246.276, '2021-08': 246.4}, 262.61553], ['246.67227', '0.93929']], ['normal control 3', [[2026, 10, 15], {'2026-05': 276.443, '2026-06': 277.626, '2026-07': 278.463, '2026-08': 277.845, '2026-09': 278.06}, 240.91398], ['278.18390', '1.15470']], ['normal control 4', [[2019, 6, 15], {'2019-01': 236.666, '2019-02': 235.995, '2019-03': 237.532, '2019-04': 238.097, '2019-05': 239.059}, 281.04403], ['237.79567', '0.84612']]], [['regression reference month lags 1', [[2028, 5, 15], {'2027-12': 304.238, '2028-01': 303.687, '2028-02': 302.908, '2028-03': 302.755, '2028-04': 302.122}, 299.2292], ['302.83890', '1.01206']], ['regression reference month lags 2', [[2030, 3, 6], {'2029-10': 295.309, '2029-11': 296.907, '2029-12': 296.367, '2030-01': 296.489, '2030-02': 296.839}, 299.08836], ['296.38668', '0.99097']], ['partial repair probe 1', [[2013, 2, 15], {'2012-09': 253.875, '2012-10': 254.039, '2012-11': 254.645, '2012-12': 254.658, '2013-01': 255.573}, 287.96727], ['254.65150', '0.88431']], ['partial repair probe 2', [[2021, 6, 29], {'2021-01': 279.907, '2021-02': 281.5, '2021-03': 281.113, '2021-04': 282.438, '2021-05': 282.5}, 192.97556], ['282.34967', '1.46314']], ['normal control 1', [[2030, 12, 28], {'2030-07': 306.559, '2030-08': 307.218, '2030-09': 306.68, '2030-10': 306.55, '2030-11': 306.188}, 195.67727], ['306.56677', '1.56670']], ['normal control 2', [[2017, 1, 1], {'2016-08': 253.152, '2016-09': 252.764, '2016-10': 252.052, '2016-11': 252.954, '2016-12': 253.05}, 198.61459], ['252.05200', '1.26905']], ['normal control 3', [[2013, 10, 1], {'2013-05': 255.612, '2013-06': 255.479, '2013-07': 256.153, '2013-08': 256.766, '2013-09': 257.865}, 181.76172], ['256.15300', '1.40928']], ['normal control 4', [[2021, 12, 1], {'2021-07': 234.843, '2021-08': 234.85, '2021-09': 234.44, '2021-10': 233.772, '2021-11': 234.991}, 266.07765], ['234.44000', '0.88110']]], [['regression reference month lags 1', [[2015, 2, 1], {'2014-09': 319.269, '2014-10': 319.577, '2014-11': 320.339, '2014-12': 320.392, '2015-01': 321.197}, 282.48459], ['320.33900', '1.13401']], ['regression reference month lags 2', [[2024, 1, 15], {'2023-08': 233.441, '2023-09': 234.867, '2023-10': 235.312, '2023-11': 235.728, '2023-12': 236.834}, 192.24828], ['235.49987', '1.22498']], ['partial repair probe 1', [[2023, 5, 15], {'2022-12': 296.712, '2023-01': 296.358, '2023-02': 295.92, '2023-03': 296.339, '2023-04': 296.201}, 262.58209], ['296.10923', '1.12768']], ['partial repair probe 2', [[2031, 4, 15], {'2030-11': 276.002, '2030-12': 276.34, '2031-01': 277.14, '2031-02': 278.213, '2031-03': 278.53}, 212.74273], ['277.64073', '1.30505']], ['normal control 1', [[2027, 6, 15], {'2027-01': 297.464, '2027-02': 298.353, '2027-03': 297.828, '2027-04': 298.397, '2027-05': 299.751}, 288.66356], ['298.09353', '1.03267']], ['normal control 2', [[2031, 8, 1], {'2031-03': 240.007, '2031-04': 240.309, '2031-05': 241.463, '2031-06': 242.242, '2031-07': 242.084}, 271.3525], ['241.46300', '0.88985']], ['normal control 3', [[2019, 5, 15], {'2018-12': 306.522, '2019-01': 307.912, '2019-02': 307.791, '2019-03': 309.196, '2019-04': 308.809}, 296.31991], ['308.42552', '1.04085']], ['normal control 4', [[2021, 8, 1], {'2021-03': 252.51, '2021-04': 252.577, '2021-05': 253.222, '2021-06': 252.785, '2021-07': 252.64}, 203.10318], ['253.22200', '1.24677']]], [['regression reference month lags 1', [[2017, 2, 6], {'2016-09': 292.897, '2016-10': 293.829, '2016-11': 293.12, '2016-12': 292.997, '2017-01': 293.992}, 240.77423], ['293.09804', '1.21731']], ['regression reference month lags 2', [[2030, 5, 1], {'2029-12': 247.076, '2030-01': 246.589, '2030-02': 245.812, '2030-03': 245.36, '2030-04': 244.958}, 248.74245], ['245.81200', '0.98822']], ['partial repair probe 1', [[2024, 1, 31], {'2023-08': 251.784, '2023-09': 251.694, '2023-10': 251.322, '2023-11': 252.369, '2023-12': 253.452}, 192.55523], ['252.33523', '1.31046']], ['partial repair probe 2', [[2026, 2, 28], {'2025-09': 310.186, '2025-10': 309.524, '2025-11': 309.905, '2025-12': 309.978, '2026-01': 310.025}, 237.45041], ['309.97539', '1.30543']], ['normal control 1', [[2027, 6, 1], {'2027-01': 250.231, '2027-02': 251.067, '2027-03': 251.03, '2027-04': 251.016, '2027-05': 252.533}, 245.70877], ['251.03000', '1.02166']], ['normal control 2', [[2014, 9, 15], {'2014-04': 289.144, '2014-05': 289.179, '2014-06': 289.08, '2014-07': 288.397, '2014-08': 289.09}, 250.20323], ['288.76127', '1.15411']], ['normal control 3', [[2015, 8, 31], {'2015-03': 288.062, '2015-04': 289.587, '2015-05': 290.23, '2015-06': 290.688, '2015-07': 289.9}, 298.45378], ['290.67323', '0.97393']], ['normal control 4', [[2014, 10, 15], {'2014-05': 244.772, '2014-06': 245.336, '2014-07': 245.724, '2014-08': 246.702, '2014-09': 247.079}, 280.45376], ['246.16568', '0.87774']]]]
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 fixtureActualExpectedOutcome
regression reference month lags 1['286.13816', '1.13445']['285.99339', '1.13388']Failed
regression reference month lags 2['322.61440', '1.19531']['322.57263', '1.19515']Failed
partial repair probe 1['265.35600', '1.46024']['265.19574', '1.45936']Failed
partial repair probe 2['232.36367', '1.16217']['232.58160', '1.16326']Failed
normal control 1['259.90300', '1.35846']['259.90300', '1.35846']Passed
normal control 2['229.58868', '0.96707']['229.44461', '0.96646']Failed
normal control 3['283.86155', '1.21669']['282.68187', '1.21164']Failed
normal control 4['232.29900', '0.85726']['232.29900', '0.85726']Passed

SHA-256 / d43a275c5ebc37ae331307d2e6dde15615a03a8846d1d47060f57dac23c16f22

3 / The verified repair

Exit 0
"""Failure Map reference implementation. Python standard library only."""
import json
from decimal import Decimal, ROUND_HALF_UP, ROUND_DOWN
N = 1
observations = []
def solve(date, cpi, base):
    y, m, d = date
    def key(k):
        t = y * 12 + (m - 1) - k
        return '%04d-%02d' % (t // 12, t % 12 + 1)
    def mlen(yy, mm):
        if mm == 2:
            return 29 if (yy % 4 == 0 and yy % 100 != 0) or yy % 400 == 0 else 28
        return 30 if mm in (4, 6, 9, 11) else 31
    c3 = Decimal(str(cpi[key(3)]))
    c2 = Decimal(str(cpi[key(2)]))
    ref = c3 + Decimal(d - 1) / Decimal(mlen(y, m)) * (c2 - c3)
    q = Decimal('0.00001')
    ref = ref.quantize(q, rounding=ROUND_HALF_UP)
    ratio = (ref / Decimal(str(base))).quantize(q, rounding=ROUND_HALF_UP)
    return [str(ref), str(ratio)]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['regression reference month lags 1', [[2014, 3, 12], {'2013-10': 285.004, '2013-11': 284.763, '2013-12': 285.943, '2014-01': 286.085, '2014-02': 286.493}, 252.22559], ['285.99339', '1.13388']], ['regression reference month lags 2', [[2030, 4, 8], {'2029-11': 320.66, '2029-12': 321.26, '2030-01': 322.249, '2030-02': 323.636, '2030-03': 323.815}, 269.90041], ['322.57263', '1.19515']], ['partial repair probe 1', [[2015, 7, 7], {'2015-02': 264.924, '2015-03': 265.93, '2015-04': 265.338, '2015-05': 264.603, '2015-06': 265.431}, 181.72035], ['265.19574', '1.45936']], ['partial repair probe 2', [[2027, 6, 15], {'2027-01': 231.116, '2027-02': 231.355, '2027-03': 231.897, '2027-04': 233.364, '2027-05': 232.897}, 199.93903], ['232.58160', '1.16326']], ['normal control 1', [[2024, 3, 1], {'2023-10': 260.395, '2023-11': 260.124, '2023-12': 259.903, '2024-01': 261.332, '2024-02': 261.114}, 191.32116], ['259.90300', '1.35846']], ['normal control 2', [[2020, 12, 15], {'2020-07': 230.527, '2020-08': 229.871, '2020-09': 229.539, '2020-10': 229.33, '2020-11': 229.649}, 237.40667], ['229.44461', '0.96646']], ['normal control 3', [[2015, 8, 31], {'2015-03': 281.76, '2015-04': 283.056, '2015-05': 282.318, '2015-06': 282.694, '2015-07': 283.913}, 233.30576], ['282.68187', '1.21164']], ['normal control 4', [[2012, 10, 1], {'2012-05': 231.342, '2012-06': 231.179, '2012-07': 232.299, '2012-08': 233.028, '2012-09': 233.246}, 270.97933], ['232.29900', '0.85726']]], [['regression reference month lags 1', [[2023, 1, 1], {'2022-08': 266.711, '2022-09': 267.206, '2022-10': 266.956, '2022-11': 268.536, '2022-12': 267.908}, 197.53338], ['266.95600', '1.35145']], ['regression reference month lags 2', [[2031, 1, 1], {'2030-08': 253.541, '2030-09': 253.435, '2030-10': 254.441, '2030-11': 254.579, '2030-12': 254.877}, 270.24681], ['254.44100', '0.94151']], ['partial repair probe 1', [[2017, 7, 21], {'2017-02': 224.025, '2017-03': 225.528, '2017-04': 225.83, '2017-05': 225.106, '2017-06': 224.778}, 229.55085], ['225.36290', '0.98176']], ['partial repair probe 2', [[2030, 6, 26], {'2030-01': 225.478, '2030-02': 226.266, '2030-03': 227.364, '2030-04': 226.998, '2030-05': 227.552}, 276.92924], ['227.05900', '0.81992']], ['normal control 1', [[2023, 6, 30], {'2023-01': 312.952, '2023-02': 313.427, '2023-03': 314.771, '2023-04': 315.869, '2023-05': 316.72}, 241.8232], ['315.83240', '1.30605']], ['normal control 2', [[2021, 9, 15], {'2021-04': 245.557, '2021-05': 245.498, '2021-06': 247.019, '2021-07': 246.276, '2021-08': 246.4}, 262.61553], ['246.67227', '0.93929']], ['normal control 3', [[2026, 10, 15], {'2026-05': 276.443, '2026-06': 277.626, '2026-07': 278.463, '2026-08': 277.845, '2026-09': 278.06}, 240.91398], ['278.18390', '1.15470']], ['normal control 4', [[2019, 6, 15], {'2019-01': 236.666, '2019-02': 235.995, '2019-03': 237.532, '2019-04': 238.097, '2019-05': 239.059}, 281.04403], ['237.79567', '0.84612']]], [['regression reference month lags 1', [[2028, 5, 15], {'2027-12': 304.238, '2028-01': 303.687, '2028-02': 302.908, '2028-03': 302.755, '2028-04': 302.122}, 299.2292], ['302.83890', '1.01206']], ['regression reference month lags 2', [[2030, 3, 6], {'2029-10': 295.309, '2029-11': 296.907, '2029-12': 296.367, '2030-01': 296.489, '2030-02': 296.839}, 299.08836], ['296.38668', '0.99097']], ['partial repair probe 1', [[2013, 2, 15], {'2012-09': 253.875, '2012-10': 254.039, '2012-11': 254.645, '2012-12': 254.658, '2013-01': 255.573}, 287.96727], ['254.65150', '0.88431']], ['partial repair probe 2', [[2021, 6, 29], {'2021-01': 279.907, '2021-02': 281.5, '2021-03': 281.113, '2021-04': 282.438, '2021-05': 282.5}, 192.97556], ['282.34967', '1.46314']], ['normal control 1', [[2030, 12, 28], {'2030-07': 306.559, '2030-08': 307.218, '2030-09': 306.68, '2030-10': 306.55, '2030-11': 306.188}, 195.67727], ['306.56677', '1.56670']], ['normal control 2', [[2017, 1, 1], {'2016-08': 253.152, '2016-09': 252.764, '2016-10': 252.052, '2016-11': 252.954, '2016-12': 253.05}, 198.61459], ['252.05200', '1.26905']], ['normal control 3', [[2013, 10, 1], {'2013-05': 255.612, '2013-06': 255.479, '2013-07': 256.153, '2013-08': 256.766, '2013-09': 257.865}, 181.76172], ['256.15300', '1.40928']], ['normal control 4', [[2021, 12, 1], {'2021-07': 234.843, '2021-08': 234.85, '2021-09': 234.44, '2021-10': 233.772, '2021-11': 234.991}, 266.07765], ['234.44000', '0.88110']]], [['regression reference month lags 1', [[2015, 2, 1], {'2014-09': 319.269, '2014-10': 319.577, '2014-11': 320.339, '2014-12': 320.392, '2015-01': 321.197}, 282.48459], ['320.33900', '1.13401']], ['regression reference month lags 2', [[2024, 1, 15], {'2023-08': 233.441, '2023-09': 234.867, '2023-10': 235.312, '2023-11': 235.728, '2023-12': 236.834}, 192.24828], ['235.49987', '1.22498']], ['partial repair probe 1', [[2023, 5, 15], {'2022-12': 296.712, '2023-01': 296.358, '2023-02': 295.92, '2023-03': 296.339, '2023-04': 296.201}, 262.58209], ['296.10923', '1.12768']], ['partial repair probe 2', [[2031, 4, 15], {'2030-11': 276.002, '2030-12': 276.34, '2031-01': 277.14, '2031-02': 278.213, '2031-03': 278.53}, 212.74273], ['277.64073', '1.30505']], ['normal control 1', [[2027, 6, 15], {'2027-01': 297.464, '2027-02': 298.353, '2027-03': 297.828, '2027-04': 298.397, '2027-05': 299.751}, 288.66356], ['298.09353', '1.03267']], ['normal control 2', [[2031, 8, 1], {'2031-03': 240.007, '2031-04': 240.309, '2031-05': 241.463, '2031-06': 242.242, '2031-07': 242.084}, 271.3525], ['241.46300', '0.88985']], ['normal control 3', [[2019, 5, 15], {'2018-12': 306.522, '2019-01': 307.912, '2019-02': 307.791, '2019-03': 309.196, '2019-04': 308.809}, 296.31991], ['308.42552', '1.04085']], ['normal control 4', [[2021, 8, 1], {'2021-03': 252.51, '2021-04': 252.577, '2021-05': 253.222, '2021-06': 252.785, '2021-07': 252.64}, 203.10318], ['253.22200', '1.24677']]], [['regression reference month lags 1', [[2017, 2, 6], {'2016-09': 292.897, '2016-10': 293.829, '2016-11': 293.12, '2016-12': 292.997, '2017-01': 293.992}, 240.77423], ['293.09804', '1.21731']], ['regression reference month lags 2', [[2030, 5, 1], {'2029-12': 247.076, '2030-01': 246.589, '2030-02': 245.812, '2030-03': 245.36, '2030-04': 244.958}, 248.74245], ['245.81200', '0.98822']], ['partial repair probe 1', [[2024, 1, 31], {'2023-08': 251.784, '2023-09': 251.694, '2023-10': 251.322, '2023-11': 252.369, '2023-12': 253.452}, 192.55523], ['252.33523', '1.31046']], ['partial repair probe 2', [[2026, 2, 28], {'2025-09': 310.186, '2025-10': 309.524, '2025-11': 309.905, '2025-12': 309.978, '2026-01': 310.025}, 237.45041], ['309.97539', '1.30543']], ['normal control 1', [[2027, 6, 1], {'2027-01': 250.231, '2027-02': 251.067, '2027-03': 251.03, '2027-04': 251.016, '2027-05': 252.533}, 245.70877], ['251.03000', '1.02166']], ['normal control 2', [[2014, 9, 15], {'2014-04': 289.144, '2014-05': 289.179, '2014-06': 289.08, '2014-07': 288.397, '2014-08': 289.09}, 250.20323], ['288.76127', '1.15411']], ['normal control 3', [[2015, 8, 31], {'2015-03': 288.062, '2015-04': 289.587, '2015-05': 290.23, '2015-06': 290.688, '2015-07': 289.9}, 298.45378], ['290.67323', '0.97393']], ['normal control 4', [[2014, 10, 15], {'2014-05': 244.772, '2014-06': 245.336, '2014-07': 245.724, '2014-08': 246.702, '2014-09': 247.079}, 280.45376], ['246.16568', '0.87774']]]]
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 fixtureActualExpectedOutcome
regression reference month lags 1['285.99339', '1.13388']['285.99339', '1.13388']Passed
regression reference month lags 2['322.57263', '1.19515']['322.57263', '1.19515']Passed
partial repair probe 1['265.19574', '1.45936']['265.19574', '1.45936']Passed
partial repair probe 2['232.58160', '1.16326']['232.58160', '1.16326']Passed
normal control 1['259.90300', '1.35846']['259.90300', '1.35846']Passed
normal control 2['229.44461', '0.96646']['229.44461', '0.96646']Passed
normal control 3['282.68187', '1.21164']['282.68187', '1.21164']Passed
normal control 4['232.29900', '0.85726']['232.29900', '0.85726']Passed

SHA-256 / 8e85622c5f2137304568b059505f0e01c9d5443d50f4b24dd9e75fdab78c3e97

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:52.269574+00:00.

Case digest / d157ad5402f325e82a85c51a2df8bd2492cd1ef183b05c789c06bc06b4591227